6 if (buf ==
NULL)
return false;
12 if ((*
magic) != pe::S_DOS) {
153 for (
int i = 0;
i < pe::DIR_ENTRIES_COUNT;
i++) {
175 for (
size_t i = 0 ;
i < pe::DIR_ENTRIES_COUNT;
i++) {
197 for (
size_t i = 0 ;
i < pe::DIR_ENTRIES_COUNT;
i++) {
219 if (!richSign)
return NULL;
224 pe::RICH_DANS_HEADER* dansHdr =
NULL;
228 dansHdr = (pe::RICH_DANS_HEADER*) this->
getContentAt(offset,
sizeof(pe::RICH_DANS_HEADER));
232 if (dansHdr->dansId == (pe::DANS_HDR_MAGIC ^
xorkey)) {
236 offset -=
sizeof(
DWORD);
238 if (!dansHdr || dansHdr->dansId != (pe::DANS_HDR_MAGIC ^
xorkey)) {
254 pe::RICH_SIGNATURE* richSign =
NULL;
261 if (!richSign)
break;
262 if (richSign->richId == pe::RICH_HDR_MAGIC)
break;
266 if (!richSign)
return NULL;
267 if (richSign->richId != pe::RICH_HDR_MAGIC) {
344 if (
isOk ==
false)
return 0;
346 return static_cast<size_t> (
secNum);
443 if (
eType >= pe::DIR_ENTRIES_COUNT)
return NULL;
488 entry->fillContent(0);
496 if (
sec ==
NULL ||
sec->canAddEntry() ==
false) {
552 const size_t nameLen = name.length();
572 return (secCount > 0) ? this->
_getSecHdr(secCount - 1) :
nullptr;
593 if (size == 0)
continue;
626 if (!
secHdr)
return nullptr;
682 ddir[pe::DIR_BOUND_IMPORT].VirtualAddress = 0;
683 ddir[pe::DIR_BOUND_IMPORT].Size = 0;
719 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]
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)
void _init(AbstractByteBuffer *v_buf)
friend class SectHdrsWrapper
size_t _getSecIndex(SectionHdrWrapper *sec) const
bool setEntryPoint(offset_t entry, Executable::addr_type aType)
pe::RICH_DANS_HEADER * getRichHeaderBgn(pe::RICH_SIGNATURE *sign)
SectionHdrWrapper * extendLastSection(bufsize_t addedSize)
SectionHdrWrapper * getLastSection()
bool dumpSection(SectionHdrWrapper *sec, QString fileName)
offset_t _getLastMapped(Executable::addr_type aType)
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)
SectionHdrWrapper * _getSecHdrAtOffset(offset_t offset, Executable::addr_type aType, bool recalculate=false, bool verbose=false)
bool moveDataDirEntry(pe::dir_entry id, offset_t newOffset, Executable::addr_type addType=Executable::RAW)
SectionHdrWrapper * _getLastSection()
virtual void clearWrappers()
offset_t _secHdrsEndOffset()
IMAGE_DATA_DIRECTORY * getDataDirectory()
virtual offset_t rawToRva(offset_t raw)
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
size_t _getSectionsCount(bool useMapped=true) const
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)