Advertisement
BsB5068

some of PS3 NAND ECC code

Dec 19th, 2013
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 47.18 KB | None | 0 0
  1. private bool KFu4(string string_1, string string_2, string string_3, ref int int_3, ref int int_4)
  2.  
  3. {
  4.  
  5. Stream input = new FileStream(string_2, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
  6.  
  7. Stream stream2 = new FileStream(string_3, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
  8.  
  9. BinaryReader reader = new BinaryReader(input);
  10.  
  11. BinaryReader reader2 = new BinaryReader(stream2);
  12.  
  13. string path = string_2 + ".new.bin";
  14.  
  15. string str2 = string_3 + ".new.bin";
  16.  
  17. if (File.Exists(path))
  18.  
  19. {
  20.  
  21. File.Delete(path);
  22.  
  23. }
  24.  
  25. if (File.Exists(str2))
  26.  
  27. {
  28.  
  29. File.Delete(str2);
  30.  
  31. }
  32.  
  33. Stream output = new FileStream(path, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.ReadWrite);
  34.  
  35. Stream stream4 = new FileStream(str2, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.ReadWrite);
  36.  
  37. BinaryWriter writer = new BinaryWriter(output);
  38.  
  39. BinaryWriter writer2 = new BinaryWriter(stream4);
  40.  
  41. Stream stream5 = new FileStream(string_1, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
  42.  
  43. BinaryReader reader3 = new BinaryReader(stream5);
  44.  
  45. string directoryName = Path.GetDirectoryName(string_2);
  46.  
  47. if (!Directory.Exists(directoryName + @"\Differential Flashing"))
  48.  
  49. {
  50.  
  51. Directory.CreateDirectory(directoryName + @"\Differential Flashing");
  52.  
  53. }
  54.  
  55. TextWriter writer3 = File.CreateText(directoryName + @"\Differential Flashing\DifferenceFileFlash0.txt");
  56.  
  57. string str4 = Path.GetDirectoryName(string_3);
  58.  
  59. if (!Directory.Exists(str4 + @"\Differential Flashing"))
  60.  
  61. {
  62.  
  63. Directory.CreateDirectory(str4 + @"\Differential Flashing");
  64.  
  65. }
  66.  
  67. TextWriter writer4 = File.CreateText(str4 + @"\Differential Flashing\DifferenceFileFlash1.txt");
  68.  
  69. List<int> list = new List<int>();
  70.  
  71. List<int> list2 = new List<int>();
  72.  
  73. this.KoXQ.Value = 0;
  74.  
  75. this.KoXQ.Maximum = ((int) (input.Length / 0x21000L)) + 1;
  76.  
  77. for (int i = 0; i < (input.Length / 0x21000L); i++)
  78.  
  79. {
  80.  
  81. byte[] buffer = new byte[0x40000];
  82.  
  83. byte[] buffer2 = new byte[0x40000];
  84.  
  85. byte[] destinationArray = new byte[0x21000];
  86.  
  87. byte[] buffer4 = new byte[0x21000];
  88.  
  89. long offset = 0L;
  90.  
  91. long num4 = 0L;
  92.  
  93. byte[] buffer5 = new byte[0x40];
  94.  
  95. byte[] buffer6 = new byte[0x40];
  96.  
  97. byte[] buffer7 = new byte[0x200];
  98.  
  99. byte[] buffer8 = new byte[0x200];
  100.  
  101. int num5 = this.K6AvpR.BlockPhyToLogIndex(i);
  102.  
  103. if ((num5 < 0) || (num5 > 0x3ff))
  104.  
  105. {
  106.  
  107. throw new Exception("Error: Physical block out of range!");
  108.  
  109. }
  110.  
  111. offset = ((num5 * 0x800) * 0x40) * 2;
  112.  
  113. stream5.Seek(offset, SeekOrigin.Begin);
  114.  
  115. reader3.Read(buffer2, 0, buffer2.Length);
  116.  
  117. for (int m = 0; m < buffer2.Length; m += 2)
  118.  
  119. {
  120.  
  121. Array.Reverse(buffer2, m, 2);
  122.  
  123. }
  124.  
  125. num5 = this.KXyytIvy8Axe3B.BlockPhyToLogIndex(i);
  126.  
  127. if ((num5 < 0) || (num5 > 0x3ff))
  128.  
  129. {
  130.  
  131. throw new Exception("Error: Physical block out of range!");
  132.  
  133. }
  134.  
  135. long num2 = ((num5 * 0x800) * 0x40) * 2;
  136.  
  137. stream5.Seek(num2, SeekOrigin.Begin);
  138.  
  139. if (num2 != offset)
  140.  
  141. {
  142.  
  143. reader3.Read(buffer, 0, buffer.Length);
  144.  
  145. for (int num7 = 0; num7 < buffer.Length; num7 += 2)
  146.  
  147. {
  148.  
  149. Array.Reverse(buffer, num7, 2);
  150.  
  151. }
  152.  
  153. }
  154.  
  155. else
  156.  
  157. {
  158.  
  159. Array.Copy(buffer2, 0, buffer, 0, buffer.Length);
  160.  
  161. }
  162.  
  163. byte[] sourceArray = new byte[10];
  164.  
  165. for (int n = 0; n < 0x40; n++)
  166.  
  167. {
  168.  
  169. num4 = (((i * 0x840) * 0x40) + (0x840 * n)) + 0x800;
  170.  
  171. stream2.Seek(num4, SeekOrigin.Begin);
  172.  
  173. reader2.Read(buffer6, 0, buffer6.Length);
  174.  
  175. Array.Copy(buffer6, 0, buffer4, (n * 0x840) + 0x800, buffer6.Length);
  176.  
  177. input.Seek(num4, SeekOrigin.Begin);
  178.  
  179. reader.Read(buffer5, 0, buffer5.Length);
  180.  
  181. Array.Copy(buffer5, 0, destinationArray, (n * 0x840) + 0x800, buffer5.Length);
  182.  
  183. int num9 = 0;
  184.  
  185. for (int num10 = 0; num10 < 4; num10++)
  186.  
  187. {
  188.  
  189. int num11 = (((i * 0x840) * 0x40) + (n * 0x840)) + (num10 * 0x200);
  190.  
  191. stream2.Seek((long) num11, SeekOrigin.Begin);
  192.  
  193. reader2.Read(buffer8, 0, buffer8.Length);
  194.  
  195. Array.Copy(buffer2, (n * 0x1000) + (num9 * 0x200), buffer4, (n * 0x840) + (num10 * 0x200), 0x200);
  196.  
  197. if (!this.K6AvpR.IsBadBlock(i) && !GPF.memcmp(buffer4, (n * 0x840) + (num10 * 0x200), buffer8, 0, 0x200))
  198.  
  199. {
  200.  
  201. sourceArray = this.KXyytIvy8Axe3B(buffer4, (n * 0x840) + (num10 * 0x200));
  202.  
  203. Array.Copy(sourceArray, 0, buffer4, (((n * 0x840) + 0x800) + 8) + (num10 * 14), sourceArray.Length);
  204.  
  205. int item = (i * 0x840) * 0x40;
  206.  
  207. if (!list2.Contains(item))
  208.  
  209. {
  210.  
  211. list2.Add(item);
  212.  
  213. }
  214.  
  215. }
  216.  
  217. num9++;
  218.  
  219. num11 = (((i * 0x840) * 0x40) + (n * 0x840)) + (num10 * 0x200);
  220.  
  221. input.Seek((long) num11, SeekOrigin.Begin);
  222.  
  223. reader.Read(buffer7, 0, buffer7.Length);
  224.  
  225. Array.Copy(buffer, (n * 0x1000) + (num9 * 0x200), destinationArray, (n * 0x840) + (num10 * 0x200), 0x200);
  226.  
  227. if (!this.KXyytIvy8Axe3B.IsBadBlock(i) && !GPF.memcmp(destinationArray, (n * 0x840) + (num10 * 0x200), buffer7, 0, 0x200))
  228.  
  229. {
  230.  
  231. sourceArray = this.KXyytIvy8Axe3B(destinationArray, (n * 0x840) + (num10 * 0x200));
  232.  
  233. Array.Copy(sourceArray, 0, destinationArray, (((n * 0x840) + 0x800) + 8) + (num10 * 14), sourceArray.Length);
  234.  
  235. int num13 = (i * 0x840) * 0x40;
  236.  
  237. if (!list.Contains(num13))
  238.  
  239. {
  240.  
  241. list.Add(num13);
  242.  
  243. }
  244.  
  245. }
  246.  
  247. num9++;
  248.  
  249. }
  250.  
  251. }
  252.  
  253. writer2.Write(buffer4);
  254.  
  255. writer.Write(destinationArray);
  256.  
  257. Application.DoEvents();
  258.  
  259. this.KoXQ.Value++;
  260.  
  261. }
  262.  
  263. for (int j = 0; j < list.Count; j++)
  264.  
  265. {
  266.  
  267. writer3.WriteLine("0x" + string.Format("{0:X8}", list[j]));
  268.  
  269. }
  270.  
  271. for (int k = 0; k < list2.Count; k++)
  272.  
  273. {
  274.  
  275. writer4.WriteLine("0x" + string.Format("{0:X8}", list2[k]));
  276.  
  277. }
  278.  
  279. int_3 = list.Count;
  280.  
  281. int_4 = list2.Count;
  282.  
  283. writer3.Close();
  284.  
  285. writer4.Close();
  286.  
  287. reader.Close();
  288.  
  289. reader2.Close();
  290.  
  291. writer.Close();
  292.  
  293. writer2.Close();
  294.  
  295. reader3.Close();
  296.  
  297. return true;
  298.  
  299. }
  300.  
  301.  
  302.  
  303.  
  304.  
  305. ----------------------------------
  306.  
  307.  
  308.  
  309. private bool KoXQ(string string_1, string string_2, string string_3)
  310.  
  311. {
  312.  
  313. Stream input = new FileStream(string_1, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
  314.  
  315. Stream stream2 = new FileStream(string_2, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
  316.  
  317. BinaryReader reader = new BinaryReader(input);
  318.  
  319. BinaryReader reader2 = new BinaryReader(stream2);
  320.  
  321. if (File.Exists(string_3))
  322.  
  323. {
  324.  
  325. File.Delete(string_3);
  326.  
  327. }
  328.  
  329. Stream output = new FileStream(string_3, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.ReadWrite);
  330.  
  331. BinaryWriter writer = new BinaryWriter(output);
  332.  
  333. this.KoXQ.Value = 0;
  334.  
  335. this.KoXQ.Maximum = ((int) (input.Length / 0x21000L)) + 1;
  336.  
  337. new ArrayList();
  338.  
  339. for (int i = 0; i < (input.Length / 0x21000L); i++)
  340.  
  341. {
  342.  
  343. int num2 = this.KXyytIvy8Axe3B.BlockLogToPhyIndex(i);
  344.  
  345. if ((num2 >= 0) && (num2 <= 0x3ff))
  346.  
  347. {
  348.  
  349. long offset = num2 * 0x21000;
  350.  
  351. input.Seek(offset, SeekOrigin.Begin);
  352.  
  353. }
  354.  
  355. num2 = this.K6AvpR.BlockLogToPhyIndex(i);
  356.  
  357. if ((num2 >= 0) && (num2 <= 0x3ff))
  358.  
  359. {
  360.  
  361. long num4 = num2 * 0x21000;
  362.  
  363. stream2.Seek(num4, SeekOrigin.Begin);
  364.  
  365. }
  366.  
  367. byte[] buffer = new byte[0x21000];
  368.  
  369. byte[] buffer2 = new byte[0x21000];
  370.  
  371. byte[] destinationArray = new byte[0x40000];
  372.  
  373. reader2.Read(buffer2, 0, buffer2.Length);
  374.  
  375. reader.Read(buffer, 0, buffer.Length);
  376.  
  377. int num5 = 0;
  378.  
  379. for (int j = 0; j < 0x40; j++)
  380.  
  381. {
  382.  
  383. int num7 = 0;
  384.  
  385. for (int m = 0; m < 4; m++)
  386.  
  387. {
  388.  
  389. Array.Copy(buffer2, (j * 0x840) + (m * 0x200), destinationArray, (j * 0x800) + ((num5 + num7) * 0x200), 0x200);
  390.  
  391. num7++;
  392.  
  393. Array.Copy(buffer, (j * 0x840) + (m * 0x200), destinationArray, (j * 0x800) + ((num5 + num7) * 0x200), 0x200);
  394.  
  395. num7++;
  396.  
  397. }
  398.  
  399. num5 += 4;
  400.  
  401. }
  402.  
  403. for (int k = 0; k < destinationArray.Length; k += 2)
  404.  
  405. {
  406.  
  407. Array.Reverse(destinationArray, k, 2);
  408.  
  409. }
  410.  
  411. writer.Write(destinationArray);
  412.  
  413. Application.DoEvents();
  414.  
  415. this.KoXQ.Value++;
  416.  
  417. }
  418.  
  419. reader.Close();
  420.  
  421. reader2.Close();
  422.  
  423. writer.Close();
  424.  
  425. return true;
  426.  
  427. }
  428.  
  429.  
  430.  
  431.  
  432.  
  433. ---------------------------------------------
  434.  
  435.  
  436.  
  437.  
  438.  
  439. private bool K7eyXIv(string string_1, bool bool_0)
  440.  
  441. {
  442.  
  443. byte[] buffer3;
  444.  
  445. string str6;
  446.  
  447. int num18;
  448.  
  449. uint num = 0;
  450.  
  451. uint num2 = 0;
  452.  
  453. uint num3 = 0;
  454.  
  455. uint num4 = 0;
  456.  
  457. uint num5 = 0;
  458.  
  459. uint num6 = 0;
  460.  
  461. uint num7 = 0;
  462.  
  463. long length = 0L;
  464.  
  465. long offset = 0L;
  466.  
  467. string str = "";
  468.  
  469. Stream input = new FileStream(string_1, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
  470.  
  471. BinaryReader reader = new BinaryReader(input);
  472.  
  473. Directory.CreateDirectory(this.KE405Sp.PathFileDir + ".LOGS");
  474.  
  475. Thread.Sleep(100);
  476.  
  477. TextWriter writer = File.CreateText(this.KE405Sp.PathFileDir + @".LOGS\ExtractionLog.txt");
  478.  
  479. string path = "";
  480.  
  481. if (bool_0)
  482.  
  483. {
  484.  
  485. path = string_1 + this.string_0;
  486.  
  487. }
  488.  
  489. else
  490.  
  491. {
  492.  
  493. path = string_1 + "REB";
  494.  
  495. }
  496.  
  497. if (Directory.Exists(path))
  498.  
  499. {
  500.  
  501. Directory.Delete(path, true);
  502.  
  503. Thread.Sleep(100);
  504.  
  505. }
  506.  
  507. Directory.CreateDirectory(path);
  508.  
  509. Thread.Sleep(100);
  510.  
  511. byte[] buffer = new byte[0x40000];
  512.  
  513. byte[] sourceArray = new byte[0x1000];
  514.  
  515. byte[] buffer4 = new byte[8];
  516.  
  517. byte[] destinationArray = new byte[4];
  518.  
  519. byte[] buffer6 = new byte[4];
  520.  
  521. byte[] buffer7 = new byte[4];
  522.  
  523. byte[] buffer8 = new byte[0x20];
  524.  
  525. byte[] buffer9 = new byte[8];
  526.  
  527. string str3 = "";
  528.  
  529. Stream output = null;
  530.  
  531. BinaryWriter writer2 = null;
  532.  
  533. int num10 = 0;
  534.  
  535. if ((this.K5d2.SelectedIndex != 2) && (this.K5d2.SelectedIndex != 3))
  536.  
  537. {
  538.  
  539. num10 = 0;
  540.  
  541. }
  542.  
  543. else
  544.  
  545. {
  546.  
  547. num10 = 0xfc0000;
  548.  
  549. }
  550.  
  551. input.Seek((long) num10, SeekOrigin.Begin);
  552.  
  553. this.KoXQ.Value = 0;
  554.  
  555. this.KoXQ.Maximum = 3;
  556.  
  557. buffer = reader.ReadBytes(0x40000);
  558.  
  559. Application.DoEvents();
  560.  
  561. this.KoXQ.Value++;
  562.  
  563. str3 = "bootloader_0";
  564.  
  565. output = new FileStream(path + @"\" + str3, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.ReadWrite);
  566.  
  567. writer2 = new BinaryWriter(output);
  568.  
  569. writer2.Write(buffer);
  570.  
  571. writer2.Close();
  572.  
  573. writer.WriteLine(path + @"\bootloader_0");
  574.  
  575. string[] strArray = new string[] { "start offset: ", num10.ToString("D10"), " (Dec) / ", string.Format("{0:X10}", num10), " (Hex) - size: ", buffer.Length.ToString("D10"), " (Dec) / ", string.Format("{0:X10}", buffer.Length), " (Hex)" };
  576.  
  577. writer.WriteLine(string.Concat(strArray));
  578.  
  579. writer.WriteLine();
  580.  
  581. Array.Copy(buffer, 0, buffer9, 0, buffer9.Length);
  582.  
  583. Application.DoEvents();
  584.  
  585. this.KoXQ.Value++;
  586.  
  587. input.Seek(0L, SeekOrigin.Begin);
  588.  
  589. if ((this.K5d2.SelectedIndex != 2) && (this.K5d2.SelectedIndex != 3))
  590.  
  591. {
  592.  
  593. input.Seek((long) buffer.Length, SeekOrigin.Begin);
  594.  
  595. }
  596.  
  597. else
  598.  
  599. {
  600.  
  601. input.Seek(0L, SeekOrigin.Begin);
  602.  
  603. }
  604.  
  605. buffer = reader.ReadBytes(0x40000);
  606.  
  607. byte[] candidate = new byte[] { 0, 0, 0, 0, 15, 0xac, 0xe0, 0xff, 0, 0, 0, 0, 0xde, 0xad, 190, 0xef };
  608.  
  609. offset = buffer.Locate(candidate);
  610.  
  611. int num11 = 0;
  612.  
  613. if ((this.K5d2.SelectedIndex != 2) && (this.K5d2.SelectedIndex != 3))
  614.  
  615. {
  616.  
  617. num7 = (uint) ((buffer.Length + ((uint) offset)) + 0x1f0);
  618.  
  619. num11 = 500;
  620.  
  621. }
  622.  
  623. else
  624.  
  625. {
  626.  
  627. num7 = 0x400;
  628.  
  629. num11 = 0x3f4;
  630.  
  631. }
  632.  
  633. Array.Copy(buffer, offset + num11, destinationArray, 0L, (long) destinationArray.Length);
  634.  
  635. Array.Reverse(destinationArray);
  636.  
  637. uint num12 = BitConverter.ToUInt32(destinationArray, 0);
  638.  
  639. if ((num12 < 0) || (num12 > 0x186a0))
  640.  
  641. {
  642.  
  643. writer.Close();
  644.  
  645. reader.Close();
  646.  
  647. return false;
  648.  
  649. }
  650.  
  651. if ((this.K5d2.SelectedIndex != 2) && (this.K5d2.SelectedIndex != 3))
  652.  
  653. {
  654.  
  655. offset += 0x200L;
  656.  
  657. }
  658.  
  659. else
  660.  
  661. {
  662.  
  663. offset += 0x400L;
  664.  
  665. }
  666.  
  667. this.KoXQ.Value = 0;
  668.  
  669. this.KoXQ.Maximum = ((int) num12) + 1;
  670.  
  671. for (int i = 0; i < num12; i++)
  672.  
  673. {
  674.  
  675. Array.Copy(buffer, offset + 4L, buffer6, 0L, (long) buffer6.Length);
  676.  
  677. Array.Reverse(buffer6);
  678.  
  679. num = BitConverter.ToUInt32(buffer6, 0) + num7;
  680.  
  681. Array.Copy(buffer, offset + 12L, buffer7, 0L, (long) buffer7.Length);
  682.  
  683. Array.Reverse(buffer7);
  684.  
  685. num2 = BitConverter.ToUInt32(buffer7, 0);
  686.  
  687. Array.Copy(buffer, offset + 0x10L, buffer8, 0L, (long) buffer8.Length);
  688.  
  689. str3 = this.KueZWIbD0qeSJp0(buffer8);
  690.  
  691. if (str3.Length > 0)
  692.  
  693. {
  694.  
  695. str3 = str3.Remove(0, 1);
  696.  
  697. }
  698.  
  699. if (((str3 == "os") || (str3 == "os0")) || ((str3 == "os1") || (str3 == "secure_loader")))
  700.  
  701. {
  702.  
  703. Directory.CreateDirectory(path + @"\" + str3);
  704.  
  705. Thread.Sleep(100);
  706.  
  707. str3 = str3 + ".raw";
  708.  
  709. if (str3 == "os.raw")
  710.  
  711. {
  712.  
  713. num3 = num;
  714.  
  715. }
  716.  
  717. else if (str3 == "os0.raw")
  718.  
  719. {
  720.  
  721. num4 = num;
  722.  
  723. }
  724.  
  725. else if (str3 == "os1.raw")
  726.  
  727. {
  728.  
  729. num5 = num;
  730.  
  731. }
  732.  
  733. else if (str3 == "secure_loader.raw")
  734.  
  735. {
  736.  
  737. num6 = num;
  738.  
  739. }
  740.  
  741. }
  742.  
  743. input.Seek((long) num, SeekOrigin.Begin);
  744.  
  745. buffer3 = new byte[num2];
  746.  
  747. buffer3 = reader.ReadBytes((int) num2);
  748.  
  749. output = new FileStream(path + @"\" + str3, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.ReadWrite);
  750.  
  751. writer2 = new BinaryWriter(output);
  752.  
  753. writer2.Write(buffer3);
  754.  
  755. writer2.Close();
  756.  
  757. if (str3.Substring(str3.Length - 3, 3) != "raw")
  758.  
  759. {
  760.  
  761. writer.WriteLine(path + @"\" + str3);
  762.  
  763. writer.WriteLine("start offset: " + num.ToString("D10") + " (Dec) / " + string.Format("{0:X10}", num) + " (Hex) - size: " + num2.ToString("D10") + " (Dec) / " + string.Format("{0:X10}", num2) + " (Hex)");
  764.  
  765. writer.WriteLine();
  766.  
  767. }
  768.  
  769. offset += 0x30L;
  770.  
  771. Application.DoEvents();
  772.  
  773. this.KoXQ.Value++;
  774.  
  775. }
  776.  
  777. if ((this.K5d2.SelectedIndex != 2) && (this.K5d2.SelectedIndex != 3))
  778.  
  779. {
  780.  
  781. this.KoXQ.Value = 0;
  782.  
  783. this.KoXQ.Maximum = 3;
  784.  
  785. input.Seek(0xec0000L, SeekOrigin.Begin);
  786.  
  787. buffer3 = new byte[0x1080000];
  788.  
  789. length = reader.ReadBytes(buffer3.Length).Locate(buffer9, 0L);
  790.  
  791. if (offset != -1L)
  792.  
  793. {
  794.  
  795. offset = length + 0xec0000L;
  796.  
  797. Application.DoEvents();
  798.  
  799. this.KoXQ.Value++;
  800.  
  801. input.Seek(offset, SeekOrigin.Begin);
  802.  
  803. buffer3 = new byte[0x40000];
  804.  
  805. buffer3 = reader.ReadBytes(buffer3.Length);
  806.  
  807. writer.WriteLine(path + @"\bootloader_1");
  808.  
  809. string[] strArray3 = new string[] { "start offset: ", offset.ToString("D10"), " (Dec) / ", string.Format("{0:X10}", offset), " (Hex) - size: ", buffer3.Length.ToString("D10"), " (Dec) / ", string.Format("{0:X10}", buffer3.Length), " (Hex)" };
  810.  
  811. writer.WriteLine(string.Concat(strArray3));
  812.  
  813. writer.WriteLine();
  814.  
  815. Application.DoEvents();
  816.  
  817. this.KoXQ.Value++;
  818.  
  819. output = new FileStream(path + @"\bootloader_1", FileMode.CreateNew, FileAccess.ReadWrite, FileShare.ReadWrite);
  820.  
  821. writer2 = new BinaryWriter(output);
  822.  
  823. writer2.Write(buffer3);
  824.  
  825. writer2.Close();
  826.  
  827. TextWriter writer3 = File.CreateText(this.KE405Sp.PathFileDir + @".LOGS\BootloadersDiff.txt");
  828.  
  829. long num14 = this.Kmuq9(path + @"\bootloader_0", path + @"\bootloader_1");
  830.  
  831. if (num14 != 0L)
  832.  
  833. {
  834.  
  835. writer3.WriteLine("bootloader_0 and bootloader_1 are different from value at offset: " + num14.ToString("D10") + " (Dec) / " + string.Format("{0:X10}", num14) + " (Hex)");
  836.  
  837. }
  838.  
  839. else
  840.  
  841. {
  842.  
  843. writer3.WriteLine("bootloader_0 and bootloader_1 are equals.");
  844.  
  845. }
  846.  
  847. writer3.Close();
  848.  
  849. Application.DoEvents();
  850.  
  851. this.KoXQ.Value++;
  852.  
  853. }
  854.  
  855. }
  856.  
  857. this.KoXQ.Value = 0;
  858.  
  859. this.KoXQ.Maximum = 3;
  860.  
  861. byte[] buffer11 = new byte[] { 0x63, 0x65, 0x6c, 0x6c, 0x5f, 0x65, 120, 0x74, 0x5f, 0x6f, 0x73, 0x5f, 0x61, 0x72, 0x65, 0x61 };
  862.  
  863. byte[] buffer12 = new byte[] { 0x43, 0x45, 0x4c, 0x4c, 0x5f, 0x45, 0x58, 0x54, 0x4e, 0x4f, 0x52, 0x5f, 0x41, 0x52, 0x45, 0x41 };
  864.  
  865. input.Seek(0xec0000L, SeekOrigin.Begin);
  866.  
  867. buffer3 = new byte[0x1080000];
  868.  
  869. buffer3 = reader.ReadBytes(buffer3.Length);
  870.  
  871. string str4 = "";
  872.  
  873. int num15 = 0;
  874.  
  875. if ((this.K5d2.SelectedIndex != 2) && (this.K5d2.SelectedIndex != 3))
  876.  
  877. {
  878.  
  879. offset = buffer3.Locate(buffer11);
  880.  
  881. str4 = "cell_ext_os_area";
  882.  
  883. num15 = 0x400000;
  884.  
  885. }
  886.  
  887. else
  888.  
  889. {
  890.  
  891. offset = buffer3.Locate(buffer12);
  892.  
  893. str4 = "cell_extnor_area";
  894.  
  895. length = input.Length;
  896.  
  897. num15 = 0xa0000;
  898.  
  899. }
  900.  
  901. if ((offset != -1L) && (offset < length))
  902.  
  903. {
  904.  
  905. offset += 0xec0000L;
  906.  
  907. Application.DoEvents();
  908.  
  909. this.KoXQ.Value++;
  910.  
  911. input.Seek(offset, SeekOrigin.Begin);
  912.  
  913. buffer3 = new byte[num15];
  914.  
  915. buffer3 = reader.ReadBytes(buffer3.Length);
  916.  
  917. Application.DoEvents();
  918.  
  919. this.KoXQ.Value++;
  920.  
  921. output = new FileStream(path + @"\" + str4, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.ReadWrite);
  922.  
  923. writer2 = new BinaryWriter(output);
  924.  
  925. writer2.Write(buffer3);
  926.  
  927. writer2.Close();
  928.  
  929. writer.WriteLine(path + @"\" + str4);
  930.  
  931. string[] strArray5 = new string[] { "start offset: ", offset.ToString("D10"), " (Dec) / ", string.Format("{0:X10}", offset), " (Hex) - size: ", buffer3.Length.ToString("D10"), " (Dec) / ", string.Format("{0:X10}", buffer3.Length), " (Hex)" };
  932.  
  933. writer.WriteLine(string.Concat(strArray5));
  934.  
  935. writer.WriteLine();
  936.  
  937. Application.DoEvents();
  938.  
  939. this.KoXQ.Value++;
  940.  
  941. }
  942.  
  943. try
  944.  
  945. {
  946.  
  947. input = new FileStream(path + @"\secure_loader.raw", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
  948.  
  949. }
  950.  
  951. catch (FileNotFoundException)
  952.  
  953. {
  954.  
  955. string text = "WARNING!\n\nIt seems like you inverted the Flash 0/1 in the selection.\n\nIt could be that this is a USA dump and most modders invert the flashes\nduring the installation. It's not a big deal, infectus works same way!\n\nPlease run the tool again inverting the flash files.\n";
  956.  
  957. MessageBox.Show(text, "WARNING!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  958.  
  959. writer.Close();
  960.  
  961. reader.Close();
  962.  
  963. return false;
  964.  
  965. }
  966.  
  967. reader = new BinaryReader(input);
  968.  
  969. input.Seek(0L, SeekOrigin.Begin);
  970.  
  971. sourceArray = reader.ReadBytes(sourceArray.Length);
  972.  
  973. offset = 0x10L;
  974.  
  975. num7 = 0;
  976.  
  977. Array.Copy(sourceArray, 4, destinationArray, 0, destinationArray.Length);
  978.  
  979. Array.Reverse(destinationArray);
  980.  
  981. num12 = BitConverter.ToUInt32(destinationArray, 0);
  982.  
  983. if ((num12 < 0) || (num12 > 0x186a0))
  984.  
  985. {
  986.  
  987. writer.Close();
  988.  
  989. reader.Close();
  990.  
  991. return false;
  992.  
  993. }
  994.  
  995. this.KoXQ.Value = 0;
  996.  
  997. this.KoXQ.Maximum = ((int) num12) + 1;
  998.  
  999. for (int j = 0; j < num12; j++)
  1000.  
  1001. {
  1002.  
  1003. Array.Copy(sourceArray, offset + 4L, buffer6, 0L, (long) buffer6.Length);
  1004.  
  1005. Array.Reverse(buffer6);
  1006.  
  1007. num = BitConverter.ToUInt32(buffer6, 0) + num7;
  1008.  
  1009. Array.Copy(sourceArray, offset + 12L, buffer7, 0L, (long) buffer7.Length);
  1010.  
  1011. Array.Reverse(buffer7);
  1012.  
  1013. num2 = BitConverter.ToUInt32(buffer7, 0);
  1014.  
  1015. Array.Copy(sourceArray, offset + 0x10L, buffer8, 0L, (long) buffer8.Length);
  1016.  
  1017. str3 = this.KueZWIbD0qeSJp0(buffer8);
  1018.  
  1019. input.Seek((long) num, SeekOrigin.Begin);
  1020.  
  1021. buffer3 = new byte[num2];
  1022.  
  1023. buffer3 = reader.ReadBytes((int) num2);
  1024.  
  1025. output = new FileStream(path + @"\secure_loader\" + str3, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.ReadWrite);
  1026.  
  1027. writer2 = new BinaryWriter(output);
  1028.  
  1029. writer2.Write(buffer3);
  1030.  
  1031. writer2.Close();
  1032.  
  1033. writer.WriteLine(path + @"\secure_loader\" + str3);
  1034.  
  1035. string[] strArray6 = new string[] { "start offset: ", (num6 + num).ToString("D10"), " (Dec) / ", string.Format("{0:X10}", num6 + num), " (Hex) - size: ", num2.ToString("D10"), " (Dec) / ", string.Format("{0:X10}", num2), " (Hex)" };
  1036.  
  1037. writer.WriteLine(string.Concat(strArray6));
  1038.  
  1039. writer.WriteLine();
  1040.  
  1041. offset += 0x30L;
  1042.  
  1043. Application.DoEvents();
  1044.  
  1045. this.KoXQ.Value++;
  1046.  
  1047. }
  1048.  
  1049. reader.Close();
  1050.  
  1051. File.Delete(path + @"\secure_loader.raw");
  1052.  
  1053. if ((this.K5d2.SelectedIndex != 2) && (this.K5d2.SelectedIndex != 3))
  1054.  
  1055. {
  1056.  
  1057. str6 = @"\os";
  1058.  
  1059. }
  1060.  
  1061. else
  1062.  
  1063. {
  1064.  
  1065. str6 = @"\os0";
  1066.  
  1067. num3 = num4;
  1068.  
  1069. }
  1070.  
  1071. input = new FileStream(path + str6 + ".raw", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
  1072.  
  1073. reader = new BinaryReader(input);
  1074.  
  1075. input.Seek(0L, SeekOrigin.Begin);
  1076.  
  1077. sourceArray = reader.ReadBytes(sourceArray.Length);
  1078.  
  1079. Directory.CreateDirectory(path + str6 + @"\sdk");
  1080.  
  1081. Thread.Sleep(100);
  1082.  
  1083. offset = 0x40L;
  1084.  
  1085. num7 = 0x30;
  1086.  
  1087. Array.Copy(sourceArray, 0x34, destinationArray, 0, destinationArray.Length);
  1088.  
  1089. Array.Reverse(destinationArray);
  1090.  
  1091. num12 = BitConverter.ToUInt32(destinationArray, 0);
  1092.  
  1093. if ((num12 < 0) || (num12 > 0x186a0))
  1094.  
  1095. {
  1096.  
  1097. writer.Close();
  1098.  
  1099. reader.Close();
  1100.  
  1101. return false;
  1102.  
  1103. }
  1104.  
  1105. this.KoXQ.Value = 0;
  1106.  
  1107. this.KoXQ.Maximum = ((int) num12) + 1;
  1108.  
  1109. for (int k = 0; k < num12; k++)
  1110.  
  1111. {
  1112.  
  1113. Array.Copy(sourceArray, offset + 4L, buffer6, 0L, (long) buffer6.Length);
  1114.  
  1115. Array.Reverse(buffer6);
  1116.  
  1117. num = BitConverter.ToUInt32(buffer6, 0) + num7;
  1118.  
  1119. Array.Copy(sourceArray, offset + 12L, buffer7, 0L, (long) buffer7.Length);
  1120.  
  1121. Array.Reverse(buffer7);
  1122.  
  1123. num2 = BitConverter.ToUInt32(buffer7, 0);
  1124.  
  1125. Array.Copy(sourceArray, offset + 0x10L, buffer8, 0L, (long) buffer8.Length);
  1126.  
  1127. str3 = this.KueZWIbD0qeSJp0(buffer8);
  1128.  
  1129. if ((k == 0) && (str3.Length > 0))
  1130.  
  1131. {
  1132.  
  1133. str3 = str3.Remove(0, 1);
  1134.  
  1135. }
  1136.  
  1137. input.Seek((long) num, SeekOrigin.Begin);
  1138.  
  1139. buffer3 = new byte[num2];
  1140.  
  1141. buffer3 = reader.ReadBytes((int) num2);
  1142.  
  1143. output = new FileStream(path + str6 + @"\sdk\" + str3, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.ReadWrite);
  1144.  
  1145. writer2 = new BinaryWriter(output);
  1146.  
  1147. writer2.Write(buffer3);
  1148.  
  1149. writer2.Close();
  1150.  
  1151. writer.WriteLine(path + str6 + @"\sdk\" + str3);
  1152.  
  1153. string[] strArray7 = new string[] { "start offset: ", (num3 + num).ToString("D10"), " (Dec) / ", string.Format("{0:X10}", num3 + num), " (Hex) - size: ", num2.ToString("D10"), " (Dec) / ", string.Format("{0:X10}", num2), " (Hex)" };
  1154.  
  1155. writer.WriteLine(string.Concat(strArray7));
  1156.  
  1157. writer.WriteLine();
  1158.  
  1159. offset += 0x30L;
  1160.  
  1161. Application.DoEvents();
  1162.  
  1163. this.KoXQ.Value++;
  1164.  
  1165. }
  1166.  
  1167. reader.Close();
  1168.  
  1169. if (num12 != 0)
  1170.  
  1171. {
  1172.  
  1173. try
  1174.  
  1175. {
  1176.  
  1177. input = new FileStream(path + str6 + @"\sdk\sdk_version", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
  1178.  
  1179. }
  1180.  
  1181. catch (FileNotFoundException)
  1182.  
  1183. {
  1184.  
  1185. writer.Close();
  1186.  
  1187. return false;
  1188.  
  1189. }
  1190.  
  1191. reader = new BinaryReader(input);
  1192.  
  1193. input.Seek(0L, SeekOrigin.Begin);
  1194.  
  1195. buffer4 = reader.ReadBytes(buffer4.Length);
  1196.  
  1197. reader.Close();
  1198.  
  1199. try
  1200.  
  1201. {
  1202.  
  1203. Directory.Move(path + str6 + @"\sdk", path + str6 + @"\" + this.KueZWIbD0qeSJp0(buffer4));
  1204.  
  1205. Thread.Sleep(100);
  1206.  
  1207. str = str + this.KueZWIbD0qeSJp0(buffer4);
  1208.  
  1209. goto Label_10E9;
  1210.  
  1211. }
  1212.  
  1213. catch (ArgumentException)
  1214.  
  1215. {
  1216.  
  1217. writer.Close();
  1218.  
  1219. return false;
  1220.  
  1221. }
  1222.  
  1223. }
  1224.  
  1225. Directory.Delete(path + str6 + @"\sdk");
  1226.  
  1227. Thread.Sleep(100);
  1228.  
  1229. Label_10E9:
  1230.  
  1231. num18 = 0;
  1232.  
  1233. if ((this.K5d2.SelectedIndex != 2) && (this.K5d2.SelectedIndex != 3))
  1234.  
  1235. {
  1236.  
  1237. str6 = @"\os";
  1238.  
  1239. num18 = 0x700020;
  1240.  
  1241. }
  1242.  
  1243. else
  1244.  
  1245. {
  1246.  
  1247. str6 = @"\os1";
  1248.  
  1249. num18 = 0x10;
  1250.  
  1251. num3 = num5;
  1252.  
  1253. }
  1254.  
  1255. input = new FileStream(path + str6 + ".raw", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
  1256.  
  1257. reader = new BinaryReader(input);
  1258.  
  1259. input.Seek((long) num18, SeekOrigin.Begin);
  1260.  
  1261. sourceArray = reader.ReadBytes(sourceArray.Length);
  1262.  
  1263. Directory.CreateDirectory(path + str6 + @"\sdk");
  1264.  
  1265. Thread.Sleep(100);
  1266.  
  1267. offset = 0x10L;
  1268.  
  1269. num7 = (uint) num18;
  1270.  
  1271. Array.Copy(sourceArray, 4, destinationArray, 0, destinationArray.Length);
  1272.  
  1273. Array.Reverse(destinationArray);
  1274.  
  1275. num12 = BitConverter.ToUInt32(destinationArray, 0);
  1276.  
  1277. if ((num12 < 0) || (num12 > 0x186a0))
  1278.  
  1279. {
  1280.  
  1281. writer.Close();
  1282.  
  1283. reader.Close();
  1284.  
  1285. return false;
  1286.  
  1287. }
  1288.  
  1289. this.KoXQ.Value = 0;
  1290.  
  1291. this.KoXQ.Maximum = ((int) num12) + 1;
  1292.  
  1293. for (int m = 0; m < num12; m++)
  1294.  
  1295. {
  1296.  
  1297. Array.Copy(sourceArray, offset + 4L, buffer6, 0L, (long) buffer6.Length);
  1298.  
  1299. Array.Reverse(buffer6);
  1300.  
  1301. num = BitConverter.ToUInt32(buffer6, 0) + num7;
  1302.  
  1303. Array.Copy(sourceArray, offset + 12L, buffer7, 0L, (long) buffer7.Length);
  1304.  
  1305. Array.Reverse(buffer7);
  1306.  
  1307. num2 = BitConverter.ToUInt32(buffer7, 0);
  1308.  
  1309. Array.Copy(sourceArray, offset + 0x10L, buffer8, 0L, (long) buffer8.Length);
  1310.  
  1311. str3 = this.KueZWIbD0qeSJp0(buffer8);
  1312.  
  1313. if ((m == 0) && (str3.Length > 0))
  1314.  
  1315. {
  1316.  
  1317. str3 = str3.Remove(0, 1);
  1318.  
  1319. }
  1320.  
  1321. input.Seek((long) num, SeekOrigin.Begin);
  1322.  
  1323. buffer3 = new byte[num2];
  1324.  
  1325. buffer3 = reader.ReadBytes((int) num2);
  1326.  
  1327. output = new FileStream(path + str6 + @"\sdk\" + str3, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.ReadWrite);
  1328.  
  1329. writer2 = new BinaryWriter(output);
  1330.  
  1331. writer2.Write(buffer3);
  1332.  
  1333. writer2.Close();
  1334.  
  1335. writer.WriteLine(path + str6 + @"\sdk\" + str3);
  1336.  
  1337. string[] strArray8 = new string[] { "start offset: ", (num3 + num).ToString("D10"), " (Dec) / ", string.Format("{0:X10}", num3 + num), " (Hex) - size: ", num2.ToString("D10"), " (Dec) / ", string.Format("{0:X10}", num2), " (Hex)" };
  1338.  
  1339. writer.WriteLine(string.Concat(strArray8));
  1340.  
  1341. writer.WriteLine();
  1342.  
  1343. offset += 0x30L;
  1344.  
  1345. Application.DoEvents();
  1346.  
  1347. this.KoXQ.Value++;
  1348.  
  1349. }
  1350.  
  1351. reader.Close();
  1352.  
  1353. if (num12 != 0)
  1354.  
  1355. {
  1356.  
  1357. bool flag;
  1358.  
  1359. try
  1360.  
  1361. {
  1362.  
  1363. input = new FileStream(path + str6 + @"\sdk\sdk_version", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
  1364.  
  1365. }
  1366.  
  1367. catch (FileNotFoundException)
  1368.  
  1369. {
  1370.  
  1371. writer.Close();
  1372.  
  1373. return false;
  1374.  
  1375. }
  1376.  
  1377. reader = new BinaryReader(input);
  1378.  
  1379. input.Seek(0L, SeekOrigin.Begin);
  1380.  
  1381. buffer4 = reader.ReadBytes(buffer4.Length);
  1382.  
  1383. reader.Close();
  1384.  
  1385. try
  1386.  
  1387. {
  1388.  
  1389. string str7 = path + str6 + @"\" + this.KueZWIbD0qeSJp0(buffer4);
  1390.  
  1391. if (Directory.Exists(str7))
  1392.  
  1393. {
  1394.  
  1395. str7 = str7 + "_#2)";
  1396.  
  1397. }
  1398.  
  1399. Directory.Move(path + str6 + @"\sdk", str7);
  1400.  
  1401. Thread.Sleep(100);
  1402.  
  1403. str = str + " / " + this.KueZWIbD0qeSJp0(buffer4);
  1404.  
  1405. goto Label_14CD;
  1406.  
  1407. }
  1408.  
  1409. catch (ArgumentException)
  1410.  
  1411. {
  1412.  
  1413. writer.Close();
  1414.  
  1415. flag = false;
  1416.  
  1417. }
  1418.  
  1419. return flag;
  1420.  
  1421. }
  1422.  
  1423. Directory.Delete(path + str6 + @"\sdk");
  1424.  
  1425. Thread.Sleep(100);
  1426.  
  1427. Directory.Move(path + str6 + ".raw", path + str6 + @"\" + str6 + ".raw");
  1428.  
  1429. Thread.Sleep(100);
  1430.  
  1431. Label_14CD:
  1432.  
  1433. File.Delete(path + str6 + ".raw");
  1434.  
  1435. input = new FileStream(path + @"\EID", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
  1436.  
  1437. reader = new BinaryReader(input);
  1438.  
  1439. input.Seek(0L, SeekOrigin.Begin);
  1440.  
  1441. sourceArray = reader.ReadBytes(sourceArray.Length);
  1442.  
  1443. Directory.CreateDirectory(path + @"\EID" + this.string_0);
  1444.  
  1445. Thread.Sleep(100);
  1446.  
  1447. offset = 0x10L;
  1448.  
  1449. num7 = 0;
  1450.  
  1451. Array.Copy(sourceArray, 0, destinationArray, 0, destinationArray.Length);
  1452.  
  1453. Array.Reverse(destinationArray);
  1454.  
  1455. num12 = BitConverter.ToUInt32(destinationArray, 0);
  1456.  
  1457. if ((num12 < 0) || (num12 > 0x186a0))
  1458.  
  1459. {
  1460.  
  1461. writer.Close();
  1462.  
  1463. reader.Close();
  1464.  
  1465. return false;
  1466.  
  1467. }
  1468.  
  1469. this.KoXQ.Value = 0;
  1470.  
  1471. this.KoXQ.Maximum = ((int) num12) + 1;
  1472.  
  1473. for (int n = 0; n < num12; n++)
  1474.  
  1475. {
  1476.  
  1477. Array.Copy(sourceArray, offset, buffer6, 0L, (long) buffer6.Length);
  1478.  
  1479. Array.Reverse(buffer6);
  1480.  
  1481. num = BitConverter.ToUInt32(buffer6, 0) + num7;
  1482.  
  1483. Array.Copy(sourceArray, offset + 4L, buffer7, 0L, (long) buffer7.Length);
  1484.  
  1485. Array.Reverse(buffer7);
  1486.  
  1487. num2 = BitConverter.ToUInt32(buffer7, 0);
  1488.  
  1489. str3 = n.ToString("D2");
  1490.  
  1491. input.Seek((long) num, SeekOrigin.Begin);
  1492.  
  1493. buffer3 = new byte[num2];
  1494.  
  1495. buffer3 = reader.ReadBytes((int) num2);
  1496.  
  1497. output = new FileStream(path + @"\EID" + this.string_0 + @"\" + str3, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.ReadWrite);
  1498.  
  1499. writer2 = new BinaryWriter(output);
  1500.  
  1501. writer2.Write(buffer3);
  1502.  
  1503. writer2.Close();
  1504.  
  1505. offset += 0x10L;
  1506.  
  1507. Application.DoEvents();
  1508.  
  1509. this.KoXQ.Value++;
  1510.  
  1511. }
  1512.  
  1513. reader.Close();
  1514.  
  1515. input = new FileStream(path + @"\EID", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
  1516.  
  1517. reader = new BinaryReader(input);
  1518.  
  1519. input.Seek(0L, SeekOrigin.Begin);
  1520.  
  1521. sourceArray = reader.ReadBytes(sourceArray.Length);
  1522.  
  1523. TextWriter writer4 = File.CreateText(this.KE405Sp.PathFileDir + @".LOGS\ConsoleAttributes.txt");
  1524.  
  1525. switch (sourceArray[0x75])
  1526.  
  1527. {
  1528.  
  1529. case 130:
  1530.  
  1531. writer4.WriteLine("Machine Type: Debug US");
  1532.  
  1533. break;
  1534.  
  1535.  
  1536.  
  1537. case 0x83:
  1538.  
  1539. writer4.WriteLine("Machine Type: Retail JP");
  1540.  
  1541. break;
  1542.  
  1543.  
  1544.  
  1545. case 0x84:
  1546.  
  1547. writer4.WriteLine("Machine Type: Retail US");
  1548.  
  1549. break;
  1550.  
  1551.  
  1552.  
  1553. case 0x85:
  1554.  
  1555. writer4.WriteLine("Machine Type: Retail EU");
  1556.  
  1557. break;
  1558.  
  1559.  
  1560.  
  1561. case 0x86:
  1562.  
  1563. writer4.WriteLine("Machine Type: Retail KR");
  1564.  
  1565. break;
  1566.  
  1567.  
  1568.  
  1569. case 0x87:
  1570.  
  1571. writer4.WriteLine("Machine Type: Retail UK");
  1572.  
  1573. break;
  1574.  
  1575.  
  1576.  
  1577. case 0x88:
  1578.  
  1579. writer4.WriteLine("Machine Type: Retail MX");
  1580.  
  1581. break;
  1582.  
  1583.  
  1584.  
  1585. case 0x89:
  1586.  
  1587. writer4.WriteLine("Machine Type: Retail AU/NZ");
  1588.  
  1589. break;
  1590.  
  1591.  
  1592.  
  1593. case 0x8a:
  1594.  
  1595. writer4.WriteLine("Machine Type: Retail SouthAsia");
  1596.  
  1597. break;
  1598.  
  1599.  
  1600.  
  1601. case 0x8b:
  1602.  
  1603. writer4.WriteLine("Machine Type: Retail TW");
  1604.  
  1605. break;
  1606.  
  1607.  
  1608.  
  1609. case 140:
  1610.  
  1611. writer4.WriteLine("Machine Type: Retail RU");
  1612.  
  1613. break;
  1614.  
  1615.  
  1616.  
  1617. case 0x8d:
  1618.  
  1619. writer4.WriteLine("Machine Type: Retail CN");
  1620.  
  1621. break;
  1622.  
  1623.  
  1624.  
  1625. case 0x8e:
  1626.  
  1627. writer4.WriteLine("Machine Type: Retail JP???");
  1628.  
  1629. break;
  1630.  
  1631.  
  1632.  
  1633. default:
  1634.  
  1635. writer4.WriteLine("Machine Type: Unknow");
  1636.  
  1637. break;
  1638.  
  1639. }
  1640.  
  1641. writer4.WriteLine("Firmware Versions: " + str);
  1642.  
  1643. reader.Close();
  1644.  
  1645. input = new FileStream(path + @"\ISD", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
  1646.  
  1647. reader = new BinaryReader(input);
  1648.  
  1649. input.Seek(0L, SeekOrigin.Begin);
  1650.  
  1651. sourceArray = reader.ReadBytes(sourceArray.Length);
  1652.  
  1653. writer4.WriteLine("Machine Mac Address: " + string.Format("{0:X2}", sourceArray[0x40]) + ":" + string.Format("{0:X2}", sourceArray[0x41]) + ":" + string.Format("{0:X2}", sourceArray[0x42]) + ":" + string.Format("{0:X2}", sourceArray[0x43]) + ":" + string.Format("{0:X2}", sourceArray[0x44]) + ":" + string.Format("{0:X2}", sourceArray[0x45]));
  1654.  
  1655. writer4.WriteLine("Motherboard S/N: " + Encoding.UTF8.GetString(sourceArray, 0x98, 12));
  1656.  
  1657. reader.Close();
  1658.  
  1659. writer.Close();
  1660.  
  1661. writer4.Close();
  1662.  
  1663. return true;
  1664.  
  1665. }
  1666.  
  1667.  
  1668.  
  1669.  
  1670.  
  1671.  
  1672.  
  1673. PS3NANDECC
  1674.  
  1675.  
  1676.  
  1677.  
  1678.  
  1679. Codice:
  1680.  
  1681.  
  1682.  
  1683. public byte[] method_0(byte[] data)
  1684.  
  1685. {
  1686.  
  1687. byte[] destinationArray = new byte[10];
  1688.  
  1689. for (int i = 0; i < 0x200; i++)
  1690.  
  1691. {
  1692.  
  1693. byte[] buffer2 = new byte[10];
  1694.  
  1695. Array.Copy(byte_0, (i * 0xa00) + (data[i] * 10), destinationArray, 0, 10);
  1696.  
  1697. for (int k = 0; k < 10; k++)
  1698.  
  1699. {
  1700.  
  1701. destinationArray[k] = (byte) (destinationArray[k] ^ buffer2[k]);
  1702.  
  1703. }
  1704.  
  1705. }
  1706.  
  1707. for (int j = 0; j < 10; j++)
  1708.  
  1709. {
  1710.  
  1711. destinationArray[j] = (byte) (destinationArray[j] ^ 0xff);
  1712.  
  1713. }
  1714.  
  1715. return destinationArray;
  1716.  
  1717. }
  1718.  
  1719.  
  1720.  
  1721.  
  1722.  
  1723. public byte[] method_1(byte[] data, int data_pos)
  1724.  
  1725. {
  1726.  
  1727. byte[] destinationArray = new byte[10];
  1728.  
  1729. for (int i = data_pos; i < (data_pos + 0x200); i++)
  1730.  
  1731. {
  1732.  
  1733. byte[] buffer2 = new byte[10];
  1734.  
  1735. Array.Copy(byte_0, ((i - data_pos) * 0xa00) + (data[i - data_pos] * 10), destinationArray, 0, 10);
  1736.  
  1737. for (int k = 0; k < 10; k++)
  1738.  
  1739. {
  1740.  
  1741. destinationArray[k] = (byte) (destinationArray[k] ^ buffer2[k]);
  1742.  
  1743. }
  1744.  
  1745. }
  1746.  
  1747. for (int j = 0; j < 10; j++)
  1748.  
  1749. {
  1750.  
  1751. destinationArray[j] = (byte) (destinationArray[j] ^ 0xff);
  1752.  
  1753. }
  1754.  
  1755. return destinationArray;
  1756.  
  1757. }
  1758.  
  1759.  
  1760.  
  1761.  
  1762.  
  1763. public bool method_2(byte[] ecc, byte[] data)
  1764.  
  1765. {
  1766.  
  1767. byte[] buffer = new byte[10];
  1768.  
  1769. return GPF.memcmp(this.method_0(data), 0, ecc, 0, 10);
  1770.  
  1771. }
  1772.  
  1773.  
  1774.  
  1775.  
  1776.  
  1777.  
  1778.  
  1779.  
  1780.  
  1781. private void method_3(ref byte[] byte_1, int int_0, int int_1, int int_2, int int_3)
  1782.  
  1783. {
  1784.  
  1785. byte[] buffer = new byte[] { 0xbb, 0x62, 0x1a, 0x73, 0xbb, 0x52, 0xc9, 40, 0x68, 0xf7 };
  1786.  
  1787. int_2 ^= 7;
  1788.  
  1789. if (int_3 != 0)
  1790.  
  1791. {
  1792.  
  1793. for (int i = int_0; i < (int_0 + 10); i++)
  1794.  
  1795. {
  1796.  
  1797. byte_1[i - int_0] = (byte) (byte_1[i - int_0] ^ this.KZh6hI5m[(((int_1 * 8) * 10) + (int_2 * 10)) + (i - int_0)]);
  1798.  
  1799. }
  1800.  
  1801. }
  1802.  
  1803. else
  1804.  
  1805. {
  1806.  
  1807. for (int j = int_0; j < (int_0 + 10); j++)
  1808.  
  1809. {
  1810.  
  1811. byte_1[j - int_0] = (byte) (byte_1[j - int_0] ^ buffer[j - int_0]);
  1812.  
  1813. }
  1814.  
  1815. }
  1816.  
  1817. }
  1818.  
  1819.  
  1820.  
  1821.  
  1822.  
  1823. Altra funzione abbastanza utile relativa al dump_unpack
  1824.  
  1825.  
  1826.  
  1827.  
  1828.  
  1829. Codice:
  1830.  
  1831.  
  1832.  
  1833. internal void K1KtW(long long_0, string string_0)
  1834.  
  1835. {
  1836.  
  1837. KoXQ(string_0);
  1838.  
  1839. string str = "";
  1840.  
  1841. this.KNBJHqOx.Seek(long_0, SeekOrigin.Begin);
  1842.  
  1843. byte[] buffer = new byte[4];
  1844.  
  1845. this.KNBJHqOx.Seek(4L, SeekOrigin.Current);
  1846.  
  1847. this.KZh6hI5m.Read(buffer, 0, buffer.Length);
  1848.  
  1849. uint num = KZh6hI5m(buffer);
  1850.  
  1851. long offset = this.KNBJHqOx.Position + 8L;
  1852.  
  1853. for (uint i = 0; i < num; i++)
  1854.  
  1855. {
  1856.  
  1857. buffer = new byte[0x20];
  1858.  
  1859. this.KNBJHqOx.Seek(offset + 0x10L, SeekOrigin.Begin);
  1860.  
  1861. this.KZh6hI5m.Read(buffer, 0, buffer.Length);
  1862.  
  1863. str = CVF.ByteArrayToAscii(buffer, 0, buffer.Length, true);
  1864.  
  1865. if (str.Contains("asecure_loader"))
  1866.  
  1867. {
  1868.  
  1869. KoXQ(string_0 + @"\" + str);
  1870.  
  1871. buffer = new byte[8];
  1872.  
  1873. this.KNBJHqOx.Seek(offset, SeekOrigin.Begin);
  1874.  
  1875. this.KZh6hI5m.Read(buffer, 0, buffer.Length);
  1876.  
  1877. this.K1KtW(long_0 + ((long) smethod_1(buffer)), string_0 + @"\" + str);
  1878.  
  1879. }
  1880.  
  1881. else if (str.Contains("ros"))
  1882.  
  1883. {
  1884.  
  1885. KoXQ(string_0 + @"\" + str);
  1886.  
  1887. buffer = new byte[8];
  1888.  
  1889. this.KNBJHqOx.Seek(offset, SeekOrigin.Begin);
  1890.  
  1891. this.KZh6hI5m.Read(buffer, 0, buffer.Length);
  1892.  
  1893. if (str == "ros")
  1894.  
  1895. {
  1896.  
  1897. long num4 = long_0 + ((long) smethod_1(buffer));
  1898.  
  1899. this.K1KtW(num4 + 0x30L, string_0 + @"\ros\sdk0");
  1900.  
  1901. if (File.Exists(string_0 + @"\ros\sdk0\sdk_version"))
  1902.  
  1903. {
  1904.  
  1905. TextReader reader = File.OpenText(string_0 + @"\ros\sdk0\sdk_version");
  1906.  
  1907. string str2 = reader.ReadLine();
  1908.  
  1909. reader.Close();
  1910.  
  1911. if (Directory.Exists(string_0 + @"\ros\" + str2))
  1912.  
  1913. {
  1914.  
  1915. str2 = str2 + ".bak";
  1916.  
  1917. }
  1918.  
  1919. Directory.Move(string_0 + @"\ros\sdk0", string_0 + @"\ros\" + str2);
  1920.  
  1921. }
  1922.  
  1923. this.KNBJHqOx.Seek(num4, SeekOrigin.Begin);
  1924.  
  1925. buffer = new byte[8];
  1926.  
  1927. this.KZh6hI5m.Read(buffer, 0, buffer.Length);
  1928.  
  1929. this.K1KtW(0x7c0020L, string_0 + @"\ros\sdk1");
  1930.  
  1931. if (File.Exists(string_0 + @"\ros\sdk1\sdk_version"))
  1932.  
  1933. {
  1934.  
  1935. TextReader reader2 = File.OpenText(string_0 + @"\ros\sdk1\sdk_version");
  1936.  
  1937. string str3 = reader2.ReadLine();
  1938.  
  1939. reader2.Close();
  1940.  
  1941. if (Directory.Exists(string_0 + @"\ros\" + str3))
  1942.  
  1943. {
  1944.  
  1945. str3 = str3 + ".bak";
  1946.  
  1947. }
  1948.  
  1949. Directory.Move(string_0 + @"\ros\sdk1", string_0 + @"\ros\" + str3);
  1950.  
  1951. }
  1952.  
  1953. }
  1954.  
  1955. else
  1956.  
  1957. {
  1958.  
  1959. this.K1KtW((long_0 + ((long) smethod_1(buffer))) + 0x10L, string_0 + @"\" + str);
  1960.  
  1961. }
  1962.  
  1963. }
  1964.  
  1965. else
  1966.  
  1967. {
  1968.  
  1969. buffer = new byte[8];
  1970.  
  1971. this.KNBJHqOx.Seek(offset, SeekOrigin.Begin);
  1972.  
  1973. this.KZh6hI5m.Read(buffer, 0, buffer.Length);
  1974.  
  1975. long num5 = long_0 + ((long) smethod_1(buffer));
  1976.  
  1977. this.KZh6hI5m.Read(buffer, 0, buffer.Length);
  1978.  
  1979. long num6 = (long) smethod_1(buffer);
  1980.  
  1981. FileStream output = new FileStream(string_0 + @"\" + str, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.ReadWrite);
  1982.  
  1983. BinaryWriter writer = new BinaryWriter(output);
  1984.  
  1985. buffer = new byte[num6];
  1986.  
  1987. this.KNBJHqOx.Seek(num5, SeekOrigin.Begin);
  1988.  
  1989. this.KZh6hI5m.Read(buffer, 0, buffer.Length);
  1990.  
  1991. writer.Write(buffer, 0, buffer.Length);
  1992.  
  1993. output.Close();
  1994.  
  1995. writer.Close();
  1996.  
  1997. }
  1998.  
  1999. offset += 0x30L;
  2000.  
  2001. }
  2002.  
  2003. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement