Beispiel #1
0
        public VirtualRegistryKey GetKey(String path, String user)
        {
            path = path.Replace('\\', '/');
            String first = path.Split('/')[0];
            String rest = path.Substring(first.Length).TrimStart('/');
            VirtualRegistryKey baseKey = null;
            if(first.Equals(HKEY_LOCAL_MACHINE)) {
                baseKey = new VirtualRegistryKey(HKEY_LOCAL_MACHINE);
                foreach (var kvp in hives) {
                    if (kvp.Value.Path.ToLower().Contains("windows/system32") && !kvp.Value.Path.ToLower().Contains("default")) {
                        VirtualRegistryKey vk = new VirtualRegistryKey(kvp.Key);
                        vk.AddKey(new VirtualRegistryKey(kvp.Value.Root));
                        baseKey.AddChildKey(vk);
                    }
                }
            } else if (first.Equals(HKEY_CURRENT_USER)) {
                baseKey = new VirtualRegistryKey(HKEY_CURRENT_USER);
                RegistryKey userKey = null, classesKey = null;

                foreach (var kvp in hives) {
                    if (kvp.Key == String.Format("{0}_{1}", user, USER_HIVE)) {
                        userKey = kvp.Value.Root;
                    }
                    if (kvp.Key == String.Format("{0}_{1}", user, USER_CLASS_HIVE)) {
                        classesKey = kvp.Value.Root;
                    }
                }

                baseKey.AddKey(new VirtualRegistryKey(userKey));
                VirtualRegistryKey classes = new VirtualRegistryKey("Classes");
                classes.AddKey(new VirtualRegistryKey(classesKey));
                GetKey(baseKey, "Software").AddChildKey(classes);

            } else if (first.Equals(HKEY_CLASSES_ROOT)) {
                baseKey = new VirtualRegistryKey(HKEY_CLASSES_ROOT);
                var k = GetKey(HKEY_CURRENT_USER + "/Software/Classes", user);
                if (k != null) {
                    baseKey.AddKey(k);
                }
                k = GetKey(HKEY_LOCAL_MACHINE + "/Software/Classes", user);
                if (k != null) {
                    baseKey.AddKey(k);
                }
            } else if (first.Equals(HKEY_USERS)) {
                baseKey = new VirtualRegistryKey(HKEY_USERS);
                foreach (var kvp in hives) {
                    if (kvp.Key.Contains("_")) {
                        baseKey.AddChildKey(new VirtualRegistryKey(kvp.Value.Root));
                    }
                }
            }
            return baseKey == null ? null : GetKey(baseKey, rest);
        }
Beispiel #2
0
 public void AddKey(VirtualRegistryKey key)
 {
     m_keys.AddRange(key.m_keys);
 }
Beispiel #3
0
 private VirtualRegistryKey GetKey(VirtualRegistryKey node, String path)
 {
     if (path.Length == 0) {
         return node;
     }
     String first = path.Split('/')[0];
     String rest = path.Substring(first.Length).TrimStart('/');
     foreach (VirtualRegistryKey child in node.GetChildren()) {
         if (child.Name.ToLower().Equals(first.ToLower())) {
             return GetKey(child, rest);
         }
     }
     return null;
 }
Beispiel #4
0
 public void AddChildKey(VirtualRegistryKey child)
 {
     m_virtualChildren.Add(child);
 }