MCPcopy Create free account
hub / github.com/NetSPI/BOF-PE / ProcessRelocations

Function ProcessRelocations

loader/mappedmodule.cpp:108–133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

106}
107
108static void ProcessRelocations(const Pe::PeNative& pe, uintptr_t delta) {
109
110 for (const auto& reloc : pe.relocs()) {
111 for (const auto& entry : reloc) {
112 switch (entry.reloc()->type()) {
113 case Pe::RelocType::dir64:
114 *((uintptr_t*)(entry.addr())) += delta;
115 break;
116 case Pe::RelocType::highlow:
117 *(uint32_t*)(entry.addr()) += uint32_t(delta);
118 break;
119 case Pe::RelocType::high:
120 *(int16_t*)(entry.addr()) += HIWORD(delta);
121 break;
122 case Pe::RelocType::low:
123 *(int16_t*)(entry.addr()) += LOWORD(delta);
124 break;
125 case Pe::RelocType::absolute:
126 break;
127 default:
128 throw std::format("Unhandled reloc type {}", entry.reloc()->rawType);
129 break;
130 }
131 }
132 }
133}
134
135static void UpdateSectionPermissions(const Pe::PeNative& pe) {
136

Callers 1

MappedModuleMethod · 0.85

Calls 4

relocsMethod · 0.80
relocMethod · 0.80
addrMethod · 0.80
typeMethod · 0.45

Tested by

no test coverage detected