https://git.reactos.org/?p=reactos.git;a=commitdiff;h=334c2e278c4b36655304a…
commit 334c2e278c4b36655304aa9d55785cb353f21387
Author: winesync <ros-dev(a)reactos.org>
AuthorDate: Mon Jan 17 18:47:36 2022 +0100
Commit: Thomas Csovcsity <thc.fr13nd(a)gmail.com>
CommitDate: Sun Jun 19 13:06:37 2022 +0200
[WINESYNC] reg/tests: Test key and value creation in 32-bit and 64-bit registry
views.
Signed-off-by: Hugh McMaster <hugh.mcmaster(a)outlook.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
wine commit id 24d0d6f524d6c51cc5d8c909bf6cd942d6ae443d by Hugh McMaster
<hugh.mcmaster(a)outlook.com>
---
modules/rostests/winetests/reg/add.c | 133 ++++++++++++++++++++++++++++++
modules/rostests/winetests/reg/import.c | 39 +++++----
modules/rostests/winetests/reg/reg_test.h | 2 +
sdk/tools/winesync/reg.cfg | 2 +-
4 files changed, 160 insertions(+), 16 deletions(-)
diff --git a/modules/rostests/winetests/reg/add.c b/modules/rostests/winetests/reg/add.c
index 384eb9012c7..264693ab349 100644
--- a/modules/rostests/winetests/reg/add.c
+++ b/modules/rostests/winetests/reg/add.c
@@ -274,6 +274,16 @@ static void test_command_syntax(void)
/* Test empty type */
run_reg_exe("reg add HKCU\\" KEY_BASE " /v emptyType /t \"\"
/d WineTest /f", &r);
ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
+
+ /* Test registry view */
+ run_reg_exe("reg add HKCU\\" KEY_BASE " /v abc /d 123 /f /reg:32
/reg:32", &r);
+ todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
+
+ run_reg_exe("reg add HKCU\\" KEY_BASE " /v abc /d 123 /f /reg:32
/reg:64", &r);
+ todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
+
+ run_reg_exe("reg add HKCU\\" KEY_BASE " /v abc /d 123 /f /reg:64
/reg:64", &r);
+ todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
}
static void test_key_formats(void)
@@ -849,6 +859,117 @@ static void test_reg_multi_sz(void)
delete_key(HKEY_CURRENT_USER, KEY_BASE, 0);
}
+static void test_registry_view_win32(void)
+{
+ HKEY hkey;
+ DWORD r;
+ BOOL is_wow64, is_win32;
+
+ IsWow64Process(GetCurrentProcess(), &is_wow64);
+ is_win32 = !is_wow64 && (sizeof(void *) == sizeof(int));
+
+ if (!is_win32) return;
+
+ /* Try adding to the 32-bit registry view (32-bit Windows) */
+ run_reg_exe("reg add HKLM\\" KEY_BASE " /v Wine32 /d Test /f
/reg:32", &r);
+ ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
+
+ open_key(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_32KEY, &hkey);
+ verify_reg(hkey, "Wine32", REG_SZ, "Test", 5, 0);
+ close_key(hkey);
+
+ open_key(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_64KEY, &hkey);
+ verify_reg(hkey, "Wine32", REG_SZ, "Test", 5, 0);
+ close_key(hkey);
+
+ delete_key(HKEY_LOCAL_MACHINE, KEY_BASE, 0);
+
+ /* Try adding to the 64-bit registry view, which doesn't exist on 32-bit Windows
*/
+ run_reg_exe("reg add HKLM\\" KEY_BASE " /v Wine64 /d Test /f
/reg:64", &r);
+ ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
+
+ open_key(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_64KEY, &hkey);
+ verify_reg(hkey, "Wine64", REG_SZ, "Test", 5, 0);
+ close_key(hkey);
+
+ open_key(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_32KEY, &hkey);
+ verify_reg(hkey, "Wine64", REG_SZ, "Test", 5, 0);
+ close_key(hkey);
+
+ delete_key(HKEY_LOCAL_MACHINE, KEY_BASE, 0);
+}
+
+static void test_registry_view_win64(void)
+{
+ HKEY hkey;
+ DWORD r;
+ BOOL is_wow64, is_win64;
+
+ IsWow64Process(GetCurrentProcess(), &is_wow64);
+ is_win64 = !is_wow64 && (sizeof(void *) > sizeof(int));
+
+ if (!is_win64) return;
+
+ /* Try adding to the 32-bit registry view (64-bit Windows) */
+ run_reg_exe("reg add HKLM\\" KEY_BASE " /v Wine32 /d Test /f
/reg:32", &r);
+ ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
+
+ todo_wine open_key(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_32KEY, &hkey);
+ todo_wine verify_reg(hkey, "Wine32", REG_SZ, "Test", 5, 0);
+ todo_wine close_key(hkey);
+ todo_wine delete_key(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_32KEY);
+
+ todo_wine verify_key_nonexist(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_64KEY);
+
+ /* Try adding to the 64-bit registry view (64-bit Windows) */
+ run_reg_exe("reg add HKLM\\" KEY_BASE " /v Wine64 /d Test /f
/reg:64", &r);
+ ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
+
+ open_key(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_64KEY, &hkey);
+ verify_reg(hkey, "Wine64", REG_SZ, "Test", 5, 0);
+ close_key(hkey);
+ delete_key(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_64KEY);
+
+ verify_key_nonexist(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_32KEY);
+}
+
+static void test_registry_view_wow64(void)
+{
+ HKEY hkey;
+ DWORD r;
+ BOOL is_wow64;
+
+ IsWow64Process(GetCurrentProcess(), &is_wow64);
+
+ if (!is_wow64) return;
+
+ /* Try adding to the 32-bit registry view (WOW64) */
+ run_reg_exe("reg add HKLM\\" KEY_BASE " /v Wine32 /d Test /f
/reg:32", &r);
+ ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
+
+ open_key(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_32KEY, &hkey);
+ verify_reg(hkey, "Wine32", REG_SZ, "Test", 5, 0);
+ close_key(hkey);
+ delete_key(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_32KEY);
+
+ verify_key_nonexist(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_64KEY);
+
+ /* Try adding to the 64-bit registry view (WOW64) */
+ run_reg_exe("reg add HKLM\\" KEY_BASE " /v Wine64 /d Test /f
/reg:64", &r);
+ ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
+
+ todo_wine open_key(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_64KEY, &hkey);
+ todo_wine verify_reg(hkey, "Wine64", REG_SZ, "Test", 5, 0);
+ todo_wine close_key(hkey);
+
+ todo_wine open_key(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_64KEY, &hkey);
+ todo_wine verify_reg(hkey, "Wine64", REG_SZ, "Test", 5, 0);
+ todo_wine close_key(hkey);
+ todo_wine delete_key(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_64KEY);
+
+ todo_wine verify_key_nonexist(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_32KEY);
+}
+
START_TEST(add)
{
DWORD r;
@@ -868,4 +989,16 @@ START_TEST(add)
test_reg_dword();
test_reg_dword_big_endian();
test_reg_multi_sz();
+
+ /* 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/import.c
b/modules/rostests/winetests/reg/import.c
index c8a6b079a6a..2d8ece8990b 100644
--- a/modules/rostests/winetests/reg/import.c
+++ b/modules/rostests/winetests/reg/import.c
@@ -18,6 +18,29 @@
#include "reg_test.h"
+BOOL is_elevated_process(void)
+{
+ LONG err;
+ HKEY hkey;
+
+ err = RegDeleteKeyA(HKEY_CLASSES_ROOT, KEY_BASE);
+
+ if (err == ERROR_ACCESS_DENIED)
+ return FALSE;
+
+ if (err == ERROR_FILE_NOT_FOUND)
+ {
+ if (RegCreateKeyExA(HKEY_CLASSES_ROOT, KEY_BASE, 0, NULL,
REG_OPTION_NON_VOLATILE,
+ KEY_READ, NULL, &hkey, NULL))
+ return FALSE;
+
+ RegCloseKey(hkey);
+ RegDeleteKeyA(HKEY_CLASSES_ROOT, KEY_BASE);
+ }
+
+ return TRUE;
+}
+
static BOOL write_file(const void *str, DWORD size)
{
HANDLE file;
@@ -3466,30 +3489,16 @@ static void test_unicode_import_with_whitespace(void)
static void test_import_win31(void)
{
- LONG err;
HKEY hkey;
DWORD r;
/* Check if reg.exe is running with elevated privileges */
- err = RegDeleteKeyA(HKEY_CLASSES_ROOT, KEY_BASE);
- if (err == ERROR_ACCESS_DENIED)
+ if (!is_elevated_process())
{
win_skip("reg.exe is not running with elevated privileges; "
"skipping Windows 3.1 import tests\n");
return;
}
- if (err == ERROR_FILE_NOT_FOUND)
- {
- if (RegCreateKeyExA(HKEY_CLASSES_ROOT, KEY_BASE, 0, NULL,
REG_OPTION_NON_VOLATILE,
- KEY_READ, NULL, &hkey, NULL))
- {
- win_skip("reg.exe is not running with elevated privileges; "
- "skipping Windows 3.1 import tests\n");
- return;
- }
- RegCloseKey(hkey);
- RegDeleteKeyA(HKEY_CLASSES_ROOT, KEY_BASE);
- }
/* Test simple value */
test_import_str("REGEDIT\r\n"
diff --git a/modules/rostests/winetests/reg/reg_test.h
b/modules/rostests/winetests/reg/reg_test.h
index db525619978..fdc747af1e9 100644
--- a/modules/rostests/winetests/reg/reg_test.h
+++ b/modules/rostests/winetests/reg/reg_test.h
@@ -90,6 +90,8 @@ extern const char *embedded_null_test;
extern const char *escaped_null_test;
/* import.c */
+BOOL is_elevated_process(void);
+
#define test_import_str(c,r) import_reg(__FILE__,__LINE__,c,FALSE,r)
#define test_import_wstr(c,r) import_reg(__FILE__,__LINE__,c,TRUE,r)
BOOL import_reg(const char *file, unsigned line, const char *contents, BOOL unicode,
DWORD *rc);
diff --git a/sdk/tools/winesync/reg.cfg b/sdk/tools/winesync/reg.cfg
index e19cdedb65b..51f62c396bf 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: 0d60749c218ae76645006e6273fc2f6a5ea87a58
+ wine: 24d0d6f524d6c51cc5d8c909bf6cd942d6ae443d