codice:
private bool KFu4(string string_1, string string_2, string string_3, ref int int_3, ref int int_4)
{
Stream input = new FileStream(string_2, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
Stream stream2 = new FileStream(string_3, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
BinaryReader reader = new BinaryReader(input);
BinaryReader reader2 = new BinaryReader(stream2);
string path = string_2 + ".new.bin";
string str2 = string_3 + ".new.bin";
if (File.Exists(path))
{
File.Delete(path);
}
if (File.Exists(str2))
{
File.Delete(str2);
}
Stream output = new FileStream(path, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.ReadWrite);
Stream stream4 = new FileStream(str2, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.ReadWrite);
BinaryWriter writer = new BinaryWriter(output);
BinaryWriter writer2 = new BinaryWriter(stream4);
Stream stream5 = new FileStream(string_1, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
BinaryReader reader3 = new BinaryReader(stream5);
string directoryName = Path.GetDirectoryName(string_2);
if (!Directory.Exists(directoryName + @"\Differential Flashing"))
{
Directory.CreateDirectory(directoryName + @"\Differential Flashing");
}
TextWriter writer3 = File.CreateText(directoryName + @"\Differential Flashing\DifferenceFileFlash0.txt");
string str4 = Path.GetDirectoryName(string_3);
if (!Directory.Exists(str4 + @"\Differential Flashing"))
{
Directory.CreateDirectory(str4 + @"\Differential Flashing");
}
TextWriter writer4 = File.CreateText(str4 + @"\Differential Flashing\DifferenceFileFlash1.txt");
List<int> list = new List<int>();
List<int> list2 = new List<int>();
this.KoXQ.Value = 0;
this.KoXQ.Maximum = ((int) (input.Length / 0x21000L)) + 1;
for (int i = 0; i < (input.Length / 0x21000L); i++)
{
byte[] buffer = new byte[0x40000];
byte[] buffer2 = new byte[0x40000];
byte[] destinationArray = new byte[0x21000];
byte[] buffer4 = new byte[0x21000];
long offset = 0L;
long num4 = 0L;
byte[] buffer5 = new byte[0x40];
byte[] buffer6 = new byte[0x40];
byte[] buffer7 = new byte[0x200];
byte[] buffer8 = new byte[0x200];
int num5 = this.K6AvpR.BlockPhyToLogIndex(i);
if ((num5 < 0) || (num5 > 0x3ff))
{
throw new Exception("Error: Physical block out of range!");
}
offset = ((num5 * 0x800) * 0x40) * 2;
stream5.Seek(offset, SeekOrigin.Begin);
reader3.Read(buffer2, 0, buffer2.Length);
for (int m = 0; m < buffer2.Length; m += 2)
{
Array.Reverse(buffer2, m, 2);
}
num5 = this.KXyytIvy8Axe3B.BlockPhyToLogIndex(i);
if ((num5 < 0) || (num5 > 0x3ff))
{
throw new Exception("Error: Physical block out of range!");
}
long num2 = ((num5 * 0x800) * 0x40) * 2;
stream5.Seek(num2, SeekOrigin.Begin);
if (num2 != offset)
{
reader3.Read(buffer, 0, buffer.Length);
for (int num7 = 0; num7 < buffer.Length; num7 += 2)
{
Array.Reverse(buffer, num7, 2);
}
}
else
{
Array.Copy(buffer2, 0, buffer, 0, buffer.Length);
}
byte[] sourceArray = new byte[10];
for (int n = 0; n < 0x40; n++)
{
num4 = (((i * 0x840) * 0x40) + (0x840 * n)) + 0x800;
stream2.Seek(num4, SeekOrigin.Begin);
reader2.Read(buffer6, 0, buffer6.Length);
Array.Copy(buffer6, 0, buffer4, (n * 0x840) + 0x800, buffer6.Length);
input.Seek(num4, SeekOrigin.Begin);
reader.Read(buffer5, 0, buffer5.Length);
Array.Copy(buffer5, 0, destinationArray, (n * 0x840) + 0x800, buffer5.Length);
int num9 = 0;
for (int num10 = 0; num10 < 4; num10++)
{
int num11 = (((i * 0x840) * 0x40) + (n * 0x840)) + (num10 * 0x200);
stream2.Seek((long) num11, SeekOrigin.Begin);
reader2.Read(buffer8, 0, buffer8.Length);
Array.Copy(buffer2, (n * 0x1000) + (num9 * 0x200), buffer4, (n * 0x840) + (num10 * 0x200), 0x200);
if (!this.K6AvpR.IsBadBlock(i) && !GPF.memcmp(buffer4, (n * 0x840) + (num10 * 0x200), buffer8, 0, 0x200))
{
sourceArray = this.KXyytIvy8Axe3B(buffer4, (n * 0x840) + (num10 * 0x200));
Array.Copy(sourceArray, 0, buffer4, (((n * 0x840) + 0x800) + 8) + (num10 * 14), sourceArray.Length);
int item = (i * 0x840) * 0x40;
if (!list2.Contains(item))
{
list2.Add(item);
}
}
num9++;
num11 = (((i * 0x840) * 0x40) + (n * 0x840)) + (num10 * 0x200);
input.Seek((long) num11, SeekOrigin.Begin);
reader.Read(buffer7, 0, buffer7.Length);
Array.Copy(buffer, (n * 0x1000) + (num9 * 0x200), destinationArray, (n * 0x840) + (num10 * 0x200), 0x200);
if (!this.KXyytIvy8Axe3B.IsBadBlock(i) && !GPF.memcmp(destinationArray, (n * 0x840) + (num10 * 0x200), buffer7, 0, 0x200))
{
sourceArray = this.KXyytIvy8Axe3B(destinationArray, (n * 0x840) + (num10 * 0x200));
Array.Copy(sourceArray, 0, destinationArray, (((n * 0x840) + 0x800) + 8) + (num10 * 14), sourceArray.Length);
int num13 = (i * 0x840) * 0x40;
if (!list.Contains(num13))
{
list.Add(num13);
}
}
num9++;
}
}
writer2.Write(buffer4);
writer.Write(destinationArray);
Application.DoEvents();
this.KoXQ.Value++;
}
for (int j = 0; j < list.Count; j++)
{
writer3.WriteLine("0x" + string.Format("{0:X8}", list[j]));
}
for (int k = 0; k < list2.Count; k++)
{
writer4.WriteLine("0x" + string.Format("{0:X8}", list2[k]));
}
int_3 = list.Count;
int_4 = list2.Count;
writer3.Close();
writer4.Close();
reader.Close();
reader2.Close();
writer.Close();
writer2.Close();
reader3.Close();
return true;
}
----------------------------------
private bool KoXQ(string string_1, string string_2, string string_3)
{
Stream input = new FileStream(string_1, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
Stream stream2 = new FileStream(string_2, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
BinaryReader reader = new BinaryReader(input);
BinaryReader reader2 = new BinaryReader(stream2);
if (File.Exists(string_3))
{
File.Delete(string_3);
}
Stream output = new FileStream(string_3, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.ReadWrite);
BinaryWriter writer = new BinaryWriter(output);
this.KoXQ.Value = 0;
this.KoXQ.Maximum = ((int) (input.Length / 0x21000L)) + 1;
new ArrayList();
for (int i = 0; i < (input.Length / 0x21000L); i++)
{
int num2 = this.KXyytIvy8Axe3B.BlockLogToPhyIndex(i);
if ((num2 >= 0) && (num2 <= 0x3ff))
{
long offset = num2 * 0x21000;
input.Seek(offset, SeekOrigin.Begin);
}
num2 = this.K6AvpR.BlockLogToPhyIndex(i);
if ((num2 >= 0) && (num2 <= 0x3ff))
{
long num4 = num2 * 0x21000;
stream2.Seek(num4, SeekOrigin.Begin);
}
byte[] buffer = new byte[0x21000];
byte[] buffer2 = new byte[0x21000];
byte[] destinationArray = new byte[0x40000];
reader2.Read(buffer2, 0, buffer2.Length);
reader.Read(buffer, 0, buffer.Length);
int num5 = 0;
for (int j = 0; j < 0x40; j++)
{
int num7 = 0;
for (int m = 0; m < 4; m++)
{
Array.Copy(buffer2, (j * 0x840) + (m * 0x200), destinationArray, (j * 0x800) + ((num5 + num7) * 0x200), 0x200);
num7++;
Array.Copy(buffer, (j * 0x840) + (m * 0x200), destinationArray, (j * 0x800) + ((num5 + num7) * 0x200), 0x200);
num7++;
}
num5 += 4;
}
for (int k = 0; k < destinationArray.Length; k += 2)
{
Array.Reverse(destinationArray, k, 2);
}
writer.Write(destinationArray);
Application.DoEvents();
this.KoXQ.Value++;
}
reader.Close();
reader2.Close();
writer.Close();
return true;
}
---------------------------------------------
private bool K7eyXIv(string string_1, bool bool_0)
{
byte[] buffer3;
string str6;
int num18;
uint num = 0;
uint num2 = 0;
uint num3 = 0;
uint num4 = 0;
uint num5 = 0;
uint num6 = 0;
uint num7 = 0;
long length = 0L;
long offset = 0L;
string str = "";
Stream input = new FileStream(string_1, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
BinaryReader reader = new BinaryReader(input);
Directory.CreateDirectory(this.KE405Sp.PathFileDir + ".LOGS");
Thread.Sleep(100);
TextWriter writer = File.CreateText(this.KE405Sp.PathFileDir + @".LOGS\ExtractionLog.txt");
string path = "";
if (bool_0)
{
path = string_1 + this.string_0;
}
else
{
path = string_1 + "REB";
}
if (Directory.Exists(path))
{
Directory.Delete(path, true);
Thread.Sleep(100);
}
Directory.CreateDirectory(path);
Thread.Sleep(100);
byte[] buffer = new byte[0x40000];
byte[] sourceArray = new byte[0x1000];
byte[] buffer4 = new byte[8];
byte[] destinationArray = new byte[4];
byte[] buffer6 = new byte[4];
byte[] buffer7 = new byte[4];
byte[] buffer8 = new byte[0x20];
byte[] buffer9 = new byte[8];
string str3 = "";
Stream output = null;
BinaryWriter writer2 = null;
int num10 = 0;
if ((this.K5d2.SelectedIndex != 2) && (this.K5d2.SelectedIndex != 3))
{
num10 = 0;
}
else
{
num10 = 0xfc0000;
}
input.Seek((long) num10, SeekOrigin.Begin);
this.KoXQ.Value = 0;
this.KoXQ.Maximum = 3;
buffer = reader.ReadBytes(0x40000);
Application.DoEvents();
this.KoXQ.Value++;
str3 = "bootloader_0";
output = new FileStream(path + @"\" + str3, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.ReadWrite);
writer2 = new BinaryWriter(output);
writer2.Write(buffer);
writer2.Close();
writer.WriteLine(path + @"\bootloader_0");
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)" };
writer.WriteLine(string.Concat(strArray));
writer.WriteLine();
Array.Copy(buffer, 0, buffer9, 0, buffer9.Length);
Application.DoEvents();
this.KoXQ.Value++;
input.Seek(0L, SeekOrigin.Begin);
if ((this.K5d2.SelectedIndex != 2) && (this.K5d2.SelectedIndex != 3))
{
input.Seek((long) buffer.Length, SeekOrigin.Begin);
}
else
{
input.Seek(0L, SeekOrigin.Begin);
}
buffer = reader.ReadBytes(0x40000);
byte[] candidate = new byte[] { 0, 0, 0, 0, 15, 0xac, 0xe0, 0xff, 0, 0, 0, 0, 0xde, 0xad, 190, 0xef };
offset = buffer.Locate(candidate);
int num11 = 0;
if ((this.K5d2.SelectedIndex != 2) && (this.K5d2.SelectedIndex != 3))
{
num7 = (uint) ((buffer.Length + ((uint) offset)) + 0x1f0);
num11 = 500;
}
else
{
num7 = 0x400;
num11 = 0x3f4;
}
Array.Copy(buffer, offset + num11, destinationArray, 0L, (long) destinationArray.Length);
Array.Reverse(destinationArray);
uint num12 = BitConverter.ToUInt32(destinationArray, 0);
if ((num12 < 0) || (num12 > 0x186a0))
{
writer.Close();
reader.Close();
return false;
}
if ((this.K5d2.SelectedIndex != 2) && (this.K5d2.SelectedIndex != 3))
{
offset += 0x200L;
}
else
{
offset += 0x400L;
}
this.KoXQ.Value = 0;
this.KoXQ.Maximum = ((int) num12) + 1;
for (int i = 0; i < num12; i++)
{
Array.Copy(buffer, offset + 4L, buffer6, 0L, (long) buffer6.Length);
Array.Reverse(buffer6);
num = BitConverter.ToUInt32(buffer6, 0) + num7;
Array.Copy(buffer, offset + 12L, buffer7, 0L, (long) buffer7.Length);
Array.Reverse(buffer7);
num2 = BitConverter.ToUInt32(buffer7, 0);
Array.Copy(buffer, offset + 0x10L, buffer8, 0L, (long) buffer8.Length);
str3 = this.KueZWIbD0qeSJp0(buffer8);
if (str3.Length > 0)
{
str3 = str3.Remove(0, 1);
}
if (((str3 == "os") || (str3 == "os0")) || ((str3 == "os1") || (str3 == "secure_loader")))
{
Directory.CreateDirectory(path + @"\" + str3);
Thread.Sleep(100);
str3 = str3 + ".raw";
if (str3 == "os.raw")
{
num3 = num;
}
else if (str3 == "os0.raw")
{
num4 = num;
}
else if (str3 == "os1.raw")
{
num5 = num;
}
else if (str3 == "secure_loader.raw")
{
num6 = num;
}
}
input.Seek((long) num, SeekOrigin.Begin);
buffer3 = new byte[num2];
buffer3 = reader.ReadBytes((int) num2);
output = new FileStream(path + @"\" + str3, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.ReadWrite);
writer2 = new BinaryWriter(output);
writer2.Write(buffer3);
writer2.Close();
if (str3.Substring(str3.Length - 3, 3) != "raw")
{
writer.WriteLine(path + @"\" + str3);
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)");
writer.WriteLine();
}
offset += 0x30L;
Application.DoEvents();
this.KoXQ.Value++;
}
if ((this.K5d2.SelectedIndex != 2) && (this.K5d2.SelectedIndex != 3))
{
this.KoXQ.Value = 0;
this.KoXQ.Maximum = 3;
input.Seek(0xec0000L, SeekOrigin.Begin);
buffer3 = new byte[0x1080000];
length = reader.ReadBytes(buffer3.Length).Locate(buffer9, 0L);
if (offset != -1L)
{
offset = length + 0xec0000L;
Application.DoEvents();
this.KoXQ.Value++;
input.Seek(offset, SeekOrigin.Begin);
buffer3 = new byte[0x40000];
buffer3 = reader.ReadBytes(buffer3.Length);
writer.WriteLine(path + @"\bootloader_1");
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)" };
writer.WriteLine(string.Concat(strArray3));
writer.WriteLine();
Application.DoEvents();
this.KoXQ.Value++;
output = new FileStream(path + @"\bootloader_1", FileMode.CreateNew, FileAccess.ReadWrite, FileShare.ReadWrite);
writer2 = new BinaryWriter(output);
writer2.Write(buffer3);
writer2.Close();
TextWriter writer3 = File.CreateText(this.KE405Sp.PathFileDir + @".LOGS\BootloadersDiff.txt");
long num14 = this.Kmuq9(path + @"\bootloader_0", path + @"\bootloader_1");
if (num14 != 0L)
{
writer3.WriteLine("bootloader_0 and bootloader_1 are different from value at offset: " + num14.ToString("D10") + " (Dec) / " + string.Format("{0:X10}", num14) + " (Hex)");
}
else
{
writer3.WriteLine("bootloader_0 and bootloader_1 are equals.");
}
writer3.Close();
Application.DoEvents();
this.KoXQ.Value++;
}
}
this.KoXQ.Value = 0;
this.KoXQ.Maximum = 3;
byte[] buffer11 = new byte[] { 0x63, 0x65, 0x6c, 0x6c, 0x5f, 0x65, 120, 0x74, 0x5f, 0x6f, 0x73, 0x5f, 0x61, 0x72, 0x65, 0x61 };
byte[] buffer12 = new byte[] { 0x43, 0x45, 0x4c, 0x4c, 0x5f, 0x45, 0x58, 0x54, 0x4e, 0x4f, 0x52, 0x5f, 0x41, 0x52, 0x45, 0x41 };
input.Seek(0xec0000L, SeekOrigin.Begin);
buffer3 = new byte[0x1080000];
buffer3 = reader.ReadBytes(buffer3.Length);
string str4 = "";
int num15 = 0;
if ((this.K5d2.SelectedIndex != 2) && (this.K5d2.SelectedIndex != 3))
{
offset = buffer3.Locate(buffer11);
str4 = "cell_ext_os_area";
num15 = 0x400000;
}
else
{
offset = buffer3.Locate(buffer12);
str4 = "cell_extnor_area";
length = input.Length;
num15 = 0xa0000;
}
if ((offset != -1L) && (offset < length))
{
offset += 0xec0000L;
Application.DoEvents();
this.KoXQ.Value++;
input.Seek(offset, SeekOrigin.Begin);
buffer3 = new byte[num15];
buffer3 = reader.ReadBytes(buffer3.Length);
Application.DoEvents();
this.KoXQ.Value++;
output = new FileStream(path + @"\" + str4, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.ReadWrite);
writer2 = new BinaryWriter(output);
writer2.Write(buffer3);
writer2.Close();
writer.WriteLine(path + @"\" + str4);
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)" };
writer.WriteLine(string.Concat(strArray5));
writer.WriteLine();
Application.DoEvents();
this.KoXQ.Value++;
}
try
{
input = new FileStream(path + @"\secure_loader.raw", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
}
catch (FileNotFoundException)
{
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";
MessageBox.Show(text, "WARNING!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
writer.Close();
reader.Close();
return false;
}
reader = new BinaryReader(input);
input.Seek(0L, SeekOrigin.Begin);
sourceArray = reader.ReadBytes(sourceArray.Length);
offset = 0x10L;
num7 = 0;
Array.Copy(sourceArray, 4, destinationArray, 0, destinationArray.Length);
Array.Reverse(destinationArray);
num12 = BitConverter.ToUInt32(destinationArray, 0);
if ((num12 < 0) || (num12 > 0x186a0))
{
writer.Close();
reader.Close();
return false;
}
this.KoXQ.Value = 0;
this.KoXQ.Maximum = ((int) num12) + 1;
for (int j = 0; j < num12; j++)
{
Array.Copy(sourceArray, offset + 4L, buffer6, 0L, (long) buffer6.Length);
Array.Reverse(buffer6);
num = BitConverter.ToUInt32(buffer6, 0) + num7;
Array.Copy(sourceArray, offset + 12L, buffer7, 0L, (long) buffer7.Length);
Array.Reverse(buffer7);
num2 = BitConverter.ToUInt32(buffer7, 0);
Array.Copy(sourceArray, offset + 0x10L, buffer8, 0L, (long) buffer8.Length);
str3 = this.KueZWIbD0qeSJp0(buffer8);
input.Seek((long) num, SeekOrigin.Begin);
buffer3 = new byte[num2];
buffer3 = reader.ReadBytes((int) num2);
output = new FileStream(path + @"\secure_loader\" + str3, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.ReadWrite);
writer2 = new BinaryWriter(output);
writer2.Write(buffer3);
writer2.Close();
writer.WriteLine(path + @"\secure_loader\" + str3);
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)" };
writer.WriteLine(string.Concat(strArray6));
writer.WriteLine();
offset += 0x30L;
Application.DoEvents();
this.KoXQ.Value++;
}
reader.Close();
File.Delete(path + @"\secure_loader.raw");
if ((this.K5d2.SelectedIndex != 2) && (this.K5d2.SelectedIndex != 3))
{
str6 = @"\os";
}
else
{
str6 = @"\os0";
num3 = num4;
}
input = new FileStream(path + str6 + ".raw", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
reader = new BinaryReader(input);
input.Seek(0L, SeekOrigin.Begin);
sourceArray = reader.ReadBytes(sourceArray.Length);
Directory.CreateDirectory(path + str6 + @"\sdk");
Thread.Sleep(100);
offset = 0x40L;
num7 = 0x30;
Array.Copy(sourceArray, 0x34, destinationArray, 0, destinationArray.Length);
Array.Reverse(destinationArray);
num12 = BitConverter.ToUInt32(destinationArray, 0);
if ((num12 < 0) || (num12 > 0x186a0))
{
writer.Close();
reader.Close();
return false;
}
this.KoXQ.Value = 0;
this.KoXQ.Maximum = ((int) num12) + 1;
for (int k = 0; k < num12; k++)
{
Array.Copy(sourceArray, offset + 4L, buffer6, 0L, (long) buffer6.Length);
Array.Reverse(buffer6);
num = BitConverter.ToUInt32(buffer6, 0) + num7;
Array.Copy(sourceArray, offset + 12L, buffer7, 0L, (long) buffer7.Length);
Array.Reverse(buffer7);
num2 = BitConverter.ToUInt32(buffer7, 0);
Array.Copy(sourceArray, offset + 0x10L, buffer8, 0L, (long) buffer8.Length);
str3 = this.KueZWIbD0qeSJp0(buffer8);
if ((k == 0) && (str3.Length > 0))
{
str3 = str3.Remove(0, 1);
}
input.Seek((long) num, SeekOrigin.Begin);
buffer3 = new byte[num2];
buffer3 = reader.ReadBytes((int) num2);
output = new FileStream(path + str6 + @"\sdk\" + str3, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.ReadWrite);
writer2 = new BinaryWriter(output);
writer2.Write(buffer3);
writer2.Close();
writer.WriteLine(path + str6 + @"\sdk\" + str3);
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)" };
writer.WriteLine(string.Concat(strArray7));
writer.WriteLine();
offset += 0x30L;
Application.DoEvents();
this.KoXQ.Value++;
}
reader.Close();
if (num12 != 0)
{
try
{
input = new FileStream(path + str6 + @"\sdk\sdk_version", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
}
catch (FileNotFoundException)
{
writer.Close();
return false;
}
reader = new BinaryReader(input);
input.Seek(0L, SeekOrigin.Begin);
buffer4 = reader.ReadBytes(buffer4.Length);
reader.Close();
try
{
Directory.Move(path + str6 + @"\sdk", path + str6 + @"\" + this.KueZWIbD0qeSJp0(buffer4));
Thread.Sleep(100);
str = str + this.KueZWIbD0qeSJp0(buffer4);
goto Label_10E9;
}
catch (ArgumentException)
{
writer.Close();
return false;
}
}
Directory.Delete(path + str6 + @"\sdk");
Thread.Sleep(100);
Label_10E9:
num18 = 0;
if ((this.K5d2.SelectedIndex != 2) && (this.K5d2.SelectedIndex != 3))
{
str6 = @"\os";
num18 = 0x700020;
}
else
{
str6 = @"\os1";
num18 = 0x10;
num3 = num5;
}
input = new FileStream(path + str6 + ".raw", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
reader = new BinaryReader(input);
input.Seek((long) num18, SeekOrigin.Begin);
sourceArray = reader.ReadBytes(sourceArray.Length);
Directory.CreateDirectory(path + str6 + @"\sdk");
Thread.Sleep(100);
offset = 0x10L;
num7 = (uint) num18;
Array.Copy(sourceArray, 4, destinationArray, 0, destinationArray.Length);
Array.Reverse(destinationArray);
num12 = BitConverter.ToUInt32(destinationArray, 0);
if ((num12 < 0) || (num12 > 0x186a0))
{
writer.Close();
reader.Close();
return false;
}
this.KoXQ.Value = 0;
this.KoXQ.Maximum = ((int) num12) + 1;
for (int m = 0; m < num12; m++)
{
Array.Copy(sourceArray, offset + 4L, buffer6, 0L, (long) buffer6.Length);
Array.Reverse(buffer6);
num = BitConverter.ToUInt32(buffer6, 0) + num7;
Array.Copy(sourceArray, offset + 12L, buffer7, 0L, (long) buffer7.Length);
Array.Reverse(buffer7);
num2 = BitConverter.ToUInt32(buffer7, 0);
Array.Copy(sourceArray, offset + 0x10L, buffer8, 0L, (long) buffer8.Length);
str3 = this.KueZWIbD0qeSJp0(buffer8);
if ((m == 0) && (str3.Length > 0))
{
str3 = str3.Remove(0, 1);
}
input.Seek((long) num, SeekOrigin.Begin);
buffer3 = new byte[num2];
buffer3 = reader.ReadBytes((int) num2);
output = new FileStream(path + str6 + @"\sdk\" + str3, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.ReadWrite);
writer2 = new BinaryWriter(output);
writer2.Write(buffer3);
writer2.Close();
writer.WriteLine(path + str6 + @"\sdk\" + str3);
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)" };
writer.WriteLine(string.Concat(strArray8));
writer.WriteLine();
offset += 0x30L;
Application.DoEvents();
this.KoXQ.Value++;
}
reader.Close();
if (num12 != 0)
{
bool flag;
try
{
input = new FileStream(path + str6 + @"\sdk\sdk_version", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
}
catch (FileNotFoundException)
{
writer.Close();
return false;
}
reader = new BinaryReader(input);
input.Seek(0L, SeekOrigin.Begin);
buffer4 = reader.ReadBytes(buffer4.Length);
reader.Close();
try
{
string str7 = path + str6 + @"\" + this.KueZWIbD0qeSJp0(buffer4);
if (Directory.Exists(str7))
{
str7 = str7 + "_#2)";
}
Directory.Move(path + str6 + @"\sdk", str7);
Thread.Sleep(100);
str = str + " / " + this.KueZWIbD0qeSJp0(buffer4);
goto Label_14CD;
}
catch (ArgumentException)
{
writer.Close();
flag = false;
}
return flag;
}
Directory.Delete(path + str6 + @"\sdk");
Thread.Sleep(100);
Directory.Move(path + str6 + ".raw", path + str6 + @"\" + str6 + ".raw");
Thread.Sleep(100);
Label_14CD:
File.Delete(path + str6 + ".raw");
input = new FileStream(path + @"\EID", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
reader = new BinaryReader(input);
input.Seek(0L, SeekOrigin.Begin);
sourceArray = reader.ReadBytes(sourceArray.Length);
Directory.CreateDirectory(path + @"\EID" + this.string_0);
Thread.Sleep(100);
offset = 0x10L;
num7 = 0;
Array.Copy(sourceArray, 0, destinationArray, 0, destinationArray.Length);
Array.Reverse(destinationArray);
num12 = BitConverter.ToUInt32(destinationArray, 0);
if ((num12 < 0) || (num12 > 0x186a0))
{
writer.Close();
reader.Close();
return false;
}
this.KoXQ.Value = 0;
this.KoXQ.Maximum = ((int) num12) + 1;
for (int n = 0; n < num12; n++)
{
Array.Copy(sourceArray, offset, buffer6, 0L, (long) buffer6.Length);
Array.Reverse(buffer6);
num = BitConverter.ToUInt32(buffer6, 0) + num7;
Array.Copy(sourceArray, offset + 4L, buffer7, 0L, (long) buffer7.Length);
Array.Reverse(buffer7);
num2 = BitConverter.ToUInt32(buffer7, 0);
str3 = n.ToString("D2");
input.Seek((long) num, SeekOrigin.Begin);
buffer3 = new byte[num2];
buffer3 = reader.ReadBytes((int) num2);
output = new FileStream(path + @"\EID" + this.string_0 + @"\" + str3, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.ReadWrite);
writer2 = new BinaryWriter(output);
writer2.Write(buffer3);
writer2.Close();
offset += 0x10L;
Application.DoEvents();
this.KoXQ.Value++;
}
reader.Close();
input = new FileStream(path + @"\EID", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
reader = new BinaryReader(input);
input.Seek(0L, SeekOrigin.Begin);
sourceArray = reader.ReadBytes(sourceArray.Length);
TextWriter writer4 = File.CreateText(this.KE405Sp.PathFileDir + @".LOGS\ConsoleAttributes.txt");
switch (sourceArray[0x75])
{
case 130:
writer4.WriteLine("Machine Type: Debug US");
break;
case 0x83:
writer4.WriteLine("Machine Type: Retail JP");
break;
case 0x84:
writer4.WriteLine("Machine Type: Retail US");
break;
case 0x85:
writer4.WriteLine("Machine Type: Retail EU");
break;
case 0x86:
writer4.WriteLine("Machine Type: Retail KR");
break;
case 0x87:
writer4.WriteLine("Machine Type: Retail UK");
break;
case 0x88:
writer4.WriteLine("Machine Type: Retail MX");
break;
case 0x89:
writer4.WriteLine("Machine Type: Retail AU/NZ");
break;
case 0x8a:
writer4.WriteLine("Machine Type: Retail SouthAsia");
break;
case 0x8b:
writer4.WriteLine("Machine Type: Retail TW");
break;
case 140:
writer4.WriteLine("Machine Type: Retail RU");
break;
case 0x8d:
writer4.WriteLine("Machine Type: Retail CN");
break;
case 0x8e:
writer4.WriteLine("Machine Type: Retail JP???");
break;
default:
writer4.WriteLine("Machine Type: Unknow");
break;
}
writer4.WriteLine("Firmware Versions: " + str);
reader.Close();
input = new FileStream(path + @"\ISD", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
reader = new BinaryReader(input);
input.Seek(0L, SeekOrigin.Begin);
sourceArray = reader.ReadBytes(sourceArray.Length);
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]));
writer4.WriteLine("Motherboard S/N: " + Encoding.UTF8.GetString(sourceArray, 0x98, 12));
reader.Close();
writer.Close();
writer4.Close();
return true;
}
Segnalibri