[PATCH v2 2/2] reg: Allow /reg:32 and /reg:64 switches to be passed via the command line

Hugh McMaster hugh.mcmaster at outlook.com
Thu Apr 8 07:10:54 CDT 2021


Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=44755
Signed-off-by: Hugh McMaster <hugh.mcmaster at outlook.com>
---
 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 f1b29e6f3a2..db1ed0f5337 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 8e4aa594503..78331498406 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..5750dbf0c79 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 = argvW[3];
+
+        if (*str != '/' && *str != '-')
+            goto invalid;
+
+        str++;
+
+        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 3ffc5fe3d8f..9dd491a517e 100644
--- a/programs/reg/reg.c
+++ b/programs/reg/reg.c
@@ -338,6 +338,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
-- 
2.31.0




More information about the wine-devel mailing list