Esempio n. 1
0
        internal static NamedKey[] GetInstances(byte[] bytes, string path, string key)
        {
            NamedKey hiveroot = RegistryHelper.GetRootKey(bytes, path);

            NamedKey nk = hiveroot;

            if (key != null)
            {
                foreach (string k in key.Split('\\'))
                {
                    NamedKey startingkey = nk;
                    foreach (NamedKey n in nk.GetSubKeys(bytes))
                    {
                        if (n.Name.ToUpper() == k.ToUpper())
                        {
                            nk = n;
                        }
                    }
                    if (nk == startingkey)
                    {
                        throw new Exception(string.Format("Cannot find key '{0}' in the '{1}' hive because it does not exist.", key, path));
                    }
                }
                if (nk == hiveroot)
                {
                    throw new Exception(string.Format("Cannot find key '{0}' in the '{1}' hive because it does not exist.", key, path));
                }
            }

            return(nk.GetSubKeys(bytes));
        }
Esempio n. 2
0
        internal static ValueKey Get(byte[] bytes, string path, string key, string val)
        {
            NamedKey hiveroot = RegistryHelper.GetRootKey(bytes, path);

            NamedKey nk = hiveroot;

            if (key != null)
            {
                foreach (string k in key.Split('\\'))
                {
                    foreach (NamedKey n in nk.GetSubKeys(bytes))
                    {
                        if (n.Name.ToUpper() == k.ToUpper())
                        {
                            nk = n;
                        }
                    }
                }
            }

            ValueKey[] values = nk.GetValues(bytes);

            foreach (ValueKey v in values)
            {
                if (v.Name.ToUpper() == val.ToUpper())
                {
                    return(v);
                }
            }

            return(null);
        }
Esempio n. 3
0
        internal static NamedKey GetOfficeKey(byte[] bytes, string path)
        {
            string key = @"Software\Microsoft\Office";

            NamedKey OfficeKey = null;

            try
            {
                OfficeKey = NamedKey.Get(bytes, path, key);
            }
            catch
            {
                throw new Exception(String.Format("Microsoft Office is not installed on this system"));
            }

            foreach (NamedKey nk in OfficeKey.GetSubKeys(bytes))
            {
                if (nk.Name.Contains(@".0"))
                {
                    if (nk.Name != "8.0")
                    {
                        return(nk);
                    }
                }
            }

            throw new Exception("Could not locate the Microsoft Office registry key");
        }
Esempio n. 4
0
        internal static string GetOfficeVersion(byte[] bytes, string hivePath)
        {
            NamedKey OfficeKey = null;

            try
            {
                OfficeKey = NamedKey.Get(bytes, hivePath, @"Software\Microsoft\Office");
            }
            catch
            {
                throw new Exception(String.Format("Microsoft Office is not installed on this system"));
            }

            foreach (NamedKey nk in OfficeKey.GetSubKeys(bytes))
            {
                if (nk.Name.Contains(@".0"))
                {
                    if (nk.Name != "8.0")
                    {
                        return(nk.FullName.Split('\\')[4]);
                    }
                }
            }

            throw new Exception("Could not locate the Microsoft Office registry key");
        }
        internal static NamedKey[] GetInstances(byte[] bytes, string path, string key)
        {
            NamedKey hiveroot = Helper.GetRootKey(bytes, path);

            NamedKey nk = hiveroot;

            if (key != null)
            {
                foreach (string k in key.Split('\\'))
                {
                    foreach (NamedKey n in nk.GetSubKeys(bytes))
                    {
                        if (n.Name.ToUpper() == k.ToUpper())
                        {
                            nk = n;
                        }
                    }
                }
            }

            return(nk.GetSubKeys(bytes));
        }
Esempio n. 6
0
        private static NamedKey[] GetInstances(byte[] bytes, NamedKey nk, bool recurse)
        {
            List <NamedKey> keyList = new List <NamedKey>();

            foreach (NamedKey subkey in nk.GetSubKeys(bytes))
            {
                keyList.Add(subkey);

                if (subkey.NumberOfSubKeys > 0)
                {
                    keyList.AddRange(GetInstances(bytes, subkey, true));
                }
            }

            return(keyList.ToArray());
        }
Esempio n. 7
0
        public static ValueKey Get(string path, string key, string val)
        {
            byte[] bytes = RegistryHelper.GetHiveBytes(path);

            NamedKey hiveroot = RegistryHelper.GetRootKey(bytes, path);

            NamedKey nk = hiveroot;

            if (key != null)
            {
                foreach (string k in key.Split('\\'))
                {
                    foreach (NamedKey n in nk.GetSubKeys(bytes))
                    {
                        if (n.Name.ToUpper() == k.ToUpper())
                        {
                            nk = n;
                        }
                    }
                }
                if (nk == hiveroot)
                {
                    throw new Exception(string.Format("Cannot find key '{0}' in the '{1}' hive because it does not exist.", key, path));
                }
            }

            ValueKey[] values = nk.GetValues(bytes);

            foreach (ValueKey v in values)
            {
                if (v.Name.ToUpper() == val.ToUpper())
                {
                    return(v);
                }
            }

            throw new Exception(string.Format("Cannot find value '{0}' as a value of '{1}' in the '{2}' hive because it does not exist.", val, key, path));
        }
Esempio n. 8
0
        public static ValueKey[] GetInstances(string path, string key)
        {
            byte[] bytes = RegistryHelper.GetHiveBytes(path);

            NamedKey hiveroot = RegistryHelper.GetRootKey(bytes, path);

            NamedKey nk = hiveroot;

            if (key != null)
            {
                foreach (string k in key.Split('\\'))
                {
                    foreach (NamedKey n in nk.GetSubKeys(bytes))
                    {
                        if (n.Name.ToUpper() == k.ToUpper())
                        {
                            nk = n;
                        }
                    }
                }
            }

            return(nk.GetValues(bytes));
        }
Esempio n. 9
0
        private static NamedKey[] GetInstances(byte[] bytes, NamedKey nk, bool recurse)
        {
            List<NamedKey> keyList = new List<NamedKey>();

            foreach(NamedKey subkey in nk.GetSubKeys(bytes, nk.FullName))
            {
                keyList.Add(subkey);

                if (subkey.NumberOfSubKeys > 0)
                {
                    keyList.AddRange(GetInstances(bytes, subkey, true));
                }
            }

            return keyList.ToArray();
        }
Esempio n. 10
0
        internal static NamedKey[] GetInstances(byte[] bytes, string path)
        {
            NamedKey hiveroot = RegistryHelper.GetRootKey(bytes, path);

            return(hiveroot.GetSubKeys());
        }