-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
60 lines (53 loc) · 1.66 KB
/
main.cpp
File metadata and controls
60 lines (53 loc) · 1.66 KB
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
48
49
50
51
52
53
54
55
56
57
58
#include "main.h"
#include "mainthread.h"
#include "minhook/include/MinHook.h"
FILE* f;
HINSTANCE g_inst;
extern "C" DLL_EXPORT BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
g_inst = hinstDLL;
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
AllocConsole();
freopen_s(&f, "CONOUT$", "w", stdout);
printf("MH_Initialize...");
if (MH_Initialize() != MH_OK)
{
printf("FAIL!\n");
MessageBoxA(NULL, "MinHook Initialize Failed", "MinHook Error", MB_OK | MB_ICONERROR);
fclose(f);
FreeConsole();
return FALSE;
}
printf("OK!\n");
printf("InitHooksPre...");
if(InitHooksPre()) // 1 = fail
{
printf("FAIL!\n");
MessageBoxA(NULL, "Failed to hook Pre-Init functions", "MinHook Error", MB_OK | MB_ICONERROR);
fclose(f);
FreeConsole();
return FALSE;
}
printf("OK!\n");
printf("Creating TMStuff thread...\n");
CreateThread(0, 0, MainThread, hinstDLL, 0, 0);
// attach to process
// return FALSE to fail DLL load
break;
case DLL_PROCESS_DETACH:
UninitHooks();
fclose(f);
FreeConsole();
// detach from process
break;
case DLL_THREAD_ATTACH:
// attach to thread
break;
case DLL_THREAD_DETACH:
// detach from thread
break;
}
return TRUE; // succesful
}