news 2026/4/16 17:27:54

nt!PiProcessNewDeviceNode函数中nt!PiCreateDeviceInstanceKey

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
nt!PiProcessNewDeviceNode函数中nt!PiCreateDeviceInstanceKey

nt!PiProcessNewDeviceNode函数中nt!PiCreateDeviceInstanceKey

NTSTATUS
PiProcessNewDeviceNode(
IN PDEVICE_NODE DeviceNode
)
{
//
// Build the device instance path and create the instance key.
//
status = PiBuildDeviceNodeInstancePath(DeviceNode, busID, deviceID, instanceID);
if (NT_SUCCESS(status)) {

status = PiCreateDeviceInstanceKey(DeviceNode, &instanceKey, &disposition);
}


0: kd> kc
#
00 nt!PiCreateDeviceInstanceKey
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
InstanceKey = 0xf789a388
Disposition = 0xf789a35c
keyValueInformation = 0x00000008
status = 0n0
unicodeString = ""
enumHandle = 0x80c9069c

status = IopOpenRegistryKeyEx(
&enumHandle,
NULL,
&CmRegistryMachineSystemCurrentControlSetEnumName,
KEY_ALL_ACCESS
);

0: kd> dv enumHandle
enumHandle = 0x80000244
0: kd> !handle 244

PROCESS 899a2278 SessionId: none Cid: 0004 Peb: 00000000 ParentCid: 0000
DirBase: 0a200000 ObjectTable: e1000e38 HandleCount: 33.
Image: System

Kernel handle table at e1000e38 with 33 entries in use

0244: Object: e127f5e0 GrantedAccess: 000f003f Entry: e1004488
Object: e127f5e0 Type: (89996048) Key
ObjectHeader: e127f5c8 (old version)
HandleCount: 1 PointerCount: 1
Directory Object: 00000000 Name: \REGISTRY\MACHINE\SYSTEM\CONTROLSET001\ENUM

if (NT_SUCCESS(status)) {

status = IopCreateRegistryKeyEx(
InstanceKey,
enumHandle,
&DeviceNode->InstancePath,
KEY_ALL_ACCESS,
REG_OPTION_NON_VOLATILE,
Disposition
);
if (NT_SUCCESS(status)) {


0: kd> dv InstanceKey
InstanceKey = 0xf789a388
0: kd> dx -r1 ((ntkrnlmp!void * *)0xf789a388)
((ntkrnlmp!void * *)0xf789a388) : 0xf789a388 [Type: void * *]
0x80000214 [Type: void *]
0: kd> !handle 214

PROCESS 899a2278 SessionId: none Cid: 0004 Peb: 00000000 ParentCid: 0000
DirBase: 0a200000 ObjectTable: e1000e38 HandleCount: 34.
Image: System

Kernel handle table at e1000e38 with 34 entries in use

0214: Object: e1271ae0 GrantedAccess: 000f003f Entry: e1004428
Object: e1271ae0 Type: (89996048) Key
ObjectHeader: e1271ac8 (old version)
HandleCount: 1 PointerCount: 1
Directory Object: 00000000 Name: \REGISTRY\MACHINE\SYSTEM\CONTROLSET001\ENUM\ACPI\PNP0A03\2&DABA3FF&0

0: kd> dv Disposition
Disposition = 0xf789a35c
0: kd> dx -r1 ((ntkrnlmp!unsigned long *)0xf789a35c)
((ntkrnlmp!unsigned long *)0xf789a35c) : 0xf789a35c : 0x2 [Type: unsigned long *]
0x2 [Type: unsigned long]


通过文本模式设置迁移的键值应被视为“新键”。迁移的键值可通过设备实例键值下是否存在非零的REG_DWORD值“Migrated”来识别。
if (NT_SUCCESS(status)) {
//
// Keys migrated by textmode setup should be treated as "new".
// Migrated keys are identified by the presence of non-zero
// REG_DWORD value "Migrated" under the device instance key.
//
if (*Disposition != REG_CREATED_NEW_KEY) {


D:\srv03rtm\public\sdk\inc/winnt.h:9079:#define REG_CREATED_NEW_KEY (0x00000001L) // New Registry Key created

//
// Key creation/open disposition
//

#define REG_CREATED_NEW_KEY (0x00000001L) // New Registry Key created
#define REG_OPENED_EXISTING_KEY (0x00000002L) // Existing Key opened


if (*Disposition != REG_CREATED_NEW_KEY) {

keyValueInformation = NULL;
IopGetRegistryValue(
*InstanceKey,
REGSTR_VALUE_MIGRATED,
&keyValueInformation);
if (keyValueInformation) {

0: kd> p
eax=c0000034 ebx=f789a35c ecx=00030001 edx=00020000 esi=f789a388 edi=00000000
eip=80c9079f esp=f789a2ac ebp=f789a2cc iopl=0 nv up ei pl nz na pe nc
cs=0008 ss=0010 ds=0023 es=0023 fs=0030 gs=0000 efl=00000206
nt!PiCreateDeviceInstanceKey+0x103:
80c9079f 8b45fc mov eax,dword ptr [ebp-4] ss:0010:f789a2c8=00000000
0: kd> dv keyValueInformation
keyValueInformation = 0x00000000

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

【计算机毕业设计案例】基于Python+Flask的在线教育平台的设计与实现在线学习平台的设计与实现(程序+文档+讲解+定制)

博主介绍:✌️码农一枚 ,专注于大学生项目实战开发、讲解和毕业🚢文撰写修改等。全栈领域优质创作者,博客之星、掘金/华为云/阿里云/InfoQ等平台优质作者、专注于Java、小程序技术领域和毕业项目实战 ✌️技术范围:&am…

作者头像 李华
网站建设 2026/4/16 10:46:40

手把手教你实现:当 GitHub 收到 Star 后,通过企微外部群自动通知

QiWe开放平台 个人名片 API驱动企微自动化,让开发更高效 核心能力:为开发者提供标准化接口、快速集成工具,助力产品高效拓展功能场景 官方站点:https://www.qiweapi.com 团队定位:专注企微API生态的技术服务团队 对接…

作者头像 李华
网站建设 2026/4/15 20:19:39

二十年“架骨注魂”的旅程

摘要 数字化转型的成功,不取决于技术的先进与否,而取决于管理思想(血肉灵魂) 与数字系统(骨骼架构) 能否在互动中相互塑造,形成具有自适应能力的 “数字共生体” 。 本系列旨在为这场深刻变革提…

作者头像 李华
网站建设 2026/4/16 11:11:00

如何处理 React 中事件处理程序的绑定问题

如何处理 React 中事件处理程序的绑定问题 —— 从「this 丢失」到「性能飙红」的实战手册 一句话总结:用「箭头函数 useCallback 传参模板」三件套,让事件绑定既安全又高性能! 一、为什么要「处理」事件绑定? React 事件绑定…

作者头像 李华