summaryrefslogtreecommitdiff
path: root/utils/zenutils/libraries/pelib-0.9/pelib/MzHeader.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'utils/zenutils/libraries/pelib-0.9/pelib/MzHeader.cpp')
-rw-r--r--[-rwxr-xr-x]utils/zenutils/libraries/pelib-0.9/pelib/MzHeader.cpp1168
1 files changed, 584 insertions, 584 deletions
diff --git a/utils/zenutils/libraries/pelib-0.9/pelib/MzHeader.cpp b/utils/zenutils/libraries/pelib-0.9/pelib/MzHeader.cpp
index 39fe54d80d..3a2119b7ac 100755..100644
--- a/utils/zenutils/libraries/pelib-0.9/pelib/MzHeader.cpp
+++ b/utils/zenutils/libraries/pelib-0.9/pelib/MzHeader.cpp
@@ -1,584 +1,584 @@
1/* 1/*
2* MzHeader.cpp - Part of the PeLib library. 2* MzHeader.cpp - 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#include "MzHeader.h" 13#include "MzHeader.h"
14#include <iostream> 14#include <iostream>
15 15
16namespace PeLib 16namespace PeLib
17{ 17{
18 /** 18 /**
19 * Reads data from an InputBuffer into the struct that represents the MZ header. 19 * Reads data from an InputBuffer into the struct that represents the MZ header.
20 * It's required that the size of the input buffer is at least as big as the 20 * It's required that the size of the input buffer is at least as big as the
21 * size of a MZ header. Otherwise we get undefined behaviour. 21 * size of a MZ header. Otherwise we get undefined behaviour.
22 * @param ibBuffer InputBuffer that holds the data. 22 * @param ibBuffer InputBuffer that holds the data.
23 * @return A non-zero value is returned if a problem occured. 23 * @return A non-zero value is returned if a problem occured.
24 **/ 24 **/
25 void MzHeader::read(InputBuffer& ibBuffer) 25 void MzHeader::read(InputBuffer& ibBuffer)
26 { 26 {
27 ibBuffer >> m_idhHeader.e_magic; 27 ibBuffer >> m_idhHeader.e_magic;
28 ibBuffer >> m_idhHeader.e_cblp; 28 ibBuffer >> m_idhHeader.e_cblp;
29 ibBuffer >> m_idhHeader.e_cp; 29 ibBuffer >> m_idhHeader.e_cp;
30 ibBuffer >> m_idhHeader.e_crlc; 30 ibBuffer >> m_idhHeader.e_crlc;
31 ibBuffer >> m_idhHeader.e_cparhdr; 31 ibBuffer >> m_idhHeader.e_cparhdr;
32 ibBuffer >> m_idhHeader.e_minalloc; 32 ibBuffer >> m_idhHeader.e_minalloc;
33 ibBuffer >> m_idhHeader.e_maxalloc; 33 ibBuffer >> m_idhHeader.e_maxalloc;
34 ibBuffer >> m_idhHeader.e_ss; 34 ibBuffer >> m_idhHeader.e_ss;
35 ibBuffer >> m_idhHeader.e_sp; 35 ibBuffer >> m_idhHeader.e_sp;
36 ibBuffer >> m_idhHeader.e_csum; 36 ibBuffer >> m_idhHeader.e_csum;
37 ibBuffer >> m_idhHeader.e_ip; 37 ibBuffer >> m_idhHeader.e_ip;
38 ibBuffer >> m_idhHeader.e_cs; 38 ibBuffer >> m_idhHeader.e_cs;
39 ibBuffer >> m_idhHeader.e_lfarlc; 39 ibBuffer >> m_idhHeader.e_lfarlc;
40 ibBuffer >> m_idhHeader.e_ovno; 40 ibBuffer >> m_idhHeader.e_ovno;
41 41
42 for (unsigned int i=0;i<sizeof(m_idhHeader.e_res)/sizeof(m_idhHeader.e_res[0]);i++) 42 for (unsigned int i=0;i<sizeof(m_idhHeader.e_res)/sizeof(m_idhHeader.e_res[0]);i++)
43 { 43 {
44 ibBuffer >> m_idhHeader.e_res[i]; 44 ibBuffer >> m_idhHeader.e_res[i];
45 } 45 }
46 46
47 ibBuffer >> m_idhHeader.e_oemid; 47 ibBuffer >> m_idhHeader.e_oemid;
48 ibBuffer >> m_idhHeader.e_oeminfo; 48 ibBuffer >> m_idhHeader.e_oeminfo;
49 49
50 for (unsigned int i=0;i<sizeof(m_idhHeader.e_res2)/sizeof(m_idhHeader.e_res2[0]);i++) 50 for (unsigned int i=0;i<sizeof(m_idhHeader.e_res2)/sizeof(m_idhHeader.e_res2[0]);i++)
51 { 51 {
52 ibBuffer >> m_idhHeader.e_res2[i]; 52 ibBuffer >> m_idhHeader.e_res2[i];
53 } 53 }
54 54
55 ibBuffer >> m_idhHeader.e_lfanew; 55 ibBuffer >> m_idhHeader.e_lfanew;
56 } 56 }
57 57
58 /** 58 /**
59 * Tests if the currently loaded MZ header is a valid MZ header. 59 * Tests if the currently loaded MZ header is a valid MZ header.
60 * Note that this function does not check if the address to the PE header is valid as this is not possible. 60 * Note that this function does not check if the address to the PE header is valid as this is not possible.
61 * Actually, the only thing this function checks is if the e_magic value is set to 0x5A4D (IMAGE_DOS_SIGNATURE). 61 * Actually, the only thing this function checks is if the e_magic value is set to 0x5A4D (IMAGE_DOS_SIGNATURE).
62 * Everything else is not relevant for Windows 2000 and that's the system PeLib is focusing on for now. 62 * Everything else is not relevant for Windows 2000 and that's the system PeLib is focusing on for now.
63 * @return A boolean value that indicates if the MZ header is correct or not. 63 * @return A boolean value that indicates if the MZ header is correct or not.
64 **/ 64 **/
65 bool MzHeader::isValid() const 65 bool MzHeader::isValid() const
66 { 66 {
67 // The only thing that matters on Windows 2K is the e_magic value. The entire rest is for DOS compatibility. 67 // The only thing that matters on Windows 2K is the e_magic value. The entire rest is for DOS compatibility.
68 return isValid(e_magic); 68 return isValid(e_magic);
69 } 69 }
70 70
71 bool MzHeader::isValid(Field f) const 71 bool MzHeader::isValid(Field f) const
72 { 72 {
73 if (f == e_magic) 73 if (f == e_magic)
74 { 74 {
75 return m_idhHeader.e_magic == PELIB_IMAGE_DOS_SIGNATURE; 75 return m_idhHeader.e_magic == PELIB_IMAGE_DOS_SIGNATURE;
76 } 76 }
77 else 77 else
78 { 78 {
79 return true; 79 return true;
80 } 80 }
81 } 81 }
82 82
83 /** 83 /**
84 * Corrects all erroneous values of the current MZ header. Note that this function does not correct the 84 * Corrects all erroneous values of the current MZ header. Note that this function does not correct the
85 * pointer to the PE header. 85 * pointer to the PE header.
86 * Actually, the only thing this function corrects is the e_magic value. 86 * Actually, the only thing this function corrects is the e_magic value.
87 * Everything else is not relevant for Windows 2000 and that's the system PeLib is focusing on for now. 87 * Everything else is not relevant for Windows 2000 and that's the system PeLib is focusing on for now.
88 **/ 88 **/
89 void MzHeader::makeValid() 89 void MzHeader::makeValid()
90 { 90 {
91 // The only thing that matters on Windows is the e_magic value. The entire rest is for DOS compatibility. 91 // The only thing that matters on Windows is the e_magic value. The entire rest is for DOS compatibility.
92 setMagicNumber(PELIB_IMAGE_DOS_SIGNATURE); 92 setMagicNumber(PELIB_IMAGE_DOS_SIGNATURE);
93 } 93 }
94 94
95 void MzHeader::makeValid(Field f) 95 void MzHeader::makeValid(Field f)
96 { 96 {
97 if (f == e_magic) 97 if (f == e_magic)
98 { 98 {
99 setMagicNumber(PELIB_IMAGE_DOS_SIGNATURE); 99 setMagicNumber(PELIB_IMAGE_DOS_SIGNATURE);
100 } 100 }
101 } 101 }
102 102
103 /** 103 /**
104 * Reads the MZ header from a file. Note that this function does not verify if a file is actually a MZ file. 104 * Reads the MZ header from a file. Note that this function does not verify if a file is actually a MZ file.
105 * For this purpose see #PeFile::MzHeader::isValid. The reason for this is simple: Otherwise it might not 105 * For this purpose see #PeFile::MzHeader::isValid. The reason for this is simple: Otherwise it might not
106 * be possible to load damaged PE files to repair them. 106 * be possible to load damaged PE files to repair them.
107 * @param strFilename Name of the file which will be read. 107 * @param strFilename Name of the file which will be read.
108 * @return A non-zero value is returned if a problem occured. 108 * @return A non-zero value is returned if a problem occured.
109 **/ 109 **/
110 int MzHeader::read(const std::string& strFilename) 110 int MzHeader::read(const std::string& strFilename)
111 { 111 {
112 std::ifstream ifFile(strFilename.c_str(), std::ios::binary); 112 std::ifstream ifFile(strFilename.c_str(), std::ios::binary);
113 113
114 if (!ifFile) 114 if (!ifFile)
115 { 115 {
116 return ERROR_OPENING_FILE; 116 return ERROR_OPENING_FILE;
117 } 117 }
118 118
119 if (fileSize(ifFile) < PELIB_IMAGE_DOS_HEADER::size()) 119 if (fileSize(ifFile) < PELIB_IMAGE_DOS_HEADER::size())
120 { 120 {
121 return ERROR_INVALID_FILE; 121 return ERROR_INVALID_FILE;
122 } 122 }
123 123
124 ifFile.seekg(0, std::ios::beg); 124 ifFile.seekg(0, std::ios::beg);
125 125
126 originalOffset = 0; 126 originalOffset = 0;
127 127
128 std::vector<byte> vBuffer(PELIB_IMAGE_DOS_HEADER::size()); 128 std::vector<byte> vBuffer(PELIB_IMAGE_DOS_HEADER::size());
129 ifFile.read(reinterpret_cast<char*>(&vBuffer[0]), static_cast<unsigned int>(vBuffer.size())); 129 ifFile.read(reinterpret_cast<char*>(&vBuffer[0]), static_cast<unsigned int>(vBuffer.size()));
130 ifFile.close(); 130 ifFile.close();
131 131
132 InputBuffer ibBuffer(vBuffer); 132 InputBuffer ibBuffer(vBuffer);
133 read(ibBuffer); 133 read(ibBuffer);
134 return NO_ERROR; 134 return NO_ERROR;
135 } 135 }
136 136
137 /** 137 /**
138 * Reads the MZ header from memory. A pointer to a location in memory is passed and the data 138 * Reads the MZ header from memory. A pointer to a location in memory is passed and the data
139 * at this location is treated like a MZ header structure. The MZ header does not need to be valid. 139 * at this location is treated like a MZ header structure. The MZ header does not need to be valid.
140 * @param pcBuffer Pointer to a MZ header. 140 * @param pcBuffer Pointer to a MZ header.
141 * @param uiSize Length of the buffer. 141 * @param uiSize Length of the buffer.
142 * @return A non-zero value is returned if a problem occured. 142 * @return A non-zero value is returned if a problem occured.
143 **/ 143 **/
144 int MzHeader::read(unsigned char* pcBuffer, unsigned int uiSize, unsigned int originalOffs) 144 int MzHeader::read(unsigned char* pcBuffer, unsigned int uiSize, unsigned int originalOffs)
145 { 145 {
146 if (uiSize < PELIB_IMAGE_DOS_HEADER::size()) 146 if (uiSize < PELIB_IMAGE_DOS_HEADER::size())
147 { 147 {
148 return ERROR_INVALID_FILE; 148 return ERROR_INVALID_FILE;
149 } 149 }
150 150
151 std::vector<byte> vBuffer(pcBuffer, pcBuffer + uiSize); 151 std::vector<byte> vBuffer(pcBuffer, pcBuffer + uiSize);
152 for (int i=0;i<0x40;i++) std::cout << std::hex << (int)vBuffer[i] << " "; 152 for (int i=0;i<0x40;i++) std::cout << std::hex << (int)vBuffer[i] << " ";
153 153
154 originalOffset = originalOffs; 154 originalOffset = originalOffs;
155 155
156 InputBuffer ibBuffer(vBuffer); 156 InputBuffer ibBuffer(vBuffer);
157 read(ibBuffer); 157 read(ibBuffer);
158 return NO_ERROR; 158 return NO_ERROR;
159 } 159 }
160 160
161 /** 161 /**
162 * Rebuilds the MZ header so that it can be written to a file. It's not guaranteed that the 162 * Rebuilds the MZ header so that it can be written to a file. It's not guaranteed that the
163 * MZ header will be valid. If you want to make sure that the MZ header will be valid you 163 * MZ header will be valid. If you want to make sure that the MZ header will be valid you
164 * must call #PeLib::MzHeader::makeValid first. 164 * must call #PeLib::MzHeader::makeValid first.
165 * @param vBuffer Buffer where the rebuilt MZ header will be stored. 165 * @param vBuffer Buffer where the rebuilt MZ header will be stored.
166 **/ 166 **/
167 void MzHeader::rebuild(std::vector<byte>& vBuffer) const 167 void MzHeader::rebuild(std::vector<byte>& vBuffer) const
168 { 168 {
169 OutputBuffer obBuffer(vBuffer); 169 OutputBuffer obBuffer(vBuffer);
170 170
171 obBuffer << m_idhHeader.e_magic; 171 obBuffer << m_idhHeader.e_magic;
172 obBuffer << m_idhHeader.e_cblp; 172 obBuffer << m_idhHeader.e_cblp;
173 obBuffer << m_idhHeader.e_cp; 173 obBuffer << m_idhHeader.e_cp;
174 obBuffer << m_idhHeader.e_crlc; 174 obBuffer << m_idhHeader.e_crlc;
175 obBuffer << m_idhHeader.e_cparhdr; 175 obBuffer << m_idhHeader.e_cparhdr;
176 obBuffer << m_idhHeader.e_minalloc; 176 obBuffer << m_idhHeader.e_minalloc;
177 obBuffer << m_idhHeader.e_maxalloc; 177 obBuffer << m_idhHeader.e_maxalloc;
178 obBuffer << m_idhHeader.e_ss; 178 obBuffer << m_idhHeader.e_ss;
179 obBuffer << m_idhHeader.e_sp; 179 obBuffer << m_idhHeader.e_sp;
180 obBuffer << m_idhHeader.e_csum; 180 obBuffer << m_idhHeader.e_csum;
181 obBuffer << m_idhHeader.e_ip; 181 obBuffer << m_idhHeader.e_ip;
182 obBuffer << m_idhHeader.e_cs; 182 obBuffer << m_idhHeader.e_cs;
183 obBuffer << m_idhHeader.e_lfarlc; 183 obBuffer << m_idhHeader.e_lfarlc;
184 obBuffer << m_idhHeader.e_ovno; 184 obBuffer << m_idhHeader.e_ovno;
185 185
186 for (unsigned int i=0;i<sizeof(m_idhHeader.e_res)/sizeof(m_idhHeader.e_res[0]);i++) 186 for (unsigned int i=0;i<sizeof(m_idhHeader.e_res)/sizeof(m_idhHeader.e_res[0]);i++)
187 { 187 {
188 obBuffer << m_idhHeader.e_res[i]; 188 obBuffer << m_idhHeader.e_res[i];
189 } 189 }
190 190
191 obBuffer << m_idhHeader.e_oemid; 191 obBuffer << m_idhHeader.e_oemid;
192 obBuffer << m_idhHeader.e_oeminfo; 192 obBuffer << m_idhHeader.e_oeminfo;
193 193
194 for (unsigned int i=0;i<sizeof(m_idhHeader.e_res2)/sizeof(m_idhHeader.e_res2[0]);i++) 194 for (unsigned int i=0;i<sizeof(m_idhHeader.e_res2)/sizeof(m_idhHeader.e_res2[0]);i++)
195 { 195 {
196 obBuffer << m_idhHeader.e_res2[i]; 196 obBuffer << m_idhHeader.e_res2[i];
197 } 197 }
198 198
199 obBuffer << m_idhHeader.e_lfanew; 199 obBuffer << m_idhHeader.e_lfanew;
200 } 200 }
201 201
202 /** 202 /**
203 * Returns the size of the MZ header. This size is actually always sizeof(IMAGE_DOS_HEADER) (== 0x40) 203 * Returns the size of the MZ header. This size is actually always sizeof(IMAGE_DOS_HEADER) (== 0x40)
204 * because the MZ header is a header of constant size if you disregard the dos stub. If you want to know the 204 * because the MZ header is a header of constant size if you disregard the dos stub. If you want to know the
205 * size of the MZ header + the size of the dos stub check #PeLib::MzHeader::getAddressOfPeHeader. 205 * size of the MZ header + the size of the dos stub check #PeLib::MzHeader::getAddressOfPeHeader.
206 * @return Size of the MZ header. 206 * @return Size of the MZ header.
207 **/ 207 **/
208 unsigned int MzHeader::size() const 208 unsigned int MzHeader::size() const
209 { 209 {
210 return sizeof(m_idhHeader); 210 return sizeof(m_idhHeader);
211 } 211 }
212 212
213 /** 213 /**
214 * Writes the current MZ header to a file. The file does not have to exist. If it doesn't exist 214 * Writes the current MZ header to a file. The file does not have to exist. If it doesn't exist
215 * it will be created. 215 * it will be created.
216 * @param strFilename Name of the file the header will be written to. 216 * @param strFilename Name of the file the header will be written to.
217 * @param dwOffset Offset the header will be written to (defaults to 0). 217 * @param dwOffset Offset the header will be written to (defaults to 0).
218 * @return A non-zero value is returned if a problem occured. 218 * @return A non-zero value is returned if a problem occured.
219 **/ 219 **/
220 int MzHeader::write(const std::string& strFilename, dword dwOffset = 0) const 220 int MzHeader::write(const std::string& strFilename, dword dwOffset = 0) const
221 { 221 {
222 std::fstream ofFile(strFilename.c_str(), std::ios_base::in); 222 std::fstream ofFile(strFilename.c_str(), std::ios_base::in);
223 223
224 if (!ofFile) 224 if (!ofFile)
225 { 225 {
226 ofFile.clear(); 226 ofFile.clear();
227 ofFile.open(strFilename.c_str(), std::ios_base::out | std::ios_base::binary); 227 ofFile.open(strFilename.c_str(), std::ios_base::out | std::ios_base::binary);
228 } 228 }
229 else 229 else
230 { 230 {
231 ofFile.close(); 231 ofFile.close();
232 ofFile.open(strFilename.c_str(), std::ios_base::in | std::ios_base::out | std::ios_base::binary); 232 ofFile.open(strFilename.c_str(), std::ios_base::in | std::ios_base::out | std::ios_base::binary);
233 } 233 }
234 234
235 if (!ofFile) 235 if (!ofFile)
236 { 236 {
237 return ERROR_OPENING_FILE; 237 return ERROR_OPENING_FILE;
238 } 238 }
239 239
240 ofFile.seekp(dwOffset, std::ios::beg); 240 ofFile.seekp(dwOffset, std::ios::beg);
241 241
242 std::vector<unsigned char> vBuffer; 242 std::vector<unsigned char> vBuffer;
243 243
244 rebuild(vBuffer); 244 rebuild(vBuffer);
245 245
246 ofFile.write(reinterpret_cast<const char*>(&vBuffer[0]), static_cast<unsigned int>(vBuffer.size())); 246 ofFile.write(reinterpret_cast<const char*>(&vBuffer[0]), static_cast<unsigned int>(vBuffer.size()));
247 247
248 ofFile.close(); 248 ofFile.close();
249 249
250 return NO_ERROR; 250 return NO_ERROR;
251 } 251 }
252 252
253 /** 253 /**
254 * Returns the MZ header's e_magic value. 254 * Returns the MZ header's e_magic value.
255 **/ 255 **/
256 word MzHeader::getMagicNumber() const 256 word MzHeader::getMagicNumber() const
257 { 257 {
258 return m_idhHeader.e_magic; 258 return m_idhHeader.e_magic;
259 } 259 }
260 260
261 /** 261 /**
262 * Returns the MZ header's e_cblp value. 262 * Returns the MZ header's e_cblp value.
263 **/ 263 **/
264 word MzHeader::getBytesOnLastPage() const 264 word MzHeader::getBytesOnLastPage() const
265 { 265 {
266 return m_idhHeader.e_cblp; 266 return m_idhHeader.e_cblp;
267 } 267 }
268 268
269 /** 269 /**
270 * Returns the MZ header's e_cp value. 270 * Returns the MZ header's e_cp value.
271 **/ 271 **/
272 word MzHeader::getPagesInFile() const 272 word MzHeader::getPagesInFile() const
273 { 273 {
274 return m_idhHeader.e_cp; 274 return m_idhHeader.e_cp;
275 } 275 }
276 276
277 /** 277 /**
278 * Returns the MZ header's e_crlc value. 278 * Returns the MZ header's e_crlc value.
279 **/ 279 **/
280 word MzHeader::getRelocations() const 280 word MzHeader::getRelocations() const
281 { 281 {
282 return m_idhHeader.e_crlc; 282 return m_idhHeader.e_crlc;
283 } 283 }
284 284
285 /** 285 /**
286 * Returns the MZ header's e_cparhdr value. 286 * Returns the MZ header's e_cparhdr value.
287 **/ 287 **/
288 word MzHeader::getSizeOfHeader() const 288 word MzHeader::getSizeOfHeader() const
289 { 289 {
290 return m_idhHeader.e_cparhdr; 290 return m_idhHeader.e_cparhdr;
291 } 291 }
292 292
293 /** 293 /**
294 * Returns the MZ header's e_minalloc value. 294 * Returns the MZ header's e_minalloc value.
295 **/ 295 **/
296 word MzHeader::getMinExtraParagraphs() const 296 word MzHeader::getMinExtraParagraphs() const
297 { 297 {
298 return m_idhHeader.e_minalloc; 298 return m_idhHeader.e_minalloc;
299 } 299 }
300 300
301 /** 301 /**
302 * Returns the MZ header's e_maxalloc value. 302 * Returns the MZ header's e_maxalloc value.
303 **/ 303 **/
304 word MzHeader::getMaxExtraParagraphs() const 304 word MzHeader::getMaxExtraParagraphs() const
305 { 305 {
306 return m_idhHeader.e_maxalloc; 306 return m_idhHeader.e_maxalloc;
307 } 307 }
308 308
309 /** 309 /**
310 * Returns the MZ header's e_ss value. 310 * Returns the MZ header's e_ss value.
311 **/ 311 **/
312 word MzHeader::getSsValue() const 312 word MzHeader::getSsValue() const
313 { 313 {
314 return m_idhHeader.e_ss; 314 return m_idhHeader.e_ss;
315 } 315 }
316 316
317 /** 317 /**
318 * Returns the MZ header's e_sp value. 318 * Returns the MZ header's e_sp value.
319 **/ 319 **/
320 word MzHeader::getSpValue() const 320 word MzHeader::getSpValue() const
321 { 321 {
322 return m_idhHeader.e_sp; 322 return m_idhHeader.e_sp;
323 } 323 }
324 324
325 /** 325 /**
326 * Returns the MZ header's e_csum value. 326 * Returns the MZ header's e_csum value.
327 **/ 327 **/
328 word MzHeader::getChecksum() const 328 word MzHeader::getChecksum() const
329 { 329 {
330 return m_idhHeader.e_csum; 330 return m_idhHeader.e_csum;
331 } 331 }
332 332
333 /** 333 /**
334 * Returns the MZ header's e_ip value. 334 * Returns the MZ header's e_ip value.
335 **/ 335 **/
336 word MzHeader::getIpValue() const 336 word MzHeader::getIpValue() const
337 { 337 {
338 return m_idhHeader.e_ip; 338 return m_idhHeader.e_ip;
339 } 339 }
340 340
341 /** 341 /**
342 * Returns the MZ header's e_cs value. 342 * Returns the MZ header's e_cs value.
343 **/ 343 **/
344 word MzHeader::getCsValue() const 344 word MzHeader::getCsValue() const
345 { 345 {
346 return m_idhHeader.e_cs; 346 return m_idhHeader.e_cs;
347 } 347 }
348 348
349 /** 349 /**
350 * Returns the MZ header's e_lfarlc value. 350 * Returns the MZ header's e_lfarlc value.
351 **/ 351 **/
352 word MzHeader::getAddrOfRelocationTable() const 352 word MzHeader::getAddrOfRelocationTable() const
353 { 353 {
354 return m_idhHeader.e_lfarlc; 354 return m_idhHeader.e_lfarlc;
355 } 355 }
356 356
357 /** 357 /**
358 * Returns the MZ header's e_ovno value. 358 * Returns the MZ header's e_ovno value.
359 **/ 359 **/
360 word MzHeader::getOverlayNumber() const 360 word MzHeader::getOverlayNumber() const
361 { 361 {
362 return m_idhHeader.e_ovno; 362 return m_idhHeader.e_ovno;
363 } 363 }
364 364
365 /** 365 /**
366 * Returns the MZ header's e_oemid value. 366 * Returns the MZ header's e_oemid value.
367 **/ 367 **/
368 word MzHeader::getOemIdentifier() const 368 word MzHeader::getOemIdentifier() const
369 { 369 {
370 return m_idhHeader.e_oemid; 370 return m_idhHeader.e_oemid;
371 } 371 }
372 372
373 /** 373 /**
374 * Returns the MZ header's e_oeminfo value. 374 * Returns the MZ header's e_oeminfo value.
375 **/ 375 **/
376 word MzHeader::getOemInformation() const 376 word MzHeader::getOemInformation() const
377 { 377 {
378 return m_idhHeader.e_oeminfo; 378 return m_idhHeader.e_oeminfo;
379 } 379 }
380 380
381 /** 381 /**
382 * Returns the MZ header's e_lfanew value. 382 * Returns the MZ header's e_lfanew value.
383 **/ 383 **/
384 dword MzHeader::getAddressOfPeHeader() const 384 dword MzHeader::getAddressOfPeHeader() const
385 { 385 {
386 return m_idhHeader.e_lfanew; 386 return m_idhHeader.e_lfanew;
387 } 387 }
388 388
389 /** 389 /**
390 * Returns the MZ header's e_res[uiNr] value. If the parameter uiNr is out of range 390 * Returns the MZ header's e_res[uiNr] value. If the parameter uiNr is out of range
391 * you will get undefined behaviour. 391 * you will get undefined behaviour.
392 * @param uiNr The index of the word in the e_res array (valid range: 0-3) 392 * @param uiNr The index of the word in the e_res array (valid range: 0-3)
393 **/ 393 **/
394 word MzHeader::getReservedWords1(unsigned int uiNr) const 394 word MzHeader::getReservedWords1(unsigned int uiNr) const
395 { 395 {
396 return m_idhHeader.e_res[uiNr]; 396 return m_idhHeader.e_res[uiNr];
397 } 397 }
398 398
399 /** 399 /**
400 * Returns the MZ header's e_res2[uiNr] value. If the parameter uiNr is out of range 400 * Returns the MZ header's e_res2[uiNr] value. If the parameter uiNr is out of range
401 * you will get undefined behaviour. 401 * you will get undefined behaviour.
402 * @param uiNr The index of the word in the e_res array (valid range: 0-9) 402 * @param uiNr The index of the word in the e_res array (valid range: 0-9)
403 **/ 403 **/
404 word MzHeader::getReservedWords2(unsigned int uiNr) const 404 word MzHeader::getReservedWords2(unsigned int uiNr) const
405 { 405 {
406 return m_idhHeader.e_res2[uiNr]; 406 return m_idhHeader.e_res2[uiNr];
407 } 407 }
408 408
409 /** 409 /**
410 * Sets the MZ header's e_magic value. 410 * Sets the MZ header's e_magic value.
411 * @param wValue The new value of e_magic. 411 * @param wValue The new value of e_magic.
412 **/ 412 **/
413 void MzHeader::setMagicNumber(word wValue) 413 void MzHeader::setMagicNumber(word wValue)
414 { 414 {
415 m_idhHeader.e_magic = wValue; 415 m_idhHeader.e_magic = wValue;
416 } 416 }
417 417
418 /** 418 /**
419 * Sets the MZ header's e_cblp value. 419 * Sets the MZ header's e_cblp value.
420 * @param wValue The new value of e_cblp. 420 * @param wValue The new value of e_cblp.
421 **/ 421 **/
422 void MzHeader::setBytesOnLastPage(word wValue) 422 void MzHeader::setBytesOnLastPage(word wValue)
423 { 423 {
424 m_idhHeader.e_cblp = wValue; 424 m_idhHeader.e_cblp = wValue;
425 } 425 }
426 426
427 /** 427 /**
428 * Sets the MZ header's e_cp value. 428 * Sets the MZ header's e_cp value.
429 * @param wValue The new value of e_cp. 429 * @param wValue The new value of e_cp.
430 **/ 430 **/
431 void MzHeader::setPagesInFile(word wValue) 431 void MzHeader::setPagesInFile(word wValue)
432 { 432 {
433 m_idhHeader.e_cp = wValue; 433 m_idhHeader.e_cp = wValue;
434 } 434 }
435 435
436 /** 436 /**
437 * Sets the MZ header's e_crlc value. 437 * Sets the MZ header's e_crlc value.
438 * @param wValue The new value of e_crlc. 438 * @param wValue The new value of e_crlc.
439 **/ 439 **/
440 void MzHeader::setRelocations(word wValue) 440 void MzHeader::setRelocations(word wValue)
441 { 441 {
442 m_idhHeader.e_crlc = wValue; 442 m_idhHeader.e_crlc = wValue;
443 } 443 }
444 444
445 /** 445 /**
446 * Sets the MZ header's e_cparhdr value. 446 * Sets the MZ header's e_cparhdr value.
447 * @param wValue The new value of e_cparhdr. 447 * @param wValue The new value of e_cparhdr.
448 **/ 448 **/
449 void MzHeader::setSizeOfHeader(word wValue) 449 void MzHeader::setSizeOfHeader(word wValue)
450 { 450 {
451 m_idhHeader.e_cparhdr = wValue; 451 m_idhHeader.e_cparhdr = wValue;
452 } 452 }
453 453
454 /** 454 /**
455 * Sets the MZ header's e_minalloc value. 455 * Sets the MZ header's e_minalloc value.
456 * @param wValue The new value of e_minalloc. 456 * @param wValue The new value of e_minalloc.
457 **/ 457 **/
458 void MzHeader::setMinExtraParagraphs(word wValue) 458 void MzHeader::setMinExtraParagraphs(word wValue)
459 { 459 {
460 m_idhHeader.e_minalloc = wValue; 460 m_idhHeader.e_minalloc = wValue;
461 } 461 }
462 462
463 /** 463 /**
464 * Sets the MZ header's e_maxalloc value. 464 * Sets the MZ header's e_maxalloc value.
465 * @param wValue The new value of e_maxalloc. 465 * @param wValue The new value of e_maxalloc.
466 **/ 466 **/
467 void MzHeader::setMaxExtraParagraphs(word wValue) 467 void MzHeader::setMaxExtraParagraphs(word wValue)
468 { 468 {
469 m_idhHeader.e_maxalloc = wValue; 469 m_idhHeader.e_maxalloc = wValue;
470 } 470 }
471 471
472 /** 472 /**
473 * Sets the MZ header's e_ss value. 473 * Sets the MZ header's e_ss value.
474 * @param wValue The new value of e_ss. 474 * @param wValue The new value of e_ss.
475 **/ 475 **/
476 void MzHeader::setSsValue(word wValue) 476 void MzHeader::setSsValue(word wValue)
477 { 477 {
478 m_idhHeader.e_ss = wValue; 478 m_idhHeader.e_ss = wValue;
479 } 479 }
480 480
481 /** 481 /**
482 * Sets the MZ header's e_sp value. 482 * Sets the MZ header's e_sp value.
483 * @param wValue The new value of e_sp. 483 * @param wValue The new value of e_sp.
484 **/ 484 **/
485 void MzHeader::setSpValue(word wValue) 485 void MzHeader::setSpValue(word wValue)
486 { 486 {
487 m_idhHeader.e_sp = wValue; 487 m_idhHeader.e_sp = wValue;
488 } 488 }
489 489
490 /** 490 /**
491 * Sets the MZ header's e_csum value. 491 * Sets the MZ header's e_csum value.
492 * @param wValue The new value of e_csum. 492 * @param wValue The new value of e_csum.
493 **/ 493 **/
494 void MzHeader::setChecksum(word wValue) 494 void MzHeader::setChecksum(word wValue)
495 { 495 {
496 m_idhHeader.e_csum = wValue; 496 m_idhHeader.e_csum = wValue;
497 } 497 }
498 498
499 /** 499 /**
500 * Sets the MZ header's e_ip value. 500 * Sets the MZ header's e_ip value.
501 * @param wValue The new value of e_ip. 501 * @param wValue The new value of e_ip.
502 **/ 502 **/
503 void MzHeader::setIpValue(word wValue) 503 void MzHeader::setIpValue(word wValue)
504 { 504 {
505 m_idhHeader.e_ip = wValue; 505 m_idhHeader.e_ip = wValue;
506 } 506 }
507 507
508 /** 508 /**
509 * Sets the MZ header's e_cs value. 509 * Sets the MZ header's e_cs value.
510 * @param wValue The new value of e_cs. 510 * @param wValue The new value of e_cs.
511 **/ 511 **/
512 void MzHeader::setCsValue(word wValue) 512 void MzHeader::setCsValue(word wValue)
513 { 513 {
514 m_idhHeader.e_cs = wValue; 514 m_idhHeader.e_cs = wValue;
515 } 515 }
516 516
517 /** 517 /**
518 * Sets the MZ header's e_lfarlc value. 518 * Sets the MZ header's e_lfarlc value.
519 * @param wValue The new value of e_lfarlc. 519 * @param wValue The new value of e_lfarlc.
520 **/ 520 **/
521 void MzHeader::setAddrOfRelocationTable(word wValue) 521 void MzHeader::setAddrOfRelocationTable(word wValue)
522 { 522 {
523 m_idhHeader.e_lfarlc = wValue; 523 m_idhHeader.e_lfarlc = wValue;
524 } 524 }
525 525
526 /** 526 /**
527 * Sets the MZ header's e_ovno value. 527 * Sets the MZ header's e_ovno value.
528 * @param wValue The new value of e_ovno. 528 * @param wValue The new value of e_ovno.
529 **/ 529 **/
530 void MzHeader::setOverlayNumber(word wValue) 530 void MzHeader::setOverlayNumber(word wValue)
531 { 531 {
532 m_idhHeader.e_ovno = wValue; 532 m_idhHeader.e_ovno = wValue;
533 } 533 }
534 534
535 /** 535 /**
536 * Sets the MZ header's e_oemid value. 536 * Sets the MZ header's e_oemid value.
537 * @param wValue The new value of e_oemid. 537 * @param wValue The new value of e_oemid.
538 **/ 538 **/
539 void MzHeader::setOemIdentifier(word wValue) 539 void MzHeader::setOemIdentifier(word wValue)
540 { 540 {
541 m_idhHeader.e_oemid = wValue; 541 m_idhHeader.e_oemid = wValue;
542 } 542 }
543 543
544 /** 544 /**
545 * Sets the MZ header's e_oeminfo value. 545 * Sets the MZ header's e_oeminfo value.
546 * @param wValue The new value of e_oeminfo. 546 * @param wValue The new value of e_oeminfo.
547 **/ 547 **/
548 void MzHeader::setOemInformation(word wValue) 548 void MzHeader::setOemInformation(word wValue)
549 { 549 {
550 m_idhHeader.e_oeminfo = wValue; 550 m_idhHeader.e_oeminfo = wValue;
551 } 551 }
552 552
553 /** 553 /**
554 * Sets the MZ header's e_lfanew value. 554 * Sets the MZ header's e_lfanew value.
555 * @param lValue The new value of e_lfanew. 555 * @param lValue The new value of e_lfanew.
556 **/ 556 **/
557 void MzHeader::setAddressOfPeHeader(dword lValue) 557 void MzHeader::setAddressOfPeHeader(dword lValue)
558 { 558 {
559 m_idhHeader.e_lfanew = lValue; 559 m_idhHeader.e_lfanew = lValue;
560 } 560 }
561 561
562 /** 562 /**
563 * Sets the MZ header's e_res[uiNr] value. If the parameter uiNr is out of range 563 * Sets the MZ header's e_res[uiNr] value. If the parameter uiNr is out of range
564 * you will get undefined behaviour. 564 * you will get undefined behaviour.
565 * @param uiNr The index of the word in the e_res array (valid range: 0-3) 565 * @param uiNr The index of the word in the e_res array (valid range: 0-3)
566 * @param wValue The new value of e_res[nr]. 566 * @param wValue The new value of e_res[nr].
567 **/ 567 **/
568 void MzHeader::setReservedWords1(unsigned int uiNr, word wValue) 568 void MzHeader::setReservedWords1(unsigned int uiNr, word wValue)
569 { 569 {
570 m_idhHeader.e_res[uiNr] = wValue; 570 m_idhHeader.e_res[uiNr] = wValue;
571 } 571 }
572 572
573 /** 573 /**
574 * Sets the MZ header's e_res2[uiNr] value. If the parameter uiNr is out of range 574 * Sets the MZ header's e_res2[uiNr] value. If the parameter uiNr is out of range
575 * you will get undefined behaviour. 575 * you will get undefined behaviour.
576 * @param uiNr The index of the word in the e_res2 array (valid range: 0-9) 576 * @param uiNr The index of the word in the e_res2 array (valid range: 0-9)
577 * @param wValue The new value of e_res[nr]. 577 * @param wValue The new value of e_res[nr].
578 **/ 578 **/
579 void MzHeader::setReservedWords2(unsigned int uiNr, word wValue) 579 void MzHeader::setReservedWords2(unsigned int uiNr, word wValue)
580 { 580 {
581 m_idhHeader.e_res2[uiNr] = wValue; 581 m_idhHeader.e_res2[uiNr] = wValue;
582 } 582 }
583 583
584} 584}