|
| 1 | +# Advanced Cheat Engine Bridge Functionality |
| 2 | + |
| 3 | +This document outlines the advanced functionality that has been added to the Cheat Engine Bridge Module (`ce_bridge.py`). |
| 4 | + |
| 5 | +## New Data Structures |
| 6 | + |
| 7 | +### MemoryScanResult |
| 8 | +- **Purpose**: Represents results from memory scanning operations |
| 9 | +- **Fields**: address, value, data_type, size, region_info |
| 10 | +- **Usage**: Returned by all memory scanning functions |
| 11 | + |
| 12 | +### DisassemblyResult |
| 13 | +- **Purpose**: Represents disassembled code instructions |
| 14 | +- **Fields**: address, bytes_data, mnemonic, op_str, size, groups |
| 15 | +- **Usage**: Returned by code disassembly functions |
| 16 | + |
| 17 | +## Enhanced Memory Scanning |
| 18 | + |
| 19 | +### 1. Value-Based Scanning |
| 20 | +- **Method**: `scan_memory_for_value(handle, value, data_type, start_address, end_address)` |
| 21 | +- **Supports**: int8, int16, int32, int64, uint8-64, float, double, string |
| 22 | +- **Features**: Multi-encoding string search, typed value reading |
| 23 | +- **Safety**: Read-only operations, result limiting |
| 24 | + |
| 25 | +### 2. Range-Based Scanning |
| 26 | +- **Method**: `scan_memory_range(handle, min_value, max_value, data_type, start_address, end_address)` |
| 27 | +- **Purpose**: Find values within a numeric range |
| 28 | +- **Optimization**: Type-aligned scanning for performance |
| 29 | +- **Use Cases**: Health/ammo ranges, coordinate boundaries |
| 30 | + |
| 31 | +### 3. Wildcard Pattern Search |
| 32 | +- **Method**: `find_pattern_with_wildcards(handle, pattern_string, start_address, end_address)` |
| 33 | +- **Format**: "48 8B ? 48 ?? 05" (? or ?? for wildcards) |
| 34 | +- **Features**: Flexible byte pattern matching |
| 35 | +- **Applications**: Code signature detection, API call patterns |
| 36 | + |
| 37 | +## Advanced Code Analysis |
| 38 | + |
| 39 | +### 1. Code Disassembly |
| 40 | +- **Method**: `disassemble_code(handle, address, size, architecture)` |
| 41 | +- **Engine**: Capstone disassembly framework |
| 42 | +- **Architectures**: x86, x64 |
| 43 | +- **Features**: Instruction groups, operand analysis |
| 44 | +- **Output**: Mnemonic, operands, instruction groups |
| 45 | + |
| 46 | +### 2. String Reference Detection |
| 47 | +- **Method**: `find_string_references(handle, target_string, start_address, end_address)` |
| 48 | +- **Encodings**: UTF-8, UTF-16LE, ASCII |
| 49 | +- **Analysis**: Finds code that references strings |
| 50 | +- **Applications**: Function discovery, string table analysis |
| 51 | + |
| 52 | +## Data Structure Analysis |
| 53 | + |
| 54 | +### 1. Automated Structure Detection |
| 55 | +- **Method**: `analyze_data_structures(handle, address, size)` |
| 56 | +- **Detection**: Pointers, strings, repeating patterns |
| 57 | +- **Analysis**: vtables, arrays, object structures |
| 58 | +- **Suggestions**: Potential data type identification |
| 59 | + |
| 60 | +### 2. Type Conversion Utilities |
| 61 | +- **Methods**: `_value_to_bytes()`, `_bytes_to_value()`, `_read_typed_value()` |
| 62 | +- **Support**: All standard data types |
| 63 | +- **Features**: Multi-format string handling |
| 64 | +- **Safety**: Error handling, bounds checking |
| 65 | + |
| 66 | +## Advanced Pointer Analysis |
| 67 | + |
| 68 | +### 1. Reverse Pointer Chain Discovery |
| 69 | +- **Method**: `find_pointer_chains_to_address(handle, target_address, max_depth, max_results)` |
| 70 | +- **Purpose**: Find all pointer chains leading to an address |
| 71 | +- **Depth**: Configurable chain depth (default: 4 levels) |
| 72 | +- **Optimization**: Memory region filtering, result limiting |
| 73 | + |
| 74 | +### 2. Enhanced Pointer Resolution |
| 75 | +- **Method**: `resolve_pointer_chain(handle, base_address, offsets)` (enhanced) |
| 76 | +- **Features**: Better error handling, 64-bit support |
| 77 | +- **Applications**: Dynamic address resolution |
| 78 | + |
| 79 | +## Memory Comparison & Snapshots |
| 80 | + |
| 81 | +### 1. Memory Snapshots |
| 82 | +- **Method**: `create_memory_snapshot(handle, address, size)` |
| 83 | +- **Purpose**: Capture memory state for comparison |
| 84 | +- **Use Cases**: Change detection, state monitoring |
| 85 | + |
| 86 | +### 2. Memory Comparison |
| 87 | +- **Method**: `compare_memory_snapshots(handle, address, size, previous_data)` |
| 88 | +- **Analysis**: Byte-by-byte comparison |
| 89 | +- **Output**: Changed regions, statistics, detailed diff |
| 90 | +- **Applications**: Memory monitoring, cheat detection |
| 91 | + |
| 92 | +### 3. Change-Based Scanning |
| 93 | +- **Method**: `search_for_changed_values(handle, old_value, new_value, data_type, previous_results)` |
| 94 | +- **Purpose**: Next scan functionality |
| 95 | +- **Features**: Filter previous results, progressive refinement |
| 96 | +- **Use Cases**: Value tracking, dynamic analysis |
| 97 | + |
| 98 | +## Safety and Performance Features |
| 99 | + |
| 100 | +### Read-Only Architecture |
| 101 | +- All functions are read-only for safety |
| 102 | +- Write operations intentionally disabled |
| 103 | +- Error logging and graceful failure handling |
| 104 | + |
| 105 | +### Performance Optimizations |
| 106 | +- Chunked memory reading (1MB chunks) |
| 107 | +- Result limiting (10,000 max results) |
| 108 | +- Memory region filtering |
| 109 | +- Type-aligned scanning |
| 110 | + |
| 111 | +### Error Handling |
| 112 | +- Comprehensive exception catching |
| 113 | +- Detailed error logging |
| 114 | +- Graceful degradation |
| 115 | +- Optional dependency handling (Capstone) |
| 116 | + |
| 117 | +## Integration Features |
| 118 | + |
| 119 | +### Conditional Dependencies |
| 120 | +- **Capstone**: Optional for disassembly features |
| 121 | +- **Graceful Fallback**: Functions work without optional dependencies |
| 122 | +- **Runtime Detection**: Automatic capability detection |
| 123 | + |
| 124 | +### Data Type Support |
| 125 | +- **Integers**: 8, 16, 32, 64-bit signed/unsigned |
| 126 | +- **Floating Point**: 32-bit float, 64-bit double |
| 127 | +- **Strings**: UTF-8, UTF-16LE, ASCII with null termination |
| 128 | +- **Raw Bytes**: Hex pattern support |
| 129 | + |
| 130 | +## Usage Examples |
| 131 | + |
| 132 | +### Basic Memory Scanning |
| 133 | +```python |
| 134 | +# Scan for integer value |
| 135 | +results = bridge.scan_memory_for_value(handle, 1000, 'int32') |
| 136 | + |
| 137 | +# Scan for value range |
| 138 | +results = bridge.scan_memory_range(handle, 100, 200, 'int32') |
| 139 | + |
| 140 | +# Wildcard pattern search |
| 141 | +addresses = bridge.find_pattern_with_wildcards(handle, "48 8B ? 48 ?? 05") |
| 142 | +``` |
| 143 | + |
| 144 | +### Code Analysis |
| 145 | +```python |
| 146 | +# Disassemble code |
| 147 | +instructions = bridge.disassemble_code(handle, address, 64, 'x64') |
| 148 | + |
| 149 | +# Find string references |
| 150 | +refs = bridge.find_string_references(handle, "Player") |
| 151 | + |
| 152 | +# Analyze data structure |
| 153 | +analysis = bridge.analyze_data_structures(handle, address, 256) |
| 154 | +``` |
| 155 | + |
| 156 | +### Advanced Operations |
| 157 | +```python |
| 158 | +# Find pointer chains |
| 159 | +chains = bridge.find_pointer_chains_to_address(handle, target_addr, max_depth=3) |
| 160 | + |
| 161 | +# Memory comparison |
| 162 | +snapshot = bridge.create_memory_snapshot(handle, address, 1024) |
| 163 | +# ... later ... |
| 164 | +changes = bridge.compare_memory_snapshots(handle, address, 1024, snapshot) |
| 165 | + |
| 166 | +# Progressive scanning |
| 167 | +first_scan = bridge.scan_memory_for_value(handle, 100, 'int32') |
| 168 | +# ... value changes to 150 ... |
| 169 | +refined = bridge.search_for_changed_values(handle, 100, 150, 'int32', first_scan) |
| 170 | +``` |
| 171 | + |
| 172 | +## Future Enhancements |
| 173 | + |
| 174 | +The modular design allows for easy addition of: |
| 175 | +- Hot patching detection |
| 176 | +- Memory protection analysis |
| 177 | +- Advanced pattern libraries |
| 178 | +- Machine learning-based structure detection |
| 179 | +- Multi-process analysis |
| 180 | +- Real-time monitoring capabilities |
| 181 | + |
| 182 | +## Dependencies |
| 183 | + |
| 184 | +### Required |
| 185 | +- ctypes (built-in) |
| 186 | +- struct (built-in) |
| 187 | +- winreg (built-in) |
| 188 | + |
| 189 | +### Optional |
| 190 | +- capstone: For code disassembly |
| 191 | +- psutil: For enhanced process information |
| 192 | + |
| 193 | +All functionality gracefully degrades when optional dependencies are unavailable. |
0 commit comments