-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSEH_MingW64.c
More file actions
64 lines (53 loc) · 1.34 KB
/
SEH_MingW64.c
File metadata and controls
64 lines (53 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#if defined(_WIN32)&&defined(_MINGW)&&defined(_WIN64)
#include <windows.h>
#include <setjmp.h>
#include <stdio.h>
#include <crtdbg.h>
#include "SEH.h"
__declspec(thread) WELEES_SEH_SET s_weLees_SEH_Maintain={0};
#if defined(__cplusplus)
EXCEPTION_NODE::~EXCEPTION_NODE(void)
{
if(Prev)
{
s_weLees_SEH_Maintain.Chain=s_weLees_SEH_Maintain.Chain->Prev;
}
}
#endif //defined(__cplusplus)
int StartSEHService(void)
{
return TRUE;
}
void StopSEHService(void)
{
}
//MINGW64 exception handler stub
LONG WINAPI DefVEHHandler(IN PEXCEPTION_POINTERS pInfo)
{
int iResult;
PEXCEPTION_NODE pNode;
printf("VEH caught exception: 0x%08X\n",pInfo->ExceptionRecord->ExceptionCode);
while(s_weLees_SEH_Maintain.Chain)
{
pNode=s_weLees_SEH_Maintain.Chain;
iResult=s_weLees_SEH_Maintain.Chain->ExceptionFilter(pInfo);
switch(iResult)
{
case EXCEPTION_EXECUTE_HANDLER:
s_weLees_SEH_Maintain.Chain=s_weLees_SEH_Maintain.Chain->Prev;//Unlink exception block
pNode->Prev=NULL;
longjmp(pNode->Entry,1);
case EXCEPTION_CONTINUE_EXECUTION:
return iResult;
case EXCEPTION_CONTINUE_SEARCH:
s_weLees_SEH_Maintain.Chain=s_weLees_SEH_Maintain.Chain->Prev;//Unlink exception block
pNode->Prev=NULL;
break;
default:
_ASSERT(FALSE);
break;
}
}
return -1;
}
#endif //defined(_WIN32)&&defined(_MINGW)&&defined(_WIN64)