libPeConv
A library to load, manipulate, dump PE files.
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
61 std::string libName;
62 std::string funcName;
65
66 //default constructor:
68
69 ExportedFunc(const ExportedFunc& other);
70 ExportedFunc(std::string libName, std::string funcName, DWORD funcOrdinal);
71 ExportedFunc(std::string libName, DWORD funcOrdinal);
72 ExportedFunc(const std::string &forwarderName);
73
80 bool operator < (const ExportedFunc& other) const
81 {
82 //if only one function is named, give the preference to the named one:
83 const size_t thisNameLen = this->funcName.length();
84 const size_t otherNameLen = other.funcName.length();
85 if (thisNameLen == 0 && otherNameLen > 0) {
86 return false;
87 }
88 if (thisNameLen > 0 && otherNameLen == 0) {
89 return true;
90 }
91 //select by shorter lib name:
92 int cmp = libName.compare(other.libName);
93 if (cmp != 0) {
94 return cmp < 0;
95 }
96 if (thisNameLen == 0 || otherNameLen == 0) {
97 return this->funcOrdinal < other.funcOrdinal;
98 }
99 if (thisNameLen != otherNameLen) {
100 return thisNameLen < otherNameLen;
101 }
102 cmp = funcName.compare(other.funcName);
103 return cmp < 0;
104 }
105
109 std::string toString() const;
110
114 std::string nameToString() const;
115
116 bool isValid() const
117 {
118 return (funcName != "" || funcOrdinal != -1);
119 }
120 };
121
122}; //namespace peconv
123
bool operator<(const ExportedFunc &other) const
Definition: exported_func.h:80
std::string funcName
Definition: exported_func.h:62
bool isValid() const
std::string nameToString() const
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)