summaryrefslogtreecommitdiffstats
path: root/utils/zenutils/libraries/pelib-0.9/pelib/ExportDirectory.h
blob: 19609b65a707ee4b8c6863874ee4ad71354a9ab4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/*
* ExportDirectory.h - Part of the PeLib library.
*
* Copyright (c) 2004 - 2005 Sebastian Porst (webmaster@the-interweb.com)
* All rights reserved.
*
* This software is licensed under the zlib/libpng License.
* For more details see http://www.opensource.org/licenses/zlib-license.php
* or the license information file (license.htm) in the root directory 
* of PeLib.
*/

#ifndef EXPORTDIRECTORY_H
#define EXPORTDIRECTORY_H
#include "PeHeader.h"

namespace PeLib
{
	/// Class that handles the export directory.
	/**
	* This class handles the export directory.
	* \todo getNameString
	**/
//	template<int bits>
	class ExportDirectory
	{
		private:
		  /// Used to store all necessary information about a file's exported functions.
		  PELIB_IMAGE_EXP_DIRECTORY m_ied;

		public:
		  /// Add another function to be exported.
		  void addFunction(const std::string& strFuncname, dword dwFuncAddr); // EXPORT
		  unsigned int calcNumberOfFunctions() const; // EXPORT
		  void clear(); // EXPORT
		  /// Identifies a function through it's name.
		  int getFunctionIndex(const std::string& strFunctionName) const; // EXPORT
		  /// Read a file's export directory.
		  int read(const std::string& strFilename, unsigned int uiOffset, unsigned int uiSize, const PeHeader& pehHeader); // EXPORT
		  /// Rebuild the current export directory.
		  void rebuild(std::vector<byte>& vBuffer, dword dwRva) const; // EXPORT
		  void removeFunction(unsigned int index); // EXPORT
		  /// Returns the size of the current export directory.
		  unsigned int size() const; // EXPORT
		  /// Writes the current export directory to a file.
		  int write(const std::string& strFilename, unsigned int uiOffset, unsigned int uiRva) const; // EXPORT

		  /// Changes the name of the file (according to the export directory).
		  void setNameString(const std::string& strFilename); // EXPORT
		  std::string getNameString() const; // EXPORT

		  /// Get the name of an exported function.
		  std::string getFunctionName(unsigned int index) const; // EXPORT
		  /// Get the ordinal of an exported function.
		  word getFunctionOrdinal(unsigned int index) const; // EXPORT
		  /// Get the address of the name of an exported function.
		  dword getAddressOfName(unsigned int index) const; // EXPORT
		  /// Get the address of an exported function.
		  dword getAddressOfFunction(unsigned int index) const; // EXPORT
		  
		  /// Change the name of an exported function.
		  void setFunctionName(unsigned int index, const std::string& strName); // EXPORT
		  /// Change the ordinal of an exported function.
		  void setFunctionOrdinal(unsigned int index, word wValue); // EXPORT
		  /// Change the address of the name of an exported function.
		  void setAddressOfName(unsigned int index, dword dwValue); // EXPORT
		  /// Change the address of an exported function.
		  void setAddressOfFunction(unsigned int index, dword dwValue); // EXPORT
		  
		  /*
		  word getFunctionOrdinal(std::string strFuncname) const;
		  dword getAddressOfName(std::string strFuncname) const;
		  dword getAddressOfFunction(std::string strFuncname) const;

		  void setFunctionOrdinal(std::string strFuncname, word wValue);
		  void setAddressOfName(std::string strFuncname, dword dwValue);
		  void setAddressOfFunction(std::string strFuncname, dword dwValue);
		  */

		  /// Return the Base value of the export directory.
		  dword getBase() const; // EXPORT
		  /// Return the Characteristics value of the export directory.
		  dword getCharacteristics() const; // EXPORT
		  /// Return the TimeDateStamp value of the export directory.
		  dword getTimeDateStamp() const; // EXPORT
		  /// Return the MajorVersion value of the export directory.
		  word getMajorVersion() const; // EXPORT
		  /// Return the MinorVersion value of the export directory.
		  word getMinorVersion() const; // EXPORT
		  /// Return the Name value of the export directory.
		  dword getName() const; // EXPORT
		  /// Return the NumberOfFunctions value of the export directory.
		  dword getNumberOfFunctions() const; // EXPORT
		  /// Return the NumberOfNames value of the export directory.
		  dword getNumberOfNames() const; // EXPORT
		  /// Return the AddressOfFunctions value of the export directory.
		  dword getAddressOfFunctions() const; // EXPORT
		  /// Return the AddressOfNames value of the export directory.
		  dword getAddressOfNames() const; // EXPORT
		  /// Returns the AddressOfNameOrdinals value.
		  dword getAddressOfNameOrdinals() const; // EXPORT

/*		  /// Returns the number of NameOrdinals.
		  dword getNumberOfNameOrdinals() const; // EXPORT
		  /// Returns the number of AddressOfFunctionNames values.
		  dword getNumberOfAddressOfFunctionNames() const; // EXPORT
		  /// Returns the number of AddressOfFunction values.
		  dword getNumberOfAddressOfFunctions() const; // EXPORT
*/
		  /// Set the Base value of the export directory.
		  void setBase(dword dwValue); // EXPORT
		  /// Set the Characteristics value of the export directory.
		  void setCharacteristics(dword dwValue); // EXPORT
		  /// Set the TimeDateStamp value of the export directory.
		  void setTimeDateStamp(dword dwValue); // EXPORT
		  /// Set the MajorVersion value of the export directory.
		  void setMajorVersion(word wValue); // EXPORT
		  /// Set the MinorVersion value of the export directory.
		  void setMinorVersion(word wValue); // EXPORT
		  /// Set the Name value of the export directory.
		  void setName(dword dwValue); // EXPORT
		  /// Set the NumberOfFunctions value of the export directory.
		  void setNumberOfFunctions(dword dwValue); // EXPORT
		  /// Set the NumberOfNames value of the export directory.
		  void setNumberOfNames(dword dwValue); // EXPORT
		  /// Set the AddressOfFunctions value of the export directory.
		  void setAddressOfFunctions(dword dwValue); // EXPORT
		  /// Set the AddressOfNames value of the export directory.
		  void setAddressOfNames(dword dwValue); // EXPORT
		  void setAddressOfNameOrdinals(dword value); // EXPORT
	};
}
#endif