41 while (parsedSize < maxSize) {
47 if (!isOk1 || !blockSize || !entry->
getPtr()) {
51 this->parsedSize += blockSize;
67 if (ptr == NULL)
return NULL;
69 IMAGE_BASE_RELOCATION *
reloc = (IMAGE_BASE_RELOCATION*) ptr;
80 IMAGE_BASE_RELOCATION* reloc =
myReloc();
81 if (!reloc)
return false;
84 if (!this->isValidPage)
return false;
86 size_t maxSize = reloc->SizeOfBlock;
87 parsedSize =
sizeof(IMAGE_BASE_RELOCATION);
90 while (parsedSize < maxSize) {
97 this->parsedSize +=
sizeof(pe::BASE_RELOCATION_ENTRY);
103void RelocBlockWrapper::validatePage()
105 this->isValidPage =
false;
106 if (!parentDir)
return;
114 this->isValidPage = (pageRva < m_PE->
getImageSize()) ? true :
false;
119 return this->isValidPage;
124 if (this->parentDir == NULL)
return NULL;
125 IMAGE_BASE_RELOCATION* reloc = this->parentDir->
reloc();
126 if (!reloc)
return NULL;
138 size_t prevNum = this->
entryNum - 1;
142 offset_t prevRaw = prevEntry->cachedRaw;
144 IMAGE_BASE_RELOCATION* prevReloc = (IMAGE_BASE_RELOCATION*) prevEntry->
getPtr();
145 raw = prevRaw + prevReloc->SizeOfBlock;
151 this->cachedRaw = raw;
158 offset_t blockSize = reloc->SizeOfBlock;
163 for (
size_t i = 0; i < this->
entryNum; i++) {
167 if (!ptr)
return NULL;
169 reloc = (IMAGE_BASE_RELOCATION*) ptr;
170 blockSize = reloc->SizeOfBlock;
173 this->cachedRaw = raw;
179 if (this->parentDir == NULL)
return 0;
180 IMAGE_BASE_RELOCATION* reloc = (IMAGE_BASE_RELOCATION*) this->
getPtr();
181 if (!reloc)
return 0;
183 if (reloc->SizeOfBlock > 0)
return reloc->SizeOfBlock;
185 return sizeof(IMAGE_BASE_RELOCATION);
190 IMAGE_BASE_RELOCATION* reloc = (IMAGE_BASE_RELOCATION*) this->
getPtr();
191 if (!reloc)
return NULL;
194 case PAGE_VA:
return (
void*) &reloc->VirtualAddress;
195 case BLOCK_SIZE :
return (
void*) &reloc->SizeOfBlock;
198 BYTE *blockSizePtr = (BYTE*) &reloc->SizeOfBlock;
199 return blockSizePtr +
sizeof(DWORD);
209 case PAGE_VA:
return "Page RVA";
237 if (entriesPtr == NULL || entriesSize == 0)
return NULL;
247 if (this->cachedMaxNum > 0)
return this->cachedMaxNum;
249 IMAGE_BASE_RELOCATION* reloc = (IMAGE_BASE_RELOCATION*) this->
getPtr();
250 if (!reloc)
return 0;
256 if (entriesOffset + entriesSize > fileSize) {
257 entriesSize = fileSize - entriesOffset;
264 entriesNum = entriesSize /
sizeof(WORD);
266 this->cachedMaxNum = entriesNum;
273 if (this->parentDir == NULL)
return NULL;
276 if (this->
entryNum >= maxNum)
return NULL;
279 if (entriesPtr == NULL)
return NULL;
281 WORD* ptr = &entriesPtr[this->
entryNum];
287 if (this->parentDir == NULL)
return 0;
293 pe::BASE_RELOCATION_ENTRY* entry = (pe::BASE_RELOCATION_ENTRY*) &relocEntryVal;
299 pe::BASE_RELOCATION_ENTRY* entry = (pe::BASE_RELOCATION_ENTRY*) &relocEntryVal;
300 return entry->Offset;
306 case 0 :
return "Padding (skipped)";
307 case 1 :
return "High WORD of 32-bit field";
308 case 2 :
return "Low WORD of 32-bit field";
309 case 3 :
return "32 bit field";
310 case 4 :
return "HighAdj";
311 case 5 :
return "MIPS JumpAddr";
312 case 6 :
case 7 :
return "Reserved";
313 case 9 :
return "MIPS16 JumpAddr";
314 case 10 :
return "64 bit field";
323 IMAGE_BASE_RELOCATION* reloc = parentDir->
myReloc();
const offset_t INVALID_ADDR
bufsize_t getDirEntrySize(bool trimToExeSize=false)
offset_t getDirEntryAddress()
virtual bufsize_t getFieldSize(size_t fieldId, size_t subField=FIELD_NONE)
virtual offset_t getFieldOffset(size_t fieldId, size_t subField=FIELD_NONE)
virtual offset_t getOffset()
virtual uint64_t getNumValue(size_t fieldId, size_t subField, bool *isOk)
virtual ExeNodeWrapper * getEntryAt(size_t fieldId)
std::vector< ExeNodeWrapper * > entries
BYTE * getContentAt(offset_t offset, bufsize_t size, bool allowExceptions=false)
virtual offset_t getRawSize() const
virtual bufsize_t getImageSize()
virtual QString getFieldName(size_t fieldId)
virtual WrappedValue::data_type containsDataType(size_t fieldId, size_t subField)
virtual void * getFieldPtr(size_t fieldId, size_t subField=FIELD_NONE)
virtual QString getName()
virtual bufsize_t getSize()
size_t maxEntriesNumInBlock()
virtual Executable::addr_type containsAddrType(size_t fieldId, size_t subField)
IMAGE_BASE_RELOCATION * myReloc()
friend class RelocBlockWrapper
IMAGE_BASE_RELOCATION * reloc()
offset_t deltaToRVA(WORD delta)
static QString translateType(WORD type)
virtual bufsize_t getSize()
static WORD getDelta(WORD relocEntryVal)
static WORD getType(WORD relocEntryVal)