BearParser
Portable Executable parsing library (from PE-bear)
Loading...
Searching...
No Matches
ExeNodeWrapper.h
Go to the documentation of this file.
1#pragma once
2
3#include "ExeElementWrapper.h"
4#include <vector>
5
6const size_t INVALID_ENTRYNUM = (-1);
7
9{
10public:
11 ExeNodeWrapper(Executable *pe, ExeNodeWrapper* parent = NULL);
12 ExeNodeWrapper(Executable *pe, ExeNodeWrapper* parent, size_t entryNumber);
13
14 virtual ~ExeNodeWrapper() { clear(); }
15
16 virtual bool wrap() { return true; }
17 virtual void reloadMapping() {}
18
19 virtual ExeNodeWrapper* getEntryAt(size_t fieldId);
20 virtual size_t getEntriesCount() { return getEntriesCount(this->entries); }
21 virtual size_t getEntriesNum() { return getEntriesCount(this->entries); }
22 virtual size_t getSubFieldsCount() { return (this->entries.size() == 0) ? 0 : this->entries[0]->getFieldsCount(); }
23
25 size_t getEntryId() { return entryNum; }
26
27 virtual void* getSubfieldPtr(size_t fieldId, size_t subField);
28 virtual bufsize_t getSubfieldSize(size_t fieldId, size_t subField);
29 virtual QString getSubfieldName(size_t fieldId, size_t subField);
30
31 virtual QString getFieldName(size_t fieldId) = 0;
32 //---
33 virtual bool canAddEntry();
34
35 virtual ExeNodeWrapper* addEntry(ExeNodeWrapper *entry);
38 virtual bufsize_t geEntrySize();
39
40 virtual bool isValid() { return true; }
41
42protected:
43 size_t getEntriesCount(std::vector<ExeNodeWrapper*> &_entries);
44 ExeNodeWrapper* getEntryAt(std::vector<ExeNodeWrapper*> &_entries, size_t fieldId);
45
46 virtual void clear();
47 virtual void addMapping(ExeNodeWrapper *entry) {}
48 virtual bool loadNextEntry(size_t entryNum) { return false; } //TODO!
49 virtual ExeNodeWrapper* addEntryAt(ExeNodeWrapper *entry, offset_t nextOffset);
50
51 virtual bool isMyEntryType(ExeNodeWrapper *entry); // is it an entry of appropriate type
52
54 size_t entryNum;
55
56 std::vector<ExeNodeWrapper*> entries; // children
57};
58
uint32_t bufsize_t
uint64_t offset_t
const size_t INVALID_ENTRYNUM
virtual QString getFieldName(size_t fieldId)=0
virtual bool isMyEntryType(ExeNodeWrapper *entry)
virtual void * getSubfieldPtr(size_t fieldId, size_t subField)
virtual ExeNodeWrapper * addEntryAt(ExeNodeWrapper *entry, offset_t nextOffset)
ExeNodeWrapper * getLastEntry()
virtual QString getSubfieldName(size_t fieldId, size_t subField)
virtual size_t getEntriesNum()
virtual bool wrap()
ExeNodeWrapper(Executable *pe, ExeNodeWrapper *parent=NULL)
virtual void reloadMapping()
virtual ExeNodeWrapper * getEntryAt(size_t fieldId)
virtual void addMapping(ExeNodeWrapper *entry)
virtual bufsize_t geEntrySize()
std::vector< ExeNodeWrapper * > entries
virtual ~ExeNodeWrapper()
size_t getEntryId()
virtual bool loadNextEntry(size_t entryNum)
virtual bool canAddEntry()
virtual offset_t getNextEntryOffset()
ExeNodeWrapper * parentNode
virtual bool isValid()
virtual size_t getEntriesCount()
virtual size_t getSubFieldsCount()
virtual void clear()
virtual bufsize_t getSubfieldSize(size_t fieldId, size_t subField)
virtual ExeNodeWrapper * addEntry(ExeNodeWrapper *entry)
virtual ExeNodeWrapper * getParentNode()