// convert file offset to virtual address DWORD file_to_va(DWORD file_offset) { for (int i=0; i= sections[i].file_offset && file_offset < sections[i].file_offset+sections[i].size) { return image_base + sections[i].rva + file_offset - sections[i].file_offset; } } return 0; // bad - not found } // convert virtual address to file offset DWORD va_to_file(DWORD va) { for (int i=0; i= sections[i].rva+image_base && va < sections[i].rva+image_base+sections[i].size) { return sections[i].file_offset+(va-(sections[i].rva+image_base)); } } return 0; // bad - not found }