ApplicationLibrary.cs 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633
  1. using JsonPrettyPrinterPlus;
  2. using LibHac;
  3. using LibHac.Common;
  4. using LibHac.Fs;
  5. using LibHac.Fs.Shim;
  6. using LibHac.FsSystem;
  7. using LibHac.FsSystem.NcaUtils;
  8. using LibHac.Ncm;
  9. using LibHac.Ns;
  10. using LibHac.Spl;
  11. using Ryujinx.Common.Logging;
  12. using Ryujinx.Configuration.System;
  13. using Ryujinx.HLE.FileSystem;
  14. using Ryujinx.HLE.Loaders.Npdm;
  15. using System;
  16. using System.Collections.Generic;
  17. using System.Globalization;
  18. using System.IO;
  19. using System.Linq;
  20. using System.Reflection;
  21. using System.Text;
  22. using Utf8Json;
  23. using Utf8Json.Resolvers;
  24. using RightsId = LibHac.Fs.RightsId;
  25. namespace Ryujinx.Ui
  26. {
  27. public class ApplicationLibrary
  28. {
  29. public static event EventHandler<ApplicationAddedEventArgs> ApplicationAdded;
  30. public static event EventHandler<ApplicationCountUpdatedEventArgs> ApplicationCountUpdated;
  31. private static readonly byte[] _nspIcon = GetResourceBytes("Ryujinx.Ui.assets.NSPIcon.png");
  32. private static readonly byte[] _xciIcon = GetResourceBytes("Ryujinx.Ui.assets.XCIIcon.png");
  33. private static readonly byte[] _ncaIcon = GetResourceBytes("Ryujinx.Ui.assets.NCAIcon.png");
  34. private static readonly byte[] _nroIcon = GetResourceBytes("Ryujinx.Ui.assets.NROIcon.png");
  35. private static readonly byte[] _nsoIcon = GetResourceBytes("Ryujinx.Ui.assets.NSOIcon.png");
  36. private static VirtualFileSystem _virtualFileSystem;
  37. private static Language _desiredTitleLanguage;
  38. private static bool _loadingError;
  39. public static IEnumerable<string> GetFilesInDirectory(string directory)
  40. {
  41. Stack<string> stack = new Stack<string>();
  42. stack.Push(directory);
  43. while (stack.Count > 0)
  44. {
  45. string dir = stack.Pop();
  46. string[] content = { };
  47. try
  48. {
  49. content = Directory.GetFiles(dir, "*");
  50. }
  51. catch (UnauthorizedAccessException)
  52. {
  53. Logger.PrintWarning(LogClass.Application, $"Failed to get access to directory: \"{dir}\"");
  54. }
  55. if (content.Length > 0)
  56. {
  57. foreach (string file in content)
  58. yield return file;
  59. }
  60. try
  61. {
  62. content = Directory.GetDirectories(dir);
  63. }
  64. catch (UnauthorizedAccessException)
  65. {
  66. Logger.PrintWarning(LogClass.Application, $"Failed to get access to directory: \"{dir}\"");
  67. }
  68. if (content.Length > 0)
  69. {
  70. foreach (string subdir in content)
  71. stack.Push(subdir);
  72. }
  73. }
  74. }
  75. public static void ReadControlData(IFileSystem controlFs, Span<byte> outProperty)
  76. {
  77. controlFs.OpenFile(out IFile controlFile, "/control.nacp".ToU8Span(), OpenMode.Read).ThrowIfFailure();
  78. controlFile.Read(out long _, 0, outProperty, ReadOption.None).ThrowIfFailure();
  79. }
  80. public static void LoadApplications(List<string> appDirs, VirtualFileSystem virtualFileSystem, Language desiredTitleLanguage)
  81. {
  82. int numApplicationsFound = 0;
  83. int numApplicationsLoaded = 0;
  84. _loadingError = false;
  85. _virtualFileSystem = virtualFileSystem;
  86. _desiredTitleLanguage = desiredTitleLanguage;
  87. // Builds the applications list with paths to found applications
  88. List<string> applications = new List<string>();
  89. foreach (string appDir in appDirs)
  90. {
  91. if (!Directory.Exists(appDir))
  92. {
  93. Logger.PrintWarning(LogClass.Application, $"The \"game_dirs\" section in \"Config.json\" contains an invalid directory: \"{appDir}\"");
  94. continue;
  95. }
  96. foreach (string app in GetFilesInDirectory(appDir))
  97. {
  98. if ((Path.GetExtension(app).ToLower() == ".nsp") ||
  99. (Path.GetExtension(app).ToLower() == ".pfs0") ||
  100. (Path.GetExtension(app).ToLower() == ".xci") ||
  101. (Path.GetExtension(app).ToLower() == ".nca") ||
  102. (Path.GetExtension(app).ToLower() == ".nro") ||
  103. (Path.GetExtension(app).ToLower() == ".nso"))
  104. {
  105. applications.Add(app);
  106. numApplicationsFound++;
  107. }
  108. }
  109. }
  110. // Loops through applications list, creating a struct and then firing an event containing the struct for each application
  111. foreach (string applicationPath in applications)
  112. {
  113. double fileSize = new FileInfo(applicationPath).Length * 0.000000000931;
  114. string titleName = "Unknown";
  115. string titleId = "0000000000000000";
  116. string developer = "Unknown";
  117. string version = "0";
  118. string saveDataPath = null;
  119. byte[] applicationIcon = null;
  120. BlitStruct<ApplicationControlProperty> controlHolder = new BlitStruct<ApplicationControlProperty>(1);
  121. try
  122. {
  123. using (FileStream file = new FileStream(applicationPath, FileMode.Open, FileAccess.Read))
  124. {
  125. if ((Path.GetExtension(applicationPath).ToLower() == ".nsp") ||
  126. (Path.GetExtension(applicationPath).ToLower() == ".pfs0") ||
  127. (Path.GetExtension(applicationPath).ToLower() == ".xci"))
  128. {
  129. try
  130. {
  131. PartitionFileSystem pfs;
  132. bool isExeFs = false;
  133. if (Path.GetExtension(applicationPath).ToLower() == ".xci")
  134. {
  135. Xci xci = new Xci(_virtualFileSystem.KeySet, file.AsStorage());
  136. pfs = xci.OpenPartition(XciPartitionType.Secure);
  137. }
  138. else
  139. {
  140. pfs = new PartitionFileSystem(file.AsStorage());
  141. // If the NSP doesn't have a main NCA, decrement the number of applications found and then continue to the next application.
  142. bool hasMainNca = false;
  143. foreach (DirectoryEntryEx fileEntry in pfs.EnumerateEntries("/", "*"))
  144. {
  145. if (Path.GetExtension(fileEntry.FullPath).ToLower() == ".nca")
  146. {
  147. pfs.OpenFile(out IFile ncaFile, fileEntry.FullPath.ToU8Span(), OpenMode.Read).ThrowIfFailure();
  148. Nca nca = new Nca(_virtualFileSystem.KeySet, ncaFile.AsStorage());
  149. int dataIndex = Nca.GetSectionIndexFromType(NcaSectionType.Data, NcaContentType.Program);
  150. if (nca.Header.ContentType == NcaContentType.Program && !nca.Header.GetFsHeader(dataIndex).IsPatchSection())
  151. {
  152. hasMainNca = true;
  153. break;
  154. }
  155. }
  156. else if (Path.GetFileNameWithoutExtension(fileEntry.FullPath) == "main")
  157. {
  158. isExeFs = true;
  159. }
  160. }
  161. if (!hasMainNca && !isExeFs)
  162. {
  163. numApplicationsFound--;
  164. continue;
  165. }
  166. }
  167. if (isExeFs)
  168. {
  169. applicationIcon = _nspIcon;
  170. Result result = pfs.OpenFile(out IFile npdmFile, "/main.npdm".ToU8Span(), OpenMode.Read);
  171. if (ResultFs.PathNotFound.Includes(result))
  172. {
  173. Npdm npdm = new Npdm(npdmFile.AsStream());
  174. titleName = npdm.TitleName;
  175. titleId = npdm.Aci0.TitleId.ToString("x16");
  176. }
  177. }
  178. else
  179. {
  180. // Store the ControlFS in variable called controlFs
  181. GetControlFsAndTitleId(pfs, out IFileSystem controlFs, out titleId);
  182. ReadControlData(controlFs, controlHolder.ByteSpan);
  183. // Creates NACP class from the NACP file
  184. controlFs.OpenFile(out IFile controlNacpFile, "/control.nacp".ToU8Span(), OpenMode.Read).ThrowIfFailure();
  185. // Get the title name, title ID, developer name and version number from the NACP
  186. version = controlHolder.Value.DisplayVersion.ToString();
  187. GetNameIdDeveloper(ref controlHolder.Value, out titleName, out _, out developer);
  188. // Read the icon from the ControlFS and store it as a byte array
  189. try
  190. {
  191. controlFs.OpenFile(out IFile icon, $"/icon_{_desiredTitleLanguage}.dat".ToU8Span(), OpenMode.Read).ThrowIfFailure();
  192. using (MemoryStream stream = new MemoryStream())
  193. {
  194. icon.AsStream().CopyTo(stream);
  195. applicationIcon = stream.ToArray();
  196. }
  197. }
  198. catch (HorizonResultException)
  199. {
  200. foreach (DirectoryEntryEx entry in controlFs.EnumerateEntries("/", "*"))
  201. {
  202. if (entry.Name == "control.nacp")
  203. {
  204. continue;
  205. }
  206. controlFs.OpenFile(out IFile icon, entry.FullPath.ToU8Span(), OpenMode.Read).ThrowIfFailure();
  207. using (MemoryStream stream = new MemoryStream())
  208. {
  209. icon.AsStream().CopyTo(stream);
  210. applicationIcon = stream.ToArray();
  211. }
  212. if (applicationIcon != null)
  213. {
  214. break;
  215. }
  216. }
  217. if (applicationIcon == null)
  218. {
  219. applicationIcon = Path.GetExtension(applicationPath).ToLower() == ".xci" ? _xciIcon : _nspIcon;
  220. }
  221. }
  222. }
  223. }
  224. catch (MissingKeyException exception)
  225. {
  226. applicationIcon = Path.GetExtension(applicationPath).ToLower() == ".xci" ? _xciIcon : _nspIcon;
  227. Logger.PrintWarning(LogClass.Application, $"Your key set is missing a key with the name: {exception.Name}");
  228. }
  229. catch (InvalidDataException)
  230. {
  231. applicationIcon = Path.GetExtension(applicationPath).ToLower() == ".xci" ? _xciIcon : _nspIcon;
  232. Logger.PrintWarning(LogClass.Application, $"The header key is incorrect or missing and therefore the NCA header content type check has failed. Errored File: {applicationPath}");
  233. }
  234. catch (Exception exception)
  235. {
  236. Logger.PrintWarning(LogClass.Application, $"The file encountered was not of a valid type. Errored File: {applicationPath}");
  237. Logger.PrintDebug(LogClass.Application, exception.ToString());
  238. numApplicationsFound--;
  239. _loadingError = true;
  240. continue;
  241. }
  242. }
  243. else if (Path.GetExtension(applicationPath).ToLower() == ".nro")
  244. {
  245. BinaryReader reader = new BinaryReader(file);
  246. byte[] Read(long position, int size)
  247. {
  248. file.Seek(position, SeekOrigin.Begin);
  249. return reader.ReadBytes(size);
  250. }
  251. try
  252. {
  253. file.Seek(24, SeekOrigin.Begin);
  254. int assetOffset = reader.ReadInt32();
  255. if (Encoding.ASCII.GetString(Read(assetOffset, 4)) == "ASET")
  256. {
  257. byte[] iconSectionInfo = Read(assetOffset + 8, 0x10);
  258. long iconOffset = BitConverter.ToInt64(iconSectionInfo, 0);
  259. long iconSize = BitConverter.ToInt64(iconSectionInfo, 8);
  260. ulong nacpOffset = reader.ReadUInt64();
  261. ulong nacpSize = reader.ReadUInt64();
  262. // Reads and stores game icon as byte array
  263. applicationIcon = Read(assetOffset + iconOffset, (int) iconSize);
  264. // Read the NACP data
  265. Read(assetOffset + (int)nacpOffset, (int)nacpSize).AsSpan().CopyTo(controlHolder.ByteSpan);
  266. // Get the title name, title ID, developer name and version number from the NACP
  267. version = controlHolder.Value.DisplayVersion.ToString();
  268. GetNameIdDeveloper(ref controlHolder.Value, out titleName, out titleId, out developer);
  269. }
  270. else
  271. {
  272. applicationIcon = _nroIcon;
  273. titleName = Path.GetFileNameWithoutExtension(applicationPath);
  274. }
  275. }
  276. catch
  277. {
  278. Logger.PrintWarning(LogClass.Application, $"The file encountered was not of a valid type. Errored File: {applicationPath}");
  279. numApplicationsFound--;
  280. continue;
  281. }
  282. }
  283. else if (Path.GetExtension(applicationPath).ToLower() == ".nca")
  284. {
  285. try
  286. {
  287. Nca nca = new Nca(_virtualFileSystem.KeySet, new FileStream(applicationPath, FileMode.Open, FileAccess.Read).AsStorage());
  288. int dataIndex = Nca.GetSectionIndexFromType(NcaSectionType.Data, NcaContentType.Program);
  289. if (nca.Header.ContentType != NcaContentType.Program || nca.Header.GetFsHeader(dataIndex).IsPatchSection())
  290. {
  291. numApplicationsFound--;
  292. continue;
  293. }
  294. }
  295. catch (InvalidDataException)
  296. {
  297. Logger.PrintWarning(LogClass.Application, $"The NCA header content type check has failed. This is usually because the header key is incorrect or missing. Errored File: {applicationPath}");
  298. }
  299. catch
  300. {
  301. Logger.PrintWarning(LogClass.Application, $"The file encountered was not of a valid type. Errored File: {applicationPath}");
  302. numApplicationsFound--;
  303. _loadingError = true;
  304. continue;
  305. }
  306. applicationIcon = _ncaIcon;
  307. titleName = Path.GetFileNameWithoutExtension(applicationPath);
  308. }
  309. // If its an NSO we just set defaults
  310. else if (Path.GetExtension(applicationPath).ToLower() == ".nso")
  311. {
  312. applicationIcon = _nsoIcon;
  313. titleName = Path.GetFileNameWithoutExtension(applicationPath);
  314. }
  315. }
  316. }
  317. catch (IOException exception)
  318. {
  319. Logger.PrintWarning(LogClass.Application, exception.Message);
  320. numApplicationsFound--;
  321. _loadingError = true;
  322. continue;
  323. }
  324. ApplicationMetadata appMetadata = LoadAndSaveMetaData(titleId);
  325. if (ulong.TryParse(titleId, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out ulong titleIdNum))
  326. {
  327. SaveDataFilter filter = new SaveDataFilter();
  328. filter.SetUserId(new UserId(1, 0));
  329. filter.SetProgramId(new TitleId(titleIdNum));
  330. Result result = virtualFileSystem.FsClient.FindSaveDataWithFilter(out SaveDataInfo saveDataInfo, SaveDataSpaceId.User, ref filter);
  331. if (result.IsSuccess())
  332. {
  333. saveDataPath = Path.Combine(virtualFileSystem.GetNandPath(), $"user/save/{saveDataInfo.SaveDataId:x16}");
  334. }
  335. }
  336. ApplicationData data = new ApplicationData()
  337. {
  338. Favorite = appMetadata.Favorite,
  339. Icon = applicationIcon,
  340. TitleName = titleName,
  341. TitleId = titleId,
  342. Developer = developer,
  343. Version = version,
  344. TimePlayed = ConvertSecondsToReadableString(appMetadata.TimePlayed),
  345. LastPlayed = appMetadata.LastPlayed,
  346. FileExtension = Path.GetExtension(applicationPath).ToUpper().Remove(0 ,1),
  347. FileSize = (fileSize < 1) ? (fileSize * 1024).ToString("0.##") + "MB" : fileSize.ToString("0.##") + "GB",
  348. Path = applicationPath,
  349. SaveDataPath = saveDataPath,
  350. ControlHolder = controlHolder
  351. };
  352. numApplicationsLoaded++;
  353. OnApplicationAdded(new ApplicationAddedEventArgs()
  354. {
  355. AppData = data
  356. });
  357. OnApplicationCountUpdated(new ApplicationCountUpdatedEventArgs()
  358. {
  359. NumAppsFound = numApplicationsFound,
  360. NumAppsLoaded = numApplicationsLoaded
  361. });
  362. }
  363. OnApplicationCountUpdated(new ApplicationCountUpdatedEventArgs()
  364. {
  365. NumAppsFound = numApplicationsFound,
  366. NumAppsLoaded = numApplicationsLoaded
  367. });
  368. if (_loadingError)
  369. {
  370. Gtk.Application.Invoke(delegate
  371. {
  372. GtkDialog.CreateErrorDialog("One or more files encountered could not be loaded, check logs for more info.");
  373. });
  374. }
  375. }
  376. protected static void OnApplicationAdded(ApplicationAddedEventArgs e)
  377. {
  378. ApplicationAdded?.Invoke(null, e);
  379. }
  380. protected static void OnApplicationCountUpdated(ApplicationCountUpdatedEventArgs e)
  381. {
  382. ApplicationCountUpdated?.Invoke(null, e);
  383. }
  384. private static byte[] GetResourceBytes(string resourceName)
  385. {
  386. Stream resourceStream = Assembly.GetCallingAssembly().GetManifestResourceStream(resourceName);
  387. byte[] resourceByteArray = new byte[resourceStream.Length];
  388. resourceStream.Read(resourceByteArray);
  389. return resourceByteArray;
  390. }
  391. private static void GetControlFsAndTitleId(PartitionFileSystem pfs, out IFileSystem controlFs, out string titleId)
  392. {
  393. Nca controlNca = null;
  394. // Add keys to key set if needed
  395. foreach (DirectoryEntryEx ticketEntry in pfs.EnumerateEntries("/", "*.tik"))
  396. {
  397. Result result = pfs.OpenFile(out IFile ticketFile, ticketEntry.FullPath.ToU8Span(), OpenMode.Read);
  398. if (result.IsSuccess())
  399. {
  400. Ticket ticket = new Ticket(ticketFile.AsStream());
  401. _virtualFileSystem.KeySet.ExternalKeySet.Add(new RightsId(ticket.RightsId), new AccessKey(ticket.GetTitleKey(_virtualFileSystem.KeySet)));
  402. }
  403. }
  404. // Find the Control NCA and store it in variable called controlNca
  405. foreach (DirectoryEntryEx fileEntry in pfs.EnumerateEntries("/", "*.nca"))
  406. {
  407. pfs.OpenFile(out IFile ncaFile, fileEntry.FullPath.ToU8Span(), OpenMode.Read).ThrowIfFailure();
  408. Nca nca = new Nca(_virtualFileSystem.KeySet, ncaFile.AsStorage());
  409. if (nca.Header.ContentType == NcaContentType.Control)
  410. {
  411. controlNca = nca;
  412. }
  413. }
  414. // Return the ControlFS
  415. controlFs = controlNca?.OpenFileSystem(NcaSectionType.Data, IntegrityCheckLevel.None);
  416. titleId = controlNca?.Header.TitleId.ToString("x16");
  417. }
  418. internal static ApplicationMetadata LoadAndSaveMetaData(string titleId, Action<ApplicationMetadata> modifyFunction = null)
  419. {
  420. string metadataFolder = Path.Combine(_virtualFileSystem.GetBasePath(), "games", titleId, "gui");
  421. string metadataFile = Path.Combine(metadataFolder, "metadata.json");
  422. IJsonFormatterResolver resolver = CompositeResolver.Create(new[] { StandardResolver.AllowPrivateSnakeCase });
  423. ApplicationMetadata appMetadata;
  424. if (!File.Exists(metadataFile))
  425. {
  426. Directory.CreateDirectory(metadataFolder);
  427. appMetadata = new ApplicationMetadata
  428. {
  429. Favorite = false,
  430. TimePlayed = 0,
  431. LastPlayed = "Never"
  432. };
  433. byte[] data = JsonSerializer.Serialize(appMetadata, resolver);
  434. File.WriteAllText(metadataFile, Encoding.UTF8.GetString(data, 0, data.Length).PrettyPrintJson());
  435. }
  436. using (Stream stream = File.OpenRead(metadataFile))
  437. {
  438. appMetadata = JsonSerializer.Deserialize<ApplicationMetadata>(stream, resolver);
  439. }
  440. if (modifyFunction != null)
  441. {
  442. modifyFunction(appMetadata);
  443. byte[] saveData = JsonSerializer.Serialize(appMetadata, resolver);
  444. File.WriteAllText(metadataFile, Encoding.UTF8.GetString(saveData, 0, saveData.Length).PrettyPrintJson());
  445. }
  446. return appMetadata;
  447. }
  448. private static string ConvertSecondsToReadableString(double seconds)
  449. {
  450. const int secondsPerMinute = 60;
  451. const int secondsPerHour = secondsPerMinute * 60;
  452. const int secondsPerDay = secondsPerHour * 24;
  453. string readableString;
  454. if (seconds < secondsPerMinute)
  455. {
  456. readableString = $"{seconds}s";
  457. }
  458. else if (seconds < secondsPerHour)
  459. {
  460. readableString = $"{Math.Round(seconds / secondsPerMinute, 2, MidpointRounding.AwayFromZero)} mins";
  461. }
  462. else if (seconds < secondsPerDay)
  463. {
  464. readableString = $"{Math.Round(seconds / secondsPerHour, 2, MidpointRounding.AwayFromZero)} hrs";
  465. }
  466. else
  467. {
  468. readableString = $"{Math.Round(seconds / secondsPerDay, 2, MidpointRounding.AwayFromZero)} days";
  469. }
  470. return readableString;
  471. }
  472. private static void GetNameIdDeveloper(ref ApplicationControlProperty controlData, out string titleName, out string titleId, out string publisher)
  473. {
  474. Enum.TryParse(_desiredTitleLanguage.ToString(), out TitleLanguage desiredTitleLanguage);
  475. if (controlData.Titles.Length > (int)desiredTitleLanguage)
  476. {
  477. titleName = controlData.Titles[(int)desiredTitleLanguage].Name.ToString();
  478. publisher = controlData.Titles[(int)desiredTitleLanguage].Publisher.ToString();
  479. }
  480. else
  481. {
  482. titleName = null;
  483. publisher = null;
  484. }
  485. if (string.IsNullOrWhiteSpace(titleName))
  486. {
  487. foreach (ApplicationControlTitle controlTitle in controlData.Titles)
  488. {
  489. if (!((U8Span)controlTitle.Name).IsEmpty())
  490. {
  491. titleName = controlTitle.Name.ToString();
  492. break;
  493. }
  494. }
  495. }
  496. if (string.IsNullOrWhiteSpace(publisher))
  497. {
  498. foreach (ApplicationControlTitle controlTitle in controlData.Titles)
  499. {
  500. if (!((U8Span)controlTitle.Publisher).IsEmpty())
  501. {
  502. publisher = controlTitle.Publisher.ToString();
  503. break;
  504. }
  505. }
  506. }
  507. if (controlData.PresenceGroupId != 0)
  508. {
  509. titleId = controlData.PresenceGroupId.ToString("x16");
  510. }
  511. else if (controlData.SaveDataOwnerId.Value != 0)
  512. {
  513. titleId = controlData.SaveDataOwnerId.ToString();
  514. }
  515. else if (controlData.AddOnContentBaseId != 0)
  516. {
  517. titleId = (controlData.AddOnContentBaseId - 0x1000).ToString("x16");
  518. }
  519. else
  520. {
  521. titleId = "0000000000000000";
  522. }
  523. }
  524. }
  525. }