Re: 指令SYSENTER是否使用SYSENTER_ESP_MSR寄存器

CPU架构

指令SYSENTER是否使用SYSENTER_ESP_MSR寄存器


merry 2009-03-28, 21:04 下午

     IA-32架构中的快速系统调用指令SYSENTER在Windows SP2上执行时,是否仅使用SYSENTER_CS_MSR和SYSENTER_EIP_MSR,没有使用SYSENTER_ESP_MSR?

    因为我在反汇编看到系统服务号放入EAX寄存器后,esp存入edx,通过edx就找到用户传入参数,好像没有使用SYSENTER_ESP_MSR。

请问情况是这样吗?

 

Re: 指令SYSENTER是否使用SYSENTER_ESP_MSR寄存器


MJ0011 2009-03-28, 23:07 下午
当然会使用了,否则堆栈怎么切换过去?否则为什么要通过EDX来让内核知道用户栈在哪里?否则为什么需要在call ebx(system service routine)前做堆栈参数COPY?

参考代码:

mov esi, edx ; (esi)->User arguments
mov ebx, [edi]+SdNumber ; get argument table address
xor ecx, ecx
mov cl, byte ptr [ebx+eax] ; (ecx) = argument size
mov edi, [edi]+SdBase ; get service table address
mov ebx, [edi+eax*4] ; (ebx)-> service routine
sub esp, ecx ; allocate space for arguments
shr ecx, 2 ; (ecx) = number of argument DWORDs
mov edi, esp ; (edi)->location to receive 1st arg
cmp esi, _MmUserProbeAddress ; check if user address
jae kss80 ; if ae, then not user address

KiSystemServiceCopyArguments:
rep movsd ; copy the arguments to top of stack.
; Since we usually copy more than 3
; arguments. rep movsd is faster than
; mov instructions.

Powered by Community Server Powered by CnForums.Net