retdec
Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
PeLib::ImageLoader Class Reference

#include <ImageLoader.h>

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

Public Member Functions

 ImageLoader (std::uint32_t loaderFlags=0)
 
int Load (ByteBuffer &fileData, bool loadHeadersOnly=false)
 
int Load (std::istream &fs, std::streamoff fileOffset=0, bool loadHeadersOnly=false)
 
int Load (const char *fileName, bool loadHeadersOnly=false)
 
int Save (std::ostream &fs, std::streamoff fileOffset=0, bool saveHeadersOnly=false)
 
int Save (const char *fileName, bool saveHeadersOnly=false)
 
bool relocateImage (std::uint64_t newImageBase)
 
std::uint32_t readImage (void *buffer, std::uint32_t rva, std::uint32_t bytesToRead)
 
std::uint32_t writeImage (void *buffer, std::uint32_t rva, std::uint32_t bytesToRead)
 
std::uint32_t readString (std::string &str, std::uint32_t rva, std::uint32_t maxLength=65535)
 
std::uint32_t readStringRc (std::string &str, std::uint32_t rva)
 
std::uint32_t readStringRaw (ByteBuffer &fileData, std::string &str, std::size_t offset, std::size_t maxLength=65535, bool mustBePrintable=false, bool mustNotBeTooLong=false)
 
std::uint32_t stringLength (std::uint32_t rva, std::uint32_t maxLength=65535) const
 
std::uint32_t readPointer (std::uint32_t rva, std::uint64_t &pointerValue)
 
std::uint32_t getPointerSize () const
 
std::uint32_t dumpImage (const char *fileName)
 
std::uint32_t getImageBitability () const
 
std::uint32_t vaToRva (std::uint64_t VirtualAddress) const
 
std::uint32_t getFileOffsetFromRva (std::uint32_t rva) const
 
std::uint32_t getRealPointerToRawData (std::size_t sectionIndex) const
 
std::uint32_t getImageProtection (std::uint32_t characteristics) const
 
std::size_t getSectionIndexByRva (std::uint32_t Rva) const
 
std::uint32_t getFieldOffset (PELIB_MEMBER_TYPE field) const
 
const PELIB_IMAGE_DOS_HEADERgetDosHeader () const
 
const PELIB_IMAGE_FILE_HEADERgetFileHeader () const
 
const PELIB_IMAGE_OPTIONAL_HEADERgetOptionalHeader () const
 
const PELIB_SECTION_HEADERgetSectionHeader (std::size_t sectionIndex) const
 
PELIB_SECTION_HEADERgetSectionHeader (std::size_t sectionIndex)
 
std::uint64_t getSizeOfFile () const
 
std::uint64_t getOrdinalMask () const
 
std::uint32_t getPeHeaderOffset () const
 
void setPeHeaderOffset (std::uint32_t new_e_lfanew)
 
std::uint32_t getNtSignature () const
 
std::uint32_t getMachine () const
 
std::uint32_t getPointerToSymbolTable () const
 
std::uint32_t getNumberOfSymbols () const
 
std::uint32_t getLoadedNumberOfSections () const
 
std::uint32_t getCharacteristics () const
 
std::uint32_t getNumberOfSections () const
 
std::uint32_t getMagic () const
 
std::uint64_t getImageBase () const
 
std::uint32_t getAddressOfEntryPoint () const
 
std::uint32_t getSizeOfHeaders () const
 
std::uint32_t getSizeOfImage () const
 
std::uint32_t getSizeOfImageAligned () const
 
std::uint32_t getSectionAlignment () const
 
std::uint32_t getFileAlignment () const
 
std::uint32_t getChecksumFileOffset () const
 
std::uint32_t getRealNumberOfDataDirectories () const
 
std::uint32_t getSecurityDirFileOffset () const
 
std::uint32_t getDataDirRva (std::size_t dataDirIndex) const
 
std::uint32_t getDataDirSize (std::size_t dataDirIndex) const
 
std::uint64_t getVirtualAddressMasked (std::uint32_t rva)
 
void setPointerToSymbolTable (std::uint32_t pointerToSymbolTable)
 
void setCharacteristics (std::uint32_t characteristics)
 
void setAddressOfEntryPoint (std::uint32_t addressOfEntryPoint)
 
void setSizeOfCode (std::uint32_t sizeOfCode, std::uint32_t baseOfCode=UINT32_MAX)
 
void setDataDirectory (std::uint32_t entryIndex, std::uint32_t VirtualAddress, std::uint32_t Size=UINT32_MAX)
 
PELIB_IMAGE_SECTION_HEADERaddSection (const char *name, std::uint32_t size)
 
void calcNewSectionAddresses (std::uint32_t &Rva, std::uint32_t &RawOffset)
 
void setSectionName (std::size_t sectionIndex, const char *newName)
 
void setSectionVirtualRange (std::size_t sectionIndex, std::uint32_t VirtualAddress, std::uint32_t VirtualSize=UINT32_MAX)
 
void setSectionRawDataRange (std::size_t sectionIndex, std::uint32_t PointerToRawData, std::uint32_t SizeOfRawData=UINT32_MAX)
 
void setSectionCharacteristics (std::size_t sectionIndex, std::uint32_t Characteristics)
 
int splitSection (std::size_t sectionIndex, const std::string &prevSectName, const std::string &nextSectName, std::uint32_t splitOffset)
 
void enlargeLastSection (std::uint32_t sectionSize)
 
int removeSection (std::size_t sizeIncrement)
 
void makeValid ()
 
int setLoaderError (LoaderError ldrErr)
 
LoaderError loaderError () const
 
std::size_t getMismatchOffset (void *buffer1, void *buffer2, std::uint32_t rva, std::size_t length)
 
void compareWithWindowsMappedImage (PELIB_IMAGE_COMPARE &ImageCompare, void *imageData, std::uint32_t imageSize)
 
template<typename LOAD_CONFIG >
bool checkForBadLoadConfigXX (uint32_t loadConfigRva, uint32_t loadConfigSize)
 

Protected Types

typedef void(* READWRITE) (PeLib::PELIB_FILE_PAGE &page, void *buffer, std::size_t offsetInPage, std::size_t bytesInPage)
 

Protected Member Functions

std::uint32_t readWriteImage (void *buffer, std::uint32_t rva, std::uint32_t bytesToRead, READWRITE ReadWrite)
 
std::uint32_t readWriteImageFile (void *buffer, std::uint32_t rva, std::uint32_t bytesToRead, bool bReadOperation)
 
void processSectionHeader (PELIB_IMAGE_SECTION_HEADER *pSectionHeader)
 
bool processImageRelocation_IA64_IMM64 (std::uint32_t fixupAddress, std::uint64_t difference)
 
bool processImageRelocations (std::uint64_t oldImageBase, std::uint64_t getImageBase, std::uint32_t VirtualAddress, std::uint32_t Size)
 
void writeNewImageBase (std::uint64_t newImageBase)
 
int captureDosHeader (ByteBuffer &fileData)
 
int saveDosHeader (std::ostream &fs, std::streamoff fileOffset)
 
int captureNtHeaders (ByteBuffer &fileData)
 
int saveNtHeaders (std::ostream &fs, std::streamoff fileOffset)
 
int captureSectionName (ByteBuffer &fileData, std::string &sectionName, const std::uint8_t *name)
 
int captureSectionHeaders (ByteBuffer &fileData)
 
int saveSectionHeaders (std::ostream &fs, std::streamoff fileOffset)
 
int captureImageSections (ByteBuffer &fileData)
 
int captureOptionalHeader32 (std::uint8_t *fileData, std::uint8_t *filePtr, std::uint8_t *fileEnd)
 
int captureOptionalHeader64 (std::uint8_t *fileData, std::uint8_t *filePtr, std::uint8_t *fileEnd)
 
int verifyDosHeader (PELIB_IMAGE_DOS_HEADER &hdr, std::size_t fileSize)
 
int verifyDosHeader (std::istream &fs, std::streamoff fileOffset, std::size_t fileSize)
 
int loadImageAsIs (ByteBuffer &fileData)
 
std::uint32_t captureImageSection (ByteBuffer &fileData, std::uint32_t virtualAddress, std::uint32_t virtualSize, std::uint32_t pointerToRawData, std::uint32_t sizeOfRawData, std::uint32_t characteristics, bool isImageHeader=false)
 
bool isGoodPagePointer (PFN_VERIFY_ADDRESS PfnVerifyAddress, void *pagePtr)
 
bool isGoodMappedPage (std::uint32_t rva)
 
bool isZeroPage (std::uint32_t rva)
 
bool isSectionHeaderPointerToRawData (uint32_t rva)
 
bool isLegacyImageArchitecture (std::uint16_t Machine)
 
bool checkForValid64BitMachine ()
 
bool checkForValid32BitMachine ()
 
bool isValidMachineForCodeIntegrifyCheck (std::uint32_t Bits)
 
bool checkForSectionTablesWithinHeader (std::uint32_t e_lfanew)
 
bool checkForBadCodeIntegrityImages (ByteBuffer &fileData)
 
bool checkForBadArchitectureSpecific ()
 
bool checkForImageAfterMapping ()
 
template<typename LOAD_CONFIG >
bool checkForBadLoadConfigXX (std::uint32_t loadConfigRva, std::uint32_t loadConfigSize)
 
bool isImageLoadable () const
 
bool isImageMappedOk () const
 
bool isValidImageBlock (std::uint32_t Rva, std::uint32_t Size) const
 
bool isPrintableChar (int ch)
 

Static Protected Member Functions

static void readFromPage (PELIB_FILE_PAGE &page, void *buffer, size_t offsetInPage, size_t bytesInPage)
 
static void writeToPage (PELIB_FILE_PAGE &page, void *buffer, size_t offsetInPage, size_t bytesInPage)
 
static std::uint32_t AlignToSize (std::uint32_t ByteSize, std::uint32_t AlignSize)
 
static std::uint32_t BytesToPages (std::uint32_t ByteSize)
 
static std::uint64_t signExtend32To64 (std::uint32_t value32)
 

Protected Attributes

std::vector< PELIB_SECTION_HEADERsections
 
std::vector< PELIB_FILE_PAGEpages
 
PELIB_IMAGE_DOS_HEADER dosHeader
 
PELIB_IMAGE_FILE_HEADER fileHeader
 
PELIB_IMAGE_OPTIONAL_HEADER optionalHeader
 
ByteBuffer rawFileData
 
LoaderError ldrError
 
std::uint64_t savedFileSize
 
std::uint32_t windowsBuildNumber
 
std::uint32_t ntSignature
 
std::uint32_t maxSectionCount
 
std::uint32_t realNumberOfRvaAndSizes
 
std::uint32_t checkSumFileOffset
 
std::uint32_t securityDirFileOffset
 
std::uint32_t ssiImageAlignment32
 
bool is64BitWindows
 
bool ntHeadersSizeCheck
 
bool sizeofImageMustMatch
 
bool architectureSpecificChecks
 
bool headerSizeCheck
 
bool loadArmImages
 
bool loadArm64Images
 
bool loadItaniumImages
 
bool forceIntegrityCheckEnabled
 
bool forceIntegrityCheckCertificate
 
bool checkNonLegacyDllCharacteristics
 
bool checkImagePostMapping
 

Static Protected Attributes

static uint8_t ImageProtectionArray [16]
 

Member Typedef Documentation

◆ READWRITE

typedef void(* PeLib::ImageLoader::READWRITE) (PeLib::PELIB_FILE_PAGE &page, void *buffer, std::size_t offsetInPage, std::size_t bytesInPage)
protected

Constructor & Destructor Documentation

◆ ImageLoader()

PeLib::ImageLoader::ImageLoader ( std::uint32_t  loaderFlags = 0)

Member Function Documentation

◆ addSection()

PeLib::PELIB_IMAGE_SECTION_HEADER * PeLib::ImageLoader::addSection ( const char *  name,
std::uint32_t  size 
)

◆ AlignToSize()

static std::uint32_t PeLib::ImageLoader::AlignToSize ( std::uint32_t  ByteSize,
std::uint32_t  AlignSize 
)
inlinestaticprotected

◆ BytesToPages()

static std::uint32_t PeLib::ImageLoader::BytesToPages ( std::uint32_t  ByteSize)
inlinestaticprotected

◆ calcNewSectionAddresses()

void PeLib::ImageLoader::calcNewSectionAddresses ( std::uint32_t &  Rva,
std::uint32_t &  RawOffset 
)

◆ captureDosHeader()

int PeLib::ImageLoader::captureDosHeader ( ByteBuffer fileData)
protected

◆ captureImageSection()

uint32_t PeLib::ImageLoader::captureImageSection ( ByteBuffer fileData,
std::uint32_t  virtualAddress,
std::uint32_t  virtualSize,
std::uint32_t  pointerToRawData,
std::uint32_t  sizeOfRawData,
std::uint32_t  characteristics,
bool  isImageHeader = false 
)
protected

◆ captureImageSections()

int PeLib::ImageLoader::captureImageSections ( ByteBuffer fileData)
protected

◆ captureNtHeaders()

int PeLib::ImageLoader::captureNtHeaders ( ByteBuffer fileData)
protected

◆ captureOptionalHeader32()

int PeLib::ImageLoader::captureOptionalHeader32 ( std::uint8_t *  fileData,
std::uint8_t *  filePtr,
std::uint8_t *  fileEnd 
)
protected

◆ captureOptionalHeader64()

int PeLib::ImageLoader::captureOptionalHeader64 ( std::uint8_t *  fileData,
std::uint8_t *  filePtr,
std::uint8_t *  fileEnd 
)
protected

◆ captureSectionHeaders()

int PeLib::ImageLoader::captureSectionHeaders ( ByteBuffer fileData)
protected

◆ captureSectionName()

int PeLib::ImageLoader::captureSectionName ( ByteBuffer fileData,
std::string &  sectionName,
const std::uint8_t *  name 
)
protected

◆ checkForBadArchitectureSpecific()

bool PeLib::ImageLoader::checkForBadArchitectureSpecific ( )
protected

◆ checkForBadCodeIntegrityImages()

bool PeLib::ImageLoader::checkForBadCodeIntegrityImages ( ByteBuffer fileData)
protected

◆ checkForBadLoadConfigXX() [1/2]

template<typename LOAD_CONFIG >
bool PeLib::ImageLoader::checkForBadLoadConfigXX ( std::uint32_t  loadConfigRva,
std::uint32_t  loadConfigSize 
)
protected

◆ checkForBadLoadConfigXX() [2/2]

template<typename LOAD_CONFIG >
bool PeLib::ImageLoader::checkForBadLoadConfigXX ( uint32_t  loadConfigRva,
uint32_t  loadConfigSize 
)

◆ checkForImageAfterMapping()

bool PeLib::ImageLoader::checkForImageAfterMapping ( )
protected

◆ checkForSectionTablesWithinHeader()

bool PeLib::ImageLoader::checkForSectionTablesWithinHeader ( std::uint32_t  e_lfanew)
protected

◆ checkForValid32BitMachine()

bool PeLib::ImageLoader::checkForValid32BitMachine ( )
protected

◆ checkForValid64BitMachine()

bool PeLib::ImageLoader::checkForValid64BitMachine ( )
protected

◆ compareWithWindowsMappedImage()

void PeLib::ImageLoader::compareWithWindowsMappedImage ( PELIB_IMAGE_COMPARE ImageCompare,
void *  imageData,
std::uint32_t  imageSize 
)

◆ dumpImage()

uint32_t PeLib::ImageLoader::dumpImage ( const char *  fileName)

◆ enlargeLastSection()

void PeLib::ImageLoader::enlargeLastSection ( std::uint32_t  sectionSize)

◆ getAddressOfEntryPoint()

std::uint32_t PeLib::ImageLoader::getAddressOfEntryPoint ( ) const
inline

◆ getCharacteristics()

std::uint32_t PeLib::ImageLoader::getCharacteristics ( ) const
inline

◆ getChecksumFileOffset()

std::uint32_t PeLib::ImageLoader::getChecksumFileOffset ( ) const
inline

◆ getDataDirRva()

std::uint32_t PeLib::ImageLoader::getDataDirRva ( std::size_t  dataDirIndex) const
inline

◆ getDataDirSize()

std::uint32_t PeLib::ImageLoader::getDataDirSize ( std::size_t  dataDirIndex) const
inline

◆ getDosHeader()

const PELIB_IMAGE_DOS_HEADER& PeLib::ImageLoader::getDosHeader ( ) const
inline

◆ getFieldOffset()

uint32_t PeLib::ImageLoader::getFieldOffset ( PELIB_MEMBER_TYPE  field) const

◆ getFileAlignment()

std::uint32_t PeLib::ImageLoader::getFileAlignment ( ) const
inline

◆ getFileHeader()

const PELIB_IMAGE_FILE_HEADER& PeLib::ImageLoader::getFileHeader ( ) const
inline

◆ getFileOffsetFromRva()

uint32_t PeLib::ImageLoader::getFileOffsetFromRva ( std::uint32_t  rva) const

◆ getImageBase()

std::uint64_t PeLib::ImageLoader::getImageBase ( ) const
inline

◆ getImageBitability()

uint32_t PeLib::ImageLoader::getImageBitability ( ) const

◆ getImageProtection()

uint32_t PeLib::ImageLoader::getImageProtection ( std::uint32_t  characteristics) const

◆ getLoadedNumberOfSections()

std::uint32_t PeLib::ImageLoader::getLoadedNumberOfSections ( ) const
inline

◆ getMachine()

std::uint32_t PeLib::ImageLoader::getMachine ( ) const
inline

◆ getMagic()

std::uint32_t PeLib::ImageLoader::getMagic ( ) const
inline

◆ getMismatchOffset()

size_t PeLib::ImageLoader::getMismatchOffset ( void *  buffer1,
void *  buffer2,
std::uint32_t  rva,
std::size_t  length 
)

◆ getNtSignature()

std::uint32_t PeLib::ImageLoader::getNtSignature ( ) const
inline

◆ getNumberOfSections()

std::uint32_t PeLib::ImageLoader::getNumberOfSections ( ) const
inline

◆ getNumberOfSymbols()

std::uint32_t PeLib::ImageLoader::getNumberOfSymbols ( ) const
inline

◆ getOptionalHeader()

const PELIB_IMAGE_OPTIONAL_HEADER& PeLib::ImageLoader::getOptionalHeader ( ) const
inline

◆ getOrdinalMask()

std::uint64_t PeLib::ImageLoader::getOrdinalMask ( ) const
inline

◆ getPeHeaderOffset()

std::uint32_t PeLib::ImageLoader::getPeHeaderOffset ( ) const
inline

◆ getPointerSize()

uint32_t PeLib::ImageLoader::getPointerSize ( ) const

◆ getPointerToSymbolTable()

std::uint32_t PeLib::ImageLoader::getPointerToSymbolTable ( ) const
inline

◆ getRealNumberOfDataDirectories()

std::uint32_t PeLib::ImageLoader::getRealNumberOfDataDirectories ( ) const
inline

◆ getRealPointerToRawData()

uint32_t PeLib::ImageLoader::getRealPointerToRawData ( std::size_t  sectionIndex) const

◆ getSectionAlignment()

std::uint32_t PeLib::ImageLoader::getSectionAlignment ( ) const
inline

◆ getSectionHeader() [1/2]

PELIB_SECTION_HEADER* PeLib::ImageLoader::getSectionHeader ( std::size_t  sectionIndex)
inline

◆ getSectionHeader() [2/2]

const PELIB_SECTION_HEADER* PeLib::ImageLoader::getSectionHeader ( std::size_t  sectionIndex) const
inline

◆ getSectionIndexByRva()

size_t PeLib::ImageLoader::getSectionIndexByRva ( std::uint32_t  Rva) const

◆ getSecurityDirFileOffset()

std::uint32_t PeLib::ImageLoader::getSecurityDirFileOffset ( ) const
inline

◆ getSizeOfFile()

std::uint64_t PeLib::ImageLoader::getSizeOfFile ( ) const
inline

◆ getSizeOfHeaders()

std::uint32_t PeLib::ImageLoader::getSizeOfHeaders ( ) const
inline

◆ getSizeOfImage()

std::uint32_t PeLib::ImageLoader::getSizeOfImage ( ) const
inline

◆ getSizeOfImageAligned()

std::uint32_t PeLib::ImageLoader::getSizeOfImageAligned ( ) const
inline

◆ getVirtualAddressMasked()

std::uint64_t PeLib::ImageLoader::getVirtualAddressMasked ( std::uint32_t  rva)
inline

◆ isGoodMappedPage()

bool PeLib::ImageLoader::isGoodMappedPage ( std::uint32_t  rva)
protected

◆ isGoodPagePointer()

bool PeLib::ImageLoader::isGoodPagePointer ( PFN_VERIFY_ADDRESS  PfnVerifyAddress,
void *  pagePtr 
)
protected

◆ isImageLoadable()

bool PeLib::ImageLoader::isImageLoadable ( ) const
protected

◆ isImageMappedOk()

bool PeLib::ImageLoader::isImageMappedOk ( ) const
protected

◆ isLegacyImageArchitecture()

bool PeLib::ImageLoader::isLegacyImageArchitecture ( std::uint16_t  Machine)
protected

◆ isPrintableChar()

bool PeLib::ImageLoader::isPrintableChar ( int  ch)
inlineprotected

◆ isSectionHeaderPointerToRawData()

bool PeLib::ImageLoader::isSectionHeaderPointerToRawData ( uint32_t  rva)
protected

◆ isValidImageBlock()

bool PeLib::ImageLoader::isValidImageBlock ( std::uint32_t  Rva,
std::uint32_t  Size 
) const
protected

◆ isValidMachineForCodeIntegrifyCheck()

bool PeLib::ImageLoader::isValidMachineForCodeIntegrifyCheck ( std::uint32_t  Bits)
protected

◆ isZeroPage()

bool PeLib::ImageLoader::isZeroPage ( std::uint32_t  rva)
protected

◆ Load() [1/3]

int PeLib::ImageLoader::Load ( ByteBuffer fileData,
bool  loadHeadersOnly = false 
)

◆ Load() [2/3]

int PeLib::ImageLoader::Load ( const char *  fileName,
bool  loadHeadersOnly = false 
)

◆ Load() [3/3]

int PeLib::ImageLoader::Load ( std::istream &  fs,
std::streamoff  fileOffset = 0,
bool  loadHeadersOnly = false 
)

◆ loaderError()

PeLib::LoaderError PeLib::ImageLoader::loaderError ( ) const

◆ loadImageAsIs()

int PeLib::ImageLoader::loadImageAsIs ( ByteBuffer fileData)
protected

◆ makeValid()

void PeLib::ImageLoader::makeValid ( )

◆ processImageRelocation_IA64_IMM64()

bool PeLib::ImageLoader::processImageRelocation_IA64_IMM64 ( std::uint32_t  fixupAddress,
std::uint64_t  difference 
)
protected

◆ processImageRelocations()

bool PeLib::ImageLoader::processImageRelocations ( std::uint64_t  oldImageBase,
std::uint64_t  getImageBase,
std::uint32_t  VirtualAddress,
std::uint32_t  Size 
)
protected

◆ processSectionHeader()

void PeLib::ImageLoader::processSectionHeader ( PELIB_IMAGE_SECTION_HEADER pSectionHeader)
protected

◆ readFromPage()

void PeLib::ImageLoader::readFromPage ( PELIB_FILE_PAGE page,
void *  buffer,
size_t  offsetInPage,
size_t  bytesInPage 
)
staticprotected

◆ readImage()

uint32_t PeLib::ImageLoader::readImage ( void *  buffer,
std::uint32_t  rva,
std::uint32_t  bytesToRead 
)

◆ readPointer()

uint32_t PeLib::ImageLoader::readPointer ( std::uint32_t  rva,
std::uint64_t &  pointerValue 
)

◆ readString()

uint32_t PeLib::ImageLoader::readString ( std::string &  str,
std::uint32_t  rva,
std::uint32_t  maxLength = 65535 
)

◆ readStringRaw()

uint32_t PeLib::ImageLoader::readStringRaw ( ByteBuffer fileData,
std::string &  str,
std::size_t  offset,
std::size_t  maxLength = 65535,
bool  mustBePrintable = false,
bool  mustNotBeTooLong = false 
)

◆ readStringRc()

uint32_t PeLib::ImageLoader::readStringRc ( std::string &  str,
std::uint32_t  rva 
)

◆ readWriteImage()

uint32_t PeLib::ImageLoader::readWriteImage ( void *  buffer,
std::uint32_t  rva,
std::uint32_t  bytesToRead,
READWRITE  ReadWrite 
)
protected

◆ readWriteImageFile()

uint32_t PeLib::ImageLoader::readWriteImageFile ( void *  buffer,
std::uint32_t  rva,
std::uint32_t  bytesToRead,
bool  bReadOperation 
)
protected

◆ relocateImage()

bool PeLib::ImageLoader::relocateImage ( std::uint64_t  newImageBase)

◆ removeSection()

int PeLib::ImageLoader::removeSection ( std::size_t  sizeIncrement)

◆ Save() [1/2]

int PeLib::ImageLoader::Save ( const char *  fileName,
bool  saveHeadersOnly = false 
)

◆ Save() [2/2]

int PeLib::ImageLoader::Save ( std::ostream &  fs,
std::streamoff  fileOffset = 0,
bool  saveHeadersOnly = false 
)

◆ saveDosHeader()

int PeLib::ImageLoader::saveDosHeader ( std::ostream &  fs,
std::streamoff  fileOffset 
)
protected

◆ saveNtHeaders()

int PeLib::ImageLoader::saveNtHeaders ( std::ostream &  fs,
std::streamoff  fileOffset 
)
protected

◆ saveSectionHeaders()

int PeLib::ImageLoader::saveSectionHeaders ( std::ostream &  fs,
std::streamoff  fileOffset 
)
protected

◆ setAddressOfEntryPoint()

void PeLib::ImageLoader::setAddressOfEntryPoint ( std::uint32_t  addressOfEntryPoint)

◆ setCharacteristics()

void PeLib::ImageLoader::setCharacteristics ( std::uint32_t  characteristics)

◆ setDataDirectory()

void PeLib::ImageLoader::setDataDirectory ( std::uint32_t  entryIndex,
std::uint32_t  VirtualAddress,
std::uint32_t  Size = UINT32_MAX 
)

◆ setLoaderError()

int PeLib::ImageLoader::setLoaderError ( PeLib::LoaderError  ldrErr)

◆ setPeHeaderOffset()

void PeLib::ImageLoader::setPeHeaderOffset ( std::uint32_t  new_e_lfanew)
inline

◆ setPointerToSymbolTable()

void PeLib::ImageLoader::setPointerToSymbolTable ( std::uint32_t  pointerToSymbolTable)

◆ setSectionCharacteristics()

void PeLib::ImageLoader::setSectionCharacteristics ( std::size_t  sectionIndex,
std::uint32_t  Characteristics 
)

◆ setSectionName()

void PeLib::ImageLoader::setSectionName ( std::size_t  sectionIndex,
const char *  newName 
)

◆ setSectionRawDataRange()

void PeLib::ImageLoader::setSectionRawDataRange ( std::size_t  sectionIndex,
std::uint32_t  PointerToRawData,
std::uint32_t  SizeOfRawData = UINT32_MAX 
)

◆ setSectionVirtualRange()

void PeLib::ImageLoader::setSectionVirtualRange ( std::size_t  sectionIndex,
std::uint32_t  VirtualAddress,
std::uint32_t  VirtualSize = UINT32_MAX 
)

◆ setSizeOfCode()

void PeLib::ImageLoader::setSizeOfCode ( std::uint32_t  sizeOfCode,
std::uint32_t  baseOfCode = UINT32_MAX 
)

◆ signExtend32To64()

static std::uint64_t PeLib::ImageLoader::signExtend32To64 ( std::uint32_t  value32)
inlinestaticprotected

◆ splitSection()

int PeLib::ImageLoader::splitSection ( std::size_t  sectionIndex,
const std::string &  prevSectName,
const std::string &  nextSectName,
std::uint32_t  splitOffset 
)

◆ stringLength()

uint32_t PeLib::ImageLoader::stringLength ( std::uint32_t  rva,
std::uint32_t  maxLength = 65535 
) const

◆ vaToRva()

uint32_t PeLib::ImageLoader::vaToRva ( std::uint64_t  VirtualAddress) const

◆ verifyDosHeader() [1/2]

int PeLib::ImageLoader::verifyDosHeader ( PELIB_IMAGE_DOS_HEADER hdr,
std::size_t  fileSize 
)
protected

◆ verifyDosHeader() [2/2]

int PeLib::ImageLoader::verifyDosHeader ( std::istream &  fs,
std::streamoff  fileOffset,
std::size_t  fileSize 
)
protected

◆ writeImage()

uint32_t PeLib::ImageLoader::writeImage ( void *  buffer,
std::uint32_t  rva,
std::uint32_t  bytesToRead 
)

◆ writeNewImageBase()

void PeLib::ImageLoader::writeNewImageBase ( std::uint64_t  newImageBase)
protected

◆ writeToPage()

void PeLib::ImageLoader::writeToPage ( PELIB_FILE_PAGE page,
void *  buffer,
size_t  offsetInPage,
size_t  bytesInPage 
)
staticprotected

Member Data Documentation

◆ architectureSpecificChecks

bool PeLib::ImageLoader::architectureSpecificChecks
protected

◆ checkImagePostMapping

bool PeLib::ImageLoader::checkImagePostMapping
protected

◆ checkNonLegacyDllCharacteristics

bool PeLib::ImageLoader::checkNonLegacyDllCharacteristics
protected

◆ checkSumFileOffset

std::uint32_t PeLib::ImageLoader::checkSumFileOffset
protected

◆ dosHeader

PELIB_IMAGE_DOS_HEADER PeLib::ImageLoader::dosHeader
protected

◆ fileHeader

PELIB_IMAGE_FILE_HEADER PeLib::ImageLoader::fileHeader
protected

◆ forceIntegrityCheckCertificate

bool PeLib::ImageLoader::forceIntegrityCheckCertificate
protected

◆ forceIntegrityCheckEnabled

bool PeLib::ImageLoader::forceIntegrityCheckEnabled
protected

◆ headerSizeCheck

bool PeLib::ImageLoader::headerSizeCheck
protected

◆ ImageProtectionArray

uint8_t PeLib::ImageLoader::ImageProtectionArray
staticprotected
Initial value:
=
{
}
@ PELIB_PAGE_WRITECOPY
Definition: PeLibAux.h:191
@ PELIB_PAGE_EXECUTE_READ
Definition: PeLibAux.h:193
@ PELIB_PAGE_EXECUTE
Definition: PeLibAux.h:192
@ PELIB_PAGE_NOACCESS
Definition: PeLibAux.h:188
@ PELIB_PAGE_READWRITE
Definition: PeLibAux.h:190
@ PELIB_PAGE_EXECUTE_READWRITE
Definition: PeLibAux.h:194
@ PELIB_PAGE_EXECUTE_WRITECOPY
Definition: PeLibAux.h:195
@ PELIB_PAGE_READONLY
Definition: PeLibAux.h:189

◆ is64BitWindows

bool PeLib::ImageLoader::is64BitWindows
protected

◆ ldrError

LoaderError PeLib::ImageLoader::ldrError
protected

◆ loadArm64Images

bool PeLib::ImageLoader::loadArm64Images
protected

◆ loadArmImages

bool PeLib::ImageLoader::loadArmImages
protected

◆ loadItaniumImages

bool PeLib::ImageLoader::loadItaniumImages
protected

◆ maxSectionCount

std::uint32_t PeLib::ImageLoader::maxSectionCount
protected

◆ ntHeadersSizeCheck

bool PeLib::ImageLoader::ntHeadersSizeCheck
protected

◆ ntSignature

std::uint32_t PeLib::ImageLoader::ntSignature
protected

◆ optionalHeader

PELIB_IMAGE_OPTIONAL_HEADER PeLib::ImageLoader::optionalHeader
protected

◆ pages

std::vector<PELIB_FILE_PAGE> PeLib::ImageLoader::pages
protected

◆ rawFileData

ByteBuffer PeLib::ImageLoader::rawFileData
protected

◆ realNumberOfRvaAndSizes

std::uint32_t PeLib::ImageLoader::realNumberOfRvaAndSizes
protected

◆ savedFileSize

std::uint64_t PeLib::ImageLoader::savedFileSize
protected

◆ sections

std::vector<PELIB_SECTION_HEADER> PeLib::ImageLoader::sections
protected

◆ securityDirFileOffset

std::uint32_t PeLib::ImageLoader::securityDirFileOffset
protected

◆ sizeofImageMustMatch

bool PeLib::ImageLoader::sizeofImageMustMatch
protected

◆ ssiImageAlignment32

std::uint32_t PeLib::ImageLoader::ssiImageAlignment32
protected

◆ windowsBuildNumber

std::uint32_t PeLib::ImageLoader::windowsBuildNumber
protected

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