-
Notifications
You must be signed in to change notification settings - Fork 0
/
dllmain.cpp
48 lines (44 loc) · 1.13 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
42
43
44
45
46
47
// dllmain.cpp : Defines the entry point for the DLL application.
#include "stdafx.h"
#include "commutils.h"
#include "utils.h"
#include "LogObject.h"
#include "HookImplementObject.h"
using namespace cchips;
BOOL g_initSuccess = FALSE;
BOOL APIENTRY DllMain(HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
{
// please don't block the dllmain, We can not do much more here, because it is risky.
//#ifdef _X86_
// __asm int 3
//#else
// BreakInt3();
//#endif
g_is_dll_module = true;
std::shared_ptr<CHipsCfgObject> hipsCfgObject = InitializeConfig();
if (hipsCfgObject != nullptr)
g_initSuccess = InitializeHook(std::move(hipsCfgObject));
}
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
if (g_initSuccess && g_impl_object)
g_impl_object->AddFilterThread(std::this_thread::get_id());
break;
case DLL_PROCESS_DETACH:
if (g_initSuccess)
{
UninitialHook();
}
break;
}
return TRUE;
}