Esempio n. 1
0
        public static void GenerateTicket(Nintendo3DSTitle title, string fileName, string outputDir)
        {
            var ticket   = Convert.FromBase64String(Resources.TikTemplate);
            var titleId  = BitConversion.HexToBytes(title.TitleId);
            var titleKey = BitConversion.HexToBytes(title.EncKey);

            const int titleKeyOffset = 0x1BF;

            for (var offset = titleKeyOffset; offset < titleKeyOffset + 0x10; offset++)
            {
                ticket[offset] = titleKey[offset - titleKeyOffset];
            }

            const int titleIdOffset = 0x1DC;

            for (int offset = titleIdOffset; offset < titleIdOffset + 0x8; offset++)
            {
                ticket[offset] = titleId[offset - titleIdOffset];
            }

            if (!Directory.Exists(outputDir))
            {
                Directory.CreateDirectory(outputDir);
            }

            fileName = SanitizeFileName(fileName);

            File.WriteAllBytes($"{outputDir}\\{fileName}", ticket);
        }
Esempio n. 2
0
        public static Nintendo3DSTitle[] ParseFromDatabase(string databasePath, string sizesPath)
        {
            var database = File.ReadAllText(databasePath);
            var sizesDb  = File.ReadAllText(sizesPath);

            Func <JToken, string> value = t => t.ToString();
            var titles = JArray.Parse(database);
            var sizes  = JObject.Parse(sizesDb);

            var entries = new List <Nintendo3DSTitle>();

            foreach (var title in titles)
            {
                var titleId = value(title["titleID"]);
                var type    = Nintendo3DSTitle.GetTitleType(value(titleId));
                var encKey  = value(title["encTitleKey"]);
                if (string.IsNullOrWhiteSpace(encKey))
                {
                    continue;
                }

                var name = value(title["name"]).Trim();

                if (string.IsNullOrWhiteSpace(name))
                {
                    name = "Unknown";
                }

                var  region = value(title["region"]);
                var  serial = value(title["serial"]);
                long size   = 0;

                if (sizes[titleId.ToUpper()] != null)
                {
                    size = sizes[titleId.ToUpper()].Value <long>();
                }

                var generated = new Nintendo3DSTitle(titleId, encKey, name, type, region, serial, size);
                entries.Add(generated);
            }

            return(entries.ToArray());
        }
Esempio n. 3
0
        public static byte[] GenerateTicket(Nintendo3DSTitle title)
        {
            var ticket   = Convert.FromBase64String(Resources.TikTemplate);
            var titleId  = BitConversion.HexToBytes(title.TitleId);
            var titleKey = BitConversion.HexToBytes(title.EncKey);

            const int titleKeyOffset = 0x1BF;

            for (var offset = titleKeyOffset; offset < titleKeyOffset + 0x10; offset++)
            {
                ticket[offset] = titleKey[offset - titleKeyOffset];
            }

            const int titleIdOffset = 0x1DC;

            for (int offset = titleIdOffset; offset < titleIdOffset + 0x8; offset++)
            {
                ticket[offset] = titleId[offset - titleIdOffset];
            }

            return(ticket);
        }