mirror of
https://github.com/BepInEx/BepInEx.git
synced 2026-10-20 01:46:13 +00:00
Add config option for forced detour provider
This commit is contained in:
1 parent
9432878863
commit
83b72d568b
1 file changed
+26
-2
@@ -1,3 +1,4 @@
|
||||
using BepInEx.Configuration;
|
||||
using BepInEx.IL2CPP.Hook.Dobby;
|
||||
using BepInEx.IL2CPP.Hook.Funchook;
|
||||
using System;
|
||||
@@ -7,11 +8,34 @@ namespace BepInEx.IL2CPP.Hook;
|
||||
|
||||
public class NativeDetourHelper
|
||||
{
|
||||
internal enum DetourProvider
|
||||
{
|
||||
Default,
|
||||
Dobby,
|
||||
Funchook
|
||||
}
|
||||
private static readonly ConfigEntry<DetourProvider> DetourProviderType = ConfigFile.CoreConfig.Bind(
|
||||
"Detours", "DetourProviderType",
|
||||
DetourProvider.Default,
|
||||
"The native provider to use for managed detours"
|
||||
);
|
||||
|
||||
public static bool DEBUG_DETOURS = false;
|
||||
|
||||
private static INativeDetour CreateDefault(nint original, nint target)
|
||||
{
|
||||
// TODO: check and provide an OS accurate provider
|
||||
return new DobbyDetour(original, target);
|
||||
}
|
||||
|
||||
public static INativeDetour Create(nint original, nint target)
|
||||
{
|
||||
return new DobbyDetour(original, target);
|
||||
//return new FunchookDetour(original, target);
|
||||
return DetourProviderType.Value switch
|
||||
{
|
||||
DetourProvider.Dobby => new DobbyDetour(original, target),
|
||||
DetourProvider.Funchook => new FunchookDetour(original, target),
|
||||
_ => CreateDefault(original, target)
|
||||
};
|
||||
}
|
||||
|
||||
public static INativeDetour CreateAndApply<T>(nint from, T to, out T original, CallingConvention? callingConvention = null)
|
||||
|
||||
Reference in new issue
Block a user