#include <MzHeader.h>
Public Types | |
enum | Field { e_magic, e_cblp, e_cp, e_crlc, e_cparhdr, e_minalloc, e_maxalloc, e_ss, e_sp, e_csum, e_ip, e_cs, e_lfarlc, e_ovno, e_res, e_oemid, e_oeminfo, e_res2, e_lfanew } |
Public Member Functions | |
dword | getAddressOfPeHeader () const |
Gets the e_lfanew value of the MZ header. | |
word | getAddrOfRelocationTable () const |
Gets the e_lfarlc value of the MZ header. | |
word | getBytesOnLastPage () const |
Gets the e_cblp value of the MZ header. | |
word | getChecksum () const |
Gets the e_csum value of the MZ header. | |
word | getCsValue () const |
Gets the e_cs value of the MZ header. | |
word | getIpValue () const |
Gets the e_ip value of the MZ header. | |
word | getMagicNumber () const |
Gets the e_magic value of the MZ header. | |
word | getMaxExtraParagraphs () const |
Gets the e_maxalloc value of the MZ header. | |
word | getMinExtraParagraphs () const |
Gets the e_minalloc value of the MZ header. | |
word | getOemIdentifier () const |
Gets the e_oemid value of the MZ header. | |
word | getOemInformation () const |
Gets the e_oeminfo value of the MZ header. | |
word | getOverlayNumber () const |
Gets the e_ovnovalue of the MZ header. | |
word | getPagesInFile () const |
Gets the e_cp value of the MZ header. | |
word | getRelocations () const |
Gets the e_crlc value of the MZ header. | |
word | getReservedWords1 (unsigned int uiNr) const |
Gets the e_res of the MZ header. | |
word | getReservedWords2 (unsigned int uiNr) const |
Gets the e_res2 of the MZ header. | |
word | getSizeOfHeader () const |
Gets the e_cparhdr value of the MZ header. | |
word | getSpValue () const |
Gets the e_sp value of the MZ header. | |
word | getSsValue () const |
Gets the e_ss value of the MZ header. | |
bool | isValid (Field) const |
bool | isValid () const |
Checks if the current MZ header is valid. | |
void | makeValid (Field) |
void | makeValid () |
Corrects the current MZ header. | |
int | read (unsigned char *pcBuffer, unsigned int uiSize, unsigned int originalOffs=0) |
Reads the MZ header from a memory location. | |
int | read (const std::string &strFilename) |
Reads the MZ header of a file. | |
void | rebuild (std::vector< byte > &vBuffer) const |
Rebuild the MZ header. | |
void | setAddressOfPeHeader (dword dwValue) |
Sets the e_lfanew value of the MZ header. | |
void | setAddrOfRelocationTable (word wValue) |
Sets the e_lfarlc value of the MZ header. | |
void | setBytesOnLastPage (word wValue) |
Sets the e_cblp value of the MZ header. | |
void | setChecksum (word wValue) |
Sets the e_csum value of the MZ header. | |
void | setCsValue (word wValue) |
Sets the e_cs value of the MZ header. | |
void | setIpValue (word wValue) |
Sets the e_ip value of the MZ header. | |
void | setMagicNumber (word wValue) |
Sets the e_magic value of the MZ header. | |
void | setMaxExtraParagraphs (word wValue) |
Sets the e_maxalloc value of the MZ header. | |
void | setMinExtraParagraphs (word wValue) |
Sets the e_minalloc value of the MZ header. | |
void | setOemIdentifier (word wValue) |
Sets the e_oemid value of the MZ header. | |
void | setOemInformation (word wValue) |
Sets the e_oeminfo value of the MZ header. | |
void | setOverlayNumber (word wValue) |
Sets the e_ovno value of the MZ header. | |
void | setPagesInFile (word wValue) |
Sets the e_cp value of the MZ header. | |
void | setRelocations (word wValue) |
Sets the e_crlc value of the MZ header. | |
void | setReservedWords1 (unsigned int uiNr, word wValue) |
Sets the e_res value of the MZ header. | |
void | setReservedWords2 (unsigned int uiNr, word wValue) |
Sets the e_res2 value of the MZ header. | |
void | setSizeOfHeader (word wValue) |
Sets the e_cparhdr value of the MZ header. | |
void | setSpValue (word wValue) |
Sets the e_sp value of the MZ header. | |
void | setSsValue (word wValue) |
Sets the e_ss value of the MZ header. | |
unsigned int | size () const |
Returns the size of the current MZ header. | |
int | write (const std::string &strFilename, dword dwOffset) const |
Writes the current MZ header to offset 0 of a file. | |
Private Member Functions | |
void | read (InputBuffer &ibBuffer) |
Reads data from an InputBuffer into a MZ header struct. | |
Private Attributes | |
PELIB_IMAGE_DOS_HEADER | m_idhHeader |
Stores all MZ header information. | |
unsigned int | originalOffset |
Offset of the MZ header in the original file. |
This class can read and modify MZ headers. It provides set- and get functions to access all individual members of a MZ header. Furthermore it's possible to validate and rebuild MZ headers.
|
Gets the e_lfanew value of the MZ header. Returns the MZ header's e_lfanew value. |
|
Gets the e_lfarlc value of the MZ header. Returns the MZ header's e_lfarlc value. |
|
Gets the e_cblp value of the MZ header. Returns the MZ header's e_cblp value. |
|
Gets the e_csum value of the MZ header. Returns the MZ header's e_csum value. |
|
Gets the e_cs value of the MZ header. Returns the MZ header's e_cs value. |
|
Gets the e_ip value of the MZ header. Returns the MZ header's e_ip value. |
|
Gets the e_magic value of the MZ header. Returns the MZ header's e_magic value. |
|
Gets the e_maxalloc value of the MZ header. Returns the MZ header's e_maxalloc value. |
|
Gets the e_minalloc value of the MZ header. Returns the MZ header's e_minalloc value. |
|
Gets the e_oemid value of the MZ header. Returns the MZ header's e_oemid value. |
|
Gets the e_oeminfo value of the MZ header. Returns the MZ header's e_oeminfo value. |
|
Gets the e_ovnovalue of the MZ header. Returns the MZ header's e_ovno value. |
|
Gets the e_cp value of the MZ header. Returns the MZ header's e_cp value. |
|
Gets the e_crlc value of the MZ header. Returns the MZ header's e_crlc value. |
|
Gets the e_res of the MZ header. Returns the MZ header's e_res[uiNr] value. If the parameter uiNr is out of range you will get undefined behaviour.
|
|
Gets the e_res2 of the MZ header. Returns the MZ header's e_res2[uiNr] value. If the parameter uiNr is out of range you will get undefined behaviour.
|
|
Gets the e_cparhdr value of the MZ header. Returns the MZ header's e_cparhdr value. |
|
Gets the e_sp value of the MZ header. Returns the MZ header's e_sp value. |
|
Gets the e_ss value of the MZ header. Returns the MZ header's e_ss value. |
|
Checks if the current MZ header is valid. Tests if the currently loaded MZ header is a valid MZ header. Note that this function does not check if the address to the PE header is valid as this is not possible. Actually, the only thing this function checks is if the e_magic value is set to 0x5A4D (IMAGE_DOS_SIGNATURE). Everything else is not relevant for Windows 2000 and that's the system PeLib is focusing on for now.
|
|
Corrects the current MZ header. Corrects all erroneous values of the current MZ header. Note that this function does not correct the pointer to the PE header. Actually, the only thing this function corrects is the e_magic value. Everything else is not relevant for Windows 2000 and that's the system PeLib is focusing on for now. Here is the call graph for this function: |
|
Reads the MZ header from a memory location. Reads the MZ header from memory. A pointer to a location in memory is passed and the data at this location is treated like a MZ header structure. The MZ header does not need to be valid.
Here is the call graph for this function: |
|
Reads the MZ header of a file. Reads the MZ header from a file. Note that this function does not verify if a file is actually a MZ file. For this purpose see #PeFile::MzHeader::isValid. The reason for this is simple: Otherwise it might not be possible to load damaged PE files to repair them.
Here is the call graph for this function: |
|
Reads data from an InputBuffer into a MZ header struct. Reads data from an InputBuffer into the struct that represents the MZ header. It's required that the size of the input buffer is at least as big as the size of a MZ header. Otherwise we get undefined behaviour.
|
|
Rebuild the MZ header. Rebuilds the MZ header so that it can be written to a file. It's not guaranteed that the MZ header will be valid. If you want to make sure that the MZ header will be valid you must call PeLib::MzHeader::makeValid first.
|
|
Sets the e_lfanew value of the MZ header. Sets the MZ header's e_lfanew value.
|
|
Sets the e_lfarlc value of the MZ header. Sets the MZ header's e_lfarlc value.
|
|
Sets the e_cblp value of the MZ header. Sets the MZ header's e_cblp value.
|
|
Sets the e_csum value of the MZ header. Sets the MZ header's e_csum value.
|
|
Sets the e_cs value of the MZ header. Sets the MZ header's e_cs value.
|
|
Sets the e_ip value of the MZ header. Sets the MZ header's e_ip value.
|
|
Sets the e_magic value of the MZ header. Sets the MZ header's e_magic value.
|
|
Sets the e_maxalloc value of the MZ header. Sets the MZ header's e_maxalloc value.
|
|
Sets the e_minalloc value of the MZ header. Sets the MZ header's e_minalloc value.
|
|
Sets the e_oemid value of the MZ header. Sets the MZ header's e_oemid value.
|
|
Sets the e_oeminfo value of the MZ header. Sets the MZ header's e_oeminfo value.
|
|
Sets the e_ovno value of the MZ header. Sets the MZ header's e_ovno value.
|
|
Sets the e_cp value of the MZ header. Sets the MZ header's e_cp value.
|
|
Sets the e_crlc value of the MZ header. Sets the MZ header's e_crlc value.
|
|
Sets the e_res value of the MZ header. Sets the MZ header's e_res[uiNr] value. If the parameter uiNr is out of range you will get undefined behaviour.
|
|
Sets the e_res2 value of the MZ header. Sets the MZ header's e_res2[uiNr] value. If the parameter uiNr is out of range you will get undefined behaviour.
|
|
Sets the e_cparhdr value of the MZ header. Sets the MZ header's e_cparhdr value.
|
|
Sets the e_sp value of the MZ header. Sets the MZ header's e_sp value.
|
|
Sets the e_ss value of the MZ header. Sets the MZ header's e_ss value.
|
|
Returns the size of the current MZ header. Returns the size of the MZ header. This size is actually always sizeof(IMAGE_DOS_HEADER) (== 0x40) because the MZ header is a header of constant size if you disregard the dos stub. If you want to know the size of the MZ header + the size of the dos stub check PeLib::MzHeader::getAddressOfPeHeader.
|
|
Writes the current MZ header to offset 0 of a file. Writes the current MZ header to a file. The file does not have to exist. If it doesn't exist it will be created.
Here is the call graph for this function: |