Daniel Lehman : msvcp140: Load critical_section functions from concrt140.

Alexandre Julliard julliard at winehq.org
Mon Aug 8 11:09:28 CDT 2016


Module: wine
Branch: master
Commit: d12235ab79d5cf2538a12ccd15e780787f089e17
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=d12235ab79d5cf2538a12ccd15e780787f089e17

Author: Daniel Lehman <dlehman at esri.com>
Date:   Thu May 26 17:49:43 2016 -0700

msvcp140: Load critical_section functions from concrt140.

Signed-off-by: Daniel Lehman <dlehman at esri.com>
Signed-off-by: Piotr Caban <piotr at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at 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 at YAPEAX_K@Z");
         MSVCRT_operator_delete = (void*)GetProcAddress(hmod, "??3 at YAXPEAX@Z");
         MSVCRT_set_new_handler = (void*)GetProcAddress(hmod, "?_set_new_handler@@YAP6AH_K at ZP6AH0@Z at Z");
-
-#if _MSVCP_VER >= 110
-        critical_section_ctor = (void*)GetProcAddress(hmod, "??0critical_section at Concurrency@@QEAA at XZ");
-        critical_section_dtor = (void*)GetProcAddress(hmod, "??1critical_section at Concurrency@@QEAA at XZ");
-        critical_section_lock = (void*)GetProcAddress(hmod, "?lock at critical_section@Concurrency@@QEAAXXZ");
-        critical_section_unlock = (void*)GetProcAddress(hmod, "?unlock at critical_section@Concurrency@@QEAAXXZ");
-        critical_section_trylock = (void*)GetProcAddress(hmod, "?try_lock at critical_section@Concurrency@@QEAA_NXZ");
-#endif
     }
     else
     {
         MSVCRT_operator_new = (void*)GetProcAddress(hmod, "??2 at YAPAXI@Z");
         MSVCRT_operator_delete = (void*)GetProcAddress(hmod, "??3 at YAXPAX@Z");
         MSVCRT_set_new_handler = (void*)GetProcAddress(hmod, "?_set_new_handler@@YAP6AHI at ZP6AHI@Z at Z");
+    }
+#endif
 
 #if _MSVCP_VER >= 110
+    if (sizeof(void *) > sizeof(int))  /* 64-bit has different names */
+    {
+        critical_section_ctor = (void*)GetProcAddress(hcon, "??0critical_section at Concurrency@@QEAA at XZ");
+        critical_section_dtor = (void*)GetProcAddress(hcon, "??1critical_section at Concurrency@@QEAA at XZ");
+        critical_section_lock = (void*)GetProcAddress(hcon, "?lock at critical_section@Concurrency@@QEAAXXZ");
+        critical_section_unlock = (void*)GetProcAddress(hcon, "?unlock at critical_section@Concurrency@@QEAAXXZ");
+        critical_section_trylock = (void*)GetProcAddress(hcon, "?try_lock at critical_section@Concurrency@@QEAA_NXZ");
+    }
+    else
+    {
 #ifdef __arm__
-        critical_section_ctor = (void*)GetProcAddress(hmod, "??0critical_section at Concurrency@@QAA at XZ");
-        critical_section_dtor = (void*)GetProcAddress(hmod, "??1critical_section at Concurrency@@QAA at XZ");
-        critical_section_lock = (void*)GetProcAddress(hmod, "?lock at critical_section@Concurrency@@QAAXXZ");
-        critical_section_unlock = (void*)GetProcAddress(hmod, "?unlock at critical_section@Concurrency@@QAAXXZ");
-        critical_section_trylock = (void*)GetProcAddress(hmod, "?try_lock at critical_section@Concurrency@@QAA_NXZ");
+        critical_section_ctor = (void*)GetProcAddress(hcon, "??0critical_section at Concurrency@@QAA at XZ");
+        critical_section_dtor = (void*)GetProcAddress(hcon, "??1critical_section at Concurrency@@QAA at XZ");
+        critical_section_lock = (void*)GetProcAddress(hcon, "?lock at critical_section@Concurrency@@QAAXXZ");
+        critical_section_unlock = (void*)GetProcAddress(hcon, "?unlock at critical_section@Concurrency@@QAAXXZ");
+        critical_section_trylock = (void*)GetProcAddress(hcon, "?try_lock at critical_section@Concurrency@@QAA_NXZ");
 #else
-        critical_section_ctor = (void*)GetProcAddress(hmod, "??0critical_section at Concurrency@@QAE at XZ");
-        critical_section_dtor = (void*)GetProcAddress(hmod, "??1critical_section at Concurrency@@QAE at XZ");
-        critical_section_lock = (void*)GetProcAddress(hmod, "?lock at critical_section@Concurrency@@QAEXXZ");
-        critical_section_unlock = (void*)GetProcAddress(hmod, "?unlock at critical_section@Concurrency@@QAEXXZ");
-        critical_section_trylock = (void*)GetProcAddress(hmod, "?try_lock at critical_section@Concurrency@@QAE_NXZ");
+        critical_section_ctor = (void*)GetProcAddress(hcon, "??0critical_section at Concurrency@@QAE at XZ");
+        critical_section_dtor = (void*)GetProcAddress(hcon, "??1critical_section at Concurrency@@QAE at XZ");
+        critical_section_lock = (void*)GetProcAddress(hcon, "?lock at critical_section@Concurrency@@QAEXXZ");
+        critical_section_unlock = (void*)GetProcAddress(hcon, "?unlock at critical_section@Concurrency@@QAEXXZ");
+        critical_section_trylock = (void*)GetProcAddress(hcon, "?try_lock at critical_section@Concurrency@@QAE_NXZ");
 #endif
-#endif /* _MSVCP_VER >= 110 */
     }
-#endif
+#endif /* _MSVCP_VER >= 110 */
 }
 
 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)




More information about the wine-cvs mailing list