news 2026/2/11 2:26:12

nt!PiProcessNewDeviceNode函数分析之得到HID和CID

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
nt!PiProcessNewDeviceNode函数分析之得到HID和CID

nt!PiProcessNewDeviceNode函数分析之得到HID和CID

0: kd> kc
#
00 nt!PpQueryID
01 nt!PiProcessNewDeviceNode
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 = 0x894ffea8
IDType = BusQueryHardwareIDs (0n1)
ID = 0xf789a378
IDLength = 0xf789a348
status = 0n-141974712
reason = struct _UNICODE_STRING "--- memory read error at address 0x00000008 ---"


0: kd> kc
#
00 ACPI!ACPIDispatchIrp
01 nt!IofCallDriver
02 nt!IopSynchronousCall
03 nt!PpIrpQueryID
04 nt!PpQueryID
05 nt!PiProcessNewDeviceNode
06 nt!PipProcessDevNodeTree
07 nt!PipDeviceActionWorker
08 nt!PipRequestDeviceAction
09 nt!IopInitializeBootDrivers
0a nt!IoInitSystem
0b nt!Phase1Initialization
0c nt!PspSystemThreadStartup
0d nt!KiThreadStartup
0: kd> dv
DeviceObject = 0x899050e8 Device for "\Driver\ACPI"
Irp = 0x89905220

0: kd> !Irp 0x89905220
Irp is active with 1 stacks 1 is current (= 0x89905290)
No Mdl: No System Buffer: Thread 899a1020: Irp stack trace.
cmd flg cl Device File Completion-Context
>[IRP_MJ_PNP(1b), IRP_MN_QUERY_ID(13)]
0 0 899050e8 00000000 00000000-00000000
\Driver\ACPI
Args: 00000001 00000000 00000000 00000000

0: kd> kc
#
00 ACPI!ACPIBusIrpQueryId
01 ACPI!ACPIDispatchIrp
02 nt!IofCallDriver
03 nt!IopSynchronousCall
04 nt!PpIrpQueryID
05 nt!PpQueryID
06 nt!PiProcessNewDeviceNode
07 nt!PipProcessDevNodeTree
08 nt!PipDeviceActionWorker
09 nt!PipRequestDeviceAction
0a nt!IopInitializeBootDrivers
0b nt!IoInitSystem
0c nt!Phase1Initialization
0d nt!PspSystemThreadStartup
0e nt!KiThreadStartup
0: kd> dv
DeviceObject = 0x899050e8 Device for "\Driver\ACPI"
Irp = 0x89905220

case BusQueryHardwareIDs:

//
// Get the device ID as a normal string
//
status = ACPIGetHardwareIDSyncWide(
deviceExtension,
&baseBuffer,
&baseBufferSize
);


//
// This macro is used to get an instance ID, in the wide format, sync
//
#define ACPIGetHardwareIDSyncWide( \
DeviceExtension, \
Buffer, \
BufferSize \
) \
ACPIGetHardwareID( \
DeviceExtension, \
(GET_PROP_SKIP_CALLBACK | \
GET_CONVERT_TO_WIDESTRING), \
NULL, \
NULL, \
Buffer, \
BufferSize \
)

#define ACPIGetHardwareID( \
DeviceExtension, \
Flags, \
CallBack, \
Context, \
Buffer, \
BufferSize \
) \
ACPIGet( \
DeviceExtension, \
PACKED_HID, \
(GET_REQUEST_STRING | \
GET_CONVERT_TO_HARDWAREID | \
GET_TYPE_INTEGER | \
GET_TYPE_STRING | \
Flags ), \
NULL, \
0, \
CallBack, \
Context, \
Buffer, \
(PULONG) BufferSize \
)


Device (PCI0)
{
Name (_HID, EisaId ("PNP0A03")) // _HID: Hardware ID
Name (_CID, EisaId ("PNP0A08")) // _CID: Compatible ID
Name (_BBN, 0x00) // _BBN: BIOS Bus Number
Name (_ADR, 0x00) // _ADR: Address
OperationRegion (REGS, PCI_Config, 0x50, 0x30)


0: kd> kc
#
00 ACPI!ACPIGet
01 ACPI!ACPIBusIrpQueryId
02 ACPI!ACPIDispatchIrp
03 nt!IofCallDriver
04 nt!IopSynchronousCall
05 nt!PpIrpQueryID
06 nt!PpQueryID
07 nt!PiProcessNewDeviceNode
08 nt!PipProcessDevNodeTree
09 nt!PipDeviceActionWorker
0a nt!PipRequestDeviceAction
0b nt!IopInitializeBootDrivers
0c nt!IoInitSystem
0d nt!Phase1Initialization
0e nt!PspSystemThreadStartup
0f nt!KiThreadStartup
0: kd> db f789a19c
f789a19c 4d dc 43 f7 58 0d 9c 89-5f 48 49 44 56 00 08 20 M.C.X..._HIDV..


0: kd> g
Breakpoint 98 hit
eax=899b0024 ebx=00000000 ecx=899b0024 edx=00000000 esi=899b0024 edi=89968680
eip=f741fe16 esp=f789a120 ebp=f789a144 iopl=0 nv up ei pl zr na pe nc
cs=0008 ss=0010 ds=0023 es=0023 fs=0030 gs=0000 efl=00000246
ACPI!SyncEvalObject:
f741fe16 55 push ebp
0: kd> g
Breakpoint 37 hit
eax=f789a104 ebx=00000000 ecx=8997e000 edx=00002707 esi=804edc6c edi=89968680
eip=f741f8c9 esp=f789a0c8 ebp=f789a11c iopl=0 nv up ei ng nz ac pe cy
cs=0008 ss=0010 ds=0023 es=0023 fs=0030 gs=0000 efl=00000297
ACPI!AsyncEvalObject:
f741f8c9 55 push ebp
0: kd> g
Breakpoint 42 hit
eax=00000000 ebx=899b0040 ecx=899b0040 edx=89569fe4 esi=f7438ca8 edi=00000000
eip=f74207d4 esp=f789a0a4 ebp=f789a0c4 iopl=0 nv up ei ng nz ac pe cy
cs=0008 ss=0010 ds=0023 es=0023 fs=0030 gs=0000 efl=00000297
ACPI!RestartContext:
f74207d4 55 push ebp
0: kd> g
Breakpoint 39 hit
eax=00000088 ebx=00000000 ecx=8997e000 edx=00002707 esi=89568000 edi=00000000
eip=f741d710 esp=f789a05c ebp=f789a080 iopl=0 nv up ei ng nz ac po cy
cs=0008 ss=0010 ds=0023 es=0023 fs=0030 gs=0000 efl=00000293
ACPI!RunContext:
f741d710 55 push ebp
0: kd> g
Breakpoint 10 hit
eax=00000000 ebx=89905220 ecx=04e40001 edx=04e30000 esi=c00000bb edi=00000000
eip=f743dc4d esp=f789a1c4 ebp=f789a1dc iopl=0 nv up ei pl zr na pe cy
cs=0008 ss=0010 ds=0023 es=0023 fs=0030 gs=0000 efl=00000247
ACPI!ACPIBusIrpQueryId+0x133:
f743dc4d 8bf0 mov esi,eax


0: kd> dv
DeviceObject = 0x899c0d58 Device for {...}
Irp = 0xe1272188
baseBuffer = 0xe1272188 "A"
deviceExtension = 0x899c0d58
minorFunction = 0x13 ''
type = BusQueryHardwareIDs (0n1)
irpStack = 0x00000001
baseBufferSize = <Memory access error>
0: kd> db 0xe1272188
e1272188 41 00 43 00 50 00 49 00-5c 00 50 00 4e 00 50 00 A.C.P.I.\.P.N.P.
e1272198 30 00 41 00 30 00 33 00-00 00 2a 00 50 00 4e 00 0.A.0.3...*.P.N.


0: kd> gu
eax=00000000 ebx=89905213 ecx=80ae0dfa edx=80b18958 esi=f743db1a edi=00000000
eip=f740410e esp=f789a1ec ebp=f789a210 iopl=0 nv up ei ng nz ac po nc
cs=0008 ss=0010 ds=0023 es=0023 fs=0030 gs=0000 efl=00000292
ACPI!ACPIDispatchIrp+0x19e:
f740410e ff75fc push dword ptr [ebp-4] ss:0010:f789a20c=899c0d58
0: kd> gu
eax=00000000 ebx=00000000 ecx=899c0e74 edx=80b18958 esi=89905220 edi=899050e8
eip=80a2675c esp=f789a220 ebp=f789a22c iopl=0 nv up ei pl nz na po nc
cs=0008 ss=0010 ds=0023 es=0023 fs=0030 gs=0000 efl=00000202
nt!IofCallDriver+0x62:
80a2675c 5f pop edi
0: kd> gu
eax=00000000 ebx=899050e8 ecx=899c0e74 edx=80b18958 esi=f789a2a0 edi=899052b4
eip=80c95e00 esp=f789a234 ebp=f789a25c iopl=0 nv up ei pl nz na po nc
cs=0008 ss=0010 ds=0023 es=0023 fs=0030 gs=0000 efl=00000202
nt!IopSynchronousCall+0x1aa:
80c95e00 8bf0 mov esi,eax
0: kd> gu
eax=00000000 ebx=00000001 ecx=e1272188 edx=80b18958 esi=f789a378 edi=f789a2a0
eip=80c97a60 esp=f789a270 ebp=f789a2a0 iopl=0 nv up ei ng nz ac po cy
cs=0008 ss=0010 ds=0023 es=0023 fs=0030 gs=0000 efl=00000293
nt!PpIrpQueryID+0x96:
80c97a60 33ff xor edi,edi
0: kd> gu
eax=00000000 ebx=f789a348 ecx=e1272188 edx=80b18958 esi=894ffea8 edi=899a1020
eip=80c8a3a6 esp=f789a2b4 ebp=f789a2c8 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!PpQueryID+0x80:
80c8a3a6 33c9 xor ecx,ecx

case BusQueryHardwareIDs:
case BusQueryCompatibleIDs:

*IDLength = PiFixupID(*ID,
MAX_DEVICE_ID_LEN,
TRUE,
(ULONG)-1,
&DeviceNode->Parent->ServiceName
);
break;

0: kd> kc
#
00 nt!PiFixupID
01 nt!PpQueryID
02 nt!PiProcessNewDeviceNode
03 nt!PipProcessDevNodeTree
04 nt!PipDeviceActionWorker
05 nt!PipRequestDeviceAction
06 nt!IopInitializeBootDrivers
07 nt!IoInitSystem
08 nt!Phase1Initialization
09 nt!PspSystemThreadStartup
0a nt!KiThreadStartup
0: kd> dv
ID = 0xe1272188
MaxIDLength = 0xc8
Multi = 0x01 ''
AllowedSeparators = 0xffffffff
LogString = 0x899c10a4 "ACPI"
reason = ""
separators = 8
0: kd> dx -r1 ((ntkrnlmp!unsigned short *)0xe1272188)
((ntkrnlmp!unsigned short *)0xe1272188) : 0xe1272188 : 0x41 [Type: unsigned short *]
0x41 [Type: unsigned short]
0: kd> db 0xe1272188
e1272188 41 00 43 00 50 00 49 00-5c 00 50 00 4e 00 50 00 A.C.P.I.\.P.N.P.
e1272198 30 00 41 00 30 00 33 00-00 00 2a 00 50 00 4e 00 0.A.0.3...*.P.N.
e12721a8 50 00 30 00 41 00 30 00-33 00 00 00 00 00 b2 b2 P.0.A.0.3.......

0: kd> dv
hwIDLength = 0x2e
hwIDs = 0xe1272188

PpQueryCompatibleIDs(
DeviceNode,
&compatibleIDs,
&compatibleIDLength);

0: kd> g
Breakpoint 74 hit
eax=0000001b ebx=00000000 ecx=89981f38 edx=89905220 esi=89905220 edi=899050e8
eip=f7403f70 esp=f789a214 ebp=f789a22c iopl=0 nv up ei ng nz na pe nc
cs=0008 ss=0010 ds=0023 es=0023 fs=0030 gs=0000 efl=00000286
ACPI!ACPIDispatchIrp:
f7403f70 55 push ebp
0: kd> kc
#
00 ACPI!ACPIDispatchIrp
01 nt!IofCallDriver
02 nt!IopSynchronousCall
03 nt!PpIrpQueryID
04 nt!PpQueryID
05 nt!PiProcessNewDeviceNode
06 nt!PipProcessDevNodeTree
07 nt!PipDeviceActionWorker
08 nt!PipRequestDeviceAction
09 nt!IopInitializeBootDrivers
0a nt!IoInitSystem
0b nt!Phase1Initialization
0c nt!PspSystemThreadStartup
0d nt!KiThreadStartup
0: kd> g
Breakpoint 5 hit
eax=00000002 ebx=89905213 ecx=899c0e74 edx=f745b068 esi=f743db1a edi=00000000
eip=f740410c esp=f789a1e4 ebp=f789a210 iopl=0 nv up ei pl nz na po nc
cs=0008 ss=0010 ds=0023 es=0023 fs=0030 gs=0000 efl=00000202
ACPI!ACPIDispatchIrp+0x19c:
f740410c ffd6 call esi {ACPI!ACPIBusIrpQueryId (f743db1a)}
0: kd> g
Breakpoint 71 hit
eax=899c0d58 ebx=89905220 ecx=f789a1e8 edx=00000002 esi=c00000bb edi=00000000
eip=f74076b8 esp=f789a19c ebp=f789a1dc iopl=0 nv up ei pl zr na pe nc
cs=0008 ss=0010 ds=0023 es=0023 fs=0030 gs=0000 efl=00000246
ACPI!ACPIGet:
f74076b8 55 push ebp
0: kd> db f789a19c
f789a19c 14 dc 43 f7 58 0d 9c 89-5f 43 49 44 17 01 08 20 ..C.X..._CID...


0: kd> g
Breakpoint 29 hit
eax=00000000 ebx=f743b938 ecx=05402000 edx=00000000 esi=89968640 edi=89968648
eip=f74078d8 esp=f789a154 ebp=f789a198 iopl=0 nv up ei pl zr na pe nc
cs=0008 ss=0010 ds=0023 es=0023 fs=0030 gs=0000 efl=00000246
ACPI!ACPIGet+0x220:
f74078d8 e83b2bffff call ACPI!ACPIAmliGetNamedChild (f73fa418)
0: kd> g
Breakpoint 98 hit
eax=899b0068 ebx=00000000 ecx=899b0068 edx=00000000 esi=899b0068 edi=89968680
eip=f741fe16 esp=f789a120 ebp=f789a144 iopl=0 nv up ei pl zr na pe nc
cs=0008 ss=0010 ds=0023 es=0023 fs=0030 gs=0000 efl=00000246
ACPI!SyncEvalObject:
f741fe16 55 push ebp
0: kd> g
Breakpoint 37 hit
eax=f789a104 ebx=00000000 ecx=8997e000 edx=00002707 esi=804edc6c edi=89968680
eip=f741f8c9 esp=f789a0c8 ebp=f789a11c iopl=0 nv up ei ng nz ac po cy
cs=0008 ss=0010 ds=0023 es=0023 fs=0030 gs=0000 efl=00000293
ACPI!AsyncEvalObject:
f741f8c9 55 push ebp
0: kd> g
Breakpoint 42 hit
eax=00000000 ebx=899b0084 ecx=899b0084 edx=89569fe4 esi=f7438ca8 edi=00000000
eip=f74207d4 esp=f789a0a4 ebp=f789a0c4 iopl=0 nv up ei ng nz ac pe cy
cs=0008 ss=0010 ds=0023 es=0023 fs=0030 gs=0000 efl=00000297
ACPI!RestartContext:
f74207d4 55 push ebp
0: kd> g
Breakpoint 39 hit
eax=0000008f ebx=00000000 ecx=8997e000 edx=00002707 esi=89568000 edi=00000000
eip=f741d710 esp=f789a05c ebp=f789a080 iopl=0 nv up ei ng nz na pe cy
cs=0008 ss=0010 ds=0023 es=0023 fs=0030 gs=0000 efl=00000287
ACPI!RunContext:
f741d710 55 push ebp

NTSTATUS
ACPIGetConvertToStringWide(
IN PDEVICE_EXTENSION DeviceExtension,
IN NTSTATUS Status,
IN POBJDATA Result,
IN ULONG Flags,
OUT PVOID *Buffer,
OUT ULONG *BufferSize OPTIONAL
)
{
//
// For a string, make sure that there is no leading '*' and
// account for the fact that we will preceed the string with
// a '*' and NULL
//
memSize = strlen(Result->pbDataBuff) + 1;


0: kd> g
Breakpoint 10 hit
eax=00000000 ebx=89905220 ecx=04e50001 edx=04e40000 esi=c00000bb edi=00000000
eip=f743dc14 esp=f789a1c4 ebp=f789a1dc iopl=0 nv up ei pl zr na po cy
cs=0008 ss=0010 ds=0023 es=0023 fs=0030 gs=0000 efl=00000243
ACPI!ACPIBusIrpQueryId+0xfa:
f743dc14 8bf0 mov esi,eax
0: kd> dv
DeviceObject = 0x899c0d58 Device for {...}
Irp = 0xe12857d0
baseBuffer = 0xe12857d0 "*"

0: kd> db 0xe12857d0
e12857d0 2a 00 50 00 4e 00 50 00-30 00 41 00 30 00 38 00 *.P.N.P.0.A.0.8.

0: kd> gu
eax=00000000 ebx=89905213 ecx=80ae0dfa edx=80b18958 esi=f743db1a edi=00000000
eip=f740410e esp=f789a1ec ebp=f789a210 iopl=0 nv up ei ng nz ac po nc
cs=0008 ss=0010 ds=0023 es=0023 fs=0030 gs=0000 efl=00000292
ACPI!ACPIDispatchIrp+0x19e:
f740410e ff75fc push dword ptr [ebp-4] ss:0010:f789a20c=899c0d58
0: kd> gu
eax=00000000 ebx=00000000 ecx=899c0e74 edx=80b18958 esi=89905220 edi=899050e8
eip=80a2675c esp=f789a220 ebp=f789a22c iopl=0 nv up ei pl nz na po nc
cs=0008 ss=0010 ds=0023 es=0023 fs=0030 gs=0000 efl=00000202
nt!IofCallDriver+0x62:
80a2675c 5f pop edi
0: kd> gu
eax=00000000 ebx=899050e8 ecx=899c0e74 edx=80b18958 esi=f789a2a0 edi=899052b4
eip=80c95e00 esp=f789a234 ebp=f789a25c iopl=0 nv up ei pl nz na po nc
cs=0008 ss=0010 ds=0023 es=0023 fs=0030 gs=0000 efl=00000202
nt!IopSynchronousCall+0x1aa:
80c95e00 8bf0 mov esi,eax
0: kd> gu
eax=00000000 ebx=00000002 ecx=e12857d0 edx=80b18958 esi=f789a37c edi=f789a2a0
eip=80c97a60 esp=f789a270 ebp=f789a2a0 iopl=0 nv up ei ng nz ac po cy
cs=0008 ss=0010 ds=0023 es=0023 fs=0030 gs=0000 efl=00000293
nt!PpIrpQueryID+0x96:
80c97a60 33ff xor edi,edi
0: kd> gu
eax=00000000 ebx=f789a34c ecx=e12857d0 edx=80b18958 esi=894ffea8 edi=899a1020
eip=80c8a3a6 esp=f789a2b4 ebp=f789a2c8 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!PpQueryID+0x80:
80c8a3a6 33c9 xor ecx,ecx
0: kd> gu
eax=00000000 ebx=00000000 ecx=00000000 edx=e12857d0 esi=894ffea8 edi=899a1020
eip=80c9417b esp=f789a2e0 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!PiProcessNewDeviceNode+0x8f9:
80c9417b 648b3d24010000 mov edi,dword ptr fs:[124h] fs:0030:00000124=899a1020
0: kd> dv compatibleIDs
compatibleIDs = 0xe12857d0
0: kd> db 0xe12857d0
e12857d0 2a 00 50 00 4e 00 50 00-30 00 41 00 30 00 38 00 *.P.N.P.0.A.0.8.
e12857e0 00 00 00 00 00 00 b2 b2-04 08 04 0c 43 4d 4e e2 ............CMN.
e12857f0 01 00 01 00 da bf 3d 00-00 00 00 00 04 00 4e 44 ......=.......ND
e1285800 49 53 00 00 01 00 b2 b2-04 08 08 0c 43 4d 44 61 IS..........CMDa
e1285810 01 00 1c 00 76 6b 05 00-18 00 00 00 00 68 0e 00 ....vk.......h..
e1285820 01 00 00 00 01 00 b2 b2-47 72 6f 75 70 b2 b2 b2 ........Group...
e1285830 46 00 69 00 6c 00 65 00-20 00 73 00 79 00 73 00 F.i.l.e. .s.y.s.
e1285840 74 00 65 00 6d 00 00 00-08 08 07 0c 53 64 62 61 t.e.m.......Sdba
0: kd> dv compatibleIDLength
compatibleIDLength = 0x14

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/2/6 15:24:17

《凌晨3点,Claude-Opus-4.6 突然发布!实测吊打GPT-5,写代码比我快100倍,程序员真的要变成“提示词胶水工”了?》

摘要&#xff1a; 就在大家还在争论DeepSeek和GPT-4谁更强的时候&#xff0c;Anthropic 不讲武德&#xff0c;悄无声息地扔下了一枚核弹——Claude-Opus-4.6。这不是简单的版本号1&#xff0c;这是对“智能”定义的重新洗牌。本文将从底层逻辑、代码实战、Agent能力三个维度&am…

作者头像 李华
网站建设 2026/2/9 16:29:47

热乎的,一次 MySQL 主从同步异常的排查

~ 目录 一、现象 最近项目的测试环境遇到一个主备同步的问题&#xff1a; 备库的同步线程停止了&#xff0c;无法同步主库的数据更改。 备库报错如下&#xff1a; 从库同步报错信息 完整的错误信息&#xff1a; Relay log read failure: Could not parse relay log event en…

作者头像 李华
网站建设 2026/2/6 15:18:38

5种方案,轻松实现Redis 分布式锁

本地加锁的方式在分布式的场景下不适用&#xff0c;所以本文我们来探讨下如何引入分布式锁解决本地锁的问题。本篇所有代码和业务基于我的开源项目 PassJava。本篇主要内容如下&#xff1a;一、本地锁的问题首先我们来回顾下本地锁的问题&#xff1a;目前题目微服务被拆分成了四…

作者头像 李华
网站建设 2026/2/6 15:17:15

Volterra LMS算法的实现与仿真分析 构建一个Volterra系统模型二阶系统

Volterra LMS算法的实现与仿真分析 构建一个Volterra系统模型二阶系统&#xff0c;我们将实现LMS算法到这样一个模型&#xff0c;称为非线性Volterra模型。 % % 1. 首先设置一个随机信号 % % 2. 设定核因子 % % 选取不同的一阶核系数和二阶核系数进行检验 % % 3.添加噪声 % % 4…

作者头像 李华
网站建设 2026/2/8 2:55:59

长尾关键词在SEO策略中的应用与效果提升分析

长尾关键词在SEO策略中扮演着重要的角色&#xff0c;能有效提升搜索引擎排名和网站流量。这类关键词通常由多个独立词组合而成&#xff0c;与用户的具体需求紧密相关。通过挖掘和使用长尾关键词&#xff0c;网站能够更准确地满足目标受众的搜索意图&#xff0c;从而吸引更为精准…

作者头像 李华