Skip to content

Commit 0d30b1f

Browse files
committed
Export dllmain and combine to 1
Signed-off-by: Brandon Yates <[email protected]>
1 parent 638f9c3 commit 0d30b1f

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

source/lib/windows/lib_init.cpp

+18-1
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,32 @@
77
*/
88

99
#include "../ze_lib.h"
10+
#ifndef DYNAMIC_LOAD_LOADER
11+
#include "../loader/ze_loader.h"
12+
#endif
1013

1114
namespace ze_lib
1215
{
13-
BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
16+
#ifdef DYNAMIC_LOAD_LOADER
17+
export "C" BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
1418
if (fdwReason == DLL_PROCESS_DETACH) {
1519
delete context;
1620
} else if (fdwReason == DLL_PROCESS_ATTACH) {
1721
context = new context_t;
1822
}
1923
return TRUE;
2024
}
25+
#else
26+
extern "C" BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
27+
if (fdwReason == DLL_PROCESS_DETACH) {
28+
delete context;
29+
delete loader::context;
30+
} else if (fdwReason == DLL_PROCESS_ATTACH) {
31+
context = new context_t;
32+
loader::context = new loader::context_t;
33+
}
34+
return TRUE;
35+
}
36+
37+
#endif
2138
}

source/loader/windows/loader_init.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@
1010

1111
namespace loader
1212
{
13-
BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
13+
#ifdef DYNAMIC_LOAD_LOADER
14+
extern "C" BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
1415
if (fdwReason == DLL_PROCESS_DETACH) {
1516
delete context;
1617
} else if (fdwReason == DLL_PROCESS_ATTACH) {
1718
context = new context_t;
1819
}
1920
return TRUE;
2021
}
22+
#endif
2123
}

0 commit comments

Comments
 (0)