4size_t RelocDirWrapper::EntriesLimit = 10000;
42 for (
size_t i = 0; i < RelocDirWrapper::EntriesLimit && parsedSize < maxSize; i++) {
45 if (entry->
getPtr() == NULL) {
52 this->parsedSize += val;
65 if (ptr == NULL)
return NULL;
67 IMAGE_BASE_RELOCATION *
reloc = (IMAGE_BASE_RELOCATION*) ptr;
78 IMAGE_BASE_RELOCATION* reloc =
myReloc();
79 if (!reloc)
return false;
81 size_t maxSize = reloc->SizeOfBlock;
82 parsedSize =
sizeof(reloc->VirtualAddress) +
sizeof(reloc->SizeOfBlock);
84 for (
size_t i = 0; i < RelocDirWrapper::EntriesLimit && parsedSize < maxSize; i++) {
87 if (entry->
getPtr() == NULL) {
92 size_t val =
sizeof(WORD);
94 this->parsedSize += val;
103 if (this->parentDir == NULL)
return NULL;
104 IMAGE_BASE_RELOCATION* reloc = this->parentDir->
reloc();
105 if (!reloc)
return NULL;
117 size_t prevNum = this->
entryNum - 1;
121 offset_t prevRaw = prevEntry->cachedRaw;
123 IMAGE_BASE_RELOCATION* prevReloc = (IMAGE_BASE_RELOCATION*) prevEntry->
getPtr();
124 raw = prevRaw + prevReloc->SizeOfBlock;
130 this->cachedRaw = raw;
137 offset_t blockSize = reloc->SizeOfBlock;
142 for (
size_t i = 0; i < this->
entryNum; i++) {
146 if (!ptr)
return NULL;
148 reloc = (IMAGE_BASE_RELOCATION*) ptr;
149 blockSize = reloc->SizeOfBlock;
152 this->cachedRaw = raw;
158 if (this->parentDir == NULL)
return 0;
159 IMAGE_BASE_RELOCATION* reloc = (IMAGE_BASE_RELOCATION*) this->
getPtr();
160 if (!reloc)
return 0;
162 if (reloc->SizeOfBlock > 0)
return reloc->SizeOfBlock;
164 return sizeof(IMAGE_BASE_RELOCATION);
169 IMAGE_BASE_RELOCATION* reloc = (IMAGE_BASE_RELOCATION*) this->
getPtr();
170 if (!reloc)
return NULL;
173 case PAGE_VA:
return (
void*) &reloc->VirtualAddress;
174 case BLOCK_SIZE :
return (
void*) &reloc->SizeOfBlock;
177 BYTE *blockSizePtr = (BYTE*) &reloc->SizeOfBlock;
178 return blockSizePtr +
sizeof(DWORD);
188 case PAGE_VA:
return "Page RVA";
216 if (entriesPtr == NULL || entriesSize == 0)
return NULL;
226 if (this->cachedMaxNum > 0)
return this->cachedMaxNum;
228 IMAGE_BASE_RELOCATION* reloc = (IMAGE_BASE_RELOCATION*) this->
getPtr();
229 if (!reloc)
return 0;
235 if (entriesOffset + entriesSize > fileSize) {
236 entriesSize = fileSize - entriesOffset;
243 entriesNum = entriesSize /
sizeof(WORD);
245 this->cachedMaxNum = entriesNum;
252 if (this->parentDir == NULL)
return NULL;
255 if (this->
entryNum >= maxNum)
return NULL;
258 if (entriesPtr == NULL)
return NULL;
260 WORD* ptr = &entriesPtr[this->
entryNum];
266 if (this->parentDir == NULL)
return 0;
272 pe::BASE_RELOCATION_ENTRY* entry = (pe::BASE_RELOCATION_ENTRY*) &relocEntryVal;
278 pe::BASE_RELOCATION_ENTRY* entry = (pe::BASE_RELOCATION_ENTRY*) &relocEntryVal;
279 return entry->Offset;
285 case 0 :
return "Padding (skipped)";
286 case 1 :
return "High WORD of 32-bit field";
287 case 2 :
return "Low WORD of 32-bit field";
288 case 3 :
return "32 bit field";
289 case 4 :
return "HighAdj";
290 case 5 :
return "MIPS JumpAddr";
291 case 6 :
case 7 :
return "Reserved";
292 case 9 :
return "MIPS16 JumpAddr";
293 case 10 :
return "64 bit field";
302 IMAGE_BASE_RELOCATION* reloc = parentDir->
myReloc();
const offset_t INVALID_ADDR
bufsize_t getDirEntrySize()
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 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 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)