-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
eda4994
commit 6f28e2a
Showing
1 changed file
with
35 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,43 @@ | ||
// dllmain.cpp : Defines the entry point for the DLL application. | ||
#include "framework.hpp" | ||
|
||
BOOL APIENTRY DllMain( HMODULE hModule, | ||
DWORD ul_reason_for_call, | ||
LPVOID lpReserved | ||
) | ||
{ | ||
switch (ul_reason_for_call) | ||
{ | ||
#ifdef _MSC_VER | ||
#include <Windows.h> | ||
|
||
#include <iostream> | ||
#include <string_view> | ||
|
||
int DebugReportHook(int reportType, char* message, int* returnValue) { | ||
const auto type = [=]() -> std::string_view { | ||
switch (reportType) { | ||
case _CRT_WARN: | ||
return "[WARNING]"; | ||
case _CRT_ERROR: | ||
return "[ERROR]"; | ||
case _CRT_ASSERT: | ||
return "[ASSERT]"; | ||
default: | ||
return "[UNKNOWN]"; | ||
} | ||
}(); | ||
|
||
std::cerr << type << ' ' << message << std::endl; | ||
throw std::runtime_error(message); | ||
} | ||
#else | ||
#define _CrtSetReportHook(x) | ||
#endif // _MSC_VER | ||
|
||
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, | ||
LPVOID lpReserved) { | ||
_CrtSetReportHook(DebugReportHook); | ||
|
||
switch (ul_reason_for_call) { | ||
case DLL_PROCESS_ATTACH: | ||
case DLL_THREAD_ATTACH: | ||
case DLL_THREAD_DETACH: | ||
case DLL_PROCESS_DETACH: | ||
break; | ||
} | ||
return TRUE; | ||
break; | ||
} | ||
return TRUE; | ||
} | ||
|