summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/registry.cc
diff options
context:
space:
mode:
Diffstat (limited to 'winsup/cygwin/registry.cc')
-rw-r--r--winsup/cygwin/registry.cc96
1 files changed, 1 insertions, 95 deletions
diff --git a/winsup/cygwin/registry.cc b/winsup/cygwin/registry.cc
index 632260aae..99b1d9b2d 100644
--- a/winsup/cygwin/registry.cc
+++ b/winsup/cygwin/registry.cc
@@ -1,7 +1,7 @@
/* registry.cc: registry interface
Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
- 2007, 2008, 2009, 2010, 2011, 2012 Red Hat, Inc.
+ 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Red Hat, Inc.
This file is part of Cygwin.
@@ -19,7 +19,6 @@ details. */
#include "tls_pbuf.h"
#include "ntdll.h"
#include <wchar.h>
-#include <alloca.h>
/* Opens a key under the appropriate Cygwin key.
Do not use HKCU per MS KB 199190 */
@@ -213,96 +212,3 @@ reg_key::~reg_key ()
NtClose (key);
key_is_invalid = 1;
}
-
-/* The buffer path points to should be at least MAX_PATH bytes. */
-PWCHAR
-get_registry_hive_path (PCWSTR name, PWCHAR path)
-{
- if (!name || !path)
- return NULL;
-
- WCHAR key[256];
- UNICODE_STRING buf;
- tmp_pathbuf tp;
- tp.u_get (&buf);
- NTSTATUS status;
-
- RTL_QUERY_REGISTRY_TABLE tab[2] = {
- { NULL, RTL_QUERY_REGISTRY_NOEXPAND | RTL_QUERY_REGISTRY_DIRECT
- | RTL_QUERY_REGISTRY_REQUIRED,
- L"ProfileImagePath", &buf, REG_NONE, NULL, 0 },
- { NULL, 0, NULL, NULL, 0, NULL, 0 }
- };
- wcpcpy (wcpcpy (key, L"ProfileList\\"), name);
- status = RtlQueryRegistryValues (RTL_REGISTRY_WINDOWS_NT, key, tab,
- NULL, NULL);
- if (!NT_SUCCESS (status) || buf.Length == 0)
- {
- debug_printf ("ProfileImagePath for %W not found, status %y", name,
- status);
- return NULL;
- }
- ExpandEnvironmentStringsW (buf.Buffer, path, MAX_PATH);
- debug_printf ("ProfileImagePath for %W: %W", name, path);
- return path;
-}
-
-void
-load_registry_hive (PCWSTR name)
-{
- if (!name)
- return;
-
- /* Fetch the path. Prepend native NT path prefix. */
- tmp_pathbuf tp;
- PWCHAR path = tp.w_get ();
- if (!get_registry_hive_path (name, wcpcpy (path, L"\\??\\")))
- return;
-
- WCHAR key[256];
- PWCHAR path_comp;
- UNICODE_STRING ukey, upath;
- OBJECT_ATTRIBUTES key_attr, path_attr;
- NTSTATUS status;
-
- /* Create keyname and path strings and object attributes. */
- wcpcpy (wcpcpy (key, L"\\Registry\\User\\"), name);
- RtlInitUnicodeString (&ukey, key);
- InitializeObjectAttributes (&key_attr, &ukey, OBJ_CASE_INSENSITIVE,
- NULL, NULL);
- /* First try to load the "normal" registry hive, which is what the user
- is supposed to see under HKEY_CURRENT_USER. */
- path_comp = wcschr (path, L'\0');
- wcpcpy (path_comp, L"\\ntuser.dat");
- RtlInitUnicodeString (&upath, path);
- InitializeObjectAttributes (&path_attr, &upath, OBJ_CASE_INSENSITIVE,
- NULL, NULL);
- status = NtLoadKey (&key_attr, &path_attr);
- if (!NT_SUCCESS (status))
- {
- debug_printf ("Loading user registry hive %S into %S failed: %y",
- &upath, &ukey, status);
- return;
- }
- debug_printf ("Loading user registry hive %S into %S SUCCEEDED: %y",
- &upath, &ukey, status);
- /* If loading the normal hive worked, try to load the classes hive into
- the sibling *_Classes subkey, which is what the user is supposed to
- see under HKEY_CLASSES_ROOT, merged with the machine-wide classes. */
- wcscat (key, L"_Classes");
- RtlInitUnicodeString (&ukey, key);
- /* Path to UsrClass.dat changed in Vista to
- \\AppData\\Local\\Microsoft\\Windows\\UsrClass.dat
- but old path is still available via symlinks. */
- wcpcpy (path_comp, L"\\Local Settings\\Application Data\\Microsoft\\"
- "Windows\\UsrClass.dat");
- RtlInitUnicodeString (&upath, path);
- /* Load UsrClass.dat file into key. */
- status = NtLoadKey (&key_attr, &path_attr);
- if (!NT_SUCCESS (status))
- debug_printf ("Loading user classes hive %S into %S failed: %y",
- &upath, &ukey, status);
- else
- debug_printf ("Loading user classes hive %S into %S SUCCEEDED: %y",
- &upath, &ukey, status);
-}