Author: akhaldi
Date: Fri Apr 18 21:58:58 2014
New Revision: 62781
URL:
http://svn.reactos.org/svn/reactos?rev=62781&view=rev
Log:
[ADVAPI32_WINETEST]
* Sync with Wine 1.7.17.
CORE-8080
Modified:
trunk/rostests/winetests/advapi32/cred.c
trunk/rostests/winetests/advapi32/crypt.c
trunk/rostests/winetests/advapi32/eventlog.c
trunk/rostests/winetests/advapi32/lsa.c
trunk/rostests/winetests/advapi32/registry.c
trunk/rostests/winetests/advapi32/security.c
trunk/rostests/winetests/advapi32/service.c
Modified: trunk/rostests/winetests/advapi32/cred.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/advapi32/cred.c…
==============================================================================
--- trunk/rostests/winetests/advapi32/cred.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/advapi32/cred.c [iso-8859-1] Fri Apr 18 21:58:58 2014
@@ -187,7 +187,7 @@
char target_name[] = "no_such_target";
CREDENTIAL_TARGET_INFORMATIONA info = {target_name, NULL, target_name, NULL, NULL,
NULL, NULL, 0, 0, NULL};
DWORD count;
- PCREDENTIAL* creds;
+ PCREDENTIALA* creds;
if (!pCredReadDomainCredentialsA)
{
@@ -563,14 +563,65 @@
static void test_CredUnmarshalCredentialA(void)
{
- static WCHAR tW[] = {'t',0};
- static WCHAR testW[] = {'t','e','s','t',0};
+ static const UCHAR cert_empty[CERT_HASH_LENGTH] = {0};
+ static const UCHAR cert_wine[CERT_HASH_LENGTH] =
{'W','i','n','e',0};
+ static const WCHAR tW[] = {'t',0};
+ static const WCHAR teW[] = {'t','e',0};
+ static const WCHAR tesW[] = {'t','e','s',0};
+ static const WCHAR testW[] = {'t','e','s','t',0};
+ void *p;
CERT_CREDENTIAL_INFO *cert;
+ const UCHAR *hash;
USERNAME_TARGET_CREDENTIAL_INFO *username;
CRED_MARSHAL_TYPE type;
- unsigned int i;
+ unsigned int i, j;
DWORD error;
BOOL ret;
+ const struct {
+ const char *cred;
+ CRED_MARSHAL_TYPE type;
+ const void *unmarshaled;
+ } tests[] = {
+ { "", 0, NULL },
+ { "@", 0, NULL },
+ { "@@", 0, NULL },
+ { "@@@", 0, NULL },
+ { "@@A", 0, NULL },
+ { "@@E", 4, NULL },
+ { "@@Z", 25, NULL },
+ { "@@a", 26, NULL },
+ { "@@0", 52, NULL },
+ { "@@#", 62, NULL },
+ { "@@-", 63, NULL },
+ { "@@B", CertCredential, NULL },
+ { "@@BA", CertCredential, NULL },
+ { "@@BAAAAAAAAAAAAAAAAAAAAAAAAAA", CertCredential, NULL },
+ { "@@BAAAAAAAAAAAAAAAAAAAAAAAAAAAA", CertCredential, NULL },
+ { "@@BAAAAAAAAAAAAAAAAAAAAAAAAAAA", CertCredential, cert_empty },
+ { "@@BXlmblBAAAAAAAAAAAAAAAAAAAAA", CertCredential, cert_wine },
+ { "@@C", UsernameTargetCredential, NULL },
+ { "@@CA", UsernameTargetCredential, NULL },
+ { "@@CAAAAAA", UsernameTargetCredential, NULL },
+ { "@@CAAAAAA0B", UsernameTargetCredential, NULL },
+ { "@@CAAAAAA0BA", UsernameTargetCredential, NULL },
+ { "@@CCAAAAA0BA", UsernameTargetCredential, tW },
+ { "@@CEAAAAA0BA", UsernameTargetCredential, NULL },
+ { "@@CEAAAAA0BAd", UsernameTargetCredential, NULL },
+ { "@@CEAAAAA0BAdA", UsernameTargetCredential, NULL },
+ { "@@CEAAAAA0BQZAA", UsernameTargetCredential, teW },
+ { "@@CEAAAAA0BQZAQ", UsernameTargetCredential, teW },
+ { "@@CEAAAAA0BQZAg", UsernameTargetCredential, teW },
+ { "@@CEAAAAA0BQZAw", UsernameTargetCredential, teW },
+ { "@@CEAAAAA0BQZAAA", UsernameTargetCredential, NULL },
+ { "@@CGAAAAA0BQZAMH", UsernameTargetCredential, NULL },
+ { "@@CGAAAAA0BQZAMHA", UsernameTargetCredential, tesW },
+ { "@@CGAAAAA0BQZAMHAA", UsernameTargetCredential, NULL },
+ { "@@CCAAAAA0BAA", UsernameTargetCredential, NULL },
+ { "@@CBAAAAA0BAA", UsernameTargetCredential, NULL },
+ { "@@CAgAAAA0BAA", UsernameTargetCredential, NULL },
+ { "@@CIAAAAA0BQZAMHA0BA", UsernameTargetCredential, testW },
+ { "@@CA-----0BQZAMHA0BA", UsernameTargetCredential, NULL },
+ };
SetLastError( 0xdeadbeef );
ret = pCredUnmarshalCredentialA( NULL, NULL, NULL );
@@ -593,14 +644,6 @@
ok( !ret, "unexpected success\n" );
ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
- type = 0;
- cert = NULL;
- SetLastError( 0xdeadbeef );
- ret = pCredUnmarshalCredentialA( "", &type, (void **)&cert );
- error = GetLastError();
- ok( !ret, "unexpected success\n" );
- ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
-
if (0) { /* crash */
SetLastError( 0xdeadbeef );
ret = pCredUnmarshalCredentialA( "@@BAAAAAAAAAAAAAAAAAAAAAAAAAAA",
&type, NULL );
@@ -615,69 +658,46 @@
ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
}
- type = 0;
- cert = NULL;
- ret = pCredUnmarshalCredentialA( "@@BAAAAAAAAAAAAAAAAAAAAAAAAAAA",
&type, (void **)&cert );
- ok( ret, "unexpected failure %u\n", GetLastError() );
- ok( type == CertCredential, "got %u\n", type );
- ok( cert != NULL, "cert is NULL\n" );
- ok( cert->cbSize == sizeof(*cert), "wrong size %u\n", cert->cbSize
);
- for (i = 0; i < sizeof(cert->rgbHashOfCert); i++) ok(
!cert->rgbHashOfCert[i], "wrong data\n" );
- pCredFree( cert );
-
- type = 0;
- cert = NULL;
- ret = pCredUnmarshalCredentialA( "@@BXlmblBAAAAAAAAAAAAAAAAAAAAA",
&type, (void **)&cert );
- ok( ret, "unexpected failure %u\n", GetLastError() );
- ok( type == CertCredential, "got %u\n", type );
- ok( cert != NULL, "cert is NULL\n" );
- ok( cert->cbSize == sizeof(*cert), "wrong size %u\n", cert->cbSize
);
- ok( cert->rgbHashOfCert[0] == 'W', "wrong data)\n" );
- ok( cert->rgbHashOfCert[1] == 'i', "wrong data\n" );
- ok( cert->rgbHashOfCert[2] == 'n', "wrong data\n" );
- ok( cert->rgbHashOfCert[3] == 'e', "wrong data\n" );
- for (i = 4; i < sizeof(cert->rgbHashOfCert); i++) ok(
!cert->rgbHashOfCert[i], "wrong data\n" );
- pCredFree( cert );
-
- SetLastError( 0xdeadbeef );
- ret = pCredUnmarshalCredentialA( "@@CAAAAAA", &type, (void
**)&username );
- error = GetLastError();
- ok( !ret, "unexpected success\n" );
- ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
-
- SetLastError( 0xdeadbeef );
- ret = pCredUnmarshalCredentialA( "@@CAAAAAA0BA", &type, (void
**)&username );
- error = GetLastError();
- ok( !ret, "unexpected success\n" );
- ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
-
- type = 0;
- username = NULL;
- ret = pCredUnmarshalCredentialA( "@@CCAAAAA0BA", &type, (void
**)&username );
- ok( ret, "unexpected failure %u\n", GetLastError() );
- ok( type == UsernameTargetCredential, "got %u\n", type );
- ok( username != NULL, "username is NULL\n" );
- ok( username->UserName != NULL, "UserName is NULL\n" );
- ok( !lstrcmpW( username->UserName, tW ), "got %s\n",
wine_dbgstr_w(username->UserName) );
- pCredFree( username );
-
- type = 0;
- username = NULL;
- ret = pCredUnmarshalCredentialA( "@@CIAAAAA0BQZAMHA0BA", &type, (void
**)&username );
- ok( ret, "unexpected failure %u\n", GetLastError() );
- ok( type == UsernameTargetCredential, "got %u\n", type );
- ok( username != NULL, "username is NULL\n" );
- ok( username->UserName != NULL, "UserName is NULL\n" );
- ok( !lstrcmpW( username->UserName, testW ), "got %s\n",
wine_dbgstr_w(username->UserName) );
- pCredFree( username );
-
- type = 0;
- username = NULL;
- SetLastError( 0xdeadbeef );
- ret = pCredUnmarshalCredentialA( "@@CA-----0BQZAMHA0BA", &type, (void
**)&username );
- error = GetLastError();
- ok( !ret, "unexpected success\n" );
- ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
+ for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++)
+ {
+ SetLastError(0xdeadbeef);
+ type = 0;
+ p = NULL;
+ ret = pCredUnmarshalCredentialA(tests[i].cred, &type, &p);
+ error = GetLastError();
+ if (tests[i].unmarshaled)
+ {
+ ok(ret, "[%u] unexpected failure %u\n", i, error);
+ ok(type == tests[i].type, "[%u] got %u\n", i, type);
+ ok(p != NULL, "[%u] returned pointer is NULL\n", i);
+ if (tests[i].type == CertCredential)
+ {
+ cert = p;
+ hash = tests[i].unmarshaled;
+ ok(cert->cbSize == sizeof(*cert),
+ "[%u] wrong size %u\n", i, cert->cbSize);
+ for (j = 0; j < sizeof(cert->rgbHashOfCert); j++)
+ ok(cert->rgbHashOfCert[j] == hash[j], "[%u] wrong
data\n", i);
+ }
+ else if (tests[i].type == UsernameTargetCredential)
+ {
+ username = p;
+ ok(username->UserName != NULL, "[%u] UserName is NULL\n",
i);
+ ok(!lstrcmpW(username->UserName, tests[i].unmarshaled),
+ "[%u] got %s\n", i, wine_dbgstr_w(username->UserName));
+ }
+ }
+ else
+ {
+ ok(!ret, "[%u] unexpected success\n", i);
+ ok(error == ERROR_INVALID_PARAMETER, "[%u] got %u\n", i, error);
+ ok(type == tests[i].type, "[%u] got %u\n", i, type);
+ ok(p == NULL, "[%u] returned pointer is not NULL\n", i);
+ }
+
+ if (ret)
+ pCredFree(p);
+ }
}
static void test_CredIsMarshaledCredentialA(void)
@@ -744,18 +764,19 @@
START_TEST(cred)
{
DWORD persists[CRED_TYPE_MAXIMUM];
-
- pCredEnumerateA = (void *)GetProcAddress(GetModuleHandle("advapi32.dll"),
"CredEnumerateA");
- pCredFree = (void *)GetProcAddress(GetModuleHandle("advapi32.dll"),
"CredFree");
- pCredGetSessionTypes = (void
*)GetProcAddress(GetModuleHandle("advapi32.dll"),
"CredGetSessionTypes");
- pCredWriteA = (void *)GetProcAddress(GetModuleHandle("advapi32.dll"),
"CredWriteA");
- pCredDeleteA = (void *)GetProcAddress(GetModuleHandle("advapi32.dll"),
"CredDeleteA");
- pCredReadA = (void *)GetProcAddress(GetModuleHandle("advapi32.dll"),
"CredReadA");
- pCredRenameA = (void *)GetProcAddress(GetModuleHandle("advapi32.dll"),
"CredRenameA");
- pCredReadDomainCredentialsA = (void
*)GetProcAddress(GetModuleHandle("advapi32.dll"),
"CredReadDomainCredentialsA");
- pCredMarshalCredentialA = (void
*)GetProcAddress(GetModuleHandle("advapi32.dll"),
"CredMarshalCredentialA");
- pCredUnmarshalCredentialA = (void
*)GetProcAddress(GetModuleHandle("advapi32.dll"),
"CredUnmarshalCredentialA");
- pCredIsMarshaledCredentialA = (void
*)GetProcAddress(GetModuleHandle("advapi32.dll"),
"CredIsMarshaledCredentialA");
+ HMODULE mod = GetModuleHandleA("advapi32.dll");
+
+ pCredEnumerateA = (void *)GetProcAddress(mod, "CredEnumerateA");
+ pCredFree = (void *)GetProcAddress(mod, "CredFree");
+ pCredGetSessionTypes = (void *)GetProcAddress(mod, "CredGetSessionTypes");
+ pCredWriteA = (void *)GetProcAddress(mod, "CredWriteA");
+ pCredDeleteA = (void *)GetProcAddress(mod, "CredDeleteA");
+ pCredReadA = (void *)GetProcAddress(mod, "CredReadA");
+ pCredRenameA = (void *)GetProcAddress(mod, "CredRenameA");
+ pCredReadDomainCredentialsA = (void *)GetProcAddress(mod,
"CredReadDomainCredentialsA");
+ pCredMarshalCredentialA = (void *)GetProcAddress(mod,
"CredMarshalCredentialA");
+ pCredUnmarshalCredentialA = (void *)GetProcAddress(mod,
"CredUnmarshalCredentialA");
+ pCredIsMarshaledCredentialA = (void *)GetProcAddress(mod,
"CredIsMarshaledCredentialA");
if (!pCredEnumerateA || !pCredFree || !pCredWriteA || !pCredDeleteA || !pCredReadA)
{
Modified: trunk/rostests/winetests/advapi32/crypt.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/advapi32/crypt.…
==============================================================================
--- trunk/rostests/winetests/advapi32/crypt.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/advapi32/crypt.c [iso-8859-1] Fri Apr 18 21:58:58 2014
@@ -474,21 +474,21 @@
HKEY subkey;
DWORD size = sizeof(DWORD);
- if (RegOpenKey(HKEY_LOCAL_MACHINE,
"Software\\Microsoft\\Cryptography\\Defaults\\Provider", &hKey))
+ if (RegOpenKeyA(HKEY_LOCAL_MACHINE,
"Software\\Microsoft\\Cryptography\\Defaults\\Provider", &hKey))
return FALSE;
- RegQueryInfoKey(hKey, NULL, NULL, NULL, pdwProvCount, pcbProvName,
+ RegQueryInfoKeyA(hKey, NULL, NULL, NULL, pdwProvCount, pcbProvName,
NULL, NULL, NULL, NULL, NULL, NULL);
(*pcbProvName)++;
if (!(*pszProvName = LocalAlloc(LMEM_ZEROINIT, *pcbProvName)))
return FALSE;
- RegEnumKeyEx(hKey, dwIndex, *pszProvName, pcbProvName, NULL, NULL, NULL, NULL);
+ RegEnumKeyExA(hKey, dwIndex, *pszProvName, pcbProvName, NULL, NULL, NULL, NULL);
(*pcbProvName)++;
- RegOpenKey(hKey, *pszProvName, &subkey);
- RegQueryValueEx(subkey, "Type", NULL, NULL, (LPBYTE)pdwProvType, &size);
+ RegOpenKeyA(hKey, *pszProvName, &subkey);
+ RegQueryValueExA(subkey, "Type", NULL, NULL, (LPBYTE)pdwProvType, &size);
RegCloseKey(subkey);
RegCloseKey(hKey);
@@ -599,10 +599,10 @@
DWORD cbName;
BOOL ret = FALSE;
- if (RegOpenKey(HKEY_LOCAL_MACHINE,
"Software\\Microsoft\\Cryptography\\Defaults\\Provider Types", &hKey))
+ if (RegOpenKeyA(HKEY_LOCAL_MACHINE,
"Software\\Microsoft\\Cryptography\\Defaults\\Provider Types", &hKey))
return FALSE;
- if (RegQueryInfoKey(hKey, NULL, NULL, NULL, pdwTypeCount, &cbName, NULL,
+ if (RegQueryInfoKeyA(hKey, NULL, NULL, NULL, pdwTypeCount, &cbName, NULL,
NULL, NULL, NULL, NULL, NULL))
goto cleanup;
cbName++;
@@ -610,7 +610,7 @@
if (!(szName = LocalAlloc(LMEM_ZEROINIT, cbName)))
goto cleanup;
- while (!RegEnumKeyEx(hKey, *pdwIndex, szName, &cbName, NULL, NULL, NULL, NULL))
+ while (!RegEnumKeyExA(hKey, *pdwIndex, szName, &cbName, NULL, NULL, NULL, NULL))
{
cbName++;
ch = szName + strlen(szName);
@@ -619,15 +619,15 @@
*pdwProvType += (*(--ch) - '0') * 10;
*pdwProvType += (*(--ch) - '0') * 100;
- if (RegOpenKey(hKey, szName, &hSubKey))
+ if (RegOpenKeyA(hKey, szName, &hSubKey))
break;
- if (!RegQueryValueEx(hSubKey, "TypeName", NULL, NULL, NULL, pcbTypeName))
+ if (!RegQueryValueExA(hSubKey, "TypeName", NULL, NULL, NULL, pcbTypeName))
{
if (!(*pszTypeName = LocalAlloc(LMEM_ZEROINIT, *pcbTypeName)))
break;
- if (!RegQueryValueEx(hSubKey, "TypeName", NULL, NULL, (LPBYTE)*pszTypeName,
pcbTypeName))
+ if (!RegQueryValueExA(hSubKey, "TypeName", NULL, NULL, (LPBYTE)*pszTypeName,
pcbTypeName))
{
ret = TRUE;
break;
@@ -763,14 +763,14 @@
} else
return FALSE;
- if (RegOpenKey((dwFlags & CRYPT_USER_DEFAULT) ? HKEY_CURRENT_USER :
HKEY_LOCAL_MACHINE ,keyname, &hKey))
+ if (RegOpenKeyA((dwFlags & CRYPT_USER_DEFAULT) ? HKEY_CURRENT_USER :
HKEY_LOCAL_MACHINE ,keyname, &hKey))
{
LocalFree(keyname);
return FALSE;
}
LocalFree(keyname);
- if (RegQueryValueEx(hKey, "Name", NULL, NULL, (LPBYTE)*pszProvName,
pcbProvName))
+ if (RegQueryValueExA(hKey, "Name", NULL, NULL, (LPBYTE)*pszProvName,
pcbProvName))
{
if (GetLastError() != ERROR_MORE_DATA)
SetLastError(NTE_PROV_TYPE_ENTRY_BAD);
@@ -780,7 +780,7 @@
if (!(*pszProvName = LocalAlloc(LMEM_ZEROINIT, *pcbProvName)))
return FALSE;
- if (RegQueryValueEx(hKey, "Name", NULL, NULL, (LPBYTE)*pszProvName,
pcbProvName))
+ if (RegQueryValueExA(hKey, "Name", NULL, NULL, (LPBYTE)*pszProvName,
pcbProvName))
{
if (GetLastError() != ERROR_MORE_DATA)
SetLastError(NTE_PROV_TYPE_ENTRY_BAD);
@@ -899,13 +899,13 @@
ok(result, "%d\n", GetLastError());
/* check pdwReserved for NULL */
- result = pCryptSetProviderExA(MS_DEF_PROV, PROV_RSA_FULL, ¬Null,
CRYPT_MACHINE_DEFAULT);
+ result = pCryptSetProviderExA(MS_DEF_PROV_A, PROV_RSA_FULL, ¬Null,
CRYPT_MACHINE_DEFAULT);
ok(!result && GetLastError()==ERROR_INVALID_PARAMETER, "expected %i, got
%d\n",
ERROR_INVALID_PARAMETER, GetLastError());
/* remove the default provider and then set it to MS_DEF_PROV/PROV_RSA_FULL */
SetLastError(0xdeadbeef);
- result = pCryptSetProviderExA(MS_DEF_PROV, PROV_RSA_FULL, NULL, CRYPT_MACHINE_DEFAULT |
CRYPT_DELETE_DEFAULT);
+ result = pCryptSetProviderExA(MS_DEF_PROV_A, PROV_RSA_FULL, NULL, CRYPT_MACHINE_DEFAULT
| CRYPT_DELETE_DEFAULT);
if (!result)
{
ok( GetLastError() == ERROR_ACCESS_DENIED || broken(GetLastError() ==
ERROR_INVALID_PARAMETER),
@@ -915,7 +915,7 @@
return;
}
- result = pCryptSetProviderExA(MS_DEF_PROV, PROV_RSA_FULL, NULL, CRYPT_MACHINE_DEFAULT);
+ result = pCryptSetProviderExA(MS_DEF_PROV_A, PROV_RSA_FULL, NULL,
CRYPT_MACHINE_DEFAULT);
ok(result, "%d\n", GetLastError());
/* call CryptGetDefaultProvider to see if they match */
@@ -925,13 +925,13 @@
goto reset;
result = pCryptGetDefaultProviderA(PROV_RSA_FULL, NULL, CRYPT_MACHINE_DEFAULT,
pszProvName, &cbProvName);
- ok(result && !strcmp(MS_DEF_PROV, pszProvName), "expected %s, got
%s\n", MS_DEF_PROV, pszProvName);
- ok(result && cbProvName==(strlen(MS_DEF_PROV) + 1), "expected %i, got
%d\n", (lstrlenA(MS_DEF_PROV) + 1), cbProvName);
+ ok(result && !strcmp(MS_DEF_PROV_A, pszProvName), "expected %s, got
%s\n", MS_DEF_PROV_A, pszProvName);
+ ok(result && cbProvName==(strlen(MS_DEF_PROV_A) + 1), "expected %i, got
%d\n", (lstrlenA(MS_DEF_PROV_A) + 1), cbProvName);
LocalFree(pszProvName);
reset:
- /* Set the provider back to it's original */
+ /* Set the provider back to its original */
result = pCryptSetProviderExA(curProvName, PROV_RSA_FULL, NULL,
CRYPT_MACHINE_DEFAULT);
ok(result, "%d\n", GetLastError());
LocalFree(curProvName);
@@ -1026,7 +1026,7 @@
}
SetLastError(0xdeadbeef);
- ret = pCryptAcquireContextA(&provider, NULL, MS_DEF_PROV,
+ ret = pCryptAcquireContextA(&provider, NULL, MS_DEF_PROV_A,
PROV_RSA_FULL, CRYPT_VERIFYCONTEXT);
ok(ret, "CryptAcquireContext error %08x\n", GetLastError());
@@ -1140,6 +1140,38 @@
ok(ret == TRUE, "Expected SystemFunction036 to return TRUE, got %d\n",
ret);
}
+static void test_container_sd(void)
+{
+ HCRYPTPROV prov;
+ SECURITY_DESCRIPTOR *sd;
+ DWORD len, err;
+ BOOL ret;
+
+ ret = CryptAcquireContextA(&prov, "winetest", "Microsoft Enhanced
Cryptographic Provider v1.0",
+ PROV_RSA_FULL, CRYPT_MACHINE_KEYSET|CRYPT_NEWKEYSET);
+ ok(ret, "got %u\n", GetLastError());
+
+ len = 0;
+ SetLastError(0xdeadbeef);
+ ret = CryptGetProvParam(prov, PP_KEYSET_SEC_DESCR, NULL, &len,
OWNER_SECURITY_INFORMATION);
+ err = GetLastError();
+ ok(ret, "got %u\n", err);
+ ok(err == ERROR_INSUFFICIENT_BUFFER || broken(err == ERROR_INVALID_PARAMETER),
"got %u\n", err);
+ ok(len, "expected len > 0\n");
+
+ sd = HeapAlloc(GetProcessHeap(), 0, len);
+ ret = CryptGetProvParam(prov, PP_KEYSET_SEC_DESCR, (BYTE *)sd, &len,
OWNER_SECURITY_INFORMATION);
+ ok(ret, "got %u\n", GetLastError());
+ HeapFree(GetProcessHeap(), 0, sd);
+
+ ret = CryptReleaseContext(prov, 0);
+ ok(ret, "got %u\n", GetLastError());
+
+ ret = CryptAcquireContextA(&prov, "winetest", "Microsoft Enhanced
Cryptographic Provider v1.0",
+ PROV_RSA_FULL, CRYPT_MACHINE_KEYSET|CRYPT_DELETEKEYSET);
+ ok(ret, "got %u\n", GetLastError());
+}
+
START_TEST(crypt)
{
init_function_pointers();
@@ -1151,6 +1183,7 @@
test_incorrect_api_usage();
test_verify_sig();
test_machine_guid();
+ test_container_sd();
clean_up_environment();
}
Modified: trunk/rostests/winetests/advapi32/eventlog.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/advapi32/eventl…
==============================================================================
--- trunk/rostests/winetests/advapi32/eventlog.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/advapi32/eventlog.c [iso-8859-1] Fri Apr 18 21:58:58 2014
@@ -49,17 +49,27 @@
pWow64RevertWow64FsRedirection = (void*)GetProcAddress(hkernel32,
"Wow64RevertWow64FsRedirection");
}
-static void create_backup(const char *filename)
+static BOOL create_backup(const char *filename)
{
HANDLE handle;
+ DWORD rc, attribs;
DeleteFileA(filename);
handle = OpenEventLogA(NULL, "Application");
- BackupEventLogA(handle, filename);
- CloseEventLog(handle);
-
- todo_wine
- ok(GetFileAttributesA(filename) != INVALID_FILE_ATTRIBUTES, "Expected a backup
file\n");
+ rc = BackupEventLogA(handle, filename);
+ if (!rc && GetLastError() == ERROR_PRIVILEGE_NOT_HELD)
+ {
+ skip("insufficient privileges to backup the eventlog\n");
+ CloseEventLog(handle);
+ return FALSE;
+ }
+ ok(rc, "BackupEventLogA failed, le=%u\n", GetLastError());
+ CloseEventLog(handle);
+
+ attribs = GetFileAttributesA(filename);
+ todo_wine
+ ok(attribs != INVALID_FILE_ATTRIBUTES, "Expected a backup file attribs=%#x
le=%u\n", attribs, GetLastError());
+ return TRUE;
}
static void test_open_close(void)
@@ -209,23 +219,24 @@
CloseEventLog(handle);
/* Make a backup eventlog to work with */
- create_backup(backup);
-
- handle = OpenBackupEventLogA(NULL, backup);
- todo_wine
- ok(handle != NULL, "Expected a handle\n");
-
- /* Does GetNumberOfEventLogRecords work with backup eventlogs? */
- count = 0xdeadbeef;
- ret = GetNumberOfEventLogRecords(handle, &count);
- todo_wine
- {
- ok(ret, "Expected success\n");
- ok(count != 0xdeadbeef, "Expected the number of records\n");
- }
-
- CloseEventLog(handle);
- DeleteFileA(backup);
+ if (create_backup(backup))
+ {
+ handle = OpenBackupEventLogA(NULL, backup);
+ todo_wine
+ ok(handle != NULL, "Expected a handle, le=%d\n", GetLastError());
+
+ /* Does GetNumberOfEventLogRecords work with backup eventlogs? */
+ count = 0xdeadbeef;
+ ret = GetNumberOfEventLogRecords(handle, &count);
+ todo_wine
+ {
+ ok(ret, "Expected success\n");
+ ok(count != 0xdeadbeef, "Expected the number of records\n");
+ }
+
+ CloseEventLog(handle);
+ DeleteFileA(backup);
+ }
}
static void test_oldest(void)
@@ -262,23 +273,24 @@
CloseEventLog(handle);
/* Make a backup eventlog to work with */
- create_backup(backup);
-
- handle = OpenBackupEventLogA(NULL, backup);
- todo_wine
- ok(handle != NULL, "Expected a handle\n");
-
- /* Does GetOldestEventLogRecord work with backup eventlogs? */
- oldest = 0xdeadbeef;
- ret = GetOldestEventLogRecord(handle, &oldest);
- todo_wine
- {
- ok(ret, "Expected success\n");
- ok(oldest != 0xdeadbeef, "Expected the number of the oldest record\n");
- }
-
- CloseEventLog(handle);
- DeleteFileA(backup);
+ if (create_backup(backup))
+ {
+ handle = OpenBackupEventLogA(NULL, backup);
+ todo_wine
+ ok(handle != NULL, "Expected a handle\n");
+
+ /* Does GetOldestEventLogRecord work with backup eventlogs? */
+ oldest = 0xdeadbeef;
+ ret = GetOldestEventLogRecord(handle, &oldest);
+ todo_wine
+ {
+ ok(ret, "Expected success\n");
+ ok(oldest != 0xdeadbeef, "Expected the number of the oldest
record\n");
+ }
+
+ CloseEventLog(handle);
+ DeleteFileA(backup);
+ }
}
static void test_backup(void)
@@ -306,6 +318,12 @@
ok(GetLastError() == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER,
got %d\n", GetLastError());
ret = BackupEventLogA(handle, backup);
+ if (!ret && GetLastError() == ERROR_PRIVILEGE_NOT_HELD)
+ {
+ skip("insufficient privileges for backup tests\n");
+ CloseEventLog(handle);
+ return;
+ }
ok(ret, "Expected success\n");
todo_wine
ok(GetFileAttributesA(backup) != INVALID_FILE_ATTRIBUTES, "Expected a backup
file\n");
@@ -516,38 +534,39 @@
"Expected RPC_S_SERVER_UNAVAILABLE, got %d\n", GetLastError());
/* Make a backup eventlog to work with */
- create_backup(backup);
-
- /* FIXME: Wine stops here */
- if (GetFileAttributesA(backup) == INVALID_FILE_ATTRIBUTES)
- {
- skip("We don't have a backup eventlog to work with\n");
- return;
- }
-
- SetLastError(0xdeadbeef);
- handle = OpenBackupEventLogA("IDontExist", backup);
- ok(handle == NULL, "Didn't expect a handle\n");
- ok(GetLastError() == RPC_S_SERVER_UNAVAILABLE ||
- GetLastError() == RPC_S_INVALID_NET_ADDR, /* Some Vista and Win7 */
- "Expected RPC_S_SERVER_UNAVAILABLE, got %d\n", GetLastError());
-
- /* Empty servername should be read as local server */
- handle = OpenBackupEventLogA("", backup);
- ok(handle != NULL, "Expected a handle\n");
- CloseEventLog(handle);
-
- handle = OpenBackupEventLogA(NULL, backup);
- ok(handle != NULL, "Expected a handle\n");
-
- /* Can we open that same backup eventlog more than once? */
- handle2 = OpenBackupEventLogA(NULL, backup);
- ok(handle2 != NULL, "Expected a handle\n");
- ok(handle2 != handle, "Didn't expect the same handle\n");
- CloseEventLog(handle2);
-
- CloseEventLog(handle);
- DeleteFileA(backup);
+ if (create_backup(backup))
+ {
+ /* FIXME: Wine stops here */
+ if (GetFileAttributesA(backup) == INVALID_FILE_ATTRIBUTES)
+ {
+ skip("We don't have a backup eventlog to work with\n");
+ return;
+ }
+
+ SetLastError(0xdeadbeef);
+ handle = OpenBackupEventLogA("IDontExist", backup);
+ ok(handle == NULL, "Didn't expect a handle\n");
+ ok(GetLastError() == RPC_S_SERVER_UNAVAILABLE ||
+ GetLastError() == RPC_S_INVALID_NET_ADDR, /* Some Vista and Win7 */
+ "Expected RPC_S_SERVER_UNAVAILABLE, got %d\n", GetLastError());
+
+ /* Empty servername should be read as local server */
+ handle = OpenBackupEventLogA("", backup);
+ ok(handle != NULL, "Expected a handle\n");
+ CloseEventLog(handle);
+
+ handle = OpenBackupEventLogA(NULL, backup);
+ ok(handle != NULL, "Expected a handle\n");
+
+ /* Can we open that same backup eventlog more than once? */
+ handle2 = OpenBackupEventLogA(NULL, backup);
+ ok(handle2 != NULL, "Expected a handle\n");
+ ok(handle2 != handle, "Didn't expect the same handle\n");
+ CloseEventLog(handle2);
+
+ CloseEventLog(handle);
+ DeleteFileA(backup);
+ }
/* Is there any content checking done? */
file = CreateFileA(backup, GENERIC_WRITE, 0, NULL, CREATE_NEW, 0, NULL);
@@ -585,7 +604,8 @@
ok(GetLastError() == ERROR_INVALID_HANDLE, "Expected ERROR_INVALID_HANDLE, got
%d\n", GetLastError());
/* Make a backup eventlog to work with */
- create_backup(backup);
+ if (!create_backup(backup))
+ return;
SetLastError(0xdeadbeef);
ret = ClearEventLogA(NULL, backup);
@@ -761,11 +781,11 @@
}
SetLastError(0xdeadbeef);
- ret = ReportEvent(handle, 0x20, 0, 0, NULL, 0, 0, NULL, NULL);
+ ret = ReportEventA(handle, 0x20, 0, 0, NULL, 0, 0, NULL, NULL);
if (!ret && GetLastError() == ERROR_CRC)
{
win_skip("Win7 fails when using incorrect event types\n");
- ret = ReportEvent(handle, 0, 0, 0, NULL, 0, 0, NULL, NULL);
+ ret = ReportEventA(handle, 0, 0, 0, NULL, 0, 0, NULL, NULL);
ok(ret, "Expected success : %d\n", GetLastError());
}
else
@@ -822,9 +842,9 @@
ok(handle != NULL, "Expected a handle\n");
SetLastError(0xdeadbeef);
- ret = ReportEvent(handle, read_write[i].evt_type, read_write[i].evt_cat,
- read_write[i].evt_id, run_sidtests ? user : NULL,
- read_write[i].evt_numstrings, 0, read_write[i].evt_strings,
NULL);
+ ret = ReportEventA(handle, read_write[i].evt_type, read_write[i].evt_cat,
+ read_write[i].evt_id, run_sidtests ? user : NULL,
+ read_write[i].evt_numstrings, 0, read_write[i].evt_strings,
NULL);
ok(ret, "Expected ReportEvent success : %d\n", GetLastError());
count = 0xdeadbeef;
Modified: trunk/rostests/winetests/advapi32/lsa.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/advapi32/lsa.c?…
==============================================================================
--- trunk/rostests/winetests/advapi32/lsa.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/advapi32/lsa.c [iso-8859-1] Fri Apr 18 21:58:58 2014
@@ -49,7 +49,7 @@
static BOOL init(void)
{
- hadvapi32 = GetModuleHandle("advapi32.dll");
+ hadvapi32 = GetModuleHandleA("advapi32.dll");
pLsaClose = (void*)GetProcAddress(hadvapi32, "LsaClose");
pLsaEnumerateAccountRights = (void*)GetProcAddress(hadvapi32,
"LsaEnumerateAccountRights");
@@ -378,7 +378,7 @@
ok(ret, "got %d\n", ret);
ret = GetTokenInformation(token, TokenUser, NULL, 0, &size);
- ok(!ret, "gotr %d\n", ret);
+ ok(!ret, "got %d\n", ret);
user = HeapAlloc(GetProcessHeap(), 0, size);
ret = GetTokenInformation(token, TokenUser, user, size, &size);
Modified: trunk/rostests/winetests/advapi32/registry.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/advapi32/regist…
==============================================================================
--- trunk/rostests/winetests/advapi32/registry.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/advapi32/registry.c [iso-8859-1] Fri Apr 18 21:58:58 2014
@@ -1087,8 +1087,8 @@
ok(!ret, "RegCreateKeyExA failed with error %d\n", ret);
/* clean up */
- RegDeleteKey(hkey2, "");
- RegDeleteKey(hkey1, "");
+ RegDeleteKeyA(hkey2, "");
+ RegDeleteKeyA(hkey1, "");
RegCloseKey(hkey2);
RegCloseKey(hkey1);
@@ -1106,8 +1106,8 @@
ok(!ret, "RegCreateKeyExA failed with error %d\n", ret);
/* clean up */
- RegDeleteKey(hkey2, "");
- RegDeleteKey(hkey1, "");
+ RegDeleteKeyA(hkey2, "");
+ RegDeleteKeyA(hkey1, "");
RegCloseKey(hkey2);
RegCloseKey(hkey1);
@@ -1117,7 +1117,7 @@
ok(ret == ERROR_BAD_PATHNAME, "expected ERROR_BAD_PATHNAME, got %d\n",
ret);
else {
ok(!ret, "RegCreateKeyExA failed with error %d\n", ret);
- RegDeleteKey(hkey1, NULL);
+ RegDeleteKeyA(hkey1, NULL);
RegCloseKey(hkey1);
}
@@ -1251,7 +1251,7 @@
{
DWORD ret;
- ret = RegDeleteKey(hkey_main, NULL);
+ ret = RegDeleteKeyA(hkey_main, NULL);
/* There is a bug in NT4 and W2K that doesn't check if the subkey is NULL. If
* there are also no subkeys available it will delete the key pointed to by
hkey_main.
@@ -1274,7 +1274,7 @@
{
DWORD ret;
- ret = RegSaveKey(hkey_main, "saved_key", NULL);
+ ret = RegSaveKeyA(hkey_main, "saved_key", NULL);
ok(ret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %d\n", ret);
}
@@ -1283,10 +1283,10 @@
DWORD ret;
HKEY hkHandle;
- ret = RegLoadKey(HKEY_LOCAL_MACHINE, "Test", "saved_key");
+ ret = RegLoadKeyA(HKEY_LOCAL_MACHINE, "Test", "saved_key");
ok(ret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %d\n", ret);
- ret = RegOpenKey(HKEY_LOCAL_MACHINE, "Test", &hkHandle);
+ ret = RegOpenKeyA(HKEY_LOCAL_MACHINE, "Test", &hkHandle);
ok(ret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %d\n", ret);
RegCloseKey(hkHandle);
@@ -1296,11 +1296,11 @@
{
DWORD ret;
- ret = RegUnLoadKey(HKEY_LOCAL_MACHINE, "Test");
+ ret = RegUnLoadKeyA(HKEY_LOCAL_MACHINE, "Test");
ok(ret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %d\n", ret);
- DeleteFile("saved_key");
- DeleteFile("saved_key.LOG");
+ DeleteFileA("saved_key");
+ DeleteFileA("saved_key.LOG");
}
static BOOL set_privileges(LPCSTR privilege, BOOL set)
@@ -1312,7 +1312,7 @@
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &hToken))
return FALSE;
- if(!LookupPrivilegeValue(NULL, privilege, &luid))
+ if(!LookupPrivilegeValueA(NULL, privilege, &luid))
{
CloseHandle(hToken);
return FALSE;
@@ -1668,7 +1668,7 @@
{
HKEY hKey;
DWORD dw = 0;
- static char keyname[] = "test_rw_order";
+ static const char keyname[] = "test_rw_order";
char value_buf[2];
DWORD values, value_len, value_name_max_len;
LSTATUS ret;
@@ -1707,7 +1707,7 @@
ok(!RegEnumValueA(hKey, 3, value_buf, &value_len, NULL, NULL, NULL, NULL),
"RegEnumValueA failed\n");
todo_wine ok(strcmp(value_buf, "B") == 0, "Expected name
\"B\", got %s\n", value_buf);
- ok(!RegDeleteKey(HKEY_CURRENT_USER, keyname), "Failed to delete key\n");
+ ok(!RegDeleteKeyA(HKEY_CURRENT_USER, keyname), "Failed to delete key\n");
}
static void test_symlinks(void)
@@ -1825,10 +1825,10 @@
KEY_ALL_ACCESS, NULL, &key, NULL );
ok( err == ERROR_ALREADY_EXISTS, "RegCreateKeyEx wrong error %u\n", err );
- err = RegDeleteKey( hkey_main, "target" );
+ err = RegDeleteKeyA( hkey_main, "target" );
ok( err == ERROR_SUCCESS, "RegDeleteKey failed error %u\n", err );
- err = RegDeleteKey( hkey_main, "link" );
+ err = RegDeleteKeyA( hkey_main, "link" );
ok( err == ERROR_FILE_NOT_FOUND, "RegDeleteKey wrong error %u\n", err );
status = pNtDeleteKey( link );
@@ -1867,8 +1867,9 @@
static void test_redirection(void)
{
DWORD err, type, dw, len;
- HKEY key, root32, root64, key32, key64;
+ HKEY key, root32, root64, key32, key64, native, op_key;
BOOL is_vista = FALSE;
+ REGSAM opposite = (sizeof(void*) == 8 ? KEY_WOW64_32KEY : KEY_WOW64_64KEY);
if (ptr_size != 64)
{
@@ -2102,6 +2103,39 @@
RegCloseKey( key64 );
RegCloseKey( root32 );
RegCloseKey( root64 );
+
+ /* open key in native bit mode */
+ err = RegOpenKeyExA(HKEY_CLASSES_ROOT, "Interface", 0, KEY_ALL_ACCESS,
&native);
+ ok(err == ERROR_SUCCESS, "got %i\n", err);
+
+ pRegDeleteKeyExA(native, "AWineTest", 0, 0);
+
+ /* write subkey in opposite bit mode */
+ err = RegOpenKeyExA(HKEY_CLASSES_ROOT, "Interface", 0, KEY_ALL_ACCESS |
opposite, &op_key);
+ ok(err == ERROR_SUCCESS, "got %i\n", err);
+
+ err = RegCreateKeyExA(op_key, "AWineTest", 0, NULL, 0, KEY_ALL_ACCESS |
opposite,
+ NULL, &key, NULL);
+ ok(err == ERROR_SUCCESS || err == ERROR_ACCESS_DENIED, "got %i\n", err);
+ if(err != ERROR_SUCCESS){
+ win_skip("Can't write to registry\n");
+ RegCloseKey(op_key);
+ RegCloseKey(native);
+ return;
+ }
+ RegCloseKey(key);
+
+ /* verify subkey is not present in native mode */
+ err = RegOpenKeyExA(native, "AWineTest", 0, KEY_ALL_ACCESS, &key);
+ ok(err == ERROR_FILE_NOT_FOUND ||
+ broken(err == ERROR_SUCCESS), /* before Win7, HKCR is reflected instead of
redirected */
+ "got %i\n", err);
+
+ err = pRegDeleteKeyExA(op_key, "AWineTest", opposite, 0);
+ ok(err == ERROR_SUCCESS, "got %i\n", err);
+
+ RegCloseKey(op_key);
+ RegCloseKey(native);
}
static void test_classesroot(void)
@@ -2133,7 +2167,6 @@
todo_wine ok(res == ERROR_SUCCESS ||
broken(res == ERROR_FILE_NOT_FOUND /* WinNT */),
"test key not found in hkcr: %d\n", res);
- todo_wine ok(IS_HKCR(hkcr), "hkcr mask not set in %p\n", hkcr);
if (res)
{
skip("HKCR key merging not supported\n");
@@ -2141,6 +2174,8 @@
RegCloseKey( hkey );
return;
}
+
+ todo_wine ok(IS_HKCR(hkcr), "hkcr mask not set in %p\n", hkcr);
/* set a value in user's classes */
res = RegSetValueExA(hkey, "val1", 0, REG_SZ, (const BYTE
*)"user", sizeof("user"));
@@ -2364,7 +2399,7 @@
RegCloseKey( hklmsub1 );
/* delete subkey1 from hkcr (should point at user's classes) */
- res = RegDeleteKey(hkcr, "subkey1");
+ res = RegDeleteKeyA(hkcr, "subkey1");
ok(res == ERROR_SUCCESS, "RegDeleteKey failed: %d\n", res);
/* confirm key was removed in hkey but not hklm */
@@ -2375,7 +2410,7 @@
ok(!IS_HKCR(hklmsub1), "hkcr mask set in %p\n", hklmsub1);
/* delete subkey1 from hkcr again (which should now point at hklm) */
- res = RegDeleteKey(hkcr, "subkey1");
+ res = RegDeleteKeyA(hkcr, "subkey1");
ok(res == ERROR_SUCCESS, "RegDeleteKey failed: %d\n", res);
/* confirm hkey was removed in hklm */
@@ -2586,7 +2621,8 @@
res = RegOpenKeyA( HKEY_CLASSES_ROOT, "CLSID", &hkey );
ok(res == ERROR_SUCCESS, "RegOpenKeyA failed: %d\n", res);
- todo_wine ok(IS_HKCR(hkey), "hkcr mask not set in %p\n", hkey);
+ todo_wine ok(IS_HKCR(hkey) || broken(!IS_HKCR(hkey)) /* WinNT */,
+ "hkcr mask not set in %p\n", hkey);
RegCloseKey( hkey );
res = RegOpenKeyA( HKEY_CURRENT_USER, "Software", &hkey );
Modified: trunk/rostests/winetests/advapi32/security.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/advapi32/securi…
==============================================================================
--- trunk/rostests/winetests/advapi32/security.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/advapi32/security.c [iso-8859-1] Fri Apr 18 21:58:58 2014
@@ -38,12 +38,29 @@
#include "wine/test.h"
+#ifndef PROCESS_QUERY_LIMITED_INFORMATION
+#define PROCESS_QUERY_LIMITED_INFORMATION 0x1000
+#endif
+
/* PROCESS_ALL_ACCESS in Vista+ PSDKs is incompatible with older Windows versions */
#define PROCESS_ALL_ACCESS_NT4 (PROCESS_ALL_ACCESS & ~0xf000)
+#define PROCESS_ALL_ACCESS_VISTA (PROCESS_ALL_ACCESS | 0xf000)
#ifndef EVENT_QUERY_STATE
#define EVENT_QUERY_STATE 0x0001
#endif
+
+#ifndef SEMAPHORE_QUERY_STATE
+#define SEMAPHORE_QUERY_STATE 0x0001
+#endif
+
+#ifndef THREAD_SET_LIMITED_INFORMATION
+#define THREAD_SET_LIMITED_INFORMATION 0x0400
+#define THREAD_QUERY_LIMITED_INFORMATION 0x0800
+#endif
+
+#define THREAD_ALL_ACCESS_NT4 (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3ff)
+#define THREAD_ALL_ACCESS_VISTA (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0xffff)
/* copied from Wine winternl.h - not included in the Windows SDK */
typedef enum _OBJECT_INFORMATION_CLASS {
@@ -104,7 +121,7 @@
static DWORD (WINAPI *pGetNamedSecurityInfoA)(LPSTR, SE_OBJECT_TYPE,
SECURITY_INFORMATION,
PSID*, PSID*, PACL*, PACL*,
PSECURITY_DESCRIPTOR*);
-static DWORD (WINAPI *pSetNamedSecurityInfoA)(LPTSTR, SE_OBJECT_TYPE,
SECURITY_INFORMATION,
+static DWORD (WINAPI *pSetNamedSecurityInfoA)(LPSTR, SE_OBJECT_TYPE,
SECURITY_INFORMATION,
PSID, PSID, PACL, PACL);
static PDWORD (WINAPI *pGetSidSubAuthority)(PSID, DWORD);
static PUCHAR (WINAPI *pGetSidSubAuthorityCount)(PSID);
@@ -160,7 +177,7 @@
pNtQueryObject = (void *)GetProcAddress( hntdll, "NtQueryObject" );
pNtAccessCheck = (void *)GetProcAddress( hntdll, "NtAccessCheck" );
- hmod = GetModuleHandle("advapi32.dll");
+ hmod = GetModuleHandleA("advapi32.dll");
pAddAccessAllowedAceEx = (void *)GetProcAddress(hmod,
"AddAccessAllowedAceEx");
pAddAccessDeniedAceEx = (void *)GetProcAddress(hmod,
"AddAccessDeniedAceEx");
pAddAuditAccessAceEx = (void *)GetProcAddress(hmod,
"AddAuditAccessAceEx");
@@ -345,9 +362,9 @@
GUID ObjectType = {0x12345678, 0x1234, 0x5678, {0x11, 0x22, 0x33, 0x44, 0x55, 0x66,
0x77, 0x88}};
GUID InheritedObjectType = {0x23456789, 0x2345, 0x6786, {0x2, 0x33, 0x44, 0x55, 0x66,
0x77, 0x88, 0x99}};
GUID ZeroGuid;
- OBJECTS_AND_NAME_ oan;
+ OBJECTS_AND_NAME_A oan;
OBJECTS_AND_SID oas;
- TRUSTEE trustee;
+ TRUSTEEA trustee;
PSID psid;
char szObjectTypeName[] = "ObjectTypeName";
char szInheritedObjectTypeName[] = "InheritedObjectTypeName";
@@ -443,7 +460,7 @@
ok(trustee.MultipleTrusteeOperation == NO_MULTIPLE_TRUSTEE,
"MultipleTrusteeOperation wrong\n");
ok(trustee.TrusteeForm == TRUSTEE_IS_OBJECTS_AND_NAME, "TrusteeForm
wrong\n");
ok(trustee.TrusteeType == TRUSTEE_IS_UNKNOWN, "TrusteeType wrong\n");
- ok(trustee.ptstrName == (LPTSTR)&oan, "ptstrName wrong\n");
+ ok(trustee.ptstrName == (LPSTR)&oan, "ptstrName wrong\n");
ok(oan.ObjectsPresent == (ACE_OBJECT_TYPE_PRESENT |
ACE_INHERITED_OBJECT_TYPE_PRESENT), "ObjectsPresent wrong\n");
ok(oan.ObjectType == SE_KERNEL_OBJECT, "ObjectType wrong\n");
@@ -480,7 +497,7 @@
ok(trustee.MultipleTrusteeOperation == NO_MULTIPLE_TRUSTEE,
"MultipleTrusteeOperation wrong\n");
ok(trustee.TrusteeForm == TRUSTEE_IS_OBJECTS_AND_NAME, "TrusteeForm
wrong\n");
ok(trustee.TrusteeType == TRUSTEE_IS_UNKNOWN, "TrusteeType wrong\n");
- ok(trustee.ptstrName == (LPTSTR)&oan, "ptstrName wrong\n");
+ ok(trustee.ptstrName == (LPSTR)&oan, "ptstrName wrong\n");
ok(oan.ObjectsPresent == ACE_OBJECT_TYPE_PRESENT, "ObjectsPresent
wrong\n");
ok(oan.ObjectType == SE_KERNEL_OBJECT, "ObjectType wrong\n");
@@ -833,20 +850,20 @@
/* Test file access permissions for a file with FILE_ATTRIBUTE_ARCHIVE */
SetLastError(0xdeadbeef);
- rc = GetTempPath(sizeof(wintmpdir), wintmpdir);
+ rc = GetTempPathA(sizeof(wintmpdir), wintmpdir);
ok(rc, "GetTempPath error %d\n", GetLastError());
SetLastError(0xdeadbeef);
- rc = GetTempFileName(wintmpdir, "tmp", 0, file);
+ rc = GetTempFileNameA(wintmpdir, "tmp", 0, file);
ok(rc, "GetTempFileName error %d\n", GetLastError());
- rc = GetFileAttributes(file);
- rc &= ~FILE_ATTRIBUTE_NOT_CONTENT_INDEXED;
+ rc = GetFileAttributesA(file);
+ rc &= ~(FILE_ATTRIBUTE_NOT_CONTENT_INDEXED|FILE_ATTRIBUTE_COMPRESSED);
ok(rc == FILE_ATTRIBUTE_ARCHIVE, "expected FILE_ATTRIBUTE_ARCHIVE got
%#x\n", rc);
retSize = 0xdeadbeef;
- rc = GetFileSecurity(file,
OWNER_SECURITY_INFORMATION|GROUP_SECURITY_INFORMATION|DACL_SECURITY_INFORMATION,
- NULL, 0, &sdSize);
+ rc = GetFileSecurityA(file,
OWNER_SECURITY_INFORMATION|GROUP_SECURITY_INFORMATION|DACL_SECURITY_INFORMATION,
+ NULL, 0, &sdSize);
ok(!rc, "GetFileSecurity should fail\n");
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
"expected ERROR_INSUFFICIENT_BUFFER got %d\n", GetLastError());
@@ -855,8 +872,8 @@
sd = HeapAlloc(GetProcessHeap (), 0, sdSize);
retSize = 0xdeadbeef;
SetLastError(0xdeadbeef);
- rc = GetFileSecurity(file,
OWNER_SECURITY_INFORMATION|GROUP_SECURITY_INFORMATION|DACL_SECURITY_INFORMATION,
- sd, sdSize, &retSize);
+ rc = GetFileSecurityA(file,
OWNER_SECURITY_INFORMATION|GROUP_SECURITY_INFORMATION|DACL_SECURITY_INFORMATION,
+ sd, sdSize, &retSize);
ok(rc, "GetFileSecurity error %d\n", GetLastError());
ok(retSize == sdSize || broken(retSize == 0) /* NT4 */, "expected %d, got
%d\n", sdSize, retSize);
@@ -941,7 +958,7 @@
/* Test file access permissions for a file with FILE_ATTRIBUTE_READONLY */
SetLastError(0xdeadbeef);
- fh = CreateFile(file, FILE_READ_DATA, FILE_SHARE_READ, NULL, CREATE_ALWAYS,
FILE_ATTRIBUTE_READONLY, 0);
+ fh = CreateFileA(file, FILE_READ_DATA, FILE_SHARE_READ, NULL, CREATE_ALWAYS,
FILE_ATTRIBUTE_READONLY, 0);
ok(fh != INVALID_HANDLE_VALUE, "CreateFile error %d\n", GetLastError());
retSize = 0xdeadbeef;
SetLastError(0xdeadbeef);
@@ -951,21 +968,21 @@
ok(retSize == 0, "expected 0, got %d\n", retSize);
CloseHandle(fh);
- rc = GetFileAttributes(file);
- rc &= ~FILE_ATTRIBUTE_NOT_CONTENT_INDEXED;
+ rc = GetFileAttributesA(file);
+ rc &= ~(FILE_ATTRIBUTE_NOT_CONTENT_INDEXED|FILE_ATTRIBUTE_COMPRESSED);
todo_wine
ok(rc == (FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_READONLY),
"expected FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_READONLY got %#x\n",
rc);
SetLastError(0xdeadbeef);
- rc = SetFileAttributes(file, FILE_ATTRIBUTE_ARCHIVE);
+ rc = SetFileAttributesA(file, FILE_ATTRIBUTE_ARCHIVE);
ok(rc, "SetFileAttributes error %d\n", GetLastError());
SetLastError(0xdeadbeef);
- rc = DeleteFile(file);
+ rc = DeleteFileA(file);
ok(rc, "DeleteFile error %d\n", GetLastError());
SetLastError(0xdeadbeef);
- fh = CreateFile(file, FILE_READ_DATA, FILE_SHARE_READ, NULL, CREATE_ALWAYS,
FILE_ATTRIBUTE_READONLY, 0);
+ fh = CreateFileA(file, FILE_READ_DATA, FILE_SHARE_READ, NULL, CREATE_ALWAYS,
FILE_ATTRIBUTE_READONLY, 0);
ok(fh != INVALID_HANDLE_VALUE, "CreateFile error %d\n", GetLastError());
retSize = 0xdeadbeef;
SetLastError(0xdeadbeef);
@@ -975,15 +992,15 @@
ok(retSize == 0, "expected 0, got %d\n", retSize);
CloseHandle(fh);
- rc = GetFileAttributes(file);
- rc &= ~FILE_ATTRIBUTE_NOT_CONTENT_INDEXED;
+ rc = GetFileAttributesA(file);
+ rc &= ~(FILE_ATTRIBUTE_NOT_CONTENT_INDEXED|FILE_ATTRIBUTE_COMPRESSED);
ok(rc == (FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_READONLY),
"expected FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_READONLY got %#x\n",
rc);
retSize = 0xdeadbeef;
SetLastError(0xdeadbeef);
- rc = GetFileSecurity(file,
OWNER_SECURITY_INFORMATION|GROUP_SECURITY_INFORMATION|DACL_SECURITY_INFORMATION,
- sd, sdSize, &retSize);
+ rc = GetFileSecurityA(file,
OWNER_SECURITY_INFORMATION|GROUP_SECURITY_INFORMATION|DACL_SECURITY_INFORMATION,
+ sd, sdSize, &retSize);
ok(rc, "GetFileSecurity error %d\n", GetLastError());
ok(retSize == sdSize || broken(retSize == 0) /* NT4 */, "expected %d, got
%d\n", sdSize, retSize);
@@ -1050,14 +1067,14 @@
ok(granted == FILE_ALL_ACCESS, "expected FILE_ALL_ACCESS, got %#x\n",
granted);
}
SetLastError(0xdeadbeef);
- rc = DeleteFile(file);
+ rc = DeleteFileA(file);
ok(!rc, "DeleteFile should fail\n");
ok(GetLastError() == ERROR_ACCESS_DENIED, "expected ERROR_ACCESS_DENIED, got
%d\n", GetLastError());
SetLastError(0xdeadbeef);
- rc = SetFileAttributes(file, FILE_ATTRIBUTE_ARCHIVE);
+ rc = SetFileAttributesA(file, FILE_ATTRIBUTE_ARCHIVE);
ok(rc, "SetFileAttributes error %d\n", GetLastError());
SetLastError(0xdeadbeef);
- rc = DeleteFile(file);
+ rc = DeleteFileA(file);
ok(rc, "DeleteFile error %d\n", GetLastError());
CloseHandle(token);
@@ -1085,7 +1102,7 @@
DWORD err;
NTSTATUS ntret, ntAccessStatus;
- NtDllModule = GetModuleHandle("ntdll.dll");
+ NtDllModule = GetModuleHandleA("ntdll.dll");
if (!NtDllModule)
{
skip("not running on NT, skipping test\n");
@@ -1493,13 +1510,13 @@
for (i = 0; i < Groups->GroupCount; i++)
{
DWORD NameLength = 255;
- TCHAR Name[255];
+ CHAR Name[255];
DWORD DomainLength = 255;
- TCHAR Domain[255];
+ CHAR Domain[255];
SID_NAME_USE SidNameUse;
Name[0] = '\0';
Domain[0] = '\0';
- ret = LookupAccountSid(NULL, Groups->Groups[i].Sid, Name, &NameLength,
Domain, &DomainLength, &SidNameUse);
+ ret = LookupAccountSidA(NULL, Groups->Groups[i].Sid, Name, &NameLength,
Domain, &DomainLength, &SidNameUse);
if (ret)
{
pConvertSidToStringSidA(Groups->Groups[i].Sid, &SidString);
@@ -1535,9 +1552,9 @@
trace("TokenPrivileges:\n");
for (i = 0; i < Privileges->PrivilegeCount; i++)
{
- TCHAR Name[256];
+ CHAR Name[256];
DWORD NameLen = sizeof(Name)/sizeof(Name[0]);
- LookupPrivilegeName(NULL, &Privileges->Privileges[i].Luid, Name,
&NameLen);
+ LookupPrivilegeNameA(NULL, &Privileges->Privileges[i].Luid, Name,
&NameLen);
trace("\t%s, 0x%x\n", Name, Privileges->Privileges[i].Attributes);
}
HeapFree(GetProcessHeap(), 0, Privileges);
@@ -1618,7 +1635,7 @@
SID_NAME_USE use;
DWORD acc_size = MAX_PATH;
DWORD dom_size = MAX_PATH;
- ret = LookupAccountSid(NULL, sid, account, &acc_size, domain, &dom_size,
&use);
+ ret = LookupAccountSidA (NULL, sid, account, &acc_size, domain,
&dom_size, &use);
ok(ret || (!ret && (GetLastError() == ERROR_NONE_MAPPED)),
"LookupAccountSid(%s) failed: %d\n", str_sid, GetLastError());
if (ret)
@@ -2120,8 +2137,8 @@
ok(EqualSid(psid,wk_sid),"(%s) Sids fail to match well known
sid!\n",name);
- ok(!lstrcmp(account, wk_account), "Expected %s , got %s\n", account,
wk_account);
- ok(!lstrcmp(domain, wk_domain), "Expected %s, got %s\n", wk_domain,
domain);
+ ok(!lstrcmpA(account, wk_account), "Expected %s , got %s\n", account,
wk_account);
+ ok(!lstrcmpA(domain, wk_domain), "Expected %s, got %s\n", wk_domain,
domain);
ok(sid_use == SidTypeWellKnownGroup , "Expected Use (5), got %d\n",
sid_use);
cleanup:
@@ -2182,10 +2199,10 @@
get_sid_info(psid, &account, &sid_dom);
ok(ret, "Failed to lookup account name\n");
ok(sid_size == GetLengthSid(psid), "Expected %d, got %d\n",
GetLengthSid(psid), sid_size);
- ok(!lstrcmp(account, user_name), "Expected %s, got %s\n", user_name,
account);
- ok(!lstrcmp(domain, sid_dom), "Expected %s, got %s\n", sid_dom, domain);
+ ok(!lstrcmpA(account, user_name), "Expected %s, got %s\n", user_name,
account);
+ ok(!lstrcmpA(domain, sid_dom), "Expected %s, got %s\n", sid_dom, domain);
ok(domain_size == domain_save - 1, "Expected %d, got %d\n", domain_save -
1, domain_size);
- ok(strlen(domain) == domain_size, "Expected %d, got %d\n", lstrlen(domain),
domain_size);
+ ok(strlen(domain) == domain_size, "Expected %d, got %d\n",
lstrlenA(domain), domain_size);
ok(sid_use == SidTypeUser, "Expected SidTypeUser (%d), got %d\n",
SidTypeUser, sid_use);
domain_size = domain_save;
sid_size = sid_save;
@@ -2200,10 +2217,10 @@
get_sid_info(psid, &account, &sid_dom);
ok(ret, "Failed to lookup account name\n");
ok(sid_size != 0, "sid_size was zero\n");
- ok(!lstrcmp(account, "Everyone"), "Expected Everyone, got
%s\n", account);
- ok(!lstrcmp(domain, sid_dom), "Expected %s, got %s\n", sid_dom,
domain);
+ ok(!lstrcmpA(account, "Everyone"), "Expected Everyone, got
%s\n", account);
+ ok(!lstrcmpA(domain, sid_dom), "Expected %s, got %s\n", sid_dom,
domain);
ok(domain_size == 0, "Expected 0, got %d\n", domain_size);
- ok(strlen(domain) == domain_size, "Expected %d, got %d\n",
lstrlen(domain), domain_size);
+ ok(strlen(domain) == domain_size, "Expected %d, got %d\n",
lstrlenA(domain), domain_size);
ok(sid_use == SidTypeWellKnownGroup, "Expected SidTypeWellKnownGroup (%d),
got %d\n", SidTypeWellKnownGroup, sid_use);
domain_size = domain_save;
}
@@ -2266,7 +2283,7 @@
get_sid_info(psid, &account, &sid_dom);
ok(ret, "Failed to lookup account name\n");
/* Using a fixed string will not work on different locales */
- ok(!lstrcmp(account, domain),
+ ok(!lstrcmpA(account, domain),
"Got %s for account and %s for domain, these should be the same\n",
account, domain);
ok(sid_use == SidTypeDomain, "Expected SidTypeDomain (%d), got %d\n",
SidTypeDomain, sid_use);
@@ -2522,7 +2539,7 @@
res = InitializeSecurityDescriptor(SecurityDescriptor,
SECURITY_DESCRIPTOR_REVISION);
ok(res, "InitializeSecurityDescriptor failed with error %d\n",
GetLastError());
- event = CreateEvent( NULL, TRUE, TRUE, "test_event" );
+ event = CreateEventA( NULL, TRUE, TRUE, "test_event" );
ok(event != NULL, "CreateEvent %d\n", GetLastError());
SecurityDescriptor->Revision = 0;
@@ -2664,9 +2681,9 @@
ok(error == ERROR_CANT_OPEN_ANONYMOUS, "OpenThreadToken on anonymous token
should have returned ERROR_CANT_OPEN_ANONYMOUS instead of %d\n", error);
/* can't perform access check when opening object against an anonymous
impersonation token */
todo_wine {
- error = RegOpenKeyEx(HKEY_CURRENT_USER, "Software", 0, KEY_READ,
&hkey);
- ok(error == ERROR_INVALID_HANDLE || error == ERROR_CANT_OPEN_ANONYMOUS,
- "RegOpenKeyEx should have failed with ERROR_INVALID_HANDLE or
ERROR_CANT_OPEN_ANONYMOUS instead of %d\n", error);
+ error = RegOpenKeyExA(HKEY_CURRENT_USER, "Software", 0, KEY_READ,
&hkey);
+ ok(error == ERROR_INVALID_HANDLE || error == ERROR_CANT_OPEN_ANONYMOUS || error ==
ERROR_BAD_IMPERSONATION_LEVEL,
+ "RegOpenKeyEx failed with %d\n", error);
}
RevertToSelf();
@@ -2717,7 +2734,7 @@
ok(ret, "OpenThreadToken failed with error %d\n", GetLastError());
/* can't perform access check when opening object against an identification
impersonation token */
- error = RegOpenKeyEx(HKEY_CURRENT_USER, "Software", 0, KEY_READ,
&hkey);
+ error = RegOpenKeyExA(HKEY_CURRENT_USER, "Software", 0, KEY_READ,
&hkey);
todo_wine {
ok(error == ERROR_INVALID_HANDLE || error == ERROR_BAD_IMPERSONATION_LEVEL,
"RegOpenKeyEx should have failed with ERROR_INVALID_HANDLE or
ERROR_BAD_IMPERSONATION_LEVEL instead of %d\n", error);
@@ -2731,7 +2748,7 @@
ok(ret, "ImpersonateSelf(SecurityImpersonation) failed with error %d\n",
GetLastError());
ret = OpenThreadToken(GetCurrentThread(), TOKEN_QUERY | TOKEN_ADJUST_PRIVILEGES |
TOKEN_QUERY_SOURCE | TOKEN_IMPERSONATE | TOKEN_ADJUST_DEFAULT, TRUE, &Token);
ok(ret, "OpenThreadToken failed with error %d\n", GetLastError());
- error = RegOpenKeyEx(HKEY_CURRENT_USER, "Software", 0, KEY_READ,
&hkey);
+ error = RegOpenKeyExA(HKEY_CURRENT_USER, "Software", 0, KEY_READ,
&hkey);
ok(error == ERROR_SUCCESS, "RegOpenKeyEx should have succeeded instead of
failing with %d\n", error);
RegCloseKey(hkey);
ret = PrivilegeCheck(Token, PrivilegeSet, &AccessGranted);
@@ -2882,7 +2899,7 @@
PACL OldAcl = NULL, NewAcl;
SID_IDENTIFIER_AUTHORITY SIDAuthWorld = { SECURITY_WORLD_SID_AUTHORITY };
SID_IDENTIFIER_AUTHORITY SIDAuthNT = { SECURITY_NT_AUTHORITY };
- EXPLICIT_ACCESS ExplicitAccess;
+ EXPLICIT_ACCESSA ExplicitAccess;
static const CHAR szEveryone[] =
{'E','v','e','r','y','o','n','e',0};
static const CHAR szCurrentUser[] = {
'C','U','R','R','E','N','T','_','U','S','E','R','\0'};
@@ -3004,6 +3021,117 @@
FreeSid(UsersSid);
FreeSid(EveryoneSid);
HeapFree(GetProcessHeap(), 0, OldAcl);
+}
+
+static void test_CreateDirectoryA(void)
+{
+ char admin_ptr[sizeof(SID)+sizeof(ULONG)*SID_MAX_SUB_AUTHORITIES], *user;
+ DWORD sid_size = sizeof(admin_ptr), user_size;
+ PSID admin_sid = (PSID) admin_ptr, user_sid;
+ char sd[SECURITY_DESCRIPTOR_MIN_LENGTH];
+ PSECURITY_DESCRIPTOR pSD = &sd;
+ ACL_SIZE_INFORMATION acl_size;
+ ACCESS_ALLOWED_ACE *ace;
+ SECURITY_ATTRIBUTES sa;
+ char tmpdir[MAX_PATH];
+ struct _SID *owner;
+ BOOL bret = TRUE;
+ HANDLE token;
+ DWORD error;
+ PACL pDacl;
+
+ if (!pGetNamedSecurityInfoA || !pCreateWellKnownSid)
+ {
+ win_skip("Required functions are not available\n");
+ return;
+ }
+
+ if (!OpenThreadToken(GetCurrentThread(), TOKEN_READ, TRUE, &token))
+ {
+ if (GetLastError() != ERROR_NO_TOKEN) bret = FALSE;
+ else if (!OpenProcessToken(GetCurrentProcess(), TOKEN_READ, &token)) bret =
FALSE;
+ }
+ if (!bret)
+ {
+ win_skip("Failed to get current user token\n");
+ return;
+ }
+ bret = GetTokenInformation(token, TokenUser, NULL, 0, &user_size);
+ ok(!bret && (GetLastError() == ERROR_INSUFFICIENT_BUFFER),
+ "GetTokenInformation(TokenUser) failed with error %d\n",
GetLastError());
+ user = HeapAlloc(GetProcessHeap(), 0, user_size);
+ bret = GetTokenInformation(token, TokenUser, user, user_size, &user_size);
+ ok(bret, "GetTokenInformation(TokenUser) failed with error %d\n",
GetLastError());
+ CloseHandle( token );
+ user_sid = ((TOKEN_USER *)user)->User.Sid;
+
+ sa.nLength = sizeof(sa);
+ sa.lpSecurityDescriptor = pSD;
+ sa.bInheritHandle = TRUE;
+ InitializeSecurityDescriptor(pSD, SECURITY_DESCRIPTOR_REVISION);
+ pCreateWellKnownSid(WinBuiltinAdministratorsSid, NULL, admin_sid, &sid_size);
+ pDacl = HeapAlloc(GetProcessHeap(), 0, 100);
+ bret = InitializeAcl(pDacl, 100, ACL_REVISION);
+ ok(bret, "Failed to initialize ACL.\n");
+ bret = pAddAccessAllowedAceEx(pDacl, ACL_REVISION,
OBJECT_INHERIT_ACE|CONTAINER_INHERIT_ACE,
+ GENERIC_ALL, user_sid);
+ ok(bret, "Failed to add Current User to ACL.\n");
+ bret = pAddAccessAllowedAceEx(pDacl, ACL_REVISION,
OBJECT_INHERIT_ACE|CONTAINER_INHERIT_ACE,
+ 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");
+
+ GetTempPathA(MAX_PATH, tmpdir);
+ lstrcatA(tmpdir, "Please Remove Me");
+ bret = CreateDirectoryA(tmpdir, &sa);
+ ok(bret == TRUE, "CreateDirectoryA(%s) failed err=%d\n", tmpdir,
GetLastError());
+ HeapFree(GetProcessHeap(), 0, pDacl);
+
+ SetLastError(0xdeadbeef);
+ error = pGetNamedSecurityInfoA(tmpdir, SE_FILE_OBJECT,
+ OWNER_SECURITY_INFORMATION|DACL_SECURITY_INFORMATION,
(PSID*)&owner,
+ NULL, &pDacl, NULL, &pSD);
+ if (error != ERROR_SUCCESS && (GetLastError() ==
ERROR_CALL_NOT_IMPLEMENTED))
+ {
+ win_skip("GetNamedSecurityInfoA is not implemented\n");
+ goto done;
+ }
+ ok(!error, "GetNamedSecurityInfo failed with error %d\n", error);
+
+ bret = pGetAclInformation(pDacl, &acl_size, sizeof(acl_size),
AclSizeInformation);
+ ok(bret, "GetAclInformation failed\n");
+ ok(acl_size.AceCount == 2, "GetAclInformation returned unexpected entry count
(%d != 2).\n",
+ acl_size.AceCount);
+ if (acl_size.AceCount > 0)
+ {
+ bret = pGetAce(pDacl, 0, (VOID **)&ace);
+ ok(bret, "Failed to get Current User ACE.\n");
+ bret = EqualSid(&ace->SidStart, user_sid);
+ todo_wine ok(bret, "Current User ACE != Current User SID.\n");
+ todo_wine ok(((ACE_HEADER *)ace)->AceFlags ==
(OBJECT_INHERIT_ACE|CONTAINER_INHERIT_ACE),
+ "Current User ACE has unexpected flags (0x%x != 0x03)\n",
+ ((ACE_HEADER *)ace)->AceFlags);
+ ok(ace->Mask == 0x1f01ff, "Current User ACE has unexpected mask (0x%x !=
0x1f01ff)\n",
+ ace->Mask);
+ }
+ if (acl_size.AceCount > 1)
+ {
+ bret = pGetAce(pDacl, 1, (VOID **)&ace);
+ ok(bret, "Failed to get Administators Group ACE.\n");
+ bret = EqualSid(&ace->SidStart, admin_sid);
+ todo_wine ok(bret, "Administators Group ACE != Administators Group
SID.\n");
+ todo_wine ok(((ACE_HEADER *)ace)->AceFlags ==
(OBJECT_INHERIT_ACE|CONTAINER_INHERIT_ACE),
+ "Administators Group ACE has unexpected flags (0x%x !=
0x03)\n",
+ ((ACE_HEADER *)ace)->AceFlags);
+ ok(ace->Mask == 0x1f01ff, "Administators Group ACE has unexpected mask
(0x%x != 0x1f01ff)\n",
+ ace->Mask);
+ }
+
+done:
+ HeapFree(GetProcessHeap(), 0, user);
+ bret = RemoveDirectoryA(tmpdir);
+ ok(bret == TRUE, "RemoveDirectoryA should always succeed\n");
}
static void test_GetNamedSecurityInfoA(void)
@@ -3402,12 +3530,12 @@
* don't replicate this feature so we only test len >= strlen+1. */
#define CHECK_RESULT_AND_FREE(exp_str) \
ok(strcmp(string, (exp_str)) == 0, "String mismatch (expected \"%s\",
got \"%s\")\n", (exp_str), string); \
- ok(len >= (strlen(exp_str) + 1), "Length mismatch (expected %d, got
%d)\n", lstrlen(exp_str) + 1, len); \
+ ok(len >= (strlen(exp_str) + 1), "Length mismatch (expected %d, got
%d)\n", lstrlenA(exp_str) + 1, len); \
LocalFree(string);
#define CHECK_ONE_OF_AND_FREE(exp_str1, exp_str2) \
ok(strcmp(string, (exp_str1)) == 0 || strcmp(string, (exp_str2)) == 0, "String
mismatch (expected\n\"%s\" or\n\"%s\", got\n\"%s\")\n",
(exp_str1), (exp_str2), string); \
- ok(len >= (strlen(exp_str1) + 1) || len >= (strlen(exp_str2) + 1), "Length
mismatch (expected %d or %d, got %d)\n", lstrlen(exp_str1) + 1, lstrlen(exp_str2) +
1, len); \
+ ok(len >= (strlen(exp_str1) + 1) || len >= (strlen(exp_str2) + 1), "Length
mismatch (expected %d or %d, got %d)\n", lstrlenA(exp_str1) + 1, lstrlenA(exp_str2) +
1, len); \
LocalFree(string);
InitializeSecurityDescriptor(&desc, SECURITY_DESCRIPTOR_REVISION);
@@ -3760,8 +3888,8 @@
user_sid = ((TOKEN_USER *)b)->User.Sid;
/* Create something. Files have lots of associated security info. */
- obj = CreateFile(myARGV[0], GENERIC_READ|WRITE_DAC, FILE_SHARE_READ, NULL,
- OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+ obj = CreateFileA(myARGV[0], GENERIC_READ|WRITE_DAC, FILE_SHARE_READ, NULL,
+ OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (obj == INVALID_HANDLE_VALUE)
{
skip("Couldn't create an object for GetSecurityInfo test\n");
@@ -4391,23 +4519,71 @@
HeapFree(GetProcessHeap(), 0, sd);
}
+static ACCESS_MASK get_obj_access(HANDLE obj)
+{
+ OBJECT_BASIC_INFORMATION info;
+ NTSTATUS status;
+
+ if (!pNtQueryObject) return 0;
+
+ status = pNtQueryObject(obj, ObjectBasicInformation, &info, sizeof(info), NULL);
+ ok(!status, "NtQueryObject error %#x\n", status);
+
+ return info.GrantedAccess;
+}
+
static void test_mutex_security(HANDLE token)
{
- HANDLE mutex;
+ DWORD ret, i, access;
+ HANDLE mutex, dup;
GENERIC_MAPPING mapping = { STANDARD_RIGHTS_READ | MUTANT_QUERY_STATE | SYNCHRONIZE,
STANDARD_RIGHTS_WRITE | MUTEX_MODIFY_STATE |
SYNCHRONIZE,
STANDARD_RIGHTS_EXECUTE | SYNCHRONIZE,
STANDARD_RIGHTS_ALL | MUTEX_ALL_ACCESS };
-
- SetLastError(0xdeadbeef);
- mutex = OpenMutex(0, FALSE, "WineTestMutex");
+ static const struct
+ {
+ int generic, mapped;
+ } map[] =
+ {
+ { 0, 0 },
+ { GENERIC_READ, STANDARD_RIGHTS_READ | MUTANT_QUERY_STATE },
+ { GENERIC_WRITE, STANDARD_RIGHTS_WRITE },
+ { GENERIC_EXECUTE, STANDARD_RIGHTS_EXECUTE | SYNCHRONIZE },
+ { GENERIC_ALL, STANDARD_RIGHTS_ALL | MUTANT_QUERY_STATE }
+ };
+
+ SetLastError(0xdeadbeef);
+ mutex = OpenMutexA(0, FALSE, "WineTestMutex");
ok(!mutex, "mutex should not exist\n");
ok(GetLastError() == ERROR_FILE_NOT_FOUND, "wrong error %u\n",
GetLastError());
SetLastError(0xdeadbeef);
- mutex = CreateMutex(NULL, FALSE, "WineTestMutex");
+ mutex = CreateMutexA(NULL, FALSE, "WineTestMutex");
ok(mutex != 0, "CreateMutex error %d\n", GetLastError());
+ access = get_obj_access(mutex);
+ ok(access == MUTANT_ALL_ACCESS, "expected MUTANT_ALL_ACCESS, got %#x\n",
access);
+
+ for (i = 0; i < sizeof(map)/sizeof(map[0]); i++)
+ {
+ SetLastError( 0xdeadbeef );
+ ret = DuplicateHandle(GetCurrentProcess(), mutex, GetCurrentProcess(), &dup,
+ map[i].generic, FALSE, 0);
+ ok(ret, "DuplicateHandle error %d\n", GetLastError());
+
+ access = get_obj_access(dup);
+ ok(access == map[i].mapped, "%d: expected %#x, got %#x\n", i,
map[i].mapped, access);
+
+ CloseHandle(dup);
+
+ SetLastError(0xdeadbeef);
+ dup = OpenMutexA(0, FALSE, "WineTestMutex");
+todo_wine
+ ok(!dup, "OpenMutex should fail\n");
+todo_wine
+ ok(GetLastError() == ERROR_ACCESS_DENIED, "wrong error %u\n",
GetLastError());
+ }
+
test_default_handle_security(token, mutex, &mapping);
CloseHandle (mutex);
@@ -4415,54 +4591,579 @@
static void test_event_security(HANDLE token)
{
- HANDLE event;
+ DWORD ret, i, access;
+ HANDLE event, dup;
GENERIC_MAPPING mapping = { STANDARD_RIGHTS_READ | EVENT_QUERY_STATE | SYNCHRONIZE,
STANDARD_RIGHTS_WRITE | EVENT_MODIFY_STATE |
SYNCHRONIZE,
STANDARD_RIGHTS_EXECUTE | SYNCHRONIZE,
STANDARD_RIGHTS_ALL | EVENT_ALL_ACCESS };
-
- SetLastError(0xdeadbeef);
- event = OpenEvent(0, FALSE, "WineTestEvent");
+ static const struct
+ {
+ int generic, mapped;
+ } map[] =
+ {
+ { 0, 0 },
+ { GENERIC_READ, STANDARD_RIGHTS_READ | EVENT_QUERY_STATE },
+ { GENERIC_WRITE, STANDARD_RIGHTS_WRITE | EVENT_MODIFY_STATE },
+ { GENERIC_EXECUTE, STANDARD_RIGHTS_EXECUTE | SYNCHRONIZE },
+ { GENERIC_ALL, STANDARD_RIGHTS_ALL | EVENT_QUERY_STATE | EVENT_MODIFY_STATE }
+ };
+
+ SetLastError(0xdeadbeef);
+ event = OpenEventA(0, FALSE, "WineTestEvent");
ok(!event, "event should not exist\n");
ok(GetLastError() == ERROR_FILE_NOT_FOUND, "wrong error %u\n",
GetLastError());
SetLastError(0xdeadbeef);
- event = CreateEvent(NULL, FALSE, FALSE, "WineTestEvent");
+ event = CreateEventA(NULL, FALSE, FALSE, "WineTestEvent");
ok(event != 0, "CreateEvent error %d\n", GetLastError());
+ access = get_obj_access(event);
+ ok(access == EVENT_ALL_ACCESS, "expected EVENT_ALL_ACCESS, got %#x\n",
access);
+
+ for (i = 0; i < sizeof(map)/sizeof(map[0]); i++)
+ {
+ SetLastError( 0xdeadbeef );
+ ret = DuplicateHandle(GetCurrentProcess(), event, GetCurrentProcess(), &dup,
+ map[i].generic, FALSE, 0);
+ ok(ret, "DuplicateHandle error %d\n", GetLastError());
+
+ access = get_obj_access(dup);
+ ok(access == map[i].mapped, "%d: expected %#x, got %#x\n", i,
map[i].mapped, access);
+
+ CloseHandle(dup);
+
+ SetLastError(0xdeadbeef);
+ dup = OpenEventA(0, FALSE, "WineTestEvent");
+todo_wine
+ ok(!dup, "OpenEvent should fail\n");
+todo_wine
+ ok(GetLastError() == ERROR_ACCESS_DENIED, "wrong error %u\n",
GetLastError());
+ }
+
test_default_handle_security(token, event, &mapping);
CloseHandle(event);
+}
+
+static void test_semaphore_security(HANDLE token)
+{
+ DWORD ret, i, access;
+ HANDLE sem, dup;
+ GENERIC_MAPPING mapping = { STANDARD_RIGHTS_READ | SEMAPHORE_QUERY_STATE,
+ STANDARD_RIGHTS_WRITE | SEMAPHORE_MODIFY_STATE,
+ STANDARD_RIGHTS_EXECUTE | SYNCHRONIZE,
+ STANDARD_RIGHTS_ALL | SEMAPHORE_ALL_ACCESS };
+ static const struct
+ {
+ int generic, mapped;
+ } map[] =
+ {
+ { 0, 0 },
+ { GENERIC_READ, STANDARD_RIGHTS_READ | SEMAPHORE_QUERY_STATE },
+ { GENERIC_WRITE, STANDARD_RIGHTS_WRITE | SEMAPHORE_MODIFY_STATE },
+ { GENERIC_EXECUTE, STANDARD_RIGHTS_EXECUTE | SYNCHRONIZE },
+ { GENERIC_ALL, STANDARD_RIGHTS_ALL | SEMAPHORE_QUERY_STATE |
SEMAPHORE_MODIFY_STATE }
+ };
+
+ SetLastError(0xdeadbeef);
+ sem = OpenSemaphoreA(0, FALSE, "WineTestSemaphore");
+ ok(!sem, "semaphore should not exist\n");
+ ok(GetLastError() == ERROR_FILE_NOT_FOUND, "wrong error %u\n",
GetLastError());
+
+ SetLastError(0xdeadbeef);
+ sem = CreateSemaphoreA(NULL, 0, 10, "WineTestSemaphore");
+ ok(sem != 0, "CreateSemaphore error %d\n", GetLastError());
+
+ access = get_obj_access(sem);
+ ok(access == SEMAPHORE_ALL_ACCESS, "expected SEMAPHORE_ALL_ACCESS, got
%#x\n", access);
+
+ for (i = 0; i < sizeof(map)/sizeof(map[0]); i++)
+ {
+ SetLastError( 0xdeadbeef );
+ ret = DuplicateHandle(GetCurrentProcess(), sem, GetCurrentProcess(), &dup,
+ map[i].generic, FALSE, 0);
+ ok(ret, "DuplicateHandle error %d\n", GetLastError());
+
+ access = get_obj_access(dup);
+ ok(access == map[i].mapped, "%d: expected %#x, got %#x\n", i,
map[i].mapped, access);
+
+ CloseHandle(dup);
+ }
+
+ test_default_handle_security(token, sem, &mapping);
+
+ CloseHandle(sem);
}
#define WINE_TEST_PIPE "\\\\.\\pipe\\WineTestPipe"
static void test_named_pipe_security(HANDLE token)
{
- HANDLE pipe, file;
+ DWORD ret, i, access;
+ HANDLE pipe, file, dup;
GENERIC_MAPPING mapping = { FILE_GENERIC_READ,
FILE_GENERIC_WRITE,
FILE_GENERIC_EXECUTE,
STANDARD_RIGHTS_ALL | FILE_ALL_ACCESS };
-
- SetLastError(0xdeadbeef);
- pipe = CreateNamedPipe(WINE_TEST_PIPE, PIPE_ACCESS_DUPLEX |
FILE_FLAG_FIRST_PIPE_INSTANCE,
- PIPE_TYPE_BYTE | PIPE_NOWAIT, PIPE_UNLIMITED_INSTANCES,
- 0, 0, NMPWAIT_USE_DEFAULT_WAIT, NULL);
+ static const struct
+ {
+ int todo, generic, mapped;
+ } map[] =
+ {
+ { 0, 0, 0 },
+ { 1, GENERIC_READ, FILE_GENERIC_READ },
+ { 1, GENERIC_WRITE, FILE_GENERIC_WRITE },
+ { 1, GENERIC_EXECUTE, FILE_GENERIC_EXECUTE },
+ { 1, GENERIC_ALL, STANDARD_RIGHTS_ALL | FILE_ALL_ACCESS }
+ };
+ static const struct
+ {
+ DWORD open_mode;
+ DWORD access;
+ } creation_access[] =
+ {
+ { PIPE_ACCESS_INBOUND, FILE_GENERIC_READ },
+ { PIPE_ACCESS_OUTBOUND, FILE_GENERIC_WRITE },
+ { PIPE_ACCESS_DUPLEX, FILE_GENERIC_READ|FILE_GENERIC_WRITE },
+ { PIPE_ACCESS_INBOUND|WRITE_DAC, FILE_GENERIC_READ|WRITE_DAC },
+ { PIPE_ACCESS_INBOUND|WRITE_OWNER, FILE_GENERIC_READ|WRITE_OWNER }
+ /* ACCESS_SYSTEM_SECURITY is also valid, but will fail with
ERROR_PRIVILEGE_NOT_HELD */
+ };
+
+ /* Test the different security access options for pipes */
+ for (i = 0; i < sizeof(creation_access)/sizeof(creation_access[0]); i++)
+ {
+ SetLastError(0xdeadbeef);
+ pipe = CreateNamedPipeA(WINE_TEST_PIPE, creation_access[i].open_mode,
+ PIPE_TYPE_BYTE | PIPE_NOWAIT, PIPE_UNLIMITED_INSTANCES,
0, 0,
+ NMPWAIT_USE_DEFAULT_WAIT, NULL);
+ ok(pipe != INVALID_HANDLE_VALUE, "CreateNamedPipe(0x%x) error %d\n",
+ creation_access[i].open_mode, GetLastError());
+ access = get_obj_access(pipe);
+ ok(access == creation_access[i].access,
+ "CreateNamedPipeA(0x%x) pipe expected access 0x%x (got 0x%x)\n",
+ creation_access[i].open_mode, creation_access[i].access, access);
+ CloseHandle(pipe);
+ }
+
+ SetLastError(0xdeadbeef);
+ pipe = CreateNamedPipeA(WINE_TEST_PIPE, PIPE_ACCESS_DUPLEX |
FILE_FLAG_FIRST_PIPE_INSTANCE,
+ PIPE_TYPE_BYTE | PIPE_NOWAIT, PIPE_UNLIMITED_INSTANCES,
+ 0, 0, NMPWAIT_USE_DEFAULT_WAIT, NULL);
ok(pipe != INVALID_HANDLE_VALUE, "CreateNamedPipe error %d\n",
GetLastError());
test_default_handle_security(token, pipe, &mapping);
SetLastError(0xdeadbeef);
- file = CreateFile(WINE_TEST_PIPE, FILE_ALL_ACCESS, 0, NULL, OPEN_EXISTING, 0, 0);
+ file = CreateFileA(WINE_TEST_PIPE, FILE_ALL_ACCESS, 0, NULL, OPEN_EXISTING, 0, 0);
ok(file != INVALID_HANDLE_VALUE, "CreateFile error %d\n", GetLastError());
+
+ access = get_obj_access(file);
+ ok(access == FILE_ALL_ACCESS, "expected FILE_ALL_ACCESS, got %#x\n",
access);
+
+ for (i = 0; i < sizeof(map)/sizeof(map[0]); i++)
+ {
+ SetLastError( 0xdeadbeef );
+ ret = DuplicateHandle(GetCurrentProcess(), file, GetCurrentProcess(), &dup,
+ map[i].generic, FALSE, 0);
+ ok(ret, "DuplicateHandle error %d\n", GetLastError());
+
+ access = get_obj_access(dup);
+ ok(access == map[i].mapped, "%d: expected %#x, got %#x\n", i,
map[i].mapped, access);
+
+ CloseHandle(dup);
+ }
+
CloseHandle(file);
-
CloseHandle(pipe);
SetLastError(0xdeadbeef);
- file = CreateFile("\\\\.\\pipe\\", FILE_ALL_ACCESS, FILE_SHARE_READ |
FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0);
+ file = CreateFileA("\\\\.\\pipe\\", FILE_ALL_ACCESS, FILE_SHARE_READ |
FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0);
ok(file != INVALID_HANDLE_VALUE || broken(file == INVALID_HANDLE_VALUE) /* before
Vista */, "CreateFile error %d\n", GetLastError());
+
+ if (file != INVALID_HANDLE_VALUE)
+ {
+ access = get_obj_access(file);
+ ok(access == FILE_ALL_ACCESS, "expected FILE_ALL_ACCESS, got %#x\n",
access);
+
+ for (i = 0; i < sizeof(map)/sizeof(map[0]); i++)
+ {
+ SetLastError( 0xdeadbeef );
+ ret = DuplicateHandle(GetCurrentProcess(), file, GetCurrentProcess(),
&dup,
+ map[i].generic, FALSE, 0);
+ ok(ret, "DuplicateHandle error %d\n", GetLastError());
+
+ access = get_obj_access(dup);
+ if (map[i].todo)
+todo_wine
+ ok(access == map[i].mapped, "%d: expected %#x, got %#x\n", i,
map[i].mapped, access);
+ else
+ ok(access == map[i].mapped, "%d: expected %#x, got %#x\n", i,
map[i].mapped, access);
+
+ CloseHandle(dup);
+ }
+ }
+
CloseHandle(file);
+}
+
+static void test_file_security(HANDLE token)
+{
+ DWORD ret, i, access, bytes;
+ HANDLE file, dup;
+ static const struct
+ {
+ int generic, mapped;
+ } map[] =
+ {
+ { 0, 0 },
+ { GENERIC_READ, FILE_GENERIC_READ },
+ { GENERIC_WRITE, FILE_GENERIC_WRITE },
+ { GENERIC_EXECUTE, FILE_GENERIC_EXECUTE },
+ { GENERIC_ALL, STANDARD_RIGHTS_ALL | FILE_ALL_ACCESS }
+ };
+ char temp_path[MAX_PATH];
+ char file_name[MAX_PATH];
+ char buf[16];
+
+ GetTempPathA(MAX_PATH, temp_path);
+ GetTempFileNameA(temp_path, "tmp", 0, file_name);
+
+ /* file */
+ SetLastError(0xdeadbeef);
+ file = CreateFileA(file_name, GENERIC_ALL, 0, NULL, CREATE_ALWAYS, 0, NULL);
+ ok(file != INVALID_HANDLE_VALUE, "CreateFile error %d\n", GetLastError());
+
+ access = get_obj_access(file);
+ ok(access == FILE_ALL_ACCESS, "expected FILE_ALL_ACCESS, got %#x\n",
access);
+
+ for (i = 0; i < sizeof(map)/sizeof(map[0]); i++)
+ {
+ SetLastError( 0xdeadbeef );
+ ret = DuplicateHandle(GetCurrentProcess(), file, GetCurrentProcess(), &dup,
+ map[i].generic, FALSE, 0);
+ ok(ret, "DuplicateHandle error %d\n", GetLastError());
+
+ access = get_obj_access(dup);
+ ok(access == map[i].mapped, "%d: expected %#x, got %#x\n", i,
map[i].mapped, access);
+
+ CloseHandle(dup);
+ }
+
+ CloseHandle(file);
+
+ SetLastError(0xdeadbeef);
+ file = CreateFileA(file_name, 0, 0, NULL, OPEN_EXISTING, 0, NULL);
+ ok(file != INVALID_HANDLE_VALUE, "CreateFile error %d\n", GetLastError());
+
+ access = get_obj_access(file);
+todo_wine
+ ok(access == (FILE_READ_ATTRIBUTES | SYNCHRONIZE), "expected
FILE_READ_ATTRIBUTES | SYNCHRONIZE, got %#x\n", access);
+
+ bytes = 0xdeadbeef;
+ SetLastError(0xdeadbeef);
+ ret = ReadFile(file, buf, sizeof(buf), &bytes, NULL);
+ ok(!ret, "ReadFile should fail\n");
+ ok(GetLastError() == ERROR_ACCESS_DENIED, "expected ERROR_ACCESS_DENIED, got
%d\n", GetLastError());
+ ok(bytes == 0, "expected 0, got %u\n", bytes);
+
+ CloseHandle(file);
+
+ SetLastError(0xdeadbeef);
+ file = CreateFileA(file_name, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0);
+ ok(file != INVALID_HANDLE_VALUE, "CreateFile error %d\n", GetLastError());
+
+ access = get_obj_access(file);
+todo_wine
+ ok(access == (FILE_GENERIC_WRITE | FILE_READ_ATTRIBUTES), "expected
FILE_GENERIC_WRITE | FILE_READ_ATTRIBUTES, got %#x\n", access);
+
+ bytes = 0xdeadbeef;
+ SetLastError(0xdeadbeef);
+ ret = ReadFile(file, buf, sizeof(buf), &bytes, NULL);
+ ok(!ret, "ReadFile should fail\n");
+ ok(GetLastError() == ERROR_ACCESS_DENIED, "expected ERROR_ACCESS_DENIED, got
%d\n", GetLastError());
+ ok(bytes == 0, "expected 0, got %u\n", bytes);
+
+ CloseHandle(file);
+ DeleteFileA(file_name);
+
+ /* directory */
+ SetLastError(0xdeadbeef);
+ file = CreateFileA(temp_path, GENERIC_ALL, 0, NULL, OPEN_EXISTING,
FILE_FLAG_BACKUP_SEMANTICS, 0);
+ ok(file != INVALID_HANDLE_VALUE, "CreateFile error %d\n", GetLastError());
+
+ access = get_obj_access(file);
+ ok(access == FILE_ALL_ACCESS, "expected FILE_ALL_ACCESS, got %#x\n",
access);
+
+ for (i = 0; i < sizeof(map)/sizeof(map[0]); i++)
+ {
+ SetLastError( 0xdeadbeef );
+ ret = DuplicateHandle(GetCurrentProcess(), file, GetCurrentProcess(), &dup,
+ map[i].generic, FALSE, 0);
+ ok(ret, "DuplicateHandle error %d\n", GetLastError());
+
+ access = get_obj_access(dup);
+ ok(access == map[i].mapped, "%d: expected %#x, got %#x\n", i,
map[i].mapped, access);
+
+ CloseHandle(dup);
+ }
+
+ CloseHandle(file);
+
+ SetLastError(0xdeadbeef);
+ file = CreateFileA(temp_path, 0, 0, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS,
0);
+ ok(file != INVALID_HANDLE_VALUE, "CreateFile error %d\n", GetLastError());
+
+ access = get_obj_access(file);
+todo_wine
+ ok(access == (FILE_READ_ATTRIBUTES | SYNCHRONIZE), "expected
FILE_READ_ATTRIBUTES | SYNCHRONIZE, got %#x\n", access);
+
+ CloseHandle(file);
+
+ SetLastError(0xdeadbeef);
+ file = CreateFileA(temp_path, GENERIC_WRITE, 0, NULL, OPEN_EXISTING,
FILE_FLAG_BACKUP_SEMANTICS, 0);
+ ok(file != INVALID_HANDLE_VALUE, "CreateFile error %d\n", GetLastError());
+
+ access = get_obj_access(file);
+todo_wine
+ ok(access == (FILE_GENERIC_WRITE | FILE_READ_ATTRIBUTES), "expected
FILE_GENERIC_WRITE | FILE_READ_ATTRIBUTES, got %#x\n", access);
+
+ CloseHandle(file);
+}
+
+static void test_filemap_security(void)
+{
+ char temp_path[MAX_PATH];
+ char file_name[MAX_PATH];
+ DWORD ret, i, access;
+ HANDLE file, mapping, dup;
+ static const struct
+ {
+ int generic, mapped;
+ } 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 }
+ };
+ static const struct
+ {
+ int prot, mapped;
+ } prot_map[] =
+ {
+ { 0, 0 },
+ { PAGE_NOACCESS, 0 },
+ { PAGE_READONLY, STANDARD_RIGHTS_REQUIRED | SECTION_QUERY | SECTION_MAP_READ },
+ { PAGE_READWRITE, STANDARD_RIGHTS_REQUIRED | SECTION_QUERY | SECTION_MAP_READ |
SECTION_MAP_WRITE },
+ { PAGE_WRITECOPY, STANDARD_RIGHTS_REQUIRED | SECTION_QUERY | SECTION_MAP_READ },
+ { PAGE_EXECUTE, 0 },
+ { PAGE_EXECUTE_READ, STANDARD_RIGHTS_REQUIRED | SECTION_QUERY | SECTION_MAP_READ
| SECTION_MAP_EXECUTE },
+ { PAGE_EXECUTE_READWRITE, STANDARD_RIGHTS_REQUIRED | SECTION_QUERY |
SECTION_MAP_READ | SECTION_MAP_WRITE | SECTION_MAP_EXECUTE },
+ { PAGE_EXECUTE_WRITECOPY, STANDARD_RIGHTS_REQUIRED | SECTION_QUERY |
SECTION_MAP_READ | SECTION_MAP_EXECUTE }
+ };
+
+ GetTempPathA(MAX_PATH, temp_path);
+ GetTempFileNameA(temp_path, "tmp", 0, file_name);
+
+ SetLastError(0xdeadbeef);
+ file = CreateFileA(file_name, GENERIC_READ|GENERIC_WRITE|GENERIC_EXECUTE, 0, NULL,
CREATE_ALWAYS, 0, 0);
+ ok(file != INVALID_HANDLE_VALUE, "CreateFile error %d\n", GetLastError());
+ SetFilePointer(file, 4096, NULL, FILE_BEGIN);
+ SetEndOfFile(file);
+
+ for (i = 0; i < sizeof(prot_map)/sizeof(prot_map[0]); i++)
+ {
+ SetLastError(0xdeadbeef);
+ mapping = CreateFileMappingW(file, NULL, prot_map[i].prot, 0, 4096, NULL);
+ if (prot_map[i].mapped)
+ {
+ if (!mapping)
+ {
+ /* NT4 and win2k don't support EXEC on file mappings */
+ if (prot_map[i].prot == PAGE_EXECUTE_READ || prot_map[i].prot ==
PAGE_EXECUTE_READWRITE || prot_map[i].prot == PAGE_EXECUTE_WRITECOPY)
+ {
+ win_skip("CreateFileMapping doesn't support PAGE_EXECUTE
protection\n");
+ continue;
+ }
+ }
+ ok(mapping != 0, "CreateFileMapping(%04x) error %d\n",
prot_map[i].prot, GetLastError());
+ }
+ else
+ {
+ ok(!mapping, "CreateFileMapping(%04x) should fail\n",
prot_map[i].prot);
+ ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected
ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
+ continue;
+ }
+
+ access = get_obj_access(mapping);
+ ok(access == prot_map[i].mapped, "%d: expected %#x, got %#x\n", i,
prot_map[i].mapped, access);
+
+ CloseHandle(mapping);
+ }
+
+ SetLastError(0xdeadbeef);
+ mapping = CreateFileMappingW(file, NULL, PAGE_EXECUTE_READWRITE, 0, 4096, NULL);
+ if (!mapping)
+ {
+ /* NT4 and win2k don't support EXEC on file mappings */
+ win_skip("CreateFileMapping doesn't support PAGE_EXECUTE
protection\n");
+ CloseHandle(file);
+ DeleteFileA(file_name);
+ return;
+ }
+ ok(mapping != 0, "CreateFileMapping error %d\n", GetLastError());
+
+ access = get_obj_access(mapping);
+ ok(access == (STANDARD_RIGHTS_REQUIRED | SECTION_QUERY | SECTION_MAP_READ |
SECTION_MAP_WRITE | SECTION_MAP_EXECUTE),
+ "expected STANDARD_RIGHTS_REQUIRED | SECTION_QUERY | SECTION_MAP_READ |
SECTION_MAP_WRITE | SECTION_MAP_EXECUTE, got %#x\n", access);
+
+ for (i = 0; i < sizeof(map)/sizeof(map[0]); i++)
+ {
+ SetLastError( 0xdeadbeef );
+ ret = DuplicateHandle(GetCurrentProcess(), mapping, GetCurrentProcess(),
&dup,
+ map[i].generic, FALSE, 0);
+ ok(ret, "DuplicateHandle error %d\n", GetLastError());
+
+ access = get_obj_access(dup);
+ ok(access == map[i].mapped, "%d: expected %#x, got %#x\n", i,
map[i].mapped, access);
+
+ CloseHandle(dup);
+ }
+
+ CloseHandle(mapping);
+ CloseHandle(file);
+ DeleteFileA(file_name);
+}
+
+static void test_thread_security(void)
+{
+ DWORD ret, i, access;
+ HANDLE thread, dup;
+ static const struct
+ {
+ int generic, mapped;
+ } map[] =
+ {
+ { 0, 0 },
+ { GENERIC_READ, STANDARD_RIGHTS_READ | THREAD_QUERY_INFORMATION |
THREAD_GET_CONTEXT },
+ { GENERIC_WRITE, STANDARD_RIGHTS_WRITE | THREAD_SET_INFORMATION |
THREAD_SET_CONTEXT | THREAD_TERMINATE | THREAD_SUSPEND_RESUME | 0x4 },
+ { GENERIC_EXECUTE, STANDARD_RIGHTS_EXECUTE | SYNCHRONIZE },
+ { GENERIC_ALL, THREAD_ALL_ACCESS_NT4 }
+ };
+
+ SetLastError(0xdeadbeef);
+ thread = CreateThread(NULL, 0, (void *)0xdeadbeef, NULL, CREATE_SUSPENDED,
&ret);
+ ok(thread != 0, "CreateThread error %d\n", GetLastError());
+
+ access = get_obj_access(thread);
+ ok(access == THREAD_ALL_ACCESS_NT4 || access == THREAD_ALL_ACCESS_VISTA,
"expected THREAD_ALL_ACCESS, got %#x\n", access);
+
+ for (i = 0; i < sizeof(map)/sizeof(map[0]); i++)
+ {
+ SetLastError( 0xdeadbeef );
+ ret = DuplicateHandle(GetCurrentProcess(), thread, GetCurrentProcess(),
&dup,
+ map[i].generic, FALSE, 0);
+ ok(ret, "DuplicateHandle error %d\n", GetLastError());
+
+ access = get_obj_access(dup);
+ switch (map[i].generic)
+ {
+ case GENERIC_READ:
+ case GENERIC_EXECUTE:
+ ok(access == map[i].mapped || access == (map[i].mapped |
THREAD_QUERY_LIMITED_INFORMATION) /* Vista+ */,
+ "%d: expected %#x, got %#x\n", i, map[i].mapped, access);
+ break;
+ case GENERIC_WRITE:
+todo_wine
+ ok(access == map[i].mapped || access == (map[i].mapped |
THREAD_SET_LIMITED_INFORMATION) /* Vista+ */,
+ "%d: expected %#x, got %#x\n", i, map[i].mapped, access);
+ break;
+ case GENERIC_ALL:
+ ok(access == map[i].mapped || access == THREAD_ALL_ACCESS_VISTA,
+ "%d: expected %#x, got %#x\n", i, map[i].mapped, access);
+ break;
+ default:
+ ok(access == map[i].mapped, "%d: expected %#x, got %#x\n", i,
map[i].mapped, access);
+ break;
+ }
+
+ CloseHandle(dup);
+ }
+
+ TerminateThread(thread, 0);
+ CloseHandle(thread);
+}
+
+static void test_process_access(void)
+{
+ DWORD ret, i, access;
+ HANDLE process, dup;
+ STARTUPINFOA sti;
+ PROCESS_INFORMATION pi;
+ char cmdline[] = "winver.exe";
+ static const struct
+ {
+ int generic, mapped;
+ } map[] =
+ {
+ { 0, 0 },
+ { GENERIC_READ, STANDARD_RIGHTS_READ | PROCESS_QUERY_INFORMATION |
PROCESS_VM_READ },
+ { GENERIC_WRITE, STANDARD_RIGHTS_WRITE | PROCESS_SET_QUOTA |
PROCESS_SET_INFORMATION | PROCESS_SUSPEND_RESUME |
+ PROCESS_VM_WRITE | PROCESS_DUP_HANDLE | PROCESS_CREATE_PROCESS |
PROCESS_CREATE_THREAD | PROCESS_VM_OPERATION },
+ { GENERIC_EXECUTE, STANDARD_RIGHTS_EXECUTE | SYNCHRONIZE },
+ { GENERIC_ALL, PROCESS_ALL_ACCESS_NT4 }
+ };
+
+ memset(&sti, 0, sizeof(sti));
+ sti.cb = sizeof(sti);
+ SetLastError(0xdeadbeef);
+ ret = CreateProcessA(NULL, cmdline, NULL, NULL, FALSE, CREATE_SUSPENDED, NULL, NULL,
&sti, &pi);
+ ok(ret, "CreateProcess() error %d\n", GetLastError());
+
+ CloseHandle(pi.hThread);
+ process = pi.hProcess;
+
+ access = get_obj_access(process);
+ ok(access == PROCESS_ALL_ACCESS_NT4 || access == PROCESS_ALL_ACCESS_VISTA,
"expected PROCESS_ALL_ACCESS, got %#x\n", access);
+
+ for (i = 0; i < sizeof(map)/sizeof(map[0]); i++)
+ {
+ SetLastError( 0xdeadbeef );
+ ret = DuplicateHandle(GetCurrentProcess(), process, GetCurrentProcess(),
&dup,
+ map[i].generic, FALSE, 0);
+ ok(ret, "DuplicateHandle error %d\n", GetLastError());
+
+ access = get_obj_access(dup);
+ switch (map[i].generic)
+ {
+ case GENERIC_READ:
+ ok(access == map[i].mapped || access == (map[i].mapped |
PROCESS_QUERY_LIMITED_INFORMATION) /* Vista+ */,
+ "%d: expected %#x, got %#x\n", i, map[i].mapped, access);
+ break;
+ case GENERIC_WRITE:
+ ok(access == map[i].mapped || access == (map[i].mapped | PROCESS_TERMINATE)
/* before Vista */,
+ "%d: expected %#x, got %#x\n", i, map[i].mapped, access);
+ break;
+ case GENERIC_EXECUTE:
+ ok(access == map[i].mapped || access == (map[i].mapped |
PROCESS_QUERY_LIMITED_INFORMATION | PROCESS_TERMINATE) /* Vista+ */,
+ "%d: expected %#x, got %#x\n", i, map[i].mapped, access);
+ break;
+ case GENERIC_ALL:
+ ok(access == map[i].mapped || access == PROCESS_ALL_ACCESS_VISTA,
+ "%d: expected %#x, got %#x\n", i, map[i].mapped, access);
+ break;
+ default:
+ ok(access == map[i].mapped, "%d: expected %#x, got %#x\n", i,
map[i].mapped, access);
+ break;
+ }
+
+ CloseHandle(dup);
+ }
+
+ TerminateProcess(process, 0);
+ CloseHandle(process);
}
static BOOL validate_impersonation_token(HANDLE token, DWORD *token_type)
@@ -4538,6 +5239,11 @@
test_mutex_security(token);
test_event_security(token);
test_named_pipe_security(token);
+ test_semaphore_security(token);
+ test_file_security(token);
+ test_filemap_security();
+ test_thread_security();
+ test_process_access();
/* FIXME: test other kernel object types */
CloseHandle(process_token);
@@ -4612,7 +5318,7 @@
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
sa.lpSecurityDescriptor = sd;
sa.bInheritHandle = FALSE;
- handle = CreateEvent( &sa, TRUE, TRUE, "test_event" );
+ handle = CreateEventA( &sa, TRUE, TRUE, "test_event" );
ok( handle != NULL, "error %u\n", GetLastError() );
size = 0;
@@ -4650,6 +5356,41 @@
HeapFree( GetProcessHeap(), 0, sa.lpSecurityDescriptor );
HeapFree( GetProcessHeap(), 0, sd );
CloseHandle( handle );
+}
+
+static void test_AdjustTokenPrivileges(void)
+{
+ TOKEN_PRIVILEGES tp, prev;
+ HANDLE token;
+ DWORD len;
+ LUID luid;
+ BOOL ret;
+
+ if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &token))
+ return;
+
+ if (!LookupPrivilegeValueA(NULL, SE_BACKUP_NAME, &luid))
+ {
+ CloseHandle(token);
+ return;
+ }
+
+ tp.PrivilegeCount = 1;
+ tp.Privileges[0].Luid = luid;
+ tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
+
+ len = 0xdeadbeef;
+ ret = AdjustTokenPrivileges(token, FALSE, &tp, sizeof(TOKEN_PRIVILEGES), NULL,
&len);
+ ok(ret, "got %d\n", ret);
+ ok(len == 0xdeadbeef, "got length %d\n", len);
+
+ /* revert */
+ tp.PrivilegeCount = 1;
+ tp.Privileges[0].Luid = luid;
+ tp.Privileges[0].Attributes = 0;
+ AdjustTokenPrivileges(token, FALSE, &tp, sizeof(TOKEN_PRIVILEGES), &prev,
NULL);
+
+ CloseHandle(token);
}
START_TEST(security)
@@ -4677,6 +5418,7 @@
test_impersonation_level();
test_SetEntriesInAclW();
test_SetEntriesInAclA();
+ test_CreateDirectoryA();
test_GetNamedSecurityInfoA();
test_ConvertStringSecurityDescriptor();
test_ConvertSecurityDescriptorToString();
@@ -4691,4 +5433,5 @@
test_CreateRestrictedToken();
test_TokenIntegrityLevel();
test_default_dacl_owner_sid();
-}
+ test_AdjustTokenPrivileges();
+}
Modified: trunk/rostests/winetests/advapi32/service.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/advapi32/servic…
==============================================================================
--- trunk/rostests/winetests/advapi32/service.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/advapi32/service.c [iso-8859-1] Fri Apr 18 21:58:58 2014
@@ -104,7 +104,6 @@
CloseServiceHandle(scm_handle); /* Just in case */
/* Proper call with an empty hostname */
- SetLastError(0xdeadbeef);
scm_handle = OpenSCManagerA("", SERVICES_ACTIVE_DATABASEA,
SC_MANAGER_CONNECT);
ok(scm_handle != NULL, "Expected success, got error %u\n",
GetLastError());
CloseServiceHandle(scm_handle);
@@ -112,6 +111,8 @@
/* Again a correct one */
SetLastError(0xdeadbeef);
scm_handle = OpenSCManagerA(NULL, NULL, SC_MANAGER_CONNECT);
+ ok(GetLastError() == ERROR_SUCCESS || broken(GetLastError() == ERROR_IO_PENDING) /*
win2k */,
+ "Expected ERROR_SUCCESS, got %u\n", GetLastError());
ok(scm_handle != NULL, "Expected success, got error %u\n",
GetLastError());
CloseServiceHandle(scm_handle);
}
@@ -169,7 +170,7 @@
/* Try to open the service with this displayname, unless the displayname equals
* the servicename as that would defeat the purpose of this test.
*/
- if (!lstrcmpi(spooler, displayname))
+ if (!lstrcmpiA(spooler, displayname))
{
skip("displayname equals servicename\n");
CloseServiceHandle(scm_handle);
@@ -418,7 +419,7 @@
/* Wait a while. One of the following tests also does a CreateService for the
* same servicename and this would result in an ERROR_SERVICE_MARKED_FOR_DELETE
- * error if we do this to quick. Vista seems more picky then the others.
+ * error if we do this too quickly. Vista seems more picky than the others.
*/
Sleep(1000);
@@ -704,7 +705,7 @@
SetLastError(0xdeadbeef);
ret = GetServiceDisplayNameA(scm_handle, servicename, displayname,
&displaysize);
ok(ret, "Expected success, got error %u\n", GetLastError());
- ok(!lstrcmpi(displayname, servicename),
+ ok(!lstrcmpiA(displayname, servicename),
"Expected displayname to be %s, got %s\n", servicename, displayname);
/* Delete the service */
@@ -872,7 +873,7 @@
{
ok(strlen(servicename) == tempsize/2,
"Expected the buffer to be twice the length of the string\n") ;
- ok(!lstrcmpi(servicename, spooler), "Expected %s, got %s\n", spooler,
servicename);
+ ok(!lstrcmpiA(servicename, spooler), "Expected %s, got %s\n", spooler,
servicename);
ok(servicesize == (tempsize * 2),
"Expected servicesize not to change if buffer not insufficient\n")
;
}
@@ -1060,9 +1061,9 @@
DWORD neededW, returnedW;
DWORD tempneeded, tempreturned, missing;
DWORD servicecountactive, servicecountinactive;
- ENUM_SERVICE_STATUS *services;
+ ENUM_SERVICE_STATUSA *services;
ENUM_SERVICE_STATUSW *servicesW;
- ENUM_SERVICE_STATUS_PROCESS *exservices;
+ ENUM_SERVICE_STATUS_PROCESSA *exservices;
UINT i;
/* All NULL or wrong */
@@ -1292,7 +1293,7 @@
/* Allocate less than the needed bytes and don't specify a resume handle */
services = HeapAlloc(GetProcessHeap(), 0, tempneeded);
- bufsize = (tempreturned - 1) * sizeof(ENUM_SERVICE_STATUS);
+ bufsize = (tempreturned - 1) * sizeof(ENUM_SERVICE_STATUSA);
needed = 0xdeadbeef;
returned = 0xdeadbeef;
SetLastError(0xdeadbeef);
@@ -1305,7 +1306,7 @@
"Expected ERROR_MORE_DATA, got %d\n", GetLastError());
/* Allocate less than the needed bytes, this time with a correct resume handle */
- bufsize = (tempreturned - 1) * sizeof(ENUM_SERVICE_STATUS);
+ bufsize = (tempreturned - 1) * sizeof(ENUM_SERVICE_STATUSA);
needed = 0xdeadbeef;
returned = 0xdeadbeef;
resume = 0;
@@ -1607,7 +1608,7 @@
/* Allocate less than the needed bytes and don't specify a resume handle */
exservices = HeapAlloc(GetProcessHeap(), 0, tempneeded);
- bufsize = (tempreturned - 1) * sizeof(ENUM_SERVICE_STATUS);
+ bufsize = (tempreturned - 1) * sizeof(ENUM_SERVICE_STATUSA);
needed = 0xdeadbeef;
returned = 0xdeadbeef;
SetLastError(0xdeadbeef);
@@ -1620,7 +1621,7 @@
"Expected ERROR_MORE_DATA, got %d\n", GetLastError());
/* Allocate less than the needed bytes, this time with a correct resume handle */
- bufsize = (tempreturned - 1) * sizeof(ENUM_SERVICE_STATUS);
+ bufsize = (tempreturned - 1) * sizeof(ENUM_SERVICE_STATUSA);
needed = 0xdeadbeef;
returned = 0xdeadbeef;
resume = 0;