Skip to content

Commit 919e79e

Browse files
committed
docs: add main README for the repository
1 parent 69f2657 commit 919e79e

1 file changed

Lines changed: 64 additions & 0 deletions

File tree

README.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,65 @@
11
# libdestruct
2+
3+
**Native structs made Pythonic.**
4+
5+
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.
6+
7+
With libdestruct you can:
8+
- Define C structs using Python type annotations
9+
- Read and write typed values from raw memory buffers
10+
- Follow pointers, including self-referential types (linked lists, trees)
11+
- Work with arrays, enums, and nested structs
12+
- Parse C struct definitions directly from source
13+
- Snapshot values and track changes with freeze/diff/reset
14+
15+
## Installation
16+
17+
```bash
18+
pip install git+https://github.com/mrindeciso/libdestruct.git
19+
```
20+
21+
## Your first script
22+
23+
```python
24+
from libdestruct import struct, c_int, c_long, inflater
25+
26+
class player_t(struct):
27+
health: c_int
28+
score: c_long
29+
30+
memory = bytearray(b"\x64\x00\x00\x00\x39\x05\x00\x00\x00\x00\x00\x00")
31+
32+
lib = inflater(memory)
33+
player = lib.inflate(player_t, 0)
34+
35+
print(player.health.value) # 100
36+
print(player.score.value) # 1337
37+
38+
# Write a new value back to memory
39+
player.health.value = 200
40+
print(player.health.value) # 200
41+
```
42+
43+
You can also skip the Python definition and parse C directly:
44+
45+
```python
46+
from libdestruct.c.struct_parser import definition_to_type
47+
48+
player_t = definition_to_type("""
49+
struct player_t {
50+
int health;
51+
long score;
52+
};
53+
""")
54+
55+
player = player_t.from_bytes(b"\x64\x00\x00\x00\x39\x05\x00\x00\x00\x00\x00\x00")
56+
print(player.health.value) # 100
57+
```
58+
59+
## Project Links
60+
61+
Documentation: [docs/](docs/)
62+
63+
## License
64+
65+
libdestruct is licensed under the [MIT License](LICENSE).

0 commit comments

Comments
 (0)