diff options
author | Toni Uhlig <matzeton@googlemail.com> | 2019-09-29 14:44:10 +0200 |
---|---|---|
committer | Toni Uhlig <matzeton@googlemail.com> | 2019-09-29 14:44:10 +0200 |
commit | 89b400e414c29163d0219d9abc2189148fd34478 (patch) | |
tree | 2d383e406da126cda724f7af01f283669dd2ab29 /TestDLL | |
parent | 955085e7ff3538a3e1bfc35f19670fb6c59b3ae7 (diff) |
We need to unlink the VAD _after_ the MS CRT was initialized to prevent crashing the process.
Diffstat (limited to 'TestDLL')
-rw-r--r-- | TestDLL/dllmain.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/TestDLL/dllmain.cpp b/TestDLL/dllmain.cpp index 2cbb478..2841415 100644 --- a/TestDLL/dllmain.cpp +++ b/TestDLL/dllmain.cpp @@ -5,9 +5,9 @@ #include <sstream> #include <array> -#pragma comment(lib, "vcruntime.lib") - +EXTERN_C BOOL WINAPI _CRT_INIT(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved); +#if 0 struct ResolvedDllEntry { const char * const baseDllName; const char * const functionName; @@ -170,7 +170,7 @@ static bool resolve_all_symbols(void) { return result; } - +#endif void APIENTRY LibEntry(PVOID user_ptr) { @@ -178,7 +178,7 @@ void APIENTRY LibEntry(PVOID user_ptr) if (firstEntry) { firstEntry = false; - +#if 0 if (!resolve_all_symbols()) { MessageBoxA(NULL, "COULD NOT RESOLVE ALL DYNAMIC DLL SYMBOLS !!!", @@ -188,7 +188,10 @@ void APIENTRY LibEntry(PVOID user_ptr) } void *bla = malloc(10); free(bla); +#endif #if 1 + HINSTANCE addr = GetModuleHandle(NULL); + _CRT_INIT(addr, DLL_PROCESS_ATTACH, NULL); std::string text; std::vector<DWORD> blubb; text = "DllMain from TestDLL: "; @@ -200,6 +203,12 @@ void APIENTRY LibEntry(PVOID user_ptr) text.c_str(), "TestDLL Notification", MB_OK | MB_ICONINFORMATION); + char buf[128]; + snprintf(buf, sizeof buf, "_%s_\n", "bla"); + MessageBoxA(NULL, + buf, + "TestDLL Notification", + MB_OK | MB_ICONINFORMATION); #else MessageBoxA(NULL, "TEST !!!", |