很早就有个想法:
看看sysenter指令的下一步操作是啥,也就是下一条指令的代码。
sysenter指令主要的操作是设置IP。
IP设置完后,这个指令的功能也就完成差不多了。
剩下的事是CPU的事了,也就是按照指定的地址去执行了。
这个指令的功能很明确了。
接下来进入正题:
1: kd> rdmsr 176
msr[176] = 00000000`805426e0
注释:SYSENTER_EIP_MSR == 176
1: kd> u 805426e0
nt!KiFastCallEntry:
805426e0 b923000000 mov ecx,23h
805426e5 6a30 push 30h
805426e7 0fa1 pop fs
805426e9 8ed9 mov ds,cx
805426eb 8ec1 mov es,cx
805426ed 648b0d40000000 mov ecx,dword ptr fs:[40h]
805426f4 8b6104 mov esp,dword ptr [ecx+4]
805426f7 6a23 push 23h
至此问题应该解决了。
注意:有的时候,按进入下一步的时候不是这个地址,而是别的,我的解释是线程的切换。
而调用者一般如下:
ntdll!KiFastSystemCall:
001b:7c92e510 8bd4 mov edx,esp
001b:7c92e512 0f34 sysenter
ntdll!KiFastSystemCallRet:
001b:7c92e514 c3 ret
------------------------------------------------------------------------------------------------------------------------------
nt!KiSystemCallExit:
805428ec cf iretd
nt!KiSystemCallExit2:
805428ed f644240901 test byte ptr [esp+9],1
805428f2 75f8 jne nt!KiSystemCallExit (805428ec)
805428f4 5a pop edx
805428f5 83c404 add esp,4
805428f8 80642401fd and byte ptr [esp+1],0FDh
805428fd 9d popfd
805428fe 59 pop ecx
805428ff fb sti
80542900 0f35 sysexit
80542902 cf iretd
80542903 90 nop
1: kd> r
eax=00000000 ebx=7c9a0600 ecx=0225f624 edx=7c92e514 esi=0016b6d8 edi=7c99e3e0
eip=80542900 esp=f824addc ebp=0225f644 iopl=0 nv up ei ng nz na po cy
cs=0008 ss=0010 ds=0023 es=0023 fs=0030 gs=0000 efl=00000283
nt!KiSystemCallExit2+0x13:
80542900 0f35 sysexit
注意:EDX的值。
说明:nt!KiSystemCallExit很少被调用。
ntdll!KiFastSystemCallRet:
001b:7c92e514 c3 ret
操作步骤:
1.在nt!KiSystemCallExit2下断点。
2.走到sysexit时,在不发生切换线程的情况下会走到ntdll!KiFastSystemCallRet的。
3.ntdll!KiFastSystemCallRet返回到函数的调用者处。
------------------------------------------------------------------------------------------------------------------------------
made by correy
made at 2014.07.22
2014年7月22日星期二
调试sysenter
订阅:
博文评论 (Atom)
没有评论:
发表评论