Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
617abe2
style: refactor project
MrIndeciso Jul 15, 2025
60ebfe0
fix: correct various problems in the codebase
MrIndeciso Mar 31, 2026
e282510
test: add general check for issue #6
MrIndeciso Mar 31, 2026
85fcd48
fix: cast to bytes in MemoryResolver instead of returning the slice d…
MrIndeciso Mar 31, 2026
7bc1802
test: add more test coverage on the entire codebase
MrIndeciso Mar 31, 2026
69f2657
fix: avoid name clashes with address and other members
MrIndeciso Mar 31, 2026
919e79e
docs: add main README for the repository
MrIndeciso Mar 31, 2026
3778fda
docs: add basic project documentation
MrIndeciso Mar 31, 2026
570dea3
feat: implement bitfield support
MrIndeciso Mar 31, 2026
54ef86a
docs: add bitfield documentation
MrIndeciso Mar 31, 2026
9aeae00
test: add bitfield tests
MrIndeciso Mar 31, 2026
c6cfefc
test: add tests for c_float and c_double
MrIndeciso Mar 31, 2026
9ff0e22
fix: add missing support for c_float and c_double
MrIndeciso Mar 31, 2026
86e7a07
feat: add support for pointer arithmetics
MrIndeciso Mar 31, 2026
1e1ed75
docs: add documentation about pointer arithmetics
MrIndeciso Mar 31, 2026
46e2d14
feat: add support for typedefs in C-to-Python struct parsing
MrIndeciso Mar 31, 2026
5e8dd5a
docs: add documentation for typedef support in C struct parsing
MrIndeciso Mar 31, 2026
40ec6b3
feat: publicly exposed size_of method
MrIndeciso Mar 31, 2026
ca3487f
docs: add documentation about size_of
MrIndeciso Mar 31, 2026
69be136
feat: implement hexdump functionality for all objects
MrIndeciso Mar 31, 2026
bda7078
docs: add guide for hexdump formatting
MrIndeciso Mar 31, 2026
03505ab
fix: implement caching for dereferenced pointer objects
MrIndeciso Mar 31, 2026
2e5b7da
docs: add explanation about pointer caching
MrIndeciso Mar 31, 2026
59f970e
chore: create SKILL.md file for AI agents
MrIndeciso Mar 31, 2026
57def08
fix: export c_char, c_uchar, c_short, c_ushort too
MrIndeciso Mar 31, 2026
911550e
feat: add comparison operators for libdestruct objects
MrIndeciso Mar 31, 2026
628bd37
feat: add support for simple and tagged unions
MrIndeciso Apr 1, 2026
25d7e5b
test: add checks for tagged and simple unions
MrIndeciso Apr 1, 2026
5915b3e
docs: add documentation for simple and tagged unions
MrIndeciso Apr 1, 2026
ee22756
feat: add quick to_dict() method to all objects
MrIndeciso Apr 1, 2026
dd6df6b
feat: add support for alignment in structs
MrIndeciso Apr 1, 2026
0c501ee
fix: solve various issues in the codebase that Opus created and then …
MrIndeciso Apr 1, 2026
7af03fe
feat: add big-endian support in the resolver
MrIndeciso Apr 1, 2026
837c574
fix: struct freezing didn't work correctly, alignment was broken for …
MrIndeciso Apr 1, 2026
fe0353d
style: hide incorrect linter annotation
MrIndeciso Apr 1, 2026
fffff7f
ci: run test suite on all python versions we support
MrIndeciso Apr 1, 2026
726f12d
feat: implement the proposal in issue #5
MrIndeciso Apr 1, 2026
88b489f
feat: add support for modifiers like offset specified through Annotat…
MrIndeciso Apr 1, 2026
baa56de
docs: change docs to use the new declarative types and Annotated fields
MrIndeciso Apr 1, 2026
2a849b6
fix: CoPilot noticed a few smaller mistakes
MrIndeciso Apr 1, 2026
b39a993
fix: solve incorrect union alignment and enum backing type assumptions
MrIndeciso Apr 1, 2026
f134091
fix: Opus found even more bugs, everything should be fixed now
MrIndeciso Apr 1, 2026
8b8ca90
fix: correct wrong enum_of implementation in code and docs
MrIndeciso Apr 1, 2026
f71009a
test/docs: automatically check doc snippets to verity their correctness
MrIndeciso Apr 1, 2026
6bf5c45
feat: implement support for VLAs and file-backed inflaters
MrIndeciso Apr 2, 2026
7c0a412
fix: solve the last remaining bugs I could find in the codebase
MrIndeciso Apr 2, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
timeout-minutes: 15
strategy:
matrix:
python-version: ["3.10", "3.13"]
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]

steps:
- uses: actions/checkout@v4
Expand All @@ -39,7 +39,7 @@ jobs:
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade wheel build
python -m pip install pwntools pytest libdebug
python -m pip install pwntools pytest libdebug mktestdocs

- name: Install library
run: |
Expand Down
64 changes: 64 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,65 @@
# libdestruct

**Native structs made Pythonic.**

libdestruct is a Python library for defining C-like data structures and inflating them directly from raw memory. It is designed for reverse engineering, binary analysis, and debugger scripting — anywhere you need to make sense of packed binary data without writing boilerplate.

With libdestruct you can:
- Define C structs using Python type annotations
- Read and write typed values from raw memory buffers
- Follow pointers, including self-referential types (linked lists, trees)
- Work with arrays, enums, and nested structs
- Parse C struct definitions directly from source
- Snapshot values and track changes with freeze/diff/reset

## Installation

```bash
pip install git+https://github.com/mrindeciso/libdestruct.git
```

## Your first script

```python
from libdestruct import struct, c_int, c_long, inflater

class player_t(struct):
health: c_int
score: c_long

memory = bytearray(b"\x64\x00\x00\x00\x39\x05\x00\x00\x00\x00\x00\x00")

lib = inflater(memory)
player = lib.inflate(player_t, 0)

print(player.health.value) # 100
print(player.score.value) # 1337

# Write a new value back to memory
player.health.value = 200
print(player.health.value) # 200
```

You can also skip the Python definition and parse C directly:

```python
from libdestruct.c.struct_parser import definition_to_type

player_t = definition_to_type("""
struct player_t {
int health;
long score;
};
""")

player = player_t.from_bytes(b"\x64\x00\x00\x00\x39\x05\x00\x00\x00\x00\x00\x00")
print(player.health.value) # 100
```

## Project Links

Documentation: [docs/](docs/)

## License

libdestruct is licensed under the [MIT License](LICENSE).
Loading
Loading