Difference between revisions of "Lua:executeCode"

From Cheat Engine
Jump to navigation Jump to search
(Created page with "<p><b>executeCode(address, parameter OPTIONAL, timeout OPTIONAL) : address</b> - Executes a stdcall function with 1 parameter at the given address in the target process and w...")
 
 
Line 1: Line 1:
<p><b>executeCode(address, parameter OPTIONAL, timeout OPTIONAL) : address</b> - Executes a stdcall function with 1 parameter at the given address in the target process and wait for it to return. The return value is the result of the function that was called</p>
+
[[Category:Lua]]
 +
{{NeedWork}}
 +
{{CodeBox|'''function''' executeCode(''address'', ''parameter'', ''timeout'') ''':''' address}}
 +
 
 +
Executes a stdcall function at the given address in the target process and waits for it to return.
 +
 
 +
This function supports one optional parameter. The return value is the result of the function that was called.
 +
 
 +
For more advanced calls, multiple parameters, explicit parameter types, or different calling conventions, use executeCodeEx.
 +
 
 +
===Function Parameters===
 +
{|width="85%" cellpadding="10%" cellspacing="0" border="0"
 +
!align="left"|Parameter
 +
!align="left"|Type
 +
!style="width: 80%;background-color:white;" align="left"|Description
 +
|-
 +
|address
 +
|Integer or [[CEAddressString]]
 +
|The address of the stdcall function to execute in the target process.
 +
|-
 +
|parameter
 +
|Any (optional)
 +
|The optional parameter to pass to the function.
 +
|-
 +
|timeout
 +
|Integer (optional)
 +
|The number of milliseconds to wait for the function to return.
 +
|}
 +
 
 +
===Returns===
 +
address — The return value of the function that was called.
 +
 
 +
===Examples===
 +
<pre>
 +
local functionAddress = getAddress("SomeFunction")
 +
 
 +
local result = executeCode(functionAddress)
 +
 
 +
print("Result: " .. tostring(result))
 +
</pre>
 +
 
 +
<pre>
 +
local functionAddress = getAddress("SomeFunction")
 +
 
 +
local result = executeCode(functionAddress, 123)
 +
 
 +
print("Result: " .. tostring(result))
 +
</pre>
 +
 
 +
<pre>
 +
local functionAddress = getAddress("SomeFunction")
 +
 
 +
-- Wait up to 1000 milliseconds for the function to return
 +
local result = executeCode(functionAddress, 123, 1000)
 +
 
 +
print("Result: " .. tostring(result))
 +
</pre>
 +
 
 +
{{LuaSeeAlso}}

Latest revision as of 05:06, 21 June 2026

⚠️ Work Needed

This page still needs significant improvements.

Please help by expanding or correcting this article where possible.

For suggestions or discussion, see the talk page.

<> Lua API Reference

function executeCode(address, parameter, timeout) : address

Executes a stdcall function at the given address in the target process and waits for it to return.

This function supports one optional parameter. The return value is the result of the function that was called.

For more advanced calls, multiple parameters, explicit parameter types, or different calling conventions, use executeCodeEx.

Function Parameters[edit]

Parameter Type Description
address Integer or CEAddressString The address of the stdcall function to execute in the target process.
parameter Any (optional) The optional parameter to pass to the function.
timeout Integer (optional) The number of milliseconds to wait for the function to return.

Returns[edit]

address — The return value of the function that was called.

Examples[edit]

local functionAddress = getAddress("SomeFunction")

local result = executeCode(functionAddress)

print("Result: " .. tostring(result))
local functionAddress = getAddress("SomeFunction")

local result = executeCode(functionAddress, 123)

print("Result: " .. tostring(result))
local functionAddress = getAddress("SomeFunction")

-- Wait up to 1000 milliseconds for the function to return
local result = executeCode(functionAddress, 123, 1000)

print("Result: " .. tostring(result))

Main Pages

Core Lua documentation entry points

Lua
Script Engine