private void InfoBox(string message)
        {
            boxInvoker b = new boxInvoker(this._infoBox);

            this.Invoke(b, message);
        }
        private void ErrorBox(string message)
        {
            boxInvoker b = new boxInvoker(this._errorBox);

            this.Invoke(b, message);
        }
Beispiel #3
0
        private void _extractAppForBrowsing(object infos)
        {
            BaseApp standardApp = (BaseApp)(((object[])infos)[0]);
            string browsePath = (string)(((object[])infos)[1]);

            Directory.CreateDirectory(browsePath);

            Wii.U8.UnpackU8(Application.StartupPath + "\\" + ((int)standardApp).ToString("x8") + ".app", browsePath);

            string[] allFiles = Directory.GetFiles(browsePath, "*", SearchOption.AllDirectories);
            int counter = 0;

            foreach (string thisFile in allFiles)
            {
                ReportProgress(++counter * 100 / allFiles.Length, "Extracting App...");

                bool extracted = false;

                while (!extracted)
                {
                    byte[] fourBytes = Wii.Tools.LoadFileToByteArray(thisFile, 0, 4);

                    if (fourBytes[0] == 'A' && fourBytes[1] == 'S' &&
                            fourBytes[2] == 'H' && fourBytes[3] == '0') //ASH0
                    {
                        try
                        {
                            DeASH(thisFile);

                            File.Delete(thisFile);
                            FileInfo fi = new FileInfo(thisFile + ".arc");
                            fi.MoveTo(thisFile);
                        }
                        catch (Exception ex)
                        {
                            SetControls(true);
                            ErrorBox(ex.Message);
                            return;
                        }
                    }
                    else if (fourBytes[0] == 'L' && fourBytes[1] == 'Z' &&
                            fourBytes[2] == '7' && fourBytes[3] == '7') //Lz77
                    {
                        try
                        {
                            byte[] decompressedFile = Wii.Lz77.Decompress(File.ReadAllBytes(thisFile), 0);

                            File.Delete(thisFile);
                            File.WriteAllBytes(thisFile, decompressedFile);
                        }
                        catch (Exception ex)
                        {
                            SetControls(true);
                            ErrorBox(ex.Message);
                            return;
                        }
                    }
                    else if (fourBytes[0] == 'Y' && fourBytes[1] == 'a' &&
                            fourBytes[2] == 'z' && fourBytes[3] == '0') //Yaz0
                    {
                        //Nothing to do about yet...
                        break;
                    }
                    else if (fourBytes[0] == 0x55 && fourBytes[1] == 0xaa &&
                            fourBytes[2] == 0x38 && fourBytes[3] == 0x2d) //U8
                    {
                        try
                        {
                            Wii.U8.UnpackU8(thisFile, Path.GetDirectoryName(thisFile) + "\\" + Path.GetFileName(thisFile).Replace(".", "_") + "_out");
                            extracted = true;
                        }
                        catch (Exception ex)
                        {
                            SetControls(true);
                            ErrorBox(ex.Message);
                            return;
                        }
                    }
                    else break;
                }
            }

            lastExtracted = standardApp;
            ReportProgress(100, " ");

            boxInvoker b = new boxInvoker(this.OpenAppBrowser);
            this.Invoke(b, browsePath);
        }
 private void InfoBox(string message)
 {
     boxInvoker b = new boxInvoker(this._infoBox);
     this.Invoke(b, message);
 }
 private void ErrorBox(string message)
 {
     boxInvoker b = new boxInvoker(this._errorBox);
     this.Invoke(b, message);
 }
Beispiel #6
0
        private void _extractAppForBrowsing(object infos)
        {
            BaseApp standardApp = (BaseApp)(((object[])infos)[0]);
            string  browsePath  = (string)(((object[])infos)[1]);

            Directory.CreateDirectory(browsePath);

            Wii.U8.UnpackU8(Application.StartupPath + "\\" + ((int)standardApp).ToString("x8") + ".app", browsePath);

            string[] allFiles = Directory.GetFiles(browsePath, "*", SearchOption.AllDirectories);
            int      counter  = 0;

            foreach (string thisFile in allFiles)
            {
                ReportProgress(++counter * 100 / allFiles.Length, "Extracting App...");

                bool extracted = false;

                while (!extracted)
                {
                    byte[] fourBytes = Wii.Tools.LoadFileToByteArray(thisFile, 0, 4);

                    if (fourBytes[0] == 'A' && fourBytes[1] == 'S' &&
                        fourBytes[2] == 'H' && fourBytes[3] == '0')     //ASH0
                    {
                        try
                        {
                            DeASH(thisFile);

                            File.Delete(thisFile);
                            FileInfo fi = new FileInfo(thisFile + ".arc");
                            fi.MoveTo(thisFile);
                        }
                        catch (Exception ex)
                        {
                            SetControls(true);
                            ErrorBox(ex.Message);
                            return;
                        }
                    }
                    else if (fourBytes[0] == 'L' && fourBytes[1] == 'Z' &&
                             fourBytes[2] == '7' && fourBytes[3] == '7') //Lz77
                    {
                        try
                        {
                            byte[] decompressedFile = Wii.Lz77.Decompress(File.ReadAllBytes(thisFile), 0);

                            File.Delete(thisFile);
                            File.WriteAllBytes(thisFile, decompressedFile);
                        }
                        catch (Exception ex)
                        {
                            SetControls(true);
                            ErrorBox(ex.Message);
                            return;
                        }
                    }
                    else if (fourBytes[0] == 'Y' && fourBytes[1] == 'a' &&
                             fourBytes[2] == 'z' && fourBytes[3] == '0') //Yaz0
                    {
                        //Nothing to do about yet...
                        break;
                    }
                    else if (fourBytes[0] == 0x55 && fourBytes[1] == 0xaa &&
                             fourBytes[2] == 0x38 && fourBytes[3] == 0x2d) //U8
                    {
                        try
                        {
                            Wii.U8.UnpackU8(thisFile, Path.GetDirectoryName(thisFile) + "\\" + Path.GetFileName(thisFile).Replace(".", "_") + "_out");
                            extracted = true;
                        }
                        catch (Exception ex)
                        {
                            SetControls(true);
                            ErrorBox(ex.Message);
                            return;
                        }
                    }
                    else
                    {
                        break;
                    }
                }
            }

            lastExtracted = standardApp;
            ReportProgress(100, " ");

            boxInvoker b = new boxInvoker(this.OpenAppBrowser);

            this.Invoke(b, browsePath);
        }