23 if (
m_PE == NULL)
return NULL;
26 return (
void*) this->header;
32 offset_t secOffset = firstSecOffset + (this->
sectNum *
sizeof(IMAGE_SECTION_HEADER));
35 this->header = (IMAGE_SECTION_HEADER*)
m_PE->
getContentAt(secOffset,
sizeof(IMAGE_SECTION_HEADER));
36 return (
void*) this->header;
41 IMAGE_SECTION_HEADER* header = (IMAGE_SECTION_HEADER*)
getPtr();
42 if (!header)
return false;
51 char *buf =
new char[BUF_LEN];
52 memset(buf, 0, BUF_LEN);
53 snprintf(buf, BUF_LEN,
"%.8s", (
char*) header->Name);
64 if (
m_PE == NULL)
return 0;
65 return sizeof(IMAGE_SECTION_HEADER);
71 if (!this->
name)
return "";
77 IMAGE_SECTION_HEADER* sec = (IMAGE_SECTION_HEADER*)
getPtr();
78 if (!sec)
return NULL;
79 if (!this->
name)
return NULL;
82 case NAME:
return (
void*) &sec->Name;
83 case VSIZE:
return (
void*) &sec->Misc.VirtualSize;
84 case VPTR:
return (
void*) &sec->VirtualAddress;
85 case RSIZE:
return (
void*) &sec->SizeOfRawData;
86 case RPTR:
return(
void*) &sec->PointerToRawData;
88 case RELOC_PTR:
return (
void*) &sec->PointerToRelocations;
89 case RELOC_NUM:
return (
void*) &sec->NumberOfRelocations;
90 case LINENUM_PTR:
return (
void*) &sec->PointerToLinenumbers;
91 case LINENUM_NUM:
return (
void*) &sec->NumberOfLinenumbers;
93 case CHARACT:
return (
void*) &sec->Characteristics;
102 case NAME:
return "Name";
103 case VSIZE:
return "Virtual Size";
104 case VPTR:
return "Virtual Addr.";
105 case RSIZE:
return "Raw size";
106 case RPTR:
return "Raw Addr.";
107 case CHARACT:
return "Characteristics";
129 if (fieldId ==
NAME) {
143 offset =
static_cast<offset_t>(this->header->PointerToRawData);
145 offset =
static_cast<offset_t>(this->header->VirtualAddress);
159 if (offset < minAlign || offset > peSize) {
168 const bool useMapped =
true;
179 if (this->header == NULL)
return 0;
183 size =
static_cast<bufsize_t>(this->header->SizeOfRawData);
185 size =
static_cast<bufsize_t>(this->header->Misc.VirtualSize);
205 if (secOffset > peSize) {
213 const bufsize_t secEnd = secOffset + roundedUpSize;
216 if (secEnd > peSize) {
218 const bufsize_t trimmedSize = peSize - secOffset;
221 if (trimmedSize > virtualSize) {
226 return roundedUpSize;
241 bufsize_t mVirtualSize = (dVirtualSize > mRawSize) ? dVirtualSize : mRawSize;
253 if (this->header == NULL)
return 0;
254 if (
m_PE == NULL)
return 0;
257 if (roundup ==
false) {
280 if (sEntry == NULL) {
290 if (entrySize == 0)
return false;
299 if (
m_PE == NULL)
return NULL;
306 size_t count = secCount + 1;
323 if (sec == NULL)
return false;
324 if (sec->
getPtr() == NULL) {
337 if (sec == NULL)
return;
351 if (
rSec.find(endRaw) !=
rSec.end()) {
353 if (prevSec == NULL)
return;
369 for (
size_t i = 0; i < count; i++) {
371 if (sec == NULL)
continue;
379 if (this->
m_PE == NULL)
return false;
383 for (
size_t i = 0; i < count; i++) {
396 if (
entries.size() == 0)
return NULL;
402 if (this->
m_PE == NULL)
return 0;
408 offset_t endOffset = hdrOffset + (secCount *
sizeof(IMAGE_SECTION_HEADER));
410 if (endOffset > fileSize) {
413 return bufsize_t (endOffset - hdrOffset);
424 if (fieldId >=
entries.size())
return NULL;
425 return entries[fieldId]->getName();
430 size_t size = this->
entries.size();
431 std::map<offset_t, SectionHdrWrapper*> *secMap = NULL;
434 secMap = &this->
rSec;
436 secMap = &this->
vSec;
438 if (secMap == NULL)
return NULL;
440 std::map<offset_t, SectionHdrWrapper*>::iterator found = secMap->lower_bound(offset);
441 std::map<offset_t, SectionHdrWrapper*>::iterator itr;
442 for (itr = found; itr != secMap->end(); itr++) {
444 if (sec == NULL)
continue;
446 printf(
"found [%llX] key: %llX sec: %llX %llX\n",
447 static_cast<unsigned long long>(offset),
448 static_cast<unsigned long long>(itr->first),
459 if (offset >= startOffset && offset < endOffset) {
462 if (offset < startOffset)
break;
469 std::map<offset_t, SectionHdrWrapper*> *secMap = NULL;
472 secMap = &this->
rSec;
474 secMap = &this->
vSec;
476 if (secMap == NULL)
return;
478 std::map<offset_t, SectionHdrWrapper*>::iterator itr;
479 for (itr = secMap->begin(); itr != secMap->end(); itr++) {
483 printf(
"[%llX] %s %llX %llX\n",
484 static_cast<unsigned long long>(secEnd),
485 sec->
getName().toStdString().c_str(),
const offset_t INVALID_ADDR
virtual bufsize_t getContentSize()=0
bool isAreaEmpty(offset_t rawOffset, bufsize_t size)
virtual bufsize_t getContentSize()
ExeNodeWrapper * getLastEntry()
virtual ExeNodeWrapper * getEntryAt(size_t fieldId)
virtual bufsize_t geEntrySize()
std::vector< ExeNodeWrapper * > entries
virtual offset_t getNextEntryOffset()
virtual size_t getEntriesCount()
virtual ExeNodeWrapper * addEntry(ExeNodeWrapper *entry)
BYTE * getContentAt(offset_t offset, bufsize_t size, bool allowExceptions=false)
virtual offset_t getRawSize() const
virtual bufsize_t getMappedSize(Executable::addr_type aType)
offset_t secHdrsOffset() const
bool setHdrSectionsNum(size_t newNum)
size_t hdrSectionsNum() const
virtual bufsize_t getAlignment(Executable::addr_type aType)
std::map< offset_t, SectionHdrWrapper * > rSec
void printSectionsMapping(Executable::addr_type aType)
ExeNodeWrapper * addEntry(ExeNodeWrapper *entry)
virtual bufsize_t getSize()
virtual bool loadNextEntry(size_t entryNum)
virtual QString getFieldName(size_t fieldId)
SectionHdrWrapper * getSecHdrAtOffset(offset_t offset, Executable::addr_type addrType, bool roundup, bool verbose=false)
bool isMyEntryType(ExeNodeWrapper *entry)
virtual void reloadMapping()
static size_t SECT_COUNT_MAX
std::map< offset_t, SectionHdrWrapper * > vSec
void addMapping(SectionHdrWrapper *sec)
static size_t SECT_INVALID_INDEX
virtual size_t getFieldsCount()
bufsize_t getMappedVirtualSize()
virtual QString getName()
virtual QString getFieldName(size_t fieldId)
bufsize_t getContentSize(Executable::addr_type aType, bool roundup)
offset_t getContentDeclaredOffset(Executable::addr_type aType)
virtual void * getFieldPtr(size_t fieldId, size_t subField=FIELD_NONE)
bufsize_t getContentDeclaredSize(Executable::addr_type aType)
virtual Executable::addr_type containsAddrType(size_t fieldId, size_t subField=FIELD_NONE)
offset_t getContentEndOffset(Executable::addr_type aType, bool roundup)
offset_t getContentOffset(Executable::addr_type aType, bool useMapped=true)
bufsize_t getMappedRawSize()
virtual WrappedValue::data_type containsDataType(size_t fieldId, size_t subField=FIELD_NONE)
virtual bufsize_t getSize()
bool append(dbg_level lvl, const char *format,...)
bufsize_t roundupToUnit(bufsize_t size, bufsize_t unit)