Closed leonitousconforti closed 1 year ago
Uhm, I don't know honestly. Your code looks correct. Two things that come in my mind right now are trying to call the staric constructor of that class first:
SomeClass.initialize();
or make sure those static fields are not per-thread ([ThreadStatic]
). You can try to run to run the relvant snippet using:
Il2Cpp.attachedThreads[0].schedule(...);
Thanks so much for the speedy suggestions!
This is what ended up working for me:
const csharpAssembly = Il2Cpp.Domain.assembly("Assembly-CSharp");
const SomeClass = csharpAssembly.image.class("SomeClass");
SomeClass.initialize();
const someField = SomeClassInstance.field<Il2Cpp.Object>("someField").value;
Here is the stub for the class that is giving me some trouble:
I want to access the someField property of the someKlass. The trouble is that SomeKlass is not instantiated by the app right away, so I have to do some user action in order to get it to create an instance of the class. The source code of the app (I have it) only ever accesses somefield via
SomeKlass.instance.someField
. I have tested and can confirm that I can access someField after doing some user input on the app, but I would like to be able to access someField without having to do user input on the app.Things I have tried to access someField without having to do the user input to have the app access
SomeKlass.instance.someField
to create the instance:// Always null const someField = SomeClassInstance.field("someField").value;
// Prints: {"SomeClass":{"handle":"0x70caa357d0"},"SomeClassInstance":{"handle":"0x6f769dbf60"},"someField":{"handle":"0x0"}} console.log(JSON.stringify({ SomeClass, SomeClassInstance, someField }));
// Always null const someField = SomeClassInstance1.field("someField").value;
// Prints: {"SomeClass":{"handle":"0x78b1893190"},"SomeClassInstance":{"handle":"0x7640838ca0"},"SomeClassInstance1":{"handle":"0x7640838ca0"},"someField":{"handle":"0x0"}} console.log(JSON.stringify({ SomeClass, SomeClassInstance, SomeClassInstance1, someField }));