Lua
Cheat Engine comes with an extensive set of Lua functions you can use inside cheat tables, trainers and standalone scripts.
Contents
- 1 Variables
- 2 Functions
- 2.1 Cheat Table
- 2.2 Trainers
- 2.3 Protection
- 2.4 Scanning
- 2.5 Process
- 2.6 Threads
- 2.7 Handles
- 2.8 Addresses
- 2.9 Memory
- 2.10 Conversions
- 2.11 Input Devices
- 2.12 Screen
- 2.13 Sounds
- 2.14 Text-to-Speech
- 2.15 Fonts
- 2.16 Forms and Windows
- 2.17 Cheat Engine
- 2.18 Lua
- 2.19 Types
- 2.20 Object-oriented
- 2.21 Assembly
- 2.22 Auto Assembler
- 2.23 Debugger
- 2.24 DBK (Driver-Based Kernel)
- 2.25 DBVM
- 2.26 Translation
- 2.27 Files
- 2.28 Structures
- 2.29 Miscellaneous
- 3 Classes
Variables[edit]
Globals[edit]
| Name | Type | Description |
|---|---|---|
| TrainerOrigin | string | Path of the trainer that launched Cheat Engine. Only set when Cheat Engine was launched as a trainer. |
| process | string | Main module name of the currently opened process (e.g. mygame.exe or module name).
|
| MainForm | object | The main Cheat Engine GUI form object. |
| AddressList | object | The address list object of the main Cheat Engine GUI (cheat table address list). |
CPU / Debug Variables (Registers)[edit]
| Register / Variable | Architecture | Description |
|---|---|---|
| EFLAGS | 32/64-bit | CPU flags register value available in the debug context. |
| EAX, EBX, ECX, EDX, EDI, ESI, EBP, ESP, EIP | 32/64-bit | Standard 32-bit register values (present when debugging 32-bit contexts or in compatible views). |
| RAX, RBX, RCX, RDX, RDI, RSI, RBP, RSP, RIP, R8, R9, R10, R11, R12, R13, R14, R15 | 64-bit only | 64-bit register values available in 64-bit debug contexts. |
Functions[edit]
Cheat Table[edit]
These functions help manage the cheat table and its files.
| Function | Description |
|---|---|
| getAddressList | Returns the cheat table Addresslist object. |
| findTableFile | Returns a TableFile stored in the cheat table (search by filename or identifier). |
| createTableFile | Adds a new file entry to the cheat table. |
| loadTable | Loads a ".ct" or ".cetrainer" file or stream into the cheat table. |
| saveTable | Saves the current cheat table to disk. |
Trainers[edit]
Functions related to the trainer (.exe) generator.
| Function | Description |
|---|---|
| registerEXETrainerFeature | Adds a new feature to the EXE trainer generator window and calls your callback when a user builds a .exe trainer. |
| unregisterEXETrainerFeature | Unregisters a previously registered trainer feature. |
Protection[edit]
Functions for protecting Cheat Engine or encoding code.
| Function | Description |
|---|---|
| activateProtection | Prevents basic memory scanners from opening or inspecting the Cheat Engine process. |
| enableDRM | Enables kernel-mode protections or DRM measures to prevent normal memory scanners from reading the Cheat Engine process. |
| encodeFunction | Encodes a given Lua function to a string that can be stored/transferred; can be decoded later with decodeFunction. |
| decodeFunction | Decodes an encoded function string back into a callable Lua function. |
Scanning[edit]
Functions that control and query memory scans.
| Function | Description |
|---|---|
| AOBScan | Scans the currently opened process for an array-of-bytes (AOB) pattern and returns a StringList of all matches. |
| AOBScanModuleUnique | Scans the process memory for a byte pattern and returns the address if exactly one unique match is found; returns nil otherwise.
|
| AOBScanUnique | Scans the entire process for a pattern and returns the address if exactly one unique match exists; returns nil otherwise.
|
| getCurrentMemscan | Returns the currently active scan session as a MemScan object. |
Process[edit]
Functions for creating/opening processes and querying system/process state.
| Function | Description |
|---|---|
| createProcess | Creates (and optionally debugs) a new process. |
| openProcess | Opens a process given a process name or PID; attaches Cheat Engine to it for memory access. |
| onOpenProcess | Callback invoked by Cheat Engine when it opens a process (user-defined handler). |
| getForegroundProcess | Returns the process ID (PID) of the currently foreground (top) window process. |
| getOpenedProcessID | Returns the PID of the currently opened/attached process. |
| getProcessIDFromProcessName | Returns the PID for a given process name (if running). |
| openFileAsProcess | Opens a file and treats it like a process (gives memory access similar to opening a process). |
| saveOpenedFile | Saves changes made to the opened file. |
| setPointerSize | Sets the pointer size (in bytes) Cheat Engine will use (e.g. 4 or 8); useful if a 64-bit process requires 32-bit pointer handling. |
| setAssemblerMode | Sets assembler bit mode: 0 = 32-bit, 1 = 64-bit.
|
| getProcesslist | Returns a system process list object. |
| getWindowlist | Returns a list of top-level windows. |
| pause | Pauses the currently opened process. |
| unpause | Resumes the currently opened process. |
| targetIs64Bit | Returns true if the target process is 64-bit, otherwise false.
|
| enumModules | Returns a table with information about each module in the current process (or a specified PID). |
| closeRemoteHandle | Closes a remote handle to a process. |
Threads[edit]
| Function | Description |
|---|---|
| getCPUCount | Returns the number of CPU cores available on the system. |
| getThreadlist | Fills a List object with the thread list of the currently opened process (returns thread IDs and basic info). |
| inMainThread | Returns true if the current Lua code is running in the main thread (available in CE 6.4+); otherwise false.
|
| synchronize | Executes the provided function in the main thread and returns that function's return value. Useful for GUI updates or operations that must run on the main thread. |
| queue | Schedules the provided function to run in the main thread but does not wait for the result (fire-and-forget). |
| checkSynchronize | Intended to be called from the main thread's loop to process pending synchronized calls when using threads and synchronize/queue.
|
Handles[edit]
| Function | Description |
|---|---|
| getHandleList | Returns a table (or list object) containing system handles (open handles) for the system or the current process, depending on context. |
Addresses[edit]
These functions help convert between memory addresses and symbol/CE address string representations.
| Function | Description |
|---|---|
| getAddress | Returns the numeric address of a symbol (module+export, label, or CE symbol). Raises an error if the symbol cannot be resolved. |
| getAddressSafe | Same as getAddress but returns nil if the symbol cannot be found (does not throw).
|
| getNameFromAddress | Returns the address formatted as a string, preferring symbol/module+offset notation when available. |
| registerSymbol | Assigns the specified symbol name to an address (adds a user-defined symbol). |
| unregisterSymbol | Removes a previously registered symbol mapping for an address. |
| getSymbolInfo | Returns a table/object with symbol information (module name, search key, address, size), matching the SymbolList structure. |
| reinitializeSymbolhandler | Reinitializes the symbol handler (useful after loading new modules). |
| inModule | Returns true if the specified address lies inside a loaded module.
|
| inSystemModule | Returns true if the address is inside a system module (OS module), e.g., kernel or system DLLs.
|
| getModuleSize | Returns the size (in bytes) of the specified module. Use getAddress to retrieve the module base address first if needed.
|
| errorOnLookupFailure | Sets whether address/symbol lookups will throw errors on failure or return 0/nil depending on configuration.
|
| registerSymbolLookupCallback | Registers a callback function invoked when a symbol is parsed/loaded. |
| unregisterSymbolLookupCallback | Unregisters a previously registered symbol lookup callback. |
| registerAddressLookupCallback | Registers a callback called when an address-to-name conversion is requested. |
| unregisterAddressLookupCallback | Unregisters the address lookup callback. |
| reinitializeDotNetSymbolhandler | Reinitializes only the .NET portion of the symbol handler (useful when .NET modules change). |
Memory[edit]
| Function | Description |
|---|---|
| allocateMemory | Allocates executable/non-executable memory in the target process and returns the allocated address. |
| deAlloc | Frees memory previously allocated in the target process. |
| allocateSharedMemory | Creates or opens a named shared memory object of the given size for interprocess communication. |
| createSection | Creates a memory section object (OS-specific) for sharing or mapping memory. |
| mapViewOfSection | Maps a created section into the process address space, returning the mapped base address. |
| unMapViewOfSection | Unmaps a previously mapped section view from the process address space. |
| copyMemory | Copies memory from a source address to a destination address (can be used within target process or between processes depending on API). |
| allocateKernelMemory | Allocates a block of nonpaged kernel memory (requires driver or appropriate privileges) and returns its address. |
| freeKernelMemory | Frees kernel-mode memory previously allocated. |
| mapMemory | Maps memory from one process context into another usermode context (maps a specified address from PID A into PID B's address space). |
| unmapMemory | Unmaps memory previously mapped with mapMemory.
|
| createMemoryStream | Creates a memory stream object that can be used to read/write memory data conveniently from Lua. |
Reading from Target Process[edit]
| Function | Description |
|---|---|
| readBytes | Reads raw bytes at the given address. If ReturnAsTable is true, returns a table; otherwise returns multiple byte values.
|
| readSmallInteger | Reads a 16-bit (word) integer from the specified address. Optional second parameter: if true, reads as signed integer. |
| readInteger | Reads a 32-bit (dword) integer from the specified address. Optional second parameter: if true, reads as signed integer. |
| readQword | Reads a 64-bit (qword) integer from the specified address. |
| readPointer | Reads a pointer-sized value: readQword on 64-bit targets, readInteger on 32-bit targets.
|
| readFloat | Reads a single-precision (32-bit) floating-point value from the specified address. |
| readDouble | Reads a double-precision (64-bit) floating-point value from the specified address. |
| readString | Reads a null-terminated string from memory up to maxlength bytes (prevents infinite loops on corrupted memory).
|
| readRegionFromFile | Reads a region from a file and writes it to a specific address in the target process. |
Reading from Cheat Engine Memory[edit]
| Function | Description |
|---|---|
| readBytesLocal | Same as readBytes, but reads from Cheat Engine's own memory.
|
| readSmallIntegerLocal | Reads a 16-bit integer from CE's memory. Optional: use signed if second parameter is true. |
| readIntegerLocal | Reads a 32-bit integer from CE's memory. Optional: use signed if second parameter is true. |
| readQwordLocal | Reads a 64-bit integer from CE's memory. |
| readPointerLocal | Reads a pointer-sized value from CE's memory (64-bit or 32-bit depending on CE build). |
| readFloatLocal | Reads a single-precision float from CE's memory. |
| readDoubleLocal | Reads a double-precision float from CE's memory. |
| readStringLocal | Reads a null-terminated string from CE's memory. |
Writing to Target Process[edit]
| Function | Description |
|---|---|
| writeBytes | Writes the given bytes (from a table) to the specified address in the target process. |
| writeSmallInteger | Writes a 16-bit integer to the specified address. Returns true on success. |
| writeInteger | Writes a 32-bit integer to the specified address. Returns true on success. |
| writeQword | Writes a 64-bit integer to the specified address. Returns true on success. |
| writeFloat | Writes a single-precision float to the specified address. Returns true on success. |
| writeDouble | Writes a double-precision float to the specified address. Returns true on success. |
| writeString | Writes a string to the specified address (typically null-terminated). Returns true on success. |
| writeRegionToFile | Writes a memory region to a file. Returns the number of bytes written. |
Writing to Cheat Engine Memory[edit]
| Function | Description |
|---|---|
| writeSmallIntegerLocal | Writes a 16-bit integer to CE's memory. Returns true on success. |
| writeIntegerLocal | Writes a 32-bit integer to CE's memory. Returns true on success. |
| writeQwordLocal | Writes a 64-bit integer to CE's memory. Returns true on success. |
| writeFloatLocal | Writes a single-precision float to CE's memory. Returns true on success. |
| writeDoubleLocal | Writes a double-precision float to CE's memory. Returns true on success. |
| writeStringLocal | Writes a string to CE's memory. Returns true on success. |
| writeBytesLocal | Writes the given bytes (from a table) to CE's memory. |
Conversions[edit]
Encoding/Decoding[edit]
| Function | Description |
|---|---|
| ansiToUtf8 | Converts a string from ANSI encoding to UTF-8 encoding. |
| utf8ToAnsi | Converts a string from UTF-8 encoding to ANSI encoding. |
| stringToMD5String | Computes and returns the MD5 hash of a string as a hexadecimal string. |
| integerToUserData | Converts a given integer to a userdata variable. |
| userDataToInteger | Converts a given userdata variable back to an integer. |
To Byte Table[edit]
Convert data types into byte tables (tables of individual byte values).
| Function | Description |
|---|---|
| wordToByteTable | Converts a 16-bit word to a byte table. |
| dwordToByteTable | Converts a 32-bit dword to a byte table. |
| qwordToByteTable | Converts a 64-bit qword to a byte table. |
| floatToByteTable | Converts a single-precision float to a byte table. |
| doubleToByteTable | Converts a double-precision float to a byte table. |
| stringToByteTable | Converts a string (ANSI/UTF-8) to a byte table. |
| wideStringToByteTable | Converts a string to a wide string (Unicode) and then to a byte table. |
From Byte Table[edit]
Convert byte tables back into data types.
| Function | Description |
|---|---|
| byteTableToWord | Converts a byte table to a 16-bit word. |
| byteTableToDword | Converts a byte table to a 32-bit dword. |
| byteTableToQword | Converts a byte table to a 64-bit qword. |
| byteTableToFloat | Converts a byte table to a single-precision float. |
| byteTableToDouble | Converts a byte table to a double-precision float. |
| byteTableToString | Converts a byte table to a string. |
| byteTableToWideString | Converts a byte table to a wide string (Unicode). |
Binary Operations[edit]
Bitwise operations on integers.
| Function | Description |
|---|---|
| bOr | Bitwise OR operation. |
| bXor | Bitwise XOR (exclusive OR) operation. |
| bAnd | Bitwise AND operation. |
| bShl | Bitwise shift left operation. |
| bShr | Bitwise shift right operation. |
| bNot | Bitwise NOT (complement) operation. |
Input Devices[edit]
Keyboard & Mouse[edit]
| Function | Description |
|---|---|
| getMousePos | Returns the current mouse cursor position as X and Y coordinates. |
| setMousePos | Sets the mouse cursor position to the specified X and Y coordinates. |
| isKeyPressed | Returns true if the specified key is currently held down.
|
| keyDown | Simulates pressing a key (puts the key into down state). |
| keyUp | Simulates releasing a key (puts the key into up state). |
| doKeyPress | Simulates a complete key press (down and up). |
| mouse_event | Calls the Windows API mouse_event directly for advanced mouse control. See MSDN documentation.
|
| setGlobalKeyPollInterval | Sets the global key poll interval (frequency of keyboard state updates). |
| setGlobalDelayBetweenHotkeyActivation | Sets the minimum delay (in milliseconds) between consecutive activations of the same hotkey. |
Game Controller[edit]
XBox/game controller input.
| Function | Description |
|---|---|
| getXBox360ControllerState | Fetches the current state (buttons, triggers, sticks) of a connected XBox 360 controller. |
| setXBox360ControllerVibration | Sets the speed of the left and right vibration motors in an XBox 360 controller (for haptic feedback). |
Clipboard[edit]
| Function | Description |
|---|---|
| writeToClipboard | Writes the given text to the system clipboard. |
Screen[edit]
| Function | Description |
|---|---|
| getScreenHeight | Returns the height of the screen in pixels. |
| getScreenWidth | Returns the width of the screen in pixels. |
| getScreenDPI | Returns the screen DPI (dots per inch) for determining screen scaling/density. |
| getWorkAreaHeight | Returns the height of the usable work area (excludes taskbars). |
| getWorkAreaWidth | Returns the width of the usable work area (excludes taskbars). |
| getScreenCanvas | Returns a Canvas object for drawing directly to the screen. Limited usefulness in practice due to performance constraints. |
| getPixel | Returns the RGB color value of a pixel at the specified screen coordinates. |
Sounds[edit]
General Audio[edit]
| Function | Description |
|---|---|
| playSound | Plays an audio file (supports various formats like .wav, .mp3, etc.). |
| beep | Plays a system beep/ping sound. |
Text-to-Speech[edit]
| Function | Description |
|---|---|
| speak | Speaks the given text using the system's text-to-speech engine and optional flags. See MSDN SpeakFlags. |
| speakEnglish | Speaks the given text using an English voice by wrapping it in an XML voice specification. |
XM Player[edit]
Plays tracked music (XM format) using the built-in XM player.
| Function | Description |
|---|---|
| xmplayer_playXM | Plays an XM audio file given its filename. |
| xmplayer_pause | Pauses the currently playing XM audio file. |
| xmplayer_resume | Resumes playback of a paused XM audio file. |
| xmplayer_stop | Stops XM audio playback completely. |
| xmplayer_isPlaying | Returns true if an XM audio file is currently being played.
|
Fonts[edit]
| Function | Description |
|---|---|
| loadFontFromStream | Loads a font from a memory stream and returns a handle/ID for later use with unloadLoadedFont.
|
| unloadLoadedFont | Unloads a previously loaded font by its handle/ID, freeing resources. |
Forms and Windows[edit]
| Function | Description |
|---|---|
| findWindow | Finds a window by class name and/or window title/caption. |
| getWindow | Gets a window handle based on a relative command (e.g. parent, child, next). See MSDN GetWindow. |
| getWindowCaption | Returns the caption/title text of the specified window. |
| getWindowClassName | Returns the class name of the specified window. |
| getWindowProcessID | Returns the process ID (PID) of the process that owns the specified window. |
| getForegroundWindow | Returns the handle of the topmost (foreground) window currently active. |
| sendMessage | Sends a Windows message to the specified window. |
| hookWndProc | Hooks a window's window procedure (WndProc) to intercept and handle messages. |
| unhookWndProc | Uninstalls a WndProc hook previously installed via hookWndProc.
|
Cheat Engine[edit]
Functions for managing and controlling Cheat Engine itself.
Version and Information[edit]
| Function | Description |
|---|---|
| getCEVersion | Returns the Cheat Engine version as a floating-point number (e.g. 7.5).
|
| getCheatEngineFileVersion | Returns full version information: a raw integer and a table containing major, minor, release, and build numbers. |
| cheatEngineIs64Bit | Returns true if Cheat Engine is running as 64-bit; false if 32-bit.
|
| getCheatEngineProcessID | Returns the process ID of the Cheat Engine process itself. |
| getCheatEngineDir | Returns the folder path where Cheat Engine (or the current trainer) is located. |
Management[edit]
| Function | Description |
|---|---|
| closeCE | Closes Cheat Engine. |
| getFreezeTimer | Returns the Timer object responsible for freezing/unfreezing values in the address list. |
| getUpdateTimer | Returns the Timer object responsible for updating displayed values in the address list. |
| getCommonModuleList | Returns the common module list as a StringList object. |
| getAutoAttachList | Returns the AutoAttach list as a StringList object. |
| connectToCEServer | Connects to a remote Cheat Engine server (given host and port). Subsequent operations route through the server. |
| reloadSettingsFromRegistry | Reloads Cheat Engine settings from the registry and applies them immediately. |
| loadPlugin | Loads the specified plugin. |
| getSettings | Returns the settings object for accessing/modifying CE configuration. |
| registerBinUtil | Registers a binutils (assembler/disassembler) toolset with Cheat Engine. |
Comments and Headers[edit]
| Function | Description |
|---|---|
| getComment | Gets the user-defined comment attached to the specified address. |
| setComment | Sets a user-defined comment at the specified address. |
| getHeader | Gets the user-defined header text at the specified address. |
| setHeader | Sets a user-defined header text at the specified address. |
Advertising and Support[edit]
| Function | Description |
|---|---|
| supportCheatEngine | Displays an advertising/support window to help fund Cheat Engine development. |
| fuckCheatEngine | Hides/closes the advertising window if it was showing (crude but functional name). |
Forms and UI[edit]
| Function | Description |
|---|---|
| getFormCount | Returns the total number of forms currently attached to the main CE application. |
| getForm | Returns the form object at the specified index (0-based). |
| getMemoryViewForm | Returns the first MemoryView form object (the hex editor window). |
| getMainForm | Returns the main Cheat Engine window form object. |
| getSettingsForm | Returns the settings/options dialog form object. |
| getLuaEngine | Returns the Lua engine/console form object (creates it if needed). |
| unhideMainCEwindow | Shows the main Cheat Engine window (opposite of hideAllCEWindows).
|
| hideAllCEWindows | Hides all normal Cheat Engine windows (e.g. the trainer table UI). |
| registerFormAddNotification | Registers a callback function invoked when a form is added to CE's form list. |
| unregisterFormAddNotification | Unregisters a previously registered form add notification callback. |
Messages[edit]
| Function | Description |
|---|---|
| showMessage | Shows a simple message box with the given text to the user. |
| messageDialog | Pops up a message dialog box (similar to showMessage, with more control over buttons/options).
|
| outputDebugString | Outputs a message using the Windows OutputDebugString API (visible in debuggers).
|
| processMessages | Processes pending window messages in the event queue, allowing button clicks and UI updates to be handled. |
Input[edit]
| Function | Description |
|---|---|
| inputQuery | Shows a dialog prompting the user to input a string. Returns the entered string, or nil if cancelled (CE 6.4+).
|
Shortcuts[edit]
| Function | Description |
|---|---|
| shortCutToText | Converts a shortcut integer value to its textual representation (e.g. "Ctrl+Alt+A"). (CE 6.4+)
|
| textToShortCut | Converts a text representation (e.g. "Ctrl+Alt+A") to a shortcut integer value. (CE 6.4+)
|
| convertKeyComboToString | Converts a key combination to its string representation, matching the hotkey handler's format. |
Speed Hack[edit]
| Function | Description |
|---|---|
| speedhack_setSpeed | Enables the speed hack (if not already active) and sets the game/process speed multiplier (e.g. 2.0 for 2x speed).
|
| speedhack_getSpeed | Returns the current speed hack multiplier value that was last set. |
Lua[edit]
Functions for managing the Lua engine and state.
| Function | Description |
|---|---|
| resetLuaState | Creates a fresh Lua state, resetting the environment and clearing all previously defined variables/functions. |
| sleep | Pauses execution for the specified number of milliseconds. |
| createRef | Creates and returns an integer reference handle that can store and retrieve Lua objects persistently. |
| getRef | Retrieves the Lua value/object referenced by the given reference handle. |
| destroyRef | Destroys and frees a reference handle, removing the reference and allowing garbage collection. |
Types[edit]
Functions for registering and managing custom data types.
| Function | Description |
|---|---|
| onAutoGuess | Registers a callback function invoked by Cheat Engine's auto-guess feature to predict and suggest variable types. |
| registerCustomTypeLua | Registers a custom data type defined using Lua functions for reading/writing/display logic. |
| registerCustomTypeAutoAssembler | Registers a custom data type defined using an Auto Assembler script. |
Object-oriented[edit]
Functions for determining class inheritance and type relationships.
| Function | Description |
|---|---|
| inheritsFromObject | Returns true if the given object is a valid Cheat Engine class instance (inherits from Object).
|
| inheritsFromComponent | Returns true if the given object inherits from the Component class.
|
| inheritsFromControl | Returns true if the given object inherits from the Control class (UI controls).
|
| inheritsFromWinControl | Returns true if the given object inherits from the WinControl class (windowed controls).
|
Assembly[edit]
Functions for working with x86/x64 machine code and assembly instructions.
| Function | Description |
|---|---|
| autoAssemble | Executes an Auto Assembler script (given as text) for code injection, patching, or other assembly operations. |
| autoAssembleCheck | Validates an Auto Assembler script for syntax errors. Returns true on success; false with error message on failure.
|
| disassemble | Disassembles the instruction at the given address and returns a formatted string: "address - bytes - opcode extra".
|
| splitDisassembledString | Parses a disassembled instruction string and returns 4 separate strings: address, bytes, opcode, and extra field. |
| getInstructionSize | Returns the size (in bytes) of the instruction at the given address. |
| getPreviousOpcode | Attempts to find and return the address of the previous instruction (heuristic guess). |
| registerAssembler | Registers a custom callback function for the single-line assembler to convert instruction mnemonics to bytes. |
| unregisterAssembler | Unregisters a previously registered custom assembler callback. |
Auto Assembler[edit]
Commands & Hooks[edit]
| Function | Description |
|---|---|
| registerAutoAssemblerCommand | Registers a custom Auto Assembler command that calls the specified Lua function when invoked in a script. |
| unregisterAutoAssemblerCommand | Unregisters a previously registered Auto Assembler command. |
| registerAutoAssemblerPrologue | Registers a callback function invoked before the Auto Assembler parses a script (prologue phase). |
| unregisterAutoAssemblerPrologue | Unregisters an Auto Assembler prologue callback. |
| fullAccess | Changes memory protection on a block of memory to be writable and executable. |
Scripts & Templates[edit]
| Function | Description |
|---|---|
| registerAutoAssemblerTemplate | Registers a reusable template for the Auto Assembler script generator. |
| unregisterAutoAssemblerTemplate | Unregisters a previously registered Auto Assembler template. |
| generateCodeInjectionScript | Generates and appends a default code injection script to the provided script (allocates space, injects code, patches original). |
| generateAOBInjectionScript | Generates and appends an Array-of-Bytes (AOB) injection script to the provided script (searches for pattern, injects code). |
| generateFullInjectionScript | Generates and appends a complete full injection script with all patches and cleanup code. |
| generateAPIHookScript | Generates an Auto Assembler script that hooks (intercepts) the given API function address. |
Debugger[edit]
Functions for managing the debugger. See Lua Debugging for detailed information.
Status and Information[edit]
| Function | Description |
|---|---|
| debug_isDebugging | Returns true if the debugger has been started and is active.
|
| debug_getCurrentDebuggerInterface | Returns the current debugger interface type: 1=Windows, 2=VEH, 3=Kernel, nil=no debugging.
|
| debug_canBreak | Returns true if the target process can stop on a breakpoint. (CE 6.4+)
|
| debug_isBroken | Returns true if the debugger is currently halted on a thread (at a breakpoint).
|
| debug_getBreakpointList | Returns a Lua table containing all currently active breakpoint addresses. |
Breakpoint Management[edit]
| Function | Description |
|---|---|
| debugProcess | Starts debugging the currently attached process. |
| debug_setBreakpoint | Sets a breakpoint of a specific size (in bytes) at the given address. |
| debug_removeBreakpoint | Removes a breakpoint at the specified address. |
| debug_continueFromBreakpoint | Resumes execution when the debugger is halted on a breakpoint. |
| debug_addThreadToNoBreakList | Adds a thread to the no-break list so breakpoints on it will be ignored. |
| debug_removeThreadFromNoBreakList | Removes a thread from the no-break list. |
Callbacks[edit]
| Function | Description |
|---|---|
| debugger_onBreakpoint | User-defined callback invoked by CE when a breakpoint is hit (define your own implementation). |
| debugger_onModuleLoad | User-defined callback invoked by the Windows debugger when a module is loaded. |
Register and Context Management[edit]
| Function | Description |
|---|---|
| debug_getContext | Force-updates the Lua variables representing CPU registers from the current thread context. (CE 6.5+) |
| debug_setContext | Force-updates the CPU registers from the Lua variables representing them. (CE 6.5+) |
| debug_updateGUI | Refreshes the UI to reflect the current debug context if the debugger is broken. |
| debug_getXMMPointer | Returns the memory address of the specified XMM register for the currently broken thread. |
Advanced Debugging[edit]
| Function | Description |
|---|---|
| debug_setLastBranchRecording | Tells the kernel-mode debugger to record the last few branch/jump instructions before a breakpoint is hit. |
| debug_getMaxLastBranchRecord | Returns the maximum number of branch records this CPU supports. |
| debug_getLastBranchRecord | Returns the Last Branch Record value at the given index (when handling a breakpoint with branch recording enabled). |
| detachIfPossible | Detaches the debugger from the target process if possible. |
DBK (Driver-Based Kernel)[edit]
Functions for kernel-mode operations via the DBK driver.
Initialization and Setup[edit]
| Function | Description |
|---|---|
| dbk_initialize | Loads and initializes the DBK kernel driver into memory if possible. |
| dbk_useKernelmodeOpenProcess | Redirects OpenProcess API calls to use kernel-mode DBK equivalents.
|
| dbk_useKernelmodeProcessMemoryAccess | Redirects ReadProcessMemory and WriteProcessMemory to use kernel-mode DBK versions.
|
| dbk_useKernelmodeQueryMemoryRegions | Redirects virtual memory query APIs to use kernel-mode DBK equivalents. |
Process and Thread Information[edit]
| Function | Description |
|---|---|
| dbk_getPEProcess | Returns the kernel pointer to the EPROCESS structure of the selected process ID. |
| dbk_getPEThread | Returns the kernel pointer to the ETHREAD structure of a given thread ID. |
CPU Register Access[edit]
| Function | Description |
|---|---|
| dbk_readMSR | Reads a Model-Specific Register (MSR) using the DBK driver. |
| dbk_writeMSR | Writes a Model-Specific Register (MSR) using the DBK driver. |
| dbk_getCR0 | Returns the value of Control Register 0 (CR0). |
| dbk_getCR3 | Returns the value of Control Register 3 (CR3) for the currently opened process. |
| dbk_getCR4 | Returns the value of Control Register 4 (CR4). |
Memory and Execution[edit]
| Function | Description |
|---|---|
| dbk_getPhysicalAddress | Converts a virtual address to its physical address using the DBK driver. |
| dbk_executeKernelMemory | Executes a routine from kernel mode (e.g. injected code written with Auto Assembler). |
| dbk_writesIgnoreWriteProtection | When set to true, write operations bypass copy-on-write behavior.
|
DBVM[edit]
Functions for hypervisor-based operations and advanced memory monitoring via DBVM.
Initialization[edit]
| Function | Description |
|---|---|
| dbvm_initialize | Initializes the DBVM hypervisor functions for use. |
Memory Operations[edit]
| Function | Description |
|---|---|
| dbvm_addMemory | Adds a memory region to DBVM. |
| dbvm_readPhysicalMemory | Reads physical memory directly using DBVM (hypervisor-level access). |
| dbvm_writePhysicalMemory | Writes physical memory directly using DBVM (hypervisor-level access). |
MSR and Control Register Access[edit]
| Function | Description |
|---|---|
| dbvm_readMSR | Reads a Model-Specific Register (MSR) using DBVM (bypasses driver). |
| dbvm_writeMSR | Writes a Model-Specific Register (MSR) using DBVM (bypasses driver). |
| dbvm_getCR4 | Returns the real (unhooked) value of Control Register 4 (CR4). |
Memory Monitoring[edit]
| Function | Description |
|---|---|
| dbvm_watch_writes | Starts monitoring write accesses to a memory region. |
| dbvm_watch_reads | Starts monitoring read accesses to a memory region. |
| dbvm_watch_retrievelog | Retrieves the log/results of memory region monitoring (reads or writes). |
| dbvm_watch_disable | Stops memory region monitoring. |
Memory Cloaking[edit]
| Function | Description |
|---|---|
| dbvm_cloak_activate | Cloaks a memory page so modifications become invisible to the target process. |
| dbvm_cloak_deactivate | Disables cloaking on a page and undoes hidden modifications. |
| dbvm_cloak_readOriginal | Reads the original (hidden) memory contents of a cloaked region. |
| dbvm_cloak_writeOriginal | Writes to the original (hidden) memory contents of a cloaked region. |
Breakpoints and Debugging[edit]
| Function | Description |
|---|---|
| dbvm_changeregonbp | Cloaks a page, sets a breakpoint at the given address, and modifies registers when the breakpoint is hit. |
| dbvm_removechangeregonbp | Removes a "change registers on breakpoint" breakpoint. |
CR3 (Process Context) Logging[edit]
| Function | Description |
|---|---|
| dbvm_log_cr3_start | Starts logging all CR3 (process context/page directory) changes. |
| dbvm_log_cr3_stop | Stops CR3 logging. |
Performance and Anti-Detection[edit]
| Function | Description |
|---|---|
| dbvm_speedhack_setSpeed | Sets system-wide speed hack via DBVM (affects all processes). |
| dbvm_setTSCAdjust | Configures TSC (Time Stamp Counter) adjustment to bypass VM detection (RDTSC hooks). |
Translation[edit]
| Function | Description |
|---|---|
| getTranslationFolder | Returns the path to the current translation files. Returns an empty string if no translation is active. |
| loadPOFile | Loads a ".PO" translation file into Cheat Engine's translation system. |
| translate | Returns the translated text for a given source string. If no translation is found, returns the original string. |
| translateID | Returns the translation for a specific string ID (lookup by numerical or symbolic ID). |
Files[edit]
| Function | Description |
|---|---|
| getFileVersion | Returns a 64-bit file version and a table splitting the version into major, minor, release, and build.
|
| getFileList | Returns an indexed table (array) of filenames in the specified directory. |
| getDirectoryList | Returns an indexed table (array) of subdirectory names in the specified directory. |
Structures[edit]
| Function | Description |
|---|---|
| registerStructureDissectOverride | Registers a callback similar to onAutoGuess that the structure dissect window calls when the user requests Cheat Engine to guess a structure layout. |
| unregisterStructureDissectOverride | Unregisters a previously registered structure dissect auto-guess override. |
| registerStructureNameLookup | Registers a function that will be called when the structure dissect UI requests a name for a newly detected structure definition. |
| unregisterStructureNameLookup | Unregisters a previously registered structure name lookup callback. |
Miscellaneous[edit]
| Function | Description |
|---|---|
| injectDll | Injects a DLL into the currently opened process. |
| shellExecute | Executes a given command or opens a file/URL using the system shell. |
| executeCode | Executes a stdcall function at a given address in the target process with one parameter and waits for it to return. |
| executeCodeEx | Extended version of executeCode (supports more parameters/options).
|
| executeCodeLocal | Executes a stdcall function at a given address in Cheat Engine's own process (local execution). |
| executeCodeLocalEx | Extended version of executeCodeLocal with additional options.
|
| onAPIPointerChange | Registers a callback invoked when an API pointer is changed (allows reacting to API remapping). |
| setAPIPointer | Sets the pointer/address used for a specified API function. |
| md5memory | Computes and returns the MD5 checksum (hex string) of the bytes at the provided memory address/size. |
| md5file | Computes and returns the MD5 checksum (hex string) of a file's contents. |
| getSystemMetrics | Retrieves the specified system metric or configuration setting. See: MSDN documentation. |
| getTickCount | Returns the tick count in milliseconds since the system started. |
| getUserRegistryEnvironmentVariable | Reads an environment variable stored in the current user's registry environment. |
| setUserRegistryEnvironmentVariable | Writes an environment variable to the current user's registry environment. |
| broadcastEnvironmentUpdate | Broadcasts a notification that environment variables were changed (call after setting registry variables). |
| getApplication | Returns the application object (main application/titlebar context). |
| getInternet | Returns an Internet client class object. The provided string specifies the client name/type. |
Classes[edit]
A compact list of notable classes implemented by Cheat Engine.
| Class | Short description |
|---|---|
| Addresslist | Container for memory records in a cheat table. |
| Bitmap | Bitmap graphic object for drawing images. |
| Brush | Brush used by a Canvas to fill areas. |
| Button | Visual button component. |
| ButtonControl | Base class common to button-like controls. |
| Canvas | Drawing surface used in paint events for lines, text, and images. |
| Calendar | Calendar/date-picker UI control. |
| CEForm | Cheat Engine main/form window class. |
| CheatComponent | Component used in Cheat Engine 5.x trainers. |
| CheckBox | Checkbox UI control supporting checked/unchecked/indeterminate states. |
| Component | Base class for owner-managed components. |
| Control | Base class for visible UI controls. |
| Collection | Abstract collection class (used by ListColumns and similar). |
| CollectionItem | Item managed by a Collection. |
| ComboBox | Edit field with an attached dropdown ListBox. |
| CriticalSection | Synchronization primitive for thread-safe access. |
| CustomControl | Base class for windowed controls that handle their own painting. |
| CustomType | Custom data-type converter for interpreting raw memory. |
| D3DHOOK | D3D hook helper for rendering overlays in DirectX 9/10/11 games. |
| D3DHook_FontMap | Font texture map used by D3D hook rendering. |
| D3DHook_Texture | Texture management for D3D hook sprites. |
| D3Dhook_TextContainer | Text container used to draw text via D3D hook. |
| D3DHook_RenderObject | Abstract render object controlling rendering behavior. |
| D3DHook_Sprite | Rendered sprite/texture displayed via D3D hook. |
| Disassembler | Disassembler helper class. |
| Disassemblerview | Visual disassembler UI used in Memory View. |
| DisassemblerviewLine | Single line entry in a disassembler view. |
| DissectCode | Structure dissection helper. |
| Edit | Single-line text edit control. |
| Event | Event wrapper class for callbacks. |
| FileStream | Stream class for file-based I/O. |
| FileDialog | Standard file selection dialog wrapper. |
| FindDialog | Search/find dialog class. |
| Font | Font definition and metrics class. |
| Form | Window/form class. |
| FoundList | Companion class for MemScan results; reads result files. |
| GenericHotkey | Register hotkeys with CE's hotkey handler. |
| Graphic | Abstract base for image/graphic classes. |
| GraphicControl | Lightweight control for simple graphics. |
| GroupBox | Panel-like container with a header. |
| Hexadecimal | Hex display helper used by Memory View. |
| Hexadecimalview | Hex display UI component in the Memory View. |
| Icon | Icon resource wrapper. |
| Image | Image control for displaying pictures. |
| Internet | Internet client helper class. |
| JpegImage | JPEG image handler class. |
| Label | Static text label control. |
| LuaPipe | Abstract pipe communication class. |
| LuaPipeClient | Client implementation for pipe communication. |
| LuaPipeServer | Server implementation for pipe communication. |
| ListBox | List box control with selectable strings. |
| ListColumn | Column descriptor for a ListView. |
| ListColumns | Container for ListColumn objects. |
| ListItem | Entry in a ListView. |
| ListItems | Container for ListItem objects. |
| Listview | Multi-column list view control. |
| MainMenu | Top-level menu bar for a form. |
| Memo | Multi-line text editor control. |
| MemScan | Memory scanner class for performing scans. |
| Menu | Common ancestor for menu-related classes. |
| MenuItem | Menu item descriptor. |
| MemoryRecord | Cheat table entry describing an address/value/hotkey etc. |
| MemoryRecordHotkey | Hotkey interface for a MemoryRecord. |
| MemoryStream | In-memory stream class. |
| Memoryview | Memory view (hex editor) window class. |
| MultiReadExclusiveWriteSynchronizer | Synchronizer for safe concurrent read/write access. |
| Object | Root base class for most CE classes. |
| PaintBox | Control for custom painting surface. |
| PageControl | Container for multiple pages/tabs. |
| Panel | Container control for grouping child controls. |
| Pen | Drawing pen used by Canvas for lines. |
| Picture | Container for Graphic objects. |
| PopupMenu | Context (right-click) menu class. |
| PortableNetworkGraphic | PNG image class. |
| ProgressBar | Visual progress indicator control. |
| RadioGroup | Group of radio-button controls. |
| RasterImage | Base class for raster image controls. |
| RIPRelativeScanner | Helper for RIP-relative instruction scanning. |
| OpenDialog | File open dialog class. |
| SaveDialog | File save dialog class. |
| SelectDirectoryDialog | Directory selection dialog class. |
| Semaphore | Semaphore synchronization primitive. |
| Settings | Access and modify Cheat Engine settings and store plugin data. |
| Splitter | UI splitter control for resizing panels. |
| Stringlist | Ordered list container for strings. |
| Strings | Abstract base for text collections. |
| StringStream | Stream wrapper around a string buffer. |
| Structure | Structure definition class for memory layouts. |
| StructureElement | Single element inside a Structure. |
| StructureFrm | Structure editor/dissector form class. |
| structGroup | Grouping helper for structure elements. |
| SymbolList | Symbol lookup class (address ↔ name). |
| TabSheet | Single page within a PageControl. |
| TableFile | Represents a file stored inside a cheat table. |
| Thread | Thread wrapper class. |
| Timer | Non-visual timer component triggering onTimer events. |
| ToggleBox | Toggleable button-like control. |
| TrackBar | Slider control for numeric values. |
| TreeNode | Node in a Treeview. |
| TreeNodes | Container for TreeNode objects. |
| Treeview | Tree view control. |
| WinControl | Base class for windowed controls. |
| xmplayer | XM player class for tracker music playback. |
SQL Classes[edit]
| Class | Short description |
|---|---|
| CustomConnection | Base for custom DB connection implementations. |
| Database | Database container/manager for connections and datasets. |
| SQLConnection | Generic SQL connection abstraction. |
| SQLite3Connection | SQLite3 connection implementation. |
| ODBCConnection | ODBC data source connection. |
| DBTransaction | Transaction object for DB operations. |
| SQLTransaction | SQL-specific transaction object. |
| Param | Single query parameter object. |
| Params | Parameter container for queries. |
| Fields | Field metadata and values container. |
| Dataset | Abstract dataset representing query results. |
| DBDataset | Database-backed dataset implementation. |
| CustomBufDataset | In-memory buffered dataset. |
| CustomSQLQuery | Extended/custom SQL query object. |
| SQLQuery | Standard SQL query executor and result-holder. |
Class Helper Functions[edit]
| Function | Description |
|---|---|
| inheritsFromObject | Returns true if the given object/class inherits from Object.
|
| inheritsFromComponent | Returns true if the object/class inherits from Component.
|
| inheritsFromControl | Returns true if the object/class inherits from Control.
|
| inheritsFromWinControl | Returns true if the object/class inherits from WinControl.
|
| createClass | Creates an instance of the specified registered class (default constructor). |
| createComponentClass | Creates an instance of the specified component class (owner/parent may be required). |
Undefined Class Property Functions[edit]
Not all class properties are explicitly exposed; these helpers allow dynamic access to published properties and method/event bindings.
| Function | Description |
|---|---|
| getPropertyList | Returns a StringList of published property names for the specified class. |
| setProperty | Sets the value of a published property on an object instance (not usable for method properties). |
| getProperty | Gets the value of a published property on an object instance (not usable for method properties). |
| setMethodProperty | Assigns a Lua function to a method/event property on an object. |
| getMethodProperty | Retrieves a callable wrapper to invoke the original method/property on the object. |
| This page still needs significant improvements.
Please help by expanding or correcting this article where possible.
|