13 #ifndef RETDEC_PELIB_RESOURCEDIRECTORY_H
14 #define RETDEC_PELIB_RESOURCEDIRECTORY_H
23 class ResourceElement;
24 class ResourceDirectory;
42 bool equalId(std::uint32_t wId)
const;
44 bool equalName(std::string strName)
const;
75 void setName(
const std::string& strNewName);
111 virtual void recalculate(
unsigned int& uiCurrentOffset,
unsigned int uiNewRva) = 0;
145 void rebuild(
OutputBuffer&,
unsigned int uiOffset,
unsigned int uiRva,
const std::string&)
const;
147 virtual void recalculate(
unsigned int& uiCurrentOffset,
unsigned int uiNewRva)
override;
159 std::vector<std::uint8_t>
getData()
const;
161 void setData(
const std::vector<std::uint8_t>& vData);
175 void setSize(std::uint32_t dwValue);
203 void rebuild(
OutputBuffer&,
unsigned int uiOffset,
unsigned int uiRva,
const std::string&)
const;
205 virtual void recalculate(
unsigned int& uiCurrentOffset,
unsigned int uiNewRva)
override;
231 void setChildName(
unsigned int uiIndex,
const std::string& strNewName);
288 node->
children.size() - std::count_if(
291 [](
const auto& i) { return i.isNamedResource(); }
308 [](
const auto& i) { return i.isNamedResource(); }
358 template<
typename S,
typename T>
359 std::vector<ResourceChild>::const_iterator
locateResourceT(S restypeid, T resid)
const;
362 template<
typename S,
typename T>
363 std::vector<ResourceChild>::iterator
locateResourceT(S restypeid, T resid);
366 template<
typename S,
typename T>
370 template<
typename S,
typename T>
374 template<
typename S,
typename T>
375 int getResourceDataT(S restypeid, T resid, std::vector<std::uint8_t>& data)
const;
378 template<
typename S,
typename T>
379 int setResourceDataT(S restypeid, T resid, std::vector<std::uint8_t>& data);
382 template<
typename S,
typename T>
386 template<
typename S,
typename T>
387 int setResourceIdT(S restypeid, T resid, std::uint32_t dwNewResId);
390 template<
typename S,
typename T>
394 template<
typename S,
typename T>
416 void rebuild(std::vector<std::uint8_t>& vBuffer,
unsigned int uiRva)
const;
418 void recalculate(
unsigned int& uiNewSize,
unsigned int uiNewRva);
422 int write(
const std::string& strFilename,
unsigned int uiOffset,
unsigned int uiRva)
const;
438 int addResource(std::uint32_t dwResTypeId, std::uint32_t dwResId);
440 int addResource(std::uint32_t dwResTypeId,
const std::string& strResName);
442 int addResource(
const std::string& strResTypeName, std::uint32_t dwResId);
444 int addResource(
const std::string& strResTypeName,
const std::string& strResName);
447 int removeResource(std::uint32_t dwResTypeId, std::uint32_t dwResId);
449 int removeResource(std::uint32_t dwResTypeId,
const std::string& strResName);
451 int removeResource(
const std::string& strResTypeName, std::uint32_t dwResId);
453 int removeResource(
const std::string& strResTypeName,
const std::string& strResName);
480 void getResourceData(std::uint32_t dwResTypeId, std::uint32_t dwResId, std::vector<std::uint8_t>& data)
const;
482 void getResourceData(std::uint32_t dwResTypeId,
const std::string& strResName, std::vector<std::uint8_t>& data)
const;
484 void getResourceData(
const std::string& strResTypeName, std::uint32_t dwResId, std::vector<std::uint8_t>& data)
const;
486 void getResourceData(
const std::string& strResTypeName,
const std::string& strResName, std::vector<std::uint8_t>& data)
const;
489 void getResourceDataByIndex(
unsigned int uiResTypeIndex,
unsigned int uiResIndex, std::vector<std::uint8_t>& data)
const;
492 void setResourceData(std::uint32_t dwResTypeId, std::uint32_t dwResId, std::vector<std::uint8_t>& data);
494 void setResourceData(std::uint32_t dwResTypeId,
const std::string& strResName, std::vector<std::uint8_t>& data);
496 void setResourceData(
const std::string& strResTypeName, std::uint32_t dwResId, std::vector<std::uint8_t>& data);
498 void setResourceData(
const std::string& strResTypeName,
const std::string& strResName, std::vector<std::uint8_t>& data);
501 void setResourceDataByIndex(
unsigned int uiResTypeIndex,
unsigned int uiResIndex, std::vector<std::uint8_t>& data);
504 std::uint32_t
getResourceId(std::uint32_t dwResTypeId,
const std::string& strResName)
const;
506 std::uint32_t
getResourceId(
const std::string& strResTypeName,
const std::string& strResName)
const;
512 void setResourceId(std::uint32_t dwResTypeId, std::uint32_t dwResId, std::uint32_t dwNewResId);
514 void setResourceId(std::uint32_t dwResTypeId,
const std::string& strResName, std::uint32_t dwNewResId);
516 void setResourceId(
const std::string& strResTypeName, std::uint32_t dwResId, std::uint32_t dwNewResId);
518 void setResourceId(
const std::string& strResTypeName,
const std::string& strResName, std::uint32_t dwNewResId);
521 void setResourceIdByIndex(
unsigned int uiResTypeIndex,
unsigned int uiResIndex, std::uint32_t dwNewResId);
524 std::string
getResourceName(std::uint32_t dwResTypeId, std::uint32_t dwResId)
const;
526 std::string
getResourceName(
const std::string& strResTypeName, std::uint32_t dwResId)
const;
532 void setResourceName(std::uint32_t dwResTypeId, std::uint32_t dwResId,
const std::string& strNewResName);
534 void setResourceName(std::uint32_t dwResTypeId,
const std::string& strResName,
const std::string& strNewResName);
536 void setResourceName(
const std::string& strResTypeName, std::uint32_t dwResId,
const std::string& strNewResName);
538 void setResourceName(
const std::string& strResTypeName,
const std::string& strResName,
const std::string& strNewResName);
541 void setResourceNameByIndex(
unsigned int uiResTypeIndex,
unsigned int uiResIndex,
const std::string& strNewResName);
559 template<
typename S,
typename T>
562 auto Iter = std::find_if(
565 [&](
const auto& res) { return res.hasEqual(restypeid); }
576 [&](
const auto& res) { return res.hasEqual(resid); }
587 template<
typename S,
typename T>
590 auto Iter = std::find_if(
593 [&](
const auto& res) { return res.hasEqual(restypeid); }
604 [&](
const auto& res) { return res.hasEqual(resid); }
614 template<
typename S,
typename T>
617 auto Iter = std::find_if(
620 [&](
const auto& res) { return res.hasEqual(restypeid); }
629 auto ResIter = std::find_if(
632 [&](
const auto& res) { return res.hasEqual(resid); }
634 if (ResIter != currNode->
children.end())
644 currNode2->
children.push_back(rlnew);
658 template<
typename S,
typename T>
661 auto Iter = std::find_if(
664 [&](
const auto& res) { return res.hasEqual(restypeid); }
673 auto ResIter = std::find_if(
676 [&](
const auto& res) { return res.hasEqual(resid); }
678 if (ResIter == currNode->
children.end())
697 template<
typename S,
typename T>
700 std::vector<ResourceChild>::const_iterator ResIter =
locateResourceT(restypeid, resid);
703 data.assign(currLeaf->
m_data.begin(), currLeaf->
m_data.end());
714 template<
typename S,
typename T>
717 std::vector<ResourceChild>::iterator ResIter =
locateResourceT(restypeid, resid);
720 currLeaf->
m_data.assign(data.begin(), data.end());
732 template<
typename S,
typename T>
735 std::vector<ResourceChild>::const_iterator ResIter =
locateResourceT(restypeid, resid);
736 return ResIter->entry.irde.Name;
745 template<
typename S,
typename T>
748 std::vector<ResourceChild>::iterator ResIter =
locateResourceT(restypeid, resid);
749 ResIter->entry.irde.Name = dwNewResId;
760 template<
typename S,
typename T>
763 std::vector<ResourceChild>::const_iterator ResIter =
locateResourceT(restypeid, resid);
764 return ResIter->entry.wstrName;
773 template<
typename S,
typename T>
776 std::vector<ResourceChild>::iterator ResIter =
locateResourceT(restypeid, resid);
777 ResIter->entry.wstrName = strNewResName;
Definition: ImageLoader.h:138
Definition: OutputBuffer.h:22
The class ResourceChild is used to store information about a resource node.
Definition: ResourceDirectory.h:28
void setName(const std::string &strNewName)
Sets the name of the node.
Definition: ResourceDirectory.cpp:243
void setNode(ResourceElement *node)
Sets a pointer to ResourceElement.
Definition: ResourceDirectory.cpp:203
ResourceChild * getChildOfThisChild(std::size_t uiIndex)
Returns a child of this child.
Definition: ResourceDirectory.cpp:153
ResourceChild()
Returns the size of a resource child.
Definition: ResourceDirectory.cpp:20
bool hasEqual(const std::string &name) const
A comparison function for searching a resource element by its name.
Definition: ResourceDirectory.h:53
bool hasEqual(std::uint32_t id) const
A comparison function for searching a resource element by its ID.
Definition: ResourceDirectory.h:51
bool isNamedResource() const
Predicate that determines if a child is identified by name or by ID.
Definition: ResourceDirectory.cpp:107
bool equalName(std::string strName) const
Function which compares a string to the node's resource name.
Definition: ResourceDirectory.cpp:99
unsigned int getNumberOfChildren() const
Returns the node's number of children.
Definition: ResourceDirectory.cpp:139
~ResourceChild()
Deletes a ResourceChild object.
Definition: ResourceDirectory.cpp:79
bool equalId(std::uint32_t wId) const
Function which compares a resource ID to the node's resource ID.
Definition: ResourceDirectory.cpp:89
ResourceElement * getNode()
Returns a pointer to ResourceElement.
Definition: ResourceDirectory.cpp:183
void setOffsetToData(std::uint32_t dwNewOffset)
Sets the OffsetToData value of the node.
Definition: ResourceDirectory.cpp:263
void setOffsetToName(std::uint32_t dwNewOffset)
Sets the Name value of the node.
Definition: ResourceDirectory.cpp:253
ResourceChild & operator=(const ResourceChild &rhs)
Makes a deep copy of a ResourceChild object.
Definition: ResourceDirectory.cpp:49
bool operator<(const ResourceChild &rc) const
Used for sorting a node's children.
Definition: ResourceDirectory.cpp:116
PELIB_IMG_RES_DIR_ENTRY entry
Stores name and offset of a resource node.
Definition: ResourceDirectory.h:36
std::uint32_t getOffsetToData() const
Returns the OffsetToData value of the node.
Definition: ResourceDirectory.cpp:233
std::string getName() const
Returns the name of the node.
Definition: ResourceDirectory.cpp:213
ResourceElement * child
A pointer to one of the node's child nodes.
Definition: ResourceDirectory.h:38
std::uint32_t getOffsetToName() const
Returns the Name value of the node.
Definition: ResourceDirectory.cpp:223
Class that represents the resource directory of a PE file.
Definition: ResourceDirectory.h:342
int removeResource(std::uint32_t dwResTypeId, std::uint32_t dwResId)
Removes a resource.
Definition: ResourceDirectory.cpp:1325
int getResourceDataT(S restypeid, T resid, std::vector< std::uint8_t > &data) const
Returns the data of a resource.
Definition: ResourceDirectory.h:698
ResourceDirectory()
Constructor.
Definition: ResourceDirectory.cpp:1011
void setResourceId(std::uint32_t dwResTypeId, std::uint32_t dwResId, std::uint32_t dwNewResId)
Sets the ID of a certain resource.
Definition: ResourceDirectory.cpp:1665
unsigned int getNumberOfResourcesByIndex(unsigned int uiIndex) const
Returns the number of resources of a certain resource type.
Definition: ResourceDirectory.cpp:1496
int write(const std::string &strFilename, unsigned int uiOffset, unsigned int uiRva) const
Returns the size of the rebuilt resource directory.
Definition: ResourceDirectory.cpp:1112
void setResourceIdByIndex(unsigned int uiResTypeIndex, unsigned int uiResIndex, std::uint32_t dwNewResId)
Sets the ID of a certain resource.
Definition: ResourceDirectory.cpp:1709
std::uint32_t getResourceIdT(S restypeid, T resid) const
Returns the ID of a resource.
Definition: ResourceDirectory.h:733
std::string getResourceName(std::uint32_t dwResTypeId, std::uint32_t dwResId) const
Returns the name of a certain resource.
Definition: ResourceDirectory.cpp:1721
int addResourceType(std::uint32_t dwResTypeId)
Adds a new resource type.
Definition: ResourceDirectory.cpp:1148
std::uint32_t getResourceTypeIdByIndex(unsigned int uiIndex) const
Returns the ID of a resource type.
Definition: ResourceDirectory.cpp:1386
int setResourceNameT(S restypeid, T resid, std::string strNewResName)
Sets the name of a resource.
Definition: ResourceDirectory.h:774
void addOccupiedAddressRange(unsigned int start, unsigned int end)
Definition: ResourceDirectory.cpp:1823
int resourceTypeIdToIndex(std::uint32_t dwResTypeId) const
Converts a resource type ID to an index.
Definition: ResourceDirectory.cpp:1408
const std::vector< std::pair< unsigned int, unsigned int > > & getOccupiedAddresses() const
Definition: ResourceDirectory.cpp:1828
void insertNodeOffset(std::size_t nodeOffset)
Insert offset of loaded node.
Definition: ResourceDirectory.cpp:1809
unsigned int getNumberOfResourceTypes() const
Returns the number of resource types.
Definition: ResourceDirectory.cpp:1374
int read(ImageLoader &imageLoader)
Reads the resource directory from a file.
Definition: ResourceDirectory.cpp:1029
void rebuild(std::vector< std::uint8_t > &vBuffer, unsigned int uiRva) const
Rebuilds the resource directory.
Definition: ResourceDirectory.cpp:1077
void setLoaderError(LoaderError ldrError)
Definition: ResourceDirectory.cpp:1054
std::string getResourceNameByIndex(unsigned int uiResTypeIndex, unsigned int uiResIndex) const
Returns the name of a certain resource.
Definition: ResourceDirectory.cpp:1743
int removeResourceTypeByIndex(unsigned int uiIndex)
Removes a resource type and all of it's resources.
Definition: ResourceDirectory.cpp:1254
std::uint32_t getResourceIdByIndex(unsigned int uiResTypeIndex, unsigned int uiResIndex) const
Returns the ID of a certain resource.
Definition: ResourceDirectory.cpp:1653
void setResourceName(std::uint32_t dwResTypeId, std::uint32_t dwResId, const std::string &strNewResName)
Sets the name of a certain resource.
Definition: ResourceDirectory.cpp:1755
unsigned int getNumberOfResources(std::uint32_t dwId) const
Returns the number of resources of a certain resource type.
Definition: ResourceDirectory.cpp:1440
void setResourceData(std::uint32_t dwResTypeId, std::uint32_t dwResId, std::vector< std::uint8_t > &data)
Sets the data of a certain resource.
Definition: ResourceDirectory.cpp:1570
std::uint32_t getResourceId(std::uint32_t dwResTypeId, const std::string &strResName) const
Returns the ID of a certain resource.
Definition: ResourceDirectory.cpp:1631
int setResourceDataT(S restypeid, T resid, std::vector< std::uint8_t > &data)
Sets the data of a resource.
Definition: ResourceDirectory.h:715
void makeValid()
Corrects a erroneous resource directory.
Definition: ResourceDirectory.cpp:1067
LoaderError loaderError() const
Retrieve the loader error.
Definition: ResourceDirectory.cpp:1049
void recalculate(unsigned int &uiNewSize, unsigned int uiNewRva)
Recalculate the tree for different RVA.
Definition: ResourceDirectory.cpp:1091
LoaderError m_ldrError
Error detected by the import table parser.
Definition: ResourceDirectory.h:353
void getResourceDataByIndex(unsigned int uiResTypeIndex, unsigned int uiResIndex, std::vector< std::uint8_t > &data) const
Returns the data of a certain resource.
Definition: ResourceDirectory.cpp:1555
void getResourceData(std::uint32_t dwResTypeId, std::uint32_t dwResId, std::vector< std::uint8_t > &data) const
Returns the data of a certain resource.
Definition: ResourceDirectory.cpp:1508
int removeResourceType(std::uint32_t dwResTypeId)
Removes a resource type and all of it's resources.
Definition: ResourceDirectory.cpp:1198
int setResourceIdT(S restypeid, T resid, std::uint32_t dwNewResId)
Sets the ID of a resource.
Definition: ResourceDirectory.h:746
int removeResourceT(S restypeid, T resid)
Removes new resource.
Definition: ResourceDirectory.h:659
std::string getResourceTypeNameByIndex(unsigned int uiIndex) const
Returns the name of a resource type.
Definition: ResourceDirectory.cpp:1398
std::vector< std::pair< unsigned int, unsigned int > > m_occupiedAddresses
Stores RVAs which are occupied by this export directory.
Definition: ResourceDirectory.h:351
int resourceTypeNameToIndex(const std::string &strResTypeName) const
Converts a resource type name to an index.
Definition: ResourceDirectory.cpp:1424
virtual ~ResourceDirectory()=default
Destructor.
std::vector< ResourceChild >::const_iterator locateResourceT(S restypeid, T resid) const
Retrieves an iterator to a specified resource child.
Definition: ResourceDirectory.h:560
int addResource(std::uint32_t dwResTypeId, std::uint32_t dwResId)
Adds a new resource.
Definition: ResourceDirectory.cpp:1273
int addResourceT(S restypeid, T resid, ResourceChild &rc)
Adds a new resource.
Definition: ResourceDirectory.h:615
void setResourceNameByIndex(unsigned int uiResTypeIndex, unsigned int uiResIndex, const std::string &strNewResName)
Sets the name of a certain resource.
Definition: ResourceDirectory.cpp:1799
ResourceNode * getRoot()
Definition: ResourceDirectory.cpp:1020
unsigned int getOffset() const
Returns start offset of resource directory in file.
Definition: ResourceDirectory.cpp:1366
std::set< std::size_t > m_resourceNodeOffsets
Detection of invalid structure of nodes in directory.
Definition: ResourceDirectory.h:349
ResourceNode m_rnRoot
The root node of the resource directory.
Definition: ResourceDirectory.h:347
bool hasNodeOffset(std::size_t nodeOffset) const
Check if node with specified offset was loaded.
Definition: ResourceDirectory.cpp:1818
unsigned int m_readOffset
Start offset of directory in file.
Definition: ResourceDirectory.h:345
void setResourceDataByIndex(unsigned int uiResTypeIndex, unsigned int uiResIndex, std::vector< std::uint8_t > &data)
Sets the data of a certain resource.
Definition: ResourceDirectory.cpp:1617
std::string getResourceNameT(S restypeid, T resid) const
Returns the name of a resource.
Definition: ResourceDirectory.h:761
Definition: ResourceDirectory.h:97
unsigned int getElementRva() const
Returns the RVA of the element in the file.
Definition: ResourceDirectory.cpp:282
virtual void rebuild(OutputBuffer &, unsigned int, unsigned int, const std::string &) const =0
Writes the next resource element into the OutputBuffer.
virtual ~ResourceElement()
Necessary virtual destructor.
Definition: ResourceDirectory.h:125
virtual void recalculate(unsigned int &uiCurrentOffset, unsigned int uiNewRva)=0
Recalculates the tree for different RVA.
virtual void makeValid()=0
Corrects erroneous values in the ResourceElement.
ResourceElement()
Returns the size of a resource element.
Definition: ResourceDirectory.cpp:287
virtual int read(ImageLoader &imageLoader, std::uint32_t, std::uint32_t, std::uint32_t, ResourceDirectory *resDir)=0
Reads the next resource element from the InputBuffer.
unsigned int uiElementRva
Stores RVA of the resource element in the file.
Definition: ResourceDirectory.h:104
virtual bool isLeaf() const =0
Indicates if the resource element is a leaf or a node.
ResourceLeafs represent the leafs of the resource tree: The actual resources.
Definition: ResourceDirectory.h:130
void setOffsetToData(std::uint32_t dwValue)
Sets the OffsetToData value of this resource leaf.
Definition: ResourceDirectory.cpp:466
virtual ~ResourceLeaf() override
Destructor.
Definition: ResourceDirectory.cpp:503
std::vector< std::uint8_t > m_data
The resource data.
Definition: ResourceDirectory.h:138
void makeValid()
Corrects erroneous values in the ResourceLeaf.
Definition: ResourceDirectory.cpp:395
std::uint32_t getCodePage() const
Returns the CodePage value of this resource leaf.
Definition: ResourceDirectory.cpp:448
std::vector< std::uint8_t > getData() const
Returns the resource data of this resource leaf.
Definition: ResourceDirectory.cpp:411
std::uint32_t getReserved() const
Returns the Reserved value of this resource leaf.
Definition: ResourceDirectory.cpp:457
bool isLeaf() const
Indicates if the resource element is a leaf or a node.
Definition: ResourceDirectory.cpp:298
ResourceLeaf()
Constructor.
Definition: ResourceDirectory.cpp:498
PELIB_IMAGE_RESOURCE_DATA_ENTRY entry
PeLib equivalent of the Win32 structure IMAGE_RESOURCE_DATA_ENTRY.
Definition: ResourceDirectory.h:140
void setCodePage(std::uint32_t dwValue)
Sets the CodePage value of this resource leaf.
Definition: ResourceDirectory.cpp:484
std::uint32_t getOffsetToData() const
Returns the OffsetToData value of this resource leaf.
Definition: ResourceDirectory.cpp:430
std::uint32_t getSize() const
Returns the Size value of this resource leaf.
Definition: ResourceDirectory.cpp:439
void setData(const std::vector< std::uint8_t > &vData)
Sets the resource data of this resource leaf.
Definition: ResourceDirectory.cpp:420
int read(ImageLoader &imageLoader, std::uint32_t uiRsrcRva, std::uint32_t uiOffset, std::uint32_t sizeOfImage, ResourceDirectory *resDir)
Definition: ResourceDirectory.cpp:311
void setSize(std::uint32_t dwValue)
Sets the Size value of this resource leaf.
Definition: ResourceDirectory.cpp:475
virtual void recalculate(unsigned int &uiCurrentOffset, unsigned int uiNewRva) override
Recalculates the tree for different RVA.
Definition: ResourceDirectory.cpp:388
void rebuild(OutputBuffer &, unsigned int uiOffset, unsigned int uiRva, const std::string &) const
Writes the next resource leaf into the OutputBuffer.
Definition: ResourceDirectory.cpp:358
void setReserved(std::uint32_t dwValue)
Sets the Reserved value of this resource leaf.
Definition: ResourceDirectory.cpp:493
ResourceNodes represent the nodes in the resource tree.
Definition: ResourceDirectory.h:188
unsigned int getNumberOfChildren() const
Returns the node's number of children.
Definition: ResourceDirectory.cpp:766
std::uint32_t getTimeDateStamp() const
Returns the node's TimeDateStamp value.
Definition: ResourceDirectory.cpp:885
std::uint32_t getOffsetToChildName(unsigned int uiIndex) const
Returns the Name value of one of the node's children.
Definition: ResourceDirectory.cpp:827
void setOffsetToChildData(unsigned int uiIndex, std::uint32_t dwNewOffset)
Sets the OffsetToData value of one of the node's children.
Definition: ResourceDirectory.cpp:867
std::vector< ResourceChild > children
The node's children.
Definition: ResourceDirectory.h:195
void setTimeDateStamp(std::uint32_t value)
Sets the node's TimeDateStamp value.
Definition: ResourceDirectory.cpp:939
int read(ImageLoader &imageLoader, std::uint32_t uiRsrcRva, std::uint32_t uiOffset, std::uint32_t sizeOfImage, ResourceDirectory *resDir)
Reads the next resource node.
Definition: ResourceDirectory.cpp:632
std::uint32_t getCharacteristics() const
Returns the node's Characteristics value.
Definition: ResourceDirectory.cpp:876
void setCharacteristics(std::uint32_t value)
Sets the node's Characteristics value.
Definition: ResourceDirectory.cpp:930
std::string getChildName(unsigned int uiIndex) const
Returns the name of one of the node's children.
Definition: ResourceDirectory.cpp:817
ResourceNode()
Returns the size of a resource node.
Definition: ResourceDirectory.cpp:996
void rebuild(OutputBuffer &, unsigned int uiOffset, unsigned int uiRva, const std::string &) const
Writes the next resource node into the OutputBuffer.
Definition: ResourceDirectory.cpp:540
PELIB_IMAGE_RESOURCE_DIRECTORY header
The node's header. Equivalent to IMAGE_RESOURCE_DIRECTORY from the Win32 API.
Definition: ResourceDirectory.h:197
void removeChild(unsigned int uiIndex)
Removes a node's child.
Definition: ResourceDirectory.cpp:807
void setNumberOfNamedEntries(std::uint16_t value)
Sets the node's NumberOfNamedEntries value.
Definition: ResourceDirectory.cpp:966
std::uint32_t getOffsetToChildData(unsigned int uiIndex) const
Returns the OffsetToData value of one of the node's children.
Definition: ResourceDirectory.cpp:837
virtual void recalculate(unsigned int &uiCurrentOffset, unsigned int uiNewRva) override
Recalculates the tree for different RVA.
Definition: ResourceDirectory.cpp:595
std::uint16_t getNumberOfIdEntries() const
Returns the node's NumberOfIdEntries value.
Definition: ResourceDirectory.cpp:921
void setMajorVersion(std::uint16_t value)
Sets the node's MajorVersion value.
Definition: ResourceDirectory.cpp:948
bool isLeaf() const
Indicates if the resource element is a leaf or a node.
Definition: ResourceDirectory.cpp:514
void makeValid()
Corrects erroneous values in the ResourceNode.
Definition: ResourceDirectory.cpp:522
void setOffsetToChildName(unsigned int uiIndex, std::uint32_t dwNewOffset)
Sets the Name value of one of the node's children.
Definition: ResourceDirectory.cpp:857
ResourceChild * getChild(std::size_t uiIndex)
Returns a node's child.
Definition: ResourceDirectory.cpp:788
std::uint16_t getNumberOfNamedEntries() const
Returns the node's NumberOfNamedEntries value.
Definition: ResourceDirectory.cpp:912
void setNumberOfIdEntries(std::uint16_t value)
Sets the node's NumberOfIdEntries value.
Definition: ResourceDirectory.cpp:975
void setMinorVersion(std::uint16_t value)
Sets the node's MinorVersion value.
Definition: ResourceDirectory.cpp:957
ResourceChild * addChild()
Adds another child to node.
Definition: ResourceDirectory.cpp:775
std::uint16_t getMajorVersion() const
Returns the node's MajorVersion value.
Definition: ResourceDirectory.cpp:894
std::uint16_t getMinorVersion() const
Returns the node's MinorVersion value.
Definition: ResourceDirectory.cpp:903
void setChildName(unsigned int uiIndex, const std::string &strNewName)
Sets the name of one of the node's children.
Definition: ResourceDirectory.cpp:847
virtual ~ResourceNode() override
Destructor.
Definition: ResourceDirectory.cpp:1001
Definition: BoundImportDirectory.h:21
LoaderError
Definition: PeLibAux.h:47
@ ERROR_NONE
Definition: PeLibAux.h:33
@ ERROR_DUPLICATE_ENTRY
Definition: PeLibAux.h:41
@ ERROR_ENTRY_NOT_FOUND
Definition: PeLibAux.h:40
Definition: PeLibAux.h:1134
Definition: PeLibAux.h:972
std::uint16_t NumberOfIdEntries
Definition: PeLibAux.h:978
std::uint16_t NumberOfNamedEntries
Definition: PeLibAux.h:977
Definition: PeLibAux.h:998
static void fix(ResourceNode *node)
Fixes a resource node's NumberOfNamedEntries value.
Definition: ResourceDirectory.h:302
static void fix(ResourceNode *node)
Fixes a resource node's NumberOfIdEntries value.
Definition: ResourceDirectory.h:285
Unspecialized function that's used as base template for the specialized versions below.
Definition: ResourceDirectory.h:275
static void fix(ResourceNode *)
Fixes a resource node's header.