3.API的调用过程(保存现场)

本文详细介绍了Windows操作系统中API调用的过程,特别是通过KiFastCallEntry和KiSystemService时,如何保存3环寄存器到_KTrap_Frame结构体中。涉及内容包括权限切换、TSS、KPCR、PEB结构、异常链表、先前模式以及调试状态的处理。最终,无论是快速调用还是中断进入,都会调用相同的后续代码。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

_KTrap_Frame 结构

kd> dt _KTrap_Frame
ntdll!_KTRAP_FRAME
	//调试系统服务
   +0x000 DbgEbp           : Uint4B
   +0x004 DbgEip           : Uint4B
   +0x008 DbgArgMark       : Uint4B
   +0x00c DbgArgPointer    : Uint4B
   
   //当需要调整栈时以下作为临时变量
   +0x010 TempSegCs        : Uint4B
   +0x014 TempEsp          : Uint4B

	//调试寄存器
   +0x018 Dr0              : Uint4B
   +0x01c Dr1              : Uint4B
   +0x020 Dr2              : Uint4B
   +0x024 Dr3              : Uint4B
   +0x028 Dr6              : Uint4B
   +0x02c Dr7              : Uint4B

	//段寄存器
   +0x030 SegGs            : Uint4B
   +0x034 SegEs            : Uint4B
   +0x038 SegDs            : Uint4B

	//易失寄存器
   +0x03c Edx              : Uint4B
   +0x040 Ecx              : Uint4B
   +0x044 Eax              : Uint4B
   
   //非易失性寄存器需要在中断例程中先保存
   +0x048 PreviousPreviousMode : Uint4B
   +0x04c ExceptionList    : Ptr32 _EXCEPTION_REGISTRATION_RECORD
   +0x050 SegFs            : Uint4B

	//非易失寄存器
   +0x054 Edi              : Uint4B
   +0x058 Esi            
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值