public bool Initialize(IntPtr targetWindow, string targetWindowName, int width, int height, int fps) { m_width = width; m_height = height; m_length = m_width * m_height * 4; m_desiredFPS = fps; m_targetWindow = targetWindow; m_targetWindowName = targetWindowName; // get working dir for loading D3D9Hook.dll System.Reflection.Assembly a = System.Reflection.Assembly.GetExecutingAssembly(); string dllPath = a.Location; int pos = dllPath.LastIndexOf('\\'); dllPath = dllPath.Remove(pos); dllPath += "\\D3D9Hook.dll"; // inject into target process (must be a directx appliction using d3d9.dll) if (!ProcessInjector.DoProcessInjection(m_targetWindow, m_targetWindowName, dllPath)) { return(false); } // Set D3D9Hook.dll capture size PinvokeD3D9Hook.SetCapSize(m_width, m_height); return(true); }
public void Stop() { Trace.TraceInformation("D3D9SurfaceCapturer Stop"); //tell D3D9Hook to stop capturing PinvokeD3D9Hook.StopCapturing(); m_stop = true; }
public void Start() { Trace.TraceInformation("D3D9SurfaceCapturer Start"); //tell D3D9Hook to start capturing PinvokeD3D9Hook.StartCapturing(); Thread th = new Thread(new ThreadStart(CaptureThread)); th.IsBackground = true; th.Start(); }
// gets bytes(surface) from d3d9hook.dll public Byte[] GetBuffer() { try { Byte[] buffer = new Byte[m_length]; IntPtr pdataout = Marshal.UnsafeAddrOfPinnedArrayElement(buffer, 0); int size = PinvokeD3D9Hook.FillBuffer(pdataout, m_length); return(buffer); } catch (Exception ex) { Trace.TraceInformation(ex.ToString()); } return(null); //bad }