| 106 | } |
| 107 | |
| 108 | static 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 | |
| 135 | static void UpdateSectionPermissions(const Pe::PeNative& pe) { |
| 136 |
no test coverage detected