Difference between revisions of "Lua:readBytes"
Jump to navigation
Jump to search
m |
|||
| (7 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
| − | + | [[Category:Lua]] | |
| + | '''function''' readBytes(''Address'', ''ByteCount'', [''ReturnAsTable'']) | ||
| − | + | Reads bytes from the specified address in the currently opened (target) process. | |
| + | Returns the bytes as multiple return values or as a table if ''ReturnAsTable'' is true. | ||
| − | + | ===Function Parameters=== | |
| − | + | {|width="85%" cellpadding="10%" cellspacing="0" border="0" | |
| − | + | !align="left"|Parameter | |
| − | + | !align="left"|Type | |
| − | + | !style="width: 80%;background-color:white;" align="left"|Description | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | {| | ||
| − | !align="left"| | ||
| − | !style="width: 80%" align="left"|Description | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
|- | |- | ||
| − | | | + | |Address |
| − | | | + | |Integer or [[CEAddressString]] |
| + | |The address in the target process to read from. | ||
|- | |- | ||
| − | | | + | |ByteCount |
| − | | | + | |Integer |
| − | | | + | |The number of bytes to read. |
| − | |||
| − | |||
|- | |- | ||
| + | |ReturnAsTable | ||
| + | |Boolean (optional) | ||
| + | |If true, returns a table of bytes. If false or omitted, returns each byte as a separate return value. | ||
|} | |} | ||
| + | ===Examples=== | ||
| + | <pre> | ||
| + | -- Read 4 bytes and get them as separate values | ||
| + | local b1, b2, b3, b4 = readBytes(0x123456, 4) | ||
| + | print(b1, b2, b3, b4) | ||
| − | + | -- Read 4 bytes and get them as a table | |
| − | + | local bytes = readBytes(0x123456, 4, true) | |
| − | + | for i, v in ipairs(bytes) do | |
| − | + | print("Byte " .. i .. ": " .. v) | |
| − | + | end | |
| − | + | </pre> | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | + | {{LuaSeeAlso}} | |
| − | + | === Related Functions === | |
| + | {{ReadWriteMemory}} | ||
Revision as of 16:01, 11 July 2025
function readBytes(Address, ByteCount, [ReturnAsTable])
Reads bytes from the specified address in the currently opened (target) process. Returns the bytes as multiple return values or as a table if ReturnAsTable is true.
Function Parameters
| Parameter | Type | Description |
|---|---|---|
| Address | Integer or CEAddressString | The address in the target process to read from. |
| ByteCount | Integer | The number of bytes to read. |
| ReturnAsTable | Boolean (optional) | If true, returns a table of bytes. If false or omitted, returns each byte as a separate return value. |
Examples
-- Read 4 bytes and get them as separate values
local b1, b2, b3, b4 = readBytes(0x123456, 4)
print(b1, b2, b3, b4)
-- Read 4 bytes and get them as a table
local bytes = readBytes(0x123456, 4, true)
for i, v in ipairs(bytes) do
print("Byte " .. i .. ": " .. v)
end
See also
| Lua |
| Script Engine |
Related Functions
| 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 |