using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace PFCRip { public class PFCObject { protected virtual byte[] SyncHeader { get; set; } public byte[] Data; public PFCObject(byte[] data, uint startIndex) { var header = new byte[SyncHeader.Length]; for (int i = 0; i < header.Length; i++) header[i] = data[startIndex + i]; //First verify the sync header is correct for (int i = 0; i < SyncHeader.Length; i++) if (data[startIndex + i] != SyncHeader[i]) throw new InvalidOperationException(String.Format("Sync header not valid: {0} required, {1} specified", BitConverter.ToString(SyncHeader), BitConverter.ToString(header))); //Get the size of the block uint size = LittleEndianConverter.ToUInt32(data, startIndex + 4); //Save this data Data = new byte[size]; for (int i = 0; i < Data.Length; i++) Data[i] = data[startIndex + 8 + i]; } } }