Skip to content
This repository has been archived by the owner on Jul 1, 2024. It is now read-only.

Commit

Permalink
Added alternate api calls with better performance
Browse files Browse the repository at this point in the history
  • Loading branch information
ds5678 authored and knah committed Jul 7, 2021
1 parent 63a9cbc commit caa1fd7
Show file tree
Hide file tree
Showing 19 changed files with 92 additions and 18 deletions.
38 changes: 20 additions & 18 deletions UnhollowerBaseLib/Runtime/Il2CppApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ internal unsafe static class Il2CppApi

public static IntPtr il2cpp_assembly_get_image(IntPtr assembly) => IL2CPP.il2cpp_assembly_get_image(assembly);

public static IntPtr il2cpp_assembly_get_name(IntPtr assembly) => UnityVersionHandler.assemblyStructHandler.il2cpp_assembly_get_name(assembly);

#endregion

#region Classes
Expand Down Expand Up @@ -187,7 +189,7 @@ internal unsafe static class Il2CppApi

#endregion

#region Domain
#region Domains

public static IntPtr il2cpp_domain_get() => IL2CPP.il2cpp_domain_get();

Expand All @@ -197,7 +199,7 @@ internal unsafe static class Il2CppApi

#endregion

#region Exception
#region Exceptions

public static IntPtr il2cpp_exception_from_name_msg(IntPtr image, IntPtr name_space, IntPtr name, IntPtr msg) => IL2CPP.il2cpp_exception_from_name_msg(image, name_space, name, msg);

Expand All @@ -215,13 +217,13 @@ internal unsafe static class Il2CppApi

public static int il2cpp_field_get_flags(IntPtr field) => IL2CPP.il2cpp_field_get_flags(field);

public static IntPtr il2cpp_field_get_name(IntPtr field) => IL2CPP.il2cpp_field_get_name(field);
public static IntPtr il2cpp_field_get_name(IntPtr field) => UnityVersionHandler.fieldInfoStructHandler.il2cpp_field_get_name(field);

public static IntPtr il2cpp_field_get_parent(IntPtr field) => IL2CPP.il2cpp_field_get_parent(field);
public static IntPtr il2cpp_field_get_parent(IntPtr field) => UnityVersionHandler.fieldInfoStructHandler.il2cpp_field_get_parent(field);

public static uint il2cpp_field_get_offset(IntPtr field) => IL2CPP.il2cpp_field_get_offset(field);
public static uint il2cpp_field_get_offset(IntPtr field) => UnityVersionHandler.fieldInfoStructHandler.il2cpp_field_get_offset(field);

public static IntPtr il2cpp_field_get_type(IntPtr field) => IL2CPP.il2cpp_field_get_type(field);
public static IntPtr il2cpp_field_get_type(IntPtr field) => UnityVersionHandler.fieldInfoStructHandler.il2cpp_field_get_type(field);

public static void il2cpp_field_get_value(IntPtr obj, IntPtr field, void* value) => IL2CPP.il2cpp_field_get_value(obj, field, value);

Expand Down Expand Up @@ -259,7 +261,7 @@ internal unsafe static class Il2CppApi

#endregion

#region GC Handle
#region GC Handles

public static uint il2cpp_gchandle_new(IntPtr obj, bool pinned) => IL2CPP.il2cpp_gchandle_new(obj, pinned);

Expand Down Expand Up @@ -297,11 +299,11 @@ internal unsafe static class Il2CppApi

#region Methods

public static IntPtr il2cpp_method_get_return_type(IntPtr method) => IL2CPP.il2cpp_method_get_return_type(method);
public static IntPtr il2cpp_method_get_return_type(IntPtr method) => UnityVersionHandler.methodInfoStructHandler.il2cpp_method_get_return_type(method);

public static IntPtr il2cpp_method_get_declaring_type(IntPtr method) => IL2CPP.il2cpp_method_get_declaring_type(method);

public static IntPtr il2cpp_method_get_name(IntPtr method) => IL2CPP.il2cpp_method_get_name(method);
public static IntPtr il2cpp_method_get_name(IntPtr method) => UnityVersionHandler.methodInfoStructHandler.il2cpp_method_get_name(method);

public static IntPtr il2cpp_method_get_from_reflection(IntPtr method) => IL2CPP.il2cpp_method_get_from_reflection(method);

Expand All @@ -313,23 +315,23 @@ internal unsafe static class Il2CppApi

public static bool il2cpp_method_is_instance(IntPtr method) => IL2CPP.il2cpp_method_is_instance(method);

public static uint il2cpp_method_get_param_count(IntPtr method) => IL2CPP.il2cpp_method_get_param_count(method);
public static uint il2cpp_method_get_param_count(IntPtr method) => UnityVersionHandler.methodInfoStructHandler.il2cpp_method_get_param_count(method);

public static IntPtr il2cpp_method_get_param(IntPtr method, uint index) => IL2CPP.il2cpp_method_get_param(method, index);

public static IntPtr il2cpp_method_get_class(IntPtr method) => IL2CPP.il2cpp_method_get_class(method);
public static IntPtr il2cpp_method_get_class(IntPtr method) => UnityVersionHandler.methodInfoStructHandler.il2cpp_method_get_class(method);

public static bool il2cpp_method_has_attribute(IntPtr method, IntPtr attr_class) => IL2CPP.il2cpp_method_has_attribute(method, attr_class);

public static uint il2cpp_method_get_flags(IntPtr method, ref uint iflags) => IL2CPP.il2cpp_method_get_flags(method, ref iflags);

public static uint il2cpp_method_get_token(IntPtr method) => IL2CPP.il2cpp_method_get_token(method);
public static uint il2cpp_method_get_token(IntPtr method) => UnityVersionHandler.methodInfoStructHandler.il2cpp_method_get_token(method);

public static IntPtr il2cpp_method_get_param_name(IntPtr method, uint index) => IL2CPP.il2cpp_method_get_param_name(method, index);

#endregion

#region Monitor
#region Monitors

public static void il2cpp_monitor_enter(IntPtr obj) => IL2CPP.il2cpp_monitor_enter(obj);

Expand Down Expand Up @@ -363,7 +365,7 @@ internal unsafe static class Il2CppApi

#endregion

#region Profiler
#region Profilers

public static void il2cpp_profiler_install(IntPtr prof, IntPtr shutdown_callback) => IL2CPP.il2cpp_profiler_install(prof, shutdown_callback);

Expand All @@ -385,13 +387,13 @@ internal unsafe static class Il2CppApi

public static uint il2cpp_property_get_flags(IntPtr prop) => IL2CPP.il2cpp_property_get_flags(prop);

public static IntPtr il2cpp_property_get_get_method(IntPtr prop) => IL2CPP.il2cpp_property_get_get_method(prop);
public static IntPtr il2cpp_property_get_get_method(IntPtr prop) => UnityVersionHandler.propertyInfoStructHandler.il2cpp_property_get_get_method(prop);

public static IntPtr il2cpp_property_get_set_method(IntPtr prop) => IL2CPP.il2cpp_property_get_set_method(prop);
public static IntPtr il2cpp_property_get_set_method(IntPtr prop) => UnityVersionHandler.propertyInfoStructHandler.il2cpp_property_get_set_method(prop);

public static IntPtr il2cpp_property_get_name(IntPtr prop) => IL2CPP.il2cpp_property_get_name(prop);
public static IntPtr il2cpp_property_get_name(IntPtr prop) => UnityVersionHandler.propertyInfoStructHandler.il2cpp_property_get_name(prop);

public static IntPtr il2cpp_property_get_parent(IntPtr prop) => IL2CPP.il2cpp_property_get_parent(prop);
public static IntPtr il2cpp_property_get_parent(IntPtr prop) => UnityVersionHandler.propertyInfoStructHandler.il2cpp_property_get_parent(prop);

#endregion

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public INativeAssemblyStruct Wrap(Il2CppAssembly* assemblyPointer)
else return new NativeAssemblyStruct((IntPtr)assemblyPointer);
}

public IntPtr il2cpp_assembly_get_name(IntPtr assembly) => ((Il2CppAssembly_16_0*)assembly)->aname.name;

#if DEBUG
public string GetName() => "NativeAssemblyStructHandler_16_0";
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public INativeAssemblyStruct Wrap(Il2CppAssembly* assemblyPointer)
else return new NativeAssemblyStruct((IntPtr)assemblyPointer);
}

public IntPtr il2cpp_assembly_get_name(IntPtr assembly) => ((Il2CppAssembly_20_0*)assembly)->aname.name;

#if DEBUG
public string GetName() => "NativeAssemblyStructHandler_20_0";
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public INativeAssemblyStruct Wrap(Il2CppAssembly* assemblyPointer)
else return new NativeAssemblyStruct((IntPtr)assemblyPointer);
}

public IntPtr il2cpp_assembly_get_name(IntPtr assembly) => ((Il2CppAssembly_24_0_B*)assembly)->aname.name;

#if DEBUG
public string GetName() => "NativeAssemblyStructHandler_24_0_B";
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public INativeAssemblyStruct Wrap(Il2CppAssembly* assemblyPointer)
else return new NativeAssemblyStruct((IntPtr)assemblyPointer);
}

public IntPtr il2cpp_assembly_get_name(IntPtr assembly) => ((Il2CppAssembly_24_1*)assembly)->aname.name;

#if DEBUG
public string GetName() => "NativeAssemblyStructHandler_24_1";
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public INativeAssemblyStruct Wrap(Il2CppAssembly* assemblyPointer)
else return new NativeAssemblyStruct((IntPtr)assemblyPointer);
}

public IntPtr il2cpp_assembly_get_name(IntPtr assembly) => ((Il2CppAssembly_24_4*)assembly)->aname.name;

#if DEBUG
public string GetName() => "NativeAssemblyStructHandler_24_4";
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ public interface INativeAssemblyStructHandler : INativeStructHandler
{
INativeAssemblyStruct CreateNewAssemblyStruct();
unsafe INativeAssemblyStruct Wrap(Il2CppAssembly* assemblyPointer);
IntPtr il2cpp_assembly_get_name(IntPtr assembly);
#if DEBUG
string GetName();
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ public INativeFieldInfoStruct Wrap(Il2CppFieldInfo* fieldInfoPointer)
else return new NativeFieldInfoStruct((IntPtr)fieldInfoPointer);
}

public IntPtr il2cpp_field_get_name(IntPtr field) => ((Il2CppFieldInfo_16_0*)field)->name;
public uint il2cpp_field_get_offset(IntPtr field) => (uint)((Il2CppFieldInfo_16_0*)field)->offset;
public IntPtr il2cpp_field_get_parent(IntPtr field) => (IntPtr)((Il2CppFieldInfo_16_0*)field)->parent;
public IntPtr il2cpp_field_get_type(IntPtr field) => (IntPtr)((Il2CppFieldInfo_16_0*)field)->type;

#if DEBUG
public string GetName() => "NativeFieldInfoStructHandler_16_0";
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ public INativeFieldInfoStruct Wrap(Il2CppFieldInfo* fieldInfoPointer)
else return new NativeFieldInfoStruct((IntPtr)fieldInfoPointer);
}

public IntPtr il2cpp_field_get_name(IntPtr field) => ((Il2CppFieldInfo_19_0*)field)->name;
public uint il2cpp_field_get_offset(IntPtr field) => (uint)((Il2CppFieldInfo_19_0*)field)->offset;
public IntPtr il2cpp_field_get_parent(IntPtr field) => (IntPtr)((Il2CppFieldInfo_19_0*)field)->parent;
public IntPtr il2cpp_field_get_type(IntPtr field) => (IntPtr)((Il2CppFieldInfo_19_0*)field)->type;

#if DEBUG
public string GetName() => "NativeFieldInfoStructHandler_19_0";
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ public INativeFieldInfoStruct Wrap(Il2CppFieldInfo* fieldInfoPointer)
else return new NativeFieldInfoStruct((IntPtr)fieldInfoPointer);
}

public IntPtr il2cpp_field_get_name(IntPtr field) => ((Il2CppFieldInfo_24_1*)field)->name;
public uint il2cpp_field_get_offset(IntPtr field) => (uint)((Il2CppFieldInfo_24_1*)field)->offset;
public IntPtr il2cpp_field_get_parent(IntPtr field) => (IntPtr)((Il2CppFieldInfo_24_1*)field)->parent;
public IntPtr il2cpp_field_get_type(IntPtr field) => (IntPtr)((Il2CppFieldInfo_24_1*)field)->type;

#if DEBUG
public string GetName() => "NativeFieldInfoStructHandler_24_1";
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ public interface INativeFieldInfoStructHandler : INativeStructHandler
{
INativeFieldInfoStruct CreateNewFieldInfoStruct();
unsafe INativeFieldInfoStruct Wrap(Il2CppFieldInfo* fieldInfoPointer);
IntPtr il2cpp_field_get_name(IntPtr field);
uint il2cpp_field_get_offset(IntPtr field);
IntPtr il2cpp_field_get_parent(IntPtr field);
IntPtr il2cpp_field_get_type(IntPtr field);
#if DEBUG
string GetName();
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ public interface INativeMethodInfoStructHandler : INativeStructHandler
unsafe INativeMethodInfoStruct Wrap(Il2CppMethodInfo* methodPointer);
IntPtr GetMethodFromReflection(IntPtr method);
IntPtr CopyMethodInfoStruct(IntPtr origMethodInfo);
IntPtr il2cpp_method_get_class(IntPtr method);
IntPtr il2cpp_method_get_name(IntPtr method);
uint il2cpp_method_get_param_count(IntPtr method);
IntPtr il2cpp_method_get_return_type(IntPtr method);
uint il2cpp_method_get_token(IntPtr method);
#if DEBUG
string GetName();
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ public IntPtr CopyMethodInfoStruct(IntPtr origMethodInfo)
return copiedMethodInfo;
}

public IntPtr il2cpp_method_get_class(IntPtr method) => (IntPtr)((Il2CppMethodInfo_16_0*)method)->klass;
public IntPtr il2cpp_method_get_name(IntPtr method) => ((Il2CppMethodInfo_16_0*)method)->name;
public uint il2cpp_method_get_param_count(IntPtr method) => ((Il2CppMethodInfo_16_0*)method)->parameters_count;
public IntPtr il2cpp_method_get_return_type(IntPtr method) => (IntPtr)((Il2CppMethodInfo_16_0*)method)->return_type;
public uint il2cpp_method_get_token(IntPtr method) => ((Il2CppMethodInfo_16_0*)method)->token;

#if DEBUG
public string GetName() => "NativeMethodInfoStructHandler_16_0";
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ public IntPtr CopyMethodInfoStruct(IntPtr origMethodInfo)
return copiedMethodInfo;
}

public IntPtr il2cpp_method_get_class(IntPtr method) => (IntPtr)((Il2CppMethodInfo_24_1*)method)->klass;
public IntPtr il2cpp_method_get_name(IntPtr method) => ((Il2CppMethodInfo_24_1*)method)->name;
public uint il2cpp_method_get_param_count(IntPtr method) => ((Il2CppMethodInfo_24_1*)method)->parameters_count;
public IntPtr il2cpp_method_get_return_type(IntPtr method) => (IntPtr)((Il2CppMethodInfo_24_1*)method)->return_type;
public uint il2cpp_method_get_token(IntPtr method) => ((Il2CppMethodInfo_24_1*)method)->token;

#if DEBUG
public string GetName() => "NativeMethodInfoStructHandler_24_1";
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ public IntPtr CopyMethodInfoStruct(IntPtr origMethodInfo)
return copiedMethodInfo;
}

public IntPtr il2cpp_method_get_class(IntPtr method) => (IntPtr)((Il2CppMethodInfo_27_3*)method)->klass;
public IntPtr il2cpp_method_get_name(IntPtr method) => ((Il2CppMethodInfo_27_3*)method)->name;
public uint il2cpp_method_get_param_count(IntPtr method) => ((Il2CppMethodInfo_27_3*)method)->parameters_count;
public IntPtr il2cpp_method_get_return_type(IntPtr method) => (IntPtr)((Il2CppMethodInfo_27_3*)method)->return_type;
public uint il2cpp_method_get_token(IntPtr method) => ((Il2CppMethodInfo_27_3*)method)->token;

#if DEBUG
public string GetName() => "NativeMethodInfoStructHandler_27_3";
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ public interface INativePropertyInfoStructHandler : INativeStructHandler
{
INativePropertyInfoStruct CreateNewPropertyInfoStruct();
unsafe INativePropertyInfoStruct Wrap(Il2CppPropertyInfo* propertyInfoPointer);
IntPtr il2cpp_property_get_name(IntPtr prop);
IntPtr il2cpp_property_get_parent(IntPtr prop);
IntPtr il2cpp_property_get_get_method(IntPtr prop);
IntPtr il2cpp_property_get_set_method(IntPtr prop);
#if DEBUG
string GetName();
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ public INativePropertyInfoStruct Wrap(Il2CppPropertyInfo* propertyInfoPointer)
else return new NativePropertyInfoStruct((IntPtr)propertyInfoPointer);
}

public IntPtr il2cpp_property_get_name(IntPtr prop) => ((Il2CppPropertyInfo_16_0*)prop)->name;
public IntPtr il2cpp_property_get_parent(IntPtr prop) => (IntPtr)((Il2CppPropertyInfo_16_0*)prop)->parent;
public IntPtr il2cpp_property_get_get_method(IntPtr prop) => (IntPtr)((Il2CppPropertyInfo_16_0*)prop)->get;
public IntPtr il2cpp_property_get_set_method(IntPtr prop) => (IntPtr)((Il2CppPropertyInfo_16_0*)prop)->set;

#if DEBUG
public string GetName() => "NativePropertyInfoStructHandler_16_0";
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ public INativePropertyInfoStruct Wrap(Il2CppPropertyInfo* propertyInfoPointer)
else return new NativePropertyInfoStruct((IntPtr)propertyInfoPointer);
}

public IntPtr il2cpp_property_get_name(IntPtr prop) => ((Il2CppPropertyInfo_19_0*)prop)->name;
public IntPtr il2cpp_property_get_parent(IntPtr prop) => (IntPtr)((Il2CppPropertyInfo_19_0*)prop)->parent;
public IntPtr il2cpp_property_get_get_method(IntPtr prop) => (IntPtr)((Il2CppPropertyInfo_19_0*)prop)->get;
public IntPtr il2cpp_property_get_set_method(IntPtr prop) => (IntPtr)((Il2CppPropertyInfo_19_0*)prop)->set;

#if DEBUG
public string GetName() => "NativePropertyInfoStructHandler_19_0";
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ public INativePropertyInfoStruct Wrap(Il2CppPropertyInfo* propertyInfoPointer)
else return new NativePropertyInfoStruct((IntPtr)propertyInfoPointer);
}

public IntPtr il2cpp_property_get_name(IntPtr prop) => ((Il2CppPropertyInfo_24_1*)prop)->name;
public IntPtr il2cpp_property_get_parent(IntPtr prop) => (IntPtr)((Il2CppPropertyInfo_24_1*)prop)->parent;
public IntPtr il2cpp_property_get_get_method(IntPtr prop) => (IntPtr)((Il2CppPropertyInfo_24_1*)prop)->get;
public IntPtr il2cpp_property_get_set_method(IntPtr prop) => (IntPtr)((Il2CppPropertyInfo_24_1*)prop)->set;

#if DEBUG
public string GetName() => "NativePropertyInfoStructHandler_24_1";
#endif
Expand Down

0 comments on commit caa1fd7

Please sign in to comment.