class ByPass
{
public delegate uint GetPointer(int Index);
public static unsafe void CreateBypass(uint CShell)
{
Console.WriteLine("Bypass Experimenting");
Type BypassType = Type.GetType("ByPass");
MethodInfo ReturnPointer = BypassType.GetMethod("Bypass");
//Console.WriteLine("Function Pointer: " + Storage.DecToHex(ReturnPointer.MethodHandle.GetFunctionPointer().ToInt32()));
//var func = (GetPointer)Marshal.GetDelegateForFunctionPointer((IntPtr)Bypass, typeof(GetPointer));
Console.WriteLine("Done");
}
public static uint Bypass(int GunIndex)
{
return 0;
}
}
Type BypassType = Type.GetType("ByPass");
Type BypassType = Type.GetType("ByPass.Class1");
public delegate uint GetPointer(int GunIndex); public static unsafe void CreateBypass(uint CShell) { Console.WriteLine("Bypass Experimenting"); Type BypassType = Type.GetType("RabirDimensionalBeast.ByPass"); MethodInfo ReturnPointer = BypassType.GetMethod("Bypass"); Console.WriteLine("Function Pointer: 0x" + Storage.DecToHex(ReturnPointer.MethodHandle.GetFunctionPointer().ToInt32())); uint FunctionPointer = (uint)ReturnPointer.MethodHandle.GetFunctionPointer().ToInt32(); var func = (GetPointer)Marshal.GetDelegateForFunctionPointer((IntPtr)FunctionPointer, typeof(GetPointer)); func(4); Console.WriteLine("Done"); } public static uint Bypass(int GunIndex) { Console.WriteLine("Access: " + GunIndex.ToString()); return 0; }
Done Access: 0 Function Pointer: 0x2AC440 Bypass Experimenting
IntPtr Func(string FunctionName, object[] Parameters)
{
Type BypassType;
MethodInfo ReturnPointer;
foreach (Type T in Assembly.GetExecutingAssembly().GetTypes())
{
BypassType = T;
if ((ReturnPointer = BypassType.GetMethod(FunctionName)) != null)
{
ReturnPointer.Invoke(Activator.CreateInstance(BypassType), Parameters);
return ReturnPointer.MethodHandle.GetFunctionPointer();
}
}
return IntPtr.Zero;
}
public static uint Bypass(int GunIndex)
{
Console.WriteLine("Access: " + GunIndex.ToString());
return 0;
}
IntPtr FunctionPointer = Func("Bypass", new object[] { 4 });
uint FunctionPointer = (uint)ReturnPointer.MethodHandle.GetFunctionPointer().ToInt32();
var func = (GetPointer)Marshal.GetDelegateForFunctionPointer((IntPtr)FunctionPointer, typeof(GetPointer));
var func = (GetPointer)Marshal.GetDelegateForFunctionPointer(ReturnPointer.MethodHandle.GetFunctionPointer(), typeof(GetPointer));
IntPtr FunctionPointer = Func("Bypass", new object[] { 4 }); //Output 4: Working...
Console.WriteLine("ByPass Pointer: 0x"+Storage.DecToHex((int)FunctionPointer));
Console.WriteLine("Call With Pointer: ");
var func = (GetPointer)Marshal.GetDelegateForFunctionPointer(FunctionPointer, typeof(GetPointer)); //Output: 0; Function be called, parameter error...
func(4);
namespace ConsoleApplication1
{
using System;
class Program
{
public delegate uint GetPointer(int nIndex);
public static void CreateBypass(uint uiShell)
{
Console.WriteLine("== Bypass Start ==");
var baseType = Type.GetType("ConsoleApplication1.Program");
if (baseType != null)
{
var methodInfo = baseType.GetMethod("Bypass");
if (methodInfo != null)
{
methodInfo.Invoke(null, new object[] { 0x04 });
}
}
Console.WriteLine("== Bypass Finish ==");
}
public static uint Bypass(int nIndex)
{
Console.WriteLine("[Bypass] Index was: {0}", nIndex);
return 0;
}
static void Main(string[] args)
{
CreateBypass(4);
}
}
}
DWORD GetPointerForWeapon(int WeaponIndex)
{
return &WeaponArray[WeaponIndex];
}
byte[][] FakeWeaponArray = new byte[999][];
uint GetPointerForFakeWeapon(int WeaponIndex)
{
fixed (byte* Ptr = FakeWeaponArray[WeaponIndex]
return (uint)Ptr;
}
call CShell.dll + 0x99A45;
call CShell.dll + 0xAAAD5;
DWORD GetPointerForWeapon(int WeaponIndex)
{
return &WeaponArray[WeaponIndex];
}
uint GetPointerForWeapon(int WeaponIndex)
{
return (uint)Marshal.ReadInt32(WeaponArrayPtr, (WeaponIndex * 4));
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate uint GtePtrDelegate(int GunIndex);
E8 860CE9FF - call CShell.dll+226600 //This is the official code...
// Direct3DCreate9 delegate..
[UnmanagedFunctionPointer(CallingConvention.StdCall, CharSet = CharSet.Auto, SetLastError = true)]
delegate IntPtr delegate_Direct3DCreate9(ushort SDKVersion);
// Creating delegate to my call..
var lpFunctionDelegate = new delegate_Direct3DCreate9(Mine_Direct3DCreate9);
// My new hooked callback..
public IntPtr Mine_Direct3DCreate9(ushort SDKVersion)
{
Debug.Write("[Mine_Direct3DCreate9] Hooked Direct3DCreate9 called.");
// Call the original function here..
// Handle return as needed here..
}
// When writing the push and retn use the function pointer to our delegate..
this.m_vPatchedBytes.Add(0x68);
this.m_vPatchedBytes.AddRange(BitConverter.GetBytes(Marshal.GetFunctionPointerForDelegate(lpFunctionDelegate).ToInt32()));
this.m_vPatchedBytes.Add(0xC3);
8B 44 24 04 - mov eax,[esp+04] 81 EC A0000000 - sub esp,000000A0 83 F8 FF - cmp eax,FF 0F84 F7010000 - je CShell.dll+395B6A 56 - push esi 50 - push eax E8 860CE9FF - call CShell.dll+226600 //****************** This one, 5 bytes, i need 6 for the push + retn... 8B F0 - mov esi,eax 83 C4 04 - add esp,04 85 F6 - test esi,esi 0F84 E2010000 - je CShell.dll+395B69