news 2026/5/7 5:12:13

ACPI!ACPIBuildDeviceExtension函数分析之建立了第一个子设备扩展

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
ACPI!ACPIBuildDeviceExtension函数分析之建立了第一个子设备扩展

ACPI!ACPIBuildDeviceExtension函数分析之建立了第一个子设备扩展

0: kd> dv
CurrentObject = 0x899affac
ParentDeviceExtension = 0x89981a18
ReturnExtension = 0xf789a0d4
0: kd> dx -id 0,0,899a2278 -r1 ((ACPI!_NSObj *)0x899affac)
((ACPI!_NSObj *)0x899affac) : 0x899affac [Type: _NSObj *]
[+0x000] list [Type: _List]
[+0x008] pnsParent : 0x899af0f0 [Type: _NSObj *]
[+0x00c] pnsFirstChild : 0x0 [Type: _NSObj *]
[+0x010] dwNameSeg : 0x30494350 [Type: unsigned long]
[+0x014] hOwner : 0x899af330 [Type: void *]
[+0x018] pnsOwnedNext : 0x899aff4c [Type: _NSObj *]
[+0x01c] ObjData [Type: _ObjData]
[+0x030] Context : 0x0 [Type: void *]
[+0x034] dwRefCount : 0x0 [Type: unsigned long]

//
// Create a new extension for the object
//
deviceExtension = ExAllocateFromNPagedLookasideList( esi=899c0d58
&DeviceExtensionLookAsideList
);

0: kd> p
eax=899c0d58 ebx=89981a18 ecx=89bfe0e0 edx=00000000 esi=899c0d58 edi=899affac
eip=f73fc8e3 esp=f789a0a8 ebp=f789a0b4 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!ACPIBuildDeviceExtension+0x7b:
f73fc8e3 85f6 test esi,esi
//
// Lets begin with a clean slate
//
RtlZeroMemory( deviceExtension, sizeof(DEVICE_EXTENSION) );

//
// Initialize the reference count mechanism. We only have a NS object
// so the value should be 1
//
deviceExtension->ReferenceCount++ ;

//
// The initial outstanding IRP count will be set to one. Only during a
// remove IRP will this drop to zero, and then it will immediately pop
// back up to one.
//
deviceExtension->OutstandingIrpCount++;

//
// Initialize the link fields
//
deviceExtension->AcpiObject = CurrentObject; 关键代码1:

//
// Initialize the data fields
//
deviceExtension->Signature = ACPI_SIGNATURE;
deviceExtension->Flags = DEV_TYPE_NOT_FOUND | DEV_TYPE_NOT_PRESENT;
deviceExtension->DispatchTable = NULL;
deviceExtension->DeviceState = Stopped;
*ReturnExtension = deviceExtension;


0: kd> dt acpi!_DEVICE_EXTENSION 899c0d58
+0x000 Flags : 0xa
+0x000 UFlags : __unnamed
+0x008 Signature : 0x5f534750
+0x00c DebugFlags : 0
+0x010 DispatchTable : (null)
+0x014 WorkContext : WORK_QUEUE_CONTEXT
+0x014 Fdo : _FDO_DEVICE_EXTENSION
+0x014 Filter : _FILTER_DEVICE_EXTENSION
+0x014 Pdo : _PDO_DEVICE_EXTENSION
+0x058 WorkQueue : EXTENSION_WORKER
+0x058 Button : BUTTON_EXTENSION
+0x058 Thermal : THERMAL_EXTENSION
+0x058 LinkNode : LINK_NODE_EXTENSION
+0x058 Dock : DOCK_EXTENSION
+0x058 Processor : _PROCESSOR_DEVICE_EXTENSION
+0x088 DeviceState : 0 ( Stopped )
+0x08c PreviousState : 0 ( Stopped )
+0x090 PowerInfo : _ACPI_POWER_INFO
+0x10c DeviceID : (null)
+0x10c Address : 0
+0x110 InstanceID : (null)
+0x114 ResourceList : (null)
+0x118 PnpResourceList : (null)
+0x11c OutstandingIrpCount : 0n1
+0x120 ReferenceCount : 0n1
+0x124 HibernatePathCount : 0n0
+0x128 RemoveEvent : (null)
+0x12c AcpiObject : 0x899affac _NSObj
+0x130 DeviceObject : (null)
+0x134 TargetDeviceObject : (null)
+0x138 PhysicalDeviceObject : (null)
+0x13c ParentExtension : (null)
+0x140 ChildDeviceList : _LIST_ENTRY [ 0x0 - 0x0 ]
+0x148 SiblingDeviceList : _LIST_ENTRY [ 0x0 - 0x0 ]
+0x150 EjectDeviceHead : _LIST_ENTRY [ 0x0 - 0x0 ]
+0x158 EjectDeviceList : _LIST_ENTRY [ 0x0 - 0x0 ]


//
// Initialize the list entries
//
InitializeListHead( &(deviceExtension->ChildDeviceList) );
InitializeListHead( &(deviceExtension->EjectDeviceHead) );
InitializeListHead( &(deviceExtension->EjectDeviceList) );
InitializeListHead( &(powerInfo->WakeSupportList) );
InitializeListHead( &(powerInfo->PowerRequestListEntry) );

//
// Make sure that the deviceExtension has pointers to its parent
// extension. Note, that this should cause the ref count on the
// parent to increase
//
deviceExtension->ParentExtension = ParentDeviceExtension; 关键代码2:


0: kd> dt acpi!_DEVICE_EXTENSION 899c0d58
+0x000 Flags : 0xa
+0x000 UFlags : __unnamed
+0x008 Signature : 0x5f534750
+0x00c DebugFlags : 0
+0x010 DispatchTable : (null)
+0x014 WorkContext : WORK_QUEUE_CONTEXT
+0x014 Fdo : _FDO_DEVICE_EXTENSION
+0x014 Filter : _FILTER_DEVICE_EXTENSION
+0x014 Pdo : _PDO_DEVICE_EXTENSION
+0x058 WorkQueue : EXTENSION_WORKER
+0x058 Button : BUTTON_EXTENSION
+0x058 Thermal : THERMAL_EXTENSION
+0x058 LinkNode : LINK_NODE_EXTENSION
+0x058 Dock : DOCK_EXTENSION
+0x058 Processor : _PROCESSOR_DEVICE_EXTENSION
+0x088 DeviceState : 0 ( Stopped )
+0x08c PreviousState : 0 ( Stopped )
+0x090 PowerInfo : _ACPI_POWER_INFO
+0x10c DeviceID : (null)
+0x10c Address : 0
+0x110 InstanceID : (null)
+0x114 ResourceList : (null)
+0x118 PnpResourceList : (null)
+0x11c OutstandingIrpCount : 0n1
+0x120 ReferenceCount : 0n1
+0x124 HibernatePathCount : 0n0
+0x128 RemoveEvent : (null)
+0x12c AcpiObject : 0x899affac _NSObj
+0x130 DeviceObject : (null)
+0x134 TargetDeviceObject : (null)
+0x138 PhysicalDeviceObject : (null)
+0x13c ParentExtension : 0x89981a18 _DEVICE_EXTENSION
+0x140 ChildDeviceList : _LIST_ENTRY [ 0x899c0e98 - 0x899c0e98 ]
+0x148 SiblingDeviceList : _LIST_ENTRY [ 0x89981b58 - 0x89981b58 ]
+0x150 EjectDeviceHead : _LIST_ENTRY [ 0x899c0ea8 - 0x899c0ea8 ]
+0x158 EjectDeviceList : _LIST_ENTRY [ 0x899c0eb0 - 0x899c0eb0 ]

if (ParentDeviceExtension) {

InterlockedIncrement( &(ParentDeviceExtension->ReferenceCount) );

//
// Add the deviceExtension into the deviceExtension tree
//
InsertTailList(
&(ParentDeviceExtension->ChildDeviceList),
&(deviceExtension->SiblingDeviceList)
); 关键代码3:
}


0: kd> dt ACPI!_DEVICE_EXTENSION 0x89981a18
+0x000 Flags : 0x0001e000`00200010
+0x000 UFlags : __unnamed
+0x008 Signature : 0x5f534750
+0x00c DebugFlags : 0
+0x010 DispatchTable : 0xf743826c IRP_DISPATCH_TABLE
+0x014 WorkContext : WORK_QUEUE_CONTEXT
+0x014 Fdo : _FDO_DEVICE_EXTENSION
+0x014 Filter : _FILTER_DEVICE_EXTENSION
+0x014 Pdo : _PDO_DEVICE_EXTENSION
+0x058 WorkQueue : EXTENSION_WORKER
+0x058 Button : BUTTON_EXTENSION
+0x058 Thermal : THERMAL_EXTENSION
+0x058 LinkNode : LINK_NODE_EXTENSION
+0x058 Dock : DOCK_EXTENSION
+0x058 Processor : _PROCESSOR_DEVICE_EXTENSION
+0x088 DeviceState : 0 ( Stopped )
+0x08c PreviousState : 0 ( Stopped )
+0x090 PowerInfo : _ACPI_POWER_INFO
+0x10c DeviceID : 0x899bfea0 "ACPI\PNP0C08"
+0x10c Address : 0x899bfea0
+0x110 InstanceID : 0x899c53e8 "0x5F534750"
+0x114 ResourceList : 0x899bfeb8 _CM_RESOURCE_LIST
+0x118 PnpResourceList : (null)
+0x11c OutstandingIrpCount : 0n2
+0x120 ReferenceCount : 0n3
+0x124 HibernatePathCount : 0n0
+0x128 RemoveEvent : (null)
+0x12c AcpiObject : (null)
+0x130 DeviceObject : 0x89981b98 _DEVICE_OBJECT
+0x134 TargetDeviceObject : 0x899c1de0 _DEVICE_OBJECT
+0x138 PhysicalDeviceObject : 0x899c1de0 _DEVICE_OBJECT
+0x13c ParentExtension : (null)
+0x140 ChildDeviceList : _LIST_ENTRY [ 0x899c0ea0 - 0x899c0ea0 ]
+0x148 SiblingDeviceList : _LIST_ENTRY [ 0x89981b60 - 0x89981b60 ]
+0x150 EjectDeviceHead : _LIST_ENTRY [ 0x89981b68 - 0x89981b68 ]
+0x158 EjectDeviceList : _LIST_ENTRY [ 0x89981b70 - 0x89981b70 ]
0: kd> dx -id 0,0,899a2278 -r1 (*((ACPI!_LIST_ENTRY *)0x89981b58))
(*((ACPI!_LIST_ENTRY *)0x89981b58)) [Type: _LIST_ENTRY]
[+0x000] Flink : 0x899c0ea0 [Type: _LIST_ENTRY *]
[+0x004] Blink : 0x899c0ea0 [Type: _LIST_ENTRY *]


//
// And make sure that the Name Space Object points to the extension
//
if (CurrentObject != NULL ) {

CurrentObject->Context = deviceExtension; 关键代码4:
}


0: kd> dx -id 0,0,899a2278 -r1 ((ACPI!_NSObj *)0x899affac)
((ACPI!_NSObj *)0x899affac) : 0x899affac [Type: _NSObj *]
[+0x000] list [Type: _List]
[+0x008] pnsParent : 0x899af0f0 [Type: _NSObj *]
[+0x00c] pnsFirstChild : 0x0 [Type: _NSObj *]
[+0x010] dwNameSeg : 0x30494350 [Type: unsigned long]
[+0x014] hOwner : 0x899af330 [Type: void *]
[+0x018] pnsOwnedNext : 0x899aff4c [Type: _NSObj *]
[+0x01c] ObjData [Type: _ObjData]
[+0x030] Context : 0x899c0d58 [Type: void *] [+0x030] Context : 0x899c0d58
[+0x034] dwRefCount : 0x0 [Type: unsigned long]


0: kd> kc
#
00 ACPI!ACPIBuildDeviceExtension
01 ACPI!OSNotifyCreateDevice
02 ACPI!OSNotifyCreate
03 ACPI!Device
04 ACPI!ParseTerm
05 ACPI!RunContext
06 ACPI!InsertReadyQueue
07 ACPI!RestartContext
08 ACPI!SyncLoadDDB
09 ACPI!AMLILoadDDB
0a ACPI!ACPIInitializeDDB
0b ACPI!ACPIInitializeDDBs
0c ACPI!ACPIInitialize
0d ACPI!ACPIInitStartACPI
0e ACPI!ACPIRootIrpStartDevice
0f ACPI!ACPIDispatchIrp
10 nt!IofCallDriver
11 nt!IopSynchronousCall
12 nt!IopStartDevice
13 nt!PipProcessStartPhase1
14 nt!PipProcessDevNodeTree
15 nt!PipDeviceActionWorker
16 nt!PipRequestDeviceAction
17 nt!IopInitializeBootDrivers
18 nt!IoInitSystem
19 nt!Phase1Initialization
1a nt!PspSystemThreadStartup
1b nt!KiThreadStartup

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

【C++26契约编程重大突破】:深度解析post条件如何重塑代码可靠性

第一章:C26契约编程中post条件的演进与意义C26标准在契约编程(Contract Programming)方面引入了更完善的语言级支持,其中对post条件(后置条件)的语义增强尤为显著。这一机制允许开发者在函数定义中显式声明…

作者头像 李华
网站建设 2026/5/1 7:51:33

std::execution on函数到底多强大?实测对比8种执行策略性能差异

第一章:std::execution on函数的核心能力解析 std::execution::on 是 C17 并发扩展中提出的重要设施,用于将执行策略(execution policy)与特定的执行上下文(如线程池或调度器)绑定,从而实现对任…

作者头像 李华
网站建设 2026/5/1 15:27:57

mybatisplus是否可用于存储lora-scripts训练元数据?数据库设计建议

MyBatis-Plus 是否可用于存储 LoRA-Scripts 训练元数据?数据库设计建议 在 AI 模型微调日益工程化的今天,LoRA(Low-Rank Adaptation)因其轻量高效、参数独立的特点,已成为 Stable Diffusion 图像生成与大语言模型适配的…

作者头像 李华
网站建设 2026/5/1 9:59:30

如何解决lora-scripts训练中显存溢出问题?实用调参技巧分享

如何解决lora-scripts训练中显存溢出问题?实用调参技巧分享 在消费级显卡上跑一个LoRA模型,结果刚启动就“CUDA out of memory”——这种经历对很多AI爱好者来说都不陌生。尤其是使用 lora-scripts 这类自动化工具时,用户往往以为“配置好YAM…

作者头像 李华
网站建设 2026/5/3 21:08:30

5款AI写论文大比拼:宏智树AI凭何脱颖而出成首选?

对于众多论文小白和被写作难题折磨的学子来说,借助AI工具辅助写论文成了高效完成学业任务的新途径。但市面上AI写论文软件众多,到底选哪款好呢?今天就给大家深度测评5款热门AI写论文工具,重点揭秘宏智树AI的独特魅力,同…

作者头像 李华
网站建设 2026/5/3 6:06:01

9款AI写论文大揭秘:宏智树AI凭何稳坐C位?

在论文写作的“战场”上,许多学子常常被选题迷茫、文献堆积、结构混乱等问题搞得焦头烂额。而随着人工智能的发展,AI写论文工具成为了大家的“救星”。但市面上AI写论文软件众多,到底哪款才是你的“真命天子”呢?今天,…

作者头像 李华