reactos操作系统实现(80)
来源:互联网 发布:百度云管家软件 编辑:程序博客网 时间:2024/04/30 01:36
下面的函数主要初始化PnP发现的设备,并为它安装服务,代码如下:
#001 NTSTATUS
#002 IopInitializePnpServices(IN PDEVICE_NODEDeviceNode)
#003 {
#004 DEVICETREE_TRAVERSE_CONTEXT Context;
#005
#006 DPRINT("IopInitializePnpServices(%p)/n", DeviceNode);
#007
构造一个响应子服务发现的操作。
#008 IopInitDeviceTreeTraverseContext(
#009 &Context,
#010 DeviceNode,
#011 IopActionInitChildServices,
#012 DeviceNode);
#013
开始遍历整个设备树。
#014 returnIopTraverseDeviceTree(&Context);
#015 }
#016
初始化每个设备节点,如下:
#001 NTSTATUS
#002 IopActionInitChildServices(PDEVICE_NODEDeviceNode,
#003 PVOID Context)
#004 {
#005 PDEVICE_NODE ParentDeviceNode;
#006 NTSTATUS Status;
#007 BOOLEAN BootDrivers = !PnpSystemInit;
#008
#009 DPRINT("IopActionInitChildServices(%p, %p)/n", DeviceNode,Context);
#010
取父节点设备。
#011 ParentDeviceNode = (PDEVICE_NODE)Context;
#012
#013 /*
#014 * We are called for the parent too, butwe don't need to do special
#015 *handling for this node
#016 */
如果下一个节点等于父节点,没有子节点,就直接返回。
#017 if (DeviceNode == ParentDeviceNode)
#018 {
#019 DPRINT("Success/n");
#020 return STATUS_SUCCESS;
#021 }
#022
#023 /*
#024 * Make sure this device node is a directchild of the parent device node
#025 * that is given as an argument
#026 */
#027 #if 0
#028 if (DeviceNode->Parent !=ParentDeviceNode)
#029 {
#030 /*
#031 * Stop the traversal immediately andindicate unsuccessful operation
#032 */
#033 DPRINT("Stop/n");
#034 return STATUS_UNSUCCESSFUL;
#035 }
#036 #endif
#037
判断这个节点是否可以安装服务。
#038 if (!IopDeviceNodeHasFlag(DeviceNode,DNF_DISABLED) &&
#039 !IopDeviceNodeHasFlag(DeviceNode,DNF_ADDED) &&
#040 !IopDeviceNodeHasFlag(DeviceNode,DNF_STARTED))
#041 {
#042 PLDR_DATA_TABLE_ENTRY ModuleObject;
#043 PDRIVER_OBJECT DriverObject;
#044
获取已经存在驱动程序指针。
#045 /* Get existing DriverObject pointer(in case the driver has
#046 already been loaded and initialized)*/
#047 Status = IopGetDriverObject(
#048 &DriverObject,
#049 &DeviceNode->ServiceName,
#050 FALSE);
#051
#052 if (!NT_SUCCESS(Status))
#053 {
#054 /* Driver is not initialized, try toload it */
#055 Status =IopLoadServiceModule(&DeviceNode->ServiceName, &ModuleObject);
#056
#057 if (NT_SUCCESS(Status) || Status ==STATUS_IMAGE_ALREADY_LOADED)
#058 {
#059 /* STATUS_IMAGE_ALREADY_LOADEDmeans this driver
#060 was loaded by the bootloader*/
#061 if ((Status !=STATUS_IMAGE_ALREADY_LOADED) ||
#062 (Status ==STATUS_IMAGE_ALREADY_LOADED && !DriverObject))
#063 {
初始化这个设备的驱动程序。
#064 /* Initialize the driver */
#065 Status =IopInitializeDriverModule(DeviceNode, ModuleObject,
#066 &DeviceNode->ServiceName, FALSE, &DriverObject);
#067 }
#068 else
#069 {
#070 Status = STATUS_SUCCESS;
#071 }
#072 }
#073 else
#074 {
#075 DPRINT1("IopLoadServiceModule(%wZ) failed with status0x%08x/n",
#076 &DeviceNode->ServiceName, Status);
#077 }
#078 }
#079
设备驱动程序已经加载,开始初始化入口点。
#080 /* Driver is loaded and initialized atthis point */
#081 if (NT_SUCCESS(Status))
#082 {
添加低层次的过滤驱动程序。
#083 /* Attach lower level filterdrivers. */
#084 IopAttachFilterDrivers(DeviceNode,TRUE);
初始化设备。
#085 /* Initialize the function driverfor the device node */
#086 Status =IopInitializeDevice(DeviceNode, DriverObject);
#087
#088 if (NT_SUCCESS(Status))
#089 {
#090 /* Attach upper level filterdrivers. */
#091 IopAttachFilterDrivers(DeviceNode, FALSE);
#092 IopDeviceNodeSetFlag(DeviceNode,DNF_STARTED);
#093
启动这个设备。
#094 Status =IopStartDevice(DeviceNode);
#095 }
#096 else
#097 {
#098 DPRINT1("IopInitializeDevice(%wZ) failed with status0x%08x/n",
#099 &DeviceNode->InstancePath, Status);
#100 }
#101 }
#102 else
#103 {
设置引导驱动程序不可以再加载。
#104 /*
#105 * Don't disable when trying to loadonly boot drivers
#106 */
#107 if (!BootDrivers)
#108 {
#109 IopDeviceNodeSetFlag(DeviceNode,DNF_DISABLED);
#110 IopDeviceNodeSetFlag(DeviceNode,DNF_START_FAILED);
#111 /* FIXME: Log the error (possiblyin IopInitializeDeviceNodeService) */
#112 DPRINT1("Initialization ofservice %S failed (Status %x)/n",
#113 DeviceNode->ServiceName.Buffer, Status);
#114 }
#115 }
#116 }
#117 else
#118 {
#119 DPRINT("Device %wZ is disabled oralready initialized/n",
#120 &DeviceNode->InstancePath);
#121 }
#122
#123 return STATUS_SUCCESS;
#124 }
- reactos操作系统实现(80)
- reactos操作系统实现(1)
- reactos操作系统实现(2)
- reactos操作系统实现(3)
- reactos操作系统实现(4)
- reactos操作系统实现(5)
- reactos操作系统实现(6)
- reactos操作系统实现(7)
- reactos操作系统实现(8)
- reactos操作系统实现(9)
- reactos操作系统实现(10)
- reactos操作系统实现(11)
- reactos操作系统实现(12)
- reactos操作系统实现(13)
- reactos操作系统实现(14)
- reactos操作系统实现(15)
- reactos操作系统实现(16)
- reactos操作系统实现(17)
- SWOT
- alert对话框显示的内容换行?
- 设计模式:建造者模式
- 瑞星升级提示网络连接失败网络配置后重试(12007) 解决办法
- 以太网MII接口类型大全 MII、RMII、SMII、SSMII、SSSMII、GMII、RGMII、SGMII、TBI、RTBI、XGMII、XAUI、XL
- reactos操作系统实现(80)
- wine用户手册概要
- ASP.net2.0中数据库连接字符串
- asp.net链接Access数据库字符串正确方法
- linux线程同步之互斥锁——linux的关键区域
- 推荐给广大游戏爱好者和程序员一本书
- System Repair Engineer 2.81 (2.8.1.1279) by Smallfrogs
- 不用临时变量实现两个变量的交换
- 我的内部类笔记