Window異常捕獲

#include <windows.h>
#include <stdio.h>
#include <iostream>
#include <string>

long __stdcall callback(_EXCEPTION_POINTERS* excp)
{
	char msg[200];
	sprintf_s(msg,"Error address %x --- %s \n",excp->ExceptionRecord->ExceptionAddress, excp->ExceptionRecord->ExceptionInformation);
	printf("CPU register:/n");
	printf("eax %x  ecx %x edx %x",excp->ContextRecord->Eax, excp->ContextRecord->Ecx,excp->ContextRecord->Edx);
	MessageBox(0, msg,"Error", MB_OK);
	return EXCEPTION_EXECUTE_HANDLER;
}

int main(int argc, char* argv[])
{
	SetUnhandledExceptionFilter(callback);
	_asm int 3
	return 0;
}
發佈了20 篇原創文章 · 獲贊 1 · 訪問量 1萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章