#include <rva.h>
Public Methods | |
RVAFileTranslator (const PE_IMAGE_SECTION_HEADER *_sections, unsigned _num_section) | |
~RVAFileTranslator () | |
RVAFileTranslator (const RVAFileTranslator &rhs) | |
void | operator= (const RVAFileTranslator &rhs) |
long | RVA2File (uint32_t rva) const |
uint32_t | File2RVA (long file) const |
long | RVA2FileSafe (uint32_t rva) const |
uint32_t | File2RVASafe (long file) const |
unsigned | GetSectionCount () const |
const PeSection * | GetSection (unsigned n) const |
Private Attributes | |
unsigned | num |
PeSection * | section_infos |
|
Definition at line 47 of file rva.cpp. References _PE_IMAGE_SECTION_HEADER::Characteristics, IMAGE_SCN_CNT_UNINITIALIZED_DATA, _PE_IMAGE_SECTION_HEADER::Misc, num, _PE_IMAGE_SECTION_HEADER::PointerToRawData, section_infos, _PE_IMAGE_SECTION_HEADER::SizeOfRawData, and _PE_IMAGE_SECTION_HEADER::VirtualAddress.
00047 : 00048 num(_num_section),section_infos(NULL) 00049 { 00050 unsigned n; 00051 00052 // check order and size 00053 uint32_t prevVirtualEnd = 0,prevFileEnd = 0; 00054 for( n=0; n<num; ++n ) 00055 { 00056 // vedi se sezione inizializzata 00057 if (!(_sections[n].Characteristics&IMAGE_SCN_CNT_UNINITIALIZED_DATA) || _sections[n].PointerToRawData != 0) 00058 // !!! una sezione puo' essere vuota e non avere il flag uninitialized settato 00059 if(_sections[n].PointerToRawData != 0 || _sections[n].SizeOfRawData != 0) 00060 { 00061 if (prevVirtualEnd > _sections[n].VirtualAddress || 00062 prevFileEnd > _sections[n].PointerToRawData ) 00063 throw std::runtime_error("Invalid order of sections"); 00064 prevVirtualEnd = _sections[n].VirtualAddress+_sections[n].Misc.VirtualSize; 00065 prevFileEnd = _sections[n].PointerToRawData+_sections[n].SizeOfRawData; 00066 } 00067 } 00068 00069 // copy 00070 section_infos = new PeSection[num]; 00071 for( n=0; n<num; ++n ) 00072 section_infos[n] = _sections[n]; 00073 } |
|
Definition at line 75 of file rva.cpp. References section_infos.
00076 { 00077 delete[] section_infos; 00078 } |
|
Definition at line 56 of file rva.h. References section_infos.
00056 :section_infos(NULL) 00057 { (*this) = rhs; }; |
|
Definition at line 90 of file rva.cpp. References num, PeSection::RawAddress, PeSection::RawSize, PeSection::RvaAddress, and section_infos. Referenced by File2RVASafe().
00091 { 00092 if (_file < 0) return 0; 00093 unsigned long file = static_cast<unsigned long>(_file); 00094 for( unsigned n=0; n<num; ++n ) 00095 { 00096 if (file >= section_infos[n].RawAddress && file < (section_infos[n].RawAddress+section_infos[n].RawSize) ) 00097 return file - section_infos[n].RawAddress + section_infos[n].RvaAddress; 00098 } 00099 return 0; 00100 } |
|
Definition at line 65 of file rva.h. References File2RVA(). Referenced by CodeParser::ExcludeFileRange().
00065 { 00066 uint32_t r = File2RVA(file); if (r==0) throw std::runtime_error("Invalid File offset"); 00067 return r; 00068 }; |
|
Definition at line 71 of file rva.h. References num, and section_infos. Referenced by CodeParser::ExcludeFileRange(), ObjectModule::ObjectModule(), and RawDump().
00072 { return ((n<num)?§ion_infos[n]:NULL); }; |
|
Definition at line 69 of file rva.h. References num. Referenced by ObjectModule::ObjectModule().
00070 { return num; } |
|
Definition at line 102 of file rva.cpp. References num, and section_infos.
00103 { 00104 delete section_infos; 00105 section_infos = new PeSection[rhs.num]; 00106 num = rhs.num; 00107 for(unsigned n=0; n<num; ++n) 00108 section_infos[n] = rhs.section_infos[n]; 00109 } |
|
Definition at line 80 of file rva.cpp. References num, PeSection::RawAddress, PeSection::RvaAddress, PeSection::RvaSize, and section_infos. Referenced by RVA2FileSafe().
00081 { 00082 for( unsigned n=0; n<num; ++n ) 00083 { 00084 if (rva >= section_infos[n].RvaAddress && rva < (section_infos[n].RvaAddress+section_infos[n].RvaSize) ) 00085 return rva - section_infos[n].RvaAddress + section_infos[n].RawAddress; 00086 } 00087 return 0; 00088 } |
|
Definition at line 61 of file rva.h. References RVA2File(). Referenced by MarkImport(), PeFile::ParseExport(), PeFile::ParseResource(), and ParseResourceDirectory().
00061 { 00062 long r = RVA2File(rva); if (r==0) throw std::runtime_error("Invalid RVA"); 00063 return r; 00064 }; |
|
Definition at line 74 of file rva.h. Referenced by File2RVA(), GetSection(), GetSectionCount(), operator=(), RVA2File(), and RVAFileTranslator(). |
|
Definition at line 76 of file rva.h. Referenced by File2RVA(), GetSection(), operator=(), RVA2File(), RVAFileTranslator(), and ~RVAFileTranslator(). |