MCPcopy Create free account
hub / github.com/GJDuck/e9patch / findPEData

Function findPEData

src/e9patch/e9pe.cpp:261–278  ·  view source on GitHub ↗

* Find data. */

Source from the content-addressed store, hash-verified

259 * Find data.
260 */
261static uint8_t *findPEData(const Binary *B, uint32_t addr)
262{
263 if (addr == 0x0)
264 return nullptr;
265 PIMAGE_FILE_HEADER file_hdr = B->pe.file_hdr;
266 PIMAGE_SECTION_HEADER shdr = B->pe.shdr;
267 for (uint16_t i = 0; i < file_hdr->NumberOfSections; i++)
268 {
269 if (addr >= shdr[i].VirtualAddress &&
270 addr < shdr[i].VirtualAddress + shdr[i].VirtualSize)
271 {
272 uint32_t offset = shdr[i].PointerToRawData +
273 (addr - shdr[i].VirtualAddress);
274 return B->patched.bytes + offset;
275 }
276 }
277 return nullptr;
278}
279
280/*
281 * Emit the (modified) PE executable.

Callers 1

emitPEFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected