Main Page | Class Hierarchy | Class List | File List | Class Members | Related Pages

MzHeader.h

00001 /* 00002 * MzHeader.h - Part of the PeLib library. 00003 * 00004 * Copyright (c) 2004 Sebastian Porst (webmaster@the-interweb.com) 00005 * All rights reserved. 00006 * 00007 * This software is licensed under the zlib/libpng License. 00008 * For more details see http://www.opensource.org/licenses/zlib-license.php 00009 * or the license information file (license.htm) in the root directory 00010 * of PeLib. 00011 */ 00012 00013 #ifndef MZHEADER_H 00014 #define MZHEADER_H 00015 00016 #include "PeLibInc.h" 00017 00018 namespace PeLib 00019 { 00021 00026 class MzHeader 00027 { 00028 private: 00029 PELIB_IMAGE_DOS_HEADER m_idhHeader; 00030 00032 void read(InputBuffer& ibBuffer); 00033 00035 unsigned int originalOffset; 00036 00037 public: 00038 00039 enum Field {e_magic, e_cblp, e_cp, e_crlc, e_cparhdr, e_minalloc, e_maxalloc, 00040 e_ss, e_sp, e_csum, e_ip, e_cs, e_lfarlc, e_ovno, e_res, e_oemid, 00041 e_oeminfo, e_res2, e_lfanew}; 00042 00044 bool isValid() const; 00045 00046 bool isValid(Field) const; 00047 00049 void makeValid(); 00050 00051 void makeValid(Field); 00052 00054 int read(const std::string& strFilename); 00055 00057 int read(unsigned char* pcBuffer, unsigned int uiSize, unsigned int originalOffs = 0); 00058 00060 void rebuild(std::vector<byte>& vBuffer) const; 00061 00063 unsigned int size() const; 00064 00066 int write(const std::string& strFilename, dword dwOffset) const; 00067 00069 word getMagicNumber() const; 00071 word getBytesOnLastPage() const; 00073 word getPagesInFile() const; 00075 word getRelocations() const; 00077 word getSizeOfHeader() const; 00079 word getMinExtraParagraphs() const; 00081 word getMaxExtraParagraphs() const; 00083 word getSsValue() const; 00085 word getSpValue() const; 00087 word getChecksum() const; 00089 word getIpValue() const; 00091 word getCsValue() const; 00093 word getAddrOfRelocationTable() const; 00095 word getOverlayNumber() const; 00097 word getOemIdentifier() const; 00099 word getOemInformation() const; 00101 dword getAddressOfPeHeader() const; 00103 word getReservedWords1(unsigned int uiNr) const; 00105 word getReservedWords2(unsigned int uiNr) const; 00106 00108 void setMagicNumber(word wValue); 00110 void setBytesOnLastPage(word wValue); 00112 void setPagesInFile(word wValue); 00114 void setRelocations(word wValue); 00116 void setSizeOfHeader(word wValue); 00118 void setMinExtraParagraphs(word wValue); 00120 void setMaxExtraParagraphs(word wValue); 00122 void setSsValue(word wValue); 00124 void setSpValue(word wValue); 00126 void setChecksum(word wValue); 00128 void setIpValue(word wValue); 00130 void setCsValue(word wValue); 00132 void setAddrOfRelocationTable(word wValue); 00134 void setOverlayNumber(word wValue); 00136 void setOemIdentifier(word wValue); 00138 void setOemInformation(word wValue); 00140 void setAddressOfPeHeader(dword dwValue); 00142 void setReservedWords1(unsigned int uiNr, word wValue); 00144 void setReservedWords2(unsigned int uiNr, word wValue); 00145 }; 00146 } 00147 00148 #endif

Generated on Mon Jan 17 20:50:08 2005 for PeLib by doxygen 1.3.7