Vstruct2
Vivisect Structure Definition/Parsing Library
Install / Use
/learn @vivisect/Vstruct2README
vstruct2 ( Mark II )
Vivisect Structure Definition/Parsing Library |Build Status|
Installing
.. 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.
Examples
Basic Parsing
Simple vstruct2 byte parsing:
.. code:: python
from vstruct2.types import *
class Foo(VStruct):
def __init__(self):
VStruct.__init__(self)
self.bar = uint32()
self.baz = vbytes(20)
foo = Foo()
# read in byts from somewhere...
foo.vsParse(byts)
# access struct fields by name
if foo.bar == 30:
print('bar == 30!')
# assign fields by name
foo.bar = 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)
self.bar = uint32()
self.baz = uint32()
foo = Foo()
# ba is a bytearray
foo.vsParse(ba, writeback=True)
# if bar is 30, set baz to 99
if foo.bar == 30:
foo.baz = 99
# ba bytearray has now been modified
Enum Types
.. |Build Status| image:: https://travis-ci.org/vivisect/vstruct2.svg :target: https://travis-ci.org/vivisect/vstruct2
Related Skills
node-connect
347.0kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
107.8kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
347.0kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
347.0kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
