Skip to content

Commit d135d8f

Browse files
authored
Create README.md
1 parent 0e075df commit d135d8f

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# patch1337-to-cpp
2+
Converts a `.1337` file to a `.cpp` runtime patcher.
3+
4+
Uses code from https://stackoverflow.com/a/48737037 to patch on runtime, thanks!
5+
6+
Sample output:
7+
```cpp
8+
#include <vector>
9+
#include <windows.h>
10+
int BaseAddress = (int)GetModuleHandle(nullptr);
11+
struct PatchAddress { int Address; unsigned char OldByte; unsigned char NewByte; };
12+
struct Patch { const char* ModuleName; std::vector<PatchAddress> Patches;};
13+
14+
void PatchUChar(unsigned char* dst, unsigned char* src, int size) {
15+
DWORD oldprotect;
16+
VirtualProtect(dst, size, PAGE_EXECUTE_READWRITE, &oldprotect);
17+
memcpy(dst, src, size);
18+
VirtualProtect(dst, size, oldprotect, &oldprotect); };
19+
20+
Patch executable_exe = { "executable.exe", {
21+
PatchAddress{ 126805, 87, 88 },
22+
PatchAddress{ 126885, 7, 8 },
23+
PatchAddress{ 126948, 200, 201 },
24+
PatchAddress{ 126965, 183, 184 },
25+
PatchAddress{ 126982, 166, 167 },
26+
PatchAddress{ 126999, 149, 150 },
27+
PatchAddress{ 127019, 129, 130 },
28+
PatchAddress{ 127036, 112, 113 },
29+
PatchAddress{ 127529, 131, 132 },
30+
PatchAddress{ 127575, 85, 86 },
31+
PatchAddress{ 127621, 39, 40 },
32+
} };
33+
void patch_executable_exe() {
34+
for (PatchAddress addr : executable_exe.Patches) {
35+
PatchUChar((unsigned char*)(BaseAddress + addr.Address), &addr.NewByte, 1); }
36+
};
37+
void unpatch_executable_exe() {
38+
for (PatchAddress addr : executable_exe.Patches) {
39+
PatchUChar((unsigned char*)(BaseAddress + addr.Address), &addr.OldByte, 1); }
40+
};
41+
```

0 commit comments

Comments
 (0)