A Python library for getting access to raw memory and internals
Project description
Memhax
A python library for accessing raw python objects and other regions in memory.
Installation
$ pip install memhax
Usage
Read/Write raw memory
from memhax.constants import memory
# Read 4 bytes from address 0x12345678
with memory(0x12345678) as mem:
data = mem.read(4)
Dump an object's struct
from memhax.cpython.primitives import PyLongObject
print(PyLongObject)
# struct PyLongObject {
# Py_ssize_t ob_refcnt;
# PyTypeObject* ob_type;
# Py_ssize_t ob_size;
# uint32_t[] ob_digit;
# }
Read/modify python objects
from memhax.cpython.collections import PyTupleObject
my_tuple = (1, "abc", 3.5)
tuple_obj = PyTupleObject(id(my_tuple))
# Get the tuple's length
print(tuple_obj.ob_size()) # => 3
# Replace an item in the tuple
new_item = [my_tuple, b"123"]
tuple_obj.ob_item[0].raw(id(new_item))
print(my_tuple) # => ([(...), b'123'], 'abc', 3.5)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
memhax-0.1.0.tar.gz
(9.6 kB
view hashes)
Built Distribution
memhax-0.1.0-py3-none-any.whl
(12.2 kB
view hashes)