Package ghidra.app.util.bin.format.mz
Class OldDOSHeader
java.lang.Object
ghidra.app.util.bin.format.mz.OldDOSHeader
- All Implemented Interfaces:
Writeable
,StructConverter
- Direct Known Subclasses:
DOSHeader
This class represents a DOS Header
WORD e_magic; // Magic number // MANDATORY WORD e_cblp; // Bytes on last page of file WORD e_cp; // Pages in file WORD e_crlc; // Relocations WORD e_cparhdr; // Size of header in paragraphs WORD e_minalloc; // Minimum extra paragraphs needed WORD e_maxalloc; // Maximum extra paragraphs needed WORD e_ss; // Initial (relative) SS value WORD e_sp; // Initial SP value WORD e_csum; // Checksum WORD e_ip; // Initial IP value WORD e_cs; // Initial (relative) CS value WORD e_lfarlc; // File address of relocation table WORD e_ovno; // Overlay number
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
static final String
The name to use when converting into a structure data type.protected BinaryReader
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionshort
e_cblp()
Returns the number of bytes on the last page of file.short
e_cp()
Returns the number of pages in the file.short
Returns the size of header in paragraphs.short
e_crlc()
Returns the number of relocations.short
e_cs()
Returns the initial (relative) CS value.short
e_csum()
Returns the checksum.short
e_ip()
Returns the initial IP value.short
e_lfarlc()
Returns the file address of relocation table.short
e_magic()
Returns the magic number.short
Returns the maximum extra paragraphs needed.short
Returns the minimum extra paragraphs needed.short
e_ovno()
Returns the overlay number.short
e_sp()
Returns the initial SP value.short
e_ss()
Returns the initial (relative) SS value.protected String
getName()
Helper to override the value of nameReturns the processor name.boolean
Returns true if a new EXE header exists.boolean
Returns true if a PE header exists.boolean
Returns true if the DOS magic number is correctprotected void
parse()
Returns a structure datatype representing the contents of the implementor of this interface.void
write
(RandomAccessFile raf, DataConverter dc) Writes this object to the specified random access file using the data converter to handle endianness.
-
Field Details
-
NAME
The name to use when converting into a structure data type.- See Also:
-
IMAGE_DOS_SIGNATURE
public static final int IMAGE_DOS_SIGNATURE- See Also:
-
reader
-
-
Constructor Details
-
OldDOSHeader
Constructs a new DOS header.- Parameters:
reader
- the binary reader- Throws:
IOException
- if there was an IO-related error
-
-
Method Details
-
getProcessorName
Returns the processor name.- Returns:
- the processor name
-
e_magic
public short e_magic()Returns the magic number.- Returns:
- the magic number
-
e_cblp
public short e_cblp()Returns the number of bytes on the last page of file.- Returns:
- the number of bytes on the last page of the file
-
e_cp
public short e_cp()Returns the number of pages in the file.- Returns:
- the number of pages in the file
-
e_crlc
public short e_crlc()Returns the number of relocations.- Returns:
- the number of relocations
-
e_cparhdr
public short e_cparhdr()Returns the size of header in paragraphs.- Returns:
- the size of header in paragraphs
-
e_minalloc
public short e_minalloc()Returns the minimum extra paragraphs needed.- Returns:
- the minimum extra paragraphs needed
-
e_maxalloc
public short e_maxalloc()Returns the maximum extra paragraphs needed.- Returns:
- the maximum extra paragraphs needed
-
e_ss
public short e_ss()Returns the initial (relative) SS value.- Returns:
- the initial (relative) SS value
-
e_sp
public short e_sp()Returns the initial SP value.- Returns:
- the initial SP value
-
e_csum
public short e_csum()Returns the checksum.- Returns:
- the checksum
-
e_ip
public short e_ip()Returns the initial IP value.- Returns:
- the initial IP value
-
e_cs
public short e_cs()Returns the initial (relative) CS value.- Returns:
- the initial (relative) CS value
-
e_lfarlc
public short e_lfarlc()Returns the file address of relocation table.- Returns:
- the file address of relocation table
-
e_ovno
public short e_ovno()Returns the overlay number.- Returns:
- the overlay number
-
hasNewExeHeader
public boolean hasNewExeHeader()Returns true if a new EXE header exists.- Returns:
- true if a new EXE header exists
-
hasPeHeader
public boolean hasPeHeader()Returns true if a PE header exists.- Returns:
- true if a PE header exists
-
isDosSignature
public boolean isDosSignature()Returns true if the DOS magic number is correct- Returns:
- true if the DOS magic number is correct
-
toDataType
Description copied from interface:StructConverter
Returns a structure datatype representing the contents of the implementor of this interface.For example, given:
class A { int foo; double bar; }
The return value should be a structure data type with two data type components; an INT and a DOUBLE. The structure should contain field names and, if possible, field comments.
- Specified by:
toDataType
in interfaceStructConverter
- Returns:
- returns a structure datatype representing the implementor of this interface
- Throws:
DuplicateNameException
- when a datatype of the same name already exists- See Also:
-
getName
Helper to override the value of name- Returns:
- The name of the header
-
parse
- Throws:
IOException
-
write
Description copied from interface:Writeable
Writes this object to the specified random access file using the data converter to handle endianness.- Specified by:
write
in interfaceWriteable
- Parameters:
raf
- the random access filedc
- the data converter- Throws:
IOException
- if an I/O error occurs
-