BearParser
Portable Executable parsing library (from PE-bear)
Loading...
Searching...
No Matches
ResourcesAlbum.h
Go to the documentation of this file.
1#pragma once
2
3#define TOP_ENTRY_ROOT long(-1)
4
8
9#include <map>
10#include <vector>
11
13public:
15 virtual ~ResourcesContainer() {} //TODO
16
19
20 size_t count() { return wrappers.size(); }
21 size_t entriesCount();
22
23protected:
24 std::vector<ResourceContentWrapper*> wrappers;
25};
26
28public:
29
31
32 virtual ~ResourcesAlbum() { clear(); }
33
34 void putLeaf(ResourceLeafWrapper* leaf, long topEntryId);
35 void clear();
36
37 size_t dirsCount() { return allLeafs.size(); }
38 size_t entriesCountAt(long topEntryId);
39 std::vector<ResourceLeafWrapper*>* entriesAt(long topEntryId);
40
41 //TODO: create ResourceContentWrapper
42 void mapIdToLeafType(long topId, pe::resource_type leafType) { idToLeafType[topId] = leafType; }
43 void wrapLeafsContent(); // TODO: wrap content on demand - lazy mode
45
46 bool hasType(pe::resource_type typeId) { return (allWrappers.find(typeId) == allWrappers.end()) ? false : true; }
47 ResourcesContainer* getResourcesOfType(pe::resource_type typeId);
48 std::vector<pe::resource_type> getResourceTypes() const { return allTypes; }
49
50protected:
51 void clearLeafsContent();
52
53 void initResourceTypes();
54 bool hasTopEntry(long topEntryId) { return (allLeafs.find(topEntryId) == allLeafs.end()) ? false : true; }
55
56 std::vector<pe::resource_type> allTypes;
57 std::map<pe::resource_type, ResourcesContainer> allWrappers;
58 std::map<long, std::vector<ResourceLeafWrapper*> > allLeafs;
59
60 std::map<long, pe::resource_type> idToLeafType; // map topEntryId to leafDataType: i. e. RT_HTML, case RT_MANIFEST
61 std::map<ResourceLeafWrapper*, ResourceContentWrapper*> leafToContentWrapper;
62
63};
64
size_t entriesCountAt(long topEntryId)
ResourcesAlbum(Executable *pe)
std::map< ResourceLeafWrapper *, ResourceContentWrapper * > leafToContentWrapper
std::vector< pe::resource_type > allTypes
void mapIdToLeafType(long topId, pe::resource_type leafType)
void putLeaf(ResourceLeafWrapper *leaf, long topEntryId)
ResourceContentWrapper * getContentWrapper(ResourceLeafWrapper *leaf)
std::map< long, std::vector< ResourceLeafWrapper * > > allLeafs
ResourcesContainer * getResourcesOfType(pe::resource_type typeId)
bool hasTopEntry(long topEntryId)
std::vector< ResourceLeafWrapper * > * entriesAt(long topEntryId)
std::vector< pe::resource_type > getResourceTypes() const
std::map< long, pe::resource_type > idToLeafType
virtual ~ResourcesAlbum()
bool hasType(pe::resource_type typeId)
std::map< pe::resource_type, ResourcesContainer > allWrappers
void putWrapper(ResourceContentWrapper *wrapper)
ResourceContentWrapper * getWrapperAt(size_t index)
std::vector< ResourceContentWrapper * > wrappers
virtual ~ResourcesContainer()