-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.c
41 lines (36 loc) · 1.23 KB
/
main.c
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 <stdio.h>
#include <windows.h>
#include "WinHook.h"
typedef int(__stdcall* MESSAGEBOXA)(HWND, LPCSTR, LPCSTR, UINT);
typedef struct {
MESSAGEBOXA pFunc;
char Text[10];
} data;
int NewMessageBox(HWND hWnd, LPCSTR lpText, LPCSTR lpCation, UINT uType)
{
#ifdef _WIN64
volatile data *Data = 0xCCCCCCCCCCCCCCCC;
#else
volatile data *Data = 0xCCCCCCCC;
#endif
return ((MESSAGEBOXA)Data->pFunc)(hWnd, Data->Text, Data->Text, uType);
}
int AtherFunc() {}
int main()
{
data Data;
strcpy(Data.Text, "Hooked!");
WINAPI_BASIC_HOOK_DATAA WinApi_Basic_Hook_Data;
strcpy(WinApi_Basic_Hook_Data.DLLName, "user32.dll");
WinApi_Basic_Hook_Data.lpOrigin = MessageBoxA;
WinApi_Basic_Hook_Data.lpNewFunction = NewMessageBox;
WinApi_Basic_Hook_Data.lpParameter = &Data;
WinApi_Basic_Hook_Data.Parameter = TRUE;
WinApi_Basic_Hook_Data.dwParameterSize = sizeof(data);
WinApi_Basic_Hook_Data.dwNewFuncSize = (Address)AtherFunc - (Address)NewMessageBox;
WinApi_Basic_Hook_Data.lpCopyOrigin = &Data.pFunc;
// DWORD PID;
// scanf("%d", &PID);
// HookA(&WinApi_Basic_Hook_Data, NULL, "TEST.exe");
// HookA(&WinApi_Basic_Hook_Data, PID, NULL);
}