news 2026/3/20 2:57:54

nt!KiInsertQueueApc函数中的KiRequestApcInterrupt到hal!HalRequestSoftwareInterrupt

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
nt!KiInsertQueueApc函数中的KiRequestApcInterrupt到hal!HalRequestSoftwareInterrupt

nt!KiInsertQueueApc函数中的KiRequestApcInterrupt到hal!HalRequestSoftwareInterrupt

第一部分:

VOID
FASTCALL
KiInsertQueueApc (
IN PKAPC InApc,
IN KPRIORITY Increment
)
{

if (ApcMode == KernelMode) {

//
// Thread transitions from the standby state to the running
// state can occur from the idle thread without holding the
// dispatcher lock. Reading the thread state after setting
// the kernel APC pending flag prevents the code from not
// delivering the APC interrupt in this case.
//

ASSERT((Thread != KeGetCurrentThread()) || (Thread->State == Running));

KeMemoryBarrier();
Thread->ApcState.KernelApcPending = TRUE;
KeMemoryBarrier();
ThreadState = Thread->State;
if (ThreadState == Running) {
KiRequestApcInterrupt(Thread->NextProcessor);

} else if ((ThreadState == Waiting) &&
(Thread->WaitIrql == 0) &&
(Thread->SpecialApcDisable == 0) &&
((Apc->NormalRoutine == NULL) ||
((Thread->KernelApcDisable == 0) &&
(Thread->ApcState.KernelApcInProgress == FALSE)))) {

KiUnwaitThread(Thread, STATUS_KERNEL_APC, Increment);
}


第二部分:


#if defined(NT_UP)

#define KiRequestApcInterrupt(Processor) KiRequestSoftwareInterrupt(APC_LEVEL)

#else

#define KiRequestApcInterrupt(Processor) \
if (KeGetCurrentProcessorNumber() == Processor) { \
KiRequestSoftwareInterrupt(APC_LEVEL); \
} else { \
KiIpiSend(AFFINITY_MASK(Processor), IPI_APC); \
}

#endif


第三部分:

1: kd> kc
#
00 hal!HalRequestSoftwareInterrupt
01 nt!KiInsertQueueApc
02 nt!KeInsertQueueApc
03 nt!IopCompleteRequest
04 nt!IopSynchronousServiceTail
05 nt!NtReadFile
06 nt!_KiSystemService
07 nt!ZwReadFile
08 win32k!StartDeviceRead
09 win32k!InputApc
0a nt!KiDeliverApc
0b nt!KiSwapThread
0c nt!KeWaitForMultipleObjects
0d win32k!xxxMsgWaitForMultipleObjects
0e win32k!xxxDesktopThread
0f win32k!xxxCreateSystemThreads
10 win32k!NtUserCallOneParam
11 nt!_KiSystemService
12 SharedUserData!SystemCallStub
13 winsrv!NtUserCallOneParam
1: kd> kv
# ChildEBP RetAddr Args to Child
00 f75f6698 80a3cbd6 8957da28 8989e048 00000000 hal!HalRequestSoftwareInterrupt (FPO: [0,0,0]) [d:\srv03rtm\base\hals\halmps\i386\mpswint.asm @ 84]
01 f75f66b8 80a3758e 8989e048 8989e008 00000000 nt!KiInsertQueueApc+0x13e (FPO: [Non-Fpo]) (CONV: fastcall) [d:\srv03rtm\base\ntos\ke\apcsup.c @ 578]
02 f75f66d4 80a2c076 8989e048 e163d238 00000000 nt!KeInsertQueueApc+0x80 (FPO: [Non-Fpo]) (CONV: stdcall) [d:\srv03rtm\base\ntos\ke\apcobj.c @ 302]
03 f75f6730 80c70c45 8989e048 f75f6778 f75f6770 nt!IopCompleteRequest+0x368 (FPO: [Non-Fpo]) (CONV: stdcall) [d:\srv03rtm\base\ntos\io\iomgr\internal.c @ 1476]
04 f75f675c 80c6c1a2 894156b0 00000000 8957da28 nt!IopSynchronousServiceTail+0x1b1 (FPO: [Non-Fpo]) (CONV: stdcall) [d:\srv03rtm\base\ntos\io\iomgr\internal.c @ 7409]
05 f75f67f4 80afbcb2 00000224 00000000 bf8e7891 nt!NtReadFile+0x6be (FPO: [Non-Fpo]) (CONV: stdcall) [d:\srv03rtm\base\ntos\io\iomgr\read.c @ 734]
06 f75f67f4 80a3ddd5 00000224 00000000 bf8e7891 nt!_KiSystemService+0x13f (FPO: [0,3] TrapFrame @ f75f682c) (CONV: cdecl) [d:\srv03rtm\base\ntos\ke\i386\trap.asm @ 1328]
07 f75f689c bf8fc2db 00000224 00000000 bf8e7891 nt!ZwReadFile+0x11 (FPO: [9,0,0]) [d:\srv03rtm\base\ntos\ke\mp\obj\i386\sysstubs.asm @ 1651]
08 f75f68d8 bf8e796d 000000f0 89804020 8989e048 win32k!StartDeviceRead+0x270 (FPO: [Non-Fpo]) (CONV: stdcall) [d:\srv03rtm\windows\core\ntuser\kernel\pnp.c @ 1827]
09 f75f68f0 80a3c8d4 e163d210 e163d238 00000000 win32k!InputApc+0xdc (FPO: [Non-Fpo]) (CONV: stdcall) [d:\srv03rtm\windows\core\ntuser\kernel\ntinput.c @ 2084]
0a f75f6938 80a44106 00000000 00000000 00000000 nt!KiDeliverApc+0x15e (FPO: [Non-Fpo]) (CONV: stdcall) [d:\srv03rtm\base\ntos\ke\apcsup.c @ 337]
0b f75f697c 80a358c7 00000000 e1639460 00000002 nt!KiSwapThread+0x642 (FPO: [Non-Fpo]) (CONV: fastcall) [d:\srv03rtm\base\ntos\ke\thredsup.c @ 2004]
0c f75f69b4 bf8a4685 00000003 89804b50 00000001 nt!KeWaitForMultipleObjects+0x3b5 (FPO: [Non-Fpo]) (CONV: stdcall) [d:\srv03rtm\base\ntos\ke\wait.c @ 816]
0d f75f6a04 bf8b123e 00000002 89804b50 bf8fe215 win32k!xxxMsgWaitForMultipleObjects+0xeb (FPO: [Non-Fpo]) (CONV: stdcall) [d:\srv03rtm\windows\core\ntuser\kernel\queue.c @ 4540]
0e f75f6d1c bf8b21ba bfa70aa0 00000001 f75f6d48 win32k!xxxDesktopThread+0x437 (FPO: [Non-Fpo]) (CONV: stdcall) [d:\srv03rtm\windows\core\ntuser\kernel\desktop.c @ 594]
0f f75f6d2c bf806d52 bfa70aa0 f75f6d58 008cfff4 win32k!xxxCreateSystemThreads+0x9c (FPO: [Non-Fpo]) (CONV: stdcall) [d:\srv03rtm\windows\core\ntuser\kernel\desktop.c @ 347]
10 f75f6d48 80afbcb2 00000000 00000022 80afb956 win32k!NtUserCallOneParam+0xa0 (FPO: [Non-Fpo]) (CONV: stdcall) [d:\srv03rtm\windows\core\ntuser\kernel\ntstubs.c @ 4789]
11 f75f6d48 7ffe0304 00000000 00000022 80afb956 nt!_KiSystemService+0x13f (FPO: [0,3] TrapFrame @ f75f6d64) (CONV: cdecl) [d:\srv03rtm\base\ntos\ke\i386\trap.asm @ 1328]
12 008cffe0 75340774 75318a89 00000000 00000022 SharedUserData!SystemCallStub+0x4 (FPO: [0,0,0])
13 008cffe8 00000000 00000022 00000004 00000000 winsrv!NtUserCallOneParam+0xc (FPO: [Non-Fpo]) (CONV: stdcall) [d:\srv03rtm\windows\core\umode\daytona\obj\i386\usrstubs.c @ 2683]

第四部分:

1: kd> g
Breakpoint 50 hit
eax=00000000 ebx=00000000 ecx=00000000 edx=00000000 esi=8989e008 edi=00000103
eip=804ee7d8 esp=f75f673c ebp=f75f675c iopl=0 nv up di pl zr na pe nc
cs=0008 ss=0010 ds=0023 es=0023 fs=0030 gs=0000 efl=00000046
hal!HalpApcInterrupt:
804ee7d8 54 push esp
1: kd> kc
#
00 hal!HalpApcInterrupt
WARNING: Frame IP not in any known module. Following frames may be wrong.
01 0x0
02 0x0

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

重工业、轻工业和复杂装备行业的设备维护策略制定:目标、策略、实施框架和工具等的差异

在工业生产领域,不同类型的设备和系统因其运行模式、价值、复杂性和在生产流程中的关键性不同,对维护目标的选择和优先级排序有着显著差异。将统一的维护策略应用于所有设备,不仅效率低下,而且可能导致资源错配和潜在风险的忽视。因此,根据设备的具体特性,量体裁衣地选择…

作者头像 李华
网站建设 2026/3/15 0:55:58

医疗健康领域应用:Linly-Talker构建智能导诊数字人

Linly-Talker:构建医疗智能导诊数字人的全栈实践 在智慧医院建设提速的今天,患者一进门诊大厅就面对长长的导诊队伍、重复的问题被问了一遍又一遍,而导医人员却疲于应付基础咨询——这样的场景正逐渐成为过去式。越来越多的医疗机构开始探索用…

作者头像 李华
网站建设 2026/3/19 16:13:27

索尼腾讯握手言和:侵权官司收场,合作再升级!

近日,备受业界关注的索尼诉腾讯游戏侵权案终于迎来尾声。双方在法院调解下达成保密和解,正式“握手言和”,并宣布将在多个项目上继续深化合作。此事不仅结束了长达半年的法律拉锯,也为中日两大游戏巨头在全球市场的协同打开了新局…

作者头像 李华
网站建设 2026/3/16 22:39:14

Linly-Talker表情驱动揭秘:情感化数字人的关键技术突破

Linly-Talker表情驱动揭秘:情感化数字人的关键技术突破 在虚拟主播直播间里,一个面容亲切的数字人正微笑着回答观众提问,她的口型与语音完美同步,说到动情处眼神闪烁、眉头轻扬,仿佛真有情绪流动。这不是电影特效&…

作者头像 李华
网站建设 2026/3/14 3:33:27

一阶低通数字滤波器定点补偿算法C语言函数探秘

一阶低通数字滤波器定点补偿算法C语言函数 这函数可以实现一阶低通数字滤波器定点运算结果和浮点结果完美对应,不会出现精度损失问题。在数字信号处理的世界里,一阶低通数字滤波器是个常见且实用的工具。但传统的定点运算,很容易出现精度损失…

作者头像 李华