retdec
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
PeLib::ExportDirectory Class Reference

Class that handles the export directory. More...

#include <ExportDirectory.h>

Collaboration diagram for PeLib::ExportDirectory:
Collaboration graph
[legend]

Public Member Functions

virtual ~ExportDirectory ()=default
 
int read (ImageLoader &imageLoader)
 Load the export directory from the image loader. More...
 
void addFunction (const std::string &strFuncname, std::uint32_t dwFuncAddr)
 Add another function to be exported. More...
 
unsigned int calcNumberOfFunctions () const
 
void clear ()
 
int getFunctionIndex (const std::string &strFunctionName) const
 Identifies a function through it's name. More...
 
void rebuild (std::vector< std::uint8_t > &vBuffer, std::uint32_t dwRva) const
 Rebuild the current export directory. More...
 
void removeFunction (unsigned int index)
 
unsigned int size () const
 Returns the size of the current export directory. More...
 
int write (const std::string &strFilename, unsigned int uiOffset, unsigned int uiRva) const
 Writes the current export directory to a file. More...
 
void setNameString (const std::string &strFilename)
 Changes the name of the file (according to the export directory). More...
 
std::string getNameString () const
 
std::string getFunctionName (std::size_t index) const
 Get the name of an exported function. More...
 
std::uint16_t getFunctionOrdinal (std::size_t index) const
 Get the ordinal of an exported function. More...
 
std::uint32_t getAddressOfName (std::size_t index) const
 Get the address of the name of an exported function. More...
 
std::uint32_t getAddressOfFunction (std::size_t index) const
 Get the address of an exported function. More...
 
void setFunctionName (std::size_t index, const std::string &strName)
 Change the name of an exported function. More...
 
void setFunctionOrdinal (std::size_t index, std::uint16_t wValue)
 Change the ordinal of an exported function. More...
 
void setAddressOfName (std::size_t index, std::uint32_t dwValue)
 Change the address of the name of an exported function. More...
 
void setAddressOfFunction (std::size_t index, std::uint32_t dwValue)
 Change the address of an exported function. More...
 
std::uint32_t getBase () const
 Return the Base value of the export directory. More...
 
std::uint32_t getCharacteristics () const
 Return the Characteristics value of the export directory. More...
 
std::uint32_t getTimeDateStamp () const
 Return the TimeDateStamp value of the export directory. More...
 
std::uint16_t getMajorVersion () const
 Return the MajorVersion value of the export directory. More...
 
std::uint16_t getMinorVersion () const
 Return the MinorVersion value of the export directory. More...
 
std::uint32_t getName () const
 Return the Name value of the export directory. More...
 
std::uint32_t getNumberOfFunctions () const
 Return the NumberOfFunctions value of the export directory. More...
 
std::uint32_t getNumberOfNames () const
 Return the NumberOfNames value of the export directory. More...
 
std::uint32_t getAddressOfFunctions () const
 Return the AddressOfFunctions value of the export directory. More...
 
std::uint32_t getAddressOfNames () const
 Return the AddressOfNames value of the export directory. More...
 
std::uint32_t getAddressOfNameOrdinals () const
 Returns the AddressOfNameOrdinals value. More...
 
void setBase (std::uint32_t dwValue)
 Set the Base value of the export directory. More...
 
void setCharacteristics (std::uint32_t dwValue)
 Set the Characteristics value of the export directory. More...
 
void setTimeDateStamp (std::uint32_t dwValue)
 Set the TimeDateStamp value of the export directory. More...
 
void setMajorVersion (std::uint16_t wValue)
 Set the MajorVersion value of the export directory. More...
 
void setMinorVersion (std::uint16_t wValue)
 Set the MinorVersion value of the export directory. More...
 
void setName (std::uint32_t dwValue)
 Set the Name value of the export directory. More...
 
void setNumberOfFunctions (std::uint32_t dwValue)
 Set the NumberOfFunctions value of the export directory. More...
 
void setNumberOfNames (std::uint32_t dwValue)
 Set the NumberOfNames value of the export directory. More...
 
void setAddressOfFunctions (std::uint32_t dwValue)
 Set the AddressOfFunctions value of the export directory. More...
 
void setAddressOfNames (std::uint32_t dwValue)
 Set the AddressOfNames value of the export directory. More...
 
void setAddressOfNameOrdinals (std::uint32_t value)
 
const std::vector< std::pair< unsigned int, unsigned int > > & getOccupiedAddresses () const
 

Protected Member Functions

void addOccupiedAddress (const std::string &str, std::uint32_t rva)
 

Protected Attributes

PELIB_IMAGE_EXP_DIRECTORY m_ied
 Used to store all necessary information about a file's exported functions. More...
 
std::vector< std::pair< unsigned int, unsigned int > > m_occupiedAddresses
 Stores RVAs which are occupied by this export directory. More...
 

Detailed Description

Class that handles the export directory.

This class handles the export directory.

Todo:
getNameString

Constructor & Destructor Documentation

◆ ~ExportDirectory()

virtual PeLib::ExportDirectory::~ExportDirectory ( )
virtualdefault

Member Function Documentation

◆ addFunction()

void PeLib::ExportDirectory::addFunction ( const std::string &  strFuncname,
std::uint32_t  dwFuncAddr 
)

Add another function to be exported.

Parameters
strFuncnameName of the function.
dwFuncAddrRVA of the function.

◆ addOccupiedAddress()

void PeLib::ExportDirectory::addOccupiedAddress ( const std::string &  str,
std::uint32_t  rva 
)
protected
Parameters
strValue of the ASCIIZ string.
rvaRVA of the begin of the string

◆ calcNumberOfFunctions()

unsigned int PeLib::ExportDirectory::calcNumberOfFunctions ( ) const

◆ clear()

void PeLib::ExportDirectory::clear ( )

◆ getAddressOfFunction()

std::uint32_t PeLib::ExportDirectory::getAddressOfFunction ( std::size_t  dwIndex) const

Get the address of an exported function.

Parameters
dwIndexNumber which identifies an exported function.
Returns
The RVA of that function.

◆ getAddressOfFunctions()

std::uint32_t PeLib::ExportDirectory::getAddressOfFunctions ( ) const

Return the AddressOfFunctions value of the export directory.

Returns
The AddressOfFunctions of the export directory.

◆ getAddressOfName()

std::uint32_t PeLib::ExportDirectory::getAddressOfName ( std::size_t  dwIndex) const

Get the address of the name of an exported function.

Parameters
dwIndexNumber which identifies an exported function.
Returns
The RVA of the name string of that function.

◆ getAddressOfNameOrdinals()

std::uint32_t PeLib::ExportDirectory::getAddressOfNameOrdinals ( ) const

Returns the AddressOfNameOrdinals value.

Returns
The AddressOfNameOrdinals of the export directory.

◆ getAddressOfNames()

std::uint32_t PeLib::ExportDirectory::getAddressOfNames ( ) const

Return the AddressOfNames value of the export directory.

Returns
The AddressOfNames of the export directory.

◆ getBase()

std::uint32_t PeLib::ExportDirectory::getBase ( ) const

Return the Base value of the export directory.

Returns
The ordinal base of the export directory.

◆ getCharacteristics()

std::uint32_t PeLib::ExportDirectory::getCharacteristics ( ) const

Return the Characteristics value of the export directory.

Returns
The characteristics of the export directory.

◆ getFunctionIndex()

int PeLib::ExportDirectory::getFunctionIndex ( const std::string &  strFunctionName) const

Identifies a function through it's name.

Identifies an exported function through it's name.

Parameters
strFunctionNameName of the function
Returns
Number which identifies the functions.

◆ getFunctionName()

std::string PeLib::ExportDirectory::getFunctionName ( std::size_t  dwIndex) const

Get the name of an exported function.

Parameters
dwIndexNumber which identifies an exported function.
Returns
The name of that function.

◆ getFunctionOrdinal()

std::uint16_t PeLib::ExportDirectory::getFunctionOrdinal ( std::size_t  dwIndex) const

Get the ordinal of an exported function.

Parameters
dwIndexNumber which identifies an exported function.
Returns
The ordinal of that function.

◆ getMajorVersion()

std::uint16_t PeLib::ExportDirectory::getMajorVersion ( ) const

Return the MajorVersion value of the export directory.

Returns
The MajorVersion of the export directory.

◆ getMinorVersion()

std::uint16_t PeLib::ExportDirectory::getMinorVersion ( ) const

Return the MinorVersion value of the export directory.

Returns
The MinorVersion of the export directory.

◆ getName()

std::uint32_t PeLib::ExportDirectory::getName ( ) const

Return the Name value of the export directory.

Returns
The RVA of the name of the file.

◆ getNameString()

std::string PeLib::ExportDirectory::getNameString ( ) const

◆ getNumberOfFunctions()

std::uint32_t PeLib::ExportDirectory::getNumberOfFunctions ( ) const

Return the NumberOfFunctions value of the export directory.

Returns
The NumberOfFunctions of the export directory.

◆ getNumberOfNames()

std::uint32_t PeLib::ExportDirectory::getNumberOfNames ( ) const

Return the NumberOfNames value of the export directory.

Returns
The NumberOfNames of the export directory.

◆ getOccupiedAddresses()

const std::vector< std::pair< unsigned int, unsigned int > > & PeLib::ExportDirectory::getOccupiedAddresses ( ) const

◆ getTimeDateStamp()

std::uint32_t PeLib::ExportDirectory::getTimeDateStamp ( ) const

Return the TimeDateStamp value of the export directory.

Returns
The time/date stamp of the export directory.

◆ read()

int PeLib::ExportDirectory::read ( ImageLoader imageLoader)

Load the export directory from the image loader.

Parameters
imageLoaderInitialized image loader
Todo:
: Proper use of InputBuffer

◆ rebuild()

void PeLib::ExportDirectory::rebuild ( std::vector< std::uint8_t > &  vBuffer,
std::uint32_t  dwRva 
) const

Rebuild the current export directory.

Parameters
vBufferBuffer where the rebuilt export directory is written to.
dwRvaRVA of the export directory.
Todo:
fValid flag

◆ removeFunction()

void PeLib::ExportDirectory::removeFunction ( unsigned int  index)

◆ setAddressOfFunction()

void PeLib::ExportDirectory::setAddressOfFunction ( std::size_t  dwIndex,
std::uint32_t  dwValue 
)

Change the address of an exported function.

Parameters
dwIndexNumber which identifies an exported function.
dwValueThe RVA of that function.

◆ setAddressOfFunctions()

void PeLib::ExportDirectory::setAddressOfFunctions ( std::uint32_t  dwValue)

Set the AddressOfFunctions value of the export directory.

Parameters
dwValueThe AddressOfFunctions of the export directory.

◆ setAddressOfName()

void PeLib::ExportDirectory::setAddressOfName ( std::size_t  dwIndex,
std::uint32_t  dwValue 
)

Change the address of the name of an exported function.

Parameters
dwIndexNumber which identifies an exported function.
dwValueThe RVA of the name string of that function.

◆ setAddressOfNameOrdinals()

void PeLib::ExportDirectory::setAddressOfNameOrdinals ( std::uint32_t  value)

◆ setAddressOfNames()

void PeLib::ExportDirectory::setAddressOfNames ( std::uint32_t  dwValue)

Set the AddressOfNames value of the export directory.

Parameters
dwValueThe AddressOfNames of the export directory.

◆ setBase()

void PeLib::ExportDirectory::setBase ( std::uint32_t  dwValue)

Set the Base value of the export directory.

Parameters
dwValueThe ordinal base of the export directory.

◆ setCharacteristics()

void PeLib::ExportDirectory::setCharacteristics ( std::uint32_t  dwValue)

Set the Characteristics value of the export directory.

Parameters
dwValueThe Characteristics of the export directory.

◆ setFunctionName()

void PeLib::ExportDirectory::setFunctionName ( std::size_t  dwIndex,
const std::string &  strName 
)

Change the name of an exported function.

Parameters
dwIndexNumber which identifies an exported function.
strNameThe name of that function.

◆ setFunctionOrdinal()

void PeLib::ExportDirectory::setFunctionOrdinal ( std::size_t  dwIndex,
std::uint16_t  wValue 
)

Change the ordinal of an exported function.

Parameters
dwIndexNumber which identifies an exported function.
wValueThe ordinal of that function.

◆ setMajorVersion()

void PeLib::ExportDirectory::setMajorVersion ( std::uint16_t  wValue)

Set the MajorVersion value of the export directory.

Parameters
wValueThe MajorVersion of the export directory.

◆ setMinorVersion()

void PeLib::ExportDirectory::setMinorVersion ( std::uint16_t  wValue)

Set the MinorVersion value of the export directory.

Parameters
wValueThe MinorVersion of the export directory.

◆ setName()

void PeLib::ExportDirectory::setName ( std::uint32_t  dwValue)

Set the Name value of the export directory.

Parameters
dwValueThe Name of the export directory.

◆ setNameString()

void PeLib::ExportDirectory::setNameString ( const std::string &  strFilename)

Changes the name of the file (according to the export directory).

Changes the filename according to the export directory.

Parameters
strFilenameNew filename.

◆ setNumberOfFunctions()

void PeLib::ExportDirectory::setNumberOfFunctions ( std::uint32_t  dwValue)

Set the NumberOfFunctions value of the export directory.

Parameters
dwValueThe NumberOfFunctions of the export directory.

◆ setNumberOfNames()

void PeLib::ExportDirectory::setNumberOfNames ( std::uint32_t  dwValue)

Set the NumberOfNames value of the export directory.

Parameters
dwValueThe NumberOfNames of the export directory.

◆ setTimeDateStamp()

void PeLib::ExportDirectory::setTimeDateStamp ( std::uint32_t  dwValue)

Set the TimeDateStamp value of the export directory.

Parameters
dwValueThe TimeDateStamp of the export directory.

◆ size()

unsigned int PeLib::ExportDirectory::size ( ) const

Returns the size of the current export directory.

Returns
Size of the current export directory.

◆ write()

int PeLib::ExportDirectory::write ( const std::string &  strFilename,
unsigned int  uiOffset,
unsigned int  uiRva 
) const

Writes the current export directory to a file.

Parameters
strFilenameName of the file.
uiOffsetFile offset the export directory will be written to.
uiRvaRVA of the export directory.
Todo:
Check if ofFile.write succeeded.

Member Data Documentation

◆ m_ied

PELIB_IMAGE_EXP_DIRECTORY PeLib::ExportDirectory::m_ied
protected

Used to store all necessary information about a file's exported functions.

◆ m_occupiedAddresses

std::vector<std::pair<unsigned int, unsigned int> > PeLib::ExportDirectory::m_occupiedAddresses
protected

Stores RVAs which are occupied by this export directory.


The documentation for this class was generated from the following files: