diff options
Diffstat (limited to 'utils/zenutils/libraries/pelib-0.9/pelib/PeHeader.h')
-rw-r--r--[-rwxr-xr-x] | utils/zenutils/libraries/pelib-0.9/pelib/PeHeader.h | 5370 |
1 files changed, 2685 insertions, 2685 deletions
diff --git a/utils/zenutils/libraries/pelib-0.9/pelib/PeHeader.h b/utils/zenutils/libraries/pelib-0.9/pelib/PeHeader.h index 08eaca4072..d5c1748233 100755..100644 --- a/utils/zenutils/libraries/pelib-0.9/pelib/PeHeader.h +++ b/utils/zenutils/libraries/pelib-0.9/pelib/PeHeader.h | |||
@@ -1,2685 +1,2685 @@ | |||
1 | /* | 1 | /* |
2 | * PeHeader.h - Part of the PeLib library. | 2 | * PeHeader.h - 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 | #ifndef PEHEADER_H | 13 | #ifndef PEHEADER_H |
14 | #define PEHEADER_H | 14 | #define PEHEADER_H |
15 | 15 | ||
16 | #include "PeLibAux.h" | 16 | #include "PeLibAux.h" |
17 | 17 | ||
18 | namespace PeLib | 18 | namespace PeLib |
19 | { | 19 | { |
20 | class PeHeader | 20 | class PeHeader |
21 | { | 21 | { |
22 | // protected: | 22 | // protected: |
23 | // virtual void readBaseOfData(InputBuffer& ibBuffer) = 0; | 23 | // virtual void readBaseOfData(InputBuffer& ibBuffer) = 0; |
24 | // virtual void rebuildBaseOfData(OutputBuffer& obBuffer) const = 0; | 24 | // virtual void rebuildBaseOfData(OutputBuffer& obBuffer) const = 0; |
25 | 25 | ||
26 | public: | 26 | public: |
27 | virtual ~PeHeader(){}; | 27 | virtual ~PeHeader(){}; |
28 | }; | 28 | }; |
29 | 29 | ||
30 | /// Class that handles the PE header of files. | 30 | /// Class that handles the PE header of files. |
31 | /** | 31 | /** |
32 | * This class can read and modify PE headers. It provides set- and get functions to access | 32 | * This class can read and modify PE headers. It provides set- and get functions to access |
33 | * all individual members of a PE header. Furthermore it's possible to validate and rebuild | 33 | * all individual members of a PE header. Furthermore it's possible to validate and rebuild |
34 | * PE headers. A PE header includes the IMAGE_Nt_HEADERS and the section definitions of a PE file. | 34 | * PE headers. A PE header includes the IMAGE_Nt_HEADERS and the section definitions of a PE file. |
35 | * \todo getIdReservedRva | 35 | * \todo getIdReservedRva |
36 | **/ | 36 | **/ |
37 | template<int x> | 37 | template<int x> |
38 | class PeHeaderT : public PeHeader | 38 | class PeHeaderT : public PeHeader |
39 | { | 39 | { |
40 | private: | 40 | private: |
41 | void readBaseOfData(InputBuffer& ibBuffer, PELIB_IMAGE_NT_HEADERS<x>& header) const; | 41 | void readBaseOfData(InputBuffer& ibBuffer, PELIB_IMAGE_NT_HEADERS<x>& header) const; |
42 | void rebuildBaseOfData(OutputBuffer& obBuffer) const; | 42 | void rebuildBaseOfData(OutputBuffer& obBuffer) const; |
43 | 43 | ||
44 | protected: | 44 | protected: |
45 | std::vector<PELIB_IMAGE_SECTION_HEADER> m_vIsh; ///< Stores section header information. | 45 | std::vector<PELIB_IMAGE_SECTION_HEADER> m_vIsh; ///< Stores section header information. |
46 | PELIB_IMAGE_NT_HEADERS<x> m_inthHeader; ///< Stores Nt header information. | 46 | PELIB_IMAGE_NT_HEADERS<x> m_inthHeader; ///< Stores Nt header information. |
47 | dword m_uiOffset; ///< Equivalent to the value returned by #PeLib::MzHeader::getAddressOfPeFile | 47 | dword m_uiOffset; ///< Equivalent to the value returned by #PeLib::MzHeader::getAddressOfPeFile |
48 | 48 | ||
49 | public: | 49 | public: |
50 | typedef typename FieldSizes<x>::VAR4_8 VAR4_8; | 50 | typedef typename FieldSizes<x>::VAR4_8 VAR4_8; |
51 | 51 | ||
52 | PeHeaderT() : m_uiOffset(0) | 52 | PeHeaderT() : m_uiOffset(0) |
53 | { | 53 | { |
54 | } | 54 | } |
55 | 55 | ||
56 | /// Add a section to the header. | 56 | /// Add a section to the header. |
57 | int addSection(const std::string& strName, dword dwSize); // EXPORT | 57 | int addSection(const std::string& strName, dword dwSize); // EXPORT |
58 | 58 | ||
59 | unsigned int calcSizeOfImage() const; // EXPORT | 59 | unsigned int calcSizeOfImage() const; // EXPORT |
60 | 60 | ||
61 | /// Returns the unused space after the header. | 61 | /// Returns the unused space after the header. |
62 | unsigned int calcSpaceAfterHeader() const; // EXPORT | 62 | unsigned int calcSpaceAfterHeader() const; // EXPORT |
63 | 63 | ||
64 | /// Returns the address of the physically first section (not the first defined section). | 64 | /// Returns the address of the physically first section (not the first defined section). |
65 | unsigned int calcStartOfCode() const; // EXPORT | 65 | unsigned int calcStartOfCode() const; // EXPORT |
66 | 66 | ||
67 | /// Calculates the offset for a new section of size uiSize. | 67 | /// Calculates the offset for a new section of size uiSize. |
68 | unsigned int calcOffset() const; // EXPORT | 68 | unsigned int calcOffset() const; // EXPORT |
69 | 69 | ||
70 | /// Calculates the Rva for a new section of size uiSize. | 70 | /// Calculates the Rva for a new section of size uiSize. |
71 | unsigned int calcRva() const; // EXPORT | 71 | unsigned int calcRva() const; // EXPORT |
72 | 72 | ||
73 | /// Returns the number of sections in the current file. | 73 | /// Returns the number of sections in the current file. |
74 | word calcNumberOfSections() const; // EXPORT | 74 | word calcNumberOfSections() const; // EXPORT |
75 | 75 | ||
76 | void enlargeLastSection(unsigned int uiSize); // EXPORT | 76 | void enlargeLastSection(unsigned int uiSize); // EXPORT |
77 | 77 | ||
78 | /// Returns the section Id of the section that contains the offset. | 78 | /// Returns the section Id of the section that contains the offset. |
79 | word getSectionWithOffset(VAR4_8 dwOffset) const; // EXPORT | 79 | word getSectionWithOffset(VAR4_8 dwOffset) const; // EXPORT |
80 | 80 | ||
81 | /// Returns the number of the section which the given relative address points to. | 81 | /// Returns the number of the section which the given relative address points to. |
82 | word getSectionWithRva(VAR4_8 rva) const; // EXPORT | 82 | word getSectionWithRva(VAR4_8 rva) const; // EXPORT |
83 | 83 | ||
84 | bool isValid() const; // EXPORT | 84 | bool isValid() const; // EXPORT |
85 | bool isValid(unsigned int foo) const; // EXPORT | 85 | bool isValid(unsigned int foo) const; // EXPORT |
86 | 86 | ||
87 | /// Corrects the current PE header. | 87 | /// Corrects the current PE header. |
88 | void makeValid(dword dwOffset); // EXPORT | 88 | void makeValid(dword dwOffset); // EXPORT |
89 | 89 | ||
90 | /// Converts a file offset to a relative virtual offset. | 90 | /// Converts a file offset to a relative virtual offset. |
91 | unsigned int offsetToRva(VAR4_8 dwOffset) const; // EXPORT | 91 | unsigned int offsetToRva(VAR4_8 dwOffset) const; // EXPORT |
92 | 92 | ||
93 | /// Converts a file offset to a virtual address. | 93 | /// Converts a file offset to a virtual address. |
94 | unsigned int offsetToVa(VAR4_8 dwOffset) const; // EXPORT | 94 | unsigned int offsetToVa(VAR4_8 dwOffset) const; // EXPORT |
95 | 95 | ||
96 | /// Reads the PE header of a file. | 96 | /// Reads the PE header of a file. |
97 | int read(std::string strFilename, unsigned int uiOffset); // EXPORT | 97 | int read(std::string strFilename, unsigned int uiOffset); // EXPORT |
98 | 98 | ||
99 | int read(const unsigned char* pcBuffer, unsigned int uiSize, unsigned int uiOffset); // EXPORT | 99 | int read(const unsigned char* pcBuffer, unsigned int uiSize, unsigned int uiOffset); // EXPORT |
100 | 100 | ||
101 | void readHeader(InputBuffer& ibBuffer, PELIB_IMAGE_NT_HEADERS<x>& header) const; | 101 | void readHeader(InputBuffer& ibBuffer, PELIB_IMAGE_NT_HEADERS<x>& header) const; |
102 | void readDataDirectories(InputBuffer& ibBuffer, PELIB_IMAGE_NT_HEADERS<x>& header) const; | 102 | void readDataDirectories(InputBuffer& ibBuffer, PELIB_IMAGE_NT_HEADERS<x>& header) const; |
103 | std::vector<PELIB_IMAGE_SECTION_HEADER> readSections(InputBuffer& ibBuffer, PELIB_IMAGE_NT_HEADERS<x>& header) const; | 103 | std::vector<PELIB_IMAGE_SECTION_HEADER> readSections(InputBuffer& ibBuffer, PELIB_IMAGE_NT_HEADERS<x>& header) const; |
104 | 104 | ||
105 | /// Rebuilds the current PE header. | 105 | /// Rebuilds the current PE header. |
106 | void rebuild(std::vector<byte>& vBuffer) const; // EXPORT | 106 | void rebuild(std::vector<byte>& vBuffer) const; // EXPORT |
107 | 107 | ||
108 | /// Converts a relative virtual address to a file offset. | 108 | /// Converts a relative virtual address to a file offset. |
109 | VAR4_8 rvaToOffset(VAR4_8 dwRva) const; // EXPORT | 109 | VAR4_8 rvaToOffset(VAR4_8 dwRva) const; // EXPORT |
110 | 110 | ||
111 | /// Converts a relative virtual address to a virtual address. | 111 | /// Converts a relative virtual address to a virtual address. |
112 | VAR4_8 rvaToVa(VAR4_8 dwRva) const; // EXPORT | 112 | VAR4_8 rvaToVa(VAR4_8 dwRva) const; // EXPORT |
113 | 113 | ||
114 | /// Calculates the size for the current PE header including all section definitions. | 114 | /// Calculates the size for the current PE header including all section definitions. |
115 | unsigned int size() const; | 115 | unsigned int size() const; |
116 | 116 | ||
117 | VAR4_8 vaToRva(VAR4_8 dwRva) const; // EXPORT | 117 | VAR4_8 vaToRva(VAR4_8 dwRva) const; // EXPORT |
118 | VAR4_8 vaToOffset(VAR4_8 dwRva) const; // EXPORT | 118 | VAR4_8 vaToOffset(VAR4_8 dwRva) const; // EXPORT |
119 | 119 | ||
120 | /// Save the PE header to a file. | 120 | /// Save the PE header to a file. |
121 | int write(std::string strFilename, unsigned int uiOffset) const; // EXPORT | 121 | int write(std::string strFilename, unsigned int uiOffset) const; // EXPORT |
122 | 122 | ||
123 | /// Writes sections to a file. | 123 | /// Writes sections to a file. |
124 | int writeSections(const std::string& strFilename) const; // EXPORT | 124 | int writeSections(const std::string& strFilename) const; // EXPORT |
125 | /// Overwrites a section with new data. | 125 | /// Overwrites a section with new data. |
126 | int writeSectionData(const std::string& strFilename, word wSecnr, const std::vector<byte>& vBuffer) const; // EXPORT | 126 | int writeSectionData(const std::string& strFilename, word wSecnr, const std::vector<byte>& vBuffer) const; // EXPORT |
127 | 127 | ||
128 | // header getters | 128 | // header getters |
129 | /// Returns the Signature value of the header. | 129 | /// Returns the Signature value of the header. |
130 | dword getNtSignature() const; // EXPORT | 130 | dword getNtSignature() const; // EXPORT |
131 | /// Returns the Machine value of the header. | 131 | /// Returns the Machine value of the header. |
132 | word getMachine() const; // EXPORT | 132 | word getMachine() const; // EXPORT |
133 | /// Returns the Sections value of the header. | 133 | /// Returns the Sections value of the header. |
134 | word getNumberOfSections() const; // EXPORT | 134 | word getNumberOfSections() const; // EXPORT |
135 | /// Returns the TimeDateStamp value of the header. | 135 | /// Returns the TimeDateStamp value of the header. |
136 | dword getTimeDateStamp() const; // EXPORT | 136 | dword getTimeDateStamp() const; // EXPORT |
137 | /// Returns the PointerToSymbolTable value of the header. | 137 | /// Returns the PointerToSymbolTable value of the header. |
138 | dword getPointerToSymbolTable() const; // EXPORT | 138 | dword getPointerToSymbolTable() const; // EXPORT |
139 | /// Returns the NumberOfSymbols value of the header. | 139 | /// Returns the NumberOfSymbols value of the header. |
140 | dword getNumberOfSymbols() const; // EXPORT | 140 | dword getNumberOfSymbols() const; // EXPORT |
141 | /// Returns the SizeOfOptionalHeader value of the header. | 141 | /// Returns the SizeOfOptionalHeader value of the header. |
142 | word getSizeOfOptionalHeader() const; // EXPORT | 142 | word getSizeOfOptionalHeader() const; // EXPORT |
143 | /// Returns the Characteristics value of the header. | 143 | /// Returns the Characteristics value of the header. |
144 | word getCharacteristics() const; // EXPORT | 144 | word getCharacteristics() const; // EXPORT |
145 | 145 | ||
146 | /// Returns the Magic value of the header. | 146 | /// Returns the Magic value of the header. |
147 | word getMagic() const; // EXPORT | 147 | word getMagic() const; // EXPORT |
148 | /// Returns the MajorLinkerVersion value of the header. | 148 | /// Returns the MajorLinkerVersion value of the header. |
149 | byte getMajorLinkerVersion() const; // EXPORT | 149 | byte getMajorLinkerVersion() const; // EXPORT |
150 | /// Returns the MinorLinkerVersion value of the header. | 150 | /// Returns the MinorLinkerVersion value of the header. |
151 | byte getMinorLinkerVersion() const; // EXPORT | 151 | byte getMinorLinkerVersion() const; // EXPORT |
152 | /// Returns the SizeOfCode value of the header. | 152 | /// Returns the SizeOfCode value of the header. |
153 | dword getSizeOfCode() const; // EXPORT | 153 | dword getSizeOfCode() const; // EXPORT |
154 | /// Returns the SizeOfInitializedData value of the header. | 154 | /// Returns the SizeOfInitializedData value of the header. |
155 | dword getSizeOfInitializedData() const; // EXPORT | 155 | dword getSizeOfInitializedData() const; // EXPORT |
156 | /// Returns the SizeOfUninitializedData value of the header. | 156 | /// Returns the SizeOfUninitializedData value of the header. |
157 | dword getSizeOfUninitializedData() const; // EXPORT | 157 | dword getSizeOfUninitializedData() const; // EXPORT |
158 | /// Returns the AddressOfEntryPoint value of the header. | 158 | /// Returns the AddressOfEntryPoint value of the header. |
159 | dword getAddressOfEntryPoint() const; // EXPORT | 159 | dword getAddressOfEntryPoint() const; // EXPORT |
160 | /// Returns the BaseOfCode value of the header. | 160 | /// Returns the BaseOfCode value of the header. |
161 | dword getBaseOfCode() const; // EXPORT | 161 | dword getBaseOfCode() const; // EXPORT |
162 | /// Returns the ImageBase value of the header. | 162 | /// Returns the ImageBase value of the header. |
163 | VAR4_8 getImageBase() const; // EXPORT | 163 | VAR4_8 getImageBase() const; // EXPORT |
164 | /// Returns the SectionAlignment value of the header. | 164 | /// Returns the SectionAlignment value of the header. |
165 | dword getSectionAlignment() const; // EXPORT | 165 | dword getSectionAlignment() const; // EXPORT |
166 | /// Returns the FileAlignment value of the header. | 166 | /// Returns the FileAlignment value of the header. |
167 | dword getFileAlignment() const; // EXPORT | 167 | dword getFileAlignment() const; // EXPORT |
168 | /// Returns the MajorOperatingSystemVersion value of the header. | 168 | /// Returns the MajorOperatingSystemVersion value of the header. |
169 | word getMajorOperatingSystemVersion() const; // EXPORT | 169 | word getMajorOperatingSystemVersion() const; // EXPORT |
170 | /// Returns the MinorOperatingSystemVersion value of the header. | 170 | /// Returns the MinorOperatingSystemVersion value of the header. |
171 | word getMinorOperatingSystemVersion() const; // EXPORT | 171 | word getMinorOperatingSystemVersion() const; // EXPORT |
172 | /// Returns the MajorImageVersion value of the header. | 172 | /// Returns the MajorImageVersion value of the header. |
173 | word getMajorImageVersion() const; // EXPORT | 173 | word getMajorImageVersion() const; // EXPORT |
174 | /// Returns the MinorImageVersion value of the header. | 174 | /// Returns the MinorImageVersion value of the header. |
175 | word getMinorImageVersion() const; // EXPORT | 175 | word getMinorImageVersion() const; // EXPORT |
176 | /// Returns the MajorSubsystemVersion value of the header. | 176 | /// Returns the MajorSubsystemVersion value of the header. |
177 | word getMajorSubsystemVersion() const; // EXPORT | 177 | word getMajorSubsystemVersion() const; // EXPORT |
178 | /// Returns the MinorSubsystemVersion value of the header. | 178 | /// Returns the MinorSubsystemVersion value of the header. |
179 | word getMinorSubsystemVersion() const; // EXPORT | 179 | word getMinorSubsystemVersion() const; // EXPORT |
180 | /// Returns the Reserved1 value of the header. | 180 | /// Returns the Reserved1 value of the header. |
181 | dword getWin32VersionValue() const; // EXPORT | 181 | dword getWin32VersionValue() const; // EXPORT |
182 | /// Returns the SizeOfImage value of the header. | 182 | /// Returns the SizeOfImage value of the header. |
183 | dword getSizeOfImage() const; // EXPORT | 183 | dword getSizeOfImage() const; // EXPORT |
184 | /// Returns the SizeOfHeaders value of the header. | 184 | /// Returns the SizeOfHeaders value of the header. |
185 | dword getSizeOfHeaders() const; // EXPORT | 185 | dword getSizeOfHeaders() const; // EXPORT |
186 | /// Returns the CheckSum value of the header. | 186 | /// Returns the CheckSum value of the header. |
187 | dword getCheckSum() const; // EXPORT | 187 | dword getCheckSum() const; // EXPORT |
188 | /// Returns the Subsystem value of the header. | 188 | /// Returns the Subsystem value of the header. |
189 | word getSubsystem() const; // EXPORT | 189 | word getSubsystem() const; // EXPORT |
190 | /// Returns the DllCharacteristics value of the header. | 190 | /// Returns the DllCharacteristics value of the header. |
191 | word getDllCharacteristics() const; // EXPORT | 191 | word getDllCharacteristics() const; // EXPORT |
192 | /// Returns the SizeOfStackReserve value of the header. | 192 | /// Returns the SizeOfStackReserve value of the header. |
193 | VAR4_8 getSizeOfStackReserve() const; // EXPORT | 193 | VAR4_8 getSizeOfStackReserve() const; // EXPORT |
194 | /// Returns the SizeOfStackCommit value of the header. | 194 | /// Returns the SizeOfStackCommit value of the header. |
195 | VAR4_8 getSizeOfStackCommit() const; // EXPORT | 195 | VAR4_8 getSizeOfStackCommit() const; // EXPORT |
196 | /// Returns the SizeOfHeapReserve value of the header. | 196 | /// Returns the SizeOfHeapReserve value of the header. |
197 | VAR4_8 getSizeOfHeapReserve() const; // EXPORT | 197 | VAR4_8 getSizeOfHeapReserve() const; // EXPORT |
198 | /// Returns the SizeOfHeapCommit value of the header. | 198 | /// Returns the SizeOfHeapCommit value of the header. |
199 | VAR4_8 getSizeOfHeapCommit() const; // EXPORT | 199 | VAR4_8 getSizeOfHeapCommit() const; // EXPORT |
200 | /// Returns the LoaderFlags value of the header. | 200 | /// Returns the LoaderFlags value of the header. |
201 | dword getLoaderFlags() const; // EXPORT | 201 | dword getLoaderFlags() const; // EXPORT |
202 | /// Returns the NumberOfRvaAndSizes value of the header. | 202 | /// Returns the NumberOfRvaAndSizes value of the header. |
203 | dword getNumberOfRvaAndSizes() const; // EXPORT | 203 | dword getNumberOfRvaAndSizes() const; // EXPORT |
204 | dword calcNumberOfRvaAndSizes() const; // EXPORT | 204 | dword calcNumberOfRvaAndSizes() const; // EXPORT |
205 | 205 | ||
206 | void addDataDirectory(); // EXPORT | 206 | void addDataDirectory(); // EXPORT |
207 | void removeDataDirectory(dword index); // EXPORT | 207 | void removeDataDirectory(dword index); // EXPORT |
208 | 208 | ||
209 | // image directory getters | 209 | // image directory getters |
210 | /// Returns the relative virtual address of the image directory Export. | 210 | /// Returns the relative virtual address of the image directory Export. |
211 | dword getIddExportRva() const; // EXPORT | 211 | dword getIddExportRva() const; // EXPORT |
212 | /// Returns the size of the image directory Export. | 212 | /// Returns the size of the image directory Export. |
213 | dword getIddExportSize() const; // EXPORT | 213 | dword getIddExportSize() const; // EXPORT |
214 | /// Returns the relative virtual address of the image directory Import. | 214 | /// Returns the relative virtual address of the image directory Import. |
215 | dword getIddImportRva() const; // EXPORT | 215 | dword getIddImportRva() const; // EXPORT |
216 | /// Returns the size of the image directory Import. | 216 | /// Returns the size of the image directory Import. |
217 | dword getIddImportSize() const; // EXPORT | 217 | dword getIddImportSize() const; // EXPORT |
218 | /// Returns the relative virtual address of the image directory Resource. | 218 | /// Returns the relative virtual address of the image directory Resource. |
219 | dword getIddResourceRva() const; // EXPORT | 219 | dword getIddResourceRva() const; // EXPORT |
220 | /// Returns the size of the image directory Resource. | 220 | /// Returns the size of the image directory Resource. |
221 | dword getIddResourceSize() const; // EXPORT | 221 | dword getIddResourceSize() const; // EXPORT |
222 | /// Returns the relative virtual address of the image directory Exception. | 222 | /// Returns the relative virtual address of the image directory Exception. |
223 | dword getIddExceptionRva() const; // EXPORT | 223 | dword getIddExceptionRva() const; // EXPORT |
224 | /// Returns the size of the image directory Exception. | 224 | /// Returns the size of the image directory Exception. |
225 | dword getIddExceptionSize() const; // EXPORT | 225 | dword getIddExceptionSize() const; // EXPORT |
226 | /// Returns the relative virtual address of the image directory Security. | 226 | /// Returns the relative virtual address of the image directory Security. |
227 | dword getIddSecurityRva() const; // EXPORT | 227 | dword getIddSecurityRva() const; // EXPORT |
228 | /// Returns the size of the image directory Security. | 228 | /// Returns the size of the image directory Security. |
229 | dword getIddSecuritySize() const; // EXPORT | 229 | dword getIddSecuritySize() const; // EXPORT |
230 | /// Returns the relative virtual address of the image directory Base Reloc. | 230 | /// Returns the relative virtual address of the image directory Base Reloc. |
231 | dword getIddBaseRelocRva() const; // EXPORT | 231 | dword getIddBaseRelocRva() const; // EXPORT |
232 | /// Returns the size of the image directory Base Reloc. | 232 | /// Returns the size of the image directory Base Reloc. |
233 | dword getIddBaseRelocSize() const; // EXPORT | 233 | dword getIddBaseRelocSize() const; // EXPORT |
234 | /// Returns the relative virtual address of the image directory Debug. | 234 | /// Returns the relative virtual address of the image directory Debug. |
235 | dword getIddDebugRva() const; // EXPORT | 235 | dword getIddDebugRva() const; // EXPORT |
236 | /// Returns the size of the image directory Debug. | 236 | /// Returns the size of the image directory Debug. |
237 | dword getIddDebugSize() const; // EXPORT | 237 | dword getIddDebugSize() const; // EXPORT |
238 | /// Returns the relative virtual address of the image directory Architecture. | 238 | /// Returns the relative virtual address of the image directory Architecture. |
239 | dword getIddArchitectureRva() const; // EXPORT | 239 | dword getIddArchitectureRva() const; // EXPORT |
240 | /// Returns the size of the image directory Architecture. | 240 | /// Returns the size of the image directory Architecture. |
241 | dword getIddArchitectureSize() const; // EXPORT | 241 | dword getIddArchitectureSize() const; // EXPORT |
242 | /// Returns the relative virtual address of the image directory GlobalPtr. | 242 | /// Returns the relative virtual address of the image directory GlobalPtr. |
243 | dword getIddGlobalPtrRva() const; // EXPORT | 243 | dword getIddGlobalPtrRva() const; // EXPORT |
244 | /// Returns the size of the image directory GlobalPtr. | 244 | /// Returns the size of the image directory GlobalPtr. |
245 | dword getIddGlobalPtrSize() const; // EXPORT | 245 | dword getIddGlobalPtrSize() const; // EXPORT |
246 | /// Returns the relative virtual address of the image directory Tls. | 246 | /// Returns the relative virtual address of the image directory Tls. |
247 | dword getIddTlsRva() const; // EXPORT | 247 | dword getIddTlsRva() const; // EXPORT |
248 | /// Returns the size of the image directory Tls. | 248 | /// Returns the size of the image directory Tls. |
249 | dword getIddTlsSize() const; // EXPORT | 249 | dword getIddTlsSize() const; // EXPORT |
250 | /// Returns the relative virtual address of the image directory LoadConfig. | 250 | /// Returns the relative virtual address of the image directory LoadConfig. |
251 | dword getIddLoadConfigRva() const; // EXPORT | 251 | dword getIddLoadConfigRva() const; // EXPORT |
252 | /// Returns the size of the image directory LoadConfig. | 252 | /// Returns the size of the image directory LoadConfig. |
253 | dword getIddLoadConfigSize() const; // EXPORT | 253 | dword getIddLoadConfigSize() const; // EXPORT |
254 | /// Returns the relative virtual address of the image directory BoundImport. | 254 | /// Returns the relative virtual address of the image directory BoundImport. |
255 | dword getIddBoundImportRva() const; // EXPORT | 255 | dword getIddBoundImportRva() const; // EXPORT |
256 | /// Returns the size of the image directory BoundImport. | 256 | /// Returns the size of the image directory BoundImport. |
257 | dword getIddBoundImportSize() const; // EXPORT | 257 | dword getIddBoundImportSize() const; // EXPORT |
258 | /// Returns the relative virtual address of the image directory Iat. | 258 | /// Returns the relative virtual address of the image directory Iat. |
259 | dword getIddIatRva() const; // EXPORT | 259 | dword getIddIatRva() const; // EXPORT |
260 | /// Returns the size of the image directory Iat. | 260 | /// Returns the size of the image directory Iat. |
261 | dword getIddIatSize() const; // EXPORT | 261 | dword getIddIatSize() const; // EXPORT |
262 | /// Returns the relative virtual address of the image directory DelayImport. | 262 | /// Returns the relative virtual address of the image directory DelayImport. |
263 | dword getIddDelayImportRva() const; // EXPORT | 263 | dword getIddDelayImportRva() const; // EXPORT |
264 | /// Returns the size of the image directory DelayImport. | 264 | /// Returns the size of the image directory DelayImport. |
265 | dword getIddDelayImportSize() const; // EXPORT | 265 | dword getIddDelayImportSize() const; // EXPORT |
266 | /// Returns the relative virtual address of the image directory COM Descriptor. | 266 | /// Returns the relative virtual address of the image directory COM Descriptor. |
267 | dword getIddComHeaderRva() const; // EXPORT | 267 | dword getIddComHeaderRva() const; // EXPORT |
268 | /// Returns the size of the image directory COM Descriptor. | 268 | /// Returns the size of the image directory COM Descriptor. |
269 | dword getIddComHeaderSize() const; // EXPORT | 269 | dword getIddComHeaderSize() const; // EXPORT |
270 | 270 | ||
271 | /// Returns the relative virtual address of an image directory. | 271 | /// Returns the relative virtual address of an image directory. |
272 | dword getImageDataDirectoryRva(dword dwDirectory) const; // EXPORT | 272 | dword getImageDataDirectoryRva(dword dwDirectory) const; // EXPORT |
273 | /// Returns the size of an image directory. | 273 | /// Returns the size of an image directory. |
274 | dword getImageDataDirectorySize(dword dwDirectory) const; // EXPORT | 274 | dword getImageDataDirectorySize(dword dwDirectory) const; // EXPORT |
275 | 275 | ||
276 | void setImageDataDirectoryRva(dword dwDirectory, dword value); // EXPORT | 276 | void setImageDataDirectoryRva(dword dwDirectory, dword value); // EXPORT |
277 | void setImageDataDirectorySize(dword dwDirectory, dword value); // EXPORT | 277 | void setImageDataDirectorySize(dword dwDirectory, dword value); // EXPORT |
278 | 278 | ||
279 | // section getters | 279 | // section getters |
280 | /// Returns the name of a section. | 280 | /// Returns the name of a section. |
281 | std::string getSectionName(word uiSectionnr) const; // EXPORT | 281 | std::string getSectionName(word uiSectionnr) const; // EXPORT |
282 | /// Returns the virtual size of a section. | 282 | /// Returns the virtual size of a section. |
283 | dword getVirtualSize(word uiSectionnr) const; // EXPORT | 283 | dword getVirtualSize(word uiSectionnr) const; // EXPORT |
284 | /// Returns the virtual address of a section. | 284 | /// Returns the virtual address of a section. |
285 | dword getVirtualAddress(word uiSectionnr) const; // EXPORT | 285 | dword getVirtualAddress(word uiSectionnr) const; // EXPORT |
286 | /// Returns the size of a section's raw data. | 286 | /// Returns the size of a section's raw data. |
287 | dword getSizeOfRawData(word uiSectionnr) const; // EXPORT | 287 | dword getSizeOfRawData(word uiSectionnr) const; // EXPORT |
288 | /// Returns file offset of the data of a section. | 288 | /// Returns file offset of the data of a section. |
289 | dword getPointerToRawData(word uiSectionnr) const; // EXPORT | 289 | dword getPointerToRawData(word uiSectionnr) const; // EXPORT |
290 | /// Returns the rva of the relocations of a section. | 290 | /// Returns the rva of the relocations of a section. |
291 | dword getPointerToRelocations(word uiSectionnr) const; // EXPORT | 291 | dword getPointerToRelocations(word uiSectionnr) const; // EXPORT |
292 | /// Returns the rva of the line numbers of a section. | 292 | /// Returns the rva of the line numbers of a section. |
293 | dword getPointerToLinenumbers(word uiSectionnr) const; // EXPORT | 293 | dword getPointerToLinenumbers(word uiSectionnr) const; // EXPORT |
294 | /// Returns the number of relocations of a section. | 294 | /// Returns the number of relocations of a section. |
295 | dword getNumberOfRelocations(word uiSectionnr) const; // EXPORT | 295 | dword getNumberOfRelocations(word uiSectionnr) const; // EXPORT |
296 | /// Returns the number of line numbers of a section. | 296 | /// Returns the number of line numbers of a section. |
297 | dword getNumberOfLinenumbers(word uiSectionnr) const; // EXPORT | 297 | dword getNumberOfLinenumbers(word uiSectionnr) const; // EXPORT |
298 | /// Returns the characteristics of a section. | 298 | /// Returns the characteristics of a section. |
299 | dword getCharacteristics(word uiSectionnr) const; // EXPORT _section | 299 | dword getCharacteristics(word uiSectionnr) const; // EXPORT _section |
300 | 300 | ||
301 | // header setters | 301 | // header setters |
302 | /// Sets the Signature value of the header. | 302 | /// Sets the Signature value of the header. |
303 | void setNtSignature(dword value); // EXPORT | 303 | void setNtSignature(dword value); // EXPORT |
304 | /// Sets the Machine value of the header. | 304 | /// Sets the Machine value of the header. |
305 | void setMachine(word value); // EXPORT | 305 | void setMachine(word value); // EXPORT |
306 | /// Sets the Sections value of the header. | 306 | /// Sets the Sections value of the header. |
307 | void setNumberOfSections(word value); // EXPORT | 307 | void setNumberOfSections(word value); // EXPORT |
308 | /// Sets the TimeDateStamp value of the header. | 308 | /// Sets the TimeDateStamp value of the header. |
309 | void setTimeDateStamp(dword value); // EXPORT | 309 | void setTimeDateStamp(dword value); // EXPORT |
310 | /// Sets the PointerToSymbolTable value of the header. | 310 | /// Sets the PointerToSymbolTable value of the header. |
311 | void setPointerToSymbolTable(dword value); // EXPORT | 311 | void setPointerToSymbolTable(dword value); // EXPORT |
312 | /// Sets the NumberOfSymbols value of the header. | 312 | /// Sets the NumberOfSymbols value of the header. |
313 | void setNumberOfSymbols(dword value); // EXPORT | 313 | void setNumberOfSymbols(dword value); // EXPORT |
314 | /// Sets the SizeOfOptionalHeader value of the header. | 314 | /// Sets the SizeOfOptionalHeader value of the header. |
315 | void setSizeOfOptionalHeader(word value); // EXPORT | 315 | void setSizeOfOptionalHeader(word value); // EXPORT |
316 | /// Sets the Characteristics value of the header. | 316 | /// Sets the Characteristics value of the header. |
317 | void setCharacteristics(word value); // EXPORT _section | 317 | void setCharacteristics(word value); // EXPORT _section |
318 | 318 | ||
319 | /// Sets the Magic value of the header. | 319 | /// Sets the Magic value of the header. |
320 | void setMagic(word value); // EXPORT | 320 | void setMagic(word value); // EXPORT |
321 | /// Sets the MajorLinkerVersion value of the header. | 321 | /// Sets the MajorLinkerVersion value of the header. |
322 | void setMajorLinkerVersion(byte value); // EXPORT | 322 | void setMajorLinkerVersion(byte value); // EXPORT |
323 | /// Sets the MinorLinkerVersion value of the header. | 323 | /// Sets the MinorLinkerVersion value of the header. |
324 | void setMinorLinkerVersion(byte value); // EXPORT | 324 | void setMinorLinkerVersion(byte value); // EXPORT |
325 | /// Sets the SizeOfCode value of the header. | 325 | /// Sets the SizeOfCode value of the header. |
326 | void setSizeOfCode(dword value); // EXPORT | 326 | void setSizeOfCode(dword value); // EXPORT |
327 | /// Sets the SizeOfInitializedData value of the header. | 327 | /// Sets the SizeOfInitializedData value of the header. |
328 | void setSizeOfInitializedData(dword value); // EXPORT | 328 | void setSizeOfInitializedData(dword value); // EXPORT |
329 | /// Sets the SizeOfUninitializedData value of the header. | 329 | /// Sets the SizeOfUninitializedData value of the header. |
330 | void setSizeOfUninitializedData(dword value); // EXPORT | 330 | void setSizeOfUninitializedData(dword value); // EXPORT |
331 | /// Sets the AddressOfEntryPoint value of the header. | 331 | /// Sets the AddressOfEntryPoint value of the header. |
332 | void setAddressOfEntryPoint(dword value); // EXPORT | 332 | void setAddressOfEntryPoint(dword value); // EXPORT |
333 | /// Sets the BaseOfCode value of the header. | 333 | /// Sets the BaseOfCode value of the header. |
334 | void setBaseOfCode(dword value); // EXPORT | 334 | void setBaseOfCode(dword value); // EXPORT |
335 | /// Sets the ImageBase value of the header. | 335 | /// Sets the ImageBase value of the header. |
336 | void setImageBase(VAR4_8 value); // EXPORT | 336 | void setImageBase(VAR4_8 value); // EXPORT |
337 | /// Sets the SectionAlignment value of the header. | 337 | /// Sets the SectionAlignment value of the header. |
338 | void setSectionAlignment(dword value); // EXPORT | 338 | void setSectionAlignment(dword value); // EXPORT |
339 | /// Sets the FileAlignment value of the header. | 339 | /// Sets the FileAlignment value of the header. |
340 | void setFileAlignment(dword value); // EXPORT | 340 | void setFileAlignment(dword value); // EXPORT |
341 | /// Sets the MajorOperatingSystemVersion value of the header. | 341 | /// Sets the MajorOperatingSystemVersion value of the header. |
342 | void setMajorOperatingSystemVersion(word value); // EXPORT | 342 | void setMajorOperatingSystemVersion(word value); // EXPORT |
343 | /// Sets the MinorOperatingSystemVersion value of the header. | 343 | /// Sets the MinorOperatingSystemVersion value of the header. |
344 | void setMinorOperatingSystemVersion(word value); // EXPORT | 344 | void setMinorOperatingSystemVersion(word value); // EXPORT |
345 | /// Sets the MajorImageVersion value of the header. | 345 | /// Sets the MajorImageVersion value of the header. |
346 | void setMajorImageVersion(word value); // EXPORT | 346 | void setMajorImageVersion(word value); // EXPORT |
347 | /// Sets the MinorImageVersion value of the header. | 347 | /// Sets the MinorImageVersion value of the header. |
348 | void setMinorImageVersion(word value); // EXPORT | 348 | void setMinorImageVersion(word value); // EXPORT |
349 | /// Sets the MajorSubsystemVersion value of the header. | 349 | /// Sets the MajorSubsystemVersion value of the header. |
350 | void setMajorSubsystemVersion(word value); // EXPORT | 350 | void setMajorSubsystemVersion(word value); // EXPORT |
351 | /// Sets the MinorSubsystemVersion value of the header. | 351 | /// Sets the MinorSubsystemVersion value of the header. |
352 | void setMinorSubsystemVersion(word value); // EXPORT | 352 | void setMinorSubsystemVersion(word value); // EXPORT |
353 | /// Sets the Reserved1 value of the header. | 353 | /// Sets the Reserved1 value of the header. |
354 | void setWin32VersionValue(dword value); // EXPORT | 354 | void setWin32VersionValue(dword value); // EXPORT |
355 | /// Sets the SizeOfImage value of the header. | 355 | /// Sets the SizeOfImage value of the header. |
356 | void setSizeOfImage(dword value); // EXPORT | 356 | void setSizeOfImage(dword value); // EXPORT |
357 | /// Sets the SizeOfHeaders value of the header. | 357 | /// Sets the SizeOfHeaders value of the header. |
358 | void setSizeOfHeaders(dword value); // EXPORT | 358 | void setSizeOfHeaders(dword value); // EXPORT |
359 | /// Sets the CheckSum value of the header. | 359 | /// Sets the CheckSum value of the header. |
360 | void setCheckSum(dword value); // EXPORT | 360 | void setCheckSum(dword value); // EXPORT |
361 | /// Sets the Subsystem value of the header. | 361 | /// Sets the Subsystem value of the header. |
362 | void setSubsystem(word value); // EXPORT | 362 | void setSubsystem(word value); // EXPORT |
363 | /// Sets the DllCharacteristics value of the header. | 363 | /// Sets the DllCharacteristics value of the header. |
364 | void setDllCharacteristics(word value); // EXPORT | 364 | void setDllCharacteristics(word value); // EXPORT |
365 | /// Sets the SizeOfStackReserve value of the header. | 365 | /// Sets the SizeOfStackReserve value of the header. |
366 | void setSizeOfStackReserve(VAR4_8 value); // EXPORT | 366 | void setSizeOfStackReserve(VAR4_8 value); // EXPORT |
367 | /// Sets the SizeOfStackCommit value of the header. | 367 | /// Sets the SizeOfStackCommit value of the header. |
368 | void setSizeOfStackCommit(VAR4_8 value); // EXPORT | 368 | void setSizeOfStackCommit(VAR4_8 value); // EXPORT |
369 | /// Sets the SizeOfHeapReserve value of the header. | 369 | /// Sets the SizeOfHeapReserve value of the header. |
370 | void setSizeOfHeapReserve(VAR4_8 value); // EXPORT | 370 | void setSizeOfHeapReserve(VAR4_8 value); // EXPORT |
371 | /// Sets the SizeOfHeapCommit value of the header. | 371 | /// Sets the SizeOfHeapCommit value of the header. |
372 | void setSizeOfHeapCommit(VAR4_8 value); // EXPORT | 372 | void setSizeOfHeapCommit(VAR4_8 value); // EXPORT |
373 | /// Sets the LoaderFlags value of the header. | 373 | /// Sets the LoaderFlags value of the header. |
374 | void setLoaderFlags(dword value); // EXPORT | 374 | void setLoaderFlags(dword value); // EXPORT |
375 | /// Sets the NumberOfRvaAndSizes value of the header. | 375 | /// Sets the NumberOfRvaAndSizes value of the header. |
376 | void setNumberOfRvaAndSizes(dword value); // EXPORT | 376 | void setNumberOfRvaAndSizes(dword value); // EXPORT |
377 | 377 | ||
378 | // image directory getters | 378 | // image directory getters |
379 | void setIddDebugRva(dword dwValue); // EXPORT | 379 | void setIddDebugRva(dword dwValue); // EXPORT |
380 | void setIddDebugSize(dword dwValue); // EXPORT | 380 | void setIddDebugSize(dword dwValue); // EXPORT |
381 | void setIddDelayImportRva(dword dwValue); // EXPORT | 381 | void setIddDelayImportRva(dword dwValue); // EXPORT |
382 | void setIddDelayImportSize(dword dwValue); // EXPORT | 382 | void setIddDelayImportSize(dword dwValue); // EXPORT |
383 | void setIddExceptionRva(dword dwValue); // EXPORT | 383 | void setIddExceptionRva(dword dwValue); // EXPORT |
384 | void setIddExceptionSize(dword dwValue); // EXPORT | 384 | void setIddExceptionSize(dword dwValue); // EXPORT |
385 | void setIddGlobalPtrRva(dword dwValue); // EXPORT | 385 | void setIddGlobalPtrRva(dword dwValue); // EXPORT |
386 | void setIddGlobalPtrSize(dword dwValue); // EXPORT | 386 | void setIddGlobalPtrSize(dword dwValue); // EXPORT |
387 | void setIddIatRva(dword dwValue); // EXPORT | 387 | void setIddIatRva(dword dwValue); // EXPORT |
388 | void setIddIatSize(dword dwValue); // EXPORT | 388 | void setIddIatSize(dword dwValue); // EXPORT |
389 | void setIddLoadConfigRva(dword dwValue); // EXPORT | 389 | void setIddLoadConfigRva(dword dwValue); // EXPORT |
390 | void setIddLoadConfigSize(dword dwValue); // EXPORT | 390 | void setIddLoadConfigSize(dword dwValue); // EXPORT |
391 | void setIddResourceRva(dword dwValue); // EXPORT | 391 | void setIddResourceRva(dword dwValue); // EXPORT |
392 | void setIddResourceSize(dword dwValue); // EXPORT | 392 | void setIddResourceSize(dword dwValue); // EXPORT |
393 | void setIddSecurityRva(dword dwValue); // EXPORT | 393 | void setIddSecurityRva(dword dwValue); // EXPORT |
394 | void setIddSecuritySize(dword dwValue); // EXPORT | 394 | void setIddSecuritySize(dword dwValue); // EXPORT |
395 | void setIddTlsRva(dword dwValue); // EXPORT | 395 | void setIddTlsRva(dword dwValue); // EXPORT |
396 | void setIddTlsSize(dword dwValue); // EXPORT | 396 | void setIddTlsSize(dword dwValue); // EXPORT |
397 | 397 | ||
398 | void setIddImportRva(dword dwValue); // EXPORT | 398 | void setIddImportRva(dword dwValue); // EXPORT |
399 | void setIddImportSize(dword dwValue); // EXPORT | 399 | void setIddImportSize(dword dwValue); // EXPORT |
400 | void setIddExportRva(dword dwValue); // EXPORT | 400 | void setIddExportRva(dword dwValue); // EXPORT |
401 | void setIddExportSize(dword dwValue); // EXPORT | 401 | void setIddExportSize(dword dwValue); // EXPORT |
402 | 402 | ||
403 | void setIddBaseRelocRva(dword value); // EXPORT | 403 | void setIddBaseRelocRva(dword value); // EXPORT |
404 | void setIddBaseRelocSize(dword value); // EXPORT | 404 | void setIddBaseRelocSize(dword value); // EXPORT |
405 | void setIddArchitectureRva(dword value); // EXPORT | 405 | void setIddArchitectureRva(dword value); // EXPORT |
406 | void setIddArchitectureSize(dword value); // EXPORT | 406 | void setIddArchitectureSize(dword value); // EXPORT |
407 | void setIddComHeaderRva(dword value); // EXPORT | 407 | void setIddComHeaderRva(dword value); // EXPORT |
408 | void setIddComHeaderSize(dword value); // EXPORT | 408 | void setIddComHeaderSize(dword value); // EXPORT |
409 | 409 | ||
410 | /// Set the name of a section. | 410 | /// Set the name of a section. |
411 | void setSectionName(word uiSectionnr, std::string strName); // EXPORT | 411 | void setSectionName(word uiSectionnr, std::string strName); // EXPORT |
412 | /// Set the virtual size of a section. | 412 | /// Set the virtual size of a section. |
413 | void setVirtualSize(word uiSectionnr, dword dwValue); // EXPORT | 413 | void setVirtualSize(word uiSectionnr, dword dwValue); // EXPORT |
414 | /// Set the virtual address of a section. | 414 | /// Set the virtual address of a section. |
415 | void setVirtualAddress(word uiSectionnr, dword dwValue); // EXPORT | 415 | void setVirtualAddress(word uiSectionnr, dword dwValue); // EXPORT |
416 | /// Set the size of raw data of a section. | 416 | /// Set the size of raw data of a section. |
417 | void setSizeOfRawData(word uiSectionnr, dword dwValue); // EXPORT | 417 | void setSizeOfRawData(word uiSectionnr, dword dwValue); // EXPORT |
418 | /// Set the file offset of a section. | 418 | /// Set the file offset of a section. |
419 | void setPointerToRawData(word uiSectionnr, dword dwValue); // EXPORT | 419 | void setPointerToRawData(word uiSectionnr, dword dwValue); // EXPORT |
420 | /// Set the pointer to relocations of a section. | 420 | /// Set the pointer to relocations of a section. |
421 | void setPointerToRelocations(word uiSectionnr, dword dwValue); // EXPORT | 421 | void setPointerToRelocations(word uiSectionnr, dword dwValue); // EXPORT |
422 | /// Set the pointer to linenumbers of a section. | 422 | /// Set the pointer to linenumbers of a section. |
423 | void setPointerToLinenumbers(word uiSectionnr, dword dwValue); // EXPORT | 423 | void setPointerToLinenumbers(word uiSectionnr, dword dwValue); // EXPORT |
424 | /// Set the number of relocations a section. | 424 | /// Set the number of relocations a section. |
425 | void setNumberOfRelocations(word uiSectionnr, dword dwValue); // EXPORT | 425 | void setNumberOfRelocations(word uiSectionnr, dword dwValue); // EXPORT |
426 | /// Set the number of linenumbers section. | 426 | /// Set the number of linenumbers section. |
427 | void setNumberOfLinenumbers(word uiSectionnr, dword dwValue); // EXPORT | 427 | void setNumberOfLinenumbers(word uiSectionnr, dword dwValue); // EXPORT |
428 | /// Set the characteristics of a section. | 428 | /// Set the characteristics of a section. |
429 | void setCharacteristics(word uiSectionnr, dword dwValue); // EXPORT | 429 | void setCharacteristics(word uiSectionnr, dword dwValue); // EXPORT |
430 | }; | 430 | }; |
431 | 431 | ||
432 | class PeHeader32 : public PeHeaderT<32> | 432 | class PeHeader32 : public PeHeaderT<32> |
433 | { | 433 | { |
434 | public: | 434 | public: |
435 | /// Returns the BaseOfData value of the header. | 435 | /// Returns the BaseOfData value of the header. |
436 | dword getBaseOfData() const; // EXPORT | 436 | dword getBaseOfData() const; // EXPORT |
437 | /// Sets the BaseOfData value of the header. | 437 | /// Sets the BaseOfData value of the header. |
438 | void setBaseOfData(dword value); // EXPORT | 438 | void setBaseOfData(dword value); // EXPORT |
439 | }; | 439 | }; |
440 | 440 | ||
441 | class PeHeader64 : public PeHeaderT<64> | 441 | class PeHeader64 : public PeHeaderT<64> |
442 | { | 442 | { |
443 | }; | 443 | }; |
444 | 444 | ||
445 | template<int x> | 445 | template<int x> |
446 | void PeHeaderT<x>::addDataDirectory() | 446 | void PeHeaderT<x>::addDataDirectory() |
447 | { | 447 | { |
448 | m_inthHeader.dataDirectories.push_back(PELIB_IMAGE_DATA_DIRECTORY()); | 448 | m_inthHeader.dataDirectories.push_back(PELIB_IMAGE_DATA_DIRECTORY()); |
449 | } | 449 | } |
450 | 450 | ||
451 | template<int x> | 451 | template<int x> |
452 | void PeHeaderT<x>::removeDataDirectory(dword index) | 452 | void PeHeaderT<x>::removeDataDirectory(dword index) |
453 | { | 453 | { |
454 | m_inthHeader.dataDirectories.erase(m_inthHeader.dataDirectories.begin() + index); | 454 | m_inthHeader.dataDirectories.erase(m_inthHeader.dataDirectories.begin() + index); |
455 | } | 455 | } |
456 | 456 | ||
457 | /** | 457 | /** |
458 | * Adds a new section to the header. The physical and virtual address as well as the virtual | 458 | * Adds a new section to the header. The physical and virtual address as well as the virtual |
459 | * size of the section will be determined automatically from the raw size. The section | 459 | * size of the section will be determined automatically from the raw size. The section |
460 | * characteristics will be set to IMAGE_SCN_MEM_WRITE | IMAGE_SCN_MEM_READ | | 460 | * characteristics will be set to IMAGE_SCN_MEM_WRITE | IMAGE_SCN_MEM_READ | |
461 | * IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_CNT_CODE. All other values will be set to 0. | 461 | * IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_CNT_CODE. All other values will be set to 0. |
462 | * Note: It's important that if the current header's FileAlignment and/or SectionAlignment values are | 462 | * Note: It's important that if the current header's FileAlignment and/or SectionAlignment values are |
463 | * 0 this function will fail. | 463 | * 0 this function will fail. |
464 | * @param strName Name of the new section. If this name is longer than 8 bytes only the first 8 bytes will be used. | 464 | * @param strName Name of the new section. If this name is longer than 8 bytes only the first 8 bytes will be used. |
465 | * @param dwSize Physical size of the new section in bytes. | 465 | * @param dwSize Physical size of the new section in bytes. |
466 | * \todo Better code that handles files with 0 sections. | 466 | * \todo Better code that handles files with 0 sections. |
467 | **/ | 467 | **/ |
468 | template<int x> | 468 | template<int x> |
469 | int PeHeaderT<x>::addSection(const std::string& strName, dword dwSize) | 469 | int PeHeaderT<x>::addSection(const std::string& strName, dword dwSize) |
470 | { | 470 | { |
471 | unsigned int uiSecnr = calcNumberOfSections(); | 471 | unsigned int uiSecnr = calcNumberOfSections(); |
472 | 472 | ||
473 | if (!getFileAlignment()) | 473 | if (!getFileAlignment()) |
474 | { | 474 | { |
475 | return ERROR_NO_FILE_ALIGNMENT; | 475 | return ERROR_NO_FILE_ALIGNMENT; |
476 | } | 476 | } |
477 | else if (!getSectionAlignment()) | 477 | else if (!getSectionAlignment()) |
478 | { | 478 | { |
479 | return ERROR_NO_SECTION_ALIGNMENT; | 479 | return ERROR_NO_SECTION_ALIGNMENT; |
480 | } | 480 | } |
481 | 481 | ||
482 | if (uiSecnr) // Always allow 1 section. | 482 | if (uiSecnr) // Always allow 1 section. |
483 | { | 483 | { |
484 | if (uiSecnr == 0xFFFF) | 484 | if (uiSecnr == 0xFFFF) |
485 | { | 485 | { |
486 | return ERROR_TOO_MANY_SECTIONS; | 486 | return ERROR_TOO_MANY_SECTIONS; |
487 | } | 487 | } |
488 | else if (calcSpaceAfterHeader() < PELIB_IMAGE_SECTION_HEADER::size()) | 488 | else if (calcSpaceAfterHeader() < PELIB_IMAGE_SECTION_HEADER::size()) |
489 | { | 489 | { |
490 | return ERROR_NOT_ENOUGH_SPACE; | 490 | return ERROR_NOT_ENOUGH_SPACE; |
491 | } | 491 | } |
492 | } | 492 | } |
493 | 493 | ||
494 | dword dwOffset = calcOffset(/*dwSize*/); | 494 | dword dwOffset = calcOffset(/*dwSize*/); |
495 | dword dwRva = calcRva(/*dwSize*/); | 495 | dword dwRva = calcRva(/*dwSize*/); |
496 | 496 | ||
497 | PELIB_IMAGE_SECTION_HEADER ishdCurr; | 497 | PELIB_IMAGE_SECTION_HEADER ishdCurr; |
498 | m_vIsh.push_back(ishdCurr); | 498 | m_vIsh.push_back(ishdCurr); |
499 | 499 | ||
500 | setSectionName(uiSecnr, strName); | 500 | setSectionName(uiSecnr, strName); |
501 | setSizeOfRawData(uiSecnr, alignOffset(dwSize, getFileAlignment())); | 501 | setSizeOfRawData(uiSecnr, alignOffset(dwSize, getFileAlignment())); |
502 | setPointerToRawData(uiSecnr, dwOffset); | 502 | setPointerToRawData(uiSecnr, dwOffset); |
503 | setVirtualSize(uiSecnr, alignOffset(dwSize, getSectionAlignment())); | 503 | setVirtualSize(uiSecnr, alignOffset(dwSize, getSectionAlignment())); |
504 | setVirtualAddress(uiSecnr, dwRva); | 504 | setVirtualAddress(uiSecnr, dwRva); |
505 | setCharacteristics(uiSecnr, PELIB_IMAGE_SCN_MEM_WRITE | PELIB_IMAGE_SCN_MEM_READ | PELIB_IMAGE_SCN_CNT_INITIALIZED_DATA | PELIB_IMAGE_SCN_CNT_CODE); | 505 | setCharacteristics(uiSecnr, PELIB_IMAGE_SCN_MEM_WRITE | PELIB_IMAGE_SCN_MEM_READ | PELIB_IMAGE_SCN_CNT_INITIALIZED_DATA | PELIB_IMAGE_SCN_CNT_CODE); |
506 | 506 | ||
507 | return NO_ERROR; | 507 | return NO_ERROR; |
508 | } | 508 | } |
509 | 509 | ||
510 | /** | 510 | /** |
511 | * Calculates a valid SizeOfImage value given the information from the current PE header. | 511 | * Calculates a valid SizeOfImage value given the information from the current PE header. |
512 | * Note that this calculation works in Win2K but probably does not work in Win9X. I didn't test that though. | 512 | * Note that this calculation works in Win2K but probably does not work in Win9X. I didn't test that though. |
513 | * @return Valid SizeOfImage value. | 513 | * @return Valid SizeOfImage value. |
514 | **/ | 514 | **/ |
515 | template<int x> | 515 | template<int x> |
516 | unsigned int PeHeaderT<x>::calcSizeOfImage() const | 516 | unsigned int PeHeaderT<x>::calcSizeOfImage() const |
517 | { | 517 | { |
518 | // Major note here: It's possible for sections to exist with a Virtual Size of 0. | 518 | // Major note here: It's possible for sections to exist with a Virtual Size of 0. |
519 | // That's why it's necessary to use std::max(Vsize, RawSize) here. | 519 | // That's why it's necessary to use std::max(Vsize, RawSize) here. |
520 | // An example for such a file is dbeng6.exe (made by Sybase). | 520 | // An example for such a file is dbeng6.exe (made by Sybase). |
521 | // In this file each and every section has a VSize of 0 but it still runs. | 521 | // In this file each and every section has a VSize of 0 but it still runs. |
522 | 522 | ||
523 | std::vector<PELIB_IMAGE_SECTION_HEADER>::const_iterator ishLastSection = std::max_element(m_vIsh.begin(), m_vIsh.end(), std::mem_fun_ref(&PELIB_IMAGE_SECTION_HEADER::biggerVirtualAddress)); | 523 | std::vector<PELIB_IMAGE_SECTION_HEADER>::const_iterator ishLastSection = std::max_element(m_vIsh.begin(), m_vIsh.end(), std::mem_fun_ref(&PELIB_IMAGE_SECTION_HEADER::biggerVirtualAddress)); |
524 | if (ishLastSection->VirtualSize != 0) return ishLastSection->VirtualAddress + ishLastSection->VirtualSize; | 524 | if (ishLastSection->VirtualSize != 0) return ishLastSection->VirtualAddress + ishLastSection->VirtualSize; |
525 | return ishLastSection->VirtualAddress + std::max(ishLastSection->VirtualSize, ishLastSection->SizeOfRawData); | 525 | return ishLastSection->VirtualAddress + std::max(ishLastSection->VirtualSize, ishLastSection->SizeOfRawData); |
526 | } | 526 | } |
527 | 527 | ||
528 | /** | 528 | /** |
529 | * Calculates the space between the last byte of the header and the first byte that's used for something | 529 | * Calculates the space between the last byte of the header and the first byte that's used for something |
530 | * else (that's either the first section or an image directory). | 530 | * else (that's either the first section or an image directory). |
531 | * @return Unused space after the header. | 531 | * @return Unused space after the header. |
532 | * \todo There are PE files with sections beginning at offset 0. They | 532 | * \todo There are PE files with sections beginning at offset 0. They |
533 | * need to be considered. | 533 | * need to be considered. |
534 | **/ | 534 | **/ |
535 | template<int x> | 535 | template<int x> |
536 | unsigned int PeHeaderT<x>::calcSpaceAfterHeader() const | 536 | unsigned int PeHeaderT<x>::calcSpaceAfterHeader() const |
537 | { | 537 | { |
538 | return (calcStartOfCode() > size() + m_uiOffset) ? calcStartOfCode() - (size() + m_uiOffset) : 0; | 538 | return (calcStartOfCode() > size() + m_uiOffset) ? calcStartOfCode() - (size() + m_uiOffset) : 0; |
539 | } | 539 | } |
540 | 540 | ||
541 | /** | 541 | /** |
542 | * Returns the first offset of the file that's actually used for something different than the header. | 542 | * Returns the first offset of the file that's actually used for something different than the header. |
543 | * That something is not necessarily code, it can be a data directory too. | 543 | * That something is not necessarily code, it can be a data directory too. |
544 | * This offset can be the beginning of a section or the beginning of a directory. | 544 | * This offset can be the beginning of a section or the beginning of a directory. |
545 | * \todo Some optimizization is surely possible here. | 545 | * \todo Some optimizization is surely possible here. |
546 | * \todo There are PE files with sections beginning at offset 0. They | 546 | * \todo There are PE files with sections beginning at offset 0. They |
547 | * need to be considered. Returning 0 for these files doesn't really make sense. | 547 | * need to be considered. Returning 0 for these files doesn't really make sense. |
548 | * So far these sections are disregarded. | 548 | * So far these sections are disregarded. |
549 | **/ | 549 | **/ |
550 | template<int x> | 550 | template<int x> |
551 | unsigned int PeHeaderT<x>::calcStartOfCode() const | 551 | unsigned int PeHeaderT<x>::calcStartOfCode() const |
552 | { | 552 | { |
553 | unsigned int directories = calcNumberOfRvaAndSizes(); | 553 | unsigned int directories = calcNumberOfRvaAndSizes(); |
554 | dword dwMinOffset = 0xFFFFFFFF; | 554 | dword dwMinOffset = 0xFFFFFFFF; |
555 | if (directories >= 1 && getIddExportRva() && rvaToOffset(getIddExportRva()) < dwMinOffset) dwMinOffset = rvaToOffset(getIddExportRva()); | 555 | if (directories >= 1 && getIddExportRva() && rvaToOffset(getIddExportRva()) < dwMinOffset) dwMinOffset = rvaToOffset(getIddExportRva()); |
556 | if (directories >= 2 && getIddImportRva() && rvaToOffset(getIddImportRva()) < dwMinOffset) dwMinOffset = rvaToOffset(getIddImportRva()); | 556 | if (directories >= 2 && getIddImportRva() && rvaToOffset(getIddImportRva()) < dwMinOffset) dwMinOffset = rvaToOffset(getIddImportRva()); |
557 | if (directories >= 3 && getIddResourceRva() && rvaToOffset(getIddResourceRva()) < dwMinOffset) dwMinOffset = rvaToOffset(getIddResourceRva()); | 557 | if (directories >= 3 && getIddResourceRva() && rvaToOffset(getIddResourceRva()) < dwMinOffset) dwMinOffset = rvaToOffset(getIddResourceRva()); |
558 | if (directories >= 4 && getIddExceptionRva() && rvaToOffset(getIddExceptionRva()) < dwMinOffset) dwMinOffset = rvaToOffset(getIddExceptionRva()); | 558 | if (directories >= 4 && getIddExceptionRva() && rvaToOffset(getIddExceptionRva()) < dwMinOffset) dwMinOffset = rvaToOffset(getIddExceptionRva()); |
559 | if (directories >= 5 && getIddSecurityRva() && rvaToOffset(getIddSecurityRva()) < dwMinOffset) dwMinOffset = rvaToOffset(getIddSecurityRva()); | 559 | if (directories >= 5 && getIddSecurityRva() && rvaToOffset(getIddSecurityRva()) < dwMinOffset) dwMinOffset = rvaToOffset(getIddSecurityRva()); |
560 | if (directories >= 6 && getIddBaseRelocRva() && rvaToOffset(getIddBaseRelocRva()) < dwMinOffset) dwMinOffset = rvaToOffset(getIddBaseRelocRva()); | 560 | if (directories >= 6 && getIddBaseRelocRva() && rvaToOffset(getIddBaseRelocRva()) < dwMinOffset) dwMinOffset = rvaToOffset(getIddBaseRelocRva()); |
561 | if (directories >= 7 && getIddDebugRva() && rvaToOffset(getIddDebugRva()) < dwMinOffset) dwMinOffset = rvaToOffset(getIddDebugRva()); | 561 | if (directories >= 7 && getIddDebugRva() && rvaToOffset(getIddDebugRva()) < dwMinOffset) dwMinOffset = rvaToOffset(getIddDebugRva()); |
562 | if (directories >= 8 && getIddArchitectureRva() && rvaToOffset(getIddArchitectureRva()) < dwMinOffset) dwMinOffset = rvaToOffset(getIddArchitectureRva()); | 562 | if (directories >= 8 && getIddArchitectureRva() && rvaToOffset(getIddArchitectureRva()) < dwMinOffset) dwMinOffset = rvaToOffset(getIddArchitectureRva()); |
563 | if (directories >= 9 && getIddGlobalPtrRva() && rvaToOffset(getIddGlobalPtrRva()) < dwMinOffset) dwMinOffset = rvaToOffset(getIddGlobalPtrRva()); | 563 | if (directories >= 9 && getIddGlobalPtrRva() && rvaToOffset(getIddGlobalPtrRva()) < dwMinOffset) dwMinOffset = rvaToOffset(getIddGlobalPtrRva()); |
564 | if (directories >= 10 && getIddTlsRva() && rvaToOffset(getIddTlsRva()) < dwMinOffset) dwMinOffset = rvaToOffset(getIddTlsRva()); | 564 | if (directories >= 10 && getIddTlsRva() && rvaToOffset(getIddTlsRva()) < dwMinOffset) dwMinOffset = rvaToOffset(getIddTlsRva()); |
565 | if (directories >= 11 && getIddLoadConfigRva() && rvaToOffset(getIddLoadConfigRva()) < dwMinOffset) dwMinOffset = rvaToOffset(getIddLoadConfigRva()); | 565 | if (directories >= 11 && getIddLoadConfigRva() && rvaToOffset(getIddLoadConfigRva()) < dwMinOffset) dwMinOffset = rvaToOffset(getIddLoadConfigRva()); |
566 | if (directories >= 12 && getIddBoundImportRva() && rvaToOffset(getIddBoundImportRva()) < dwMinOffset) dwMinOffset = rvaToOffset(getIddBoundImportRva()); | 566 | if (directories >= 12 && getIddBoundImportRva() && rvaToOffset(getIddBoundImportRva()) < dwMinOffset) dwMinOffset = rvaToOffset(getIddBoundImportRva()); |
567 | if (directories >= 13 && getIddIatRva() && rvaToOffset(getIddIatRva()) < dwMinOffset) dwMinOffset = rvaToOffset(getIddIatRva()); | 567 | if (directories >= 13 && getIddIatRva() && rvaToOffset(getIddIatRva()) < dwMinOffset) dwMinOffset = rvaToOffset(getIddIatRva()); |
568 | if (directories >= 14 && getIddDelayImportRva() && rvaToOffset(getIddDelayImportRva()) < dwMinOffset) dwMinOffset = rvaToOffset(getIddDelayImportRva()); | 568 | if (directories >= 14 && getIddDelayImportRva() && rvaToOffset(getIddDelayImportRva()) < dwMinOffset) dwMinOffset = rvaToOffset(getIddDelayImportRva()); |
569 | if (directories >= 15 && getIddComHeaderRva() && rvaToOffset(getIddComHeaderRva()) < dwMinOffset) dwMinOffset = rvaToOffset(getIddComHeaderRva()); | 569 | if (directories >= 15 && getIddComHeaderRva() && rvaToOffset(getIddComHeaderRva()) < dwMinOffset) dwMinOffset = rvaToOffset(getIddComHeaderRva()); |
570 | 570 | ||
571 | for (word i=0;i<calcNumberOfSections();i++) | 571 | for (word i=0;i<calcNumberOfSections();i++) |
572 | { | 572 | { |
573 | if ((getPointerToRawData(i) < dwMinOffset || dwMinOffset == 0xFFFFFFFF) && getSizeOfRawData(i)) | 573 | if ((getPointerToRawData(i) < dwMinOffset || dwMinOffset == 0xFFFFFFFF) && getSizeOfRawData(i)) |
574 | { | 574 | { |
575 | if (getPointerToRawData(i)) dwMinOffset = getPointerToRawData(i); | 575 | if (getPointerToRawData(i)) dwMinOffset = getPointerToRawData(i); |
576 | } | 576 | } |
577 | } | 577 | } |
578 | return dwMinOffset; | 578 | return dwMinOffset; |
579 | } | 579 | } |
580 | 580 | ||
581 | /** | 581 | /** |
582 | * Calculates the file offset for a new section. The file offset will already be aligned to the file's FileAlignment. | 582 | * Calculates the file offset for a new section. The file offset will already be aligned to the file's FileAlignment. |
583 | * @return Aligned file offset. | 583 | * @return Aligned file offset. |
584 | * \todo uiSize isn't used yet. Will be used later on to search for caves. | 584 | * \todo uiSize isn't used yet. Will be used later on to search for caves. |
585 | **/ | 585 | **/ |
586 | template<int x> | 586 | template<int x> |
587 | unsigned int PeHeaderT<x>::calcOffset(/*unsigned int uiSize*/) const | 587 | unsigned int PeHeaderT<x>::calcOffset(/*unsigned int uiSize*/) const |
588 | { | 588 | { |
589 | unsigned int maxoffset = size(); | 589 | unsigned int maxoffset = size(); |
590 | 590 | ||
591 | for (word i=0;i<calcNumberOfSections();i++) | 591 | for (word i=0;i<calcNumberOfSections();i++) |
592 | { | 592 | { |
593 | if (getPointerToRawData(i) + getSizeOfRawData(i) > maxoffset) maxoffset = getPointerToRawData(i) + getSizeOfRawData(i); | 593 | if (getPointerToRawData(i) + getSizeOfRawData(i) > maxoffset) maxoffset = getPointerToRawData(i) + getSizeOfRawData(i); |
594 | } | 594 | } |
595 | 595 | ||
596 | return alignOffset(maxoffset, getFileAlignment()); | 596 | return alignOffset(maxoffset, getFileAlignment()); |
597 | } | 597 | } |
598 | 598 | ||
599 | /** | 599 | /** |
600 | * Calculates the Rva for a new section. The Rva will already be aligned to the file's SectionAlignment. | 600 | * Calculates the Rva for a new section. The Rva will already be aligned to the file's SectionAlignment. |
601 | * \todo uiSize isn't used yet. Will be used later on to search for caves. | 601 | * \todo uiSize isn't used yet. Will be used later on to search for caves. |
602 | * @return Aligned Rva. | 602 | * @return Aligned Rva. |
603 | **/ | 603 | **/ |
604 | template<int x> | 604 | template<int x> |
605 | unsigned int PeHeaderT<x>::calcRva(/*unsigned int uiSize*/) const | 605 | unsigned int PeHeaderT<x>::calcRva(/*unsigned int uiSize*/) const |
606 | { | 606 | { |
607 | // Major note here: It's possible for sections to exist with a Virtual Size of 0. | 607 | // Major note here: It's possible for sections to exist with a Virtual Size of 0. |
608 | // That's why it's necessary to use std::max(Vsize, RawSize) here. | 608 | // That's why it's necessary to use std::max(Vsize, RawSize) here. |
609 | // An example for such a file is dbeng6.exe (made by Sybase). | 609 | // An example for such a file is dbeng6.exe (made by Sybase). |
610 | // In this file each and every section has a VSize of 0 but it still runs. | 610 | // In this file each and every section has a VSize of 0 but it still runs. |
611 | 611 | ||
612 | unsigned int maxoffset = size(); | 612 | unsigned int maxoffset = size(); |
613 | for (word i=0;i<calcNumberOfSections();i++) | 613 | for (word i=0;i<calcNumberOfSections();i++) |
614 | { | 614 | { |
615 | if (getVirtualAddress(i) + std::max(getVirtualSize(i), getSizeOfRawData(i)) > maxoffset) maxoffset = getVirtualAddress(i) + std::max(getVirtualSize(i), getSizeOfRawData(i)); | 615 | if (getVirtualAddress(i) + std::max(getVirtualSize(i), getSizeOfRawData(i)) > maxoffset) maxoffset = getVirtualAddress(i) + std::max(getVirtualSize(i), getSizeOfRawData(i)); |
616 | } | 616 | } |
617 | 617 | ||
618 | return alignOffset(maxoffset, getSectionAlignment()); | 618 | return alignOffset(maxoffset, getSectionAlignment()); |
619 | } | 619 | } |
620 | 620 | ||
621 | /** | 621 | /** |
622 | * Returns the number of currently defined sections. Note that this value can be different from the number | 622 | * Returns the number of currently defined sections. Note that this value can be different from the number |
623 | * of sections according to the header (see #PeLib::PeHeaderT<x>::getNumberOfSections). | 623 | * of sections according to the header (see #PeLib::PeHeaderT<x>::getNumberOfSections). |
624 | * @return Number of currently defined sections. | 624 | * @return Number of currently defined sections. |
625 | **/ | 625 | **/ |
626 | template<int x> | 626 | template<int x> |
627 | word PeHeaderT<x>::calcNumberOfSections() const | 627 | word PeHeaderT<x>::calcNumberOfSections() const |
628 | { | 628 | { |
629 | return static_cast<PeLib::word>(m_vIsh.size()); | 629 | return static_cast<PeLib::word>(m_vIsh.size()); |
630 | } | 630 | } |
631 | 631 | ||
632 | /** | 632 | /** |
633 | * Enlarges the physically last section in the file. | 633 | * Enlarges the physically last section in the file. |
634 | * @param uiSize Additional size that's added to the section's size. | 634 | * @param uiSize Additional size that's added to the section's size. |
635 | **/ | 635 | **/ |
636 | template<int x> | 636 | template<int x> |
637 | void PeHeaderT<x>::enlargeLastSection(unsigned int uiSize) | 637 | void PeHeaderT<x>::enlargeLastSection(unsigned int uiSize) |
638 | { | 638 | { |
639 | std::vector<PELIB_IMAGE_SECTION_HEADER>::iterator ishLastSection = std::max_element(m_vIsh.begin(), m_vIsh.end(), std::mem_fun_ref(&PELIB_IMAGE_SECTION_HEADER::biggerFileOffset)); | 639 | std::vector<PELIB_IMAGE_SECTION_HEADER>::iterator ishLastSection = std::max_element(m_vIsh.begin(), m_vIsh.end(), std::mem_fun_ref(&PELIB_IMAGE_SECTION_HEADER::biggerFileOffset)); |
640 | unsigned int uiRawDataSize = alignOffset(ishLastSection->SizeOfRawData + uiSize, getFileAlignment()); | 640 | unsigned int uiRawDataSize = alignOffset(ishLastSection->SizeOfRawData + uiSize, getFileAlignment()); |
641 | 641 | ||
642 | ishLastSection->SizeOfRawData = uiRawDataSize; | 642 | ishLastSection->SizeOfRawData = uiRawDataSize; |
643 | ishLastSection->VirtualSize = ishLastSection->SizeOfRawData; | 643 | ishLastSection->VirtualSize = ishLastSection->SizeOfRawData; |
644 | 644 | ||
645 | setSizeOfImage(calcSizeOfImage()); | 645 | setSizeOfImage(calcSizeOfImage()); |
646 | } | 646 | } |
647 | 647 | ||
648 | /** | 648 | /** |
649 | * Determines the section which contains the file offset. | 649 | * Determines the section which contains the file offset. |
650 | * @param dwOffset File offset. | 650 | * @param dwOffset File offset. |
651 | * @return Section Id of the section which contains the offset. | 651 | * @return Section Id of the section which contains the offset. |
652 | **/ | 652 | **/ |
653 | template<int x> | 653 | template<int x> |
654 | word PeHeaderT<x>::getSectionWithOffset(VAR4_8 dwOffset) const | 654 | word PeHeaderT<x>::getSectionWithOffset(VAR4_8 dwOffset) const |
655 | { | 655 | { |
656 | // Offset = 0 must be handled explicitly as there are files | 656 | // Offset = 0 must be handled explicitly as there are files |
657 | // with sections that begin at offset 0, that means the section | 657 | // with sections that begin at offset 0, that means the section |
658 | // only exists in memory. | 658 | // only exists in memory. |
659 | 659 | ||
660 | if (!dwOffset) return std::numeric_limits<word>::max(); | 660 | if (!dwOffset) return std::numeric_limits<word>::max(); |
661 | 661 | ||
662 | for (word i=0;i<calcNumberOfSections();i++) | 662 | for (word i=0;i<calcNumberOfSections();i++) |
663 | { | 663 | { |
664 | // Explicity exclude sections with raw pointer = 0. | 664 | // Explicity exclude sections with raw pointer = 0. |
665 | dword rawptr = getPointerToRawData(i); | 665 | dword rawptr = getPointerToRawData(i); |
666 | if (rawptr && rawptr <= dwOffset && rawptr + getSizeOfRawData(i) > dwOffset) return i; | 666 | if (rawptr && rawptr <= dwOffset && rawptr + getSizeOfRawData(i) > dwOffset) return i; |
667 | } | 667 | } |
668 | 668 | ||
669 | return std::numeric_limits<word>::max(); | 669 | return std::numeric_limits<word>::max(); |
670 | } | 670 | } |
671 | 671 | ||
672 | /** | 672 | /** |
673 | * Determines the section which contains the Rva. | 673 | * Determines the section which contains the Rva. |
674 | * @param dwRva A relative virtual address. | 674 | * @param dwRva A relative virtual address. |
675 | * @return Section Id of the section which contains the Rva. | 675 | * @return Section Id of the section which contains the Rva. |
676 | **/ | 676 | **/ |
677 | template<int x> | 677 | template<int x> |
678 | word PeHeaderT<x>::getSectionWithRva(VAR4_8 dwRva) const | 678 | word PeHeaderT<x>::getSectionWithRva(VAR4_8 dwRva) const |
679 | { | 679 | { |
680 | // Major note here: It's possible for sections to exist with a Virtual Size of 0. | 680 | // Major note here: It's possible for sections to exist with a Virtual Size of 0. |
681 | // That's why it's necessary to use std::max(Vsize, RawSize) here. | 681 | // That's why it's necessary to use std::max(Vsize, RawSize) here. |
682 | // An example for such a file is dbeng6.exe (made by Sybase). | 682 | // An example for such a file is dbeng6.exe (made by Sybase). |
683 | // In this file each and every section has a VSize of 0 but it still runs. | 683 | // In this file each and every section has a VSize of 0 but it still runs. |
684 | 684 | ||
685 | for (word i=0;i<calcNumberOfSections();i++) | 685 | for (word i=0;i<calcNumberOfSections();i++) |
686 | { | 686 | { |
687 | // Weird VC++7 error doesn't allow me to use std::max here. | 687 | // Weird VC++7 error doesn't allow me to use std::max here. |
688 | dword max = getVirtualSize(i) >= getSizeOfRawData(i) ? getVirtualSize(i) : getSizeOfRawData(i); | 688 | dword max = getVirtualSize(i) >= getSizeOfRawData(i) ? getVirtualSize(i) : getSizeOfRawData(i); |
689 | if (getVirtualAddress(i) <= dwRva && getVirtualAddress(i) + max > dwRva) return i; | 689 | if (getVirtualAddress(i) <= dwRva && getVirtualAddress(i) + max > dwRva) return i; |
690 | } | 690 | } |
691 | 691 | ||
692 | return -1; | 692 | return -1; |
693 | } | 693 | } |
694 | 694 | ||
695 | /** | 695 | /** |
696 | * Corrects all faulty values of the current PE header. The following values will be corrected: NtSignature, | 696 | * Corrects all faulty values of the current PE header. The following values will be corrected: NtSignature, |
697 | * NumberOfSections, SizeOfOptionalHeader, FileAlignment (will be aligned to n*0x200), | 697 | * NumberOfSections, SizeOfOptionalHeader, FileAlignment (will be aligned to n*0x200), |
698 | * SectionAlignment (will be aligned to n*0x1000), NumberOfRvaAndSizes, SizeOfHeaders, SizeOfImage, | 698 | * SectionAlignment (will be aligned to n*0x1000), NumberOfRvaAndSizes, SizeOfHeaders, SizeOfImage, |
699 | * Magic, Characteristics. | 699 | * Magic, Characteristics. |
700 | * @param dwOffset Beginning of PeHeader (see #PeLib::MzHeader::getAddressOfPeHeader). | 700 | * @param dwOffset Beginning of PeHeader (see #PeLib::MzHeader::getAddressOfPeHeader). |
701 | * \todo 32bit and 64bit versions. | 701 | * \todo 32bit and 64bit versions. |
702 | **/ | 702 | **/ |
703 | template<int x> | 703 | template<int x> |
704 | void PeHeaderT<x>::makeValid(dword dwOffset) | 704 | void PeHeaderT<x>::makeValid(dword dwOffset) |
705 | { | 705 | { |
706 | setNtSignature(PELIB_IMAGE_NT_SIGNATURE); // 'PE' | 706 | setNtSignature(PELIB_IMAGE_NT_SIGNATURE); // 'PE' |
707 | setMachine(PELIB_IMAGE_FILE_MACHINE_I386); | 707 | setMachine(PELIB_IMAGE_FILE_MACHINE_I386); |
708 | setNumberOfSections(calcNumberOfSections()); | 708 | setNumberOfSections(calcNumberOfSections()); |
709 | 709 | ||
710 | // Check if 64 bits. | 710 | // Check if 64 bits. |
711 | setSizeOfOptionalHeader(PELIB_IMAGE_OPTIONAL_HEADER<x>::size() + calcNumberOfRvaAndSizes() * 8); | 711 | setSizeOfOptionalHeader(PELIB_IMAGE_OPTIONAL_HEADER<x>::size() + calcNumberOfRvaAndSizes() * 8); |
712 | 712 | ||
713 | // Check if 64 bits. | 713 | // Check if 64 bits. |
714 | dword dwCharacteristics = PELIB_IMAGE_FILE_EXECUTABLE_IMAGE | PELIB_IMAGE_FILE_32BIT_MACHINE; | 714 | dword dwCharacteristics = PELIB_IMAGE_FILE_EXECUTABLE_IMAGE | PELIB_IMAGE_FILE_32BIT_MACHINE; |
715 | setCharacteristics(dwCharacteristics); | 715 | setCharacteristics(dwCharacteristics); |
716 | 716 | ||
717 | // Check if 64 bits. | 717 | // Check if 64 bits. |
718 | setMagic(PELIB_IMAGE_NT_OPTIONAL_HDR32_MAGIC); | 718 | setMagic(PELIB_IMAGE_NT_OPTIONAL_HDR32_MAGIC); |
719 | 719 | ||
720 | // setImageBase(0x01000000); | 720 | // setImageBase(0x01000000); |
721 | 721 | ||
722 | // Align file and section alignment values | 722 | // Align file and section alignment values |
723 | unsigned int dwAlignedOffset = alignOffset(getSectionAlignment(), 0x1000); | 723 | unsigned int dwAlignedOffset = alignOffset(getSectionAlignment(), 0x1000); |
724 | setSectionAlignment(dwAlignedOffset ? dwAlignedOffset : 0x1000); | 724 | setSectionAlignment(dwAlignedOffset ? dwAlignedOffset : 0x1000); |
725 | 725 | ||
726 | dwAlignedOffset = alignOffset(getFileAlignment(), 0x200); | 726 | dwAlignedOffset = alignOffset(getFileAlignment(), 0x200); |
727 | setFileAlignment(dwAlignedOffset ? dwAlignedOffset : 0x200); | 727 | setFileAlignment(dwAlignedOffset ? dwAlignedOffset : 0x200); |
728 | 728 | ||
729 | // setMajorSubsystemVersion(4); | 729 | // setMajorSubsystemVersion(4); |
730 | // setSubsystem(IMAGE_SUBSYSTEM_WINDOWS_GUI); | 730 | // setSubsystem(IMAGE_SUBSYSTEM_WINDOWS_GUI); |
731 | setNumberOfRvaAndSizes(calcNumberOfRvaAndSizes()); | 731 | setNumberOfRvaAndSizes(calcNumberOfRvaAndSizes()); |
732 | 732 | ||
733 | // Code below depends on code above. Don't change the order. | 733 | // Code below depends on code above. Don't change the order. |
734 | dword dwSizeOfHeaders = alignOffset(dwOffset + size(), getFileAlignment()); | 734 | dword dwSizeOfHeaders = alignOffset(dwOffset + size(), getFileAlignment()); |
735 | setSizeOfHeaders(dwSizeOfHeaders); | 735 | setSizeOfHeaders(dwSizeOfHeaders); |
736 | 736 | ||
737 | dword dwSizeOfImage = alignOffset(dwSizeOfHeaders, getSectionAlignment()); | 737 | dword dwSizeOfImage = alignOffset(dwSizeOfHeaders, getSectionAlignment()); |
738 | 738 | ||
739 | for (int i=0;i<calcNumberOfSections();i++) | 739 | for (int i=0;i<calcNumberOfSections();i++) |
740 | { | 740 | { |
741 | dwSizeOfImage += alignOffset(getVirtualSize(i), getSectionAlignment()); | 741 | dwSizeOfImage += alignOffset(getVirtualSize(i), getSectionAlignment()); |
742 | } | 742 | } |
743 | 743 | ||
744 | dwSizeOfImage = alignOffset(dwSizeOfImage, getSectionAlignment()); | 744 | dwSizeOfImage = alignOffset(dwSizeOfImage, getSectionAlignment()); |
745 | setSizeOfImage(dwSizeOfImage); | 745 | setSizeOfImage(dwSizeOfImage); |
746 | } | 746 | } |
747 | 747 | ||
748 | template<int x> | 748 | template<int x> |
749 | unsigned int PeHeaderT<x>::offsetToRva(VAR4_8 dwOffset) const | 749 | unsigned int PeHeaderT<x>::offsetToRva(VAR4_8 dwOffset) const |
750 | { | 750 | { |
751 | if (dwOffset < calcStartOfCode()) return dwOffset; | 751 | if (dwOffset < calcStartOfCode()) return dwOffset; |
752 | 752 | ||
753 | PeLib::word uiSecnr = getSectionWithOffset(dwOffset); | 753 | PeLib::word uiSecnr = getSectionWithOffset(dwOffset); |
754 | 754 | ||
755 | if (uiSecnr == 0xFFFF) return -1; | 755 | if (uiSecnr == 0xFFFF) return -1; |
756 | 756 | ||
757 | return getVirtualAddress(uiSecnr) + dwOffset - getPointerToRawData(uiSecnr); | 757 | return getVirtualAddress(uiSecnr) + dwOffset - getPointerToRawData(uiSecnr); |
758 | } | 758 | } |
759 | 759 | ||
760 | /** | 760 | /** |
761 | * Converts a file offset to a virtual address. | 761 | * Converts a file offset to a virtual address. |
762 | * @param dwOffset File offset. | 762 | * @param dwOffset File offset. |
763 | * @return Virtual Address. | 763 | * @return Virtual Address. |
764 | **/ | 764 | **/ |
765 | template<int x> | 765 | template<int x> |
766 | unsigned int PeHeaderT<x>::offsetToVa(VAR4_8 dwOffset) const | 766 | unsigned int PeHeaderT<x>::offsetToVa(VAR4_8 dwOffset) const |
767 | { | 767 | { |
768 | if (dwOffset < calcStartOfCode()) return getImageBase() + dwOffset; | 768 | if (dwOffset < calcStartOfCode()) return getImageBase() + dwOffset; |
769 | 769 | ||
770 | PeLib::word uiSecnr = getSectionWithOffset(dwOffset); | 770 | PeLib::word uiSecnr = getSectionWithOffset(dwOffset); |
771 | 771 | ||
772 | if (uiSecnr == 0xFFFF) return -1; | 772 | if (uiSecnr == 0xFFFF) return -1; |
773 | 773 | ||
774 | return getImageBase() + getVirtualAddress(uiSecnr) + dwOffset - getPointerToRawData(uiSecnr); | 774 | return getImageBase() + getVirtualAddress(uiSecnr) + dwOffset - getPointerToRawData(uiSecnr); |
775 | } | 775 | } |
776 | 776 | ||
777 | template<int x> | 777 | template<int x> |
778 | void PeHeaderT<x>::readHeader(InputBuffer& ibBuffer, PELIB_IMAGE_NT_HEADERS<x>& header) const | 778 | void PeHeaderT<x>::readHeader(InputBuffer& ibBuffer, PELIB_IMAGE_NT_HEADERS<x>& header) const |
779 | { | 779 | { |
780 | ibBuffer >> header.Signature; | 780 | ibBuffer >> header.Signature; |
781 | 781 | ||
782 | ibBuffer >> header.FileHeader.Machine; | 782 | ibBuffer >> header.FileHeader.Machine; |
783 | ibBuffer >> header.FileHeader.NumberOfSections; | 783 | ibBuffer >> header.FileHeader.NumberOfSections; |
784 | ibBuffer >> header.FileHeader.TimeDateStamp; | 784 | ibBuffer >> header.FileHeader.TimeDateStamp; |
785 | ibBuffer >> header.FileHeader.PointerToSymbolTable; | 785 | ibBuffer >> header.FileHeader.PointerToSymbolTable; |
786 | ibBuffer >> header.FileHeader.NumberOfSymbols; | 786 | ibBuffer >> header.FileHeader.NumberOfSymbols; |
787 | ibBuffer >> header.FileHeader.SizeOfOptionalHeader; | 787 | ibBuffer >> header.FileHeader.SizeOfOptionalHeader; |
788 | ibBuffer >> header.FileHeader.Characteristics; | 788 | ibBuffer >> header.FileHeader.Characteristics; |
789 | ibBuffer >> header.OptionalHeader.Magic; | 789 | ibBuffer >> header.OptionalHeader.Magic; |
790 | 790 | ||
791 | ibBuffer >> header.OptionalHeader.MajorLinkerVersion; | 791 | ibBuffer >> header.OptionalHeader.MajorLinkerVersion; |
792 | ibBuffer >> header.OptionalHeader.MinorLinkerVersion; | 792 | ibBuffer >> header.OptionalHeader.MinorLinkerVersion; |
793 | ibBuffer >> header.OptionalHeader.SizeOfCode; | 793 | ibBuffer >> header.OptionalHeader.SizeOfCode; |
794 | ibBuffer >> header.OptionalHeader.SizeOfInitializedData; | 794 | ibBuffer >> header.OptionalHeader.SizeOfInitializedData; |
795 | ibBuffer >> header.OptionalHeader.SizeOfUninitializedData; | 795 | ibBuffer >> header.OptionalHeader.SizeOfUninitializedData; |
796 | ibBuffer >> header.OptionalHeader.AddressOfEntryPoint; | 796 | ibBuffer >> header.OptionalHeader.AddressOfEntryPoint; |
797 | ibBuffer >> header.OptionalHeader.BaseOfCode; | 797 | ibBuffer >> header.OptionalHeader.BaseOfCode; |
798 | readBaseOfData(ibBuffer, header); | 798 | readBaseOfData(ibBuffer, header); |
799 | ibBuffer >> header.OptionalHeader.ImageBase; | 799 | ibBuffer >> header.OptionalHeader.ImageBase; |
800 | ibBuffer >> header.OptionalHeader.SectionAlignment; | 800 | ibBuffer >> header.OptionalHeader.SectionAlignment; |
801 | ibBuffer >> header.OptionalHeader.FileAlignment; | 801 | ibBuffer >> header.OptionalHeader.FileAlignment; |
802 | ibBuffer >> header.OptionalHeader.MajorOperatingSystemVersion; | 802 | ibBuffer >> header.OptionalHeader.MajorOperatingSystemVersion; |
803 | ibBuffer >> header.OptionalHeader.MinorOperatingSystemVersion; | 803 | ibBuffer >> header.OptionalHeader.MinorOperatingSystemVersion; |
804 | ibBuffer >> header.OptionalHeader.MajorImageVersion; | 804 | ibBuffer >> header.OptionalHeader.MajorImageVersion; |
805 | ibBuffer >> header.OptionalHeader.MinorImageVersion; | 805 | ibBuffer >> header.OptionalHeader.MinorImageVersion; |
806 | ibBuffer >> header.OptionalHeader.MajorSubsystemVersion; | 806 | ibBuffer >> header.OptionalHeader.MajorSubsystemVersion; |
807 | ibBuffer >> header.OptionalHeader.MinorSubsystemVersion; | 807 | ibBuffer >> header.OptionalHeader.MinorSubsystemVersion; |
808 | ibBuffer >> header.OptionalHeader.Win32VersionValue; | 808 | ibBuffer >> header.OptionalHeader.Win32VersionValue; |
809 | ibBuffer >> header.OptionalHeader.SizeOfImage; | 809 | ibBuffer >> header.OptionalHeader.SizeOfImage; |
810 | ibBuffer >> header.OptionalHeader.SizeOfHeaders; | 810 | ibBuffer >> header.OptionalHeader.SizeOfHeaders; |
811 | ibBuffer >> header.OptionalHeader.CheckSum; | 811 | ibBuffer >> header.OptionalHeader.CheckSum; |
812 | ibBuffer >> header.OptionalHeader.Subsystem; | 812 | ibBuffer >> header.OptionalHeader.Subsystem; |
813 | ibBuffer >> header.OptionalHeader.DllCharacteristics; | 813 | ibBuffer >> header.OptionalHeader.DllCharacteristics; |
814 | ibBuffer >> header.OptionalHeader.SizeOfStackReserve; | 814 | ibBuffer >> header.OptionalHeader.SizeOfStackReserve; |
815 | ibBuffer >> header.OptionalHeader.SizeOfStackCommit; | 815 | ibBuffer >> header.OptionalHeader.SizeOfStackCommit; |
816 | ibBuffer >> header.OptionalHeader.SizeOfHeapReserve; | 816 | ibBuffer >> header.OptionalHeader.SizeOfHeapReserve; |
817 | ibBuffer >> header.OptionalHeader.SizeOfHeapCommit; | 817 | ibBuffer >> header.OptionalHeader.SizeOfHeapCommit; |
818 | ibBuffer >> header.OptionalHeader.LoaderFlags; | 818 | ibBuffer >> header.OptionalHeader.LoaderFlags; |
819 | ibBuffer >> header.OptionalHeader.NumberOfRvaAndSizes; | 819 | ibBuffer >> header.OptionalHeader.NumberOfRvaAndSizes; |
820 | } | 820 | } |
821 | 821 | ||
822 | template<int x> | 822 | template<int x> |
823 | void PeHeaderT<x>::readDataDirectories(InputBuffer& ibBuffer, PELIB_IMAGE_NT_HEADERS<x>& header) const | 823 | void PeHeaderT<x>::readDataDirectories(InputBuffer& ibBuffer, PELIB_IMAGE_NT_HEADERS<x>& header) const |
824 | { | 824 | { |
825 | PELIB_IMAGE_DATA_DIRECTORY idd; | 825 | PELIB_IMAGE_DATA_DIRECTORY idd; |
826 | 826 | ||
827 | for (unsigned int i=0;i<header.OptionalHeader.NumberOfRvaAndSizes;i++) | 827 | for (unsigned int i=0;i<header.OptionalHeader.NumberOfRvaAndSizes;i++) |
828 | { | 828 | { |
829 | ibBuffer >> idd.VirtualAddress; | 829 | ibBuffer >> idd.VirtualAddress; |
830 | ibBuffer >> idd.Size; | 830 | ibBuffer >> idd.Size; |
831 | header.dataDirectories.push_back(idd); | 831 | header.dataDirectories.push_back(idd); |
832 | } | 832 | } |
833 | } | 833 | } |
834 | 834 | ||
835 | template<int x> | 835 | template<int x> |
836 | std::vector<PELIB_IMAGE_SECTION_HEADER> PeHeaderT<x>::readSections(InputBuffer& ibBuffer, PELIB_IMAGE_NT_HEADERS<x>& header) const | 836 | std::vector<PELIB_IMAGE_SECTION_HEADER> PeHeaderT<x>::readSections(InputBuffer& ibBuffer, PELIB_IMAGE_NT_HEADERS<x>& header) const |
837 | { | 837 | { |
838 | const unsigned int nrSections = header.FileHeader.NumberOfSections; | 838 | const unsigned int nrSections = header.FileHeader.NumberOfSections; |
839 | PELIB_IMAGE_SECTION_HEADER ishCurr; | 839 | PELIB_IMAGE_SECTION_HEADER ishCurr; |
840 | 840 | ||
841 | std::vector<PELIB_IMAGE_SECTION_HEADER> vIshdCurr; | 841 | std::vector<PELIB_IMAGE_SECTION_HEADER> vIshdCurr; |
842 | 842 | ||
843 | for (unsigned int i=0;i<nrSections;i++) | 843 | for (unsigned int i=0;i<nrSections;i++) |
844 | { | 844 | { |
845 | ibBuffer.read(reinterpret_cast<char*>(ishCurr.Name), 8); | 845 | ibBuffer.read(reinterpret_cast<char*>(ishCurr.Name), 8); |
846 | ibBuffer >> ishCurr.VirtualSize; | 846 | ibBuffer >> ishCurr.VirtualSize; |
847 | ibBuffer >> ishCurr.VirtualAddress; | 847 | ibBuffer >> ishCurr.VirtualAddress; |
848 | ibBuffer >> ishCurr.SizeOfRawData; | 848 | ibBuffer >> ishCurr.SizeOfRawData; |
849 | ibBuffer >> ishCurr.PointerToRawData; | 849 | ibBuffer >> ishCurr.PointerToRawData; |
850 | ibBuffer >> ishCurr.PointerToRelocations; | 850 | ibBuffer >> ishCurr.PointerToRelocations; |
851 | ibBuffer >> ishCurr.PointerToLinenumbers; | 851 | ibBuffer >> ishCurr.PointerToLinenumbers; |
852 | ibBuffer >> ishCurr.NumberOfRelocations; | 852 | ibBuffer >> ishCurr.NumberOfRelocations; |
853 | ibBuffer >> ishCurr.NumberOfLinenumbers; | 853 | ibBuffer >> ishCurr.NumberOfLinenumbers; |
854 | ibBuffer >> ishCurr.Characteristics; | 854 | ibBuffer >> ishCurr.Characteristics; |
855 | vIshdCurr.push_back(ishCurr); | 855 | vIshdCurr.push_back(ishCurr); |
856 | } | 856 | } |
857 | 857 | ||
858 | return vIshdCurr; | 858 | return vIshdCurr; |
859 | } | 859 | } |
860 | 860 | ||
861 | template<int x> | 861 | template<int x> |
862 | int PeHeaderT<x>::read(const unsigned char* pcBuffer, unsigned int uiSize, unsigned int uiOffset) | 862 | int PeHeaderT<x>::read(const unsigned char* pcBuffer, unsigned int uiSize, unsigned int uiOffset) |
863 | { | 863 | { |
864 | if (uiSize < m_inthHeader.size()) | 864 | if (uiSize < m_inthHeader.size()) |
865 | { | 865 | { |
866 | return ERROR_INVALID_FILE; | 866 | return ERROR_INVALID_FILE; |
867 | } | 867 | } |
868 | 868 | ||
869 | std::vector<unsigned char> vBuffer(pcBuffer, pcBuffer + m_inthHeader.size()); | 869 | std::vector<unsigned char> vBuffer(pcBuffer, pcBuffer + m_inthHeader.size()); |
870 | 870 | ||
871 | InputBuffer ibBuffer(vBuffer); | 871 | InputBuffer ibBuffer(vBuffer); |
872 | PELIB_IMAGE_NT_HEADERS<x> header; | 872 | PELIB_IMAGE_NT_HEADERS<x> header; |
873 | 873 | ||
874 | readHeader(ibBuffer, header); | 874 | readHeader(ibBuffer, header); |
875 | 875 | ||
876 | if (uiSize < m_inthHeader.size() + header.OptionalHeader.NumberOfRvaAndSizes * 8 + header.FileHeader.NumberOfSections * 0x28) | 876 | if (uiSize < m_inthHeader.size() + header.OptionalHeader.NumberOfRvaAndSizes * 8 + header.FileHeader.NumberOfSections * 0x28) |
877 | { | 877 | { |
878 | return ERROR_INVALID_FILE; | 878 | return ERROR_INVALID_FILE; |
879 | } | 879 | } |
880 | 880 | ||
881 | vBuffer.resize(header.OptionalHeader.NumberOfRvaAndSizes * 8 + header.FileHeader.NumberOfSections * 0x28); | 881 | vBuffer.resize(header.OptionalHeader.NumberOfRvaAndSizes * 8 + header.FileHeader.NumberOfSections * 0x28); |
882 | vBuffer.assign(pcBuffer + m_inthHeader.size(), pcBuffer + m_inthHeader.size() + header.OptionalHeader.NumberOfRvaAndSizes * 8 + header.FileHeader.NumberOfSections * 0x28); | 882 | vBuffer.assign(pcBuffer + m_inthHeader.size(), pcBuffer + m_inthHeader.size() + header.OptionalHeader.NumberOfRvaAndSizes * 8 + header.FileHeader.NumberOfSections * 0x28); |
883 | 883 | ||
884 | ibBuffer.setBuffer(vBuffer); | 884 | ibBuffer.setBuffer(vBuffer); |
885 | 885 | ||
886 | readDataDirectories(ibBuffer, header); | 886 | readDataDirectories(ibBuffer, header); |
887 | 887 | ||
888 | m_vIsh = readSections(ibBuffer, header); | 888 | m_vIsh = readSections(ibBuffer, header); |
889 | 889 | ||
890 | std::swap(m_inthHeader, header); | 890 | std::swap(m_inthHeader, header); |
891 | 891 | ||
892 | m_uiOffset = uiOffset; | 892 | m_uiOffset = uiOffset; |
893 | 893 | ||
894 | return NO_ERROR; | 894 | return NO_ERROR; |
895 | } | 895 | } |
896 | 896 | ||
897 | /** | 897 | /** |
898 | * Reads the PE header from a file Note that this function does not verify if a file is actually a MZ file. | 898 | * Reads the PE header from a file Note that this function does not verify if a file is actually a MZ file. |
899 | * For this purpose see #PeLib::PeHeaderT<x>::isValid. The only check this function makes is a check to see if | 899 | * For this purpose see #PeLib::PeHeaderT<x>::isValid. The only check this function makes is a check to see if |
900 | * the file is large enough to be a PE header. If the data is valid doesn't matter. | 900 | * the file is large enough to be a PE header. If the data is valid doesn't matter. |
901 | * @param strFilename Name of the file which will be read. | 901 | * @param strFilename Name of the file which will be read. |
902 | * @param uiOffset File offset of PE header (see #PeLib::MzHeader::getAddressOfPeHeader). | 902 | * @param uiOffset File offset of PE header (see #PeLib::MzHeader::getAddressOfPeHeader). |
903 | **/ | 903 | **/ |
904 | template<int x> | 904 | template<int x> |
905 | int PeHeaderT<x>::read(std::string strFilename, unsigned int uiOffset) | 905 | int PeHeaderT<x>::read(std::string strFilename, unsigned int uiOffset) |
906 | { | 906 | { |
907 | std::ifstream ifFile(strFilename.c_str(), std::ios::binary); | 907 | std::ifstream ifFile(strFilename.c_str(), std::ios::binary); |
908 | 908 | ||
909 | if (!ifFile) | 909 | if (!ifFile) |
910 | { | 910 | { |
911 | return ERROR_OPENING_FILE; | 911 | return ERROR_OPENING_FILE; |
912 | } | 912 | } |
913 | 913 | ||
914 | // File too small | 914 | // File too small |
915 | if (fileSize(ifFile) < uiOffset + m_inthHeader.size()) | 915 | if (fileSize(ifFile) < uiOffset + m_inthHeader.size()) |
916 | { | 916 | { |
917 | return ERROR_INVALID_FILE; | 917 | return ERROR_INVALID_FILE; |
918 | } | 918 | } |
919 | 919 | ||
920 | std::vector<unsigned char> vBuffer(m_inthHeader.size()); | 920 | std::vector<unsigned char> vBuffer(m_inthHeader.size()); |
921 | 921 | ||
922 | ifFile.seekg(uiOffset, std::ios::beg); | 922 | ifFile.seekg(uiOffset, std::ios::beg); |
923 | ifFile.read(reinterpret_cast<char*>(&vBuffer[0]), static_cast<std::streamsize>(vBuffer.size())); | 923 | ifFile.read(reinterpret_cast<char*>(&vBuffer[0]), static_cast<std::streamsize>(vBuffer.size())); |
924 | 924 | ||
925 | InputBuffer ibBuffer(vBuffer); | 925 | InputBuffer ibBuffer(vBuffer); |
926 | PELIB_IMAGE_NT_HEADERS<x> header; | 926 | PELIB_IMAGE_NT_HEADERS<x> header; |
927 | 927 | ||
928 | readHeader(ibBuffer, header); | 928 | readHeader(ibBuffer, header); |
929 | 929 | ||
930 | vBuffer.resize(header.OptionalHeader.NumberOfRvaAndSizes * 8 + header.FileHeader.NumberOfSections * 0x28); | 930 | vBuffer.resize(header.OptionalHeader.NumberOfRvaAndSizes * 8 + header.FileHeader.NumberOfSections * 0x28); |
931 | 931 | ||
932 | ifFile.read(reinterpret_cast<char*>(&vBuffer[0]), static_cast<std::streamsize>(vBuffer.size())); | 932 | ifFile.read(reinterpret_cast<char*>(&vBuffer[0]), static_cast<std::streamsize>(vBuffer.size())); |
933 | if (!ifFile) | 933 | if (!ifFile) |
934 | { | 934 | { |
935 | return ERROR_INVALID_FILE; | 935 | return ERROR_INVALID_FILE; |
936 | } | 936 | } |
937 | 937 | ||
938 | ibBuffer.setBuffer(vBuffer); | 938 | ibBuffer.setBuffer(vBuffer); |
939 | 939 | ||
940 | readDataDirectories(ibBuffer, header); | 940 | readDataDirectories(ibBuffer, header); |
941 | 941 | ||
942 | // Sections | 942 | // Sections |
943 | // const unsigned int nrSections = header.FileHeader.NumberOfSections; | 943 | // const unsigned int nrSections = header.FileHeader.NumberOfSections; |
944 | // if (fileSize(ifFile) < uiOffset + m_inthHeader.size() + nrSections * PELIB_IMAGE_SECTION_HEADER::size()) | 944 | // if (fileSize(ifFile) < uiOffset + m_inthHeader.size() + nrSections * PELIB_IMAGE_SECTION_HEADER::size()) |
945 | // { | 945 | // { |
946 | // return ERROR_INVALID_FILE; | 946 | // return ERROR_INVALID_FILE; |
947 | // } | 947 | // } |
948 | 948 | ||
949 | m_vIsh = readSections(ibBuffer, header); | 949 | m_vIsh = readSections(ibBuffer, header); |
950 | 950 | ||
951 | std::swap(m_inthHeader, header); | 951 | std::swap(m_inthHeader, header); |
952 | 952 | ||
953 | m_uiOffset = uiOffset; | 953 | m_uiOffset = uiOffset; |
954 | 954 | ||
955 | ifFile.close(); | 955 | ifFile.close(); |
956 | 956 | ||
957 | return NO_ERROR; | 957 | return NO_ERROR; |
958 | } | 958 | } |
959 | 959 | ||
960 | /** | 960 | /** |
961 | * Rebuilds the PE header so that it can be written to a file. It's not guaranteed that the | 961 | * Rebuilds the PE header so that it can be written to a file. It's not guaranteed that the |
962 | * header will be valid. If you want to make sure that the header will be valid you | 962 | * header will be valid. If you want to make sure that the header will be valid you |
963 | * must call #PeLib::PeHeaderT<x>::makeValid first. | 963 | * must call #PeLib::PeHeaderT<x>::makeValid first. |
964 | * @param vBuffer Buffer where the rebuilt header will be stored. | 964 | * @param vBuffer Buffer where the rebuilt header will be stored. |
965 | **/ | 965 | **/ |
966 | template<int x> | 966 | template<int x> |
967 | void PeHeaderT<x>::rebuild(std::vector<byte>& vBuffer) const | 967 | void PeHeaderT<x>::rebuild(std::vector<byte>& vBuffer) const |
968 | { | 968 | { |
969 | OutputBuffer obBuffer(vBuffer); | 969 | OutputBuffer obBuffer(vBuffer); |
970 | 970 | ||
971 | obBuffer << m_inthHeader.Signature; | 971 | obBuffer << m_inthHeader.Signature; |
972 | 972 | ||
973 | obBuffer << m_inthHeader.FileHeader.Machine; | 973 | obBuffer << m_inthHeader.FileHeader.Machine; |
974 | obBuffer << m_inthHeader.FileHeader.NumberOfSections; | 974 | obBuffer << m_inthHeader.FileHeader.NumberOfSections; |
975 | obBuffer << m_inthHeader.FileHeader.TimeDateStamp; | 975 | obBuffer << m_inthHeader.FileHeader.TimeDateStamp; |
976 | obBuffer << m_inthHeader.FileHeader.PointerToSymbolTable; | 976 | obBuffer << m_inthHeader.FileHeader.PointerToSymbolTable; |
977 | obBuffer << m_inthHeader.FileHeader.NumberOfSymbols; | 977 | obBuffer << m_inthHeader.FileHeader.NumberOfSymbols; |
978 | obBuffer << m_inthHeader.FileHeader.SizeOfOptionalHeader; | 978 | obBuffer << m_inthHeader.FileHeader.SizeOfOptionalHeader; |
979 | obBuffer << m_inthHeader.FileHeader.Characteristics; | 979 | obBuffer << m_inthHeader.FileHeader.Characteristics; |
980 | obBuffer << m_inthHeader.OptionalHeader.Magic; | 980 | obBuffer << m_inthHeader.OptionalHeader.Magic; |
981 | obBuffer << m_inthHeader.OptionalHeader.MajorLinkerVersion; | 981 | obBuffer << m_inthHeader.OptionalHeader.MajorLinkerVersion; |
982 | obBuffer << m_inthHeader.OptionalHeader.MinorLinkerVersion; | 982 | obBuffer << m_inthHeader.OptionalHeader.MinorLinkerVersion; |
983 | obBuffer << m_inthHeader.OptionalHeader.SizeOfCode; | 983 | obBuffer << m_inthHeader.OptionalHeader.SizeOfCode; |
984 | obBuffer << m_inthHeader.OptionalHeader.SizeOfInitializedData; | 984 | obBuffer << m_inthHeader.OptionalHeader.SizeOfInitializedData; |
985 | obBuffer << m_inthHeader.OptionalHeader.SizeOfUninitializedData; | 985 | obBuffer << m_inthHeader.OptionalHeader.SizeOfUninitializedData; |
986 | obBuffer << m_inthHeader.OptionalHeader.AddressOfEntryPoint; | 986 | obBuffer << m_inthHeader.OptionalHeader.AddressOfEntryPoint; |
987 | obBuffer << m_inthHeader.OptionalHeader.BaseOfCode; | 987 | obBuffer << m_inthHeader.OptionalHeader.BaseOfCode; |
988 | rebuildBaseOfData(obBuffer); | 988 | rebuildBaseOfData(obBuffer); |
989 | // obBuffer << m_inthHeader.OptionalHeader.BaseOfData; | 989 | // obBuffer << m_inthHeader.OptionalHeader.BaseOfData; |
990 | obBuffer << m_inthHeader.OptionalHeader.ImageBase; | 990 | obBuffer << m_inthHeader.OptionalHeader.ImageBase; |
991 | obBuffer << m_inthHeader.OptionalHeader.SectionAlignment; | 991 | obBuffer << m_inthHeader.OptionalHeader.SectionAlignment; |
992 | obBuffer << m_inthHeader.OptionalHeader.FileAlignment; | 992 | obBuffer << m_inthHeader.OptionalHeader.FileAlignment; |
993 | obBuffer << m_inthHeader.OptionalHeader.MajorOperatingSystemVersion; | 993 | obBuffer << m_inthHeader.OptionalHeader.MajorOperatingSystemVersion; |
994 | obBuffer << m_inthHeader.OptionalHeader.MinorOperatingSystemVersion; | 994 | obBuffer << m_inthHeader.OptionalHeader.MinorOperatingSystemVersion; |
995 | obBuffer << m_inthHeader.OptionalHeader.MajorImageVersion; | 995 | obBuffer << m_inthHeader.OptionalHeader.MajorImageVersion; |
996 | obBuffer << m_inthHeader.OptionalHeader.MinorImageVersion; | 996 | obBuffer << m_inthHeader.OptionalHeader.MinorImageVersion; |
997 | obBuffer << m_inthHeader.OptionalHeader.MajorSubsystemVersion; | 997 | obBuffer << m_inthHeader.OptionalHeader.MajorSubsystemVersion; |
998 | obBuffer << m_inthHeader.OptionalHeader.MinorSubsystemVersion; | 998 | obBuffer << m_inthHeader.OptionalHeader.MinorSubsystemVersion; |
999 | obBuffer << m_inthHeader.OptionalHeader.Win32VersionValue; | 999 | obBuffer << m_inthHeader.OptionalHeader.Win32VersionValue; |
1000 | obBuffer << m_inthHeader.OptionalHeader.SizeOfImage; | 1000 | obBuffer << m_inthHeader.OptionalHeader.SizeOfImage; |
1001 | obBuffer << m_inthHeader.OptionalHeader.SizeOfHeaders; | 1001 | obBuffer << m_inthHeader.OptionalHeader.SizeOfHeaders; |
1002 | obBuffer << m_inthHeader.OptionalHeader.CheckSum; | 1002 | obBuffer << m_inthHeader.OptionalHeader.CheckSum; |
1003 | obBuffer << m_inthHeader.OptionalHeader.Subsystem; | 1003 | obBuffer << m_inthHeader.OptionalHeader.Subsystem; |
1004 | obBuffer << m_inthHeader.OptionalHeader.DllCharacteristics; | 1004 | obBuffer << m_inthHeader.OptionalHeader.DllCharacteristics; |
1005 | obBuffer << m_inthHeader.OptionalHeader.SizeOfStackReserve; | 1005 | obBuffer << m_inthHeader.OptionalHeader.SizeOfStackReserve; |
1006 | obBuffer << m_inthHeader.OptionalHeader.SizeOfStackCommit; | 1006 | obBuffer << m_inthHeader.OptionalHeader.SizeOfStackCommit; |
1007 | obBuffer << m_inthHeader.OptionalHeader.SizeOfHeapReserve; | 1007 | obBuffer << m_inthHeader.OptionalHeader.SizeOfHeapReserve; |
1008 | obBuffer << m_inthHeader.OptionalHeader.SizeOfHeapCommit; | 1008 | obBuffer << m_inthHeader.OptionalHeader.SizeOfHeapCommit; |
1009 | obBuffer << m_inthHeader.OptionalHeader.LoaderFlags; | 1009 | obBuffer << m_inthHeader.OptionalHeader.LoaderFlags; |
1010 | obBuffer << m_inthHeader.OptionalHeader.NumberOfRvaAndSizes; | 1010 | obBuffer << m_inthHeader.OptionalHeader.NumberOfRvaAndSizes; |
1011 | 1011 | ||
1012 | // The 0x10 data directories | 1012 | // The 0x10 data directories |
1013 | for (unsigned int i=0;i<calcNumberOfRvaAndSizes();i++) | 1013 | for (unsigned int i=0;i<calcNumberOfRvaAndSizes();i++) |
1014 | { | 1014 | { |
1015 | obBuffer << m_inthHeader.dataDirectories[i].VirtualAddress; | 1015 | obBuffer << m_inthHeader.dataDirectories[i].VirtualAddress; |
1016 | obBuffer << m_inthHeader.dataDirectories[i].Size; | 1016 | obBuffer << m_inthHeader.dataDirectories[i].Size; |
1017 | } | 1017 | } |
1018 | 1018 | ||
1019 | // The section definitions | 1019 | // The section definitions |
1020 | const unsigned int nrSections = calcNumberOfSections(); | 1020 | const unsigned int nrSections = calcNumberOfSections(); |
1021 | for (unsigned int i=0;i<nrSections;i++) | 1021 | for (unsigned int i=0;i<nrSections;i++) |
1022 | { | 1022 | { |
1023 | char temp[9] = {0}; | 1023 | char temp[9] = {0}; |
1024 | strcpy(temp, getSectionName(i).c_str()); | 1024 | strcpy(temp, getSectionName(i).c_str()); |
1025 | obBuffer.add(temp, 8); | 1025 | obBuffer.add(temp, 8); |
1026 | obBuffer << m_vIsh[i].VirtualSize; | 1026 | obBuffer << m_vIsh[i].VirtualSize; |
1027 | obBuffer << m_vIsh[i].VirtualAddress; | 1027 | obBuffer << m_vIsh[i].VirtualAddress; |
1028 | obBuffer << m_vIsh[i].SizeOfRawData; | 1028 | obBuffer << m_vIsh[i].SizeOfRawData; |
1029 | obBuffer << m_vIsh[i].PointerToRawData; | 1029 | obBuffer << m_vIsh[i].PointerToRawData; |
1030 | obBuffer << m_vIsh[i].PointerToRelocations; | 1030 | obBuffer << m_vIsh[i].PointerToRelocations; |
1031 | obBuffer << m_vIsh[i].PointerToLinenumbers; | 1031 | obBuffer << m_vIsh[i].PointerToLinenumbers; |
1032 | obBuffer << m_vIsh[i].NumberOfRelocations; | 1032 | obBuffer << m_vIsh[i].NumberOfRelocations; |
1033 | obBuffer << m_vIsh[i].NumberOfLinenumbers; | 1033 | obBuffer << m_vIsh[i].NumberOfLinenumbers; |
1034 | obBuffer << m_vIsh[i].Characteristics; | 1034 | obBuffer << m_vIsh[i].Characteristics; |
1035 | } | 1035 | } |
1036 | } | 1036 | } |
1037 | 1037 | ||
1038 | /** | 1038 | /** |
1039 | * Converts a relative virtual offset to a file offset. | 1039 | * Converts a relative virtual offset to a file offset. |
1040 | * @param dwRva A relative virtual offset. | 1040 | * @param dwRva A relative virtual offset. |
1041 | * @return A file offset. | 1041 | * @return A file offset. |
1042 | * \todo It's not always 0x1000. | 1042 | * \todo It's not always 0x1000. |
1043 | **/ | 1043 | **/ |
1044 | template<int x> | 1044 | template<int x> |
1045 | typename FieldSizes<x>::VAR4_8 PeHeaderT<x>::rvaToOffset(VAR4_8 dwRva) const | 1045 | typename FieldSizes<x>::VAR4_8 PeHeaderT<x>::rvaToOffset(VAR4_8 dwRva) const |
1046 | { | 1046 | { |
1047 | // XXX: Not correct | 1047 | // XXX: Not correct |
1048 | if (dwRva < 0x1000) return dwRva; | 1048 | if (dwRva < 0x1000) return dwRva; |
1049 | 1049 | ||
1050 | PeLib::word uiSecnr = getSectionWithRva(dwRva); | 1050 | PeLib::word uiSecnr = getSectionWithRva(dwRva); |
1051 | if (uiSecnr == 0xFFFF || dwRva > getVirtualAddress(uiSecnr) + getSizeOfRawData(uiSecnr)) | 1051 | if (uiSecnr == 0xFFFF || dwRva > getVirtualAddress(uiSecnr) + getSizeOfRawData(uiSecnr)) |
1052 | { | 1052 | { |
1053 | return std::numeric_limits<VAR4_8>::max(); | 1053 | return std::numeric_limits<VAR4_8>::max(); |
1054 | } | 1054 | } |
1055 | 1055 | ||
1056 | return getPointerToRawData(uiSecnr) + dwRva - getVirtualAddress(uiSecnr); | 1056 | return getPointerToRawData(uiSecnr) + dwRva - getVirtualAddress(uiSecnr); |
1057 | } | 1057 | } |
1058 | 1058 | ||
1059 | /** | 1059 | /** |
1060 | * Converts a relative virtual offset to a virtual offset. | 1060 | * Converts a relative virtual offset to a virtual offset. |
1061 | * @param dwRva A relative virtual offset. | 1061 | * @param dwRva A relative virtual offset. |
1062 | * @return A virtual offset. | 1062 | * @return A virtual offset. |
1063 | **/ | 1063 | **/ |
1064 | template<int x> | 1064 | template<int x> |
1065 | typename FieldSizes<x>::VAR4_8 PeHeaderT<x>::rvaToVa(VAR4_8 dwRva) const | 1065 | typename FieldSizes<x>::VAR4_8 PeHeaderT<x>::rvaToVa(VAR4_8 dwRva) const |
1066 | { | 1066 | { |
1067 | return getImageBase() + dwRva; | 1067 | return getImageBase() + dwRva; |
1068 | } | 1068 | } |
1069 | 1069 | ||
1070 | /** | 1070 | /** |
1071 | * Calculates the size of the current PE header. This includes the actual header and the section definitions. | 1071 | * Calculates the size of the current PE header. This includes the actual header and the section definitions. |
1072 | * @return Size of the current PE header. | 1072 | * @return Size of the current PE header. |
1073 | * \todo Better handling of files with less than 0x10 directories. | 1073 | * \todo Better handling of files with less than 0x10 directories. |
1074 | **/ | 1074 | **/ |
1075 | template<int x> | 1075 | template<int x> |
1076 | unsigned int PeHeaderT<x>::size() const | 1076 | unsigned int PeHeaderT<x>::size() const |
1077 | { | 1077 | { |
1078 | return m_inthHeader.size() + getNumberOfSections() * PELIB_IMAGE_SECTION_HEADER::size(); | 1078 | return m_inthHeader.size() + getNumberOfSections() * PELIB_IMAGE_SECTION_HEADER::size(); |
1079 | } | 1079 | } |
1080 | 1080 | ||
1081 | // \todo Not sure if this works. | 1081 | // \todo Not sure if this works. |
1082 | template<int x> | 1082 | template<int x> |
1083 | typename FieldSizes<x>::VAR4_8 PeHeaderT<x>::vaToRva(VAR4_8 dwRva) const | 1083 | typename FieldSizes<x>::VAR4_8 PeHeaderT<x>::vaToRva(VAR4_8 dwRva) const |
1084 | { | 1084 | { |
1085 | if (dwRva - getImageBase() < calcStartOfCode()) return dwRva - getImageBase(); | 1085 | if (dwRva - getImageBase() < calcStartOfCode()) return dwRva - getImageBase(); |
1086 | 1086 | ||
1087 | if (getSectionWithRva(dwRva - getImageBase()) == 0xFFFF) return -1; | 1087 | if (getSectionWithRva(dwRva - getImageBase()) == 0xFFFF) return -1; |
1088 | 1088 | ||
1089 | return dwRva - getImageBase(); | 1089 | return dwRva - getImageBase(); |
1090 | } | 1090 | } |
1091 | 1091 | ||
1092 | template<int x> | 1092 | template<int x> |
1093 | typename FieldSizes<x>::VAR4_8 PeHeaderT<x>::vaToOffset(VAR4_8 dwRva) const | 1093 | typename FieldSizes<x>::VAR4_8 PeHeaderT<x>::vaToOffset(VAR4_8 dwRva) const |
1094 | { | 1094 | { |
1095 | return rvaToOffset(dwRva - getImageBase()); | 1095 | return rvaToOffset(dwRva - getImageBase()); |
1096 | } | 1096 | } |
1097 | 1097 | ||
1098 | /** | 1098 | /** |
1099 | * Saves the PE header to a file. Note that this only saves the header information, if you have added sections | 1099 | * Saves the PE header to a file. Note that this only saves the header information, if you have added sections |
1100 | * and want to save these to the file you have to call #PeLib::PeHeaderT<x>::saveSections too. This function also | 1100 | * and want to save these to the file you have to call #PeLib::PeHeaderT<x>::saveSections too. This function also |
1101 | * does not verify if the PE header is correct. If you want to make sure that the current PE header is valid, | 1101 | * does not verify if the PE header is correct. If you want to make sure that the current PE header is valid, |
1102 | * call #PeLib::PeHeaderT<x>::isValid and #PeLib::PeHeaderT<x>::makeValid first. | 1102 | * call #PeLib::PeHeaderT<x>::isValid and #PeLib::PeHeaderT<x>::makeValid first. |
1103 | * @param strFilename Filename of the file the header will be written to. | 1103 | * @param strFilename Filename of the file the header will be written to. |
1104 | * @param uiOffset File offset the header will be written to. | 1104 | * @param uiOffset File offset the header will be written to. |
1105 | **/ | 1105 | **/ |
1106 | template<int x> | 1106 | template<int x> |
1107 | int PeHeaderT<x>::write(std::string strFilename, unsigned int uiOffset) const | 1107 | int PeHeaderT<x>::write(std::string strFilename, unsigned int uiOffset) const |
1108 | { | 1108 | { |
1109 | std::fstream ofFile(strFilename.c_str(), std::ios_base::in); | 1109 | std::fstream ofFile(strFilename.c_str(), std::ios_base::in); |
1110 | 1110 | ||
1111 | if (!ofFile) | 1111 | if (!ofFile) |
1112 | { | 1112 | { |
1113 | ofFile.clear(); | 1113 | ofFile.clear(); |
1114 | ofFile.open(strFilename.c_str(), std::ios_base::out | std::ios_base::binary); | 1114 | ofFile.open(strFilename.c_str(), std::ios_base::out | std::ios_base::binary); |
1115 | } | 1115 | } |
1116 | else | 1116 | else |
1117 | { | 1117 | { |
1118 | ofFile.close(); | 1118 | ofFile.close(); |
1119 | ofFile.open(strFilename.c_str(), std::ios_base::in | std::ios_base::out | std::ios_base::binary); | 1119 | ofFile.open(strFilename.c_str(), std::ios_base::in | std::ios_base::out | std::ios_base::binary); |
1120 | } | 1120 | } |
1121 | 1121 | ||
1122 | if (!ofFile) | 1122 | if (!ofFile) |
1123 | { | 1123 | { |
1124 | return ERROR_OPENING_FILE; | 1124 | return ERROR_OPENING_FILE; |
1125 | } | 1125 | } |
1126 | 1126 | ||
1127 | ofFile.seekp(uiOffset, std::ios::beg); | 1127 | ofFile.seekp(uiOffset, std::ios::beg); |
1128 | 1128 | ||
1129 | std::vector<unsigned char> vBuffer; | 1129 | std::vector<unsigned char> vBuffer; |
1130 | 1130 | ||
1131 | rebuild(vBuffer); | 1131 | rebuild(vBuffer); |
1132 | 1132 | ||
1133 | ofFile.write(reinterpret_cast<const char*>(&vBuffer[0]), static_cast<unsigned int>(vBuffer.size())); | 1133 | ofFile.write(reinterpret_cast<const char*>(&vBuffer[0]), static_cast<unsigned int>(vBuffer.size())); |
1134 | 1134 | ||
1135 | ofFile.close(); | 1135 | ofFile.close(); |
1136 | 1136 | ||
1137 | return NO_ERROR; | 1137 | return NO_ERROR; |
1138 | } | 1138 | } |
1139 | 1139 | ||
1140 | 1140 | ||
1141 | /** | 1141 | /** |
1142 | * Overwrites a section's data. | 1142 | * Overwrites a section's data. |
1143 | * @param wSecnr Number of the section which will be overwritten. | 1143 | * @param wSecnr Number of the section which will be overwritten. |
1144 | * @param strFilename Name of the file where the section will be written to. | 1144 | * @param strFilename Name of the file where the section will be written to. |
1145 | * @param wSecnr Number of the section that will be written. | 1145 | * @param wSecnr Number of the section that will be written. |
1146 | * @param vBuffer New data of the section. | 1146 | * @param vBuffer New data of the section. |
1147 | **/ | 1147 | **/ |
1148 | template<int x> | 1148 | template<int x> |
1149 | int PeHeaderT<x>::writeSectionData(const std::string& strFilename, word wSecnr, const std::vector<byte>& vBuffer) const | 1149 | int PeHeaderT<x>::writeSectionData(const std::string& strFilename, word wSecnr, const std::vector<byte>& vBuffer) const |
1150 | { | 1150 | { |
1151 | std::fstream ofFile(strFilename.c_str(), std::ios_base::in); | 1151 | std::fstream ofFile(strFilename.c_str(), std::ios_base::in); |
1152 | 1152 | ||
1153 | if (!ofFile) | 1153 | if (!ofFile) |
1154 | { | 1154 | { |
1155 | ofFile.clear(); | 1155 | ofFile.clear(); |
1156 | ofFile.open(strFilename.c_str(), std::ios_base::out | std::ios_base::binary); | 1156 | ofFile.open(strFilename.c_str(), std::ios_base::out | std::ios_base::binary); |
1157 | } | 1157 | } |
1158 | else | 1158 | else |
1159 | { | 1159 | { |
1160 | ofFile.close(); | 1160 | ofFile.close(); |
1161 | ofFile.open(strFilename.c_str(), std::ios_base::in | std::ios_base::out | std::ios_base::binary); | 1161 | ofFile.open(strFilename.c_str(), std::ios_base::in | std::ios_base::out | std::ios_base::binary); |
1162 | } | 1162 | } |
1163 | 1163 | ||
1164 | if (!ofFile) | 1164 | if (!ofFile) |
1165 | { | 1165 | { |
1166 | ofFile.clear(); | 1166 | ofFile.clear(); |
1167 | 1167 | ||
1168 | return ERROR_OPENING_FILE; | 1168 | return ERROR_OPENING_FILE; |
1169 | } | 1169 | } |
1170 | 1170 | ||
1171 | ofFile.seekp(getPointerToRawData(wSecnr), std::ios::beg); | 1171 | ofFile.seekp(getPointerToRawData(wSecnr), std::ios::beg); |
1172 | 1172 | ||
1173 | ofFile.write(reinterpret_cast<const char*>(&vBuffer[0]), std::min(static_cast<unsigned int>(vBuffer.size()), getSizeOfRawData(wSecnr))); | 1173 | ofFile.write(reinterpret_cast<const char*>(&vBuffer[0]), std::min(static_cast<unsigned int>(vBuffer.size()), getSizeOfRawData(wSecnr))); |
1174 | 1174 | ||
1175 | ofFile.close(); | 1175 | ofFile.close(); |
1176 | 1176 | ||
1177 | return NO_ERROR; | 1177 | return NO_ERROR; |
1178 | } | 1178 | } |
1179 | 1179 | ||
1180 | template<int x> | 1180 | template<int x> |
1181 | int PeHeaderT<x>::writeSections(const std::string& strFilename) const | 1181 | int PeHeaderT<x>::writeSections(const std::string& strFilename) const |
1182 | { | 1182 | { |
1183 | std::fstream ofFile(strFilename.c_str(), std::ios_base::in); | 1183 | std::fstream ofFile(strFilename.c_str(), std::ios_base::in); |
1184 | 1184 | ||
1185 | if (!ofFile) | 1185 | if (!ofFile) |
1186 | { | 1186 | { |
1187 | ofFile.clear(); | 1187 | ofFile.clear(); |
1188 | ofFile.open(strFilename.c_str(), std::ios_base::out | std::ios_base::binary); | 1188 | ofFile.open(strFilename.c_str(), std::ios_base::out | std::ios_base::binary); |
1189 | } | 1189 | } |
1190 | else | 1190 | else |
1191 | { | 1191 | { |
1192 | ofFile.close(); | 1192 | ofFile.close(); |
1193 | ofFile.open(strFilename.c_str(), std::ios_base::in | std::ios_base::out | std::ios_base::binary); | 1193 | ofFile.open(strFilename.c_str(), std::ios_base::in | std::ios_base::out | std::ios_base::binary); |
1194 | } | 1194 | } |
1195 | 1195 | ||
1196 | if (!ofFile) | 1196 | if (!ofFile) |
1197 | { | 1197 | { |
1198 | return ERROR_OPENING_FILE; | 1198 | return ERROR_OPENING_FILE; |
1199 | } | 1199 | } |
1200 | 1200 | ||
1201 | unsigned int uiFilesize = fileSize(ofFile); | 1201 | unsigned int uiFilesize = fileSize(ofFile); |
1202 | 1202 | ||
1203 | for (int i=0;i<calcNumberOfSections();i++) | 1203 | for (int i=0;i<calcNumberOfSections();i++) |
1204 | { | 1204 | { |
1205 | if (uiFilesize < getPointerToRawData(i) + getSizeOfRawData(i)) | 1205 | if (uiFilesize < getPointerToRawData(i) + getSizeOfRawData(i)) |
1206 | { | 1206 | { |
1207 | unsigned int uiToWrite = getPointerToRawData(i) + getSizeOfRawData(i) - uiFilesize; | 1207 | unsigned int uiToWrite = getPointerToRawData(i) + getSizeOfRawData(i) - uiFilesize; |
1208 | std::vector<char> vBuffer(uiToWrite); | 1208 | std::vector<char> vBuffer(uiToWrite); |
1209 | ofFile.seekp(0, std::ios::end); | 1209 | ofFile.seekp(0, std::ios::end); |
1210 | ofFile.write(&vBuffer[0], static_cast<unsigned int>(vBuffer.size())); | 1210 | ofFile.write(&vBuffer[0], static_cast<unsigned int>(vBuffer.size())); |
1211 | uiFilesize = getPointerToRawData(i) + getSizeOfRawData(i); | 1211 | uiFilesize = getPointerToRawData(i) + getSizeOfRawData(i); |
1212 | } | 1212 | } |
1213 | } | 1213 | } |
1214 | 1214 | ||
1215 | ofFile.close(); | 1215 | ofFile.close(); |
1216 | 1216 | ||
1217 | return NO_ERROR; | 1217 | return NO_ERROR; |
1218 | } | 1218 | } |
1219 | 1219 | ||
1220 | /** | 1220 | /** |
1221 | * Returns the file's Nt signature. | 1221 | * Returns the file's Nt signature. |
1222 | * @return The Nt signature value from the PE header. | 1222 | * @return The Nt signature value from the PE header. |
1223 | **/ | 1223 | **/ |
1224 | template<int x> | 1224 | template<int x> |
1225 | dword PeHeaderT<x>::getNtSignature() const | 1225 | dword PeHeaderT<x>::getNtSignature() const |
1226 | { | 1226 | { |
1227 | return m_inthHeader.Signature; | 1227 | return m_inthHeader.Signature; |
1228 | } | 1228 | } |
1229 | 1229 | ||
1230 | /** | 1230 | /** |
1231 | * Returns the file's machine. | 1231 | * Returns the file's machine. |
1232 | * @return The Machine value from the PE header. | 1232 | * @return The Machine value from the PE header. |
1233 | **/ | 1233 | **/ |
1234 | template<int x> | 1234 | template<int x> |
1235 | word PeHeaderT<x>::getMachine() const | 1235 | word PeHeaderT<x>::getMachine() const |
1236 | { | 1236 | { |
1237 | return m_inthHeader.FileHeader.Machine; | 1237 | return m_inthHeader.FileHeader.Machine; |
1238 | } | 1238 | } |
1239 | 1239 | ||
1240 | 1240 | ||
1241 | /** | 1241 | /** |
1242 | * Returns the file's number of sections as defined in the header. Note that this value can be different | 1242 | * Returns the file's number of sections as defined in the header. Note that this value can be different |
1243 | * from the number of defined sections (#see PeLib::PeHeaderT<x>::getNumberOfSections). | 1243 | * from the number of defined sections (#see PeLib::PeHeaderT<x>::getNumberOfSections). |
1244 | * @return The NumberOfSections value from the PE header. | 1244 | * @return The NumberOfSections value from the PE header. |
1245 | **/ | 1245 | **/ |
1246 | template<int x> | 1246 | template<int x> |
1247 | word PeHeaderT<x>::getNumberOfSections() const | 1247 | word PeHeaderT<x>::getNumberOfSections() const |
1248 | { | 1248 | { |
1249 | return m_inthHeader.FileHeader.NumberOfSections; | 1249 | return m_inthHeader.FileHeader.NumberOfSections; |
1250 | } | 1250 | } |
1251 | 1251 | ||
1252 | /** | 1252 | /** |
1253 | * Returns the file's TimeDateStamp. | 1253 | * Returns the file's TimeDateStamp. |
1254 | * @return The TimeDateStamp value from the PE header. | 1254 | * @return The TimeDateStamp value from the PE header. |
1255 | **/ | 1255 | **/ |
1256 | template<int x> | 1256 | template<int x> |
1257 | dword PeHeaderT<x>::getTimeDateStamp() const | 1257 | dword PeHeaderT<x>::getTimeDateStamp() const |
1258 | { | 1258 | { |
1259 | return m_inthHeader.FileHeader.TimeDateStamp; | 1259 | return m_inthHeader.FileHeader.TimeDateStamp; |
1260 | } | 1260 | } |
1261 | 1261 | ||
1262 | /** | 1262 | /** |
1263 | * Returns the relative virtual address of the file's symbol table. | 1263 | * Returns the relative virtual address of the file's symbol table. |
1264 | * @return The PointerToSymbolTable value from the PE header. | 1264 | * @return The PointerToSymbolTable value from the PE header. |
1265 | **/ | 1265 | **/ |
1266 | template<int x> | 1266 | template<int x> |
1267 | dword PeHeaderT<x>::getPointerToSymbolTable() const | 1267 | dword PeHeaderT<x>::getPointerToSymbolTable() const |
1268 | { | 1268 | { |
1269 | return m_inthHeader.FileHeader.PointerToSymbolTable; | 1269 | return m_inthHeader.FileHeader.PointerToSymbolTable; |
1270 | } | 1270 | } |
1271 | 1271 | ||
1272 | /** | 1272 | /** |
1273 | * Returns the number of symbols of the file's symbol table. | 1273 | * Returns the number of symbols of the file's symbol table. |
1274 | * @return The NumberOfSymbols value from the PE header. | 1274 | * @return The NumberOfSymbols value from the PE header. |
1275 | **/ | 1275 | **/ |
1276 | template<int x> | 1276 | template<int x> |
1277 | dword PeHeaderT<x>::getNumberOfSymbols() const | 1277 | dword PeHeaderT<x>::getNumberOfSymbols() const |
1278 | { | 1278 | { |
1279 | return m_inthHeader.FileHeader.NumberOfSymbols; | 1279 | return m_inthHeader.FileHeader.NumberOfSymbols; |
1280 | } | 1280 | } |
1281 | 1281 | ||
1282 | /** | 1282 | /** |
1283 | * Returns the size of optional header of the file. | 1283 | * Returns the size of optional header of the file. |
1284 | * @return The SizeOfOptionalHeader value from the PE header. | 1284 | * @return The SizeOfOptionalHeader value from the PE header. |
1285 | **/ | 1285 | **/ |
1286 | template<int x> | 1286 | template<int x> |
1287 | word PeHeaderT<x>::getSizeOfOptionalHeader() const | 1287 | word PeHeaderT<x>::getSizeOfOptionalHeader() const |
1288 | { | 1288 | { |
1289 | return m_inthHeader.FileHeader.SizeOfOptionalHeader; | 1289 | return m_inthHeader.FileHeader.SizeOfOptionalHeader; |
1290 | } | 1290 | } |
1291 | 1291 | ||
1292 | /** | 1292 | /** |
1293 | * @return The Characteristics value from the PE header. | 1293 | * @return The Characteristics value from the PE header. |
1294 | **/ | 1294 | **/ |
1295 | template<int x> | 1295 | template<int x> |
1296 | word PeHeaderT<x>::getCharacteristics() const | 1296 | word PeHeaderT<x>::getCharacteristics() const |
1297 | { | 1297 | { |
1298 | return m_inthHeader.FileHeader.Characteristics; | 1298 | return m_inthHeader.FileHeader.Characteristics; |
1299 | } | 1299 | } |
1300 | 1300 | ||
1301 | /** | 1301 | /** |
1302 | * @return The Magic value from the PE header. | 1302 | * @return The Magic value from the PE header. |
1303 | **/ | 1303 | **/ |
1304 | template<int x> | 1304 | template<int x> |
1305 | word PeHeaderT<x>::getMagic() const | 1305 | word PeHeaderT<x>::getMagic() const |
1306 | { | 1306 | { |
1307 | return m_inthHeader.OptionalHeader.Magic; | 1307 | return m_inthHeader.OptionalHeader.Magic; |
1308 | } | 1308 | } |
1309 | 1309 | ||
1310 | /** | 1310 | /** |
1311 | * @return The MajorLinkerVersion value from the PE header. | 1311 | * @return The MajorLinkerVersion value from the PE header. |
1312 | **/ | 1312 | **/ |
1313 | template<int x> | 1313 | template<int x> |
1314 | byte PeHeaderT<x>::getMajorLinkerVersion() const | 1314 | byte PeHeaderT<x>::getMajorLinkerVersion() const |
1315 | { | 1315 | { |
1316 | return m_inthHeader.OptionalHeader.MajorLinkerVersion; | 1316 | return m_inthHeader.OptionalHeader.MajorLinkerVersion; |
1317 | } | 1317 | } |
1318 | 1318 | ||
1319 | /** | 1319 | /** |
1320 | * @return The MinorLinkerVersion value from the PE header. | 1320 | * @return The MinorLinkerVersion value from the PE header. |
1321 | **/ | 1321 | **/ |
1322 | template<int x> | 1322 | template<int x> |
1323 | byte PeHeaderT<x>::getMinorLinkerVersion() const | 1323 | byte PeHeaderT<x>::getMinorLinkerVersion() const |
1324 | { | 1324 | { |
1325 | return m_inthHeader.OptionalHeader.MinorLinkerVersion; | 1325 | return m_inthHeader.OptionalHeader.MinorLinkerVersion; |
1326 | } | 1326 | } |
1327 | 1327 | ||
1328 | /** | 1328 | /** |
1329 | * @return The SizeOfCode value from the PE header. | 1329 | * @return The SizeOfCode value from the PE header. |
1330 | **/ | 1330 | **/ |
1331 | template<int x> | 1331 | template<int x> |
1332 | dword PeHeaderT<x>::getSizeOfCode() const | 1332 | dword PeHeaderT<x>::getSizeOfCode() const |
1333 | { | 1333 | { |
1334 | return m_inthHeader.OptionalHeader.SizeOfCode; | 1334 | return m_inthHeader.OptionalHeader.SizeOfCode; |
1335 | } | 1335 | } |
1336 | 1336 | ||
1337 | /** | 1337 | /** |
1338 | * @return The SizeOfInitializedData value from the PE header. | 1338 | * @return The SizeOfInitializedData value from the PE header. |
1339 | **/ | 1339 | **/ |
1340 | template<int x> | 1340 | template<int x> |
1341 | dword PeHeaderT<x>::getSizeOfInitializedData() const | 1341 | dword PeHeaderT<x>::getSizeOfInitializedData() const |
1342 | { | 1342 | { |
1343 | return m_inthHeader.OptionalHeader.SizeOfInitializedData; | 1343 | return m_inthHeader.OptionalHeader.SizeOfInitializedData; |
1344 | } | 1344 | } |
1345 | 1345 | ||
1346 | /** | 1346 | /** |
1347 | * @return The SizeOfUninitializedData value from the PE header. | 1347 | * @return The SizeOfUninitializedData value from the PE header. |
1348 | **/ | 1348 | **/ |
1349 | template<int x> | 1349 | template<int x> |
1350 | dword PeHeaderT<x>::getSizeOfUninitializedData() const | 1350 | dword PeHeaderT<x>::getSizeOfUninitializedData() const |
1351 | { | 1351 | { |
1352 | return m_inthHeader.OptionalHeader.SizeOfUninitializedData; | 1352 | return m_inthHeader.OptionalHeader.SizeOfUninitializedData; |
1353 | } | 1353 | } |
1354 | 1354 | ||
1355 | /** | 1355 | /** |
1356 | * @return The AddressOfEntryPoint value from the PE header. | 1356 | * @return The AddressOfEntryPoint value from the PE header. |
1357 | **/ | 1357 | **/ |
1358 | template<int x> | 1358 | template<int x> |
1359 | dword PeHeaderT<x>::getAddressOfEntryPoint() const | 1359 | dword PeHeaderT<x>::getAddressOfEntryPoint() const |
1360 | { | 1360 | { |
1361 | return m_inthHeader.OptionalHeader.AddressOfEntryPoint; | 1361 | return m_inthHeader.OptionalHeader.AddressOfEntryPoint; |
1362 | } | 1362 | } |
1363 | 1363 | ||
1364 | /** | 1364 | /** |
1365 | * @return The BaseOfCode value from the PE header. | 1365 | * @return The BaseOfCode value from the PE header. |
1366 | **/ | 1366 | **/ |
1367 | template<int x> | 1367 | template<int x> |
1368 | dword PeHeaderT<x>::getBaseOfCode() const | 1368 | dword PeHeaderT<x>::getBaseOfCode() const |
1369 | { | 1369 | { |
1370 | return m_inthHeader.OptionalHeader.BaseOfCode; | 1370 | return m_inthHeader.OptionalHeader.BaseOfCode; |
1371 | } | 1371 | } |
1372 | 1372 | ||
1373 | /** | 1373 | /** |
1374 | * @return The ImageBase value from the PE header. | 1374 | * @return The ImageBase value from the PE header. |
1375 | **/ | 1375 | **/ |
1376 | template<int x> | 1376 | template<int x> |
1377 | typename FieldSizes<x>::VAR4_8 PeHeaderT<x>::getImageBase() const | 1377 | typename FieldSizes<x>::VAR4_8 PeHeaderT<x>::getImageBase() const |
1378 | { | 1378 | { |
1379 | return m_inthHeader.OptionalHeader.ImageBase; | 1379 | return m_inthHeader.OptionalHeader.ImageBase; |
1380 | } | 1380 | } |
1381 | 1381 | ||
1382 | /** | 1382 | /** |
1383 | * @return The SectionAlignment value from the PE header. | 1383 | * @return The SectionAlignment value from the PE header. |
1384 | **/ | 1384 | **/ |
1385 | template<int x> | 1385 | template<int x> |
1386 | dword PeHeaderT<x>::getSectionAlignment() const | 1386 | dword PeHeaderT<x>::getSectionAlignment() const |
1387 | { | 1387 | { |
1388 | return m_inthHeader.OptionalHeader.SectionAlignment; | 1388 | return m_inthHeader.OptionalHeader.SectionAlignment; |
1389 | } | 1389 | } |
1390 | 1390 | ||
1391 | /** | 1391 | /** |
1392 | * @return The FileAlignment value from the PE header. | 1392 | * @return The FileAlignment value from the PE header. |
1393 | **/ | 1393 | **/ |
1394 | template<int x> | 1394 | template<int x> |
1395 | dword PeHeaderT<x>::getFileAlignment() const | 1395 | dword PeHeaderT<x>::getFileAlignment() const |
1396 | { | 1396 | { |
1397 | return m_inthHeader.OptionalHeader.FileAlignment; | 1397 | return m_inthHeader.OptionalHeader.FileAlignment; |
1398 | } | 1398 | } |
1399 | 1399 | ||
1400 | /** | 1400 | /** |
1401 | * @return The MajorOperatingSystemVersion value from the PE header. | 1401 | * @return The MajorOperatingSystemVersion value from the PE header. |
1402 | **/ | 1402 | **/ |
1403 | template<int x> | 1403 | template<int x> |
1404 | word PeHeaderT<x>::getMajorOperatingSystemVersion() const | 1404 | word PeHeaderT<x>::getMajorOperatingSystemVersion() const |
1405 | { | 1405 | { |
1406 | return m_inthHeader.OptionalHeader.MajorOperatingSystemVersion; | 1406 | return m_inthHeader.OptionalHeader.MajorOperatingSystemVersion; |
1407 | } | 1407 | } |
1408 | 1408 | ||
1409 | /** | 1409 | /** |
1410 | * @return The MinorOperatingSystemVersion value from the PE header. | 1410 | * @return The MinorOperatingSystemVersion value from the PE header. |
1411 | **/ | 1411 | **/ |
1412 | template<int x> | 1412 | template<int x> |
1413 | word PeHeaderT<x>::getMinorOperatingSystemVersion() const | 1413 | word PeHeaderT<x>::getMinorOperatingSystemVersion() const |
1414 | { | 1414 | { |
1415 | return m_inthHeader.OptionalHeader.MinorOperatingSystemVersion; | 1415 | return m_inthHeader.OptionalHeader.MinorOperatingSystemVersion; |
1416 | } | 1416 | } |
1417 | 1417 | ||
1418 | /** | 1418 | /** |
1419 | * @return The MajorImageVersion value from the PE header. | 1419 | * @return The MajorImageVersion value from the PE header. |
1420 | **/ | 1420 | **/ |
1421 | template<int x> | 1421 | template<int x> |
1422 | word PeHeaderT<x>::getMajorImageVersion() const | 1422 | word PeHeaderT<x>::getMajorImageVersion() const |
1423 | { | 1423 | { |
1424 | return m_inthHeader.OptionalHeader.MajorImageVersion; | 1424 | return m_inthHeader.OptionalHeader.MajorImageVersion; |
1425 | } | 1425 | } |
1426 | 1426 | ||
1427 | /** | 1427 | /** |
1428 | * @return The MinorImageVersion value from the PE header. | 1428 | * @return The MinorImageVersion value from the PE header. |
1429 | **/ | 1429 | **/ |
1430 | template<int x> | 1430 | template<int x> |
1431 | word PeHeaderT<x>::getMinorImageVersion() const | 1431 | word PeHeaderT<x>::getMinorImageVersion() const |
1432 | { | 1432 | { |
1433 | return m_inthHeader.OptionalHeader.MinorImageVersion; | 1433 | return m_inthHeader.OptionalHeader.MinorImageVersion; |
1434 | } | 1434 | } |
1435 | 1435 | ||
1436 | /** | 1436 | /** |
1437 | * @return The MajorSubsystemVersion value from the PE header. | 1437 | * @return The MajorSubsystemVersion value from the PE header. |
1438 | **/ | 1438 | **/ |
1439 | template<int x> | 1439 | template<int x> |
1440 | word PeHeaderT<x>::getMajorSubsystemVersion() const | 1440 | word PeHeaderT<x>::getMajorSubsystemVersion() const |
1441 | { | 1441 | { |
1442 | return m_inthHeader.OptionalHeader.MajorSubsystemVersion; | 1442 | return m_inthHeader.OptionalHeader.MajorSubsystemVersion; |
1443 | } | 1443 | } |
1444 | 1444 | ||
1445 | /** | 1445 | /** |
1446 | * @return The MinorSubsystemVersion value from the PE header. | 1446 | * @return The MinorSubsystemVersion value from the PE header. |
1447 | **/ | 1447 | **/ |
1448 | template<int x> | 1448 | template<int x> |
1449 | word PeHeaderT<x>::getMinorSubsystemVersion() const | 1449 | word PeHeaderT<x>::getMinorSubsystemVersion() const |
1450 | { | 1450 | { |
1451 | return m_inthHeader.OptionalHeader.MinorSubsystemVersion; | 1451 | return m_inthHeader.OptionalHeader.MinorSubsystemVersion; |
1452 | } | 1452 | } |
1453 | 1453 | ||
1454 | /** | 1454 | /** |
1455 | * @return The WinVersionValue value from the PE header. | 1455 | * @return The WinVersionValue value from the PE header. |
1456 | **/ | 1456 | **/ |
1457 | template<int x> | 1457 | template<int x> |
1458 | dword PeHeaderT<x>::getWin32VersionValue() const | 1458 | dword PeHeaderT<x>::getWin32VersionValue() const |
1459 | { | 1459 | { |
1460 | return m_inthHeader.OptionalHeader.Win32VersionValue; | 1460 | return m_inthHeader.OptionalHeader.Win32VersionValue; |
1461 | } | 1461 | } |
1462 | 1462 | ||
1463 | /** | 1463 | /** |
1464 | * @return The SizeOfImage value from the PE header. | 1464 | * @return The SizeOfImage value from the PE header. |
1465 | **/ | 1465 | **/ |
1466 | template<int x> | 1466 | template<int x> |
1467 | dword PeHeaderT<x>::getSizeOfImage() const | 1467 | dword PeHeaderT<x>::getSizeOfImage() const |
1468 | { | 1468 | { |
1469 | return m_inthHeader.OptionalHeader.SizeOfImage; | 1469 | return m_inthHeader.OptionalHeader.SizeOfImage; |
1470 | } | 1470 | } |
1471 | 1471 | ||
1472 | /** | 1472 | /** |
1473 | * @return The SizeOfHeaders value from the PE header. | 1473 | * @return The SizeOfHeaders value from the PE header. |
1474 | **/ | 1474 | **/ |
1475 | template<int x> | 1475 | template<int x> |
1476 | dword PeHeaderT<x>::getSizeOfHeaders() const | 1476 | dword PeHeaderT<x>::getSizeOfHeaders() const |
1477 | { | 1477 | { |
1478 | return m_inthHeader.OptionalHeader.SizeOfHeaders; | 1478 | return m_inthHeader.OptionalHeader.SizeOfHeaders; |
1479 | } | 1479 | } |
1480 | 1480 | ||
1481 | /** | 1481 | /** |
1482 | * @return The CheckSums value from the PE header. | 1482 | * @return The CheckSums value from the PE header. |
1483 | **/ | 1483 | **/ |
1484 | template<int x> | 1484 | template<int x> |
1485 | dword PeHeaderT<x>::getCheckSum() const | 1485 | dword PeHeaderT<x>::getCheckSum() const |
1486 | { | 1486 | { |
1487 | return m_inthHeader.OptionalHeader.CheckSum; | 1487 | return m_inthHeader.OptionalHeader.CheckSum; |
1488 | } | 1488 | } |
1489 | 1489 | ||
1490 | /** | 1490 | /** |
1491 | * @return The Subsystem value from the PE header. | 1491 | * @return The Subsystem value from the PE header. |
1492 | **/ | 1492 | **/ |
1493 | template<int x> | 1493 | template<int x> |
1494 | word PeHeaderT<x>::getSubsystem() const | 1494 | word PeHeaderT<x>::getSubsystem() const |
1495 | { | 1495 | { |
1496 | return m_inthHeader.OptionalHeader.Subsystem; | 1496 | return m_inthHeader.OptionalHeader.Subsystem; |
1497 | } | 1497 | } |
1498 | 1498 | ||
1499 | /** | 1499 | /** |
1500 | * @return The DllCharacteristics value from the PE header. | 1500 | * @return The DllCharacteristics value from the PE header. |
1501 | **/ | 1501 | **/ |
1502 | template<int x> | 1502 | template<int x> |
1503 | word PeHeaderT<x>::getDllCharacteristics() const | 1503 | word PeHeaderT<x>::getDllCharacteristics() const |
1504 | { | 1504 | { |
1505 | return m_inthHeader.OptionalHeader.DllCharacteristics; | 1505 | return m_inthHeader.OptionalHeader.DllCharacteristics; |
1506 | } | 1506 | } |
1507 | 1507 | ||
1508 | /** | 1508 | /** |
1509 | * @return The SizeOfStackReserve value from the PE header. | 1509 | * @return The SizeOfStackReserve value from the PE header. |
1510 | **/ | 1510 | **/ |
1511 | template<int x> | 1511 | template<int x> |
1512 | typename FieldSizes<x>::VAR4_8 PeHeaderT<x>::getSizeOfStackReserve() const | 1512 | typename FieldSizes<x>::VAR4_8 PeHeaderT<x>::getSizeOfStackReserve() const |
1513 | { | 1513 | { |
1514 | return m_inthHeader.OptionalHeader.SizeOfStackReserve; | 1514 | return m_inthHeader.OptionalHeader.SizeOfStackReserve; |
1515 | } | 1515 | } |
1516 | 1516 | ||
1517 | /** | 1517 | /** |
1518 | * @return The SizeOfStackCommit value from the PE header. | 1518 | * @return The SizeOfStackCommit value from the PE header. |
1519 | **/ | 1519 | **/ |
1520 | template<int x> | 1520 | template<int x> |
1521 | typename FieldSizes<x>::VAR4_8 PeHeaderT<x>::getSizeOfStackCommit() const | 1521 | typename FieldSizes<x>::VAR4_8 PeHeaderT<x>::getSizeOfStackCommit() const |
1522 | { | 1522 | { |
1523 | return m_inthHeader.OptionalHeader.SizeOfStackCommit; | 1523 | return m_inthHeader.OptionalHeader.SizeOfStackCommit; |
1524 | } | 1524 | } |
1525 | 1525 | ||
1526 | /** | 1526 | /** |
1527 | * @return The SizeOfHeapReserve value from the PE header. | 1527 | * @return The SizeOfHeapReserve value from the PE header. |
1528 | **/ | 1528 | **/ |
1529 | template<int x> | 1529 | template<int x> |
1530 | typename FieldSizes<x>::VAR4_8 PeHeaderT<x>::getSizeOfHeapReserve() const | 1530 | typename FieldSizes<x>::VAR4_8 PeHeaderT<x>::getSizeOfHeapReserve() const |
1531 | { | 1531 | { |
1532 | return m_inthHeader.OptionalHeader.SizeOfHeapReserve; | 1532 | return m_inthHeader.OptionalHeader.SizeOfHeapReserve; |
1533 | } | 1533 | } |
1534 | 1534 | ||
1535 | /** | 1535 | /** |
1536 | * @return The SizeOfHeapCommit value from the PE header. | 1536 | * @return The SizeOfHeapCommit value from the PE header. |
1537 | **/ | 1537 | **/ |
1538 | template<int x> | 1538 | template<int x> |
1539 | typename FieldSizes<x>::VAR4_8 PeHeaderT<x>::getSizeOfHeapCommit() const | 1539 | typename FieldSizes<x>::VAR4_8 PeHeaderT<x>::getSizeOfHeapCommit() const |
1540 | { | 1540 | { |
1541 | return m_inthHeader.OptionalHeader.SizeOfHeapCommit; | 1541 | return m_inthHeader.OptionalHeader.SizeOfHeapCommit; |
1542 | } | 1542 | } |
1543 | 1543 | ||
1544 | /** | 1544 | /** |
1545 | * @return The LoaderFlags value from the PE header. | 1545 | * @return The LoaderFlags value from the PE header. |
1546 | **/ | 1546 | **/ |
1547 | template<int x> | 1547 | template<int x> |
1548 | dword PeHeaderT<x>::getLoaderFlags() const | 1548 | dword PeHeaderT<x>::getLoaderFlags() const |
1549 | { | 1549 | { |
1550 | return m_inthHeader.OptionalHeader.LoaderFlags; | 1550 | return m_inthHeader.OptionalHeader.LoaderFlags; |
1551 | } | 1551 | } |
1552 | 1552 | ||
1553 | /** | 1553 | /** |
1554 | * @return The NumberOfRvaAndSizes value from the PE header. | 1554 | * @return The NumberOfRvaAndSizes value from the PE header. |
1555 | **/ | 1555 | **/ |
1556 | template<int x> | 1556 | template<int x> |
1557 | dword PeHeaderT<x>::getNumberOfRvaAndSizes() const | 1557 | dword PeHeaderT<x>::getNumberOfRvaAndSizes() const |
1558 | { | 1558 | { |
1559 | return m_inthHeader.OptionalHeader.NumberOfRvaAndSizes; | 1559 | return m_inthHeader.OptionalHeader.NumberOfRvaAndSizes; |
1560 | } | 1560 | } |
1561 | 1561 | ||
1562 | template<int x> | 1562 | template<int x> |
1563 | dword PeHeaderT<x>::calcNumberOfRvaAndSizes() const | 1563 | dword PeHeaderT<x>::calcNumberOfRvaAndSizes() const |
1564 | { | 1564 | { |
1565 | return static_cast<dword>(m_inthHeader.dataDirectories.size()); | 1565 | return static_cast<dword>(m_inthHeader.dataDirectories.size()); |
1566 | } | 1566 | } |
1567 | 1567 | ||
1568 | /** | 1568 | /** |
1569 | * Returns the relative virtual address of the current file's export directory. | 1569 | * Returns the relative virtual address of the current file's export directory. |
1570 | * @return The Rva of the Export directory. | 1570 | * @return The Rva of the Export directory. |
1571 | **/ | 1571 | **/ |
1572 | template<int x> | 1572 | template<int x> |
1573 | dword PeHeaderT<x>::getIddExportRva() const | 1573 | dword PeHeaderT<x>::getIddExportRva() const |
1574 | { | 1574 | { |
1575 | return m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress; | 1575 | return m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress; |
1576 | } | 1576 | } |
1577 | 1577 | ||
1578 | /** | 1578 | /** |
1579 | * Returns the size of the current file's export directory. | 1579 | * Returns the size of the current file's export directory. |
1580 | * @return The sizeof the Export directory. | 1580 | * @return The sizeof the Export directory. |
1581 | **/ | 1581 | **/ |
1582 | template<int x> | 1582 | template<int x> |
1583 | dword PeHeaderT<x>::getIddExportSize() const | 1583 | dword PeHeaderT<x>::getIddExportSize() const |
1584 | { | 1584 | { |
1585 | return m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_EXPORT].Size; | 1585 | return m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_EXPORT].Size; |
1586 | } | 1586 | } |
1587 | 1587 | ||
1588 | /** | 1588 | /** |
1589 | * Returns the relative virtual address of the current file's import directory. | 1589 | * Returns the relative virtual address of the current file's import directory. |
1590 | * @return The Rva of the Import directory. | 1590 | * @return The Rva of the Import directory. |
1591 | **/ | 1591 | **/ |
1592 | template<int x> | 1592 | template<int x> |
1593 | dword PeHeaderT<x>::getIddImportRva() const | 1593 | dword PeHeaderT<x>::getIddImportRva() const |
1594 | { | 1594 | { |
1595 | return m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress; | 1595 | return m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress; |
1596 | } | 1596 | } |
1597 | 1597 | ||
1598 | /** | 1598 | /** |
1599 | * Returns the size of the current file's import directory. | 1599 | * Returns the size of the current file's import directory. |
1600 | * @return The size of the Import directory. | 1600 | * @return The size of the Import directory. |
1601 | **/ | 1601 | **/ |
1602 | template<int x> | 1602 | template<int x> |
1603 | dword PeHeaderT<x>::getIddImportSize() const | 1603 | dword PeHeaderT<x>::getIddImportSize() const |
1604 | { | 1604 | { |
1605 | return m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_IMPORT].Size; | 1605 | return m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_IMPORT].Size; |
1606 | } | 1606 | } |
1607 | 1607 | ||
1608 | /** | 1608 | /** |
1609 | * Returns the relative virtual address of the current file's resource directory. | 1609 | * Returns the relative virtual address of the current file's resource directory. |
1610 | * @return The Rva of the Resource directory. | 1610 | * @return The Rva of the Resource directory. |
1611 | **/ | 1611 | **/ |
1612 | template<int x> | 1612 | template<int x> |
1613 | dword PeHeaderT<x>::getIddResourceRva() const | 1613 | dword PeHeaderT<x>::getIddResourceRva() const |
1614 | { | 1614 | { |
1615 | return m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_RESOURCE].VirtualAddress; | 1615 | return m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_RESOURCE].VirtualAddress; |
1616 | } | 1616 | } |
1617 | 1617 | ||
1618 | /** | 1618 | /** |
1619 | * Returns the size of the current file'resource resource directory. | 1619 | * Returns the size of the current file'resource resource directory. |
1620 | * @return The size of the Resource directory. | 1620 | * @return The size of the Resource directory. |
1621 | **/ | 1621 | **/ |
1622 | template<int x> | 1622 | template<int x> |
1623 | dword PeHeaderT<x>::getIddResourceSize() const | 1623 | dword PeHeaderT<x>::getIddResourceSize() const |
1624 | { | 1624 | { |
1625 | return m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_RESOURCE].Size; | 1625 | return m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_RESOURCE].Size; |
1626 | } | 1626 | } |
1627 | 1627 | ||
1628 | /** | 1628 | /** |
1629 | * Returns the relative virtual address of the current file's exception directory. | 1629 | * Returns the relative virtual address of the current file's exception directory. |
1630 | * @return The Rva of the Exception directory. | 1630 | * @return The Rva of the Exception directory. |
1631 | **/ | 1631 | **/ |
1632 | template<int x> | 1632 | template<int x> |
1633 | dword PeHeaderT<x>::getIddExceptionRva() const | 1633 | dword PeHeaderT<x>::getIddExceptionRva() const |
1634 | { | 1634 | { |
1635 | return m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_EXCEPTION].VirtualAddress; | 1635 | return m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_EXCEPTION].VirtualAddress; |
1636 | } | 1636 | } |
1637 | 1637 | ||
1638 | /** | 1638 | /** |
1639 | * Returns the size of the current file's exception directory. | 1639 | * Returns the size of the current file's exception directory. |
1640 | * @return The size of the Exception directory. | 1640 | * @return The size of the Exception directory. |
1641 | **/ | 1641 | **/ |
1642 | template<int x> | 1642 | template<int x> |
1643 | dword PeHeaderT<x>::getIddExceptionSize() const | 1643 | dword PeHeaderT<x>::getIddExceptionSize() const |
1644 | { | 1644 | { |
1645 | return m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_EXCEPTION].Size; | 1645 | return m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_EXCEPTION].Size; |
1646 | } | 1646 | } |
1647 | 1647 | ||
1648 | /** | 1648 | /** |
1649 | * Returns the relative virtual address of the current file's security directory. | 1649 | * Returns the relative virtual address of the current file's security directory. |
1650 | * @return The Rva of the Security directory. | 1650 | * @return The Rva of the Security directory. |
1651 | **/ | 1651 | **/ |
1652 | template<int x> | 1652 | template<int x> |
1653 | dword PeHeaderT<x>::getIddSecurityRva() const | 1653 | dword PeHeaderT<x>::getIddSecurityRva() const |
1654 | { | 1654 | { |
1655 | return m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_SECURITY].VirtualAddress; | 1655 | return m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_SECURITY].VirtualAddress; |
1656 | } | 1656 | } |
1657 | 1657 | ||
1658 | /** | 1658 | /** |
1659 | * Returns the size of the current file's security directory. | 1659 | * Returns the size of the current file's security directory. |
1660 | * @return The size of the Security directory. | 1660 | * @return The size of the Security directory. |
1661 | **/ | 1661 | **/ |
1662 | template<int x> | 1662 | template<int x> |
1663 | dword PeHeaderT<x>::getIddSecuritySize() const | 1663 | dword PeHeaderT<x>::getIddSecuritySize() const |
1664 | { | 1664 | { |
1665 | return m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_SECURITY].Size; | 1665 | return m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_SECURITY].Size; |
1666 | } | 1666 | } |
1667 | 1667 | ||
1668 | /** | 1668 | /** |
1669 | * Returns the relative virtual address of the current file's base reloc directory. | 1669 | * Returns the relative virtual address of the current file's base reloc directory. |
1670 | * @return The Rva of the Base Reloc directory. | 1670 | * @return The Rva of the Base Reloc directory. |
1671 | **/ | 1671 | **/ |
1672 | template<int x> | 1672 | template<int x> |
1673 | dword PeHeaderT<x>::getIddBaseRelocRva() const | 1673 | dword PeHeaderT<x>::getIddBaseRelocRva() const |
1674 | { | 1674 | { |
1675 | return m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_BASERELOC].VirtualAddress; | 1675 | return m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_BASERELOC].VirtualAddress; |
1676 | } | 1676 | } |
1677 | 1677 | ||
1678 | /** | 1678 | /** |
1679 | * Returns the size of the current file's base reloc directory. | 1679 | * Returns the size of the current file's base reloc directory. |
1680 | * @return The size of the Base Reloc directory. | 1680 | * @return The size of the Base Reloc directory. |
1681 | **/ | 1681 | **/ |
1682 | template<int x> | 1682 | template<int x> |
1683 | dword PeHeaderT<x>::getIddBaseRelocSize() const | 1683 | dword PeHeaderT<x>::getIddBaseRelocSize() const |
1684 | { | 1684 | { |
1685 | return m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_BASERELOC].Size; | 1685 | return m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_BASERELOC].Size; |
1686 | } | 1686 | } |
1687 | 1687 | ||
1688 | /** | 1688 | /** |
1689 | * Returns the relative virtual address of the current file's debug directory. | 1689 | * Returns the relative virtual address of the current file's debug directory. |
1690 | * @return The Rva of the Debug directory. | 1690 | * @return The Rva of the Debug directory. |
1691 | **/ | 1691 | **/ |
1692 | template<int x> | 1692 | template<int x> |
1693 | dword PeHeaderT<x>::getIddDebugRva() const | 1693 | dword PeHeaderT<x>::getIddDebugRva() const |
1694 | { | 1694 | { |
1695 | return m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress; | 1695 | return m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress; |
1696 | } | 1696 | } |
1697 | 1697 | ||
1698 | /** | 1698 | /** |
1699 | * Returns the size of the current file's debug directory. | 1699 | * Returns the size of the current file's debug directory. |
1700 | * @return The size of the Debug directory. | 1700 | * @return The size of the Debug directory. |
1701 | **/ | 1701 | **/ |
1702 | template<int x> | 1702 | template<int x> |
1703 | dword PeHeaderT<x>::getIddDebugSize() const | 1703 | dword PeHeaderT<x>::getIddDebugSize() const |
1704 | { | 1704 | { |
1705 | return m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_DEBUG].Size; | 1705 | return m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_DEBUG].Size; |
1706 | } | 1706 | } |
1707 | 1707 | ||
1708 | /** | 1708 | /** |
1709 | * Returns the relative virtual address of the current file's Architecture directory. | 1709 | * Returns the relative virtual address of the current file's Architecture directory. |
1710 | * @return The Rva of the Architecture directory. | 1710 | * @return The Rva of the Architecture directory. |
1711 | **/ | 1711 | **/ |
1712 | template<int x> | 1712 | template<int x> |
1713 | dword PeHeaderT<x>::getIddArchitectureRva() const | 1713 | dword PeHeaderT<x>::getIddArchitectureRva() const |
1714 | { | 1714 | { |
1715 | return m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_ARCHITECTURE].VirtualAddress; | 1715 | return m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_ARCHITECTURE].VirtualAddress; |
1716 | } | 1716 | } |
1717 | 1717 | ||
1718 | /** | 1718 | /** |
1719 | * Returns the size of the current file's Architecture directory. | 1719 | * Returns the size of the current file's Architecture directory. |
1720 | * @return The size of the Architecture directory. | 1720 | * @return The size of the Architecture directory. |
1721 | **/ | 1721 | **/ |
1722 | template<int x> | 1722 | template<int x> |
1723 | dword PeHeaderT<x>::getIddArchitectureSize() const | 1723 | dword PeHeaderT<x>::getIddArchitectureSize() const |
1724 | { | 1724 | { |
1725 | return m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_ARCHITECTURE].Size; | 1725 | return m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_ARCHITECTURE].Size; |
1726 | } | 1726 | } |
1727 | 1727 | ||
1728 | /** | 1728 | /** |
1729 | * Returns the relative virtual address of the current file's global ptr directory. | 1729 | * Returns the relative virtual address of the current file's global ptr directory. |
1730 | * @return The Rva of the GlobalPtr directory. | 1730 | * @return The Rva of the GlobalPtr directory. |
1731 | **/ | 1731 | **/ |
1732 | template<int x> | 1732 | template<int x> |
1733 | dword PeHeaderT<x>::getIddGlobalPtrRva() const | 1733 | dword PeHeaderT<x>::getIddGlobalPtrRva() const |
1734 | { | 1734 | { |
1735 | return m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_GLOBALPTR].VirtualAddress; | 1735 | return m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_GLOBALPTR].VirtualAddress; |
1736 | } | 1736 | } |
1737 | 1737 | ||
1738 | /** | 1738 | /** |
1739 | * Returns the size of the current file's global ptr directory. | 1739 | * Returns the size of the current file's global ptr directory. |
1740 | * @return The size of the GlobalPtr directory. | 1740 | * @return The size of the GlobalPtr directory. |
1741 | **/ | 1741 | **/ |
1742 | template<int x> | 1742 | template<int x> |
1743 | dword PeHeaderT<x>::getIddGlobalPtrSize() const | 1743 | dword PeHeaderT<x>::getIddGlobalPtrSize() const |
1744 | { | 1744 | { |
1745 | return m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_GLOBALPTR].Size; | 1745 | return m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_GLOBALPTR].Size; |
1746 | } | 1746 | } |
1747 | 1747 | ||
1748 | /** | 1748 | /** |
1749 | * Returns the relative virtual address of the current file's TLS directory. | 1749 | * Returns the relative virtual address of the current file's TLS directory. |
1750 | * @return The Rva of the Tls directory. | 1750 | * @return The Rva of the Tls directory. |
1751 | **/ | 1751 | **/ |
1752 | template<int x> | 1752 | template<int x> |
1753 | dword PeHeaderT<x>::getIddTlsRva() const | 1753 | dword PeHeaderT<x>::getIddTlsRva() const |
1754 | { | 1754 | { |
1755 | return m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_TLS].VirtualAddress; | 1755 | return m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_TLS].VirtualAddress; |
1756 | } | 1756 | } |
1757 | 1757 | ||
1758 | /** | 1758 | /** |
1759 | * Returns the size of the current file's TLS directory. | 1759 | * Returns the size of the current file's TLS directory. |
1760 | * @return The size of the Tls directory. | 1760 | * @return The size of the Tls directory. |
1761 | **/ | 1761 | **/ |
1762 | template<int x> | 1762 | template<int x> |
1763 | dword PeHeaderT<x>::getIddTlsSize() const | 1763 | dword PeHeaderT<x>::getIddTlsSize() const |
1764 | { | 1764 | { |
1765 | return m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_TLS].Size; | 1765 | return m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_TLS].Size; |
1766 | } | 1766 | } |
1767 | 1767 | ||
1768 | /** | 1768 | /** |
1769 | * Returns the relative virtual address of the current file's load config directory. | 1769 | * Returns the relative virtual address of the current file's load config directory. |
1770 | * @return The Rva of the LoadConfig directory. | 1770 | * @return The Rva of the LoadConfig directory. |
1771 | **/ | 1771 | **/ |
1772 | template<int x> | 1772 | template<int x> |
1773 | dword PeHeaderT<x>::getIddLoadConfigRva() const | 1773 | dword PeHeaderT<x>::getIddLoadConfigRva() const |
1774 | { | 1774 | { |
1775 | return m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG].VirtualAddress; | 1775 | return m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG].VirtualAddress; |
1776 | } | 1776 | } |
1777 | 1777 | ||
1778 | /** | 1778 | /** |
1779 | * Returns the size of the current file's load config directory. | 1779 | * Returns the size of the current file's load config directory. |
1780 | * @return The size of the LoadConfig directory. | 1780 | * @return The size of the LoadConfig directory. |
1781 | **/ | 1781 | **/ |
1782 | template<int x> | 1782 | template<int x> |
1783 | dword PeHeaderT<x>::getIddLoadConfigSize() const | 1783 | dword PeHeaderT<x>::getIddLoadConfigSize() const |
1784 | { | 1784 | { |
1785 | return m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG].Size; | 1785 | return m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG].Size; |
1786 | } | 1786 | } |
1787 | 1787 | ||
1788 | /** | 1788 | /** |
1789 | * Returns the relative virtual address of the current file's bound import directory. | 1789 | * Returns the relative virtual address of the current file's bound import directory. |
1790 | * @return The Rva of the BoundImport directory. | 1790 | * @return The Rva of the BoundImport directory. |
1791 | **/ | 1791 | **/ |
1792 | template<int x> | 1792 | template<int x> |
1793 | dword PeHeaderT<x>::getIddBoundImportRva() const | 1793 | dword PeHeaderT<x>::getIddBoundImportRva() const |
1794 | { | 1794 | { |
1795 | return m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT].VirtualAddress; | 1795 | return m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT].VirtualAddress; |
1796 | } | 1796 | } |
1797 | 1797 | ||
1798 | /** | 1798 | /** |
1799 | * Returns the size of the current file's bound import directory. | 1799 | * Returns the size of the current file's bound import directory. |
1800 | * @return The size of the BoundImport directory. | 1800 | * @return The size of the BoundImport directory. |
1801 | **/ | 1801 | **/ |
1802 | template<int x> | 1802 | template<int x> |
1803 | dword PeHeaderT<x>::getIddBoundImportSize() const | 1803 | dword PeHeaderT<x>::getIddBoundImportSize() const |
1804 | { | 1804 | { |
1805 | return m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT].Size; | 1805 | return m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT].Size; |
1806 | } | 1806 | } |
1807 | 1807 | ||
1808 | /** | 1808 | /** |
1809 | * Returns the relative virtual address of the current file's IAT directory. | 1809 | * Returns the relative virtual address of the current file's IAT directory. |
1810 | * @return The Rva of the IAT directory. | 1810 | * @return The Rva of the IAT directory. |
1811 | **/ | 1811 | **/ |
1812 | template<int x> | 1812 | template<int x> |
1813 | dword PeHeaderT<x>::getIddIatRva() const | 1813 | dword PeHeaderT<x>::getIddIatRva() const |
1814 | { | 1814 | { |
1815 | return m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_IAT].VirtualAddress; | 1815 | return m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_IAT].VirtualAddress; |
1816 | } | 1816 | } |
1817 | 1817 | ||
1818 | /** | 1818 | /** |
1819 | * Returns the size of the current file's IAT directory. | 1819 | * Returns the size of the current file's IAT directory. |
1820 | * @return The size of the IAT directory. | 1820 | * @return The size of the IAT directory. |
1821 | **/ | 1821 | **/ |
1822 | template<int x> | 1822 | template<int x> |
1823 | dword PeHeaderT<x>::getIddIatSize() const | 1823 | dword PeHeaderT<x>::getIddIatSize() const |
1824 | { | 1824 | { |
1825 | return m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_IAT].Size; | 1825 | return m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_IAT].Size; |
1826 | } | 1826 | } |
1827 | 1827 | ||
1828 | /** | 1828 | /** |
1829 | * Returns the relative virtual address of the current file's Delay Import directory. | 1829 | * Returns the relative virtual address of the current file's Delay Import directory. |
1830 | * @return The Rva of the DelayImport directory. | 1830 | * @return The Rva of the DelayImport directory. |
1831 | **/ | 1831 | **/ |
1832 | template<int x> | 1832 | template<int x> |
1833 | dword PeHeaderT<x>::getIddDelayImportRva() const | 1833 | dword PeHeaderT<x>::getIddDelayImportRva() const |
1834 | { | 1834 | { |
1835 | return m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT].VirtualAddress; | 1835 | return m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT].VirtualAddress; |
1836 | } | 1836 | } |
1837 | 1837 | ||
1838 | /** | 1838 | /** |
1839 | * Returns the size of the current file's Delay Import directory. | 1839 | * Returns the size of the current file's Delay Import directory. |
1840 | * @return The size of the DelayImport directory. | 1840 | * @return The size of the DelayImport directory. |
1841 | **/ | 1841 | **/ |
1842 | template<int x> | 1842 | template<int x> |
1843 | dword PeHeaderT<x>::getIddDelayImportSize() const | 1843 | dword PeHeaderT<x>::getIddDelayImportSize() const |
1844 | { | 1844 | { |
1845 | return m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT].Size; | 1845 | return m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT].Size; |
1846 | } | 1846 | } |
1847 | 1847 | ||
1848 | /** | 1848 | /** |
1849 | * Returns the relative virtual address of the current file's COM Descriptor directory. | 1849 | * Returns the relative virtual address of the current file's COM Descriptor directory. |
1850 | * @return The Rva of the COM Descriptor directory. | 1850 | * @return The Rva of the COM Descriptor directory. |
1851 | **/ | 1851 | **/ |
1852 | template<int x> | 1852 | template<int x> |
1853 | dword PeHeaderT<x>::getIddComHeaderRva() const | 1853 | dword PeHeaderT<x>::getIddComHeaderRva() const |
1854 | { | 1854 | { |
1855 | return m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR].VirtualAddress; | 1855 | return m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR].VirtualAddress; |
1856 | } | 1856 | } |
1857 | 1857 | ||
1858 | /** | 1858 | /** |
1859 | * Returns the size of the current file's COM Descriptor directory. | 1859 | * Returns the size of the current file's COM Descriptor directory. |
1860 | * @return The Rva of the COM Descriptor directory. | 1860 | * @return The Rva of the COM Descriptor directory. |
1861 | **/ | 1861 | **/ |
1862 | template<int x> | 1862 | template<int x> |
1863 | dword PeHeaderT<x>::getIddComHeaderSize() const | 1863 | dword PeHeaderT<x>::getIddComHeaderSize() const |
1864 | { | 1864 | { |
1865 | return m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR].Size; | 1865 | return m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR].Size; |
1866 | } | 1866 | } |
1867 | 1867 | ||
1868 | /** | 1868 | /** |
1869 | * Returns the relative virtual address of an image directory. | 1869 | * Returns the relative virtual address of an image directory. |
1870 | * @param dwDirectory The identifier of an image directory. | 1870 | * @param dwDirectory The identifier of an image directory. |
1871 | * @return The Rva of the image directory. | 1871 | * @return The Rva of the image directory. |
1872 | **/ | 1872 | **/ |
1873 | template<int x> | 1873 | template<int x> |
1874 | dword PeHeaderT<x>::getImageDataDirectoryRva(dword dwDirectory) const | 1874 | dword PeHeaderT<x>::getImageDataDirectoryRva(dword dwDirectory) const |
1875 | { | 1875 | { |
1876 | return m_inthHeader.dataDirectories[dwDirectory].VirtualAddress; | 1876 | return m_inthHeader.dataDirectories[dwDirectory].VirtualAddress; |
1877 | } | 1877 | } |
1878 | 1878 | ||
1879 | template<int x> | 1879 | template<int x> |
1880 | void PeHeaderT<x>::setImageDataDirectoryRva(dword dwDirectory, dword value) | 1880 | void PeHeaderT<x>::setImageDataDirectoryRva(dword dwDirectory, dword value) |
1881 | { | 1881 | { |
1882 | m_inthHeader.dataDirectories[dwDirectory].VirtualAddress = value; | 1882 | m_inthHeader.dataDirectories[dwDirectory].VirtualAddress = value; |
1883 | } | 1883 | } |
1884 | 1884 | ||
1885 | /** | 1885 | /** |
1886 | * Returns the size of an image directory. | 1886 | * Returns the size of an image directory. |
1887 | * @param dwDirectory The identifier of an image directory. | 1887 | * @param dwDirectory The identifier of an image directory. |
1888 | * @return The size of the image directory. | 1888 | * @return The size of the image directory. |
1889 | **/ | 1889 | **/ |
1890 | template<int x> | 1890 | template<int x> |
1891 | dword PeHeaderT<x>::getImageDataDirectorySize(dword dwDirectory) const | 1891 | dword PeHeaderT<x>::getImageDataDirectorySize(dword dwDirectory) const |
1892 | { | 1892 | { |
1893 | return m_inthHeader.dataDirectories[dwDirectory].Size; | 1893 | return m_inthHeader.dataDirectories[dwDirectory].Size; |
1894 | } | 1894 | } |
1895 | 1895 | ||
1896 | template<int x> | 1896 | template<int x> |
1897 | void PeHeaderT<x>::setImageDataDirectorySize(dword dwDirectory, dword value) | 1897 | void PeHeaderT<x>::setImageDataDirectorySize(dword dwDirectory, dword value) |
1898 | { | 1898 | { |
1899 | m_inthHeader.dataDirectories[dwDirectory].Size = value; | 1899 | m_inthHeader.dataDirectories[dwDirectory].Size = value; |
1900 | } | 1900 | } |
1901 | 1901 | ||
1902 | /** | 1902 | /** |
1903 | * Returns the name of the section which is specified by the parameter wSectionnr. | 1903 | * Returns the name of the section which is specified by the parameter wSectionnr. |
1904 | * @param wSectionnr Index of the section. | 1904 | * @param wSectionnr Index of the section. |
1905 | * @return The name of the section. | 1905 | * @return The name of the section. |
1906 | **/ | 1906 | **/ |
1907 | template<int x> | 1907 | template<int x> |
1908 | std::string PeHeaderT<x>::getSectionName(word wSectionnr) const | 1908 | std::string PeHeaderT<x>::getSectionName(word wSectionnr) const |
1909 | { | 1909 | { |
1910 | std::string sectionName = ""; | 1910 | std::string sectionName = ""; |
1911 | 1911 | ||
1912 | for (unsigned int i=0;i<sizeof(m_vIsh[wSectionnr].Name);i++) | 1912 | for (unsigned int i=0;i<sizeof(m_vIsh[wSectionnr].Name);i++) |
1913 | { | 1913 | { |
1914 | if (m_vIsh[wSectionnr].Name[i]) sectionName += m_vIsh[wSectionnr].Name[i]; | 1914 | if (m_vIsh[wSectionnr].Name[i]) sectionName += m_vIsh[wSectionnr].Name[i]; |
1915 | } | 1915 | } |
1916 | 1916 | ||
1917 | return sectionName; | 1917 | return sectionName; |
1918 | } | 1918 | } |
1919 | 1919 | ||
1920 | /** | 1920 | /** |
1921 | * Returns the virtual size of the section which is specified by the parameter wSectionnr. | 1921 | * Returns the virtual size of the section which is specified by the parameter wSectionnr. |
1922 | * @param wSectionnr Index of the section. | 1922 | * @param wSectionnr Index of the section. |
1923 | * @return The virtual size of the section. | 1923 | * @return The virtual size of the section. |
1924 | **/ | 1924 | **/ |
1925 | template<int x> | 1925 | template<int x> |
1926 | dword PeHeaderT<x>::getVirtualSize(word wSectionnr) const | 1926 | dword PeHeaderT<x>::getVirtualSize(word wSectionnr) const |
1927 | { | 1927 | { |
1928 | return m_vIsh[wSectionnr].VirtualSize; | 1928 | return m_vIsh[wSectionnr].VirtualSize; |
1929 | } | 1929 | } |
1930 | 1930 | ||
1931 | /** | 1931 | /** |
1932 | * Returns the relative virtual address of the section which is specified by the parameter wSectionnr. | 1932 | * Returns the relative virtual address of the section which is specified by the parameter wSectionnr. |
1933 | * @param wSectionnr Index of the section. | 1933 | * @param wSectionnr Index of the section. |
1934 | * @return The Rva of the section. | 1934 | * @return The Rva of the section. |
1935 | **/ | 1935 | **/ |
1936 | template<int x> | 1936 | template<int x> |
1937 | dword PeHeaderT<x>::getVirtualAddress(word wSectionnr) const | 1937 | dword PeHeaderT<x>::getVirtualAddress(word wSectionnr) const |
1938 | { | 1938 | { |
1939 | return m_vIsh[wSectionnr].VirtualAddress; | 1939 | return m_vIsh[wSectionnr].VirtualAddress; |
1940 | } | 1940 | } |
1941 | 1941 | ||
1942 | /** | 1942 | /** |
1943 | * Returns the size of raw data of the section which is specified by the parameter wSectionnr. | 1943 | * Returns the size of raw data of the section which is specified by the parameter wSectionnr. |
1944 | * @param wSectionnr Index of the section. | 1944 | * @param wSectionnr Index of the section. |
1945 | * @return The size of raw data of the section. | 1945 | * @return The size of raw data of the section. |
1946 | **/ | 1946 | **/ |
1947 | template<int x> | 1947 | template<int x> |
1948 | dword PeHeaderT<x>::getSizeOfRawData(word wSectionnr) const | 1948 | dword PeHeaderT<x>::getSizeOfRawData(word wSectionnr) const |
1949 | { | 1949 | { |
1950 | return m_vIsh[wSectionnr].SizeOfRawData; | 1950 | return m_vIsh[wSectionnr].SizeOfRawData; |
1951 | } | 1951 | } |
1952 | 1952 | ||
1953 | /** | 1953 | /** |
1954 | * Returns the file offset of the section which is specified by the parameter wSectionnr. | 1954 | * Returns the file offset of the section which is specified by the parameter wSectionnr. |
1955 | * @param wSectionnr Index of the section. | 1955 | * @param wSectionnr Index of the section. |
1956 | * @return The file offset of the section. | 1956 | * @return The file offset of the section. |
1957 | **/ | 1957 | **/ |
1958 | template<int x> | 1958 | template<int x> |
1959 | dword PeHeaderT<x>::getPointerToRawData(word wSectionnr) const | 1959 | dword PeHeaderT<x>::getPointerToRawData(word wSectionnr) const |
1960 | { | 1960 | { |
1961 | return m_vIsh[wSectionnr].PointerToRawData; | 1961 | return m_vIsh[wSectionnr].PointerToRawData; |
1962 | } | 1962 | } |
1963 | 1963 | ||
1964 | /** | 1964 | /** |
1965 | * Returns the pointer to relocations of the section which is specified by the parameter wSectionnr. | 1965 | * Returns the pointer to relocations of the section which is specified by the parameter wSectionnr. |
1966 | * @param wSectionnr Index of the section. | 1966 | * @param wSectionnr Index of the section. |
1967 | * @return The pointer to relocations of the section. | 1967 | * @return The pointer to relocations of the section. |
1968 | **/ | 1968 | **/ |
1969 | template<int x> | 1969 | template<int x> |
1970 | dword PeHeaderT<x>::getPointerToRelocations(word wSectionnr) const | 1970 | dword PeHeaderT<x>::getPointerToRelocations(word wSectionnr) const |
1971 | { | 1971 | { |
1972 | return m_vIsh[wSectionnr].PointerToRelocations; | 1972 | return m_vIsh[wSectionnr].PointerToRelocations; |
1973 | } | 1973 | } |
1974 | 1974 | ||
1975 | /** | 1975 | /** |
1976 | * Returns the poiner to line numbers of the section which is specified by the parameter wSectionnr. | 1976 | * Returns the poiner to line numbers of the section which is specified by the parameter wSectionnr. |
1977 | * @param wSectionnr Index of the section. | 1977 | * @param wSectionnr Index of the section. |
1978 | * @return The pointer to line numbers of the section. | 1978 | * @return The pointer to line numbers of the section. |
1979 | **/ | 1979 | **/ |
1980 | template<int x> | 1980 | template<int x> |
1981 | dword PeHeaderT<x>::getPointerToLinenumbers(word wSectionnr) const | 1981 | dword PeHeaderT<x>::getPointerToLinenumbers(word wSectionnr) const |
1982 | { | 1982 | { |
1983 | return m_vIsh[wSectionnr].PointerToLinenumbers; | 1983 | return m_vIsh[wSectionnr].PointerToLinenumbers; |
1984 | } | 1984 | } |
1985 | 1985 | ||
1986 | /** | 1986 | /** |
1987 | * Returns the number of relocations of the section which is specified by the parameter wSectionnr. | 1987 | * Returns the number of relocations of the section which is specified by the parameter wSectionnr. |
1988 | * @param wSectionnr Index of the section. | 1988 | * @param wSectionnr Index of the section. |
1989 | * @return The number of relocations of the section. | 1989 | * @return The number of relocations of the section. |
1990 | **/ | 1990 | **/ |
1991 | template<int x> | 1991 | template<int x> |
1992 | dword PeHeaderT<x>::getNumberOfRelocations(word wSectionnr) const | 1992 | dword PeHeaderT<x>::getNumberOfRelocations(word wSectionnr) const |
1993 | { | 1993 | { |
1994 | return m_vIsh[wSectionnr].NumberOfRelocations; | 1994 | return m_vIsh[wSectionnr].NumberOfRelocations; |
1995 | } | 1995 | } |
1996 | 1996 | ||
1997 | /** | 1997 | /** |
1998 | * Returns the number of line numbers of the section which is specified by the parameter wSectionnr. | 1998 | * Returns the number of line numbers of the section which is specified by the parameter wSectionnr. |
1999 | * @param wSectionnr Index of the section. | 1999 | * @param wSectionnr Index of the section. |
2000 | * @return The number of line numbers of the section. | 2000 | * @return The number of line numbers of the section. |
2001 | **/ | 2001 | **/ |
2002 | template<int x> | 2002 | template<int x> |
2003 | dword PeHeaderT<x>::getNumberOfLinenumbers(word wSectionnr) const | 2003 | dword PeHeaderT<x>::getNumberOfLinenumbers(word wSectionnr) const |
2004 | { | 2004 | { |
2005 | return m_vIsh[wSectionnr].NumberOfLinenumbers; | 2005 | return m_vIsh[wSectionnr].NumberOfLinenumbers; |
2006 | } | 2006 | } |
2007 | 2007 | ||
2008 | /** | 2008 | /** |
2009 | * Returns the characteristics of the section which is specified by the parameter wSectionnr. | 2009 | * Returns the characteristics of the section which is specified by the parameter wSectionnr. |
2010 | * @param wSectionnr Index of the section. | 2010 | * @param wSectionnr Index of the section. |
2011 | * @return The characteristics of the section. | 2011 | * @return The characteristics of the section. |
2012 | **/ | 2012 | **/ |
2013 | template<int x> | 2013 | template<int x> |
2014 | dword PeHeaderT<x>::getCharacteristics(word wSectionnr) const | 2014 | dword PeHeaderT<x>::getCharacteristics(word wSectionnr) const |
2015 | { | 2015 | { |
2016 | return m_vIsh[wSectionnr].Characteristics; | 2016 | return m_vIsh[wSectionnr].Characteristics; |
2017 | } | 2017 | } |
2018 | 2018 | ||
2019 | /** | 2019 | /** |
2020 | * Changes the file's Nt signature. | 2020 | * Changes the file's Nt signature. |
2021 | * @param dwValue New value. | 2021 | * @param dwValue New value. |
2022 | **/ | 2022 | **/ |
2023 | template<int x> | 2023 | template<int x> |
2024 | void PeHeaderT<x>::setNtSignature(dword dwValue) | 2024 | void PeHeaderT<x>::setNtSignature(dword dwValue) |
2025 | { | 2025 | { |
2026 | m_inthHeader.Signature = dwValue; | 2026 | m_inthHeader.Signature = dwValue; |
2027 | } | 2027 | } |
2028 | 2028 | ||
2029 | /** | 2029 | /** |
2030 | * Changes the file's Machine. | 2030 | * Changes the file's Machine. |
2031 | * @param wValue New value. | 2031 | * @param wValue New value. |
2032 | **/ | 2032 | **/ |
2033 | template<int x> | 2033 | template<int x> |
2034 | void PeHeaderT<x>::setMachine(word wValue) | 2034 | void PeHeaderT<x>::setMachine(word wValue) |
2035 | { | 2035 | { |
2036 | m_inthHeader.FileHeader.Machine = wValue; | 2036 | m_inthHeader.FileHeader.Machine = wValue; |
2037 | } | 2037 | } |
2038 | 2038 | ||
2039 | /** | 2039 | /** |
2040 | * Changes the number of sections. | 2040 | * Changes the number of sections. |
2041 | * @param wValue New value. | 2041 | * @param wValue New value. |
2042 | **/ | 2042 | **/ |
2043 | template<int x> | 2043 | template<int x> |
2044 | void PeHeaderT<x>::setNumberOfSections(word wValue) | 2044 | void PeHeaderT<x>::setNumberOfSections(word wValue) |
2045 | { | 2045 | { |
2046 | m_inthHeader.FileHeader.NumberOfSections = wValue; | 2046 | m_inthHeader.FileHeader.NumberOfSections = wValue; |
2047 | } | 2047 | } |
2048 | 2048 | ||
2049 | /** | 2049 | /** |
2050 | * Changes the file's TimeDateStamp. | 2050 | * Changes the file's TimeDateStamp. |
2051 | * @param dwValue New value. | 2051 | * @param dwValue New value. |
2052 | **/ | 2052 | **/ |
2053 | template<int x> | 2053 | template<int x> |
2054 | void PeHeaderT<x>::setTimeDateStamp(dword dwValue) | 2054 | void PeHeaderT<x>::setTimeDateStamp(dword dwValue) |
2055 | { | 2055 | { |
2056 | m_inthHeader.FileHeader.TimeDateStamp = dwValue; | 2056 | m_inthHeader.FileHeader.TimeDateStamp = dwValue; |
2057 | } | 2057 | } |
2058 | 2058 | ||
2059 | /** | 2059 | /** |
2060 | * Changes the file's PointerToSymbolTable. | 2060 | * Changes the file's PointerToSymbolTable. |
2061 | * @param dwValue New value. | 2061 | * @param dwValue New value. |
2062 | **/ | 2062 | **/ |
2063 | template<int x> | 2063 | template<int x> |
2064 | void PeHeaderT<x>::setPointerToSymbolTable(dword dwValue) | 2064 | void PeHeaderT<x>::setPointerToSymbolTable(dword dwValue) |
2065 | { | 2065 | { |
2066 | m_inthHeader.FileHeader.PointerToSymbolTable = dwValue; | 2066 | m_inthHeader.FileHeader.PointerToSymbolTable = dwValue; |
2067 | } | 2067 | } |
2068 | 2068 | ||
2069 | /** | 2069 | /** |
2070 | * Changes the file's NumberOfSymbols. | 2070 | * Changes the file's NumberOfSymbols. |
2071 | * @param dwValue New value. | 2071 | * @param dwValue New value. |
2072 | **/ | 2072 | **/ |
2073 | template<int x> | 2073 | template<int x> |
2074 | void PeHeaderT<x>::setNumberOfSymbols(dword dwValue) | 2074 | void PeHeaderT<x>::setNumberOfSymbols(dword dwValue) |
2075 | { | 2075 | { |
2076 | m_inthHeader.FileHeader.NumberOfSymbols = dwValue; | 2076 | m_inthHeader.FileHeader.NumberOfSymbols = dwValue; |
2077 | } | 2077 | } |
2078 | 2078 | ||
2079 | /** | 2079 | /** |
2080 | * Changes the file's SizeOfOptionalHeader. | 2080 | * Changes the file's SizeOfOptionalHeader. |
2081 | * @param wValue New value. | 2081 | * @param wValue New value. |
2082 | **/ | 2082 | **/ |
2083 | template<int x> | 2083 | template<int x> |
2084 | void PeHeaderT<x>::setSizeOfOptionalHeader(word wValue) | 2084 | void PeHeaderT<x>::setSizeOfOptionalHeader(word wValue) |
2085 | { | 2085 | { |
2086 | m_inthHeader.FileHeader.SizeOfOptionalHeader = wValue; | 2086 | m_inthHeader.FileHeader.SizeOfOptionalHeader = wValue; |
2087 | } | 2087 | } |
2088 | 2088 | ||
2089 | /** | 2089 | /** |
2090 | * Changes the file's Characteristics. | 2090 | * Changes the file's Characteristics. |
2091 | * @param wValue New value. | 2091 | * @param wValue New value. |
2092 | **/ | 2092 | **/ |
2093 | template<int x> | 2093 | template<int x> |
2094 | void PeHeaderT<x>::setCharacteristics(word wValue) | 2094 | void PeHeaderT<x>::setCharacteristics(word wValue) |
2095 | { | 2095 | { |
2096 | m_inthHeader.FileHeader.Characteristics = wValue; | 2096 | m_inthHeader.FileHeader.Characteristics = wValue; |
2097 | } | 2097 | } |
2098 | 2098 | ||
2099 | /** | 2099 | /** |
2100 | * Changes the file's Magic. | 2100 | * Changes the file's Magic. |
2101 | * @param wValue New value. | 2101 | * @param wValue New value. |
2102 | **/ | 2102 | **/ |
2103 | template<int x> | 2103 | template<int x> |
2104 | void PeHeaderT<x>::setMagic(word wValue) | 2104 | void PeHeaderT<x>::setMagic(word wValue) |
2105 | { | 2105 | { |
2106 | m_inthHeader.OptionalHeader.Magic = wValue; | 2106 | m_inthHeader.OptionalHeader.Magic = wValue; |
2107 | } | 2107 | } |
2108 | 2108 | ||
2109 | /** | 2109 | /** |
2110 | * Changes the file's MajorLinkerVersion. | 2110 | * Changes the file's MajorLinkerVersion. |
2111 | * @param bValue New value. | 2111 | * @param bValue New value. |
2112 | **/ | 2112 | **/ |
2113 | template<int x> | 2113 | template<int x> |
2114 | void PeHeaderT<x>::setMajorLinkerVersion(byte bValue) | 2114 | void PeHeaderT<x>::setMajorLinkerVersion(byte bValue) |
2115 | { | 2115 | { |
2116 | m_inthHeader.OptionalHeader.MajorLinkerVersion = bValue; | 2116 | m_inthHeader.OptionalHeader.MajorLinkerVersion = bValue; |
2117 | } | 2117 | } |
2118 | 2118 | ||
2119 | /** | 2119 | /** |
2120 | * Changes the file's MinorLinkerVersion. | 2120 | * Changes the file's MinorLinkerVersion. |
2121 | * @param bValue New value. | 2121 | * @param bValue New value. |
2122 | **/ | 2122 | **/ |
2123 | template<int x> | 2123 | template<int x> |
2124 | void PeHeaderT<x>::setMinorLinkerVersion(byte bValue) | 2124 | void PeHeaderT<x>::setMinorLinkerVersion(byte bValue) |
2125 | { | 2125 | { |
2126 | m_inthHeader.OptionalHeader.MinorLinkerVersion = bValue; | 2126 | m_inthHeader.OptionalHeader.MinorLinkerVersion = bValue; |
2127 | } | 2127 | } |
2128 | 2128 | ||
2129 | /** | 2129 | /** |
2130 | * Changes the file's SizeOfCode. | 2130 | * Changes the file's SizeOfCode. |
2131 | * @param dwValue New value. | 2131 | * @param dwValue New value. |
2132 | **/ | 2132 | **/ |
2133 | template<int x> | 2133 | template<int x> |
2134 | void PeHeaderT<x>::setSizeOfCode(dword dwValue) | 2134 | void PeHeaderT<x>::setSizeOfCode(dword dwValue) |
2135 | { | 2135 | { |
2136 | m_inthHeader.OptionalHeader.SizeOfCode = dwValue; | 2136 | m_inthHeader.OptionalHeader.SizeOfCode = dwValue; |
2137 | } | 2137 | } |
2138 | 2138 | ||
2139 | /** | 2139 | /** |
2140 | * Changes the file's SizeOfInitializedData. | 2140 | * Changes the file's SizeOfInitializedData. |
2141 | * @param dwValue New value. | 2141 | * @param dwValue New value. |
2142 | **/ | 2142 | **/ |
2143 | template<int x> | 2143 | template<int x> |
2144 | void PeHeaderT<x>::setSizeOfInitializedData(dword dwValue) | 2144 | void PeHeaderT<x>::setSizeOfInitializedData(dword dwValue) |
2145 | { | 2145 | { |
2146 | m_inthHeader.OptionalHeader.SizeOfInitializedData = dwValue; | 2146 | m_inthHeader.OptionalHeader.SizeOfInitializedData = dwValue; |
2147 | } | 2147 | } |
2148 | 2148 | ||
2149 | /** | 2149 | /** |
2150 | * Changes the file's SizeOfUninitializedData. | 2150 | * Changes the file's SizeOfUninitializedData. |
2151 | * @param dwValue New value. | 2151 | * @param dwValue New value. |
2152 | **/ | 2152 | **/ |
2153 | template<int x> | 2153 | template<int x> |
2154 | void PeHeaderT<x>::setSizeOfUninitializedData(dword dwValue) | 2154 | void PeHeaderT<x>::setSizeOfUninitializedData(dword dwValue) |
2155 | { | 2155 | { |
2156 | m_inthHeader.OptionalHeader.SizeOfUninitializedData = dwValue; | 2156 | m_inthHeader.OptionalHeader.SizeOfUninitializedData = dwValue; |
2157 | } | 2157 | } |
2158 | 2158 | ||
2159 | /** | 2159 | /** |
2160 | * Changes the file's AddressOfEntryPoint. | 2160 | * Changes the file's AddressOfEntryPoint. |
2161 | * @param dwValue New value. | 2161 | * @param dwValue New value. |
2162 | **/ | 2162 | **/ |
2163 | template<int x> | 2163 | template<int x> |
2164 | void PeHeaderT<x>::setAddressOfEntryPoint(dword dwValue) | 2164 | void PeHeaderT<x>::setAddressOfEntryPoint(dword dwValue) |
2165 | { | 2165 | { |
2166 | m_inthHeader.OptionalHeader.AddressOfEntryPoint = dwValue; | 2166 | m_inthHeader.OptionalHeader.AddressOfEntryPoint = dwValue; |
2167 | } | 2167 | } |
2168 | 2168 | ||
2169 | /** | 2169 | /** |
2170 | * Changes the file's BaseOfCode. | 2170 | * Changes the file's BaseOfCode. |
2171 | * @param dwValue New value. | 2171 | * @param dwValue New value. |
2172 | **/ | 2172 | **/ |
2173 | template<int x> | 2173 | template<int x> |
2174 | void PeHeaderT<x>::setBaseOfCode(dword dwValue) | 2174 | void PeHeaderT<x>::setBaseOfCode(dword dwValue) |
2175 | { | 2175 | { |
2176 | m_inthHeader.OptionalHeader.BaseOfCode = dwValue; | 2176 | m_inthHeader.OptionalHeader.BaseOfCode = dwValue; |
2177 | } | 2177 | } |
2178 | 2178 | ||
2179 | /** | 2179 | /** |
2180 | * Changes the file's ImageBase. | 2180 | * Changes the file's ImageBase. |
2181 | * @param dwValue New value. | 2181 | * @param dwValue New value. |
2182 | **/ | 2182 | **/ |
2183 | template<int x> | 2183 | template<int x> |
2184 | void PeHeaderT<x>::setImageBase(typename FieldSizes<x>::VAR4_8 dwValue) | 2184 | void PeHeaderT<x>::setImageBase(typename FieldSizes<x>::VAR4_8 dwValue) |
2185 | { | 2185 | { |
2186 | m_inthHeader.OptionalHeader.ImageBase = dwValue; | 2186 | m_inthHeader.OptionalHeader.ImageBase = dwValue; |
2187 | } | 2187 | } |
2188 | 2188 | ||
2189 | /** | 2189 | /** |
2190 | * Changes the file's SectionAlignment. | 2190 | * Changes the file's SectionAlignment. |
2191 | * @param dwValue New value. | 2191 | * @param dwValue New value. |
2192 | **/ | 2192 | **/ |
2193 | template<int x> | 2193 | template<int x> |
2194 | void PeHeaderT<x>::setSectionAlignment(dword dwValue) | 2194 | void PeHeaderT<x>::setSectionAlignment(dword dwValue) |
2195 | { | 2195 | { |
2196 | m_inthHeader.OptionalHeader.SectionAlignment = dwValue; | 2196 | m_inthHeader.OptionalHeader.SectionAlignment = dwValue; |
2197 | } | 2197 | } |
2198 | 2198 | ||
2199 | /** | 2199 | /** |
2200 | * Changes the file's FileAlignment. | 2200 | * Changes the file's FileAlignment. |
2201 | * @param dwValue New value. | 2201 | * @param dwValue New value. |
2202 | **/ | 2202 | **/ |
2203 | template<int x> | 2203 | template<int x> |
2204 | void PeHeaderT<x>::setFileAlignment(dword dwValue) | 2204 | void PeHeaderT<x>::setFileAlignment(dword dwValue) |
2205 | { | 2205 | { |
2206 | m_inthHeader.OptionalHeader.FileAlignment = dwValue; | 2206 | m_inthHeader.OptionalHeader.FileAlignment = dwValue; |
2207 | } | 2207 | } |
2208 | 2208 | ||
2209 | /** | 2209 | /** |
2210 | * Changes the file's MajorOperatingSystemVersion. | 2210 | * Changes the file's MajorOperatingSystemVersion. |
2211 | * @param wValue New value. | 2211 | * @param wValue New value. |
2212 | **/ | 2212 | **/ |
2213 | template<int x> | 2213 | template<int x> |
2214 | void PeHeaderT<x>::setMajorOperatingSystemVersion(word wValue) | 2214 | void PeHeaderT<x>::setMajorOperatingSystemVersion(word wValue) |
2215 | { | 2215 | { |
2216 | m_inthHeader.OptionalHeader.MajorOperatingSystemVersion = wValue; | 2216 | m_inthHeader.OptionalHeader.MajorOperatingSystemVersion = wValue; |
2217 | } | 2217 | } |
2218 | 2218 | ||
2219 | /** | 2219 | /** |
2220 | * Changes the file's MinorOperatingSystemVersion. | 2220 | * Changes the file's MinorOperatingSystemVersion. |
2221 | * @param wValue New value. | 2221 | * @param wValue New value. |
2222 | **/ | 2222 | **/ |
2223 | template<int x> | 2223 | template<int x> |
2224 | void PeHeaderT<x>::setMinorOperatingSystemVersion(word wValue) | 2224 | void PeHeaderT<x>::setMinorOperatingSystemVersion(word wValue) |
2225 | { | 2225 | { |
2226 | m_inthHeader.OptionalHeader.MinorOperatingSystemVersion = wValue; | 2226 | m_inthHeader.OptionalHeader.MinorOperatingSystemVersion = wValue; |
2227 | } | 2227 | } |
2228 | 2228 | ||
2229 | /** | 2229 | /** |
2230 | * Changes the file's MajorImageVersion. | 2230 | * Changes the file's MajorImageVersion. |
2231 | * @param wValue New value. | 2231 | * @param wValue New value. |
2232 | **/ | 2232 | **/ |
2233 | template<int x> | 2233 | template<int x> |
2234 | void PeHeaderT<x>::setMajorImageVersion(word wValue) | 2234 | void PeHeaderT<x>::setMajorImageVersion(word wValue) |
2235 | { | 2235 | { |
2236 | m_inthHeader.OptionalHeader.MajorImageVersion = wValue; | 2236 | m_inthHeader.OptionalHeader.MajorImageVersion = wValue; |
2237 | } | 2237 | } |
2238 | 2238 | ||
2239 | /** | 2239 | /** |
2240 | * Changes the file's MinorImageVersion. | 2240 | * Changes the file's MinorImageVersion. |
2241 | * @param wValue New value. | 2241 | * @param wValue New value. |
2242 | **/ | 2242 | **/ |
2243 | template<int x> | 2243 | template<int x> |
2244 | void PeHeaderT<x>::setMinorImageVersion(word wValue) | 2244 | void PeHeaderT<x>::setMinorImageVersion(word wValue) |
2245 | { | 2245 | { |
2246 | m_inthHeader.OptionalHeader.MinorImageVersion = wValue; | 2246 | m_inthHeader.OptionalHeader.MinorImageVersion = wValue; |
2247 | } | 2247 | } |
2248 | 2248 | ||
2249 | /** | 2249 | /** |
2250 | * Changes the file's MajorSubsystemVersion. | 2250 | * Changes the file's MajorSubsystemVersion. |
2251 | * @param wValue New value. | 2251 | * @param wValue New value. |
2252 | **/ | 2252 | **/ |
2253 | template<int x> | 2253 | template<int x> |
2254 | void PeHeaderT<x>::setMajorSubsystemVersion(word wValue) | 2254 | void PeHeaderT<x>::setMajorSubsystemVersion(word wValue) |
2255 | { | 2255 | { |
2256 | m_inthHeader.OptionalHeader.MajorSubsystemVersion = wValue; | 2256 | m_inthHeader.OptionalHeader.MajorSubsystemVersion = wValue; |
2257 | } | 2257 | } |
2258 | 2258 | ||
2259 | /** | 2259 | /** |
2260 | * Changes the file's MinorSubsystemVersion. | 2260 | * Changes the file's MinorSubsystemVersion. |
2261 | * @param wValue New value. | 2261 | * @param wValue New value. |
2262 | **/ | 2262 | **/ |
2263 | template<int x> | 2263 | template<int x> |
2264 | void PeHeaderT<x>::setMinorSubsystemVersion(word wValue) | 2264 | void PeHeaderT<x>::setMinorSubsystemVersion(word wValue) |
2265 | { | 2265 | { |
2266 | m_inthHeader.OptionalHeader.MinorSubsystemVersion = wValue; | 2266 | m_inthHeader.OptionalHeader.MinorSubsystemVersion = wValue; |
2267 | } | 2267 | } |
2268 | 2268 | ||
2269 | /** | 2269 | /** |
2270 | * Changes the file's Win32VersionValue. | 2270 | * Changes the file's Win32VersionValue. |
2271 | * @param dwValue New value. | 2271 | * @param dwValue New value. |
2272 | **/ | 2272 | **/ |
2273 | template<int x> | 2273 | template<int x> |
2274 | void PeHeaderT<x>::setWin32VersionValue(dword dwValue) | 2274 | void PeHeaderT<x>::setWin32VersionValue(dword dwValue) |
2275 | { | 2275 | { |
2276 | m_inthHeader.OptionalHeader.Win32VersionValue = dwValue; | 2276 | m_inthHeader.OptionalHeader.Win32VersionValue = dwValue; |
2277 | } | 2277 | } |
2278 | 2278 | ||
2279 | /** | 2279 | /** |
2280 | * Changes the file's SizeOfImage. | 2280 | * Changes the file's SizeOfImage. |
2281 | * @param dwValue New value. | 2281 | * @param dwValue New value. |
2282 | **/ | 2282 | **/ |
2283 | template<int x> | 2283 | template<int x> |
2284 | void PeHeaderT<x>::setSizeOfImage(dword dwValue) | 2284 | void PeHeaderT<x>::setSizeOfImage(dword dwValue) |
2285 | { | 2285 | { |
2286 | m_inthHeader.OptionalHeader.SizeOfImage = dwValue; | 2286 | m_inthHeader.OptionalHeader.SizeOfImage = dwValue; |
2287 | } | 2287 | } |
2288 | 2288 | ||
2289 | /** | 2289 | /** |
2290 | * Changes the file's SizeOfHeaders. | 2290 | * Changes the file's SizeOfHeaders. |
2291 | * @param dwValue New value. | 2291 | * @param dwValue New value. |
2292 | **/ | 2292 | **/ |
2293 | template<int x> | 2293 | template<int x> |
2294 | void PeHeaderT<x>::setSizeOfHeaders(dword dwValue) | 2294 | void PeHeaderT<x>::setSizeOfHeaders(dword dwValue) |
2295 | { | 2295 | { |
2296 | m_inthHeader.OptionalHeader.SizeOfHeaders = dwValue; | 2296 | m_inthHeader.OptionalHeader.SizeOfHeaders = dwValue; |
2297 | } | 2297 | } |
2298 | 2298 | ||
2299 | /** | 2299 | /** |
2300 | * Changes the file's CheckSum. | 2300 | * Changes the file's CheckSum. |
2301 | * @param dwValue New value. | 2301 | * @param dwValue New value. |
2302 | **/ | 2302 | **/ |
2303 | template<int x> | 2303 | template<int x> |
2304 | void PeHeaderT<x>::setCheckSum(dword dwValue) | 2304 | void PeHeaderT<x>::setCheckSum(dword dwValue) |
2305 | { | 2305 | { |
2306 | m_inthHeader.OptionalHeader.CheckSum = dwValue; | 2306 | m_inthHeader.OptionalHeader.CheckSum = dwValue; |
2307 | } | 2307 | } |
2308 | 2308 | ||
2309 | /** | 2309 | /** |
2310 | * Changes the file's Subsystem. | 2310 | * Changes the file's Subsystem. |
2311 | * @param wValue New value. | 2311 | * @param wValue New value. |
2312 | **/ | 2312 | **/ |
2313 | template<int x> | 2313 | template<int x> |
2314 | void PeHeaderT<x>::setSubsystem(word wValue) | 2314 | void PeHeaderT<x>::setSubsystem(word wValue) |
2315 | { | 2315 | { |
2316 | m_inthHeader.OptionalHeader.Subsystem = wValue; | 2316 | m_inthHeader.OptionalHeader.Subsystem = wValue; |
2317 | } | 2317 | } |
2318 | 2318 | ||
2319 | /** | 2319 | /** |
2320 | * Changes the file's DllCharacteristics. | 2320 | * Changes the file's DllCharacteristics. |
2321 | * @param wValue New value. | 2321 | * @param wValue New value. |
2322 | **/ | 2322 | **/ |
2323 | template<int x> | 2323 | template<int x> |
2324 | void PeHeaderT<x>::setDllCharacteristics(word wValue) | 2324 | void PeHeaderT<x>::setDllCharacteristics(word wValue) |
2325 | { | 2325 | { |
2326 | m_inthHeader.OptionalHeader.DllCharacteristics = wValue; | 2326 | m_inthHeader.OptionalHeader.DllCharacteristics = wValue; |
2327 | } | 2327 | } |
2328 | 2328 | ||
2329 | /** | 2329 | /** |
2330 | * Changes the file's SizeOfStackReserve. | 2330 | * Changes the file's SizeOfStackReserve. |
2331 | * @param dwValue New value. | 2331 | * @param dwValue New value. |
2332 | **/ | 2332 | **/ |
2333 | template<int x> | 2333 | template<int x> |
2334 | void PeHeaderT<x>::setSizeOfStackReserve(typename FieldSizes<x>::VAR4_8 dwValue) | 2334 | void PeHeaderT<x>::setSizeOfStackReserve(typename FieldSizes<x>::VAR4_8 dwValue) |
2335 | { | 2335 | { |
2336 | m_inthHeader.OptionalHeader.SizeOfStackReserve = dwValue; | 2336 | m_inthHeader.OptionalHeader.SizeOfStackReserve = dwValue; |
2337 | } | 2337 | } |
2338 | 2338 | ||
2339 | /** | 2339 | /** |
2340 | * Changes the file's SizeOfStackCommit. | 2340 | * Changes the file's SizeOfStackCommit. |
2341 | * @param dwValue New value. | 2341 | * @param dwValue New value. |
2342 | **/ | 2342 | **/ |
2343 | template<int x> | 2343 | template<int x> |
2344 | void PeHeaderT<x>::setSizeOfStackCommit(typename FieldSizes<x>::VAR4_8 dwValue) | 2344 | void PeHeaderT<x>::setSizeOfStackCommit(typename FieldSizes<x>::VAR4_8 dwValue) |
2345 | { | 2345 | { |
2346 | m_inthHeader.OptionalHeader.SizeOfStackCommit = dwValue; | 2346 | m_inthHeader.OptionalHeader.SizeOfStackCommit = dwValue; |
2347 | } | 2347 | } |
2348 | 2348 | ||
2349 | /** | 2349 | /** |
2350 | * Changes the file's SizeOfHeapReserve. | 2350 | * Changes the file's SizeOfHeapReserve. |
2351 | * @param dwValue New value. | 2351 | * @param dwValue New value. |
2352 | **/ | 2352 | **/ |
2353 | template<int x> | 2353 | template<int x> |
2354 | void PeHeaderT<x>::setSizeOfHeapReserve(typename FieldSizes<x>::VAR4_8 dwValue) | 2354 | void PeHeaderT<x>::setSizeOfHeapReserve(typename FieldSizes<x>::VAR4_8 dwValue) |
2355 | { | 2355 | { |
2356 | m_inthHeader.OptionalHeader.SizeOfHeapReserve = dwValue; | 2356 | m_inthHeader.OptionalHeader.SizeOfHeapReserve = dwValue; |
2357 | } | 2357 | } |
2358 | 2358 | ||
2359 | /** | 2359 | /** |
2360 | * Changes the file's SizeOfHeapCommit. | 2360 | * Changes the file's SizeOfHeapCommit. |
2361 | * @param dwValue New value. | 2361 | * @param dwValue New value. |
2362 | **/ | 2362 | **/ |
2363 | template<int x> | 2363 | template<int x> |
2364 | void PeHeaderT<x>::setSizeOfHeapCommit(typename FieldSizes<x>::VAR4_8 dwValue) | 2364 | void PeHeaderT<x>::setSizeOfHeapCommit(typename FieldSizes<x>::VAR4_8 dwValue) |
2365 | { | 2365 | { |
2366 | m_inthHeader.OptionalHeader.SizeOfHeapCommit = dwValue; | 2366 | m_inthHeader.OptionalHeader.SizeOfHeapCommit = dwValue; |
2367 | } | 2367 | } |
2368 | 2368 | ||
2369 | /** | 2369 | /** |
2370 | * Changes the file's LoaderFlags. | 2370 | * Changes the file's LoaderFlags. |
2371 | * @param dwValue New value. | 2371 | * @param dwValue New value. |
2372 | **/ | 2372 | **/ |
2373 | template<int x> | 2373 | template<int x> |
2374 | void PeHeaderT<x>::setLoaderFlags(dword dwValue) | 2374 | void PeHeaderT<x>::setLoaderFlags(dword dwValue) |
2375 | { | 2375 | { |
2376 | m_inthHeader.OptionalHeader.LoaderFlags = dwValue; | 2376 | m_inthHeader.OptionalHeader.LoaderFlags = dwValue; |
2377 | } | 2377 | } |
2378 | 2378 | ||
2379 | /** | 2379 | /** |
2380 | * Changes the file's NumberOfRvaAndSizes. | 2380 | * Changes the file's NumberOfRvaAndSizes. |
2381 | * @param dwValue New value. | 2381 | * @param dwValue New value. |
2382 | **/ | 2382 | **/ |
2383 | template<int x> | 2383 | template<int x> |
2384 | void PeHeaderT<x>::setNumberOfRvaAndSizes(dword dwValue) | 2384 | void PeHeaderT<x>::setNumberOfRvaAndSizes(dword dwValue) |
2385 | { | 2385 | { |
2386 | m_inthHeader.OptionalHeader.NumberOfRvaAndSizes = dwValue; | 2386 | m_inthHeader.OptionalHeader.NumberOfRvaAndSizes = dwValue; |
2387 | } | 2387 | } |
2388 | 2388 | ||
2389 | template<int x> | 2389 | template<int x> |
2390 | void PeHeaderT<x>::setIddDebugRva(dword dwValue) | 2390 | void PeHeaderT<x>::setIddDebugRva(dword dwValue) |
2391 | { | 2391 | { |
2392 | m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress = dwValue; | 2392 | m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress = dwValue; |
2393 | } | 2393 | } |
2394 | 2394 | ||
2395 | template<int x> | 2395 | template<int x> |
2396 | void PeHeaderT<x>::setIddDebugSize(dword dwValue) | 2396 | void PeHeaderT<x>::setIddDebugSize(dword dwValue) |
2397 | { | 2397 | { |
2398 | m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_DEBUG].Size = dwValue; | 2398 | m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_DEBUG].Size = dwValue; |
2399 | } | 2399 | } |
2400 | 2400 | ||
2401 | template<int x> | 2401 | template<int x> |
2402 | void PeHeaderT<x>::setIddDelayImportRva(dword dwValue) | 2402 | void PeHeaderT<x>::setIddDelayImportRva(dword dwValue) |
2403 | { | 2403 | { |
2404 | m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT].VirtualAddress = dwValue; | 2404 | m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT].VirtualAddress = dwValue; |
2405 | } | 2405 | } |
2406 | 2406 | ||
2407 | template<int x> | 2407 | template<int x> |
2408 | void PeHeaderT<x>::setIddDelayImportSize(dword dwValue) | 2408 | void PeHeaderT<x>::setIddDelayImportSize(dword dwValue) |
2409 | { | 2409 | { |
2410 | m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT].Size = dwValue; | 2410 | m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT].Size = dwValue; |
2411 | } | 2411 | } |
2412 | 2412 | ||
2413 | template<int x> | 2413 | template<int x> |
2414 | void PeHeaderT<x>::setIddExceptionRva(dword dwValue) | 2414 | void PeHeaderT<x>::setIddExceptionRva(dword dwValue) |
2415 | { | 2415 | { |
2416 | m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_EXCEPTION].VirtualAddress = dwValue; | 2416 | m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_EXCEPTION].VirtualAddress = dwValue; |
2417 | } | 2417 | } |
2418 | 2418 | ||
2419 | template<int x> | 2419 | template<int x> |
2420 | void PeHeaderT<x>::setIddExceptionSize(dword dwValue) | 2420 | void PeHeaderT<x>::setIddExceptionSize(dword dwValue) |
2421 | { | 2421 | { |
2422 | m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_EXCEPTION].Size = dwValue; | 2422 | m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_EXCEPTION].Size = dwValue; |
2423 | } | 2423 | } |
2424 | 2424 | ||
2425 | template<int x> | 2425 | template<int x> |
2426 | void PeHeaderT<x>::setIddGlobalPtrRva(dword dwValue) | 2426 | void PeHeaderT<x>::setIddGlobalPtrRva(dword dwValue) |
2427 | { | 2427 | { |
2428 | m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_GLOBALPTR].VirtualAddress = dwValue; | 2428 | m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_GLOBALPTR].VirtualAddress = dwValue; |
2429 | } | 2429 | } |
2430 | 2430 | ||
2431 | template<int x> | 2431 | template<int x> |
2432 | void PeHeaderT<x>::setIddGlobalPtrSize(dword dwValue) | 2432 | void PeHeaderT<x>::setIddGlobalPtrSize(dword dwValue) |
2433 | { | 2433 | { |
2434 | m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_GLOBALPTR].Size = dwValue; | 2434 | m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_GLOBALPTR].Size = dwValue; |
2435 | } | 2435 | } |
2436 | 2436 | ||
2437 | template<int x> | 2437 | template<int x> |
2438 | void PeHeaderT<x>::setIddIatRva(dword dwValue) | 2438 | void PeHeaderT<x>::setIddIatRva(dword dwValue) |
2439 | { | 2439 | { |
2440 | m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_IAT].VirtualAddress = dwValue; | 2440 | m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_IAT].VirtualAddress = dwValue; |
2441 | } | 2441 | } |
2442 | 2442 | ||
2443 | template<int x> | 2443 | template<int x> |
2444 | void PeHeaderT<x>::setIddIatSize(dword dwValue) | 2444 | void PeHeaderT<x>::setIddIatSize(dword dwValue) |
2445 | { | 2445 | { |
2446 | m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_IAT].Size = dwValue; | 2446 | m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_IAT].Size = dwValue; |
2447 | } | 2447 | } |
2448 | 2448 | ||
2449 | template<int x> | 2449 | template<int x> |
2450 | void PeHeaderT<x>::setIddLoadConfigRva(dword dwValue) | 2450 | void PeHeaderT<x>::setIddLoadConfigRva(dword dwValue) |
2451 | { | 2451 | { |
2452 | m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG].VirtualAddress = dwValue; | 2452 | m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG].VirtualAddress = dwValue; |
2453 | } | 2453 | } |
2454 | 2454 | ||
2455 | template<int x> | 2455 | template<int x> |
2456 | void PeHeaderT<x>::setIddLoadConfigSize(dword dwValue) | 2456 | void PeHeaderT<x>::setIddLoadConfigSize(dword dwValue) |
2457 | { | 2457 | { |
2458 | m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG].Size = dwValue; | 2458 | m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG].Size = dwValue; |
2459 | } | 2459 | } |
2460 | 2460 | ||
2461 | template<int x> | 2461 | template<int x> |
2462 | void PeHeaderT<x>::setIddResourceRva(dword dwValue) | 2462 | void PeHeaderT<x>::setIddResourceRva(dword dwValue) |
2463 | { | 2463 | { |
2464 | m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_RESOURCE].VirtualAddress = dwValue; | 2464 | m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_RESOURCE].VirtualAddress = dwValue; |
2465 | } | 2465 | } |
2466 | 2466 | ||
2467 | template<int x> | 2467 | template<int x> |
2468 | void PeHeaderT<x>::setIddResourceSize(dword dwValue) | 2468 | void PeHeaderT<x>::setIddResourceSize(dword dwValue) |
2469 | { | 2469 | { |
2470 | m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_RESOURCE].Size = dwValue; | 2470 | m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_RESOURCE].Size = dwValue; |
2471 | } | 2471 | } |
2472 | 2472 | ||
2473 | template<int x> | 2473 | template<int x> |
2474 | void PeHeaderT<x>::setIddSecurityRva(dword dwValue) | 2474 | void PeHeaderT<x>::setIddSecurityRva(dword dwValue) |
2475 | { | 2475 | { |
2476 | m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_SECURITY].VirtualAddress = dwValue; | 2476 | m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_SECURITY].VirtualAddress = dwValue; |
2477 | } | 2477 | } |
2478 | 2478 | ||
2479 | template<int x> | 2479 | template<int x> |
2480 | void PeHeaderT<x>::setIddSecuritySize(dword dwValue) | 2480 | void PeHeaderT<x>::setIddSecuritySize(dword dwValue) |
2481 | { | 2481 | { |
2482 | m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_SECURITY].Size = dwValue; | 2482 | m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_SECURITY].Size = dwValue; |
2483 | } | 2483 | } |
2484 | 2484 | ||
2485 | template<int x> | 2485 | template<int x> |
2486 | void PeHeaderT<x>::setIddTlsRva(dword dwValue) | 2486 | void PeHeaderT<x>::setIddTlsRva(dword dwValue) |
2487 | { | 2487 | { |
2488 | m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_TLS].VirtualAddress = dwValue; | 2488 | m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_TLS].VirtualAddress = dwValue; |
2489 | } | 2489 | } |
2490 | 2490 | ||
2491 | template<int x> | 2491 | template<int x> |
2492 | void PeHeaderT<x>::setIddTlsSize(dword dwValue) | 2492 | void PeHeaderT<x>::setIddTlsSize(dword dwValue) |
2493 | { | 2493 | { |
2494 | m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_TLS].Size = dwValue; | 2494 | m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_TLS].Size = dwValue; |
2495 | } | 2495 | } |
2496 | 2496 | ||
2497 | /** | 2497 | /** |
2498 | * Changes the rva of the file's export directory. | 2498 | * Changes the rva of the file's export directory. |
2499 | * @param dwValue New value. | 2499 | * @param dwValue New value. |
2500 | **/ | 2500 | **/ |
2501 | template<int x> | 2501 | template<int x> |
2502 | void PeHeaderT<x>::setIddExportRva(dword dwValue) | 2502 | void PeHeaderT<x>::setIddExportRva(dword dwValue) |
2503 | { | 2503 | { |
2504 | m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress = dwValue; | 2504 | m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress = dwValue; |
2505 | } | 2505 | } |
2506 | 2506 | ||
2507 | /** | 2507 | /** |
2508 | * Changes the size of the file's export directory. | 2508 | * Changes the size of the file's export directory. |
2509 | * @param dwValue New value. | 2509 | * @param dwValue New value. |
2510 | **/ | 2510 | **/ |
2511 | template<int x> | 2511 | template<int x> |
2512 | void PeHeaderT<x>::setIddExportSize(dword dwValue) | 2512 | void PeHeaderT<x>::setIddExportSize(dword dwValue) |
2513 | { | 2513 | { |
2514 | m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_EXPORT].Size = dwValue; | 2514 | m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_EXPORT].Size = dwValue; |
2515 | } | 2515 | } |
2516 | 2516 | ||
2517 | template<int x> | 2517 | template<int x> |
2518 | void PeHeaderT<x>::setIddBaseRelocRva(dword value) | 2518 | void PeHeaderT<x>::setIddBaseRelocRva(dword value) |
2519 | { | 2519 | { |
2520 | m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_BASERELOC].VirtualAddress = value; | 2520 | m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_BASERELOC].VirtualAddress = value; |
2521 | } | 2521 | } |
2522 | 2522 | ||
2523 | template<int x> | 2523 | template<int x> |
2524 | void PeHeaderT<x>::setIddBaseRelocSize(dword value) | 2524 | void PeHeaderT<x>::setIddBaseRelocSize(dword value) |
2525 | { | 2525 | { |
2526 | m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_BASERELOC].Size = value; | 2526 | m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_BASERELOC].Size = value; |
2527 | } | 2527 | } |
2528 | 2528 | ||
2529 | template<int x> | 2529 | template<int x> |
2530 | void PeHeaderT<x>::setIddArchitectureRva(dword value) | 2530 | void PeHeaderT<x>::setIddArchitectureRva(dword value) |
2531 | { | 2531 | { |
2532 | m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_ARCHITECTURE].VirtualAddress = value; | 2532 | m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_ARCHITECTURE].VirtualAddress = value; |
2533 | } | 2533 | } |
2534 | 2534 | ||
2535 | template<int x> | 2535 | template<int x> |
2536 | void PeHeaderT<x>::setIddArchitectureSize(dword value) | 2536 | void PeHeaderT<x>::setIddArchitectureSize(dword value) |
2537 | { | 2537 | { |
2538 | m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_ARCHITECTURE].Size = value; | 2538 | m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_ARCHITECTURE].Size = value; |
2539 | } | 2539 | } |
2540 | 2540 | ||
2541 | template<int x> | 2541 | template<int x> |
2542 | void PeHeaderT<x>::setIddComHeaderRva(dword value) | 2542 | void PeHeaderT<x>::setIddComHeaderRva(dword value) |
2543 | { | 2543 | { |
2544 | m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR].VirtualAddress = value; | 2544 | m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR].VirtualAddress = value; |
2545 | } | 2545 | } |
2546 | 2546 | ||
2547 | template<int x> | 2547 | template<int x> |
2548 | void PeHeaderT<x>::setIddComHeaderSize(dword value) | 2548 | void PeHeaderT<x>::setIddComHeaderSize(dword value) |
2549 | { | 2549 | { |
2550 | m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR].Size = value; | 2550 | m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR].Size = value; |
2551 | } | 2551 | } |
2552 | 2552 | ||
2553 | /** | 2553 | /** |
2554 | * Changes the rva of the file's import directory. | 2554 | * Changes the rva of the file's import directory. |
2555 | * @param dwValue New value. | 2555 | * @param dwValue New value. |
2556 | **/ | 2556 | **/ |
2557 | template<int x> | 2557 | template<int x> |
2558 | void PeHeaderT<x>::setIddImportRva(dword dwValue) | 2558 | void PeHeaderT<x>::setIddImportRva(dword dwValue) |
2559 | { | 2559 | { |
2560 | m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress = dwValue; | 2560 | m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress = dwValue; |
2561 | } | 2561 | } |
2562 | 2562 | ||
2563 | /** | 2563 | /** |
2564 | * Changes the size of the file's import directory. | 2564 | * Changes the size of the file's import directory. |
2565 | * @param dwValue New value. | 2565 | * @param dwValue New value. |
2566 | **/ | 2566 | **/ |
2567 | template<int x> | 2567 | template<int x> |
2568 | void PeHeaderT<x>::setIddImportSize(dword dwValue) | 2568 | void PeHeaderT<x>::setIddImportSize(dword dwValue) |
2569 | { | 2569 | { |
2570 | m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_IMPORT].Size = dwValue; | 2570 | m_inthHeader.dataDirectories[PELIB_IMAGE_DIRECTORY_ENTRY_IMPORT].Size = dwValue; |
2571 | } | 2571 | } |
2572 | 2572 | ||
2573 | /** | 2573 | /** |
2574 | * Changes the name of a section. | 2574 | * Changes the name of a section. |
2575 | * @param wSectionnr Identifier of the section | 2575 | * @param wSectionnr Identifier of the section |
2576 | * @param strName New name. | 2576 | * @param strName New name. |
2577 | **/ | 2577 | **/ |
2578 | template<int x> | 2578 | template<int x> |
2579 | void PeHeaderT<x>::setSectionName(word wSectionnr, std::string strName) | 2579 | void PeHeaderT<x>::setSectionName(word wSectionnr, std::string strName) |
2580 | { | 2580 | { |
2581 | strncpy(reinterpret_cast<char*>(m_vIsh[wSectionnr].Name), strName.c_str(), sizeof(m_vIsh[wSectionnr].Name)); | 2581 | strncpy(reinterpret_cast<char*>(m_vIsh[wSectionnr].Name), strName.c_str(), sizeof(m_vIsh[wSectionnr].Name)); |
2582 | } | 2582 | } |
2583 | 2583 | ||
2584 | /** | 2584 | /** |
2585 | * Changes the virtual size of a section. | 2585 | * Changes the virtual size of a section. |
2586 | * @param wSectionnr Identifier of the section | 2586 | * @param wSectionnr Identifier of the section |
2587 | * @param dwValue New value. | 2587 | * @param dwValue New value. |
2588 | **/ | 2588 | **/ |
2589 | template<int x> | 2589 | template<int x> |
2590 | void PeHeaderT<x>::setVirtualSize(word wSectionnr, dword dwValue) | 2590 | void PeHeaderT<x>::setVirtualSize(word wSectionnr, dword dwValue) |
2591 | { | 2591 | { |
2592 | m_vIsh[wSectionnr].VirtualSize = dwValue; | 2592 | m_vIsh[wSectionnr].VirtualSize = dwValue; |
2593 | } | 2593 | } |
2594 | 2594 | ||
2595 | /** | 2595 | /** |
2596 | * Changes the virtual address of a section. | 2596 | * Changes the virtual address of a section. |
2597 | * @param wSectionnr Identifier of the section | 2597 | * @param wSectionnr Identifier of the section |
2598 | * @param dwValue New value. | 2598 | * @param dwValue New value. |
2599 | **/ | 2599 | **/ |
2600 | template<int x> | 2600 | template<int x> |
2601 | void PeHeaderT<x>::setVirtualAddress(word wSectionnr, dword dwValue) | 2601 | void PeHeaderT<x>::setVirtualAddress(word wSectionnr, dword dwValue) |
2602 | { | 2602 | { |
2603 | m_vIsh[wSectionnr].VirtualAddress = dwValue; | 2603 | m_vIsh[wSectionnr].VirtualAddress = dwValue; |
2604 | } | 2604 | } |
2605 | 2605 | ||
2606 | /** | 2606 | /** |
2607 | * Changes the size of raw data of a section. | 2607 | * Changes the size of raw data of a section. |
2608 | * @param wSectionnr Identifier of the section | 2608 | * @param wSectionnr Identifier of the section |
2609 | * @param dwValue New value. | 2609 | * @param dwValue New value. |
2610 | **/ | 2610 | **/ |
2611 | template<int x> | 2611 | template<int x> |
2612 | void PeHeaderT<x>::setSizeOfRawData(word wSectionnr, dword dwValue) | 2612 | void PeHeaderT<x>::setSizeOfRawData(word wSectionnr, dword dwValue) |
2613 | { | 2613 | { |
2614 | m_vIsh[wSectionnr].SizeOfRawData = dwValue; | 2614 | m_vIsh[wSectionnr].SizeOfRawData = dwValue; |
2615 | } | 2615 | } |
2616 | 2616 | ||
2617 | /** | 2617 | /** |
2618 | * Changes the size of raw data of a section. | 2618 | * Changes the size of raw data of a section. |
2619 | * @param wSectionnr Identifier of the section | 2619 | * @param wSectionnr Identifier of the section |
2620 | * @param dwValue New value. | 2620 | * @param dwValue New value. |
2621 | **/ | 2621 | **/ |
2622 | template<int x> | 2622 | template<int x> |
2623 | void PeHeaderT<x>::setPointerToRawData(word wSectionnr, dword dwValue) | 2623 | void PeHeaderT<x>::setPointerToRawData(word wSectionnr, dword dwValue) |
2624 | { | 2624 | { |
2625 | m_vIsh[wSectionnr].PointerToRawData = dwValue; | 2625 | m_vIsh[wSectionnr].PointerToRawData = dwValue; |
2626 | } | 2626 | } |
2627 | 2627 | ||
2628 | /** | 2628 | /** |
2629 | * Changes the pointer to relocations of a section. | 2629 | * Changes the pointer to relocations of a section. |
2630 | * @param wSectionnr Identifier of the section | 2630 | * @param wSectionnr Identifier of the section |
2631 | * @param dwValue New value. | 2631 | * @param dwValue New value. |
2632 | **/ | 2632 | **/ |
2633 | template<int x> | 2633 | template<int x> |
2634 | void PeHeaderT<x>::setPointerToRelocations(word wSectionnr, dword dwValue) | 2634 | void PeHeaderT<x>::setPointerToRelocations(word wSectionnr, dword dwValue) |
2635 | { | 2635 | { |
2636 | m_vIsh[wSectionnr].PointerToRelocations = dwValue; | 2636 | m_vIsh[wSectionnr].PointerToRelocations = dwValue; |
2637 | } | 2637 | } |
2638 | 2638 | ||
2639 | /** | 2639 | /** |
2640 | * Changes the pointer to line numbers of a section. | 2640 | * Changes the pointer to line numbers of a section. |
2641 | * @param wSectionnr Identifier of the section | 2641 | * @param wSectionnr Identifier of the section |
2642 | * @param dwValue New value. | 2642 | * @param dwValue New value. |
2643 | **/ | 2643 | **/ |
2644 | template<int x> | 2644 | template<int x> |
2645 | void PeHeaderT<x>::setPointerToLinenumbers(word wSectionnr, dword dwValue) | 2645 | void PeHeaderT<x>::setPointerToLinenumbers(word wSectionnr, dword dwValue) |
2646 | { | 2646 | { |
2647 | m_vIsh[wSectionnr].PointerToLinenumbers = dwValue; | 2647 | m_vIsh[wSectionnr].PointerToLinenumbers = dwValue; |
2648 | } | 2648 | } |
2649 | 2649 | ||
2650 | /** | 2650 | /** |
2651 | * Changes the number of relocations of a section. | 2651 | * Changes the number of relocations of a section. |
2652 | * @param wSectionnr Identifier of the section | 2652 | * @param wSectionnr Identifier of the section |
2653 | * @param dwValue New value. | 2653 | * @param dwValue New value. |
2654 | **/ | 2654 | **/ |
2655 | template<int x> | 2655 | template<int x> |
2656 | void PeHeaderT<x>::setNumberOfRelocations(word wSectionnr, dword dwValue) | 2656 | void PeHeaderT<x>::setNumberOfRelocations(word wSectionnr, dword dwValue) |
2657 | { | 2657 | { |
2658 | m_vIsh[wSectionnr].NumberOfRelocations = dwValue; | 2658 | m_vIsh[wSectionnr].NumberOfRelocations = dwValue; |
2659 | } | 2659 | } |
2660 | 2660 | ||
2661 | /** | 2661 | /** |
2662 | * Changes the number of line numbers of a section. | 2662 | * Changes the number of line numbers of a section. |
2663 | * @param wSectionnr Identifier of the section | 2663 | * @param wSectionnr Identifier of the section |
2664 | * @param dwValue New value. | 2664 | * @param dwValue New value. |
2665 | **/ | 2665 | **/ |
2666 | template<int x> | 2666 | template<int x> |
2667 | void PeHeaderT<x>::setNumberOfLinenumbers(word wSectionnr, dword dwValue) | 2667 | void PeHeaderT<x>::setNumberOfLinenumbers(word wSectionnr, dword dwValue) |
2668 | { | 2668 | { |
2669 | m_vIsh[wSectionnr].NumberOfLinenumbers = dwValue; | 2669 | m_vIsh[wSectionnr].NumberOfLinenumbers = dwValue; |
2670 | } | 2670 | } |
2671 | 2671 | ||
2672 | /** | 2672 | /** |
2673 | * Changes the characteristics of a section. | 2673 | * Changes the characteristics of a section. |
2674 | * @param wSectionnr Identifier of the section | 2674 | * @param wSectionnr Identifier of the section |
2675 | * @param dwValue New value. | 2675 | * @param dwValue New value. |
2676 | **/ | 2676 | **/ |
2677 | template<int x> | 2677 | template<int x> |
2678 | void PeHeaderT<x>::setCharacteristics(word wSectionnr, dword dwValue) | 2678 | void PeHeaderT<x>::setCharacteristics(word wSectionnr, dword dwValue) |
2679 | { | 2679 | { |
2680 | m_vIsh[wSectionnr].Characteristics = dwValue; | 2680 | m_vIsh[wSectionnr].Characteristics = dwValue; |
2681 | } | 2681 | } |
2682 | 2682 | ||
2683 | } | 2683 | } |
2684 | 2684 | ||
2685 | #endif | 2685 | #endif |