View previous topic :: View next topic |
Author |
Message |
Vortexian How do I cheat?
Reputation: 0
Joined: 18 Jul 2018 Posts: 8
|
Posted: Wed Mar 16, 2022 3:20 pm Post subject: Getting class instance address in script |
|
|
I'm trying to simulate the button "Lookup Instances" in the .NET Info window in a Lua script to no success. Not really sure what functions I need to be using. I have my full class name and everything, and I can manually get the address of the class by clicking the button on the .NET Info window, but I'd like to be able to just enable my script and have the address of the class popped into a variable. How would I do this?
Edit 1:
I have this so far:
Code: |
if syntaxcheck then return end
LaunchMonoDataCollector()
GetLuaEngine().MenuItem5.doClick()
mono_initialize()
local assems = mono_enumAssemblies()
for i in pairs(assems) do
local imageID = mono_getImageFromAssembly(assems[i])
local imageName = mono_image_get_name(imageID)
if imageName == "RoR2" then
print("RoR2 classes:")
local classTable = mono_image_enumClasses(imageID)
for j in pairs(classTable) do
local className = mono_class_getName(classTable[j])
print(className)
end
end
end
|
However, the printing of class names doesn't do anything - my lua console is printing empty strings. I'd guess the table of classIds returned by enumClasses() is empty but I don't know why, because the RoR2 image has a *lot* of classes in the .NET window.
_________________
im kinda edgy |
|
Back to top |
|
 |
Frouk Grandmaster Cheater
Reputation: 5
Joined: 22 Jun 2021 Posts: 510
|
Posted: Thu Mar 17, 2022 1:50 am Post subject: |
|
|
idk if that wiil help:
Code: | function playerStatusInit()
local class = mono_findClass('Assembly-CSharp','PlayerStatus')
local id = mono_class_getStaticFieldAddress('Instance',class)
PlayerStatus = getAddress(id)
end
playerStatusInit() |
that's example of getting address from mono
|
|
Back to top |
|
 |
panraven Grandmaster Cheater
Reputation: 62
Joined: 01 Oct 2008 Posts: 958
|
Posted: Thu Mar 17, 2022 9:15 am Post subject: |
|
|
The return of mono_image_enumClasses is an array (say cs) if success.
The index of the array run from 1 to #cs, and its element has fields like,
cs[i] = {classname = 'simple class name(no namespace)' , namespace='..some name space..', class = <some number>}
What the mono_class_getName need is the number cs[i].class, ie.
Code: |
local className = mono_class_getName(classTable[j].class)
|
but mono_class_getName should just return the cs[i].className.
You probably want mono_class_getFullName, which should include namespace and may return nested class (eg. namespace.aClass+aNestedClass).
Please check monoscript.lua in autorun directory to see how these mono function use.
btw, CE's lua only print number and string directly, table or boolean values etc need to convert to string (tostring) or use format or it only show like empty string, so you might think it's 'empty'.
_________________
- Retarded. |
|
Back to top |
|
 |
Vortexian How do I cheat?
Reputation: 0
Joined: 18 Jul 2018 Posts: 8
|
Posted: Thu Mar 17, 2022 12:30 pm Post subject: |
|
|
This is close to what I want, but not exactly. I've attached an image to this with what I'm trying to get. The .NET info screen has a "Lookup Instances" button that returns an address in the text field. I want that address it comes up with.
Description: |
|
Filesize: |
7.92 KB |
Viewed: |
3340 Time(s) |

|
_________________
im kinda edgy |
|
Back to top |
|
 |
|