public bool LoadBase(string path) { if (Directory.Exists("base")) { Directory.Delete("base", true); Cll.Log.WriteLine("Previous base deleted."); } if (IsValidBase(path)) { Cll.Log.WriteLine("The \"" + path + "\" folder contains a valid base."); Useful.DirectoryCopy(path, "base", true); } else if (IsValidEncryptedBase(path)) { Cll.Log.WriteLine("The \"" + path + "\" folder contains a valid encrypted base."); NusContent.Decrypt(path, "base"); } else { Cll.Log.WriteLine("The \"" + path + "\" folder not contains a valid base."); } _base = GetLoadedBase(); return(BaseIsLoaded); }
public bool Inject() { _base = GetLoadedBase(); bool _continue = BaseIsLoaded; if (_continue) { Cll.Log.WriteLine("Base info:"); Cll.Log.WriteLine(_base.ToString()); } else { Cll.Log.WriteLine("The base is not loaded."); } if (_continue) { _continue = InjectImages(); } if (_continue) { _continue = InjectMeta(); } if (_continue) { _continue = InjectRom(); } if (_continue) { if (Encrypt) { Cll.Log.WriteLine("Creating encrypted output."); string inPath = Environment.CurrentDirectory + "\\base"; _continue = NusContent.Encrypt(inPath, OutPath); } else { Cll.Log.WriteLine("Creating unencrypted output."); _continue = Useful.DirectoryCopy("base", OutPath, true); } } if (_continue) { Cll.Log.WriteLine("Injection completed successfully!"); } else { Cll.Log.WriteLine("The injection failed.\nCheck the log file \"" + Cll.Log.Filename + "\"."); } return(_continue); }
public static bool Decrypt(string inputPath, string outputPath) { string titleId = CheckEncrypted(inputPath); if (titleId != null && CheckCommonKeyFiles() && GetJavaVersion() != null && File.Exists("resources\\jnustool\\JNUSTool.jar")) { string name = JNUSToolWrapper(inputPath, 0, Int32.MaxValue, titleId, ".*"); if (name != null) { Useful.DirectoryCopy(name, outputPath, true); Directory.Delete(name, true); return(true); } } return(false); }
private bool InjectMeta() { string titleId = TitleId; byte[] id = Useful.StrHexToByteArray(titleId, ""); XmlWriterSettings xmlSettings = new XmlWriterSettings { Encoding = new UTF8Encoding(false), Indent = true, IndentChars = " ", NewLineChars = "\n", NewLineHandling = NewLineHandling.Replace }; XmlDocument xmlApp = new XmlDocument(); XmlDocument xmlMeta = new XmlDocument(); try { Cll.Log.WriteLine("Editing \"app.xml\" and \"meta.xml\" files."); xmlApp.Load("base\\code\\app.xml"); xmlMeta.Load("base\\meta\\meta.xml"); XmlNode app_title_id = xmlApp.SelectSingleNode("app/title_id"); XmlNode app_group_id = xmlApp.SelectSingleNode("app/group_id"); XmlNode meta_product_code = xmlMeta.SelectSingleNode("menu/product_code"); XmlNode meta_title_id = xmlMeta.SelectSingleNode("menu/title_id"); XmlNode meta_group_id = xmlMeta.SelectSingleNode("menu/group_id"); XmlNode meta_longname_ja = xmlMeta.SelectSingleNode("menu/longname_ja"); XmlNode meta_longname_en = xmlMeta.SelectSingleNode("menu/longname_en"); XmlNode meta_longname_fr = xmlMeta.SelectSingleNode("menu/longname_fr"); XmlNode meta_longname_de = xmlMeta.SelectSingleNode("menu/longname_de"); XmlNode meta_longname_it = xmlMeta.SelectSingleNode("menu/longname_it"); XmlNode meta_longname_es = xmlMeta.SelectSingleNode("menu/longname_es"); XmlNode meta_longname_zhs = xmlMeta.SelectSingleNode("menu/longname_zhs"); XmlNode meta_longname_ko = xmlMeta.SelectSingleNode("menu/longname_ko"); XmlNode meta_longname_nl = xmlMeta.SelectSingleNode("menu/longname_nl"); XmlNode meta_longname_pt = xmlMeta.SelectSingleNode("menu/longname_pt"); XmlNode meta_longname_ru = xmlMeta.SelectSingleNode("menu/longname_ru"); XmlNode meta_longname_zht = xmlMeta.SelectSingleNode("menu/longname_zht"); XmlNode meta_shortname_ja = xmlMeta.SelectSingleNode("menu/shortname_ja"); XmlNode meta_shortname_en = xmlMeta.SelectSingleNode("menu/shortname_en"); XmlNode meta_shortname_fr = xmlMeta.SelectSingleNode("menu/shortname_fr"); XmlNode meta_shortname_de = xmlMeta.SelectSingleNode("menu/shortname_de"); XmlNode meta_shortname_it = xmlMeta.SelectSingleNode("menu/shortname_it"); XmlNode meta_shortname_es = xmlMeta.SelectSingleNode("menu/shortname_es"); XmlNode meta_shortname_zhs = xmlMeta.SelectSingleNode("menu/shortname_zhs"); XmlNode meta_shortname_ko = xmlMeta.SelectSingleNode("menu/shortname_ko"); XmlNode meta_shortname_nl = xmlMeta.SelectSingleNode("menu/shortname_nl"); XmlNode meta_shortname_pt = xmlMeta.SelectSingleNode("menu/shortname_pt"); XmlNode meta_shortname_ru = xmlMeta.SelectSingleNode("menu/shortname_ru"); XmlNode meta_shortname_zht = xmlMeta.SelectSingleNode("menu/shortname_zht"); app_title_id.InnerText = titleId; app_group_id.InnerText = "0000" + id[5].ToString("X2") + id[6].ToString("X2"); meta_product_code.InnerText = "WUP-N-" + Rom.ProductCode; meta_title_id.InnerText = titleId; meta_group_id.InnerText = "0000" + id[5].ToString("X2") + id[6].ToString("X2"); meta_longname_ja.InnerText = LongName; meta_longname_en.InnerText = LongName; meta_longname_fr.InnerText = LongName; meta_longname_de.InnerText = LongName; meta_longname_it.InnerText = LongName; meta_longname_es.InnerText = LongName; meta_longname_zhs.InnerText = LongName; meta_longname_ko.InnerText = LongName; meta_longname_nl.InnerText = LongName; meta_longname_pt.InnerText = LongName; meta_longname_ru.InnerText = LongName; meta_longname_zht.InnerText = LongName; meta_shortname_ja.InnerText = ShortName; meta_shortname_en.InnerText = ShortName; meta_shortname_fr.InnerText = ShortName; meta_shortname_de.InnerText = ShortName; meta_shortname_it.InnerText = ShortName; meta_shortname_es.InnerText = ShortName; meta_shortname_zhs.InnerText = ShortName; meta_shortname_ko.InnerText = ShortName; meta_shortname_nl.InnerText = ShortName; meta_shortname_pt.InnerText = ShortName; meta_shortname_ru.InnerText = ShortName; meta_shortname_zht.InnerText = ShortName; XmlWriter app = XmlWriter.Create("base\\code\\app.xml", xmlSettings); XmlWriter meta = XmlWriter.Create("base\\meta\\meta.xml", xmlSettings); xmlApp.Save(app); xmlMeta.Save(meta); app.Close(); meta.Close(); Cll.Log.WriteLine("\"app.xml\" and \"meta.xml\" files editing successfully."); return(true); } catch { Cll.Log.WriteLine("Error editing \"app.xml\" and \"meta.xml\" files."); } return(false); }