news 2026/1/18 8:52:51

HalEndSystemInterrupt为什么能调用KiDispatchInterrupt因为HalRequestSoftwareInterrupt设置PCR[PcHal.DpcPending]为1

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
HalEndSystemInterrupt为什么能调用KiDispatchInterrupt因为HalRequestSoftwareInterrupt设置PCR[PcHal.DpcPending]为1

hal!HalEndSystemInterrupt函数为什么能调用nt!KiDispatchInterrupt函数因为hal!HalRequestSoftwareInterrupt最后设置PCR[PcHal.DpcPending]为1

第一部分:

HeiNewIrql equ [esp + 4]
HeiVector equ [esp + 8]

cPublicProc _HalEndSystemInterrupt ,2
cPublicFpo 2, 0
xor ecx,ecx
mov cl, byte ptr HeiNewIrql ; get new IRQL
mov cl, _HalpIRQLtoTPR[ecx] ; get corresponding TPR value

mov dword ptr APIC[LU_EOI], 0 ; send EOI to APIC local unit
APICFIX edx

cmp cl, DPC_VECTOR ; Is new irql < DPC?
jc short es10 ; Yes, go check for pending DPC

es05: mov dword ptr APIC[LU_TPR], ecx ; Set new Priority

;
; We have to ensure that the requested priority is set before
; we return. The caller is counting on it.
;
mov edx, dword ptr APIC[LU_TPR]
CHECKTPR ecx, edx
stdRET _HalEndSystemInterrupt

es10: cmp PCR[PcHal.DpcPending], 0 ; Is a DPC pending?
mov PCR[PcHal.ShortDpc], 0 ; Clear short dpc flag
jz short es05 ; No, eoi

mov dword ptr APIC[LU_TPR], DPC_VECTOR ; lower to DPC level
APICFIX edx

push ebx ; Save EBX (used by KiDispatchInterrupt)
push ecx ; Save OldIrql
cPublicFpo 2, 2

sti

es20: mov PCR[PcHal.DpcPending], 0 ; Clear pending flag

stdCall _KiDispatchInterrupt ; Dispatch interrupt //这里调用了_KiDispatchInterrupt

cli

pop ecx
pop ebx
jmp short es05

stdENDP _HalEndSystemInterrupt

第二部分:

F:\srv03rtm>grep "DpcPending" -nr F:\srv03rtm\base\hals |grep -v "inary"
F:\srv03rtm\base\hals/halmps/i386/mpswint.asm:132:; DpcPending flag - whomever set ShortDpc will check the flag
F:\srv03rtm\base\hals/halmps/i386/mpswint.asm:136:rsi10: mov PCR[PcHal.DpcPending], 1
F:\srv03rtm\base\hals/halmps/i386/mpsysint.asm:121:es10: cmp PCR[PcHal.DpcPending], 0 ; Is a DPC pending?
F:\srv03rtm\base\hals/halmps/i386/mpsysint.asm:134:es20: mov PCR[PcHal.DpcPending], 0 ; Clear pending flag

参考:

cPublicFastCall HalRequestSoftwareInterrupt ,1
cPublicFpo 0,0

cmp cl, PCR[PcHal.ShortDpc]
je short rsi10

xor eax, eax
mov al, cl ; get irql

;
; In an APIC based system the TPR is the IDTEntry
;

xor ecx, ecx
mov cl, _HalpIRQLtoTPR[eax] ; get IDTEntry for IRQL

;
; Build the ICR Command - Fixed Delivery to Self, IDTEntry == al
;

or ecx, (DELIVER_FIXED OR ICR_SELF)

;
; Make sure the ICR is available
;

pushfd ; save interrupt mode
cli ; disable interrupt
STALL_WHILE_APIC_BUSY

;
; Now write the command to the Memory Mapped Register
;

mov dword ptr APIC[LU_INT_CMD_LOW], ecx

;
; We have to wait for the request to be delivered.
; If we don't wait here, then we will return to the caller
; before the request has been issued.
;
STALL_WHILE_APIC_BUSY

popfd ; restore original interrupt mode
fstRET HalRequestSoftwareInterrupt

;
; Requesting a DPC interrupt when ShortDpc is set. Just set the
; DpcPending flag - whomever set ShortDpc will check the flag
; at the proper time
;

rsi10: mov PCR[PcHal.DpcPending], 1这里!!!
fstRET HalRequestSoftwareInterrupt

参考:

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

终极指南:如何轻松将NTFS转换为Btrfs文件系统

终极指南&#xff1a;如何轻松将NTFS转换为Btrfs文件系统 【免费下载链接】ntfs2btrfs 项目地址: https://gitcode.com/gh_mirrors/nt/ntfs2btrfs 想要在Linux系统上享受Btrfs文件系统的强大功能&#xff0c;却担心数据迁移的麻烦&#xff1f;ntfs2btrfs正是你需要的解…

作者头像 李华
网站建设 2026/1/7 2:16:10

气象AI模型更新困局破解(20年专家实战经验倾囊相授)

第一章&#xff1a;气象AI模型更新困局破解综述气象AI模型在实际业务中面临频繁的数据漂移、计算资源紧张以及模型再训练延迟等问题&#xff0c;导致预测精度随时间推移显著下降。传统全量重训策略不仅耗时耗力&#xff0c;且难以满足实时性要求。为此&#xff0c;亟需构建一套…

作者头像 李华
网站建设 2025/12/29 18:01:53

为什么顶尖医院纷纷引入医疗影像Agent?真相令人震惊

第一章&#xff1a;医疗影像Agent辅助诊断的兴起背景近年来&#xff0c;随着人工智能技术的飞速发展&#xff0c;医疗影像领域正经历一场深刻的变革。传统的医学影像诊断高度依赖放射科医生的经验与判断&#xff0c;面临工作负荷重、误诊漏诊风险高等挑战。在此背景下&#xff…

作者头像 李华
网站建设 2025/12/29 18:01:51

FanControl终极指南:10分钟打造完美显卡散热系统

FanControl终极指南&#xff1a;10分钟打造完美显卡散热系统 【免费下载链接】FanControl.Releases This is the release repository for Fan Control, a highly customizable fan controlling software for Windows. 项目地址: https://gitcode.com/GitHub_Trending/fa/FanC…

作者头像 李华
网站建设 2026/1/3 2:05:00

Golang Word文档自动化处理完全指南:从零到精通的终极方案

Golang Word文档自动化处理完全指南&#xff1a;从零到精通的终极方案 【免费下载链接】docx Simple Google Go (Golang) library for replacing text in Microsoft Word (.docx) file 项目地址: https://gitcode.com/gh_mirrors/docx/docx 在现代企业级应用开发中&…

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

负荷突变难掌控?Agent协同预测模型让电力调度提前72小时预警

第一章&#xff1a;负荷突变难掌控&#xff1f;Agent协同预测模型让电力调度提前72小时预警在现代电网运行中&#xff0c;电力负荷的突发性波动常导致调度滞后、设备过载甚至区域停电。传统预测模型依赖历史数据线性外推&#xff0c;难以捕捉极端天气、突发事件或大规模用电行为…

作者头像 李华