libPeConv
A library to load, manipulate, dump PE files.
Loading...
Searching...
No Matches
fix_imports.h
Go to the documentation of this file.
1
6#pragma once
7
8#include <windows.h>
9
10#include <string>
11
12#include <set>
13#include <map>
14
15#include <iterator>
16
17#include "pe_hdrs_helper.h"
18#include "exports_lookup.h"
19#include "exports_mapper.h"
20
21#define MIN_DLL_LEN 5
22
23namespace peconv {
24
29 {
30 public:
33
34 /*
35 Number of stored records
36 */
37 size_t count() { return thunkToAddr.size(); }
38
39 void insert(DWORD thunkRVA, ULONGLONG searchedAddr);
40
41 std::map<DWORD, ULONGLONG> thunkToAddr; //addresses of not recovered functions with their thunks (call_via)
42 };
43
47 bool fix_imports(IN OUT PVOID modulePtr, IN size_t moduleSize, IN const peconv::ExportsMapper& exportsMap, OUT OPTIONAL peconv::ImpsNotCovered* notCovered);
48
53 {
54 public:
60 ImportedDllCoverage(std::set<ULONGLONG>& _addresses, const peconv::ExportsMapper& _exportsMap)
61 : addresses(_addresses), exportsMap(_exportsMap)
62 {
63 }
64
69 bool findCoveringDll();
70
79 size_t mapAddressesToFunctions(const std::string &_mappedDllName);
80
85 bool isMappingComplete() { return (addresses.size() == addrToFunc.size()) ? true : false; }
86
90 std::map<ULONGLONG, std::set<ExportedFunc>> addrToFunc;
91
95 std::set<ULONGLONG> notFound;
96
100 std::string dllName;
101
102 protected:
106 std::string mappedDllName;
107
112 std::set<ULONGLONG> &addresses;
113
118 };
119}
ImportedDllCoverage(std::set< ULONGLONG > &_addresses, const peconv::ExportsMapper &_exportsMap)
Definition fix_imports.h:60
const peconv::ExportsMapper & exportsMap
size_t mapAddressesToFunctions(const std::string &_mappedDllName)
std::set< ULONGLONG > notFound
Definition fix_imports.h:95
std::set< ULONGLONG > & addresses
std::map< ULONGLONG, std::set< ExportedFunc > > addrToFunc
Definition fix_imports.h:90
void insert(DWORD thunkRVA, ULONGLONG searchedAddr)
std::map< DWORD, ULONGLONG > thunkToAddr
Definition fix_imports.h:41
Searching specific functions in PE's Exports Table.
A definition of ExportsMapper class. Creates a lookup of all the exported functions from the supplied...
bool fix_imports(IN OUT PVOID modulePtr, IN size_t moduleSize, IN const peconv::ExportsMapper &exportsMap, OUT OPTIONAL peconv::ImpsNotCovered *notCovered)
Wrappers over various fields in the PE header. Read, write, parse PE headers.