Difference between revisions of "Lua:getAddressSafe"
Jump to navigation
Jump to search
Mr millchick (talk | contribs) (added more detailed documentation as well as examples and comparison with getAddress) |
|||
| Line 1: | Line 1: | ||
[[Category:Lua]] | [[Category:Lua]] | ||
| − | '''function''' getAddressSafe('' | + | {{CodeBox|'''function''' getAddressSafe(''symbolname'', ''local'', ''shallow'') ''':''' integer}} |
| − | + | Returns the address of a symbol, or nil if the symbol could not be resolved. | |
| − | + | This function is similar to using getAddress with errorOnLookup set to false, but returns nil instead of raising an error when the symbol is not found. | |
| − | + | 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. | |
| − | {|width="85%" cellpadding="10 | + | ===Function Parameters=== |
| + | {|width="85%" cellpadding="10%" cellspacing="0" border="0" | ||
!align="left"|Parameter | !align="left"|Parameter | ||
!align="left"|Type | !align="left"|Type | ||
| − | !style="width: 80%;" align="left"|Description | + | !style="width: 80%;background-color:white;" align="left"|Description |
|- | |- | ||
| − | | | + | |symbolname |
| − | | | + | |String |
| − | |The symbol | + | |The symbol, module name, or exported symbol to resolve. |
|- | |- | ||
|local | |local | ||
| − | | | + | |Boolean (optional) |
| − | | | + | |If true, queries the symbol table of the Cheat Engine process. |
|- | |- | ||
|shallow | |shallow | ||
| − | | | + | |Boolean (optional) |
| − | | | + | |If true, performs a shallow lookup. |
|} | |} | ||
| + | ===Returns=== | ||
| + | integer or nil — The resolved address of the given symbol, or nil if the symbol could not be found. | ||
| − | === | + | ===Examples=== |
| − | + | <pre> | |
| − | + | local address = getAddressSafe("KERNEL32.AddAtomA") | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| + | if address ~= nil then | ||
| + | print(string.format("%X", address)) | ||
| + | else | ||
| + | print("Symbol could not be resolved") | ||
| + | end | ||
| + | </pre> | ||
{{LuaSeeAlso}} | {{LuaSeeAlso}} | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
Revision as of 04:36, 21 June 2026
Returns the address of a symbol, or nil if the symbol could not be resolved.
This function is similar to using getAddress with errorOnLookup set to false, but returns nil instead of raising an error when the symbol is not found.
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
| Parameter | Type | Description |
|---|---|---|
| symbolname | String | The symbol, module name, or exported symbol to resolve. |
| local | Boolean (optional) | If true, queries the symbol table of the Cheat Engine process. |
| shallow | Boolean (optional) | If true, performs a shallow lookup. |
Returns
integer or nil — The resolved address of the given symbol, or nil if the symbol could not be found.
Examples
local address = getAddressSafe("KERNEL32.AddAtomA")
if address ~= nil then
print(string.format("%X", address))
else
print("Symbol could not be resolved")
end