Ejemplo n.º 1
0
        // Main wrapper that assembles the ROM based on the following specifications:
        public static bool buildROM(bool Card2, string LOGO_NAME,
                                    string EXEFS_PATH, string ROMFS_PATH, string EXHEADER_PATH,
                                    string SERIAL_TEXT, string SAVE_PATH,
                                    bool trimmed = false, ProgressBar PB_Show = null, RichTextBox TB_Progress = null)
        {
            PB_Show     = PB_Show ?? new ProgressBar();
            TB_Progress = TB_Progress ?? new RichTextBox();

            // Sanity check the input files.
            if (!
                ((File.Exists(EXEFS_PATH) || Directory.Exists(EXEFS_PATH)) &&
                 (File.Exists(ROMFS_PATH) || Directory.Exists(ROMFS_PATH)) &&
                 File.Exists(EXHEADER_PATH)))
            {
                return(false);
            }

            // If ExeFS and RomFS are not built, build.
            if (!File.Exists(EXEFS_PATH) && Directory.Exists(EXEFS_PATH))
            {
                ExeFS.set(Directory.GetFiles(EXEFS_PATH), EXEFS_PATH = "exefs.bin");
            }
            if (!File.Exists(ROMFS_PATH) && Directory.Exists(ROMFS_PATH))
            {
                RomFS.BuildRomFS(ROMFS_PATH, ROMFS_PATH = "romfs.bin", TB_Progress, PB_Show);
            }

            NCCH NCCH    = setNCCH(EXEFS_PATH, ROMFS_PATH, EXHEADER_PATH, SERIAL_TEXT, LOGO_NAME, PB_Show, TB_Progress);
            NCSD NCSD    = setNCSD(NCCH, Card2, PB_Show, TB_Progress);
            bool success = writeROM(NCSD, SAVE_PATH, trimmed, PB_Show, TB_Progress);

            return(success);
        }
Ejemplo n.º 2
0
        private void ExtractExeFS(string NCCH_PATH, string outputDirectory, RichTextBox TB_Progress = null, ProgressBar PB_Show = null)
        {
            string exefsbinpath = Path.Combine(outputDirectory, "exefs.bin");
            string exefspath    = Path.Combine(outputDirectory, "exefs");

            updateTB(TB_Progress, "Extracting exefs.bin from CXI...");
            byte[] exefsbytes = new byte[header.ExefsSize * MEDIA_UNIT_SIZE];

            using (FileStream fs = new FileStream(NCCH_PATH, FileMode.Open, FileAccess.Read))
            {
                fs.Seek(Convert.ToInt32(header.ExefsOffset * MEDIA_UNIT_SIZE), SeekOrigin.Begin);
                fs.Read(exefsbytes, 0, exefsbytes.Length);
            }

            File.WriteAllBytes(exefsbinpath, exefsbytes);
            ExeFS.get(exefsbinpath, exefspath);
            File.Delete(exefsbinpath);
        }