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