Skip to content

Base Method

AFP edited this page Apr 1, 2023 · 2 revisions

There is some base method to working with PE files:

Load File

there is some method you can use to load a PE file. first of all using file path, second method is using a vector of byte.

#include <iostream>
#include <POEX.h>  // include POEX header

int main()
{
    // loading as file path
    auto pe1 = POEX::PE(L"1.exe");

    // loading as vector of byte
    std::vector<byte> data  {}; // you need to fill it by data in any method you can.
    auto pe2 = POEX::PE(data);

    // Other stuff here
    return 0;
}

Is 64 Bit file

#include <iostream>
#include <POEX.h> // include POEX header

int main()
{
    auto pe = POEX::PE(L"1.exe");

    // Checking file Type
    auto is64Bit = pe.Is64Bit();

    // other stuff in here

    return 0;
}

Is 32 Bit file

#include <iostream>
#include <POEX.h> // include POEX header

int main()
{
    auto pe = POEX::PE(L"1.exe");

    // Checking file Type
    auto is32Bit = pe.Is32Bit();

    // other stuff in here

    return 0;
}

Is DLL file

#include <iostream>
#include <POEX.h> // include POEX header

int main()
{
    auto pe = POEX::PE(L"1.exe");

    // Checking file Type
    auto isDll = pe.IsDll();

    // other stuff in here

    return 0;
}

Is Exe file

#include <iostream>
#include <POEX.h> // include POEX header

int main()
{
    auto pe = POEX::PE(L"1.exe");

    // Checking file Type
    auto isExe= pe.Exe();

    // other stuff in here

    return 0;
}

Saving to file

using SaveFile() method, save changing on current base file.

#include <iostream>
#include <POEX.h> // include POEX header

int main()
{
    auto pe = POEX::PE(L"1.exe");

    // other stuff in here

    // Saving to existing file
    pe.SaveFile();

    // other stuff in here

    return 0;
}

Saving to another file

using SaveFile(filepath) method, save changing on new file.

#include <iostream>
#include <POEX.h> // include POEX header

int main()
{
    auto pe = POEX::PE(L"1.exe");

    // other stuff in here

    // Saving to another file
    pe.SaveFile(L"2.exe");

    // other stuff in here

    return 0;
}

Clone this wiki locally