////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        public int GetProcess(AD_PROCESS_ID ProcessId, out IDebugProcess2 ppProcess)
        {
            //
            // Gets the specified process running on a port.
            //

            LoggingUtils.PrintFunction();

            ppProcess = null;

            try
            {
                if (ProcessId.ProcessIdType == (uint)enum_AD_PROCESS_ID.AD_PROCESS_ID_SYSTEM)
                {
                    LoggingUtils.RequireOk(RefreshProcesses());

                    DebuggeeProcess process = GetProcessForPid(ProcessId.dwProcessId) ?? throw new InvalidOperationException($"Could not locate requested process. Pid: {ProcessId.dwProcessId}");

                    ppProcess = process as IDebugProcess2;
                }
                else /*if (ProcessId.ProcessIdType == (uint) enum_AD_PROCESS_ID.AD_PROCESS_ID_GUID)*/
                {
                    throw new NotImplementedException();
                }

                return(Constants.S_OK);
            }
            catch (Exception e)
            {
                LoggingUtils.HandleException(e);

                return(Constants.E_FAIL);
            }
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        #region IDebugPort2 Members

        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        public int EnumProcesses(out IEnumDebugProcesses2 ppEnum)
        {
            //
            // Returns a list of all the processes running on a port.
            //

            LoggingUtils.PrintFunction();

            try
            {
                RefreshProcesses();

                DebuggeeProcess [] processes = new DebuggeeProcess [m_portProcesses.Count];

                m_portProcesses.Values.CopyTo(processes, 0);

                ppEnum = new DebuggeeProcess.Enumerator(processes);

                return(Constants.S_OK);
            }
            catch (Exception e)
            {
                LoggingUtils.HandleException(e);

                ppEnum = null;

                return(Constants.E_FAIL);
            }
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        public DebuggeeProgram(DebuggeeProcess process)
        {
            Guid = Guid.NewGuid();

            DebugProcess = process;

            AttachedEngine = null;
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        public DebuggeeProcess GetProcessForPid(uint pid)
        {
            LoggingUtils.PrintFunction();

            DebuggeeProcess process = null;

            m_portProcesses.TryGetValue(pid, out process);

            return(process);
        }