retdec
Public Member Functions | Private Attributes | List of all members
PeLib::PeFileT Class Reference

#include <PeFile.h>

Inheritance diagram for PeLib::PeFileT:
Inheritance graph
[legend]
Collaboration diagram for PeLib::PeFileT:
Collaboration graph
[legend]

Public Member Functions

 PeFileT (const std::string &strFileName)
 
 PeFileT (std::istream &stream)
 
 PeFileT ()
 
virtual ~PeFileT ()
 Default constructor which exists only for the sake of allowing to construct files without filenames. More...
 
int loadPeHeaders (bool loadHeadersOnly=false)
 Load the PE file using the already-open stream. More...
 
int loadPeHeaders (ByteBuffer &fileData, bool loadHeadersOnly=false)
 Alternate load - can be used when the data are already loaded to memory to prevent duplicating large buffers. More...
 
int getFileType () const
 returns PEFILE64 or PEFILE32 More...
 
std::string getFileName () const
 Returns the name of the current file. More...
 
void setFileName (const std::string &strFilename)
 Changes the name of the current file. More...
 
int readExportDirectory ()
 Reads the export directory of the current file from disc. More...
 
int readImportDirectory ()
 Reads the import directory of the current file from disc. More...
 
int readBoundImportDirectory ()
 Reads the bound import directory of the current file from disc. More...
 
int readResourceDirectory ()
 Reads the resource directory of the current file from disc. More...
 
int readRelocationsDirectory ()
 Reads the relocations directory of the current file from disc. More...
 
int readComHeaderDirectory ()
 Reads the COM+ descriptor directory of the current file from disc. More...
 
int readIatDirectory ()
 Reads the IAT directory of the current file from disc. More...
 
int readDebugDirectory ()
 Reads the Debug directory of the current file. More...
 
int readTlsDirectory ()
 Reads the TLS directory of the current file. More...
 
int readRichHeader (std::size_t offset, std::size_t size, bool ignoreInvalidKey=false)
 Reads rich header of the current file. More...
 
int readCoffSymbolTable (ByteBuffer &fileData)
 Reads the COFF symbol table of the current file. More...
 
int readDelayImportDirectory ()
 Reads delay import directory of the current file. More...
 
int readSecurityDirectory ()
 Reads the security directory of the current file. More...
 
LoaderError checkEntryPointErrors () const
 Checks the entry point code. More...
 
LoaderError checkForInMemoryLayout (LoaderError ldrError) const
 
LoaderError loaderError () const
 Returns a loader error, if there was any. More...
 
unsigned int getBits () const
 
const ExportDirectoryexpDir () const
 Accessor function for the export directory. More...
 
ExportDirectoryexpDir ()
 Accessor function for the export directory. More...
 
const ImportDirectoryimpDir () const
 Accessor function for the import directory. More...
 
ImportDirectoryimpDir ()
 Accessor function for the import directory. More...
 
const BoundImportDirectoryboundImpDir () const
 Accessor function for the bound import directory. More...
 
BoundImportDirectoryboundImpDir ()
 Accessor function for the bound import directory. More...
 
const ResourceDirectoryresDir () const
 Accessor function for the resource directory. More...
 
ResourceDirectoryresDir ()
 Accessor function for the resource directory. More...
 
const RelocationsDirectoryrelocDir () const
 Accessor function for the relocations directory. More...
 
RelocationsDirectoryrelocDir ()
 Accessor function for the relocations directory. More...
 
const ComHeaderDirectorycomDir () const
 Accessor function for the COM+ descriptor directory. More...
 
ComHeaderDirectorycomDir ()
 Accessor function for the COM+ descriptor directory. More...
 
const IatDirectoryiatDir () const
 Accessor function for the IAT directory. More...
 
IatDirectoryiatDir ()
 Accessor function for the IAT directory. More...
 
const DebugDirectorydebugDir () const
 Accessor function for the debug directory. More...
 
DebugDirectorydebugDir ()
 Accessor function for the debug directory. More...
 
const DelayImportDirectorydelayImports () const
 Accessor function for the delay import directory. More...
 
DelayImportDirectorydelayImports ()
 Accessor function for the delay import directory. More...
 
const TlsDirectorytlsDir () const
 Accessor function for the TLS directory. More...
 
TlsDirectorytlsDir ()
 Accessor function for the TLS directory. More...
 
- Public Member Functions inherited from PeLib::PeFile
virtual ~PeFile ()
 
const ImageLoaderimageLoader () const
 Accessor function for the image loader. More...
 
ImageLoaderimageLoader ()
 Accessor function for the MZ header. More...
 
const RichHeaderrichHeader () const
 Accessor function for the Rich header. More...
 
RichHeaderrichHeader ()
 Accessor function for the Rich header. More...
 
const CoffSymbolTablecoffSymTab () const
 Accessor function for the COFF symbol table. More...
 
CoffSymbolTablecoffSymTab ()
 Accessor function for the COFF symbol table. More...
 
const SecurityDirectorysecurityDir () const
 Accessor function for the security directory. More...
 
SecurityDirectorysecurityDir ()
 Accessor function for the security directory. More...
 

Private Attributes

std::ifstream m_ifStream
 Valid if we opened the file stream ourself. More...
 
std::istream & m_iStream
 Can also reference m_ifStream. More...
 
ExportDirectory m_expdir
 Export directory of the current file. More...
 
ImportDirectory m_impdir
 Import directory of the current file. More...
 
BoundImportDirectory m_boundimpdir
 BoundImportDirectory of the current file. More...
 
ResourceDirectory m_resdir
 ResourceDirectory of the current file. More...
 
RelocationsDirectory m_relocs
 Relocations directory of the current file. More...
 
ComHeaderDirectory m_comdesc
 COM+ descriptor directory of the current file. More...
 
IatDirectory m_iat
 Import address table of the current file. More...
 
DebugDirectory m_debugdir
 Debug directory of the current file. More...
 
DelayImportDirectory m_delayimpdir
 Delay import directory of the current file. More...
 
TlsDirectory m_tlsdir
 TLS directory of the current file. More...
 

Additional Inherited Members

- Protected Attributes inherited from PeLib::PeFile
std::string m_filename
 Name of the current file. More...
 
ImageLoader m_imageLoader
 
RichHeader m_richheader
 Rich header of the current file. More...
 
CoffSymbolTable m_coffsymtab
 Symbol table of the current file. More...
 
SecurityDirectory m_secdir
 Security directory of the current file. More...
 

Detailed Description

This class implements the common structures of PE and PE+ files.

Constructor & Destructor Documentation

◆ PeFileT() [1/3]

PeLib::PeFileT::PeFileT ( const std::string &  strFileName)

◆ PeFileT() [2/3]

PeLib::PeFileT::PeFileT ( std::istream &  stream)

◆ PeFileT() [3/3]

PeLib::PeFileT::PeFileT ( )

◆ ~PeFileT()

virtual PeLib::PeFileT::~PeFileT ( )
inlinevirtual

Default constructor which exists only for the sake of allowing to construct files without filenames.

Member Function Documentation

◆ boundImpDir() [1/2]

BoundImportDirectory & PeLib::PeFileT::boundImpDir ( )

Accessor function for the bound import directory.

Returns
A reference to the file's bound import directory.

◆ boundImpDir() [2/2]

const BoundImportDirectory & PeLib::PeFileT::boundImpDir ( ) const

Accessor function for the bound import directory.

Returns
A reference to the file's bound import directory.

◆ checkEntryPointErrors()

LoaderError PeLib::PeFileT::checkEntryPointErrors ( ) const

Checks the entry point code.

◆ checkForInMemoryLayout()

LoaderError PeLib::PeFileT::checkForInMemoryLayout ( LoaderError  ldrError) const

◆ comDir() [1/2]

ComHeaderDirectory & PeLib::PeFileT::comDir ( )

Accessor function for the COM+ descriptor directory.

Returns
A reference to the file's COM+ descriptor directory.

◆ comDir() [2/2]

const ComHeaderDirectory & PeLib::PeFileT::comDir ( ) const

Accessor function for the COM+ descriptor directory.

Returns
A reference to the file's COM+ descriptor directory.

◆ debugDir() [1/2]

DebugDirectory & PeLib::PeFileT::debugDir ( )

Accessor function for the debug directory.

◆ debugDir() [2/2]

const DebugDirectory & PeLib::PeFileT::debugDir ( ) const

Accessor function for the debug directory.

◆ delayImports() [1/2]

DelayImportDirectory & PeLib::PeFileT::delayImports ( )

Accessor function for the delay import directory.

Returns
A reference to the file's delay import directory.

◆ delayImports() [2/2]

const DelayImportDirectory & PeLib::PeFileT::delayImports ( ) const

Accessor function for the delay import directory.

Returns
A reference to the file's delay import directory.

◆ expDir() [1/2]

ExportDirectory & PeLib::PeFileT::expDir ( )

Accessor function for the export directory.

Returns
A reference to the file's export directory.

◆ expDir() [2/2]

const ExportDirectory & PeLib::PeFileT::expDir ( ) const

Accessor function for the export directory.

Returns
A reference to the file's export directory.

◆ getBits()

unsigned int PeLib::PeFileT::getBits ( ) const
inlinevirtual

Implements PeLib::PeFile.

◆ getFileName()

std::string PeLib::PeFileT::getFileName ( ) const
virtual

Returns the name of the current file.

Returns
Filename of the current file.

Implements PeLib::PeFile.

◆ getFileType()

int PeLib::PeFileT::getFileType ( ) const

returns PEFILE64 or PEFILE32

◆ iatDir() [1/2]

IatDirectory & PeLib::PeFileT::iatDir ( )

Accessor function for the IAT directory.

◆ iatDir() [2/2]

const IatDirectory & PeLib::PeFileT::iatDir ( ) const

Accessor function for the IAT directory.

◆ impDir() [1/2]

ImportDirectory & PeLib::PeFileT::impDir ( )

Accessor function for the import directory.

Returns
A reference to the file's import directory.

◆ impDir() [2/2]

const ImportDirectory & PeLib::PeFileT::impDir ( ) const

Accessor function for the import directory.

Returns
A reference to the file's import directory.

◆ loaderError()

LoaderError PeLib::PeFileT::loaderError ( ) const
virtual

Returns a loader error, if there was any.

Implements PeLib::PeFile.

◆ loadPeHeaders() [1/2]

int PeLib::PeFileT::loadPeHeaders ( bool  loadHeadersOnly = false)

Load the PE file using the already-open stream.

◆ loadPeHeaders() [2/2]

int PeLib::PeFileT::loadPeHeaders ( ByteBuffer fileData,
bool  loadHeadersOnly = false 
)

Alternate load - can be used when the data are already loaded to memory to prevent duplicating large buffers.

◆ readBoundImportDirectory()

int PeLib::PeFileT::readBoundImportDirectory ( )
virtual

Reads the bound import directory of the current file from disc.

Implements PeLib::PeFile.

◆ readCoffSymbolTable()

int PeLib::PeFileT::readCoffSymbolTable ( ByteBuffer fileData)
virtual

Reads the COFF symbol table of the current file.

Implements PeLib::PeFile.

◆ readComHeaderDirectory()

int PeLib::PeFileT::readComHeaderDirectory ( )
virtual

Reads the COM+ descriptor directory of the current file from disc.

Implements PeLib::PeFile.

◆ readDebugDirectory()

int PeLib::PeFileT::readDebugDirectory ( )
virtual

Reads the Debug directory of the current file.

Implements PeLib::PeFile.

◆ readDelayImportDirectory()

int PeLib::PeFileT::readDelayImportDirectory ( )
virtual

Reads delay import directory of the current file.

Implements PeLib::PeFile.

◆ readExportDirectory()

int PeLib::PeFileT::readExportDirectory ( )
virtual

Reads the export directory of the current file from disc.

Implements PeLib::PeFile.

◆ readIatDirectory()

int PeLib::PeFileT::readIatDirectory ( )
virtual

Reads the IAT directory of the current file from disc.

Implements PeLib::PeFile.

◆ readImportDirectory()

int PeLib::PeFileT::readImportDirectory ( )
virtual

Reads the import directory of the current file from disc.

Implements PeLib::PeFile.

◆ readRelocationsDirectory()

int PeLib::PeFileT::readRelocationsDirectory ( )
virtual

Reads the relocations directory of the current file from disc.

Implements PeLib::PeFile.

◆ readResourceDirectory()

int PeLib::PeFileT::readResourceDirectory ( )
virtual

Reads the resource directory of the current file from disc.

Implements PeLib::PeFile.

◆ readRichHeader()

int PeLib::PeFileT::readRichHeader ( std::size_t  offset,
std::size_t  size,
bool  ignoreInvalidKey = false 
)
virtual

Reads rich header of the current file.

Implements PeLib::PeFile.

◆ readSecurityDirectory()

int PeLib::PeFileT::readSecurityDirectory ( )
virtual

Reads the security directory of the current file.

Implements PeLib::PeFile.

◆ readTlsDirectory()

int PeLib::PeFileT::readTlsDirectory ( )
virtual

Reads the TLS directory of the current file.

Implements PeLib::PeFile.

◆ relocDir() [1/2]

RelocationsDirectory & PeLib::PeFileT::relocDir ( )

Accessor function for the relocations directory.

Returns
A reference to the file's relocations directory.

◆ relocDir() [2/2]

const RelocationsDirectory & PeLib::PeFileT::relocDir ( ) const

Accessor function for the relocations directory.

Returns
A reference to the file's relocations directory.

◆ resDir() [1/2]

ResourceDirectory & PeLib::PeFileT::resDir ( )

Accessor function for the resource directory.

Returns
A reference to the file's resource directory.

◆ resDir() [2/2]

const ResourceDirectory & PeLib::PeFileT::resDir ( ) const

Accessor function for the resource directory.

Returns
A reference to the file's resource directory.

◆ setFileName()

void PeLib::PeFileT::setFileName ( const std::string &  strFilename)
virtual

Changes the name of the current file.

Parameters
strFilenameNew filename.

Implements PeLib::PeFile.

◆ tlsDir() [1/2]

TlsDirectory & PeLib::PeFileT::tlsDir ( )

Accessor function for the TLS directory.

◆ tlsDir() [2/2]

const TlsDirectory & PeLib::PeFileT::tlsDir ( ) const

Accessor function for the TLS directory.

Member Data Documentation

◆ m_boundimpdir

BoundImportDirectory PeLib::PeFileT::m_boundimpdir
private

BoundImportDirectory of the current file.

◆ m_comdesc

ComHeaderDirectory PeLib::PeFileT::m_comdesc
private

COM+ descriptor directory of the current file.

◆ m_debugdir

DebugDirectory PeLib::PeFileT::m_debugdir
private

Debug directory of the current file.

◆ m_delayimpdir

DelayImportDirectory PeLib::PeFileT::m_delayimpdir
private

Delay import directory of the current file.

◆ m_expdir

ExportDirectory PeLib::PeFileT::m_expdir
private

Export directory of the current file.

◆ m_iat

IatDirectory PeLib::PeFileT::m_iat
private

Import address table of the current file.

◆ m_ifStream

std::ifstream PeLib::PeFileT::m_ifStream
private

Valid if we opened the file stream ourself.

◆ m_impdir

ImportDirectory PeLib::PeFileT::m_impdir
private

Import directory of the current file.

◆ m_iStream

std::istream& PeLib::PeFileT::m_iStream
private

Can also reference m_ifStream.

◆ m_relocs

RelocationsDirectory PeLib::PeFileT::m_relocs
private

Relocations directory of the current file.

◆ m_resdir

ResourceDirectory PeLib::PeFileT::m_resdir
private

ResourceDirectory of the current file.

◆ m_tlsdir

TlsDirectory PeLib::PeFileT::m_tlsdir
private

TLS directory of the current file.


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