6 if (buf ==
NULL)
return false;
12 if ((*
magic) != pe::S_DOS) {
127 for (
size_t i = 0 ;
i < pe::DIR_ENTRIES_COUNT;
i++) {
184 for (
int i = 0;
i < pe::DIR_ENTRIES_COUNT;
i++) {
195 if (!richSign)
return NULL;
200 pe::RICH_DANS_HEADER* dansHdr =
NULL;
204 dansHdr = (pe::RICH_DANS_HEADER*) this->
getContentAt(offset,
sizeof(pe::RICH_DANS_HEADER));
208 if (dansHdr->dansId == (pe::DANS_HDR_MAGIC ^
xorkey)) {
212 offset -=
sizeof(
DWORD);
214 if (!dansHdr || dansHdr->dansId != (pe::DANS_HDR_MAGIC ^
xorkey)) {
230 pe::RICH_SIGNATURE* richSign =
NULL;
237 if (!richSign)
break;
238 if (richSign->richId == pe::RICH_HDR_MAGIC)
break;
242 if (!richSign)
return NULL;
243 if (richSign->richId != pe::RICH_HDR_MAGIC) {
320 if (
isOk ==
false)
return 0;
322 return static_cast<size_t> (
secNum);
415 if (
eType >= pe::DIR_ENTRIES_COUNT)
return NULL;
459 entry->fillContent(0);
467 if (
sec ==
NULL ||
sec->canAddEntry() ==
false) {
509 const size_t nameLen = name.length();
518 secHdr.SizeOfRawData = size;
529 if (secCount == 0)
return NULL;
551 if (size == 0)
continue;
620 ddir[pe::DIR_BOUND_IMPORT].VirtualAddress = 0;
621 ddir[pe::DIR_BOUND_IMPORT].Size = 0;
671 if (!
entry)
continue;
INT_TYPE _getNumValue(void *ptr)
const offset_t INVALID_ADDR
virtual BYTE * getContentAt(offset_t offset, bufsize_t size, bool allowExceptions=false)
virtual offset_t getOffset(void *ptr, bool allowExceptions=false)
static bufsize_t dump(const QString &fileName, AbstractByteBuffer &buf, bool allowExceptions=false)
virtual bufsize_t getContentSize()
virtual bool setNumValue(size_t fieldId, size_t subField, uint64_t val)
virtual offset_t getFieldOffset(size_t fieldId, size_t subField=FIELD_NONE)
virtual uint64_t getNumValue(size_t fieldId, size_t subField, bool *isOk)
virtual size_t getEntriesCount()
std::map< size_t, ExeElementWrapper * > wrappers
virtual ExeElementWrapper * getWrapper(size_t wrapperId)
virtual offset_t toRaw(offset_t offset, addr_type addrType, bool allowExceptions=false)
BYTE * getContentAt(offset_t offset, bufsize_t size, bool allowExceptions=false)
virtual offset_t convertAddr(offset_t inAddr, Executable::addr_type inType, Executable::addr_type outType)
virtual bufsize_t getContentSize()
QString getForwarderStr()
virtual bool resize(bufsize_t newSize)
bufsize_t hdrsSize() const
bool wrap(AbstractByteBuffer *v_buf)
virtual bufsize_t getImageSize()
offset_t peSignatureOffset() const
bufsize_t peNtHeadersSize() const
virtual Executable * build(AbstractByteBuffer *buf)
virtual bool signatureMatches(AbstractByteBuffer *buf)
DataDirEntryWrapper * dataDirEntries[pe::DIR_ENTRIES_COUNT]
size_t getSecIndex(SectionHdrWrapper *sec) const
virtual bufsize_t getMappedSize(Executable::addr_type aType)
BufferView * _createSectionView(SectionHdrWrapper *sec)
size_t getExportsMap(QMap< offset_t, QString > &entrypoints, Executable::addr_type aType=Executable::RVA)
SectionHdrWrapper * getSecHdr(size_t index) const
offset_t peDataDirOffset()
virtual offset_t getEntryPoint(Executable::addr_type addrType=Executable::RVA)
friend class SectHdrsWrapper
offset_t getLastMapped(Executable::addr_type aType)
bool setEntryPoint(offset_t entry, Executable::addr_type aType)
size_t getSectionsCount(bool useMapped=true) const
pe::RICH_DANS_HEADER * getRichHeaderBgn(pe::RICH_SIGNATURE *sign)
SectionHdrWrapper * extendLastSection(bufsize_t addedSize)
SectionHdrWrapper * getLastSection()
bool dumpSection(SectionHdrWrapper *sec, QString fileName)
virtual offset_t rvaToRaw(offset_t rva)
BufferView * createSectionView(size_t secNum)
bool setHdrSectionsNum(size_t newNum)
bool setVirtualSize(bufsize_t newSize)
DataDirEntryWrapper * getDataDirEntry(pe::dir_entry eType)
bool moveDataDirEntry(pe::dir_entry id, offset_t newOffset, Executable::addr_type addType=Executable::RAW)
virtual void clearWrappers()
IMAGE_DATA_DIRECTORY * getDataDirectory()
virtual offset_t rawToRva(offset_t raw)
offset_t secHdrsEndOffset() const
size_t hdrSectionsNum() const
PEFile(AbstractByteBuffer *v_buf)
virtual bufsize_t getAlignment(Executable::addr_type aType) const
pe::RICH_SIGNATURE * getRichHeaderSign()
static long computeChecksum(BYTE *buffer, size_t bufferSize, offset_t checksumOffset)
DosHdrWrapper * dosHdrWrapper
SectionHdrWrapper * getSecHdrAtOffset(offset_t offset, Executable::addr_type aType, bool recalculate=false, bool verbose=false)
SectionHdrWrapper * addNewSection(QString name, bufsize_t size, bufsize_t v_size=0)
static size_t SECT_COUNT_MAX
static size_t SECT_INVALID_INDEX
bool append(dbg_level lvl, const char *format,...)
bufsize_t roundupToUnit(bufsize_t size, bufsize_t unit)