dissect.cstruct.types.structure¶
Module Contents¶
Classes¶
Structure field. |
|
Base metaclass for cstruct structure type classes. |
|
Base class for cstruct structure type classes. |
|
A proxy for the values of fields of a Structure. |
|
Base metaclass for cstruct union type classes. |
|
Base class for cstruct union type classes. |
|
Functions¶
Generates an |
|
Generates an |
|
Generates an |
|
Generates a |
|
Generates a |
|
Generates an |
|
Generates an |
|
Generates an |
|
Generates a |
|
Generates a |
- class dissect.cstruct.types.structure.Field(name: str | None, type_: type[dissect.cstruct.types.base.BaseType], bits: int | None = None, offset: int | None = None)¶
Structure field.
- name¶
- type¶
- bits = None¶
- offset = None¶
- alignment¶
- __repr__() str¶
- class dissect.cstruct.types.structure.StructureMetaType¶
Bases:
dissect.cstruct.types.base.MetaTypeBase metaclass for cstruct structure type classes.
- fields: dict[str, Field]¶
Mapping of field names to
Fieldobjects, including “folded” fields from anonymous structures.
- lookup: dict[str, Field]¶
Mapping of “raw” field names to
Fieldobjects. E.g. holds the anonymous struct and not its fields.
- __fields__: list[Field]¶
List of
Fieldobjects for this structure. This is the structures’ Single Source Of Truth.
- __align__: bool¶
- __anonymous__: bool¶
- __updating__ = False¶
- __compiled__ = False¶
- __static_sizes__: dict[str, int]¶
- __call__(*args, **kwargs) typing_extensions.Self¶
Adds support for
TypeClass(bytes | file-like object)parsing syntax.
- add_field(name: str, type_: type[dissect.cstruct.types.base.BaseType], bits: int | None = None, offset: int | None = None) None¶
- start_update() collections.abc.Iterator[None]¶
- commit() None¶
- class dissect.cstruct.types.structure.Structure¶
Bases:
dissect.cstruct.types.base.BaseTypeBase class for cstruct structure type classes.
Note that setting attributes which do not correspond to a field in the structure results in undefined behavior. For performance reasons, the structure does not check if the field exists when writing to an attribute.
- __dynamic_sizes__: dict[str, int]¶
- __len__() int¶
Return the byte size of the type.
- __getitem__(item: str) Any¶
- __repr__() str¶
- property __values__: collections.abc.MutableMapping[str, Any]¶
- property __sizes__: collections.abc.Mapping[str, int | None]¶
- class dissect.cstruct.types.structure.StructureValuesProxy(struct: Structure)¶
Bases:
collections.abc.MutableMappingA proxy for the values of fields of a Structure.
- __getitem__(key: str) Any¶
- __setitem__(key: str, value: Any) None¶
- __contains__(key: str) bool¶
- __iter__() collections.abc.Iterator[str]¶
- __len__() int¶
- __repr__() str¶
- abstract __delitem__(_: str)¶
- class dissect.cstruct.types.structure.UnionMetaType¶
Bases:
StructureMetaTypeBase metaclass for cstruct union type classes.
- __call__(*args, **kwargs) typing_extensions.Self¶
Adds support for
TypeClass(bytes | file-like object)parsing syntax.
- class dissect.cstruct.types.structure.Union¶
Bases:
StructureBase class for cstruct union type classes.
- __eq__(other: object) bool¶
- __setattr__(attr: str, value: Any) None¶
- class dissect.cstruct.types.structure.UnionProxy(union: Union, attr: str, target: Structure)¶
-
- __attr__: str¶
- __len__() int¶
- __getitem__(item: str) Any¶
- __repr__() str¶
- __getattr__(attr: str) Any¶
- __setattr__(attr: str, value: Any) None¶
- dissect.cstruct.types.structure.attrsetter(path: str) collections.abc.Callable[[Any], Any]¶
- dissect.cstruct.types.structure._make_structure__init__(fields: list[str]) str¶
Generates an
__init__method for a structure with the specified fields.- Parameters:
fields – List of field names.
- dissect.cstruct.types.structure._make_union__init__(fields: list[str]) str¶
Generates an
__init__method for a class with the specified fields using setattr.- Parameters:
fields – List of field names.
- dissect.cstruct.types.structure._make__eq__(fields: list[str]) str¶
Generates an
__eq__method for a class with the specified fields.- Parameters:
fields – List of field names.
- dissect.cstruct.types.structure._make__bool__(fields: list[str]) str¶
Generates a
__bool__method for a class with the specified fields.- Parameters:
fields – List of field names.
- dissect.cstruct.types.structure._make__hash__(fields: list[str]) str¶
Generates a
__hash__method for a class with the specified fields.- Parameters:
fields – List of field names.
- dissect.cstruct.types.structure._generate_structure__init__(fields: list[Field]) types.FunctionType¶
Generates an
__init__method for a structure with the specified fields.- Parameters:
fields – List of field names.
- dissect.cstruct.types.structure._generate_union__init__(fields: list[Field]) types.FunctionType¶
Generates an
__init__method for a union with the specified fields.- Parameters:
fields – List of field names.
- dissect.cstruct.types.structure._generate__eq__(fields: list[str]) types.FunctionType¶
Generates an
__eq__method for a class with the specified fields.- Parameters:
fields – List of field names.
- dissect.cstruct.types.structure._generate__bool__(fields: list[str]) types.FunctionType¶
Generates a
__bool__method for a class with the specified fields.- Parameters:
fields – List of field names.
- dissect.cstruct.types.structure._generate__hash__(fields: list[str]) types.FunctionType¶
Generates a
__hash__method for a class with the specified fields.- Parameters:
fields – List of field names.