Skip to content

Commit

Permalink
Try to improve things
Browse files Browse the repository at this point in the history
  • Loading branch information
tkreuzer committed Dec 11, 2024
1 parent bba1038 commit e7d2d4a
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 17 deletions.
19 changes: 19 additions & 0 deletions modules/rostests/apitests/include/apitest.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#define InvalidPointer ((PVOID)0x5555555555555555ULL)
// #define InvalidPointer ((PVOID)0x0123456789ABCDEFULL)

#ifdef __USE_PSEH2__
#include <pseh/pseh2.h>

#define StartSeh() \
Expand All @@ -31,6 +32,24 @@
"Exception 0x%08lx, expected 0x%08lx\n", \
ExceptionStatus, (ExpectedStatus)); \
}
#else
#define StartSeh() \
{ \
NTSTATUS ExceptionStatus = STATUS_SUCCESS; \
__try \
{

#define EndSeh(ExpectedStatus) \
} \
__except(EXCEPTION_EXECUTE_HANDLER) \
{ \
ExceptionStatus = GetExceptionCode(); \
} \
ok(ExceptionStatus == (ExpectedStatus), \
"Exception 0x%08lx, expected 0x%08lx\n", \
ExceptionStatus, (ExpectedStatus)); \
}
#endif

#define ok_hr(status, expected) ok_hex(status, expected)
#define ok_hr_(file, line, status, expected) ok_hex_(file, line, status, expected)
Expand Down
31 changes: 19 additions & 12 deletions sdk/include/psdk/rpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
#endif /* _INC_WINDOWS */
#endif

#if defined(__USE_PSEH2__) && !defined(RC_INVOKED)
#include <pseh/pseh2.h>
#endif

#ifndef __RPC_H__
#define __RPC_H__

Expand Down Expand Up @@ -122,14 +118,25 @@ typedef int RPC_STATUS;
#include <excpt.h>
#include <winerror.h>

#define RpcTryExcept _SEH2_TRY
#define RpcExcept(expr) _SEH2_EXCEPT((expr))
#define RpcEndExcept _SEH2_END;
#define RpcTryFinally _SEH2_TRY
#define RpcFinally _SEH2_FINALLY
#define RpcEndFinally _SEH2_END;
#define RpcExceptionCode() _SEH2_GetExceptionCode()
#define RpcAbnormalTermination() (_SEH2_GetExceptionCode() != 0)
#ifndef __USE_PSEH2__
#define RpcTryExcept __try {
#define RpcExcept(expr) } __except (expr) {
#define RpcEndExcept }
#define RpcTryFinally __try {
#define RpcFinally } __finally {
#define RpcEndFinally }
#define RpcExceptionCode() GetExceptionCode()
#define RpcAbnormalTermination() AbnormalTermination()
#else
#define RpcTryExcept _SEH2_TRY
#define RpcExcept(expr) _SEH2_EXCEPT((expr))
#define RpcEndExcept _SEH2_END;
#define RpcTryFinally _SEH2_TRY
#define RpcFinally _SEH2_FINALLY
#define RpcEndFinally _SEH2_END;
#define RpcExceptionCode() _SEH2_GetExceptionCode()
#define RpcAbnormalTermination() (_SEH2_GetExceptionCode() != 0)
#endif
#endif

#if defined(__RPC_WIN64__)
Expand Down
16 changes: 12 additions & 4 deletions sdk/include/reactos/wine/exception.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@

#include <setjmp.h>
#include <intrin.h>
#ifdef __USE_PSEH2__
# include <pseh/pseh2.h>
# include <pseh/excpt.h>
#endif
#include <excpt.h>

#ifdef __cplusplus
extern "C" {
Expand Down Expand Up @@ -58,6 +55,7 @@ typedef struct _WINE_EXCEPTION_REGISTRATION_RECORD
#define PEXCEPTION_REGISTRATION_RECORD PWINE_EXCEPTION_REGISTRATION_RECORD
#endif

#ifdef __USE_PSEH2__
#define __TRY _SEH2_TRY
#define __EXCEPT(func) _SEH2_EXCEPT(func(_SEH2_GetExceptionInformation()))
#define __EXCEPT_CTX(func, ctx) _SEH2_EXCEPT((func)(GetExceptionInformation(), ctx))
Expand All @@ -78,6 +76,16 @@ typedef struct _WINE_EXCEPTION_REGISTRATION_RECORD
#ifndef AbnormalTermination
#define AbnormalTermination() _SEH2_AbnormalTermination()
#endif
#else
#define __TRY __try
#define __EXCEPT(func) __except(func(GetExceptionInformation()))
#define __EXCEPT_CTX(func, ctx) __except((func)(GetExceptionInformation(), ctx))
#define __EXCEPT_PAGE_FAULT __except(GetExceptionCode() == STATUS_ACCESS_VIOLATION)
#define __EXCEPT_ALL __except(1)
#define __ENDTRY
#define __FINALLY(func) __finally { func(!AbnormalTermination()); }
#define __FINALLY_CTX(func, ctx) __finally { func(!AbnormalTermination(), ctx); }
#endif

#if defined(__MINGW32__) || defined(__CYGWIN__)
#define sigjmp_buf jmp_buf
Expand Down
1 change: 0 additions & 1 deletion sdk/lib/pseh/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,4 @@ target_include_directories(pseh INTERFACE include)
# Make it clear that we are using PSEH2
if ((CMAKE_C_COMPILER_ID STREQUAL "GNU") OR
((CMAKE_C_COMPILER_ID STREQUAL "Clang") AND (NOT (ARCH STREQUAL "amd64"))))
target_compile_definitions(pseh INTERFACE __USE_PSEH2__)
endif()
2 changes: 2 additions & 0 deletions sdk/lib/pseh/include/pseh/pseh2.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#ifndef KJK_PSEH2_H_
#define KJK_PSEH2_H_

#define __USE_PSEH2__

#if defined(_USE_NATIVE_SEH) || defined(_MSC_VER)

#define _SEH2_TRY __try
Expand Down

0 comments on commit e7d2d4a

Please sign in to comment.