#include <ResourceDirectory.h>
Collaboration diagram for ResourceDirectory:
Public Member Functions | |
int | addResource (const std::string &strResTypeName, const std::string &strResName) |
Adds a new resource. | |
int | addResource (const std::string &strResTypeName, dword dwResId) |
Adds a new resource. | |
int | addResource (dword dwResTypeId, const std::string &strResName) |
Adds a new resource. | |
int | addResource (dword dwResTypeId, dword dwResId) |
Adds a new resource. | |
int | addResourceType (const std::string &strResTypeName) |
Adds a new resource type. | |
int | addResourceType (dword dwResTypeId) |
Adds a new resource type. | |
unsigned int | getNumberOfResources (const std::string &strResTypeName) const |
Returns the number of resources of a certain resource type. | |
unsigned int | getNumberOfResources (dword dwId) const |
Returns the number of resources of a certain resource type. | |
unsigned int | getNumberOfResourcesByIndex (unsigned int uiIndex) const |
Returns the number of resources of a certain resource type. | |
unsigned int | getNumberOfResourceTypes () const |
Returns the number of resource types. | |
void | getResourceData (const std::string &strResTypeName, const std::string &strResName, std::vector< byte > &data) const |
Returns the data of a certain resource. | |
void | getResourceData (const std::string &strResTypeName, dword dwResId, std::vector< byte > &data) const |
Returns the data of a certain resource. | |
void | getResourceData (dword dwResTypeId, const std::string &strResName, std::vector< byte > &data) const |
Returns the data of a certain resource. | |
void | getResourceData (dword dwResTypeId, dword dwResId, std::vector< byte > &data) const |
Returns the data of a certain resource. | |
void | getResourceDataByIndex (unsigned int uiResTypeIndex, unsigned int uiResIndex, std::vector< byte > &data) const |
Returns the data of a certain resource. | |
dword | getResourceId (const std::string &strResTypeName, const std::string &strResName) const |
Returns the ID of a certain resource. | |
dword | getResourceId (dword dwResTypeId, const std::string &strResName) const |
Returns the ID of a certain resource. | |
dword | getResourceIdByIndex (unsigned int uiResTypeIndex, unsigned int uiResIndex) const |
Returns the ID of a certain resource. | |
std::string | getResourceName (const std::string &strResTypeName, dword dwResId) const |
Returns the name of a certain resource. | |
std::string | getResourceName (dword dwResTypeId, dword dwResId) const |
Returns the name of a certain resource. | |
std::string | getResourceNameByIndex (unsigned int uiResTypeIndex, unsigned int uiResIndex) const |
Returns the name of a certain resource. | |
dword | getResourceTypeIdByIndex (unsigned int uiIndex) const |
Returns the ID of a resource type. | |
std::string | getResourceTypeNameByIndex (unsigned int uiIndex) const |
Returns the name of a resource type. | |
ResourceNode * | getRoot () |
void | makeValid () |
Corrects a erroneous resource directory. | |
int | read (const std::string &strFilename, unsigned int uiOffset, unsigned int uiSize, unsigned int uiResDirRva) |
Reads the resource directory from a file. | |
void | rebuild (std::vector< byte > &vBuffer, unsigned int uiRva) const |
Rebuilds the resource directory. | |
int | removeResource (const std::string &strResTypeName, const std::string &strResName) |
Removes a resource. | |
int | removeResource (const std::string &strResTypeName, dword dwResId) |
Removes a resource. | |
int | removeResource (dword dwResTypeId, const std::string &strResName) |
Removes a resource. | |
int | removeResource (dword dwResTypeId, dword dwResId) |
Removes a resource. | |
int | removeResourceType (const std::string &strResTypeName) |
Removes a resource type and all of it's resources. | |
int | removeResourceType (dword dwResTypeId) |
Removes a resource type and all of it's resources. | |
int | removeResourceTypeByIndex (unsigned int uiIndex) |
Removes a resource type and all of it's resources. | |
int | resourceTypeIdToIndex (dword dwResTypeId) const |
Converts a resource type ID to an index. | |
int | resourceTypeNameToIndex (const std::string &strResTypeName) const |
Converts a resource type name to an index. | |
void | setResourceData (const std::string &strResTypeName, const std::string &strResName, std::vector< byte > &data) |
Sets the data of a certain resource. | |
void | setResourceData (const std::string &strResTypeName, dword dwResId, std::vector< byte > &data) |
Sets the data of a certain resource. | |
void | setResourceData (dword dwResTypeId, const std::string &strResName, std::vector< byte > &data) |
Sets the data of a certain resource. | |
void | setResourceData (dword dwResTypeId, dword dwResId, std::vector< byte > &data) |
Sets the data of a certain resource. | |
void | setResourceDataByIndex (unsigned int uiResTypeIndex, unsigned int uiResIndex, std::vector< byte > &data) |
Sets the data of a certain resource. | |
void | setResourceId (const std::string &strResTypeName, const std::string &strResName, dword dwNewResId) |
Sets the ID of a certain resource. | |
void | setResourceId (const std::string &strResTypeName, dword dwResId, dword dwNewResId) |
Sets the ID of a certain resource. | |
void | setResourceId (dword dwResTypeId, const std::string &strResName, dword dwNewResId) |
Sets the ID of a certain resource. | |
void | setResourceId (dword dwResTypeId, dword dwResId, dword dwNewResId) |
Sets the ID of a certain resource. | |
void | setResourceIdByIndex (unsigned int uiResTypeIndex, unsigned int uiResIndex, dword dwNewResId) |
Sets the ID of a certain resource. | |
void | setResourceName (const std::string &strResTypeName, const std::string &strResName, const std::string &strNewResName) |
Sets the name of a certain resource. | |
void | setResourceName (const std::string &strResTypeName, dword dwResId, const std::string &strNewResName) |
Sets the name of a certain resource. | |
void | setResourceName (dword dwResTypeId, const std::string &strResName, const std::string &strNewResName) |
Sets the name of a certain resource. | |
void | setResourceName (dword dwResTypeId, dword dwResId, const std::string &strNewResName) |
Sets the name of a certain resource. | |
void | setResourceNameByIndex (unsigned int uiResTypeIndex, unsigned int uiResIndex, const std::string &strNewResName) |
Sets the name of a certain resource. | |
int | write (const std::string &strFilename, unsigned int uiOffset, unsigned int uiRva) const |
Writes the resource directory to a file. | |
Private Member Functions | |
template<typename S, typename T> int | addResourceT (S restypeid, T resid, ResourceChild &rc) |
Adds a new resource. | |
template<typename S, typename T> int | getResourceDataT (S restypeid, T resid, std::vector< byte > &data) const |
Returns the data of a resource. | |
template<typename S, typename T> dword | getResourceIdT (S restypeid, T resid) const |
Returns the ID of a resource. | |
template<typename S, typename T> std::string | getResourceNameT (S restypeid, T resid) const |
Returns the name of a resource. | |
template<typename S, typename T> std::vector< ResourceChild >::iterator | locateResourceT (S restypeid, T resid) |
Retrieves an iterator to a specified resource child. | |
template<typename S, typename T> std::vector< ResourceChild >::const_iterator | locateResourceT (S restypeid, T resid) const |
Retrieves an iterator to a specified resource child. | |
template<typename S, typename T> int | removeResourceT (S restypeid, T resid) |
Removes new resource. | |
template<typename S, typename T> int | setResourceDataT (S restypeid, T resid, std::vector< byte > &data) |
Sets the data of a resource. | |
template<typename S, typename T> int | setResourceIdT (S restypeid, T resid, dword dwNewResId) |
Sets the ID of a resource. | |
template<typename S, typename T> int | setResourceNameT (S restypeid, T resid, std::string strNewResName) |
Sets the name of a resource. | |
Private Attributes | |
ResourceNode | m_rnRoot |
The root node of the resource directory. |
The class ResourceDirectory represents the resource directory of a PE file. This class is fundamentally different from the other classes of the PeLib library due to the structure of the ResourceDirectory. For once, it's possible to manipulate the ResourceDirectory through a set of "high level" functions and and through a set of "low level" functions. The "high level" functions are the functions inside the ResourceDirectory class with the exception of getRoot.
getRoot on the other hand is the first "low level" function. Use it to retrieve the root node of the resource tree. Then you can traverse through the tree and manipulate individual nodes and leafs directly using the functions provided by the classes ResourceNode and ResourceLeaf.
There's another difference between the ResourceDirectory class and the other PeLib classes, which is once again caused by the special structure of the PE resource directory. The nodes of the resource tree must be in a certain order. Manipulating the resource tree does not directly sort the nodes correctly as this would cause more trouble than it fixes. That means it's your responsibility to fix the resource tree after manipulating it. PeLib makes the job easy for you, just call the ResourceDirectory::makeValid function.
You might also wonder why there's no size() function in this class. I did not forget it. It's just that it's impossible to calculate the size of the resource directory without rebuilding it. So why should PeLib do this if you can do it just as easily by calling rebuild() and then checking the length of the returned vector.
There are also different ways to serialize (rebuild) the resource tree as it's not a fixed structure that can easily be minimized like most other PE directories.
This means it's entirely possible that the resource tree you read from a file differs from the one PeLib creates. This might cause a minor issue. The original resource tree might be smaller (due to different padding) so it's crucial that you check if there's enough space in the original resource directory before you write the rebuilt resource directory back to the file.
|
Adds a new resource. Adds another resource to the resource tree. The first parameter identifies the resource type of the new resource, the second parameter identifies the resource itself.
Here is the call graph for this function: |
|
Adds a new resource. Adds another resource to the resource tree. The first parameter identifies the resource type of the new resource, the second parameter identifies the resource itself.
Here is the call graph for this function: |
|
Adds a new resource. Adds another resource to the resource tree. The first parameter identifies the resource type of the new resource, the second parameter identifies the resource itself.
Here is the call graph for this function: |
|
Adds a new resource. Adds another resource to the resource tree. The first parameter identifies the resource type of the new resource, the second parameter identifies the resource itself.
Here is the call graph for this function: |
|
Adds a new resource. Adds a new resource, resource type and ID are specified by the parameters.
|
|
Adds a new resource type. Adds another resource type. The new resource type is identified by the name strResTypeName.
|
|
Adds a new resource type. Adds another resource type. The new resource type is identified by the ID dwResTypeId.
|
|
Returns the number of resources of a certain resource type. Returns the number of resources of a specific resource type.
|
|
Returns the number of resources of a certain resource type. Returns the number of resources of a specific resource type.
|
|
Returns the number of resources of a certain resource type. Returns the number of resources of a resource type which was specified through an index. The valid range of the parameter uiIndex is 0...getNumberOfResourceTypes() - 1. Leaving the invalid range leads to undefined behaviour.
|
|
Returns the number of resource types. Returns the number of resource types. |
|
Returns the data of a certain resource. Gets the resource data of a specific resource.
Here is the call graph for this function: |
|
Returns the data of a certain resource. Gets the resource data of a specific resource.
Here is the call graph for this function: |
|
Returns the data of a certain resource. Gets the resource data of a specific resource.
Here is the call graph for this function: |
|
Returns the data of a certain resource. Gets the resource data of a specific resource.
Here is the call graph for this function: |
|
Returns the data of a certain resource. Gets the resource data of a specific resource by index. The valid range of the parameter uiResTypeIndex is 0...getNumberOfResourceTypes() - 1. The valid range of the parameter uiResIndex is 0...getNumberOfResources() - 1. Leaving the invalid range leads to undefined behaviour.
|
|
Returns the data of a resource. Returns the data of a resource, resource type and ID are specified by the parameters.
|
|
Returns the ID of a certain resource. Gets the ID of a specific resource.
Here is the call graph for this function: |
|
Returns the ID of a certain resource. Gets the ID of a specific resource.
Here is the call graph for this function: |
|
Returns the ID of a certain resource. Gets the ID of a specific resource by index.
|
|
Returns the ID of a resource. Returns the id of a resource, resource type and ID are specified by the parameters. Note: Calling this function with resid == the ID of the resource makes no sense at all.
|
|
Returns the name of a certain resource. Gets the Name of a specific resource.
Here is the call graph for this function: |
|
Returns the name of a certain resource. Gets the Name of a specific resource.
Here is the call graph for this function: |
|
Returns the name of a certain resource. Gets the name of a specific resource by index.
|
|
Returns the name of a resource. Returns the name of a resource, resource type and ID are specified by the parameters. Note: Calling this function with resid == the name of the resource makes no sense at all.
|
|
Returns the ID of a resource type. Returns the ID of a resource type which was specified through an index. The valid range of the parameter uiIndex is 0...getNumberOfResourceTypes() - 1. Leaving the invalid range leads to undefined behaviour.
|
|
Returns the name of a resource type. Returns the name of a resource type which was specified through an index. The valid range of the parameter uiIndex is 0...getNumberOfResourceTypes() - 1. Leaving the invalid range leads to undefined behaviour.
|
|
Returns the root node of the resource directory.
|
|
Retrieves an iterator to a specified resource child. Looks through the entire resource tree and returns an iterator to the resource specified by the parameters.
|
|
Retrieves an iterator to a specified resource child. Looks through the entire resource tree and returns a const_iterator to the resource specified by the parameters.
|
|
Corrects a erroneous resource directory. Correctly sorts the resource nodes of the resource tree. This function should be called before calling rebuild. Here is the call graph for this function: |
|
Reads the resource directory from a file. Reads the resource directory from a file.
Here is the call graph for this function: |
|
Rebuilds the resource directory. Rebuilds the resource directory.
Here is the call graph for this function: |
|
Removes a resource. Removes a resource from the resource tree. The first parameter identifies the resource type of the new resource, the second parameter identifies the resource itself.
Here is the call graph for this function: |
|
Removes a resource. Removes a resource from the resource tree. The first parameter identifies the resource type of the new resource, the second parameter identifies the resource itself.
Here is the call graph for this function: |
|
Removes a resource. Removes a resource from the resource tree. The first parameter identifies the resource type of the new resource, the second parameter identifies the resource itself.
Here is the call graph for this function: |
|
Removes a resource. Removes a resource from the resource tree. The first parameter identifies the resource type of the new resource, the second parameter identifies the resource itself.
Here is the call graph for this function: |
|
Removes new resource. Removes a resource, resource type and ID are specified by the parameters.
|
|
Removes a resource type and all of it's resources. Removes the resource type identified by the name strResTypeName.
|
|
Removes a resource type and all of it's resources. Removes the resource type identified by the ID dwResTypeId.
|
|
Removes a resource type and all of it's resources. Removes the resource type identified by the index uiIndex.
|
|
Converts a resource type ID to an index. Converts the ID of a resource type to an index.
|
|
Converts a resource type name to an index. Converts the name of a resource type to an index.
|
|
Sets the data of a certain resource. Sets the resource data of a specific resource.
Here is the call graph for this function: |
|
Sets the data of a certain resource. Sets the resource data of a specific resource.
Here is the call graph for this function: |
|
Sets the data of a certain resource. Sets the resource data of a specific resource.
Here is the call graph for this function: |
|
Sets the data of a certain resource. Sets the resource data of a specific resource.
Here is the call graph for this function: |
|
Sets the data of a certain resource. Sets the resource data of a specific resource by index. The valid range of the parameter uiResTypeIndex is 0...getNumberOfResourceTypes() - 1. The valid range of the parameter uiResIndex is 0...getNumberOfResources() - 1. Leaving the invalid range leads to undefined behaviour.
|
|
Sets the data of a resource. Sets the data of a resource, resource type and ID are specified by the parameters.
|
|
Sets the ID of a certain resource. Sets the ID of a specific resource.
Here is the call graph for this function: |
|
Sets the ID of a certain resource. Sets the ID of a specific resource.
Here is the call graph for this function: |
|
Sets the ID of a certain resource. Sets the ID of a specific resource.
Here is the call graph for this function: |
|
Sets the ID of a certain resource. Sets the ID of a specific resource.
Here is the call graph for this function: |
|
Sets the ID of a certain resource. Sets the ID of a specific resource by index.
|
|
Sets the ID of a resource. Sets the id of a resource, resource type and ID are specified by the parameters.
|
|
Sets the name of a certain resource. Sets the name of a specific resource.
Here is the call graph for this function: |
|
Sets the name of a certain resource. Sets the name of a specific resource.
Here is the call graph for this function: |
|
Sets the name of a certain resource. Sets the name of a specific resource.
Here is the call graph for this function: |
|
Sets the name of a certain resource. Sets the name of a specific resource.
Here is the call graph for this function: |
|
Sets the name of a certain resource. Sets the name of a specific resource by index.
|
|
Sets the name of a resource. Sets the name of a resource, resource type and ID are specified by the parameters.
|
|
Writes the resource directory to a file. Writes the current resource directory back into a file.
Here is the call graph for this function: |