public PropertyContext(NodeDataDTO data) { var HN = new HN(data); BTH = new BTH(HN); Properties = BTH.GetExchangeProperties(); }
public PropertyContext(ulong nid, PSTFile pst) { var bytes = BlockBO.GetNodeData(nid, pst); var HN = new HN(bytes); this.BTH = new BTH(HN); this.Properties = this.BTH.GetExchangeProperties(); }
public BTHIndexNode(HID hid, BTH tree, int level) { this.Level = level; this.HID = hid; if (hid.hidBlockIndex == 0 && hid.hidIndex == 0) return; this.Entries = new List<BTHIndexEntry>(); if (level == 0) { this.Data = new BTHDataNode(hid, tree); /* for (int i = 0; i < bytes.Length; i += (int)tree.Header.KeySize + 4) this.Entries.Add(new BTHIndexEntry(bytes, i, tree.Header)); this.DataChildren = new List<BTHDataNode>(); foreach(var entry in this.Entries) this.DataChildren.Add(new BTHDataNode(entry.HID, tree));*/ } else { var bytes = tree.GetHIDBytes(hid); for (int i = 0; i < bytes.Data.Length; i += (int)tree.Header.KeySize + 4) this.Entries.Add(new BTHIndexEntry(bytes.Data, i, tree.Header)); this.Children = new List<BTHIndexNode>(); foreach(var entry in this.Entries) this.Children.Add(new BTHIndexNode(entry.HID, tree, level - 1)); } }
public BTHDataEntry(HNDataDTO data, int offset, BTH tree) { Key = data.Data.RangeSubset(offset, (int)tree.Header.KeySize); //Key = bytes.Skip(offset).Take((int)tree.Header.KeySize).ToArray(); Data = data.Data.RangeSubset(offset + (int)tree.Header.KeySize, (int)tree.Header.DataSize); DataOffset = (ulong)offset + tree.Header.KeySize; ParentTree = tree; }
public BTHDataEntry(HNDataDTO data, int offset, BTH tree) { this.Key = data.Data.RangeSubset(offset, (int) tree.Header.KeySize); //this.Key = bytes.Skip(offset).Take((int)tree.Header.KeySize).ToArray(); var temp = offset + (int) tree.Header.KeySize; this.Data = data.Data.RangeSubset(temp, (int)tree.Header.DataSize); this.DataOffset = (ulong) offset + tree.Header.KeySize; this.ParentTree = tree; }
public BTHDataNode(HID hid, BTH tree) { this.Tree = tree; var bytes = tree.GetHIDBytes(hid); this._data = bytes; this.DataEntries = new List<BTHDataEntry>(); for(int i= 0;i < bytes.Data.Length;i+= (int)(tree.Header.KeySize+tree.Header.DataSize)) this.DataEntries.Add(new BTHDataEntry(bytes, i, tree)); }
public ExchangeProperty(BTHDataEntry entry, BTH heap) { //this.entry = entry; Key = entry.Data.RangeSubset(2, entry.Data.Length - 2); ID = (MessageProperty)BitConverter.ToUInt16(entry.Key, 0); Type = (PropType)BitConverter.ToUInt16(entry.Data, 0); GetData(heap); }
public ExchangeProperty(BTHDataEntry entry, BTH heap) { //this.entry = entry; this.Key = entry.Data.RangeSubset(2, entry.Data.Length - 2); this.ID = BitConverter.ToUInt16(entry.Key, 0); this.Type = BitConverter.ToUInt16(entry.Data, 0); this.GetData(heap); }
public TCRowMatrixData(byte[] bytes, TableContext context, BTH heap, int offset = 0) { this.ColumnXREF = new Dictionary <uint, byte[]>(); this._heap = heap; //todo: cell existence test //var rowSize = context.TCHeader.EndOffsetCEB; foreach (var col in context.TCHeader.ColumnsDescriptors) { this.ColumnXREF.Add(col.Tag, bytes.RangeSubset(offset + col.DataOffset, col.DataSize)); } }
public ExchangeProperty(UInt16 ID, UInt16 type, BTH heap, byte[] key) { this.ID = ID; this.Type = type; /*var tempKey = new byte[key.Length + 2]; tempKey[0] = 0x00; tempKey[1] = 0x00; for (int i = 0; i < key.Length; i++) tempKey[i + 2] = key[i];*/ this.Key = key; GetData(heap, true); }
public BTHDataNode(HID hid, BTH tree) { this.Tree = tree; var bytes = tree.GetHIDBytes(hid); this._data = bytes; this.DataEntries = new List <BTHDataEntry>(); for (int i = 0; i < bytes.Data.Length; i += (int)(tree.Header.KeySize + tree.Header.DataSize)) { this.DataEntries.Add(new BTHDataEntry(bytes, i, tree)); } }
public ExchangeProperty(UInt16 ID, UInt16 type, BTH heap, byte[] key) { this.ID = ID; this.Type = type; /*var tempKey = new byte[key.Length + 2]; * tempKey[0] = 0x00; * tempKey[1] = 0x00; * for (int i = 0; i < key.Length; i++) * tempKey[i + 2] = key[i];*/ this.Key = key; GetData(heap, true); }
public TableContext(NodeDataDTO nodeData) { this.NodeData = nodeData; this.HeapNode = new HN(this.NodeData); var tcinfoHID = this.HeapNode.HeapNodes[0].Header.UserRoot; var tcinfoHIDbytes = this.HeapNode.GetHIDBytes(tcinfoHID); this.TCHeader = new TCINFOHEADER(tcinfoHIDbytes.Data); this.RowIndexBTH = new BTH(this.HeapNode, this.TCHeader.RowIndexLocation); this.ReverseRowIndex = new Dictionary<uint, uint>(); foreach (var prop in this.RowIndexBTH.Properties) { var temp = BitConverter.ToUInt32(prop.Value.Data, 0); this.ReverseRowIndex.Add(temp, BitConverter.ToUInt32(prop.Key, 0)); } this.RowMatrix = new TCRowMatrix(this, this.RowIndexBTH); }
public TableContext(NodeDataDTO nodeData) { this.NodeData = nodeData; this.HeapNode = new HN(this.NodeData); var tcinfoHID = this.HeapNode.HeapNodes[0].Header.UserRoot; var tcinfoHIDbytes = this.HeapNode.GetHIDBytes(tcinfoHID); this.TCHeader = new TCINFOHEADER(tcinfoHIDbytes.Data); this.RowIndexBTH = new BTH(this.HeapNode, this.TCHeader.RowIndexLocation); this.ReverseRowIndex = new Dictionary <uint, uint>(); foreach (var prop in this.RowIndexBTH.Properties) { var temp = BitConverter.ToUInt32(prop.Value.Data, 0); this.ReverseRowIndex.Add(temp, BitConverter.ToUInt32(prop.Key, 0)); } this.RowMatrix = new TCRowMatrix(this, this.RowIndexBTH); }
public BTHIndexNode(HID hid, BTH tree, int level) { this.Level = level; this.HID = hid; if (hid.hidBlockIndex == 0 && hid.hidIndex == 0) { return; } this.Entries = new List <BTHIndexEntry>(); if (level == 0) { this.Data = new BTHDataNode(hid, tree); /* * for (int i = 0; i < bytes.Length; i += (int)tree.Header.KeySize + 4) * this.Entries.Add(new BTHIndexEntry(bytes, i, tree.Header)); * this.DataChildren = new List<BTHDataNode>(); * foreach(var entry in this.Entries) * this.DataChildren.Add(new BTHDataNode(entry.HID, tree));*/ } else { var bytes = tree.GetHIDBytes(hid); for (int i = 0; i < bytes.Data.Length; i += (int)tree.Header.KeySize + 4) { this.Entries.Add(new BTHIndexEntry(bytes.Data, i, tree.Header)); } this.Children = new List <BTHIndexNode>(); foreach (var entry in this.Entries) { this.Children.Add(new BTHIndexNode(entry.HID, tree, level - 1)); } } }
public PropertyContext(NodeDataDTO data) { var HN = new HN(data); this.BTH = new BTH(HN); this.Properties = this.BTH.GetExchangeProperties(); }
private void GetData(BTH heap, bool isTable = false) { if (ExchangeProperty.PropertyLookupByTypeID.ContainsKey(this.Type)) { var prop = ExchangeProperty.PropertyLookupByTypeID[this.Type]; this.MultiValue = prop.MultiValue; this.Variable = prop.Variable; this.ByteCount = prop.ByteCount; } //get data here if (!this.MultiValue && !this.Variable) { if (this.ByteCount <= 4 || (isTable && this.ByteCount <= 8)) { this.Data = this.Key; } else { this.Data = heap.GetHIDBytes(new HID(this.Key)).Data; } } else { //oh no, it's an HNID var curID = BitConverter.ToUInt32(this.Key, 0); if (curID == 0) { } else if ((curID & 0x1F) == 0) //must be HID { this.Data = heap.GetHIDBytes(new HID(this.Key)).Data; } else //let's assume NID { var totalSize = 0; var dataBlocks = new List <BlockDataDTO>(); if (heap.HeapNode.HeapSubNode.ContainsKey(curID)) { dataBlocks = heap.HeapNode.HeapSubNode[curID].NodeData; } else { var tempSubNodeXREF = new Dictionary <ulong, NodeDataDTO>(); foreach (var heapSubNode in heap.HeapNode.HeapSubNode) { tempSubNodeXREF.Add(heapSubNode.Key & 0xFFFFFFFF, heapSubNode.Value); } dataBlocks = tempSubNodeXREF[curID].NodeData; //dataBlocks = entry.ParentTree.HeapNode.HeapSubNode[curID].NodeData; } foreach (var dataBlock in dataBlocks) { totalSize += dataBlock.Data.Length; } var allData = new byte[totalSize]; var curPos = 0; foreach (var datablock in dataBlocks) { for (int i = 0; i < datablock.Data.Length; i++) { allData[i + curPos] = datablock.Data[i]; } curPos += datablock.Data.Length; } this.Data = allData; } } }
public TCRowMatrix(TableContext tableContext, BTH heap) { this.Rows = new List <TCRowMatrixData>(); this.RowXREF = new Dictionary <uint, TCRowMatrixData>(); this.TableContext = tableContext; var rowMatrixHNID = this.TableContext.TCHeader.RowMatrixLocation; if (rowMatrixHNID == 0) { return; } if ((rowMatrixHNID & 0x1F) == 0)//HID { this.TCRMData = new List <BlockDataDTO> { new BlockDataDTO { Data = this.TableContext.HeapNode.GetHIDBytes(new HID(BitConverter.GetBytes(rowMatrixHNID))).Data } }; } else { if (this.TableContext.HeapNode.HeapSubNode.ContainsKey(rowMatrixHNID)) { this.TCRMData = this.TableContext.HeapNode.HeapSubNode[rowMatrixHNID].NodeData; } else { var tempSubNodes = new Dictionary <ulong, NodeDataDTO>(); foreach (var nod in this.TableContext.HeapNode.HeapSubNode) { tempSubNodes.Add(nod.Key & 0xffffffff, nod.Value); } this.TCRMData = tempSubNodes[rowMatrixHNID].NodeData; } } //this.TCRMSubNodeData = this.TableContext.HeapNode.HeapSubNode[]; var rowSize = this.TableContext.TCHeader.EndOffsetCEB; //var rowPerBlock = (8192 - 16)/rowSize; foreach (var row in this.TableContext.RowIndexBTH.Properties) { var rowIndex = BitConverter.ToUInt32(row.Value.Data, 0); var blockTrailerSize = 16; var maxBlockSize = 8192 - blockTrailerSize; var recordsPerBlock = maxBlockSize / rowSize; var blockIndex = (int)rowIndex / recordsPerBlock; var indexInBlock = rowIndex % recordsPerBlock; var curRow = new TCRowMatrixData(this.TCRMData[blockIndex].Data, this.TableContext, heap, (int)indexInBlock * rowSize); this.RowXREF.Add(BitConverter.ToUInt32(row.Key, 0), curRow); this.Rows.Add(curRow); } /* * uint curIndex = 0; * foreach (var dataBlock in this.TCRMData) * { * for(int i = 0;i + rowSize < dataBlock.Data.Length; i += rowSize) * { * var curRow = new TCRowMatrixData(dataBlock.Data, this.TableContext, i); * this.RowXREF.Add(this.TableContext.ReverseRowIndex[curIndex], curRow); * this.Rows.Add(curRow); * curIndex++; * } * }*/ }
public TCRowMatrix(TableContext tableContext, BTH heap) { this.Rows = new List<TCRowMatrixData>(); this.RowXREF = new Dictionary<uint, TCRowMatrixData>(); this.TableContext = tableContext; var rowMatrixHNID = this.TableContext.TCHeader.RowMatrixLocation; if (rowMatrixHNID == 0) return; if ((rowMatrixHNID & 0x1F) == 0)//HID { this.TCRMData = new List<BlockDataDTO>{ new BlockDataDTO { Data = this.TableContext.HeapNode.GetHIDBytes(new HID(BitConverter.GetBytes(rowMatrixHNID))).Data }}; } else { if (this.TableContext.HeapNode.HeapSubNode.ContainsKey(rowMatrixHNID)) this.TCRMData = this.TableContext.HeapNode.HeapSubNode[rowMatrixHNID].NodeData; else { var tempSubNodes = new Dictionary<ulong, NodeDataDTO>(); foreach(var nod in this.TableContext.HeapNode.HeapSubNode) tempSubNodes.Add(nod.Key & 0xffffffff, nod.Value); this.TCRMData = tempSubNodes[rowMatrixHNID].NodeData; } } //this.TCRMSubNodeData = this.TableContext.HeapNode.HeapSubNode[]; var rowSize = this.TableContext.TCHeader.EndOffsetCEB; //var rowPerBlock = (8192 - 16)/rowSize; foreach(var row in this.TableContext.RowIndexBTH.Properties) { var rowIndex = BitConverter.ToUInt32(row.Value.Data, 0); var blockTrailerSize = 16; var maxBlockSize = 8192 - blockTrailerSize; var recordsPerBlock = maxBlockSize/rowSize; var blockIndex = (int)rowIndex/recordsPerBlock; var indexInBlock = rowIndex%recordsPerBlock; var curRow = new TCRowMatrixData(this.TCRMData[blockIndex].Data, this.TableContext, heap, (int) indexInBlock*rowSize); this.RowXREF.Add(BitConverter.ToUInt32(row.Key, 0), curRow); this.Rows.Add(curRow); } /* uint curIndex = 0; foreach (var dataBlock in this.TCRMData) { for(int i = 0;i + rowSize < dataBlock.Data.Length; i += rowSize) { var curRow = new TCRowMatrixData(dataBlock.Data, this.TableContext, i); this.RowXREF.Add(this.TableContext.ReverseRowIndex[curIndex], curRow); this.Rows.Add(curRow); curIndex++; } }*/ }
private void GetData(BTH heap, bool isTable = false) { if (ExchangeProperty.PropertyLookupByTypeID.ContainsKey(this.Type)) { var prop = ExchangeProperty.PropertyLookupByTypeID[this.Type]; this.MultiValue = prop.MultiValue; this.Variable = prop.Variable; this.ByteCount = prop.ByteCount; } //get data here if (!this.MultiValue && !this.Variable) { if (this.ByteCount <= 4 || (isTable && this.ByteCount <= 8)) { this.Data = this.Key; } else { this.Data = heap.GetHIDBytes(new HID(this.Key)).Data; } } else { //oh no, it's an HNID var curID = BitConverter.ToUInt32(this.Key, 0); if (curID == 0) { } else if ((curID & 0x1F) == 0) //must be HID { this.Data = heap.GetHIDBytes(new HID(this.Key)).Data; } else //let's assume NID { var totalSize = 0; var dataBlocks = new List<BlockDataDTO>(); if (heap.HeapNode.HeapSubNode.ContainsKey(curID)) dataBlocks = heap.HeapNode.HeapSubNode[curID].NodeData; else { var tempSubNodeXREF = new Dictionary<ulong, NodeDataDTO>(); foreach (var heapSubNode in heap.HeapNode.HeapSubNode) tempSubNodeXREF.Add(heapSubNode.Key & 0xFFFFFFFF, heapSubNode.Value); dataBlocks = tempSubNodeXREF[curID].NodeData; //dataBlocks = entry.ParentTree.HeapNode.HeapSubNode[curID].NodeData; } foreach (var dataBlock in dataBlocks) totalSize += dataBlock.Data.Length; var allData = new byte[totalSize]; var curPos = 0; foreach (var datablock in dataBlocks) { for (int i = 0; i < datablock.Data.Length; i++) { allData[i + curPos] = datablock.Data[i]; } curPos += datablock.Data.Length; } this.Data = allData; } } }