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 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 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 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)); } } }
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; } } }
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; } } }