File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
Il2CppInterop.HarmonySupport Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change 1212using Il2CppInterop . Runtime . Startup ;
1313using Microsoft . Extensions . Logging ;
1414using MonoMod . Cil ;
15+ using MonoMod . RuntimeDetour ;
1516using MonoMod . Utils ;
17+ using Detour = MonoMod . RuntimeDetour . Detour ;
18+ using IDetour = Il2CppInterop . Runtime . Injection . IDetour ;
1619using ValueType = Il2CppSystem . ValueType ;
17- using Void = Il2CppSystem . Void ;
1820
1921namespace Il2CppInterop . HarmonySupport ;
2022
@@ -57,6 +59,8 @@ private static readonly MethodInfo ReportExceptionMethodInfo
5759 } ;
5860
5961 private static readonly List < object > DelegateCache = new ( ) ;
62+ private static readonly List < object > DetourCache = new ( ) ;
63+
6064 private INativeMethodInfoStruct modifiedNativeMethodInfo ;
6165
6266 private IDetour nativeDetour ;
@@ -147,8 +151,10 @@ public override MethodBase DetourTo(MethodBase replacement)
147151 nativeDetour . Apply ( ) ;
148152 modifiedNativeMethodInfo . MethodPointer = nativeDetour . OriginalTrampoline ;
149153
150- // TODO: Add an ILHook for the original unhollowed method to go directly to managedHookedMethod
151- // Right now it goes through three times as much interop conversion as it needs to, when being called from managed side
154+ var detour = new Detour ( Original , managedHookedMethod ) ;
155+ detour . Apply ( ) ;
156+ DetourCache . Add ( detour ) ;
157+
152158 return managedHookedMethod ;
153159 }
154160
You can’t perform that action at this time.
0 commit comments