From: Vibhav Pant vibhavp@gmail.com
--- dlls/vccorlib140/cxx.h | 1 + dlls/vccorlib140/vccorlib.c | 23 +++++++++++++++++++++++ dlls/vccorlib140/vccorlib140.spec | 6 +++--- 3 files changed, 27 insertions(+), 3 deletions(-)
diff --git a/dlls/vccorlib140/cxx.h b/dlls/vccorlib140/cxx.h index 0ce3275886c..f8f8fe08984 100644 --- a/dlls/vccorlib140/cxx.h +++ b/dlls/vccorlib140/cxx.h @@ -168,6 +168,7 @@ void __asm_dummy_ ## type ## _exception_type(void) \ ".long %c1\n\t" \ ".rva " #__VA_ARGS__ "\n\t" \ __ASM_GLOBL(#type "_exception_type") "\n\t" \ + /* All C++/CX exceptions set this field to 16, presumably for __abi__translateCurrentException? */ \ ".long 16\n\t" \ ".long 0\n\t" \ ".long 0\n\t" \ diff --git a/dlls/vccorlib140/vccorlib.c b/dlls/vccorlib140/vccorlib.c index 9c71a36393e..584ac5c03f5 100644 --- a/dlls/vccorlib140/vccorlib.c +++ b/dlls/vccorlib140/vccorlib.c @@ -1071,6 +1071,29 @@ void WINAPI DECLSPEC_NORETURN __abi_WinRTraiseCOMException(HRESULT hr) } }
+#define TYPE_FLAG_CPPCX 16 +extern const void **__cdecl __current_exception(void); + +HRESULT WINAPI __abi_translateCurrentException(bool unknown) +{ + const struct platform_exception *excp; + const EXCEPTION_RECORD *record; + const cxx_exception_type *type; + + FIXME("(%d): semi-stub!\n", unknown); + + record = *__current_exception(); + /* Native aborts if: + * There is no exception being currently handled. + * There is no associated exception object (_CxxThrowException(NULL, ...) was called). + * There is no associated cxx_exception_type param (_CxxThrowException(..., NULL) was called). + * A non C++/CX exception has been thrown. */ + if (!record || !(excp = (struct platform_exception *)record->ExceptionInformation[1]) || + !(type = (cxx_exception_type *)record->ExceptionInformation[2]) || !(type->flags & TYPE_FLAG_CPPCX)) + abort(); + return excp->inner.hr; +} + BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, void *reserved) { if (reason == DLL_PROCESS_ATTACH) diff --git a/dlls/vccorlib140/vccorlib140.spec b/dlls/vccorlib140/vccorlib140.spec index ad236ceb48f..396c69b74ce 100644 --- a/dlls/vccorlib140/vccorlib140.spec +++ b/dlls/vccorlib140/vccorlib140.spec @@ -338,9 +338,9 @@ @ stdcall -arch=win64 ?__abi_make_type_id@@YAPE$AAVType@Platform@@AEBU__abi_type_descriptor@@@Z(ptr) __abi_make_type_id @ stub -arch=win32 ??0IntPtr@Platform@@QAA@PAX@Z @ stub -arch=win64 ??0IntPtr@Platform@@QEAA@PEAX@Z -@ stub -arch=i386 ?__abi_translateCurrentException@@YGJ_N@Z -@ stub -arch=arm ?__abi_translateCurrentException@@YAJ_N@Z -@ stub -arch=win64 ?__abi_translateCurrentException@@YAJ_N@Z +@ stdcall -arch=i386 ?__abi_translateCurrentException@@YGJ_N@Z(long) __abi_translateCurrentException +@ stdcall -arch=arm ?__abi_translateCurrentException@@YAJ_N@Z(long) __abi_translateCurrentException +@ stdcall -arch=win64 ?__abi_translateCurrentException@@YAJ_N@Z(long) __abi_translateCurrentException @ stub -arch=i386 ?__getActivationFactoryByHSTRING@@YGJPAUHSTRING__@@AAVGuid@Platform@@PAPAX@Z @ stub -arch=arm ?__getActivationFactoryByHSTRING@@YAJPAUHSTRING__@@AAVGuid@Platform@@PAPAX@Z @ stub -arch=win64 ?__getActivationFactoryByHSTRING@@YAJPEAUHSTRING__@@AEAVGuid@Platform@@PEAPEAX@Z