mirror of
https://git.chinosk6.cn/chinosk/gkms-local.git
synced 2026-02-04 09:04:52 +00:00
fix crash when using remote files
This commit is contained in:
@@ -36,6 +36,74 @@ namespace Il2cppUtils {
|
||||
uint8_t is_marshaled_from_native : 1;
|
||||
};
|
||||
|
||||
struct Il2CppObject
|
||||
{
|
||||
union
|
||||
{
|
||||
void* klass;
|
||||
void* vtable;
|
||||
};
|
||||
void* monitor;
|
||||
};
|
||||
|
||||
enum Il2CppTypeEnum
|
||||
{
|
||||
IL2CPP_TYPE_END = 0x00, /* End of List */
|
||||
IL2CPP_TYPE_VOID = 0x01,
|
||||
IL2CPP_TYPE_BOOLEAN = 0x02,
|
||||
IL2CPP_TYPE_CHAR = 0x03,
|
||||
IL2CPP_TYPE_I1 = 0x04,
|
||||
IL2CPP_TYPE_U1 = 0x05,
|
||||
IL2CPP_TYPE_I2 = 0x06,
|
||||
IL2CPP_TYPE_U2 = 0x07,
|
||||
IL2CPP_TYPE_I4 = 0x08,
|
||||
IL2CPP_TYPE_U4 = 0x09,
|
||||
IL2CPP_TYPE_I8 = 0x0a,
|
||||
IL2CPP_TYPE_U8 = 0x0b,
|
||||
IL2CPP_TYPE_R4 = 0x0c,
|
||||
IL2CPP_TYPE_R8 = 0x0d,
|
||||
IL2CPP_TYPE_STRING = 0x0e,
|
||||
IL2CPP_TYPE_PTR = 0x0f,
|
||||
IL2CPP_TYPE_BYREF = 0x10,
|
||||
IL2CPP_TYPE_VALUETYPE = 0x11,
|
||||
IL2CPP_TYPE_CLASS = 0x12,
|
||||
IL2CPP_TYPE_VAR = 0x13,
|
||||
IL2CPP_TYPE_ARRAY = 0x14,
|
||||
IL2CPP_TYPE_GENERICINST = 0x15,
|
||||
IL2CPP_TYPE_TYPEDBYREF = 0x16,
|
||||
IL2CPP_TYPE_I = 0x18,
|
||||
IL2CPP_TYPE_U = 0x19,
|
||||
IL2CPP_TYPE_FNPTR = 0x1b,
|
||||
IL2CPP_TYPE_OBJECT = 0x1c,
|
||||
IL2CPP_TYPE_SZARRAY = 0x1d,
|
||||
IL2CPP_TYPE_MVAR = 0x1e,
|
||||
IL2CPP_TYPE_CMOD_REQD = 0x1f,
|
||||
IL2CPP_TYPE_CMOD_OPT = 0x20,
|
||||
IL2CPP_TYPE_INTERNAL = 0x21,
|
||||
|
||||
IL2CPP_TYPE_MODIFIER = 0x40,
|
||||
IL2CPP_TYPE_SENTINEL = 0x41,
|
||||
IL2CPP_TYPE_PINNED = 0x45,
|
||||
|
||||
IL2CPP_TYPE_ENUM = 0x55
|
||||
};
|
||||
|
||||
typedef struct Il2CppType
|
||||
{
|
||||
void* dummy;
|
||||
unsigned int attrs : 16;
|
||||
Il2CppTypeEnum type : 8;
|
||||
unsigned int num_mods : 6;
|
||||
unsigned int byref : 1;
|
||||
unsigned int pinned : 1;
|
||||
} Il2CppType;
|
||||
|
||||
struct Il2CppReflectionType
|
||||
{
|
||||
Il2CppObject object;
|
||||
const Il2CppType* type;
|
||||
};
|
||||
|
||||
struct Resolution_t {
|
||||
int width;
|
||||
int height;
|
||||
@@ -160,5 +228,20 @@ namespace Il2cppUtils {
|
||||
*reinterpret_cast<RType*>(reinterpret_cast<uintptr_t>(obj) + field->offset) = value;
|
||||
}
|
||||
|
||||
void* get_system_class_from_reflection_type_str(const char* typeStr, const char* assemblyName = "mscorlib") {
|
||||
using Il2CppString = UnityResolve::UnityType::String;
|
||||
|
||||
static auto assemblyLoad = reinterpret_cast<void* (*)(Il2CppString*)>(
|
||||
GetMethodPointer("mscorlib.dll", "System.Reflection",
|
||||
"Assembly", "Load", {"*"})
|
||||
);
|
||||
static auto assemblyGetType = reinterpret_cast<Il2CppReflectionType * (*)(void*, Il2CppString*)>(
|
||||
GetMethodPointer("mscorlib.dll", "System.Reflection",
|
||||
"Assembly", "GetType", {"*"})
|
||||
);
|
||||
|
||||
static auto reflectionAssembly = assemblyLoad(Il2CppString::New(assemblyName));
|
||||
auto reflectionType = assemblyGetType(reflectionAssembly, Il2CppString::New(typeStr));
|
||||
return UnityResolve::Invoke<void*>("il2cpp_class_from_system_type", reflectionType);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user