diff OrthancFramework/SharedLibrary/DllMain.cpp @ 5277:acaea72a3e91 Orthanc-1.12.0

Orthanc-1.12.0
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 14 Apr 2023 17:31:27 +0200
parents 0ea402b4d901
children 48b8dae6dc77
line wrap: on
line diff
--- a/OrthancFramework/SharedLibrary/DllMain.cpp	Fri Apr 14 13:20:24 2023 +0200
+++ b/OrthancFramework/SharedLibrary/DllMain.cpp	Fri Apr 14 17:31:27 2023 +0200
@@ -27,35 +27,55 @@
    ${BOOST_SOURCES_DIR}/libs/thread/src/win32/tss_dll.cpp
    ${OPENSSL_SOURCES_DIR}/crypto/dllmain.c
 
- **/
+**/
 
 #if defined(_WIN32) || defined(__CYGWIN__)
-# ifdef __CYGWIN__
-#  include <windows.h>
-# endif
+
+#include <boost/thread/detail/tss_hooks.hpp>
+
+#include <windows.h>
+
+#include <crypto/cryptlib.h>
 
-#include "e_os.h"
-#include "crypto/cryptlib.h"
-
-BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
+#if defined(__BORLANDC__)
+extern "C" BOOL WINAPI DllEntryPoint(HINSTANCE /*hInstance*/, DWORD dwReason, LPVOID /*lpReserved*/)
+#elif defined(_WIN32_WCE)
+  extern "C" BOOL WINAPI DllMain(HANDLE /*hInstance*/, DWORD dwReason, LPVOID /*lpReserved*/)
+#else
+  extern "C" BOOL WINAPI DllMain(HINSTANCE /*hInstance*/, DWORD dwReason, LPVOID /*lpReserved*/)
+#endif
 {
-  switch (fdwReason)
+  switch(dwReason)
   {
     case DLL_PROCESS_ATTACH:
+    {
       //OPENSSL_cpuid_setup();  // TODO - Is this necessary?
+      boost::on_process_enter();
+      boost::on_thread_enter();
       break;
-        
+    }
+
     case DLL_THREAD_ATTACH:
+    {
+      boost::on_thread_enter();
       break;
-        
+    }
+
     case DLL_THREAD_DETACH:
+    {
       OPENSSL_thread_stop();
+      boost::on_thread_exit();
       break;
-        
+    }
+
     case DLL_PROCESS_DETACH:
+    {
+      boost::on_thread_exit();
+      boost::on_process_exit();
       break;
+    }
   }
-    
+
   return TRUE;
 }