Metadata-Version: 2.1
Name: memory_manager
Version: 0.31
Summary: Memory manager for hooking and manipulating game memory
Author: FURYMOB
Author-email: 
Keywords: videogame,memory,addresses,manager,triggers
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.6
Description-Content-Type: text/markdown
Requires-Dist: pymem

Sure, here's the complete and updated description of `memory_manager` in English, including the new trigger features, usage examples, and detailed explanations.

# 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.
- Manage triggers to monitor changes in memory values and execute callback functions.

## 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_experience_value)
if not success:
    print("Failed to write new experience 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)
```

### Triggers
You can add triggers to monitor changes in memory values and execute callback functions when a change is detected. This is useful for real-time updates and monitoring specific in-game variables.

#### Adding a Trigger
```python
# Define a callback function for the triggers
def on_value_change(old_value, new_value):
    print(f"Value changed from {old_value} to {new_value}")

# Add a trigger to monitor "Health" every 0.5 seconds
trigger = pointers["Health"]["Triggers"](0.5, on_value_change)

# Main loop (the program could continue doing other things here)
try:
    while True:
        time.sleep(1)  # Simulating the main loop of the program
except KeyboardInterrupt:
    print("Program interrupted.")
    # Remove the trigger when the program ends
    trigger()
```

#### Removing a Trigger
The trigger can be removed by calling the function returned when the trigger was added.

```python
# Remove the trigger
trigger()
```

# Acknowledgments
- `pymem` - A Python library for process memory manipulation.

This extended example provides a comprehensive guide to using the `memory_manager` library, including setting up triggers to monitor memory changes dynamically. Adjust the base addresses, offsets, and process/module names as needed for your specific use case.
