dissect.cstruct.types.base
¶
Module Contents¶
Classes¶
Base metaclass for cstruct type classes. |
|
Base class for cstruct type classes. |
|
Base metaclass for array-like types. |
|
Implements a fixed or dynamically sized array type. |
Attributes¶
- dissect.cstruct.types.base.EOF = -3599¶
- class dissect.cstruct.types.base.MetaType¶
Bases:
type
Base metaclass for cstruct type classes.
- cs: dissect.cstruct.cstruct.cstruct¶
The cstruct instance this type class belongs to.
- size: int | None¶
The size of the type in bytes. Can be
None
for dynamic sized types.
- dynamic: bool¶
Whether or not the type is dynamically sized.
- alignment: int | None¶
The alignment of the type in bytes. A value of
None
will be treated as 1-byte aligned.
- __call__(*args, **kwargs) MetaType | BaseType ¶
Adds support for
TypeClass(bytes | file-like object)
parsing syntax.
- __getitem__(num_entries: int | dissect.cstruct.expression.Expression | None) ArrayMetaType ¶
Create a new array with the given number of entries.
- __len__() int ¶
Return the byte size of the type.
- reads(data: bytes) BaseType ¶
Parse the given data from a bytes-like object.
- Parameters:
data – Bytes-like object to parse.
- Returns:
The parsed value of this type.
- read(obj: BinaryIO | bytes) BaseType ¶
Parse the given data.
- Parameters:
obj – Data to parse. Can be a bytes-like object or a file-like object.
- Returns:
The parsed value of this type.
- write(stream: BinaryIO, value: Any) int ¶
Write a value to a writable file-like object.
- Parameters:
stream – File-like objects that supports writing.
value – Value to write.
- Returns:
The amount of bytes written.
- class dissect.cstruct.types.base.BaseType¶
Base class for cstruct type classes.
- dumps¶
- write¶
- __len__() int ¶
Return the byte size of the type.
- class dissect.cstruct.types.base.ArrayMetaType¶
Bases:
MetaType
Base metaclass for array-like types.
- num_entries: int | dissect.cstruct.expression.Expression | None¶
- null_terminated: bool¶