public static List <PartitionInfo> GetSamsungPartitions(string pitFile)
        {
            List <PartitionInfo> list2 = new List <PartitionInfo>();

            using (FileStream stream = new FileStream(pitFile, FileMode.Open, FileAccess.Read))
            {
                PitInputStream inputStream = new PitInputStream(stream);
                PitData        data        = new PitData();
                if (!data.ReadPITFile(inputStream))
                {
                    return(list2);
                }
                string[] strArray = Strings.Split(ADB.IssueADBCmd(ADB.CreateADBShellCmd(_device, false, "busybox", new string[] { "find", "/dev/block", "-maxdepth 1", "-iname", "'mmcblk0p*'", "|", "busybox", "tac" })), "\r\n", -1, CompareMethod.Binary);
                if (strArray.Length <= 1)
                {
                    stream.Close();
                    throw new Exception("Unable to enumerate partitions!");
                }
                foreach (string str5 in strArray)
                {
                    int num;
                    if (int.TryParse(str5.Substring(str5.LastIndexOf("p") + 1), out num))
                    {
                        foreach (PitEntry entry in data.Entries)
                        {
                            if (entry.PartitionID == num)
                            {
                                string partitionName = entry.PartitionName;
                                string str2          = str5;
                                string str           = str5.Remove(0, str5.LastIndexOf("/") + 1);
                                if (!string.IsNullOrEmpty(entry.FlashFileName.Trim(Invalids)) & (entry.FlashFileName.Trim(Invalids) != "-"))
                                {
                                    list2.Add(new PartitionInfo(partitionName.Trim(Invalids).ToLower(), entry.FlashFileName.Trim(Invalids).ToLower(), str2.Trim(Invalids), str.Trim(Invalids)));
                                }
                                else
                                {
                                    list2.Add(new PartitionInfo(partitionName.Trim(Invalids).ToLower(), partitionName.Trim(Invalids).ToLower() + ".epb", str2.Trim(Invalids), str.Trim(Invalids)));
                                }
                                break;
                            }
                        }
                    }
                }
            }
            return(list2);
        }
        public static PitData ParsePIT(string fileName)
        {
            PitData data2;

            if (!File.Exists(fileName))
            {
                throw new Exception("The specified PIT file does not exist!");
            }
            using (FileStream stream4 = new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.ReadWrite))
            {
                byte[] array   = new byte[((int)(stream4.Length - 1L)) + 1];
                byte[] buffer2 = new byte[0x1400];
                byte[] pattern = new byte[] { 0x76, 0x98, 0x34, 0x12 };
                byte[] buffer4 = new byte[0x100];
                long   num     = 0L;
                stream4.Read(array, 0, array.Length);
                num              = HelperUtils.FindByteOffset(array, pattern, 0);
                buffer2          = HelperUtils.GetByteArray(array, ((int)num) - pattern.Length, buffer2.Length + 1);
                stream4.Position = 0L;
                stream4.SetLength((long)buffer2.Length);
                stream4.Write(buffer2, 0, buffer2.Length);
                stream4.Position = 0L;
                PitInputStream inputStream = new PitInputStream(stream4);
                data2 = new PitData();
                if (!data2.ReadPITFile(inputStream))
                {
                    throw new Exception("The specified PIT file contains corrupt or invalid data!");
                }
                MemoryStream    byteStream   = new MemoryStream();
                PitOutputStream outputStream = new PitOutputStream(byteStream);
                data2.WritePITFile(outputStream);
                stream4.Position = 0L;
                stream4.SetLength(byteStream.Length + buffer4.Length);
                stream4.Write(byteStream.ToArray(), 0, (int)byteStream.Length);
            }
            return(data2);
        }