예제 #1
0
        public void LoadBase(string path)
        {
            NUSContent.Format format = NUSContent.GetFormat(path);

            if (format == NUSContent.Format.Decrypted)
            {
                ValidateBase(path);

                if (Directory.Exists(BasePath))
                {
                    Directory.Delete(BasePath, true);
                    Base = null;
                }

                if (Useful.DirectoryCopy(path, BasePath, true))
                {
                    Base = GetLoadedBase();
                }
                else
                {
                    throw new Exception("Could not load base \"" + path + "\".");
                }
            }
            else if (format == NUSContent.Format.Encrypted)
            {
                ValidateEncryptedBase(path);

                if (Directory.Exists(BasePath))
                {
                    Directory.Delete(BasePath, true);
                    Base = null;
                }

                Directory.CreateDirectory(BasePath);
                NUSContent.Decrypt(path, BasePath);
                Base = GetLoadedBase();
            }
            else
            {
                StringBuilder strBuilder = new StringBuilder();
                strBuilder.AppendLine("The folder not contains a valid NUS content.");
                strBuilder.AppendLine("If it is an unpackaged (decrypted) NUS content, then:");
                strBuilder.AppendLine("The \"" + path + "\\code\" folder not exist.");
                strBuilder.AppendLine("Or \"" + path + "\\content\" folder not exist.");
                strBuilder.AppendLine("Or \"" + path + "\\meta\" folder not exist.");
                strBuilder.AppendLine("If it is an packaged (encrypted) NUS content, then:");
                strBuilder.AppendLine("The \"" + path + "\\title.tmd\" file not exist.");
                strBuilder.AppendLine("Or \"" + path + "\\title.tik\" file not exist.");
                strBuilder.AppendLine("Or \"" + path + "\\title.cert\" file not exist.");
                throw new Exception(strBuilder.ToString());
            }
        }
예제 #2
0
 private void textBoxCommonKey_TextChanged(object sender, EventArgs e)
 {
     if (NUSContent.LoadKey(textBoxCommonKey.Text))
     {
         textBoxCommonKey.Text          = "";
         textBoxCommonKey.BackColor     = Color.FromArgb(33, 33, 33);
         textBoxCommonKey.Enabled       = false;
         panelCommonKey.BackgroundImage = Properties.Resources.checkmark_16;
     }
     else
     {
         textBoxCommonKey.BackColor     = Color.FromArgb(51, 51, 51);
         textBoxCommonKey.Enabled       = true;
         panelCommonKey.BackgroundImage = Properties.Resources.x_mark_16;
     }
 }
예제 #3
0
        protected void InjectImages(Bitmap menuIconImg, Bitmap bootTvImg, Bitmap bootDrcImg)
        {
            Graphics g;

            if (menuIconImg != null)
            {
                Bitmap tmpMenuIconImg;
                tmpMenuIconImg = new Bitmap(128, 128, PixelFormat.Format32bppArgb);
                g = Graphics.FromImage(tmpMenuIconImg);
                g.DrawImage(menuIconImg, new Rectangle(0, 0, 128, 128));
                g.Dispose();
                if (!NUSContent.SaveTGA(tmpMenuIconImg, BasePath + "\\meta\\iconTex.tga"))
                {
                    throw new Exception("Error creating \"iconTex.tga\" file.");
                }
            }

            if (bootTvImg != null)
            {
                Bitmap tmpBootTvImg;
                tmpBootTvImg = new Bitmap(1280, 720, PixelFormat.Format24bppRgb);
                g            = Graphics.FromImage(tmpBootTvImg);
                g.DrawImage(bootTvImg, new Rectangle(0, 0, 1280, 720));
                g.Dispose();
                if (!NUSContent.SaveTGA(tmpBootTvImg, BasePath + "\\meta\\bootTvTex.tga"))
                {
                    throw new Exception("Error creating \"bootTvTex.tga\" file.");
                }
            }

            if (bootDrcImg != null)
            {
                Bitmap tmpBootDrcImg;
                tmpBootDrcImg = new Bitmap(854, 480, PixelFormat.Format24bppRgb);
                g             = Graphics.FromImage(tmpBootDrcImg);
                g.DrawImage(bootDrcImg, new Rectangle(0, 0, 854, 480));
                g.Dispose();
                if (!NUSContent.SaveTGA(tmpBootDrcImg, BasePath + "\\meta\\bootDrcTex.tga"))
                {
                    throw new Exception("Error creating \"bootDrcTex.tga\" file.");
                }
            }
        }
예제 #4
0
        public void Inject(bool encrypt, string outputPath, string shortName, string longName,
                           Bitmap menuIconImg, Bitmap bootTvImg, Bitmap bootDrcImg)
        {
            string outPath = encrypt ?
                             Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "decrypted") :
                             GetValidOutputPath(outputPath, shortName);

            if (!encrypt && Directory.Exists(outPath) &&
                (Directory.GetDirectories(outPath).Length != 0 || Directory.GetFiles(outPath).Length != 0))
            {
                throw new Exception("The output path \"" + outPath + "\"exists and is not empty.");
            }

            if (encrypt && Directory.Exists(outPath))
            {
                Directory.Delete(outPath, true);
            }

            CopyBase(outPath);
            BasePath = outPath;
            Base     = GetLoadedBase();
            if (!BaseIsLoaded)
            {
                throw new Exception("The base is not ready.");
            }
            InjectImages(menuIconImg, bootTvImg, bootDrcImg);
            InjectMeta(shortName, longName);
            BasePath = Path.Combine(DataPath, "base");

            InjectMultimedia(Path.Combine(outPath, "content", "app"));

            if (encrypt)
            {
                if (Directory.Exists(GetValidOutputPath(outputPath, shortName)))
                {
                    Directory.Delete(GetValidOutputPath(outputPath, shortName), true);
                }
                Directory.CreateDirectory(GetValidOutputPath(outputPath, shortName));
                NUSContent.Encrypt(outPath, GetValidOutputPath(outputPath, shortName));
            }
        }
예제 #5
0
        protected string GetAppFileName(string path)
        {
            string unpackPath = Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "NUSConverter"), "unpack");

            if (File.Exists(Path.Combine(unpackPath, "cos.xml")))
            {
                File.Delete(Path.Combine(unpackPath, "cos.xml"));
            }

            NUSContent.Decrypt(path, "code\\cos.xml", Path.Combine(unpackPath, "cos.xml"));

            if (!File.Exists(Path.Combine(unpackPath, "cos.xml")))
            {
                throw new Exception("The NUS content does not contains \"code\\cos.xml\" file.");
            }

            XmlDocument xmlCos = new XmlDocument();

            xmlCos.Load(Path.Combine(unpackPath, "cos.xml"));
            XmlNode cos_argstr = xmlCos.SelectSingleNode("app/argstr");

            return(cos_argstr.InnerText);
        }
예제 #6
0
        public WUMInjectorGUI()
        {
            Cll.Log.SaveIn("WUMInjector.log");
            Cll.Log.WriteLine("WUM Injector " + MediaInjector.Release);
            Cll.Log.WriteLine(DateTime.Now.ToString());

            InitializeComponent();

            BootTvImg   = new BootImage();
            BootDrcImg  = new BootImage();
            MenuIconImg = new MenuIconImage();

            this.Text = "WUM Injector " + MediaInjector.Release;

            ResourcesPath = Path.Combine(MediaInjector.DataPath, "resources");
            string imagesPath           = Path.Combine(ResourcesPath, "images");
            string NUSConverterDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "NUSConverter");
            string packPath             = Path.Combine(NUSConverterDataPath, "pack");
            string unpackPath           = Path.Combine(NUSConverterDataPath, "unpack");
            string cnuspackerPath       = Path.Combine(packPath, "CNUSPacker.exe");
            string cdecryptPath         = Path.Combine(unpackPath, "CDecrypt.exe");

            if (!Directory.Exists(NUSConverterDataPath))
            {
                Directory.CreateDirectory(NUSConverterDataPath);
                Directory.CreateDirectory(packPath);
                Directory.CreateDirectory(unpackPath);
                FileStream fs = File.Create(cnuspackerPath);
                fs.Write(Resources.CNUSPacker, 0, Resources.CNUSPacker.Length);
                fs.Close();
                fs = File.Create(cdecryptPath);
                fs.Write(Resources.CDecrypt, 0, Resources.CDecrypt.Length);
                fs.Close();
                fs = File.Create(Path.Combine(unpackPath, "libeay32.dll"));
                fs.Write(Resources.libeay32, 0, Resources.libeay32.Length);
                fs.Close();
            }

            if (Directory.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "WUMMInjector")))
            {
                Directory.Delete(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "WUMMInjector"), true);
            }

            if (!Directory.Exists(MediaInjector.DataPath))
            {
                Directory.CreateDirectory(MediaInjector.DataPath);
            }

            if (!Directory.Exists(ResourcesPath))
            {
                Directory.CreateDirectory(ResourcesPath);
                StreamWriter sw = File.CreateText(Path.Combine(ResourcesPath, "version"));
                sw.Write(MediaInjector.Release);
                sw.Close();
            }

            if (!Directory.Exists(imagesPath))
            {
                Directory.CreateDirectory(imagesPath);
                Resources.icon_multimedia.Save(Path.Combine(imagesPath, "icon.png"), ImageFormat.Png);
            }

            StringBuilder sb      = new StringBuilder();
            bool          warning = false;

            if (!File.Exists(cnuspackerPath))
            {
                sb.AppendLine("Warning! \"" + cnuspackerPath + "\" not found! NUSPacker allows you to encrypt NUS Content for WUP Installer.");
                sb.AppendLine("");
                warning = true;
            }
            if (!File.Exists(cdecryptPath))
            {
                sb.AppendLine("Warning! \"" + cdecryptPath + "\" not found! CDecrypt allows you to decrypt NUS Content for Loadiine.");
                warning = true;
            }
            if (warning)
            {
                MessageBox.Show(sb.ToString(), "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            if (NUSContent.CheckCommonKeyFiles())
            {
                textBoxCommonKey.Enabled       = false;
                panelCommonKey.BackgroundImage = Properties.Resources.checkmark_16;
            }
            else
            {
                textBoxCommonKey.Enabled       = true;
                panelCommonKey.BackgroundImage = Properties.Resources.x_mark_16;
            }

            Injector = new MediaInjector();
            if (Injector.BaseIsLoaded)
            {
                panelLoadedBase.BackgroundImage = Properties.Resources.checkmark_16;
                labelBase.Text         = Injector.LoadedBase;
                buttonLoadBase.Enabled = false;
            }
            else
            {
                panelLoadedBase.BackgroundImage = Properties.Resources.x_mark_16;
                labelBase.Text = "Base invalid!";
            }

            if (File.Exists(Path.Combine(imagesPath, "icon.png")))
            {
                MenuIconImg.Frame = new Bitmap(Path.Combine(imagesPath, "icon.png"));
            }
            else
            {
                MenuIconImg.Frame = null;
            }

            UpdateMenuIconPictureBox();
            UpdateBootTvPictureBox();
            UpdateBootDrcPictureBox();
        }