news 2026/4/23 21:51:58

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/4/23 13:26:07

警惕!伪装ChatGPT提示传播MacStealer恶意软件的新型攻击手法

网络攻击警告:MacStealer恶意软件通过虚假ChatGPT提示传播 安全研究人员发现,攻击者正在利用ChatGPT诱骗Mac用户将命令行粘贴到终端中,从而安装恶意软件。具体而言,它会安装MacStealer,这款恶意软件能让攻击者获取受害…

作者头像 李华
网站建设 2026/4/15 13:10:41

学术探险家的秘密武器:书匠策AI如何改写本科论文写作规则

对于许多本科生而言,论文写作是一场“孤军奋战”的冒险——选题撞车、文献迷航、逻辑混乱、语言生硬……这些问题像无形的迷雾,让学术小白困在“新手村”。但如今,一款名为书匠策AI的智能工具正以“学术探险装备库”的姿态,将论文…

作者头像 李华
网站建设 2026/4/23 3:36:59

leetcode 3047

3047: 求交集区域内的最大正方形面积bottomLeft[i] 和 topRight[i] 分别代表第 i 个矩形的 左下角 和 右上角 坐标。如果两个矩形有交集,那么交集也是矩形。求出这个交集矩形的左下角和右上角,就可以算出交集矩形的长和宽。左下角横坐标:两个…

作者头像 李华
网站建设 2026/4/23 17:48:00

学长亲荐10个AI论文写作软件,MBA毕业论文轻松搞定!

学长亲荐10个AI论文写作软件,MBA毕业论文轻松搞定! AI工具如何改变论文写作的未来 在当今快节奏的学术环境中,MBA学生面临着前所未有的挑战。从选题到撰写,再到反复修改,每一个环节都需要大量的时间和精力。而随着AI技…

作者头像 李华