Esempio n. 1
0
        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));
            }
        }
Esempio n. 2
0
        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));
                }
            }
        }
Esempio n. 3
0
        private void GetData(BTH heap, bool isTable = false)
        {
            if (PropertyLookupByTypeID.ContainsKey(Type))
            {
                var prop = PropertyLookupByTypeID[this.Type];
                MultiValue = prop.MultiValue;
                Variable   = prop.Variable;
                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;
                }
            }
        }