-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
41 lines (32 loc) · 923 Bytes
/
main.cpp
File metadata and controls
41 lines (32 loc) · 923 Bytes
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 <cassert>
#include <memory>
import radiance.hook.dispatcher;
import radiance;
void __attribute__((noinline)) test_stack_args(int a, int b, int c, int d)
{
char buf[128];
__builtin_snprintf(buf, sizeof(buf), "Args: %d %d %d %d", a, b, c, d);
MessageBoxA(nullptr, buf, "Original Function", MB_OK);
}
void hk_test_stack_args(int a, int b, int c, int d)
{
char buf[128];
__builtin_snprintf(buf, sizeof(buf), "HOOKED Args: %d %d %d %d", a, b, c, d);
MessageBoxA(nullptr, buf, "Hooked Function", MB_OK);
test_stack_args(1, 3, 3, 7);
}
int main()
{
radiance::C_Radiance radiance;
auto hook = radiance.create(
reinterpret_cast<void*>(test_stack_args),
reinterpret_cast<void*>(hk_test_stack_args)
);
if (!hook) {
assert("Unable to set hook!");
return -1;
}
test_stack_args(11, 22, 33, 44);
return 0;
}