Skip to content

Optional explicit sizing of structure #22

@emesare

Description

@emesare
class SizedStruct(Structure):
  _size_ = 0x4
  _fields_ = [("len", c_int16)]

_size_ will bound _fields_ & _offsets_ to be at most, >= _size_, while also ensuring that the structures size in memory is respected so that if the fields defined are less than _size_ (in bytes) the subsequent associated reads are starting at _size_. i.e.

class Test(Structure):
  _fields_ = [("sized", SizedStruct), ("num", c_int32)]

The field num should be at offset 0x4 of the structure Test, instead of 0x2.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions