您的位置:首页 > 其它

如何防止在SEH中探测drx 寄存器

2010-06-22 18:01 197 查看
long scratch;

EXCEPTION_DISPOSITION __cdecl _kkexcept_handler(
struct _EXCEPTION_RECORD *ExceptionRecord,
void * EstablisherFrame,
struct _CONTEXT *ContextRecord,
void * DispatcherContext )
{
unsigned i;
// printf( "Hello from an exception handler\n" );
// ContextRecord->Eax = (DWORD)&scratch;
if (ContextRecord->Dr0!=0 || ContextRecord->Dr1!=0 || ContextRecord->Dr2!=0 || ContextRecord->Dr3!=0){
::MessageBox(0,"drx",0,0);
}
return ExceptionContinueExecution;
}

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
DWORD handler = (DWORD)_kkexcept_handler;
__asm
{ // Build EXCEPTION_REGISTRATION record:
push handler // Address of handler function
push FS:[0] // Address of previous handler
mov FS:[0],ESP // Install new EXECEPTION_REGISTRATION
}
__asm {
mov eax,0 // Zero out EAX
mov [eax], 1 // Write to EAX to deliberately cause a fault
}
printf( "After writing!\n" );
__asm { // Remove our EXECEPTION_REGISTRATION record
mov eax,[ESP] // Get pointer to previous record
mov FS:[0], EAX // Install previous record
add esp, 8 // Clean our EXECEPTION_REGISTRATION off stack
}
return 0;
}
本文出自 “坐坐吧” 博客,谢绝转载!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: