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.
_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.The field
num
should be at offset0x4
of the structureTest
, instead of0x2
.