public NativeDetour(MethodBase method, IntPtr from, IntPtr to, ref NativeDetourConfig config) { Method = method; if (!(OnDetour?.InvokeWhileTrue(this, method, from, to) ?? true)) { return; } IsValid = true; Data = DetourHelper.Native.Create(from, to, null); // Backing up the original function only needs to happen once. if (!config.SkipILCopy) { method?.TryCreateILCopy(out _BackupMethod); } // BackupNative is required even if BackupMethod is present to undo the detour. _BackupNative = DetourHelper.Native.MemAlloc(Data.Size); if (!config.ManualApply) { Apply(); } }
public NativeDetour(MethodBase method, IntPtr from, IntPtr to, ref NativeDetourConfig config) { if (from == to) { throw new InvalidOperationException($"Cannot detour from a location to itself! (from: {from:X16} to: {to:X16} method: {method})"); } method = method?.GetIdentifiable(); Method = method; if (!(OnDetour?.InvokeWhileTrue(this, method, from, to) ?? true)) { return; } IsValid = true; _Data = DetourHelper.Native.Create(from, to, null); // Backing up the original function only needs to happen once. if (!config.SkipILCopy) { method?.TryCreateILCopy(out _BackupMethod); } // BackupNative is required even if BackupMethod is present to undo the detour. _BackupNative = DetourHelper.Native.MemAlloc(_Data.Size); if (!config.ManualApply) { Apply(); } }
public NativeDetour(MethodBase from, IntPtr to, NativeDetourConfig config) : this(from, from.Pin().GetNativeStart(), to, ref config) { _Pinned.Add(from); }
public NativeDetour(IntPtr from, IntPtr to, NativeDetourConfig config) : this(null, from, to, ref config) { }
public NativeDetour(MethodBase method, IntPtr from, IntPtr to, NativeDetourConfig config) : this(method, from, to, ref config) { }
public NativeDetour(Delegate from, Delegate to, NativeDetourConfig config) : this(from.Method, to.Method, ref config) { }
public NativeDetour(IntPtr from, Delegate to, ref NativeDetourConfig config) : this(from, to.Method, ref config) { }
public NativeDetour(Delegate from, IntPtr to, ref NativeDetourConfig config) : this(from.Method, to, ref config) { }
public NativeDetour(MethodBase from, MethodBase to, NativeDetourConfig config) : this(from, DetourHelper.Runtime.GetDetourTarget(from, to).Pin().GetNativeStart(), ref config) { _Pinned.Add(to); }
public NativeDetour(IntPtr from, MethodBase to, NativeDetourConfig config) : this(from, to.Pin().GetNativeStart(), ref config) { _Pinned.Add(to); }
public NativeDetour(MethodBase from, IntPtr to, NativeDetourConfig config) : this(from, from.GetNativeStart(), to, ref config) { }
public NativeDetour(MethodBase from, MethodBase to, ref NativeDetourConfig config) : this(from, DetourHelper.Runtime.GetDetourTarget(from, to).GetNativeStart(), ref config) { }
public NativeDetour(IntPtr from, MethodBase to, NativeDetourConfig config) : this(from, to.GetNativeStart(), ref config) { }