Initial
This commit is contained in:
185
image/DOSHDR.HPP
Normal file
185
image/DOSHDR.HPP
Normal file
@@ -0,0 +1,185 @@
|
||||
#ifndef _IMAGE_DOSHEADER_HPP_
|
||||
#define _IMAGE_DOSHEADER_HPP_
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_PUREVIEWOFFILE_HPP_
|
||||
#include <common/pview.hpp>
|
||||
#endif
|
||||
|
||||
class DOSHeader : private _IMAGE_DOS_HEADER
|
||||
{
|
||||
public:
|
||||
enum{MZSignature=IMAGE_DOS_SIGNATURE};
|
||||
DOSHeader(void);
|
||||
DOSHeader(const DOSHeader &someDOSHeader);
|
||||
~DOSHeader();
|
||||
DOSHeader &operator=(const DOSHeader &someDOSHeader);
|
||||
WORD operator==(const DOSHeader &someDOSHeader);
|
||||
WORD operator<<(PureViewOfFile &pureView);
|
||||
WORD magic(void)const;
|
||||
WORD bytesLastPage(void)const;
|
||||
WORD pages(void)const;
|
||||
WORD relocations(void)const;
|
||||
WORD headerParagraphs(void)const;
|
||||
WORD minExtraParagraphs(void)const;
|
||||
WORD maxExtraParagraphs(void)const;
|
||||
WORD initialStackSegment(void)const;
|
||||
WORD initialStackPointer(void)const;
|
||||
WORD checksum(void)const;
|
||||
WORD relocationTableAddress(void)const;
|
||||
WORD overlayNumber(void)const;
|
||||
WORD oemID(void)const;
|
||||
WORD oemInfo(void)const;
|
||||
LONG neHeaderAddress(void)const;
|
||||
WORD isOkay(void)const;
|
||||
private:
|
||||
};
|
||||
|
||||
inline
|
||||
DOSHeader::DOSHeader(void)
|
||||
{
|
||||
::memset((char*)&((_IMAGE_DOS_HEADER&)*this),0,sizeof(_IMAGE_DOS_HEADER));
|
||||
}
|
||||
|
||||
inline
|
||||
DOSHeader::DOSHeader(const DOSHeader &someDOSHeader)
|
||||
{
|
||||
*this=someDOSHeader;
|
||||
}
|
||||
|
||||
inline
|
||||
DOSHeader::~DOSHeader()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
WORD DOSHeader::operator<<(PureViewOfFile &pureView)
|
||||
{
|
||||
if(sizeof(_IMAGE_DOS_HEADER)!=pureView.read((char*)&((_IMAGE_DOS_HEADER&)*this),sizeof(_IMAGE_DOS_HEADER)))return FALSE;
|
||||
return isOkay();
|
||||
}
|
||||
|
||||
inline
|
||||
DOSHeader &DOSHeader::operator=(const DOSHeader &someDOSHeader)
|
||||
{
|
||||
::memcpy((char*)&((_IMAGE_DOS_HEADER&)*this),(char*)&((_IMAGE_DOS_HEADER&)someDOSHeader),sizeof(_IMAGE_DOS_HEADER));
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD DOSHeader::operator==(const DOSHeader &someDOSHeader)
|
||||
{
|
||||
return (magic()==someDOSHeader.magic()&&
|
||||
bytesLastPage()==someDOSHeader.bytesLastPage()&&
|
||||
pages()==someDOSHeader.pages()&&
|
||||
relocations()==someDOSHeader.relocations()&&
|
||||
headerParagraphs()==someDOSHeader.headerParagraphs()&&
|
||||
minExtraParagraphs()==someDOSHeader.minExtraParagraphs()&&
|
||||
maxExtraParagraphs()==someDOSHeader.maxExtraParagraphs()&&
|
||||
initialStackSegment()==someDOSHeader.initialStackSegment()&&
|
||||
initialStackPointer()==someDOSHeader.initialStackPointer()&&
|
||||
checksum()==someDOSHeader.checksum()&&
|
||||
relocationTableAddress()==someDOSHeader.relocationTableAddress()&&
|
||||
overlayNumber()==someDOSHeader.overlayNumber()&&
|
||||
oemID()==someDOSHeader.oemID()&&
|
||||
oemInfo()==someDOSHeader.oemInfo()&&
|
||||
neHeaderAddress()==someDOSHeader.neHeaderAddress());
|
||||
}
|
||||
|
||||
inline
|
||||
WORD DOSHeader::magic(void)const
|
||||
{
|
||||
return _IMAGE_DOS_HEADER::e_magic;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD DOSHeader::bytesLastPage(void)const
|
||||
{
|
||||
return _IMAGE_DOS_HEADER::e_cblp;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD DOSHeader::pages(void)const
|
||||
{
|
||||
return _IMAGE_DOS_HEADER::e_cp;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD DOSHeader::relocations(void)const
|
||||
{
|
||||
return _IMAGE_DOS_HEADER::e_crlc;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD DOSHeader::headerParagraphs(void)const
|
||||
{
|
||||
return _IMAGE_DOS_HEADER::e_cparhdr;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD DOSHeader::minExtraParagraphs(void)const
|
||||
{
|
||||
return _IMAGE_DOS_HEADER::e_minalloc;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD DOSHeader::maxExtraParagraphs(void)const
|
||||
{
|
||||
return _IMAGE_DOS_HEADER::e_maxalloc;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD DOSHeader::initialStackSegment(void)const
|
||||
{
|
||||
return _IMAGE_DOS_HEADER::e_ss;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD DOSHeader::initialStackPointer(void)const
|
||||
{
|
||||
return _IMAGE_DOS_HEADER::e_sp;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD DOSHeader::checksum(void)const
|
||||
{
|
||||
return _IMAGE_DOS_HEADER::e_csum;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD DOSHeader::relocationTableAddress(void)const
|
||||
{
|
||||
return _IMAGE_DOS_HEADER::e_lfarlc;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD DOSHeader::overlayNumber(void)const
|
||||
{
|
||||
return _IMAGE_DOS_HEADER::e_ovno;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD DOSHeader::oemID(void)const
|
||||
{
|
||||
return _IMAGE_DOS_HEADER::e_oemid;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD DOSHeader::oemInfo(void)const
|
||||
{
|
||||
return _IMAGE_DOS_HEADER::e_oeminfo;
|
||||
}
|
||||
|
||||
inline
|
||||
LONG DOSHeader::neHeaderAddress(void)const
|
||||
{
|
||||
return _IMAGE_DOS_HEADER::e_lfanew;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD DOSHeader::isOkay(void)const
|
||||
{
|
||||
return MZSignature==magic();
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user