Bases: vstruct.VStruct
Bases: vstruct.primitives.v_base
The VStruct class is the bases for all groups of primitive fields which define a “structure”. Fields may be added with vsAddField() or simply added as attributes (provided you use a VStruct or one of the vstruct.primitives in the initial assignment.)
import vstruct from vstruct.primitives import *
vs = vstruct.VStruct() vs.fieldone = v_uint32() vs.fieldtwo = v_str(size=30)
bytes = vs.vsEmit()
Register a callback which will be triggered when the field with the given name is set by the parser. This can be used to simplify auto-parsing to change fields sizes or whatnot during parsing.
(You may also name a method pcb_<FieldName> to get a callback for your struct.)
Example:
- def updateLengthTarget(vs):
- dostuff()
v.vsAddParseCallback(‘lenfield’, updateLengthTarget)
Calculate fields which need correction before emitting bytes etc...
(VStruct extenders may call this, then modify fields internally)
Clear all fields from the current vstruct object. This may be useful in specialized parsers which populate their structure on vsParse()
Get a list of (fieldname, fieldobj) tuples for all the kids in this VStruct (non-recursive)
return an order’d list of the primitive fields in this structure definition. This is recursive and will return the sub fields of all nested structures.
Test weather this structure contains a field with the given name....
WARNING: vsInsertField does NOT honor field alignment! # FIXME (AND CAN MESS UP OTHER FIELDS ALIGNMENT!)
Bases: vstruct.VStruct
Return an instance of the specified structure. The structure name may be a definition that was added with addStructure() or a python path (ie. win32.TEB) of a definition from within vstruct.defs.
VStruct builder! Used to serialize structure definitions etc...
Bases: vstruct.primitives.v_prim
Bases: vstruct.primitives.v_prim
v_bytes is used for fixed width byte fields.
Bases: vstruct.primitives.v_number
Bases: vstruct.primitives.v_number
Bases: vstruct.primitives.v_number
Bases: vstruct.primitives.v_number
Bases: vstruct.primitives.v_number
Bases: vstruct.primitives.v_prim
Bases: vstruct.primitives.v_base
Get the type specific value for this field. (Used by the structure dereference method to return a python native for the field by name)
Parser for primitives which assumes we are calling parse directly.
Bases: vstruct.primitives.v_size_t
Bases: vstruct.primitives.v_ptr
Bases: vstruct.primitives.v_ptr
Bases: vstruct.primitives.v_number
Bases: vstruct.primitives.v_prim
A string placeholder class which will automagically return up to a null terminator (and will keep it’s size by null padding when assigned to)
Bases: vstruct.primitives.v_number
Bases: vstruct.primitives.v_number
Bases: vstruct.primitives.v_number
Bases: vstruct.primitives.v_number
Bases: vstruct.primitives.v_number
Bases: vstruct.primitives.v_str
Unicode variant of the above string class
NOTE: the size paramater is in WCHARs!
Bases: vstruct.primitives.v_prim
A string placeholder class which will automagically return up to a null terminator dynamically.
Bases: vstruct.VStruct