BearParser
Portable Executable parsing library (from PE-bear)
Loading...
Searching...
No Matches
DataDirEntryWrapper.cpp
Go to the documentation of this file.
2#include "pe/PEFile.h"
3
5 : PENodeWrapper(pe), entryType(v_entryType)
6{
7 wrap();
8}
9
18
20{
22 const size_t recordsCount = dDir ? dDir->getDirsCount() : 0;
23 if (this->entryType >= recordsCount) return INVALID_ADDR;
24
26 if (!d) return INVALID_ADDR;
27
28 offset_t rva = static_cast<offset_t>(d[this->entryType].VirtualAddress);
29 if (rva == 0) return INVALID_ADDR;
30 return rva;
31}
32
34{
36 const size_t recordsCount = dDir ? dDir->getDirsCount() : 0;
37 if (this->entryType >= recordsCount) return 0;
38
40 if (!d) return 0;
41
42 bufsize_t dirSize = static_cast<bufsize_t>(d[this->entryType].Size);
43 if (!trimToExeSize) {
44 return dirSize;
45 }
46
47 if (!this->m_Exe) return 0; // should never happen
48
49 offset_t dirRva = d[this->entryType].VirtualAddress;
50 offset_t dirRaw = this->m_Exe->rvaToRaw(dirRva);
51 if (dirRaw == INVALID_ADDR) {
52 return 0;
53 }
56
58}
INT_TYPE _getNumValue(void *ptr)
uint32_t bufsize_t
const offset_t INVALID_ADDR
uint64_t offset_t
bufsize_t getDirEntrySize(bool trimToExeSize=false)
offset_t getDirEntryAddress()
int entryType
DataDirEntryWrapper(PEFile *pe, pe::dir_entry v_entryType)
IMAGE_DATA_DIRECTORY * getDataDirectory()
virtual bool wrap()
virtual ExeElementWrapper * getWrapper(size_t wrapperId)
Definition MappedExe.cpp:13
virtual offset_t rvaToRaw(offset_t rva)=0
virtual bufsize_t getContentSize()
Definition Executable.h:51
@ WR_DATADIR
Definition PEFile.h:49
IMAGE_DATA_DIRECTORY * getDataDirectory()
Definition PEFile.cpp:268