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); } 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.AddTarget(ETargetType.PS3, name, ipAddress, StatoscopeCryEnginePort); } return(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); }