hook Sysenter 崩溃

VirtualRookit 2011-03-22 06:02:11
两个疑问:
疑问一:
看网上资料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..之后目标机就卡住了,好像死机一般。
...全文
230 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
VirtualRookit 2011-03-23
  • 打赏
  • 举报
回复
第一个问题,的确是没有symbols造成。但第二个问题却没找到原因,结贴咯。
VirtualRookit 2011-03-22
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 lactoferrin 的回复:]
第一个问题,你是不是没有符号文件?
第二个问题,你把Hook_KiFastCallEntry里面的DbgPrint去掉试试
[/Quote]

我的确没有符号文件,以前有装过,但装完windbg还是提示,没找着符号(我是严格按被调试机的操作系统去下载符号文件的),所以这个问题的真相会出在这吗?

我把DbgPrint去掉了,结果 windbg如下
kd> p
RTL: RtlNtStatusToDosError(0xc0000258): No Valid Win32 Error Mapping
RTL: Edit ntos\rtl\generr.c to correct the problem
RTL: ERROR_MR_MID_NOT_FOUND is being returned
nt!NtWriteFile+0x453f:
80577807 8945ac mov dword ptr [ebp-54h],eax
kd> g
RTL: RtlNtStatusToDosError(0x81540000): No Valid Win32 Error Mapping
RTL: Edit ntos\rtl\generr.c to correct the problem
RTL: ERROR_MR_MID_NOT_FOUND is being returned
Break instruction exception - code 80000003 (first chance)
001b:7c839aad cc int 3
kd> g
Break instruction exception - code 80000003 (first chance)
001b:7c839aae cc int 3
kd> g
Break instruction exception - code 80000003 (first chance)
001b:7c839aaf cc int 3
Lactoferrin 2011-03-22
  • 打赏
  • 举报
回复
第一个问题,你是不是没有符号文件?
第二个问题,你把Hook_KiFastCallEntry里面的DbgPrint去掉试试

69,371

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧