Skip to main content
Help us improve PyPI by participating in user testing. All experience levels needed!

Vivisect Structure Definition/Parsing Library

Project description

vstruct2 ( Mark II )

Vivisect Structure Definition/Parsing Library
|Build Status|


.. code::

python3.4 -m pip install vstruct2

vstruct2 can now be installed via pip!

Additionally, a repository of existing structure definitions
is available as a seperate package named fracture.


Basic Parsing

Simple vstruct2 byte parsing:

.. code:: python

from vstruct2.types import *

class Foo(VStruct):

def __init__(self):
VStruct.__init__(self) = uint32()
self.baz = vbytes(20)

foo = Foo()

# read in byts from somewhere...

# access struct fields by name
if == 30:
print('bar == 30!')

# assign fields by name = 90

# emit modified bytes back out
byts = bytes(foo) # same as foo.vsEmit()

Parser Callbacks

WriteBack Bytes/Files

vstruct2 supports "writeback" functionality for both files and mutable
bytearray types, allowing field assignments to change the underlying file
or bytearray immediately.

.. code:: python

class Foo(VStruct):

def __init__(self):
VStruct.__init__(self) = uint32()
self.baz = uint32()

foo = Foo()

# ba is a bytearray
foo.vsParse(ba, writeback=True)

# if bar is 30, set baz to 99
if == 30:
foo.baz = 99

# ba bytearray has now been modified

Enum Types

.. |Build Status| image::

Project details

Release history Release notifications

This version
History Node


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
vstruct2-2.0.2-py2-none-any.whl (9.5 kB) Copy SHA256 hash SHA256 Wheel 2.7 Mar 3, 2017
vstruct2-2.0.2-py3-none-any.whl (9.5 kB) Copy SHA256 hash SHA256 Wheel 3.5 Mar 3, 2017

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page