Ejemplo n.º 1
0
        internal static List Factory(byte[] bytes, byte[] subKeyListBytes, string type)
        {
            if (type == "lf")
            {
                return(new Leaf(subKeyListBytes));
            }
            else if (type == "lh")
            {
                return(new HashedLeaf(subKeyListBytes));
            }
            else if (type == "li")
            {
                return(new LeafItem(subKeyListBytes));
            }
            else if (type == "ri")
            {
                List ri = new ReferenceItem(subKeyListBytes);

                List[] listArray = new List[ri.Count];

                for (int i = 0; i < ri.Offset.Length; i++)
                {
                    byte[] sublistBytes = Util.GetSubArray(bytes, ri.Offset[i], (uint)Math.Abs(BitConverter.ToInt32(bytes, (int)ri.Offset[i])));
                    string subtype      = Encoding.ASCII.GetString(sublistBytes, 0x04, 0x02);

                    listArray[i] = List.Factory(bytes, sublistBytes, subtype);
                }

                ushort aggCount = 0;
                foreach (List l in listArray)
                {
                    aggCount += l.Count;
                }

                uint[] aggOffset = new uint[aggCount];
                int    j         = 0;
                foreach (List l in listArray)
                {
                    for (int k = 0; (k < l.Count) && (j < aggCount); k++)
                    {
                        aggOffset[j] = l.Offset[k];
                        j++;
                    }
                }

                return(new ReferenceItem(aggCount, aggOffset));
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 2
0
        internal NamedKey[] GetSubKeys(byte[] bytes)
        {
            if (NumberOfSubKeys > 0)
            {
                byte[] subKeyListBytes = Util.GetSubArray(bytes, (uint)SubKeysListOffset, (uint)Math.Abs(BitConverter.ToInt32(bytes, this.SubKeysListOffset)));
                string type            = Encoding.ASCII.GetString(subKeyListBytes, 0x04, 0x02);

                List list = List.Factory(bytes, subKeyListBytes, type);

                NamedKey[] nkArray = new NamedKey[list.Count];

                for (int i = 0; i < list.Count; i++)
                {
                    int size = Math.Abs(BitConverter.ToInt32(bytes, (int)list.Offset[i]));
                    nkArray[i] = new NamedKey(Util.GetSubArray(bytes, list.Offset[i], (uint)size), HivePath, this.FullName);
                }

                return(nkArray);
            }
            else
            {
                return(null);
            }
        }