/// <summary> /// Gets the main thread of a given process. /// </summary> /// <param name="hWindowHandle">The window handle of the process whose main thread will be returned.</param> /// <returns>Returns the main thread on success, null on failure.</returns> public static ProcessThread GetMainThread(IntPtr hWindowHandle) { if (hWindowHandle == IntPtr.Zero) { return(null); } return(GetMainThread(SProcess.GetProcessFromWindow(hWindowHandle))); }
/// <summary> /// Gets the main thread ID of a given process. /// </summary> /// <param name="hWindowHandle">The window handle of the process whose main thread ID will be returned.</param> /// <returns>Returns non-zero on success, zero on failure.</returns> public static int GetMainThreadId(IntPtr hWindowHandle) { if (hWindowHandle == IntPtr.Zero) { return(0); } return(GetMainThreadId(SProcess.GetProcessFromWindow(hWindowHandle))); }
/// <summary> /// Opens a process for interaction. /// </summary> /// <param name="WindowHandle">Window handle of main window of process with which we wish to interact.</param> /// <returns>Returns true on success, false on failure.</returns> public bool Open(IntPtr WindowHandle) { if (WindowHandle == IntPtr.Zero) { return(false); } return(this.Open(SProcess.GetProcessFromWindow(WindowHandle))); }
//##OPEN############################################################### /// <summary> /// Opens a process and its main thread for interaction. /// </summary> /// <param name="ProcessId">Process Id of process with which we wish to interact.</param> /// <returns>Returns true on success, false on failure.</returns> public bool Open(int ProcessId) { if (ProcessId == 0) { return(false); } if (ProcessId == m_ProcessId) { return(true); } if (m_bProcessOpen) { this.CloseProcess(); } if (SetDebugPrivileges) { System.Diagnostics.Process.EnterDebugMode(); } m_bProcessOpen = (m_hProcess = SProcess.OpenProcess(ProcessId)) != IntPtr.Zero; if (m_bProcessOpen) { m_ProcessId = ProcessId; m_hWnd = SWindow.FindWindowByProcessId(ProcessId); m_Modules = System.Diagnostics.Process.GetProcessById(m_ProcessId).Modules; m_MainModule = m_Modules[0]; if (Asm == null) { Asm = new ManagedFasm(m_hProcess); } else { Asm.SetProcessHandle(m_hProcess); } } return(m_bProcessOpen); }
/// <summary> /// Allows interfacing with an external process (memory manipulation, thread manipulation, etc.) /// </summary> /// <param name="WindowHandle">Window handle of main window of process with which we wish to interact.</param> public BlackMagic(IntPtr WindowHandle) : this(SProcess.GetProcessFromWindow(WindowHandle)) { }