news 2026/4/18 13:27:35

hal!HalEndSystemInterrupt函数分析之汇编代码和调试分析

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
hal!HalEndSystemInterrupt函数分析之汇编代码和调试分析

hal!HalEndSystemInterrupt函数分析之汇编代码和调试分析

LOCALAPIC equ 0fffe0000h
APIC equ ds:[LOCALAPIC]
LU_EOI equ 000000B0H ;


第一部分:

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

cli

pop ecx
pop ebx
jmp short es05

stdENDP _HalEndSystemInterrupt

第二部分:

0: kd> g
Breakpoint 21 hit
eax=0002625a ebx=00000000 ecx=80b18af8 edx=00000349 esi=80affb51 edi=80b00720
eip=804ee8d0 esp=f78cdee8 ebp=f78cdef4 iopl=0 nv up di pl nz na pe nc
cs=0008 ss=0010 ds=0023 es=0023 fs=0030 gs=0000 efl=00000006
hal!HalEndSystemInterrupt:
804ee8d0 33c9 xor ecx,ecx

0: kd> kc 3
#
00 hal!HalEndSystemInterrupt
01 nt!KeUpdateSystemTime
02 nt!KiDispatchInterrupt
0: kd> !irql
Debugger saved IRQL for processor 0x0 -- 29 (IPI_LEVEL)
0: kd> p
eax=0002625a ebx=00000000 ecx=00000000 edx=00000349 esi=80affb51 edi=80b00720
eip=804ee8d2 esp=f78cdee8 ebp=f78cdef4 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!HalEndSystemInterrupt+0x2:
804ee8d2 8a4c2404 mov cl,byte ptr [esp+4] ss:0010:f78cdeec=02
0: kd> p
eax=0002625a ebx=00000000 ecx=00000002 edx=00000349 esi=80affb51 edi=80b00720
eip=804ee8d6 esp=f78cdee8 ebp=f78cdef4 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!HalEndSystemInterrupt+0x6:
804ee8d6 8a89b8db4e80 mov cl,byte ptr hal!HalpIRQLtoTPR (804edbb8)[ecx] ds:0023:804edbba=41
0: kd> p
eax=8949c5d8 ebx=b9e46854 ecx=8948b5a8 edx=e14b45a0 esi=b9e46864 edi=f7142e24
eip=804ee934 esp=b9e465dc ebp=b9e465f4 iopl=0 nv up di ng nz ac po nc
cs=0008 ss=0010 ds=0023 es=0023 fs=0030 gs=0000 efl=00000092
hal!HalBeginSystemInterrupt:
804ee934 33c0 xor eax,eax

1: kd> g
Single step exception - code 80000004 (first chance)
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.
eax=0002625a ebx=00000000 ecx=00000041 edx=00000349 esi=80affb51 edi=80b00720
eip=804ee8dc esp=f78cdee8 ebp=f78cdef4 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!HalEndSystemInterrupt+0xc:
804ee8dc c705b000feff00000000mov dword ptr ds:[0FFFE00B0h],0ds:0023:fffe00b0=00000000
0: kd> p
eax=0002625a ebx=00000000 ecx=00000041 edx=00000349 esi=80affb51 edi=80b00720
eip=804ee8e6 esp=f78cdee8 ebp=f78cdef4 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!HalEndSystemInterrupt+0x16:
804ee8e6 80f941 cmp cl,41h
0: kd> p
eax=0002625a ebx=00000000 ecx=00000041 edx=00000349 esi=80affb51 edi=80b00720
eip=804ee8e9 esp=f78cdee8 ebp=f78cdef4 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!HalEndSystemInterrupt+0x19:
804ee8e9 7214 jb hal!HalEndSystemInterrupt+0x2f (804ee8ff) [br=0]
0: kd> p
eax=0002625a ebx=00000000 ecx=00000041 edx=00000349 esi=80affb51 edi=80b00720
eip=804ee8eb esp=f78cdee8 ebp=f78cdef4 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!HalEndSystemInterrupt+0x1b:
804ee8eb 890d8000feff mov dword ptr ds:[0FFFE0080h],ecx ds:0023:fffe0080=000000ff
0: kd> p
eax=0002625a ebx=00000000 ecx=00000041 edx=00000349 esi=80affb51 edi=80b00720
eip=804ee8f1 esp=f78cdee8 ebp=f78cdef4 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!HalEndSystemInterrupt+0x21:
804ee8f1 8b158000feff mov edx,dword ptr ds:[0FFFE0080h] ds:0023:fffe0080=000000ff
0: kd> p
eax=0002625a ebx=00000000 ecx=00000041 edx=00000041 esi=80affb51 edi=80b00720
eip=804ee8f7 esp=f78cdee8 ebp=f78cdef4 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!HalEndSystemInterrupt+0x27:
804ee8f7 3bca cmp ecx,edx
0: kd> p
eax=0002625a ebx=00000000 ecx=00000041 edx=00000041 esi=80affb51 edi=80b00720
eip=804ee8fc esp=f78cdee8 ebp=f78cdef4 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!HalEndSystemInterrupt+0x2c:
804ee8fc c20800 ret 8
0: kd> p
Breakpoint 23 hit
eax=0002625a ebx=00000000 ecx=00000041 edx=00000041 esi=80affb51 edi=80b00720
eip=80affb5d esp=f78cdef4 ebp=f78cdef4 iopl=0 nv up di pl zr na pe nc
cs=0008 ss=0010 ds=0023 es=0023 fs=0030 gs=0000 efl=00000046
nt!KeUpdateSystemTime+0x135:
80affb5d e926cbffff jmp nt!KiExceptionExit (80afc688)
0: kd> !irql
Debugger saved IRQL for processor 0x0 -- 2 (DISPATCH_LEVEL)

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

FlutterOpenHarmony侧边栏抽屉组件开发

前言 侧边栏抽屉是移动应用中常见的导航模式&#xff0c;它将次要的导航选项和功能入口收纳在屏幕侧边&#xff0c;用户可以通过滑动或点击按钮来展开。在笔记应用中&#xff0c;侧边栏通常用于展示文件夹列表、标签分类、设置入口等内容。本文将详细介绍如何在Flutter和OpenHa…

作者头像 李华
网站建设 2026/4/18 8:25:36

FlutterOpenHarmony弹窗与对话框组件

前言 弹窗和对话框是应用中与用户进行交互的重要方式&#xff0c;它们用于显示提示信息、确认操作、收集用户输入等场景。在笔记应用中&#xff0c;删除确认、保存提示、表单输入等功能都需要使用弹窗组件。一个设计良好的弹窗应该清晰传达信息、提供明确的操作选项&#xff0c…

作者头像 李华
网站建设 2026/4/18 3:00:02

【数据科学必备技能】:用R和Python打通数据库的6种高效方法

第一章&#xff1a;R-Python 数据库交互概述在现代数据科学实践中&#xff0c;R 与 Python 作为两大主流分析语言&#xff0c;常需协同访问数据库以完成复杂的数据处理任务。通过标准化接口&#xff0c;两者均可连接主流数据库系统&#xff0c;如 PostgreSQL、MySQL 和 SQLite&…

作者头像 李华
网站建设 2026/4/18 8:42:42

一文带你玩转木马攻击,零基础到精通的通关秘籍,这篇必须收藏

木马攻击实验 计算机木马病毒是指隐藏在正常程序中的一段具有特殊功能表面无害的恶意代码&#xff0c;是具备破坏和删除文件、发送密码、记录键盘等特殊功能的后门程序。 学员需在本实验中通过“冰河”木马的使用&#xff0c;掌握木马的工作原理以及清除方法。 实验简介 实验…

作者头像 李华
网站建设 2026/4/18 10:52:02

揭秘Dify中加密PDF解析难题:3步实现高效进度追踪

第一章&#xff1a;揭秘Dify中加密PDF解析的核心挑战在Dify平台处理文档自动化流程时&#xff0c;加密PDF文件的解析成为一项关键且复杂的技术任务。这类文件通常受到权限控制或密码保护&#xff0c;直接读取内容会触发安全机制&#xff0c;导致解析失败或数据丢失。加密PDF的主…

作者头像 李华