-
Notifications
You must be signed in to change notification settings - Fork 0
Image Base Relocation Directory
AFP edited this page Apr 1, 2023
·
1 revision
after initialize the PE class you can get access the Image Base Relocation Directory structure by calling GetImageBaseRelocationDirectory() method. by calling this function, you get the object of ImageBaseRelocationDirectory class, so you can retrieve the fields, change or modify them.
#include <iostream>
#include <POEX.h> // include POEX header
int main()
{
auto pe = POEX::PE(L"1.exe");
// Access to Image Base Relocation Directory
auto baseRelDirectory = pe.GetImageBaseRelocationDirectory();
// other stuff in here
return 0;
}With calling GetImageBaseRelocationDirectory method, you can access the structure and method in bellow:
/// <summary>
/// RVA of the relocation block.
/// </summary>
/// <returns>RVA</returns>
auto VirtualAddress() const -> unsigned int;
/// <summary>
/// RVA of the relocation block.
/// </summary>
/// <param name="va">RVA</param>
/// <returns></returns>
auto VirtualAddress(const unsigned int& va) -> void;
/// <summary>
/// SizeOfBlock-8 indicates how many TypeOffsets follow the SizeOfBlock.
/// </summary>
/// <returns>length</returns>
auto SizeOfBlock() const -> unsigned int;
/// <summary>
/// SizeOfBlock-8 indicates how many TypeOffsets follow the SizeOfBlock.
/// </summary>
/// <param name="len">length</param>
/// <returns></returns>
auto SizeOfBlock(const unsigned int& len) -> void;
auto TypeOffsets() -> std::vector<std::unique_ptr<TypeOffset>>;By calling TypeOffsets method you can access to TypeOffsets structure:
/// <summary>
/// The type is described in the 4 lower bits of the TypeOffset word.
/// </summary>
/// <returns>type</returns>
auto Type() const->std::string;
/// <summary>
/// The offset is described in the 12 higher bits of the TypeOffset word.
/// </summary>
/// <returns>offset</returns>
auto Offset() const->unsigned short;