libPeConv
A library to load, manipulate, dump PE files.
Loading...
Searching...
No Matches
exported_func.h
Go to the documentation of this file.
1
6#pragma once
7
8#include <windows.h>
9#include <string>
10#include <algorithm>
11#include <set>
12
13namespace peconv {
14
18 size_t forwarder_name_len(BYTE* fPtr);
19
23 std::string get_dll_shortname(const std::string& str);
24
28 std::string get_func_name(const std::string& str);
29
33 std::string ordinal_to_string(DWORD func_ordinal);
34
38 bool is_ordinal_string(const std::string& str);
39
43 DWORD ordinal_string_to_val(const std::string& str);
44
48 std::string format_dll_func(const std::string& str);
49
54 {
55 public:
59 static std::string formatName(std::string name);
60
62 static bool isTheSameFuncName(const peconv::ExportedFunc& func1, const peconv::ExportedFunc& func2);
63
65 static bool isTheSameDllName(const peconv::ExportedFunc& func1, const peconv::ExportedFunc& func2);
66
68 static bool isTheSameFunc(const peconv::ExportedFunc& func1, const peconv::ExportedFunc& func2);
69
70 std::string libName;
71 std::string funcName;
74
75 //default constructor:
77
78 ExportedFunc(const ExportedFunc& other);
79 ExportedFunc(std::string libName, std::string funcName, DWORD funcOrdinal);
80 ExportedFunc(std::string libName, DWORD funcOrdinal);
81 ExportedFunc(const std::string &forwarderName);
82
89 bool operator < (const ExportedFunc& other) const
90 {
91 //if only one function is named, give the preference to the named one:
92 const size_t thisNameLen = this->funcName.length();
93 const size_t otherNameLen = other.funcName.length();
94 if (thisNameLen == 0 && otherNameLen > 0) {
95 return false;
96 }
97 if (thisNameLen > 0 && otherNameLen == 0) {
98 return true;
99 }
100 //select by shorter lib name:
101 int cmp = libName.compare(other.libName);
102 if (cmp != 0) {
103 return cmp < 0;
104 }
105 if (thisNameLen == 0 || otherNameLen == 0) {
106 return this->funcOrdinal < other.funcOrdinal;
107 }
108 if (thisNameLen != otherNameLen) {
109 return thisNameLen < otherNameLen;
110 }
111 cmp = funcName.compare(other.funcName);
112 return cmp < 0;
113 }
114
118 std::string toString() const;
119
123 std::string nameToString() const;
124
125 bool isValid() const
126 {
127 return (funcName != "" || funcOrdinal != -1);
128 }
129 };
130
131}; //namespace peconv
132
bool operator<(const ExportedFunc &other) const
static bool isTheSameFunc(const peconv::ExportedFunc &func1, const peconv::ExportedFunc &func2)
Compares functions' names. If function is defined by an ordinal, compares ordinals....
std::string nameToString() const
static bool isTheSameDllName(const peconv::ExportedFunc &func1, const peconv::ExportedFunc &func2)
Compares functions' DLL names.
static bool isTheSameFuncName(const peconv::ExportedFunc &func1, const peconv::ExportedFunc &func2)
Compares functions' names. If function is defined by an ordinal, compares ordinals....
static std::string formatName(std::string name)
std::string toString() const
bool is_ordinal_string(const std::string &str)
std::string ordinal_to_string(DWORD func_ordinal)
size_t forwarder_name_len(BYTE *fPtr)
std::string get_func_name(const std::string &str)
std::string format_dll_func(const std::string &str)
DWORD ordinal_string_to_val(const std::string &str)
std::string get_dll_shortname(const std::string &str)