* regtool.cc (KEY_WOW64_64KEY): Define.
(longopts): Add --wow64 option. (opts): Add -w option. (wow64): New variable to control usage of KEY_WOW64_64KEY access flag. (usage): Add text for --wow64/-w option. (print_version): Fix copyright. (find_key): Use wow64 value in calls to RegOpenKeyEx and RegCreateKeyEx. (cmd_add): Use wow64 value in call to RegCreateKeyEx. (regDeleteKeyEx): New function pointer to load RegDeleteKeyEx function dynamically. (cmd_remove): Load and use regDeleteKeyEx when wow64 is set. (main): Handle --wow64/-w option. * utils.sgml: Document the new -w option.
This commit is contained in:
parent
0b8affca5e
commit
40c60b89d5
@ -1,3 +1,19 @@
|
||||
2006-10-16 Corinna Vinschen <corinna@vinschen.de>
|
||||
|
||||
* regtool.cc (KEY_WOW64_64KEY): Define.
|
||||
(longopts): Add --wow64 option.
|
||||
(opts): Add -w option.
|
||||
(wow64): New variable to control usage of KEY_WOW64_64KEY access flag.
|
||||
(usage): Add text for --wow64/-w option.
|
||||
(print_version): Fix copyright.
|
||||
(find_key): Use wow64 value in calls to RegOpenKeyEx and RegCreateKeyEx.
|
||||
(cmd_add): Use wow64 value in call to RegCreateKeyEx.
|
||||
(regDeleteKeyEx): New function pointer to load RegDeleteKeyEx function
|
||||
dynamically.
|
||||
(cmd_remove): Load and use regDeleteKeyEx when wow64 is set.
|
||||
(main): Handle --wow64/-w option.
|
||||
* utils.sgml: Document the new -w option.
|
||||
|
||||
2006-10-05 Igor Peshansky <pechtcha@cs.nyu.edu>
|
||||
|
||||
* cygcheck.cc (get_word, get_dword): Move to path.cc.
|
||||
|
@ -18,6 +18,10 @@ details. */
|
||||
|
||||
#define DEFAULT_KEY_SEPARATOR '\\'
|
||||
|
||||
#ifndef KEY_WOW64_64KEY
|
||||
#define KEY_WOW64_64KEY 0x100
|
||||
#endif
|
||||
|
||||
enum
|
||||
{
|
||||
KT_AUTO, KT_BINARY, KT_INT, KT_STRING, KT_EXPAND, KT_MULTI
|
||||
@ -46,16 +50,18 @@ static struct option longopts[] =
|
||||
{"string", no_argument, NULL, 's'},
|
||||
{"verbose", no_argument, NULL, 'v'},
|
||||
{"version", no_argument, NULL, 'V'},
|
||||
{"wow64", no_argument, NULL, 'w'},
|
||||
{"key-separator", required_argument, NULL, 'K'},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
static char opts[] = "behiklmpqsvVK:";
|
||||
static char opts[] = "behiklmpqsvVwK:";
|
||||
|
||||
int listwhat = 0;
|
||||
int postfix = 0;
|
||||
int verbose = 0;
|
||||
int quiet = 0;
|
||||
DWORD wow64 = 0;
|
||||
char **argv;
|
||||
|
||||
HKEY key;
|
||||
@ -106,6 +112,7 @@ usage (FILE *where = stderr)
|
||||
" -h, --help output usage information and exit\n"
|
||||
" -q, --quiet no error output, just nonzero return if KEY/VALUE missing\n"
|
||||
" -v, --verbose verbose output, including VALUE contents when applicable\n"
|
||||
" -w, --wow64 access 64 bit registry view (ignored on 32 bit Windows)\n"
|
||||
" -V, --version output version information and exit\n"
|
||||
"\n");
|
||||
if (where == stdout)
|
||||
@ -148,7 +155,7 @@ print_version ()
|
||||
printf ("\
|
||||
%s (cygwin) %.*s\n\
|
||||
Registry Tool\n\
|
||||
Copyright 2000, 2001, 2002, 2003, 2004, 2005 Red Hat, Inc.\n\
|
||||
Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006 Red Hat, Inc.\n\
|
||||
Compiled on %s\n\
|
||||
", prog_name, len, v, __DATE__);
|
||||
}
|
||||
@ -360,13 +367,13 @@ find_key (int howmanyparts, REGSAM access, int option = 0)
|
||||
{
|
||||
if (access)
|
||||
{
|
||||
rv = RegOpenKeyEx (base, n, 0, access, &key);
|
||||
rv = RegOpenKeyEx (base, n, 0, access | wow64, &key);
|
||||
if (option && (rv == ERROR_SUCCESS || rv == ERROR_ACCESS_DENIED))
|
||||
{
|
||||
/* reopen with desired option due to missing option support in RegOpenKeyE */
|
||||
/* FIXME: may create the key in rare cases (e.g. access denied in parent) */
|
||||
HKEY key2;
|
||||
if (RegCreateKeyEx (base, n, 0, NULL, option, access, NULL, &key2, NULL)
|
||||
if (RegCreateKeyEx (base, n, 0, NULL, option, access | wow64, NULL, &key2, NULL)
|
||||
== ERROR_SUCCESS)
|
||||
{
|
||||
if (rv == ERROR_SUCCESS)
|
||||
@ -496,7 +503,7 @@ cmd_add ()
|
||||
HKEY newkey;
|
||||
DWORD newtype;
|
||||
int rv = RegCreateKeyEx (key, value, 0, (char *) "", REG_OPTION_NON_VOLATILE,
|
||||
KEY_ALL_ACCESS, 0, &newkey, &newtype);
|
||||
KEY_ALL_ACCESS | wow64, 0, &newkey, &newtype);
|
||||
if (rv != ERROR_SUCCESS)
|
||||
Fail (rv);
|
||||
|
||||
@ -510,11 +517,26 @@ cmd_add ()
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
WINADVAPI LONG WINAPI (*regDeleteKeyEx)(HKEY, LPCSTR, REGSAM, DWORD);
|
||||
}
|
||||
|
||||
int
|
||||
cmd_remove ()
|
||||
{
|
||||
DWORD rv;
|
||||
|
||||
find_key (2, KEY_ALL_ACCESS);
|
||||
DWORD rv = RegDeleteKey (key, value);
|
||||
if (wow64)
|
||||
{
|
||||
HMODULE mod = LoadLibrary ("advapi32.dll");
|
||||
if (mod)
|
||||
regDeleteKeyEx = (WINADVAPI LONG WINAPI (*)(HKEY, LPCSTR, REGSAM, DWORD)) GetProcAddress (mod, "RegDeleteKeyExA");
|
||||
}
|
||||
if (regDeleteKeyEx)
|
||||
rv = (*regDeleteKeyEx) (key, value, wow64, 0);
|
||||
else
|
||||
rv = RegDeleteKey (key, value);
|
||||
if (rv != ERROR_SUCCESS)
|
||||
Fail (rv);
|
||||
if (verbose)
|
||||
@ -838,6 +860,9 @@ main (int argc, char **_argv)
|
||||
case 'V':
|
||||
print_version ();
|
||||
exit (0);
|
||||
case 'w':
|
||||
wow64 = KEY_WOW64_64KEY;
|
||||
break;
|
||||
case 'K':
|
||||
key_sep = *optarg;
|
||||
break;
|
||||
|
@ -1060,6 +1060,7 @@ Other Options:
|
||||
-h, --help output usage information and exit
|
||||
-q, --quiet no error output, just nonzero return if KEY/VALUE missing
|
||||
-v, --verbose verbose output, including VALUE contents when applicable
|
||||
-w, --wow64 access 64 bit registry view (ignored on 32 bit Windows)
|
||||
-V, --version output version information and exit
|
||||
|
||||
KEY is in the format [host]\prefix\KEY\KEY\VALUE, where host is optional
|
||||
@ -1086,6 +1087,15 @@ Conversely, the <literal>-q</literal> option supresses error messages,
|
||||
so you can use the exit status of the program to detect if a key
|
||||
exists or not (for example).</para>
|
||||
|
||||
<para>The <literal>-w</literal> option allows to access the 64 bit view
|
||||
on the registry. Several subkeys exist in a 32 bit and a 64 bit version
|
||||
when running on Windows 64. Since Cygwin is running in 32 bit mode, it
|
||||
has only access to the 32 bit view of these registry keys. When using
|
||||
the <literal>-w</literal> the 64 bit view is used and
|
||||
<command>regtool</command> can access the entire registry.
|
||||
This option is simply ignored when running on 32 bit Windows versions.
|
||||
</para>
|
||||
|
||||
<para>You must provide <command>regtool</command> with an
|
||||
<emphasis>action</emphasis> following options (if any). Currently,
|
||||
the action must be <literal>add</literal>, <literal>set</literal>,
|
||||
|
Loading…
x
Reference in New Issue
Block a user