diff options
author | Maurus Cuelenaere <mcuelenaere@gmail.com> | 2008-07-11 15:50:46 +0000 |
---|---|---|
committer | Maurus Cuelenaere <mcuelenaere@gmail.com> | 2008-07-11 15:50:46 +0000 |
commit | 14c7f45cdae826f88dc539c8c38dd95caf305731 (patch) | |
tree | 832da054b7cfb2dc6fd63339af736625f31d21aa /utils/zenutils/libraries/pelib-0.9/pelib/MzHeader.h | |
parent | 7c84ede3781c27db73403bd6302f320c76a58c8c (diff) | |
download | rockbox-14c7f45cdae826f88dc539c8c38dd95caf305731.tar.gz rockbox-14c7f45cdae826f88dc539c8c38dd95caf305731.zip |
Add zook's ZenUtils to SVN
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18010 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'utils/zenutils/libraries/pelib-0.9/pelib/MzHeader.h')
-rwxr-xr-x | utils/zenutils/libraries/pelib-0.9/pelib/MzHeader.h | 148 |
1 files changed, 148 insertions, 0 deletions
diff --git a/utils/zenutils/libraries/pelib-0.9/pelib/MzHeader.h b/utils/zenutils/libraries/pelib-0.9/pelib/MzHeader.h new file mode 100755 index 0000000000..5aca6bfe59 --- /dev/null +++ b/utils/zenutils/libraries/pelib-0.9/pelib/MzHeader.h | |||
@@ -0,0 +1,148 @@ | |||
1 | /* | ||
2 | * MzHeader.h - Part of the PeLib library. | ||
3 | * | ||
4 | * Copyright (c) 2004 - 2005 Sebastian Porst (webmaster@the-interweb.com) | ||
5 | * All rights reserved. | ||
6 | * | ||
7 | * This software is licensed under the zlib/libpng License. | ||
8 | * For more details see http://www.opensource.org/licenses/zlib-license.php | ||
9 | * or the license information file (license.htm) in the root directory | ||
10 | * of PeLib. | ||
11 | */ | ||
12 | |||
13 | #ifndef MZHEADER_H | ||
14 | #define MZHEADER_H | ||
15 | |||
16 | #include "PeLibInc.h" | ||
17 | |||
18 | namespace PeLib | ||
19 | { | ||
20 | /// Class that handles the MZ header of files. | ||
21 | /** | ||
22 | * This class can read and modify MZ headers. It provides set- and get functions to access | ||
23 | * all individual members of a MZ header. Furthermore it's possible to validate and rebuild | ||
24 | * MZ headers. | ||
25 | **/ | ||
26 | class MzHeader | ||
27 | { | ||
28 | private: | ||
29 | PELIB_IMAGE_DOS_HEADER m_idhHeader; ///< Stores all MZ header information. | ||
30 | |||
31 | /// Reads data from an InputBuffer into a MZ header struct. | ||
32 | void read(InputBuffer& ibBuffer); | ||
33 | |||
34 | /// Offset of the MZ header in the original file. | ||
35 | unsigned int originalOffset; | ||
36 | |||
37 | public: | ||
38 | |||
39 | enum Field {e_magic, e_cblp, e_cp, e_crlc, e_cparhdr, e_minalloc, e_maxalloc, | ||
40 | e_ss, e_sp, e_csum, e_ip, e_cs, e_lfarlc, e_ovno, e_res, e_oemid, | ||
41 | e_oeminfo, e_res2, e_lfanew}; | ||
42 | |||
43 | /// Checks if the current MZ header is valid. | ||
44 | bool isValid() const; // EXPORT | ||
45 | |||
46 | bool isValid(Field field) const; // EXPORT _field | ||
47 | |||
48 | /// Corrects the current MZ header. | ||
49 | void makeValid(); // EXPORT | ||
50 | |||
51 | void makeValid(Field field); // EXPORT _field | ||
52 | |||
53 | /// Reads the MZ header of a file. | ||
54 | int read(const std::string& strFilename); // EXPORT | ||
55 | |||
56 | /// Reads the MZ header from a memory location. | ||
57 | int read(unsigned char* pcBuffer, unsigned int uiSize, unsigned int originalOffs = 0); // EXPORT _fromMemory | ||
58 | |||
59 | /// Rebuild the MZ header. | ||
60 | void rebuild(std::vector<byte>& vBuffer) const; // EXPORT | ||
61 | |||
62 | /// Returns the size of the current MZ header. | ||
63 | unsigned int size() const; // EXPORT | ||
64 | |||
65 | /// Writes the current MZ header to offset 0 of a file. | ||
66 | int write(const std::string& strFilename, dword dwOffset) const; // EXPORT | ||
67 | |||
68 | /// Gets the e_magic value of the MZ header. | ||
69 | word getMagicNumber() const; // EXPORT | ||
70 | /// Gets the e_cblp value of the MZ header. | ||
71 | word getBytesOnLastPage() const; // EXPORT | ||
72 | /// Gets the e_cp value of the MZ header. | ||
73 | word getPagesInFile() const; // EXPORT | ||
74 | /// Gets the e_crlc value of the MZ header. | ||
75 | word getRelocations() const; // EXPORT | ||
76 | /// Gets the e_cparhdr value of the MZ header. | ||
77 | word getSizeOfHeader() const; // EXPORT | ||
78 | /// Gets the e_minalloc value of the MZ header. | ||
79 | word getMinExtraParagraphs() const; // EXPORT | ||
80 | /// Gets the e_maxalloc value of the MZ header. | ||
81 | word getMaxExtraParagraphs() const; // EXPORT | ||
82 | /// Gets the e_ss value of the MZ header. | ||
83 | word getSsValue() const; // EXPORT | ||
84 | /// Gets the e_sp value of the MZ header. | ||
85 | word getSpValue() const; // EXPORT | ||
86 | /// Gets the e_csum value of the MZ header. | ||
87 | word getChecksum() const; // EXPORT | ||
88 | /// Gets the e_ip value of the MZ header. | ||
89 | word getIpValue() const; // EXPORT | ||
90 | /// Gets the e_cs value of the MZ header. | ||
91 | word getCsValue() const; // EXPORT | ||
92 | /// Gets the e_lfarlc value of the MZ header. | ||
93 | word getAddrOfRelocationTable() const; // EXPORT | ||
94 | /// Gets the e_ovnovalue of the MZ header. | ||
95 | word getOverlayNumber() const; // EXPORT | ||
96 | /// Gets the e_oemid value of the MZ header. | ||
97 | word getOemIdentifier() const; // EXPORT | ||
98 | /// Gets the e_oeminfo value of the MZ header. | ||
99 | word getOemInformation() const; // EXPORT | ||
100 | /// Gets the e_lfanew value of the MZ header. | ||
101 | dword getAddressOfPeHeader() const; // EXPORT | ||
102 | /// Gets the e_res of the MZ header. | ||
103 | word getReservedWords1(unsigned int uiNr) const; // EXPORT | ||
104 | /// Gets the e_res2 of the MZ header. | ||
105 | word getReservedWords2(unsigned int uiNr) const; // EXPORT | ||
106 | |||
107 | /// Sets the e_magic value of the MZ header. | ||
108 | void setMagicNumber(word wValue); // EXPORT | ||
109 | /// Sets the e_cblp value of the MZ header. | ||
110 | void setBytesOnLastPage(word wValue); // EXPORT | ||
111 | /// Sets the e_cp value of the MZ header. | ||
112 | void setPagesInFile(word wValue); // EXPORT | ||
113 | /// Sets the e_crlc value of the MZ header. | ||
114 | void setRelocations(word wValue); // EXPORT | ||
115 | /// Sets the e_cparhdr value of the MZ header. | ||
116 | void setSizeOfHeader(word wValue); // EXPORT | ||
117 | /// Sets the e_minalloc value of the MZ header. | ||
118 | void setMinExtraParagraphs(word wValue); // EXPORT | ||
119 | /// Sets the e_maxalloc value of the MZ header. | ||
120 | void setMaxExtraParagraphs(word wValue); // EXPORT | ||
121 | /// Sets the e_ss value of the MZ header. | ||
122 | void setSsValue(word wValue); // EXPORT | ||
123 | /// Sets the e_sp value of the MZ header. | ||
124 | void setSpValue(word wValue); // EXPORT | ||
125 | /// Sets the e_csum value of the MZ header. | ||
126 | void setChecksum(word wValue); // EXPORT | ||
127 | /// Sets the e_ip value of the MZ header. | ||
128 | void setIpValue(word wValue); // EXPORT | ||
129 | /// Sets the e_cs value of the MZ header. | ||
130 | void setCsValue(word wValue); // EXPORT | ||
131 | /// Sets the e_lfarlc value of the MZ header. | ||
132 | void setAddrOfRelocationTable(word wValue); // EXPORT | ||
133 | /// Sets the e_ovno value of the MZ header. | ||
134 | void setOverlayNumber(word wValue); // EXPORT | ||
135 | /// Sets the e_oemid value of the MZ header. | ||
136 | void setOemIdentifier(word wValue); // EXPORT | ||
137 | /// Sets the e_oeminfo value of the MZ header. | ||
138 | void setOemInformation(word wValue); // EXPORT | ||
139 | /// Sets the e_lfanew value of the MZ header. | ||
140 | void setAddressOfPeHeader(dword dwValue); // EXPORT | ||
141 | /// Sets the e_res value of the MZ header. | ||
142 | void setReservedWords1(unsigned int uiNr, word wValue); // EXPORT | ||
143 | /// Sets the e_res2 value of the MZ header. | ||
144 | void setReservedWords2(unsigned int uiNr, word wValue); // EXPORT | ||
145 | }; | ||
146 | } | ||
147 | |||
148 | #endif | ||