news 2026/4/7 18:39:54

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/3/31 17:28:52

物流仓储Agent效率突飞猛进:基于强化学习的动态分拣策略全披露

第一章&#xff1a;物流仓储 Agent 的分拣效率 在现代物流系统中&#xff0c;仓储 Agent 作为自动化分拣的核心组件&#xff0c;其效率直接影响整体运营表现。通过智能调度与路径优化&#xff0c;Agent 能够在复杂仓库环境中快速定位货品并完成搬运任务&#xff0c;显著降低人工…

作者头像 李华
网站建设 2026/3/30 1:20:42

如何快速掌握文件差异对比:Diff Checker 完整使用指南

如何快速掌握文件差异对比&#xff1a;Diff Checker 完整使用指南 【免费下载链接】diff-checker Desktop application to compare text differences between two files (Windows, Mac, Linux) 项目地址: https://gitcode.com/gh_mirrors/di/diff-checker 在编程开发、文…

作者头像 李华
网站建设 2026/4/7 8:05:23

36、Linux 命令行实用技巧与高级特性

Linux 命令行实用技巧与高级特性 1. 信号处理与陷阱(Traps) 在编写脚本时,尤其是大型复杂脚本,需要考虑用户在脚本运行过程中注销或关机的情况。此时,系统会向受影响的进程发送信号,脚本应能做出相应处理,以确保程序正常有序终止。 1.1 陷阱机制 Bash 提供了 trap …

作者头像 李华
网站建设 2026/4/3 14:15:04

【行业机密曝光】:头部物流企业Agent分拣效率领先同行2倍的底层逻辑

第一章&#xff1a;头部物流企业Agent分拣效率领先同行2倍的底层逻辑在物流行业高度竞争的今天&#xff0c;头部企业通过智能Agent系统实现了分拣效率的跨越式提升&#xff0c;其核心并非单一技术突破&#xff0c;而是多维度系统工程的协同优化。这些企业将人工智能、边缘计算与…

作者头像 李华
网站建设 2026/4/5 17:41:58

【金融 AI Agent 安全加固】:6大验证机制详解与落地实践

第一章&#xff1a;金融 AI Agent 安全验证概述在金融领域&#xff0c;AI Agent 被广泛应用于自动化交易、风险评估、客户服务和欺诈检测等关键场景。随着其决策影响力日益增强&#xff0c;确保这些智能体的行为安全、合规且可解释&#xff0c;成为系统设计中的核心议题。安全验…

作者头像 李华
网站建设 2026/3/27 18:05:06

flv怎么转换成m2ts?flv格式转m2ts格式操作技巧

M2TS是一种常用于高清视频存储的专业格式&#xff0c;广泛应用于蓝光光盘和高端摄像设备。将FLV转换为M2TS格式可以有效提升视频的兼容性和画质表现&#xff0c;特别适合需要高质量视频输出的场景。以下是使用简鹿视频格式转换器完成转换的具体步骤&#xff1a; 1.首先在电脑上…

作者头像 李华