1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | #ifdef _MSC_VER
|
11 |
|
12 | #pragma managed(push, off)
|
13 |
|
14 | #ifndef WIN32_LEAN_AND_MEAN
|
15 | #define WIN32_LEAN_AND_MEAN
|
16 | #endif
|
17 |
|
18 | #include <windows.h>
|
19 |
|
20 | #include <delayimp.h>
|
21 | #include <string.h>
|
22 |
|
23 | static FARPROC WINAPI load_exe_hook(unsigned int event, DelayLoadInfo* info) {
|
24 | HMODULE m;
|
25 | if (event != dliNotePreLoadLibrary)
|
26 | return NULL;
|
27 |
|
28 | if (_stricmp(info->szDll, HOST_BINARY) != 0)
|
29 | return NULL;
|
30 |
|
31 | m = GetModuleHandle(NULL);
|
32 | return (FARPROC) m;
|
33 | }
|
34 |
|
35 | decltype(__pfnDliNotifyHook2) __pfnDliNotifyHook2 = load_exe_hook;
|
36 |
|
37 | #pragma managed(pop)
|
38 |
|
39 | #endif
|