private void ConnectionThreadEntry() { try { string username = System.Security.Principal.WindowsIdentity.GetCurrent().Name; m_Connection = StaticExports.CreateTargetControl(m_Host, m_RemoteIdent, username, true); if (m_Connection.Connected) { string api = "No API detected"; if (m_Connection.API.Length > 0) { api = m_Connection.API; } this.BeginInvoke((MethodInvoker) delegate { if (m_Connection.PID == 0) { connectionStatus.Text = String.Format("Connection established to {0} ({1})", m_Connection.Target, api); SetText(String.Format("{0}", m_Connection.Target)); } else { connectionStatus.Text = String.Format("Connection established to {0} [PID {1}] ({2})", m_Connection.Target, m_Connection.PID, api); SetText(String.Format("{0} [PID {1}]", m_Connection.Target, m_Connection.PID)); } connectionIcon.Image = global::renderdocui.Properties.Resources.connect; }); } else { throw new ReplayCreateException(ReplayCreateStatus.NetworkIOFailed); } while (m_Connection.Connected) { m_Connection.ReceiveMessage(); if (m_TriggerCapture) { m_Connection.TriggerCapture((uint)m_CaptureNumFrames); m_TriggerCapture = false; } if (m_QueueCapture) { m_Connection.QueueCapture((uint)m_CaptureFrameNum); m_QueueCapture = false; m_CaptureFrameNum = 0; } if (m_CopyLogLocalPath != "") { m_Connection.CopyCapture(m_CopyLogID, m_CopyLogLocalPath); m_CopyLogLocalPath = ""; m_CopyLogID = uint.MaxValue; } List <uint> dels = new List <uint>(); lock (m_DeleteLogs) { dels.AddRange(m_DeleteLogs); m_DeleteLogs.Clear(); } foreach (var del in dels) { m_Connection.DeleteCapture(del); } if (m_Disconnect) { m_Connection.Shutdown(); m_Connection = null; return; } if (m_Connection.InfoUpdated) { this.BeginInvoke((MethodInvoker) delegate { if (m_Connection.PID == 0) { connectionStatus.Text = String.Format("Connection established to {0} ({1})", m_Connection.Target, m_Connection.API); SetText(String.Format("{0}", m_Connection.Target)); } else { connectionStatus.Text = String.Format("Connection established to {0} [PID {1}] ({2})", m_Connection.Target, m_Connection.PID, m_Connection.API); SetText(String.Format("{0} [PID {1}]", m_Connection.Target, m_Connection.PID)); } connectionIcon.Image = global::renderdocui.Properties.Resources.connect; }); m_Connection.InfoUpdated = false; } if (m_Connection.CaptureExists) { uint capID = m_Connection.CaptureFile.ID; DateTime timestamp = new DateTime(1970, 1, 1, 0, 0, 0); timestamp = timestamp.AddSeconds(m_Connection.CaptureFile.timestamp).ToLocalTime(); byte[] thumb = m_Connection.CaptureFile.thumbnail; int thumbWidth = m_Connection.CaptureFile.thumbWidth; int thumbHeight = m_Connection.CaptureFile.thumbHeight; string path = m_Connection.CaptureFile.path; bool local = m_Connection.CaptureFile.local; this.BeginInvoke((MethodInvoker) delegate { CaptureAdded(capID, m_Connection.Target, m_Connection.API, thumb, thumbWidth, thumbHeight, timestamp, path, local); }); m_Connection.CaptureExists = false; } if (m_Connection.CaptureCopied) { uint capID = m_Connection.CaptureFile.ID; string path = m_Connection.CaptureFile.path; this.BeginInvoke((MethodInvoker) delegate { CaptureCopied(capID, path); }); m_Connection.CaptureCopied = false; } if (m_Connection.ChildAdded) { if (m_Connection.NewChild.PID != 0) { try { ChildProcess c = new ChildProcess(); c.PID = (int)m_Connection.NewChild.PID; c.ident = m_Connection.NewChild.ident; c.name = Process.GetProcessById((int)m_Connection.NewChild.PID).ProcessName; lock (m_Children) { m_Children.Add(c); } } catch (Exception) { // process expired/doesn't exist anymore } } m_Connection.ChildAdded = false; } } this.BeginInvoke((MethodInvoker) delegate { connectionStatus.Text = "Connection closed"; connectionIcon.Image = global::renderdocui.Properties.Resources.disconnect; numFrames.Enabled = captureDelay.Enabled = captureFrame.Enabled = triggerCapture.Enabled = queueCap.Enabled = false; ConnectionClosed(); }); } catch (ReplayCreateException) { this.BeginInvoke((MethodInvoker) delegate { SetText("Connection failed"); connectionStatus.Text = "Connection failed"; connectionIcon.Image = global::renderdocui.Properties.Resources.delete; ConnectionClosed(); }); } }