コード例 #1
0
        public static void SendDol(string[] args)
        {
            if (args.Length < 2)
            {
                SendDol_help();
                return;
            }
            if (args[1].ToUpper() == "-H" || args[1].ToUpper() == "-HELP")
            {
                SendDol_help();
                return;
            }
            string input     = "";
            string ip        = "";
            string protocol  = "JODI";
            string arguments = "";
            bool   compress  = true;
            bool   saveip    = false;
            bool   noip      = true;

            //Get parameters
            for (int i = 1; i < args.Length; i++)
            {
                switch (args[i].ToUpper())
                {
                case "-IP":
                    if (i + 1 >= args.Length)
                    {
                        Console.WriteLine("ERROR: No ip set");
                        Console.WriteLine("Error: SHARPII_NET_CORE_HBC_NO_IP_01");
                        Environment.Exit(0x00003E83);
                        return;
                    }
                    ip   = args[i + 1];
                    noip = false;
                    break;

                case "-SAVEIP":
                    saveip = true;
                    break;

                case "-DOL":
                    if (i + 1 >= args.Length)
                    {
                        Console.WriteLine("ERROR: No dol set");
                        Console.WriteLine("Error: SHARPII_NET_CORE_HBC_NO_DOL_01");
                        Environment.Exit(0x00003E84);
                        return;
                    }
                    input = args[i + 1];
                    //Check if file exists
                    if (File.Exists(input) == false)
                    {
                        Console.WriteLine("ERROR: Unable to open file: {0}", input);
                        Console.WriteLine("Either the file doesn't exist, or Sharpii doesn't have permission to open it.");
                        Console.WriteLine("Error: SHARPII_NET_CORE_HBC_FILE_ERR_01");
                        Environment.Exit(0x00003E81);
                        return;
                    }

                    if (i + 1 < args.Length)
                    {
                        for (int n = i + 2; n < args.Length; n++)
                        {
                            arguments = arguments + "\x0000";
                            arguments = arguments + args[n];
                        }
                    }
                    break;

                case "-NOCOMP":
                    compress = false;
                    break;

                case "-OLD":
                    protocol = "HAXX";
                    break;
                }
            }

            //Run main part, and check for exceptions
            try
            {
                if (ip != "" && saveip == true)
                {
                    if (BeQuiet.quiet > 2)
                    {
                        Console.WriteLine("Saving IP");
                    }
                    Environment.SetEnvironmentVariable("SharpiiIP", ip, EnvironmentVariableTarget.Machine);
                }

                if (String.IsNullOrEmpty(ip))
                {
                    ip = Environment.GetEnvironmentVariable("SharpiiIP", EnvironmentVariableTarget.User);
                }
                if (String.IsNullOrEmpty(ip))
                {
                    ip = Environment.GetEnvironmentVariable("SharpiiIP", EnvironmentVariableTarget.Machine);
                }
                if (String.IsNullOrEmpty(ip))
                {
                    Console.WriteLine("ERROR: No IP set");
                    Console.WriteLine("Error: SHARPII_NET_CORE_HBC_NO_IP_01");
                    Environment.Exit(0x00003E83);
                    return;
                }
                if (noip == true && BeQuiet.quiet > 2)
                {
                    Console.WriteLine("No IP set, using {0}", ip);
                }

                libWiiSharp.Protocol proto = Protocol.JODI;

                if (BeQuiet.quiet > 2 && protocol == "HAXX")
                {
                    Console.WriteLine("Using old protocol");
                }

                if (protocol == "HAXX")
                {
                    proto = Protocol.HAXX;
                }

                if (BeQuiet.quiet > 2)
                {
                    Console.Write("Loading File...");
                }

                HbcTransmitter file = new HbcTransmitter(proto, ip);

                if (BeQuiet.quiet > 2)
                {
                    Console.Write("Done!\n");
                }


                if (BeQuiet.quiet > 2 && compress == true)
                {
                    Console.Write("Compressing File...");
                }

                file.Compress = compress;

                if (BeQuiet.quiet > 2 && compress == true)
                {
                    Console.Write("Done!\n");
                }

                if (BeQuiet.quiet > 1)
                {
                    Console.Write("Sending file...");
                }

                file.TransmitFile(Path.GetFileName(input) + arguments, File.ReadAllBytes(input));

                if (BeQuiet.quiet > 1)
                {
                    Console.Write("Done!\n");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("An unknown error occured, please try again");
                Console.WriteLine("");
                Console.WriteLine("ERROR DETAILS: {0}", ex.Message);
                Console.WriteLine("Error: SHARPII_NET_CORE_HBC_UNKNOWN_01");
                Environment.Exit(0x00003E82);
                return;
            }

            return;
        }
コード例 #2
0
        public static void SendWad(string[] args)
        {
            string input    = "";
            string ip       = "";
            string ios      = "";
            string protocol = "JODI";
            bool   ahb      = false;
            bool   saveip   = false;
            bool   noip     = true;

            //Get parameters
            for (int i = 1; i < args.Length; i++)
            {
                switch (args[i].ToUpper())
                {
                case "-IOS":
                    if (i + 1 >= args.Length)
                    {
                        Console.WriteLine("ERROR: No ios set");
                        Console.WriteLine("Error: SHARPII_NET_CORE_HBC_NO_IOS_01");
                        Environment.Exit(0x00003E86);
                        return;
                    }
                    ios = args[i + 1];
                    if (!(Convert.ToInt32(ios) >= 3 && Convert.ToInt32(ios) <= 255))
                    {
                        Console.WriteLine("ERROR: Invalid IOS number");
                        Console.WriteLine("Error: SHARPII_NET_CORE_HBC_INVALID_IOS_01");
                        Environment.Exit(0x00003E87);
                        return;
                    }
                    break;

                case "-AHB":
                    ahb = true;
                    break;

                case "-IP":
                    if (i + 1 >= args.Length)
                    {
                        Console.WriteLine("ERROR: No ip set");
                        Console.WriteLine("Error: SHARPII_NET_CORE_HBC_NO_IP_01");
                        Environment.Exit(0x00003E83);
                        return;
                    }
                    ip   = args[i + 1];
                    noip = false;
                    break;

                case "-SAVEIP":
                    saveip = true;
                    break;

                case "-WAD":
                    if (i + 1 >= args.Length)
                    {
                        Console.WriteLine("ERROR: No WAD set");
                        Console.WriteLine("Error: SHARPII_NET_CORE_HBC_NO_WAD_01");
                        Environment.Exit(0x00003E88);
                        return;
                    }
                    input = args[i + 1];
                    //Check if file exists
                    if (File.Exists(input) == false)
                    {
                        Console.WriteLine("ERROR: Unable to open file: {0}", input);
                        Console.WriteLine("Error: SHARPII_NET_CORE_BNS_FILE_ERR_01");
                        Environment.Exit(0x00003E81);
                        return;
                    }
                    break;

                case "-OLD":
                    protocol = "HAXX";
                    break;
                }
            }

            //Run main part, and check for exceptions
            try
            {
                if (ip != "" && saveip == true)
                {
                    if (BeQuiet.quiet > 2)
                    {
                        Console.WriteLine("Saving IP");
                    }
                    Environment.SetEnvironmentVariable("SharpiiIP", ip, EnvironmentVariableTarget.Machine);
                }

                if (ahb == true || ios == "")
                {
                    if (BeQuiet.quiet > 2)
                    {
                        Console.WriteLine("Using AHBPROT");
                    }
                    ios = "0";
                }

                if (String.IsNullOrEmpty(ip))
                {
                    ip = Environment.GetEnvironmentVariable("SharpiiIP", EnvironmentVariableTarget.User);
                }
                if (String.IsNullOrEmpty(ip))
                {
                    ip = Environment.GetEnvironmentVariable("SharpiiIP", EnvironmentVariableTarget.Machine);
                }
                if (String.IsNullOrEmpty(ip))
                {
                    Console.WriteLine("ERROR: No IP set");
                    Console.WriteLine("Error: SHARPII_NET_CORE_HBC_NO_IP_01");
                    Environment.Exit(0x00003E83);
                    return;
                }
                if (noip == true && BeQuiet.quiet > 2)
                {
                    Console.WriteLine("No IP set, using {0}", ip);
                }

                libWiiSharp.Protocol proto = Protocol.JODI;

                if (BeQuiet.quiet > 2 && protocol == "HAXX")
                {
                    Console.WriteLine("Using old protocol");
                }

                if (protocol == "HAXX")
                {
                    proto = Protocol.HAXX;
                }

                if (BeQuiet.quiet > 2)
                {
                    Console.Write("Loading File...");
                }

                HbcTransmitter file      = new HbcTransmitter(proto, ip);
                byte[]         Installer = WadInstaller.InstallerHelper.CreateInstaller(input, (byte)Convert.ToInt32(ios)).ToArray();

                if (BeQuiet.quiet > 2)
                {
                    Console.Write("Done!\n");
                }

                if (BeQuiet.quiet > 1)
                {
                    Console.Write("Sending file...");
                }

                file.TransmitFile("WadInstaller.dol", Installer);

                if (BeQuiet.quiet > 1)
                {
                    Console.Write("Done!\n");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("An unknown error occured, please try again");
                Console.WriteLine("");
                Console.WriteLine("ERROR DETAILS: {0}", ex.Message);
                Console.WriteLine("Error: SHARPII_NET_CORE_HBC_UNKNOWN_01");
                Environment.Exit(0x00003E82);
                return;
            }

            return;
        }