Installation
From PyPI (Recommended)
From Source
Custom libmem Installation
If you have libmem installed in a custom location, set theLIBDIR environment variable:
Requirements
- Python >= 3.6
- Automatically fetches libmem binaries (no manual installation needed)
Importing
Basic Usage
Finding Processes and Modules
Reading and Writing Memory
Memory Scanning
Complete Example: Health Hack
Working with Data Types
Converting Integers to Bytes
Reading Data Types
Assembly and Disassembly
Assembling Instructions
Disassembling Instructions
Function Hooking
Working with Pointer Chains
Pattern and Signature Scanning
Memory Allocation and Protection
Key Functions
Process Management
| Function | Return Type | Description |
|---|---|---|
find_process(name) | Process or None | Find process by name |
get_process() | Process or None | Get current process |
is_process_alive(process) | bool | Check if process is alive |
enum_processes() | list[Process] or None | List all processes |
Module Management
| Function | Return Type | Description |
|---|---|---|
find_module(name) | Module or None | Find module in current process |
find_module_ex(proc, name) | Module or None | Find module in target process |
enum_modules() | list[Module] or None | List modules in current process |
enum_modules_ex(proc) | list[Module] or None | List modules in target process |
load_module(path) | Module or None | Load a module/library |
load_module_ex(proc, path) | Module or None | Load module into target process |
Memory Operations
| Function | Return Type | Description |
|---|---|---|
read_memory(addr, size) | bytearray or None | Read memory in current process |
read_memory_ex(proc, addr, size) | bytearray or None | Read memory in target process |
write_memory(addr, data) | int | Write memory in current process |
write_memory_ex(proc, addr, data) | int | Write memory in target process |
alloc_memory(size, prot) | int or None | Allocate memory |
alloc_memory_ex(proc, size, prot) | int or None | Allocate memory in target process |
free_memory(addr, size) | bool | Free allocated memory |
free_memory_ex(proc, addr, size) | bool | Free memory in target process |
prot_memory(addr, size, prot) | Prot or None | Change memory protection |
prot_memory_ex(proc, addr, size, prot) | Prot or None | Change protection in target process |
Scanning
| Function | Return Type | Description |
|---|---|---|
sig_scan(sig, addr, size) | int or None | Signature scan in current process |
sig_scan_ex(proc, sig, addr, size) | int or None | Signature scan in target process |
pattern_scan(pattern, mask, addr, size) | int or None | Pattern scan with mask |
pattern_scan_ex(proc, pattern, mask, addr, size) | int or None | Pattern scan in target process |
data_scan(data, addr, size) | int or None | Scan for exact bytes |
data_scan_ex(proc, data, addr, size) | int or None | Data scan in target process |
deep_pointer(base, offsets) | int | Resolve pointer chain |
deep_pointer_ex(proc, base, offsets) | int or None | Resolve pointer chain in target process |
Assembly/Disassembly
| Function | Return Type | Description |
|---|---|---|
assemble(code) | Inst or None | Assemble single instruction |
assemble_ex(code, arch, addr) | bytearray or None | Assemble multiple instructions |
disassemble(addr) | Inst or None | Disassemble single instruction |
disassemble_ex(addr, arch, max_size, count, runtime_addr) | list[Inst] or None | Disassemble multiple instructions |
Hooking
| Function | Return Type | Description |
|---|---|---|
hook_code(from_addr, to_addr) | Trampoline or None | Hook a function |
hook_code_ex(proc, from_addr, to_addr) | RemoteTrampoline or None | Hook in target process |
unhook_code(from_addr, trampoline) | bool | Remove a hook |
unhook_code_ex(proc, from_addr, trampoline) | bool | Remove hook in target process |
Type Reference
Error Handling
Python bindings returnNone on failure:
See Also
- C/C++ Bindings - C and C++ language bindings
- Rust Bindings - Rust language bindings
- API Reference - Complete API documentation