Difference between revisions of "Lua:getNameFromAddress"
Jump to navigation
Jump to search
m (Added related function template.) |
|||
| (8 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
[[Category:Lua]] | [[Category:Lua]] | ||
| − | '''function''' getNameFromAddress(''address'') ''':''' string | + | {{CodeBox|'''function''' getNameFromAddress(''address'', ''ModuleNames'', ''Symbols'', ''Sections'') ''':''' string}} |
| − | Returns | + | Returns the given address as a string. |
| + | |||
| + | Depending on the address and the enabled lookup options, the returned string can be a registered symbol name, a module name with offset, a section name with offset, or a hexadecimal address string. | ||
===Function Parameters=== | ===Function Parameters=== | ||
| − | {|width="85%" cellpadding="10 | + | {|width="85%" cellpadding="10%" cellspacing="0" border="0" |
!align="left"|Parameter | !align="left"|Parameter | ||
!align="left"|Type | !align="left"|Type | ||
| Line 11: | Line 13: | ||
|- | |- | ||
|address | |address | ||
| − | |[[CEAddressString]] | + | |Integer or [[CEAddressString]] |
| − | |The address to convert to a string | + | |The address to convert to a readable name string. |
| + | |- | ||
| + | |ModuleNames | ||
| + | |Boolean (optional) | ||
| + | |If true, module names may be used when formatting the returned address string. Defaults to true. | ||
| + | |- | ||
| + | |Symbols | ||
| + | |Boolean (optional) | ||
| + | |If true, registered symbols may be used when formatting the returned address string. Defaults to true. | ||
| + | |- | ||
| + | |Sections | ||
| + | |Boolean (optional) | ||
| + | |If true, section names may be used when formatting the returned address string. Defaults to false. | ||
|} | |} | ||
| + | ===Returns=== | ||
| + | string — The given address represented as a readable string. | ||
| + | |||
| + | ===Examples=== | ||
| + | <syntaxhighlight lang="lua" line> | ||
| + | local address = getAddress("KERNEL32.AddAtomA") | ||
| + | local name = getNameFromAddress(address) | ||
| + | |||
| + | print(name) | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | <syntaxhighlight lang="lua" line> | ||
| + | local address = getAddress("KERNEL32.AddAtomA") | ||
| + | |||
| + | -- Allow module names and symbols, but do not include section names | ||
| + | local name = getNameFromAddress(address, true, true, false) | ||
| + | |||
| + | print(name) | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | <syntaxhighlight lang="lua" line> | ||
| + | local address = getAddress("KERNEL32.AddAtomA") | ||
| + | |||
| + | -- Return a more raw representation by disabling module names, symbols, and sections | ||
| + | local name = getNameFromAddress(address, false, false, false) | ||
| + | |||
| + | print(name) | ||
| + | </syntaxhighlight> | ||
| − | + | {{LuaSeeAlso}} | |
| − | |||
| − | |||
| − | + | {{Address}} | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
Latest revision as of 22:48, 26 June 2026
Returns the given address as a string.
Depending on the address and the enabled lookup options, the returned string can be a registered symbol name, a module name with offset, a section name with offset, or a hexadecimal address string.
Function Parameters[edit]
| Parameter | Type | Description |
|---|---|---|
| address | Integer or CEAddressString | The address to convert to a readable name string. |
| ModuleNames | Boolean (optional) | If true, module names may be used when formatting the returned address string. Defaults to true. |
| Symbols | Boolean (optional) | If true, registered symbols may be used when formatting the returned address string. Defaults to true. |
| Sections | Boolean (optional) | If true, section names may be used when formatting the returned address string. Defaults to false. |
Returns[edit]
string — The given address represented as a readable string.
Examples[edit]
1 local address = getAddress("KERNEL32.AddAtomA")
2 local name = getNameFromAddress(address)
3
4 print(name)
1 local address = getAddress("KERNEL32.AddAtomA")
2
3 -- Allow module names and symbols, but do not include section names
4 local name = getNameFromAddress(address, true, true, false)
5
6 print(name)
1 local address = getAddress("KERNEL32.AddAtomA")
2
3 -- Return a more raw representation by disabling module names, symbols, and sections
4 local name = getNameFromAddress(address, false, false, false)
5
6 print(name)