Esempio n. 1
0
 public SMCConfig()
 {
     InitializeComponent();
     try
     {
         smc_config = Nand.Nand.getConfigValues(Nand.Nand.getsmcconfig(variables.filename1, out block_offset), block_offset);
     }
     catch (Exception ex) { if (variables.debugme)
                            {
                                Console.WriteLine(ex.ToString());
                            }
     }
 }
Esempio n. 2
0
        private void config_edit()
        {
            try
            {
                string newfile = Path.Combine(Path.GetDirectoryName(variables.filename1), Path.GetFileNameWithoutExtension(variables.filename1) + "_edited" + Path.GetExtension(variables.filename1));
                Console.WriteLine("Saving to {0}", newfile);
                File.Copy(variables.filename1, newfile, true);
                Nand.SMCConfig val = new Nand.SMCConfig(false);

                val.structure = Oper.StringToByteArray_v2(txtstructure.Text);
                val.config    = Oper.StringToByteArray_v2(txtconfig.Text);
                val.bit       = Oper.StringToByteArray_v2(txtbit.Text);
                val.mac       = Oper.StringToByteArray_v2(txtmac.Text.Replace("-", "").Replace(" ", ""));
                val.cpugain   = Oper.StringToByteArray_v2(txtcpugain.Text);
                val.cpuoff    = Oper.StringToByteArray_v2(txtcpuoff.Text);
                val.gpugain   = Oper.StringToByteArray_v2(txtgpugain.Text);
                val.gpuoff    = Oper.StringToByteArray_v2(txtgpuoff.Text);
                val.dramgain  = Oper.StringToByteArray_v2(txtedramgain.Text);
                val.dramoff   = Oper.StringToByteArray_v2(txtedramoff.Text);
                val.boardgain = Oper.StringToByteArray_v2(txtboardgain.Text);
                val.boardoff  = Oper.StringToByteArray_v2(txtboardoff.Text);
                val.ana       = Oper.StringToByteArray_v2(txtana.Text);
                val.anabackup = Oper.StringToByteArray_v2(txtanabackup.Text);
                val.clock     = Oper.StringToByteArray_v2(txtclock.Text);
                val.flags     = Oper.StringToByteArray_v2(txtflags.Text);
                val.version   = Oper.StringToByteArray_v2(txtversion.Text);
                val.net       = Oper.StringToByteArray_v2(txtnet.Text);

                val.reset = ascii.GetBytes(txtreset.Text);
                string thr = Oper.ByteArrayToString(smc_config.thermal);

                val.thermal = new byte[6];
                try
                {
                    var th  = txtthermal.Text.Split('C');
                    int len = th.Length < 6 ? th.Length : 6;
                    for (int i = 0; i < len; i++)
                    {
                        byte.TryParse(Regex.Replace(th[i], @"[^\d]", ""), out val.thermal[i]);
                    }
                }
                catch (Exception ex) { Console.WriteLine(ex.ToString()); }

                val.gainoff = Oper.StringToByteArray_v2(txtgainoff.Text.Replace(";", ""));

                val.dvdregion    = new byte[1];
                val.dvdregion[0] = comboDVD.SelectedIndex != 8 ? (byte)(comboDVD.SelectedIndex + 1) : (byte)0xFF;
                val.gameregion   = new byte[1];
                val.videoregion  = new byte[1];

                if (comboVideo.SelectedIndex == (int)VideoRegion.PAL)
                {
                    val.gameregion[0] = 0x02;
                }
                switch (comboGame.SelectedIndex)
                {
                case (int)GameRegion.USA:
                    val.videoregion[0] = 0xFF;
                    break;

                case (int)GameRegion.HK:
                    val.videoregion[0] = 0x01;
                    val.gameregion[0]  = 0x01;
                    break;

                case (int)GameRegion.KOR:
                    val.videoregion[0] = 0xFC;
                    val.gameregion[0]  = 0x01;
                    break;

                case (int)GameRegion.JAP:
                    val.videoregion[0] = 0xFF;
                    val.gameregion[0]  = 0x01;
                    break;

                case (int)GameRegion.AUS:
                    val.videoregion[0] = 0x01;
                    break;

                case (int)GameRegion.EU:
                    val.videoregion[0] = 0xFE;
                    break;
                }

                val.pwrmode  = Oper.StringToByteArray_v2(txtpwrmode.Text);
                val.powervcs = Oper.StringToByteArray_v2(txtpowervcs.Text);

                val.cpufanspeed = new byte[1];
                if (chkcpufanspeed.Checked)
                {
                    val.cpufanspeed[0] = 0x7F;
                }
                else
                {
                    val.cpufanspeed[0] = (byte)(trackCPU.Value + 0x80);
                }
                val.gpufanspeed = new byte[1];
                if (chkgpufanspeed.Checked)
                {
                    val.gpufanspeed[0] = 0x7F;
                }
                else
                {
                    val.gpufanspeed[0] = (byte)(trackGPU.Value + 0x80);
                }

                val.reserve0 = Oper.StringToByteArray_v2(txtreserve0.Text);
                val.reserve1 = Oper.StringToByteArray_v2(txtreserve1.Text);
                val.reserve2 = Oper.StringToByteArray_v2(txtreserve2.Text);
                val.reserve3 = Oper.StringToByteArray_v2(txtreserve3.Text);
                val.reserve4 = Oper.StringToByteArray_v2(txtreserve4.Text);
                val.reserve5 = Oper.StringToByteArray_v2(txtreserve5.Text);

                if (variables.debugme)
                {
                    Console.WriteLine("editing");
                }
                byte[] smc_conf = Nand.Nand.editConfigValues(newfile, val);
                if (variables.debugme)
                {
                    Console.WriteLine("injecting");
                }
                Nand.Nand.injectSMCConf(newfile, smc_conf);
            }
            catch (Exception ex) { Console.WriteLine(ex.Message); if (variables.debugme)
                                   {
                                       Console.WriteLine(ex.ToString());
                                   }
            }
            Console.WriteLine("Done");
        }