Package ghidra.app.util.bin.format.pef
Class SectionHeader
- java.lang.Object
-
- ghidra.app.util.bin.format.pef.SectionHeader
-
- All Implemented Interfaces:
StructConverter
public class SectionHeader extends java.lang.Object implements StructConverter
See Apple's -- PEFBinaryFormatstruct PEFSectionHeader { SInt32 nameOffset; // Offset of name within the section name table, -1 => none. UInt32 defaultAddress; // Default address, affects relocations. UInt32 totalLength; // Fully expanded size in bytes of the section contents. UInt32 unpackedLength; // Size in bytes of the "initialized" part of the contents. UInt32 containerLength; // Size in bytes of the raw data in the container. UInt32 containerOffset; // Offset of section's raw data. UInt8 sectionKind; // Kind of section contents/usage. UInt8 shareKind; // Sharing level, if a writeable section. UInt8 alignment; // Preferred alignment, expressed as log 2. UInt8 reservedA; // Reserved, must be zero. };
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte
getAlignment()
int
getContainerLength()
Returns the size in bytes of the raw data in the container.int
getContainerOffset()
java.io.InputStream
getData()
Returns an input stream to underlying bytes of this section.int
getDefaultAddress()
Returns the preferred address of this section.java.lang.String
getName()
Returns the name of this section.int
getNameOffset()
The offset from the start of the section name table to the name of this section.byte
getReservedA()
Reserved!SectionKind
getSectionKind()
SectionShareKind
getShareKind()
int
getTotalLength()
byte[]
getUnpackedData(TaskMonitor monitor)
Unpack the data in a packed section.int
getUnpackedLength()
Returns the size in bytes of the "initialized" part of the contents.boolean
isExecute()
Returns true if this section has execute permissions.boolean
isRead()
Returns true if this section has read permissions.boolean
isWrite()
Returns true if this section has write permissions.DataType
toDataType()
Returns a structure datatype representing the contents of the implementor of this interface.java.lang.String
toString()
-
-
-
Field Detail
-
NO_NAME_OFFSET
public static final int NO_NAME_OFFSET
- See Also:
- Constant Field Values
-
-
Method Detail
-
getNameOffset
public int getNameOffset()
The offset from the start of the section name table to the name of this section. A value of -1 indicates an unnamed section.- Returns:
- the offset from the start of the section name table
-
getName
public java.lang.String getName()
Returns the name of this section.- Returns:
- the name of this section
-
getData
public java.io.InputStream getData() throws java.io.IOException
Returns an input stream to underlying bytes of this section.- Returns:
- an input stream to underlying bytes of this section
- Throws:
java.io.IOException
- if an i/o error occurs.
-
getUnpackedData
public byte[] getUnpackedData(TaskMonitor monitor) throws java.io.IOException
Unpack the data in a packed section. Calling this method is only valid on a packed section.- Parameters:
monitor
- the task monitor- Returns:
- the unpacked data
- Throws:
java.io.IOException
- if an i/o error occurs or the section is not packed.
-
getDefaultAddress
public int getDefaultAddress()
Returns the preferred address of this section.- Returns:
- the preferred address of this section
-
getTotalLength
public int getTotalLength()
-
getUnpackedLength
public int getUnpackedLength()
Returns the size in bytes of the "initialized" part of the contents.- Returns:
- the size in bytes of the "initialized" part of the contents
-
getContainerLength
public int getContainerLength()
Returns the size in bytes of the raw data in the container.- Returns:
- the size in bytes of the raw data in the container
-
getContainerOffset
public int getContainerOffset()
-
getSectionKind
public SectionKind getSectionKind()
-
getShareKind
public SectionShareKind getShareKind()
-
getAlignment
public byte getAlignment()
-
getReservedA
public byte getReservedA()
Reserved!- Returns:
- Reserved!
-
isRead
public boolean isRead()
Returns true if this section has read permissions.- Returns:
- true if this section has read permissions
-
isWrite
public boolean isWrite()
Returns true if this section has write permissions.- Returns:
- true if this section has write permissions
-
isExecute
public boolean isExecute()
Returns true if this section has execute permissions.- Returns:
- true if this section has execute permissions
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
toDataType
public DataType toDataType() throws DuplicateNameException, java.io.IOException
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 existsjava.io.IOException
- See Also:
StructureDataType
-
-