BearParser
Portable Executable parsing library (from PE-bear)
Loading...
Searching...
No Matches
RelocDirWrapper.h
Go to the documentation of this file.
1#pragma once
2
4
8
10{
11public:
13 : DataDirEntryWrapper(pe, pe::DIR_BASERELOC),
14 parsedSize(0)
15 {
16 wrap();
17 }
18
19 bool wrap();
20
21 virtual void* getPtr() { return reloc(); }
22
23 virtual bufsize_t getSize() { return parsedSize; }
24 virtual QString getName() { return "Relocation Dir."; }
25 virtual size_t getFieldsCount() { return entries.size(); }
26
27 virtual void* getFieldPtr(size_t fieldId, size_t subField) { return getSubfieldPtr(fieldId, subField ); }
28 virtual bufsize_t getFieldSize(size_t fieldId, size_t subField) { return getSubfieldSize(fieldId, subField ); }
29 virtual QString getFieldName(size_t fieldId) { return "Relocation Block"; }
30 virtual QString getFieldName(size_t fieldId, size_t subField) { return getSubfieldName(fieldId, subField ); }
31
32protected:
33 IMAGE_BASE_RELOCATION* reloc();
34
35private:
36 bufsize_t parsedSize;
37
38friend class RelocBlockWrapper;
39};
40
41
43{
44public:
45 // fields :
53
54 RelocBlockWrapper(Executable *pe, RelocDirWrapper *parentDir, size_t entryNumber)
55 : ExeNodeWrapper(pe, parentDir, entryNumber),
56 cachedRaw(INVALID_ADDR), cachedMaxNum(0),
57 isValidPage(false)
58 {
59 this->parentDir = parentDir;
60 wrap();
61 }
62
63 bool wrap();
64 bool isValid();
65 // full structure boundaries
66 virtual void* getPtr();
67 virtual bufsize_t getSize();
68 virtual QString getName() { return "Relocation Block"; }
69 virtual size_t getFieldsCount() { return FIELD_COUNTER; }
70
71 // specific field boundaries
72 virtual void* getFieldPtr(size_t fieldId, size_t subField = FIELD_NONE);
73 virtual QString getFieldName(size_t fieldId);
74 virtual Executable::addr_type containsAddrType(size_t fieldId, size_t subField);
75 virtual WrappedValue::data_type containsDataType(size_t fieldId, size_t subField);
76
77 void* getEntriesPtr();
78 size_t maxEntriesNumInBlock();
79
80 IMAGE_BASE_RELOCATION* myReloc() { return (IMAGE_BASE_RELOCATION*) getPtr(); }
81
82private:
83 void validatePage();
84 bool isValidPage;
85
86 offset_t cachedRaw;
87 //size_t cachedSize; // TODO
88 offset_t cachedMaxNum;
89
90 RelocDirWrapper* parentDir;
91
92 size_t parsedSize;
93
94};
95
97{
98public:
99 // fields :
105
106 RelocEntryWrapper(Executable* pe, RelocBlockWrapper *parentDir, size_t entryNumber)
107 : ExeNodeWrapper(pe, parentDir, entryNumber) { this->parentDir = parentDir; }
108
109 // full structure boundaries
110 virtual void* getPtr();
111 virtual bufsize_t getSize();
112 virtual QString getName() { return "Type-Offset"; }
113 virtual size_t getFieldsCount() { return FIELD_COUNTER; }
114 virtual size_t getSubFieldsCount() { return 1; }
115
116 // specific field boundaries
117 virtual void* getFieldPtr(size_t fieldId, size_t subField = FIELD_NONE) { return getPtr(); }
118 virtual QString getFieldName(size_t fieldId) { return getName(); }
119 virtual Executable::addr_type containsAddrType(size_t fieldId, size_t subField) { return Executable::NOT_ADDR; }
120
121 offset_t deltaToRVA(WORD delta);
122 static WORD getType(WORD relocEntryVal);
123 static WORD getDelta(WORD relocEntryVal);
124 static QString translateType(WORD type);
125
126private:
127 RelocBlockWrapper* parentDir;
128};
129
uint32_t bufsize_t
const offset_t INVALID_ADDR
uint64_t offset_t
#define FIELD_NONE
virtual void * getSubfieldPtr(size_t fieldId, size_t subField)
virtual QString getSubfieldName(size_t fieldId, size_t subField)
std::vector< ExeNodeWrapper * > entries
virtual bufsize_t getSubfieldSize(size_t fieldId, size_t subField)
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)
RelocBlockWrapper(Executable *pe, RelocDirWrapper *parentDir, size_t entryNumber)
virtual void * getPtr()
virtual size_t getFieldsCount()
virtual QString getName()
virtual bufsize_t getSize()
virtual Executable::addr_type containsAddrType(size_t fieldId, size_t subField)
IMAGE_BASE_RELOCATION * myReloc()
virtual QString getName()
virtual void * getFieldPtr(size_t fieldId, size_t subField)
virtual QString getFieldName(size_t fieldId, size_t subField)
virtual bufsize_t getSize()
virtual QString getFieldName(size_t fieldId)
virtual bufsize_t getFieldSize(size_t fieldId, size_t subField)
RelocDirWrapper(PEFile *pe)
virtual void * getPtr()
IMAGE_BASE_RELOCATION * reloc()
virtual size_t getFieldsCount()
offset_t deltaToRVA(WORD delta)
virtual size_t getSubFieldsCount()
static QString translateType(WORD type)
virtual Executable::addr_type containsAddrType(size_t fieldId, size_t subField)
virtual size_t getFieldsCount()
FieldID
@ FIELD_COUNTER
@ RELOC_ENTRY_VAL
@ NONE
virtual void * getPtr()
virtual void * getFieldPtr(size_t fieldId, size_t subField=FIELD_NONE)
virtual bufsize_t getSize()
static WORD getDelta(WORD relocEntryVal)
RelocEntryWrapper(Executable *pe, RelocBlockWrapper *parentDir, size_t entryNumber)
virtual QString getName()
virtual QString getFieldName(size_t fieldId)
static WORD getType(WORD relocEntryVal)