[SDK][PSEH] Improve PSEH a bit

Add PSEH include dir globally, include pseh2.h from excpt.h and add compatibility macros to reduce hacks in 3rd-perty code.
This commit is contained in:
Timo Kreuzer 2024-11-16 21:48:13 +02:00
parent 3a61dd7fe7
commit 53f498c968
7 changed files with 36 additions and 13 deletions

View file

@ -324,7 +324,8 @@ Enable this if the module uses typeid or dynamic_cast. You will probably need to
sdk/include/ddk
sdk/include/ndk
sdk/include/reactos
sdk/include/reactos/libs)
sdk/include/reactos/libs
sdk/lib/pseh/include)
if(ARCH STREQUAL "arm")
include_directories(${REACTOS_SOURCE_DIR}/sdk/include/reactos/arm)

View file

@ -5,7 +5,6 @@ if(_WINKD_)
endif()
include_directories(spapisup utils)
include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/pseh/include)
list(APPEND SOURCE
spapisup/fileqsup.c

View file

@ -23,9 +23,6 @@
#define leave _SEH2_LEAVE
#define endtry _SEH2_END
#define abnormal_termination _abnormal_termination
#define GetExceptionInformation() _SEH2_GetExceptionInformation()
#define GetExceptionCode() _SEH2_GetExceptionCode()
#define AbnormalTermination() _SEH2_AbnormalTermination()
#define gcc_volatile volatile
#endif

View file

@ -8,6 +8,10 @@
#include <vcruntime.h>
#if !defined(RC_INVOKED)
#include <pseh/pseh2.h>
#endif
#pragma pack(push,_CRT_PACKING)
#ifdef __cplusplus
@ -71,16 +75,17 @@ typedef enum _EXCEPTION_DISPOSITION
#endif
#if defined(_MSC_VER) || (defined(__clang__) && defined(__SEH__))
unsigned long __cdecl _exception_code(void);
void *__cdecl _exception_info(void);
int __cdecl _abnormal_termination(void);
#endif
#define GetExceptionCode _exception_code
#define exception_code _exception_code
#define GetExceptionInformation (struct _EXCEPTION_POINTERS *)_exception_info
#define exception_info (struct _EXCEPTION_POINTERS *)_exception_info
#define AbnormalTermination _abnormal_termination
#define abnormal_termination _abnormal_termination
unsigned long __cdecl _exception_code(void);
void *__cdecl _exception_info(void);
int __cdecl _abnormal_termination(void);
#endif
#define EXCEPTION_EXECUTE_HANDLER 1
#define EXCEPTION_CONTINUE_SEARCH 0

View file

@ -30,12 +30,13 @@
* |-----------|
*/
/* We need the full structure with all non-volatile */
#define _SEH3$_FRAME_ALL_NONVOLATILES 1
#include <stdarg.h>
#include <windef.h>
#include <winnt.h>
/* We need the full structure with all non-volatile */
#define _SEH3$_FRAME_ALL_NONVOLATILES 1
#include "pseh3.h"
#include "pseh3_asmdef.h"

View file

@ -25,7 +25,6 @@
#if defined(_USE_NATIVE_SEH) || (defined(_MSC_VER) && !(defined(__clang__) && defined(_M_AMD64)))
#include <excpt.h>
#define _SEH2_TRY __try
#define _SEH2_FINALLY __finally
#define _SEH2_EXCEPT(...) __except(__VA_ARGS__)
@ -37,6 +36,8 @@
#define _SEH2_LEAVE __leave
#define _SEH2_VOLATILE
#define __endtry
#elif defined(__GNUC__) && !defined(__clang__) && defined(_M_AMD64)
#include "pseh2_64.h"
@ -101,6 +102,14 @@ _Pragma("GCC diagnostic pop")
#define _SEH2_YIELD(x) x
#define _SEH2_VOLATILE volatile
#ifndef __try // Conflict with GCC's STL
#define __try _SEH3_TRY
#define __except _SEH3_EXCEPT
#define __finally _SEH3_FINALLY
#define __endtry _SEH3_END
#define __leave _SEH3_LEAVE
#endif
#elif defined(__GNUC__)
struct _EXCEPTION_RECORD;

View file

@ -173,3 +173,14 @@ __seh2$$begin_except__: __MINGW_ATTRIB_UNUSED;
#define _SEH2_LEAVE goto __seh2$$leave_scope__
#define _SEH2_YIELD(__stmt) __stmt
#define _SEH2_VOLATILE volatile
#ifndef __try // Conflict with GCC's STL
#define __try _SEH2_TRY
#define __except _SEH2_EXCEPT
#define __finally _SEH2_FINALLY
#define __endtry _SEH2_END
#define __leave goto __seh2$$leave_scope__
#define _exception_info() __seh2$$exception_ptr__
#define _exception_code() __seh2$$exception_code__
#define _abnormal_termination() __seh2$$abnormal_termination__
#endif