Difference between revisions of "Lua:autoAssemble"

From Cheat Engine
Jump to navigation Jump to search
m (Reverted edits by 84.243.24.18 (Talk) to last revision by Dark Byte)
Line 1: Line 1:
 
'''function''' autoAssemble(''AutoAssemblerScript'', ''TargetSelf'' OPTIONAL)
 
'''function''' autoAssemble(''AutoAssemblerScript'', ''TargetSelf'' OPTIONAL)
  
Executes the given string by ce's auto assembler.
+
Runs the given string with Cheat Engine's auto assembler. Returns 'true' on success.
  
tip: Use [[  ]] quotes for multiline script.
+
Tip: Use '[[ ]]' or '[==[ ]==]' quotes for multiline script.
  
Example:
+
=== Function Parameters ===
  autoAssemble([[
 
    alloc(myscript)
 
    label(returnhere)
 
   
 
    myscript:
 
    mov eax,123
 
    jmp returnhere
 
   
 
    00400500:
 
    jmp myscript
 
    returnhere:   
 
  ]])
 
  
 
===Function Parameters===
 
 
{|width="85%" cellpadding="10%" cellpadding="5%" cellspacing="0" border="0"
 
{|width="85%" cellpadding="10%" cellpadding="5%" cellspacing="0" border="0"
 
!align="left"|Parameter
 
!align="left"|Parameter
Line 27: Line 13:
 
|-
 
|-
 
|AutoAssemblerScript
 
|AutoAssemblerScript
|String
+
|string
|The script to execute by the auto assembler
+
|The script to run with Cheat Engine's auto assembler
 
|-
 
|-
 
|TargetSelf
 
|TargetSelf
|Boolean
+
|boolean
|When set to true the autoassembler will assemble the given script in Cheat Engine's address space instead of the target process.
+
|If set it will assemble into Cheat Engine itself
 
|}
 
|}
 +
 +
 +
== Examples ==
 +
 +
 +
  autoAssemble("{$lua}\n print('Printed Form Auto Assembler Script!')")
 +
 +
 +
  local scriptStr = [==[
 +
    alloc(memExample)
 +
    label(returnHere)
 +
     
 +
    memExample:
 +
      mov eax,123
 +
      jmp returnHere
 +
     
 +
    00400500:
 +
      jmp memExample
 +
      returnHere:
 +
  ]==]
 +
   
 +
  if autoAssemble(scriptStr) then
 +
    print('The auto assembler script was successful.')
 +
  else
 +
    print('There was an error with the auto assembler script.')
 +
  end
 +
 +
 +
  local scriptStr = [==[
 +
    alloc(memExample2)
 +
    memExample2:
 +
      dd (float)364.12458729
 +
      dd (float)12.65594753
 +
      dd (float)50.75331054
 +
      dd 0
 +
      // player base
 +
      dq 0
 +
      // map base
 +
      dq 0
 +
  ]==]
 +
   
 +
  if not autoAssemble(scriptStr, true) then
 +
    return 1, 'There was an error with the auto assembler script.'
 +
  end
  
  
 
== See also ==
 
== See also ==
 
* [[Lua]]
 
* [[Lua]]
 +
* [[Help_File:Script engine|Script engine]]
 +
 +
=== Related Functions ===
 +
* [[AOBScan]]
 +
* [[disassemble]]
 +
* [[getInstructionSize]]
 +
* [[getPreviousOpcode]]
 +
* [[allocateSharedMemory]]
 +
* [[mapMemory]]
 +
* [[unmapMemory]]
 +
* [[readBytes]]
 +
* [[readPointer]]
 +
* [[writeBytes]]
 +
* [[writeFloat]]
 +
* [[readBytesLocal]]
 +
* [[readPointerLocal]]
 +
* [[writeBytesLocal]]
 +
* [[wordToByteTable]]
 +
* [[dwordToByteTable]]
 +
* [[qwordToByteTable]]
 +
* [[floatToByteTable]]
 +
* [[doubleToByteTable]]
 +
* [[stringToByteTable]]
 +
* [[wideStringToByteTable]]
 +
* [[byteTableToWord]]
 +
* [[byteTableToDword]]
 +
* [[byteTableToQword]]
 +
* [[byteTableToFloat]]
 +
* [[byteTableToDouble]]
 +
* [[byteTableToString]]
 +
* [[byteTableToWideString]]

Revision as of 19:15, 9 March 2017

function autoAssemble(AutoAssemblerScript, TargetSelf OPTIONAL)

Runs the given string with Cheat Engine's auto assembler. Returns 'true' on success.

Tip: Use '[[ ]]' or '[==[ ]==]' quotes for multiline script.

Function Parameters

Parameter Type Description
AutoAssemblerScript string The script to run with Cheat Engine's auto assembler
TargetSelf boolean If set it will assemble into Cheat Engine itself


Examples

 autoAssemble("{$lua}\n print('Printed Form Auto Assembler Script!')")


 local scriptStr = [==[
   alloc(memExample)
   label(returnHere)
    
   memExample:
     mov eax,123
     jmp returnHere
    
   00400500:
     jmp memExample
     returnHere:
 ]==]
  
 if autoAssemble(scriptStr) then
   print('The auto assembler script was successful.')
 else
   print('There was an error with the auto assembler script.')
 end


 local scriptStr = [==[
   alloc(memExample2)
   memExample2:
     dd (float)364.12458729
     dd (float)12.65594753
     dd (float)50.75331054
     dd 0
     // player base
     dq 0
     // map base
     dq 0
 ]==]
  
 if not autoAssemble(scriptStr, true) then
   return 1, 'There was an error with the auto assembler script.'
 end


See also

Related Functions