https://git.reactos.org/?p=reactos.git;a=commitdiff;h=be726bd76999c74498c1a…
commit be726bd76999c74498c1a09dcd404285e6d5a798
Author: winesync <ros-dev(a)reactos.org>
AuthorDate: Mon Jan 17 18:47:39 2022 +0100
Commit: Thomas Csovcsity <thc.fr13nd(a)gmail.com>
CommitDate: Sun Jun 19 13:06:39 2022 +0200
[WINESYNC] reg/tests: Test use of registry views when copying registry data.
Signed-off-by: Hugh McMaster <hugh.mcmaster(a)outlook.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
wine commit id d92f26ed1264ec80f97c0a45a59b986f0b9cae38 by Hugh McMaster
<hugh.mcmaster(a)outlook.com>
---
modules/rostests/winetests/reg/copy.c | 172 ++++++++++++++++++++++++++++++
modules/rostests/winetests/reg/export.c | 18 ++--
modules/rostests/winetests/reg/reg_test.h | 1 +
sdk/tools/winesync/reg.cfg | 2 +-
4 files changed, 183 insertions(+), 10 deletions(-)
diff --git a/modules/rostests/winetests/reg/copy.c
b/modules/rostests/winetests/reg/copy.c
index e9542a67f5e..0f9e1221200 100644
--- a/modules/rostests/winetests/reg/copy.c
+++ b/modules/rostests/winetests/reg/copy.c
@@ -588,6 +588,166 @@ static void test_copy_overwrite(void)
delete_key(HKEY_CURRENT_USER, KEY_BASE, 0);
}
+static void create_test_key(REGSAM sam)
+{
+ HKEY hkey, subkey;
+ DWORD dword = 0x100;
+
+ add_key(HKEY_LOCAL_MACHINE, COPY_SRC, sam, &hkey);
+ add_value(hkey, "DWORD", REG_DWORD, &dword, sizeof(dword));
+ add_value(hkey, "String", REG_SZ, "Your text here...", 18);
+
+ add_key(hkey, "Subkey1", sam, &subkey);
+ add_value(subkey, "Binary", REG_BINARY, "\x11\x22\x33\x44", 4);
+ add_value(subkey, "Undefined hex", 0x100, "%PATH%", 7);
+ close_key(subkey);
+
+ close_key(hkey);
+}
+
+static void test_registry_view_win32(void)
+{
+ DWORD r;
+ BOOL is_wow64, is_win32;
+
+ IsWow64Process(GetCurrentProcess(), &is_wow64);
+ is_win32 = !is_wow64 && (sizeof(void *) == sizeof(int));
+
+ if (!is_win32) return;
+
+ delete_tree(HKEY_LOCAL_MACHINE, COPY_SRC, KEY_WOW64_32KEY);
+ delete_tree(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_32KEY);
+
+ /* Try copying registry data in the 32-bit registry view (32-bit Windows) */
+ create_test_key(KEY_WOW64_32KEY);
+
+ run_reg_exe("reg copy HKLM\\" COPY_SRC " HKLM\\" KEY_BASE "
/s /f /reg:32", &r);
+ ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
+
+ run_reg_exe("reg export HKLM\\" KEY_BASE " file.reg /y /reg:32",
&r);
+ ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
+ ok(compare_export("file.reg", registry_view_test, 0),
"compare_export() failed\n");
+
+ delete_tree(HKEY_LOCAL_MACHINE, COPY_SRC, KEY_WOW64_32KEY);
+ delete_tree(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_32KEY);
+
+ /* Try copying registry data in the 64-bit registry view, which doesn't exist on
32-bit Windows */
+ create_test_key(KEY_WOW64_64KEY);
+
+ run_reg_exe("reg copy HKLM\\" COPY_SRC " HKLM\\" KEY_BASE "
/s /f /reg:64", &r);
+ ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
+
+ run_reg_exe("reg export HKLM\\" KEY_BASE " file.reg /y /reg:64",
&r);
+ ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
+ ok(compare_export("file.reg", registry_view_test, 0),
"compare_export() failed\n");
+
+ delete_tree(HKEY_LOCAL_MACHINE, COPY_SRC, KEY_WOW64_64KEY);
+ delete_tree(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_64KEY);
+}
+
+static void test_registry_view_win64(void)
+{
+ DWORD r;
+ BOOL is_wow64, is_win64;
+
+ IsWow64Process(GetCurrentProcess(), &is_wow64);
+ is_win64 = !is_wow64 && (sizeof(void *) > sizeof(int));
+
+ if (!is_win64) return;
+
+ delete_tree(HKEY_LOCAL_MACHINE, COPY_SRC, KEY_WOW64_32KEY);
+ delete_tree(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_32KEY);
+ delete_tree(HKEY_LOCAL_MACHINE, COPY_SRC, KEY_WOW64_64KEY);
+ delete_tree(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_64KEY);
+
+ /* Try copying registry data in the 32-bit registry view (64-bit Windows) */
+ create_test_key(KEY_WOW64_32KEY);
+ verify_key_nonexist(HKEY_LOCAL_MACHINE, COPY_SRC, KEY_WOW64_64KEY);
+ verify_key_nonexist(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_64KEY);
+
+ run_reg_exe("reg copy HKLM\\" COPY_SRC " HKLM\\" KEY_BASE "
/s /f /reg:32", &r);
+ todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
+
+ run_reg_exe("reg export HKLM\\" KEY_BASE " file.reg /y /reg:32",
&r);
+ todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
+ todo_wine ok(compare_export("file.reg", registry_view_test, 0),
"compare_export() failed\n");
+
+ run_reg_exe("reg copy HKLM\\" COPY_SRC " HKLM\\" KEY_BASE "
/s /f /reg:64", &r);
+ ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
+
+ delete_tree(HKEY_LOCAL_MACHINE, COPY_SRC, KEY_WOW64_32KEY);
+ delete_tree(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_32KEY);
+
+ /* Try copying registry data in the 64-bit registry view (64-bit Windows) */
+ create_test_key(KEY_WOW64_64KEY);
+ verify_key_nonexist(HKEY_LOCAL_MACHINE, COPY_SRC, KEY_WOW64_32KEY);
+ verify_key_nonexist(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_32KEY);
+
+ run_reg_exe("reg copy HKLM\\" COPY_SRC " HKLM\\" KEY_BASE "
/s /f /reg:64", &r);
+ ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
+
+ run_reg_exe("reg export HKLM\\" KEY_BASE " file.reg /y /reg:64",
&r);
+ ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
+ ok(compare_export("file.reg", registry_view_test, 0),
"compare_export() failed\n");
+
+ run_reg_exe("reg copy HKLM\\" COPY_SRC " HKLM\\" KEY_BASE "
/s /f /reg:32", &r);
+ todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
+
+ delete_tree(HKEY_LOCAL_MACHINE, COPY_SRC, KEY_WOW64_64KEY);
+ delete_tree(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_64KEY);
+}
+
+static void test_registry_view_wow64(void)
+{
+ DWORD r;
+ BOOL is_wow64;
+
+ IsWow64Process(GetCurrentProcess(), &is_wow64);
+
+ if (!is_wow64) return;
+
+ delete_tree(HKEY_LOCAL_MACHINE, COPY_SRC, KEY_WOW64_32KEY);
+ delete_tree(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_32KEY);
+ delete_tree(HKEY_LOCAL_MACHINE, COPY_SRC, KEY_WOW64_64KEY);
+ delete_tree(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_64KEY);
+
+ /* Try copying registry data in the 32-bit registry view (WOW64) */
+ create_test_key(KEY_WOW64_32KEY);
+ verify_key_nonexist(HKEY_LOCAL_MACHINE, COPY_SRC, KEY_WOW64_64KEY);
+ verify_key_nonexist(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_64KEY);
+
+ run_reg_exe("reg copy HKLM\\" COPY_SRC " HKLM\\" KEY_BASE "
/s /f /reg:32", &r);
+ ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
+
+ run_reg_exe("reg export HKLM\\" KEY_BASE " file.reg /y /reg:32",
&r);
+ ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
+ ok(compare_export("file.reg", registry_view_test, 0),
"compare_export() failed\n");
+
+ run_reg_exe("reg copy HKLM\\" COPY_SRC " HKLM\\" KEY_BASE "
/s /f /reg:64", &r);
+ todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
+
+ delete_tree(HKEY_LOCAL_MACHINE, COPY_SRC, KEY_WOW64_32KEY);
+ delete_tree(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_32KEY);
+
+ /* Try copying registry data in the 64-bit registry view (WOW64) */
+ create_test_key(KEY_WOW64_64KEY);
+ verify_key_nonexist(HKEY_LOCAL_MACHINE, COPY_SRC, KEY_WOW64_32KEY);
+ verify_key_nonexist(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_32KEY);
+
+ run_reg_exe("reg copy HKLM\\" COPY_SRC " HKLM\\" KEY_BASE "
/s /f /reg:64", &r);
+ todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
+
+ run_reg_exe("reg export HKLM\\" KEY_BASE " file.reg /y /reg:64",
&r);
+ todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
+ todo_wine ok(compare_export("file.reg", registry_view_test, 0),
"compare_export() failed\n");
+
+ run_reg_exe("reg copy HKLM\\" COPY_SRC " HKLM\\" KEY_BASE "
/s /f /reg:32", &r);
+ ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
+
+ delete_tree(HKEY_LOCAL_MACHINE, COPY_SRC, KEY_WOW64_64KEY);
+ delete_tree(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_64KEY);
+}
+
START_TEST(copy)
{
DWORD r;
@@ -609,4 +769,16 @@ START_TEST(copy)
test_copy_escaped_null_values();
test_copy_key_class();
test_copy_overwrite();
+
+ /* Check if reg.exe is running with elevated privileges */
+ if (!is_elevated_process())
+ {
+ win_skip("reg.exe is not running with elevated privileges; "
+ "skipping registry view tests\n");
+ return;
+ }
+
+ test_registry_view_win32();
+ test_registry_view_win64();
+ test_registry_view_wow64();
}
diff --git a/modules/rostests/winetests/reg/export.c
b/modules/rostests/winetests/reg/export.c
index 7d352519690..3061783ca06 100644
--- a/modules/rostests/winetests/reg/export.c
+++ b/modules/rostests/winetests/reg/export.c
@@ -165,6 +165,15 @@ const char *escaped_null_test =
"\"Wine5e\"=\"Value3\\\\0Value4\"\r\n"
"\"Wine5f\"=\"\\\\0Value5\"\r\n\r\n";
+const char *registry_view_test =
+ "\xef\xbb\xbfWindows Registry Editor Version 5.00\r\n\r\n"
+ "[HKEY_LOCAL_MACHINE\\" KEY_BASE "]\r\n"
+ "\"DWORD\"=dword:00000100\r\n"
+ "\"String\"=\"Your text here...\"\r\n\r\n"
+ "[HKEY_LOCAL_MACHINE\\" KEY_BASE "\\Subkey1]\r\n"
+ "\"Binary\"=hex:11,22,33,44\r\n"
+ "\"Undefined hex\"=hex(100):25,50,41,54,48,25,00\r\n\r\n";
+
/* Unit tests */
@@ -463,15 +472,6 @@ static void create_test_key(REGSAM sam)
close_key(hkey);
}
-static const char *registry_view_test =
- "\xef\xbb\xbfWindows Registry Editor Version 5.00\r\n\r\n"
- "[HKEY_LOCAL_MACHINE\\" KEY_BASE "]\r\n"
- "\"DWORD\"=dword:00000100\r\n"
- "\"String\"=\"Your text here...\"\r\n\r\n"
- "[HKEY_LOCAL_MACHINE\\" KEY_BASE "\\Subkey1]\r\n"
- "\"Binary\"=hex:11,22,33,44\r\n"
- "\"Undefined hex\"=hex(100):25,50,41,54,48,25,00\r\n\r\n";
-
static void test_registry_view_win32(void)
{
DWORD r;
diff --git a/modules/rostests/winetests/reg/reg_test.h
b/modules/rostests/winetests/reg/reg_test.h
index 45d480cda49..8fd7704751a 100644
--- a/modules/rostests/winetests/reg/reg_test.h
+++ b/modules/rostests/winetests/reg/reg_test.h
@@ -89,6 +89,7 @@ extern const char *hex_types_test;
extern const char *slashes_test;
extern const char *embedded_null_test;
extern const char *escaped_null_test;
+extern const char *registry_view_test;
/* import.c */
BOOL is_elevated_process(void);
diff --git a/sdk/tools/winesync/reg.cfg b/sdk/tools/winesync/reg.cfg
index 0369f3afbff..a3c5a089804 100644
--- a/sdk/tools/winesync/reg.cfg
+++ b/sdk/tools/winesync/reg.cfg
@@ -4,4 +4,4 @@ directories:
files:
programs/reg/resource.h: base/applications/cmdutils/reg/resource.h
tags:
- wine: fcf79426147adf0d9f1d80b0cf24d0b6abd8bf59
+ wine: d92f26ed1264ec80f97c0a45a59b986f0b9cae38