Difference between revisions of "Lua:autoAssembleCheck"

From Cheat Engine
Jump to navigation Jump to search
m (Added CodeBox Template.)
m (Updated example.)
Line 27: Line 27:
 
<pre>
 
<pre>
 
local script = [[
 
local script = [[
  alloc(newmem,1024)
+
alloc(newmem,2048,"cheatengine-x86_64-SSE4-AVX2.exe"+3E18)
  label(returnhere)
+
label(returnhere)
  ...
+
label(originalcode)
 +
label(exit)
 +
 
 +
newmem: //this is allocated memory, you have read,write,execute access
 +
//place your code here
 +
 
 +
originalcode:
 +
lea rsp,[rsp+28]
 +
 
 +
exit:
 +
jmp returnhere
 +
 
 +
"cheatengine-x86_64-SSE4-AVX2.exe"+3E18:
 +
jmp newmem
 +
returnhere:
 
]]
 
]]
  

Revision as of 00:30, 5 December 2025

<> Lua API Reference

function autoAssembleCheck(text, enable, targetself)

Checks the given Auto Assembler script for syntax errors. Returns true on success, or false with an error message on failure.

Function Parameters

Parameter Type Description
text String The Auto Assembler script to validate.
enable Boolean If set, checks the [ENABLE] part of the script.
targetself Boolean If true, checks the script as if assembling into Cheat Engine itself.

Example

local script = [[
alloc(newmem,2048,"cheatengine-x86_64-SSE4-AVX2.exe"+3E18)
label(returnhere)
label(originalcode)
label(exit)

newmem: //this is allocated memory, you have read,write,execute access
//place your code here

originalcode:
lea rsp,[rsp+28]

exit:
jmp returnhere

"cheatengine-x86_64-SSE4-AVX2.exe"+3E18:
jmp newmem
returnhere:
]]

local ok, err = autoAssembleCheck(script, true, false)
if ok then
  print("Script is valid")
else
  print("Syntax error:", err)
end

Main Pages

Core Lua documentation entry points

Lua
Script Engine

Assembler and Disassembler Related Lua Functions

Auto assembler, disassembly helpers, instruction size lookup, and assembler callbacks