Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Get Mono Namespace from address.

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
TheyCallMeTim13
Wiki Contributor
Reputation: 19

Joined: 24 Feb 2017
Posts: 616
Location: 'Merica

PostPosted: Sat May 05, 2018 5:55 am    Post subject: Get Mono Namespace from address. Reply with quote

I have tried using "mono_object_getClass" but this seems to always return nil, so I'm not sure I'm using it correctly.

Code:
local cID, cName = mono_object_getClass(getAddress('PlayerStatsManager:TakeDamage'))
print(mono_class_getNamespace(cID))


Even after JITing the method, "cID" and "cName" are still "nil".

_________________
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 357

Joined: 09 May 2003
Posts: 20899
Location: The netherlands

PostPosted: Sat May 05, 2018 6:16 am    Post subject: Reply with quote

mono_object_* take the start address of an instanced object, you are giving it a method address

you probably want to use mono_getJitInfo(address)
mono_method_getClass can then be used on the method it returns snd from that the namespace

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Back to top
View user's profile Send private message MSN Messenger
FreeER
Grandmaster Cheater
Reputation: 34

Joined: 09 Aug 2013
Posts: 907

PostPosted: Sat May 05, 2018 6:29 am    Post subject: Reply with quote

edit: looks like DB sneaked in Very Happy
Why are you passing a method address to a function designed for objects (an instance of a class)?

A little test and it seems that a mono "method" isn't the same as the address of the code, there doesn't seem to be a mono_findMethod(address) but you can use mono_getJitInfo
Code:
LaunchMonoDataCollector()
local name = 'PlayerStatsManager:TakeDamage'
local addr = getAddress(name)

local method = mono_getJitInfo(addr).method
local klass = mono_method_getClass(method)
-- namespace tends to be empty string ''
return mono_class_getNamespace(klass), mono_class_getName(klass)

_________________
https://github.com/FreeER/ has a few CE related repos
Back to top
View user's profile Send private message
TheyCallMeTim13
Wiki Contributor
Reputation: 19

Joined: 24 Feb 2017
Posts: 616
Location: 'Merica

PostPosted: Sat May 05, 2018 6:49 am    Post subject: Reply with quote

FreeER wrote:
...
Why are you passing a method address to a function designed for objects (an instance of a class)?...


Best I could come up with, I thought may be it being under "PlayerStatsManager" it might work, but yeah hence the "I'm not sure I'm using it correctly" part. But mostly didn't spot the "mono_method_getClass" it seems.


So this gets me a blank Namespace:
Code:
local addr = 'PlayerStatsManager:TakeDamage'
addr = getAddress('PlayerStatsManager:TakeDamage')
print(addr)
local mID = mono_getJitInfo(addr).method
print(mID)
local cID = mono_method_getClass(mID)
print(cID)
print(type(mono_class_getNamespace(cID)), mono_class_getNamespace(cID))


And it does work with this:
Code:
local mId = mono_findMethod('', 'PlayerStatsManager', 'TakeDamage')
mono_compile_method(mId)


But this also works, and I thought this is what was needed:
Code:
local mId = mono_findMethod('Assembly-CSharp', 'PlayerStatsManager', 'TakeDamage')
mono_compile_method(mId)


Why or how is it working with the empty namespace, does CE just search and use the first NS that has "PlayerStatsManager:TakeDamage"?

EDIT:
Was asked for a Mono tut and I have been wanting to do some messing around with it, basically this is where I'm at:
https://wiki.cheatengine.org/index.php?title=Tutorial:Mono:Basic

_________________
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 357

Joined: 09 May 2003
Posts: 20899
Location: The netherlands

PostPosted: Sat May 05, 2018 8:19 am    Post subject: Reply with quote

mono_getJitInfo returns a table with fields
Code:

jitinfo
method
code_start
code_size


the method field should get you further


often namespace is '' so it's not necesary to specify

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites