cheatengine 5.8.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,461 @@
1
+ English | [中文](README_CN.md)
2
+
3
+ # CE MCP v5.8.4 - AI-Assisted Reverse Engineering
4
+
5
+ MCP bridge enabling AI assistants to directly control Cheat Engine for game hacking and reverse engineering.
6
+
7
+ ## Architecture
8
+
9
+ ```
10
+ AI <--MCP/JSON-RPC--> ce_mcp_server.py <--Named Pipe--> ce_mcp_bridge.lua (CE)
11
+
12
+ Background auto-reconnect
13
+ ```
14
+
15
+ ## Installation
16
+
17
+ ### Quick Start (NPX) - Recommended
18
+
19
+ 1. **Install Dependencies**: `pip install pywin32`
20
+
21
+ 2. **Load in CE** (choose one):
22
+ - **Auto-load**: Copy `ce_mcp_bridge.lua` to CE's `autorun` folder (e.g. `D:\Cheat Engine\autorun\`)
23
+ - **Manual**: Press `Ctrl+Alt+L`, execute:
24
+ ```lua
25
+ dofile([[D:\path\to\ce_mcp_bridge.lua]])
26
+ ```
27
+
28
+ 3. **Configure MCP** (`.kiro/settings/mcp.json`):
29
+ ```json
30
+ {
31
+ "mcpServers": {
32
+ "cheat-engine": {
33
+ "command": "npx",
34
+ "args": ["--yes", "ce-mcp"]
35
+ }
36
+ }
37
+ }
38
+ ```
39
+
40
+ ### Manual Installation (Local)
41
+
42
+ If you prefer to run from source:
43
+
44
+ ```json
45
+ {
46
+ "mcpServers": {
47
+ "cheat-engine": {
48
+ "command": "python",
49
+ "args": ["D:/path/to/ce_mcp/ce_mcp_server.py"]
50
+ }
51
+ }
52
+ }
53
+ ```
54
+
55
+ ## Connection Features
56
+
57
+ - **Auto-reconnect**: MCP Server automatically reconnects when CE restarts
58
+ - **Background retry**: Connection attempts run in background with exponential backoff
59
+ - **Diagnostic on failure**: `ce_ping` returns detailed diagnostic info when connection fails
60
+ - **Thread-safe**: All pipe operations are protected by locks
61
+
62
+ ## Security Features
63
+
64
+ ### Authentication Token
65
+
66
+ Optional authentication layer for pipe communication. When enabled, all requests must include a valid token.
67
+
68
+ **Setup:**
69
+ 1. Set the same environment variable on both sides:
70
+ ```bash
71
+ # Windows CMD
72
+ set CE_MCP_AUTH_TOKEN=your_secret_token_here
73
+
74
+ # PowerShell
75
+ $env:CE_MCP_AUTH_TOKEN = "your_secret_token_here"
76
+ ```
77
+
78
+ 2. Start CE and load the bridge
79
+ 3. Start the MCP server
80
+
81
+ If tokens don't match, requests will be rejected with "Authentication failed" error.
82
+
83
+ ### Custom Pipe Name
84
+
85
+ For anti-detection, you can customize the pipe name:
86
+ ```bash
87
+ set CE_MCP_PIPE_NAME=my_custom_pipe_name
88
+ ```
89
+
90
+ ### Hook Name Validation
91
+
92
+ Hook names are validated to prevent AA script injection:
93
+ - Must start with letter or underscore
94
+ - Can only contain alphanumeric characters and underscores
95
+ - Pattern: `^[a-zA-Z_][a-zA-Z0-9_]*$`
96
+
97
+ Invalid names like `"my hook"` or `"hook;inject"` will be rejected.
98
+
99
+ ---
100
+
101
+ ## Tool Reference
102
+
103
+ ### System & Connection
104
+
105
+ #### `ce_ping`
106
+ Test connection to CE bridge. **Returns diagnostic info with troubleshooting suggestions on failure.**
107
+
108
+ #### `ce_get_process_info`
109
+ Get attached process info and refresh symbol handler. Also clears address cache.
110
+
111
+ #### `ce_attach_process(target)`
112
+ Attach to a process by PID or name. Clears caches and scan sessions after attaching.
113
+
114
+ **Parameters:**
115
+ - `target` (string, required): Process ID (number) or process name (e.g. `"game.exe"`)
116
+
117
+ #### `ce_auto_assemble(script, target_self?)`
118
+ Execute an Auto Assembler script. Supports enable/disable scripts, code injection, etc.
119
+
120
+ **Parameters:**
121
+ - `script` (string, required): Auto Assembler script content
122
+ - `target_self` (boolean, optional): Target CE process itself (default: false)
123
+
124
+ #### `ce_execute_lua(code)`
125
+ Execute arbitrary Lua code in CE.
126
+
127
+ **Parameters:**
128
+ - `code` (string, required): Lua code to execute
129
+
130
+ ---
131
+
132
+ ### Memory Read/Write
133
+
134
+ #### `ce_read_memory(address, type, size?)`
135
+ Read a single memory value.
136
+
137
+ **Parameters:**
138
+ - `address` (string, required): Address expression (e.g. `"game.exe+0x1234"`, `"0x140001000"`)
139
+ - `type` (string, required): `byte`, `word`, `dword`, `qword`, `float`, `double`, `string`, `bytes`
140
+ - `size` (integer, optional): Size for string/bytes type (default: 100)
141
+
142
+ #### `ce_read_memory_batch(requests)`
143
+ Read multiple addresses in one call. **Always prefer this over multiple ce_read_memory calls.**
144
+
145
+ **Parameters:**
146
+ - `requests` (array, required): Array of `{address, type, id?, size?}`
147
+
148
+ #### `ce_write_memory(address, type, value)`
149
+ Write a value to memory.
150
+
151
+ **Parameters:**
152
+ - `address` (string, required): Address expression
153
+ - `type` (string, required): Value type
154
+ - `value` (string, required): Value to write
155
+
156
+ ---
157
+
158
+ ### Scanning & Search
159
+
160
+ #### `ce_aob_scan(aob_string, module?, protection?, max_results?)`
161
+ Scan memory for Array of Bytes pattern. Supports `??` wildcards.
162
+
163
+ **Parameters:**
164
+ - `aob_string` (string, required): Pattern like `"48 89 5C 24 ?? 48 83 EC 20"`
165
+ - `module` (string, optional): Limit scan to module (e.g. `"game.exe"`)
166
+ - `protection` (string, optional): Memory protection flags (default: `"-C+X"`)
167
+ - `max_results` (integer, optional): Maximum results (default: 100)
168
+
169
+ #### `ce_value_scan(value, type, module?, protection?)`
170
+ Scan for a specific value. Useful for pointer tracing. **One-shot scan - for iterative scanning use Scan Sessions.**
171
+
172
+ **Parameters:**
173
+ - `value` (string, required): Value to search (e.g. `"0x255D5E758"` or `"12345"`)
174
+ - `type` (string, required): `byte`, `word`, `dword`, `qword`, `float`, `double`, `string`
175
+ - `module` (string, optional): Limit to module
176
+ - `protection` (string, optional): Default `"+W-C"` for writable memory
177
+
178
+ ---
179
+
180
+ ### Scan Sessions
181
+
182
+ Implements CE's core "First Scan → Next Scan" workflow with session management. Sessions auto-expire after 5 minutes of inactivity.
183
+
184
+ #### `ce_scan_new(value, type, module?, protection?)`
185
+ Start a new scan session.
186
+
187
+ #### `ce_scan_next(session_id, value, scan_type?, value2?)`
188
+ Continue scanning (filter) an existing session.
189
+
190
+ **scan_type options:**
191
+ - `exact` - Exact value match
192
+ - `increased` / `decreased` - Value increased/decreased
193
+ - `changed` / `unchanged` - Value changed/unchanged
194
+ - `bigger_than` / `smaller_than` - Greater/less than
195
+ - `between` - Between value and value2
196
+
197
+ #### `ce_scan_results(session_id, start_index?, limit?)`
198
+ Get paginated results from a scan session.
199
+
200
+ #### `ce_scan_close(session_id)`
201
+ Close a scan session and release resources.
202
+
203
+ #### `ce_scan_list`
204
+ List all active scan sessions.
205
+
206
+ #### `ce_enum_modules`
207
+ List all loaded modules (DLLs).
208
+
209
+ ---
210
+
211
+ ### Symbols & Addresses
212
+
213
+ #### `ce_get_address(expression)`
214
+ Resolve address expression to numeric address.
215
+
216
+ **Parameters:**
217
+ - `expression` (string, required): e.g. `"game.exe+0x1234"`, `"[[game.exe+100]+20]+8"`
218
+
219
+ #### `ce_get_symbol(address, include_module?)`
220
+ Get symbol name from address, with RTTI class info.
221
+
222
+ #### `ce_resolve_pointer(base, offsets, read_value?, value_type?)`
223
+ Resolve multi-level pointer chain with CE notation support.
224
+
225
+ **Parameters:**
226
+ - `base` (string, required): Base address or symbol (e.g. `"game.exe+1234"`)
227
+ - `offsets` (array, required): Array of offsets, e.g. `[0x100, 0x20, 0x8]`
228
+ - `read_value` (boolean, optional): Read value at final address (default: false)
229
+ - `value_type` (string, optional): Value type (default: "dword")
230
+
231
+ **Returns:** Includes `ceNotation` (CE-compatible pointer notation) that can be directly used in CE address list.
232
+
233
+ #### `ce_auto_guess(address)`
234
+ Guess the value type at an address.
235
+
236
+ ---
237
+
238
+ ### Disassembly & Code Analysis
239
+
240
+ #### `ce_disassemble(address, count?, direction?)`
241
+ Disassemble instructions.
242
+
243
+ **Parameters:**
244
+ - `address` (string, required): Start address
245
+ - `count` (integer, optional): Number of instructions (default: 10)
246
+ - `direction` (string, optional): `"forward"` or `"backward"` (default: forward)
247
+
248
+ #### `ce_get_instruction_info(address)`
249
+ Get detailed info about a single instruction.
250
+
251
+ #### `ce_analyze_code(address, count?)`
252
+ Static analysis of code block (calls, jumps, refs).
253
+
254
+ ---
255
+
256
+ ### Debugging & Breakpoints
257
+
258
+ #### `ce_set_breakpoint(address, type?, size?)`
259
+ Set a hardware breakpoint.
260
+
261
+ **Parameters:**
262
+ - `address` (string, required): Address expression
263
+ - `type` (string, optional): `"execute"`, `"write"`, `"access"` (default: execute)
264
+ - `size` (integer, optional): Size for write/access breakpoints (default: 1)
265
+
266
+ #### `ce_break_and_get_regs(address, timeout?, include_xmm?, stack_depth?)`
267
+ Set breakpoint and capture registers when hit. Also returns call stack.
268
+
269
+ #### `ce_break_and_trace(address, max_steps?, timeout?, stop_on_ret?, trace_into_call?, end_address?, initial_regs?)`
270
+ **Multi-step execution trace.** Most powerful debugging tool - traces code execution step by step, capturing full register state at each instruction.
271
+
272
+ **Parameters:**
273
+ - `address` (string, required): Start address (breakpoint location)
274
+ - `max_steps` (integer, optional): Maximum instructions to trace (default: 100)
275
+ - `timeout` (integer, optional): Timeout in ms (default: 10000)
276
+ - `stop_on_ret` (boolean, optional): Stop when `ret` is encountered (default: true)
277
+ - `trace_into_call` (boolean, optional): Step into calls vs step over (default: false)
278
+ - `end_address` (string, optional): Stop when this address is reached
279
+ - `initial_regs` (object, optional): Set register values at first hit
280
+
281
+ **Stop reasons:** `"ret"`, `"end_address"`, `"max_steps"`, `"timeout"`
282
+
283
+ #### `ce_cleanup`
284
+ Remove all breakpoints and traces. Use when game freezes.
285
+
286
+ ---
287
+
288
+ ### Analysis Tools
289
+
290
+ #### `ce_find_what_accesses(address, size?, duration_ms?, max_records?)`
291
+ Find what code accesses this address (like CE's F5 feature). Monitors reads and writes.
292
+
293
+ #### `ce_find_what_writes(address, size?, duration_ms?, max_records?)`
294
+ Find what writes to this address (like CE's F6 feature). Monitors only writes.
295
+
296
+ #### `ce_find_pointer_path(address, max_depth?, strategy?)`
297
+ **Automatic pointer chain tracing.** Finds static base address for dynamic addresses.
298
+
299
+ **Parameters:**
300
+ - `address` (string, required): Dynamic address to trace
301
+ - `max_depth` (integer, optional): Max pointer depth 1-10 (default: 7)
302
+ - `strategy` (string, optional): `"hybrid"`, `"f5"`, `"value_scan"` (default: hybrid)
303
+
304
+ #### `ce_find_references(address, limit?)`
305
+ Find all code locations that reference a specific address.
306
+
307
+ #### `ce_find_call_references(address, module?, limit?)`
308
+ Find all CALL instructions that target a specific function.
309
+
310
+ #### `ce_find_function_boundaries(address, max_search?)`
311
+ Detect function start and end by analyzing prologue/epilogue patterns.
312
+
313
+ #### `ce_generate_signature(address)`
314
+ Generate unique AOB signature for an address. Useful for game updates.
315
+
316
+ ---
317
+
318
+ ### Advanced Analysis
319
+
320
+ #### `ce_build_cfg(address, max_blocks?, max_instructions?, detect_loops?)`
321
+ Build Control Flow Graph for a function.
322
+
323
+ #### `ce_detect_patterns(address, max_instructions?, patterns?)`
324
+ Detect common code patterns: switch tables, virtual calls, string refs, crypto constants.
325
+
326
+ #### `ce_compare_functions(address1, address2, max_instructions?)`
327
+ Compare two functions for similarity.
328
+
329
+ #### `ce_trace_dataflow(address, register, direction?, max_instructions?)`
330
+ Trace data flow for a register within a function.
331
+
332
+ #### `ce_program_slice(address, criterion, direction?, max_instructions?)`
333
+ Compute program slice - find all instructions affecting or affected by a variable.
334
+
335
+ ---
336
+
337
+ ### Code Emulation
338
+
339
+ #### `ce_symbolic_trace(address, count?, initial_state?, stop_on_call?, stop_on_ret?)`
340
+ Lightweight symbolic execution. Interprets instruction semantics without executing.
341
+
342
+ **Parameters:**
343
+ - `address` (string, required): Start address
344
+ - `count` (integer, optional): Instructions to trace (default: 30)
345
+ - `initial_state` (object, optional): Initial register symbols, e.g. `{"rcx": "this_ptr", "rdx": "arg1"}`
346
+
347
+ #### `ce_call_function(address, args?, return_type?, timeout?)`
348
+ Call a function in the target process. **WARNING: Executes real code!**
349
+
350
+ ---
351
+
352
+ ### Function Hooking
353
+
354
+ #### `ce_hook_function(address, name, capture_args?, calling_convention?)`
355
+ Hook a function to intercept calls and capture arguments.
356
+
357
+ **Parameters:**
358
+ - `address` (string, required): Function address
359
+ - `name` (string, required): Hook identifier
360
+ - `capture_args` (integer, optional): Number of args to capture 0-4 (default: 4)
361
+ - `calling_convention` (string, optional): `"auto"`, `"fastcall"`, `"stdcall"`, `"cdecl"`
362
+
363
+ #### `ce_get_hook_log(name, limit?, clear?)`
364
+ Get captured function call arguments.
365
+
366
+ #### `ce_unhook_function(name)`
367
+ Remove a function hook.
368
+
369
+ #### `ce_list_hooks`
370
+ List all active hooks.
371
+
372
+ ---
373
+
374
+ ### Cheat Table
375
+
376
+ #### `ce_get_address_list(include_script?)`
377
+ Get all records from Cheat Table.
378
+
379
+ #### `ce_add_address_record(description, address, value_type?, script?)`
380
+ Add a new record to Cheat Table.
381
+
382
+ ---
383
+
384
+ ## Recommended Workflows
385
+
386
+ ### Pointer Tracing
387
+ ```python
388
+ # Automatic (preferred)
389
+ result = ce_find_pointer_path(address="0x255D5E758")
390
+ # Returns: base_address, offsets, ce_pointer_notation
391
+
392
+ # Manual (if automatic fails)
393
+ # 1. Find what accesses the address
394
+ accesses = ce_find_what_accesses(address="0x255D5E758")
395
+ # 2. Get register value (e.g., rcx = 0x255D5E658)
396
+ # 3. Search for pointer storing that value
397
+ pointers = ce_value_scan(value="0x255D5E658", type="qword")
398
+ # 4. Repeat until finding game.exe+offset
399
+ ```
400
+
401
+ ### Function Analysis
402
+ ```python
403
+ # 1. Find function boundaries
404
+ bounds = ce_find_function_boundaries(address="0x14587EDB0")
405
+
406
+ # 2. Trace execution
407
+ trace = ce_break_and_trace(address="0x14587EDB0", max_steps=100)
408
+
409
+ # 3. Generate signature for updates
410
+ sig = ce_generate_signature(address="0x14587EDB0")
411
+ ```
412
+
413
+ ### Reverse Engineering Unknown Code
414
+ ```python
415
+ # 1. Disassemble
416
+ code = ce_disassemble(address="0x14587EDB0", count=20)
417
+
418
+ # 2. Symbolic trace to understand logic
419
+ symbolic = ce_symbolic_trace(address="0x14587EDB0", initial_state={"rcx": "this"})
420
+
421
+ # 3. Build CFG for complex functions
422
+ cfg = ce_build_cfg(address="0x14587EDB0")
423
+
424
+ # 4. Detect patterns
425
+ patterns = ce_detect_patterns(address="0x14587EDB0")
426
+ ```
427
+
428
+ ---
429
+
430
+ ## Troubleshooting
431
+
432
+ | Issue | Solution |
433
+ |-------|----------|
434
+ | Connection failed | Use `ce_ping` - it returns diagnostic info with specific suggestions |
435
+ | CE restarted | MCP Server auto-reconnects, just reload the Lua script in CE |
436
+ | Pipe error | Run `CE_MCP.stop()` then `CE_MCP.start()` in CE |
437
+ | Permission denied | Run CE as administrator |
438
+ | Game frozen | Use `ce_cleanup()` to remove all breakpoints |
439
+ | Breakpoint not triggering | Ensure code path is executed in game |
440
+
441
+ ## Status Check
442
+
443
+ ```lua
444
+ CE_MCP.stats() -- Check bridge status in CE
445
+ reloadMcpBridge() -- Reload bridge after code changes
446
+ ```
447
+
448
+ ## Version History
449
+
450
+ - **v5.8.4**: Connection improvements - Background auto-reconnect thread; Auto-reconnect when CE restarts; `ce_ping` returns diagnostic info on failure; Thread-safe pipe operations
451
+ - **v5.8.3**: Improved tool descriptions for better AI recognition
452
+ - **v5.8.1**: Security improvements - Added optional authentication token; Added hook name validation
453
+ - **v5.8.0**: Added Scan Sessions, `ce_attach_process`, `ce_auto_assemble`
454
+ - **v5.0**: Added `ce_break_and_trace` with multi-step tracing
455
+ - **v4.2**: Added CFG, pattern detection, dataflow analysis
456
+ - **v4.0**: Added function hooking, symbolic trace
457
+ - **v3.0**: Added pointer path finding, structure analysis
458
+
459
+ ## References
460
+
461
+ - [CE Wiki](https://wiki.cheatengine.org/)