forked from dschu012/d2lootfilter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dllmain.cpp
42 lines (36 loc) · 1 KB
/
dllmain.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <Windows.h>
#include "ItemFilter.h"
void Error(const wchar_t* wszMessage) {
MessageBox(nullptr, wszMessage, L"Error", MB_OK | MB_ICONSTOP);
exit(0);
}
BOOL DllAttach() {
#ifdef _DEBUG
AllocConsole();
AttachConsole(GetCurrentProcessId());
freopen_s(reinterpret_cast<FILE**>(stdin), "CONIN$", "r", stdin);
freopen_s(reinterpret_cast<FILE**>(stdout), "CONOUT$", "w", stdout);
freopen_s(reinterpret_cast<FILE**>(stderr), "CONOUT$", "w", stderr);
#endif
if (GetGameVersion() == D2Version::ERR) {
Error(L"Could not determine the game version.");
}
ItemFilter::Initialize();
return TRUE;
}
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
return DllAttach();
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}