hook Sysenter 崩溃
两个疑问:
疑问一:
看网上资料WinDBG输入"lkd> rdmsr 176",可以见转入了地址80541770用ln命令"ln 80541770"可见最终转入nt!KiFastCallEntry()--->但我在xp sp3下自已动手试了下事实如下:
kd> rdmsr 176
msr[176] = 00000000`8053e550
kd> u 8053e550
nt!KeReleaseInStackQueuedSpinLockFromDpcLevel+0xa1c:
8053e550 b923000000 mov ecx,23h
8053e555 6a30 push 30h
8053e557 0fa1 pop fs
8053e559 8ed9 mov ds,cx
...如上,为什么sysenter并非如网上所述是KiFastCallEntry而是KeReleaseInStackQueuedSpinLockFromDpcLevel。
疑问二:
ULONG Real_KiFastCallEntry;
ULONG ulCnt = 0;
__declspec(naked) Hook_KiFastCallEntry()
{
ulCnt++;
if (ulCnt%100 == 0)
{
DbgPrint("第%d百次调用SYSENTER指令!\n", ulCnt/100);
}
__asm {
jmp Real_KiFastCallEntry ;
}
}
NTSTATUS
DriverEntry(
__in struct _DRIVER_OBJECT *pDriverObject,
__in PUNICODE_STRING pRegistryPath
)
{
#ifdef DBG
_asm int 3;
#endif
pDriverObject->DriverUnload = Unload;
__asm {
mov ecx, 0x176;
xor edx, edx; //写SYSENTER_EIP_MSR寄存器前得清空edx,否则引起系统崩溃
rdmsr; // 读取SYSENTER_EIP_MSR寄存器
mov Real_KiFastCallEntry, eax;
mov eax, Hook_KiFastCallEntry;
wrmsr; // 写入SYSENTER_EIP_MSR寄存器
}
return STATUS_SUCCESS;
}
//驱动卸载
VOID
Unload(
__in struct _DRIVER_OBJECT *pDriverObject
)
{
_asm
{
mov ecx, 0x176;
xor edx, edx;
mov eax, Real_KiFastCallEntry;
wrmsr; // 写入SYSENTER_EIP_MSR寄存器
}
DbgPrint("Unload运行完毕,驱动卸载成功");
}
/****************/
当DriverEntry返回STATUS_SUCCESS后,WINDBG提示:
Terminating critical process 0x815EE340 (csrss.exe)
Break, or Ignore (bi)? ...选择i..之后目标机就卡住了,好像死机一般。