Difference between revisions of "Lua:readString"
Jump to navigation
Jump to search
m (moved readString to Lua:readString) |
m (Added CodeBox Template.) |
||
| (One intermediate revision by the same user not shown) | |||
| Line 1: | Line 1: | ||
[[Category:Lua]] | [[Category:Lua]] | ||
| − | '''function''' readString(''Address'', '' | + | {{CodeBox|'''function''' readString(''Address'', ''MaxLength'', [''WideChar'']) ''':''' String}} |
| − | Reads the | + | Reads a string from the specified address in the currently opened (target) process until a 0-terminator is encountered. |
| + | The maximum number of characters to read is limited by ''MaxLength'' to prevent freezing. | ||
| + | Set ''WideChar'' to true if the string is encoded using widechar (UTF-16/Unicode) formatting. | ||
===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 read | + | |The address in the target process to read from. |
|- | |- | ||
| − | | | + | |MaxLength |
|Integer | |Integer | ||
| − | |The maximum number of characters to read. | + | |The maximum number of characters to read (prevents infinite loops; use 6000 if you don't care). |
|- | |- | ||
| − | | | + | |WideChar |
| − | |Boolean | + | |Boolean (optional) |
| − | | | + | |Set to true to read as a widechar (UTF-16/Unicode) string. Default is false (ASCII/ANSI). |
|} | |} | ||
| + | |||
| + | ===Returns=== | ||
| + | String — The string read from the specified address. | ||
| + | |||
| + | ===Examples=== | ||
| + | <pre> | ||
| + | -- Read an ASCII string from address 0x123456, up to 100 characters | ||
| + | local str = readString(0x123456, 100) | ||
| + | print("String:", str) | ||
| + | |||
| + | -- Read a widechar (Unicode) string from a CEAddressString | ||
| + | local wstr = readString("game.exe+1234", 256, true) | ||
| + | print("Wide string:", wstr) | ||
| + | </pre> | ||
{{LuaSeeAlso}} | {{LuaSeeAlso}} | ||
Latest revision as of 23:00, 4 December 2025
| <> Function function readString(Address, MaxLength, [WideChar]) : String |
Reads a string from the specified address in the currently opened (target) process until a 0-terminator is encountered. The maximum number of characters to read is limited by MaxLength to prevent freezing. Set WideChar to true if the string is encoded using widechar (UTF-16/Unicode) formatting.
Function Parameters[edit]
| Parameter | Type | Description |
|---|---|---|
| Address | Integer or CEAddressString | The address in the target process to read from. |
| MaxLength | Integer | The maximum number of characters to read (prevents infinite loops; use 6000 if you don't care). |
| WideChar | Boolean (optional) | Set to true to read as a widechar (UTF-16/Unicode) string. Default is false (ASCII/ANSI). |
Returns[edit]
String — The string read from the specified address.
Examples[edit]
-- Read an ASCII string from address 0x123456, up to 100 characters
local str = readString(0x123456, 100)
print("String:", str)
-- Read a widechar (Unicode) string from a CEAddressString
local wstr = readString("game.exe+1234", 256, true)
print("Wide string:", wstr)
See also[edit]
| Lua |
| Script Engine |
Related Functions[edit]
| Read Functions |
|---|
| readBytes |
| readSmallInteger |
| readInteger |
| readQword |
| readPointer |
| readFloat |
| readDouble |
| readString |
| Read Functions (Local Process) |
| readBytesLocal |
| readIntegerLocal |
| readQwordLocal |
| readPointerLocal |
| readFloatLocal |
| readDoubleLocal |
| readStringLocal |
| Write Functions |
| writeBytes |
| writeSmallInteger |
| writeInteger |
| writeQword |
| writeFloat |
| writeDouble |
| writeString |
| Write Functions (Local Process) |
| writeBytesLocal |
| writeIntegerLocal |
| writeQwordLocal |
| writeFloatLocal |
| writeDoubleLocal |
| writeStringLocal |
| Byte Table Conversions (Value → Byte Table) |
| wordToByteTable |
| dwordToByteTable |
| qwordToByteTable |
| floatToByteTable |
| doubleToByteTable |
| stringToByteTable |
| wideStringToByteTable |
| Byte Table Conversions (Byte Table → Value) |
| byteTableToWord |
| byteTableToDword |
| byteTableToQword |
| byteTableToFloat |
| byteTableToDouble |
| byteTableToString |
| byteTableToWideString |