public BaseDXHook(CaptureInterface ssInterface) { this.Interface = ssInterface; this.Timer = new Stopwatch(); this.Timer.Start(); this.FPS = new FramesPerSecond(); }
/// <summary> /// Prepares capturing in the target process. Note that the process must not already be hooked, and must have a MainWindowHandle/>. /// </summary> /// <param name="process">The process to inject into</param> /// <param name="config"></param> /// <param name="captureInterface"></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 CaptureProcess(Process process, CaptureConfig config, CaptureInterface captureInterface) { // 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(); } Process = process; Process.EnableRaisingEvents = true; captureInterface.ProcessId = Process.Id; CaptureInterface = captureInterface; //_serverInterface = new CaptureInterface() { ProcessId = process.Id }; // Initialise the IPC server (with our instance of _serverInterface) RemoteHooking.IpcCreateServer( ref channelName, WellKnownObjectMode.Singleton, CaptureInterface); try { // Inject DLL into target process RemoteHooking.Inject( Process.Id, InjectionOptions.Default, typeof(CaptureInterface).Assembly.Location, // 32-bit (the same because AnyCPU) could use different assembly that links to 32-bit C++ helper dll typeof(CaptureInterface).Assembly.Location, // 64-bit (the same because AnyCPU) could use different assembly that links to 64-bit C++ helper dll // the optional parameter list... channelName, // The name of the IPC channel for the injected assembly to connect to config ); } catch (Exception e) { throw new InjectionFailedException(e); } HookManager.AddHookedProcess(Process.Id); // 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(); Process.Exited += (_, _) => { Dispose(); }; }
public static void Capture(IntPtr hwnd, Direct3DVersion direct3DVersion = Direct3DVersion.AUTO_DETECT) { NativeUtils.GetWindowThreadProcessId(hwnd, out var processID); var process = Process.GetProcessById(processID); var captureConfig = new CaptureConfig { Direct3DVersion = direct3DVersion, ShowOverlay = true, CaptureMouseEvents = true, CaptureKeyboardEvents = true }; var captureInterface = new CaptureInterface(); captureInterface.RemoteMessage += e => { Debug.WriteLine(e.Message); }; captureInterface.Connected += () => { captureInterface.DrawOverlayInGame(new Overlay { Elements = new List <IOverlayElement> { new RectangleElement { Colour = Color.FromArgb(Color.Gray.ToArgb() ^ (0x33 << 24)), Location = new Point(0, 0), Width = -1, Height = -1 }, new RectangleMouseHookElement { Colour = Color.FromArgb(Color.Green.ToArgb() ^ (0x33 << 24)), Width = 0, Height = 0 }, new FramesPerSecond(new Font("Arial", 16, FontStyle.Bold)) { Location = new Point(0, 0), Color = Color.Red, AntiAliased = true, Text = "{0:N0} FPS" } }, Hidden = false }); }; var captureProcess = new CaptureProcess(process, captureConfig, captureInterface); while (!captureProcess.IsDisposed) { Thread.Sleep(500); } Debug.WriteLine("Disconnected from DirectX Hook"); }
public EntryPoint( EasyHook.RemoteHooking.IContext context, String channelName, CaptureConfig config) { // Get reference to IPC to host application // Note: any methods called or events triggered against _interface will execute in the host process. _interface = EasyHook.RemoteHooking.IpcConnectClient <CaptureInterface>(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 System.Collections.IDictionary properties = new System.Collections.Hashtable(); properties["name"] = channelName; properties["portName"] = channelName + Guid.NewGuid().ToString("N"); // random portName so no conflict with existing channels of channelName System.Runtime.Remoting.Channels.BinaryServerFormatterSinkProvider binaryProv = new System.Runtime.Remoting.Channels.BinaryServerFormatterSinkProvider(); binaryProv.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full; System.Runtime.Remoting.Channels.Ipc.IpcServerChannel _clientServerChannel = new System.Runtime.Remoting.Channels.Ipc.IpcServerChannel(properties, binaryProv); System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(_clientServerChannel, false); #endregion }
private void FinishCapture() { if (this._activeSettings.UseScaling) { int num = 0; do { if (!this.SaveImage(this._outputImageSize.Width, this._outputImageSize.Height, ImageFormat.Png, Main.SavePath + (object)Path.DirectorySeparatorChar + "Captures" + (object)Path.DirectorySeparatorChar + this._activeSettings.OutputName + ".png")) { GC.Collect(); Thread.Sleep(5); ++num; Console.WriteLine(Language.GetTextValue("Error.CaptureError")); } else { goto label_5; } }while (num <= 5); Console.WriteLine(Language.GetTextValue("Error.UnableToCapture")); } label_5: this._outputData = (byte[])null; this._scaledFrameData = (byte[])null; Main.GlobalTimerPaused = false; CaptureInterface.EndCamera(); if (this._scaledFrameBuffer != null) { ((GraphicsResource)this._scaledFrameBuffer).Dispose(); this._scaledFrameBuffer = (RenderTarget2D)null; } this._activeSettings = (CaptureSettings)null; }
private void FinishCapture() { if (_activeSettings.UseScaling) { int num = 0; do { if (!SaveImage(_outputImageSize.Width, _outputImageSize.Height, ImageFormat.Png, "Data\\Captures" + Path.DirectorySeparatorChar + _activeSettings.OutputName + ".png")) { GC.Collect(); Thread.Sleep(5); ++num; Console.WriteLine("An error occured while saving the capture. Attempting again..."); } } while (num <= 5); Console.WriteLine("Unable to capture."); _outputData = null; _scaledFrameData = null; Main.GlobalTimerPaused = false; CaptureInterface.EndCamera(); if (_scaledFrameBuffer != null) { _scaledFrameBuffer.Dispose(); _scaledFrameBuffer = null; } _activeSettings = null; } }
public DXHookD3D9(CaptureInterface ssInterface, int captureWidth, int captureHeight) : base(ssInterface, captureWidth, captureHeight) { privateDataTimer = new Timer(); privateDataTimer.Elapsed += PrivateDataTimer_Elapsed; privateDataTimer.Interval = 1500; }
public static void ExitToMenu(bool save = true) { IngameOptions.Close(); Main.menuMode = 10; if (save) { WorldGen.SaveAndQuit((Action)null); } else { ThreadPool.QueueUserWorkItem(new WaitCallback(delegate(object state) { Main.invasionProgress = 0; Main.invasionProgressDisplayLeft = 0; Main.invasionProgressAlpha = 0f; Main.StopTrackedSounds(); CaptureInterface.ResetFocus(); Main.ActivePlayerFileData.StopPlayTimer(); Main.gameMenu = true; if (Main.netMode != 0) { Netplay.disconnect = true; Main.netMode = 0; } Main.fastForwardTime = false; Main.UpdateSundial(); Main.menuMode = 0; }), (Action)null); } }
private bool HookProcess(ProcStatus procStatus) { if (procStatus.ProcessId == 0) { return(false); } Direct3DVersion direct3DVersion = Direct3DVersion.AutoDetect; CaptureConfig cc = new CaptureConfig() { Direct3DVersion = direct3DVersion, ShowOverlay = showFPSToolStripMenuItem.Checked }; FileUnblocker.Unblock("EasyHook32Svc.exe"); FileUnblocker.Unblock("EasyHook64Svc.exe"); var captureInterface = new CaptureInterface(); captureInterface.RemoteMessage += CaptureInterface_RemoteMessage; procStatus.CaptureProcess = new CaptureProcess(procStatus.Process, cc, captureInterface); PrintStatus("* Hooked " + procStatus.Name); hookedProcesses.Add(procStatus.ProcessId, procStatus); AddExitHook(procStatus); return(true); }
private void FinishCapture() { if (_activeSettings.UseScaling) { int num = 0; while (!SaveImage(_outputImageSize.Width, _outputImageSize.Height, ImageFormat.Png, Main.SavePath + Path.DirectorySeparatorChar.ToString() + "Captures" + Path.DirectorySeparatorChar.ToString() + _activeSettings.OutputName + ".png")) { GC.Collect(); Thread.Sleep(5); num++; Console.WriteLine(Language.GetTextValue("Error.CaptureError")); if (num > 5) { Console.WriteLine(Language.GetTextValue("Error.UnableToCapture")); break; } } } _outputData = null; _scaledFrameData = null; Main.GlobalTimerPaused = false; CaptureInterface.EndCamera(); if (_scaledFrameBuffer != null) { _scaledFrameBuffer.Dispose(); _scaledFrameBuffer = null; } _activeSettings = null; }
/// <summary> /// Class constructor. /// </summary> /// <param name="ContentSource"></param> public LoadableSourceContent(CaptureInterface.ContentInterface.IContentInterface ContentSource) { contentSource = ContentSource; Initialize(); Shared.SharedData.CameraCaptureChanged += OnCameraCaptureChanged; }
public BaseDXHook(CaptureInterface ssInterface, int captureWidth, int captureHeight) { this.Interface = ssInterface; this.producer = new CircularBuffer(name: "MySharedMemory"); this.captureWidth = captureWidth; this.captureHeight = captureHeight; Interface.ResolutionChanged += InterfaceEventProxy.ResolutionChangeHandler; InterfaceEventProxy.ResolutionChange += new ResolutionChangeEvent(InterfaceEventProxy_ResolutionChange); }
private void FinishCapture() { if (this._activeSettings.UseScaling) { int num = 0; do { int width = this._outputImageSize.Width; int height = this._outputImageSize.Height; ImageFormat png = ImageFormat.Png; string[] strArray = new string[6]; strArray[0] = Main.SavePath; int index1 = 1; char directorySeparatorChar = Path.DirectorySeparatorChar; string str1 = directorySeparatorChar.ToString(); strArray[index1] = str1; int index2 = 2; string str2 = "Captures"; strArray[index2] = str2; int index3 = 3; directorySeparatorChar = Path.DirectorySeparatorChar; string str3 = directorySeparatorChar.ToString(); strArray[index3] = str3; int index4 = 4; string outputName = this._activeSettings.OutputName; strArray[index4] = outputName; int index5 = 5; string str4 = ".png"; strArray[index5] = str4; string filename = string.Concat(strArray); if (!this.SaveImage(width, height, png, filename)) { GC.Collect(); Thread.Sleep(5); ++num; Console.WriteLine(Language.GetTextValue("Error.CaptureError")); } else { goto label_5; } }while (num <= 5); Console.WriteLine(Language.GetTextValue("Error.UnableToCapture")); } label_5: this._outputData = (byte[])null; this._scaledFrameData = (byte[])null; Main.GlobalTimerPaused = false; CaptureInterface.EndCamera(); if (this._scaledFrameBuffer != null) { ((GraphicsResource)this._scaledFrameBuffer).Dispose(); this._scaledFrameBuffer = (RenderTarget2D)null; } this._activeSettings = (CaptureSettings)null; }
public override void KeyboardInput(KeyboardInputEventArgs e, CaptureInterface captureInterface) { if (e.Key != Keys.Escape) { return; } Hidden = true; captureInterface.Disconnect(); }
public BaseDXHook(CaptureInterface ssInterface) { this.Interface = ssInterface; this.Timer = new Stopwatch(); this.Timer.Start(); this.FPS = new FramesPerSecond(); Interface.ScreenshotRequested += InterfaceEventProxy.ScreenshotRequestedProxyHandler; Interface.DisplayText += InterfaceEventProxy.DisplayTextProxyHandler; InterfaceEventProxy.ScreenshotRequested += new ScreenshotRequestedEvent(InterfaceEventProxy_ScreenshotRequested); InterfaceEventProxy.DisplayText += new DisplayTextEvent(InterfaceEventProxy_DisplayText); }
protected virtual void Dispose(bool disposing) { if (!_disposed) { if (disposing) { CaptureInterface.Disconnect(); HookManager.RemoveHookedProcess(Process.Id); } _disposed = true; } }
/// <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 CaptureProcess(Process process, CaptureConfig config, CaptureInterface captureInterface) { // 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(); } captureInterface.ProcessId = process.Id; this._serverInterface = captureInterface; //_serverInterface = new CaptureInterface() { ProcessId = process.Id }; // Initialise the IPC server (with our instance of _serverInterface) this._screenshotServer = RemoteHooking.IpcCreateServer <CaptureInterface>( ref this._channelName, WellKnownObjectMode.Singleton, this._serverInterface); try { var dllName = typeof(CaptureInterface).Assembly.GetName().Name + ".dll"; var location = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, dllName); // Inject DLL into target process RemoteHooking.Inject( process.Id, InjectionOptions.NoService | InjectionOptions.DoNotRequireStrongName, location, //"Capture.dll", // 32-bit version (the same because AnyCPU) could use different assembly that links to 32-bit C++ helper dll location, //"Capture.dll", // 64-bit version (the same because AnyCPU) could use different assembly that links to 64-bit C++ helper dll // the optional parameter list... this._channelName, // The name of the IPC channel for the injected assembly to connect to config ); } catch (Exception e) { throw new InjectionFailedException(e); } HookManager.AddHookedProcess(process.Id); this.Process = process; }
public void AttachProcess() { Process[] processes = Process.GetProcessesByName("HuniePop 2 - Double Date"); foreach (Process process in processes) { // Simply attach to the first one found. // 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) { continue; } // Skip if the process is already hooked (and we want to hook multiple applications) if (HookManager.IsHooked(process.Id)) { continue; } Direct3DVersion direct3DVersion = Direct3DVersion.AutoDetect; CaptureConfig cc = new CaptureConfig() { Direct3DVersion = direct3DVersion, ShowOverlay = true }; processId = process.Id; _process = process; var captureInterface = new CaptureInterface(); captureInterface.RemoteMessage += new MessageReceivedEvent(CaptureInterface_RemoteMessage); _captureProcess = new CaptureProcess(process, cc, captureInterface); break; } Thread.Sleep(10); if (_captureProcess == null) { this.parent.launcHuniePop2Listener(); hooked = false; } else { this.message.Foreground = new SolidColorBrush(Colors.DarkGreen); this.message.Text = "Attached to game"; hooked = true; } }
private bool AttachHookToProcess() { if (this.attached) { return(true); } Process[] processes = Process.GetProcessesByName(HEARTHSTONE_PROCESS_NAME); if (processes.Length <= 0) { Log.Debug("GetProcessesByName failed."); return(false); } var process = processes[0]; // Check incompatible modules: foreach (ProcessModule module in process.Modules) { if (module.ModuleName.ToLower().StartsWith("rtsshooks")) { Publish(new IncompatibleHooksFound("RTSSHooks", "MSI Afterburner / Riva Tuner Statistics Server")); } } //if (process.MainWindowHandle == IntPtr.Zero) //{ // Log.Debug("Could not get MainWindowHandle."); // return false; //} if (HookManager.IsHooked(process.Id)) { return(true); } if (captureProcess != null) { Log.Warn("Call DettachHookFromProcess first"); DettachHookFromProcess(); extraDelay = 200; Thread.Sleep(200); } captureInterface = new CaptureInterface(); captureInterface.RemoteMessage += this.CaptureInterfaceOnRemoteMessage; this.captureProcess = new CaptureProcess(process, captureConfig, captureInterface); this.attached = true; return(true); }
private void AttachProcess() { string exeName = "Bejeweled3"; Process[] processes = Process.GetProcessesByName(exeName); foreach (Process process in processes) { // Simply attach to the first one found. // 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) { continue; } // Skip if the process is already hooked (and we want to hook multiple applications) if (HookManager.IsHooked(process.Id)) { continue; } Direct3DVersion direct3DVersion = Direct3DVersion.AutoDetect; CaptureConfig cc = new CaptureConfig() { Direct3DVersion = direct3DVersion, ShowOverlay = cbDrawOverlay.Checked }; capturing.ProcessId = process.Id; capturing.Process = process; var captureInterface = new CaptureInterface(); captureInterface.RemoteMessage += new MessageReceivedEvent(CaptureInterface_RemoteMessage); capturing.CaptureProcess = new CaptureProcess(process, cc, captureInterface); break; } Thread.Sleep(10); if (capturing.CaptureProcess == null) { MessageBox.Show("No executable found matching: '" + exeName + "'"); } else { btnLoadTest.Enabled = true; btnCapture.Enabled = true; } }
private void InitServerChannel() { // Initialise the IPC server (with our instance of _serverInterface) try { string channelName = "hslog"; //this._interface = IpcUtil.IpcConnectClient<CaptureInterface>(channelName); //this._interface.Ping(); if (this._interface != null) { this._interface.Disconnect(); RemotingServices.Disconnect(this._interface); this._interface = null; } this._interface = new CaptureInterface(); this._server = IpcUtil.IpcCreateServer <CaptureInterface>( ref channelName, WellKnownObjectMode.Singleton, this._interface); //// Attempt to create a IpcServerChannel so that any event handlers on the client will function correctly //System.Collections.IDictionary properties = new System.Collections.Hashtable(); //properties["name"] = channelName + ".rem"; //properties["port"] = 19191 + 1; //// random portName so no conflict with existing channels of channelName //var binaryProv = new BinaryServerFormatterSinkProvider // { // TypeFilterLevel = // System.Runtime.Serialization.Formatters.TypeFilterLevel // .Full // }; //this._clientServerChannel = new TcpServerChannel(properties, binaryProv); //ChannelServices.RegisterChannel(this._clientServerChannel, false); //this._clientEventProxy = new ClientCaptureInterfaceEventProxy(); //this._interface.RemoteMessage += this._clientEventProxy.RemoteMessageHandler; //this._clientEventProxy.RemoteMessage += ServerInterfaceOnRemoteMessage; CaptureInterface.RemoteMessage += ServerInterfaceOnRemoteMessage; CaptureInterface.Published += ServerInterfaceOnPublished; } finally { } Log.Info("Remoting service channel setup."); }
private void Quit(Action callback = null, bool saveWorld = false, bool savePlayer = false) { ThreadPool.QueueUserWorkItem(new WaitCallback(QuitCallBack), callback); void QuitCallBack(object threadContext) { if (Main.netMode == NetmodeID.SinglePlayer) { WorldFile.CacheSaveTime(); } Main.invasionProgress = 0; Main.invasionProgressDisplayLeft = 0; Main.invasionProgressAlpha = 0f; Main.menuMode = 10; Main.gameMenu = true; Main.StopTrackedSounds(); CaptureInterface.ResetFocus(); Main.ActivePlayerFileData.StopPlayTimer(); if (savePlayer) { Player.SavePlayer(Main.ActivePlayerFileData, false); } if (Main.netMode == NetmodeID.SinglePlayer) { if (saveWorld) { WorldFile.saveWorld(); } } else { Netplay.disconnect = true; Main.netMode = NetmodeID.SinglePlayer; } Main.fastForwardTime = false; Main.UpdateSundial(); Main.menuMode = 0; if (threadContext != null) { ((Action)threadContext)(); } } }
public void StartHook() { var exeName = "GTA5"; Process[] processes = Process.GetProcessesByName(exeName); foreach (var process in processes) { if (process == null) { continue; } if (HookManager.IsHooked(process.Id)) { continue; } Direct3DVersion direct3dVersion = Direct3DVersion.Direct3D11; /* * switch (gameSettings.Graphics.DX_Version.Value) * { * case 0: * direct3dVersion = Direct3DVersion.Direct3D10; * break; * case 1: * direct3dVersion = Direct3DVersion.Direct3D10_1; * break; * case 2: * direct3dVersion = Direct3DVersion.Direct3D11; * break; * }*/ CaptureConfig cc = new CaptureConfig() { Direct3DVersion = direct3dVersion, ShowOverlay = true, }; _gtaProcessId = process.Id; _gtaProcess = process; var captureInterface = new CaptureInterface(); _captureProcess = new CaptureProcess(process, cc, captureInterface); //Thread.Sleep(5000); //_captureProcess.CaptureInterface.DisplayInGameText("HELLO FROM PLAYMultiV!", TimeSpan.FromSeconds(60)); //_captureProcess.CaptureInterface.up } }
public void AddHooks() { if (HookManager.IsHooked(_process.Id)) { return; } var captureConfig = new CaptureConfig { Direct3DVersion = Direct3DVersion.AutoDetect, ShowOverlay = true }; var captureInterface = new CaptureInterface(); captureInterface.RemoteMessage += CaptureInterfaceOnRemoteMessage; _captureProcess = new CaptureProcess(_process, captureConfig, captureInterface); }
public BaseDXHook(CaptureInterface ssInterface) { Interface = ssInterface; Timer = new Stopwatch(); Timer.Start(); FPS = new FramesPerSecond(); OverlayElements = new List <IOverlayElement>(); Interface.ScreenshotRequested += InterfaceEventProxy.ScreenshotRequestedProxyHandler; Interface.DisplayText += InterfaceEventProxy.DisplayTextProxyHandler; Interface.DrawOverlay += InterfaceEventProxy.DrawOverlayProxyHandler; InterfaceEventProxy.ScreenshotRequested += InterfaceEventProxy_ScreenshotRequested; InterfaceEventProxy.DisplayText += InterfaceEventProxy_DisplayText; InterfaceEventProxy.DrawOverlay += InterfaceEventProxy_DrawOverlay; }
private void AttachProcess() { string exeName = Path.GetFileNameWithoutExtension("Europa_Client.exe"); Process[] processes = Process.GetProcessesByName(exeName); foreach (Process process in processes) { // Simply attach to the first one found. // 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) { continue; } // Skip if the process is already hooked (and we want to hook multiple applications) if (HookManager.IsHooked(process.Id)) { continue; } Direct3DVersion direct3DVersion = Direct3DVersion.AutoDetect; CaptureConfig cc = new CaptureConfig() { Direct3DVersion = direct3DVersion, ShowOverlay = true, WallhackEnabled = checkBox1.Checked, WeaponEnabled = checkBox2.Checked }; processId = process.Id; _process = process; var captureInterface = new CaptureInterface(); captureInterface.RemoteMessage += new MessageReceivedEvent(CaptureInterface_RemoteMessage); _captureProcess = new CaptureProcess(process, cc, captureInterface); break; } Thread.Sleep(10); if (_captureProcess == null) { MessageBox.Show("No executable found matching: '" + exeName + "'"); } }
private void CreateCaptureProcess(Process process) { _process = process; Direct3DVersion direct3DVersion = Direct3DVersion.Direct3D10; if (rbDirect3D11.Checked) { direct3DVersion = Direct3DVersion.Direct3D11; } else if (rbDirect3D10_1.Checked) { direct3DVersion = Direct3DVersion.Direct3D10_1; } else if (rbDirect3D10.Checked) { direct3DVersion = Direct3DVersion.Direct3D10; } else if (rbDirect3D9.Checked) { direct3DVersion = Direct3DVersion.Direct3D9; } else if (rbAutodetect.Checked) { direct3DVersion = Direct3DVersion.AutoDetect; } var cc = new CaptureConfig { Direct3DVersion = direct3DVersion, ShowOverlay = cbDrawOverlay.Checked, TestThisShit = 300 }; var captureInterface = new CaptureInterface(); if (frm2 != null) { frm2.Close(); frm2.Dispose(); } frm2 = new form2JT(captureInterface); captureInterface.RemoteMessage += CaptureInterface_RemoteMessage; _captureProcess = new CaptureProcess(process, cc, captureInterface); }
public ImGuiRender(Device dev, NativeMethods.Rect windowRect, CaptureInterface _interface, Process currentProcess) { device = dev; _windowHandle = currentProcess.MainWindowHandle; hp = hookProc; var cp = Process.GetCurrentProcess(); var mName = Path.GetFileNameWithoutExtension(cp.MainModule.ModuleName); hHook = SetWindowsHookEx(HookType.WH_GETMESSAGE, hp, GetModuleHandle(mName), cp.Threads[0].Id); ImGui.CreateContext(); var io = ImGui.GetIO(); io.DisplaySize = new Vector2(windowRect.Right - windowRect.Left, windowRect.Bottom - windowRect.Top); ImGui.GetStyle().WindowBorderSize = 0; PrepareTextureImGui(); SetupKeyMapping(io); }
public void AttachProcess(string proc) { string exeName = Path.GetFileNameWithoutExtension(proc); Process[] processes = Process.GetProcessesByName(exeName); foreach (Process process in processes) { // Simply attach to the first one found. // 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) { continue; } // Skip if the process is already hooked (and we want to hook multiple applications) if (HookManager.IsHooked(process.Id)) { continue; } Direct3DVersion direct3DVersion = Direct3DVersion.AutoDetect; CaptureConfig cc = new CaptureConfig() { Direct3DVersion = direct3DVersion, ShowOverlay = true }; ProcessID = process.Id; Process = process; var captureInterface = new CaptureInterface(); CaptureProcess = new CaptureProcess(process, cc, captureInterface); break; } Thread.Sleep(10); if (CaptureProcess == null) { MessageBox.Show("No executable found matching: '" + exeName + "'"); Environment.Exit(0); } }
private void AttachProcess() { string exeName = Path.GetFileNameWithoutExtension(_config.HellbladeExecutablePath); Process[] processes = Process.GetProcessesByName(exeName); foreach (Process process in processes) { // Simply attach to the first one found. // 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) { continue; } // Skip if the process is already hooked (and we want to hook multiple applications) if (HookManager.IsHooked(process.Id)) { continue; } CaptureConfig cc = new CaptureConfig() { Direct3DVersion = Direct3DVersion.AutoDetect, ShowOverlay = false }; _process = process; var captureInterface = new CaptureInterface(); captureInterface.RemoteMessage += new MessageReceivedEvent(CaptureInterface_RemoteMessage); _captureProcess = new CaptureProcess(process, cc, captureInterface); break; } Thread.Sleep(10); if (_captureProcess == null) { throw new InvalidOperationException($"No executable found matching: '{exeName}''"); } _isAttached = true; }
public DXHookD3D9SharedMem(CaptureInterface ssInterface) : base(ssInterface) { var security = new MutexSecurity(); security.AddAccessRule(new MutexAccessRule(new SecurityIdentifier(WellKnownSidType.WorldSid, null), MutexRights.Synchronize | MutexRights.Modify, AccessControlType.Allow)); bool created; sharedMemMutexes = new[] { new Mutex(false, "Global\\DXHookD3D9Shared0", out created, security), new Mutex(false, "Global\\DXHookD3D9Shared1", out created, security) }; var ewsecurity = new EventWaitHandleSecurity(); ewsecurity.AddAccessRule(new EventWaitHandleAccessRule(new SecurityIdentifier(WellKnownSidType.WorldSid, null), EventWaitHandleRights.FullControl, AccessControlType.Allow)); captureWaitHandle = new EventWaitHandle(false, EventResetMode.ManualReset, "Global\\DXHookD3D9Capture", out created, ewsecurity); hookReadyWaitHandle = new EventWaitHandle(false, EventResetMode.ManualReset, "Global\\DXHookD3D9CaptureReady", out created, ewsecurity); }
/// <summary> /// The state of a camera capture is changed. /// </summary> /// <param name="CameraState">New state of the camera capture.</param> /// <param name="CameraCapture">Fired in this camera capture.</param> private void OnCameraStateChanged(CaptureInterface.Enumeration.CameraState CameraState, CameraCapture.Model.CameraCapture.CameraCapture CameraCapture) { if (Shared.SharedData.CameraCapture != null) { Shared.SharedData.CameraCapture.OnWPFGrayFrame -= OnWPFFrame; Shared.SharedData.CameraCapture.OnWPFColorFrame -= OnWPFFrame; Shared.SharedData.CameraCapture.OnWPFSmallGrayFrame -= OnWPFFrame; Shared.SharedData.CameraCapture.OnWPFSmoothedGrayFrame -= OnWPFFrame; switch (CameraState) { case global::CaptureInterface.Enumeration.CameraState.Open: { Shared.SharedData.CameraCapture.OnWPFGrayFrame += OnWPFFrame; } break; } } }
/// <summary> /// The host container is set a delegate to this method on startup. /// By call this, we can set the receive color depth image. /// </summary> /// <param name="OpenCVImageRequest">The set delegate on strtup.</param> public void InterestInImageType(CaptureInterface.Delegates.OpenCVImageRequest OpenCVImageRequest) { /* Keep request of we will later changed the color depth. */ openCVImageRequest = OpenCVImageRequest; /* We are interest in grayscale images. */ OpenCVImageRequest(CaptureInterface.Enumeration.ColorDepth.Gray); }
/// <summary> /// Send back the manipulated shared image. /// </summary> /// <param name="SharedImageResult">The manipulated shared image.</param> public void SendManipulateSharedImageBack(CaptureInterface.Delegates.SendManipulateSharedImageBackDelegate SharedImageResult) { sharedImageResultSendBackDelegate = SharedImageResult; }
/// <summary> /// On receive a manipulation to the global shared image. /// </summary> /// <param name="SharedImage">Received manipulated global image.</param> private static void OnReceiveManipulateSharedImage(CaptureInterface.ContentInterface.IContentInterface Source, Image<Gray, Byte> SharedImage) { Shared.SharedData.SharedImage = SharedImage; /* We get the manipulated image. So we have to update on all other contents. */ foreach (var item in presentationContents.OfType<Contents.LoadableSourceContent.LoadableSourceContent>().Where(x => x.ContentSource != Source)) { item.ContentSource.SharedImage = SharedImage; } }
/// <summary> /// Set the current rectengle of the roi selection. /// </summary> /// <param name="SelectionRectengle">Set roi to all available items.</param> public static void SetSelectionRectengle(CaptureInterface.DrawControl.ISelectionRectengle SelectionRectengle) { Shared.SharedData.CurrentRectangle = SelectionRectengle; foreach (var item in presentationContents) { if (item is Contents.LoadableSourceContent.LoadableSourceContent) { (item as Contents.LoadableSourceContent.LoadableSourceContent).ContentSource.SelectionRectengle = SelectionRectengle; } } /* Also set to the shared image. */ if (Shared.SharedData.SharedImage != null) { Rectangle calcrectangle = new Rectangle((int)SelectionRectengle.RectangleLeft, (int)SelectionRectengle.RectangleTop, (int)SelectionRectengle.RectangleWidth, (int)SelectionRectengle.RectangleHeight); Shared.SharedData.SharedImage = Shared.ImageMethods.GetLastGrayCaptureImage().Copy(calcrectangle); } }