From f3d911bfbb6fbc5811fae1a4f592732118f1efe3 Mon Sep 17 00:00:00 2001 From: Amine Khaldi Date: Sat, 4 Jun 2016 17:57:35 +0000 Subject: [PATCH] [ADVAPI32_WINETEST] Sync with Wine Staging 1.9.11. CORE-11368 svn path=/trunk/; revision=71517 --- rostests/winetests/advapi32/registry.c | 76 ++++++++++++++++++++++++-- rostests/winetests/advapi32/security.c | 50 +++++++++++++---- 2 files changed, 111 insertions(+), 15 deletions(-) diff --git a/rostests/winetests/advapi32/registry.c b/rostests/winetests/advapi32/registry.c index 82f573a432c..521902a8979 100644 --- a/rostests/winetests/advapi32/registry.c +++ b/rostests/winetests/advapi32/registry.c @@ -2237,7 +2237,7 @@ static void test_reg_delete_tree(void) "subkey2 was not deleted\n"); size = MAX_PATH; ok(!RegQueryValueA(subkey, NULL, buffer, &size), - "Default value of subkey not longer present\n"); + "Default value of subkey no longer present\n"); ret = RegCreateKeyA(subkey, "subkey2", &subkey2); ok(ret == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", ret); @@ -2248,7 +2248,7 @@ static void test_reg_delete_tree(void) ok(RegOpenKeyA(subkey, "subkey2", &subkey2), "subkey2 was not deleted\n"); ok(!RegQueryValueA(subkey, NULL, buffer, &size), - "Default value of subkey not longer present\n"); + "Default value of subkey no longer present\n"); ret = RegCreateKeyA(subkey, "subkey2", &subkey2); ok(ret == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", ret); @@ -2278,6 +2278,20 @@ static void test_reg_delete_tree(void) dwsize = MAX_PATH; ok(RegQueryValueExA(subkey, "value", NULL, &type, (BYTE *)buffer, &dwsize), "Value is still present\n"); + ret = RegCloseKey(subkey); + ok(ret == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", ret); + + ret = RegOpenKeyA(hkey_main, "subkey", &subkey); + ok(ret == ERROR_SUCCESS, "subkey was deleted\n"); + ret = pRegDeleteTreeA(subkey, ""); + ok(ret == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", ret); + ret = RegCloseKey(subkey); + ok(ret == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", ret); + + ret = RegOpenKeyA(hkey_main, "subkey", &subkey); + ok(ret == ERROR_SUCCESS, "subkey was deleted\n"); + ret = RegCloseKey(subkey); + ok(ret == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", ret); ret = pRegDeleteTreeA(hkey_main, "not-here"); ok(ret == ERROR_FILE_NOT_FOUND, @@ -2697,8 +2711,8 @@ static void test_redirection(void) check_key_value( key, "Winetest", 0, ptr_size ); check_key_value( key, "Winetest", KEY_WOW64_64KEY, is_vista ? 64 : ptr_size ); dw = get_key_value( key, "Winetest", KEY_WOW64_32KEY ); - if (ptr_size == 32) ok( dw == 32, "wrong value %u\n", dw ); - else todo_wine ok( dw == 32, "wrong value %u\n", dw ); + todo_wine_if (ptr_size != 32) + ok( dw == 32, "wrong value %u\n", dw ); RegCloseKey( key ); if (ptr_size == 32) @@ -3358,6 +3372,19 @@ static void test_delete_value(void) res = RegDeleteValueA( hkey_main, longname ); ok(res == ERROR_FILE_NOT_FOUND || broken(res == ERROR_MORE_DATA), /* nt4, win2k */ "expect ERROR_FILE_NOT_FOUND, got %i\n", res); + + /* Default registry value */ + res = RegSetValueExA(hkey_main, "", 0, REG_SZ, (const BYTE *)"value", 6); + ok(res == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %d\n", res); + + res = RegQueryValueExA(hkey_main, "", NULL, NULL, NULL, NULL); + ok(res == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %d\n", res); + + res = RegDeleteValueA(hkey_main, "" ); + ok(res == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %d\n", res); + + res = RegQueryValueExA(hkey_main, "", NULL, NULL, NULL, NULL); + ok(res == ERROR_FILE_NOT_FOUND, "expected ERROR_FILE_NOT_FOUND, got %d\n", res); } static void test_delete_key_value(void) @@ -3406,6 +3433,19 @@ static void test_delete_key_value(void) ret = RegQueryValueExA(subkey, "test", NULL, NULL, NULL, NULL); ok(ret == ERROR_FILE_NOT_FOUND, "got %d\n", ret); + /* Default registry value */ + ret = RegSetValueExA(subkey, "", 0, REG_SZ, (const BYTE *)"value", 6); + ok(ret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %d\n", ret); + + ret = RegQueryValueExA(subkey, "", NULL, NULL, NULL, NULL); + ok(ret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %d\n", ret); + + ret = pRegDeleteKeyValueA(hkey_main, "Subkey1", "" ); + ok(ret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %d\n", ret); + + ret = RegQueryValueExA(subkey, "", NULL, NULL, NULL, NULL); + ok(ret == ERROR_FILE_NOT_FOUND, "expected ERROR_FILE_NOT_FOUND, got %d\n", ret); + RegDeleteKeyA(subkey, ""); RegCloseKey(subkey); } @@ -3422,6 +3462,33 @@ static void test_RegOpenCurrentUser(void) RegCloseKey(key); } +static void test_RegNotifyChangeKeyValue(void) +{ + HKEY key, subkey; + HANDLE event; + DWORD dwret; + LONG ret; + + event = CreateEventW(NULL, FALSE, TRUE, NULL); + ok(event != NULL, "CreateEvent failed, error %u\n", GetLastError()); + ret = RegCreateKeyA(hkey_main, "TestKey", &key); + ok(ret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %d\n", ret); + + ret = RegNotifyChangeKeyValue(key, TRUE, REG_NOTIFY_CHANGE_NAME, event, TRUE); + ok(ret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %d\n", ret); + dwret = WaitForSingleObject(event, 0); + ok(dwret == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %u\n", dwret); + + ret = RegCreateKeyA(key, "SubKey", &subkey); + ok(ret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %d\n", ret); + dwret = WaitForSingleObject(event, 0); + ok(dwret == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %u\n", dwret); + + RegDeleteKeyA(key, ""); + RegCloseKey(key); + CloseHandle(event); +} + START_TEST(registry) { /* Load pointers for functions that are not available in all Windows versions */ @@ -3456,6 +3523,7 @@ START_TEST(registry) test_delete_value(); test_delete_key_value(); test_RegOpenCurrentUser(); + test_RegNotifyChangeKeyValue(); /* cleanup */ delete_key( hkey_main ); diff --git a/rostests/winetests/advapi32/security.c b/rostests/winetests/advapi32/security.c index e99cfd71204..f94e648d8fe 100644 --- a/rostests/winetests/advapi32/security.c +++ b/rostests/winetests/advapi32/security.c @@ -3531,7 +3531,7 @@ static void test_CreateDirectoryA(void) GENERIC_ALL, admin_sid); ok(bret, "Failed to add Administrator Group to ACL.\n"); bret = SetSecurityDescriptorDacl(pSD, TRUE, pDacl, FALSE); - ok(bret, "Failed to add ACL to security desciptor.\n"); + ok(bret, "Failed to add ACL to security descriptor.\n"); GetTempPathA(MAX_PATH, tmpdir); lstrcatA(tmpdir, "Please Remove Me"); @@ -3578,7 +3578,7 @@ static void test_CreateDirectoryA(void) bret = InitializeAcl(pDacl, sizeof(ACL), ACL_REVISION); ok(bret, "Failed to initialize ACL\n"); bret = SetSecurityDescriptorDacl(pSD, TRUE, pDacl, FALSE); - ok(bret, "Failed to add ACL to security desciptor\n"); + ok(bret, "Failed to add ACL to security descriptor\n"); strcpy(tmpfile, tmpdir); lstrcatA(tmpfile, "/tmpfile"); @@ -3646,7 +3646,7 @@ static void test_CreateDirectoryA(void) bret = InitializeAcl(pDacl, sizeof(ACL), ACL_REVISION); ok(bret, "Failed to initialize ACL\n"); bret = SetSecurityDescriptorDacl(pSD, TRUE, pDacl, FALSE); - ok(bret, "Failed to add ACL to security desciptor\n"); + ok(bret, "Failed to add ACL to security descriptor\n"); strcpy(tmpfile, tmpdir); lstrcatA(tmpfile, "/tmpfile"); @@ -3671,6 +3671,7 @@ static void test_CreateDirectoryA(void) ok(error == ERROR_SUCCESS, "GetNamedSecurityInfo failed with error %d\n", error); bret = pGetAclInformation(pDacl, &acl_size, sizeof(acl_size), AclSizeInformation); ok(bret, "GetAclInformation failed\n"); + todo_wine ok(acl_size.AceCount == 0, "GetAclInformation returned unexpected entry count (%d != 0).\n", acl_size.AceCount); LocalFree(pSD); @@ -3729,7 +3730,6 @@ static void test_CreateDirectoryA(void) ok(error == ERROR_SUCCESS, "GetNamedSecurityInfo failed with error %d\n", error); bret = pGetAclInformation(pDacl, &acl_size, sizeof(acl_size), AclSizeInformation); ok(bret, "GetAclInformation failed\n"); - todo_wine ok(acl_size.AceCount == 0, "GetAclInformation returned unexpected entry count (%d != 0).\n", acl_size.AceCount); LocalFree(pSD); @@ -3970,7 +3970,7 @@ static void test_GetNamedSecurityInfoA(void) bret = pAddAccessAllowedAceEx(pDacl, ACL_REVISION, 0, GENERIC_ALL, admin_sid); ok(bret, "Failed to add Administrator Group to ACL.\n"); bret = SetSecurityDescriptorDacl(pSD, TRUE, pDacl, FALSE); - ok(bret, "Failed to add ACL to security desciptor.\n"); + ok(bret, "Failed to add ACL to security descriptor.\n"); GetTempFileNameA(".", "foo", 0, tmpfile); hTemp = CreateFileA(tmpfile, WRITE_DAC|GENERIC_WRITE, FILE_SHARE_DELETE|FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_DELETE_ON_CLOSE, NULL); @@ -4078,7 +4078,7 @@ static void test_GetNamedSecurityInfoA(void) bret = InitializeAcl(pDacl, sizeof(ACL), ACL_REVISION); ok(bret, "Failed to initialize ACL.\n"); bret = SetSecurityDescriptorDacl(pSD, TRUE, pDacl, FALSE); - ok(bret, "Failed to add ACL to security desciptor.\n"); + ok(bret, "Failed to add ACL to security descriptor.\n"); status = pNtSetSecurityObject(hTemp, DACL_SECURITY_INFORMATION, pSD); ok(status == ERROR_SUCCESS, "NtSetSecurityObject returned %x\n", status); @@ -4114,7 +4114,7 @@ static void test_GetNamedSecurityInfoA(void) bret = pAddAccessDeniedAceEx(pDacl, ACL_REVISION, 0, GENERIC_ALL, user_sid); ok(bret, "Failed to add Current User to ACL.\n"); bret = SetSecurityDescriptorDacl(pSD, TRUE, pDacl, FALSE); - ok(bret, "Failed to add ACL to security desciptor.\n"); + ok(bret, "Failed to add ACL to security descriptor.\n"); status = pNtSetSecurityObject(hTemp, DACL_SECURITY_INFORMATION, pSD); ok(status == ERROR_SUCCESS, "NtSetSecurityObject returned %x\n", status); @@ -4130,7 +4130,7 @@ static void test_GetNamedSecurityInfoA(void) bret = pAddAccessAllowedAceEx(pDacl, ACL_REVISION, 0, GENERIC_ALL, user_sid); ok(bret, "Failed to add Current User to ACL.\n"); bret = SetSecurityDescriptorDacl(pSD, TRUE, pDacl, FALSE); - ok(bret, "Failed to add ACL to security desciptor.\n"); + ok(bret, "Failed to add ACL to security descriptor.\n"); status = pNtSetSecurityObject(hTemp, DACL_SECURITY_INFORMATION, pSD); ok(status == ERROR_SUCCESS, "NtSetSecurityObject returned %x\n", status); @@ -4787,7 +4787,7 @@ static void test_GetSecurityInfo(void) bret = pAddAccessAllowedAceEx(pDacl, ACL_REVISION, 0, GENERIC_ALL, admin_sid); ok(bret, "Failed to add Administrator Group to ACL.\n"); bret = SetSecurityDescriptorDacl(pSD, TRUE, pDacl, FALSE); - ok(bret, "Failed to add ACL to security desciptor.\n"); + ok(bret, "Failed to add ACL to security descriptor.\n"); ret = pSetSecurityInfo(obj, SE_FILE_OBJECT, DACL_SECURITY_INFORMATION, NULL, NULL, pDacl, NULL); ok(ret == ERROR_SUCCESS, "SetSecurityInfo returned %d\n", ret); @@ -5835,17 +5835,23 @@ static void test_filemap_security(void) char temp_path[MAX_PATH]; char file_name[MAX_PATH]; DWORD ret, i, access; - HANDLE file, mapping, dup; + HANDLE file, mapping, dup, created_mapping; static const struct { int generic, mapped; + BOOL open_only; } map[] = { { 0, 0 }, { GENERIC_READ, STANDARD_RIGHTS_READ | SECTION_QUERY | SECTION_MAP_READ }, { GENERIC_WRITE, STANDARD_RIGHTS_WRITE | SECTION_MAP_WRITE }, { GENERIC_EXECUTE, STANDARD_RIGHTS_EXECUTE | SECTION_MAP_EXECUTE }, - { GENERIC_ALL, STANDARD_RIGHTS_REQUIRED | SECTION_ALL_ACCESS } + { GENERIC_ALL, STANDARD_RIGHTS_REQUIRED | SECTION_ALL_ACCESS }, + { SECTION_MAP_READ | SECTION_MAP_WRITE, SECTION_MAP_READ | SECTION_MAP_WRITE }, + { SECTION_MAP_WRITE, SECTION_MAP_WRITE }, + { SECTION_MAP_READ | SECTION_QUERY, SECTION_MAP_READ | SECTION_QUERY }, + { SECTION_QUERY, SECTION_MAP_READ, TRUE }, + { SECTION_QUERY | SECTION_MAP_READ, SECTION_QUERY | SECTION_MAP_READ } }; static const struct { @@ -5874,6 +5880,8 @@ static void test_filemap_security(void) for (i = 0; i < sizeof(prot_map)/sizeof(prot_map[0]); i++) { + if (map[i].open_only) continue; + SetLastError(0xdeadbeef); mapping = CreateFileMappingW(file, NULL, prot_map[i].prot, 0, 4096, NULL); if (prot_map[i].mapped) @@ -5920,6 +5928,8 @@ static void test_filemap_security(void) for (i = 0; i < sizeof(map)/sizeof(map[0]); i++) { + if (map[i].open_only) continue; + SetLastError( 0xdeadbeef ); ret = DuplicateHandle(GetCurrentProcess(), mapping, GetCurrentProcess(), &dup, map[i].generic, FALSE, 0); @@ -5934,6 +5944,24 @@ static void test_filemap_security(void) CloseHandle(mapping); CloseHandle(file); DeleteFileA(file_name); + + created_mapping = CreateFileMappingA(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, 0x1000, + "Wine Test Open Mapping"); + ok(created_mapping != NULL, "CreateFileMapping failed with error %u\n", GetLastError()); + + for (i = 0; i < sizeof(map)/sizeof(map[0]); i++) + { + if (!map[i].generic) continue; + + mapping = OpenFileMappingA(map[i].generic, FALSE, "Wine Test Open Mapping"); + ok(mapping != NULL, "OpenFileMapping failed with error %d\n", GetLastError()); + access = get_obj_access(mapping); + ok(access == map[i].mapped, "%d: unexpected access flags %#x, expected %#x\n", + i, access, map[i].mapped); + CloseHandle(mapping); + } + + CloseHandle(created_mapping); } static void test_thread_security(void)