#include <module.h>
Public Types | |
| typedef std::vector< Section > | TSections |
Public Methods | |
| DataReader | GetDataReader (vma_t address) |
| ObjectModule (CFile &file, const RVAFileTranslator &rva, uint32_t imageBase, bool hasRelocation, const RelocationInfos &relocationInfos, const Symbols &symbols, const Symbols &exportSymbols, vma_t entryPoint) | |
| ObjectModule::ObjectModule (vma_t start, const unsigned char *ptr, unsigned len) | |
| ~ObjectModule () | |
| uint8_t | ReadByte (vma_t address) |
| uint16_t | ReadWord (vma_t address) |
| uint32_t | ReadDword (vma_t address) |
| bool | IsValid (vma_t address) |
| bool | HasRelocation () const |
| const RelocationInfos & | GetRelocationInfos () const |
| const Symbols & | GetSymbols () const |
| const Symbols & | GetExportSymbols () const |
| vma_t | GetEntryPoint () const |
| const Section * | GetSection (vma_t address) const |
| const TSections & | GetSections () const |
Static Public Methods | |
| const Section * | GetErrorSection () |
Private Methods | |
| void | operator= (const ObjectModule &) |
| ObjectModule (const ObjectModule &) | |
Private Attributes | |
| TSections | sections |
| bool | hasRelocation |
| RelocationInfos | relocationInfos |
| Symbols | symbols |
| Symbols | exportSymbols |
| vma_t | entryPoint |
Static Private Attributes | |
| const Section | errorSection |
|
|
Definition at line 59 of file module.h. Referenced by GetSections(). |
|
||||||||||||||||||||||||||||||||||||
|
Definition at line 36 of file module.cpp. References entryPoint, RVAFileTranslator::GetSection(), RVAFileTranslator::GetSectionCount(), PeSection::IsCode(), PeSection::RawAddress, CFile::RawRead(), PeSection::RawSize, PeSection::RvaAddress, PeSection::RvaSize, sections, CFile::Seek(), and vma_t.
00039 : 00040 sections(rva.GetSectionCount()), 00041 hasRelocation(_hasRelocation),relocationInfos(_relocationInfos), 00042 symbols(_symbols),exportSymbols(_exportSymbols) 00043 { 00044 entryPoint = _entryPoint==0?0:_entryPoint+imageBase; 00045 00046 unsigned numSection = rva.GetSectionCount(); 00047 uint8_t *buffer; 00048 for (unsigned n=0;n<numSection;++n) 00049 { 00050 // se RawSize > RvaSize altri bytes non utilizzati (indirizzi invalidi) 00051 // se RvaSize > RawSize altri bytes non inizializzati 00052 // calcola dimensione sezione 00053 unsigned size = rva.GetSection(n)->RvaSize; 00054 // inizializza valori 00055 sections[n].begin = rva.GetSection(n)->RvaAddress + imageBase; 00056 sections[n].end = rva.GetSection(n)->RvaAddress + imageBase + size; 00057 if ( rva.GetSection(n)->IsCode() ) 00058 sections[n].SetIsCode(); 00059 else 00060 sections[n].SetIsData(); 00061 00062 // inizializza buffer 00063 buffer = new uint8_t[size]; 00064 memset(buffer,0,size); 00065 00066 // se puntatore valido leggi da memoria 00067 if ( rva.GetSection(n)->RawAddress != 0 ) 00068 { 00069 unsigned rawSize = rva.GetSection(n)->RawSize; 00070 file.Seek( rva.GetSection(n)->RawAddress ); 00071 file.RawRead( buffer,size<rawSize?size:rawSize ); 00072 } 00073 00074 sections[n].data = buffer; 00075 sections[n].data_end = buffer+size; 00076 if (n != 0) 00077 sections[n-1].next = §ions[n]; 00078 } 00079 } |
|
|
Definition at line 100 of file module.cpp.
00101 {
00102 }
|
|
|
|
|
|
Definition at line 159 of file module.cpp. References ObjectModule::Section::data, sections, and vma_t. Referenced by CodeParser::ExecuteComplexReferenceMemory(), CodeParser::GetBitStat(), GetInstruction(), CodeParser::GetPointerArrayStats(), CodeParser::GetStringStats(), CodeParser::Parse(), ReadByte(), ReadDword(), ReadWord(), CodeParser::ScanCode(), CodeParser::WriteBegin(), CodeParser::WriteCode(), and CodeParser::WriteString().
00160 {
00161 // !!! optimize saving last searched section
00162 // find sectionBuffer
00163 Section* sec;
00164 for( TSections::size_type n=0; n < sections.size(); ++n )
00165 {
00166 vma_t begin = sections[n].begin;
00167 vma_t end = sections[n].end;
00168 if (begin <= address && address < end)
00169 {
00170 sec = §ions[n];
00171 return DataReader(sec,sec->data + (address - begin));
00172 }
00173 }
00174
00175 throw OutOfAddress(address);
00176 }
|
|
|
Definition at line 98 of file module.h. References entryPoint, and vma_t. Referenced by CodeParser::CheckReference(), and CodeParser::Parse().
00099 { return entryPoint; }
|
|
|
Definition at line 105 of file module.h. References errorSection.
00105 { return &errorSection; }
|
|
|
Definition at line 96 of file module.h. References exportSymbols. Referenced by CodeParser::CheckJumpReference(), CodeParser::CheckReference(), and CodeParser::Parse().
00097 { return exportSymbols; }
|
|
|
Definition at line 92 of file module.h. References relocationInfos. Referenced by CodeParser::ExecuteComplexReferenceMemory(), GetInstruction(), CodeParser::GetStringStats(), CodeParser::Parse(), CodeParser::ScanCode(), and CodeParser::WriteCode().
00093 { return relocationInfos; }
|
|
|
Definition at line 144 of file module.cpp. References errorSection, sections, and vma_t. Referenced by CodeParser::ExecuteComplexReferenceMemory(), CodeParser::GetPointerArrayStats(), CodeParser::Parse(), ScanningComplexReg::ProcessInstruction(), CodeParser::ScanCode(), and THeuristicMotor::THeuristicMotor().
00145 {
00146 // cerca sezione
00147 for( TSections::size_type n=0; n < sections.size(); ++n )
00148 {
00149 vma_t begin = sections[n].begin;
00150 vma_t end = sections[n].end;
00151 if (begin <= address && address < end)
00152 {
00153 return §ions[n];
00154 }
00155 }
00156 return &errorSection;
00157 }
|
|
|
Definition at line 108 of file module.h. References sections, and TSections.
00109 { return sections; }
|
|
|
Definition at line 94 of file module.h. References symbols. Referenced by CodeParser::AddTempFlow(), CodeParser::CheckJumpReference(), and CodeParser::IsApiReference().
00095 { return symbols; }
|
|
|
Definition at line 90 of file module.h. References hasRelocation. Referenced by CodeParser::ContainValidAddress(), CodeParser::ExecuteComplexReferenceMemory(), and CodeParser::GetStringStats().
00091 { return hasRelocation; }
|
|
|
Definition at line 105 of file module.cpp. References sections, and vma_t. Referenced by CodeParser::ContainValidAddress(), and CodeParser::GetPointerArrayStats().
00106 {
00107 // prova con la sezione corrente
00108 // if ( currSection && currSection->begin <= address && address < currSection->end )
00109 // return true;
00110
00111 // cerca sezione
00112 for( TSections::size_type n=0; n < sections.size(); ++n )
00113 {
00114 vma_t begin = sections[n].begin;
00115 vma_t end = sections[n].end;
00116 if (begin <= address && address < end)
00117 {
00118 return true;
00119 }
00120 }
00121 return false;
00122 }
|
|
||||||||||||||||
|
|
|
|
|
|
|
Definition at line 178 of file module.cpp. References GetDataReader(), ObjectModule::DataReader::ReadByte(), and vma_t.
00179 {
00180 DataReader reader = GetDataReader(address);
00181 return reader.ReadByte();
00182 }
|
|
|
Definition at line 190 of file module.cpp. References GetDataReader(), ObjectModule::DataReader::ReadDword(), and vma_t.
00191 {
00192 DataReader reader = GetDataReader(address);
00193 return reader.ReadDword();
00194 }
|
|
|
Definition at line 184 of file module.cpp. References GetDataReader(), ObjectModule::DataReader::ReadWord(), and vma_t.
00185 {
00186 DataReader reader = GetDataReader(address);
00187 return reader.ReadWord();
00188 }
|
|
|
Definition at line 122 of file module.h. Referenced by GetEntryPoint(), and ObjectModule(). |
|
|
Definition at line 34 of file module.cpp. Referenced by GetErrorSection(), and GetSection(). |
|
|
Definition at line 121 of file module.h. Referenced by GetExportSymbols(). |
|
|
Definition at line 118 of file module.h. Referenced by HasRelocation(). |
|
|
Definition at line 119 of file module.h. Referenced by GetRelocationInfos(). |
|
|
Definition at line 111 of file module.h. Referenced by GetDataReader(), GetSection(), GetSections(), IsValid(), and ObjectModule(). |
|
|
Definition at line 121 of file module.h. Referenced by GetSymbols(). |
1.2.15