annotate OrthancFramework/SharedLibrary/DllMain.cpp @ 5669:f690568f0325

Fix C-Find queries not returning computed tags in very specific use-cases
author Alain Mazy <am@orthanc.team>
date Fri, 05 Jul 2024 19:18:23 +0200
parents f7adfb22e20e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4106
50cb0fb99e34 added license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4063
diff changeset
1 /**
50cb0fb99e34 added license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4063
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
50cb0fb99e34 added license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4063
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
50cb0fb99e34 added license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4063
diff changeset
4 * Department, University Hospital of Liege, Belgium
5640
f7adfb22e20e updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5485
diff changeset
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium
f7adfb22e20e updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5485
diff changeset
6 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium
5485
48b8dae6dc77 upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5277
diff changeset
7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
4106
50cb0fb99e34 added license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4063
diff changeset
8 *
50cb0fb99e34 added license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4063
diff changeset
9 * This program is free software: you can redistribute it and/or
4119
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4106
diff changeset
10 * modify it under the terms of the GNU Lesser General Public License
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4106
diff changeset
11 * as published by the Free Software Foundation, either version 3 of
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4106
diff changeset
12 * the License, or (at your option) any later version.
4106
50cb0fb99e34 added license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4063
diff changeset
13 *
50cb0fb99e34 added license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4063
diff changeset
14 * This program is distributed in the hope that it will be useful, but
50cb0fb99e34 added license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4063
diff changeset
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
50cb0fb99e34 added license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4063
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4119
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4106
diff changeset
17 * Lesser General Public License for more details.
4106
50cb0fb99e34 added license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4063
diff changeset
18 *
4119
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4106
diff changeset
19 * You should have received a copy of the GNU Lesser General Public
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4106
diff changeset
20 * License along with this program. If not, see
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4106
diff changeset
21 * <http://www.gnu.org/licenses/>.
4106
50cb0fb99e34 added license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4063
diff changeset
22 **/
50cb0fb99e34 added license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4063
diff changeset
23
50cb0fb99e34 added license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4063
diff changeset
24
4063
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 /**
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 This file merges 2 files:
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 ${BOOST_SOURCES_DIR}/libs/thread/src/win32/tss_dll.cpp
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 ${OPENSSL_SOURCES_DIR}/crypto/dllmain.c
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30
5277
acaea72a3e91 Orthanc-1.12.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
31 **/
4063
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 #if defined(_WIN32) || defined(__CYGWIN__)
5277
acaea72a3e91 Orthanc-1.12.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
34
acaea72a3e91 Orthanc-1.12.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
35 #include <boost/thread/detail/tss_hooks.hpp>
acaea72a3e91 Orthanc-1.12.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
36
acaea72a3e91 Orthanc-1.12.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
37 #include <windows.h>
acaea72a3e91 Orthanc-1.12.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
38
acaea72a3e91 Orthanc-1.12.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
39 #include <crypto/cryptlib.h>
4063
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40
5277
acaea72a3e91 Orthanc-1.12.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
41 #if defined(__BORLANDC__)
acaea72a3e91 Orthanc-1.12.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
42 extern "C" BOOL WINAPI DllEntryPoint(HINSTANCE /*hInstance*/, DWORD dwReason, LPVOID /*lpReserved*/)
acaea72a3e91 Orthanc-1.12.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
43 #elif defined(_WIN32_WCE)
acaea72a3e91 Orthanc-1.12.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
44 extern "C" BOOL WINAPI DllMain(HANDLE /*hInstance*/, DWORD dwReason, LPVOID /*lpReserved*/)
acaea72a3e91 Orthanc-1.12.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
45 #else
acaea72a3e91 Orthanc-1.12.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
46 extern "C" BOOL WINAPI DllMain(HINSTANCE /*hInstance*/, DWORD dwReason, LPVOID /*lpReserved*/)
acaea72a3e91 Orthanc-1.12.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
47 #endif
4063
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 {
5277
acaea72a3e91 Orthanc-1.12.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
49 switch(dwReason)
4063
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 {
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 case DLL_PROCESS_ATTACH:
5277
acaea72a3e91 Orthanc-1.12.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
52 {
4063
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 //OPENSSL_cpuid_setup(); // TODO - Is this necessary?
5277
acaea72a3e91 Orthanc-1.12.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
54 boost::on_process_enter();
acaea72a3e91 Orthanc-1.12.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
55 boost::on_thread_enter();
4063
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 break;
5277
acaea72a3e91 Orthanc-1.12.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
57 }
acaea72a3e91 Orthanc-1.12.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
58
4063
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 case DLL_THREAD_ATTACH:
5277
acaea72a3e91 Orthanc-1.12.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
60 {
acaea72a3e91 Orthanc-1.12.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
61 boost::on_thread_enter();
4063
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 break;
5277
acaea72a3e91 Orthanc-1.12.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
63 }
acaea72a3e91 Orthanc-1.12.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
64
4063
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 case DLL_THREAD_DETACH:
5277
acaea72a3e91 Orthanc-1.12.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
66 {
4063
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 OPENSSL_thread_stop();
5277
acaea72a3e91 Orthanc-1.12.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
68 boost::on_thread_exit();
4063
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 break;
5277
acaea72a3e91 Orthanc-1.12.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
70 }
acaea72a3e91 Orthanc-1.12.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
71
4063
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 case DLL_PROCESS_DETACH:
5277
acaea72a3e91 Orthanc-1.12.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
73 {
acaea72a3e91 Orthanc-1.12.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
74 boost::on_thread_exit();
acaea72a3e91 Orthanc-1.12.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
75 boost::on_process_exit();
4063
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 break;
5277
acaea72a3e91 Orthanc-1.12.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
77 }
4063
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 }
5277
acaea72a3e91 Orthanc-1.12.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
79
4063
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 return TRUE;
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 }
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 #endif
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 namespace boost
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 {
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 void tss_cleanup_implemented()
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 {
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 /*
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 This function's sole purpose is to cause a link error in cases where
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 automatic tss cleanup is not implemented by Boost.Threads as a
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 reminder that user code is responsible for calling the necessary
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 functions at the appropriate times (and for implementing an a
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 tss_cleanup_implemented() function to eliminate the linker's
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 missing symbol error).
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 If Boost.Threads later implements automatic tss cleanup in cases
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 where it currently doesn't (which is the plan), the duplicate
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 symbol error will warn the user that their custom solution is no
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 longer needed and can be removed.
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 */
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 }
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 }
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105