Class CliBlob
java.lang.Object
ghidra.app.util.bin.format.pe.cli.blobs.CliBlob
- All Implemented Interfaces:
StructConverter
- Direct Known Subclasses:
CliAbstractSig
,CliBlobCustomAttrib
,CliBlobMarshalSpec
Describes a blob in the #Blob heap. Format is a coded size then the blob contents.
Paraphrasing from ISO 23271:2012 11.24.2.4 (p272): - If the first one byte of the 'blob' is 0bbbbbbb_2: size is bbbbbbb_2 bytes. - If the first two bytes are 10bbbbbb_2 and x: size is (bbbbbb_2 << 8 + x) bytes. - If the first four bytes are 110bbbbb_2, x, y, and z: size is (bbbbb_2<<24 + x<<16 + y<<8 + z) bytes. The first entry in the heap is the empty 'blob' consisting of a single zero byte.
-
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionCliBlob
(int streamIndex, BinaryReader reader) Creates a new blob from the given reader, which should be positioned at the start of the blob.protected
Creates a new blob that is a copy of the given blob.protected
CliBlob
(CliBlob blob, BinaryReader reader) Creates a new blob that is a copy of the given blob but with a new reader. -
Method Summary
Modifier and TypeMethodDescriptionstatic int
decodeCompressedSigned
(byte codedSize) static int
decodeCompressedSigned
(int codedSize) static int
decodeCompressedSigned
(short codedSize) static int
static int
decodeCompressedUnsigned
(byte codedSize) static int
decodeCompressedUnsigned
(int codedSize) static int
decodeCompressedUnsigned
(short codedSize) static int
byte[]
Gets the blob's contents.Gets the comment associated with this blob's contents.Gets the data type associated with this blob's contents.Gets the name associated with this blob's contents.Gets a new binary reader positioned at the start of this blob's contents.int
Gets the blob's contents size in bytes.static DataType
getDataTypeForBytes
(int numBytes) getName()
Gets the name of this blob.Gets the string representation of this blob.int
getSize()
Gets the blob's size in bytes (includes all fields).Gets the proper data type for the blob's size field.int
Gets the index into the blob stream of this blob.boolean
Checks to see whether or not this blob is little endian.static void
Returns a structure datatype representing the contents of the implementor of this interface.Create CLI Blob structure.
-
Field Details
-
PATH
- See Also:
-
blobOffset
protected long blobOffset -
contentsOffset
protected long contentsOffset -
contentsSize
protected int contentsSize
-
-
Constructor Details
-
CliBlob
Creates a new blob from the given reader, which should be positioned at the start of the blob. The reader will be positioned directly after the blob upon completion of the constructor.- Parameters:
streamIndex
- The blob's stream index.reader
- The reader to use to read the blob.- Throws:
IOException
- if there was a problem reading the blob.
-
CliBlob
Creates a new blob that is a copy of the given blob.- Parameters:
blob
- The blob to copy.
-
CliBlob
Creates a new blob that is a copy of the given blob but with a new reader. The provided reader must be positioned to the start of the new blob.- Parameters:
blob
- The blob to copy.reader
- The reader to use to read the new blob. It must be positioned to the start of the new blob.
-
-
Method Details
-
getSize
public int getSize()Gets the blob's size in bytes (includes all fields).- Returns:
- The blob's size in bytes.
-
getContentsReader
Gets a new binary reader positioned at the start of this blob's contents.- Returns:
- A new binary reader positioned at the start of this blob's contents.
-
getContentsSize
public int getContentsSize()Gets the blob's contents size in bytes.- Returns:
- The blob's contents size in bytes.
-
getContents
public byte[] getContents()Gets the blob's contents.- Returns:
- the blob's contents. Could be null if there was a problem reading the contents.
-
getRepresentation
Gets the string representation of this blob.- Returns:
- The string representation of this blob.
-
isLittleEndian
public boolean isLittleEndian()Checks to see whether or not this blob is little endian.- Returns:
- True if this blob is little endian; false if big endian.
-
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
- See Also:
-
toDataType
Create CLI Blob structure. NOTE: This form is provided to reduce resolution time when target datatype manager is known.- Parameters:
dtm
- datatype manager or null if target datatype manager is unknown.- Returns:
- blob structure
-
getStreamIndex
public int getStreamIndex()Gets the index into the blob stream of this blob.- Returns:
- The index into the blob stream of this blob.
-
getName
Gets the name of this blob.- Returns:
- The name of this blob.
-
getContentsName
Gets the name associated with this blob's contents.- Returns:
- The name associated with this blob's contents.
-
getContentsDataType
Gets the data type associated with this blob's contents.- Returns:
- The data type associated with this blob's contents.
-
getContentsComment
Gets the comment associated with this blob's contents.- Returns:
- The comment associated with this blob's contents.
-
getSizeDataType
Gets the proper data type for the blob's size field.- Returns:
- The proper data type for the blob's size field.
-
testSizeDecoding
public static void testSizeDecoding() -
decodeCompressedSigned
public static int decodeCompressedSigned(byte codedSize) -
decodeCompressedSigned
public static int decodeCompressedSigned(short codedSize) -
decodeCompressedSigned
public static int decodeCompressedSigned(int codedSize) -
decodeCompressedUnsigned
public static int decodeCompressedUnsigned(byte codedSize) -
decodeCompressedUnsigned
public static int decodeCompressedUnsigned(short codedSize) -
decodeCompressedUnsigned
public static int decodeCompressedUnsigned(int codedSize) -
decodeCompressedSignedInt
- Throws:
IOException
-
decodeCompressedUnsignedInt
- Throws:
IOException
-
getDataTypeForBytes
-