14 BYTE*
load_no_sec_pe(BYTE* dllRawData,
size_t r_size, OUT
size_t &v_size,
bool executable)
16 ULONGLONG desired_base = 0;
22 DWORD protect = (executable) ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE;
27 memcpy(mappedPE, dllRawData, r_size);
42 ULONGLONG desired_base = NULL;
49 BYTE *mappedDLL =
pe_raw_to_virtual(dllRawData, r_size, v_size, executable, desired_base);
52 if (relocate && !
relocate_module(mappedDLL, v_size, (ULONGLONG)mappedDLL)) {
54 printf(
"Could not relocate the module!");
59 printf(
"Could not allocate memory at the desired base!\n");
67 BYTE *dllRawData =
load_file(filename, r_size);
70 std::cerr <<
"Cannot load the file: " << filename << std::endl;
74 BYTE* mappedPE =
load_pe_module(dllRawData, r_size, v_size, executable, relocate);
81 BYTE* loaded_pe =
load_pe_module(dllRawData, r_size, v_size,
true,
true);
83 printf(
"[-] Loading failed!\n");
87 printf(
"Loaded at: %p\n", loaded_pe);
91 printf(
"[-] Loading imports failed!");
97 printf(
"[-] PE doesn't have a valid Import Table!\n");
106 printf(
"Module: %s\n", my_path);
110 printf(
"Loading failed!\n");
114 printf(
"Loaded at: %p\n", loaded_pe);
117 printf(
"[-] Loading imports failed!");
Definitions of the used buffer types. Functions for their allocation and deallocation.
Searching specific functions in PE's Exports Table.
Definitions of basic Imports Resolver classes. They can be used for filling imports when the PE is lo...
Parsing and filling the Import Table.
bool has_relocations(IN const BYTE *pe_buffer)
bool has_valid_import_table(const PBYTE modulePtr, size_t moduleSize)
BYTE * load_no_sec_pe(BYTE *dllRawData, size_t r_size, OUT size_t &v_size, bool executable)
ULONGLONG get_image_base(IN const BYTE *pe_buffer)
BYTE * load_pe_executable(BYTE *dllRawData, size_t r_size, OUT size_t &v_size, t_function_resolver *import_resolver=NULL)
BYTE * load_pe_module(BYTE *dllRawData, size_t r_size, OUT size_t &v_size, bool executable, bool relocate)
DWORD get_image_size(IN const BYTE *payload)
bool free_pe_buffer(ALIGNED_BUF buffer, size_t buffer_size=0)
ALIGNED_BUF alloc_pe_buffer(size_t buffer_size, DWORD protect, ULONGLONG desired_base=NULL)
peconv::ALIGNED_BUF load_file(IN const char *filename, OUT size_t &r_size)
BYTE * pe_raw_to_virtual(IN const BYTE *rawPeBuffer, IN size_t rawPeSize, OUT size_t &outputSize, IN OPTIONAL bool executable=true, IN OPTIONAL ULONGLONG desired_base=0)
size_t get_sections_count(IN const BYTE *buffer, IN const size_t buffer_size)
bool relocate_module(IN BYTE *modulePtr, IN SIZE_T moduleSize, IN ULONGLONG newBase, IN ULONGLONG oldBase=0)
BYTE * get_nt_hdrs(IN const BYTE *pe_buffer, IN OPTIONAL size_t buffer_size=0)
bool load_imports(BYTE *modulePtr, t_function_resolver *func_resolver=nullptr)
Loading PE from a file with the help of the custom loader.
Operating on PE file's relocations table.