Extracts an actual, usable piece of data, such as a number or
string, from a memory chunk.
If you are reading a string, you must also specify the maximum length
to try reading with the 'length' parameter.
'type' should be a string that represents the type of data to read
("byte", "ubyte", "int", "uint", "int64", "uint64", "float", "double", "string", etc.). See
Data Types for more information on
available types.
'offset' should be the number of bytes after the start address to read data from.
Example:
local procId = process.findByExe("ExampleGame.exe");
local proc = process.open();
local characterAddress = 0x4A7A00;
local hpOffset = 0x0C;
local maxHpOffset = 0x10;
local mpOffset = 0x14;
local maxMpOffset = 0x18;
local nameOffset = 0xD0;
local nameSize = 16;
local charStructSize = 0xFF;
if( not proc ) then
error("Unable to open handle to target process.");
end
-- Read our character's stats (example only)
characterChunk = process.readChunk(proc, characterAddress, charStructSize);
-- We just read in the whole character struct as a 255-byte (0xFF) chunk. Extract data from it now.
local hp = characterChunk:getData("int", hpOffset);
local maxHp = characterChunk:getData("int", maxHpOffset);
local mp = characterChunk:getData("int", mpOffset);
local maxMp = characterChunk:getData("int", maxMpOffset);
local name = characterChunk:getData("string", nameOffset, nameSize);