summaryrefslogtreecommitdiff
path: root/utils/zenutils/libraries/pelib-0.9/pelib/PeFile.h
diff options
context:
space:
mode:
authorNicolas Pennequin <nicolas.pennequin@free.fr>2008-07-11 16:51:25 +0000
committerNicolas Pennequin <nicolas.pennequin@free.fr>2008-07-11 16:51:25 +0000
commitca5bb76d2b8f65aa97e50b633f828c1deb241526 (patch)
tree453a1b2de3a0dc0d0b2f7080d10d033bf8fbcdf1 /utils/zenutils/libraries/pelib-0.9/pelib/PeFile.h
parent141774be48940d56e3ad4dbf451d245b61d4f8b2 (diff)
downloadrockbox-ca5bb76d2b8f65aa97e50b633f828c1deb241526.tar.gz
rockbox-ca5bb76d2b8f65aa97e50b633f828c1deb241526.zip
Delete the svn:executable property and set svn:eol-style to native for all those text files.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18012 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'utils/zenutils/libraries/pelib-0.9/pelib/PeFile.h')
-rw-r--r--[-rwxr-xr-x]utils/zenutils/libraries/pelib-0.9/pelib/PeFile.h902
1 files changed, 451 insertions, 451 deletions
diff --git a/utils/zenutils/libraries/pelib-0.9/pelib/PeFile.h b/utils/zenutils/libraries/pelib-0.9/pelib/PeFile.h
index a2b02cdfa8..e08d8da309 100755..100644
--- a/utils/zenutils/libraries/pelib-0.9/pelib/PeFile.h
+++ b/utils/zenutils/libraries/pelib-0.9/pelib/PeFile.h
@@ -1,451 +1,451 @@
1/* 1/*
2* PeFile.h - Part of the PeLib library. 2* PeFile.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 PEFILE_H 13#ifndef PEFILE_H
14#define PEFILE_H 14#define PEFILE_H
15 15
16#include "PeLibInc.h" 16#include "PeLibInc.h"
17#include "MzHeader.h" 17#include "MzHeader.h"
18#include "PeHeader.h" 18#include "PeHeader.h"
19#include "ImportDirectory.h" 19#include "ImportDirectory.h"
20#include "ExportDirectory.h" 20#include "ExportDirectory.h"
21#include "BoundImportDirectory.h" 21#include "BoundImportDirectory.h"
22#include "ResourceDirectory.h" 22#include "ResourceDirectory.h"
23#include "RelocationsDirectory.h" 23#include "RelocationsDirectory.h"
24#include "ComHeaderDirectory.h" 24#include "ComHeaderDirectory.h"
25#include "IatDirectory.h" 25#include "IatDirectory.h"
26#include "DebugDirectory.h" 26#include "DebugDirectory.h"
27#include "TlsDirectory.h" 27#include "TlsDirectory.h"
28 28
29namespace PeLib 29namespace PeLib
30{ 30{
31 class PeFile32; 31 class PeFile32;
32 class PeFile64; 32 class PeFile64;
33 33
34 /** 34 /**
35 * Visitor base class for PeFiles. 35 * Visitor base class for PeFiles.
36 **/ 36 **/
37 class PeFileVisitor 37 class PeFileVisitor
38 { 38 {
39 public: 39 public:
40 virtual void callback(PeFile32 &file){} 40 virtual void callback(PeFile32 &file){}
41 virtual void callback(PeFile64 &file){} 41 virtual void callback(PeFile64 &file){}
42 virtual ~PeFileVisitor(){} 42 virtual ~PeFileVisitor(){}
43 }; 43 };
44 44
45 /** 45 /**
46 * Traits class that's used to decide of what type the PeHeader in a PeFile is. 46 * Traits class that's used to decide of what type the PeHeader in a PeFile is.
47 **/ 47 **/
48 template<int> 48 template<int>
49 struct PeFile_Traits; 49 struct PeFile_Traits;
50 50
51 template<> 51 template<>
52 struct PeFile_Traits<32> 52 struct PeFile_Traits<32>
53 { 53 {
54 typedef PeHeader32 PeHeader32_64; 54 typedef PeHeader32 PeHeader32_64;
55 }; 55 };
56 56
57 template<> 57 template<>
58 struct PeFile_Traits<64> 58 struct PeFile_Traits<64>
59 { 59 {
60 typedef PeHeader64 PeHeader32_64; 60 typedef PeHeader64 PeHeader32_64;
61 }; 61 };
62 62
63 /** 63 /**
64 * This class represents the common structures of PE and PE+ files. 64 * This class represents the common structures of PE and PE+ files.
65 **/ 65 **/
66 class PeFile 66 class PeFile
67 { 67 {
68 protected: 68 protected:
69 std::string m_filename; ///< Name of the current file. 69 std::string m_filename; ///< Name of the current file.
70 MzHeader m_mzh; ///< MZ header of the current file. 70 MzHeader m_mzh; ///< MZ header of the current file.
71 ExportDirectory m_expdir; ///< Export directory of the current file. 71 ExportDirectory m_expdir; ///< Export directory of the current file.
72 BoundImportDirectory m_boundimpdir; ///< BoundImportDirectory of the current file. 72 BoundImportDirectory m_boundimpdir; ///< BoundImportDirectory of the current file.
73 ResourceDirectory m_resdir; ///< ResourceDirectory of the current file. 73 ResourceDirectory m_resdir; ///< ResourceDirectory of the current file.
74 RelocationsDirectory m_relocs; ///< Relocations directory of the current file. 74 RelocationsDirectory m_relocs; ///< Relocations directory of the current file.
75 ComHeaderDirectory m_comdesc; ///< COM+ descriptor directory of the current file. 75 ComHeaderDirectory m_comdesc; ///< COM+ descriptor directory of the current file.
76 IatDirectory m_iat; ///< Import address table of the current file. 76 IatDirectory m_iat; ///< Import address table of the current file.
77 DebugDirectory m_debugdir; 77 DebugDirectory m_debugdir;
78 public: 78 public:
79 virtual ~PeFile(); 79 virtual ~PeFile();
80 80
81 /// Returns the name of the current file. 81 /// Returns the name of the current file.
82 virtual std::string getFileName() const = 0; // EXPORT 82 virtual std::string getFileName() const = 0; // EXPORT
83 /// Changes the name of the current file. 83 /// Changes the name of the current file.
84 virtual void setFileName(std::string strFilename) = 0; // EXPORT 84 virtual void setFileName(std::string strFilename) = 0; // EXPORT
85 85
86 virtual void visit(PeFileVisitor &v) = 0; 86 virtual void visit(PeFileVisitor &v) = 0;
87 87
88 /// Reads the MZ header of the current file from disc. 88 /// Reads the MZ header of the current file from disc.
89 virtual int readMzHeader() = 0; // EXPORT 89 virtual int readMzHeader() = 0; // EXPORT
90 /// Reads the export directory of the current file from disc. 90 /// Reads the export directory of the current file from disc.
91 virtual int readExportDirectory() = 0; // EXPORT 91 virtual int readExportDirectory() = 0; // EXPORT
92 /// Reads the PE header of the current file from disc. 92 /// Reads the PE header of the current file from disc.
93 virtual int readPeHeader() = 0; // EXPORT 93 virtual int readPeHeader() = 0; // EXPORT
94 /// Reads the import directory of the current file from disc. 94 /// Reads the import directory of the current file from disc.
95 virtual int readImportDirectory() = 0; // EXPORT 95 virtual int readImportDirectory() = 0; // EXPORT
96 /// Reads the bound import directory of the current file from disc. 96 /// Reads the bound import directory of the current file from disc.
97 virtual int readBoundImportDirectory() = 0; // EXPORT 97 virtual int readBoundImportDirectory() = 0; // EXPORT
98 /// Reads the resource directory of the current file from disc. 98 /// Reads the resource directory of the current file from disc.
99 virtual int readResourceDirectory() = 0; // EXPORT 99 virtual int readResourceDirectory() = 0; // EXPORT
100 /// Reads the relocations directory of the current file from disc. 100 /// Reads the relocations directory of the current file from disc.
101 virtual int readRelocationsDirectory() = 0; // EXPORT 101 virtual int readRelocationsDirectory() = 0; // EXPORT
102 /// Reads the COM+ descriptor directory of the current file from disc. 102 /// Reads the COM+ descriptor directory of the current file from disc.
103 virtual int readComHeaderDirectory() = 0; // EXPORT 103 virtual int readComHeaderDirectory() = 0; // EXPORT
104 /// Reads the IAT directory of the current file from disc. 104 /// Reads the IAT directory of the current file from disc.
105 virtual int readIatDirectory() = 0; // EXPORT 105 virtual int readIatDirectory() = 0; // EXPORT
106 /// Reads the Debug directory of the current file. 106 /// Reads the Debug directory of the current file.
107 virtual int readDebugDirectory() = 0; // EXPORT 107 virtual int readDebugDirectory() = 0; // EXPORT
108 virtual int readTlsDirectory() = 0; // EXPORT 108 virtual int readTlsDirectory() = 0; // EXPORT
109 109
110 virtual unsigned int getBits() const = 0; 110 virtual unsigned int getBits() const = 0;
111 111
112 /// Accessor function for the MZ header. 112 /// Accessor function for the MZ header.
113 const MzHeader& mzHeader() const; 113 const MzHeader& mzHeader() const;
114 /// Accessor function for the MZ header. 114 /// Accessor function for the MZ header.
115 MzHeader& mzHeader(); // EXPORT 115 MzHeader& mzHeader(); // EXPORT
116 116
117 /// Accessor function for the export directory. 117 /// Accessor function for the export directory.
118 const ExportDirectory& expDir() const; 118 const ExportDirectory& expDir() const;
119 /// Accessor function for the export directory. 119 /// Accessor function for the export directory.
120 ExportDirectory& expDir(); // EXPORT 120 ExportDirectory& expDir(); // EXPORT
121 121
122 /// Accessor function for the bound import directory. 122 /// Accessor function for the bound import directory.
123 const BoundImportDirectory& boundImpDir() const; 123 const BoundImportDirectory& boundImpDir() const;
124 /// Accessor function for the bound import directory. 124 /// Accessor function for the bound import directory.
125 BoundImportDirectory& boundImpDir(); // EXPORT 125 BoundImportDirectory& boundImpDir(); // EXPORT
126 126
127 /// Accessor function for the resource directory. 127 /// Accessor function for the resource directory.
128 const ResourceDirectory& resDir() const; 128 const ResourceDirectory& resDir() const;
129 /// Accessor function for the resource directory. 129 /// Accessor function for the resource directory.
130 ResourceDirectory& resDir(); // EXPORT 130 ResourceDirectory& resDir(); // EXPORT
131 131
132 /// Accessor function for the relocations directory. 132 /// Accessor function for the relocations directory.
133 const RelocationsDirectory& relocDir() const; 133 const RelocationsDirectory& relocDir() const;
134 /// Accessor function for the relocations directory. 134 /// Accessor function for the relocations directory.
135 RelocationsDirectory& relocDir(); // EXPORT 135 RelocationsDirectory& relocDir(); // EXPORT
136 136
137 /// Accessor function for the COM+ descriptor directory. 137 /// Accessor function for the COM+ descriptor directory.
138 const ComHeaderDirectory& comDir() const; 138 const ComHeaderDirectory& comDir() const;
139 /// Accessor function for the COM+ descriptor directory. 139 /// Accessor function for the COM+ descriptor directory.
140 ComHeaderDirectory& comDir(); // EXPORT 140 ComHeaderDirectory& comDir(); // EXPORT
141 141
142 /// Accessor function for the IAT directory. 142 /// Accessor function for the IAT directory.
143 const IatDirectory& iatDir() const; 143 const IatDirectory& iatDir() const;
144 /// Accessor function for the IAT directory. 144 /// Accessor function for the IAT directory.
145 IatDirectory& iatDir(); // EXPORT 145 IatDirectory& iatDir(); // EXPORT
146 146
147 /// Accessor function for the debug directory. 147 /// Accessor function for the debug directory.
148 const DebugDirectory& debugDir() const; 148 const DebugDirectory& debugDir() const;
149 /// Accessor function for the debug directory. 149 /// Accessor function for the debug directory.
150 DebugDirectory& debugDir(); // EXPORT 150 DebugDirectory& debugDir(); // EXPORT
151 151
152 }; 152 };
153 153
154 /** 154 /**
155 * This class implements the common structures of PE and PE+ files. 155 * This class implements the common structures of PE and PE+ files.
156 **/ 156 **/
157 template<int bits> 157 template<int bits>
158 class PeFileT : public PeFile 158 class PeFileT : public PeFile
159 { 159 {
160 typedef typename PeFile_Traits<bits>::PeHeader32_64 PeHeader32_64; 160 typedef typename PeFile_Traits<bits>::PeHeader32_64 PeHeader32_64;
161 161
162 private: 162 private:
163 PeHeader32_64 m_peh; ///< PE header of the current file. 163 PeHeader32_64 m_peh; ///< PE header of the current file.
164 ImportDirectory<bits> m_impdir; ///< Import directory of the current file. 164 ImportDirectory<bits> m_impdir; ///< Import directory of the current file.
165 TlsDirectory<bits> m_tlsdir; 165 TlsDirectory<bits> m_tlsdir;
166 166
167 public: 167 public:
168 /// Default constructor which exists only for the sake of allowing to construct files without filenames. 168 /// Default constructor which exists only for the sake of allowing to construct files without filenames.
169 PeFileT(); 169 PeFileT();
170 170
171 virtual ~PeFileT() {} 171 virtual ~PeFileT() {}
172 172
173 /// Initializes a PeFile with a filename 173 /// Initializes a PeFile with a filename
174 explicit PeFileT(const std::string& strFilename); 174 explicit PeFileT(const std::string& strFilename);
175 175
176 /// Returns the name of the current file. 176 /// Returns the name of the current file.
177 std::string getFileName() const; 177 std::string getFileName() const;
178 /// Changes the name of the current file. 178 /// Changes the name of the current file.
179 void setFileName(std::string strFilename); 179 void setFileName(std::string strFilename);
180 180
181 /// Reads the MZ header of the current file from disc. 181 /// Reads the MZ header of the current file from disc.
182 int readMzHeader() ; 182 int readMzHeader() ;
183 /// Reads the export directory of the current file from disc. 183 /// Reads the export directory of the current file from disc.
184 int readExportDirectory() ; 184 int readExportDirectory() ;
185 /// Reads the PE header of the current file from disc. 185 /// Reads the PE header of the current file from disc.
186 int readPeHeader() ; 186 int readPeHeader() ;
187 /// Reads the import directory of the current file from disc. 187 /// Reads the import directory of the current file from disc.
188 int readImportDirectory() ; 188 int readImportDirectory() ;
189 /// Reads the bound import directory of the current file from disc. 189 /// Reads the bound import directory of the current file from disc.
190 int readBoundImportDirectory() ; 190 int readBoundImportDirectory() ;
191 /// Reads the resource directory of the current file from disc. 191 /// Reads the resource directory of the current file from disc.
192 int readResourceDirectory() ; 192 int readResourceDirectory() ;
193 /// Reads the relocations directory of the current file from disc. 193 /// Reads the relocations directory of the current file from disc.
194 int readRelocationsDirectory() ; 194 int readRelocationsDirectory() ;
195 /// Reads the COM+ descriptor directory of the current file from disc. 195 /// Reads the COM+ descriptor directory of the current file from disc.
196 int readComHeaderDirectory() ; 196 int readComHeaderDirectory() ;
197 /// Reads the IAT directory of the current file from disc. 197 /// Reads the IAT directory of the current file from disc.
198 int readIatDirectory() ; 198 int readIatDirectory() ;
199 /// Reads the Debug directory of the current file. 199 /// Reads the Debug directory of the current file.
200 int readDebugDirectory() ; 200 int readDebugDirectory() ;
201 int readTlsDirectory() ; 201 int readTlsDirectory() ;
202 202
203 unsigned int getBits() const 203 unsigned int getBits() const
204 { 204 {
205 return bits; 205 return bits;
206 } 206 }
207 207
208 /// Accessor function for the PE header. 208 /// Accessor function for the PE header.
209 const PeHeader32_64& peHeader() const; 209 const PeHeader32_64& peHeader() const;
210 /// Accessor function for the PE header. 210 /// Accessor function for the PE header.
211 PeHeader32_64& peHeader(); 211 PeHeader32_64& peHeader();
212 212
213 /// Accessor function for the import directory. 213 /// Accessor function for the import directory.
214 const ImportDirectory<bits>& impDir() const; 214 const ImportDirectory<bits>& impDir() const;
215 /// Accessor function for the import directory. 215 /// Accessor function for the import directory.
216 ImportDirectory<bits>& impDir(); 216 ImportDirectory<bits>& impDir();
217 217
218 const TlsDirectory<bits>& tlsDir() const; 218 const TlsDirectory<bits>& tlsDir() const;
219 TlsDirectory<bits>& tlsDir(); 219 TlsDirectory<bits>& tlsDir();
220 }; 220 };
221 221
222 /** 222 /**
223 * This class is the main class for handling PE files. 223 * This class is the main class for handling PE files.
224 **/ 224 **/
225 class PeFile32 : public PeFileT<32> 225 class PeFile32 : public PeFileT<32>
226 { 226 {
227 public: 227 public:
228 /// Default constructor which exists only for the sake of allowing to construct files without filenames. 228 /// Default constructor which exists only for the sake of allowing to construct files without filenames.
229 PeFile32(); 229 PeFile32();
230 230
231 /// Initializes a PeFile with a filename 231 /// Initializes a PeFile with a filename
232 explicit PeFile32(const std::string& strFlename); 232 explicit PeFile32(const std::string& strFlename);
233 virtual void visit(PeFileVisitor &v) { v.callback( *this ); } 233 virtual void visit(PeFileVisitor &v) { v.callback( *this ); }
234 }; 234 };
235 235
236 /** 236 /**
237 * This class is the main class for handling PE+ files. 237 * This class is the main class for handling PE+ files.
238 **/ 238 **/
239 class PeFile64 : public PeFileT<64> 239 class PeFile64 : public PeFileT<64>
240 { 240 {
241 public: 241 public:
242 /// Default constructor which exists only for the sake of allowing to construct files without filenames. 242 /// Default constructor which exists only for the sake of allowing to construct files without filenames.
243 PeFile64(); 243 PeFile64();
244 244
245 /// Initializes a PeFile with a filename 245 /// Initializes a PeFile with a filename
246 explicit PeFile64(const std::string& strFlename); 246 explicit PeFile64(const std::string& strFlename);
247 virtual void visit(PeFileVisitor &v) { v.callback( *this ); } 247 virtual void visit(PeFileVisitor &v) { v.callback( *this ); }
248 }; 248 };
249 249
250 //typedef PeFileT<32> PeFile32; 250 //typedef PeFileT<32> PeFile32;
251 //typedef PeFileT<64> PeFile64; 251 //typedef PeFileT<64> PeFile64;
252 252
253 /** 253 /**
254 * @param strFilename Name of the current file. 254 * @param strFilename Name of the current file.
255 **/ 255 **/
256 template<int bits> 256 template<int bits>
257 PeFileT<bits>::PeFileT(const std::string& strFilename) 257 PeFileT<bits>::PeFileT(const std::string& strFilename)
258 { 258 {
259 m_filename = strFilename; 259 m_filename = strFilename;
260 } 260 }
261 261
262 template<int bits> 262 template<int bits>
263 PeFileT<bits>::PeFileT() 263 PeFileT<bits>::PeFileT()
264 { 264 {
265 } 265 }
266 266
267 template<int bits> 267 template<int bits>
268 int PeFileT<bits>::readPeHeader() 268 int PeFileT<bits>::readPeHeader()
269 { 269 {
270 return peHeader().read(getFileName(), mzHeader().getAddressOfPeHeader()); 270 return peHeader().read(getFileName(), mzHeader().getAddressOfPeHeader());
271 } 271 }
272 272
273 273
274 template<int bits> 274 template<int bits>
275 int PeFileT<bits>::readImportDirectory() 275 int PeFileT<bits>::readImportDirectory()
276 { 276 {
277 if (peHeader().calcNumberOfRvaAndSizes() >= 2 277 if (peHeader().calcNumberOfRvaAndSizes() >= 2
278 && peHeader().getIddImportRva() 278 && peHeader().getIddImportRva()
279 && peHeader().getIddImportSize()) 279 && peHeader().getIddImportSize())
280 { 280 {
281 return impDir().read(getFileName(), static_cast<unsigned int>(peHeader().rvaToOffset(peHeader().getIddImportRva())), peHeader().getIddImportSize(), peHeader()); 281 return impDir().read(getFileName(), static_cast<unsigned int>(peHeader().rvaToOffset(peHeader().getIddImportRva())), peHeader().getIddImportSize(), peHeader());
282 } 282 }
283 return ERROR_DIRECTORY_DOES_NOT_EXIST; 283 return ERROR_DIRECTORY_DOES_NOT_EXIST;
284 } 284 }
285 285
286 /** 286 /**
287 * @return A reference to the file's PE header. 287 * @return A reference to the file's PE header.
288 **/ 288 **/
289 template<int bits> 289 template<int bits>
290 const typename PeFile_Traits<bits>::PeHeader32_64& PeFileT<bits>::peHeader() const 290 const typename PeFile_Traits<bits>::PeHeader32_64& PeFileT<bits>::peHeader() const
291 { 291 {
292 return m_peh; 292 return m_peh;
293 } 293 }
294 294
295 /** 295 /**
296 * @return A reference to the file's PE header. 296 * @return A reference to the file's PE header.
297 **/ 297 **/
298 template<int bits> 298 template<int bits>
299 typename PeFile_Traits<bits>::PeHeader32_64& PeFileT<bits>::peHeader() 299 typename PeFile_Traits<bits>::PeHeader32_64& PeFileT<bits>::peHeader()
300 { 300 {
301 return m_peh; 301 return m_peh;
302 } 302 }
303 303
304 /** 304 /**
305 * @return A reference to the file's import directory. 305 * @return A reference to the file's import directory.
306 **/ 306 **/
307 template<int bits> 307 template<int bits>
308 const ImportDirectory<bits>& PeFileT<bits>::impDir() const 308 const ImportDirectory<bits>& PeFileT<bits>::impDir() const
309 { 309 {
310 return m_impdir; 310 return m_impdir;
311 } 311 }
312 312
313 /** 313 /**
314 * @return A reference to the file's import directory. 314 * @return A reference to the file's import directory.
315 **/ 315 **/
316 template<int bits> 316 template<int bits>
317 ImportDirectory<bits>& PeFileT<bits>::impDir() 317 ImportDirectory<bits>& PeFileT<bits>::impDir()
318 { 318 {
319 return m_impdir; 319 return m_impdir;
320 } 320 }
321 321
322 template<int bits> 322 template<int bits>
323 const TlsDirectory<bits>& PeFileT<bits>::tlsDir() const 323 const TlsDirectory<bits>& PeFileT<bits>::tlsDir() const
324 { 324 {
325 return m_tlsdir; 325 return m_tlsdir;
326 } 326 }
327 327
328 template<int bits> 328 template<int bits>
329 TlsDirectory<bits>& PeFileT<bits>::tlsDir() 329 TlsDirectory<bits>& PeFileT<bits>::tlsDir()
330 { 330 {
331 return m_tlsdir; 331 return m_tlsdir;
332 } 332 }
333 333
334 /** 334 /**
335 * @return Filename of the current file. 335 * @return Filename of the current file.
336 **/ 336 **/
337 template<int bits> 337 template<int bits>
338 std::string PeFileT<bits>::getFileName() const 338 std::string PeFileT<bits>::getFileName() const
339 { 339 {
340 return m_filename; 340 return m_filename;
341 } 341 }
342 342
343 /** 343 /**
344 * @param strFilename New filename. 344 * @param strFilename New filename.
345 **/ 345 **/
346 template<int bits> 346 template<int bits>
347 void PeFileT<bits>::setFileName(std::string strFilename) 347 void PeFileT<bits>::setFileName(std::string strFilename)
348 { 348 {
349 m_filename = strFilename; 349 m_filename = strFilename;
350 } 350 }
351 351
352 template<int bits> 352 template<int bits>
353 int PeFileT<bits>::readMzHeader() 353 int PeFileT<bits>::readMzHeader()
354 { 354 {
355 return mzHeader().read(getFileName()); 355 return mzHeader().read(getFileName());
356 } 356 }
357 357
358 template<int bits> 358 template<int bits>
359 int PeFileT<bits>::readExportDirectory() 359 int PeFileT<bits>::readExportDirectory()
360 { 360 {
361 if (peHeader().calcNumberOfRvaAndSizes() >= 1 361 if (peHeader().calcNumberOfRvaAndSizes() >= 1
362 && peHeader().getIddExportRva() && peHeader().getIddExportSize()) 362 && peHeader().getIddExportRva() && peHeader().getIddExportSize())
363 { 363 {
364 return expDir().read(getFileName(), static_cast<unsigned int>(peHeader().rvaToOffset(peHeader().getIddExportRva())), peHeader().getIddExportSize(), peHeader()); 364 return expDir().read(getFileName(), static_cast<unsigned int>(peHeader().rvaToOffset(peHeader().getIddExportRva())), peHeader().getIddExportSize(), peHeader());
365 } 365 }
366 return ERROR_DIRECTORY_DOES_NOT_EXIST; 366 return ERROR_DIRECTORY_DOES_NOT_EXIST;
367 } 367 }
368 368
369 369
370 template<int bits> 370 template<int bits>
371 int PeFileT<bits>::readBoundImportDirectory() 371 int PeFileT<bits>::readBoundImportDirectory()
372 { 372 {
373 if (peHeader().calcNumberOfRvaAndSizes() >= 12 373 if (peHeader().calcNumberOfRvaAndSizes() >= 12
374 && peHeader().getIddBoundImportRva() && peHeader().getIddBoundImportSize()) 374 && peHeader().getIddBoundImportRva() && peHeader().getIddBoundImportSize())
375 { 375 {
376 return boundImpDir().read(getFileName(), static_cast<unsigned int>(peHeader().rvaToOffset(peHeader().getIddBoundImportRva())), peHeader().getIddBoundImportSize()); 376 return boundImpDir().read(getFileName(), static_cast<unsigned int>(peHeader().rvaToOffset(peHeader().getIddBoundImportRva())), peHeader().getIddBoundImportSize());
377 } 377 }
378 return ERROR_DIRECTORY_DOES_NOT_EXIST; 378 return ERROR_DIRECTORY_DOES_NOT_EXIST;
379 } 379 }
380 380
381 template<int bits> 381 template<int bits>
382 int PeFileT<bits>::readResourceDirectory() 382 int PeFileT<bits>::readResourceDirectory()
383 { 383 {
384 if (peHeader().calcNumberOfRvaAndSizes() >= 3 384 if (peHeader().calcNumberOfRvaAndSizes() >= 3
385 && peHeader().getIddResourceRva() && peHeader().getIddResourceSize()) 385 && peHeader().getIddResourceRva() && peHeader().getIddResourceSize())
386 { 386 {
387 return resDir().read(getFileName(), static_cast<unsigned int>(peHeader().rvaToOffset(peHeader().getIddResourceRva())), peHeader().getIddResourceSize(), peHeader().getIddResourceRva()); 387 return resDir().read(getFileName(), static_cast<unsigned int>(peHeader().rvaToOffset(peHeader().getIddResourceRva())), peHeader().getIddResourceSize(), peHeader().getIddResourceRva());
388 } 388 }
389 return ERROR_DIRECTORY_DOES_NOT_EXIST; 389 return ERROR_DIRECTORY_DOES_NOT_EXIST;
390 } 390 }
391 391
392 template<int bits> 392 template<int bits>
393 int PeFileT<bits>::readRelocationsDirectory() 393 int PeFileT<bits>::readRelocationsDirectory()
394 { 394 {
395 if (peHeader().calcNumberOfRvaAndSizes() >= 6 395 if (peHeader().calcNumberOfRvaAndSizes() >= 6
396 && peHeader().getIddBaseRelocRva() && peHeader().getIddBaseRelocSize()) 396 && peHeader().getIddBaseRelocRva() && peHeader().getIddBaseRelocSize())
397 { 397 {
398 return relocDir().read(getFileName(), static_cast<unsigned int>(peHeader().rvaToOffset(peHeader().getIddBaseRelocRva())), peHeader().getIddBaseRelocSize()); 398 return relocDir().read(getFileName(), static_cast<unsigned int>(peHeader().rvaToOffset(peHeader().getIddBaseRelocRva())), peHeader().getIddBaseRelocSize());
399 } 399 }
400 return ERROR_DIRECTORY_DOES_NOT_EXIST; 400 return ERROR_DIRECTORY_DOES_NOT_EXIST;
401 } 401 }
402 402
403 template<int bits> 403 template<int bits>
404 int PeFileT<bits>::readComHeaderDirectory() 404 int PeFileT<bits>::readComHeaderDirectory()
405 { 405 {
406 if (peHeader().calcNumberOfRvaAndSizes() >= 15 406 if (peHeader().calcNumberOfRvaAndSizes() >= 15
407 && peHeader().getIddComHeaderRva() && peHeader().getIddComHeaderSize()) 407 && peHeader().getIddComHeaderRva() && peHeader().getIddComHeaderSize())
408 { 408 {
409 return comDir().read(getFileName(), static_cast<unsigned int>(peHeader().rvaToOffset(peHeader().getIddComHeaderRva())), peHeader().getIddComHeaderSize()); 409 return comDir().read(getFileName(), static_cast<unsigned int>(peHeader().rvaToOffset(peHeader().getIddComHeaderRva())), peHeader().getIddComHeaderSize());
410 } 410 }
411 std::cout << peHeader().getIddComHeaderRva() << std::endl; 411 std::cout << peHeader().getIddComHeaderRva() << std::endl;
412 std::exit(0); 412 std::exit(0);
413 return ERROR_DIRECTORY_DOES_NOT_EXIST; 413 return ERROR_DIRECTORY_DOES_NOT_EXIST;
414 } 414 }
415 415
416 template<int bits> 416 template<int bits>
417 int PeFileT<bits>::readIatDirectory() 417 int PeFileT<bits>::readIatDirectory()
418 { 418 {
419 if (peHeader().calcNumberOfRvaAndSizes() >= 13 419 if (peHeader().calcNumberOfRvaAndSizes() >= 13
420 && peHeader().getIddIatRva() && peHeader().getIddIatSize()) 420 && peHeader().getIddIatRva() && peHeader().getIddIatSize())
421 { 421 {
422 return iatDir().read(getFileName(), static_cast<unsigned int>(peHeader().rvaToOffset(peHeader().getIddIatRva())), peHeader().getIddIatSize()); 422 return iatDir().read(getFileName(), static_cast<unsigned int>(peHeader().rvaToOffset(peHeader().getIddIatRva())), peHeader().getIddIatSize());
423 } 423 }
424 return ERROR_DIRECTORY_DOES_NOT_EXIST; 424 return ERROR_DIRECTORY_DOES_NOT_EXIST;
425 } 425 }
426 426
427 template<int bits> 427 template<int bits>
428 int PeFileT<bits>::readDebugDirectory() 428 int PeFileT<bits>::readDebugDirectory()
429 { 429 {
430 if (peHeader().calcNumberOfRvaAndSizes() >= 7 430 if (peHeader().calcNumberOfRvaAndSizes() >= 7
431 && peHeader().getIddDebugRva() && peHeader().getIddDebugSize()) 431 && peHeader().getIddDebugRva() && peHeader().getIddDebugSize())
432 { 432 {
433 return debugDir().read(getFileName(), static_cast<unsigned int>(peHeader().rvaToOffset(peHeader().getIddDebugRva())), peHeader().getIddDebugSize()); 433 return debugDir().read(getFileName(), static_cast<unsigned int>(peHeader().rvaToOffset(peHeader().getIddDebugRva())), peHeader().getIddDebugSize());
434 } 434 }
435 return ERROR_DIRECTORY_DOES_NOT_EXIST; 435 return ERROR_DIRECTORY_DOES_NOT_EXIST;
436 } 436 }
437 437
438 template<int bits> 438 template<int bits>
439 int PeFileT<bits>::readTlsDirectory() 439 int PeFileT<bits>::readTlsDirectory()
440 { 440 {
441 if (peHeader().calcNumberOfRvaAndSizes() >= 10 441 if (peHeader().calcNumberOfRvaAndSizes() >= 10
442 && peHeader().getIddTlsRva() && peHeader().getIddTlsSize()) 442 && peHeader().getIddTlsRva() && peHeader().getIddTlsSize())
443 { 443 {
444 return tlsDir().read(getFileName(), static_cast<unsigned int>(peHeader().rvaToOffset(peHeader().getIddTlsRva())), peHeader().getIddTlsSize()); 444 return tlsDir().read(getFileName(), static_cast<unsigned int>(peHeader().rvaToOffset(peHeader().getIddTlsRva())), peHeader().getIddTlsSize());
445 } 445 }
446 return ERROR_DIRECTORY_DOES_NOT_EXIST; 446 return ERROR_DIRECTORY_DOES_NOT_EXIST;
447 } 447 }
448 448
449} 449}
450 450
451#endif 451#endif