-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpattern.hpp
More file actions
90 lines (71 loc) · 1.91 KB
/
pattern.hpp
File metadata and controls
90 lines (71 loc) · 1.91 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#pragma once
#include <cstdint>
#include <string>
#include <windows.h>
namespace scanner
{
class handle {
public:
handle() = default;
explicit handle(uintptr_t address) : m_address(address) {}
template <typename T>
T as() const {
return reinterpret_cast<T>(m_address);
}
handle add(uintptr_t offset) const {
if (m_address != 0)
{
return handle(m_address + offset);
}
return *this;
}
handle sub(uintptr_t offset) const {
if (m_address != 0)
{
return handle(m_address - offset);
}
return *this;
}
handle rip() const {
if (m_address != 0)
{
auto offset = *as<int32_t*>();
return add(offset + sizeof(int32_t));
}
return *this;
}
private:
uintptr_t m_address = 0;
};
class _module {
public:
_module(const char* module) : m_module(module)
{
m_module_handle = GetModuleHandleA(m_module);
}
handle get_export(const char* func)
{
return handle((std::uintptr_t)GetProcAddress(m_module_handle, func));
}
HMODULE get_handle()
{
return m_module_handle;
}
private:
const char* m_module;
HMODULE m_module_handle;
};
class pattern {
public:
explicit pattern(_module module);
~pattern() noexcept;
pattern& scan_now(const char* sig_name, const char* ida_sig);
handle get_result();
private:
std::string m_module_name;
_module m_module;
size_t m_module_size;
HMODULE m_module_handle;
handle m_result;
};
}