-
Notifications
You must be signed in to change notification settings - Fork 62
/
GHDumper.cpp
106 lines (81 loc) · 2.38 KB
/
GHDumper.cpp
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#include "stdafx.h"
#include "GHDumper.h"
#include "SigData.h"
jsonxx::Object ParseConfig()
{
//Open File Stream & parse JSON data into object
std::ifstream f("config.json", std::ios::in);
std::string jsonBuffer((std::istreambuf_iterator<char>(f)), std::istreambuf_iterator<char>());
jsonxx::Object o;
o.parse(jsonBuffer);
return o;
}
Dumper::Dumper() {}
Dumper::Dumper(jsonxx::Object* json)
{
jsonConfig = json;
//Get & attach to process
//std::string procName = jsonConfig->get<std::string>("executable");
std::string procName = "hl2.exe";
//Find proc & open handle
ProcEx proc((char*)procName.c_str());
}
void Dumper::ProcessSignatures()
{
//select signature array in json
jsonxx::Array sigs = jsonConfig->get<jsonxx::Array>("signatures");
//Loop through json signature array
for (size_t i = 0; i < sigs.size(); i++)
{
jsonxx::Object curr = sigs.get<jsonxx::Object>(i);
SigData currData;
currData.name = curr.get<std::string>("name");
currData.extra = (int)curr.get<jsonxx::Number>("extra");
currData.relative = curr.get<jsonxx::Boolean>("relative");
currData.module = curr.get<std::string>("module");
//dump offsets from json into vector, not all have offsets
jsonxx::Array offsetArray;
//only grab them if they exist
if (curr.has<jsonxx::Array>("offsets"))
{
offsetArray = curr.get<jsonxx::Array>("offsets");
//Despite most only have 1 offset, it's an arrays
for (size_t j = 0; j < offsetArray.size(); j++)
{
currData.offsets.push_back((int)offsetArray.get<jsonxx::Number>(j));
}
}
currData.comboPattern = curr.get<std::string>("pattern");
signatures.push_back(currData);
}
for (auto& s : signatures)
{
//Scan for the pattern, process the relative & extra offsets
s.Scan(proc);
}
}
void Dumper::GenerateHeaderOuput()
{
//TODO: convert to string output
std::ofstream file;
file.open(jsonConfig->get<std::string>("filename") + ".h");
file << "#pragma once\n#include <cstdint>\n";
//timestamp
file << "//GuidedHacking.com r0x0rs ur b0x0rs\n";
file << "namespace offsets\n{\n";
for (auto s : signatures)
{
file << "constexpr ptrdiff_t " << s.name << " = 0x" << std::uppercase << std::hex << s.result << ";\n";
}
file << "\n}\n";
file.close();
}
void Dumper::Dump()
{
ProcessSignatures();
//Generate header output
GenerateHeaderOuput();
//Generate Cheat Engine output
//Generate ReClass.NET output
//Write Output files
}