[REFACT] Added func. get/set characteristics in SectHdrsWrapper

This commit is contained in:
hasherezade
2014-09-19 14:40:46 +02:00
parent d78fb0866c
commit 367eebcbc1
3 changed files with 20 additions and 5 deletions
+1 -2
View File
@@ -302,7 +302,7 @@ bool PEFile::moveDataDirEntry(pe::dir_entry id, offset_t newOffset, Executable::
}
SectionHdrWrapper* PEFile::addNewSection(QString name, bufsize_t size, DWORD characteristics)
SectionHdrWrapper* PEFile::addNewSection(QString name, bufsize_t size)
{
ExeNodeWrapper* sec = dynamic_cast<ExeNodeWrapper*>(getWrapper(PEFile::WR_SECTIONS));
if (sec == NULL || sec->canAddEntry() == false) {
@@ -344,7 +344,6 @@ SectionHdrWrapper* PEFile::addNewSection(QString name, bufsize_t size, DWORD cha
secHdr.VirtualAddress = static_cast<DWORD>(roundedVirtualEnd);
secHdr.SizeOfRawData = size;
secHdr.Misc.VirtualSize = size;
secHdr.Characteristics = characteristics;
SectionHdrWrapper wr(this, &secHdr);
SectionHdrWrapper* secHdrWr = dynamic_cast<SectionHdrWrapper*>(sec->addEntry(&wr));
+1 -1
View File
@@ -105,7 +105,7 @@ public:
bool moveDataDirEntry(pe::dir_entry id, offset_t newOffset, Executable::addr_type addType = Executable::RAW); //throws CustomException
SectionHdrWrapper* getLastSection();
SectionHdrWrapper* addNewSection(QString name, bufsize_t size, DWORD characteristics = 0xE0000000);
SectionHdrWrapper* addNewSection(QString name, bufsize_t size);
SectionHdrWrapper* extendLastSection(bufsize_t addedSize);
+18 -2
View File
@@ -47,8 +47,24 @@ public:
offset_t getContentEndOffset(Executable::addr_type aType, bool roundup); //always useMapped startOFfset
bufsize_t getContentSize(Executable::addr_type aType, bool roundup);
protected:
DWORD getCharacteristics()
{
if (header == NULL) return 0;
return header->Characteristics;
}
//modifications:
bool setCharacteristics(DWORD newCharacteristics)
{
if (header == NULL) return false;
//TODO: validate newCharacteristics
header->Characteristics = newCharacteristics;
return true;
}
protected:
SectionHdrWrapper(PEFile *pe, pe::IMAGE_SECTION_HEADER *v_header) //standalone entry
: PENodeWrapper(pe), sectNum(INVALID_ENTRYNUM), name(NULL), header(v_header)
{