Esempio n. 1
0
        private void PatchKernelButton_Click(object sender, EventArgs e)
        {
            string pkg2 = "BCPKG2-1-Normal-Main";

            if (!FileStuff.doesFileExist("keys.ini") || !FileStuff.doesFileExist(pkg2))
            {
                return;
            }
            #region Remove Leading 0's from BCPKG2-1-Normal-Main and save as pkg2NoLeading0 then delete the original
            byte[] hex        = File.ReadAllBytes(pkg2);
            int    indexesOf0 = 0;
            while (hex[indexesOf0] == 0x00)
            {
                indexesOf0++;
            }
            File.WriteAllBytes("pkg2NoLeading0", hex.Skip(indexesOf0).ToArray());
            File.Delete(pkg2);
            #endregion
            #region Extract hactool
            FileStuff.extractHactool();
            #endregion
            #region Use hactool to decrypt pkg2NoLeading0 to Kernel.bin
            FileStuff.executeFile("hactool.exe", "-tpk21 -k keys.ini --outdir pkg2Decrypted \"pkg2NoLeading0\"");
            #endregion
            #region Delete hactool
            FileStuff.deleteHactool();
            #endregion
            #region Delete Decrypted.bin and INI1.bin, not needed
            File.Delete("pkg2Decrypted/Decrypted.bin");
            File.Delete("pkg2Decrypted/INI1.bin");
            #endregion
            #region Rename Kernel.bin to lowercase and move it out of pkg2Decrypted
            File.Move("pkg2Decrypted/Kernel.bin", "kernel.bin");
            #endregion
            #region Delete Empty pkg2Decrypted as its no longer needed
            Directory.Delete("pkg2Decrypted");
            #endregion
            #region Use kernelpatches.exe to patch the kernel, then delete kernelpatches.exe
            File.WriteAllBytes("kernelpatches.exe", Resources.kernelpatches);
            Process.Start("kernelpatches.exe").WaitForExit();
            File.Delete("kernelpatches.exe");
            #endregion
            #region Delete the original kernel.bin and pkg2noleading0
            File.Delete("kernel.bin");
            File.Delete("pkg2NoLeading0");
            #endregion
            #region Move kernel-patched.bin to /modules/romfs/kernel-patched.bin
            MessageBox.Show("Insert your Switch's SDCard into your PC and then hit OK.");
            using (FolderBrowserDialog fbd = new FolderBrowserDialog()) {
                fbd.RootFolder  = Environment.SpecialFolder.MyComputer;
                fbd.Description = "I will need to know the location of your SD Card's ROOT! (So if its D:/ drive, just select D:/ and hit OK)";
                while (fbd.ShowDialog() != DialogResult.OK || string.IsNullOrWhiteSpace(fbd.SelectedPath))
                {
                    MessageBox.Show("You need to select a directory to continue.");
                }
                File.Move("kernel-patched.bin", Path.Combine(fbd.SelectedPath, "modules", "romfs", "kernel-patched.bin"));
            }
            #endregion
            MessageBox.Show("Done!");
        }
Esempio n. 2
0
        private void XCIDecryptButton_Click(object sender, EventArgs e)
        {
            #region Verify Files and Donor TitleID
            if (!FileStuff.doesFileExist("keys.ini") || !FileStuff.doesFileExist("game.xci"))
            {
                return;
            }
            if (donorTitleId.Text == "0100XXXXXXXXXXX")
            {
                MessageBox.Show("You need to put a Donor Title ID!");
                return;
            }
            if (donorTitleId.Text.StartsWith("100"))
            {
                MessageBox.Show("The Donor Title ID needs to start with 0100.");
                return;
            }
            #endregion
            #region Extract Hactool
            FileStuff.extractHactool();
            #endregion
            #region Extract .NCA's
            Process.Start("hactool.exe", "-k keys.ini -txci --securedir=\"" + donorTitleId.Text + "\" \"game.xci\"").WaitForExit();
            #endregion
            #region Extract RomFS and ExeFS
            FileStuff.executeFile("hactool.exe", "-k keys.ini --romfs=\"" + donorTitleId.Text + "\\romfs.bin\" --exefsdir=\"" + donorTitleId.Text + "\\exefs\" \"" + donorTitleId.Text + "\\" + new DirectoryInfo(donorTitleId.Text).EnumerateFiles().OrderByDescending(f => f.Length).FirstOrDefault().Name + "\"");
            #endregion
            #region Delete hactool
            FileStuff.deleteHactool();
            #endregion
            #region Delete .NCA's
            foreach (string file in Directory.GetFiles(donorTitleId.Text, "*.nca"))
            {
                File.Delete(file);
            }
            #endregion
            #region Insert the new title id at offset 0x430 in ASIo

            #region Get the Title ID as bytes with hexadecimal base 16 and reverse it (little endian)
            byte[]          titleBytes = new byte[8];
            MatchCollection mc         = Regex.Matches(donorTitleId.Text, @"[a-fA-F0-9]{2}");
            for (int i = 0; i < 8; i++)
            {
                titleBytes[i] = Convert.ToByte(mc[i].Value, 16);
            }
            titleBytes = titleBytes.Reverse().ToArray();
            #endregion
            #region Write the new little endian hexadecimal base 16 hex values to the npdm
            using (FileStream source = File.OpenRead(donorTitleId.Text + "/exefs/main.npdm"))
                using (FileStream destination = File.OpenWrite(donorTitleId.Text + "/exefs/main.npdm.new")) {
                    byte[] patchedNpdm = patchTitleId(File.ReadAllBytes(donorTitleId.Text + "/exefs/main.npdm"), titleBytes);
                    destination.Write(patchedNpdm, 0, patchedNpdm.Length);
                }
            #endregion

            #endregion
            #region Delete the original npdm and overwrite it with the new edited npdm
            File.Delete(donorTitleId.Text + "/exefs/main.npdm");
            File.Move(donorTitleId.Text + "/exefs/main.npdm.new", donorTitleId.Text + "/exefs/main.npdm");
            #endregion
            MessageBox.Show(
                "The XCI is now decrypted. The folder was automatically renamed and the main.nmpd was automatically edited to contain the Donor TitleID!\n" +
                "Now just copy: " + donorTitleId.Text + " next to this applications .exe to sd:/atmosphere/titles/" + donorTitleId.Text + "\n" +
                "HAVE FUN! -PRAGMA"
                );
        }
Esempio n. 3
0
 private void button2_Click(object sender, EventArgs e)
 {
     FileStuff.rcmSmash(Resources.biskeydump);
 }
Esempio n. 4
0
 private void button3_Click(object sender, EventArgs e)
 {
     FileStuff.rcmSmash(Resources.hekate_lfs);
 }
Esempio n. 5
0
 private void button1_Click_1(object sender, EventArgs e)
 {
     FileStuff.rcmSmash(Resources.hekate_ctcaer);
 }