Difference between revisions of "Lua:getAddress"

From Cheat Engine
Jump to navigation Jump to search
m
m (Added related function template.)
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
[[Category:Lua]]
 
[[Category:Lua]]
'''function''' getAddress(''String'', [''Local'']) ''':''' Integer
+
{{CodeBox|'''function''' getAddress(''string'', ''local'') ''':''' integer}}
  
Returns the address of a symbol, module, or export.
+
Returns the address of a symbol.
If <code>Local</code> is true, queries the symbol table of the Cheat Engine process itself.
+
 
 +
The symbol can be a registered symbol, a module name, or an exported symbol. Set ''local'' to true to query the symbol table of the Cheat Engine process instead of the currently opened target process.
  
 
===Function Parameters===
 
===Function Parameters===
Line 11: Line 12:
 
!style="width: 80%;background-color:white;" align="left"|Description
 
!style="width: 80%;background-color:white;" align="left"|Description
 
|-
 
|-
|String
+
|symbolname
|String
+
|String or [[CEAddressString]]
|The symbol, module name, or export to resolve to an address.
+
|The symbol, module name, or exported symbol to resolve.
 
|-
 
|-
|Local
+
|local
 
|Boolean (optional)
 
|Boolean (optional)
|If true, queries the symbol table of the Cheat Engine process. Default is false (target process).
+
|If true, queries the symbol table of the Cheat Engine process.
 
|}
 
|}
  
 
===Returns===
 
===Returns===
Integer — The resolved address, or nil if not found.
+
integer — The resolved address of the given symbol.
  
 
===Examples===
 
===Examples===
<pre>
+
<syntaxhighlight lang="lua" line>
-- Get the address of a registered symbol in the target process
+
local address = getAddress("KERNEL32.AddAtomA")
registerSymbol("MySymbol", 0x401000)
 
local symAddr = getAddress("MySymbol")
 
print(string.format("MySymbol = 0x%X", symAddr))
 
  
-- Get the address of a symbol in the target process
+
print(string.format("%X", address))
local ceAddr = getAddress("cheatengine-x86_64-SSE4-AVX2.exe+5000")
+
</syntaxhighlight>
print(string.format("CE process address = 0x%X", ceAddr))
 
</pre>
 
  
 
{{LuaSeeAlso}}
 
{{LuaSeeAlso}}
  
=== Related Functions ===
+
{{Address}}
* [[Lua:getAddressSafe|getAddressSafe]]
 
* [[Lua:getNameFromAddress|getNameFromAddress]]
 
* [[Lua:getCommonModuleList|getCommonModuleList]]
 
* [[Lua:inModule|inModule]]
 
* [[Lua:inSystemModule|inSystemModule]]
 
* [[Lua:targetIs64Bit|targetIs64Bit]]
 
* [[Lua:enumModules|enumModules]]
 

Latest revision as of 22:48, 26 June 2026

<> Lua API Reference

function getAddress(string, local) : integer

Returns the address of a symbol.

The symbol can be a registered symbol, a module name, or an exported symbol. Set local to true to query the symbol table of the Cheat Engine process instead of the currently opened target process.

Function Parameters[edit]

Parameter Type Description
symbolname String or CEAddressString The symbol, module name, or exported symbol to resolve.
local Boolean (optional) If true, queries the symbol table of the Cheat Engine process.

Returns[edit]

integer — The resolved address of the given symbol.

Examples[edit]

1 local address = getAddress("KERNEL32.AddAtomA")
2 
3 print(string.format("%X", address))

Main Pages

Core Lua documentation entry points

Lua
Script Engine

Symbol Related Lua Functions

Symbol lookup, address resolution, module checks, and lookup callbacks