Lua mono - get field addr

Want Cheat Engine to do something specific and no idea how to do that, ask here. (From simple scripts to full trainers and extensions)
Post Reply
miraikolus
Expert Cheater
Expert Cheater
Posts: 59
Joined: Fri Jan 04, 2019 12:09 am
Reputation: 19

Lua mono - get field addr

Post by miraikolus »

I've tried now for some time, but just can't it running (prob s.t simple but ... I don't get it yet).

Curr. experimenting with mono features, and I do want to get the build vers (also read a structure for dropdown but let's keep it simple for now., might be same problem)

What I did manage so far (also trying other things but on that topic):



[SPOILER="lua code"]

[CODE=lua]

local namespace='WolfFramework'

local class='GameManager'

local method='Update'

local fver='BUILD_VERSION'

local fstr='BUILD_VERSION_STRING'



local dom=mono_enumDomains()

local ass=mono_enumAssemblies()



local cId = mono_findClass(namespace, class)

local cName = mono_class_getName(cId)

local cStatic = mono_class_getStaticFieldAddress(dom[1], cId)



local ftbl = mono_class_enumFields(cId)

local ftblver, ftblstr = {},{}



local mId = mono_findMethod(namespace,class,method)

local mcId = mono_method_getClass(mId)

local pcId = mono_class_getParent(mcId)

local pcIdname= mono_class_getName(pcId)



for i=1,#ftbl do

if ftbl[i].name == fver then ftblver = ftbl[i] end

if ftbl[i].name == fstr then ftblstr = ftbl[i] end

if next(ftblver)~=nil and next(ftblstr)~=nil then

print("found both")

break

end

end



local addr = getAddress('WolfFramework:GameManager:Update')



print("class ",cId, string.format("%.8x",cId))

print("classname ",cName)

print("static ",cStatic, string.format("%.8x",cStatic))

print("fields ",#ftbl,ftbl[1].name,ftbl[#ftbl].name)

print("method ",mId,string.format("%.8x",mId))

print("method-cl ",mcId, string.format("%.8x",mcId))

print("parent ",pcId, string.format("%.8x",pcId),pcIdname)

print("addr ",addr, string.format("%.8x",addr))



local test = readPointer(ftblver.field)

print("test ",test, string.format("%.8x",test))



return ftblver,ftblstr

[/CODE]

[/SPOILER]

[SPOILER="result"]

[CODE=ruby]found both

class 3027348515648 2c0dc086b40

classname GameManager

static 3027188070240 2c0d2783760

fields 308 PIRATESHIP_TYPES_QUANTITY valueToCheck

method 3027350643184 2c0dc28e1f0

method-cl 3027348515648 2c0dc086b40

parent 3027288188728 2c0d86fe738 MonoBehaviour

addr 3027638222848 2c0ed4d0000

test 3027350668768 2c0dc2945e0

2:table

[

name = BUILD_VERSION

flags = 32854

field = 3027347685512

isStatic = true

isConst = true

monotype = 8

parent = 3027348515648

typename = System.Int32

offset = 0

type = 3027350668768

]

3:table

[

name = BUILD_VERSION_STRING

flags = 32854

field = 3027347685608

isStatic = true

isConst = true

monotype = 14

parent = 3027348515648

typename = System.String

offset = 0

type = 3027350668816

]

[/CODE]

[/SPOILER]

[SPOILER="Notes"]Since it does not show offsets, I don't believe f.e. [URL='https://www.cheatengine.org/forum/viewtopic.php?t=608459']this does help[/URL], does it? OR

[URL]https://forum.cheatengine.org/viewtopic.php?t=577110[/URL]

[URL]https://forum.cheatengine.org/viewtopic.php?t=577110[/URL]

[URL]https://www.cheatengine.org/forum/viewtopic.php?t=602625[/URL]

... and way more (just last results)



idk, is there something I can read in on mono features that is ... not extensive like 100+ documentation (esp. since engl. is not my native language)

Or is there some table I have not found yet but can take a look at doing ~ the same?



dnSpy does show

[CODE=csharp]// WolfFramework.GameManager

// Token: 0x04002B7C RID: 11132

public const int BUILD_VERSION = 114;[/CODE]

[/SPOILER]
Last edited by miraikolus on Wed May 20, 2020 10:51 pm, edited 2 times in total.

Post Reply

Who is online

Users browsing this forum: No registered users