View Single Post
  #2  
Old 12-24-2004, 02:06
Eggi
 
Posts: n/a
Code:
DWORD OffsetToRVA(DWORD offset, IMAGE_SECTION_HEADER *is_hdr, unsigned scount){
	// Find section holding the Offset
	for(unsigned i = 0; i < scount;i++)
		if((offset >= is_hdr[i].PointerToRawData) && (offset <= is_hdr[i].PointerToRawData +is_hdr[i].SizeOfRawData)){
			// Convert Offset to RVA
			return offset+is_hdr[i].VirtualAddress-is_hdr[i].PointerToRawData;
		}
		return 0;
}
should work...
is_hdr is a array of IMAGE_SECTION_HEADERS and scount is the number of sections (file header)

Last edited by Eggi; 12-24-2004 at 03:12.
Reply With Quote