retdec
|
Class that represents the resource directory of a PE file. More...
#include <ResourceDirectory.h>
Public Member Functions | |
ResourceDirectory () | |
Constructor. More... | |
virtual | ~ResourceDirectory ()=default |
Destructor. More... | |
int | read (ImageLoader &imageLoader) |
Reads the resource directory from a file. More... | |
ResourceNode * | getRoot () |
const ResourceNode * | getRoot () const |
LoaderError | loaderError () const |
Retrieve the loader error. More... | |
void | setLoaderError (LoaderError ldrError) |
void | makeValid () |
Corrects a erroneous resource directory. More... | |
void | rebuild (std::vector< std::uint8_t > &vBuffer, unsigned int uiRva) const |
Rebuilds the resource directory. More... | |
void | recalculate (unsigned int &uiNewSize, unsigned int uiNewRva) |
Recalculate the tree for different RVA. More... | |
int | write (const std::string &strFilename, unsigned int uiOffset, unsigned int uiRva) const |
Returns the size of the rebuilt resource directory. More... | |
int | addResourceType (std::uint32_t dwResTypeId) |
Adds a new resource type. More... | |
int | addResourceType (const std::string &strResTypeName) |
Adds a new resource type. More... | |
int | removeResourceType (std::uint32_t dwResTypeId) |
Removes a resource type and all of it's resources. More... | |
int | removeResourceType (const std::string &strResTypeName) |
Removes a resource type and all of it's resources. More... | |
int | removeResourceTypeByIndex (unsigned int uiIndex) |
Removes a resource type and all of it's resources. More... | |
int | addResource (std::uint32_t dwResTypeId, std::uint32_t dwResId) |
Adds a new resource. More... | |
int | addResource (std::uint32_t dwResTypeId, const std::string &strResName) |
Adds a new resource. More... | |
int | addResource (const std::string &strResTypeName, std::uint32_t dwResId) |
Adds a new resource. More... | |
int | addResource (const std::string &strResTypeName, const std::string &strResName) |
Adds a new resource. More... | |
int | removeResource (std::uint32_t dwResTypeId, std::uint32_t dwResId) |
Removes a resource. More... | |
int | removeResource (std::uint32_t dwResTypeId, const std::string &strResName) |
Removes a resource. More... | |
int | removeResource (const std::string &strResTypeName, std::uint32_t dwResId) |
Removes a resource. More... | |
int | removeResource (const std::string &strResTypeName, const std::string &strResName) |
Removes a resource. More... | |
unsigned int | getOffset () const |
Returns start offset of resource directory in file. More... | |
unsigned int | getNumberOfResourceTypes () const |
Returns the number of resource types. More... | |
std::uint32_t | getResourceTypeIdByIndex (unsigned int uiIndex) const |
Returns the ID of a resource type. More... | |
std::string | getResourceTypeNameByIndex (unsigned int uiIndex) const |
Returns the name of a resource type. More... | |
int | resourceTypeIdToIndex (std::uint32_t dwResTypeId) const |
Converts a resource type ID to an index. More... | |
int | resourceTypeNameToIndex (const std::string &strResTypeName) const |
Converts a resource type name to an index. More... | |
unsigned int | getNumberOfResources (std::uint32_t dwId) const |
Returns the number of resources of a certain resource type. More... | |
unsigned int | getNumberOfResources (const std::string &strResTypeName) const |
Returns the number of resources of a certain resource type. More... | |
unsigned int | getNumberOfResourcesByIndex (unsigned int uiIndex) const |
Returns the number of resources of a certain resource type. More... | |
void | getResourceData (std::uint32_t dwResTypeId, std::uint32_t dwResId, std::vector< std::uint8_t > &data) const |
Returns the data of a certain resource. More... | |
void | getResourceData (std::uint32_t dwResTypeId, const std::string &strResName, std::vector< std::uint8_t > &data) const |
Returns the data of a certain resource. More... | |
void | getResourceData (const std::string &strResTypeName, std::uint32_t dwResId, std::vector< std::uint8_t > &data) const |
Returns the data of a certain resource. More... | |
void | getResourceData (const std::string &strResTypeName, const std::string &strResName, std::vector< std::uint8_t > &data) const |
Returns the data of a certain resource. More... | |
void | getResourceDataByIndex (unsigned int uiResTypeIndex, unsigned int uiResIndex, std::vector< std::uint8_t > &data) const |
Returns the data of a certain resource. More... | |
void | setResourceData (std::uint32_t dwResTypeId, std::uint32_t dwResId, std::vector< std::uint8_t > &data) |
Sets the data of a certain resource. More... | |
void | setResourceData (std::uint32_t dwResTypeId, const std::string &strResName, std::vector< std::uint8_t > &data) |
Sets the data of a certain resource. More... | |
void | setResourceData (const std::string &strResTypeName, std::uint32_t dwResId, std::vector< std::uint8_t > &data) |
Sets the data of a certain resource. More... | |
void | setResourceData (const std::string &strResTypeName, const std::string &strResName, std::vector< std::uint8_t > &data) |
Sets the data of a certain resource. More... | |
void | setResourceDataByIndex (unsigned int uiResTypeIndex, unsigned int uiResIndex, std::vector< std::uint8_t > &data) |
Sets the data of a certain resource. More... | |
std::uint32_t | getResourceId (std::uint32_t dwResTypeId, const std::string &strResName) const |
Returns the ID of a certain resource. More... | |
std::uint32_t | getResourceId (const std::string &strResTypeName, const std::string &strResName) const |
Returns the ID of a certain resource. More... | |
std::uint32_t | getResourceIdByIndex (unsigned int uiResTypeIndex, unsigned int uiResIndex) const |
Returns the ID of a certain resource. More... | |
void | setResourceId (std::uint32_t dwResTypeId, std::uint32_t dwResId, std::uint32_t dwNewResId) |
Sets the ID of a certain resource. More... | |
void | setResourceId (std::uint32_t dwResTypeId, const std::string &strResName, std::uint32_t dwNewResId) |
Sets the ID of a certain resource. More... | |
void | setResourceId (const std::string &strResTypeName, std::uint32_t dwResId, std::uint32_t dwNewResId) |
Sets the ID of a certain resource. More... | |
void | setResourceId (const std::string &strResTypeName, const std::string &strResName, std::uint32_t dwNewResId) |
Sets the ID of a certain resource. More... | |
void | setResourceIdByIndex (unsigned int uiResTypeIndex, unsigned int uiResIndex, std::uint32_t dwNewResId) |
Sets the ID of a certain resource. More... | |
std::string | getResourceName (std::uint32_t dwResTypeId, std::uint32_t dwResId) const |
Returns the name of a certain resource. More... | |
std::string | getResourceName (const std::string &strResTypeName, std::uint32_t dwResId) const |
Returns the name of a certain resource. More... | |
std::string | getResourceNameByIndex (unsigned int uiResTypeIndex, unsigned int uiResIndex) const |
Returns the name of a certain resource. More... | |
void | setResourceName (std::uint32_t dwResTypeId, std::uint32_t dwResId, const std::string &strNewResName) |
Sets the name of a certain resource. More... | |
void | setResourceName (std::uint32_t dwResTypeId, const std::string &strResName, const std::string &strNewResName) |
Sets the name of a certain resource. More... | |
void | setResourceName (const std::string &strResTypeName, std::uint32_t dwResId, const std::string &strNewResName) |
Sets the name of a certain resource. More... | |
void | setResourceName (const std::string &strResTypeName, const std::string &strResName, const std::string &strNewResName) |
Sets the name of a certain resource. More... | |
void | setResourceNameByIndex (unsigned int uiResTypeIndex, unsigned int uiResIndex, const std::string &strNewResName) |
Sets the name of a certain resource. More... | |
void | insertNodeOffset (std::size_t nodeOffset) |
Insert offset of loaded node. More... | |
bool | hasNodeOffset (std::size_t nodeOffset) const |
Check if node with specified offset was loaded. More... | |
void | addOccupiedAddressRange (unsigned int start, unsigned int end) |
const std::vector< std::pair< unsigned int, unsigned int > > & | getOccupiedAddresses () const |
Protected Member Functions | |
template<typename S , typename T > | |
std::vector< ResourceChild >::const_iterator | locateResourceT (S restypeid, T resid) const |
Retrieves an iterator to a specified resource child. More... | |
template<typename S , typename T > | |
std::vector< ResourceChild >::iterator | locateResourceT (S restypeid, T resid) |
Retrieves an iterator to a specified resource child. More... | |
template<typename S , typename T > | |
int | addResourceT (S restypeid, T resid, ResourceChild &rc) |
Adds a new resource. More... | |
template<typename S , typename T > | |
int | removeResourceT (S restypeid, T resid) |
Removes new resource. More... | |
template<typename S , typename T > | |
int | getResourceDataT (S restypeid, T resid, std::vector< std::uint8_t > &data) const |
Returns the data of a resource. More... | |
template<typename S , typename T > | |
int | setResourceDataT (S restypeid, T resid, std::vector< std::uint8_t > &data) |
Sets the data of a resource. More... | |
template<typename S , typename T > | |
std::uint32_t | getResourceIdT (S restypeid, T resid) const |
Returns the ID of a resource. More... | |
template<typename S , typename T > | |
int | setResourceIdT (S restypeid, T resid, std::uint32_t dwNewResId) |
Sets the ID of a resource. More... | |
template<typename S , typename T > | |
std::string | getResourceNameT (S restypeid, T resid) const |
Returns the name of a resource. More... | |
template<typename S , typename T > | |
int | setResourceNameT (S restypeid, T resid, std::string strNewResName) |
Sets the name of a resource. More... | |
Protected Attributes | |
unsigned int | m_readOffset |
Start offset of directory in file. More... | |
ResourceNode | m_rnRoot |
The root node of the resource directory. More... | |
std::set< std::size_t > | m_resourceNodeOffsets |
Detection of invalid structure of nodes in directory. More... | |
std::vector< std::pair< unsigned int, unsigned int > > | m_occupiedAddresses |
Stores RVAs which are occupied by this export directory. More... | |
LoaderError | m_ldrError |
Error detected by the import table parser. More... | |
Class that represents the resource directory of a PE file.
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<bits>::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.
PeLib::ResourceDirectory::ResourceDirectory | ( | ) |
Constructor.
Constructor
|
virtualdefault |
Destructor.
void PeLib::ResourceDirectory::addOccupiedAddressRange | ( | unsigned int | start, |
unsigned int | end | ||
) |
int PeLib::ResourceDirectory::addResource | ( | const std::string & | strResTypeName, |
const std::string & | strResName | ||
) |
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.
strResTypeName | Name of the resource type. |
strResName | Name of the resource. |
int PeLib::ResourceDirectory::addResource | ( | const std::string & | strResTypeName, |
std::uint32_t | dwResId | ||
) |
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.
strResTypeName | Name of the resource type. |
dwResId | ID of the resource. |
int PeLib::ResourceDirectory::addResource | ( | std::uint32_t | dwResTypeId, |
const std::string & | strResName | ||
) |
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.
dwResTypeId | ID of the resource type. |
strResName | Name of the resource. |
int PeLib::ResourceDirectory::addResource | ( | std::uint32_t | dwResTypeId, |
std::uint32_t | dwResId | ||
) |
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.
dwResTypeId | ID of the resource type. |
dwResId | ID of the resource. |
|
protected |
Adds a new resource.
Adds a new resource, resource type and ID are specified by the parameters.
restypeid | Identifier of the resource type (either ID or name). |
resid | Identifier of the resource (either ID or name). |
rc | ResourceChild that will be added. |
int PeLib::ResourceDirectory::addResourceType | ( | const std::string & | strResTypeName | ) |
Adds a new resource type.
Adds another resource type. The new resource type is identified by the name strResTypeName.
strResTypeName | Name which identifies the resource type. |
int PeLib::ResourceDirectory::addResourceType | ( | std::uint32_t | dwResTypeId | ) |
Adds a new resource type.
Adds another resource type. The new resource type is identified by the ID dwResTypeId.
dwResTypeId | ID which identifies the resource type. |
unsigned int PeLib::ResourceDirectory::getNumberOfResources | ( | const std::string & | strResTypeName | ) | const |
Returns the number of resources of a certain resource type.
Returns the number of resources of a specific resource type.
strResTypeName | Name of the resource type. |
unsigned int PeLib::ResourceDirectory::getNumberOfResources | ( | std::uint32_t | dwId | ) | const |
Returns the number of resources of a certain resource type.
Returns the number of resources of a specific resource type.
dwId | ID of the resource type. |
unsigned int PeLib::ResourceDirectory::getNumberOfResourcesByIndex | ( | unsigned int | uiIndex | ) | const |
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.
uiIndex | Index which identifies a resource type. |
unsigned int PeLib::ResourceDirectory::getNumberOfResourceTypes | ( | ) | const |
Returns the number of resource types.
Returns the number of resource types.
const std::vector< std::pair< unsigned int, unsigned int > > & PeLib::ResourceDirectory::getOccupiedAddresses | ( | ) | const |
unsigned int PeLib::ResourceDirectory::getOffset | ( | ) | const |
Returns start offset of resource directory in file.
Returns start offset of resource directory in file.
void PeLib::ResourceDirectory::getResourceData | ( | const std::string & | strResTypeName, |
const std::string & | strResName, | ||
std::vector< std::uint8_t > & | data | ||
) | const |
Returns the data of a certain resource.
Gets the resource data of a specific resource.
strResTypeName | Identifies the resource type of the resource. |
strResName | Identifies the resource. |
data | Vector where the data is stored. |
void PeLib::ResourceDirectory::getResourceData | ( | const std::string & | strResTypeName, |
std::uint32_t | dwResId, | ||
std::vector< std::uint8_t > & | data | ||
) | const |
Returns the data of a certain resource.
Gets the resource data of a specific resource.
strResTypeName | Identifies the resource type of the resource. |
dwResId | Identifies the resource. |
data | Vector where the data is stored. |
void PeLib::ResourceDirectory::getResourceData | ( | std::uint32_t | dwResTypeId, |
const std::string & | strResName, | ||
std::vector< std::uint8_t > & | data | ||
) | const |
Returns the data of a certain resource.
Gets the resource data of a specific resource.
dwResTypeId | Identifies the resource type of the resource. |
strResName | Identifies the resource. |
data | Vector where the data is stored. |
void PeLib::ResourceDirectory::getResourceData | ( | std::uint32_t | dwResTypeId, |
std::uint32_t | dwResId, | ||
std::vector< std::uint8_t > & | data | ||
) | const |
Returns the data of a certain resource.
Gets the resource data of a specific resource.
dwResTypeId | Identifies the resource type of the resource. |
dwResId | Identifies the resource. |
data | Vector where the data is stored. |
void PeLib::ResourceDirectory::getResourceDataByIndex | ( | unsigned int | uiResTypeIndex, |
unsigned int | uiResIndex, | ||
std::vector< std::uint8_t > & | data | ||
) | const |
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.
uiResTypeIndex | Identifies the resource type of the resource. |
uiResIndex | Identifies the resource. |
data | Vector where the data is stored. |
|
protected |
Returns the data of a resource.
Returns the data of a resource, resource type and ID are specified by the parameters.
restypeid | Identifier of the resource type (either ID or name). |
resid | Identifier of the resource (either ID or name). |
data | The data of the resource will be written into this vector. |
std::uint32_t PeLib::ResourceDirectory::getResourceId | ( | const std::string & | strResTypeName, |
const std::string & | strResName | ||
) | const |
Returns the ID of a certain resource.
Gets the ID of a specific resource.
strResTypeName | Identifies the resource type of the resource. |
strResName | Identifies the resource. |
std::uint32_t PeLib::ResourceDirectory::getResourceId | ( | std::uint32_t | dwResTypeId, |
const std::string & | strResName | ||
) | const |
Returns the ID of a certain resource.
Gets the ID of a specific resource.
dwResTypeId | Identifies the resource type of the resource. |
strResName | Identifies the resource. |
std::uint32_t PeLib::ResourceDirectory::getResourceIdByIndex | ( | unsigned int | uiResTypeIndex, |
unsigned int | uiResIndex | ||
) | const |
Returns the ID of a certain resource.
Gets the ID of a specific resource by index.
uiResTypeIndex | Identifies the resource type of the resource. |
uiResIndex | Identifies the resource. |
|
protected |
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.
restypeid | Identifier of the resource type (either ID or name). |
resid | Identifier of the resource (either ID or name). |
std::string PeLib::ResourceDirectory::getResourceName | ( | const std::string & | strResTypeName, |
std::uint32_t | dwResId | ||
) | const |
Returns the name of a certain resource.
Gets the Name of a specific resource.
strResTypeName | Identifies the resource type of the resource. |
dwResId | Identifies the resource. |
std::string PeLib::ResourceDirectory::getResourceName | ( | std::uint32_t | dwResTypeId, |
std::uint32_t | dwResId | ||
) | const |
Returns the name of a certain resource.
Gets the Name of a specific resource.
dwResTypeId | Identifies the resource type of the resource. |
dwResId | Identifies the resource. |
std::string PeLib::ResourceDirectory::getResourceNameByIndex | ( | unsigned int | uiResTypeIndex, |
unsigned int | uiResIndex | ||
) | const |
Returns the name of a certain resource.
Gets the name of a specific resource by index.
uiResTypeIndex | Identifies the resource type of the resource. |
uiResIndex | Identifies the resource. |
|
protected |
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.
restypeid | Identifier of the resource type (either ID or name). |
resid | Identifier of the resource (either ID or name). |
std::uint32_t PeLib::ResourceDirectory::getResourceTypeIdByIndex | ( | unsigned int | uiIndex | ) | const |
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.
uiIndex | Index which identifies a resource type. |
std::string PeLib::ResourceDirectory::getResourceTypeNameByIndex | ( | unsigned int | uiIndex | ) | const |
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.
uiIndex | Index which identifies a resource type. |
ResourceNode * PeLib::ResourceDirectory::getRoot | ( | ) |
Returns the root node of the resource directory.
const ResourceNode * PeLib::ResourceDirectory::getRoot | ( | ) | const |
Returns the root node of the resource directory.
bool PeLib::ResourceDirectory::hasNodeOffset | ( | std::size_t | nodeOffset | ) | const |
Check if node with specified offset was loaded.
Check if node with specified offset was loaded.
nodeOffset | Offset of node. |
void PeLib::ResourceDirectory::insertNodeOffset | ( | std::size_t | nodeOffset | ) |
Insert offset of loaded node.
Insert offset of loaded node.
nodeOffset | Offset of loaded node. |
LoaderError PeLib::ResourceDirectory::loaderError | ( | ) | const |
Retrieve the loader error.
Get the error that was detected during resource parsing
|
protected |
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.
restypeid | Identifier of the resource type (either ID or name). |
resid | Identifier of the resource (either ID or name). |
|
protected |
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.
restypeid | Identifier of the resource type (either ID or name). |
resid | Identifier of the resource (either ID or name). |
void PeLib::ResourceDirectory::makeValid | ( | ) |
Corrects a erroneous resource directory.
Correctly sorts the resource nodes of the resource tree. This function should be called before calling rebuild.
int PeLib::ResourceDirectory::read | ( | ImageLoader & | imageLoader | ) |
Reads the resource directory from a file.
Reads the resource directory from a file.
imageLoader | image loader |
void PeLib::ResourceDirectory::rebuild | ( | std::vector< std::uint8_t > & | vBuffer, |
unsigned int | uiRva | ||
) | const |
Rebuilds the resource directory.
Rebuilds the resource directory.
vBuffer | Buffer the source directory will be written to. |
uiRva | RVA of the resource directory. |
void PeLib::ResourceDirectory::recalculate | ( | unsigned int & | uiNewSize, |
unsigned int | uiNewRva | ||
) |
Recalculate the tree for different RVA.
Recalculates the resource directory for directory with new RVA.
uiNewSize | The size of the new directory. Is recalculated after the whole resource tree is traversed. |
uiNewRva | The RVA of the new directory. |
int PeLib::ResourceDirectory::removeResource | ( | const std::string & | strResTypeName, |
const std::string & | strResName | ||
) |
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.
strResTypeName | Name of the resource type. |
strResName | Name of the resource. |
int PeLib::ResourceDirectory::removeResource | ( | const std::string & | strResTypeName, |
std::uint32_t | dwResId | ||
) |
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.
strResTypeName | Name of the resource type. |
dwResId | ID of the resource. |
int PeLib::ResourceDirectory::removeResource | ( | std::uint32_t | dwResTypeIndex, |
const std::string & | strResName | ||
) |
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.
dwResTypeIndex | ID of the resource type. |
strResName | Name of the resource. |
int PeLib::ResourceDirectory::removeResource | ( | std::uint32_t | dwResTypeIndex, |
std::uint32_t | dwResId | ||
) |
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.
dwResTypeIndex | ID of the resource type. |
dwResId | ID of the resource. |
|
protected |
Removes new resource.
Removes a resource, resource type and ID are specified by the parameters.
restypeid | Identifier of the resource type (either ID or name). |
resid | Identifier of the resource (either ID or name). |
int PeLib::ResourceDirectory::removeResourceType | ( | const std::string & | strResTypeName | ) |
Removes a resource type and all of it's resources.
Removes the resource type identified by the name strResTypeName.
strResTypeName | Name which identifies the resource type. |
int PeLib::ResourceDirectory::removeResourceType | ( | std::uint32_t | dwResTypeId | ) |
Removes a resource type and all of it's resources.
Removes the resource type identified by the ID dwResTypeId.
dwResTypeId | ID which identifies the resource type. |
int PeLib::ResourceDirectory::removeResourceTypeByIndex | ( | unsigned int | uiIndex | ) |
Removes a resource type and all of it's resources.
Removes the resource type identified by the index uiIndex.
uiIndex | Index which identifies the resource type. |
int PeLib::ResourceDirectory::resourceTypeIdToIndex | ( | std::uint32_t | dwResTypeId | ) | const |
Converts a resource type ID to an index.
Converts the ID of a resource type to an index.
dwResTypeId | ID of the resource type. |
int PeLib::ResourceDirectory::resourceTypeNameToIndex | ( | const std::string & | strResTypeName | ) | const |
Converts a resource type name to an index.
Converts the name of a resource type to an index.
strResTypeName | ID of the resource type. |
void PeLib::ResourceDirectory::setLoaderError | ( | LoaderError | ldrError | ) |
void PeLib::ResourceDirectory::setResourceData | ( | const std::string & | strResTypeName, |
const std::string & | strResName, | ||
std::vector< std::uint8_t > & | data | ||
) |
Sets the data of a certain resource.
Sets the resource data of a specific resource.
strResTypeName | Identifies the resource type of the resource. |
strResName | Identifies the resource. |
data | The new resource data. |
void PeLib::ResourceDirectory::setResourceData | ( | const std::string & | strResTypeName, |
std::uint32_t | dwResId, | ||
std::vector< std::uint8_t > & | data | ||
) |
Sets the data of a certain resource.
Sets the resource data of a specific resource.
strResTypeName | Identifies the resource type of the resource. |
dwResId | Identifies the resource. |
data | The new resource data. |
void PeLib::ResourceDirectory::setResourceData | ( | std::uint32_t | dwResTypeId, |
const std::string & | strResName, | ||
std::vector< std::uint8_t > & | data | ||
) |
Sets the data of a certain resource.
Sets the resource data of a specific resource.
dwResTypeId | Identifies the resource type of the resource. |
strResName | Identifies the resource. |
data | The new resource data. |
void PeLib::ResourceDirectory::setResourceData | ( | std::uint32_t | dwResTypeId, |
std::uint32_t | dwResId, | ||
std::vector< std::uint8_t > & | data | ||
) |
Sets the data of a certain resource.
Sets the resource data of a specific resource.
dwResTypeId | Identifies the resource type of the resource. |
dwResId | Identifies the resource. |
data | The new resource data. |
void PeLib::ResourceDirectory::setResourceDataByIndex | ( | unsigned int | uiResTypeIndex, |
unsigned int | uiResIndex, | ||
std::vector< std::uint8_t > & | data | ||
) |
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.
uiResTypeIndex | Identifies the resource type of the resource. |
uiResIndex | Identifies the resource. |
data | The new resource data. |
|
protected |
Sets the data of a resource.
Sets the data of a resource, resource type and ID are specified by the parameters.
restypeid | Identifier of the resource type (either ID or name). |
resid | Identifier of the resource (either ID or name). |
data | The new data of the resource is taken from this vector. |
void PeLib::ResourceDirectory::setResourceId | ( | const std::string & | strResTypeName, |
const std::string & | strResName, | ||
std::uint32_t | dwNewResId | ||
) |
Sets the ID of a certain resource.
Sets the ID of a specific resource.
strResTypeName | Identifies the resource type of the resource. |
strResName | Identifies the resource. |
dwNewResId | New ID of the resource. |
void PeLib::ResourceDirectory::setResourceId | ( | const std::string & | strResTypeName, |
std::uint32_t | dwResId, | ||
std::uint32_t | dwNewResId | ||
) |
Sets the ID of a certain resource.
Sets the ID of a specific resource.
strResTypeName | Identifies the resource type of the resource. |
dwResId | Identifies the resource. |
dwNewResId | New ID of the resource. |
void PeLib::ResourceDirectory::setResourceId | ( | std::uint32_t | dwResTypeId, |
const std::string & | strResName, | ||
std::uint32_t | dwNewResId | ||
) |
Sets the ID of a certain resource.
Sets the ID of a specific resource.
dwResTypeId | Identifies the resource type of the resource. |
strResName | Identifies the resource. |
dwNewResId | New ID of the resource. |
void PeLib::ResourceDirectory::setResourceId | ( | std::uint32_t | dwResTypeId, |
std::uint32_t | dwResId, | ||
std::uint32_t | dwNewResId | ||
) |
Sets the ID of a certain resource.
Sets the ID of a specific resource.
dwResTypeId | Identifies the resource type of the resource. |
dwResId | Identifies the resource. |
dwNewResId | New ID of the resource. |
void PeLib::ResourceDirectory::setResourceIdByIndex | ( | unsigned int | uiResTypeIndex, |
unsigned int | uiResIndex, | ||
std::uint32_t | dwNewResId | ||
) |
Sets the ID of a certain resource.
Sets the ID of a specific resource by index.
uiResTypeIndex | Identifies the resource type of the resource. |
uiResIndex | Identifies the resource. |
dwNewResId | New ID of the specified resource. |
|
protected |
Sets the ID of a resource.
Sets the id of a resource, resource type and ID are specified by the parameters.
restypeid | Identifier of the resource type (either ID or name). |
resid | Identifier of the resource (either ID or name). |
dwNewResId | New ID of the resource. |
void PeLib::ResourceDirectory::setResourceName | ( | const std::string & | strResTypeName, |
const std::string & | strResName, | ||
const std::string & | strNewResName | ||
) |
Sets the name of a certain resource.
Sets the name of a specific resource.
strResTypeName | Identifies the resource type of the resource. |
strResName | Identifies the resource. |
strNewResName | New name of the specified resource. |
void PeLib::ResourceDirectory::setResourceName | ( | const std::string & | strResTypeName, |
std::uint32_t | dwResId, | ||
const std::string & | strNewResName | ||
) |
Sets the name of a certain resource.
Sets the name of a specific resource.
strResTypeName | Identifies the resource type of the resource. |
dwResId | Identifies the resource. |
strNewResName | New name of the specified resource. |
void PeLib::ResourceDirectory::setResourceName | ( | std::uint32_t | dwResTypeId, |
const std::string & | strResName, | ||
const std::string & | strNewResName | ||
) |
Sets the name of a certain resource.
Sets the name of a specific resource.
dwResTypeId | Identifies the resource type of the resource. |
strResName | Identifies the resource. |
strNewResName | New name of the specified resource. |
void PeLib::ResourceDirectory::setResourceName | ( | std::uint32_t | dwResTypeId, |
std::uint32_t | dwResId, | ||
const std::string & | strNewResName | ||
) |
Sets the name of a certain resource.
Sets the name of a specific resource.
dwResTypeId | Identifies the resource type of the resource. |
dwResId | Identifies the resource. |
strNewResName | New name of the specified resource. |
void PeLib::ResourceDirectory::setResourceNameByIndex | ( | unsigned int | uiResTypeIndex, |
unsigned int | uiResIndex, | ||
const std::string & | strNewResName | ||
) |
Sets the name of a certain resource.
Sets the name of a specific resource by index.
uiResTypeIndex | Identifies the resource type of the resource. |
uiResIndex | Identifies the resource. |
strNewResName | New name of the specified resource. |
|
protected |
Sets the name of a resource.
Sets the name of a resource, resource type and ID are specified by the parameters.
restypeid | Identifier of the resource type (either ID or name). |
resid | Identifier of the resource (either ID or name). |
strNewResName | The new name of the resource. |
int PeLib::ResourceDirectory::write | ( | const std::string & | strFilename, |
unsigned int | uiOffset, | ||
unsigned int | uiRva | ||
) | const |
Returns the size of the rebuilt resource directory.
Writes the resource directory to a file.
Returns the size of the entire rebuilt resource directory. That's the size of the entire structure as it's written back to a file. Writes the current resource directory back into a file.
strFilename | Name of the output file. |
uiOffset | File offset where the resource directory will be written to. |
uiRva | RVA of the file offset. |
|
protected |
Error detected by the import table parser.
|
protected |
Stores RVAs which are occupied by this export directory.
|
protected |
Start offset of directory in file.
|
protected |
Detection of invalid structure of nodes in directory.
|
protected |
The root node of the resource directory.