Exemplo n.º 1
0
        public SIBLOCK(BlockDataDTO dataBlock)
        {
            this.DataBlock = dataBlock;
            var type   = dataBlock.Data[0];
            var cLevel = dataBlock.Data[1];

            this.EntryCount = BitConverter.ToUInt16(dataBlock.Data, 2);
            this.Entries    = new List <SIENTRY>();
            for (int i = 0; i < EntryCount; i++)
            {
                this.Entries.Add(new SIENTRY(dataBlock.Data.RangeSubset(8 + 16 * i, 16)));
            }
        }
Exemplo n.º 2
0
 public XBLOCK(BlockDataDTO block)
 {
     this.Block         = block;
     this.BlockType     = block.Data[0];
     this.HeaderLevel   = block.Data[1];
     this.BIDEntryCount = BitConverter.ToUInt16(block.Data, 2);
     this.TotalBytes    = BitConverter.ToUInt32(block.Data, 4);
     this.BIDEntries    = new ulong[BIDEntryCount];
     for (int i = 0; i < BIDEntryCount; i++)
     {
         BIDEntries[i] = BitConverter.ToUInt64(block.Data, 8 + i * 8);
     }
 }
Exemplo n.º 3
0
        public SLBLOCK(BlockDataDTO blockData)
        {
            BlockData = blockData;
            var type   = blockData.Data[0];
            var clevel = blockData.Data[1];

            EntryCount = BitConverter.ToUInt16(blockData.Data, 2);
            Entries    = new List <SLENTRY>();
            for (int i = 0; i < EntryCount; i++)
            {
                Entries.Add(new SLENTRY(blockData.Data.RangeSubset(8 + 24 * i, 24)));
            }
        }
Exemplo n.º 4
0
        public XXBLOCK(BlockDataDTO block)
        {
            this.Block = block;

            this.Type          = block.Data[0];
            this.CLevel        = block.Data[1];
            this.TotalChildren = BitConverter.ToUInt16(block.Data, 2);
            this.TotalBytes    = BitConverter.ToUInt32(block.Data, 4);
            this.XBlockBIDs    = new ulong[this.TotalChildren];
            for (var i = 0; i < TotalChildren; i++)
            {
                this.XBlockBIDs[i] = BitConverter.ToUInt64(block.Data, 8 + 8 * i);
            }
        }
Exemplo n.º 5
0
        //for a given bbt entry, retrieve the raw bytes associated with the BID
        //this includes retrieving data trees via xblocks
        public static List <BlockDataDTO> GetBBTEntryData(BBTENTRY entry, PSTFile pst)
        {
            if (entry == null)
            {
                throw new InvalidDataException("Failed while parsing BBTEntry, the data block was invalid, try running a PST repair");
            }

            var dataSize  = entry.BlockByteCount;
            var blockSize = entry.BlockByteCount + 16;

            if (blockSize % 64 != 0)
            {
                blockSize += 64 - (blockSize % 64);
            }
            List <BlockDataDTO> dataBlocks;

            /*if (isSubNode)
             * {
             *  using (var viewer = PSTFile.PSTMMF.CreateViewAccessor((long)entry.BREF.IB, blockSize))
             *  {
             *      var blockBytes = new byte[dataSize];
             *      viewer.ReadArray(0, blockBytes, 0, dataSize);
             *      dataBlocks = new List<BlockDataDTO>
             *                       {new BlockDataDTO {Data = blockBytes, PstOffset = entry.BREF.IB, BBTEntry = entry}};
             *      return dataBlocks;
             *  }
             * } else */
            if (entry.Internal)
            {
                using (var viewer = pst.PSTMMF.CreateViewAccessor((long)entry.BREF.IB, blockSize))
                {
                    var blockBytes = new byte[dataSize];
                    viewer.ReadArray(0, blockBytes, 0, dataSize);

                    var trailerBytes = new byte[16];
                    viewer.ReadArray(blockSize - 16, trailerBytes, 0, 16);
                    var trailer = new BlockTrailer(trailerBytes, 0);

                    var dataBlockDTO = new BlockDataDTO
                    {
                        Data      = blockBytes,
                        PstOffset = entry.BREF.IB,
                        CRCOffset = (uint)((long)entry.BREF.IB + (blockSize - 12)),
                        BBTEntry  = entry
                    };
                    var type  = blockBytes[0];
                    var level = blockBytes[1];

                    if (type == 2) //si or sl entry
                    {
                        return(new List <BlockDataDTO> {
                            dataBlockDTO
                        });
                    }
                    else if (type == 1)
                    {
                        if (blockBytes[1] == 0x01) //XBLOCK
                        {
                            var xblock = new XBLOCK(dataBlockDTO);
                            return(BlockBO.GetXBlockData(xblock, pst));
                        }
                        else //XXBLOCK
                        {
                            var xxblock = new XXBLOCK(dataBlockDTO);
                            return(BlockBO.GetXXBlockData(xxblock, pst));
                        }
                    }
                    else
                    {
                        throw new NotImplementedException();
                    }
                }
            }
            else
            {
                using (var viewer = pst.PSTMMF.CreateViewAccessor((long)entry.BREF.IB, blockSize))
                {
                    var dataBytes = new byte[dataSize];
                    viewer.ReadArray(0, dataBytes, 0, dataSize);

                    var trailerBytes = new byte[16];
                    viewer.ReadArray(blockSize - 16, trailerBytes, 0, 16);
                    var trailer = new BlockTrailer(trailerBytes, 0);
                    dataBlocks = new List <BlockDataDTO>
                    {
                        new BlockDataDTO
                        {
                            Data      = dataBytes,
                            PstOffset = entry.BREF.IB,
                            CRC32     = trailer.CRC,
                            CRCOffset = (uint)(blockSize - 12),
                            BBTEntry  = entry
                        }
                    };
                }
            }

            for (int i = 0; i < dataBlocks.Count; i++)
            {
                var temp = dataBlocks[i].Data;
                DatatEncoder.CryptPermute(temp, temp.Length, false, pst);
            }
            return(dataBlocks);
        }