# Memory Manager
`memory_manager` is a Python package designed to facilitate hooking and manipulating game memory using the `pymem` library. This package simplifies the process of reading and writing memory addresses for various in-game variables, such as currency and weapon ammo, providing an easy-to-use library.
## Features
- Hook into a game's process using `pymem`.
- Read and write different data types (e.g., integers, floats) at specified memory addresses.
- Support for both constant and recalculated pointers.
- Simple and clear API for memory manipulation.
## Installation
You can install `memory_manager` via pip:
```bash
pip install memory_manager
```
# Usage
## Basic Setup
To get started, import the MemoryManager class and use the hook method to attach to the game's process and module.
```python
from memory_manager import MemoryManager
# Initialize the memory manager and hook into the game's process and module
process_name = "game_name"
module_name = "game_module"
pointers = {
"Health": {
"Address": 0xB6,
"Offsets": [0x1A, 0x2B, 0x3C],
"Type": "4 Bytes",
"Constant": True
},
"Gold": {
"Address": 0x1DE,
"Offsets": [0x4D, 0x5E, 0x6F],
"Type": "4 Bytes",
"Constant": False
},
"PlayerStats": {
"Stamina": {
"Address": 0x2F,
"Offsets": [0xA, 0xB, 0xC],
"Type": "Float",
"Constant": True
},
"Experience": {
"Address": 0x3A,
"Offsets": [0xD, 0xE],
"Type": "2 Bytes",
"Constant": True
}
}
}
mm = MemoryManager()
pointers = mm.hook(process_name, module_name, pointers)
```
## Reading and Writing Memory
Once you've hooked into the game's process, you can read and write memory values using the Get and Set methods attached to each pointer.
### Reading Memory
```python
# Read the value of health
health = pointers["Health"]["Get"]()
print(f"Current health: {health}")
# Read the value of gold
gold = pointers["Gold"]["Get"]()
print(f"Current gold: {gold}")
# Read the value of stamina
stamina = pointers["PlayerStats"]["Stamina"]["Get"]()
print(f"Current stamina: {stamina}")
# Read the value of experience
experience = pointers["PlayerStats"]["Experience"]["Get"]()
print(f"Current experience: {experience}")
```
### Writing Memory
```python
# Set the value of health
new_health_value = 100
pointers["Health"]["Set"](new_health_value)
# Set the value of gold
new_gold_value = 9999
pointers["Gold"]["Set"](new_gold_value)
# Set the value of stamina
new_stamina_value = 75.5
pointers["PlayerStats"]["Stamina"]["Set"](new_stamina_value)
# Set the value of experience
new_experience_value = 5000
pointers["PlayerStats"]["Experience"]["Set"](new_experience_value)
```
## Handling Errors
The memory_manager package is designed to handle errors gracefully. If a memory read or write operation fails, the functions will return False instead of raising an exception.
```python
# Attempt to read memory
success = pointers["Health"]["Get"]()
if not success:
print("Failed to read health value.")
# Attempt to write memory
success = pointers["PlayerStats"]["Experience"]["Set"](new_gold_value)
if not success:
print("Failed to write new gold value.")
```
## Advanced Usage
### Custom Data Types
You can extend the MemoryManager to support additional data types by modifying the read_funcs and write_funcs dictionaries.
```python
# Add support for 8-byte integers
mm.read_funcs["8 Bytes"] = mm.mem.read_longlong
mm.write_funcs["8 Bytes"] = mm.mem.write_longlong
# Example usage
pointers["New Pointer"] = {
"Address": 0x11223344,
"Offsets": [0x70, 0x80],
"Type": "8 Bytes",
"Constant": True
}
value = pointers["New Pointer"]["Get"]()
pointers["New Pointer"]["Set"](value + 100)
```
### Dynamic Pointer Calculation
For pointers that require dynamic recalculation (i.e., Constant is False), the Get and Set methods will automatically recalculate the pointer address before performing the read or write operation.
```python
# Read and write dynamic pointers
gold = pointers["Gold"]["Get"]()
pointers["Gold"]["Set"](gold + 500)
```
# Acknowledgments
- pymem - A python library for process memory manipulation.
Raw data
{
"_id": null,
"home_page": null,
"name": "memory-manager",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": "videogame, memory, addresses, manager",
"author": "FURYMOB",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/40/ab/ac24ac42ff19e5dffb6a68eb347dcbcfcdb309ac18fdab989c31400bb747/memory_manager-0.21.tar.gz",
"platform": null,
"description": "# Memory Manager\r\n\r\n`memory_manager` is a Python package designed to facilitate hooking and manipulating game memory using the `pymem` library. This package simplifies the process of reading and writing memory addresses for various in-game variables, such as currency and weapon ammo, providing an easy-to-use library.\r\n\r\n## Features\r\n\r\n- Hook into a game's process using `pymem`.\r\n- Read and write different data types (e.g., integers, floats) at specified memory addresses.\r\n- Support for both constant and recalculated pointers.\r\n- Simple and clear API for memory manipulation.\r\n\r\n## Installation\r\n\r\nYou can install `memory_manager` via pip:\r\n\r\n```bash\r\npip install memory_manager\r\n```\r\n\r\n# Usage\r\n## Basic Setup\r\n\r\nTo get started, import the MemoryManager class and use the hook method to attach to the game's process and module.\r\n\r\n```python\r\nfrom memory_manager import MemoryManager\r\n\r\n# Initialize the memory manager and hook into the game's process and module\r\nprocess_name = \"game_name\"\r\nmodule_name = \"game_module\"\r\npointers = {\r\n \"Health\": {\r\n \"Address\": 0xB6,\r\n \"Offsets\": [0x1A, 0x2B, 0x3C],\r\n \"Type\": \"4 Bytes\",\r\n \"Constant\": True\r\n },\r\n \"Gold\": {\r\n \"Address\": 0x1DE,\r\n \"Offsets\": [0x4D, 0x5E, 0x6F],\r\n \"Type\": \"4 Bytes\",\r\n \"Constant\": False\r\n },\r\n \"PlayerStats\": {\r\n \"Stamina\": {\r\n \"Address\": 0x2F,\r\n \"Offsets\": [0xA, 0xB, 0xC],\r\n \"Type\": \"Float\",\r\n \"Constant\": True\r\n },\r\n \"Experience\": {\r\n \"Address\": 0x3A,\r\n \"Offsets\": [0xD, 0xE],\r\n \"Type\": \"2 Bytes\",\r\n \"Constant\": True\r\n }\r\n }\r\n}\r\n\r\nmm = MemoryManager()\r\npointers = mm.hook(process_name, module_name, pointers)\r\n```\r\n## Reading and Writing Memory\r\nOnce you've hooked into the game's process, you can read and write memory values using the Get and Set methods attached to each pointer.\r\n\r\n### Reading Memory\r\n```python\r\n# Read the value of health\r\nhealth = pointers[\"Health\"][\"Get\"]()\r\nprint(f\"Current health: {health}\")\r\n\r\n# Read the value of gold\r\ngold = pointers[\"Gold\"][\"Get\"]()\r\nprint(f\"Current gold: {gold}\")\r\n\r\n# Read the value of stamina\r\nstamina = pointers[\"PlayerStats\"][\"Stamina\"][\"Get\"]()\r\nprint(f\"Current stamina: {stamina}\")\r\n\r\n# Read the value of experience\r\nexperience = pointers[\"PlayerStats\"][\"Experience\"][\"Get\"]()\r\nprint(f\"Current experience: {experience}\")\r\n```\r\n\r\n### Writing Memory\r\n```python\r\n# Set the value of health\r\nnew_health_value = 100\r\npointers[\"Health\"][\"Set\"](new_health_value)\r\n\r\n# Set the value of gold\r\nnew_gold_value = 9999\r\npointers[\"Gold\"][\"Set\"](new_gold_value)\r\n\r\n# Set the value of stamina\r\nnew_stamina_value = 75.5\r\npointers[\"PlayerStats\"][\"Stamina\"][\"Set\"](new_stamina_value)\r\n\r\n# Set the value of experience\r\nnew_experience_value = 5000\r\npointers[\"PlayerStats\"][\"Experience\"][\"Set\"](new_experience_value)\r\n```\r\n\r\n## Handling Errors\r\nThe memory_manager package is designed to handle errors gracefully. If a memory read or write operation fails, the functions will return False instead of raising an exception.\r\n\r\n```python\r\n# Attempt to read memory\r\nsuccess = pointers[\"Health\"][\"Get\"]()\r\nif not success:\r\n print(\"Failed to read health value.\")\r\n\r\n# Attempt to write memory\r\nsuccess = pointers[\"PlayerStats\"][\"Experience\"][\"Set\"](new_gold_value)\r\nif not success:\r\n print(\"Failed to write new gold value.\")\r\n```\r\n\r\n## Advanced Usage\r\n### Custom Data Types\r\nYou can extend the MemoryManager to support additional data types by modifying the read_funcs and write_funcs dictionaries.\r\n\r\n```python\r\n# Add support for 8-byte integers\r\nmm.read_funcs[\"8 Bytes\"] = mm.mem.read_longlong\r\nmm.write_funcs[\"8 Bytes\"] = mm.mem.write_longlong\r\n\r\n# Example usage\r\npointers[\"New Pointer\"] = {\r\n \"Address\": 0x11223344,\r\n \"Offsets\": [0x70, 0x80],\r\n \"Type\": \"8 Bytes\",\r\n \"Constant\": True\r\n}\r\n\r\nvalue = pointers[\"New Pointer\"][\"Get\"]()\r\npointers[\"New Pointer\"][\"Set\"](value + 100)\r\n```\r\n\r\n### Dynamic Pointer Calculation\r\nFor pointers that require dynamic recalculation (i.e., Constant is False), the Get and Set methods will automatically recalculate the pointer address before performing the read or write operation.\r\n\r\n```python\r\n# Read and write dynamic pointers\r\ngold = pointers[\"Gold\"][\"Get\"]()\r\npointers[\"Gold\"][\"Set\"](gold + 500)\r\n```\r\n# Acknowledgments\r\n- pymem - A python library for process memory manipulation.\r\n",
"bugtrack_url": null,
"license": null,
"summary": "Memory manager for hooking and manipulating game memory",
"version": "0.21",
"project_urls": null,
"split_keywords": [
"videogame",
" memory",
" addresses",
" manager"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "5bc7a0b534363745c69e5b387b2f84138e4623974d5489b5410826cb8804fcdd",
"md5": "5348f62db4e7ad84a7d5244363edde59",
"sha256": "52709a23ea99b4d6be3a52233ab8a0ce332922c7cfde01231f55241caa39c7b5"
},
"downloads": -1,
"filename": "memory_manager-0.21-py3-none-any.whl",
"has_sig": false,
"md5_digest": "5348f62db4e7ad84a7d5244363edde59",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 3887,
"upload_time": "2024-06-20T21:48:45",
"upload_time_iso_8601": "2024-06-20T21:48:45.754330Z",
"url": "https://files.pythonhosted.org/packages/5b/c7/a0b534363745c69e5b387b2f84138e4623974d5489b5410826cb8804fcdd/memory_manager-0.21-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "40abac24ac42ff19e5dffb6a68eb347dcbcfcdb309ac18fdab989c31400bb747",
"md5": "14528c7a17a310924beaf5373525d1e6",
"sha256": "4b7041977c45c323c614ae7cf2a5d1e9f919fce8845790f45f44e13a9b0f5647"
},
"downloads": -1,
"filename": "memory_manager-0.21.tar.gz",
"has_sig": false,
"md5_digest": "14528c7a17a310924beaf5373525d1e6",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 3706,
"upload_time": "2024-06-20T21:48:47",
"upload_time_iso_8601": "2024-06-20T21:48:47.247322Z",
"url": "https://files.pythonhosted.org/packages/40/ab/ac24ac42ff19e5dffb6a68eb347dcbcfcdb309ac18fdab989c31400bb747/memory_manager-0.21.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-06-20 21:48:47",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "memory-manager"
}