diff --git a/managed/CounterStrikeSharp.API/Core/API.cs b/managed/CounterStrikeSharp.API/Core/API.cs index eec7689d8..10f66bf03 100644 --- a/managed/CounterStrikeSharp.API/Core/API.cs +++ b/managed/CounterStrikeSharp.API/Core/API.cs @@ -1421,10 +1421,11 @@ public static void UnhookFunction(IntPtr function, InputArgument hook, bool post } } - public static T ExecuteVirtualFunction(IntPtr function, object[] arguments){ + public static T ExecuteVirtualFunction(IntPtr function, bool bypass, object[] arguments){ lock (ScriptContext.GlobalScriptContext.Lock) { ScriptContext.GlobalScriptContext.Reset(); ScriptContext.GlobalScriptContext.Push(function); + ScriptContext.GlobalScriptContext.Push(bypass); foreach (var obj in arguments) { ScriptContext.GlobalScriptContext.Push(obj); diff --git a/managed/CounterStrikeSharp.API/Modules/Memory/DynamicFunctions/BaseMemoryFunction.cs b/managed/CounterStrikeSharp.API/Modules/Memory/DynamicFunctions/BaseMemoryFunction.cs index 05cc01e12..c9d8ed018 100644 --- a/managed/CounterStrikeSharp.API/Modules/Memory/DynamicFunctions/BaseMemoryFunction.cs +++ b/managed/CounterStrikeSharp.API/Modules/Memory/DynamicFunctions/BaseMemoryFunction.cs @@ -67,13 +67,13 @@ public void Unhook(Func handler, HookMode mode) NativeAPI.UnhookFunction(Handle, handler, mode == HookMode.Post); } - protected T InvokeInternal(params object[] args) + protected T InvokeInternal(bool bypass, params object[] args) { - return NativeAPI.ExecuteVirtualFunction(Handle, args); + return NativeAPI.ExecuteVirtualFunction(Handle, bypass, args); } - protected void InvokeInternalVoid(params object[] args) + protected void InvokeInternalVoid(bool bypass, params object[] args) { - NativeAPI.ExecuteVirtualFunction(Handle, args); + NativeAPI.ExecuteVirtualFunction(Handle, bypass, args); } } \ No newline at end of file diff --git a/managed/CounterStrikeSharp.API/Modules/Memory/DynamicFunctions/MemoryFunctionVoid.cs b/managed/CounterStrikeSharp.API/Modules/Memory/DynamicFunctions/MemoryFunctionVoid.cs index 482254d6e..867c5b096 100644 --- a/managed/CounterStrikeSharp.API/Modules/Memory/DynamicFunctions/MemoryFunctionVoid.cs +++ b/managed/CounterStrikeSharp.API/Modules/Memory/DynamicFunctions/MemoryFunctionVoid.cs @@ -17,7 +17,12 @@ public MemoryFunctionVoid(string signature, string binarypath) : base(signature, public void Invoke() { - InvokeInternalVoid(); + InvokeInternalVoid(false); + } + + public void Invoke(bool bypasshook) + { + InvokeInternalVoid(bypasshook); } } @@ -35,7 +40,12 @@ public MemoryFunctionVoid(string signature, string binarypath) : base(signature, public void Invoke(T1 arg1) { - InvokeInternalVoid(arg1); + InvokeInternalVoid(false, arg1); + } + + public void Invoke(T1 arg1, bool bypasshook) + { + InvokeInternalVoid(bypasshook, arg1); } } @@ -53,7 +63,12 @@ public MemoryFunctionVoid(string signature, string binarypath) : base(signature, public void Invoke(T1 arg1, T2 arg2) { - InvokeInternalVoid(arg1, arg2); + InvokeInternalVoid(false, arg1, arg2); + } + + public void Invoke(T1 arg1, T2 arg2, bool bypasshook) + { + InvokeInternalVoid(bypasshook, arg1, arg2); } } @@ -71,7 +86,12 @@ public MemoryFunctionVoid(string signature, string binarypath) : base(signature, public void Invoke(T1 arg1, T2 arg2, T3 arg3) { - InvokeInternalVoid(arg1, arg2, arg3); + InvokeInternalVoid(false, arg1, arg2, arg3); + } + + public void Invoke(T1 arg1, T2 arg2, T3 arg3, bool bypasshook) + { + InvokeInternalVoid(bypasshook, arg1, arg2, arg3); } } @@ -97,7 +117,12 @@ public MemoryFunctionVoid(string signature, string binarypath) : base(signature, public void Invoke(T1 arg1, T2 arg2, T3 arg3, T4 arg4) { - InvokeInternalVoid(arg1, arg2, arg3, arg4); + InvokeInternalVoid(false, arg1, arg2, arg3, arg4); + } + + public void Invoke(T1 arg1, T2 arg2, T3 arg3, T4 arg4, bool bypasshook) + { + InvokeInternalVoid(bypasshook, arg1, arg2, arg3, arg4); } } @@ -125,7 +150,12 @@ public MemoryFunctionVoid(string signature, string binarypath) : base(signature, public void Invoke(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) { - InvokeInternalVoid(arg1, arg2, arg3, arg4, arg5); + InvokeInternalVoid(false, arg1, arg2, arg3, arg4, arg5); + } + + public void Invoke(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, bool bypasshook) + { + InvokeInternalVoid(bypasshook, arg1, arg2, arg3, arg4, arg5); } } @@ -153,7 +183,12 @@ public MemoryFunctionVoid(string signature, string binarypath) : base(signature, public void Invoke(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6) { - InvokeInternalVoid(arg1, arg2, arg3, arg4, arg5, arg6); + InvokeInternalVoid(false, arg1, arg2, arg3, arg4, arg5, arg6); + } + + public void Invoke(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, bool bypasshook) + { + InvokeInternalVoid(bypasshook, arg1, arg2, arg3, arg4, arg5, arg6); } } @@ -183,7 +218,12 @@ public MemoryFunctionVoid(string signature, string binarypath) : base(signature, public void Invoke(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7) { - InvokeInternalVoid(arg1, arg2, arg3, arg4, arg5, arg6, arg7); + InvokeInternalVoid(false, arg1, arg2, arg3, arg4, arg5, arg6, arg7); + } + + public void Invoke(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, bool bypasshook) + { + InvokeInternalVoid(bypasshook, arg1, arg2, arg3, arg4, arg5, arg6, arg7); } } @@ -213,7 +253,12 @@ public MemoryFunctionVoid(string signature, string binarypath) : base(signature, public void Invoke(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8) { - InvokeInternalVoid(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); + InvokeInternalVoid(false, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); + } + + public void Invoke(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, bool bypasshook) + { + InvokeInternalVoid(bypasshook, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); } } @@ -245,7 +290,12 @@ public MemoryFunctionVoid(string signature, string binarypath) : base(signature, public void Invoke(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9) { - InvokeInternalVoid(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); + InvokeInternalVoid(false, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); + } + + public void Invoke(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, bool bypasshook) + { + InvokeInternalVoid(bypasshook, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); } } @@ -277,7 +327,12 @@ public MemoryFunctionVoid(string signature, string binarypath) : base(signature, public void Invoke(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10) { - InvokeInternalVoid(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10); + InvokeInternalVoid(false, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10); + } + + public void Invoke(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, bool bypasshook) + { + InvokeInternalVoid(bypasshook, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10); } } diff --git a/managed/CounterStrikeSharp.API/Modules/Memory/DynamicFunctions/MemoryFunctionWithReturn.cs b/managed/CounterStrikeSharp.API/Modules/Memory/DynamicFunctions/MemoryFunctionWithReturn.cs index 8730debe7..7d121bf3d 100644 --- a/managed/CounterStrikeSharp.API/Modules/Memory/DynamicFunctions/MemoryFunctionWithReturn.cs +++ b/managed/CounterStrikeSharp.API/Modules/Memory/DynamicFunctions/MemoryFunctionWithReturn.cs @@ -19,7 +19,12 @@ public MemoryFunctionWithReturn(string signature, string binarypath) : base(sign public TResult Invoke() { - return InvokeInternal(); + return InvokeInternal(false); + } + + public TResult Invoke(bool bypasshook) + { + return InvokeInternal(bypasshook); } } @@ -37,7 +42,12 @@ public MemoryFunctionWithReturn(string signature, string binarypath) : base(sign public TResult Invoke(T1 arg1) { - return InvokeInternal(arg1); + return InvokeInternal(false, arg1); + } + + public TResult Invoke(T1 arg1, bool bypasshook) + { + return InvokeInternal(bypasshook, arg1); } } @@ -55,7 +65,12 @@ public MemoryFunctionWithReturn(string signature, string binarypath) : base(sign public TResult Invoke(T1 arg1, T2 arg2) { - return InvokeInternal(arg1, arg2); + return InvokeInternal(false, arg1, arg2); + } + + public TResult Invoke(T1 arg1, T2 arg2, bool bypasshook) + { + return InvokeInternal(bypasshook, arg1, arg2); } } @@ -73,7 +88,12 @@ public MemoryFunctionWithReturn(string signature, string binarypath) : base(sign public TResult Invoke(T1 arg1, T2 arg2, T3 arg3) { - return InvokeInternal(arg1, arg2, arg3); + return InvokeInternal(false, arg1, arg2, arg3); + } + + public TResult Invoke(T1 arg1, T2 arg2, T3 arg3, bool bypasshook) + { + return InvokeInternal(bypasshook, arg1, arg2, arg3); } } @@ -99,7 +119,12 @@ public MemoryFunctionWithReturn(string signature, string binarypath) : base(sign public TResult Invoke(T1 arg1, T2 arg2, T3 arg3, T4 arg4) { - return InvokeInternal(arg1, arg2, arg3, arg4); + return InvokeInternal(false, arg1, arg2, arg3, arg4); + } + + public TResult Invoke(T1 arg1, T2 arg2, T3 arg3, T4 arg4, bool bypasshook) + { + return InvokeInternal(bypasshook, arg1, arg2, arg3, arg4); } } @@ -125,7 +150,12 @@ public MemoryFunctionWithReturn(string signature, string binarypath) : base(sign public TResult Invoke(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) { - return InvokeInternal(arg1, arg2, arg3, arg4, arg5); + return InvokeInternal(false, arg1, arg2, arg3, arg4, arg5); + } + + public TResult Invoke(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, bool bypasshook) + { + return InvokeInternal(bypasshook, arg1, arg2, arg3, arg4, arg5); } } @@ -151,7 +181,12 @@ public MemoryFunctionWithReturn(string signature, string binarypath) : base(sign public TResult Invoke(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6) { - return InvokeInternal(arg1, arg2, arg3, arg4, arg5, arg6); + return InvokeInternal(false, arg1, arg2, arg3, arg4, arg5, arg6); + } + + public TResult Invoke(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, bool bypasshook) + { + return InvokeInternal(bypasshook, arg1, arg2, arg3, arg4, arg5, arg6); } } @@ -179,7 +214,12 @@ public MemoryFunctionWithReturn(string signature, string binarypath) : base(sign public TResult Invoke(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7) { - return InvokeInternal(arg1, arg2, arg3, arg4, arg5, arg6, arg7); + return InvokeInternal(false, arg1, arg2, arg3, arg4, arg5, arg6, arg7); + } + + public TResult Invoke(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, bool bypasshook) + { + return InvokeInternal(bypasshook, arg1, arg2, arg3, arg4, arg5, arg6, arg7); } } @@ -207,7 +247,12 @@ public MemoryFunctionWithReturn(string signature, string binarypath) : base(sign public TResult Invoke(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8) { - return InvokeInternal(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); + return InvokeInternal(false, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); + } + + public TResult Invoke(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, bool bypasshook) + { + return InvokeInternal(bypasshook, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); } } @@ -235,7 +280,12 @@ public MemoryFunctionWithReturn(string signature, string binarypath) : base(sign public TResult Invoke(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9) { - return InvokeInternal(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); + return InvokeInternal(false, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); + } + + public TResult Invoke(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, bool bypasshook) + { + return InvokeInternal(bypasshook, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); } } @@ -265,7 +315,12 @@ public MemoryFunctionWithReturn(string signature, string binarypath) : base(sign public TResult Invoke(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10) { - return InvokeInternal(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10); + return InvokeInternal(false, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10); + } + + public TResult Invoke(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, bool bypasshook) + { + return InvokeInternal(bypasshook, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10); } } diff --git a/managed/CounterStrikeSharp.API/Modules/Memory/VirtualFunctionOffset.cs b/managed/CounterStrikeSharp.API/Modules/Memory/VirtualFunctionOffset.cs index bc2eeac67..eedda7dd4 100644 --- a/managed/CounterStrikeSharp.API/Modules/Memory/VirtualFunctionOffset.cs +++ b/managed/CounterStrikeSharp.API/Modules/Memory/VirtualFunctionOffset.cs @@ -42,7 +42,17 @@ public static Action Create(IntPtr objectPtr, int offset) var virtualFunctionPointer = CreateVirtualFunction(objectPtr, offset, arguments, DataType.DATA_TYPE_VOID, arguments.Cast().ToArray()); - return () => { NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, new object[] { }); }; + return () => { NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, new object[] { }); }; + } + + public static Action Create(IntPtr objectPtr, int offset, bool bypasshook) + { + var arguments = Enumerable.Empty().ToArray(); + + var virtualFunctionPointer = CreateVirtualFunction(objectPtr, offset, arguments, + DataType.DATA_TYPE_VOID, arguments.Cast().ToArray()); + + return () => { NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, new object[] { }); }; } public static Action CreateVoid(IntPtr objectPtr, int offset) @@ -62,7 +72,28 @@ public static Action CreateVoid(IntPtr objectPtr, int offset) return (arg1) => { - NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, new object[] { arg1 }); + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, new object[] { arg1 }); + }; + } + + public static Action CreateVoid(IntPtr objectPtr, int offset, bool bypasshook) + { + var arguments = new[] + { + typeof(TArg1).ToDataType() + }; + + if (arguments.Any(x => x == null)) + { + throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); + } + + var virtualFunctionPointer = CreateVirtualFunction(objectPtr, offset, arguments.Cast(), + DataType.DATA_TYPE_VOID, arguments.Cast().ToArray()); + + return (arg1) => + { + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, new object[] { arg1 }); }; } @@ -84,7 +115,29 @@ public static Action CreateVoid(IntPtr objectPtr, in return (arg1, arg2) => { - NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, new object[] { arg1, arg2 }); + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, new object[] { arg1, arg2 }); + }; + } + + public static Action CreateVoid(IntPtr objectPtr, int offset, bool bypasshook) + { + var arguments = new[] + { + typeof(TArg1).ToDataType(), + typeof(TArg2).ToDataType() + }; + + if (arguments.Any(x => x == null)) + { + throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); + } + + var virtualFunctionPointer = CreateVirtualFunction(objectPtr, offset, arguments.Cast(), + DataType.DATA_TYPE_VOID, arguments.Cast().ToArray()); + + return (arg1, arg2) => + { + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, new object[] { arg1, arg2 }); }; } @@ -107,7 +160,30 @@ public static Action CreateVoid(IntPtr return (arg1, arg2, arg3) => { - NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, new object[] { arg1, arg2, arg3 }); + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, new object[] { arg1, arg2, arg3 }); + }; + } + + public static Action CreateVoid(IntPtr objectPtr, int offset, bool bypasshook) + { + var arguments = new[] + { + typeof(TArg1).ToDataType(), + typeof(TArg2).ToDataType(), + typeof(TArg3).ToDataType() + }; + + if (arguments.Any(x => x == null)) + { + throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); + } + + var virtualFunctionPointer = CreateVirtualFunction(objectPtr, offset, arguments.Cast(), + DataType.DATA_TYPE_VOID, arguments.Cast().ToArray()); + + return (arg1, arg2, arg3) => + { + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, new object[] { arg1, arg2, arg3 }); }; } @@ -132,7 +208,33 @@ public static Action CreateVoid { - NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, + new object[] { arg1, arg2, arg3, arg4 }); + }; + } + + public static Action CreateVoid(IntPtr objectPtr, + int offset, bool bypasshook) + { + var arguments = new[] + { + typeof(TArg1).ToDataType(), + typeof(TArg2).ToDataType(), + typeof(TArg3).ToDataType(), + typeof(TArg4).ToDataType() + }; + + if (arguments.Any(x => x == null)) + { + throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); + } + + var virtualFunctionPointer = CreateVirtualFunction(objectPtr, offset, arguments.Cast(), + DataType.DATA_TYPE_VOID, arguments.Cast().ToArray()); + + return (arg1, arg2, arg3, arg4) => + { + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, new object[] { arg1, arg2, arg3, arg4 }); }; } @@ -159,7 +261,34 @@ public static Action CreateVoid { - NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, + new object[] { arg1, arg2, arg3, arg4, arg5 }); + }; + } + + public static Action CreateVoid( + IntPtr objectPtr, int offset, bool bypasshook) + { + var arguments = new[] + { + typeof(TArg1).ToDataType(), + typeof(TArg2).ToDataType(), + typeof(TArg3).ToDataType(), + typeof(TArg4).ToDataType(), + typeof(TArg5).ToDataType() + }; + + if (arguments.Any(x => x == null)) + { + throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); + } + + var virtualFunctionPointer = CreateVirtualFunction(objectPtr, offset, arguments.Cast(), + DataType.DATA_TYPE_VOID, arguments.Cast().ToArray()); + + return (arg1, arg2, arg3, arg4, arg5) => + { + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, new object[] { arg1, arg2, arg3, arg4, arg5 }); }; } @@ -188,7 +317,36 @@ public static Action CreateVoid { - NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, + new object[] { arg1, arg2, arg3, arg4, arg5, arg6 }); + }; + } + + public static Action CreateVoid( + IntPtr objectPtr, int offset, bool bypasshook) + { + var arguments = new[] + { + typeof(TArg1).ToDataType(), + typeof(TArg2).ToDataType(), + typeof(TArg3).ToDataType(), + typeof(TArg4).ToDataType(), + typeof(TArg5).ToDataType(), + typeof(TArg6).ToDataType() + }; + + if (arguments.Any(x => x == null)) + { + throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); + } + + var virtualFunctionPointer = CreateVirtualFunction(objectPtr, offset, arguments.Cast(), + DataType.DATA_TYPE_VOID, arguments.Cast().ToArray()); + + return (arg1, arg2, arg3, arg4, arg5, arg6) => + { + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, new object[] { arg1, arg2, arg3, arg4, arg5, arg6 }); }; } @@ -218,7 +376,37 @@ public static Action CreateVoid { - NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, + new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7 }); + }; + } + + public static Action CreateVoid(IntPtr objectPtr, int offset, bool bypasshook) + { + var arguments = new[] + { + typeof(TArg1).ToDataType(), + typeof(TArg2).ToDataType(), + typeof(TArg3).ToDataType(), + typeof(TArg4).ToDataType(), + typeof(TArg5).ToDataType(), + typeof(TArg6).ToDataType(), + typeof(TArg7).ToDataType() + }; + + if (arguments.Any(x => x == null)) + { + throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); + } + + var virtualFunctionPointer = CreateVirtualFunction(objectPtr, offset, arguments.Cast(), + DataType.DATA_TYPE_VOID, arguments.Cast().ToArray()); + + return (arg1, arg2, arg3, arg4, arg5, arg6, arg7) => + { + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7 }); }; } @@ -249,7 +437,38 @@ public static Action CreateVoid { - NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, + new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8 }); + }; + } + + public static Action CreateVoid(IntPtr objectPtr, int offset, bool bypasshook) + { + var arguments = new[] + { + typeof(TArg1).ToDataType(), + typeof(TArg2).ToDataType(), + typeof(TArg3).ToDataType(), + typeof(TArg4).ToDataType(), + typeof(TArg5).ToDataType(), + typeof(TArg6).ToDataType(), + typeof(TArg7).ToDataType(), + typeof(TArg8).ToDataType() + }; + + if (arguments.Any(x => x == null)) + { + throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); + } + + var virtualFunctionPointer = CreateVirtualFunction(objectPtr, offset, arguments.Cast(), + DataType.DATA_TYPE_VOID, arguments.Cast().ToArray()); + + return (arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) => + { + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8 }); }; } @@ -281,7 +500,39 @@ public static Action CreateVoid { - NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, + new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 }); + }; + } + + public static Action CreateVoid(IntPtr objectPtr, int offset, bool bypasshook) + { + var arguments = new[] + { + typeof(TArg1).ToDataType(), + typeof(TArg2).ToDataType(), + typeof(TArg3).ToDataType(), + typeof(TArg4).ToDataType(), + typeof(TArg5).ToDataType(), + typeof(TArg6).ToDataType(), + typeof(TArg7).ToDataType(), + typeof(TArg8).ToDataType(), + typeof(TArg9).ToDataType() + }; + + if (arguments.Any(x => x == null)) + { + throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); + } + + var virtualFunctionPointer = CreateVirtualFunction(objectPtr, offset, arguments.Cast(), + DataType.DATA_TYPE_VOID, arguments.Cast().ToArray()); + + return (arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) => + { + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 }); }; } @@ -314,7 +565,40 @@ public static Action CreateVoid { - NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, + new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10 }); + }; + } + + public static Action CreateVoid(IntPtr objectPtr, int offset, bool bypasshook) + { + var arguments = new[] + { + typeof(TArg1).ToDataType(), + typeof(TArg2).ToDataType(), + typeof(TArg3).ToDataType(), + typeof(TArg4).ToDataType(), + typeof(TArg5).ToDataType(), + typeof(TArg6).ToDataType(), + typeof(TArg7).ToDataType(), + typeof(TArg8).ToDataType(), + typeof(TArg9).ToDataType(), + typeof(TArg10).ToDataType() + }; + + if (arguments.Any(x => x == null)) + { + throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); + } + + var virtualFunctionPointer = CreateVirtualFunction(objectPtr, offset, arguments.Cast(), + DataType.DATA_TYPE_VOID, arguments.Cast().ToArray()); + + return (arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) => + { + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10 }); }; } @@ -335,7 +619,22 @@ public static Func Create(IntPtr objectPtr, int offset) var virtualFunctionPointer = CreateVirtualFunction(objectPtr, offset, arguments, (DataType)typeof(TResult).ToDataType()!, arguments.Cast().ToArray()); - return () => NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, new object[] { }); + return () => NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, new object[] { }); + } + + public static Func Create(IntPtr objectPtr, int offset, bool bypasshook) + { + var arguments = Enumerable.Empty().ToArray(); + + if (typeof(TResult).ToDataType() == null) + { + throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); + } + + var virtualFunctionPointer = CreateVirtualFunction(objectPtr, offset, arguments, + (DataType)typeof(TResult).ToDataType()!, arguments.Cast().ToArray()); + + return () => NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, new object[] { }); } public static Func Create(IntPtr objectPtr, int offset) @@ -353,7 +652,25 @@ public static Func Create(IntPtr objectPtr, int var virtualFunctionPointer = CreateVirtualFunction(objectPtr, offset, arguments.Cast(), (DataType)typeof(TResult).ToDataType()!, arguments.Cast().ToArray()); - return (arg1) => NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, new object[] { arg1 }); + return (arg1) => NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, new object[] { arg1 }); + } + + public static Func Create(IntPtr objectPtr, int offset, bool bypasshook) + { + var arguments = new[] + { + typeof(TArg1).ToDataType() + }; + + if (arguments.Any(x => x == null)) + { + throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); + } + + var virtualFunctionPointer = CreateVirtualFunction(objectPtr, offset, arguments.Cast(), + (DataType)typeof(TResult).ToDataType()!, arguments.Cast().ToArray()); + + return (arg1) => NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, new object[] { arg1 }); } public static Func Create(IntPtr objectPtr, int offset) @@ -373,7 +690,27 @@ public static Func Create(IntPtr o (DataType)typeof(TResult).ToDataType()!, arguments.Cast().ToArray()); return (arg1, arg2) => - NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, new object[] { arg1, arg2 }); + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, new object[] { arg1, arg2 }); + } + + public static Func Create(IntPtr objectPtr, int offset, bool bypasshook) + { + var arguments = new[] + { + typeof(TArg1).ToDataType(), + typeof(TArg2).ToDataType() + }; + + if (arguments.Any(x => x == null)) + { + throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); + } + + var virtualFunctionPointer = CreateVirtualFunction(objectPtr, offset, arguments.Cast(), + (DataType)typeof(TResult).ToDataType()!, arguments.Cast().ToArray()); + + return (arg1, arg2) => + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, new object[] { arg1, arg2 }); } public static Func Create(IntPtr objectPtr, @@ -395,7 +732,29 @@ public static Func Create().ToArray()); return (arg1, arg2, arg3) => - NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, new object[] { arg1, arg2, arg3 }); + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, new object[] { arg1, arg2, arg3 }); + } + + public static Func Create(IntPtr objectPtr, + int offset, bool bypasshook) + { + var arguments = new[] + { + typeof(TArg1).ToDataType(), + typeof(TArg2).ToDataType(), + typeof(TArg3).ToDataType() + }; + + if (arguments.Any(x => x == null)) + { + throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); + } + + var virtualFunctionPointer = CreateVirtualFunction(objectPtr, offset, arguments.Cast(), + (DataType)typeof(TResult).ToDataType()!, arguments.Cast().ToArray()); + + return (arg1, arg2, arg3) => + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, new object[] { arg1, arg2, arg3 }); } public static Func Create( @@ -418,7 +777,31 @@ public static Func Create().ToArray()); return (arg1, arg2, arg3, arg4) => - NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, + new object[] { arg1, arg2, arg3, arg4 }); + } + + public static Func Create( + IntPtr objectPtr, int offset, bool bypasshook) + { + var arguments = new[] + { + typeof(TArg1).ToDataType(), + typeof(TArg2).ToDataType(), + typeof(TArg3).ToDataType(), + typeof(TArg4).ToDataType() + }; + + if (arguments.Any(x => x == null)) + { + throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); + } + + var virtualFunctionPointer = CreateVirtualFunction(objectPtr, offset, arguments.Cast(), + (DataType)typeof(TResult).ToDataType()!, arguments.Cast().ToArray()); + + return (arg1, arg2, arg3, arg4) => + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, new object[] { arg1, arg2, arg3, arg4 }); } @@ -443,7 +826,32 @@ public static Func Create().ToArray()); return (arg1, arg2, arg3, arg4, arg5) => - NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, + new object[] { arg1, arg2, arg3, arg4, arg5 }); + } + + public static Func Create(IntPtr objectPtr, int offset, bool bypasshook) + { + var arguments = new[] + { + typeof(TArg1).ToDataType(), + typeof(TArg2).ToDataType(), + typeof(TArg3).ToDataType(), + typeof(TArg4).ToDataType(), + typeof(TArg5).ToDataType() + }; + + if (arguments.Any(x => x == null)) + { + throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); + } + + var virtualFunctionPointer = CreateVirtualFunction(objectPtr, offset, arguments.Cast(), + (DataType)typeof(TResult).ToDataType()!, arguments.Cast().ToArray()); + + return (arg1, arg2, arg3, arg4, arg5) => + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, new object[] { arg1, arg2, arg3, arg4, arg5 }); } @@ -469,7 +877,33 @@ public static Func Create().ToArray()); return (arg1, arg2, arg3, arg4, arg5, arg6) => - NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, + new object[] { arg1, arg2, arg3, arg4, arg5, arg6 }); + } + + public static Func Create(IntPtr objectPtr, int offset, bool bypasshook) + { + var arguments = new[] + { + typeof(TArg1).ToDataType(), + typeof(TArg2).ToDataType(), + typeof(TArg3).ToDataType(), + typeof(TArg4).ToDataType(), + typeof(TArg5).ToDataType(), + typeof(TArg6).ToDataType() + }; + + if (arguments.Any(x => x == null)) + { + throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); + } + + var virtualFunctionPointer = CreateVirtualFunction(objectPtr, offset, arguments.Cast(), + (DataType)typeof(TResult).ToDataType()!, arguments.Cast().ToArray()); + + return (arg1, arg2, arg3, arg4, arg5, arg6) => + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, new object[] { arg1, arg2, arg3, arg4, arg5, arg6 }); } @@ -496,7 +930,34 @@ public static Func Create().ToArray()); return (arg1, arg2, arg3, arg4, arg5, arg6, arg7) => - NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, + new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7 }); + } + + public static Func Create(IntPtr objectPtr, int offset, bool bypasshook) + { + var arguments = new[] + { + typeof(TArg1).ToDataType(), + typeof(TArg2).ToDataType(), + typeof(TArg3).ToDataType(), + typeof(TArg4).ToDataType(), + typeof(TArg5).ToDataType(), + typeof(TArg6).ToDataType(), + typeof(TArg7).ToDataType() + }; + + if (arguments.Any(x => x == null)) + { + throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); + } + + var virtualFunctionPointer = CreateVirtualFunction(objectPtr, offset, arguments.Cast(), + (DataType)typeof(TResult).ToDataType()!, arguments.Cast().ToArray()); + + return (arg1, arg2, arg3, arg4, arg5, arg6, arg7) => + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7 }); } @@ -524,7 +985,35 @@ public static Func Create().ToArray()); return (arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) => - NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, + new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8 }); + } + + public static Func Create(IntPtr objectPtr, int offset, bool bypasshook) + { + var arguments = new[] + { + typeof(TArg1).ToDataType(), + typeof(TArg2).ToDataType(), + typeof(TArg3).ToDataType(), + typeof(TArg4).ToDataType(), + typeof(TArg5).ToDataType(), + typeof(TArg6).ToDataType(), + typeof(TArg7).ToDataType(), + typeof(TArg8).ToDataType() + }; + + if (arguments.Any(x => x == null)) + { + throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); + } + + var virtualFunctionPointer = CreateVirtualFunction(objectPtr, offset, arguments.Cast(), + (DataType)typeof(TResult).ToDataType()!, arguments.Cast().ToArray()); + + return (arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) => + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8 }); } @@ -553,7 +1042,36 @@ public static Func Create().ToArray()); return (arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) => - NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, + new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 }); + } + + public static Func Create(IntPtr objectPtr, int offset, bool bypasshook) + { + var arguments = new[] + { + typeof(TArg1).ToDataType(), + typeof(TArg2).ToDataType(), + typeof(TArg3).ToDataType(), + typeof(TArg4).ToDataType(), + typeof(TArg5).ToDataType(), + typeof(TArg6).ToDataType(), + typeof(TArg7).ToDataType(), + typeof(TArg8).ToDataType(), + typeof(TArg9).ToDataType() + }; + + if (arguments.Any(x => x == null)) + { + throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); + } + + var virtualFunctionPointer = CreateVirtualFunction(objectPtr, offset, arguments.Cast(), + (DataType)typeof(TResult).ToDataType()!, arguments.Cast().ToArray()); + + return (arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) => + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 }); } @@ -583,7 +1101,38 @@ public static Func Create().ToArray()); return (arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) => - NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, + new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10 }); + } + + public static Func Create(IntPtr objectPtr, int offset, + bool bypasshook) + { + var arguments = new[] + { + typeof(TArg1).ToDataType(), + typeof(TArg2).ToDataType(), + typeof(TArg3).ToDataType(), + typeof(TArg4).ToDataType(), + typeof(TArg5).ToDataType(), + typeof(TArg6).ToDataType(), + typeof(TArg7).ToDataType(), + typeof(TArg8).ToDataType(), + typeof(TArg9).ToDataType(), + typeof(TArg10).ToDataType() + }; + + if (arguments.Any(x => x == null)) + { + throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); + } + + var virtualFunctionPointer = CreateVirtualFunction(objectPtr, offset, arguments.Cast(), + (DataType)typeof(TResult).ToDataType()!, arguments.Cast().ToArray()); + + return (arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) => + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10 }); } diff --git a/managed/CounterStrikeSharp.API/Modules/Memory/VirtualFunctionSignature.cs b/managed/CounterStrikeSharp.API/Modules/Memory/VirtualFunctionSignature.cs index cff32e130..04ec0283e 100644 --- a/managed/CounterStrikeSharp.API/Modules/Memory/VirtualFunctionSignature.cs +++ b/managed/CounterStrikeSharp.API/Modules/Memory/VirtualFunctionSignature.cs @@ -80,7 +80,22 @@ public static Func Create(string signature) var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, arguments, (DataType)typeof(TResult).ToDataType()!, arguments.Cast().ToArray()); - return () => NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, new object[] { }); + return () => NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, new object[] { }); + } + + public static Func Create(string signature, bool bypasshook) + { + var arguments = Enumerable.Empty().ToArray(); + + if (typeof(TResult).ToDataType() == null) + { + throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); + } + + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, arguments, + (DataType)typeof(TResult).ToDataType()!, arguments.Cast().ToArray()); + + return () => NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, new object[] { }); } public static Func Create(string signature) @@ -98,15 +113,14 @@ public static Func Create(string signature) var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, arguments.Cast(), (DataType)typeof(TResult).ToDataType()!, arguments.Cast().ToArray()); - return (arg1) => NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, new object[] { arg1 }); + return (arg1) => NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, new object[] { arg1 }); } - public static Func Create(string signature) + public static Func Create(string signature, bool bypasshook) { var arguments = new[] { - typeof(TArg1).ToDataType(), - typeof(TArg2).ToDataType() + typeof(TArg1).ToDataType() }; if (arguments.Any(x => x == null)) @@ -117,17 +131,15 @@ public static Func Create(string s var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, arguments.Cast(), (DataType)typeof(TResult).ToDataType()!, arguments.Cast().ToArray()); - return (arg1, arg2) => - NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, new object[] { arg1, arg2 }); + return (arg1) => NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, new object[] { arg1 }); } - public static Func Create(string signature) + public static Func Create(string signature) { var arguments = new[] { typeof(TArg1).ToDataType(), - typeof(TArg2).ToDataType(), - typeof(TArg3).ToDataType() + typeof(TArg2).ToDataType() }; if (arguments.Any(x => x == null)) @@ -138,19 +150,16 @@ public static Func Create(), (DataType)typeof(TResult).ToDataType()!, arguments.Cast().ToArray()); - return (arg1, arg2, arg3) => - NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, new object[] { arg1, arg2, arg3 }); + return (arg1, arg2) => + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, new object[] { arg1, arg2 }); } - public static Func Create( - string signature) + public static Func Create(string signature, bool bypasshook) { var arguments = new[] { typeof(TArg1).ToDataType(), - typeof(TArg2).ToDataType(), - typeof(TArg3).ToDataType(), - typeof(TArg4).ToDataType() + typeof(TArg2).ToDataType() }; if (arguments.Any(x => x == null)) @@ -161,20 +170,17 @@ public static Func Create(), (DataType)typeof(TResult).ToDataType()!, arguments.Cast().ToArray()); - return (arg1, arg2, arg3, arg4) => - NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, new object[] { arg1, arg2, arg3, arg4 }); + return (arg1, arg2) => + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, new object[] { arg1, arg2 }); } - public static Func Create( - string signature) + public static Func Create(string signature) { var arguments = new[] { typeof(TArg1).ToDataType(), typeof(TArg2).ToDataType(), - typeof(TArg3).ToDataType(), - typeof(TArg4).ToDataType(), - typeof(TArg5).ToDataType() + typeof(TArg3).ToDataType() }; if (arguments.Any(x => x == null)) @@ -185,22 +191,17 @@ public static Func Create(), (DataType)typeof(TResult).ToDataType()!, arguments.Cast().ToArray()); - return (arg1, arg2, arg3, arg4, arg5) => - NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, - new object[] { arg1, arg2, arg3, arg4, arg5 }); + return (arg1, arg2, arg3) => + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, new object[] { arg1, arg2, arg3 }); } - public static Func Create(string signature) + public static Func Create(string signature, bool bypasshook) { var arguments = new[] { typeof(TArg1).ToDataType(), typeof(TArg2).ToDataType(), - typeof(TArg3).ToDataType(), - typeof(TArg4).ToDataType(), - typeof(TArg5).ToDataType(), - typeof(TArg6).ToDataType() + typeof(TArg3).ToDataType() }; if (arguments.Any(x => x == null)) @@ -211,22 +212,19 @@ public static Func Create(), (DataType)typeof(TResult).ToDataType()!, arguments.Cast().ToArray()); - return (arg1, arg2, arg3, arg4, arg5, arg6) => NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, - new object[] { arg1, arg2, arg3, arg4, arg5, arg6 }); + return (arg1, arg2, arg3) => + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, new object[] { arg1, arg2, arg3 }); } - public static Func Create(string signature) + public static Func Create( + string signature) { var arguments = new[] { typeof(TArg1).ToDataType(), typeof(TArg2).ToDataType(), typeof(TArg3).ToDataType(), - typeof(TArg4).ToDataType(), - typeof(TArg5).ToDataType(), - typeof(TArg6).ToDataType(), - typeof(TArg7).ToDataType() + typeof(TArg4).ToDataType() }; if (arguments.Any(x => x == null)) @@ -237,24 +235,19 @@ public static Func Create(), (DataType)typeof(TResult).ToDataType()!, arguments.Cast().ToArray()); - return (arg1, arg2, arg3, arg4, arg5, arg6, arg7) => - NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, - new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7 }); + return (arg1, arg2, arg3, arg4) => + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, new object[] { arg1, arg2, arg3, arg4 }); } - public static Func Create(string signature) + public static Func Create( + string signature, bool bypasshook) { var arguments = new[] { typeof(TArg1).ToDataType(), typeof(TArg2).ToDataType(), typeof(TArg3).ToDataType(), - typeof(TArg4).ToDataType(), - typeof(TArg5).ToDataType(), - typeof(TArg6).ToDataType(), - typeof(TArg7).ToDataType(), - typeof(TArg8).ToDataType() + typeof(TArg4).ToDataType() }; if (arguments.Any(x => x == null)) @@ -265,13 +258,12 @@ public static Func Create(), (DataType)typeof(TResult).ToDataType()!, arguments.Cast().ToArray()); - return (arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) => - NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, - new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8 }); + return (arg1, arg2, arg3, arg4) => + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, new object[] { arg1, arg2, arg3, arg4 }); } - public static Func Create(string signature) + public static Func Create( + string signature) { var arguments = new[] { @@ -279,11 +271,7 @@ public static Func Create x == null)) @@ -294,13 +282,13 @@ public static Func Create(), (DataType)typeof(TResult).ToDataType()!, arguments.Cast().ToArray()); - return (arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) => - NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, - new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 }); + return (arg1, arg2, arg3, arg4, arg5) => + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, + new object[] { arg1, arg2, arg3, arg4, arg5 }); } - public static Func Create(string signature) + public static Func Create( + string signature, bool bypasshook) { var arguments = new[] { @@ -308,12 +296,7 @@ public static Func Create x == null)) @@ -324,34 +307,47 @@ public static Func Create(), (DataType)typeof(TResult).ToDataType()!, arguments.Cast().ToArray()); - return (arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) => - NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, - new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10 }); + return (arg1, arg2, arg3, arg4, arg5) => + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, + new object[] { arg1, arg2, arg3, arg4, arg5 }); } - #endregion - - #region FuncsBinary - public static Func Create(string signature, string binarypath) + public static Func Create(string signature) { - var arguments = Enumerable.Empty().ToArray(); + var arguments = new[] + { + typeof(TArg1).ToDataType(), + typeof(TArg2).ToDataType(), + typeof(TArg3).ToDataType(), + typeof(TArg4).ToDataType(), + typeof(TArg5).ToDataType(), + typeof(TArg6).ToDataType() + }; - if (typeof(TResult).ToDataType() == null) + if (arguments.Any(x => x == null)) { throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); } - var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, binarypath, arguments, + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, arguments.Cast(), (DataType)typeof(TResult).ToDataType()!, arguments.Cast().ToArray()); - return () => NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, new object[] { }); + return (arg1, arg2, arg3, arg4, arg5, arg6) => NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, + false, new object[] { arg1, arg2, arg3, arg4, arg5, arg6 }); } - public static Func Create(string signature, string binarypath) + public static Func Create(string signature, bool bypasshook) { var arguments = new[] { - typeof(TArg1).ToDataType() + typeof(TArg1).ToDataType(), + typeof(TArg2).ToDataType(), + typeof(TArg3).ToDataType(), + typeof(TArg4).ToDataType(), + typeof(TArg5).ToDataType(), + typeof(TArg6).ToDataType() }; if (arguments.Any(x => x == null)) @@ -359,18 +355,25 @@ public static Func Create(string signature, stri throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); } - var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, binarypath, arguments.Cast(), + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, arguments.Cast(), (DataType)typeof(TResult).ToDataType()!, arguments.Cast().ToArray()); - return (arg1) => NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, new object[] { arg1 }); + return (arg1, arg2, arg3, arg4, arg5, arg6) => NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, + bypasshook, new object[] { arg1, arg2, arg3, arg4, arg5, arg6 }); } - public static Func Create(string signature, string binarypath) + public static Func Create(string signature) { var arguments = new[] { typeof(TArg1).ToDataType(), - typeof(TArg2).ToDataType() + typeof(TArg2).ToDataType(), + typeof(TArg3).ToDataType(), + typeof(TArg4).ToDataType(), + typeof(TArg5).ToDataType(), + typeof(TArg6).ToDataType(), + typeof(TArg7).ToDataType() }; if (arguments.Any(x => x == null)) @@ -378,20 +381,26 @@ public static Func Create(string s throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); } - var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, binarypath, arguments.Cast(), + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, arguments.Cast(), (DataType)typeof(TResult).ToDataType()!, arguments.Cast().ToArray()); - return (arg1, arg2) => - NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, new object[] { arg1, arg2 }); + return (arg1, arg2, arg3, arg4, arg5, arg6, arg7) => + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, + new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7 }); } - public static Func Create(string signature, string binarypath) + public static Func Create(string signature, bool bypasshook) { var arguments = new[] { typeof(TArg1).ToDataType(), typeof(TArg2).ToDataType(), - typeof(TArg3).ToDataType() + typeof(TArg3).ToDataType(), + typeof(TArg4).ToDataType(), + typeof(TArg5).ToDataType(), + typeof(TArg6).ToDataType(), + typeof(TArg7).ToDataType() }; if (arguments.Any(x => x == null)) @@ -399,22 +408,27 @@ public static Func Create(), + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, arguments.Cast(), (DataType)typeof(TResult).ToDataType()!, arguments.Cast().ToArray()); - return (arg1, arg2, arg3) => - NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, new object[] { arg1, arg2, arg3 }); + return (arg1, arg2, arg3, arg4, arg5, arg6, arg7) => + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, + new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7 }); } - public static Func Create( - string signature, string binarypath) + public static Func Create(string signature) { var arguments = new[] { typeof(TArg1).ToDataType(), typeof(TArg2).ToDataType(), typeof(TArg3).ToDataType(), - typeof(TArg4).ToDataType() + typeof(TArg4).ToDataType(), + typeof(TArg5).ToDataType(), + typeof(TArg6).ToDataType(), + typeof(TArg7).ToDataType(), + typeof(TArg8).ToDataType() }; if (arguments.Any(x => x == null)) @@ -422,15 +436,16 @@ public static Func Create(), + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, arguments.Cast(), (DataType)typeof(TResult).ToDataType()!, arguments.Cast().ToArray()); - return (arg1, arg2, arg3, arg4) => - NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, new object[] { arg1, arg2, arg3, arg4 }); + return (arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) => + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, + new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8 }); } - public static Func Create( - string signature, string binarypath) + public static Func Create(string signature, bool bypasshook) { var arguments = new[] { @@ -438,7 +453,10 @@ public static Func Create x == null)) @@ -446,16 +464,16 @@ public static Func Create(), + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, arguments.Cast(), (DataType)typeof(TResult).ToDataType()!, arguments.Cast().ToArray()); - return (arg1, arg2, arg3, arg4, arg5) => - NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, - new object[] { arg1, arg2, arg3, arg4, arg5 }); + return (arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) => + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, + new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8 }); } - public static Func Create(string signature, string binarypath) + public static Func Create(string signature) { var arguments = new[] { @@ -464,7 +482,10 @@ public static Func Create x == null)) @@ -472,15 +493,16 @@ public static Func Create(), + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, arguments.Cast(), (DataType)typeof(TResult).ToDataType()!, arguments.Cast().ToArray()); - return (arg1, arg2, arg3, arg4, arg5, arg6) => NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, - new object[] { arg1, arg2, arg3, arg4, arg5, arg6 }); + return (arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) => + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, + new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 }); } - public static Func Create(string signature, string binarypath) + public static Func Create(string signature, bool bypasshook) { var arguments = new[] { @@ -490,7 +512,9 @@ public static Func Create x == null)) @@ -498,16 +522,16 @@ public static Func Create(), + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, arguments.Cast(), (DataType)typeof(TResult).ToDataType()!, arguments.Cast().ToArray()); - return (arg1, arg2, arg3, arg4, arg5, arg6, arg7) => - NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, - new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7 }); + return (arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) => + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, + new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 }); } - public static Func Create(string signature, string binarypath) + public static Func Create(string signature) { var arguments = new[] { @@ -518,7 +542,9 @@ public static Func Create x == null)) @@ -526,16 +552,16 @@ public static Func Create(), + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, arguments.Cast(), (DataType)typeof(TResult).ToDataType()!, arguments.Cast().ToArray()); - return (arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) => - NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, - new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8 }); + return (arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) => + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, + new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10 }); } - public static Func Create(string signature, string binarypath) + public static Func Create(string signature, bool bypasshook) { var arguments = new[] { @@ -547,7 +573,8 @@ public static Func Create x == null)) @@ -555,16 +582,1062 @@ public static Func Create(), + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, arguments.Cast(), (DataType)typeof(TResult).ToDataType()!, arguments.Cast().ToArray()); - return (arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) => - NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, - new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 }); + return (arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) => + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, + new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10 }); } - public static Func Create(string signature, string binarypath) + #endregion + + #region FuncsBinary + public static Func Create(string signature, string binarypath) + { + var arguments = Enumerable.Empty().ToArray(); + + if (typeof(TResult).ToDataType() == null) + { + throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); + } + + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, binarypath, arguments, + (DataType)typeof(TResult).ToDataType()!, arguments.Cast().ToArray()); + + return () => NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, new object[] { }); + } + + public static Func Create(string signature, string binarypath, bool bypasshook) + { + var arguments = Enumerable.Empty().ToArray(); + + if (typeof(TResult).ToDataType() == null) + { + throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); + } + + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, binarypath, arguments, + (DataType)typeof(TResult).ToDataType()!, arguments.Cast().ToArray()); + + return () => NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, new object[] { }); + } + + public static Func Create(string signature, string binarypath) + { + var arguments = new[] + { + typeof(TArg1).ToDataType() + }; + + if (arguments.Any(x => x == null)) + { + throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); + } + + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, binarypath, arguments.Cast(), + (DataType)typeof(TResult).ToDataType()!, arguments.Cast().ToArray()); + + return (arg1) => NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, new object[] { arg1 }); + } + + public static Func Create(string signature, string binarypath, bool bypasshook) + { + var arguments = new[] + { + typeof(TArg1).ToDataType() + }; + + if (arguments.Any(x => x == null)) + { + throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); + } + + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, binarypath, arguments.Cast(), + (DataType)typeof(TResult).ToDataType()!, arguments.Cast().ToArray()); + + return (arg1) => NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, new object[] { arg1 }); + } + + public static Func Create(string signature, string binarypath) + { + var arguments = new[] + { + typeof(TArg1).ToDataType(), + typeof(TArg2).ToDataType() + }; + + if (arguments.Any(x => x == null)) + { + throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); + } + + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, binarypath, arguments.Cast(), + (DataType)typeof(TResult).ToDataType()!, arguments.Cast().ToArray()); + + return (arg1, arg2) => + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, new object[] { arg1, arg2 }); + } + + public static Func Create(string signature, string binarypath, bool bypasshook) + { + var arguments = new[] + { + typeof(TArg1).ToDataType(), + typeof(TArg2).ToDataType() + }; + + if (arguments.Any(x => x == null)) + { + throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); + } + + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, binarypath, arguments.Cast(), + (DataType)typeof(TResult).ToDataType()!, arguments.Cast().ToArray()); + + return (arg1, arg2) => + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, new object[] { arg1, arg2 }); + } + + public static Func Create(string signature, string binarypath) + { + var arguments = new[] + { + typeof(TArg1).ToDataType(), + typeof(TArg2).ToDataType(), + typeof(TArg3).ToDataType() + }; + + if (arguments.Any(x => x == null)) + { + throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); + } + + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, binarypath, arguments.Cast(), + (DataType)typeof(TResult).ToDataType()!, arguments.Cast().ToArray()); + + return (arg1, arg2, arg3) => + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, new object[] { arg1, arg2, arg3 }); + } + + public static Func Create(string signature, string binarypath, bool bypasshook) + { + var arguments = new[] + { + typeof(TArg1).ToDataType(), + typeof(TArg2).ToDataType(), + typeof(TArg3).ToDataType() + }; + + if (arguments.Any(x => x == null)) + { + throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); + } + + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, binarypath, arguments.Cast(), + (DataType)typeof(TResult).ToDataType()!, arguments.Cast().ToArray()); + + return (arg1, arg2, arg3) => + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, new object[] { arg1, arg2, arg3 }); + } + + public static Func Create( + string signature, string binarypath) + { + var arguments = new[] + { + typeof(TArg1).ToDataType(), + typeof(TArg2).ToDataType(), + typeof(TArg3).ToDataType(), + typeof(TArg4).ToDataType() + }; + + if (arguments.Any(x => x == null)) + { + throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); + } + + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, binarypath, arguments.Cast(), + (DataType)typeof(TResult).ToDataType()!, arguments.Cast().ToArray()); + + return (arg1, arg2, arg3, arg4) => + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, new object[] { arg1, arg2, arg3, arg4 }); + } + + public static Func Create( + string signature, string binarypath, bool bypasshook) + { + var arguments = new[] + { + typeof(TArg1).ToDataType(), + typeof(TArg2).ToDataType(), + typeof(TArg3).ToDataType(), + typeof(TArg4).ToDataType() + }; + + if (arguments.Any(x => x == null)) + { + throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); + } + + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, binarypath, arguments.Cast(), + (DataType)typeof(TResult).ToDataType()!, arguments.Cast().ToArray()); + + return (arg1, arg2, arg3, arg4) => + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, new object[] { arg1, arg2, arg3, arg4 }); + } + + public static Func Create( + string signature, string binarypath) + { + var arguments = new[] + { + typeof(TArg1).ToDataType(), + typeof(TArg2).ToDataType(), + typeof(TArg3).ToDataType(), + typeof(TArg4).ToDataType(), + typeof(TArg5).ToDataType() + }; + + if (arguments.Any(x => x == null)) + { + throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); + } + + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, binarypath, arguments.Cast(), + (DataType)typeof(TResult).ToDataType()!, arguments.Cast().ToArray()); + + return (arg1, arg2, arg3, arg4, arg5) => + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, + new object[] { arg1, arg2, arg3, arg4, arg5 }); + } + + public static Func Create( + string signature, string binarypath, bool bypasshook) + { + var arguments = new[] + { + typeof(TArg1).ToDataType(), + typeof(TArg2).ToDataType(), + typeof(TArg3).ToDataType(), + typeof(TArg4).ToDataType(), + typeof(TArg5).ToDataType() + }; + + if (arguments.Any(x => x == null)) + { + throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); + } + + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, binarypath, arguments.Cast(), + (DataType)typeof(TResult).ToDataType()!, arguments.Cast().ToArray()); + + return (arg1, arg2, arg3, arg4, arg5) => + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, + new object[] { arg1, arg2, arg3, arg4, arg5 }); + } + + public static Func Create(string signature, string binarypath) + { + var arguments = new[] + { + typeof(TArg1).ToDataType(), + typeof(TArg2).ToDataType(), + typeof(TArg3).ToDataType(), + typeof(TArg4).ToDataType(), + typeof(TArg5).ToDataType(), + typeof(TArg6).ToDataType() + }; + + if (arguments.Any(x => x == null)) + { + throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); + } + + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, binarypath, arguments.Cast(), + (DataType)typeof(TResult).ToDataType()!, arguments.Cast().ToArray()); + + return (arg1, arg2, arg3, arg4, arg5, arg6) => NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, + false, new object[] { arg1, arg2, arg3, arg4, arg5, arg6 }); + } + + public static Func Create(string signature, string binarypath, bool bypasshook) + { + var arguments = new[] + { + typeof(TArg1).ToDataType(), + typeof(TArg2).ToDataType(), + typeof(TArg3).ToDataType(), + typeof(TArg4).ToDataType(), + typeof(TArg5).ToDataType(), + typeof(TArg6).ToDataType() + }; + + if (arguments.Any(x => x == null)) + { + throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); + } + + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, binarypath, arguments.Cast(), + (DataType)typeof(TResult).ToDataType()!, arguments.Cast().ToArray()); + + return (arg1, arg2, arg3, arg4, arg5, arg6) => NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, + bypasshook, new object[] { arg1, arg2, arg3, arg4, arg5, arg6 }); + } + + public static Func Create(string signature, string binarypath) + { + var arguments = new[] + { + typeof(TArg1).ToDataType(), + typeof(TArg2).ToDataType(), + typeof(TArg3).ToDataType(), + typeof(TArg4).ToDataType(), + typeof(TArg5).ToDataType(), + typeof(TArg6).ToDataType(), + typeof(TArg7).ToDataType() + }; + + if (arguments.Any(x => x == null)) + { + throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); + } + + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, binarypath, arguments.Cast(), + (DataType)typeof(TResult).ToDataType()!, arguments.Cast().ToArray()); + + return (arg1, arg2, arg3, arg4, arg5, arg6, arg7) => + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, + new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7 }); + } + + public static Func Create(string signature, string binarypath, bool bypasshook) + { + var arguments = new[] + { + typeof(TArg1).ToDataType(), + typeof(TArg2).ToDataType(), + typeof(TArg3).ToDataType(), + typeof(TArg4).ToDataType(), + typeof(TArg5).ToDataType(), + typeof(TArg6).ToDataType(), + typeof(TArg7).ToDataType() + }; + + if (arguments.Any(x => x == null)) + { + throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); + } + + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, binarypath, arguments.Cast(), + (DataType)typeof(TResult).ToDataType()!, arguments.Cast().ToArray()); + + return (arg1, arg2, arg3, arg4, arg5, arg6, arg7) => + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, + new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7 }); + } + + public static Func Create(string signature, string binarypath) + { + var arguments = new[] + { + typeof(TArg1).ToDataType(), + typeof(TArg2).ToDataType(), + typeof(TArg3).ToDataType(), + typeof(TArg4).ToDataType(), + typeof(TArg5).ToDataType(), + typeof(TArg6).ToDataType(), + typeof(TArg7).ToDataType(), + typeof(TArg8).ToDataType() + }; + + if (arguments.Any(x => x == null)) + { + throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); + } + + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, binarypath, arguments.Cast(), + (DataType)typeof(TResult).ToDataType()!, arguments.Cast().ToArray()); + + return (arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) => + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, + new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8 }); + } + + public static Func Create(string signature, string binarypath, bool bypasshook) + { + var arguments = new[] + { + typeof(TArg1).ToDataType(), + typeof(TArg2).ToDataType(), + typeof(TArg3).ToDataType(), + typeof(TArg4).ToDataType(), + typeof(TArg5).ToDataType(), + typeof(TArg6).ToDataType(), + typeof(TArg7).ToDataType(), + typeof(TArg8).ToDataType() + }; + + if (arguments.Any(x => x == null)) + { + throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); + } + + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, binarypath, arguments.Cast(), + (DataType)typeof(TResult).ToDataType()!, arguments.Cast().ToArray()); + + return (arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) => + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, + new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8 }); + } + + public static Func Create(string signature, string binarypath) + { + var arguments = new[] + { + typeof(TArg1).ToDataType(), + typeof(TArg2).ToDataType(), + typeof(TArg3).ToDataType(), + typeof(TArg4).ToDataType(), + typeof(TArg5).ToDataType(), + typeof(TArg6).ToDataType(), + typeof(TArg7).ToDataType(), + typeof(TArg8).ToDataType(), + typeof(TArg9).ToDataType() + }; + + if (arguments.Any(x => x == null)) + { + throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); + } + + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, binarypath, arguments.Cast(), + (DataType)typeof(TResult).ToDataType()!, arguments.Cast().ToArray()); + + return (arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) => + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, + new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 }); + } + + public static Func Create(string signature, string binarypath, bool bypasshook) + { + var arguments = new[] + { + typeof(TArg1).ToDataType(), + typeof(TArg2).ToDataType(), + typeof(TArg3).ToDataType(), + typeof(TArg4).ToDataType(), + typeof(TArg5).ToDataType(), + typeof(TArg6).ToDataType(), + typeof(TArg7).ToDataType(), + typeof(TArg8).ToDataType(), + typeof(TArg9).ToDataType() + }; + + if (arguments.Any(x => x == null)) + { + throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); + } + + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, binarypath, arguments.Cast(), + (DataType)typeof(TResult).ToDataType()!, arguments.Cast().ToArray()); + + return (arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) => + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, + new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 }); + } + + public static Func Create(string signature, string binarypath) + { + var arguments = new[] + { + typeof(TArg1).ToDataType(), + typeof(TArg2).ToDataType(), + typeof(TArg3).ToDataType(), + typeof(TArg4).ToDataType(), + typeof(TArg5).ToDataType(), + typeof(TArg6).ToDataType(), + typeof(TArg7).ToDataType(), + typeof(TArg8).ToDataType(), + typeof(TArg9).ToDataType(), + typeof(TArg10).ToDataType() + }; + + if (arguments.Any(x => x == null)) + { + throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); + } + + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, binarypath, arguments.Cast(), + (DataType)typeof(TResult).ToDataType()!, arguments.Cast().ToArray()); + + return (arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) => + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, + new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10 }); + } + + public static Func Create(string signature, string binarypath, bool bypasshook) + { + var arguments = new[] + { + typeof(TArg1).ToDataType(), + typeof(TArg2).ToDataType(), + typeof(TArg3).ToDataType(), + typeof(TArg4).ToDataType(), + typeof(TArg5).ToDataType(), + typeof(TArg6).ToDataType(), + typeof(TArg7).ToDataType(), + typeof(TArg8).ToDataType(), + typeof(TArg9).ToDataType(), + typeof(TArg10).ToDataType() + }; + + if (arguments.Any(x => x == null)) + { + throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); + } + + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, binarypath, arguments.Cast(), + (DataType)typeof(TResult).ToDataType()!, arguments.Cast().ToArray()); + + return (arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) => + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, + new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10 }); + } + #endregion + + #region Void Actions + + public static Action CreateVoid(string signature) + { + var arguments = Enumerable.Empty().ToArray(); + + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, arguments, + DataType.DATA_TYPE_VOID, arguments.Cast().ToArray()); + + return () => { NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, new object[] { }); }; + } + + public static Action CreateVoid(string signature, bool bypasshook) + { + var arguments = Enumerable.Empty().ToArray(); + + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, arguments, + DataType.DATA_TYPE_VOID, arguments.Cast().ToArray()); + + return () => { NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, new object[] { }); }; + } + + public static Action CreateVoid(string signature) + { + var arguments = new[] + { + typeof(TArg1).ToDataType() + }; + + if (arguments.Any(x => x == null)) + { + throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); + } + + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, arguments.Cast(), + DataType.DATA_TYPE_VOID, arguments.Cast().ToArray()); + + return (arg1) => { NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, new object[] { arg1 }); }; + } + + public static Action CreateVoid(string signature, bool bypasshook) + { + var arguments = new[] + { + typeof(TArg1).ToDataType() + }; + + if (arguments.Any(x => x == null)) + { + throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); + } + + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, arguments.Cast(), + DataType.DATA_TYPE_VOID, arguments.Cast().ToArray()); + + return (arg1) => { NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, new object[] { arg1 }); }; + } + + public static Action CreateVoid(string signature) + { + var arguments = new[] + { + typeof(TArg1).ToDataType(), + typeof(TArg2).ToDataType() + }; + + if (arguments.Any(x => x == null)) + { + throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); + } + + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, arguments.Cast(), + DataType.DATA_TYPE_VOID, arguments.Cast().ToArray()); + + return (arg1, arg2) => + { + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, new object[] { arg1, arg2 }); + }; + } + + public static Action CreateVoid(string signature, bool bypasshook) + { + var arguments = new[] + { + typeof(TArg1).ToDataType(), + typeof(TArg2).ToDataType() + }; + + if (arguments.Any(x => x == null)) + { + throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); + } + + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, arguments.Cast(), + DataType.DATA_TYPE_VOID, arguments.Cast().ToArray()); + + return (arg1, arg2) => + { + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, new object[] { arg1, arg2 }); + }; + } + + public static Action CreateVoid(string signature) + { + var arguments = new[] + { + typeof(TArg1).ToDataType(), + typeof(TArg2).ToDataType(), + typeof(TArg3).ToDataType() + }; + + if (arguments.Any(x => x == null)) + { + throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); + } + + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, arguments.Cast(), + DataType.DATA_TYPE_VOID, arguments.Cast().ToArray()); + + return (arg1, arg2, arg3) => + { + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, new object[] { arg1, arg2, arg3 }); + }; + } + + public static Action CreateVoid(string signature, bool bypasshook) + { + var arguments = new[] + { + typeof(TArg1).ToDataType(), + typeof(TArg2).ToDataType(), + typeof(TArg3).ToDataType() + }; + + if (arguments.Any(x => x == null)) + { + throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); + } + + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, arguments.Cast(), + DataType.DATA_TYPE_VOID, arguments.Cast().ToArray()); + + return (arg1, arg2, arg3) => + { + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, new object[] { arg1, arg2, arg3 }); + }; + } + + public static Action CreateVoid(string signature) + { + var arguments = new[] + { + typeof(TArg1).ToDataType(), + typeof(TArg2).ToDataType(), + typeof(TArg3).ToDataType(), + typeof(TArg4).ToDataType() + }; + + if (arguments.Any(x => x == null)) + { + throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); + } + + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, arguments.Cast(), + DataType.DATA_TYPE_VOID, arguments.Cast().ToArray()); + + return (arg1, arg2, arg3, arg4) => + { + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, + new object[] { arg1, arg2, arg3, arg4 }); + }; + } + + public static Action CreateVoid(string signature, bool bypasshook) + { + var arguments = new[] + { + typeof(TArg1).ToDataType(), + typeof(TArg2).ToDataType(), + typeof(TArg3).ToDataType(), + typeof(TArg4).ToDataType() + }; + + if (arguments.Any(x => x == null)) + { + throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); + } + + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, arguments.Cast(), + DataType.DATA_TYPE_VOID, arguments.Cast().ToArray()); + + return (arg1, arg2, arg3, arg4) => + { + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, + new object[] { arg1, arg2, arg3, arg4 }); + }; + } + + public static Action CreateVoid( + string signature) + { + var arguments = new[] + { + typeof(TArg1).ToDataType(), + typeof(TArg2).ToDataType(), + typeof(TArg3).ToDataType(), + typeof(TArg4).ToDataType(), + typeof(TArg5).ToDataType() + }; + + if (arguments.Any(x => x == null)) + { + throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); + } + + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, arguments.Cast(), + DataType.DATA_TYPE_VOID, arguments.Cast().ToArray()); + + return (arg1, arg2, arg3, arg4, arg5) => + { + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, + new object[] { arg1, arg2, arg3, arg4, arg5 }); + }; + } + + public static Action CreateVoid( + string signature, bool bypasshook) + { + var arguments = new[] + { + typeof(TArg1).ToDataType(), + typeof(TArg2).ToDataType(), + typeof(TArg3).ToDataType(), + typeof(TArg4).ToDataType(), + typeof(TArg5).ToDataType() + }; + + if (arguments.Any(x => x == null)) + { + throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); + } + + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, arguments.Cast(), + DataType.DATA_TYPE_VOID, arguments.Cast().ToArray()); + + return (arg1, arg2, arg3, arg4, arg5) => + { + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, + new object[] { arg1, arg2, arg3, arg4, arg5 }); + }; + } + + public static Action CreateVoid( + string signature) + { + var arguments = new[] + { + typeof(TArg1).ToDataType(), + typeof(TArg2).ToDataType(), + typeof(TArg3).ToDataType(), + typeof(TArg4).ToDataType(), + typeof(TArg5).ToDataType(), + typeof(TArg6).ToDataType() + }; + + if (arguments.Any(x => x == null)) + { + throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); + } + + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, arguments.Cast(), + DataType.DATA_TYPE_VOID, arguments.Cast().ToArray()); + + return (arg1, arg2, arg3, arg4, arg5, arg6) => + { + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, + new object[] { arg1, arg2, arg3, arg4, arg5, arg6 }); + }; + } + + public static Action CreateVoid( + string signature, bool bypasshook) + { + var arguments = new[] + { + typeof(TArg1).ToDataType(), + typeof(TArg2).ToDataType(), + typeof(TArg3).ToDataType(), + typeof(TArg4).ToDataType(), + typeof(TArg5).ToDataType(), + typeof(TArg6).ToDataType() + }; + + if (arguments.Any(x => x == null)) + { + throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); + } + + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, arguments.Cast(), + DataType.DATA_TYPE_VOID, arguments.Cast().ToArray()); + + return (arg1, arg2, arg3, arg4, arg5, arg6) => + { + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, + new object[] { arg1, arg2, arg3, arg4, arg5, arg6 }); + }; + } + + public static Action CreateVoid(string signature) + { + var arguments = new[] + { + typeof(TArg1).ToDataType(), + typeof(TArg2).ToDataType(), + typeof(TArg3).ToDataType(), + typeof(TArg4).ToDataType(), + typeof(TArg5).ToDataType(), + typeof(TArg6).ToDataType(), + typeof(TArg7).ToDataType() + }; + + if (arguments.Any(x => x == null)) + { + throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); + } + + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, arguments.Cast(), + DataType.DATA_TYPE_VOID, arguments.Cast().ToArray()); + + return (arg1, arg2, arg3, arg4, arg5, arg6, arg7) => + { + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, + new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7 }); + }; + } + + public static Action CreateVoid(string signature, bool bypasshook) + { + var arguments = new[] + { + typeof(TArg1).ToDataType(), + typeof(TArg2).ToDataType(), + typeof(TArg3).ToDataType(), + typeof(TArg4).ToDataType(), + typeof(TArg5).ToDataType(), + typeof(TArg6).ToDataType(), + typeof(TArg7).ToDataType() + }; + + if (arguments.Any(x => x == null)) + { + throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); + } + + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, arguments.Cast(), + DataType.DATA_TYPE_VOID, arguments.Cast().ToArray()); + + return (arg1, arg2, arg3, arg4, arg5, arg6, arg7) => + { + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, + new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7 }); + }; + } + + public static Action CreateVoid(string signature) + { + var arguments = new[] + { + typeof(TArg1).ToDataType(), + typeof(TArg2).ToDataType(), + typeof(TArg3).ToDataType(), + typeof(TArg4).ToDataType(), + typeof(TArg5).ToDataType(), + typeof(TArg6).ToDataType(), + typeof(TArg7).ToDataType(), + typeof(TArg8).ToDataType() + }; + + if (arguments.Any(x => x == null)) + { + throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); + } + + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, arguments.Cast(), + DataType.DATA_TYPE_VOID, arguments.Cast().ToArray()); + + return (arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) => + { + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, + new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8 }); + }; + } + + public static Action CreateVoid(string signature, bool bypasshook) + { + var arguments = new[] + { + typeof(TArg1).ToDataType(), + typeof(TArg2).ToDataType(), + typeof(TArg3).ToDataType(), + typeof(TArg4).ToDataType(), + typeof(TArg5).ToDataType(), + typeof(TArg6).ToDataType(), + typeof(TArg7).ToDataType(), + typeof(TArg8).ToDataType() + }; + + if (arguments.Any(x => x == null)) + { + throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); + } + + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, arguments.Cast(), + DataType.DATA_TYPE_VOID, arguments.Cast().ToArray()); + + return (arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) => + { + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, + new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8 }); + }; + } + + public static Action CreateVoid(string signature) + { + var arguments = new[] + { + typeof(TArg1).ToDataType(), + typeof(TArg2).ToDataType(), + typeof(TArg3).ToDataType(), + typeof(TArg4).ToDataType(), + typeof(TArg5).ToDataType(), + typeof(TArg6).ToDataType(), + typeof(TArg7).ToDataType(), + typeof(TArg8).ToDataType(), + typeof(TArg9).ToDataType() + }; + + if (arguments.Any(x => x == null)) + { + throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); + } + + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, arguments.Cast(), + DataType.DATA_TYPE_VOID, arguments.Cast().ToArray()); + + return (arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) => + { + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, + new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 }); + }; + } + + public static Action CreateVoid(string signature, bool bypasshook) + { + var arguments = new[] + { + typeof(TArg1).ToDataType(), + typeof(TArg2).ToDataType(), + typeof(TArg3).ToDataType(), + typeof(TArg4).ToDataType(), + typeof(TArg5).ToDataType(), + typeof(TArg6).ToDataType(), + typeof(TArg7).ToDataType(), + typeof(TArg8).ToDataType(), + typeof(TArg9).ToDataType() + }; + + if (arguments.Any(x => x == null)) + { + throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); + } + + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, arguments.Cast(), + DataType.DATA_TYPE_VOID, arguments.Cast().ToArray()); + + return (arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) => + { + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, + new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 }); + }; + } + + public static Action CreateVoid(string signature) + { + var arguments = new[] + { + typeof(TArg1).ToDataType(), + typeof(TArg2).ToDataType(), + typeof(TArg3).ToDataType(), + typeof(TArg4).ToDataType(), + typeof(TArg5).ToDataType(), + typeof(TArg6).ToDataType(), + typeof(TArg7).ToDataType(), + typeof(TArg8).ToDataType(), + typeof(TArg9).ToDataType(), + typeof(TArg10).ToDataType() + }; + + if (arguments.Any(x => x == null)) + { + throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); + } + + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, arguments.Cast(), + DataType.DATA_TYPE_VOID, arguments.Cast().ToArray()); + + return (arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) => + { + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, + new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10 }); + }; + } + + public static Action CreateVoid(string signature, bool bypasshook) { var arguments = new[] { @@ -585,28 +1658,40 @@ public static Func Create(), - (DataType)typeof(TResult).ToDataType()!, arguments.Cast().ToArray()); + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, arguments.Cast(), + DataType.DATA_TYPE_VOID, arguments.Cast().ToArray()); return (arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) => - NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, + { + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10 }); + }; } + #endregion - #region Void Actions + #region Void Actions Binary + public static Action CreateVoid(string signature, string binarypath) + { + var arguments = Enumerable.Empty().ToArray(); - public static Action CreateVoid(string signature) + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, binarypath, arguments, + DataType.DATA_TYPE_VOID, arguments.Cast().ToArray()); + + return () => { NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, new object[] { }); }; + } + + public static Action CreateVoid(string signature, string binarypath, bool bypasshook) { var arguments = Enumerable.Empty().ToArray(); - var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, arguments, + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, binarypath, arguments, DataType.DATA_TYPE_VOID, arguments.Cast().ToArray()); - return () => { NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, new object[] { }); }; + return () => { NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, new object[] { }); }; } - public static Action CreateVoid(string signature) + public static Action CreateVoid(string signature, string binarypath) { var arguments = new[] { @@ -618,18 +1703,17 @@ public static Action CreateVoid(string signature) throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); } - var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, arguments.Cast(), + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, binarypath, arguments.Cast(), DataType.DATA_TYPE_VOID, arguments.Cast().ToArray()); - return (arg1) => { NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, new object[] { arg1 }); }; + return (arg1) => { NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, new object[] { arg1 }); }; } - public static Action CreateVoid(string signature) + public static Action CreateVoid(string signature, string binarypath, bool bypasshook) { var arguments = new[] { - typeof(TArg1).ToDataType(), - typeof(TArg2).ToDataType() + typeof(TArg1).ToDataType() }; if (arguments.Any(x => x == null)) @@ -637,22 +1721,18 @@ public static Action CreateVoid(string signature) throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); } - var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, arguments.Cast(), + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, binarypath, arguments.Cast(), DataType.DATA_TYPE_VOID, arguments.Cast().ToArray()); - return (arg1, arg2) => - { - NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, new object[] { arg1, arg2 }); - }; + return (arg1) => { NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, new object[] { arg1 }); }; } - public static Action CreateVoid(string signature) + public static Action CreateVoid(string signature, string binarypath) { var arguments = new[] { typeof(TArg1).ToDataType(), - typeof(TArg2).ToDataType(), - typeof(TArg3).ToDataType() + typeof(TArg2).ToDataType() }; if (arguments.Any(x => x == null)) @@ -660,23 +1740,21 @@ public static Action CreateVoid(string throw new Exception($"Invalid argument type(s) supplied to Virtual Function"); } - var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, arguments.Cast(), + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, binarypath, arguments.Cast(), DataType.DATA_TYPE_VOID, arguments.Cast().ToArray()); - return (arg1, arg2, arg3) => + return (arg1, arg2) => { - NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, new object[] { arg1, arg2, arg3 }); + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, new object[] { arg1, arg2 }); }; } - public static Action CreateVoid(string signature) + public static Action CreateVoid(string signature, string binarypath, bool bypasshook) { var arguments = new[] { typeof(TArg1).ToDataType(), - typeof(TArg2).ToDataType(), - typeof(TArg3).ToDataType(), - typeof(TArg4).ToDataType() + typeof(TArg2).ToDataType() }; if (arguments.Any(x => x == null)) @@ -684,26 +1762,22 @@ public static Action CreateVoid(), + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, binarypath, arguments.Cast(), DataType.DATA_TYPE_VOID, arguments.Cast().ToArray()); - return (arg1, arg2, arg3, arg4) => + return (arg1, arg2) => { - NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, - new object[] { arg1, arg2, arg3, arg4 }); + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, new object[] { arg1, arg2 }); }; } - public static Action CreateVoid( - string signature) + public static Action CreateVoid(string signature, string binarypath) { var arguments = new[] { typeof(TArg1).ToDataType(), typeof(TArg2).ToDataType(), - typeof(TArg3).ToDataType(), - typeof(TArg4).ToDataType(), - typeof(TArg5).ToDataType() + typeof(TArg3).ToDataType() }; if (arguments.Any(x => x == null)) @@ -711,27 +1785,22 @@ public static Action CreateVoid(), + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, binarypath, arguments.Cast(), DataType.DATA_TYPE_VOID, arguments.Cast().ToArray()); - return (arg1, arg2, arg3, arg4, arg5) => + return (arg1, arg2, arg3) => { - NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, - new object[] { arg1, arg2, arg3, arg4, arg5 }); + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, new object[] { arg1, arg2, arg3 }); }; } - public static Action CreateVoid( - string signature) + public static Action CreateVoid(string signature, string binarypath, bool bypasshook) { var arguments = new[] { typeof(TArg1).ToDataType(), typeof(TArg2).ToDataType(), - typeof(TArg3).ToDataType(), - typeof(TArg4).ToDataType(), - typeof(TArg5).ToDataType(), - typeof(TArg6).ToDataType() + typeof(TArg3).ToDataType() }; if (arguments.Any(x => x == null)) @@ -739,28 +1808,23 @@ public static Action CreateVoid(), + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, binarypath, arguments.Cast(), DataType.DATA_TYPE_VOID, arguments.Cast().ToArray()); - return (arg1, arg2, arg3, arg4, arg5, arg6) => + return (arg1, arg2, arg3) => { - NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, - new object[] { arg1, arg2, arg3, arg4, arg5, arg6 }); + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, new object[] { arg1, arg2, arg3 }); }; } - public static Action CreateVoid(string signature) + public static Action CreateVoid(string signature, string binarypath) { var arguments = new[] { typeof(TArg1).ToDataType(), typeof(TArg2).ToDataType(), typeof(TArg3).ToDataType(), - typeof(TArg4).ToDataType(), - typeof(TArg5).ToDataType(), - typeof(TArg6).ToDataType(), - typeof(TArg7).ToDataType() + typeof(TArg4).ToDataType() }; if (arguments.Any(x => x == null)) @@ -768,29 +1832,24 @@ public static Action CreateVoid(), + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, binarypath, arguments.Cast(), DataType.DATA_TYPE_VOID, arguments.Cast().ToArray()); - return (arg1, arg2, arg3, arg4, arg5, arg6, arg7) => + return (arg1, arg2, arg3, arg4) => { - NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, - new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7 }); + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, + new object[] { arg1, arg2, arg3, arg4 }); }; } - public static Action CreateVoid(string signature) + public static Action CreateVoid(string signature, string binarypath, bool bypasshook) { var arguments = new[] { typeof(TArg1).ToDataType(), typeof(TArg2).ToDataType(), typeof(TArg3).ToDataType(), - typeof(TArg4).ToDataType(), - typeof(TArg5).ToDataType(), - typeof(TArg6).ToDataType(), - typeof(TArg7).ToDataType(), - typeof(TArg8).ToDataType() + typeof(TArg4).ToDataType() }; if (arguments.Any(x => x == null)) @@ -798,18 +1857,18 @@ public static Action CreateVoid(), + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, binarypath, arguments.Cast(), DataType.DATA_TYPE_VOID, arguments.Cast().ToArray()); - return (arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) => + return (arg1, arg2, arg3, arg4) => { - NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, - new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8 }); + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, + new object[] { arg1, arg2, arg3, arg4 }); }; } - public static Action CreateVoid(string signature) + public static Action CreateVoid( + string signature, string binarypath) { var arguments = new[] { @@ -817,11 +1876,7 @@ public static Action CreateVoid x == null)) @@ -829,18 +1884,18 @@ public static Action CreateVoid(), + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, binarypath, arguments.Cast(), DataType.DATA_TYPE_VOID, arguments.Cast().ToArray()); - return (arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) => + return (arg1, arg2, arg3, arg4, arg5) => { - NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, - new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 }); + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, + new object[] { arg1, arg2, arg3, arg4, arg5 }); }; } - public static Action CreateVoid(string signature) + public static Action CreateVoid( + string signature, string binarypath, bool bypasshook) { var arguments = new[] { @@ -848,12 +1903,7 @@ public static Action CreateVoid x == null)) @@ -861,34 +1911,27 @@ public static Action CreateVoid(), + var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, binarypath, arguments.Cast(), DataType.DATA_TYPE_VOID, arguments.Cast().ToArray()); - return (arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) => + return (arg1, arg2, arg3, arg4, arg5) => { - NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, - new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10 }); + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, + new object[] { arg1, arg2, arg3, arg4, arg5 }); }; } - #endregion - - #region Void Actions Binary - public static Action CreateVoid(string signature, string binarypath) - { - var arguments = Enumerable.Empty().ToArray(); - - var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, binarypath, arguments, - DataType.DATA_TYPE_VOID, arguments.Cast().ToArray()); - - return () => { NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, new object[] { }); }; - } - - public static Action CreateVoid(string signature, string binarypath) + public static Action CreateVoid( + string signature, string binarypath) { var arguments = new[] { - typeof(TArg1).ToDataType() + typeof(TArg1).ToDataType(), + typeof(TArg2).ToDataType(), + typeof(TArg3).ToDataType(), + typeof(TArg4).ToDataType(), + typeof(TArg5).ToDataType(), + typeof(TArg6).ToDataType() }; if (arguments.Any(x => x == null)) @@ -899,15 +1942,24 @@ public static Action CreateVoid(string signature, string binarypat var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, binarypath, arguments.Cast(), DataType.DATA_TYPE_VOID, arguments.Cast().ToArray()); - return (arg1) => { NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, new object[] { arg1 }); }; + return (arg1, arg2, arg3, arg4, arg5, arg6) => + { + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, + new object[] { arg1, arg2, arg3, arg4, arg5, arg6 }); + }; } - public static Action CreateVoid(string signature, string binarypath) + public static Action CreateVoid( + string signature, string binarypath, bool bypasshook) { var arguments = new[] { typeof(TArg1).ToDataType(), - typeof(TArg2).ToDataType() + typeof(TArg2).ToDataType(), + typeof(TArg3).ToDataType(), + typeof(TArg4).ToDataType(), + typeof(TArg5).ToDataType(), + typeof(TArg6).ToDataType() }; if (arguments.Any(x => x == null)) @@ -918,19 +1970,25 @@ public static Action CreateVoid(string signature, st var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, binarypath, arguments.Cast(), DataType.DATA_TYPE_VOID, arguments.Cast().ToArray()); - return (arg1, arg2) => + return (arg1, arg2, arg3, arg4, arg5, arg6) => { - NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, new object[] { arg1, arg2 }); + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, + new object[] { arg1, arg2, arg3, arg4, arg5, arg6 }); }; } - public static Action CreateVoid(string signature, string binarypath) + public static Action CreateVoid(string signature, string binarypath) { var arguments = new[] { typeof(TArg1).ToDataType(), typeof(TArg2).ToDataType(), - typeof(TArg3).ToDataType() + typeof(TArg3).ToDataType(), + typeof(TArg4).ToDataType(), + typeof(TArg5).ToDataType(), + typeof(TArg6).ToDataType(), + typeof(TArg7).ToDataType() }; if (arguments.Any(x => x == null)) @@ -941,20 +1999,25 @@ public static Action CreateVoid(string var virtualFunctionPointer = CreateVirtualFunctionBySignature(signature, binarypath, arguments.Cast(), DataType.DATA_TYPE_VOID, arguments.Cast().ToArray()); - return (arg1, arg2, arg3) => + return (arg1, arg2, arg3, arg4, arg5, arg6, arg7) => { - NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, new object[] { arg1, arg2, arg3 }); + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, + new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7 }); }; } - public static Action CreateVoid(string signature, string binarypath) + public static Action CreateVoid(string signature, string binarypath, bool bypasshook) { var arguments = new[] { typeof(TArg1).ToDataType(), typeof(TArg2).ToDataType(), typeof(TArg3).ToDataType(), - typeof(TArg4).ToDataType() + typeof(TArg4).ToDataType(), + typeof(TArg5).ToDataType(), + typeof(TArg6).ToDataType(), + typeof(TArg7).ToDataType() }; if (arguments.Any(x => x == null)) @@ -965,15 +2028,15 @@ public static Action CreateVoid(), DataType.DATA_TYPE_VOID, arguments.Cast().ToArray()); - return (arg1, arg2, arg3, arg4) => + return (arg1, arg2, arg3, arg4, arg5, arg6, arg7) => { - NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, - new object[] { arg1, arg2, arg3, arg4 }); + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, + new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7 }); }; } - public static Action CreateVoid( - string signature, string binarypath) + public static Action CreateVoid(string signature, string binarypath) { var arguments = new[] { @@ -981,7 +2044,10 @@ public static Action CreateVoid x == null)) @@ -992,15 +2058,15 @@ public static Action CreateVoid(), DataType.DATA_TYPE_VOID, arguments.Cast().ToArray()); - return (arg1, arg2, arg3, arg4, arg5) => + return (arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) => { - NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, - new object[] { arg1, arg2, arg3, arg4, arg5 }); + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, + new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8 }); }; } - public static Action CreateVoid( - string signature, string binarypath) + public static Action CreateVoid(string signature, string binarypath, bool bypasshook) { var arguments = new[] { @@ -1009,7 +2075,9 @@ public static Action CreateVoid x == null)) @@ -1020,15 +2088,15 @@ public static Action CreateVoid(), DataType.DATA_TYPE_VOID, arguments.Cast().ToArray()); - return (arg1, arg2, arg3, arg4, arg5, arg6) => + return (arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) => { - NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, - new object[] { arg1, arg2, arg3, arg4, arg5, arg6 }); + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, + new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8 }); }; } - public static Action CreateVoid(string signature, string binarypath) + public static Action CreateVoid(string signature, string binarypath) { var arguments = new[] { @@ -1038,7 +2106,9 @@ public static Action CreateVoid x == null)) @@ -1049,15 +2119,15 @@ public static Action CreateVoid(), DataType.DATA_TYPE_VOID, arguments.Cast().ToArray()); - return (arg1, arg2, arg3, arg4, arg5, arg6, arg7) => + return (arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) => { - NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, - new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7 }); + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, + new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 }); }; } - public static Action CreateVoid(string signature, string binarypath) + public static Action CreateVoid(string signature, string binarypath, bool bypasshook) { var arguments = new[] { @@ -1068,7 +2138,8 @@ public static Action CreateVoid x == null)) @@ -1079,15 +2150,15 @@ public static Action CreateVoid(), DataType.DATA_TYPE_VOID, arguments.Cast().ToArray()); - return (arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) => + return (arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) => { - NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, - new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8 }); + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, + new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 }); }; } - public static Action CreateVoid(string signature, string binarypath) + public static Action CreateVoid(string signature, string binarypath) { var arguments = new[] { @@ -1099,7 +2170,8 @@ public static Action CreateVoid x == null)) @@ -1110,15 +2182,15 @@ public static Action CreateVoid(), DataType.DATA_TYPE_VOID, arguments.Cast().ToArray()); - return (arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) => + return (arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) => { - NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, - new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 }); + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, false, + new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10 }); }; } public static Action CreateVoid(string signature, string binarypath) + TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10>(string signature, string binarypath, bool bypasshook) { var arguments = new[] { @@ -1144,7 +2216,7 @@ public static Action CreateVoid { - NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, + NativeAPI.ExecuteVirtualFunction(virtualFunctionPointer, bypasshook, new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10 }); }; } diff --git a/src/core/function.cpp b/src/core/function.cpp index c61335dee..313d47550 100644 --- a/src/core/function.cpp +++ b/src/core/function.cpp @@ -111,7 +111,7 @@ template ReturnType CallHelper(Function func, void CallHelperVoid(DCCallVM* vm, void* addr) { dcCallVoid(vm, (void*)addr); } -void ValveFunction::Call(ScriptContext& script_context, int offset) +void ValveFunction::Call(ScriptContext& script_context, int offset, bool bypass) { if (!IsCallable()) return; @@ -174,55 +174,61 @@ void ValveFunction::Call(ScriptContext& script_context, int offset) } } + void* m_target = m_ulAddr; + if (bypass && m_trampoline) + { + m_target = m_trampoline; + } + switch (m_eReturnType) { case DATA_TYPE_VOID: - CallHelperVoid(g_pCallVM, m_ulAddr); + CallHelperVoid(g_pCallVM, m_target); break; case DATA_TYPE_BOOL: - script_context.SetResult(CallHelper(dcCallBool, g_pCallVM, m_ulAddr)); + script_context.SetResult(CallHelper(dcCallBool, g_pCallVM, m_target)); break; case DATA_TYPE_CHAR: - script_context.SetResult(CallHelper(dcCallChar, g_pCallVM, m_ulAddr)); + script_context.SetResult(CallHelper(dcCallChar, g_pCallVM, m_target)); break; case DATA_TYPE_UCHAR: - script_context.SetResult(CallHelper(dcCallChar, g_pCallVM, m_ulAddr)); + script_context.SetResult(CallHelper(dcCallChar, g_pCallVM, m_target)); break; case DATA_TYPE_SHORT: - script_context.SetResult(CallHelper(dcCallShort, g_pCallVM, m_ulAddr)); + script_context.SetResult(CallHelper(dcCallShort, g_pCallVM, m_target)); break; case DATA_TYPE_USHORT: - script_context.SetResult(CallHelper(dcCallShort, g_pCallVM, m_ulAddr)); + script_context.SetResult(CallHelper(dcCallShort, g_pCallVM, m_target)); break; case DATA_TYPE_INT: - script_context.SetResult(CallHelper(dcCallInt, g_pCallVM, m_ulAddr)); + script_context.SetResult(CallHelper(dcCallInt, g_pCallVM, m_target)); break; case DATA_TYPE_UINT: - script_context.SetResult(CallHelper(dcCallInt, g_pCallVM, m_ulAddr)); + script_context.SetResult(CallHelper(dcCallInt, g_pCallVM, m_target)); break; case DATA_TYPE_LONG: - script_context.SetResult(CallHelper(dcCallLong, g_pCallVM, m_ulAddr)); + script_context.SetResult(CallHelper(dcCallLong, g_pCallVM, m_target)); break; case DATA_TYPE_ULONG: - script_context.SetResult(CallHelper(dcCallLong, g_pCallVM, m_ulAddr)); + script_context.SetResult(CallHelper(dcCallLong, g_pCallVM, m_target)); break; case DATA_TYPE_LONG_LONG: - script_context.SetResult(CallHelper(dcCallLongLong, g_pCallVM, m_ulAddr)); + script_context.SetResult(CallHelper(dcCallLongLong, g_pCallVM, m_target)); break; case DATA_TYPE_ULONG_LONG: - script_context.SetResult(CallHelper(dcCallLongLong, g_pCallVM, m_ulAddr)); + script_context.SetResult(CallHelper(dcCallLongLong, g_pCallVM, m_target)); break; case DATA_TYPE_FLOAT: - script_context.SetResult(CallHelper(dcCallFloat, g_pCallVM, m_ulAddr)); + script_context.SetResult(CallHelper(dcCallFloat, g_pCallVM, m_target)); break; case DATA_TYPE_DOUBLE: - script_context.SetResult(CallHelper(dcCallDouble, g_pCallVM, m_ulAddr)); + script_context.SetResult(CallHelper(dcCallDouble, g_pCallVM, m_target)); break; case DATA_TYPE_POINTER: - script_context.SetResult(CallHelper(dcCallPointer, g_pCallVM, m_ulAddr)); + script_context.SetResult(CallHelper(dcCallPointer, g_pCallVM, m_target)); break; case DATA_TYPE_STRING: - script_context.SetResult(CallHelper(dcCallPointer, g_pCallVM, m_ulAddr)); + script_context.SetResult(CallHelper(dcCallPointer, g_pCallVM, m_target)); break; default: assert(!"Unknown function return type!"); @@ -287,6 +293,7 @@ void ValveFunction::AddHook(CallbackT callable, bool post) g_HookMap[hook] = this; hook->addCallback(dyno::HookType::Post, (dyno::HookHandler*)&HookHandler); hook->addCallback(dyno::HookType::Pre, (dyno::HookHandler*)&HookHandler); + m_trampoline = hook->getOriginal(); if (post) { @@ -316,6 +323,7 @@ void ValveFunction::RemoveHook(CallbackT callable, bool post) #endif }); g_HookMap[hook] = this; + m_trampoline = nullptr; if (post) { diff --git a/src/core/function.h b/src/core/function.h index f30cd9ee3..0c0aebb59 100644 --- a/src/core/function.h +++ b/src/core/function.h @@ -93,11 +93,12 @@ class ValveFunction void SetOffset(int offset) { m_offset = offset; } void SetSignature(const char* signature) { m_signature = signature; } - void Call(ScriptContext& args, int offset = 0); + void Call(ScriptContext& args, int offset = 0, bool bypass = false); void AddHook(CallbackT callable, bool post); void RemoveHook(CallbackT callable, bool post); void* m_ulAddr; + void* m_trampoline; std::vector m_Args; DataType_t m_eReturnType; diff --git a/src/scripting/natives/natives_memory.cpp b/src/scripting/natives/natives_memory.cpp index a31d0957b..03f73341a 100644 --- a/src/scripting/natives/natives_memory.cpp +++ b/src/scripting/natives/natives_memory.cpp @@ -127,6 +127,7 @@ void UnhookFunction(ScriptContext& script_context) void ExecuteVirtualFunction(ScriptContext& script_context) { auto function = script_context.GetArgument(0); + auto bypasshook = script_context.GetArgument(1); if (!function) { @@ -134,7 +135,7 @@ void ExecuteVirtualFunction(ScriptContext& script_context) return; } - function->Call(script_context, 1); + function->Call(script_context, 2, bypasshook); } int GetNetworkVectorSize(ScriptContext& script_context) diff --git a/src/scripting/natives/natives_memory.yaml b/src/scripting/natives/natives_memory.yaml index 7d8c9610b..e67e38865 100644 --- a/src/scripting/natives/natives_memory.yaml +++ b/src/scripting/natives/natives_memory.yaml @@ -2,7 +2,7 @@ CREATE_VIRTUAL_FUNCTION: pointer:pointer,vtableOffset:int,numArguments:int,retur CREATE_VIRTUAL_FUNCTION_BY_SIGNATURE: pointer:pointer,binaryName:string,signature:string,numArguments:int,returnType:int,arguments:object[] -> pointer HOOK_FUNCTION: function:pointer, hook:callback, post:bool -> void UNHOOK_FUNCTION: function:pointer, hook:callback, post:bool -> void -EXECUTE_VIRTUAL_FUNCTION: function:pointer,arguments:object[] -> any +EXECUTE_VIRTUAL_FUNCTION: function:pointer, bypass:bool, arguments:object[] -> any FIND_SIGNATURE: modulePath:string, signature:string -> pointer GET_NETWORK_VECTOR_SIZE: vec:pointer -> int GET_NETWORK_VECTOR_ELEMENT_AT: vec:pointer, index:int -> pointer