Exemplo n.º 1
0
 public void WritePITFile(PitOutputStream outputStream)
 {
     outputStream.WriteInt(0x12349876);
     outputStream.WriteInt(this._entryCount);
     outputStream.WriteBytes(this._dummyData1);
     outputStream.WriteBytes(this._dummyData2);
     outputStream.WriteBytes(this._dummyData3);
     outputStream.WriteBytes(this._dummyData4);
     outputStream.WriteBytes(this._dummyData5);
     for (int i = 0; i < this._entryCount; i++)
     {
         PitEntry entry = this._entries[i];
         outputStream.WriteInt((int)entry.BinaryType);
         outputStream.WriteInt((int)entry.DeviceType);
         outputStream.WriteInt(entry.Identifier);
         outputStream.WriteInt((int)entry.Attribute);
         outputStream.WriteInt((int)entry.UpdateAttribute);
         outputStream.WriteInt(entry.BlockSize);
         outputStream.WriteInt(entry.BlockCount);
         outputStream.WriteInt(entry.FileOffset);
         outputStream.WriteInt(entry.FileSize);
         outputStream.WriteString(entry.PartitionName, 0x20);
         outputStream.WriteString(entry.FlashFileName, 0x20);
         outputStream.WriteString(entry.FotaFileName, 0x20);
     }
 }
Exemplo n.º 2
0
 public static PitEntry Clone(PitEntry pEntry)
 {
     using (MemoryStream stream = new MemoryStream())
     {
         BinaryFormatter formatter = new BinaryFormatter();
         formatter.Serialize(stream, pEntry);
         stream.Position = 0L;
         return((PitEntry)formatter.Deserialize(stream));
     }
 }
Exemplo n.º 3
0
        public PitEntry FindEntry(string partitionName)
        {
            int num = 0;

            while (num < this._entries.Count)
            {
                PitEntry entry2 = this._entries[num];
                if (string.Equals(partitionName, entry2.PartitionName))
                {
                    return(entry2);
                }
            }
            return(null);
        }
Exemplo n.º 4
0
 public bool ReadPITFile(PitInputStream inputStream)
 {
     byte[] buffer  = new byte[4];
     byte[] buffer2 = new byte[0x20];
     if (inputStream.ReadInt() != 0x12349876)
     {
         return(false);
     }
     this._entries.Clear();
     this._entryCount       = inputStream.ReadInt();
     this._entries.Capacity = this._entryCount;
     this._dummyData1       = inputStream.ReadBytes(4);
     this._dummyData2       = inputStream.ReadBytes(4);
     this._dummyData3       = inputStream.ReadBytes(4);
     this._dummyData4       = inputStream.ReadBytes(4);
     this._dummyData5       = inputStream.ReadBytes(4);
     for (int i = 0; i < this._entryCount; i++)
     {
         PitEntry item = new PitEntry {
             Index = i
         };
         item.SetEntryMemAddr(inputStream.GetMemoryAddress());
         int num2 = inputStream.ReadInt();
         item.BinaryType      = (PitEntry.EntryBinaryType)num2;
         num2                 = inputStream.ReadInt();
         item.DeviceType      = (PitEntry.EntryDeviceType)num2;
         num2                 = inputStream.ReadInt();
         item.Identifier      = num2;
         num2                 = inputStream.ReadInt();
         item.Attribute       = (PitEntry.EntryAttribute)num2;
         num2                 = inputStream.ReadInt();
         item.UpdateAttribute = (PitEntry.EntryUpdateAttribute)num2;
         num2                 = inputStream.ReadInt();
         item.BlockSize       = num2;
         num2                 = inputStream.ReadInt();
         item.BlockCount      = num2;
         num2                 = inputStream.ReadInt();
         item.FileOffset      = num2;
         num2                 = inputStream.ReadInt();
         item.FileSize        = num2;
         item.PartitionName   = inputStream.ReadString(buffer2, 0x20);
         item.FlashFileName   = inputStream.ReadString(buffer2, 0x20);
         item.FotaFileName    = inputStream.ReadString(buffer2, 0x20);
         this._entries.Add(item);
     }
     return(true);
 }
Exemplo n.º 5
0
 public bool Matches(PitData otherPitData)
 {
     if (!((((((this._entryCount == otherPitData._entryCount) & this.CompareByteArray(this._dummyData1, otherPitData._dummyData1)) & this.CompareByteArray(this._dummyData2, otherPitData._dummyData2)) & this.CompareByteArray(this._dummyData3, otherPitData._dummyData3)) & this.CompareByteArray(this._dummyData4, otherPitData._dummyData4)) & this.CompareByteArray(this._dummyData5, otherPitData._dummyData5)))
     {
         return(false);
     }
     for (int i = 0; i < this._entryCount; i++)
     {
         PitEntry entry         = this._entries[i];
         PitEntry otherPitEntry = otherPitData._entries[i];
         if (Conversions.ToBoolean(Operators.NotObject(entry.Matches(otherPitEntry))))
         {
             return(false);
         }
     }
     return(true);
 }
Exemplo n.º 6
0
        public void RemoveEntry(int index)
        {
            List <PitEntry> .Enumerator enumerator;
            this._entries.RemoveAt(index);
            this._entryCount--;
            int num = 0;

            try
            {
                enumerator = this._entries.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    PitEntry current = enumerator.Current;
                    current.Index = num;
                    num++;
                }
            }
            finally
            {
                enumerator.Dispose();
            }
        }
Exemplo n.º 7
0
 public void AddEntry(PitEntry entry)
 {
     entry.Index = this._entryCount;
     this._entries.Add(entry);
     this._entryCount++;
 }
Exemplo n.º 8
0
 public void SetEntry(int index, PitEntry newPitEntry)
 {
     this._entries.RemoveAt(index);
     this._entries.Insert(index, newPitEntry);
 }
Exemplo n.º 9
0
 public object Matches(PitEntry otherPitEntry) =>
 ((((((((((((this._binaryType == otherPitEntry._binaryType) & (this._deviceType == otherPitEntry._deviceType)) & (this._identifier == otherPitEntry._identifier)) & (this._attribute == otherPitEntry._attribute)) & (this._updateAttribute == otherPitEntry._updateAttribute)) & (this._blockSize == otherPitEntry._blockSize)) & (this._blockCount == otherPitEntry._blockCount)) & (this._fileOffset == otherPitEntry._fileOffset)) & (this._fileSize == otherPitEntry._fileSize)) & string.Equals(this._partitionName, otherPitEntry._partitionName)) & string.Equals(this._flashFilename, otherPitEntry._flashFilename)) & string.Equals(this._fotaFilename, otherPitEntry._fotaFilename));