Signed-off-by: Hugh McMaster hugh.mcmaster@outlook.com --- programs/reg/tests/add.c | 17 ++++++++++------- programs/reg/tests/copy.c | 36 +++++++++++++++++------------------ programs/reg/tests/delete.c | 4 ++-- programs/reg/tests/export.c | 8 ++++---- programs/reg/tests/import.c | 12 ++++++------ programs/reg/tests/query.c | 6 +++--- programs/reg/tests/reg_test.h | 2 +- 7 files changed, 44 insertions(+), 41 deletions(-)
diff --git a/programs/reg/tests/add.c b/programs/reg/tests/add.c index 3b4a895d0c5..bb72c4a3737 100644 --- a/programs/reg/tests/add.c +++ b/programs/reg/tests/add.c @@ -154,7 +154,7 @@ void delete_key_(const char *file, unsigned line, HKEY root, const char *path, R } }
-LONG delete_tree(const HKEY key, const char *subkey) +LONG delete_tree(HKEY root, const char *path, REGSAM sam) { HKEY hkey; LONG ret; @@ -162,7 +162,7 @@ LONG delete_tree(const HKEY key, const char *subkey) DWORD max_subkey_len, subkey_len; static const char empty[1];
- ret = RegOpenKeyExA(key, subkey, 0, KEY_READ, &hkey); + ret = RegOpenKeyExA(root, path, 0, KEY_READ|sam, &hkey); if (ret) return ret;
ret = RegQueryInfoKeyA(hkey, NULL, NULL, NULL, NULL, &max_subkey_len, @@ -184,11 +184,14 @@ LONG delete_tree(const HKEY key, const char *subkey) ret = RegEnumKeyExA(hkey, 0, subkey_name, &subkey_len, NULL, NULL, NULL, NULL); if (ret == ERROR_NO_MORE_ITEMS) break; if (ret) goto cleanup; - ret = delete_tree(hkey, subkey_name); + ret = delete_tree(hkey, subkey_name, sam); if (ret) goto cleanup; }
- ret = RegDeleteKeyA(hkey, empty); + if (!sam) + ret = RegDeleteKeyA(hkey, empty); + else + ret = RegDeleteKeyExA(hkey, empty, sam, 0);
cleanup: HeapFree(GetProcessHeap(), 0, subkey_name); @@ -219,7 +222,7 @@ static void test_command_syntax(void) { DWORD r;
- delete_tree(HKEY_CURRENT_USER, KEY_BASE); + delete_tree(HKEY_CURRENT_USER, KEY_BASE, 0); verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE, 0);
run_reg_exe("reg add", &r); @@ -322,7 +325,7 @@ static void test_key_formats(void) verify_key(hkey, "https://winehq.org", 0);
close_key(hkey); - delete_tree(HKEY_CURRENT_USER, KEY_BASE); + delete_tree(HKEY_CURRENT_USER, KEY_BASE, 0);
/* Test validity of trailing backslash after system key */ run_reg_exe("reg add HKCU\ /v Value1 /t REG_SZ /d foo /f", &r); @@ -409,7 +412,7 @@ static void test_add(void) verify_reg(hkey, NULL, REG_NONE, "T\0e\0s\0t\0\0", 10, 0);
close_key(hkey); - delete_tree(HKEY_CURRENT_USER, KEY_BASE); + delete_tree(HKEY_CURRENT_USER, KEY_BASE, 0); }
static void test_reg_none(void) diff --git a/programs/reg/tests/copy.c b/programs/reg/tests/copy.c index 2b461c17f5e..c6a83e57276 100644 --- a/programs/reg/tests/copy.c +++ b/programs/reg/tests/copy.c @@ -126,10 +126,10 @@ static void test_copy_empty_key(void) { DWORD r;
- delete_tree(HKEY_CURRENT_USER, COPY_SRC); + delete_tree(HKEY_CURRENT_USER, COPY_SRC, 0); verify_key_nonexist(HKEY_CURRENT_USER, COPY_SRC, 0);
- delete_tree(HKEY_CURRENT_USER, KEY_BASE); + delete_tree(HKEY_CURRENT_USER, KEY_BASE, 0); verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE, 0);
add_key(HKEY_CURRENT_USER, COPY_SRC, 0, NULL); @@ -191,10 +191,10 @@ static void test_copy_simple_data(void) HKEY hkey; DWORD r, dword;
- delete_tree(HKEY_CURRENT_USER, COPY_SRC); + delete_tree(HKEY_CURRENT_USER, COPY_SRC, 0); verify_key_nonexist(HKEY_CURRENT_USER, COPY_SRC, 0);
- delete_tree(HKEY_CURRENT_USER, KEY_BASE); + delete_tree(HKEY_CURRENT_USER, KEY_BASE, 0); verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE, 0);
add_key(HKEY_CURRENT_USER, COPY_SRC, 0, &hkey); @@ -261,10 +261,10 @@ static void test_copy_complex_data(void) HKEY hkey, subkey; DWORD r, dword;
- delete_tree(HKEY_CURRENT_USER, COPY_SRC); + delete_tree(HKEY_CURRENT_USER, COPY_SRC, 0); verify_key_nonexist(HKEY_CURRENT_USER, COPY_SRC, 0);
- delete_tree(HKEY_CURRENT_USER, KEY_BASE); + delete_tree(HKEY_CURRENT_USER, KEY_BASE, 0); verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE, 0);
add_key(HKEY_CURRENT_USER, COPY_SRC, 0, &hkey); @@ -330,10 +330,10 @@ static void test_copy_key_order(void) HKEY hkey; DWORD r;
- delete_tree(HKEY_CURRENT_USER, COPY_SRC); + delete_tree(HKEY_CURRENT_USER, COPY_SRC, 0); verify_key_nonexist(HKEY_CURRENT_USER, COPY_SRC, 0);
- delete_tree(HKEY_CURRENT_USER, KEY_BASE); + delete_tree(HKEY_CURRENT_USER, KEY_BASE, 0); verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE, 0);
add_key(HKEY_CURRENT_USER, COPY_SRC, 0, &hkey); @@ -355,10 +355,10 @@ static void test_copy_value_order(void) HKEY hkey; DWORD r;
- delete_tree(HKEY_CURRENT_USER, COPY_SRC); + delete_tree(HKEY_CURRENT_USER, COPY_SRC, 0); verify_key_nonexist(HKEY_CURRENT_USER, COPY_SRC, 0);
- delete_tree(HKEY_CURRENT_USER, KEY_BASE); + delete_tree(HKEY_CURRENT_USER, KEY_BASE, 0); verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE, 0);
add_key(HKEY_CURRENT_USER, COPY_SRC, 0, &hkey); @@ -380,10 +380,10 @@ static void test_copy_hex_data(void) HKEY hkey; DWORD r;
- delete_tree(HKEY_CURRENT_USER, COPY_SRC); + delete_tree(HKEY_CURRENT_USER, COPY_SRC, 0); verify_key_nonexist(HKEY_CURRENT_USER, COPY_SRC, 0);
- delete_tree(HKEY_CURRENT_USER, KEY_BASE); + delete_tree(HKEY_CURRENT_USER, KEY_BASE, 0); verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE, 0);
/* Try copying empty hex values */ @@ -449,10 +449,10 @@ static void test_copy_embedded_null_values(void) { DWORD r;
- delete_tree(HKEY_CURRENT_USER, COPY_SRC); + delete_tree(HKEY_CURRENT_USER, COPY_SRC, 0); verify_key_nonexist(HKEY_CURRENT_USER, COPY_SRC, 0);
- delete_tree(HKEY_CURRENT_USER, KEY_BASE); + delete_tree(HKEY_CURRENT_USER, KEY_BASE, 0); verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE, 0);
test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n" @@ -482,10 +482,10 @@ static void test_copy_slashes(void) HKEY hkey; DWORD r;
- delete_tree(HKEY_CURRENT_USER, COPY_SRC); + delete_tree(HKEY_CURRENT_USER, COPY_SRC, 0); verify_key_nonexist(HKEY_CURRENT_USER, COPY_SRC, 0);
- delete_tree(HKEY_CURRENT_USER, KEY_BASE); + delete_tree(HKEY_CURRENT_USER, KEY_BASE, 0); verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE, 0);
add_key(HKEY_CURRENT_USER, COPY_SRC, 0, &hkey); @@ -508,10 +508,10 @@ static void test_copy_escaped_null_values(void) HKEY hkey; DWORD r;
- delete_tree(HKEY_CURRENT_USER, COPY_SRC); + delete_tree(HKEY_CURRENT_USER, COPY_SRC, 0); verify_key_nonexist(HKEY_CURRENT_USER, COPY_SRC, 0);
- delete_tree(HKEY_CURRENT_USER, KEY_BASE); + delete_tree(HKEY_CURRENT_USER, KEY_BASE, 0); verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE, 0);
add_key(HKEY_CURRENT_USER, COPY_SRC, 0, &hkey); diff --git a/programs/reg/tests/delete.c b/programs/reg/tests/delete.c index 251a15f3371..e40c0256925 100644 --- a/programs/reg/tests/delete.c +++ b/programs/reg/tests/delete.c @@ -23,7 +23,7 @@ static void test_command_syntax(void) { DWORD r;
- delete_tree(HKEY_CURRENT_USER, KEY_BASE); + delete_tree(HKEY_CURRENT_USER, KEY_BASE, 0); verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE, 0);
run_reg_exe("reg delete", &r); @@ -74,7 +74,7 @@ static void test_delete(void) DWORD r; const DWORD deadbeef = 0xdeadbeef;
- delete_tree(HKEY_CURRENT_USER, KEY_BASE); + delete_tree(HKEY_CURRENT_USER, KEY_BASE, 0); verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE, 0);
/* Create a test key */ diff --git a/programs/reg/tests/export.c b/programs/reg/tests/export.c index df44baddb30..0f48443384e 100644 --- a/programs/reg/tests/export.c +++ b/programs/reg/tests/export.c @@ -176,7 +176,7 @@ static void test_export(void) HKEY hkey, subkey; BYTE hex[4], buffer[8];
- delete_tree(HKEY_CURRENT_USER, KEY_BASE); + delete_tree(HKEY_CURRENT_USER, KEY_BASE, 0); verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE, 0);
run_reg_exe("reg export", &r); @@ -287,7 +287,7 @@ static void test_export(void) run_reg_exe("reg export HKEY_CURRENT_USER\" KEY_BASE " file.reg /y", &r); ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); ok(compare_export("file.reg", complex_data_test, 0), "compare_export() failed\n"); - delete_tree(HKEY_CURRENT_USER, KEY_BASE); + delete_tree(HKEY_CURRENT_USER, KEY_BASE, 0);
/* Test the export order of registry keys */ add_key(HKEY_CURRENT_USER, KEY_BASE, 0, &hkey); @@ -413,7 +413,7 @@ static void test_export(void) run_reg_exe("reg export HKEY_CURRENT_USER\" KEY_BASE " file.reg /y", &r); ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); ok(compare_export("file.reg", slashes_test, TODO_REG_COMPARE), "compare_export() failed\n"); - delete_tree(HKEY_CURRENT_USER, KEY_BASE); + delete_tree(HKEY_CURRENT_USER, KEY_BASE, 0);
/* Test escaped null characters */ add_key(HKEY_CURRENT_USER, KEY_BASE, 0, &hkey); @@ -428,7 +428,7 @@ static void test_export(void) run_reg_exe("reg export HKEY_CURRENT_USER\" KEY_BASE " file.reg /y", &r); ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); ok(compare_export("file.reg", escaped_null_test, 0), "compare_export() failed\n"); - delete_tree(HKEY_CURRENT_USER, KEY_BASE); + delete_tree(HKEY_CURRENT_USER, KEY_BASE, 0); }
START_TEST(export) diff --git a/programs/reg/tests/import.c b/programs/reg/tests/import.c index 2d8ece8990b..2531ba336e8 100644 --- a/programs/reg/tests/import.c +++ b/programs/reg/tests/import.c @@ -101,7 +101,7 @@ static void test_import(void) LONG err; BYTE hex[8];
- delete_tree(HKEY_CURRENT_USER, KEY_BASE); + delete_tree(HKEY_CURRENT_USER, KEY_BASE, 0); verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE, 0);
run_reg_exe("reg import", &r); @@ -1643,7 +1643,7 @@ static void test_import(void)
close_key(hkey);
- delete_tree(HKEY_CURRENT_USER, KEY_BASE); + delete_tree(HKEY_CURRENT_USER, KEY_BASE, 0); }
static void test_unicode_import(void) @@ -1654,7 +1654,7 @@ static void test_unicode_import(void) char buffer[24]; BYTE hex[8];
- delete_tree(HKEY_CURRENT_USER, KEY_BASE); + delete_tree(HKEY_CURRENT_USER, KEY_BASE, 0); verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE, 0);
test_import_wstr("REGEDIT\n", &r); @@ -3192,7 +3192,7 @@ static void test_unicode_import(void)
close_key(hkey);
- delete_tree(HKEY_CURRENT_USER, KEY_BASE); + delete_tree(HKEY_CURRENT_USER, KEY_BASE, 0); }
static void test_import_with_whitespace(void) @@ -3200,7 +3200,7 @@ static void test_import_with_whitespace(void) HKEY hkey; DWORD r, dword;
- delete_tree(HKEY_CURRENT_USER, KEY_BASE); + delete_tree(HKEY_CURRENT_USER, KEY_BASE, 0); verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE, 0);
test_import_str(" REGEDIT4\n\n" @@ -3346,7 +3346,7 @@ static void test_unicode_import_with_whitespace(void) HKEY hkey; DWORD r, dword;
- delete_tree(HKEY_CURRENT_USER, KEY_BASE); + delete_tree(HKEY_CURRENT_USER, KEY_BASE, 0); verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE, 0);
test_import_wstr("\xef\xbb\xbf Windows Registry Editor Version 5.00\n\n" diff --git a/programs/reg/tests/query.c b/programs/reg/tests/query.c index 3e8b134363b..270f0aad75d 100644 --- a/programs/reg/tests/query.c +++ b/programs/reg/tests/query.c @@ -164,7 +164,7 @@ static void test_query(void) HKEY hkey, subkey; BYTE buf[512];
- delete_tree(HKEY_CURRENT_USER, KEY_BASE); + delete_tree(HKEY_CURRENT_USER, KEY_BASE, 0); verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE, 0);
run_reg_exe("reg query", &r); @@ -270,7 +270,7 @@ static void test_query(void) ok(r == REG_EXIT_SUCCESS || r == REG_EXIT_FAILURE /* WinXP */, "got exit code %d, expected 0\n", r);
- delete_tree(HKEY_CURRENT_USER, KEY_BASE); + delete_tree(HKEY_CURRENT_USER, KEY_BASE, 0);
/* Subkeys only */ add_key(HKEY_CURRENT_USER, KEY_BASE, 0, &hkey); @@ -288,7 +288,7 @@ static void test_query(void) ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); compare_query(buf, test8b, FALSE, 0);
- delete_tree(HKEY_CURRENT_USER, KEY_BASE); + delete_tree(HKEY_CURRENT_USER, KEY_BASE, 0); }
START_TEST(query) diff --git a/programs/reg/tests/reg_test.h b/programs/reg/tests/reg_test.h index fdc747af1e9..a5d7169beb4 100644 --- a/programs/reg/tests/reg_test.h +++ b/programs/reg/tests/reg_test.h @@ -64,7 +64,7 @@ void add_key_(const char *file, unsigned line, const HKEY root, const char *path #define delete_key(r,p,s) delete_key_(__FILE__,__LINE__,r,p,s) void delete_key_(const char *file, unsigned line, HKEY root, const char *path, REGSAM sam);
-LONG delete_tree(const HKEY key, const char *subkey); +LONG delete_tree(HKEY root, const char *path, REGSAM sam);
#define add_value(k,n,t,d,s) add_value_(__FILE__,__LINE__,k,n,t,d,s) void add_value_(const char *file, unsigned line, HKEY hkey, const char *name,
Signed-off-by: Hugh McMaster hugh.mcmaster@outlook.com --- programs/reg/tests/add.c | 4 ---- 1 file changed, 4 deletions(-)
diff --git a/programs/reg/tests/add.c b/programs/reg/tests/add.c index bb72c4a3737..36fa634796d 100644 --- a/programs/reg/tests/add.c +++ b/programs/reg/tests/add.c @@ -961,10 +961,6 @@ static void test_registry_view_wow64(void) 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_64KEY, &hkey); verify_reg(hkey, "Wine64", REG_SZ, "Test", 5, 0); close_key(hkey);
Signed-off-by: Hugh McMaster hugh.mcmaster@outlook.com --- programs/reg/tests/delete.c | 275 ++++++++++++++++++++++++++++++++++++ 1 file changed, 275 insertions(+)
diff --git a/programs/reg/tests/delete.c b/programs/reg/tests/delete.c index e40c0256925..d6a3b7e1d04 100644 --- a/programs/reg/tests/delete.c +++ b/programs/reg/tests/delete.c @@ -66,6 +66,16 @@ static void test_command_syntax(void)
run_reg_exe("reg delete HKCU\" KEY_BASE " /f /v", &r); ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r); + + /* Test registry view */ + run_reg_exe("reg delete HKCU\" KEY_BASE " /f /reg:32 /reg:32", &r); + ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r); + + run_reg_exe("reg delete HKCU\" KEY_BASE " /f /reg:32 /reg:64", &r); + ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r); + + run_reg_exe("reg delete HKCU\" KEY_BASE " /f /reg:64 /reg:64", &r); + ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r); }
static void test_delete(void) @@ -141,6 +151,259 @@ static void test_delete(void) ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r); }
+static void create_test_key(REGSAM sam) +{ + HKEY hkey, subkey; + DWORD dword; + + add_key(HKEY_LOCAL_MACHINE, KEY_BASE, sam, &hkey); + + dword = 0x100; + add_value(hkey, "DWORD", REG_DWORD, &dword, sizeof(dword)); + add_value(hkey, "String", REG_SZ, "Your text here...", 18); + add_value(hkey, NULL, REG_SZ, "Default value name", 19); + add_value(hkey, "Multiple Strings", REG_MULTI_SZ, "Line1\0Line2\0Line3\0", 19); + + add_key(hkey, "Subkey", 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) +{ + 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; + + delete_tree(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_32KEY); + verify_key_nonexist(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_32KEY); + + /* Test deletion from the 32-bit registry view (32-bit Windows) */ + create_test_key(KEY_WOW64_32KEY); + + open_key(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_32KEY, &hkey); + + run_reg_exe("reg delete HKLM\" KEY_BASE " /v DWORD /f /reg:32", &r); + ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); + verify_reg_nonexist(hkey, "DWORD"); + + run_reg_exe("reg delete HKLM\" KEY_BASE " /ve /f /reg:32", &r); + ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); + verify_reg_nonexist(hkey, NULL); + + run_reg_exe("reg delete HKLM\" KEY_BASE " /va /f /reg:32", &r); + ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); + verify_reg_nonexist(hkey, "String"); + verify_reg_nonexist(hkey, "Multiple Strings"); + verify_key(hkey, "Subkey", KEY_WOW64_32KEY); + + run_reg_exe("reg delete HKLM\" KEY_BASE "\Subkey /f /reg:32", &r); + ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); + verify_key_nonexist(hkey, "Subkey", KEY_WOW64_32KEY); + + close_key(hkey); + + run_reg_exe("reg delete HKLM\" KEY_BASE " /f /reg:32", &r); + ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); + verify_key_nonexist(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_32KEY); + + /* Test deletion from the 64-bit registry view, which doesn't exist on 32-bit Windows */ + create_test_key(KEY_WOW64_64KEY); + + open_key(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_64KEY, &hkey); + + run_reg_exe("reg delete HKLM\" KEY_BASE " /v DWORD /f /reg:64", &r); + ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); + verify_reg_nonexist(hkey, "DWORD"); + + run_reg_exe("reg delete HKLM\" KEY_BASE " /ve /f /reg:64", &r); + ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); + verify_reg_nonexist(hkey, NULL); + + run_reg_exe("reg delete HKLM\" KEY_BASE " /va /f /reg:64", &r); + ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); + verify_reg_nonexist(hkey, "String"); + verify_reg_nonexist(hkey, "Multiple Strings"); + verify_key(hkey, "Subkey", KEY_WOW64_64KEY); + + run_reg_exe("reg delete HKLM\" KEY_BASE "\Subkey /f /reg:64", &r); + ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); + verify_key_nonexist(hkey, "Subkey", KEY_WOW64_64KEY); + + close_key(hkey); + + run_reg_exe("reg delete HKLM\" KEY_BASE " /f /reg:64", &r); + ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); + verify_key_nonexist(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_64KEY); +} + +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; + + delete_tree(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_32KEY); + verify_key_nonexist(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_32KEY); + + delete_tree(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_64KEY); + verify_key_nonexist(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_64KEY); + + /* Test deletion from the 32-bit registry view (64-bit Windows) */ + create_test_key(KEY_WOW64_32KEY); + + verify_key_nonexist(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_64KEY); + + open_key(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_32KEY, &hkey); + + run_reg_exe("reg delete HKLM\" KEY_BASE " /v DWORD /f /reg:32", &r); + todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); + todo_wine verify_reg_nonexist(hkey, "DWORD"); + + run_reg_exe("reg delete HKLM\" KEY_BASE " /ve /f /reg:32", &r); + todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); + todo_wine verify_reg_nonexist(hkey, NULL); + + run_reg_exe("reg delete HKLM\" KEY_BASE " /va /f /reg:32", &r); + todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); + todo_wine verify_reg_nonexist(hkey, "String"); + todo_wine verify_reg_nonexist(hkey, "Multiple Strings"); + verify_key(hkey, "Subkey", KEY_WOW64_32KEY); + + run_reg_exe("reg delete HKLM\" KEY_BASE "\Subkey /f /reg:32", &r); + todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); + todo_wine verify_key_nonexist(hkey, "Subkey", KEY_WOW64_32KEY); + + close_key(hkey); + + run_reg_exe("reg delete HKLM\" KEY_BASE " /f /reg:32", &r); + todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); + todo_wine verify_key_nonexist(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_32KEY); + + /* Test deletion from the 64-bit registry view (64-bit Windows) */ + create_test_key(KEY_WOW64_64KEY); + + todo_wine verify_key_nonexist(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_32KEY); + + open_key(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_64KEY, &hkey); + + run_reg_exe("reg delete HKLM\" KEY_BASE " /v DWORD /f /reg:64", &r); + ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); + verify_reg_nonexist(hkey, "DWORD"); + + run_reg_exe("reg delete HKLM\" KEY_BASE " /ve /f /reg:64", &r); + ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); + verify_reg_nonexist(hkey, NULL); + + run_reg_exe("reg delete HKLM\" KEY_BASE " /va /f /reg:64", &r); + ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); + verify_reg_nonexist(hkey, "String"); + verify_reg_nonexist(hkey, "Multiple Strings"); + verify_key(hkey, "Subkey", KEY_WOW64_64KEY); + + run_reg_exe("reg delete HKLM\" KEY_BASE "\Subkey /f /reg:64", &r); + ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); + verify_key_nonexist(hkey, "Subkey", KEY_WOW64_64KEY); + + close_key(hkey); + + run_reg_exe("reg delete HKLM\" KEY_BASE " /f /reg:64", &r); + ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); + verify_key_nonexist(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_64KEY); +} + +static void test_registry_view_wow64(void) +{ + HKEY hkey; + DWORD r; + BOOL is_wow64; + + IsWow64Process(GetCurrentProcess(), &is_wow64); + + if (!is_wow64) return; + + delete_tree(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_32KEY); + verify_key_nonexist(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_32KEY); + + delete_tree(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_64KEY); + verify_key_nonexist(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_64KEY); + + /* Test deletion from the 32-bit registry view (WOW64) */ + create_test_key(KEY_WOW64_32KEY); + + verify_key_nonexist(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_64KEY); + + open_key(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_32KEY, &hkey); + + run_reg_exe("reg delete HKLM\" KEY_BASE " /v DWORD /f /reg:32", &r); + ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); + verify_reg_nonexist(hkey, "DWORD"); + + run_reg_exe("reg delete HKLM\" KEY_BASE " /ve /f /reg:32", &r); + ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); + verify_reg_nonexist(hkey, NULL); + + run_reg_exe("reg delete HKLM\" KEY_BASE " /va /f /reg:32", &r); + ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); + verify_reg_nonexist(hkey, "String"); + verify_reg_nonexist(hkey, "Multiple Strings"); + verify_key(hkey, "Subkey", KEY_WOW64_32KEY); + + run_reg_exe("reg delete HKLM\" KEY_BASE "\Subkey /f /reg:32", &r); + ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); + verify_key_nonexist(hkey, "Subkey", KEY_WOW64_32KEY); + + close_key(hkey); + + run_reg_exe("reg delete HKLM\" KEY_BASE " /f /reg:32", &r); + ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); + verify_key_nonexist(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_32KEY); + + /* Test deletion from the 64-bit registry view (WOW64) */ + create_test_key(KEY_WOW64_64KEY); + + verify_key_nonexist(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_32KEY); + + open_key(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_64KEY, &hkey); + + run_reg_exe("reg delete HKLM\" KEY_BASE " /v DWORD /f /reg:64", &r); + todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); + todo_wine verify_reg_nonexist(hkey, "DWORD"); + + run_reg_exe("reg delete HKLM\" KEY_BASE " /ve /f /reg:64", &r); + todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); + todo_wine verify_reg_nonexist(hkey, NULL); + + run_reg_exe("reg delete HKLM\" KEY_BASE " /va /f /reg:64", &r); + todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); + todo_wine verify_reg_nonexist(hkey, "String"); + todo_wine verify_reg_nonexist(hkey, "Multiple Strings"); + verify_key(hkey, "Subkey", KEY_WOW64_64KEY); + + run_reg_exe("reg delete HKLM\" KEY_BASE "\Subkey /f /reg:64", &r); + todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); + todo_wine verify_key_nonexist(hkey, "Subkey", KEY_WOW64_64KEY); + + close_key(hkey); + + run_reg_exe("reg delete HKLM\" KEY_BASE " /f /reg:64", &r); + todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); + todo_wine verify_key_nonexist(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_64KEY); +} + START_TEST(delete) { DWORD r; @@ -152,4 +415,16 @@ START_TEST(delete)
test_command_syntax(); test_delete(); + + /* 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(); }