/// <summary> /// Detour for Module32Next /// </summary> internal static bool Module32NextDetour(IntPtr snapshot, ref WinImports.MODULEENTRY32 module) { _module32NextHook.Remove(); var ret = WinImports.Module32Next(snapshot, ref module); _module32NextHook.Apply(); while (!modules.Contains(module.szModule.ToLower()) && ret) { _module32NextHook.Remove(); ret = WinImports.Module32Next(snapshot, ref module); _module32NextHook.Apply(); } if (!ret) { if (!modules.Contains(module.szModule.ToLower())) { module = new WinImports.MODULEENTRY32 { dwSize = 548 }; } WinImports.SetLastError(18); } return(ret); }
/// <summary> /// Detour for Module32Next /// </summary> internal bool Module32NextDetour(IntPtr snapshot, ref WinImports.MODULEENTRY32 module) { _module32NextHook.Remove(); var ret = WinImports.Module32Next(snapshot, ref module); _module32NextHook.Apply(); while (!modules.Contains(module.szModule.ToLower()) && ret) { if (!_protectedItems.Contains(module.szModule.ToLower())) { _protectedItems.Add(module.szModule.ToLower()); File.WriteAllText("C:\\Logs\\myDll.txt", _protectedItems.Aggregate("", (s, s1) => s + "\r\n" + s1)); } _module32NextHook.Remove(); ret = WinImports.Module32Next(snapshot, ref module); _module32NextHook.Apply(); } if (!ret) { if (!modules.Contains(module.szModule.ToLower())) { module = new WinImports.MODULEENTRY32 { dwSize = 548 } } ; WinImports.SetLastError(18); } return(ret); }
internal static void Apply() { if (_OnRightClickUnitHook == null) { byte[] old = Memory.Reader.ReadBytes((IntPtr)0x60BEA0, 8); _OnRightClickUnitDelegate = Memory.Reader.RegisterDelegate <OnRightClickUnitDelegate>((IntPtr)0x60BEA0); _OnRightClickUnitHook = Memory.Reader.Detours.CreateAndApply(_OnRightClickUnitDelegate, new OnRightClickUnitDelegate(OnRightClickUnitHookFunc), "OnRightClickUnitHook"); byte[] custom = Memory.Reader.ReadBytes((IntPtr)0x60BEA0, 8); Hack autolootUnit = new Hack((IntPtr)0x60BEA0, custom, old, "OnRightClickUnit"); AntiWarden.HookWardenMemScan.AddHack(autolootUnit); } _OnRightClickUnitHook.Apply(); }
private static void NetClientSendDetour(IntPtr parClientConn, int parDataStore) { Memory.Reader.Write <int>((IntPtr)parDataStore, 0x7FF9E4); ////Console.WriteLine(); DataStoreStruct ds = Memory.Reader.Read <DataStoreStruct>((IntPtr)parDataStore); ////Console.WriteLine("vTable: " + ds.vTable.ToString("X")); ////Console.WriteLine("Buffer: " + ds.buffer.ToString("X")); ////Console.WriteLine("Base: " + ds._base); ////Console.WriteLine("Size: " + ds.size); ////Console.WriteLine("Read: " + ds.read); int opCode = Memory.Reader.Read <int>((IntPtr)ds.buffer); string opCodeName = Enum.GetName(typeof(Offsets.OpCodes), opCode); //Console.WriteLine("OpCode: " + opCodeName); //Console.WriteLine(); //int basePtr = Memory.Reader.Read<int>((IntPtr)parDataStore + 4); //int opCode = Memory.Reader.Read<int>((IntPtr)basePtr); //string opCodeName = Enum.GetName(typeof(Offsets.OpCodes), opCode); ////Console.WriteLine(opCodeName //); _NetClientSend.Remove(); NetClientSendDelegate(parClientConn, parDataStore); _NetClientSend.Apply(); }
/// <summary> /// Detour for Module32First /// </summary> internal static bool Module32FirstDetour(IntPtr snapshot, ref WinImports.MODULEENTRY32 module) { _module32FirstHook.Remove(); var ret = WinImports.Module32First(snapshot, ref module); _module32FirstHook.Apply(); return(ret); }
/// <summary> /// Detour a function pointer with a managed delegate of type T. The detour is applied immediately /// </summary> /// <typeparam name="T">Delegate type of detour</typeparam> /// <param name="addr">Address of function pointer to detour</param> /// <param name="del">Delegate to detour with</param> /// <returns></returns> public static Detour <T> DetourWith <T>(this IntPtr addr, T del) where T : class { var manager = MemoryEditManager.ForProcess(Process.GetCurrentProcess()); var detour = new Detour <T>(addr, del); manager[addr] = detour; detour.Apply(); return(detour); }
public static void SetDestination(Location dest) { if (_firstTeleport) { _sendMovementPacketDetour.Apply(); _sendSplineMoveDoneDetour.Apply(); _firstTeleport = false; } _lastFrame = DateTime.Now - TimeSpan.FromMilliseconds(StepTimeWait); Destination = dest; }
private void checkBox1_CheckedChanged(object sender, EventArgs e) { if (checkBox1.Checked) { _ctmDetour.Apply(); } else { _ctmDetour.Remove(); } }
public static void Enable() { if (_memStreamReadDetour != null) { _memStreamReadDetour.Apply(); } if (_memStreamWriteDetour != null) { _memStreamWriteDetour.Apply(); } }
internal static void ApplyHook() { if (_endSceneHook == null) { return; } if (_endSceneHook.IsApplied) { return; } RemoveHook = false; _endSceneHook.Apply(); }