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 details)
Built Distribution
memhax-0.1.0-py3-none-any.whl
(12.2 kB
view details)
File details
Details for the file memhax-0.1.0.tar.gz
.
File metadata
- Download URL: memhax-0.1.0.tar.gz
- Upload date:
- Size: 9.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.0rc1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d617beccb6c8d452cd0c53c6547b99bcd23ea59efc4736010b5016bcf9a672d5 |
|
MD5 | 704bfc2b45edc9ce79afd24f56903973 |
|
BLAKE2b-256 | 9df3aeac8e339cb75fb0d03a8bd5734d1f9d21e3f5ff5b3c9778e3b0a7ba362a |
File details
Details for the file memhax-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: memhax-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.0rc1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 55373eddbec32a4e8f197ccad947e6ed6b9554452f5909fa5513ff8d55f496e6 |
|
MD5 | b8a6fd8ed37f8547457b95c1cf9997f9 |
|
BLAKE2b-256 | 9a756c4bd8bfb4f7be58a850e6f201ffb405ed103f8e89b5691ff5e917fc3d66 |