Difference between revisions of "Lua:process"
Jump to navigation
Jump to search
(Major overhaul of the post.) |
|||
| (3 intermediate revisions by 3 users not shown) | |||
| Line 1: | Line 1: | ||
[[Category:Lua]] | [[Category:Lua]] | ||
| − | ''' | + | {{CodeBox|'''variable''' process ''':''' string}} |
| − | + | Contains the main module name of the currently opened process. | |
| − | + | ===Value=== | |
| + | String — The main module name of the currently opened process. | ||
| + | If no process is opened, this variable may be empty or not point to a readable module base. | ||
| − | == Examples == | + | ===Examples=== |
| − | |||
| − | + | ====Print the current process module name==== | |
| − | + | <syntaxhighlight lang="lua" line highlight="1"> | |
| − | + | print(process) | |
| − | + | </syntaxhighlight> | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | + | ====Check whether Cheat Engine is attached==== | |
| + | <syntaxhighlight lang="lua" line highlight="1"> | ||
| + | local attached = readInteger(process) ~= nil | ||
| − | + | print("Attached: " .. tostring(attached)) | |
| − | + | </syntaxhighlight> | |
| − | |||
| − | |||
| − | |||
| − | + | ====Use process as a module base==== | |
| − | + | <syntaxhighlight lang="lua" line highlight="1"> | |
| − | + | local base = getAddress(process) | |
| − | |||
| + | print(string.format("%X", base)) | ||
| + | </syntaxhighlight> | ||
| − | == | + | ====Resolve an address relative to the main module==== |
| − | + | <syntaxhighlight lang="lua" line highlight="1"> | |
| − | + | local address = getAddress(process .. "+1234") | |
| − | + | print(string.format("%X", address)) | |
| − | + | </syntaxhighlight> | |
| − | === | + | ====Read a value relative to the main module==== |
| − | + | <syntaxhighlight lang="lua" line highlight="1"> | |
| − | + | local value = readInteger(process .. "+1234") | |
| − | + | ||
| − | + | print(value) | |
| − | + | </syntaxhighlight> | |
| − | + | ||
| − | + | ====Guard code until a process is attached==== | |
| − | + | <syntaxhighlight lang="lua" line highlight="1"> | |
| − | + | if readInteger(process) == nil then | |
| − | + | print("No readable process module is currently opened") | |
| − | + | return | |
| + | end | ||
| + | |||
| + | print("Attached to: " .. process) | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | ====Use process with auto assembler scripts==== | ||
| + | <syntaxhighlight lang="lua" line highlight="1,4"> | ||
| + | local script = process .. [[+1234: | ||
| + | nop | ||
| + | ]] | ||
| + | |||
| + | autoAssemble(script) | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | ====Compare process with a target name==== | ||
| + | <syntaxhighlight lang="lua" line highlight="1"> | ||
| + | if process == "game.exe" then | ||
| + | print("The target process is open") | ||
| + | end | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | {{LuaSeeAlso}} | ||
Latest revision as of 20:24, 25 June 2026
Contains the main module name of the currently opened process.
Contents
- 1 Value
- 2 Examples
- 2.1 Print the current process module name
- 2.2 Check whether Cheat Engine is attached
- 2.3 Use process as a module base
- 2.4 Resolve an address relative to the main module
- 2.5 Read a value relative to the main module
- 2.6 Guard code until a process is attached
- 2.7 Use process with auto assembler scripts
- 2.8 Compare process with a target name
Value[edit]
String — The main module name of the currently opened process.
If no process is opened, this variable may be empty or not point to a readable module base.
Examples[edit]
Print the current process module name[edit]
1 print(process)
Check whether Cheat Engine is attached[edit]
1 local attached = readInteger(process) ~= nil
2
3 print("Attached: " .. tostring(attached))
Use process as a module base[edit]
1 local base = getAddress(process)
2
3 print(string.format("%X", base))
Resolve an address relative to the main module[edit]
1 local address = getAddress(process .. "+1234")
2
3 print(string.format("%X", address))
Read a value relative to the main module[edit]
1 local value = readInteger(process .. "+1234")
2
3 print(value)
Guard code until a process is attached[edit]
1 if readInteger(process) == nil then
2 print("No readable process module is currently opened")
3 return
4 end
5
6 print("Attached to: " .. process)
Use process with auto assembler scripts[edit]
1 local script = process .. [[+1234:
2 nop
3 ]]
4
5 autoAssemble(script)
Compare process with a target name[edit]
1 if process == "game.exe" then
2 print("The target process is open")
3 end