Signed-off-by: Hugh McMaster hugh.mcmaster@outlook.com --- programs/reg/reg.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/programs/reg/reg.h b/programs/reg/reg.h index c7719a6e4f0..c281770bdb4 100644 --- a/programs/reg/reg.h +++ b/programs/reg/reg.h @@ -27,7 +27,7 @@
/* reg.c */ struct reg_type_rels { - DWORD type; + const DWORD type; const WCHAR *name; };
Signed-off-by: Hugh McMaster hugh.mcmaster@outlook.com --- programs/reg/add.c | 4 ++-- programs/reg/delete.c | 4 +++- programs/reg/export.c | 8 +++++--- programs/reg/query.c | 4 +++- programs/reg/reg.c | 6 ++---- programs/reg/reg.h | 3 ++- 6 files changed, 17 insertions(+), 12 deletions(-)
diff --git a/programs/reg/add.c b/programs/reg/add.c index f259f0a4100..d94789ad484 100644 --- a/programs/reg/add.c +++ b/programs/reg/add.c @@ -213,11 +213,11 @@ static int run_add(HKEY root, WCHAR *path, WCHAR *value_name, BOOL value_empty, int reg_add(int argc, WCHAR *argvW[]) { HKEY root; - WCHAR *path, *key_name, *value_name = NULL, *type = NULL, *data = NULL, separator = '\0'; + WCHAR *path, *value_name = NULL, *type = NULL, *data = NULL, separator = '\0'; BOOL value_empty = FALSE, force = FALSE; int i;
- if (!parse_registry_key(argvW[2], &root, &path, &key_name)) + if (!parse_registry_key(argvW[2], &root, &path)) return 1;
for (i = 3; i < argc; i++) diff --git a/programs/reg/delete.c b/programs/reg/delete.c index b23b14e8dab..626fcf3b341 100644 --- a/programs/reg/delete.c +++ b/programs/reg/delete.c @@ -113,7 +113,7 @@ int reg_delete(int argc, WCHAR *argvW[]) BOOL value_all = FALSE, value_empty = FALSE, force = FALSE; int i;
- if (!parse_registry_key(argvW[2], &root, &path, &key_name)) + if (!parse_registry_key(argvW[2], &root, &path)) return 1;
for (i = 3; i < argc; i++) @@ -158,6 +158,8 @@ int reg_delete(int argc, WCHAR *argvW[]) if ((value_name && value_empty) || (value_name && value_all) || (value_empty && value_all)) goto invalid;
+ key_name = get_long_key(root, path); + return run_delete(root, path, key_name, value_name, value_empty, value_all, force);
invalid: diff --git a/programs/reg/export.c b/programs/reg/export.c index 5d55eaad407..13d5871d57e 100644 --- a/programs/reg/export.c +++ b/programs/reg/export.c @@ -347,14 +347,14 @@ static HANDLE get_file_handle(WCHAR *filename, BOOL overwrite_file) int reg_export(int argc, WCHAR *argvW[]) { HKEY root, hkey; - WCHAR *path, *long_key; + WCHAR *path, *key_name; BOOL overwrite_file = FALSE; HANDLE hFile; int i, ret;
if (argc < 4) goto invalid;
- if (!parse_registry_key(argvW[2], &root, &path, &long_key)) + if (!parse_registry_key(argvW[2], &root, &path)) return 1;
for (i = 4; i < argc; i++) @@ -378,9 +378,11 @@ int reg_export(int argc, WCHAR *argvW[]) return 1; }
+ key_name = get_long_key(root, path); + hFile = get_file_handle(argvW[3], overwrite_file); export_file_header(hFile); - ret = export_registry_data(hFile, hkey, long_key); + ret = export_registry_data(hFile, hkey, key_name); export_newline(hFile); CloseHandle(hFile);
diff --git a/programs/reg/query.c b/programs/reg/query.c index cc8f264e780..76f12b4a2d3 100644 --- a/programs/reg/query.c +++ b/programs/reg/query.c @@ -329,7 +329,7 @@ int reg_query(int argc, WCHAR *argvW[]) BOOL value_empty = FALSE, recurse = FALSE; int i;
- if (!parse_registry_key(argvW[2], &root, &path, &key_name)) + if (!parse_registry_key(argvW[2], &root, &path)) return 1;
for (i = 3; i < argc; i++) @@ -368,6 +368,8 @@ int reg_query(int argc, WCHAR *argvW[]) if (value_name && value_empty) goto invalid;
+ key_name = get_long_key(root, path); + return run_query(root, path, key_name, value_name, value_empty, recurse);
invalid: diff --git a/programs/reg/reg.c b/programs/reg/reg.c index 6b337f5d415..3ffc5fe3d8f 100644 --- a/programs/reg/reg.c +++ b/programs/reg/reg.c @@ -203,7 +203,7 @@ WCHAR *build_subkey_path(WCHAR *path, DWORD path_len, WCHAR *subkey_name, DWORD return subkey_path; }
-static WCHAR *get_long_key(HKEY root, WCHAR *path) +WCHAR *get_long_key(HKEY root, WCHAR *path) { DWORD i, array_size = ARRAY_SIZE(root_rels), len; WCHAR *long_key; @@ -229,7 +229,7 @@ static WCHAR *get_long_key(HKEY root, WCHAR *path) return long_key; }
-BOOL parse_registry_key(const WCHAR *key, HKEY *root, WCHAR **path, WCHAR **long_key) +BOOL parse_registry_key(const WCHAR *key, HKEY *root, WCHAR **path) { if (!sane_path(key)) return FALSE; @@ -245,8 +245,6 @@ BOOL parse_registry_key(const WCHAR *key, HKEY *root, WCHAR **path, WCHAR **long return FALSE; }
- *long_key = get_long_key(*root, *path); - return TRUE; }
diff --git a/programs/reg/reg.h b/programs/reg/reg.h index c281770bdb4..c71ae2445e9 100644 --- a/programs/reg/reg.h +++ b/programs/reg/reg.h @@ -39,7 +39,8 @@ void WINAPIV output_string(const WCHAR *fmt, ...); BOOL ask_confirm(unsigned int msgid, WCHAR *reg_info); HKEY path_get_rootkey(const WCHAR *path); WCHAR *build_subkey_path(WCHAR *path, DWORD path_len, WCHAR *subkey_name, DWORD subkey_len); -BOOL parse_registry_key(const WCHAR *key, HKEY *root, WCHAR **path, WCHAR **long_key); +WCHAR *get_long_key(HKEY root, WCHAR *path); +BOOL parse_registry_key(const WCHAR *key, HKEY *root, WCHAR **path); BOOL is_char(const WCHAR s, const WCHAR c); BOOL is_switch(const WCHAR *s, const WCHAR c);
Signed-off-by: Hugh McMaster hugh.mcmaster@outlook.com --- programs/reg/reg.c | 7 +++++-- programs/reg/reg.h | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/programs/reg/reg.c b/programs/reg/reg.c index 3ffc5fe3d8f..a31ce2be743 100644 --- a/programs/reg/reg.c +++ b/programs/reg/reg.c @@ -174,7 +174,7 @@ HKEY path_get_rootkey(const WCHAR *path) return NULL; }
-static BOOL sane_path(const WCHAR *key) +static BOOL sane_path(WCHAR *key) { unsigned int i = lstrlenW(key);
@@ -190,6 +190,9 @@ static BOOL sane_path(const WCHAR *key) return FALSE; }
+ if (key[i - 1] == '\') + key[i - 1] = 0; + return TRUE; }
@@ -229,7 +232,7 @@ WCHAR *get_long_key(HKEY root, WCHAR *path) return long_key; }
-BOOL parse_registry_key(const WCHAR *key, HKEY *root, WCHAR **path) +BOOL parse_registry_key(WCHAR *key, HKEY *root, WCHAR **path) { if (!sane_path(key)) return FALSE; diff --git a/programs/reg/reg.h b/programs/reg/reg.h index c71ae2445e9..20196cf4a72 100644 --- a/programs/reg/reg.h +++ b/programs/reg/reg.h @@ -40,7 +40,7 @@ BOOL ask_confirm(unsigned int msgid, WCHAR *reg_info); HKEY path_get_rootkey(const WCHAR *path); WCHAR *build_subkey_path(WCHAR *path, DWORD path_len, WCHAR *subkey_name, DWORD subkey_len); WCHAR *get_long_key(HKEY root, WCHAR *path); -BOOL parse_registry_key(const WCHAR *key, HKEY *root, WCHAR **path); +BOOL parse_registry_key(WCHAR *key, HKEY *root, WCHAR **path); BOOL is_char(const WCHAR s, const WCHAR c); BOOL is_switch(const WCHAR *s, const WCHAR c);
Signed-off-by: Hugh McMaster hugh.mcmaster@outlook.com --- programs/reg/add.c | 3 ++- programs/reg/delete.c | 3 ++- programs/reg/query.c | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/programs/reg/add.c b/programs/reg/add.c index d94789ad484..4b50a13b975 100644 --- a/programs/reg/add.c +++ b/programs/reg/add.c @@ -273,6 +273,7 @@ int reg_add(int argc, WCHAR *argvW[]) return run_add(root, path, value_name, value_empty, type, separator, data, force);
invalid: - output_message(STRING_INVALID_CMDLINE); + output_message(STRING_INVALID_SYNTAX); + output_message(STRING_FUNC_HELP, wcsupr(argvW[1])); return 1; } diff --git a/programs/reg/delete.c b/programs/reg/delete.c index 626fcf3b341..ac3c1108d70 100644 --- a/programs/reg/delete.c +++ b/programs/reg/delete.c @@ -163,6 +163,7 @@ int reg_delete(int argc, WCHAR *argvW[]) return run_delete(root, path, key_name, value_name, value_empty, value_all, force);
invalid: - output_message(STRING_INVALID_CMDLINE); + output_message(STRING_INVALID_SYNTAX); + output_message(STRING_FUNC_HELP, wcsupr(argvW[1])); return 1; } diff --git a/programs/reg/query.c b/programs/reg/query.c index 76f12b4a2d3..d2a7968fa0b 100644 --- a/programs/reg/query.c +++ b/programs/reg/query.c @@ -373,6 +373,7 @@ int reg_query(int argc, WCHAR *argvW[]) return run_query(root, path, key_name, value_name, value_empty, recurse);
invalid: - output_message(STRING_INVALID_CMDLINE); + output_message(STRING_INVALID_SYNTAX); + output_message(STRING_FUNC_HELP, wcsupr(argvW[1])); return 1; }
No further action is taken at this time.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=44755 Signed-off-by: Hugh McMaster hugh.mcmaster@outlook.com --- Please let me know if we should limit the display of this output to versions defined as Windows 8 and 10, as the switches aren't available on older versions of Windows.
programs/reg/add.c | 2 ++ programs/reg/delete.c | 2 ++ programs/reg/export.c | 2 ++ programs/reg/import.c | 21 +++++++++++++++++---- programs/reg/query.c | 2 ++ programs/reg/reg.c | 1 + programs/reg/reg.rc | 4 ++++ programs/reg/resource.h | 1 + 8 files changed, 31 insertions(+), 4 deletions(-)
diff --git a/programs/reg/add.c b/programs/reg/add.c index 4b50a13b975..de22874b901 100644 --- a/programs/reg/add.c +++ b/programs/reg/add.c @@ -235,6 +235,8 @@ int reg_add(int argc, WCHAR *argvW[]) value_empty = TRUE; continue; } + else if (!lstrcmpiW(str, L"reg:32") || !lstrcmpiW(str, L"reg:64")) + continue; else if (!str[0] || str[1]) goto invalid;
diff --git a/programs/reg/delete.c b/programs/reg/delete.c index ac3c1108d70..d6fb81d1cc4 100644 --- a/programs/reg/delete.c +++ b/programs/reg/delete.c @@ -137,6 +137,8 @@ int reg_delete(int argc, WCHAR *argvW[]) value_empty = TRUE; continue; } + else if (!lstrcmpiW(str, L"reg:32") || !lstrcmpiW(str, L"reg:64")) + continue; else if (!str[0] || str[1]) goto invalid;
diff --git a/programs/reg/export.c b/programs/reg/export.c index 13d5871d57e..1e484c536fb 100644 --- a/programs/reg/export.c +++ b/programs/reg/export.c @@ -368,6 +368,8 @@ int reg_export(int argc, WCHAR *argvW[])
if (is_char(*str, 'y') && !str[1]) overwrite_file = TRUE; + else if (!lstrcmpiW(str, L"reg:32") || !lstrcmpiW(str, L"reg:64")) + continue; else goto invalid; } diff --git a/programs/reg/import.c b/programs/reg/import.c index 223e7db0e48..b29deba58e5 100644 --- a/programs/reg/import.c +++ b/programs/reg/import.c @@ -978,11 +978,19 @@ int reg_import(int argc, WCHAR *argvW[]) BYTE s[2]; struct parser parser;
- if (argc > 3) + if (argc > 4) goto invalid; + + if (argc == 4) { - output_message(STRING_INVALID_SYNTAX); - output_message(STRING_FUNC_HELP, wcsupr(argvW[1])); - return 1; + WCHAR *str; + + if (argvW[3][0] != '/' && argvW[3][0] != '-') + goto invalid; + + str = &argvW[3][1]; + + if (lstrcmpiW(str, L"reg:32") && lstrcmpiW(str, L"reg:64")) + goto invalid; }
filename = argvW[2]; @@ -1032,4 +1040,9 @@ int reg_import(int argc, WCHAR *argvW[]) error: fclose(fp); return 1; + +invalid: + output_message(STRING_INVALID_SYNTAX); + output_message(STRING_FUNC_HELP, wcsupr(argvW[1])); + return 1; } diff --git a/programs/reg/query.c b/programs/reg/query.c index d2a7968fa0b..9d840c8947d 100644 --- a/programs/reg/query.c +++ b/programs/reg/query.c @@ -347,6 +347,8 @@ int reg_query(int argc, WCHAR *argvW[]) value_empty = TRUE; continue; } + else if (!lstrcmpiW(str, L"reg:32") || !lstrcmpiW(str, L"reg:64")) + continue; else if (!str[0] || str[1]) goto invalid;
diff --git a/programs/reg/reg.c b/programs/reg/reg.c index a31ce2be743..fa5c4bcd33c 100644 --- a/programs/reg/reg.c +++ b/programs/reg/reg.c @@ -341,6 +341,7 @@ int __cdecl wmain(int argc, WCHAR *argvW[]) if (is_help_switch(argvW[2])) { output_message(op_help); + output_message(STRING_REG_VIEW_USAGE); return 0; }
diff --git a/programs/reg/reg.rc b/programs/reg/reg.rc index abfed18b93b..85e3675464c 100644 --- a/programs/reg/reg.rc +++ b/programs/reg/reg.rc @@ -172,4 +172,8 @@ STRINGTABLE STRING_OVERWRITE_FILE, "The file '%1' already exists. Do you want to overwrite it?" STRING_KEY_NONEXIST, "reg: Unable to find the specified registry key\n" STRING_KEY_IMPORT_FAILED, "reg: Unable to import the registry key '%1'\n" + STRING_REG_VIEW_USAGE, " /reg:32\n\ +\ Access the registry using the 32-bit view.\n\n\ +\ /reg:64\n\ +\ Access the registry using the 64-bit view.\n\n" } diff --git a/programs/reg/resource.h b/programs/reg/resource.h index 8b0d9de7653..b673e21883a 100644 --- a/programs/reg/resource.h +++ b/programs/reg/resource.h @@ -61,3 +61,4 @@ #define STRING_OVERWRITE_FILE 138 #define STRING_KEY_NONEXIST 139 #define STRING_KEY_IMPORT_FAILED 140 +#define STRING_REG_VIEW_USAGE 141
Hugh McMaster hugh.mcmaster@outlook.com writes:
Signed-off-by: Hugh McMaster hugh.mcmaster@outlook.com
programs/reg/reg.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/programs/reg/reg.h b/programs/reg/reg.h index c7719a6e4f0..c281770bdb4 100644 --- a/programs/reg/reg.h +++ b/programs/reg/reg.h @@ -27,7 +27,7 @@
/* reg.c */ struct reg_type_rels {
- DWORD type;
- const DWORD type; const WCHAR *name;
};
Declaring structure members as const is in general not useful, and potentially makes the struct harder to use.