示例#1
0
        private static int FindTargetSelfCallback(int target, IntPtr userData)
        {
            Ps3TmApi.SNPS3GamePortIPAddressData gameIpAddress;
            int result = Ps3TmApi.SNPS3GetGamePortIPAddrData(target, IntPtr.Zero, out gameIpAddress);

            if (result == 0 && gameIpAddress.uReturnValue == 0)
            {
                byte   p1        = (byte)(gameIpAddress.uIPAddress >> 24 & 0xFF);
                byte   p2        = (byte)(gameIpAddress.uIPAddress >> 16 & 0xFF);
                byte   p3        = (byte)(gameIpAddress.uIPAddress >> 8 & 0xFF);
                byte   p4        = (byte)(gameIpAddress.uIPAddress >> 0 & 0xFF);
                string ipAddress = string.Format("{0}.{1}.{2}.{3}", p1, p2, p3, p4);
                if (ipAddress == searchIpAddress)
                {
                    // Found the target we are looking for, now get the self path
                    int[] processIds     = new int[64];
                    int   processesCount = processIds.Length;
                    result = SNPS3ProcessList(target, ref processesCount, processIds);
                    // Should only be 1 process running, let's assume it is the first once
                    if (processesCount > 0)
                    {
                        SNPS3PROCESSINFO processInfo = new SNPS3PROCESSINFO();
                        int processInfoSize          = Marshal.SizeOf(processInfo);
                        result = SNPS3ProcessInfo(target, processIds[0], ref processInfoSize, out processInfo);
                        if (result == 0)
                        {
                            string prefix = "/app_home/";
                            if (processInfo.Hdr.szPath.StartsWith(prefix))
                            {
                                foundSelfPath = processInfo.Hdr.szPath.Substring(prefix.Length);
                                return(1);                                              // Return 1 to stop enumeration
                            }
                        }
                    }
                }
            }
            return(0);
        }
示例#2
0
        private static int GetPS3TargetInfoCallback(int target, IntPtr userData)
        {
            Ps3TmApi.SNPS3TargetInfo targetInfo = new Ps3TmApi.SNPS3TargetInfo();
            targetInfo.hTarget = target;
            targetInfo.nFlags  = Ps3TmApi.SN_TI_TARGETID | Ps3TmApi.SN_TI_NAME | Ps3TmApi.SN_TI_INFO;
            int    result    = Ps3TmApi.SNPS3GetTargetInfo(ref targetInfo);
            string type      = Marshal.PtrToStringAnsi(targetInfo.pszType);
            string name      = Marshal.PtrToStringAnsi(targetInfo.pszName);
            string info      = Marshal.PtrToStringAnsi(targetInfo.pszInfo);
            string ipAddress = string.Empty;

            Ps3TmApi.SNPS3GamePortIPAddressData gameIpAddress;
            // Note: We can only get the game port IP address if we are connected to the kit and it is running a game
            result = Ps3TmApi.SNPS3GetGamePortIPAddrData(target, IntPtr.Zero, out gameIpAddress);
            if (result == 0 && gameIpAddress.uReturnValue == 0)
            {
                byte p1 = (byte)(gameIpAddress.uIPAddress >> 24 & 0xFF);
                byte p2 = (byte)(gameIpAddress.uIPAddress >> 16 & 0xFF);
                byte p3 = (byte)(gameIpAddress.uIPAddress >> 8 & 0xFF);
                byte p4 = (byte)(gameIpAddress.uIPAddress >> 0 & 0xFF);
                ipAddress = string.Format("{0}.{1}.{2}.{3}", p1, p2, p3, p4);
                name     += " (connected)";
            }
            else if (type == "PS3_DBG_DEX")
            {
                // Test kits only have 1 IP address, and we can get it from the info string
                string[] parts    = info.Split(',');
                string   lastPart = parts[parts.Length - 1].Trim();
                ipAddress = lastPart.Split(':')[0];
            }
            if (!string.IsNullOrEmpty(ipAddress))
            {
                currentConnectMessageBox.comboBoxTarget.Items.Add(new TargetItem(string.Format("[PS3] {0}", name), ipAddress, CryNotificationNetworkClient.NN_PORT));
            }
            return(0);
        }
示例#3
0
        private void OnVersionInformationReceived(Platform hostPlatform, int hostVersion, int clientVersion)
        {
            if (hostVersion != clientVersion)
            {
                string text = string.Format("Version mismatch, host version: {0}, client version: {1}\n", hostVersion, clientVersion);
                if (hostVersion > clientVersion)
                {
                    text += "You need to update your remote debugger client.\n\n";
                }
                else
                {
                    text += "The game is not using the latest remote debugger code.\n\n";
                }
                text += "Continue anyway?";
                if (MessageBox.Show(this, text, "Version mismatch", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
                {
                    // Bail!
                    debugger.Disconnect();
                    return;
                }
            }
            if (hostPlatform == Platform.PS3)
            {
                string ps3BinPath = Settings.Default.Ps3BinPath;
                if (string.IsNullOrEmpty(ps3BinPath) || !File.Exists(ps3BinPath))
                {
                    ps3BinPath = null;
                    // Try to find the PS3 bin folder automatically
                    string ps3Root = Environment.GetEnvironmentVariable("SCE_PS3_ROOT");
                    if (ps3Root != null)
                    {
                        ps3BinPath = Path.Combine(ps3Root, "host-win32/sn/bin/ps3bin.exe");
                        if (!File.Exists(ps3BinPath))
                        {
                            ps3BinPath = null;
                        }
                    }
                }
                if (string.IsNullOrEmpty(ps3BinPath))
                {
                    // As a last resort, ask the user to locate it
                    string caption = "In order to resolve C++ callstacks on the PS3, we need access to ps3bin.exe.\n";
                    caption += "It is a part of the CELL SDK and should be located under <cell>/host-win32/sn/bin/ps3bin.exe.\n\n";
                    caption += "Do you want to locate it now?";
                    if (MessageBox.Show(this, caption, "Locate ps3bin.exe", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        using (OpenFileDialog fileDialog = new OpenFileDialog())
                        {
                            fileDialog.CheckFileExists = true;
                            fileDialog.Filter          = "ps3bin.exe|ps3bin.exe";
                            if (fileDialog.ShowDialog(this) == DialogResult.OK && fileDialog.FileName.EndsWith("ps3bin.exe", StringComparison.OrdinalIgnoreCase))
                            {
                                ps3BinPath = fileDialog.FileName;
                            }
                        }
                    }
                }
                if (!string.IsNullOrEmpty(ps3BinPath))
                {
                    string selfPath = null;
                    // Try to determine the executing self from the target manager API
                    if (Ps3TmApi.Available && debugger.ConnectedIpAddress != null)
                    {
                        selfPath = Ps3TmApi.FindTargetSelf(debugger.ConnectedIpAddress);
                    }

                    // As a last resort, ask the user to locate it
                    if (string.IsNullOrEmpty(selfPath))
                    {
                        string caption = "In order to resolve C++ callstacks on the PS3, we need access to the compiled self file.\n\n";
                        caption += "Do you want to locate it now?";
                        if (MessageBox.Show(this, caption, "Locate self", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            using (OpenFileDialog fileDialog = new OpenFileDialog())
                            {
                                fileDialog.CheckFileExists = true;
                                fileDialog.Filter          = "self files (*.self)|*.self";
                                if (fileDialog.ShowDialog(this) == DialogResult.OK)
                                {
                                    selfPath = fileDialog.FileName;
                                }
                            }
                        }
                    }
                    if (!string.IsNullOrEmpty(selfPath))
                    {
                        debugger.SetSymbolsManager(new Ps3SymbolsManager(ps3BinPath, selfPath));
                    }
                    Settings.Default.Ps3BinPath = ps3BinPath;                                   // Save the path for next time
                }
            }

            SendBreakpointsToDebugger();
            CheckFileDifferences();
            debugger.EnableCppCallstack(GetCppCallStackMode());
        }