2008 06 30 19 33 關閉 try exception


s

s



#include
#include
#include

__inline __declspec(naked) unsigned int removeSEH()
{
__asm {
push esi
push ecx
mov esi,fs:0
lodsd
GetNextExeception:
cmp [eax],0xffffffff
je FoundLastExeceptionFilter
mov eax,[eax]
jmp GetNextExeception
FoundLastExeceptionFilter:
mov fs:0,eax

pop ecx
pop esi
ret
}
}

int main(void)
{
int x=10,y=0,z=0;

removeSEH();

__try {
z=x/y;
printf("%d DIV %d = %d\n",x,y,z);
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
printf("catch exception\n");
}
getch();
return 0;
}