first commit
This commit is contained in:
commit
7dd9dd689e
40 changed files with 4100 additions and 0 deletions
53
Core/il2cpp/Helper/Il2CppHelper.cpp
Normal file
53
Core/il2cpp/Helper/Il2CppHelper.cpp
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
#include "pch.h"
|
||||
#include "Il2CppHelper.h"
|
||||
|
||||
const uint8_t* Il2CppHelper::FindMethodInHierarchy(Il2CppClass* klass, const std::string &methodName, const std::vector<std::string> paramCount) {
|
||||
const uint8_t* method = nullptr;
|
||||
|
||||
while (klass != nullptr) {
|
||||
method = FindMethod(klass, methodName, paramCount);
|
||||
if(method) break;
|
||||
|
||||
klass = Il2CppApi::ClassGetParent(klass);
|
||||
}
|
||||
|
||||
return method;
|
||||
}
|
||||
|
||||
|
||||
const uint8_t* Il2CppHelper::FindMethod(Il2CppClass* klass, const std::string &name, const std::vector<std::string> &arg_types)
|
||||
{
|
||||
Il2CppApi::ClassInit(klass);
|
||||
void* iter = nullptr;
|
||||
|
||||
while (auto method = Il2CppApi::ClassGetMethods(klass, &iter)) {
|
||||
auto methodName = Il2CppApi::MethodGetName(method);
|
||||
if (methodName == name) {
|
||||
auto paramCount = Il2CppApi::MethodGetParamCount(method);
|
||||
|
||||
if (paramCount == arg_types.size()) {
|
||||
bool fail = false;
|
||||
for (size_t i = 0; i < paramCount; ++i) {
|
||||
auto typeName = Il2CppApi::TypeGetName(Il2CppApi::MethodGetParam(method, i));
|
||||
|
||||
if (arg_types[i] != typeName) {
|
||||
fail = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!fail) {
|
||||
return method;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
uintptr_t* Il2CppHelper::GetFieldDataPtr(uintptr_t* field, Il2CppObject* object) {
|
||||
size_t offset = Il2CppApi::FieldGetOffset(field);
|
||||
uintptr_t* base_ptr = reinterpret_cast<uintptr_t*>(object);
|
||||
|
||||
return base_ptr + offset;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue