All pastes #572421 Raw Edit

Something

public c v1 · immutable
·published 2007-06-17 17:29 UTC
rendered paste body
// convert file offset to virtual addressDWORD file_to_va(DWORD file_offset){	for (int i=0; i<number_of_sections; i++)	{		if (file_offset >= 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 offsetDWORD va_to_file(DWORD va){	for (int i=0; i<number_of_sections; i++)	{		if (va >= 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}