From 0871055dff12f453de8bc61e32a519e6695e48b6 Mon Sep 17 00:00:00 2001 From: MiroKaku <50670906+MiroKaku@users.noreply.github.com> Date: Mon, 1 Jul 2024 19:23:41 +0800 Subject: [PATCH] feat: prioritize using my jbcxrval.c undo: unnecessary changes --- .gitignore | 2 +- msvc/ucxxrt.test.vcxproj | 2 ++ src/crt/i386/chandler4.cpp | 8 ++++++-- src/crt/i386/trnsctrl.cpp | 10 +++++++--- src/crt/vcruntime/ehhelpers.h | 4 ++-- src/crt/vcruntime/frame.cpp | 4 ++++ src/crt/vcruntime/jbcxrval.c | 16 ++++++++++------ 7 files changed, 32 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index 9b875b9..cf784eb 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,7 @@ bld/ [Oo]bj/ [Bb]in/ [Ll]ib/ +ucxxrt/ # Visual Studio 2015 cache/options directory .vs/ @@ -262,4 +263,3 @@ __pycache__/ # VSCode .vscode/ -/ucxxrt diff --git a/msvc/ucxxrt.test.vcxproj b/msvc/ucxxrt.test.vcxproj index 632cbb3..f714056 100644 --- a/msvc/ucxxrt.test.vcxproj +++ b/msvc/ucxxrt.test.vcxproj @@ -45,6 +45,8 @@ WDM Desktop Spectre + Windows10 + diff --git a/src/crt/i386/chandler4.cpp b/src/crt/i386/chandler4.cpp index 86a0e87..c166a4a 100644 --- a/src/crt/i386/chandler4.cpp +++ b/src/crt/i386/chandler4.cpp @@ -190,13 +190,17 @@ _EH4_LocalUnwind( #endif -extern "C" -void +extern "C" +void __cdecl __except_validate_context_record( _In_ PCONTEXT ContextRecord ); +#if defined(_X86_) +_VEIL_DECLARE_ALTERNATE_NAME(__except_validate_context_record, _UCXXRT___except_validate_context_record); +#endif + /*** *ValidateLocalCookies - perform local cookie validation during SEH processing * diff --git a/src/crt/i386/trnsctrl.cpp b/src/crt/i386/trnsctrl.cpp index f54445b..f3d8393 100644 --- a/src/crt/i386/trnsctrl.cpp +++ b/src/crt/i386/trnsctrl.cpp @@ -328,13 +328,17 @@ extern "C" _VCRTIMP __declspec(naked) DECLSPEC_GUARD_SUPPRESS EXCEPTION_DISPOSIT } } -extern "C" -void -__cdecl +extern "C" +void +__cdecl __except_validate_jump_buffer ( _In_ _JUMP_BUFFER *JumpBuffer ); +#if defined(_X86_) +_VEIL_DECLARE_ALTERNATE_NAME(__except_validate_jump_buffer, _UCXXRT___except_validate_jump_buffer); +#endif + ///////////////////////////////////////////////////////////////////////////// // // __CxxLongjmpUnwind - Entry point for local unwind required by longjmp diff --git a/src/crt/vcruntime/ehhelpers.h b/src/crt/vcruntime/ehhelpers.h index f44c408..02b7e31 100644 --- a/src/crt/vcruntime/ehhelpers.h +++ b/src/crt/vcruntime/ehhelpers.h @@ -26,7 +26,7 @@ #define MANAGED_EXCEPTION_CODE_V4 0XE0434352 extern "C" -void +void __cdecl __except_validate_context_record( _In_ PCONTEXT ContextRecord @@ -61,7 +61,7 @@ extern "C" _VCRTIMP int __cdecl RENAME_EH_EXTERN(__TypeMatch4)( FH4::HandlerType4 *, CatchableType *, ThrowInfo * - ); +); extern "C" _VCRTIMP int __cdecl RENAME_EH_EXTERN(__TypeMatch)( HandlerType *, diff --git a/src/crt/vcruntime/frame.cpp b/src/crt/vcruntime/frame.cpp index 0da108f..81d049b 100644 --- a/src/crt/vcruntime/frame.cpp +++ b/src/crt/vcruntime/frame.cpp @@ -28,6 +28,10 @@ #include "winapi_thunks.h" +#if defined(_X86_) +_VEIL_DECLARE_ALTERNATE_NAME(__except_validate_context_record, _UCXXRT___except_validate_context_record); +#endif + // Make non-namespace prefixed names available for FH4 using namespace FH4; diff --git a/src/crt/vcruntime/jbcxrval.c b/src/crt/vcruntime/jbcxrval.c index 8c5fff1..782d5a2 100644 --- a/src/crt/vcruntime/jbcxrval.c +++ b/src/crt/vcruntime/jbcxrval.c @@ -167,12 +167,15 @@ __except_validate_jump_buffer( #else // defined(NTOS_KERNEL_RUNTIME) - -#if !defined(_X86_) // In X86, this function conflicts with the function in libcntpr.lib void __cdecl +#if defined(_X86_) +_UCXXRT___except_validate_context_record( + _In_ PCONTEXT ContextRecord +#else __except_validate_context_record( _In_ PCONTEXT ContextRecord +#endif ) /*++ @@ -214,7 +217,6 @@ Return Value: } } } -#endif // !defined(_X86_) __forceinline @@ -279,17 +281,19 @@ static PVOID __except_get_jumpbuf_sp(_In_reads_(_JBLEN) jmp_buf JumpBuffer) return (PVOID)JUMP_BUFFER_TO_STACK_POINTER((_JUMP_BUFFER*)JumpBuffer); } - -#if !defined(_X86_) // In X86, this function conflicts with the function in libcntpr.lib void __cdecl +#if defined(_X86_) +_UCXXRT___except_validate_jump_buffer( + _In_reads_(_JBLEN) jmp_buf JumpBuffer +#else __except_validate_jump_buffer( _In_reads_(_JBLEN) jmp_buf JumpBuffer +#endif ) { __except_validate_jump_buffer_common(JumpBuffer, __except_get_jumpbuf_sp); } -#endif // !defined(_X86_) #endif // !defined(NTOS_KERNEL_RUNTIME) \ No newline at end of file