news 2026/6/9 17:19:34

ACPI!ACPIBuildProcessGenericList函数中2次InterlockedCompareExchange函数作用是标记为WORK_DONE_PENDING下次直接略过

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
ACPI!ACPIBuildProcessGenericList函数中2次InterlockedCompareExchange函数作用是标记为WORK_DONE_PENDING下次直接略过

ACPI!ACPIBuildProcessGenericList函数中2次InterlockedCompareExchange函数作用是标记为WORK_DONE_PENDING下次直接略过


//
// Check to see if we have any work to do on the request
//
workDone = InterlockedCompareExchange(
&(buildRequest->WorkDone),
WORK_DONE_PENDING,
WORK_DONE_PENDING
);

//
// Look at the dispatch table to see if there is a function to
// call
//
buildFunction = DispatchTable[ workDone ];
if (buildFunction != NULL) {

//
// Just to help us along, if we are going to the failure
// path, then we should not update the Current Work Done field.
// This gives us an easy means of find which step failed
//
if (workDone != WORK_DONE_FAILURE) {

//
// Mark the node as being in the state 'workDone'
//
buildRequest->CurrentWorkDone = workDone;

}

//
// Mark the request as pending
//
workDone = InterlockedCompareExchange(
&(buildRequest->WorkDone),
WORK_DONE_PENDING,
workDone
);

//
// Call the function
//
status = (buildFunction)( buildRequest );

1: kd> bp ACPI!ACPIBuildDeviceDpc
1: kd> g
Breakpoint 34 hit
eax=00000000 ebx=f7737120 ecx=f7737988 edx=f7737980 esi=f73fc5b2 edi=f7737980
eip=f73fc5b2 esp=f78aefa0 ebp=f78aeff4 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!ACPIBuildDeviceDpc:
f73fc5b2 53 push ebx
1: kd> kc
#
00 ACPI!ACPIBuildDeviceDpc
01 nt!KiRetireDpcList
02 nt!KiDispatchInterrupt
WARNING: Frame IP not in any known module. Following frames may be wrong.
03 0x0
1: kd> dv
Dpc = 0x00000000
DpcContext = 0x00000000
SystemArgument1 = 0x00000000
SystemArgument2 = 0x804ee186


1: kd> x acpi!AcpiBuildQueueList
f743b890 ACPI!AcpiBuildQueueList = struct _LIST_ENTRY [ 0xf743b890 - 0xf743b890 ]
1: kd> dx -r1 (*((ACPI!_LIST_ENTRY *)0xf743b890))
(*((ACPI!_LIST_ENTRY *)0xf743b890)) [Type: _LIST_ENTRY]
[+0x000] Flink : 0xf743b890 [Type: _LIST_ENTRY *]
[+0x004] Blink : 0xf743b890 [Type: _LIST_ENTRY *]


1: kd> x acpi!AcpiBuildRunMethodList
f743b870 ACPI!AcpiBuildRunMethodList = struct _LIST_ENTRY [ 0x89d39ac0 - 0x89d39840 ]


1: kd> g
Breakpoint 35 hit
eax=f743b870 ebx=80afae90 ecx=f743b898 edx=f7737980 esi=f743b898 edi=f7737980
eip=f73fb8c4 esp=f78aef88 ebp=f78aeff4 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!ACPIBuildProcessGenericList:
f73fb8c4 55 push ebp
1: kd> kc
#
00 ACPI!ACPIBuildProcessGenericList
01 ACPI!ACPIBuildDeviceDpc
02 nt!KiRetireDpcList
03 nt!KiDispatchInterrupt
WARNING: Frame IP not in any known module. Following frames may be wrong.
04 0x0
1: kd> dv
ListEntry = 0xf743b870 [ 0x89d39ac0 - 0x89d39840 ]
DispatchTable = 0xf74380e8
tempEntry = 0xf73fb8c5 [ 0xec83ec8b - 0x84d8b0c ]
allWorkComplete = 0x00 ''
buildFunction = 0x00000000

1: kd> dv
ListEntry = 0xf743b870 [ 0x89d39ac0 - 0x89d39840 ]
DispatchTable = 0xf74380e8
tempEntry = 0xf73fb8c5 [ 0xec83ec8b - 0x84d8b0c ]
allWorkComplete = 0x00 ''
buildFunction = 0x00000000
1: kd> dx -r1 ((ACPI!_LIST_ENTRY *)0xf743b870)
((ACPI!_LIST_ENTRY *)0xf743b870) : 0xf743b870 [Type: _LIST_ENTRY *]
[+0x000] Flink : 0x89d39ac0 [Type: _LIST_ENTRY *]
[+0x004] Blink : 0x89d39840 [Type: _LIST_ENTRY *]
1: kd> dx -r1 ((ACPI!_LIST_ENTRY *)0x89d39ac0)
((ACPI!_LIST_ENTRY *)0x89d39ac0) : 0x89d39ac0 [Type: _LIST_ENTRY *]
[+0x000] Flink : 0x89d39a70 [Type: _LIST_ENTRY *]
[+0x004] Blink : 0xf743b870 [Type: _LIST_ENTRY *]
1: kd> dx -r1 ((ACPI!_LIST_ENTRY *)0x89d39a70)
((ACPI!_LIST_ENTRY *)0x89d39a70) : 0x89d39a70 [Type: _LIST_ENTRY *]
[+0x000] Flink : 0x89d399d0 [Type: _LIST_ENTRY *]
[+0x004] Blink : 0x89d39ac0 [Type: _LIST_ENTRY *]
1: kd> dx -r1 ((ACPI!_LIST_ENTRY *)0x89d399d0)
((ACPI!_LIST_ENTRY *)0x89d399d0) : 0x89d399d0 [Type: _LIST_ENTRY *]
[+0x000] Flink : 0x89d39980 [Type: _LIST_ENTRY *]
[+0x004] Blink : 0x89d39a70 [Type: _LIST_ENTRY *]
1: kd> dx -r1 ((ACPI!_LIST_ENTRY *)0x89d39980)
((ACPI!_LIST_ENTRY *)0x89d39980) : 0x89d39980 [Type: _LIST_ENTRY *]
[+0x000] Flink : 0x89d39930 [Type: _LIST_ENTRY *]
[+0x004] Blink : 0x89d399d0 [Type: _LIST_ENTRY *]

1: kd> dt ACPI_BUILD_REQUEST 0x89d39ac0
+0x000 ListEntry : _LIST_ENTRY [ 0x89d39a70 - 0xf743b870 ]
+0x008 Signature : 0x5f534750
+0x00c Flags : 0xc
+0x00c UFlags : __unnamed
+0x010 WorkDone : 1
+0x014 CurrentWorkDone : 3
+0x018 NextWorkDone : 4
+0x01c BuildContext : 0x89df4288 Void
+0x020 Status : 0n0
+0x024 CurrentObject : (null)
+0x028 CallBack : (null)
+0x02c CallBackContext : (null)
+0x030 DeviceRequest : __unnamed
+0x030 RunRequest : __unnamed
+0x030 SynchronizeRequest : __unnamed
+0x044 Integer : 0
+0x044 String : (null)
+0x044 TargetListEntry : (null)
1: kd> dt ACPI_BUILD_REQUEST 0x89d39a70
+0x000 ListEntry : _LIST_ENTRY [ 0x89d399d0 - 0x89d39ac0 ]
+0x008 Signature : 0x5f534750
+0x00c Flags : 0xc
+0x00c UFlags : __unnamed
+0x010 WorkDone : 1
+0x014 CurrentWorkDone : 3
+0x018 NextWorkDone : 4
+0x01c BuildContext : 0x89da2008 Void
+0x020 Status : 0n0
+0x024 CurrentObject : (null)
+0x028 CallBack : (null)
+0x02c CallBackContext : (null)
+0x030 DeviceRequest : __unnamed
+0x030 RunRequest : __unnamed
+0x030 SynchronizeRequest : __unnamed
+0x044 Integer : 0
+0x044 String : (null)
+0x044 TargetListEntry : (null)
1: kd> dt ACPI_BUILD_REQUEST 0x89d399d0
+0x000 ListEntry : _LIST_ENTRY [ 0x89d39980 - 0x89d39a70 ]
+0x008 Signature : 0x5f534750
+0x00c Flags : 0xc
+0x00c UFlags : __unnamed
+0x010 WorkDone : 1
+0x014 CurrentWorkDone : 3
+0x018 NextWorkDone : 4
+0x01c BuildContext : 0x89da2c40 Void
+0x020 Status : 0n0
+0x024 CurrentObject : (null)
+0x028 CallBack : (null)
+0x02c CallBackContext : (null)
+0x030 DeviceRequest : __unnamed
+0x030 RunRequest : __unnamed
+0x030 SynchronizeRequest : __unnamed
+0x044 Integer : 0
+0x044 String : (null)
+0x044 TargetListEntry : (null)


1: kd> dt ACPI_BUILD_REQUEST 0x89d39980
+0x000 ListEntry : _LIST_ENTRY [ 0x89d39930 - 0x89d399d0 ]
+0x008 Signature : 0x5f534750
+0x00c Flags : 0xc
+0x00c UFlags : __unnamed
+0x010 WorkDone : 1
+0x014 CurrentWorkDone : 5
+0x018 NextWorkDone : 2
+0x01c BuildContext : 0x89dea908 Void
+0x020 Status : 0n0
+0x024 CurrentObject : (null)
+0x028 CallBack : (null)
+0x02c CallBackContext : (null)
+0x030 DeviceRequest : __unnamed
+0x030 RunRequest : __unnamed
+0x030 SynchronizeRequest : __unnamed
+0x044 Integer : 0xf
+0x044 String : 0x0000000f "--- memory read error at address 0x0000000f ---"
+0x044 TargetListEntry : 0x0000000f _LIST_ENTRY


1: kd> dx -r1 (*((ACPI!_LIST_ENTRY *)0xf743b870))
(*((ACPI!_LIST_ENTRY *)0xf743b870)) [Type: _LIST_ENTRY]
[+0x000] Flink : 0x89d39ac0 [Type: _LIST_ENTRY *]
[+0x004] Blink : 0x89d39840 [Type: _LIST_ENTRY *]
1: kd> dx -r1 ((ACPI!_LIST_ENTRY *)0x89d39ac0)
((ACPI!_LIST_ENTRY *)0x89d39ac0) : 0x89d39ac0 [Type: _LIST_ENTRY *]
[+0x000] Flink : 0x89d39a70 [Type: _LIST_ENTRY *]
[+0x004] Blink : 0xf743b870 [Type: _LIST_ENTRY *]
1: kd> dx -r1 ((ACPI!_LIST_ENTRY *)0x89d39a70)
((ACPI!_LIST_ENTRY *)0x89d39a70) : 0x89d39a70 [Type: _LIST_ENTRY *]
[+0x000] Flink : 0x89d399d0 [Type: _LIST_ENTRY *]
[+0x004] Blink : 0x89d39ac0 [Type: _LIST_ENTRY *]
1: kd> dx -r1 ((ACPI!_LIST_ENTRY *)0x89d399d0)
((ACPI!_LIST_ENTRY *)0x89d399d0) : 0x89d399d0 [Type: _LIST_ENTRY *]
[+0x000] Flink : 0x89d39930 [Type: _LIST_ENTRY *]
[+0x004] Blink : 0x89d39a70 [Type: _LIST_ENTRY *]
1: kd> dx -r1 ((ACPI!_LIST_ENTRY *)0x89d39930)
((ACPI!_LIST_ENTRY *)0x89d39930) : 0x89d39930 [Type: _LIST_ENTRY *]
[+0x000] Flink : 0x89d398e0 [Type: _LIST_ENTRY *]
[+0x004] Blink : 0x89d399d0 [Type: _LIST_ENTRY *]
1: kd> dx -r1 ((ACPI!_LIST_ENTRY *)0x89d398e0)
((ACPI!_LIST_ENTRY *)0x89d398e0) : 0x89d398e0 [Type: _LIST_ENTRY *]
[+0x000] Flink : 0x89d39890 [Type: _LIST_ENTRY *]
[+0x004] Blink : 0x89d39930 [Type: _LIST_ENTRY *]
1: kd> dx -r1 ((ACPI!_LIST_ENTRY *)0x89d39890)
((ACPI!_LIST_ENTRY *)0x89d39890) : 0x89d39890 [Type: _LIST_ENTRY *]
[+0x000] Flink : 0x89d396b0 [Type: _LIST_ENTRY *]
[+0x004] Blink : 0x89d398e0 [Type: _LIST_ENTRY *]


1: kd> g
Breakpoint 37 hit
eax=00000001 ebx=89d39940 ecx=00000000 edx=00000001 esi=89d398e0 edi=80b019f4
eip=f73fb8e1 esp=f78aef6c ebp=f78aef84 iopl=0 nv up ei ng nz na po cy
cs=0008 ss=0010 ds=0023 es=0023 fs=0030 gs=0000 efl=00000283
ACPI!ACPIBuildProcessGenericList+0x1d:
f73fb8e1 8b06 mov eax,dword ptr [esi] ds:0023:89d398e0=89d39890
1: kd> dt ACPI_BUILD_REQUEST 89d398e0
+0x000 ListEntry : _LIST_ENTRY [ 0x89d39890 - 0x89d39930 ]
+0x008 Signature : 0x5f534750
+0x00c Flags : 0xc
+0x00c UFlags : __unnamed
+0x010 WorkDone : 4
+0x014 CurrentWorkDone : 3
+0x018 NextWorkDone : 2
+0x01c BuildContext : 0x89d41a28 Void
+0x020 Status : 0n0
+0x024 CurrentObject : (null)
+0x028 CallBack : (null)
+0x02c CallBackContext : (null)
+0x030 DeviceRequest : __unnamed
+0x030 RunRequest : __unnamed
+0x030 SynchronizeRequest : __unnamed
+0x044 Integer : 0
+0x044 String : (null)
+0x044 TargetListEntry : (null)


ACPI_BUILD_REQUEST结构中的WorkDone什么时候变成4的?

VOID EXPORT
ACPIBuildCompleteMustSucceed(
IN PNSOBJ AcpiObject,
IN NTSTATUS Status,
IN POBJDATA ObjectData,
IN PVOID Context
)
/*++

Routine Description:

This is a generic completion handler. If the interperter has successfully
execute the method, it completes the request to the next desired WORK_DONE,
otherwise, it fails the request

Arguments:

AcpiObject - Points to the control that was run
Status - Result of the method
ObjectData - Information about the result
Context - PACPI_BUILD_REQUEST

Return Value:

VOID

--*/
{
PACPI_BUILD_REQUEST buildRequest = (PACPI_BUILD_REQUEST) Context;
ULONG nextWorkDone = buildRequest->NextWorkDone;

//
// Device what state we should transition to next
//
if (!NT_SUCCESS(Status)) {

//
// Remember why we failed, and mark the request as being failed
//
buildRequest->Status = Status;

//
// Death
//
KeBugCheckEx(
ACPI_BIOS_ERROR,
ACPI_FAILED_MUST_SUCCEED_METHOD,
(ULONG_PTR) AcpiObject,
Status,
(AcpiObject ? AcpiObject->dwNameSeg : 0)
);

} else {

//
// Note: we don't have a race condition here because only one
// routine can be processing a request at any given time. Thus it
// is safe for us to specify a new next phase
//
buildRequest->NextWorkDone = WORK_DONE_FAILURE;

//
// Transition to the next stage
//
ACPIBuildCompleteCommon(
&(buildRequest->WorkDone),
nextWorkDone
);

}

}


VOID
ACPIBuildCompleteCommon(
IN PULONG OldWorkDone,
IN ULONG NewWorkDone
)
/*++

Routine Description:

Since the completion routines all have to do some bit of common work to
get the DPC firing again, this routine reduces the code duplication

Arguments:

OldWorkDone - Pointer to the old amount of work done
NewWorkDone - The new amount of work that has been completed

NOTENOTE: There is an implicit assumption that the current value of
WorkDone in the request is WORK_DONE_PENDING. If that is
not the case, we will fail to transition to the next stage,
which means that we will loop forever.

Return Value:

None

--*/
{
KIRQL oldIrql;

//
// Update the state of the request
//
InterlockedCompareExchange( OldWorkDone, NewWorkDone,WORK_DONE_PENDING);//这个时候buildRequest->WorkDone变成了4

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

论文写作“变形记”:书匠策AI如何重塑本科生的学术战场

在学术江湖里,本科论文写作常被视为“新手村”的第一场BOSS战——选题撞车、文献迷航、逻辑混乱、格式翻车……这些痛点像无形的枷锁,困住了无数怀揣学术梦想的年轻人。但如今,一款名为书匠策AI的智能工具正以“学术变形金刚”的姿态&#xf…

作者头像 李华
网站建设 2026/6/10 9:48:09

FastJson2 与 SnackJson4 有什么区别?

在 Java 圈子里,提起 JSON 处理,大部分人的第一反应是 Jackson 或者 FastJson。但随着技术演进,FastJson2(阿里迭代之作)和 SnackJson4(后起之秀,Solon 框架核心组件)成为了很多架构…

作者头像 李华
网站建设 2026/6/10 9:51:18

Wireshark/Tcpdump:网络协议层分析

第一部分:开篇明义 —— 定义、价值与目标 定位与价值 在网络空间这座无形的城市里,数据包是川流不息的车辆,承载着信息、指令与财富。作为网络安全从业者,我们不仅是交通规则的制定者,更是事故现场的调查员、犯罪行为…

作者头像 李华
网站建设 2026/6/10 9:51:12

深度解析:Linux 下 TCP 服务端编程核心实现

在网络编程中,构建一个稳定、高效的 TCP 服务器是所有进阶开发者的必修课。本文将根据 Linux 环境下的 Socket 编程规范,手把手带你实现一个经典的回显服务器(Echo Server)。 一、 TCP 服务端开发的“七步走”流程 编写一个 TCP 服务端程序,通常遵循以下严格的逻辑顺序:…

作者头像 李华
网站建设 2026/6/10 9:54:00

吐血推荐!继续教育AI论文工具TOP9:写论文不再难

吐血推荐!继续教育AI论文工具TOP9:写论文不再难 2026年继续教育AI论文工具测评:为何值得关注? 在当前快节奏的学术环境中,尤其是针对继续教育群体,撰写高质量论文已成为一项挑战。从选题构思到文献综述&…

作者头像 李华