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

Class that handles the Import Address Table (IAT) More...

#include <IatDirectory.h>

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

Public Member Functions

virtual ~IatDirectory ()=default
 
int read (const void *buffer, std::size_t buffersize)
 Reads the Import Address Table from a PE file. More...
 
int read (PeLib::ImageLoader &imageLoader)
 Reads the Import Address Table from an image loader. More...
 
unsigned int calcNumberOfAddresses () const
 Returns the number of fields in the IAT. More...
 
void addAddress (std::uint32_t dwValue)
 Adds another address to the IAT. More...
 
void removeAddress (unsigned int index)
 Removes an address from the IAT. More...
 
void clear ()
 Empties the IAT. More...
 
void rebuild (std::vector< std::uint8_t > &vBuffer) const
 
unsigned int size () const
 Returns the size of the current IAT. More...
 
int write (const std::string &strFilename, unsigned int uiOffset) const
 Writes the current IAT to a file. More...
 
std::uint32_t getAddress (unsigned int index) const
 Retrieve the value of a field in the IAT. More...
 
void setAddress (std::uint32_t dwAddrnr, std::uint32_t dwValue)
 Change the value of a field in the IAT. More...
 

Protected Attributes

std::vector< std::uint32_t > m_vIat
 Stores the individual IAT fields. More...
 

Detailed Description

Class that handles the Import Address Table (IAT)

This class can read and modify the Import Address Table of a PE file.

Constructor & Destructor Documentation

◆ ~IatDirectory()

virtual PeLib::IatDirectory::~IatDirectory ( )
virtualdefault

Member Function Documentation

◆ addAddress()

void PeLib::IatDirectory::addAddress ( std::uint32_t  dwValue)

Adds another address to the IAT.

Adds another field to the IAT.

Parameters
dwValuedwValue of the new field.

◆ calcNumberOfAddresses()

unsigned int PeLib::IatDirectory::calcNumberOfAddresses ( ) const

Returns the number of fields in the IAT.

Returns the number of fields in the IAT. This is equivalent to the number of imported functions.

Returns
Number of fields in the IAT.

◆ clear()

void PeLib::IatDirectory::clear ( )

Empties the IAT.

Delete all entries from the IAT.

◆ getAddress()

std::uint32_t PeLib::IatDirectory::getAddress ( unsigned int  index) const

Retrieve the value of a field in the IAT.

Returns the dwValue of a field in the IAT.

Parameters
indexNumber identifying the field.
Returns
dwValue of the field.

◆ read() [1/2]

int PeLib::IatDirectory::read ( const void *  buffer,
std::size_t  buffersize 
)

Reads the Import Address Table from a PE file.

Reads the Import Address table from an image

Parameters
bufferPointer to the IAT data
buffersizeLength of the data pointed by 'buffer'

◆ read() [2/2]

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

Reads the Import Address Table from an image loader.

Reads the Import Address table from an image

Parameters
imageLoaderInitialized image loader

◆ rebuild()

void PeLib::IatDirectory::rebuild ( std::vector< std::uint8_t > &  vBuffer) const

Rebuilds the complete Import Address Table.

Parameters
vBufferBuffer where the rebuilt IAT will be stored.

◆ removeAddress()

void PeLib::IatDirectory::removeAddress ( unsigned int  index)

Removes an address from the IAT.

Removes an address from the IAT.

Parameters
indexNumber identifying the field.

◆ setAddress()

void PeLib::IatDirectory::setAddress ( std::uint32_t  dwAddrnr,
std::uint32_t  dwValue 
)

Change the value of a field in the IAT.

Updates the dwValue of a field in the IAT.

Parameters
dwAddrnrNumber identifying the field.
dwValueNew dwValue of the field.

◆ size()

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

Returns the size of the current IAT.

◆ write()

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

Writes the current IAT to a file.

Member Data Documentation

◆ m_vIat

std::vector<std::uint32_t> PeLib::IatDirectory::m_vIat
protected

Stores the individual IAT fields.


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