-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExample.cpp
30 lines (24 loc) · 961 Bytes
/
Example.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
#include <CodeInjection.h>
#include <iostream>
int main() {
auto injection =
CodeInjection::New("My Injection")
.OnInstall([](Injection& _) {
_.AllocateMemory("allocatedMemoryAddress", [](Injection& __) {
__.WriteAssembly([](Assembly::Code code) {
BeginAssembly;
code.mov(eax, 0x69);
code.ret();
});
});
})
.OnUninstall([](Injection& _) { _.DeallocateMemory("allocatedMemoryAddress"); });
injection.Install();
auto allocatedMemoryAddress = injection.Var<uintptr_t>("allocatedMemoryAddress");
std::cout << string_format("Allocated memory address: {:x}", allocatedMemoryAddress)
<< std::endl;
// Pause and ask for any key to continue...
std::cout << "Press any key to continue...";
std::cin.get();
injection.Uninstall();
}