40 while (parsedSize < maxSize) {
47 if (!entry->
getPtr() || !val || !isOk) {
51 this->parsedSize += val;
64 if (ptr == NULL)
return NULL;
66 IMAGE_BASE_RELOCATION *
reloc = (IMAGE_BASE_RELOCATION*) ptr;
77 IMAGE_BASE_RELOCATION* reloc =
myReloc();
78 if (!reloc)
return false;
80 size_t maxSize = reloc->SizeOfBlock;
81 parsedSize =
sizeof(IMAGE_BASE_RELOCATION);
84 while (parsedSize < maxSize) {
91 this->parsedSize +=
sizeof(pe::BASE_RELOCATION_ENTRY);
100 if (this->parentDir == NULL)
return NULL;
101 IMAGE_BASE_RELOCATION* reloc = this->parentDir->
reloc();
102 if (!reloc)
return NULL;
114 size_t prevNum = this->
entryNum - 1;
118 offset_t prevRaw = prevEntry->cachedRaw;
120 IMAGE_BASE_RELOCATION* prevReloc = (IMAGE_BASE_RELOCATION*) prevEntry->
getPtr();
121 raw = prevRaw + prevReloc->SizeOfBlock;
127 this->cachedRaw = raw;
134 offset_t blockSize = reloc->SizeOfBlock;
139 for (
size_t i = 0; i < this->
entryNum; i++) {
143 if (!ptr)
return NULL;
145 reloc = (IMAGE_BASE_RELOCATION*) ptr;
146 blockSize = reloc->SizeOfBlock;
149 this->cachedRaw = raw;
155 if (this->parentDir == NULL)
return 0;
156 IMAGE_BASE_RELOCATION* reloc = (IMAGE_BASE_RELOCATION*) this->
getPtr();
157 if (!reloc)
return 0;
159 if (reloc->SizeOfBlock > 0)
return reloc->SizeOfBlock;
161 return sizeof(IMAGE_BASE_RELOCATION);
166 IMAGE_BASE_RELOCATION* reloc = (IMAGE_BASE_RELOCATION*) this->
getPtr();
167 if (!reloc)
return NULL;
170 case PAGE_VA:
return (
void*) &reloc->VirtualAddress;
171 case BLOCK_SIZE :
return (
void*) &reloc->SizeOfBlock;
174 BYTE *blockSizePtr = (BYTE*) &reloc->SizeOfBlock;
175 return blockSizePtr +
sizeof(DWORD);
185 case PAGE_VA:
return "Page RVA";
213 if (entriesPtr == NULL || entriesSize == 0)
return NULL;
223 if (this->cachedMaxNum > 0)
return this->cachedMaxNum;
225 IMAGE_BASE_RELOCATION* reloc = (IMAGE_BASE_RELOCATION*) this->
getPtr();
226 if (!reloc)
return 0;
232 if (entriesOffset + entriesSize > fileSize) {
233 entriesSize = fileSize - entriesOffset;
240 entriesNum = entriesSize /
sizeof(WORD);
242 this->cachedMaxNum = entriesNum;
249 if (this->parentDir == NULL)
return NULL;
252 if (this->
entryNum >= maxNum)
return NULL;
255 if (entriesPtr == NULL)
return NULL;
257 WORD* ptr = &entriesPtr[this->
entryNum];
263 if (this->parentDir == NULL)
return 0;
269 pe::BASE_RELOCATION_ENTRY* entry = (pe::BASE_RELOCATION_ENTRY*) &relocEntryVal;
275 pe::BASE_RELOCATION_ENTRY* entry = (pe::BASE_RELOCATION_ENTRY*) &relocEntryVal;
276 return entry->Offset;
282 case 0 :
return "Padding (skipped)";
283 case 1 :
return "High WORD of 32-bit field";
284 case 2 :
return "Low WORD of 32-bit field";
285 case 3 :
return "32 bit field";
286 case 4 :
return "HighAdj";
287 case 5 :
return "MIPS JumpAddr";
288 case 6 :
case 7 :
return "Reserved";
289 case 9 :
return "MIPS16 JumpAddr";
290 case 10 :
return "64 bit field";
299 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 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)