nt!PipEnumerateCompleted函数分析分配设备节点后调用nt!PpDevNodeInsertIntoTree函数
NTSTATUS
PipProcessDevNodeTree(
IN PDEVICE_NODE SubtreeRootDeviceNode,
IN BOOLEAN LoadDriver,
IN BOOLEAN ReallocateResources,
IN ENUM_TYPE EnumType,
IN BOOLEAN Synchronous,
IN BOOLEAN ProcessOnlyIntermediateStates,
IN PADD_CONTEXT AddContext,
IN PPI_DEVICE_REQUEST Request
)
{
case DeviceNodeStarted:
nextNode = ChildNode;
if (!ProcessOnlyIntermediateStates) {
if ((currentNode->Flags & DNF_REENUMERATE)) {
status = PipEnumerateDevice(currentNode, Synchronous);
if (NT_SUCCESS(status)) {
//
// Remember the bus we just enumerated.
//
enumeratedBus = currentNode;
nextNode = SameNode;
}
case DeviceNodeEnumerateCompletion:
status = PipEnumerateCompleted(currentNode);
nextNode = ChildNode;
break;
0: kd> kc
#
00 nt!PipEnumerateCompleted
01 nt!PipProcessDevNodeTree
02 nt!PipDeviceActionWorker
03 nt!PipRequestDeviceAction
04 nt!IopInitializeBootDrivers
05 nt!IoInitSystem
06 nt!Phase1Initialization
07 nt!PspSystemThreadStartup
08 nt!KiThreadStartup
0: kd> dv
DeviceNode = 0x899c1008
childRemoved = 0x89 ''
childDeviceNode = 0x00000008
i = 0x899c1008
0: kd> !devnode 0x899c1008
DevNode 0x899c1008 for PDO 0x899c1de0
Parent 0x89986008 Sibling 0000000000 Child 0000000000
InstancePath is "ACPI_HAL\PNP0C08\0"
ServiceName is "ACPI"
State = DeviceNodeEnumerateCompletion (0x30d)
Previous State = DeviceNodeStarted (0x308)
StateHistory[06] = DeviceNodeStarted (0x308)
StateHistory[05] = DeviceNodeStartPostWork (0x307)
StateHistory[04] = DeviceNodeStartCompletion (0x306)
StateHistory[03] = DeviceNodeResourcesAssigned (0x304)
StateHistory[02] = DeviceNodeDriversAdded (0x303)
StateHistory[01] = DeviceNodeInitialized (0x302)
StateHistory[00] = DeviceNodeUninitialized (0x301)
StateHistory[19] = Unknown State (0x0)
StateHistory[18] = Unknown State (0x0)
StateHistory[17] = Unknown State (0x0)
StateHistory[16] = Unknown State (0x0)
StateHistory[15] = Unknown State (0x0)
StateHistory[14] = Unknown State (0x0)
StateHistory[13] = Unknown State (0x0)
StateHistory[12] = Unknown State (0x0)
StateHistory[11] = Unknown State (0x0)
StateHistory[10] = Unknown State (0x0)
StateHistory[09] = Unknown State (0x0)
StateHistory[08] = Unknown State (0x0)
StateHistory[07] = Unknown State (0x0)
Flags (0x000000f0) DNF_ENUMERATED, DNF_IDS_QUERIED,
DNF_HAS_BOOT_CONFIG, DNF_BOOT_CONFIG_RESERVED
CapabilityFlags (0x000000c0) UniqueID, SilentInstall
建立完新的子节点后会被清除。
ExFreePool(DeviceNode->OverUsed1.PendingDeviceRelations);
DeviceNode->OverUsed1.PendingDeviceRelations = NULL;
0: kd> dx -r1 ((ntkrnlmp!_DEVICE_NODE *)0x899c1008)
((ntkrnlmp!_DEVICE_NODE *)0x899c1008) : 0x899c1008 [Type: _DEVICE_NODE *]
[+0x000] Sibling : 0x0 [Type: _DEVICE_NODE *]
[+0x004] Child : 0x0 [Type: _DEVICE_NODE *]
[+0x008] Parent : 0x89986008 [Type: _DEVICE_NODE *]
[+0x00c] LastChild : 0x0 [Type: _DEVICE_NODE *]
[+0x010] Level : 0x2 [Type: unsigned long]
[+0x014] Notify : 0x0 [Type: _PO_DEVICE_NOTIFY *]
[+0x018] State : DeviceNodeEnumerateCompletion (781) [Type: _PNP_DEVNODE_STATE]
[+0x01c] PreviousState : DeviceNodeStarted (776) [Type: _PNP_DEVNODE_STATE]
[+0x020] StateHistory [Type: _PNP_DEVNODE_STATE [20]]
[+0x070] StateHistoryEntry : 0x7 [Type: unsigned long]
[+0x074] CompletionStatus : 0 [Type: long]
[+0x078] PendingIrp : 0x0 [Type: _IRP *]
[+0x07c] Flags : 0xf0 [Type: unsigned long]
[+0x080] UserFlags : 0x0 [Type: unsigned long]
[+0x084] Problem : 0x0 [Type: unsigned long]
[+0x088] PhysicalDeviceObject : 0x899c1de0 : Device for "\Driver\ACPI_HAL" [Type: _DEVICE_OBJECT *]
[+0x08c] ResourceList : 0xe127b758 [Type: _CM_RESOURCE_LIST *]
[+0x090] ResourceListTranslated : 0xe127fe58 [Type: _CM_RESOURCE_LIST *]
[+0x094] InstancePath : "ACPI_HAL\PNP0C08\0" [Type: _UNICODE_STRING]
[+0x09c] ServiceName : "ACPI" [Type: _UNICODE_STRING]
[+0x0a4] DuplicatePDO : 0x0 [Type: _DEVICE_OBJECT *]
[+0x0a8] ResourceRequirements : 0xe1287ce8 [Type: _IO_RESOURCE_REQUIREMENTS_LIST *]
[+0x0ac] InterfaceType : InterfaceTypeUndefined (-1) [Type: _INTERFACE_TYPE]
[+0x0b0] BusNumber : 0xfffffff0 [Type: unsigned long]
[+0x0b4] ChildInterfaceType : InterfaceTypeUndefined (-1) [Type: _INTERFACE_TYPE]
[+0x0b8] ChildBusNumber : 0xfffffff0 [Type: unsigned long]
[+0x0bc] ChildBusTypeIndex : 0xffff [Type: unsigned short]
[+0x0be] RemovalPolicy : 0x1 [Type: unsigned char]
[+0x0bf] HardwareRemovalPolicy : 0x1 [Type: unsigned char]
[+0x0c0] TargetDeviceNotify [Type: _LIST_ENTRY]
[+0x0c8] DeviceArbiterList [Type: _LIST_ENTRY]
[+0x0d0] DeviceTranslatorList [Type: _LIST_ENTRY]
[+0x0d8] NoTranslatorMask : 0x0 [Type: unsigned short]
[+0x0da] QueryTranslatorMask : 0x0 [Type: unsigned short]
[+0x0dc] NoArbiterMask : 0x0 [Type: unsigned short]
[+0x0de] QueryArbiterMask : 0x0 [Type: unsigned short]
[+0x0e0] OverUsed1 [Type: __unnamed]
[+0x0e4] OverUsed2 [Type: __unnamed]
[+0x0e8] BootResources : 0xe127cbb8 [Type: _CM_RESOURCE_LIST *]
[+0x0ec] CapabilityFlags : 0xc0 [Type: unsigned long]
[+0x0f0] DockInfo [Type: __unnamed]
[+0x100] DisableableDepends : 0x0 [Type: unsigned long]
[+0x104] PendedSetInterfaceState [Type: _LIST_ENTRY]
[+0x10c] LegacyBusListEntry [Type: _LIST_ENTRY]
0: kd> dd 0x899c1008+e0
899c10e8 899875a0
子节点信息放到 [+0x004] Child : 0x0 [Type: _DEVICE_NODE *]里面去了。!!!
第1次循环结束后:
0: kd> !devnode 0 1
Dumping IopRootDeviceNode (= 0x899c5ac8)
DevNode 0x899c5ac8 for PDO 0x899c5c08
InstancePath is "HTREE\ROOT\0"
State = DeviceNodeStarted (0x308)
Previous State = DeviceNodeEnumerateCompletion (0x30d)
DevNode 0x89986008 for PDO 0x899c5938
InstancePath is "Root\ACPI_HAL\0000"
State = DeviceNodeStarted (0x308)
Previous State = DeviceNodeEnumerateCompletion (0x30d)
DevNode 0x899c1008 for PDO 0x899c1de0
InstancePath is "ACPI_HAL\PNP0C08\0"
ServiceName is "ACPI"
State = DeviceNodeEnumerateCompletion (0x30d)
Previous State = DeviceNodeStarted (0x308)
DevNode 0x894ffea8 for PDO 0x899050e8 新节点1
State = DeviceNodeUninitialized (0x301)
Previous State = Unknown State (0x0)
DevNode 0x89986d38 for PDO 0x89986e90
InstancePath is "Root\COMPOSITE_BATTERY\0000"
ServiceName is "Compbatt"
State = DeviceNodeInitialized (0x302)
Previous State = DeviceNodeUninitialized (0x301)
第2次循环结束后:
0: kd> !devnode 0 1
Dumping IopRootDeviceNode (= 0x899c5ac8)
DevNode 0x899c5ac8 for PDO 0x899c5c08
InstancePath is "HTREE\ROOT\0"
State = DeviceNodeStarted (0x308)
Previous State = DeviceNodeEnumerateCompletion (0x30d)
DevNode 0x89986008 for PDO 0x899c5938
InstancePath is "Root\ACPI_HAL\0000"
State = DeviceNodeStarted (0x308)
Previous State = DeviceNodeEnumerateCompletion (0x30d)
DevNode 0x899c1008 for PDO 0x899c1de0
InstancePath is "ACPI_HAL\PNP0C08\0"
ServiceName is "ACPI"
State = DeviceNodeEnumerateCompletion (0x30d)
Previous State = DeviceNodeStarted (0x308)
DevNode 0x894ffea8 for PDO 0x899050e8
State = DeviceNodeUninitialized (0x301)
Previous State = Unknown State (0x0)
DevNode 0x8952a1e0 for PDO 0x89906690 新节点2
State = DeviceNodeUninitialized (0x301)
Previous State = Unknown State (0x0)
DevNode 0x89986d38 for PDO 0x89986e90
InstancePath is "Root\COMPOSITE_BATTERY\0000"
ServiceName is "Compbatt"
State = DeviceNodeInitialized (0x302)
Previous State = DeviceNodeUninitialized (0x301)
第3次循环结束后:
0: kd> !devnode 0 1
Dumping IopRootDeviceNode (= 0x899c5ac8)
DevNode 0x899c5ac8 for PDO 0x899c5c08
InstancePath is "HTREE\ROOT\0"
State = DeviceNodeStarted (0x308)
Previous State = DeviceNodeEnumerateCompletion (0x30d)
DevNode 0x89986008 for PDO 0x899c5938
InstancePath is "Root\ACPI_HAL\0000"
State = DeviceNodeStarted (0x308)
Previous State = DeviceNodeEnumerateCompletion (0x30d)
DevNode 0x899c1008 for PDO 0x899c1de0
InstancePath is "ACPI_HAL\PNP0C08\0"
ServiceName is "ACPI"
State = DeviceNodeEnumerateCompletion (0x30d)
Previous State = DeviceNodeStarted (0x308)
DevNode 0x894ffea8 for PDO 0x899050e8
State = DeviceNodeUninitialized (0x301)
Previous State = Unknown State (0x0)
DevNode 0x8952a1e0 for PDO 0x89906690
State = DeviceNodeUninitialized (0x301)
Previous State = Unknown State (0x0)
DevNode 0x8952a370 for PDO 0x8952a6c8 新节点3
State = DeviceNodeUninitialized (0x301)
Previous State = Unknown State (0x0)
DevNode 0x89986d38 for PDO 0x89986e90
InstancePath is "Root\COMPOSITE_BATTERY\0000"
ServiceName is "Compbatt"
State = DeviceNodeInitialized (0x302)
Previous State = DeviceNodeUninitialized (0x301)
第4次循环结束后:
0: kd> !devnode 0 1
Dumping IopRootDeviceNode (= 0x899c5ac8)
DevNode 0x899c5ac8 for PDO 0x899c5c08
InstancePath is "HTREE\ROOT\0"
State = DeviceNodeStarted (0x308)
Previous State = DeviceNodeEnumerateCompletion (0x30d)
DevNode 0x89986008 for PDO 0x899c5938
InstancePath is "Root\ACPI_HAL\0000"
State = DeviceNodeStarted (0x308)
Previous State = DeviceNodeEnumerateCompletion (0x30d)
DevNode 0x899c1008 for PDO 0x899c1de0
InstancePath is "ACPI_HAL\PNP0C08\0"
ServiceName is "ACPI"
State = DeviceNodeEnumerateCompletion (0x30d)
Previous State = DeviceNodeStarted (0x308)
DevNode 0x894ffea8 for PDO 0x899050e8
State = DeviceNodeUninitialized (0x301)
Previous State = Unknown State (0x0)
DevNode 0x8952a1e0 for PDO 0x89906690
State = DeviceNodeUninitialized (0x301)
Previous State = Unknown State (0x0)
DevNode 0x8952a370 for PDO 0x8952a6c8
State = DeviceNodeUninitialized (0x301)
Previous State = Unknown State (0x0)
DevNode 0x89996c40 for PDO 0x8952a858 新节点4
State = DeviceNodeUninitialized (0x301)
Previous State = Unknown State (0x0)
DevNode 0x89986d38 for PDO 0x89986e90
InstancePath is "Root\COMPOSITE_BATTERY\0000"
ServiceName is "Compbatt"
State = DeviceNodeInitialized (0x302)
Previous State = DeviceNodeUninitialized (0x301)
第5次循环结束后:
0: kd> !devnode 0 1
Dumping IopRootDeviceNode (= 0x899c5ac8)
DevNode 0x899c5ac8 for PDO 0x899c5c08
InstancePath is "HTREE\ROOT\0"
State = DeviceNodeStarted (0x308)
Previous State = DeviceNodeEnumerateCompletion (0x30d)
DevNode 0x89986008 for PDO 0x899c5938
InstancePath is "Root\ACPI_HAL\0000"
State = DeviceNodeStarted (0x308)
Previous State = DeviceNodeEnumerateCompletion (0x30d)
DevNode 0x899c1008 for PDO 0x899c1de0
InstancePath is "ACPI_HAL\PNP0C08\0"
ServiceName is "ACPI"
State = DeviceNodeEnumerateCompletion (0x30d)
Previous State = DeviceNodeStarted (0x308)
DevNode 0x894ffea8 for PDO 0x899050e8
State = DeviceNodeUninitialized (0x301)
Previous State = Unknown State (0x0)
DevNode 0x8952a1e0 for PDO 0x89906690
State = DeviceNodeUninitialized (0x301)
Previous State = Unknown State (0x0)
DevNode 0x8952a370 for PDO 0x8952a6c8
State = DeviceNodeUninitialized (0x301)
Previous State = Unknown State (0x0)
DevNode 0x89996c40 for PDO 0x8952a858
State = DeviceNodeUninitialized (0x301)
Previous State = Unknown State (0x0)
DevNode 0x8952a500 for PDO 0x8952a9e8 新节点5
State = DeviceNodeUninitialized (0x301)
Previous State = Unknown State (0x0)
DevNode 0x89986d38 for PDO 0x89986e90
InstancePath is "Root\COMPOSITE_BATTERY\0000"
ServiceName is "Compbatt"
State = DeviceNodeInitialized (0x302)
Previous State = DeviceNodeUninitialized (0x301)
0: kd> gu
Breakpoint 96 hit
eax=00000000 ebx=00000000 ecx=00000010 edx=00000000 esi=00000000 edi=899c1008
eip=80a2ec74 esp=f789a36c ebp=f789a38c iopl=0 nv up ei pl zr na pe nc
cs=0008 ss=0010 ds=0023 es=0023 fs=0030 gs=0000 efl=00000246
nt!PipSetDevNodeState:
80a2ec74 55 push ebp
0: kd> kc
#
00 nt!PipSetDevNodeState
01 nt!PipEnumerateCompleted
02 nt!PipProcessDevNodeTree
03 nt!PipDeviceActionWorker
04 nt!PipRequestDeviceAction
05 nt!IopInitializeBootDrivers
06 nt!IoInitSystem
07 nt!Phase1Initialization
08 nt!PspSystemThreadStartup
09 nt!KiThreadStartup
0: kd> dv
DeviceNode = 0x899c1008
State = DeviceNodeStarted (0n776)
OldState = 0x00000000
oldIrql = 0x89 ''
0: kd> !devnode 0x899c1008
DevNode 0x899c1008 for PDO 0x899c1de0
Parent 0x89986008 Sibling 0000000000 Child 0x894ffea8
InstancePath is "ACPI_HAL\PNP0C08\0"
ServiceName is "ACPI"
State = DeviceNodeEnumerateCompletion (0x30d)
Previous State = DeviceNodeStarted (0x308)
StateHistory[06] = DeviceNodeStarted (0x308)
StateHistory[05] = DeviceNodeStartPostWork (0x307)
StateHistory[04] = DeviceNodeStartCompletion (0x306)
StateHistory[03] = DeviceNodeResourcesAssigned (0x304)
StateHistory[02] = DeviceNodeDriversAdded (0x303)
StateHistory[01] = DeviceNodeInitialized (0x302)
StateHistory[00] = DeviceNodeUninitialized (0x301)
StateHistory[19] = Unknown State (0x0)
StateHistory[18] = Unknown State (0x0)
StateHistory[17] = Unknown State (0x0)
StateHistory[16] = Unknown State (0x0)
StateHistory[15] = Unknown State (0x0)
StateHistory[14] = Unknown State (0x0)
StateHistory[13] = Unknown State (0x0)
StateHistory[12] = Unknown State (0x0)
StateHistory[11] = Unknown State (0x0)
StateHistory[10] = Unknown State (0x0)
StateHistory[09] = Unknown State (0x0)
StateHistory[08] = Unknown State (0x0)
StateHistory[07] = Unknown State (0x0)
Flags (0x000000f0) DNF_ENUMERATED, DNF_IDS_QUERIED,
DNF_HAS_BOOT_CONFIG, DNF_BOOT_CONFIG_RESERVED
CapabilityFlags (0x000000c0) UniqueID, SilentInstall
0: kd> gu
eax=00000000 ebx=00000000 ecx=80ae0dfa edx=80b18978 esi=00000000 edi=899c1008
eip=80c8dc95 esp=f789a37c ebp=f789a38c iopl=0 nv up ei ng nz na po cy
cs=0008 ss=0010 ds=0023 es=0023 fs=0030 gs=0000 efl=00000283
nt!PipEnumerateCompleted+0x2ff:
80c8dc95 807d0b00 cmp byte ptr [ebp+0Bh],0 ss:0010:f789a397=00
0: kd> !devnode 0x899c1008
DevNode 0x899c1008 for PDO 0x899c1de0
Parent 0x89986008 Sibling 0000000000 Child 0x894ffea8
InstancePath is "ACPI_HAL\PNP0C08\0"
ServiceName is "ACPI"
State = DeviceNodeStarted (0x308)
Previous State = DeviceNodeEnumerateCompletion (0x30d)
StateHistory[07] = DeviceNodeEnumerateCompletion (0x30d)
StateHistory[06] = DeviceNodeStarted (0x308)
StateHistory[05] = DeviceNodeStartPostWork (0x307)
StateHistory[04] = DeviceNodeStartCompletion (0x306)
StateHistory[03] = DeviceNodeResourcesAssigned (0x304)
StateHistory[02] = DeviceNodeDriversAdded (0x303)
StateHistory[01] = DeviceNodeInitialized (0x302)
StateHistory[00] = DeviceNodeUninitialized (0x301)
StateHistory[19] = Unknown State (0x0)
StateHistory[18] = Unknown State (0x0)
StateHistory[17] = Unknown State (0x0)
StateHistory[16] = Unknown State (0x0)
StateHistory[15] = Unknown State (0x0)
StateHistory[14] = Unknown State (0x0)
StateHistory[13] = Unknown State (0x0)
StateHistory[12] = Unknown State (0x0)
StateHistory[11] = Unknown State (0x0)
StateHistory[10] = Unknown State (0x0)
StateHistory[09] = Unknown State (0x0)
StateHistory[08] = Unknown State (0x0)
Flags (0x000000f0) DNF_ENUMERATED, DNF_IDS_QUERIED,
DNF_HAS_BOOT_CONFIG, DNF_BOOT_CONFIG_RESERVED
CapabilityFlags (0x000000c0) UniqueID, SilentInstall