PirsEntry getEntry() { PirsEntry entry = new PirsEntry(); entry.Filename = readString(0x27); //Console.WriteLine(entry.FileName.Length); if (!String.IsNullOrWhiteSpace(entry.Filename.Trim())) { entry.Flags = br.ReadByte(); if (getBit(entry.Flags, 7)) { entry.Folder = true; } else { entry.Folder = false; } br.ReadBytes(0x3); entry.Blocklen = Oper.ByteArrayToInt(br.ReadBytes(0x3)); entry.Cluster = br.ReadInt32() >> 8; entry.Parent = (ushort)Convert.ToUInt32(Oper.ByteArrayToString(br.ReadBytes(2)), 16); entry.Size = Oper.ByteArrayToInt(br.ReadBytes(0x4)); entry.UpdateTime = dosDateTime(Oper.ByteArrayToInt(br.ReadBytes(0x4))); entry.AccessTime = dosDateTime(Oper.ByteArrayToInt(br.ReadBytes(0x4))); long pos = br.BaseStream.Position; entry.CRC = getCRC(br, entry.Cluster, entry.Size); br.BaseStream.Seek(pos, SeekOrigin.Begin); } return(entry); }
private int GetID() { UsbSetupPacket packet = new UsbSetupPacket(); UsbSetupPacket packetread = new UsbSetupPacket(); byte[] readBuffer = new byte[8]; byte buf = 0x48; int transfer = 0x08; packet.Value = 0x00; packet.Index = 0x00; packet.Length = 0x8; packet.Request = 0x30; packet.RequestType = (byte)UsbRequestType.TypeVendor; packetread.Value = 0x00; packetread.Index = 0x00; packetread.Length = 0x8; packetread.Request = 0x31; packetread.RequestType = 0xC0; byte[] ID = { 0x03, 0xEF, 0x20, 0x01 }; Console.WriteLine("Sending Flash ID..."); MyUsbDevice.ControlTransfer(ref packet, buf, 5, out transfer); if (MainForm.debugme) { Console.WriteLine("Length Transferred: {0}", transfer); } MyUsbDevice.ControlTransfer(ref packetread, readBuffer, 8, out transfer); if (MainForm.debugme) { Console.WriteLine("Length Transferred: {0}", transfer); } if (NandX.ByteArrayCompare(ID, Oper.returnportion(readBuffer, 1, 4))) { Console.WriteLine("ISD-2100 detected"); return(1); } else { Console.WriteLine("no ISD-2100 detected"); Console.WriteLine("In {0}", Oper.ByteArrayToString(readBuffer)); return(0); } }
private byte[] editbl(byte[] bl) { int length = Convert.ToInt32(Oper.ByteArrayToString(Oper.returnportion(bl, 0xC, 4)), 16); if (bl[0] == 0x43 && bl[1] == 0x42) { for (int i = 0x10; i < 0x40; i++) { bl[i] = 0x0; } } else if (bl[0] == 0x43 && bl[1] == 0x44) { for (int i = 0x10; i < 0x20; i++) { bl[i] = 0x0; } } else if (bl[0] == 0x43 && bl[1] == 0x45) { for (int i = 0x10; i < 0x20; i++) { bl[i] = 0x0; } } else if (bl[0] == 0x43 && bl[1] == 0x46) { for (int i = 0x20; i < 0x230; i++) { bl[i] = 0x0; } } else if (bl[0] == 0x43 && bl[1] == 0x47) { for (int i = 0x10; i < 0x20; i++) { bl[i] = 0x0; } } else { length = bl.Length; } return(Oper.returnportion(bl, 0, length)); }
private void extractUpd(byte[] upd, out byte[] cf, out byte[] cg) { int CFlength = Convert.ToInt32(Oper.ByteArrayToString(Oper.returnportion(upd, 0xC, 4)), 16); int CGlength = Convert.ToInt32(Oper.ByteArrayToString(Oper.returnportion(upd, CFlength + 0xC, 4)), 16); cf = Oper.returnportion(upd, 0, CFlength); cg = Oper.returnportion(upd, CFlength, CGlength); cf = Nand.Nand.decrypt_CF(cf); cg = Nand.Nand.decrypt_CG(cg, cf); crc32 crc = new crc32(); int dash = Convert.ToInt32(Oper.ByteArrayToString(Oper.returnportion(cf, 0x2, 2)), 16); Console.WriteLine("cf_" + dash + ".bin," + crc.CRC(editbl(cf)).ToString("X8").ToLower()); crc = new crc32(); dash = Convert.ToInt32(Oper.ByteArrayToString(Oper.returnportion(cg, 0x2, 2)), 16); Console.WriteLine("cg_" + dash + ".bin," + crc.CRC(editbl(cg)).ToString("X8").ToLower()); }
void send() { if (MyUsbDevice != null && MyUsbDevice.IsOpen) { Console.WriteLine("Device Already in Use"); return; } try { MyUsbDevice = UsbDevice.OpenUsbDevice(x360usb); if (MyUsbDevice == null) { Console.WriteLine("Device Not Found"); return; } //ErrorCode ec = ErrorCode.None; IUsbDevice wholeUsbDevice = MyUsbDevice as IUsbDevice; if (!ReferenceEquals(wholeUsbDevice, null)) { wholeUsbDevice.SetConfiguration(1); if (variables.debugme) { Console.WriteLine("Claiming Interface..."); } wholeUsbDevice.ClaimInterface(0); if (variables.debugme) { Console.WriteLine("The Interface is ours!"); } } UsbEndpointReader reader = MyUsbDevice.OpenEndpointReader(ReadEndpointID.Ep01); UsbEndpointWriter writer = MyUsbDevice.OpenEndpointWriter(WriteEndpointID.Ep01); ErrorCode ec = ErrorCode.None; int bytesRead = 1; int timeout = 500; byte[] writeBuffer = Oper.StringToByteArray_v2(txtBuffer.Text); byte[] readBuffer = new byte[64]; ec = writer.Write(writeBuffer, 500, out bytesRead); Console.WriteLine("Write {0} - Status: {1} - Length: {2}", Oper.ByteArrayToString(writeBuffer), ec, bytesRead); ec = reader.Read(readBuffer, timeout, out bytesRead); Console.WriteLine("Read - Status: {0} - Length: {1}", ec, bytesRead); Console.WriteLine(Oper.ByteArrayToString(readBuffer, 0, bytesRead)); Console.WriteLine("Sent"); //ec = reader.Read(readBuffer, timeout, out bytesRead); } catch (Exception ex) { Console.WriteLine(); Console.WriteLine(ex.Message); } finally { if (MyUsbDevice != null) { if (MyUsbDevice.IsOpen) { IUsbDevice wholeUsbDevice = MyUsbDevice as IUsbDevice; if (!ReferenceEquals(wholeUsbDevice, null)) { wholeUsbDevice.ReleaseInterface(0); } MyUsbDevice.Close(); } } MyUsbDevice = null; UsbDevice.Exit(); } }
void test() { if (MyUsbDevice != null && MyUsbDevice.IsOpen) { Console.WriteLine("Device Already in Use"); return; } try { MyUsbDevice = UsbDevice.OpenUsbDevice(x360usb); if (MyUsbDevice == null) { Console.WriteLine("Device Not Found"); return; } //ErrorCode ec = ErrorCode.None; IUsbDevice wholeUsbDevice = MyUsbDevice as IUsbDevice; if (!ReferenceEquals(wholeUsbDevice, null)) { wholeUsbDevice.SetConfiguration(1); if (variables.debugme) { Console.WriteLine("Claiming Interface..."); } wholeUsbDevice.ClaimInterface(0); if (variables.debugme) { Console.WriteLine("The Interface is ours!"); } } UsbEndpointReader reader = MyUsbDevice.OpenEndpointReader(ReadEndpointID.Ep01); UsbEndpointWriter writer = MyUsbDevice.OpenEndpointWriter(WriteEndpointID.Ep01); ErrorCode ec = ErrorCode.None; int bytesRead = 1; int timeout = 500; byte[] writeBuffer; byte[] readBuffer = new byte[4]; writeBuffer = new byte[] { 0x17, 0x00, 0x00 }; ec = writer.Write(writeBuffer, timeout, out bytesRead); Console.WriteLine("Write {0} - Status: {1} - Length: {2}", Oper.ByteArrayToString(writeBuffer), ec, bytesRead); ec = reader.Read(readBuffer, timeout, out bytesRead); Console.WriteLine("Read - Status: {0} - Length: {1}", ec, bytesRead); Console.WriteLine(Oper.ByteArrayToString(readBuffer)); readBuffer = new byte[4]; writeBuffer = new byte[] { 0x16, 0xA0, 0x00 }; ec = writer.Write(writeBuffer, timeout, out bytesRead); Console.WriteLine("Write {0} - Status: {1} - Length: {2}", Oper.ByteArrayToString(writeBuffer), ec, bytesRead); ec = reader.Read(readBuffer, timeout, out bytesRead); Console.WriteLine("Read - Status: {0} - Length: {1}", ec, bytesRead); Console.WriteLine(Oper.ByteArrayToString(readBuffer)); readBuffer = new byte[4]; writeBuffer = new byte[] { 0x27 }; ec = writer.Write(writeBuffer, timeout, out bytesRead); Console.WriteLine("Write {0} - Status: {1} - Length: {2}", Oper.ByteArrayToString(writeBuffer), ec, bytesRead); ec = reader.Read(readBuffer, timeout, out bytesRead); Console.WriteLine("Read - Status: {0} - Length: {1}", ec, bytesRead); Console.WriteLine(Oper.ByteArrayToString(readBuffer)); readBuffer = new byte[4]; writeBuffer = new byte[] { 0x27 }; ec = writer.Write(writeBuffer, timeout, out bytesRead); Console.WriteLine("Write {0} - Status: {1} - Length: {2}", Oper.ByteArrayToString(writeBuffer), ec, bytesRead); ec = reader.Read(readBuffer, timeout, out bytesRead); Console.WriteLine("Read - Status: {0} - Length: {1}", ec, bytesRead); Console.WriteLine(Oper.ByteArrayToString(readBuffer)); readBuffer = new byte[4]; writeBuffer = new byte[] { 0x26 }; ec = writer.Write(writeBuffer, timeout, out bytesRead); Console.WriteLine("Write {0} - Status: {1} - Length: {2}", Oper.ByteArrayToString(writeBuffer), ec, bytesRead); ec = reader.Read(readBuffer, timeout, out bytesRead); Console.WriteLine("Read - Status: {0} - Length: {1}", ec, bytesRead); Console.WriteLine(Oper.ByteArrayToString(readBuffer)); readBuffer = new byte[4]; writeBuffer = new byte[] { 0x17, 0xEC, 0x00 }; ec = writer.Write(writeBuffer, timeout, out bytesRead); Console.WriteLine("Write {0} - Status: {1} - Length: {2}", Oper.ByteArrayToString(writeBuffer), ec, bytesRead); ec = reader.Read(readBuffer, timeout, out bytesRead); Console.WriteLine("Read - Status: {0} - Length: {1}", ec, bytesRead); Console.WriteLine(Oper.ByteArrayToString(readBuffer)); readBuffer = new byte[4]; writeBuffer = new byte[] { 0x27 }; ec = writer.Write(writeBuffer, timeout, out bytesRead); Console.WriteLine("Write {0} - Status: {1} - Length: {2}", Oper.ByteArrayToString(writeBuffer), ec, bytesRead); ec = reader.Read(readBuffer, timeout, out bytesRead); Console.WriteLine("Read - Status: {0} - Length: {1}", ec, bytesRead); Console.WriteLine(Oper.ByteArrayToString(readBuffer)); readBuffer = new byte[4]; writeBuffer = new byte[] { 0x21 }; ec = writer.Write(writeBuffer, timeout, out bytesRead); Console.WriteLine("Write {0} - Status: {1} - Length: {2}", Oper.ByteArrayToString(writeBuffer), ec, bytesRead); ec = reader.Read(readBuffer, timeout, out bytesRead); Console.WriteLine("Read - Status: {0} - Length: {1}", ec, bytesRead); Console.WriteLine(Oper.ByteArrayToString(readBuffer)); readBuffer = new byte[4]; writeBuffer = new byte[] { 0x26 }; ec = writer.Write(writeBuffer, timeout, out bytesRead); Console.WriteLine("Write {0} - Status: {1} - Length: {2}", Oper.ByteArrayToString(writeBuffer), ec, bytesRead); ec = reader.Read(readBuffer, timeout, out bytesRead); Console.WriteLine("Read - Status: {0} - Length: {1}", ec, bytesRead); Console.WriteLine(Oper.ByteArrayToString(readBuffer)); readBuffer = new byte[4]; writeBuffer = new byte[] { 0x25 }; ec = writer.Write(writeBuffer, timeout, out bytesRead); Console.WriteLine("Write {0} - Status: {1} - Length: {2}", Oper.ByteArrayToString(writeBuffer), ec, bytesRead); ec = reader.Read(readBuffer, timeout, out bytesRead); Console.WriteLine("Read - Status: {0} - Length: {1}", ec, bytesRead); Console.WriteLine(Oper.ByteArrayToString(readBuffer)); readBuffer = new byte[4]; writeBuffer = new byte[] { 0x24 }; ec = writer.Write(writeBuffer, timeout, out bytesRead); Console.WriteLine("Write {0} - Status: {1} - Length: {2}", Oper.ByteArrayToString(writeBuffer), ec, bytesRead); ec = reader.Read(readBuffer, timeout, out bytesRead); Console.WriteLine("Read - Status: {0} - Length: {1}", ec, bytesRead); Console.WriteLine(Oper.ByteArrayToString(readBuffer)); readBuffer = new byte[4]; writeBuffer = new byte[] { 0x23 }; ec = writer.Write(writeBuffer, timeout, out bytesRead); Console.WriteLine("Write {0} - Status: {1} - Length: {2}", Oper.ByteArrayToString(writeBuffer), ec, bytesRead); ec = reader.Read(readBuffer, timeout, out bytesRead); Console.WriteLine("Read - Status: {0} - Length: {1}", ec, bytesRead); Console.WriteLine(Oper.ByteArrayToString(readBuffer)); readBuffer = new byte[4]; writeBuffer = new byte[] { 0x22 }; ec = writer.Write(writeBuffer, timeout, out bytesRead); Console.WriteLine("Write {0} - Status: {1} - Length: {2}", Oper.ByteArrayToString(writeBuffer), ec, bytesRead); ec = reader.Read(readBuffer, timeout, out bytesRead); Console.WriteLine("Read - Status: {0} - Length: {1}", ec, bytesRead); Console.WriteLine(Oper.ByteArrayToString(readBuffer)); readBuffer = new byte[4]; writeBuffer = new byte[] { 0x27 }; ec = writer.Write(writeBuffer, timeout, out bytesRead); Console.WriteLine("Write {0} - Status: {1} - Length: {2}", Oper.ByteArrayToString(writeBuffer), ec, bytesRead); ec = reader.Read(readBuffer, timeout, out bytesRead); Console.WriteLine("Read - Status: {0} - Length: {1}", ec, bytesRead); Console.WriteLine(Oper.ByteArrayToString(readBuffer)); readBuffer = new byte[4]; writeBuffer = new byte[] { 0x11, 0x00, 0x00 }; ec = writer.Write(writeBuffer, timeout, out bytesRead); Console.WriteLine("Write {0} - Status: {1} - Length: {2}", Oper.ByteArrayToString(writeBuffer), ec, bytesRead); ec = reader.Read(readBuffer, timeout, out bytesRead); Console.WriteLine("Read - Status: {0} - Length: {1}", ec, bytesRead); Console.WriteLine(Oper.ByteArrayToString(readBuffer)); readBuffer = new byte[4]; writeBuffer = new byte[] { 0x12, 0x00, 0x00 }; ec = writer.Write(writeBuffer, timeout, out bytesRead); Console.WriteLine("Write {0} - Status: {1} - Length: {2}", Oper.ByteArrayToString(writeBuffer), ec, bytesRead); ec = reader.Read(readBuffer, timeout, out bytesRead); Console.WriteLine("Read - Status: {0} - Length: {1}", ec, bytesRead); Console.WriteLine(Oper.ByteArrayToString(readBuffer)); readBuffer = new byte[4]; writeBuffer = new byte[] { 0x14, 0x00, 0x00 }; ec = writer.Write(writeBuffer, timeout, out bytesRead); Console.WriteLine("Write {0} - Status: {1} - Length: {2}", Oper.ByteArrayToString(writeBuffer), ec, bytesRead); ec = reader.Read(readBuffer, timeout, out bytesRead); Console.WriteLine("Read - Status: {0} - Length: {1}", ec, bytesRead); Console.WriteLine(Oper.ByteArrayToString(readBuffer)); readBuffer = new byte[4]; writeBuffer = new byte[] { 0x15, 0x02, 0x00 }; ec = writer.Write(writeBuffer, timeout, out bytesRead); Console.WriteLine("Write {0} - Status: {1} - Length: {2}", Oper.ByteArrayToString(writeBuffer), ec, bytesRead); ec = reader.Read(readBuffer, timeout, out bytesRead); Console.WriteLine("Read - Status: {0} - Length: {1}", ec, bytesRead); Console.WriteLine(Oper.ByteArrayToString(readBuffer)); readBuffer = new byte[4]; writeBuffer = new byte[] { 0x26 }; ec = writer.Write(writeBuffer, timeout, out bytesRead); Console.WriteLine("Write {0} - Status: {1} - Length: {2}", Oper.ByteArrayToString(writeBuffer), ec, bytesRead); ec = reader.Read(readBuffer, timeout, out bytesRead); Console.WriteLine("Read - Status: {0} - Length: {1}", ec, bytesRead); Console.WriteLine(Oper.ByteArrayToString(readBuffer)); readBuffer = new byte[4]; writeBuffer = new byte[] { 0x17, 0xA0, 0x00 }; ec = writer.Write(writeBuffer, timeout, out bytesRead); Console.WriteLine("Write {0} - Status: {1} - Length: {2}", Oper.ByteArrayToString(writeBuffer), ec, bytesRead); ec = reader.Read(readBuffer, timeout, out bytesRead); Console.WriteLine("Read - Status: {0} - Length: {1}", ec, bytesRead); Console.WriteLine(Oper.ByteArrayToString(readBuffer)); writeBuffer = new byte[] { 0x27 }; readBuffer = new byte[4]; ec = writer.Write(writeBuffer, timeout, out bytesRead); Console.WriteLine("Write {0} - Status: {1} - Length: {2}", Oper.ByteArrayToString(writeBuffer), ec, bytesRead); ec = reader.Read(readBuffer, timeout, out bytesRead); Console.WriteLine("Read - Status: {0} - Length: {1}", ec, bytesRead); Console.WriteLine(Oper.ByteArrayToString(readBuffer)); ec = writer.Write(writeBuffer, timeout, out bytesRead); readBuffer = new byte[4]; Console.WriteLine("Write {0} - Status: {1} - Length: {2}", Oper.ByteArrayToString(writeBuffer), ec, bytesRead); ec = reader.Read(readBuffer, timeout, out bytesRead); Console.WriteLine("Read - Status: {0} - Length: {1}", ec, bytesRead); Console.WriteLine(Oper.ByteArrayToString(readBuffer)); writeBuffer = new byte[] { 0x41, 0x0C, 0x12, 0x00, 0x00, 0x00, 0x60, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; readBuffer = new byte[4]; ec = writer.Write(writeBuffer, timeout, out bytesRead); Console.WriteLine("Write {0} - Status: {1} - Length: {2}", Oper.ByteArrayToString(writeBuffer), ec, bytesRead); ec = reader.Read(readBuffer, timeout, out bytesRead); Console.WriteLine("Read - Status: {0} - Length: {1}", ec, bytesRead); Console.WriteLine(Oper.ByteArrayToString(readBuffer)); writeBuffer = new byte[] { 0x27 }; readBuffer = new byte[4]; ec = writer.Write(writeBuffer, timeout, out bytesRead); Console.WriteLine("Write {0} - Status: {1} - Length: {2}", Oper.ByteArrayToString(writeBuffer), ec, bytesRead); ec = reader.Read(readBuffer, timeout, out bytesRead); Console.WriteLine("Read - Status: {0} - Length: {1}", ec, bytesRead); Console.WriteLine(Oper.ByteArrayToString(readBuffer)); readBuffer = new byte[4]; ec = writer.Write(writeBuffer, timeout, out bytesRead); Console.WriteLine("Write {0} - Status: {1} - Length: {2}", Oper.ByteArrayToString(writeBuffer), ec, bytesRead); ec = reader.Read(readBuffer, timeout, out bytesRead); Console.WriteLine("Read - Status: {0} - Length: {1}", ec, bytesRead); Console.WriteLine(Oper.ByteArrayToString(readBuffer)); readBuffer = new byte[4]; ec = writer.Write(writeBuffer, timeout, out bytesRead); Console.WriteLine("Write {0} - Status: {1} - Length: {2}", Oper.ByteArrayToString(writeBuffer), ec, bytesRead); ec = reader.Read(readBuffer, timeout, out bytesRead); Console.WriteLine("Read - Status: {0} - Length: {1}", ec, bytesRead); Console.WriteLine(Oper.ByteArrayToString(readBuffer)); writeBuffer = new byte[] { 0x25 }; readBuffer = new byte[4]; ec = writer.Write(writeBuffer, timeout, out bytesRead); Console.WriteLine("Write {0} - Status: {1} - Length: {2}", Oper.ByteArrayToString(writeBuffer), ec, bytesRead); ec = reader.Read(readBuffer, timeout, out bytesRead); Console.WriteLine("Read - Status: {0} - Length: {1}", ec, bytesRead); Console.WriteLine(Oper.ByteArrayToString(readBuffer)); writeBuffer = new byte[] { 0x24 }; readBuffer = new byte[4]; ec = writer.Write(writeBuffer, timeout, out bytesRead); Console.WriteLine("Write {0} - Status: {1} - Length: {2}", Oper.ByteArrayToString(writeBuffer), ec, bytesRead); ec = reader.Read(readBuffer, timeout, out bytesRead); Console.WriteLine("Read - Status: {0} - Length: {1}", ec, bytesRead); Console.WriteLine(Oper.ByteArrayToString(readBuffer)); writeBuffer = new byte[] { 0x40, 0x40 }; readBuffer = new byte[64]; ec = writer.Write(writeBuffer, timeout, out bytesRead); Console.WriteLine("Write {0} - Status: {1} - Length: {2}", Oper.ByteArrayToString(writeBuffer), ec, bytesRead); ec = reader.Read(readBuffer, timeout, out bytesRead); Console.WriteLine("Read - Status: {0} - Length: {1}", ec, bytesRead); Console.WriteLine(Encoding.ASCII.GetString(readBuffer)); Console.WriteLine("Sent"); //ec = reader.Read(readBuffer, timeout, out bytesRead); } catch (Exception ex) { Console.WriteLine(); Console.WriteLine(ex.Message); } finally { if (MyUsbDevice != null) { if (MyUsbDevice.IsOpen) { IUsbDevice wholeUsbDevice = MyUsbDevice as IUsbDevice; if (!ReferenceEquals(wholeUsbDevice, null)) { wholeUsbDevice.ReleaseInterface(0); } MyUsbDevice.Close(); } } MyUsbDevice = null; UsbDevice.Exit(); } }
private void SMCConfig_Load(object sender, EventArgs e) { if (smc_config.ok) { btnEdit.Enabled = true; txtchecksum.Text = Oper.ByteArrayToString(smc_config.checksum); txtstructure.Text = Oper.ByteArrayToString(smc_config.structure); txtconfig.Text = Oper.ByteArrayToString(smc_config.config); txtbit.Text = Oper.ByteArrayToString(smc_config.bit); txtmac.Text = Regex.Replace(Oper.ByteArrayToString(smc_config.mac), @"(.{2})(.{2})(.{2})(.{2})(.{2})(.{2})", @"$1 - $2 - $3 - $4 - $5 - $6"); txtcpugain.Text = Oper.ByteArrayToString(smc_config.cpugain); txtcpuoff.Text = Oper.ByteArrayToString(smc_config.cpuoff); txtgpugain.Text = Oper.ByteArrayToString(smc_config.gpugain); txtgpuoff.Text = Oper.ByteArrayToString(smc_config.gpuoff); txtedramgain.Text = Oper.ByteArrayToString(smc_config.dramgain); txtedramoff.Text = Oper.ByteArrayToString(smc_config.dramoff); txtboardgain.Text = Oper.ByteArrayToString(smc_config.boardgain); txtboardoff.Text = Oper.ByteArrayToString(smc_config.boardoff); txtana.Text = Oper.ByteArrayToString(smc_config.ana); txtanabackup.Text = Oper.ByteArrayToString(smc_config.anabackup); txtclock.Text = Oper.ByteArrayToString(smc_config.clock); txtflags.Text = Oper.ByteArrayToString(smc_config.flags); txtversion.Text = Oper.ByteArrayToString(smc_config.version); txtnet.Text = Oper.ByteArrayToString(smc_config.net); txtreset.Text = ascii.GetString(smc_config.reset); string thr = Oper.ByteArrayToString(smc_config.thermal); txtthermal.Text = Convert.ToInt32(thr.Substring(0, 2), 16).ToString() + "°C;" + Convert.ToInt32(thr.Substring(2, 2), 16).ToString() + "°C;" + Convert.ToInt32(thr.Substring(4, 2), 16).ToString() + "°C - " + Convert.ToInt32(thr.Substring(6, 2), 16).ToString() + "°C;" + Convert.ToInt32(thr.Substring(8, 2), 16).ToString() + "°C;" + Convert.ToInt32(thr.Substring(10, 2), 16).ToString() + "°C;"; txtgainoff.Text = Regex.Replace(Oper.ByteArrayToString(smc_config.gainoff), @"(.{4})(.{4})(.{4})(.{4})(.{4})(.{4})(.{4})(.{4})", @"$1;$2;$3;$4;$5;$6;$7;$8"); //txtdvdregion.Text = Oper.ByteArrayToString(smc_config.dvdregion); //txtgameregion.Text = Oper.ByteArrayToString(smc_config.gameregion); //txtvideoregion.Text = Oper.ByteArrayToString(smc_config.videoregion); switch (smc_config.dvdregion[0]) { case 0x01: comboDVD.SelectedIndex = 0; break; case 0x02: comboDVD.SelectedIndex = 1; break; case 0x03: comboDVD.SelectedIndex = 2; break; case 0x04: comboDVD.SelectedIndex = 3; break; case 0x05: comboDVD.SelectedIndex = 4; break; case 0x06: comboDVD.SelectedIndex = 5; break; case 0x07: comboDVD.SelectedIndex = 6; break; case 0x08: comboDVD.SelectedIndex = 7; break; case 0xFF: comboDVD.SelectedIndex = 8; break; } switch (smc_config.gameregion[0]) { case 0x00: comboVideo.SelectedIndex = (int)VideoRegion.NTSC; switch (smc_config.videoregion[0]) { case 0xFF: comboGame.SelectedIndex = (int)GameRegion.USA; break; } break; case 0x01: comboVideo.SelectedIndex = (int)VideoRegion.NTSC; switch (smc_config.videoregion[0]) { case 0x01: comboVideo.SelectedIndex = (int)GameRegion.HK; break; case 0xFC: comboVideo.SelectedIndex = (int)GameRegion.KOR; break; case 0xFE: case 0xFF: comboVideo.SelectedIndex = (int)GameRegion.JAP; break; } break; case 0x02: comboVideo.SelectedIndex = (int)VideoRegion.PAL; switch (smc_config.videoregion[0]) { case 0x01: comboGame.SelectedIndex = (int)GameRegion.AUS; break; case 0xFE: comboGame.SelectedIndex = (int)GameRegion.EU; break; } break; } txtpwrmode.Text = Oper.ByteArrayToString(smc_config.pwrmode); txtpowervcs.Text = Oper.ByteArrayToString(smc_config.powervcs); txtreserve0.Text = Oper.ByteArrayToString(smc_config.reserve0); txtreserve1.Text = Oper.ByteArrayToString(smc_config.reserve1); txtreserve2.Text = Oper.ByteArrayToString(smc_config.reserve2); txtreserve3.Text = Oper.ByteArrayToString(smc_config.reserve3); txtreserve4.Text = Oper.ByteArrayToString(smc_config.reserve4); txtreserve5.Text = Oper.ByteArrayToString(smc_config.reserve5); if (Oper.ByteArrayToString(smc_config.cpufanspeed) == "7F") { chkcpufanspeed.Checked = true; } else if ((smc_config.cpufanspeed[0]) >= 0x80) { chkcpufanspeed.Checked = false; chkcpufanspeed.Text = "CPU Fan Speed [Manual Mode]"; trackCPU.Visible = true; trackCPU.Value = (smc_config.cpufanspeed[0] - 0x80); } if (Oper.ByteArrayToString(smc_config.gpufanspeed) == "7F") { chkgpufanspeed.Checked = true; } else if ((smc_config.gpufanspeed[0]) >= 0x80) { chkgpufanspeed.Checked = false; chkgpufanspeed.Text = "GPU Fan Speed [Manual Mode]"; trackGPU.Enabled = true; trackGPU.Value = (smc_config.gpufanspeed[0] - 0x80); } } }
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"); }
private void update_ini(string filename) { string[] lines = File.ReadAllLines(filename); string old_version = "", new_version = ""; string cf_checksum = "", cg_checksum = ""; foreach (string s in lines) { if (s.Contains("cf_")) { old_version = s.Substring(3, 5); break; } } foreach (PirsEntry a in p.getList()) { if (a.Filename == "xboxupd.bin") { byte[] upd = p.extractFile(a.Cluster, a.Size); int CFlength = Convert.ToInt32(Oper.ByteArrayToString(Oper.returnportion(upd, 0xC, 4)), 16); int CGlength = Convert.ToInt32(Oper.ByteArrayToString(Oper.returnportion(upd, CFlength + 0xC, 4)), 16); byte[] cf = Oper.returnportion(upd, 0, CFlength); byte[] cg = Oper.returnportion(upd, CFlength, CGlength); cf = Nand.Nand.decrypt_CF(cf); cg = Nand.Nand.decrypt_CG(cg, cf); crc32 crc = new crc32(); new_version = Convert.ToInt32(Oper.ByteArrayToString(Oper.returnportion(cf, 0x2, 2)), 16).ToString(); cf_checksum = crc.CRC(editbl(cf)).ToString("X8").ToLower(); crc = new crc32(); cg_checksum = crc.CRC(editbl(cg)).ToString("X8").ToLower(); break; } } bool test = false; Console.WriteLine(old_version); Console.WriteLine(new_version); Console.WriteLine(cf_checksum); Console.WriteLine(cg_checksum); for (int i = 0; i < lines.Length; i++) { if (String.IsNullOrWhiteSpace(lines[i])) { continue; } string line = lines[i]; if (line.Contains(old_version)) { lines[i] = line.Replace(old_version, new_version); line = lines[i]; } if (line.Contains("cf_")) { lines[i] = line.Substring(0, line.IndexOf(',')) + "," + cf_checksum; } if (line.Contains("cg_")) { lines[i] = line.Substring(0, line.IndexOf(',')) + "," + cg_checksum; } if (line.Contains("[flashfs]")) { test = true; continue; } if (test) { if (!line.Contains(",")) { continue; } string name = line.Substring(0, line.IndexOf(',')); foreach (PirsEntry a in p.getList()) { if ("$flash_" + name == a.Filename) { lines[i] = name + "," + a.CRC.ToString("X8").ToLower(); break; } } } } File.WriteAllLines(Path.Combine(Path.GetDirectoryName(filename), Path.GetFileNameWithoutExtension(filename) + "_new" + Path.GetExtension(filename)), lines); }
int ReadUInt32_LE(byte[] data, int pos) { return((int)Convert.ToUInt32(Oper.ByteArrayToString(data), 16)); }
public static List <int> checkifremapped(byte[] reserved, List <int> badblocks, bool bigblock = false, bool stealth = false) { if (badblocks.Count == 0) { return(new List <int>()); } List <int> remappedlist = new List <int>(); for (int i = 0; i < badblocks.Count; i++) { remappedlist.Add(-1); } bool found = false; int left = 0, blocksize, reserveblockpos, markeroffset, idoffset; if (bigblock) { blocksize = 0x21000; markeroffset = 0x200; idoffset = 0x201; //reserveblockpos = 0x1FF; reserveblockpos = 0x200; } else { //reserveblockpos = 0x3FF; reserveblockpos = 0x400; blocksize = 0x4200; markeroffset = 0x205; idoffset = 0x200; } int reservestartpos = reserveblockpos - 0x20; //if (variables.debugme) Console.WriteLine("-C- Blocksize {0:X} - ReserveBlockPos {1:X} - ReserveStartPos {2:X} ", blocksize, reserveblockpos, reservestartpos); try { for (int block = 0x1F; block != 0x0; block--) { if (left == badblocks.Count) { break; } //if (variables.debugme) Console.WriteLine("-C- Block {0:X}", block); if (!Oper.allsame(Oper.returnportion(reserved, (blocksize * (block + 1)) - 0x10, 0x10), 0xFF) || !Oper.allsame(Oper.returnportion(reserved, (blocksize * block) + 0x200, 0x10), 0xFF)) { string blockid = Oper.ByteArrayToString(Oper.returnportion(reserved, (blocksize * (block + 1)) - (0x210 - idoffset), 0x4).Reverse().ToArray()); string blockid2 = Oper.ByteArrayToString(Oper.returnportion(reserved, (blocksize * (block)) + idoffset, 0x4).Reverse().ToArray()); if (blockid.Substring(6, 2) == "00") { blockid = blockid.Remove(6).Insert(0, "00"); } if (blockid2.Substring(6, 2) == "00") { blockid2 = blockid2.Remove(6).Insert(0, "00"); } //if (variables.debugme) Console.WriteLine("1 {0}", blockid); //if (variables.debugme) Console.WriteLine("2 {0}", blockid2); if (reserved.Length > ((blocksize * (block + 1)) - (0x210 - markeroffset))) { //if (variables.debugme) Console.WriteLine("{0:X} - {1:X}", (blocksize * (block + 1)) - (0x210 - markeroffset), (blocksize * block) + markeroffset); if ((reserved[(blocksize * (block + 1)) - (0x210 - markeroffset)] != 0xFF) && (reserved[(blocksize * block) + markeroffset] != 0xFF)) { continue; } } int index = 0; foreach (int bblocks in badblocks) { if (bblocks == -1) { continue; } if (remappedlist[index] != -1) { index++; continue; } //if (variables.debugme) Console.WriteLine("B {0:X}", (bblocks).ToString("X8")); if (blockid.Contains((bblocks).ToString("X8")) || blockid2.Contains((bblocks).ToString("X8"))) { found = true; remappedlist[index] = block; if ((stealth && variables.debugme) || !stealth) { Console.WriteLine("Bad Block ID {0:X4} Found @ 0x{1:X4} [Offset: 0x{2:X}]", badblocks[index], reservestartpos + block, blocksize * (reservestartpos + block)); } left++; break; } index++; } } } } catch (Exception ex) { Console.WriteLine(ex.Message.ToString()); if (variables.debugme) { Console.WriteLine(ex.ToString()); } } if (!found) { if ((variables.debugme)) { Console.WriteLine("Can't fix it. Remapped Blocks don't exist."); } return(remappedlist); } return(remappedlist); }