summaryrefslogtreecommitdiff
path: root/loader/server/manual_map.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'loader/server/manual_map.cpp')
-rw-r--r--loader/server/manual_map.cpp38
1 files changed, 32 insertions, 6 deletions
diff --git a/loader/server/manual_map.cpp b/loader/server/manual_map.cpp
index 1c6fa12..86aae27 100644
--- a/loader/server/manual_map.cpp
+++ b/loader/server/manual_map.cpp
@@ -3,8 +3,8 @@
namespace remote_code {
//i really hope you do this the turbochad way and sigscan your own shellcode for 69696969
// u rite
- constexpr size_t shellcode_size = 83;
- constexpr uint8_t shellcode_code[] = {
+ constexpr size_t shellcode_size = 83;
+ constexpr uint8_t shellcode_code[] = {
0x55, // push ebp
0x8B, 0xEC, // mov ebp, esp
0x51, // push ecx
@@ -80,7 +80,7 @@ namespace remote_code {
// there are three occurences of endscene
// nave i hope ur happy
- for(int n = 0; n < 3; ++n)
+ for (int n = 0; n < 3; ++n)
patch_code(code, find_byte_pattern(code, { 0x69, 0x69, 0x69, 0x69 }), arg->m_endscene);
return code;
@@ -103,7 +103,7 @@ namespace inject {
m_file.resize(pe_size);
pe_file.seekg(0, pe_file.beg);
-
+
// AAAAAAAAAAAA BAD
pe_file.read((char*)m_file.data(), pe_size);
@@ -128,7 +128,7 @@ namespace inject {
nt_headers = reinterpret_cast<decltype(nt_headers)>(data() + dos_header->e_lfanew);
if (nt_headers->Signature != 0x50450000)
- return false;
+ return false;
return true;
}
@@ -137,7 +137,7 @@ namespace inject {
// go to the beginning of the file
return m_file.data();
}
-
+
size_t c_pe_file::size() const {
return m_file.size();
}
@@ -179,6 +179,32 @@ namespace inject {
return true;
}
+ IMAGE_BASE_RELOCATION *reloc;
+
+ uintptr_t address = nt_headers->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_BASERELOC].VirtualAddress;
+ uintptr_t delta = (uintptr_t)m_pe.data() - nt_headers->OptionalHeader.ImageBase;
+
+ reloc = reinterpret_cast<decltype(reloc)>(m_pe.data() + address);
+
+ while (reloc->VirtualAddress) {
+ if (reloc->SizeOfBlock >= sizeof IMAGE_BASE_RELOCATION) {
+ size_t count = (reloc->SizeOfBlock - sizeof IMAGE_BASE_RELOCATION) / sizeof uint16_t;
+
+ uint16_t *list = (uint16_t *)reloc + 1;
+
+ uintptr_t* ptr{ };
+ for (size_t i{ }; i < count; ++i) {
+ if (list[i]) {
+ ptr = (uintptr_t*)((uintptr_t)(m_pe.data()) + (reloc->VirtualAddress + (list[i] & 0xfff)));
+ *ptr += delta;
+ }
+ }
+ }
+
+ // advance
+ reloc = (IMAGE_BASE_RELOCATION *)((uintptr_t)reloc + reloc->SizeOfBlock);
+ }
+
return true;
}