Difference between revisions of "Lua:getAddress"

From Cheat Engine
Jump to navigation Jump to search
m
 
(5 intermediate revisions by one other user not shown)
Line 1: Line 1:
'''function''' getAddress(''AddressString'') ''':''' integer
+
[[Category:Lua]]
 
+
'''function''' getAddress(''String'', [''Local'']) ''':''' Integer
Passes the given string to Cheat Engine's symbol handler and returns the corresponding address as an integer
 
 
 
If errorOnLookupFailure is set to true (the default value), if you look up a symbol that does not exist, it will throw an error. With errorOnLookupFailure set to false, it will return 0.
 
  
 +
Returns the address of a symbol, module, or export. 
 +
If <code>Local</code> is true, queries the symbol table of the Cheat Engine process itself.
  
 
===Function Parameters===
 
===Function Parameters===
{|width="85%" cellpadding="10%" cellpadding="5%" cellspacing="0" border="0"
+
{|width="85%" cellpadding="10%" cellspacing="0" border="0"
 
!align="left"|Parameter
 
!align="left"|Parameter
 
!align="left"|Type
 
!align="left"|Type
 
!style="width: 80%;background-color:white;" align="left"|Description
 
!style="width: 80%;background-color:white;" align="left"|Description
 
|-
 
|-
|AddressString
+
|String
|[[CEAddressString]]
+
|String
|The addressstring to convert to an integer
+
|The symbol, module name, or export to resolve to an address.
 +
|-
 +
|Local
 +
|Boolean (optional)
 +
|If true, queries the symbol table of the Cheat Engine process. Default is false (target process).
 
|}
 
|}
  
 +
===Returns===
 +
Integer — The resolved address, or nil if not found.
 +
 +
===Examples===
 +
<pre>
 +
-- Get the address of a registered symbol in the target process
 +
registerSymbol("MySymbol", 0x401000)
 +
local symAddr = getAddress("MySymbol")
 +
print(string.format("MySymbol = 0x%X", symAddr))
 +
 +
-- Get the address of a symbol in the target process
 +
local ceAddr = getAddress("cheatengine-x86_64-SSE4-AVX2.exe+5000")
 +
print(string.format("CE process address = 0x%X", ceAddr))
 +
</pre>
  
== See also ==
+
{{LuaSeeAlso}}
* [[Lua]]
 
* [[Help_File:Script engine|Script engine]]
 
  
 
=== Related Functions ===
 
=== Related Functions ===
* [[getNameFromAddress]]
+
* [[Lua:getAddressSafe|getAddressSafe]]
* [[getCommonModuleList]]
+
* [[Lua:getNameFromAddress|getNameFromAddress]]
* [[inModule]]
+
* [[Lua:getCommonModuleList|getCommonModuleList]]
* [[inSystemModule]]
+
* [[Lua:inModule|inModule]]
* [[targetIs64Bit]]
+
* [[Lua:inSystemModule|inSystemModule]]
* [[enumModules]]
+
* [[Lua:targetIs64Bit|targetIs64Bit]]
 +
* [[Lua:enumModules|enumModules]]

Latest revision as of 19:46, 11 July 2025

function getAddress(String, [Local]) : Integer

Returns the address of a symbol, module, or export. If Local is true, queries the symbol table of the Cheat Engine process itself.

Function Parameters[edit]

Parameter Type Description
String String The symbol, module name, or export to resolve to an address.
Local Boolean (optional) If true, queries the symbol table of the Cheat Engine process. Default is false (target process).

Returns[edit]

Integer — The resolved address, or nil if not found.

Examples[edit]

-- Get the address of a registered symbol in the target process
registerSymbol("MySymbol", 0x401000)
local symAddr = getAddress("MySymbol")
print(string.format("MySymbol = 0x%X", symAddr))

-- Get the address of a symbol in the target process
local ceAddr = getAddress("cheatengine-x86_64-SSE4-AVX2.exe+5000")
print(string.format("CE process address = 0x%X", ceAddr))

See also[edit]

Related Functions[edit]