MCPcopy Create free account
hub / github.com/connorjaydunn/BinaryShield / rvaToFileOffset

Method rvaToFileOffset

src/pe.cpp:100–113  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

98bool PE::addVmSection() { return addSection(".binshld", 0xE0000000, vmSection.getBytes()); }
99
100DWORD PE::rvaToFileOffset(DWORD rva)
101{
102 // find section rva lies within and calculate file offset
103 for (int i = 0; i < pNtHeader->FileHeader.NumberOfSections; i++)
104 {
105 if (rva >= pSectionHeader[i].VirtualAddress &&
106 rva < pSectionHeader[i].VirtualAddress + (pSectionHeader[i].Misc.VirtualSize))
107 {
108 return (rva - pSectionHeader[i].VirtualAddress) + pSectionHeader[i].PointerToRawData;
109 }
110 }
111
112 return 0x0; // this should never happen, throw exception here
113}
114
115DWORD PE::fileOffsetToRva(DWORD offset)
116{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected