

A library to load and manipulate PE files.
Objectives
The goal of libPEConv was to create a "swiss army knife" for custom loading of PE files. It gathers various helper functions that you can quickly integrate in your own loader. For example: remapping sections, applying relocations, loading imports, parsing resources.
Not only it allows for loading PE files, but also for customizing of some steps, i.e. IAT hooking (by providing custom IAT resolvers), and functions redirection. Yet, it is NOT focused on inline hooking and should not be confused with libraries such as MS Detours or MinHook.
LibPeConv can be used for creating PE binders, as it allows to load a PE directly from the resource, and integrate it as if it was a local code.
As well it can help you in dumping PEs from the memory, and rebuilding their IATs.
WARNING: applications that use MUI are not supported.
Basic example
The simplest usecase: use libPeConv to manually load and run an EXE of you choice.
#include <Windows.h>
#include <iostream>
int main(int argc, char *argv[])
{
if (argc < 2) {
std::cout << "Args: <path to the exe>" << std::endl;
return 0;
}
LPCSTR pe_path = argv[1];
size_t v_size = 0;
#ifdef LOAD_FROM_PATH
#else
size_t bufsize = 0;
#endif
if (!my_pe) {
return -1;
}
const ULONGLONG load_base = (ULONGLONG)my_pe;
if (!ep_rva) {
return -2;
}
ULONG_PTR ep_va = ep_rva + (ULONG_PTR) my_pe;
int (*new_main)() = (int(*)())ep_va;
return new_main();
}
size_t run_tls_callbacks(IN PVOID modulePtr, IN size_t moduleSize=0, IN DWORD dwReason=DLL_PROCESS_ATTACH)
DWORD get_entry_point_rva(IN const BYTE *pe_buffer)
bool load_delayed_imports(BYTE *modulePtr, const ULONGLONG moduleBase, t_function_resolver *func_resolver=nullptr)
bool set_main_module_in_peb(HMODULE hModule)
peconv::UNALIGNED_BUF load_file(IN LPCTSTR filename, OUT size_t &r_size)
BYTE * load_pe_executable(BYTE *payload_raw, size_t r_size, OUT size_t &v_size, t_function_resolver *import_resolver=nullptr, ULONG_PTR desired_base=0)
Master include for LibPEConv.
See also: https://github.com/hasherezade/libpeconv_tpl/blob/master/project_template/main.cpp
Read more