From b734af01d04353e30b5d61897f94d2a095f6cc3f Mon Sep 17 00:00:00 2001 From: Daniel Lehman Date: Thu, 16 Jun 2016 16:38:08 -0700 Subject: [PATCH] msvcp140: Forward __ExceptionPtr* to msvcr120 on older visual studios, the __ExceptionPtr* were in the C runtime at vs2015, they were moved to the C++ runtime Signed-off-by: Daniel Lehman --- dlls/msvcp140/msvcp140.spec | 24 +++++++-------- dlls/msvcp90/msvcp_main.c | 75 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+), 12 deletions(-) diff --git a/dlls/msvcp140/msvcp140.spec b/dlls/msvcp140/msvcp140.spec index eb3ba0f..e4be82a 100644 --- a/dlls/msvcp140/msvcp140.spec +++ b/dlls/msvcp140/msvcp140.spec @@ -1693,22 +1693,22 @@ @ stub -arch=win64 ?__ExceptionPtrAssign@@YAXPEAXPEBX@Z @ stub -arch=win32 ?__ExceptionPtrCompare@@YA_NPBX0@Z @ stub -arch=win64 ?__ExceptionPtrCompare@@YA_NPEBX0@Z -@ stub -arch=win32 ?__ExceptionPtrCopy@@YAXPAXPBX@Z -@ stub -arch=win64 ?__ExceptionPtrCopy@@YAXPEAXPEBX@Z +@ cdecl -arch=win32 ?__ExceptionPtrCopy@@YAXPAXPBX@Z(ptr ptr) __ExceptionPtrCopy +@ cdecl -arch=win64 ?__ExceptionPtrCopy@@YAXPEAXPEBX@Z(ptr ptr) __ExceptionPtrCopy @ stub -arch=win32 ?__ExceptionPtrCopyException@@YAXPAXPBX1@Z @ stub -arch=win64 ?__ExceptionPtrCopyException@@YAXPEAXPEBX1@Z -@ stub -arch=win32 ?__ExceptionPtrCreate@@YAXPAX@Z -@ stub -arch=win64 ?__ExceptionPtrCreate@@YAXPEAX@Z -@ stub -arch=win32 ?__ExceptionPtrCurrentException@@YAXPAX@Z -@ stub -arch=win64 ?__ExceptionPtrCurrentException@@YAXPEAX@Z -@ stub -arch=win32 ?__ExceptionPtrDestroy@@YAXPAX@Z -@ stub -arch=win64 ?__ExceptionPtrDestroy@@YAXPEAX@Z -@ stub -arch=win32 ?__ExceptionPtrRethrow@@YAXPBX@Z -@ stub -arch=win64 ?__ExceptionPtrRethrow@@YAXPEBX@Z +@ cdecl -arch=win32 ?__ExceptionPtrCreate@@YAXPAX@Z(ptr) __ExceptionPtrCreate +@ cdecl -arch=win64 ?__ExceptionPtrCreate@@YAXPEAX@Z(ptr) __ExceptionPtrCreate +@ cdecl -arch=win32 ?__ExceptionPtrCurrentException@@YAXPAX@Z(ptr) __ExceptionPtrCurrentException +@ cdecl -arch=win64 ?__ExceptionPtrCurrentException@@YAXPEAX@Z(ptr) __ExceptionPtrCurrentException +@ cdecl -arch=win32 ?__ExceptionPtrDestroy@@YAXPAX@Z(ptr) __ExceptionPtrDestroy +@ cdecl -arch=win64 ?__ExceptionPtrDestroy@@YAXPEAX@Z(ptr) __ExceptionPtrDestroy +@ cdecl -arch=win32 ?__ExceptionPtrRethrow@@YAXPBX@Z(ptr) __ExceptionPtrRethrow +@ cdecl -arch=win64 ?__ExceptionPtrRethrow@@YAXPEBX@Z(ptr) __ExceptionPtrRethrow @ stub -arch=win32 ?__ExceptionPtrSwap@@YAXPAX0@Z @ stub -arch=win64 ?__ExceptionPtrSwap@@YAXPEAX0@Z -@ stub -arch=win32 ?__ExceptionPtrToBool@@YA_NPBX@Z -@ stub -arch=win64 ?__ExceptionPtrToBool@@YA_NPEBX@Z +@ cdecl -arch=win32 ?__ExceptionPtrToBool@@YA_NPBX@Z(ptr) __ExceptionPtrToBool +@ cdecl -arch=win64 ?__ExceptionPtrToBool@@YA_NPEBX@Z(ptr) __ExceptionPtrToBool @ cdecl -arch=arm ?always_noconv@codecvt_base@std@@QBA_NXZ(ptr) codecvt_base_always_noconv @ thiscall -arch=i386 ?always_noconv@codecvt_base@std@@QBE_NXZ(ptr) codecvt_base_always_noconv @ cdecl -arch=win64 ?always_noconv@codecvt_base@std@@QEBA_NXZ(ptr) codecvt_base_always_noconv diff --git a/dlls/msvcp90/msvcp_main.c b/dlls/msvcp90/msvcp_main.c index 377ae01..359e0ec 100644 --- a/dlls/msvcp90/msvcp_main.c +++ b/dlls/msvcp90/msvcp_main.c @@ -189,6 +189,80 @@ static void init_cxx_funcs(void) #endif /* _MSVCP_VER >= 110 */ } + +#if _MSVCP_VER >= 140 +/* at vs2015, these are moved from the C library */ +/* see dlls/msvcrt/cpp.c */ +/* std::exception_ptr class helpers */ +typedef struct +{ + EXCEPTION_RECORD *rec; + int *ref; /* not binary compatible with native msvcr100 */ +} exception_ptr; + +static void (__cdecl *MSVCRT___ExceptionPtrCreate)(exception_ptr *); +static void (__cdecl *MSVCRT___ExceptionPtrDestroy)(exception_ptr *); +static void (__cdecl *MSVCRT___ExceptionPtrCopy)(exception_ptr *, const exception_ptr *); +static void (__cdecl *MSVCRT___ExceptionPtrRethrow)(const exception_ptr *); +static void (__cdecl *MSVCRT___ExceptionPtrCurrentException)(exception_ptr *); +static MSVCP_bool (__cdecl *MSVCRT___ExceptionPtrToBool)(exception_ptr *); + +void __cdecl __ExceptionPtrCreate(exception_ptr *ep) +{ + MSVCRT___ExceptionPtrCreate(ep); +} + +void __cdecl __ExceptionPtrDestroy(exception_ptr *ep) +{ + MSVCRT___ExceptionPtrDestroy(ep); +} + +void __cdecl __ExceptionPtrCopy(exception_ptr *ep, const exception_ptr *copy) +{ + MSVCRT___ExceptionPtrCopy(ep, copy); +} + +void __cdecl __ExceptionPtrRethrow(const exception_ptr *ep) +{ + MSVCRT___ExceptionPtrRethrow(ep); +} + +void __cdecl __ExceptionPtrCurrentException(exception_ptr *ep) +{ + MSVCRT___ExceptionPtrCurrentException(ep); +} + +MSVCP_bool __cdecl __ExceptionPtrToBool(exception_ptr *ep) +{ + return MSVCRT___ExceptionPtrToBool(ep); +} +#endif + +static void init_cxx_exception_funcs(void) +{ +#if _MSVCP_VER >= 140 + HMODULE hmod = LoadLibraryA( "msvcr120.dll" ); + if (sizeof(void *) > sizeof(int)) /* 64-bit has different names */ + { + MSVCRT___ExceptionPtrCreate = (void*)GetProcAddress(hmod, "?__ExceptionPtrCreate@@YAXPEAX@Z"); + MSVCRT___ExceptionPtrDestroy = (void*)GetProcAddress(hmod, "?__ExceptionPtrDestroy@@YAXPEAX@Z"); + MSVCRT___ExceptionPtrCopy = (void*)GetProcAddress(hmod, "?__ExceptionPtrCopy@@YAXPEAXPEBX@Z"); + MSVCRT___ExceptionPtrRethrow = (void*)GetProcAddress(hmod, "?__ExceptionPtrRethrow@@YAXPEBX@Z"); + MSVCRT___ExceptionPtrCurrentException = (void*)GetProcAddress(hmod, "?__ExceptionPtrCurrentException@@YAXPEAX@Z"); + MSVCRT___ExceptionPtrToBool = (void*)GetProcAddress(hmod, "?__ExceptionPtrToBool@@YA_NPEBX@Z"); + } + else + { + MSVCRT___ExceptionPtrCreate = (void*)GetProcAddress(hmod, "?__ExceptionPtrCreate@@YAXPAX@Z"); + MSVCRT___ExceptionPtrDestroy = (void*)GetProcAddress(hmod, "?__ExceptionPtrDestroy@@YAXPAX@Z"); + MSVCRT___ExceptionPtrCopy = (void*)GetProcAddress(hmod, "?__ExceptionPtrCopy@@YAXPAXPBX@Z"); + MSVCRT___ExceptionPtrRethrow = (void*)GetProcAddress(hmod, "?__ExceptionPtrRethrow@@YAXPBX@Z"); + MSVCRT___ExceptionPtrCurrentException = (void*)GetProcAddress(hmod, "?__ExceptionPtrCurrentException@@YAXPAX@Z"); + MSVCRT___ExceptionPtrToBool = (void*)GetProcAddress(hmod, "?__ExceptionPtrToBool@@YA_NPBX@Z"); + } +#endif +} + BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { TRACE("(0x%p, %d, %p)\n", hinstDLL, fdwReason, lpvReserved); @@ -197,6 +271,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { case DLL_PROCESS_ATTACH: init_cxx_funcs(); + init_cxx_exception_funcs(); init_lockit(); init_exception(hinstDLL); init_locale(hinstDLL); -- 1.9.5