Bump Unhollower.RuntimeLib version

This commit is contained in:
ghorsington committed 2021-04-04 19:15:25 +03:00
1 parent e24ff244d8
commit 89699db292
2 files changed
+10 -11

No files matched your search

+1 -1
View File
@@ -25,7 +25,7 @@
<PackageReference Include="BepInEx.Il2Cpp.TlsAdapter" Version="1.0.1" />
<PackageReference Include="HarmonyX" Version="2.4.0" />
<PackageReference Include="Iced" Version="1.11.0" />
<PackageReference Include="Il2CppAssemblyUnhollower.BaseLib" Version="0.4.13" />
<PackageReference Include="Il2CppAssemblyUnhollower.BaseLib" Version="0.4.14" />
<PackageReference Include="Il2CppAssemblyUnhollower.BaseLib.Legacy" Version="0.4.11.1" />
<PackageReference Include="Il2CppAssemblyUnhollower.Tool" Version="0.4.13" />
<PackageReference Include="Il2CppDumper" Version="6.5.3" />
@@ -59,11 +59,11 @@ namespace BepInEx.IL2CPP.Hook
private static readonly Dictionary<int, Type> FixedStructCache = new();
private bool isValid;
private Il2CppMethodInfo* modifiedNativeMethodInfo;
private INativeMethodStruct modifiedNativeMethodInfo;
private FastNativeDetour nativeDetour;
private Il2CppMethodInfo* originalNativeMethodInfo;
private INativeMethodStruct originalNativeMethodInfo;
/// <summary>
/// Constructs a new instance of <see cref="NativeDetour" /> method patcher.
@@ -91,17 +91,16 @@ namespace BepInEx.IL2CPP.Hook
}
// Get the native MethodInfo struct for the target method
originalNativeMethodInfo = (Il2CppMethodInfo*) (IntPtr) methodField.GetValue(null);
originalNativeMethodInfo = UnityVersionHandler.Wrap((Il2CppMethodInfo*) (IntPtr) methodField.GetValue(null));
// Create a trampoline from the original target method
var trampolinePtr =
DetourGenerator.CreateTrampolineFromFunction(originalNativeMethodInfo->methodPointer, out _, out _);
DetourGenerator.CreateTrampolineFromFunction(originalNativeMethodInfo.MethodPointer, out _, out _);
// Create a modified native MethodInfo struct to point towards the trampoline
modifiedNativeMethodInfo = (Il2CppMethodInfo*) Marshal.AllocHGlobal(Marshal.SizeOf<Il2CppMethodInfo>());
Marshal.StructureToPtr(*originalNativeMethodInfo, (IntPtr) modifiedNativeMethodInfo, false);
modifiedNativeMethodInfo->methodPointer = trampolinePtr;
modifiedNativeMethodInfo = UnityVersionHandler.NewMethod(); //(Il2CppMethodInfo*) Marshal.AllocHGlobal(Marshal.SizeOf<Il2CppMethodInfo>());
Buffer.MemoryCopy(originalNativeMethodInfo.Pointer.ToPointer(), modifiedNativeMethodInfo.Pointer.ToPointer(), modifiedNativeMethodInfo.StructSize, originalNativeMethodInfo.StructSize);
modifiedNativeMethodInfo.MethodPointer = trampolinePtr;
isValid = true;
}
catch (Exception e)
@@ -136,7 +135,7 @@ namespace BepInEx.IL2CPP.Hook
var detourPtr =
Marshal.GetFunctionPointerForDelegate(unmanagedTrampolineMethod.CreateDelegate(unmanagedDelegateType));
nativeDetour = new FastNativeDetour(originalNativeMethodInfo->methodPointer, detourPtr);
nativeDetour = new FastNativeDetour(originalNativeMethodInfo.MethodPointer, detourPtr);
nativeDetour.Apply();
// TODO: Add an ILHook for the original unhollowed method to go directly to managedHookedMethod
@@ -169,7 +168,7 @@ namespace BepInEx.IL2CPP.Hook
// Replace original IL2CPPMethodInfo pointer with a modified one that points to the trampoline
cursor
.Emit(Mono.Cecil.Cil.OpCodes.Ldc_I8, ((IntPtr) modifiedNativeMethodInfo).ToInt64())
.Emit(Mono.Cecil.Cil.OpCodes.Ldc_I8, modifiedNativeMethodInfo.Pointer.ToInt64())
.Emit(Mono.Cecil.Cil.OpCodes.Conv_I);
return dmd;