Visualizzazione dei risultati da 1 a 11 su 11
Like Tree8Likes
  • 5 Post By Dark-G
  • 3 Post By Electron^-

Discussione: Code Snippets From Flow Rebuilder source code

  1. #1
    Junior Member L'avatar di Dark-G
    Registrato dal
    Jan 2013
    Messaggi
    11

    Code Snippets From Flow Rebuilder source code

    Visto che a quanto pare più di qualcuno si sta occupando di creare programmi per il controllo dei dump ho pensato che qualche funzione utile presa dal sorgente di Flow Rebuilder potesse farvi comodo; parte del codice è criptata ma per ora è il massimo che si possa ottenere, in seguito cercherò di aggiungere qualcos' altro. Per favore niente richieste stupide o roba simile, quelli a cui è diretto questo materiale sapranno come utilizzarlo e inoltre la pappa pronta non mi piace... Studiate e "riutilizzate" !

    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;
    }

    Enjoy

  2. #2
    iCouch L'avatar di guerrierodipace
    Registrato dal
    Jan 2013
    residenza
    Bologna
    Messaggi
    1,821

    R: Code Snippets From Flow Rebuilder source code

    Bel regalo per la community :-)
    Grazie
    Io purtroppo non ho gli skills per sfruttarlo,speriamo legga chi ne ha....

    inviato dal mio...

  3. #3
    Cadranno anche loro L'avatar di carloss
    Registrato dal
    Jul 2011
    residenza
    Altamura(BA)
    Messaggi
    919
    Grande!!! C'è la funzione per ordinare i blocchi logici

  4. #4
    Junior Member L'avatar di Dark-G
    Registrato dal
    Jan 2013
    Messaggi
    11
    PS3NANDECC


    codice:
    public byte[] method_0(byte[] data)
    {
        byte[] destinationArray = new byte[10];
        for (int i = 0; i < 0x200; i++)
        {
            byte[] buffer2 = new byte[10];
            Array.Copy(byte_0, (i * 0xa00) + (data[i] * 10), destinationArray, 0, 10);
            for (int k = 0; k < 10; k++)
            {
                destinationArray[k] = (byte) (destinationArray[k] ^ buffer2[k]);
            }
        }
        for (int j = 0; j < 10; j++)
        {
            destinationArray[j] = (byte) (destinationArray[j] ^ 0xff);
        }
        return destinationArray;
    }
    
    
    public byte[] method_1(byte[] data, int data_pos)
    {
        byte[] destinationArray = new byte[10];
        for (int i = data_pos; i < (data_pos + 0x200); i++)
        {
            byte[] buffer2 = new byte[10];
            Array.Copy(byte_0, ((i - data_pos) * 0xa00) + (data[i - data_pos] * 10), destinationArray, 0, 10);
            for (int k = 0; k < 10; k++)
            {
                destinationArray[k] = (byte) (destinationArray[k] ^ buffer2[k]);
            }
        }
        for (int j = 0; j < 10; j++)
        {
            destinationArray[j] = (byte) (destinationArray[j] ^ 0xff);
        }
        return destinationArray;
    }
    
     
    public bool method_2(byte[] ecc, byte[] data)
    {
        byte[] buffer = new byte[10];
        return GPF.memcmp(this.method_0(data), 0, ecc, 0, 10);
    }
    
     
    
     
    private void method_3(ref byte[] byte_1, int int_0, int int_1, int int_2, int int_3)
    {
        byte[] buffer = new byte[] { 0xbb, 0x62, 0x1a, 0x73, 0xbb, 0x52, 0xc9, 40, 0x68, 0xf7 };
        int_2 ^= 7;
        if (int_3 != 0)
        {
            for (int i = int_0; i < (int_0 + 10); i++)
            {
                byte_1[i - int_0] = (byte) (byte_1[i - int_0] ^ this.KZh6hI5m[(((int_1 * 8) * 10) + (int_2 * 10)) + (i - int_0)]);
            }
        }
        else
        {
            for (int j = int_0; j < (int_0 + 10); j++)
            {
                byte_1[j - int_0] = (byte) (byte_1[j - int_0] ^ buffer[j - int_0]);
            }
        }
    }

  5. #5
    Divide et impera L'avatar di Titty
    Registrato dal
    Jul 2011
    Messaggi
    4,190
    Grande, forse riusciamo a risolver eil problema di quelle famose NAND
    Non si da supporto privato, i vostri dubbi vanno risolti sul forum tramite un post... così tutta la Comunity cresce con voi

  6. #6
    Junior Member L'avatar di Dark-G
    Registrato dal
    Jan 2013
    Messaggi
    11
    come mai spesso quando provo a scrivere un post mi dice che il messaggio deve essere approvato da un mod ?
    Ultima modifica di Dark-G; 29-01-13 a 11: 56

  7. #7
    Junior Member L'avatar di Dark-G
    Registrato dal
    Jan 2013
    Messaggi
    11
    Altra funzione abbastanza utile relativa al dump_unpack


    codice:
    internal void K1KtW(long long_0, string string_0)
    {
        KoXQ(string_0);
        string str = "";
        this.KNBJHqOx.Seek(long_0, SeekOrigin.Begin);
        byte[] buffer = new byte[4];
        this.KNBJHqOx.Seek(4L, SeekOrigin.Current);
        this.KZh6hI5m.Read(buffer, 0, buffer.Length);
        uint num = KZh6hI5m(buffer);
        long offset = this.KNBJHqOx.Position + 8L;
        for (uint i = 0; i < num; i++)
        {
            buffer = new byte[0x20];
            this.KNBJHqOx.Seek(offset + 0x10L, SeekOrigin.Begin);
            this.KZh6hI5m.Read(buffer, 0, buffer.Length);
            str = CVF.ByteArrayToAscii(buffer, 0, buffer.Length, true);
            if (str.Contains("asecure_loader"))
            {
                KoXQ(string_0 + @"\" + str);
                buffer = new byte[8];
                this.KNBJHqOx.Seek(offset, SeekOrigin.Begin);
                this.KZh6hI5m.Read(buffer, 0, buffer.Length);
                this.K1KtW(long_0 + ((long) smethod_1(buffer)), string_0 + @"\" + str);
            }
            else if (str.Contains("ros"))
            {
                KoXQ(string_0 + @"\" + str);
                buffer = new byte[8];
                this.KNBJHqOx.Seek(offset, SeekOrigin.Begin);
                this.KZh6hI5m.Read(buffer, 0, buffer.Length);
                if (str == "ros")
                {
                    long num4 = long_0 + ((long) smethod_1(buffer));
                    this.K1KtW(num4 + 0x30L, string_0 + @"\ros\sdk0");
                    if (File.Exists(string_0 + @"\ros\sdk0\sdk_version"))
                    {
                        TextReader reader = File.OpenText(string_0 + @"\ros\sdk0\sdk_version");
                        string str2 = reader.ReadLine();
                        reader.Close();
                        if (Directory.Exists(string_0 + @"\ros\" + str2))
                        {
                            str2 = str2 + ".bak";
                        }
                        Directory.Move(string_0 + @"\ros\sdk0", string_0 + @"\ros\" + str2);
                    }
                    this.KNBJHqOx.Seek(num4, SeekOrigin.Begin);
                    buffer = new byte[8];
                    this.KZh6hI5m.Read(buffer, 0, buffer.Length);
                    this.K1KtW(0x7c0020L, string_0 + @"\ros\sdk1");
                    if (File.Exists(string_0 + @"\ros\sdk1\sdk_version"))
                    {
                        TextReader reader2 = File.OpenText(string_0 + @"\ros\sdk1\sdk_version");
                        string str3 = reader2.ReadLine();
                        reader2.Close();
                        if (Directory.Exists(string_0 + @"\ros\" + str3))
                        {
                            str3 = str3 + ".bak";
                        }
                        Directory.Move(string_0 + @"\ros\sdk1", string_0 + @"\ros\" + str3);
                    }
                }
                else
                {
                    this.K1KtW((long_0 + ((long) smethod_1(buffer))) + 0x10L, string_0 + @"\" + str);
                }
            }
            else
            {
                buffer = new byte[8];
                this.KNBJHqOx.Seek(offset, SeekOrigin.Begin);
                this.KZh6hI5m.Read(buffer, 0, buffer.Length);
                long num5 = long_0 + ((long) smethod_1(buffer));
                this.KZh6hI5m.Read(buffer, 0, buffer.Length);
                long num6 = (long) smethod_1(buffer);
                FileStream output = new FileStream(string_0 + @"\" + str, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.ReadWrite);
                BinaryWriter writer = new BinaryWriter(output);
                buffer = new byte[num6];
                this.KNBJHqOx.Seek(num5, SeekOrigin.Begin);
                this.KZh6hI5m.Read(buffer, 0, buffer.Length);
                writer.Write(buffer, 0, buffer.Length);
                output.Close();
                writer.Close();
            }
            offset += 0x30L;
        }
    }
    PS: Ma qualcuno sta utilizzando questi snippets ? mi piacerebbe avere riscontri sull' integrazione con le vostre applicazioni

  8. #8
    Time to play the Game! I am the debt that can't be paid... You're going down in flames... L'avatar di The Pusher
    Registrato dal
    Jul 2011
    Messaggi
    6,016
    Potevi dirlo che eri tu XD
    CONSOLE, ACCESSORI e RICAMBI
    XBOX360 Modificate WII modificate PSP modificate Ps3 modificate




    VENDITA XBOX 360 SLIM MODIFICATE , WII MODIFICATE , PSP MODIFICATE , PS3 MODIFICATE , ACCESSORI e RICAMBI
    PER TUTTE LE CONSOLE
    TUTTE LE NOTIZIE SUL MONDO INTER


  9. #9
    Junior Member L'avatar di Dark-G
    Registrato dal
    Jan 2013
    Messaggi
    11
    scusa a cosa ti riferisci ? io sono un semplice nuovo utente

    hai avuto paura vero ? ahahahah purtroppo questo succede quando i membri del tuo staff sono dei tossicodipendenti ahahaha
    Ultima modifica di Dark-G; 29-01-13 a 12: 33

  10. #10
    e-tool's Creator L'avatar di Electron^-
    Registrato dal
    Jun 2011
    residenza
    Casima
    Messaggi
    1,451
    [OT]
    La punizione sarà come da allegato
    [/OT]
    Grazie comunque per la condvisione
    Icone allegate Icone allegate Code Snippets From Flow Rebuilder source code-tomba.jpg  
    Ultima modifica di Electron^-; 29-01-13 a 12: 54
    "Unix is user-friendly. It's just very selective about who its friends are."

    I miei piccoli:

    PC:Processore: Athlon 643000+ 754 @2400, Ram: 1GBddr400@480, Sk.Video: ATIRadeon HD3650 AGP @780-1100
    NOTEBOOK:Modello: HP ProBook 4520s,Processore: Intel i5-460M@2.53GHz, Ram: 4GBddr3@1333MHz, Sk.Video:ATI Mobility Radeon HD5470 512MB
    Xbox360:Mobo:Jasper, Lettore:Liteon 74850, Firmware:iXtreme LT+ 3.0, Rebooter:Freeboot (14719), Dash:Freestyle Dash 2.2,
    HDD
    :WD Black Scorpio 500GB 7200RPM 16MB cache, MODEstetica: X intagliata sul lato nera sfumata verde
    Xbox360 Slim:Mobo:Corona, Lettore:Liteon 1075, Firmware: Originale, Rebooter:In Lavorazione,
    HDD
    :250GB originale Microsoft, MODEstetica: Non Prevista Xbox360 Slim:Mobo:Trinity, Lettore:Liteon 0272 con PCB Matrix Freedom, Firmware:iXtreme LT+ 3.0, RGH (Matrix Trident):Freeboot (14719), Originale, Vuota Dash:Freestyle Dash 2.2,
    HDD
    :Originale Microsoft 250GB, MODEstetica:
    In elaborazione mentaleWii:Mod: Software, Modestetica: prossimamente
    PSP:Modello: 1004, Firmware:5.50 GEN-D3, Mobo:TA-v82
    Monitor:Marca: Asus, Modello: VK246H, Tempo di risposta:2ms, Risoluzione: Full-HD


  11. #11
    Cadranno anche loro L'avatar di carloss
    Registrato dal
    Jul 2011
    residenza
    Altamura(BA)
    Messaggi
    919
    PS: Ma qualcuno sta utilizzando questi snippets ? mi piacerebbe avere riscontri sull' integrazione con le vostre applicazioni
    Stasera riprendo il lavoro

Segnalibri

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •