Difference between revisions of "Lua:autoAssemble"
Jump to navigation
Jump to search
(no special chars in syntaxhightlighting needed) |
|||
(8 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
[[Category:Lua]] | [[Category:Lua]] | ||
[[Category:Assembler]] | [[Category:Assembler]] | ||
− | '''function''' autoAssemble(''AutoAssemblerScript'', ''TargetSelf'' OPTIONAL, ''DisableInfo'' OPTIONAL) ''':''' nil '''-''' boolean | + | '''function''' autoAssemble(''AutoAssemblerScript'', ''TargetSelf'' OPTIONAL, ''DisableInfo'' OPTIONAL) ''':''' nil,errorstring '''-''' boolean, table |
− | '''function''' autoAssemble(''AutoAssemblerScript'', ''DisableInfo'' OPTIONAL) ''':''' nil '''-''' boolean | + | '''function''' autoAssemble(''AutoAssemblerScript'', ''DisableInfo'' OPTIONAL) ''':''' nil,errorstring '''-''' boolean, table |
runs the auto assembler with the given text. Returns true on success, with as secondary a table you can use when disabling (if ''TargetSelf'' is set it will assemble into Cheat Engine itself). If ''DisableInfo'' is provided the [Disable] section will be handled. | runs the auto assembler with the given text. Returns true on success, with as secondary a table you can use when disabling (if ''TargetSelf'' is set it will assemble into Cheat Engine itself). If ''DisableInfo'' is provided the [Disable] section will be handled. | ||
Line 28: | Line 28: | ||
|If provided the [Disable] section will be handled | |If provided the [Disable] section will be handled | ||
|} | |} | ||
+ | |||
+ | {|width="85%" cellpadding="10%" cellpadding="5%" cellspacing="0" border="0" | ||
+ | !align="left"|Parameter | ||
+ | !align="left"|Type | ||
+ | !style="width: 80%;background-color:white;" align="left"|Description | ||
+ | |- | ||
+ | |AutoAssemblerScript | ||
+ | |string | ||
+ | |The script to run with Cheat Engine's auto assembler | ||
+ | |- | ||
+ | |DisableInfo | ||
+ | |boolean | ||
+ | |If provided the [Disable] section will be handled | ||
+ | |} | ||
+ | |||
== Examples == | == Examples == | ||
− | + | <syntaxhighlight lang="lua"> | |
autoAssemble("{$lua}\n print('Printed Form Auto Assembler Script!')") | autoAssemble("{$lua}\n print('Printed Form Auto Assembler Script!')") | ||
− | local scriptStr = | + | local scriptStr = [[ |
alloc(memExample) | alloc(memExample) | ||
label(returnHere) | label(returnHere) | ||
− | + | ||
memExample: | memExample: | ||
mov eax,123 | mov eax,123 | ||
Line 47: | Line 62: | ||
jmp memExample | jmp memExample | ||
returnHere: | returnHere: | ||
− | + | ]] | |
− | + | ||
if autoAssemble(scriptStr) then | if autoAssemble(scriptStr) then | ||
print('The auto assembler script was successful.') | print('The auto assembler script was successful.') | ||
Line 56: | Line 71: | ||
− | local scriptStr = | + | local scriptStr = [==[ |
+ | alloc(memExample) | ||
+ | label(returnHere) | ||
+ | |||
+ | memExample: | ||
+ | mov eax,123 | ||
+ | jmp returnHere | ||
+ | |||
+ | 00400500: | ||
+ | jmp memExample | ||
+ | returnHere: | ||
+ | ]==] | ||
+ | ---- Enable script | ||
+ | local enabledOk, disableInfo = autoAssemble(scriptStr) | ||
+ | if enabledOk then | ||
+ | print('The auto assembler script was enabled successfully.') | ||
+ | else | ||
+ | print('There was an error enabling the auto assembler script.') | ||
+ | end | ||
+ | ---- Disable script | ||
+ | local disabledOk = autoAssemble(scriptStr, disableInfo) | ||
+ | if disabledOk then | ||
+ | disableInfo = nil | ||
+ | print('The auto assembler script was disabled successfully.') | ||
+ | else | ||
+ | print('There was an error disabling the auto assembler script.') | ||
+ | end | ||
+ | |||
+ | |||
+ | local scriptStr = [[ | ||
alloc(memExample2) | alloc(memExample2) | ||
memExample2: | memExample2: | ||
Line 67: | Line 111: | ||
// map base | // map base | ||
dq 0 | dq 0 | ||
− | + | ]] | |
− | + | ||
if not autoAssemble(scriptStr, true) then | if not autoAssemble(scriptStr, true) then | ||
return 1, 'There was an error with the auto assembler script.' | return 1, 'There was an error with the auto assembler script.' | ||
end | end | ||
− | + | </syntaxhighlight> | |
{{LuaSeeAlso}} | {{LuaSeeAlso}} | ||
=== Related Functions === | === Related Functions === | ||
− | * [[AOBScan]] | + | * [[Lua:autoAssembleCheck|autoAssembleCheck]] |
− | * [[disassemble]] | + | * [[Lua:AOBScan|AOBScan]] |
− | * [[getInstructionSize]] | + | * [[Lua:disassemble|disassemble]] |
− | * [[getPreviousOpcode]] | + | * [[Lua:getInstructionSize|getInstructionSize]] |
− | * [[allocateSharedMemory]] | + | * [[Lua:getPreviousOpcode|getPreviousOpcode]] |
− | * [[mapMemory]] | + | * [[Lua:allocateSharedMemory|allocateSharedMemory]] |
− | * [[unmapMemory]] | + | * [[Lua:mapMemory|mapMemory]] |
− | * [[readBytes]] | + | * [[Lua:unmapMemory|unmapMemory]] |
− | * [[readPointer]] | + | * [[Lua:readBytes|readBytes]] |
− | * [[writeBytes]] | + | * [[Lua:readPointer|readPointer]] |
− | * [[readBytesLocal]] | + | * [[Lua:writeBytes|writeBytes]] |
− | * [[readPointerLocal]] | + | * [[Lua:readBytesLocal|readBytesLocal]] |
− | * [[writeBytesLocal]] | + | * [[Lua:readPointerLocal|readPointerLocal]] |
− | * [[wordToByteTable]] | + | * [[Lua:writeBytesLocal|writeBytesLocal]] |
− | * [[dwordToByteTable]] | + | * [[Lua:wordToByteTable|wordToByteTable]] |
− | * [[qwordToByteTable]] | + | * [[Lua:dwordToByteTable|dwordToByteTable]] |
− | * [[floatToByteTable]] | + | * [[Lua:qwordToByteTable|qwordToByteTable]] |
− | * [[doubleToByteTable]] | + | * [[Lua:floatToByteTable|floatToByteTable]] |
− | * [[stringToByteTable]] | + | * [[Lua:doubleToByteTable|doubleToByteTable]] |
− | * [[wideStringToByteTable]] | + | * [[Lua:stringToByteTable|stringToByteTable]] |
− | * [[byteTableToWord]] | + | * [[Lua:wideStringToByteTable|wideStringToByteTable]] |
− | * [[byteTableToDword]] | + | * [[Lua:byteTableToWord|byteTableToWord]] |
− | * [[byteTableToQword]] | + | * [[Lua:byteTableToDword|byteTableToDword]] |
− | * [[byteTableToFloat]] | + | * [[Lua:byteTableToQword|byteTableToQword]] |
− | * [[byteTableToDouble]] | + | * [[Lua:byteTableToFloat|byteTableToFloat]] |
− | * [[byteTableToString]] | + | * [[Lua:byteTableToDouble|byteTableToDouble]] |
− | * [[byteTableToWideString]] | + | * [[Lua:byteTableToString|byteTableToString]] |
+ | * [[Lua:byteTableToWideString|byteTableToWideString]] |
Latest revision as of 08:35, 18 May 2019
function autoAssemble(AutoAssemblerScript, TargetSelf OPTIONAL, DisableInfo OPTIONAL) : nil,errorstring - boolean, table
function autoAssemble(AutoAssemblerScript, DisableInfo OPTIONAL) : nil,errorstring - boolean, table
runs the auto assembler with the given text. Returns true on success, with as secondary a table you can use when disabling (if TargetSelf is set it will assemble into Cheat Engine itself). If DisableInfo is provided the [Disable] section will be handled.
Tip: Use '[[ ]]' or '[==[ ]==]' quotes for multiline script.
Function Parameters[edit]
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 |
DisableInfo | boolean | If provided the [Disable] section will be handled |
Parameter | Type | Description |
---|---|---|
AutoAssemblerScript | string | The script to run with Cheat Engine's auto assembler |
DisableInfo | boolean | If provided the [Disable] section will be handled |
Examples[edit]
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(memExample)
label(returnHere)
memExample:
mov eax,123
jmp returnHere
00400500:
jmp memExample
returnHere:
]==]
---- Enable script
local enabledOk, disableInfo = autoAssemble(scriptStr)
if enabledOk then
print('The auto assembler script was enabled successfully.')
else
print('There was an error enabling the auto assembler script.')
end
---- Disable script
local disabledOk = autoAssemble(scriptStr, disableInfo)
if disabledOk then
disableInfo = nil
print('The auto assembler script was disabled successfully.')
else
print('There was an error disabling 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[edit]
Related Functions[edit]
- autoAssembleCheck
- AOBScan
- disassemble
- getInstructionSize
- getPreviousOpcode
- allocateSharedMemory
- mapMemory
- unmapMemory
- readBytes
- readPointer
- writeBytes
- readBytesLocal
- readPointerLocal
- writeBytesLocal
- wordToByteTable
- dwordToByteTable
- qwordToByteTable
- floatToByteTable
- doubleToByteTable
- stringToByteTable
- wideStringToByteTable
- byteTableToWord
- byteTableToDword
- byteTableToQword
- byteTableToFloat
- byteTableToDouble
- byteTableToString
- byteTableToWideString