Ejemplo n.º 1
0
        public bool Inject()
        {
            _base = GetLoadedBase();
            bool _continue = BaseIsLoaded;

            Cll.Log.WriteLine("The base is ready: " + _continue.ToString());

            if (_continue)
            {
                _continue = InjectGameLayout();
            }

            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);
        }
Ejemplo n.º 2
0
        private void PackUnpack(string[] args)
        {
            bool _continue = true;

            if (args.Length == 3 && args[1] == "-in")
            {
                injector.InPath  = args[2];
                injector.OutPath = Environment.CurrentDirectory + "\\" + args[0] + "_result";

                if (Directory.Exists(injector.OutPath))
                {
                    Directory.Delete(injector.OutPath, true);
                }
                Directory.CreateDirectory(injector.OutPath);
            }
            else if (args.Length == 5 && args[1] == "-in" && args[3] == "-out")
            {
                injector.InPath  = args[2];
                injector.OutPath = args[4];
            }
            else
            {
                Cll.Log.WriteLine("Incorrect " + args[0] + " syntax.");
                Cll.Log.WriteLine("");
                _continue = false;
            }

            if (_continue)
            {
                if (!Directory.Exists(injector.InPath) || !Path.IsPathRooted(injector.InPath))
                {
                    Cll.Log.WriteLine("The input folder \"" + injector.InPath + "\" not exist.");
                    Cll.Log.WriteLine("Do not use relative paths.");
                    Cll.Log.WriteLine("");
                    _continue = false;
                }
                if (!Directory.Exists(injector.OutPath) || !Path.IsPathRooted(injector.OutPath))
                {
                    Cll.Log.WriteLine("The output folder \"" + injector.OutPath + "\" not exist.");
                    Cll.Log.WriteLine("Do not use relative paths.");
                    Cll.Log.WriteLine("");
                    _continue = false;
                }
            }

            if (_continue && Directory.Exists(injector.OutPath))
            {
                if (Directory.GetDirectories(injector.OutPath).Length != 0 ||
                    Directory.GetFiles(injector.OutPath).Length != 0)
                {
                    Cll.Log.WriteLine("The \"" + injector.OutPath + "\" folder exist and not empty.");
                    Cll.Log.WriteLine("");
                    _continue = false;
                }
            }

            if (_continue)
            {
                Cll.Log.WriteLine("in: " + injector.InPath);
                Cll.Log.WriteLine("out: " + injector.OutPath);
                Cll.Log.WriteLine("");

                if (args[0] == "pack")
                {
                    if (NusContent.Encrypt(injector.InPath, injector.OutPath))
                    {
                        Cll.Log.WriteLine("The encryption was successful.");
                    }
                    else
                    {
                        Cll.Log.WriteLine("The encryption failed.");
                    }
                }
                else if (args[0] == "unpack")
                {
                    if (NusContent.Decrypt(injector.InPath, injector.OutPath))
                    {
                        Cll.Log.WriteLine("The decryption was successful.");
                    }
                    else
                    {
                        Cll.Log.WriteLine("The decryption failed.");
                    }
                }
            }
            else if (args[0] == "pack")
            {
                Cll.Log.WriteLine("The encryption failed.");
            }
            else
            {
                Cll.Log.WriteLine("The decryption failed.");
            }
        }