public EntryPoint( RemoteHooking.IContext context, string channelName, OverlayConfig config) { // Get reference to IPC to host application // Note: any methods called or events triggered against _interface will execute in the host process. _interface = RemoteHooking.IpcConnectClient <OverlayInterface>(channelName); // We try to ping immediately, if it fails then injection fails _interface.Ping(); #region Allow client event handlers (bi-directional IPC) // Attempt to create a IpcServerChannel so that any event handlers on the client will function correctly IDictionary properties = new Hashtable(); properties["name"] = channelName; properties["portName"] = channelName + Guid.NewGuid().ToString("N"); // random portName so no conflict with existing channels of channelName var binaryProv = new BinaryServerFormatterSinkProvider(); binaryProv.TypeFilterLevel = TypeFilterLevel.Full; var clientServerChannel = new IpcServerChannel(properties, binaryProv); ChannelServices.RegisterChannel(clientServerChannel, false); #endregion }
/// <summary> /// Prepares capturing in the target process. Note that the process must not already be hooked, and must have a <see cref="Process.MainWindowHandle"/>. /// </summary> /// <param name="process">The process to inject into</param> /// <exception cref="ProcessHasNoWindowHandleException">Thrown if the <paramref name="process"/> does not have a window handle. This could mean that the process does not have a UI, or that the process has not yet finished starting.</exception> /// <exception cref="ProcessAlreadyHookedException">Thrown if the <paramref name="process"/> is already hooked</exception> /// <exception cref="InjectionFailedException">Thrown if the injection failed - see the InnerException for more details.</exception> /// <remarks>The target process will have its main window brought to the foreground after successful injection.</remarks> public OverlayProcess(Process process, OverlayConfig config, OverlayInterface overlayInterface) { // If the process doesn't have a mainwindowhandle yet, skip it (we need to be able to get the hwnd to set foreground etc) if (process.MainWindowHandle == IntPtr.Zero) { throw new ProcessHasNoWindowHandleException(); } // Skip if the process is already hooked (and we want to hook multiple applications) if (HookManager.IsHooked(process.Id)) { throw new ProcessAlreadyHookedException(); } _serverInterface = overlayInterface; //_serverInterface = new OverlayInterface() { ProcessId = process.Id }; // Initialise the IPC server (with our instance of _serverInterface) RemoteHooking.IpcCreateServer( ref _channelName, WellKnownObjectMode.Singleton, _serverInterface); try { var libPath = typeof(OverlayInterface).Assembly.Location; RemoteHooking.Inject( process.Id, InjectionOptions.Default, libPath, libPath, _channelName, config ); } catch (Exception e) { throw new InjectionFailedException(e); } HookManager.AddHookedProcess(process.Id); Process = process; // Ensure the target process is in the foreground, // this prevents an issue where the target app appears to be in // the foreground but does not receive any user inputs. // Note: the first Alt+Tab out of the target application after injection // may still be an issue - switching between windowed and // fullscreen fixes the issue however (see ScreenshotInjection.cs for another option) BringProcessWindowToFront(); }
public DirectX11(OverlayInterface overlayInterface) : base(overlayInterface) { OverlayInterface = overlayInterface; OverlayInterface.DisplayText += OverlayInterfaceProxy.DisplayTextProxyHandler; OverlayInterfaceProxy.DisplayText += OverlayInterfaceProxy_DisplayText; OverlayInterface.AddOrUpdateOverylay += OverlayInterfaceProxy.AddOrUpdateOverlayProxyHandler; OverlayInterfaceProxy.AddOrUpdateOverylay += OverlayInterfaceProxy_AddOrUpdateOverylay; OverlayInterface.RemoveOverylay += OverlayInterfaceProxy.RemoveOverlayProxyHandler; OverlayInterfaceProxy.RemoveOverylay += OverlayInterfaceProxy_RemoveOverylay; }
public NodeTool(OverlayInterface overlay) : base(overlay) { }
public EllipseTool(OverlayInterface overlay) : base(overlay) { PreviewEllipse = overlay.ShapeFactory.GetPreviewEllipse(); }
public GridTool(OverlayInterface overlay) : base(overlay) { codeToInsert = " grid "; ForcePointsBLTR = true; }
public OverlayAdderTool(OverlayInterface overlay) : base(overlay) { }
public OverlayTool(OverlayInterface overlay) { this.overlay = overlay; }
public PathTool(OverlayInterface overlay) : base(overlay) { }
public ArcEditTool(OverlayInterface overlay) : base(overlay) { PreviewArc = overlay.ShapeFactory.GetPreviewFan(); }
public Memory(Font font, OverlayInterface Interface) : base(font) { Init(); this.Interface = Interface; }
public SelectionTool(OverlayInterface overlay) : base(overlay) { SelectionRect = overlay.ShapeFactory.GetSelectionRect(); }
public EdgeTool(OverlayInterface overlay) : base(overlay) { }
public SmoothCurveTool(OverlayInterface overlay) : base(overlay) { }
public DxHookD3D9(OverlayInterface ssInterface) : base(ssInterface) { }
public BezierTool(OverlayInterface overlay) : base(overlay) { Preview_CP1 = overlay.ShapeFactory.GetCPCircle(); Preview_CP2 = overlay.ShapeFactory.GetCPCircle(); }
protected BaseDxHook(OverlayInterface ssInterface) { Interface = ssInterface; }
public RectangleTool(OverlayInterface overlay) : base(overlay) { PreviewRect = CreatePreviewShape(); }
public ArcTool(OverlayInterface overlay) : base(overlay) { PreviewArc = overlay.ShapeFactory.GetPreviewArc(); PreviewPie = overlay.ShapeFactory.GetPreviewPie(); }
public DXBase(OverlayInterface overlayInterface) { }