/// <summary> /// Injects enabled hooks to the desired process id /// </summary> public static string Inject(int processId, BridgeEventType enabledHooks = (BridgeEventType)uint.MaxValue) { string channelName = null; Console.WriteLine("Injecting to {0}!", processId); try { // Register assemblies to the GAC Config.Register( "AOHook library by Demoder", "Demoder.AoHookBridge.dll" ); RemoteHooking.IpcCreateServer <HookInterface>( ref channelName, WellKnownObjectMode.SingleCall); RemoteHooking.Inject( processId, "Demoder.AoHookBridge.dll", "Demoder.AoHookBridge.dll", channelName, enabledHooks, processId); return(channelName); } catch (Exception ex) { Console.WriteLine("Injector::Inject: Exception:"); Console.WriteLine(ex.ToString()); } return(null); }
/// <summary> /// Injects enabled hooks to the desired process id /// </summary> public static string Inject(int processId, BridgeEventType enabledHooks = (BridgeEventType)uint.MaxValue) { Debug.WriteLine("Injecting to {0}", processId); string channelName = null; try { //Config.Register("AOHook library by Demoder", typeof(AoHookBridge.HookInterface).Assembly.Location); //Config.Register("AOHook library by Demoder", System.Reflection.Assembly.GetEntryAssembly().Location + "\\AoHookBridge.dll"); RemoteHooking.IpcCreateServer<HookInterface>(ref channelName, WellKnownObjectMode.SingleCall); RemoteHooking.Inject( processId, InjectionOptions.DoNotRequireStrongName, AppDomain.CurrentDomain.BaseDirectory + "\\AoHookBridge.dll", AppDomain.CurrentDomain.BaseDirectory + "\\AoHookBridge.dll", channelName, enabledHooks, processId ); return channelName; } catch (Exception ex) { Debug.WriteLine("Injection failed: " + ex.ToString()); } return null; }
/// <summary> /// Injects enabled hooks to the desired process id /// </summary> public static string Inject(int processId, BridgeEventType enabledHooks = (BridgeEventType)uint.MaxValue) { Debug.WriteLine("Injecting to {0}", processId); string channelName = null; try { //Config.Register("AOHook library by Demoder", typeof(AoHookBridge.HookInterface).Assembly.Location); //Config.Register("AOHook library by Demoder", System.Reflection.Assembly.GetEntryAssembly().Location + "\\AoHookBridge.dll"); RemoteHooking.IpcCreateServer <HookInterface>(ref channelName, WellKnownObjectMode.SingleCall); RemoteHooking.Inject( processId, InjectionOptions.DoNotRequireStrongName, AppDomain.CurrentDomain.BaseDirectory + "\\AoHookBridge.dll", AppDomain.CurrentDomain.BaseDirectory + "\\AoHookBridge.dll", channelName, enabledHooks, processId ); return(channelName); } catch (Exception ex) { Debug.WriteLine("Injection failed: " + ex.ToString()); } return(null); }
/// <summary> /// Spawned within the client (hooked process) /// </summary> /// <param name="context"></param> /// <param name="channelName"></param> public EasyHookEntryPoint(RemoteHooking.IContext context, string channelName, BridgeEventType enabledHooks, int processId) { // Retrieve a reference to our interface this.hookInterface = RemoteHooking.IpcConnectClient <HookInterface>(channelName); // Validate connection this.hookInterface.Ping(); this.enabledHooks = enabledHooks; this.ProcessID = processId; }
/// <summary> /// Spawned within the client (hooked process) /// </summary> /// <param name="context"></param> /// <param name="channelName"></param> public EasyHookEntryPoint(RemoteHooking.IContext context, string channelName, BridgeEventType enabledHooks, int processId) { // Retrieve a reference to our interface this.hookInterface = RemoteHooking.IpcConnectClient<HookInterface>(channelName); // Validate connection this.hookInterface.Ping(); this.enabledHooks = enabledHooks; this.ProcessID = processId; }
protected BridgeEventArgs(BridgeEventType type) { this.ProcessId = RemoteHooking.GetCurrentProcessId(); this.EventType = type; this.Time = DateTime.Now; }
/// <summary> /// Installs hooks into AO, and shuffles data across the Alpha Bridge. /// </summary> /// <param name="context"></param> /// <param name="channelName"></param> public void Run(RemoteHooking.IContext context, string channelName, BridgeEventType enabledHooks, int processId) { this.enabledHooks = enabledHooks; try { #region Install hooks // FrameProcess this.aoHookFrameProcess = LocalHook.Create( LocalHook.GetProcAddress("Interfaces.dll", "?FrameProcess@Client_t@@QAEXXZ"), new API.Interfaces.Client_t.AoFrameProcessDelegate(Hooks.Interfaces.Client_t.AoFrameProcess), this ); this.aoHookFrameProcess.ThreadACL.SetExclusiveACL(new int[] { 0 }); // Retrieve quest/mission locator information when uploaded to map this.aoHookGetQuestWorldPos = LocalHook.Create(LocalHook.GetProcAddress("Interfaces.dll", "?N3Msg_GetQuestWorldPos@N3InterfaceModule_t@@QBE_NABVIdentity_t@@AAV2@AAVVector3_t@@2@Z"), new API.Interfaces.N3InterfaceModule.GetQuestWorldPosDelegate(Hooks.Interfaces.N3InterfaceModule.GetQuestWorldPos), this ); this.aoHookGetQuestWorldPos.ThreadACL.SetExclusiveACL(new int[] { 0 }); #endregion } catch (Exception ex) { this.hookInterface.ReportException(ex); return; } // Notify that we've successfully installed a hook. Pass along character ID if available. this.SendBridgeEvent(new HookStateChangeEventArgs(true)); #region Push messages across Alpha Bridge try { this.hookTimer = Stopwatch.StartNew(); while (!this.aborted) { bool sendPing = true; try { sendPing = this.ProcessEventQueue(); } catch (Exception ex) { this.hookInterface.ReportException(ex); } if (sendPing) { this.hookInterface.Ping(); } // Limit to 30 updates per second. Thread.Sleep(33); } } catch (Exception ex) { try { this.hookInterface.ReportException(ex); } catch { /* Bridge is dead; Can't report exception. */ } } #endregion #region Uninstall hooks try { // Uninstall hooks if (this.aoHookFrameProcess != null) { this.aoHookFrameProcess.Dispose(); } if (this.aoHookGetQuestWorldPos != null) { this.aoHookGetQuestWorldPos.Dispose(); } } catch { } try { this.SendBridgeEvent(new HookStateChangeEventArgs(false)); this.ProcessEventQueue(); } catch { } #endregion }