/// <summary> /// Init the hook and set enabled to true /// </summary> private SignalEvent_0Hook() { Console.WriteLine("SignalEvent_0Hook loaded"); // Pointer the delegate to our c# function _SignalEvent_0Delegate = _EventSignalHook; // get PTR for our c# function var addrToDetour = Marshal.GetFunctionPointerForDelegate(_SignalEvent_0Delegate); // Alloc space for the ASM part of our detour string[] asmCode = { SendOvers.EventSignal0[0], SendOvers.EventSignal0[1], SendOvers.EventSignal0[2], SendOvers.EventSignal0[3], SendOvers.EventSignal0[4], SendOvers.EventSignal0[5], SendOvers.EventSignal0[6].Replace("[|addr|]","0x" + ((uint)addrToDetour).ToString("X")), SendOvers.EventSignal0[7], SendOvers.EventSignal0[8], SendOvers.EventSignal0[9].Replace("[|addr|]","0x" + ((uint)Offsets.Hooks.SignalEvent_0 + 6).ToString("X")), }; // Inject the asm code which calls our c# function var codeCave = Memory.InjectAsm(asmCode, "EventSignal_0Detour"); // set the jmp from WoWs code to my injected code Memory.InjectAsm((uint)Offsets.Hooks.SignalEvent_0, "jmp " + codeCave, "EventSignal_0DetourJmp"); }
/// <summary> /// Init the hook and set enabled to true /// </summary> private SignalEvent_0Hook() { Console.WriteLine("SignalEvent_0Hook loaded"); // Pointer the delegate to our c# function _SignalEvent_0Delegate = _EventSignalHook; // get PTR for our c# function var addrToDetour = Marshal.GetFunctionPointerForDelegate(_SignalEvent_0Delegate); // Alloc space for the ASM part of our detour string[] asmCode = { "PUSH ESI", "CALL 0x007040D0", "pushfd", "pushad", "mov EDI, [EDI]", "push EDI", "call " + "0x" + ((uint)addrToDetour).ToString("X"), "popad", "popfd", "jmp " + "0x" + ((uint)Offsets.Hooks.SignalEvent_0 + 6).ToString("X") }; // Inject the asm code which calls our c# function var codeCave = Memory.InjectAsm(asmCode, "EventSignal_0Detour"); // set the jmp from WoWs code to my injected code Memory.InjectAsm((uint)Offsets.Hooks.SignalEvent_0, "jmp " + codeCave, "EventSignal_0DetourJmp"); }