2021-03-01 03:16:45 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2014 Akihiro Sagawa
|
|
|
|
* Copyright 2016-2018, 2021 Hugh McMaster
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "reg_test.h"
|
|
|
|
|
2021-06-18 12:31:58 +00:00
|
|
|
static void test_command_syntax(void)
|
2021-03-01 03:16:45 +00:00
|
|
|
{
|
|
|
|
DWORD r;
|
|
|
|
|
2021-06-25 12:58:10 +00:00
|
|
|
delete_tree(HKEY_CURRENT_USER, KEY_BASE, 0);
|
2021-03-01 03:16:45 +00:00
|
|
|
|
|
|
|
run_reg_exe("reg delete", &r);
|
2022-02-03 11:04:28 +00:00
|
|
|
ok(r == REG_EXIT_FAILURE, "got exit code %ld, expected 1\n", r);
|
2021-03-01 03:16:45 +00:00
|
|
|
|
|
|
|
run_reg_exe("reg delete /?", &r);
|
2022-02-03 11:04:28 +00:00
|
|
|
ok(r == REG_EXIT_SUCCESS, "got exit code %ld, expected 0\n", r);
|
2021-03-01 03:16:45 +00:00
|
|
|
|
|
|
|
run_reg_exe("reg delete /h", &r);
|
2022-02-03 11:04:28 +00:00
|
|
|
ok(r == REG_EXIT_SUCCESS, "got exit code %ld, expected 0\n", r);
|
2021-03-01 03:16:45 +00:00
|
|
|
|
|
|
|
run_reg_exe("reg delete -H", &r);
|
2022-02-03 11:04:28 +00:00
|
|
|
ok(r == REG_EXIT_SUCCESS, "got exit code %ld, expected 0\n", r);
|
2021-03-01 03:16:45 +00:00
|
|
|
|
|
|
|
/* Multiple /v* switches */
|
|
|
|
run_reg_exe("reg delete HKCU\\" KEY_BASE " /v Wine /ve", &r);
|
2022-02-03 11:04:28 +00:00
|
|
|
ok(r == REG_EXIT_FAILURE, "got exit code %ld, expected 1\n", r);
|
2021-03-01 03:16:45 +00:00
|
|
|
|
|
|
|
run_reg_exe("reg delete HKCU\\" KEY_BASE " /v Wine /va", &r);
|
2022-02-03 11:04:28 +00:00
|
|
|
ok(r == REG_EXIT_FAILURE, "got exit code %ld, expected 1\n", r);
|
2021-03-01 03:16:45 +00:00
|
|
|
|
2021-03-24 08:08:59 +00:00
|
|
|
run_reg_exe("reg delete HKCU\\" KEY_BASE " /ve /ve", &r);
|
2022-02-03 11:04:28 +00:00
|
|
|
ok(r == REG_EXIT_FAILURE, "got exit code %ld, expected 1\n", r);
|
2021-03-24 08:08:59 +00:00
|
|
|
|
2021-03-01 03:16:45 +00:00
|
|
|
run_reg_exe("reg delete HKCU\\" KEY_BASE " /ve /va", &r);
|
2022-02-03 11:04:28 +00:00
|
|
|
ok(r == REG_EXIT_FAILURE, "got exit code %ld, expected 1\n", r);
|
2021-03-01 03:16:45 +00:00
|
|
|
|
2021-03-24 08:08:59 +00:00
|
|
|
run_reg_exe("reg delete HKCU\\" KEY_BASE " /va /va", &r);
|
2022-02-03 11:04:28 +00:00
|
|
|
ok(r == REG_EXIT_FAILURE, "got exit code %ld, expected 1\n", r);
|
2021-03-24 08:08:59 +00:00
|
|
|
|
|
|
|
run_reg_exe("reg delete HKCU\\" KEY_BASE " /v Test /ve /va", &r);
|
2022-02-03 11:04:28 +00:00
|
|
|
ok(r == REG_EXIT_FAILURE, "got exit code %ld, expected 1\n", r);
|
2021-03-24 08:08:59 +00:00
|
|
|
|
2021-03-01 03:16:45 +00:00
|
|
|
run_reg_exe("reg delete HKCU\\" KEY_BASE " /v Wine /v Test /f", &r);
|
2022-02-03 11:04:28 +00:00
|
|
|
ok(r == REG_EXIT_FAILURE, "got exit code %ld, expected 1\n", r);
|
2021-03-01 03:16:45 +00:00
|
|
|
|
|
|
|
/* No /v argument */
|
|
|
|
run_reg_exe("reg delete HKCU\\" KEY_BASE " /v", &r);
|
2022-02-03 11:04:28 +00:00
|
|
|
ok(r == REG_EXIT_FAILURE, "got exit code %ld, expected 1\n", r);
|
2021-03-01 03:16:45 +00:00
|
|
|
|
|
|
|
run_reg_exe("reg delete HKCU\\" KEY_BASE " /f /v", &r);
|
2022-02-03 11:04:28 +00:00
|
|
|
ok(r == REG_EXIT_FAILURE, "got exit code %ld, expected 1\n", r);
|
2021-06-25 12:58:12 +00:00
|
|
|
|
|
|
|
/* Test registry view */
|
|
|
|
run_reg_exe("reg delete HKCU\\" KEY_BASE " /f /reg:32 /reg:32", &r);
|
2022-02-03 11:04:28 +00:00
|
|
|
ok(r == REG_EXIT_FAILURE, "got exit code %ld, expected 1\n", r);
|
2021-06-25 12:58:12 +00:00
|
|
|
|
|
|
|
run_reg_exe("reg delete HKCU\\" KEY_BASE " /f /reg:32 /reg:64", &r);
|
2022-02-03 11:04:28 +00:00
|
|
|
ok(r == REG_EXIT_FAILURE, "got exit code %ld, expected 1\n", r);
|
2021-06-25 12:58:12 +00:00
|
|
|
|
|
|
|
run_reg_exe("reg delete HKCU\\" KEY_BASE " /f /reg:64 /reg:64", &r);
|
2022-02-03 11:04:28 +00:00
|
|
|
ok(r == REG_EXIT_FAILURE, "got exit code %ld, expected 1\n", r);
|
2021-06-18 12:31:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void test_delete(void)
|
|
|
|
{
|
|
|
|
HKEY hkey;
|
|
|
|
DWORD r;
|
|
|
|
const DWORD deadbeef = 0xdeadbeef;
|
|
|
|
|
2021-06-25 12:58:10 +00:00
|
|
|
delete_tree(HKEY_CURRENT_USER, KEY_BASE, 0);
|
2021-03-01 03:16:45 +00:00
|
|
|
|
|
|
|
/* Create a test key */
|
2021-06-16 12:43:10 +00:00
|
|
|
add_key(HKEY_CURRENT_USER, KEY_BASE, 0, &hkey);
|
2021-03-01 03:16:45 +00:00
|
|
|
add_value(hkey, "foo", REG_DWORD, &deadbeef, sizeof(deadbeef));
|
|
|
|
add_value(hkey, "bar", REG_DWORD, &deadbeef, sizeof(deadbeef));
|
|
|
|
add_value(hkey, NULL, REG_DWORD, &deadbeef, sizeof(deadbeef));
|
|
|
|
|
2021-06-16 12:43:10 +00:00
|
|
|
add_key(hkey, "subkey", 0, NULL);
|
2021-03-01 03:16:45 +00:00
|
|
|
|
|
|
|
run_reg_exe("reg delete HKCU\\" KEY_BASE " /v bar /f", &r);
|
2022-02-03 11:04:28 +00:00
|
|
|
ok(r == REG_EXIT_SUCCESS, "got exit code %ld, expected 0\n", r);
|
2021-03-01 03:16:45 +00:00
|
|
|
verify_reg_nonexist(hkey, "bar");
|
|
|
|
|
|
|
|
run_reg_exe("reg delete HKCU\\" KEY_BASE " /ve /f", &r);
|
2022-02-03 11:04:28 +00:00
|
|
|
ok(r == REG_EXIT_SUCCESS, "got exit code %ld, expected 0\n", r);
|
2021-03-01 03:16:45 +00:00
|
|
|
verify_reg_nonexist(hkey, "");
|
|
|
|
|
|
|
|
run_reg_exe("reg delete HKCU\\" KEY_BASE " /va /f", &r);
|
2022-02-03 11:04:28 +00:00
|
|
|
ok(r == REG_EXIT_SUCCESS, "got exit code %ld, expected 0\n", r);
|
2021-03-01 03:16:45 +00:00
|
|
|
verify_reg_nonexist(hkey, "foo");
|
2021-06-16 12:43:07 +00:00
|
|
|
verify_key(hkey, "subkey", 0);
|
2021-03-01 03:16:45 +00:00
|
|
|
|
|
|
|
/* Test forward and back slashes */
|
2021-06-16 12:43:10 +00:00
|
|
|
add_key(hkey, "https://winehq.org", 0, NULL);
|
2021-03-01 03:16:45 +00:00
|
|
|
add_value(hkey, "count/up", REG_SZ, "one/two/three", 14);
|
|
|
|
add_value(hkey, "\\foo\\bar", REG_SZ, "", 1);
|
|
|
|
|
|
|
|
run_reg_exe("reg delete HKCU\\" KEY_BASE "\\https://winehq.org /f", &r);
|
2022-02-03 11:04:28 +00:00
|
|
|
ok(r == REG_EXIT_SUCCESS, "got exit code %ld, expected 0\n", r);
|
2021-06-16 12:43:08 +00:00
|
|
|
verify_key_nonexist(hkey, "https://winehq.org", 0);
|
2021-03-01 03:16:45 +00:00
|
|
|
|
|
|
|
run_reg_exe("reg delete HKCU\\" KEY_BASE " /v count/up /f", &r);
|
2022-02-03 11:04:28 +00:00
|
|
|
ok(r == REG_EXIT_SUCCESS, "got exit code %ld, expected 0\n", r);
|
2021-03-01 03:16:45 +00:00
|
|
|
verify_reg_nonexist(hkey, "count/up");
|
|
|
|
|
|
|
|
run_reg_exe("reg delete HKCU\\" KEY_BASE " /v \\foo\\bar /f", &r);
|
2022-02-03 11:04:28 +00:00
|
|
|
ok(r == REG_EXIT_SUCCESS, "got exit code %ld, expected 0\n", r);
|
2021-03-01 03:16:45 +00:00
|
|
|
verify_reg_nonexist(hkey, "\\foo\\bar");
|
|
|
|
|
2021-03-10 12:25:20 +00:00
|
|
|
add_value(hkey, "string\\01", REG_SZ, "Value", 6);
|
|
|
|
add_value(hkey, "string2", REG_SZ, "foo\\0bar", 9);
|
|
|
|
add_value(hkey, "\\0", REG_SZ, "Value", 6);
|
|
|
|
|
|
|
|
run_reg_exe("reg delete HKCU\\" KEY_BASE " /v string\\01 /f", &r);
|
2022-02-03 11:04:28 +00:00
|
|
|
ok(r == REG_EXIT_SUCCESS, "got exit code %ld, expected 0\n", r);
|
2021-03-10 12:25:20 +00:00
|
|
|
verify_reg_nonexist(hkey, "string\\01");
|
|
|
|
|
|
|
|
run_reg_exe("reg delete HKCU\\" KEY_BASE " /v string2 /f", &r);
|
2022-02-03 11:04:28 +00:00
|
|
|
ok(r == REG_EXIT_SUCCESS, "got exit code %ld, expected 0\n", r);
|
2021-03-10 12:25:20 +00:00
|
|
|
verify_reg_nonexist(hkey, "string2");
|
|
|
|
|
|
|
|
run_reg_exe("reg delete HKCU\\" KEY_BASE " /v \\0 /f", &r);
|
2022-02-03 11:04:28 +00:00
|
|
|
ok(r == REG_EXIT_SUCCESS, "got exit code %ld, expected 0\n", r);
|
2021-03-10 12:25:20 +00:00
|
|
|
verify_reg_nonexist(hkey, "\\0");
|
|
|
|
|
2021-03-01 03:16:45 +00:00
|
|
|
close_key(hkey);
|
|
|
|
|
|
|
|
run_reg_exe("reg delete HKCU\\" KEY_BASE " /f", &r);
|
2022-02-03 11:04:28 +00:00
|
|
|
ok(r == REG_EXIT_SUCCESS, "got exit code %ld, expected 0\n", r);
|
2021-06-16 12:43:08 +00:00
|
|
|
verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE, 0);
|
2021-03-01 03:16:45 +00:00
|
|
|
|
|
|
|
run_reg_exe("reg delete HKCU\\" KEY_BASE " /f", &r);
|
2022-02-03 11:04:28 +00:00
|
|
|
ok(r == REG_EXIT_FAILURE, "got exit code %ld, expected 1\n", r);
|
2021-03-01 03:16:45 +00:00
|
|
|
}
|
|
|
|
|
2021-06-25 12:58:12 +00:00
|
|
|
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);
|
|
|
|
|
|
|
|
/* 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);
|
2022-02-03 11:04:28 +00:00
|
|
|
ok(r == REG_EXIT_SUCCESS, "got exit code %ld, expected 0\n", r);
|
2021-06-25 12:58:12 +00:00
|
|
|
verify_reg_nonexist(hkey, "DWORD");
|
|
|
|
|
|
|
|
run_reg_exe("reg delete HKLM\\" KEY_BASE " /ve /f /reg:32", &r);
|
2022-02-03 11:04:28 +00:00
|
|
|
ok(r == REG_EXIT_SUCCESS, "got exit code %ld, expected 0\n", r);
|
2021-06-25 12:58:12 +00:00
|
|
|
verify_reg_nonexist(hkey, NULL);
|
|
|
|
|
|
|
|
run_reg_exe("reg delete HKLM\\" KEY_BASE " /va /f /reg:32", &r);
|
2022-02-03 11:04:28 +00:00
|
|
|
ok(r == REG_EXIT_SUCCESS, "got exit code %ld, expected 0\n", r);
|
2021-06-25 12:58:12 +00:00
|
|
|
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);
|
2022-02-03 11:04:28 +00:00
|
|
|
ok(r == REG_EXIT_SUCCESS, "got exit code %ld, expected 0\n", r);
|
2021-06-25 12:58:12 +00:00
|
|
|
verify_key_nonexist(hkey, "Subkey", KEY_WOW64_32KEY);
|
|
|
|
|
|
|
|
close_key(hkey);
|
|
|
|
|
|
|
|
run_reg_exe("reg delete HKLM\\" KEY_BASE " /f /reg:32", &r);
|
2022-02-03 11:04:28 +00:00
|
|
|
ok(r == REG_EXIT_SUCCESS, "got exit code %ld, expected 0\n", r);
|
2021-06-25 12:58:12 +00:00
|
|
|
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);
|
2022-02-03 11:04:28 +00:00
|
|
|
ok(r == REG_EXIT_SUCCESS, "got exit code %ld, expected 0\n", r);
|
2021-06-25 12:58:12 +00:00
|
|
|
verify_reg_nonexist(hkey, "DWORD");
|
|
|
|
|
|
|
|
run_reg_exe("reg delete HKLM\\" KEY_BASE " /ve /f /reg:64", &r);
|
2022-02-03 11:04:28 +00:00
|
|
|
ok(r == REG_EXIT_SUCCESS, "got exit code %ld, expected 0\n", r);
|
2021-06-25 12:58:12 +00:00
|
|
|
verify_reg_nonexist(hkey, NULL);
|
|
|
|
|
|
|
|
run_reg_exe("reg delete HKLM\\" KEY_BASE " /va /f /reg:64", &r);
|
2022-02-03 11:04:28 +00:00
|
|
|
ok(r == REG_EXIT_SUCCESS, "got exit code %ld, expected 0\n", r);
|
2021-06-25 12:58:12 +00:00
|
|
|
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);
|
2022-02-03 11:04:28 +00:00
|
|
|
ok(r == REG_EXIT_SUCCESS, "got exit code %ld, expected 0\n", r);
|
2021-06-25 12:58:12 +00:00
|
|
|
verify_key_nonexist(hkey, "Subkey", KEY_WOW64_64KEY);
|
|
|
|
|
|
|
|
close_key(hkey);
|
|
|
|
|
|
|
|
run_reg_exe("reg delete HKLM\\" KEY_BASE " /f /reg:64", &r);
|
2022-02-03 11:04:28 +00:00
|
|
|
ok(r == REG_EXIT_SUCCESS, "got exit code %ld, expected 0\n", r);
|
2021-06-25 12:58:12 +00:00
|
|
|
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);
|
|
|
|
delete_tree(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);
|
2022-02-03 11:04:28 +00:00
|
|
|
ok(r == REG_EXIT_SUCCESS, "got exit code %ld, expected 0\n", r);
|
2021-06-28 12:57:46 +00:00
|
|
|
verify_reg_nonexist(hkey, "DWORD");
|
2021-06-25 12:58:12 +00:00
|
|
|
|
|
|
|
run_reg_exe("reg delete HKLM\\" KEY_BASE " /ve /f /reg:32", &r);
|
2022-02-03 11:04:28 +00:00
|
|
|
ok(r == REG_EXIT_SUCCESS, "got exit code %ld, expected 0\n", r);
|
2021-06-28 12:57:46 +00:00
|
|
|
verify_reg_nonexist(hkey, NULL);
|
2021-06-25 12:58:12 +00:00
|
|
|
|
|
|
|
run_reg_exe("reg delete HKLM\\" KEY_BASE " /va /f /reg:32", &r);
|
2022-02-03 11:04:28 +00:00
|
|
|
ok(r == REG_EXIT_SUCCESS, "got exit code %ld, expected 0\n", r);
|
2021-06-28 12:57:46 +00:00
|
|
|
verify_reg_nonexist(hkey, "String");
|
|
|
|
verify_reg_nonexist(hkey, "Multiple Strings");
|
2021-06-25 12:58:12 +00:00
|
|
|
verify_key(hkey, "Subkey", KEY_WOW64_32KEY);
|
|
|
|
|
|
|
|
run_reg_exe("reg delete HKLM\\" KEY_BASE "\\Subkey /f /reg:32", &r);
|
2022-02-03 11:04:28 +00:00
|
|
|
ok(r == REG_EXIT_SUCCESS, "got exit code %ld, expected 0\n", r);
|
2021-06-28 12:57:47 +00:00
|
|
|
verify_key_nonexist(hkey, "Subkey", KEY_WOW64_32KEY);
|
2021-06-25 12:58:12 +00:00
|
|
|
|
|
|
|
close_key(hkey);
|
|
|
|
|
|
|
|
run_reg_exe("reg delete HKLM\\" KEY_BASE " /f /reg:32", &r);
|
2022-02-03 11:04:28 +00:00
|
|
|
ok(r == REG_EXIT_SUCCESS, "got exit code %ld, expected 0\n", r);
|
2021-06-28 12:57:47 +00:00
|
|
|
verify_key_nonexist(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_32KEY);
|
2021-06-25 12:58:12 +00:00
|
|
|
|
|
|
|
/* Test deletion from the 64-bit registry view (64-bit Windows) */
|
|
|
|
create_test_key(KEY_WOW64_64KEY);
|
|
|
|
|
2021-06-28 12:57:47 +00:00
|
|
|
verify_key_nonexist(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_32KEY);
|
2021-06-25 12:58:12 +00:00
|
|
|
|
|
|
|
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);
|
2022-02-03 11:04:28 +00:00
|
|
|
ok(r == REG_EXIT_SUCCESS, "got exit code %ld, expected 0\n", r);
|
2021-06-25 12:58:12 +00:00
|
|
|
verify_reg_nonexist(hkey, "DWORD");
|
|
|
|
|
|
|
|
run_reg_exe("reg delete HKLM\\" KEY_BASE " /ve /f /reg:64", &r);
|
2022-02-03 11:04:28 +00:00
|
|
|
ok(r == REG_EXIT_SUCCESS, "got exit code %ld, expected 0\n", r);
|
2021-06-25 12:58:12 +00:00
|
|
|
verify_reg_nonexist(hkey, NULL);
|
|
|
|
|
|
|
|
run_reg_exe("reg delete HKLM\\" KEY_BASE " /va /f /reg:64", &r);
|
2022-02-03 11:04:28 +00:00
|
|
|
ok(r == REG_EXIT_SUCCESS, "got exit code %ld, expected 0\n", r);
|
2021-06-25 12:58:12 +00:00
|
|
|
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);
|
2022-02-03 11:04:28 +00:00
|
|
|
ok(r == REG_EXIT_SUCCESS, "got exit code %ld, expected 0\n", r);
|
2021-06-25 12:58:12 +00:00
|
|
|
verify_key_nonexist(hkey, "Subkey", KEY_WOW64_64KEY);
|
|
|
|
|
|
|
|
close_key(hkey);
|
|
|
|
|
|
|
|
run_reg_exe("reg delete HKLM\\" KEY_BASE " /f /reg:64", &r);
|
2022-02-03 11:04:28 +00:00
|
|
|
ok(r == REG_EXIT_SUCCESS, "got exit code %ld, expected 0\n", r);
|
2021-06-25 12:58:12 +00:00
|
|
|
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);
|
|
|
|
delete_tree(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);
|
2022-02-03 11:04:28 +00:00
|
|
|
ok(r == REG_EXIT_SUCCESS, "got exit code %ld, expected 0\n", r);
|
2021-06-25 12:58:12 +00:00
|
|
|
verify_reg_nonexist(hkey, "DWORD");
|
|
|
|
|
|
|
|
run_reg_exe("reg delete HKLM\\" KEY_BASE " /ve /f /reg:32", &r);
|
2022-02-03 11:04:28 +00:00
|
|
|
ok(r == REG_EXIT_SUCCESS, "got exit code %ld, expected 0\n", r);
|
2021-06-25 12:58:12 +00:00
|
|
|
verify_reg_nonexist(hkey, NULL);
|
|
|
|
|
|
|
|
run_reg_exe("reg delete HKLM\\" KEY_BASE " /va /f /reg:32", &r);
|
2022-02-03 11:04:28 +00:00
|
|
|
ok(r == REG_EXIT_SUCCESS, "got exit code %ld, expected 0\n", r);
|
2021-06-25 12:58:12 +00:00
|
|
|
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);
|
2022-02-03 11:04:28 +00:00
|
|
|
ok(r == REG_EXIT_SUCCESS, "got exit code %ld, expected 0\n", r);
|
2021-06-25 12:58:12 +00:00
|
|
|
verify_key_nonexist(hkey, "Subkey", KEY_WOW64_32KEY);
|
|
|
|
|
|
|
|
close_key(hkey);
|
|
|
|
|
|
|
|
run_reg_exe("reg delete HKLM\\" KEY_BASE " /f /reg:32", &r);
|
2022-02-03 11:04:28 +00:00
|
|
|
ok(r == REG_EXIT_SUCCESS, "got exit code %ld, expected 0\n", r);
|
2021-06-25 12:58:12 +00:00
|
|
|
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);
|
2022-02-03 11:04:28 +00:00
|
|
|
ok(r == REG_EXIT_SUCCESS, "got exit code %ld, expected 0\n", r);
|
2021-06-28 12:57:46 +00:00
|
|
|
verify_reg_nonexist(hkey, "DWORD");
|
2021-06-25 12:58:12 +00:00
|
|
|
|
|
|
|
run_reg_exe("reg delete HKLM\\" KEY_BASE " /ve /f /reg:64", &r);
|
2022-02-03 11:04:28 +00:00
|
|
|
ok(r == REG_EXIT_SUCCESS, "got exit code %ld, expected 0\n", r);
|
2021-06-28 12:57:46 +00:00
|
|
|
verify_reg_nonexist(hkey, NULL);
|
2021-06-25 12:58:12 +00:00
|
|
|
|
|
|
|
run_reg_exe("reg delete HKLM\\" KEY_BASE " /va /f /reg:64", &r);
|
2022-02-03 11:04:28 +00:00
|
|
|
ok(r == REG_EXIT_SUCCESS, "got exit code %ld, expected 0\n", r);
|
2021-06-28 12:57:46 +00:00
|
|
|
verify_reg_nonexist(hkey, "String");
|
|
|
|
verify_reg_nonexist(hkey, "Multiple Strings");
|
2021-06-25 12:58:12 +00:00
|
|
|
verify_key(hkey, "Subkey", KEY_WOW64_64KEY);
|
|
|
|
|
|
|
|
run_reg_exe("reg delete HKLM\\" KEY_BASE "\\Subkey /f /reg:64", &r);
|
2022-02-03 11:04:28 +00:00
|
|
|
ok(r == REG_EXIT_SUCCESS, "got exit code %ld, expected 0\n", r);
|
2021-06-28 12:57:47 +00:00
|
|
|
verify_key_nonexist(hkey, "Subkey", KEY_WOW64_64KEY);
|
2021-06-25 12:58:12 +00:00
|
|
|
|
|
|
|
close_key(hkey);
|
|
|
|
|
|
|
|
run_reg_exe("reg delete HKLM\\" KEY_BASE " /f /reg:64", &r);
|
2022-02-03 11:04:28 +00:00
|
|
|
ok(r == REG_EXIT_SUCCESS, "got exit code %ld, expected 0\n", r);
|
2021-06-28 12:57:47 +00:00
|
|
|
verify_key_nonexist(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_64KEY);
|
2021-06-25 12:58:12 +00:00
|
|
|
}
|
|
|
|
|
2021-03-01 03:16:45 +00:00
|
|
|
START_TEST(delete)
|
|
|
|
{
|
|
|
|
DWORD r;
|
|
|
|
|
|
|
|
if (!run_reg_exe("reg.exe /?", &r)) {
|
|
|
|
win_skip("reg.exe not available, skipping 'delete' tests\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-06-18 12:31:58 +00:00
|
|
|
test_command_syntax();
|
2021-03-01 03:16:45 +00:00
|
|
|
test_delete();
|
2021-06-25 12:58:12 +00:00
|
|
|
|
|
|
|
/* 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();
|
2021-03-01 03:16:45 +00:00
|
|
|
}
|