Module: wine Branch: master Commit: d12235ab79d5cf2538a12ccd15e780787f089e17 URL: http://source.winehq.org/git/wine.git/?a=commit;h=d12235ab79d5cf2538a12ccd15... Author: Daniel Lehman <dlehman(a)esri.com> Date: Thu May 26 17:49:43 2016 -0700 msvcp140: Load critical_section functions from concrt140. Signed-off-by: Daniel Lehman <dlehman(a)esri.com> Signed-off-by: Piotr Caban <piotr(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/msvcp90/msvcp_main.c | 50 ++++++++++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/dlls/msvcp90/msvcp_main.c b/dlls/msvcp90/msvcp_main.c index c9a72d2..377ae01 100644 --- a/dlls/msvcp90/msvcp_main.c +++ b/dlls/msvcp90/msvcp_main.c @@ -71,6 +71,7 @@ MSVCP_bool (__thiscall *critical_section_trylock)(critical_section*); #define VERSION_STRING(ver) #ver #if _MSVCP_VER >= 140 #define MSVCRT_NAME(ver) "ucrtbase.dll" +#define CONCRT_NAME(ver) "concrt" VERSION_STRING(ver) ".dll" #else #define MSVCRT_NAME(ver) "msvcr" VERSION_STRING(ver) ".dll" #endif @@ -132,6 +133,9 @@ int __cdecl sprintf(char *buf, const char *fmt, ...) static void init_cxx_funcs(void) { HMODULE hmod = GetModuleHandleA( MSVCRT_NAME(_MSVCP_VER) ); +#if _MSVCP_VER >= 110 + HMODULE hcon = hmod; +#endif if (!hmod) FIXME( "%s not loaded\n", MSVCRT_NAME(_MSVCP_VER) ); @@ -139,44 +143,50 @@ static void init_cxx_funcs(void) MSVCRT_operator_new = operator_new; MSVCRT_operator_delete = operator_delete; MSVCRT_set_new_handler = (void*)GetProcAddress(hmod, "_set_new_handler"); + + hcon = LoadLibraryA( CONCRT_NAME(_MSVCP_VER) ); + if (!hcon) FIXME( "%s not loaded\n", CONCRT_NAME(_MSVCP_VER) ); #else if (sizeof(void *) > sizeof(int)) /* 64-bit has different names */ { MSVCRT_operator_new = (void*)GetProcAddress(hmod, "??2(a)YAPEAX_K@Z"); MSVCRT_operator_delete = (void*)GetProcAddress(hmod, "??3(a)YAXPEAX@Z"); MSVCRT_set_new_handler = (void*)GetProcAddress(hmod, "?_set_new_handler@@YAP6AH_K(a)ZP6AH0@Z(a)Z"); - -#if _MSVCP_VER >= 110 - critical_section_ctor = (void*)GetProcAddress(hmod, "??0critical_section(a)Concurrency@@QEAA(a)XZ"); - critical_section_dtor = (void*)GetProcAddress(hmod, "??1critical_section(a)Concurrency@@QEAA(a)XZ"); - critical_section_lock = (void*)GetProcAddress(hmod, "?lock(a)critical_section@Concurrency@@QEAAXXZ"); - critical_section_unlock = (void*)GetProcAddress(hmod, "?unlock(a)critical_section@Concurrency@@QEAAXXZ"); - critical_section_trylock = (void*)GetProcAddress(hmod, "?try_lock(a)critical_section@Concurrency@@QEAA_NXZ"); -#endif } else { MSVCRT_operator_new = (void*)GetProcAddress(hmod, "??2(a)YAPAXI@Z"); MSVCRT_operator_delete = (void*)GetProcAddress(hmod, "??3(a)YAXPAX@Z"); MSVCRT_set_new_handler = (void*)GetProcAddress(hmod, "?_set_new_handler@@YAP6AHI(a)ZP6AHI@Z(a)Z"); + } +#endif #if _MSVCP_VER >= 110 + if (sizeof(void *) > sizeof(int)) /* 64-bit has different names */ + { + critical_section_ctor = (void*)GetProcAddress(hcon, "??0critical_section(a)Concurrency@@QEAA(a)XZ"); + critical_section_dtor = (void*)GetProcAddress(hcon, "??1critical_section(a)Concurrency@@QEAA(a)XZ"); + critical_section_lock = (void*)GetProcAddress(hcon, "?lock(a)critical_section@Concurrency@@QEAAXXZ"); + critical_section_unlock = (void*)GetProcAddress(hcon, "?unlock(a)critical_section@Concurrency@@QEAAXXZ"); + critical_section_trylock = (void*)GetProcAddress(hcon, "?try_lock(a)critical_section@Concurrency@@QEAA_NXZ"); + } + else + { #ifdef __arm__ - critical_section_ctor = (void*)GetProcAddress(hmod, "??0critical_section(a)Concurrency@@QAA(a)XZ"); - critical_section_dtor = (void*)GetProcAddress(hmod, "??1critical_section(a)Concurrency@@QAA(a)XZ"); - critical_section_lock = (void*)GetProcAddress(hmod, "?lock(a)critical_section@Concurrency@@QAAXXZ"); - critical_section_unlock = (void*)GetProcAddress(hmod, "?unlock(a)critical_section@Concurrency@@QAAXXZ"); - critical_section_trylock = (void*)GetProcAddress(hmod, "?try_lock(a)critical_section@Concurrency@@QAA_NXZ"); + critical_section_ctor = (void*)GetProcAddress(hcon, "??0critical_section(a)Concurrency@@QAA(a)XZ"); + critical_section_dtor = (void*)GetProcAddress(hcon, "??1critical_section(a)Concurrency@@QAA(a)XZ"); + critical_section_lock = (void*)GetProcAddress(hcon, "?lock(a)critical_section@Concurrency@@QAAXXZ"); + critical_section_unlock = (void*)GetProcAddress(hcon, "?unlock(a)critical_section@Concurrency@@QAAXXZ"); + critical_section_trylock = (void*)GetProcAddress(hcon, "?try_lock(a)critical_section@Concurrency@@QAA_NXZ"); #else - critical_section_ctor = (void*)GetProcAddress(hmod, "??0critical_section(a)Concurrency@@QAE(a)XZ"); - critical_section_dtor = (void*)GetProcAddress(hmod, "??1critical_section(a)Concurrency@@QAE(a)XZ"); - critical_section_lock = (void*)GetProcAddress(hmod, "?lock(a)critical_section@Concurrency@@QAEXXZ"); - critical_section_unlock = (void*)GetProcAddress(hmod, "?unlock(a)critical_section@Concurrency@@QAEXXZ"); - critical_section_trylock = (void*)GetProcAddress(hmod, "?try_lock(a)critical_section@Concurrency@@QAE_NXZ"); + critical_section_ctor = (void*)GetProcAddress(hcon, "??0critical_section(a)Concurrency@@QAE(a)XZ"); + critical_section_dtor = (void*)GetProcAddress(hcon, "??1critical_section(a)Concurrency@@QAE(a)XZ"); + critical_section_lock = (void*)GetProcAddress(hcon, "?lock(a)critical_section@Concurrency@@QAEXXZ"); + critical_section_unlock = (void*)GetProcAddress(hcon, "?unlock(a)critical_section@Concurrency@@QAEXXZ"); + critical_section_trylock = (void*)GetProcAddress(hcon, "?try_lock(a)critical_section@Concurrency@@QAE_NXZ"); #endif -#endif /* _MSVCP_VER >= 110 */ } -#endif +#endif /* _MSVCP_VER >= 110 */ } BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)