-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcodestorage.cpp
More file actions
45 lines (38 loc) · 1.47 KB
/
Copy pathcodestorage.cpp
File metadata and controls
45 lines (38 loc) · 1.47 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
#include "include/codestorage.h"
_Pragma("optimize(\"\", off)")
static void testmb() {
uintptr_t func_ptr = 0xDEADBEEFDEADC0DE;
uintptr_t arg_hwnd = 0xDEADBEEFDEADC0DE;
uintptr_t arg_text = 0xDEADBEEFDEADC0DE;
uintptr_t arg_caption = 0xDEADBEEFDEADC0DE;
uintptr_t arg_type = 0xDEADBEEFDEADC0DE;
auto pMessageBox = (int(WINAPI*)(HWND, LPCSTR, LPCSTR, UINT))func_ptr;
pMessageBox((HWND)arg_hwnd, (LPCSTR)arg_text, (LPCSTR)arg_caption, (UINT)arg_type);
return;
}
_Pragma("optimize(\"\", on)")
CodeStorage::CodeStorage(const std::string& name) : target_function_ptr(nullptr), function_name(name) {
const char* nameStr = name.c_str();
unsigned int name_hash = Utils::hash(nameStr);
switch (name_hash) {
case testmb_hash:
target_function_ptr = testmb;
printf("[%s] Found function pointer for testmb: %p\n", __FUNCTION__, (void*)target_function_ptr);
break;
default:
printf("[%s] Unknown function name '%s' (Hash: 0x%x). No function pointer assigned.\n", __FUNCTION__, name.c_str(), name_hash);
break;
}
if (target_function_ptr == nullptr) {
printf("[%s] CodeStorage created for '%s', but no matching function pointer was found.\n", __FUNCTION__, name.c_str());
}
}
// Getter implementation
void (*CodeStorage::get_function_pointer() const)() {
return target_function_ptr;
}
const std::string& CodeStorage::get_name() const {
return function_name;
}
CodeStorage::~CodeStorage() {
}