@@ -10,48 +10,64 @@ bool install_menu_hook() {
10
10
}
11
11
12
12
13
- // fn_ptr_t tmp_global_i_hate_this_variable = nullptr; //gone?
14
13
bool install_menu_hook (fn_ptr_t fn) {
15
14
bool hooked = false ;
16
15
uintptr_t src = blurAPI->moduleBase + HOOK_MENU_FUNC_ADDY;
17
- fn_ptr_t t = install_void_hook ((void *) src, menu_hook_func , HOOK_MENU_FUNC_INS_LEN);
16
+ fn_ptr_t t = install_void_hook ((void *) src, hook_menu_leave , HOOK_MENU_FUNC_INS_LEN);
18
17
if (t) {
19
- blurAPI->hooks .fn = fn;
20
- blurAPI->hooks .fn_trampoline = t;
21
- // tmp_global_i_hate_this_variable = t; //PLEASE I DONT LIKE YOU SO JUST WORK (FIXED?)
18
+ blurAPI->hooks .fn_menu_callback = fn;
19
+ blurAPI->hooks .fn_menu_trampoline = t;
22
20
hooked = true ;
23
21
}
24
22
return hooked;
25
23
}
26
24
27
- void __declspec (naked) menu_hook_func() {
25
+
26
+ // https://www.agner.org/optimize/calling_conventions.pdf
27
+ // its a __thiscall, pointer to __THIS @ ECX register
28
+ void __declspec (naked) hook_menu_leave() {
29
+ /* no direct innits in __declspec(naked) funcs */
28
30
void * f;
29
- f = blurAPI->hooks .fn_trampoline ; // like this it works...
31
+ f = blurAPI->hooks .fn_menu_trampoline ;
30
32
__asm PUSHAD;
31
33
__asm PUSHFD;
32
34
__asm nop;
33
35
__asm nop;
34
- (blurAPI->hooks .fn )();
36
+ (blurAPI->hooks .fn_menu_callback )();
35
37
__asm nop;
36
38
__asm nop;
37
39
__asm POPFD;
38
40
__asm POPAD;
39
41
__asm jmp [f];
40
- // __asm jmp [tmp_global_i_hate_this_variable];
41
- // __asm jmp [blurAPI->hooks.fn_trampoline];
42
- // (blurAPI->hooks.fn_trampoline)();
43
42
}
44
43
45
44
46
45
void fn_hello_world () {
47
- if (blurAPI->set_LAN_name (blurAPI->config .user_name )) {
48
- blurAPI->console .print (" SET NAME TO: [" + blurAPI->config .user_name + " ]" );
49
- } else {
50
- blurAPI->console .print (" FAILED TO SET NAME TO: [" + blurAPI->config .user_name + " ]" );
51
- }
46
+ blurAPI->console .print (" Hello world -- fn_hello_world()!" );
52
47
// aux_print_registers();
53
48
}
54
49
50
+
51
+ bool install_username_hook () {
52
+ return set_call_func ((void *)(blurAPI->moduleBase + HOOK_NAME_FUNC_ADDY), (fn_ptr_t ) hook_GetUserNameA);
53
+ }
54
+
55
+
56
+
57
+ bool __stdcall hook_GetUserNameA (char * buff, unsigned long * len) {
58
+ // bool r = GetUserNameA(buff, len); //original func
59
+ bool r = true ;
60
+ std::string name = blurAPI->config .user_name ;
61
+ int n = name.length ();
62
+ for (int i=0 ; i<n; i++) buff[i] = name[i];
63
+ buff[n] = NULL ;
64
+ *len = n;
65
+ blurAPI->console .print (" Name set to: " + name);
66
+ return r;
67
+ }
68
+
69
+
70
+
55
71
// TODO: debug stuff
56
72
// https://en.wikibooks.org/wiki/X86_Assembly/X86_Architecture
57
73
void aux_print_registers () {
@@ -80,3 +96,4 @@ void aux_print_registers() {
80
96
__asm {mov [reg_dst], edi};
81
97
std::printf (" %#010x [reg_dst], edi\n " , reg_dst);
82
98
}
99
+
0 commit comments