This interface is sent when a process is launched. (http://msdn.microsoft.com/en-ca/library/bb161755.aspx)
Inheritance: IDebugEvent2, IDebugProcessCreateEvent2
Ejemplo n.º 1
0
        /// <summary>
        /// Gets the list of processes running on this port.
        /// </summary>
        /// <returns> Returns the list of processes running on this port. </returns>
        IEnumerable <AD7Process> GetProcesses()
        {
            IDebugCoreServer2 server = null;

            if (m_processes.Count() != 0)
            {
                foreach (AD7Process p in m_processes)
                {
                    AD7ProcessDestroyEvent ev = new AD7ProcessDestroyEvent();
                    SendEvent(server, this, p, null, ev, ev.getGuid());
                }
                m_processes.Clear();
            }

            string publicKeyPath = Environment.GetEnvironmentVariable("AppData") + @"\BlackBerry\bbt_id_rsa.pub";

            string response = GDBParser.GetPIDsThroughGDB(m_IP, m_password, m_isSimulator, m_toolsPath, publicKeyPath, 7);

            if ((response == "TIMEOUT!") || (response.IndexOf("1^error,msg=", 0) != -1)) //found an error
            {
                if (response == "TIMEOUT!")                                              // Timeout error, normally happen when the device is not connected.
                {
                    MessageBox.Show("Please, verify if the Device/Simulator IP in \"BlackBerry -> Settings\" menu is correct and check if it is connected.", "Device/Simulator not connected or not configured properly", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                if (response[29] == ':') // error: 1^error,msg="169.254.0.3:8000: The requested address is not valid in its context."
                {
                    string txt     = response.Substring(13, response.IndexOf(':', 13) - 13) + response.Substring(29, response.IndexOf('"', 31) - 29);
                    string caption = "";
                    if (txt.IndexOf("The requested address is not valid in its context.") != -1)
                    {
                        txt    += "\n\nPlease, verify the BlackBerry device/simulator IP settings.";
                        caption = "Invalid IP";
                    }
                    else
                    {
                        txt    += "\n\nPlease, verify if the device/simulator is connected.";
                        caption = "Connection failed";
                    }
                    MessageBox.Show(txt, caption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                response = "";
            }
            else if (response.Contains("^done"))
            {
                response = response.Remove(response.IndexOf("^done"));
                string[] tempListOfProcesses = response.Split('\n');

                int ind = (response[0] == '&') ? 1 : 0; // ignore the first if it starts with & (&"info pidlist")
                while (ind < tempListOfProcesses.Length - 1)
                {
                    string process = tempListOfProcesses[ind];
                    int    pos     = process.LastIndexOf('/');
                    if (pos == -1)
                    {
                        ind++;
                        continue;
                    }
                    process = process.Remove(pos).Substring(2);
                    for (ind = ind + 1; ind < tempListOfProcesses.Length - 1; ind++) // ignore the duplicates
                    {
                        int pos2 = tempListOfProcesses[ind].LastIndexOf('/');
                        if ((pos2 <= 2) || (tempListOfProcesses[ind].Substring(2, pos2 - 2) != process))
                        {
                            break;
                        }
                    }
                    AD7Process proc = new AD7Process(this, process.Substring(process.IndexOf("- ") + 2), process.Remove(process.IndexOf(" ")));
                    m_processes.Add(proc);
                    AD7ProcessCreateEvent ev = new AD7ProcessCreateEvent();
                    SendEvent(server, this, proc, null, ev, ev.getGuid());
                }
            }
            return(m_processes);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets the list of processes running on this port.
        /// </summary>
        /// <returns> Returns the list of processes running on this port. </returns>
        IEnumerable<AD7Process> GetProcesses()
        {
            IDebugCoreServer2 server = null;
            if (m_processes.Count() != 0)
            {
                foreach (AD7Process p in m_processes)
                {
                    AD7ProcessDestroyEvent ev = new AD7ProcessDestroyEvent();
                    SendEvent(server, this, p, null, ev, ev.getGuid());
                }
                m_processes.Clear();
            }

            string publicKeyPath = Environment.GetEnvironmentVariable("AppData") + @"\BlackBerry\bbt_id_rsa.pub";

            string response = GDBParser.GetPIDsThroughGDB(m_IP, m_password, m_isSimulator, m_toolsPath, publicKeyPath, 7);

            if ((response == "TIMEOUT!") || (response.IndexOf("1^error,msg=", 0) != -1)) //found an error
            {
                if (response == "TIMEOUT!") // Timeout error, normally happen when the device is not connected.
                {
                    MessageBox.Show("Please, verify if the Device/Simulator IP in \"BlackBerry -> Settings\" menu is correct and check if it is connected.", "Device/Simulator not connected or not configured properly", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                if (response[29] == ':') // error: 1^error,msg="169.254.0.3:8000: The requested address is not valid in its context."
                {
                    string txt = response.Substring(13, response.IndexOf(':', 13) - 13) + response.Substring(29, response.IndexOf('"', 31) - 29);
                    string caption = "";
                    if (txt.IndexOf("The requested address is not valid in its context.") != -1)
                    {
                        txt += "\n\nPlease, verify the BlackBerry device/simulator IP settings.";
                        caption = "Invalid IP";
                    }
                    else
                    {
                        txt += "\n\nPlease, verify if the device/simulator is connected.";
                        caption = "Connection failed";
                    }
                    MessageBox.Show(txt, caption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                response = "";
            }
            else if (response.Contains("^done"))
            {
                response = response.Remove(response.IndexOf("^done"));
                string[] tempListOfProcesses = response.Split('\n');

                int ind = (response[0] == '&') ? 1 : 0; // ignore the first if it starts with & (&"info pidlist")
                while (ind < tempListOfProcesses.Length - 1)
                {
                    string process = tempListOfProcesses[ind];
                    int pos = process.LastIndexOf('/');
                    if (pos == -1)
                    {
                        ind++;
                        continue;
                    }
                    process = process.Remove(pos).Substring(2);
                    for (ind = ind + 1; ind < tempListOfProcesses.Length - 1; ind++) // ignore the duplicates
                    {
                        int pos2 = tempListOfProcesses[ind].LastIndexOf('/');
                        if ((pos2 <= 2) || (tempListOfProcesses[ind].Substring(2, pos2 - 2) != process))
                            break;
                    }
                    AD7Process proc = new AD7Process(this, process.Substring(process.IndexOf("- ") + 2), process.Remove(process.IndexOf(" ")));
                    m_processes.Add(proc);
                    AD7ProcessCreateEvent ev = new AD7ProcessCreateEvent();
                    SendEvent(server, this, proc, null, ev, ev.getGuid());
                }
            }
            return m_processes;
        }