forked from wrenchonline/copydllhook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOurDoorToolx64.cpp
52 lines (52 loc) · 1.33 KB
/
OurDoorToolx64.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
48
49
50
51
52
#include <stdio.h>
#include <windows.h>
#define WM_UPDATE_STATIC (WM_USER + 0x100)
#define WM_EXITPROCESS (WM_USER + 0x103)
void(WINAPI *InstallHook)();
void(WINAPI *UnstallHook)();
PVOID LoadDllFunc(LPCTSTR lpFileName, LPCSTR lpProcName){
PVOID insthook;
HINSTANCE hinst = NULL;
hinst = LoadLibrary(lpFileName);
if (!hinst)
return NULL;
insthook = GetProcAddress(hinst, lpProcName);
if (!insthook)
return NULL;
return insthook;
}
BOOLEAN init() {
InstallHook = (void (WINAPI*)())LoadDllFunc(TEXT("copyDllHookx64.dll"), "StartHookMsg");
UnstallHook = (void(WINAPI*)())LoadDllFunc(TEXT("copyDllHookx64.dll"), "EndHookMsg");
if (InstallHook != NULL && UnstallHook != NULL)
return TRUE;
return FALSE;
}
void main() {
MSG msg = { 0 };
BOOLEAN bRet;
char ConsoleTitle[1024] = {0};
if (init())
InstallHook();
else
return;
SetConsoleTitleA("Wrenchx64");
GetConsoleTitleA(ConsoleTitle, 1024);
HWND PWND = FindWindowA(NULL, ConsoleTitle);
printf_s("ConsoleTitle:%s PWND:%08x \n", ConsoleTitle, PWND);
while (GetMessageA(&msg, NULL, 0, WM_USER + 0x103))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
if (msg.message == WM_EXITPROCESS)
{
if (msg.lParam == 0 && msg.wParam == 0)
{
printf_s("process exit,UnstallHooking...");
UnstallHook();
printf_s("okey,bye~");
exit(0);
}
}
}
}