=.=
sunorr
全部博文(50)
2010年(7)
2009年(43)
zhoujin8
haoyunkk
woyotest
lcltmac
分类: WINDOWS
2010-04-29 09:13:51
ULONG RVA2Offset(PIMAGE_NT_HEADERS pNtHeader, ULONG ulRVA) { PIMAGE_SECTION_HEADER pSection = (PIMAGE_SECTION_HEADER)((ULONG)pNtHeader + sizeof(IMAGE_NT_HEADERS)); ULONG i = 0; for( i = 0; i < pNtHeader->FileHeader.NumberOfSections; i++) { if(ulRVA >= pSection[i].VirtualAddress && ulRVA < (pSection[i].VirtualAddress + pSection[i].SizeOfRawData)) { return pSection[i].PointerToRawData + (ulRVA - pSection[i].VirtualAddress); } } return 0; } ULONG Offset2RVA( PIMAGE_NT_HEADERS pNtHeader, ULONG ulOffset ) { PIMAGE_SECTION_HEADER pSection = (PIMAGE_NT_HEADERS)( (ULONG)pNtHeader + sizeof(IMAGE_NT_HEADERS) ); ULONG i = 0; for ( i = 0; i < pNtHeader->FileHeader.NumberOfSections; i++ ) { if ( ulOffset >= pSection[i].PointerToRawData && ulOffset < pSection[i].PointerToRawData + pSection[i].Misc.VirtualSize ) { return pSection[i].VirtualAddress + ( ulOffset - pSection[i].PointerToRawData ); } } return 0; }
上一篇:GBK(GB2312) 转换 UTF-8 (Windows下)
下一篇:枚举 pspcidtable
登录 注册