what is the value of handle in this context?
catlowlevel opened this issue · comments
inside the method class, there's this line inside invokeRaw method
if (this.isInflated) {
allocatedParameters.push(this.handle);
}
what is handle
in here? Is it the MethodInfo*
I am attempting to invoke a method in C++, and it's resulting in crashes. I suspect I need this handle
as the method I'm trying to invoke is inflated
. Here's how I currently invoke it:
template<typename T, typename... Args>
T MethodInfo::invoke(Il2CppObject *instance, Args &&... args) {
using Invoker = T(*)(Il2CppObject *, Args...);
auto invoker = reinterpret_cast<Invoker>(this->methodPointer);
return invoker(instance, std::forward<Args>(args)...);
}
what is handle in here? Is it the MethodInfo*
Yes.
The following C# code
class Class : Interface
{
static Class()
{
}
}
is transpiled to the following C++ code
// System.Void Class::.cctor()
extern "C" IL2CPP_METHOD_ATTR void Class__cctor_m8C31123D4284696F79E3E30569AF75657805F8B7 (const RuntimeMethod* method)
{
{
return;
}
}
More in general, it looks like the method instance is always passed as the last parameter.
However, the compiler eventually removes that parameter if it's unused - but inflated methods actually needs the method instance (for whatever reason I didn't investigate, but it's easy to guess)
I've actually tried passing the MethodInfo* as the last parameter and yet the game is still crashing 🤔
For more context, it is the method get_Item from Dictionary class
Does it occur with every method?
Does it occur with every method?
No, it doesn't
Only this method so far
Well, I don't really know, then. The method you invoke might be throwing an exception for whatever business logic it implemented as well...
The method you invoke might be throwing an exception for whatever business logic it implemented as well...
But this module invoked the method just fine, so it couldn't be it
I think you passing the parameters incorrectly, then... I don't know C++ so I can't help you
I think you passing the parameters incorrectly, then... I don't know C++ so I can't help you
alright, that's okay.
thanks for your time
okay, i was testing stuff and i forgot to change the method name
auto m = dict->klass->getMethod("get_Item");
LOGD("is Inflated %d", m->isInflated());
// int i = 0;
auto item = dict->invoke_method<Il2CppObject *>("get_Keys", 0, m); //should've been get_Item
now i pass the m
directly instead of string literal and now it works