Skip to content

Commit 5abc69f

Browse files
committed
[PSEH] Make x64 PSEH independent of SDK headers
1 parent ad50a00 commit 5abc69f

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

sdk/lib/pseh/include/pseh/pseh2_64.h

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
11

22
#pragma once
33

4+
struct _SEH$$_EXCEPTION_RECORD
5+
{
6+
unsigned long ExceptionCode;
7+
unsigned long ExceptionFlags;
8+
struct _EXCEPTION_RECORD *ExceptionRecord;
9+
void* ExceptionAddress;
10+
unsigned long NumberParameters;
11+
unsigned long long ExceptionInformation[15];
12+
};
13+
14+
struct _SEH$$_EXCEPTION_POINTERS
15+
{
16+
struct _SEH$$_EXCEPTION_RECORD *ExceptionRecord;
17+
struct _CONTEXT *ContextRecord;
18+
};
19+
420
/* Declare our global trampoline function for filter and unwinder */
521
__asm__(
622
".p2align 4, 0x90\n"
@@ -78,7 +94,7 @@ __seh2$$end_try__:(void)0;
7894
if (0) \
7995
{ \
8096
__label__ __seh2$$leave_scope__; \
81-
LONG __MINGW_ATTRIB_UNUSED __seh2$$exception_code__; \
97+
long __MINGW_ATTRIB_UNUSED __seh2$$exception_code__; \
8298
/* Add our handlers to the list */ \
8399
if (0) \
84100
{ \
@@ -93,7 +109,7 @@ __seh2$$end_try__:(void)0;
93109
: "%r8" \
94110
: __seh2$$filter_funclet__); \
95111
/* Actually declare our filter funclet */ \
96-
struct _EXCEPTION_POINTERS* __seh2$$exception_ptr__; \
112+
struct _SEH$$_EXCEPTION_POINTERS* __seh2$$exception_ptr__; \
97113
__seh2$$filter_funclet__: \
98114
/* At this point, the compiler can't count on any register being valid */ \
99115
__asm__ __volatile__("" \
@@ -167,20 +183,19 @@ __seh2$$begin_except__: __MINGW_ATTRIB_UNUSED;
167183
} \
168184
}
169185

170-
#define _SEH2_GetExceptionInformation() __seh2$$exception_ptr__
186+
#define _SEH2_GetExceptionInformation() ((struct _EXCEPTION_POINTERS*)__seh2$$exception_ptr__)
171187
#define _SEH2_GetExceptionCode() __seh2$$exception_code__
172188
#define _SEH2_AbnormalTermination() __seh2$$abnormal_termination__
173189
#define _SEH2_LEAVE goto __seh2$$leave_scope__
174190
#define _SEH2_YIELD(__stmt) __stmt
175191
#define _SEH2_VOLATILE volatile
176192

177-
#ifndef __try // Conflict with GCC's STL
193+
#undef __try // undef from GCC's stl
178194
#define __try _SEH2_TRY
179195
#define __except _SEH2_EXCEPT
180196
#define __finally _SEH2_FINALLY
181197
#define __endtry _SEH2_END
182198
#define __leave goto __seh2$$leave_scope__
183-
#define _exception_info() __seh2$$exception_ptr__
199+
#define _exception_info() ((struct _EXCEPTION_POINTERS*)__seh2$$exception_ptr__)
184200
#define _exception_code() __seh2$$exception_code__
185201
#define _abnormal_termination() __seh2$$abnormal_termination__
186-
#endif

0 commit comments

Comments
 (0)