libPeConv
A library to load, manipulate, dump PE files.
Loading...
Searching...
No Matches
function_resolver.cpp
Go to the documentation of this file.
2
3#include <iostream>
4
5FARPROC peconv::default_func_resolver::resolve_func(LPCSTR lib_name, LPCSTR func_name)
6{
7 HMODULE libBasePtr = LoadLibraryA(lib_name);
8 if (libBasePtr == NULL) {
9 std::cerr << "Could not load the library: " << lib_name << std::endl;
10 return NULL;
11 }
12 FARPROC hProc = GetProcAddress(libBasePtr, func_name);
13 if (hProc == NULL) {
14 ULONGLONG func_val = (ULONGLONG)func_name;
15 //is only the first WORD filled?
16 bool is_ord = (func_val & (0x0FFFF)) == func_val;
17 std::cerr << "Could not load the function: " << lib_name << ".";
18 if (is_ord) {
19 std::cerr << std::hex << "0x" << func_val;
20 }
21 else {
22 std::cerr << func_name;
23 }
24 std::cerr << std::endl;
25 return NULL;
26 }
27 return hProc;
28}
virtual FARPROC resolve_func(LPCSTR lib_name, LPCSTR func_name)
Definitions of basic Imports Resolver classes. They can be used for filling imports when the PE is lo...