diff options
Diffstat (limited to 'utils/zenutils/libraries/pelib-0.9/pelib/ExportDirectory.cpp')
-rw-r--r--[-rwxr-xr-x] | utils/zenutils/libraries/pelib-0.9/pelib/ExportDirectory.cpp | 1384 |
1 files changed, 692 insertions, 692 deletions
diff --git a/utils/zenutils/libraries/pelib-0.9/pelib/ExportDirectory.cpp b/utils/zenutils/libraries/pelib-0.9/pelib/ExportDirectory.cpp index aa9c28a50f..83c4b4e69d 100755..100644 --- a/utils/zenutils/libraries/pelib-0.9/pelib/ExportDirectory.cpp +++ b/utils/zenutils/libraries/pelib-0.9/pelib/ExportDirectory.cpp | |||
@@ -1,692 +1,692 @@ | |||
1 | /* | 1 | /* |
2 | * ExportDirectory.cpp - Part of the PeLib library. | 2 | * ExportDirectory.cpp - Part of the PeLib library. |
3 | * | 3 | * |
4 | * Copyright (c) 2004 - 2005 Sebastian Porst (webmaster@the-interweb.com) | 4 | * Copyright (c) 2004 - 2005 Sebastian Porst (webmaster@the-interweb.com) |
5 | * All rights reserved. | 5 | * All rights reserved. |
6 | * | 6 | * |
7 | * This software is licensed under the zlib/libpng License. | 7 | * This software is licensed under the zlib/libpng License. |
8 | * For more details see http://www.opensource.org/licenses/zlib-license.php | 8 | * For more details see http://www.opensource.org/licenses/zlib-license.php |
9 | * or the license information file (license.htm) in the root directory | 9 | * or the license information file (license.htm) in the root directory |
10 | * of PeLib. | 10 | * of PeLib. |
11 | */ | 11 | */ |
12 | 12 | ||
13 | //#ifdef false | 13 | //#ifdef false |
14 | 14 | ||
15 | #include "PeLibInc.h" | 15 | #include "PeLibInc.h" |
16 | #include "ExportDirectory.h" | 16 | #include "ExportDirectory.h" |
17 | 17 | ||
18 | namespace PeLib | 18 | namespace PeLib |
19 | { | 19 | { |
20 | /** | 20 | /** |
21 | * @param strFuncname Name of the function. | 21 | * @param strFuncname Name of the function. |
22 | * @param dwFuncAddr RVA of the function. | 22 | * @param dwFuncAddr RVA of the function. |
23 | **/ | 23 | **/ |
24 | void ExportDirectory::addFunction(const std::string& strFuncname, dword dwFuncAddr) | 24 | void ExportDirectory::addFunction(const std::string& strFuncname, dword dwFuncAddr) |
25 | { | 25 | { |
26 | PELIB_EXP_FUNC_INFORMATION efiCurr; | 26 | PELIB_EXP_FUNC_INFORMATION efiCurr; |
27 | efiCurr.funcname = strFuncname; | 27 | efiCurr.funcname = strFuncname; |
28 | efiCurr.addroffunc = dwFuncAddr; | 28 | efiCurr.addroffunc = dwFuncAddr; |
29 | m_ied.functions.push_back(efiCurr); | 29 | m_ied.functions.push_back(efiCurr); |
30 | } | 30 | } |
31 | 31 | ||
32 | void ExportDirectory::removeFunction(unsigned int index) | 32 | void ExportDirectory::removeFunction(unsigned int index) |
33 | { | 33 | { |
34 | m_ied.functions.erase(m_ied.functions.begin() + index); | 34 | m_ied.functions.erase(m_ied.functions.begin() + index); |
35 | } | 35 | } |
36 | 36 | ||
37 | void ExportDirectory::clear() | 37 | void ExportDirectory::clear() |
38 | { | 38 | { |
39 | m_ied.functions.clear(); | 39 | m_ied.functions.clear(); |
40 | } | 40 | } |
41 | 41 | ||
42 | unsigned int ExportDirectory::calcNumberOfFunctions() const | 42 | unsigned int ExportDirectory::calcNumberOfFunctions() const |
43 | { | 43 | { |
44 | return static_cast<unsigned int>(m_ied.functions.size()); | 44 | return static_cast<unsigned int>(m_ied.functions.size()); |
45 | } | 45 | } |
46 | 46 | ||
47 | /** | 47 | /** |
48 | * Identifies an exported function through it's name. | 48 | * Identifies an exported function through it's name. |
49 | * @param strFunctionName Name of the function | 49 | * @param strFunctionName Name of the function |
50 | * @return Number which identifies the functions. | 50 | * @return Number which identifies the functions. |
51 | **/ | 51 | **/ |
52 | int ExportDirectory::getFunctionIndex(const std::string& strFunctionName) const | 52 | int ExportDirectory::getFunctionIndex(const std::string& strFunctionName) const |
53 | { | 53 | { |
54 | std::vector<PELIB_EXP_FUNC_INFORMATION>::const_iterator Iter = std::find_if(m_ied.functions.begin(), m_ied.functions.end(), std::bind2nd(std::mem_fun_ref(&PELIB_EXP_FUNC_INFORMATION::equal), strFunctionName)); | 54 | std::vector<PELIB_EXP_FUNC_INFORMATION>::const_iterator Iter = std::find_if(m_ied.functions.begin(), m_ied.functions.end(), std::bind2nd(std::mem_fun_ref(&PELIB_EXP_FUNC_INFORMATION::equal), strFunctionName)); |
55 | 55 | ||
56 | if (Iter == m_ied.functions.end()) | 56 | if (Iter == m_ied.functions.end()) |
57 | { | 57 | { |
58 | // throw Exceptions::InvalidName(ExportDirectoryId, __LINE__); | 58 | // throw Exceptions::InvalidName(ExportDirectoryId, __LINE__); |
59 | return -1; | 59 | return -1; |
60 | } | 60 | } |
61 | 61 | ||
62 | return static_cast<int>(std::distance(m_ied.functions.begin(), Iter)); | 62 | return static_cast<int>(std::distance(m_ied.functions.begin(), Iter)); |
63 | } | 63 | } |
64 | 64 | ||
65 | /** | 65 | /** |
66 | * @param strFilename Name of the file. | 66 | * @param strFilename Name of the file. |
67 | * @param uiOffset File offset of the export directory. | 67 | * @param uiOffset File offset of the export directory. |
68 | * @param uiSize Size of the export directory. | 68 | * @param uiSize Size of the export directory. |
69 | * @param pehHeader A valid PE header which is necessary because some RVA calculations need to be done. | 69 | * @param pehHeader A valid PE header which is necessary because some RVA calculations need to be done. |
70 | * \todo: Proper use of InputBuffer | 70 | * \todo: Proper use of InputBuffer |
71 | **/ | 71 | **/ |
72 | int ExportDirectory::read(const std::string& strFilename, unsigned int uiOffset, unsigned int uiSize, const PeHeader& pehHeader) | 72 | int ExportDirectory::read(const std::string& strFilename, unsigned int uiOffset, unsigned int uiSize, const PeHeader& pehHeader) |
73 | { | 73 | { |
74 | std::ifstream ifFile(strFilename.c_str(), std::ios::binary); | 74 | std::ifstream ifFile(strFilename.c_str(), std::ios::binary); |
75 | 75 | ||
76 | if (!ifFile) | 76 | if (!ifFile) |
77 | { | 77 | { |
78 | return ERROR_OPENING_FILE; | 78 | return ERROR_OPENING_FILE; |
79 | } | 79 | } |
80 | 80 | ||
81 | unsigned int filesize = fileSize(ifFile); | 81 | unsigned int filesize = fileSize(ifFile); |
82 | 82 | ||
83 | if (filesize < uiOffset + uiSize) | 83 | if (filesize < uiOffset + uiSize) |
84 | { | 84 | { |
85 | return ERROR_INVALID_FILE; | 85 | return ERROR_INVALID_FILE; |
86 | } | 86 | } |
87 | 87 | ||
88 | ifFile.seekg(uiOffset, std::ios::beg); | 88 | ifFile.seekg(uiOffset, std::ios::beg); |
89 | 89 | ||
90 | PELIB_IMAGE_EXP_DIRECTORY iedCurr; | 90 | PELIB_IMAGE_EXP_DIRECTORY iedCurr; |
91 | 91 | ||
92 | std::vector<unsigned char> vExportdirectory(uiSize); | 92 | std::vector<unsigned char> vExportdirectory(uiSize); |
93 | ifFile.read(reinterpret_cast<char*>(&vExportdirectory[0]), uiSize); | 93 | ifFile.read(reinterpret_cast<char*>(&vExportdirectory[0]), uiSize); |
94 | 94 | ||
95 | InputBuffer inpBuffer(vExportdirectory); | 95 | InputBuffer inpBuffer(vExportdirectory); |
96 | 96 | ||
97 | inpBuffer >> iedCurr.ied.Characteristics; | 97 | inpBuffer >> iedCurr.ied.Characteristics; |
98 | inpBuffer >> iedCurr.ied.TimeDateStamp; | 98 | inpBuffer >> iedCurr.ied.TimeDateStamp; |
99 | inpBuffer >> iedCurr.ied.MajorVersion; | 99 | inpBuffer >> iedCurr.ied.MajorVersion; |
100 | inpBuffer >> iedCurr.ied.MinorVersion; | 100 | inpBuffer >> iedCurr.ied.MinorVersion; |
101 | inpBuffer >> iedCurr.ied.Name; | 101 | inpBuffer >> iedCurr.ied.Name; |
102 | inpBuffer >> iedCurr.ied.Base; | 102 | inpBuffer >> iedCurr.ied.Base; |
103 | inpBuffer >> iedCurr.ied.NumberOfFunctions; | 103 | inpBuffer >> iedCurr.ied.NumberOfFunctions; |
104 | inpBuffer >> iedCurr.ied.NumberOfNames; | 104 | inpBuffer >> iedCurr.ied.NumberOfNames; |
105 | inpBuffer >> iedCurr.ied.AddressOfFunctions; | 105 | inpBuffer >> iedCurr.ied.AddressOfFunctions; |
106 | inpBuffer >> iedCurr.ied.AddressOfNames; | 106 | inpBuffer >> iedCurr.ied.AddressOfNames; |
107 | inpBuffer >> iedCurr.ied.AddressOfNameOrdinals; | 107 | inpBuffer >> iedCurr.ied.AddressOfNameOrdinals; |
108 | 108 | ||
109 | if (const PeHeader32* p32 = dynamic_cast<const PeHeader32*>(&pehHeader)) | 109 | if (const PeHeader32* p32 = dynamic_cast<const PeHeader32*>(&pehHeader)) |
110 | { | 110 | { |
111 | unsigned int offset = p32->rvaToOffset(iedCurr.ied.Name); | 111 | unsigned int offset = p32->rvaToOffset(iedCurr.ied.Name); |
112 | 112 | ||
113 | if (offset >= filesize) | 113 | if (offset >= filesize) |
114 | return ERROR_INVALID_FILE; | 114 | return ERROR_INVALID_FILE; |
115 | 115 | ||
116 | ifFile.seekg(offset, std::ios::beg); | 116 | ifFile.seekg(offset, std::ios::beg); |
117 | } | 117 | } |
118 | else if (const PeHeader64* p64 = dynamic_cast<const PeHeader64*>(&pehHeader)) | 118 | else if (const PeHeader64* p64 = dynamic_cast<const PeHeader64*>(&pehHeader)) |
119 | { | 119 | { |
120 | // XXX: Files might be > 4 GB | 120 | // XXX: Files might be > 4 GB |
121 | unsigned int offset = static_cast<unsigned int>(p64->rvaToOffset(iedCurr.ied.Name)); | 121 | unsigned int offset = static_cast<unsigned int>(p64->rvaToOffset(iedCurr.ied.Name)); |
122 | 122 | ||
123 | if (offset >= filesize) | 123 | if (offset >= filesize) |
124 | return ERROR_INVALID_FILE; | 124 | return ERROR_INVALID_FILE; |
125 | 125 | ||
126 | ifFile.seekg(offset, std::ios::beg); | 126 | ifFile.seekg(offset, std::ios::beg); |
127 | } | 127 | } |
128 | 128 | ||
129 | char c = 0; | 129 | char c = 0; |
130 | std::string strFname = ""; | 130 | std::string strFname = ""; |
131 | do | 131 | do |
132 | { | 132 | { |
133 | ifFile.read(reinterpret_cast<char*>(&c), sizeof(c)); | 133 | ifFile.read(reinterpret_cast<char*>(&c), sizeof(c)); |
134 | if (!ifFile) return ERROR_INVALID_FILE; | 134 | if (!ifFile) return ERROR_INVALID_FILE; |
135 | if (c) strFname += c; | 135 | if (c) strFname += c; |
136 | } | 136 | } |
137 | while (c != 0); | 137 | while (c != 0); |
138 | iedCurr.name = strFname; | 138 | iedCurr.name = strFname; |
139 | 139 | ||
140 | if (const PeHeader32* p32 = dynamic_cast<const PeHeader32*>(&pehHeader)) | 140 | if (const PeHeader32* p32 = dynamic_cast<const PeHeader32*>(&pehHeader)) |
141 | { | 141 | { |
142 | unsigned int offset = p32->rvaToOffset(iedCurr.ied.AddressOfFunctions); | 142 | unsigned int offset = p32->rvaToOffset(iedCurr.ied.AddressOfFunctions); |
143 | 143 | ||
144 | if (offset >= filesize) | 144 | if (offset >= filesize) |
145 | return ERROR_INVALID_FILE; | 145 | return ERROR_INVALID_FILE; |
146 | 146 | ||
147 | ifFile.seekg(offset, std::ios::beg); | 147 | ifFile.seekg(offset, std::ios::beg); |
148 | } | 148 | } |
149 | else if (const PeHeader64* p64 = dynamic_cast<const PeHeader64*>(&pehHeader)) | 149 | else if (const PeHeader64* p64 = dynamic_cast<const PeHeader64*>(&pehHeader)) |
150 | { | 150 | { |
151 | // XXX: File might be > 4 GB | 151 | // XXX: File might be > 4 GB |
152 | unsigned int offset = static_cast<unsigned int>(p64->rvaToOffset(iedCurr.ied.AddressOfFunctions)); | 152 | unsigned int offset = static_cast<unsigned int>(p64->rvaToOffset(iedCurr.ied.AddressOfFunctions)); |
153 | 153 | ||
154 | if (offset >= filesize) | 154 | if (offset >= filesize) |
155 | return ERROR_INVALID_FILE; | 155 | return ERROR_INVALID_FILE; |
156 | 156 | ||
157 | ifFile.seekg(offset, std::ios::beg); | 157 | ifFile.seekg(offset, std::ios::beg); |
158 | } | 158 | } |
159 | 159 | ||
160 | PELIB_EXP_FUNC_INFORMATION efiCurr; | 160 | PELIB_EXP_FUNC_INFORMATION efiCurr; |
161 | efiCurr.ordinal = 0; efiCurr.addroffunc = 0; efiCurr.addrofname = 0; | 161 | efiCurr.ordinal = 0; efiCurr.addroffunc = 0; efiCurr.addrofname = 0; |
162 | 162 | ||
163 | for (unsigned int i=0;i<iedCurr.ied.NumberOfFunctions;i++) | 163 | for (unsigned int i=0;i<iedCurr.ied.NumberOfFunctions;i++) |
164 | { | 164 | { |
165 | if (const PeHeader32* p32 = dynamic_cast<const PeHeader32*>(&pehHeader)) | 165 | if (const PeHeader32* p32 = dynamic_cast<const PeHeader32*>(&pehHeader)) |
166 | { | 166 | { |
167 | unsigned int offset = p32->rvaToOffset(iedCurr.ied.AddressOfFunctions) + i*sizeof(efiCurr.addroffunc); | 167 | unsigned int offset = p32->rvaToOffset(iedCurr.ied.AddressOfFunctions) + i*sizeof(efiCurr.addroffunc); |
168 | 168 | ||
169 | if (offset >= filesize) | 169 | if (offset >= filesize) |
170 | return ERROR_INVALID_FILE; | 170 | return ERROR_INVALID_FILE; |
171 | 171 | ||
172 | ifFile.seekg(offset, std::ios::beg); | 172 | ifFile.seekg(offset, std::ios::beg); |
173 | } | 173 | } |
174 | else if (const PeHeader64* p64 = dynamic_cast<const PeHeader64*>(&pehHeader)) | 174 | else if (const PeHeader64* p64 = dynamic_cast<const PeHeader64*>(&pehHeader)) |
175 | { | 175 | { |
176 | // XXX: File might be > 4GB | 176 | // XXX: File might be > 4GB |
177 | unsigned int offset = static_cast<unsigned int>(p64->rvaToOffset(iedCurr.ied.AddressOfFunctions)) + i*sizeof(efiCurr.addroffunc); | 177 | unsigned int offset = static_cast<unsigned int>(p64->rvaToOffset(iedCurr.ied.AddressOfFunctions)) + i*sizeof(efiCurr.addroffunc); |
178 | 178 | ||
179 | if (offset >= filesize) | 179 | if (offset >= filesize) |
180 | return ERROR_INVALID_FILE; | 180 | return ERROR_INVALID_FILE; |
181 | 181 | ||
182 | ifFile.seekg(offset, std::ios::beg); | 182 | ifFile.seekg(offset, std::ios::beg); |
183 | } | 183 | } |
184 | 184 | ||
185 | ifFile.read(reinterpret_cast<char*>(&efiCurr.addroffunc), sizeof(efiCurr.addroffunc)); | 185 | ifFile.read(reinterpret_cast<char*>(&efiCurr.addroffunc), sizeof(efiCurr.addroffunc)); |
186 | 186 | ||
187 | if (!ifFile) | 187 | if (!ifFile) |
188 | return ERROR_INVALID_FILE; | 188 | return ERROR_INVALID_FILE; |
189 | 189 | ||
190 | efiCurr.ordinal = i; | 190 | efiCurr.ordinal = i; |
191 | iedCurr.functions.push_back(efiCurr); | 191 | iedCurr.functions.push_back(efiCurr); |
192 | } | 192 | } |
193 | 193 | ||
194 | for (unsigned int i=0;i<iedCurr.ied.NumberOfNames;i++) | 194 | for (unsigned int i=0;i<iedCurr.ied.NumberOfNames;i++) |
195 | { | 195 | { |
196 | if (const PeHeader32* p32 = dynamic_cast<const PeHeader32*>(&pehHeader)) | 196 | if (const PeHeader32* p32 = dynamic_cast<const PeHeader32*>(&pehHeader)) |
197 | { | 197 | { |
198 | unsigned int offset = p32->rvaToOffset(iedCurr.ied.AddressOfNameOrdinals) + i*sizeof(efiCurr.ordinal); | 198 | unsigned int offset = p32->rvaToOffset(iedCurr.ied.AddressOfNameOrdinals) + i*sizeof(efiCurr.ordinal); |
199 | 199 | ||
200 | if (offset >= filesize) | 200 | if (offset >= filesize) |
201 | return ERROR_INVALID_FILE; | 201 | return ERROR_INVALID_FILE; |
202 | 202 | ||
203 | ifFile.seekg(offset, std::ios::beg); | 203 | ifFile.seekg(offset, std::ios::beg); |
204 | } | 204 | } |
205 | else if (const PeHeader64* p64 = dynamic_cast<const PeHeader64*>(&pehHeader)) | 205 | else if (const PeHeader64* p64 = dynamic_cast<const PeHeader64*>(&pehHeader)) |
206 | { | 206 | { |
207 | // XXX: File might be > 4 GB | 207 | // XXX: File might be > 4 GB |
208 | unsigned int offset = static_cast<unsigned int>(p64->rvaToOffset(iedCurr.ied.AddressOfNameOrdinals)) + i*sizeof(efiCurr.ordinal); | 208 | unsigned int offset = static_cast<unsigned int>(p64->rvaToOffset(iedCurr.ied.AddressOfNameOrdinals)) + i*sizeof(efiCurr.ordinal); |
209 | 209 | ||
210 | if (offset >= filesize) | 210 | if (offset >= filesize) |
211 | return ERROR_INVALID_FILE; | 211 | return ERROR_INVALID_FILE; |
212 | 212 | ||
213 | ifFile.seekg(offset, std::ios::beg); | 213 | ifFile.seekg(offset, std::ios::beg); |
214 | } | 214 | } |
215 | 215 | ||
216 | word ordinal; | 216 | word ordinal; |
217 | ifFile.read(reinterpret_cast<char*>(&ordinal), sizeof(ordinal)); | 217 | ifFile.read(reinterpret_cast<char*>(&ordinal), sizeof(ordinal)); |
218 | 218 | ||
219 | if (!ifFile) | 219 | if (!ifFile) |
220 | return ERROR_INVALID_FILE; | 220 | return ERROR_INVALID_FILE; |
221 | 221 | ||
222 | iedCurr.functions[ordinal].ordinal = ordinal; | 222 | iedCurr.functions[ordinal].ordinal = ordinal; |
223 | 223 | ||
224 | if (const PeHeader32* p32 = dynamic_cast<const PeHeader32*>(&pehHeader)) | 224 | if (const PeHeader32* p32 = dynamic_cast<const PeHeader32*>(&pehHeader)) |
225 | { | 225 | { |
226 | unsigned int offset = p32->rvaToOffset(iedCurr.ied.AddressOfNames) + i*sizeof(efiCurr.addrofname); | 226 | unsigned int offset = p32->rvaToOffset(iedCurr.ied.AddressOfNames) + i*sizeof(efiCurr.addrofname); |
227 | 227 | ||
228 | if (offset >= filesize) | 228 | if (offset >= filesize) |
229 | return ERROR_INVALID_FILE; | 229 | return ERROR_INVALID_FILE; |
230 | 230 | ||
231 | ifFile.seekg(offset, std::ios::beg); | 231 | ifFile.seekg(offset, std::ios::beg); |
232 | } | 232 | } |
233 | else if (const PeHeader64* p64 = dynamic_cast<const PeHeader64*>(&pehHeader)) | 233 | else if (const PeHeader64* p64 = dynamic_cast<const PeHeader64*>(&pehHeader)) |
234 | { | 234 | { |
235 | // XXX: File might be > 4 GB. | 235 | // XXX: File might be > 4 GB. |
236 | unsigned int offset = static_cast<unsigned int>(p64->rvaToOffset(iedCurr.ied.AddressOfNames)) + i*sizeof(efiCurr.addrofname); | 236 | unsigned int offset = static_cast<unsigned int>(p64->rvaToOffset(iedCurr.ied.AddressOfNames)) + i*sizeof(efiCurr.addrofname); |
237 | 237 | ||
238 | if (offset >= filesize) | 238 | if (offset >= filesize) |
239 | return ERROR_INVALID_FILE; | 239 | return ERROR_INVALID_FILE; |
240 | 240 | ||
241 | ifFile.seekg(offset, std::ios::beg); | 241 | ifFile.seekg(offset, std::ios::beg); |
242 | } | 242 | } |
243 | 243 | ||
244 | ifFile.read(reinterpret_cast<char*>(&iedCurr.functions[ordinal].addrofname), sizeof(iedCurr.functions[ordinal].addrofname)); | 244 | ifFile.read(reinterpret_cast<char*>(&iedCurr.functions[ordinal].addrofname), sizeof(iedCurr.functions[ordinal].addrofname)); |
245 | 245 | ||
246 | if (!ifFile) | 246 | if (!ifFile) |
247 | return ERROR_INVALID_FILE; | 247 | return ERROR_INVALID_FILE; |
248 | 248 | ||
249 | if (const PeHeader32* p32 = dynamic_cast<const PeHeader32*>(&pehHeader)) | 249 | if (const PeHeader32* p32 = dynamic_cast<const PeHeader32*>(&pehHeader)) |
250 | { | 250 | { |
251 | unsigned int offset = p32->rvaToOffset(iedCurr.functions[ordinal].addrofname); | 251 | unsigned int offset = p32->rvaToOffset(iedCurr.functions[ordinal].addrofname); |
252 | 252 | ||
253 | if (offset >= filesize) | 253 | if (offset >= filesize) |
254 | return ERROR_INVALID_FILE; | 254 | return ERROR_INVALID_FILE; |
255 | 255 | ||
256 | ifFile.seekg(offset, std::ios::beg); | 256 | ifFile.seekg(offset, std::ios::beg); |
257 | } | 257 | } |
258 | else if (const PeHeader64* p64 = dynamic_cast<const PeHeader64*>(&pehHeader)) | 258 | else if (const PeHeader64* p64 = dynamic_cast<const PeHeader64*>(&pehHeader)) |
259 | { | 259 | { |
260 | // XXX: File might be > 4 GB. | 260 | // XXX: File might be > 4 GB. |
261 | unsigned int offset = static_cast<unsigned int>(p64->rvaToOffset(iedCurr.functions[ordinal].addrofname)); | 261 | unsigned int offset = static_cast<unsigned int>(p64->rvaToOffset(iedCurr.functions[ordinal].addrofname)); |
262 | 262 | ||
263 | if (offset >= filesize) | 263 | if (offset >= filesize) |
264 | return ERROR_INVALID_FILE; | 264 | return ERROR_INVALID_FILE; |
265 | 265 | ||
266 | ifFile.seekg(static_cast<unsigned int>(p64->rvaToOffset(iedCurr.functions[ordinal].addrofname)), std::ios::beg); | 266 | ifFile.seekg(static_cast<unsigned int>(p64->rvaToOffset(iedCurr.functions[ordinal].addrofname)), std::ios::beg); |
267 | } | 267 | } |
268 | 268 | ||
269 | char c = 0; | 269 | char c = 0; |
270 | std::string strFname = ""; | 270 | std::string strFname = ""; |
271 | do | 271 | do |
272 | { | 272 | { |
273 | ifFile.read(reinterpret_cast<char*>(&c), sizeof(c)); | 273 | ifFile.read(reinterpret_cast<char*>(&c), sizeof(c)); |
274 | 274 | ||
275 | if (!ifFile) | 275 | if (!ifFile) |
276 | return ERROR_INVALID_FILE; | 276 | return ERROR_INVALID_FILE; |
277 | 277 | ||
278 | if (c) strFname += c; | 278 | if (c) strFname += c; |
279 | } | 279 | } |
280 | while (c != 0); | 280 | while (c != 0); |
281 | 281 | ||
282 | iedCurr.functions[ordinal].funcname = strFname; | 282 | iedCurr.functions[ordinal].funcname = strFname; |
283 | } | 283 | } |
284 | 284 | ||
285 | std::swap(m_ied, iedCurr); | 285 | std::swap(m_ied, iedCurr); |
286 | 286 | ||
287 | return NO_ERROR; | 287 | return NO_ERROR; |
288 | } | 288 | } |
289 | 289 | ||
290 | /** | 290 | /** |
291 | * @param vBuffer Buffer where the rebuilt export directory is written to. | 291 | * @param vBuffer Buffer where the rebuilt export directory is written to. |
292 | * @param dwRva RVA of the export directory. | 292 | * @param dwRva RVA of the export directory. |
293 | * \todo fValid flag | 293 | * \todo fValid flag |
294 | **/ | 294 | **/ |
295 | void ExportDirectory::rebuild(std::vector<byte>& vBuffer, dword dwRva) const | 295 | void ExportDirectory::rebuild(std::vector<byte>& vBuffer, dword dwRva) const |
296 | { | 296 | { |
297 | unsigned int uiSizeDirectory = sizeof(PELIB_IMAGE_EXPORT_DIRECTORY); | 297 | unsigned int uiSizeDirectory = sizeof(PELIB_IMAGE_EXPORT_DIRECTORY); |
298 | 298 | ||
299 | unsigned int uiSizeNames = 0; | 299 | unsigned int uiSizeNames = 0; |
300 | unsigned int uiSizeAddrFuncs = 0; | 300 | unsigned int uiSizeAddrFuncs = 0; |
301 | unsigned int uiSizeAddrNames = 0; | 301 | unsigned int uiSizeAddrNames = 0; |
302 | unsigned int uiSizeOrdinals = 0; | 302 | unsigned int uiSizeOrdinals = 0; |
303 | 303 | ||
304 | for (unsigned int i=0;i<m_ied.functions.size();i++) | 304 | for (unsigned int i=0;i<m_ied.functions.size();i++) |
305 | { | 305 | { |
306 | uiSizeNames += (m_ied.functions[i].funcname.empty()) ? 0 : static_cast<unsigned int>(m_ied.functions[i].funcname.size()) + 1; | 306 | uiSizeNames += (m_ied.functions[i].funcname.empty()) ? 0 : static_cast<unsigned int>(m_ied.functions[i].funcname.size()) + 1; |
307 | uiSizeAddrFuncs += sizeof(m_ied.functions[i].addroffunc); | 307 | uiSizeAddrFuncs += sizeof(m_ied.functions[i].addroffunc); |
308 | uiSizeAddrNames += (m_ied.functions[i].funcname.empty()) ? 0 : sizeof(m_ied.functions[i].addrofname); | 308 | uiSizeAddrNames += (m_ied.functions[i].funcname.empty()) ? 0 : sizeof(m_ied.functions[i].addrofname); |
309 | uiSizeOrdinals += (m_ied.functions[i].funcname.empty()) ? 0 : sizeof(m_ied.functions[i].ordinal); | 309 | uiSizeOrdinals += (m_ied.functions[i].funcname.empty()) ? 0 : sizeof(m_ied.functions[i].ordinal); |
310 | } | 310 | } |
311 | 311 | ||
312 | unsigned int uiFilenameSize = static_cast<unsigned int>(m_ied.name.size()) + 1; | 312 | unsigned int uiFilenameSize = static_cast<unsigned int>(m_ied.name.size()) + 1; |
313 | 313 | ||
314 | OutputBuffer obBuffer(vBuffer); | 314 | OutputBuffer obBuffer(vBuffer); |
315 | 315 | ||
316 | obBuffer << m_ied.ied.Characteristics; | 316 | obBuffer << m_ied.ied.Characteristics; |
317 | obBuffer << m_ied.ied.TimeDateStamp; | 317 | obBuffer << m_ied.ied.TimeDateStamp; |
318 | obBuffer << m_ied.ied.MajorVersion; | 318 | obBuffer << m_ied.ied.MajorVersion; |
319 | obBuffer << m_ied.ied.MinorVersion; | 319 | obBuffer << m_ied.ied.MinorVersion; |
320 | obBuffer << dwRva + uiSizeDirectory; | 320 | obBuffer << dwRva + uiSizeDirectory; |
321 | obBuffer << m_ied.ied.Base; | 321 | obBuffer << m_ied.ied.Base; |
322 | obBuffer << static_cast<unsigned int>(m_ied.functions.size()); | 322 | obBuffer << static_cast<unsigned int>(m_ied.functions.size()); |
323 | 323 | ||
324 | // TODO: Not correct but sufficient for now. (Update: I forgot what this comment refers to, but I'll leave it in) | 324 | // TODO: Not correct but sufficient for now. (Update: I forgot what this comment refers to, but I'll leave it in) |
325 | obBuffer << static_cast<unsigned int>(m_ied.functions.size()); | 325 | obBuffer << static_cast<unsigned int>(m_ied.functions.size()); |
326 | obBuffer << dwRva + uiSizeDirectory + uiFilenameSize; | 326 | obBuffer << dwRva + uiSizeDirectory + uiFilenameSize; |
327 | obBuffer << dwRva + uiSizeDirectory + uiFilenameSize + uiSizeAddrFuncs; | 327 | obBuffer << dwRva + uiSizeDirectory + uiFilenameSize + uiSizeAddrFuncs; |
328 | obBuffer << dwRva + uiSizeDirectory + uiFilenameSize + uiSizeAddrFuncs + uiSizeAddrNames; | 328 | obBuffer << dwRva + uiSizeDirectory + uiFilenameSize + uiSizeAddrFuncs + uiSizeAddrNames; |
329 | 329 | ||
330 | obBuffer.add(m_ied.name.c_str(), static_cast<unsigned int>(m_ied.name.size())+1); | 330 | obBuffer.add(m_ied.name.c_str(), static_cast<unsigned int>(m_ied.name.size())+1); |
331 | 331 | ||
332 | for (unsigned int i=0;i<m_ied.functions.size();i++) | 332 | for (unsigned int i=0;i<m_ied.functions.size();i++) |
333 | { | 333 | { |
334 | obBuffer << m_ied.functions[i].addroffunc; | 334 | obBuffer << m_ied.functions[i].addroffunc; |
335 | } | 335 | } |
336 | 336 | ||
337 | unsigned int ulFuncCounter = dwRva + uiSizeDirectory + uiFilenameSize + uiSizeAddrFuncs + uiSizeAddrNames + uiSizeOrdinals; | 337 | unsigned int ulFuncCounter = dwRva + uiSizeDirectory + uiFilenameSize + uiSizeAddrFuncs + uiSizeAddrNames + uiSizeOrdinals; |
338 | 338 | ||
339 | for (unsigned int i=0;i<m_ied.functions.size();i++) | 339 | for (unsigned int i=0;i<m_ied.functions.size();i++) |
340 | { | 340 | { |
341 | if (!m_ied.functions[i].funcname.empty()) | 341 | if (!m_ied.functions[i].funcname.empty()) |
342 | { | 342 | { |
343 | obBuffer << ulFuncCounter; | 343 | obBuffer << ulFuncCounter; |
344 | ulFuncCounter += static_cast<unsigned int>(m_ied.functions[i].funcname.size()) + 1; | 344 | ulFuncCounter += static_cast<unsigned int>(m_ied.functions[i].funcname.size()) + 1; |
345 | } | 345 | } |
346 | } | 346 | } |
347 | 347 | ||
348 | for (unsigned int i=0;i<m_ied.functions.size();i++) | 348 | for (unsigned int i=0;i<m_ied.functions.size();i++) |
349 | { | 349 | { |
350 | if (!m_ied.functions[i].funcname.empty()) | 350 | if (!m_ied.functions[i].funcname.empty()) |
351 | { | 351 | { |
352 | obBuffer << m_ied.functions[i].ordinal; | 352 | obBuffer << m_ied.functions[i].ordinal; |
353 | } | 353 | } |
354 | } | 354 | } |
355 | 355 | ||
356 | for (unsigned int i=0;i<m_ied.functions.size();i++) | 356 | for (unsigned int i=0;i<m_ied.functions.size();i++) |
357 | { | 357 | { |
358 | if (m_ied.functions[i].funcname.empty() && m_ied.functions[i].addroffunc) | 358 | if (m_ied.functions[i].funcname.empty() && m_ied.functions[i].addroffunc) |
359 | { | 359 | { |
360 | obBuffer << m_ied.functions[i].ordinal; | 360 | obBuffer << m_ied.functions[i].ordinal; |
361 | } | 361 | } |
362 | } | 362 | } |
363 | 363 | ||
364 | for (unsigned int i=0;i<m_ied.functions.size();i++) | 364 | for (unsigned int i=0;i<m_ied.functions.size();i++) |
365 | { | 365 | { |
366 | if (!m_ied.functions[i].funcname.empty()) | 366 | if (!m_ied.functions[i].funcname.empty()) |
367 | { | 367 | { |
368 | obBuffer.add(m_ied.functions[i].funcname.c_str(), static_cast<unsigned int>(m_ied.functions[i].funcname.size()) + 1); | 368 | obBuffer.add(m_ied.functions[i].funcname.c_str(), static_cast<unsigned int>(m_ied.functions[i].funcname.size()) + 1); |
369 | } | 369 | } |
370 | } | 370 | } |
371 | } | 371 | } |
372 | 372 | ||
373 | /** | 373 | /** |
374 | * @return Size of the current export directory. | 374 | * @return Size of the current export directory. |
375 | **/ | 375 | **/ |
376 | unsigned int ExportDirectory::size() const | 376 | unsigned int ExportDirectory::size() const |
377 | { | 377 | { |
378 | return m_ied.size(); | 378 | return m_ied.size(); |
379 | } | 379 | } |
380 | 380 | ||
381 | /** | 381 | /** |
382 | * @param strFilename Name of the file. | 382 | * @param strFilename Name of the file. |
383 | * @param uiOffset File offset the export directory will be written to. | 383 | * @param uiOffset File offset the export directory will be written to. |
384 | * @param uiRva RVA of the export directory. | 384 | * @param uiRva RVA of the export directory. |
385 | * \todo Check if ofFile.write succeeded. | 385 | * \todo Check if ofFile.write succeeded. |
386 | **/ | 386 | **/ |
387 | int ExportDirectory::write(const std::string& strFilename, unsigned int uiOffset, unsigned int uiRva) const | 387 | int ExportDirectory::write(const std::string& strFilename, unsigned int uiOffset, unsigned int uiRva) const |
388 | { | 388 | { |
389 | std::fstream ofFile(strFilename.c_str(), std::ios_base::in); | 389 | std::fstream ofFile(strFilename.c_str(), std::ios_base::in); |
390 | 390 | ||
391 | if (!ofFile) | 391 | if (!ofFile) |
392 | { | 392 | { |
393 | ofFile.clear(); | 393 | ofFile.clear(); |
394 | ofFile.open(strFilename.c_str(), std::ios_base::out | std::ios_base::binary); | 394 | ofFile.open(strFilename.c_str(), std::ios_base::out | std::ios_base::binary); |
395 | } | 395 | } |
396 | else | 396 | else |
397 | { | 397 | { |
398 | ofFile.close(); | 398 | ofFile.close(); |
399 | ofFile.open(strFilename.c_str(), std::ios_base::in | std::ios_base::out | std::ios_base::binary); | 399 | ofFile.open(strFilename.c_str(), std::ios_base::in | std::ios_base::out | std::ios_base::binary); |
400 | } | 400 | } |
401 | 401 | ||
402 | if (!ofFile) | 402 | if (!ofFile) |
403 | { | 403 | { |
404 | return ERROR_OPENING_FILE; | 404 | return ERROR_OPENING_FILE; |
405 | } | 405 | } |
406 | 406 | ||
407 | ofFile.seekp(uiOffset, std::ios::beg); | 407 | ofFile.seekp(uiOffset, std::ios::beg); |
408 | 408 | ||
409 | std::vector<unsigned char> vBuffer; | 409 | std::vector<unsigned char> vBuffer; |
410 | rebuild(vBuffer, uiRva); | 410 | rebuild(vBuffer, uiRva); |
411 | 411 | ||
412 | ofFile.write(reinterpret_cast<const char*>(&vBuffer[0]), static_cast<unsigned int>(vBuffer.size())); | 412 | ofFile.write(reinterpret_cast<const char*>(&vBuffer[0]), static_cast<unsigned int>(vBuffer.size())); |
413 | 413 | ||
414 | ofFile.close(); | 414 | ofFile.close(); |
415 | 415 | ||
416 | return NO_ERROR; | 416 | return NO_ERROR; |
417 | } | 417 | } |
418 | 418 | ||
419 | /** | 419 | /** |
420 | * Changes the filename according to the export directory. | 420 | * Changes the filename according to the export directory. |
421 | * @param strFilename New filename. | 421 | * @param strFilename New filename. |
422 | **/ | 422 | **/ |
423 | void ExportDirectory::setNameString(const std::string& strFilename) | 423 | void ExportDirectory::setNameString(const std::string& strFilename) |
424 | { | 424 | { |
425 | m_ied.name = strFilename; | 425 | m_ied.name = strFilename; |
426 | } | 426 | } |
427 | 427 | ||
428 | std::string ExportDirectory::getNameString() const | 428 | std::string ExportDirectory::getNameString() const |
429 | { | 429 | { |
430 | return m_ied.name; | 430 | return m_ied.name; |
431 | } | 431 | } |
432 | 432 | ||
433 | /** | 433 | /** |
434 | * @param dwIndex Number which identifies an exported function. | 434 | * @param dwIndex Number which identifies an exported function. |
435 | * @return The name of that function. | 435 | * @return The name of that function. |
436 | **/ | 436 | **/ |
437 | std::string ExportDirectory::getFunctionName(dword dwIndex) const | 437 | std::string ExportDirectory::getFunctionName(dword dwIndex) const |
438 | { | 438 | { |
439 | return m_ied.functions[dwIndex].funcname; | 439 | return m_ied.functions[dwIndex].funcname; |
440 | } | 440 | } |
441 | 441 | ||
442 | /** | 442 | /** |
443 | * @param dwIndex Number which identifies an exported function. | 443 | * @param dwIndex Number which identifies an exported function. |
444 | * @return The ordinal of that function. | 444 | * @return The ordinal of that function. |
445 | **/ | 445 | **/ |
446 | word ExportDirectory::getFunctionOrdinal(dword dwIndex) const | 446 | word ExportDirectory::getFunctionOrdinal(dword dwIndex) const |
447 | { | 447 | { |
448 | return m_ied.functions[dwIndex].ordinal; | 448 | return m_ied.functions[dwIndex].ordinal; |
449 | } | 449 | } |
450 | 450 | ||
451 | /** | 451 | /** |
452 | * @param dwIndex Number which identifies an exported function. | 452 | * @param dwIndex Number which identifies an exported function. |
453 | * @return The RVA of the name string of that function. | 453 | * @return The RVA of the name string of that function. |
454 | **/ | 454 | **/ |
455 | dword ExportDirectory::getAddressOfName(dword dwIndex) const | 455 | dword ExportDirectory::getAddressOfName(dword dwIndex) const |
456 | { | 456 | { |
457 | return m_ied.functions[dwIndex].addrofname; | 457 | return m_ied.functions[dwIndex].addrofname; |
458 | } | 458 | } |
459 | 459 | ||
460 | /** | 460 | /** |
461 | * @param dwIndex Number which identifies an exported function. | 461 | * @param dwIndex Number which identifies an exported function. |
462 | * @return The RVA of that function. | 462 | * @return The RVA of that function. |
463 | **/ | 463 | **/ |
464 | dword ExportDirectory::getAddressOfFunction(dword dwIndex) const | 464 | dword ExportDirectory::getAddressOfFunction(dword dwIndex) const |
465 | { | 465 | { |
466 | return m_ied.functions[dwIndex].addroffunc; | 466 | return m_ied.functions[dwIndex].addroffunc; |
467 | } | 467 | } |
468 | 468 | ||
469 | /** | 469 | /** |
470 | * @param dwIndex Number which identifies an exported function. | 470 | * @param dwIndex Number which identifies an exported function. |
471 | * @param strName The name of that function. | 471 | * @param strName The name of that function. |
472 | **/ | 472 | **/ |
473 | void ExportDirectory::setFunctionName(dword dwIndex, const std::string& strName) | 473 | void ExportDirectory::setFunctionName(dword dwIndex, const std::string& strName) |
474 | { | 474 | { |
475 | m_ied.functions[dwIndex].funcname = strName; | 475 | m_ied.functions[dwIndex].funcname = strName; |
476 | } | 476 | } |
477 | 477 | ||
478 | /** | 478 | /** |
479 | * @param dwIndex Number which identifies an exported function. | 479 | * @param dwIndex Number which identifies an exported function. |
480 | * @param wValue The ordinal of that function. | 480 | * @param wValue The ordinal of that function. |
481 | **/ | 481 | **/ |
482 | void ExportDirectory::setFunctionOrdinal(dword dwIndex, word wValue) | 482 | void ExportDirectory::setFunctionOrdinal(dword dwIndex, word wValue) |
483 | { | 483 | { |
484 | m_ied.functions[dwIndex].ordinal = wValue; | 484 | m_ied.functions[dwIndex].ordinal = wValue; |
485 | } | 485 | } |
486 | 486 | ||
487 | /** | 487 | /** |
488 | * @param dwIndex Number which identifies an exported function. | 488 | * @param dwIndex Number which identifies an exported function. |
489 | * @param dwValue The RVA of the name string of that function. | 489 | * @param dwValue The RVA of the name string of that function. |
490 | **/ | 490 | **/ |
491 | void ExportDirectory::setAddressOfName(dword dwIndex, dword dwValue) | 491 | void ExportDirectory::setAddressOfName(dword dwIndex, dword dwValue) |
492 | { | 492 | { |
493 | m_ied.functions[dwIndex].addrofname = dwValue; | 493 | m_ied.functions[dwIndex].addrofname = dwValue; |
494 | } | 494 | } |
495 | 495 | ||
496 | /** | 496 | /** |
497 | * @param dwIndex Number which identifies an exported function. | 497 | * @param dwIndex Number which identifies an exported function. |
498 | * @param dwValue The RVA of that function. | 498 | * @param dwValue The RVA of that function. |
499 | **/ | 499 | **/ |
500 | void ExportDirectory::setAddressOfFunction(dword dwIndex, dword dwValue) | 500 | void ExportDirectory::setAddressOfFunction(dword dwIndex, dword dwValue) |
501 | { | 501 | { |
502 | m_ied.functions[dwIndex].addroffunc = dwValue; | 502 | m_ied.functions[dwIndex].addroffunc = dwValue; |
503 | } | 503 | } |
504 | 504 | ||
505 | /** | 505 | /** |
506 | * @return The ordinal base of the export directory. | 506 | * @return The ordinal base of the export directory. |
507 | **/ | 507 | **/ |
508 | dword ExportDirectory::getBase() const | 508 | dword ExportDirectory::getBase() const |
509 | { | 509 | { |
510 | return m_ied.ied.Base; | 510 | return m_ied.ied.Base; |
511 | } | 511 | } |
512 | 512 | ||
513 | /** | 513 | /** |
514 | * @return The characteristics of the export directory. | 514 | * @return The characteristics of the export directory. |
515 | **/ | 515 | **/ |
516 | dword ExportDirectory::getCharacteristics() const | 516 | dword ExportDirectory::getCharacteristics() const |
517 | { | 517 | { |
518 | return m_ied.ied.Characteristics; | 518 | return m_ied.ied.Characteristics; |
519 | } | 519 | } |
520 | 520 | ||
521 | /** | 521 | /** |
522 | * @return The time/date stamp of the export directory. | 522 | * @return The time/date stamp of the export directory. |
523 | **/ | 523 | **/ |
524 | dword ExportDirectory::getTimeDateStamp() const | 524 | dword ExportDirectory::getTimeDateStamp() const |
525 | { | 525 | { |
526 | return m_ied.ied.TimeDateStamp; | 526 | return m_ied.ied.TimeDateStamp; |
527 | } | 527 | } |
528 | 528 | ||
529 | /** | 529 | /** |
530 | * @return The MajorVersion of the export directory. | 530 | * @return The MajorVersion of the export directory. |
531 | **/ | 531 | **/ |
532 | word ExportDirectory::getMajorVersion() const | 532 | word ExportDirectory::getMajorVersion() const |
533 | { | 533 | { |
534 | return m_ied.ied.MajorVersion; | 534 | return m_ied.ied.MajorVersion; |
535 | } | 535 | } |
536 | 536 | ||
537 | /** | 537 | /** |
538 | * @return The MinorVersion of the export directory. | 538 | * @return The MinorVersion of the export directory. |
539 | **/ | 539 | **/ |
540 | word ExportDirectory::getMinorVersion() const | 540 | word ExportDirectory::getMinorVersion() const |
541 | { | 541 | { |
542 | return m_ied.ied.MinorVersion; | 542 | return m_ied.ied.MinorVersion; |
543 | } | 543 | } |
544 | 544 | ||
545 | /** | 545 | /** |
546 | * @return The RVA of the name of the file. | 546 | * @return The RVA of the name of the file. |
547 | **/ | 547 | **/ |
548 | dword ExportDirectory::getName() const | 548 | dword ExportDirectory::getName() const |
549 | { | 549 | { |
550 | return m_ied.ied.Name; | 550 | return m_ied.ied.Name; |
551 | } | 551 | } |
552 | 552 | ||
553 | /** | 553 | /** |
554 | * @return The NumberOfFunctions of the export directory. | 554 | * @return The NumberOfFunctions of the export directory. |
555 | **/ | 555 | **/ |
556 | dword ExportDirectory::getNumberOfFunctions() const | 556 | dword ExportDirectory::getNumberOfFunctions() const |
557 | { | 557 | { |
558 | return m_ied.ied.NumberOfFunctions; | 558 | return m_ied.ied.NumberOfFunctions; |
559 | } | 559 | } |
560 | 560 | ||
561 | /** | 561 | /** |
562 | * @return The NumberOfNames of the export directory. | 562 | * @return The NumberOfNames of the export directory. |
563 | **/ | 563 | **/ |
564 | dword ExportDirectory::getNumberOfNames() const | 564 | dword ExportDirectory::getNumberOfNames() const |
565 | { | 565 | { |
566 | return m_ied.ied.NumberOfNames; | 566 | return m_ied.ied.NumberOfNames; |
567 | } | 567 | } |
568 | 568 | ||
569 | /** | 569 | /** |
570 | * @return The AddressOfFunctions of the export directory. | 570 | * @return The AddressOfFunctions of the export directory. |
571 | **/ | 571 | **/ |
572 | dword ExportDirectory::getAddressOfFunctions() const | 572 | dword ExportDirectory::getAddressOfFunctions() const |
573 | { | 573 | { |
574 | return m_ied.ied.AddressOfFunctions; | 574 | return m_ied.ied.AddressOfFunctions; |
575 | } | 575 | } |
576 | 576 | ||
577 | /** | 577 | /** |
578 | * @return The AddressOfNames of the export directory. | 578 | * @return The AddressOfNames of the export directory. |
579 | **/ | 579 | **/ |
580 | dword ExportDirectory::getAddressOfNames() const | 580 | dword ExportDirectory::getAddressOfNames() const |
581 | { | 581 | { |
582 | return m_ied.ied.AddressOfNames; | 582 | return m_ied.ied.AddressOfNames; |
583 | } | 583 | } |
584 | 584 | ||
585 | /* dword ExportDirectory::getNumberOfNameOrdinals() const | 585 | /* dword ExportDirectory::getNumberOfNameOrdinals() const |
586 | { | 586 | { |
587 | return static_cast<dword>(m_ied.functions.size()); | 587 | return static_cast<dword>(m_ied.functions.size()); |
588 | } | 588 | } |
589 | 589 | ||
590 | dword ExportDirectory::getNumberOfAddressOfFunctionNames() const | 590 | dword ExportDirectory::getNumberOfAddressOfFunctionNames() const |
591 | { | 591 | { |
592 | return static_cast<dword>(m_ied.functions.size()); | 592 | return static_cast<dword>(m_ied.functions.size()); |
593 | } | 593 | } |
594 | 594 | ||
595 | dword ExportDirectory::getNumberOfAddressOfFunctions() const | 595 | dword ExportDirectory::getNumberOfAddressOfFunctions() const |
596 | { | 596 | { |
597 | return static_cast<dword>(m_ied.functions.size()); | 597 | return static_cast<dword>(m_ied.functions.size()); |
598 | } | 598 | } |
599 | */ | 599 | */ |
600 | /** | 600 | /** |
601 | * @return The AddressOfNameOrdinals of the export directory. | 601 | * @return The AddressOfNameOrdinals of the export directory. |
602 | **/ | 602 | **/ |
603 | dword ExportDirectory::getAddressOfNameOrdinals() const | 603 | dword ExportDirectory::getAddressOfNameOrdinals() const |
604 | { | 604 | { |
605 | return m_ied.ied.AddressOfNameOrdinals; | 605 | return m_ied.ied.AddressOfNameOrdinals; |
606 | } | 606 | } |
607 | 607 | ||
608 | /** | 608 | /** |
609 | * @param dwValue The ordinal base of the export directory. | 609 | * @param dwValue The ordinal base of the export directory. |
610 | **/ | 610 | **/ |
611 | void ExportDirectory::setBase(dword dwValue) | 611 | void ExportDirectory::setBase(dword dwValue) |
612 | { | 612 | { |
613 | m_ied.ied.Base = dwValue; | 613 | m_ied.ied.Base = dwValue; |
614 | } | 614 | } |
615 | 615 | ||
616 | /** | 616 | /** |
617 | * @param dwValue The Characteristics of the export directory. | 617 | * @param dwValue The Characteristics of the export directory. |
618 | **/ | 618 | **/ |
619 | void ExportDirectory::setCharacteristics(dword dwValue) | 619 | void ExportDirectory::setCharacteristics(dword dwValue) |
620 | { | 620 | { |
621 | m_ied.ied.Characteristics = dwValue; | 621 | m_ied.ied.Characteristics = dwValue; |
622 | } | 622 | } |
623 | 623 | ||
624 | /** | 624 | /** |
625 | * @param dwValue The TimeDateStamp of the export directory. | 625 | * @param dwValue The TimeDateStamp of the export directory. |
626 | **/ | 626 | **/ |
627 | void ExportDirectory::setTimeDateStamp(dword dwValue) | 627 | void ExportDirectory::setTimeDateStamp(dword dwValue) |
628 | { | 628 | { |
629 | m_ied.ied.TimeDateStamp = dwValue; | 629 | m_ied.ied.TimeDateStamp = dwValue; |
630 | } | 630 | } |
631 | 631 | ||
632 | /** | 632 | /** |
633 | * @param wValue The MajorVersion of the export directory. | 633 | * @param wValue The MajorVersion of the export directory. |
634 | **/ | 634 | **/ |
635 | void ExportDirectory::setMajorVersion(word wValue) | 635 | void ExportDirectory::setMajorVersion(word wValue) |
636 | { | 636 | { |
637 | m_ied.ied.MajorVersion = wValue; | 637 | m_ied.ied.MajorVersion = wValue; |
638 | } | 638 | } |
639 | 639 | ||
640 | /** | 640 | /** |
641 | * @param wValue The MinorVersion of the export directory. | 641 | * @param wValue The MinorVersion of the export directory. |
642 | **/ | 642 | **/ |
643 | void ExportDirectory::setMinorVersion(word wValue) | 643 | void ExportDirectory::setMinorVersion(word wValue) |
644 | { | 644 | { |
645 | m_ied.ied.MinorVersion = wValue; | 645 | m_ied.ied.MinorVersion = wValue; |
646 | } | 646 | } |
647 | 647 | ||
648 | /** | 648 | /** |
649 | * @param dwValue The Name of the export directory. | 649 | * @param dwValue The Name of the export directory. |
650 | **/ | 650 | **/ |
651 | void ExportDirectory::setName(dword dwValue) | 651 | void ExportDirectory::setName(dword dwValue) |
652 | { | 652 | { |
653 | m_ied.ied.Name = dwValue; | 653 | m_ied.ied.Name = dwValue; |
654 | } | 654 | } |
655 | 655 | ||
656 | /** | 656 | /** |
657 | * @param dwValue The NumberOfFunctions of the export directory. | 657 | * @param dwValue The NumberOfFunctions of the export directory. |
658 | **/ | 658 | **/ |
659 | void ExportDirectory::setNumberOfFunctions(dword dwValue) | 659 | void ExportDirectory::setNumberOfFunctions(dword dwValue) |
660 | { | 660 | { |
661 | m_ied.ied.NumberOfFunctions = dwValue; | 661 | m_ied.ied.NumberOfFunctions = dwValue; |
662 | } | 662 | } |
663 | 663 | ||
664 | /** | 664 | /** |
665 | * @param dwValue The NumberOfNames of the export directory. | 665 | * @param dwValue The NumberOfNames of the export directory. |
666 | **/ | 666 | **/ |
667 | void ExportDirectory::setNumberOfNames(dword dwValue) | 667 | void ExportDirectory::setNumberOfNames(dword dwValue) |
668 | { | 668 | { |
669 | m_ied.ied.NumberOfNames = dwValue; | 669 | m_ied.ied.NumberOfNames = dwValue; |
670 | } | 670 | } |
671 | 671 | ||
672 | /** | 672 | /** |
673 | * @param dwValue The AddressOfFunctions of the export directory. | 673 | * @param dwValue The AddressOfFunctions of the export directory. |
674 | **/ | 674 | **/ |
675 | void ExportDirectory::setAddressOfFunctions(dword dwValue) | 675 | void ExportDirectory::setAddressOfFunctions(dword dwValue) |
676 | { | 676 | { |
677 | m_ied.ied.AddressOfFunctions = dwValue; | 677 | m_ied.ied.AddressOfFunctions = dwValue; |
678 | } | 678 | } |
679 | 679 | ||
680 | /** | 680 | /** |
681 | * @param dwValue The AddressOfNames of the export directory. | 681 | * @param dwValue The AddressOfNames of the export directory. |
682 | **/ | 682 | **/ |
683 | void ExportDirectory::setAddressOfNames(dword dwValue) | 683 | void ExportDirectory::setAddressOfNames(dword dwValue) |
684 | { | 684 | { |
685 | m_ied.ied.AddressOfNames = dwValue; | 685 | m_ied.ied.AddressOfNames = dwValue; |
686 | } | 686 | } |
687 | 687 | ||
688 | void ExportDirectory::setAddressOfNameOrdinals(dword value) | 688 | void ExportDirectory::setAddressOfNameOrdinals(dword value) |
689 | { | 689 | { |
690 | m_ied.ied.AddressOfNameOrdinals = value; | 690 | m_ied.ied.AddressOfNameOrdinals = value; |
691 | } | 691 | } |
692 | } | 692 | } |