Created
August 4, 2022 15:52
-
-
Save lyf-is-coding/6ad851621658326ce0195c4e58c9f28f to your computer and use it in GitHub Desktop.
Cheat Engine Lua Mono append fields to class memory record
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local LAST_OFFSET_INDEX = 0 | |
function MonoMemRecordAppendFields(parent_memrc, classID, is_include_parents, is_debug) | |
if parent_memrc == nil or parent_memrc == 0 or classID == nil or classID == 0 then | |
return false | |
end | |
LaunchMonoDataCollector() | |
local addressList = getAddressList() | |
local class = mono_object_getClass(classID) | |
local fields = mono_class_enumFields(class, is_include_parents) | |
for i = 1, #fields do | |
-- All MONO_TYPE can be found here https://github.com/cheat-engine/cheat-engine/blob/master/Cheat%20Engine/bin/autorun/monoscript.lua#L75 | |
if fields[i].monotype == MONO_TYPE_CLASS or fields[i].isStatic then | |
if is_debug then print("- " .. fields[i].name .. ' ' .. fields[i].typename) end | |
goto continue | |
end | |
local child_memrc = addressList.createMemoryRecord() | |
child_memrc.setDescription(fields[i].name) | |
child_memrc.setAddress(parent_memrc.getAddress()) | |
child_memrc.setOffset(LAST_OFFSET_INDEX, fields[i].offset) | |
child_memrc.Type = monoTypeToVarType(fields[i].monotype) | |
child_memrc.appendToEntry(parent_memrc) | |
if is_debug then | |
print("+ " .. child_memrc.getDescription() .. ' ' .. string.format("%#x", child_memrc.getOffset(LAST_OFFSET_INDEX)) .. ' ' .. string.format("%#x", fields[i].monotype) .. ' ' .. fields[i].typename) | |
end | |
::continue:: | |
end | |
return true | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment