1 /**
2 * Windows DLL entry points.
3 *
4 * Copyright: Copyright Auburn Sounds 2015-2016.
5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
6 * Authors: Guillaume Piolat
7 */
8 module dplug.client.dllmain;
9
10 // Dynamic libraries entry point.
11 // Basically only needed on Windows, on OSX we have other entry points.
12
13 version = doNotUseRuntime;
14
15 version(Windows)
16 {
17 version(doNotUseRuntime)
18 {
19 template DLLEntryPoint()
20 {
21 const char[] DLLEntryPoint = q{
22 import std.c.windows.windows;
23 import core.sys.windows.dll;
24 extern (Windows) BOOL DllMain(HINSTANCE hInstance, ULONG ulReason, LPVOID pvReserved)
25 {
26 return true;
27 }
28 };
29 }
30 }
31 else
32 {
33 template DLLEntryPoint()
34 {
35 const char[] DLLEntryPoint = q{
36 import std.c.windows.windows;
37 import core.sys.windows.dll;
38
39 extern (Windows) BOOL DllMain(HINSTANCE hInstance, ULONG ulReason, LPVOID pvReserved)
40 {
41 switch (ulReason)
42 {
43 case DLL_PROCESS_ATTACH:
44 dll_process_attach(hInstance, false);
45 break;
46
47 case DLL_PROCESS_DETACH:
48 dll_process_detach(hInstance, true);
49 break;
50
51 case DLL_THREAD_ATTACH:
52 dll_thread_attach(false, true);
53 break;
54
55 case DLL_THREAD_DETACH:
56 dll_thread_detach(false, true);
57 break;
58
59 default:
60 break;
61 }
62 return true;
63 }
64 };
65 }
66 }
67 }
68 else
69 {
70 template DLLEntryPoint()
71 {
72 const char[] DLLEntryPoint = ``;
73 }
74 }
75