mirror of
https://github.com/reactos/reactos.git
synced 2025-01-07 14:51:00 +00:00
- Sync advapi32_winetest with Wine head
svn path=/trunk/; revision=39481
This commit is contained in:
parent
efa5b443b0
commit
37a3abe6fe
8 changed files with 487 additions and 191 deletions
|
@ -34,6 +34,8 @@ static BOOL (WINAPI *pCredGetSessionTypes)(DWORD,LPDWORD);
|
|||
static BOOL (WINAPI *pCredReadA)(LPCSTR,DWORD,DWORD,PCREDENTIALA *);
|
||||
static BOOL (WINAPI *pCredRenameA)(LPCSTR,LPCSTR,DWORD,DWORD);
|
||||
static BOOL (WINAPI *pCredWriteA)(PCREDENTIALA,DWORD);
|
||||
static BOOL (WINAPI *pCredReadDomainCredentialsA)(PCREDENTIAL_TARGET_INFORMATIONA,DWORD,DWORD*,PCREDENTIALA**);
|
||||
|
||||
|
||||
#define TEST_TARGET_NAME "credtest.winehq.org"
|
||||
#define TEST_TARGET_NAME2 "credtest2.winehq.org"
|
||||
|
@ -136,6 +138,65 @@ static void test_CredDeleteA(void)
|
|||
GetLastError());
|
||||
}
|
||||
|
||||
static void test_CredReadDomainCredentialsA(void)
|
||||
{
|
||||
BOOL ret;
|
||||
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;
|
||||
|
||||
if (!pCredReadDomainCredentialsA)
|
||||
{
|
||||
win_skip("CredReadDomainCredentialsA() is not implemented\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* these two tests would crash on both native and Wine. Implementations
|
||||
* does not check for NULL output pointers and try to zero them out early */
|
||||
#if 0
|
||||
ok(!pCredReadDomainCredentialsA(&info, 0, NULL, &creds) &&
|
||||
GetLastError() == ERROR_INVALID_PARAMETER, "!\n");
|
||||
ok(!pCredReadDomainCredentialsA(&info, 0, &count, NULL) &&
|
||||
GetLastError() == ERROR_INVALID_PARAMETER, "!\n");
|
||||
#endif
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = pCredReadDomainCredentialsA(NULL, 0, &count, &creds);
|
||||
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
|
||||
"CredReadDomainCredentialsA should have failed with ERROR_INVALID_PARAMETER instead of %d\n",
|
||||
GetLastError());
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
creds = (void*)0x12345;
|
||||
count = 2;
|
||||
ret = pCredReadDomainCredentialsA(&info, 0, &count, &creds);
|
||||
ok(!ret && GetLastError() == ERROR_NOT_FOUND,
|
||||
"CredReadDomainCredentialsA should have failed with ERROR_NOT_FOUND instead of %d\n",
|
||||
GetLastError());
|
||||
ok(count ==0 && creds == NULL, "CredReadDomainCredentialsA must not return any result\n");
|
||||
|
||||
info.TargetName = NULL;
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = pCredReadDomainCredentialsA(&info, 0, &count, &creds);
|
||||
ok(!ret, "CredReadDomainCredentialsA should have failed\n");
|
||||
ok(GetLastError() == ERROR_NOT_FOUND ||
|
||||
GetLastError() == ERROR_INVALID_PARAMETER, /* Vista, W2K8 */
|
||||
"Expected ERROR_NOT_FOUND or ERROR_INVALID_PARAMETER instead of %d\n",
|
||||
GetLastError());
|
||||
|
||||
info.DnsServerName = NULL;
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = pCredReadDomainCredentialsA(&info, 0, &count, &creds);
|
||||
ok(!ret, "CredReadDomainCredentialsA should have failed\n");
|
||||
ok(GetLastError() == ERROR_NOT_FOUND ||
|
||||
GetLastError() == ERROR_INVALID_PARAMETER, /* Vista, W2K8 */
|
||||
"Expected ERROR_NOT_FOUND or ERROR_INVALID_PARAMETER instead of %d\n",
|
||||
GetLastError());
|
||||
}
|
||||
|
||||
static void check_blob(int line, DWORD cred_type, PCREDENTIALA cred)
|
||||
{
|
||||
if (cred_type == CRED_TYPE_DOMAIN_PASSWORD)
|
||||
|
@ -279,6 +340,7 @@ START_TEST(cred)
|
|||
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");
|
||||
|
||||
if (!pCredEnumerateA || !pCredFree || !pCredWriteA || !pCredDeleteA ||
|
||||
!pCredReadA)
|
||||
|
@ -304,6 +366,8 @@ START_TEST(cred)
|
|||
test_CredWriteA();
|
||||
test_CredDeleteA();
|
||||
|
||||
test_CredReadDomainCredentialsA();
|
||||
|
||||
trace("generic:\n");
|
||||
if (persists[CRED_TYPE_GENERIC] == CRED_PERSIST_NONE)
|
||||
skip("CRED_TYPE_GENERIC credentials are not supported or are disabled. Skipping\n");
|
||||
|
|
|
@ -461,8 +461,8 @@ static BOOL FindProvRegVals(DWORD dwIndex, DWORD *pdwProvType, LPSTR *pszProvNam
|
|||
RegQueryInfoKey(hKey, NULL, NULL, NULL, pdwProvCount, pcbProvName,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
(*pcbProvName)++;
|
||||
|
||||
if (!(*pszProvName = ((LPSTR)LocalAlloc(LMEM_ZEROINIT, *pcbProvName))))
|
||||
|
||||
if (!(*pszProvName = LocalAlloc(LMEM_ZEROINIT, *pcbProvName)))
|
||||
return FALSE;
|
||||
|
||||
RegEnumKeyEx(hKey, dwIndex, *pszProvName, pcbProvName, NULL, NULL, NULL, NULL);
|
||||
|
@ -518,7 +518,7 @@ static void test_enum_providers(void)
|
|||
/* alloc provider to half the size required
|
||||
* cbName holds the size required */
|
||||
providerLen = cbName / 2;
|
||||
if (!(provider = ((LPSTR)LocalAlloc(LMEM_ZEROINIT, providerLen))))
|
||||
if (!(provider = LocalAlloc(LMEM_ZEROINIT, providerLen)))
|
||||
return;
|
||||
|
||||
result = pCryptEnumProvidersA(dwIndex, NULL, 0, &type, provider, &providerLen);
|
||||
|
@ -546,7 +546,7 @@ static void test_enum_providers(void)
|
|||
/* check expected versus actual values returned */
|
||||
result = pCryptEnumProvidersA(dwIndex, NULL, 0, &type, NULL, &providerLen);
|
||||
ok(result && providerLen==cbName, "expected %i, got %i\n", (int)cbName, (int)providerLen);
|
||||
if (!(provider = ((LPSTR)LocalAlloc(LMEM_ZEROINIT, providerLen))))
|
||||
if (!(provider = LocalAlloc(LMEM_ZEROINIT, providerLen)))
|
||||
return;
|
||||
|
||||
providerLen = 0xdeadbeef;
|
||||
|
@ -670,7 +670,7 @@ static void test_enum_provider_types(void)
|
|||
/* alloc provider type to half the size required
|
||||
* cbTypeName holds the size required */
|
||||
typeNameSize = cbTypeName / 2;
|
||||
if (!(typeName = ((LPSTR)LocalAlloc(LMEM_ZEROINIT, typeNameSize))))
|
||||
if (!(typeName = LocalAlloc(LMEM_ZEROINIT, typeNameSize)))
|
||||
goto cleanup;
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
|
@ -700,7 +700,7 @@ static void test_enum_provider_types(void)
|
|||
/* check expected versus actual values returned */
|
||||
result = pCryptEnumProviderTypesA(index, NULL, 0, &provType, NULL, &typeNameSize);
|
||||
ok(result && typeNameSize==cbTypeName, "expected %d, got %d\n", cbTypeName, typeNameSize);
|
||||
if (!(typeName = ((LPSTR)LocalAlloc(LMEM_ZEROINIT, typeNameSize))))
|
||||
if (!(typeName = LocalAlloc(LMEM_ZEROINIT, typeNameSize)))
|
||||
goto cleanup;
|
||||
|
||||
typeNameSize = 0xdeadbeef;
|
||||
|
@ -870,12 +870,13 @@ static void test_set_provider_ex(void)
|
|||
/* 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);
|
||||
if (!result && (GetLastError() == ERROR_ACCESS_DENIED))
|
||||
if (!result)
|
||||
{
|
||||
ok( GetLastError() == ERROR_ACCESS_DENIED || broken(GetLastError() == ERROR_INVALID_PARAMETER),
|
||||
"wrong error %u\n", GetLastError() );
|
||||
skip("Not enough rights to remove the default provider\n");
|
||||
return;
|
||||
}
|
||||
ok(result, "%d\n", GetLastError());
|
||||
|
||||
result = pCryptSetProviderExA(MS_DEF_PROV, PROV_RSA_FULL, NULL, CRYPT_MACHINE_DEFAULT);
|
||||
ok(result, "%d\n", GetLastError());
|
||||
|
|
|
@ -259,7 +259,7 @@ static void test_SystemFunction004(void)
|
|||
key.Length = 0x100;
|
||||
key.MaximumLength = 0x100;
|
||||
|
||||
r = pSystemFunction004(&in, &key, (struct ustring *)&out);
|
||||
r = pSystemFunction004(&in, &key, &out);
|
||||
ok(r == STATUS_BUFFER_TOO_SMALL, "function failed\n");
|
||||
|
||||
in.Buffer = inbuf;
|
||||
|
|
|
@ -49,7 +49,7 @@ fnSystemFunction007 pSystemFunction007;
|
|||
md4hashfunc pSystemFunction010;
|
||||
md4hashfunc pSystemFunction011;
|
||||
|
||||
#define ctxcmp( a, b ) memcmp( (char*)a, (char*)b, FIELD_OFFSET( MD4_CTX, in ) )
|
||||
#define ctxcmp( a, b ) memcmp( a, b, FIELD_OFFSET( MD4_CTX, in ) )
|
||||
|
||||
static void test_md4_ctx(void)
|
||||
{
|
||||
|
|
|
@ -41,7 +41,7 @@ fnMD5Init pMD5Init;
|
|||
fnMD5Update pMD5Update;
|
||||
fnMD5Final pMD5Final;
|
||||
|
||||
#define ctxcmp( a, b ) memcmp( (char*)a, (char*)b, FIELD_OFFSET( MD5_CTX, in ) )
|
||||
#define ctxcmp( a, b ) memcmp( a, b, FIELD_OFFSET( MD5_CTX, in ) )
|
||||
|
||||
static void test_md5_ctx(void)
|
||||
{
|
||||
|
|
|
@ -1475,6 +1475,52 @@ static void test_reg_delete_tree(void)
|
|||
"Expected ERROR_FILE_NOT_FOUND, got %d\n", ret);
|
||||
}
|
||||
|
||||
static void test_rw_order(void)
|
||||
{
|
||||
HKEY hKey;
|
||||
DWORD dw = 0;
|
||||
static char keyname[] = "test_rw_order";
|
||||
char value_buf[2];
|
||||
DWORD values, value_len, value_name_max_len;
|
||||
LSTATUS ret;
|
||||
|
||||
RegDeleteKeyA(HKEY_CURRENT_USER, keyname);
|
||||
ret = RegCreateKeyA(HKEY_CURRENT_USER, keyname, &hKey);
|
||||
if(ret != ERROR_SUCCESS) {
|
||||
skip("Couldn't create key. Skipping.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
ok(!RegSetValueExA(hKey, "A", 0, REG_DWORD, (LPBYTE)&dw, sizeof(dw)),
|
||||
"RegSetValueExA for value \"A\" failed\n");
|
||||
ok(!RegSetValueExA(hKey, "C", 0, REG_DWORD, (LPBYTE)&dw, sizeof(dw)),
|
||||
"RegSetValueExA for value \"C\" failed\n");
|
||||
ok(!RegSetValueExA(hKey, "D", 0, REG_DWORD, (LPBYTE)&dw, sizeof(dw)),
|
||||
"RegSetValueExA for value \"D\" failed\n");
|
||||
ok(!RegSetValueExA(hKey, "B", 0, REG_DWORD, (LPBYTE)&dw, sizeof(dw)),
|
||||
"RegSetValueExA for value \"B\" failed\n");
|
||||
|
||||
ok(!RegQueryInfoKeyA(hKey, NULL, NULL, NULL, NULL, NULL, NULL, &values,
|
||||
&value_name_max_len, NULL, NULL, NULL), "RegQueryInfoKeyA failed\n");
|
||||
ok(values == 4, "Expected 4 values, got %u\n", values);
|
||||
|
||||
/* Value enumeration preserves RegSetValueEx call order */
|
||||
value_len = 2;
|
||||
ok(!RegEnumValueA(hKey, 0, value_buf, &value_len, NULL, NULL, NULL, NULL), "RegEnumValueA failed\n");
|
||||
ok(strcmp(value_buf, "A") == 0, "Expected name \"A\", got %s\n", value_buf);
|
||||
value_len = 2;
|
||||
ok(!RegEnumValueA(hKey, 1, value_buf, &value_len, NULL, NULL, NULL, NULL), "RegEnumValueA failed\n");
|
||||
todo_wine ok(strcmp(value_buf, "C") == 0, "Expected name \"C\", got %s\n", value_buf);
|
||||
value_len = 2;
|
||||
ok(!RegEnumValueA(hKey, 2, value_buf, &value_len, NULL, NULL, NULL, NULL), "RegEnumValueA failed\n");
|
||||
todo_wine ok(strcmp(value_buf, "D") == 0, "Expected name \"D\", got %s\n", value_buf);
|
||||
value_len = 2;
|
||||
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");
|
||||
}
|
||||
|
||||
START_TEST(registry)
|
||||
{
|
||||
/* Load pointers for functions that are not available in all Windows versions */
|
||||
|
@ -1506,6 +1552,7 @@ START_TEST(registry)
|
|||
}
|
||||
|
||||
test_reg_delete_tree();
|
||||
test_rw_order();
|
||||
|
||||
/* cleanup */
|
||||
delete_key( hkey_main );
|
||||
|
|
|
@ -107,6 +107,8 @@ static BOOL (WINAPI *pSetSecurityDescriptorControl)(PSECURITY_DESCRIPTOR, SECURI
|
|||
SECURITY_DESCRIPTOR_CONTROL);
|
||||
static DWORD (WINAPI *pGetSecurityInfo)(HANDLE, SE_OBJECT_TYPE, SECURITY_INFORMATION,
|
||||
PSID*, PSID*, PACL*, PACL*, PSECURITY_DESCRIPTOR*);
|
||||
static NTSTATUS (WINAPI *pNtAccessCheck)(PSECURITY_DESCRIPTOR, HANDLE, ACCESS_MASK, PGENERIC_MAPPING,
|
||||
PPRIVILEGE_SET, PULONG, PULONG, NTSTATUS*);
|
||||
|
||||
static HMODULE hmod;
|
||||
static int myARGC;
|
||||
|
@ -142,6 +144,7 @@ static void init(void)
|
|||
|
||||
hntdll = GetModuleHandleA("ntdll.dll");
|
||||
pNtQueryObject = (void *)GetProcAddress( hntdll, "NtQueryObject" );
|
||||
pNtAccessCheck = (void *)GetProcAddress( hntdll, "NtAccessCheck" );
|
||||
|
||||
hmod = GetModuleHandle("advapi32.dll");
|
||||
pAddAccessAllowedAceEx = (void *)GetProcAddress(hmod, "AddAccessAllowedAceEx");
|
||||
|
@ -240,7 +243,7 @@ static void test_sid(void)
|
|||
GetLastError() );
|
||||
|
||||
ok(pConvertStringSidToSidA("S-1-5-21-93476-23408-4576", &psid), "ConvertStringSidToSidA failed\n");
|
||||
pisid = (SID *)psid;
|
||||
pisid = psid;
|
||||
ok(pisid->SubAuthorityCount == 4, "Invalid sub authority count - expected 4, got %d\n", pisid->SubAuthorityCount);
|
||||
ok(pisid->SubAuthority[0] == 21, "Invalid subauthority 0 - expceted 21, got %d\n", pisid->SubAuthority[0]);
|
||||
ok(pisid->SubAuthority[3] == 4576, "Invalid subauthority 0 - expceted 4576, got %d\n", pisid->SubAuthority[3]);
|
||||
|
@ -266,7 +269,7 @@ static void test_sid(void)
|
|||
|
||||
r = pConvertStringSidToSidA( refs[i].refStr, &psid );
|
||||
ok( r, "failed to parse sid string\n" );
|
||||
pisid = (PISID)psid;
|
||||
pisid = psid;
|
||||
ok( pisid &&
|
||||
!memcmp( pisid->IdentifierAuthority.Value, refs[i].auth.Value,
|
||||
sizeof(refs[i].auth) ),
|
||||
|
@ -373,7 +376,7 @@ static void test_trustee(void)
|
|||
"MultipleTrusteeOperation wrong\n");
|
||||
ok( trustee.TrusteeForm == TRUSTEE_IS_SID, "TrusteeForm wrong\n");
|
||||
ok( trustee.TrusteeType == TRUSTEE_IS_UNKNOWN, "TrusteeType wrong\n");
|
||||
ok( trustee.ptstrName == (LPSTR) psid, "ptstrName wrong\n" );
|
||||
ok( trustee.ptstrName == psid, "ptstrName wrong\n" );
|
||||
|
||||
/* test BuildTrusteeWithObjectsAndSidA (test 1) */
|
||||
memset( &trustee, 0xff, sizeof trustee );
|
||||
|
@ -842,6 +845,7 @@ static void test_AccessCheck(void)
|
|||
HMODULE NtDllModule;
|
||||
BOOLEAN Enabled;
|
||||
DWORD err;
|
||||
NTSTATUS ntret, ntAccessStatus;
|
||||
|
||||
NtDllModule = GetModuleHandle("ntdll.dll");
|
||||
if (!NtDllModule)
|
||||
|
@ -917,6 +921,7 @@ static void test_AccessCheck(void)
|
|||
|
||||
/* Generic access mask */
|
||||
SetLastError(0xdeadbeef);
|
||||
Access = AccessStatus = 0xdeadbeef;
|
||||
ret = AccessCheck(SecurityDescriptor, Token, GENERIC_READ, &Mapping,
|
||||
PrivSet, &PrivSetLen, &Access, &AccessStatus);
|
||||
err = GetLastError();
|
||||
|
@ -925,7 +930,41 @@ static void test_AccessCheck(void)
|
|||
ok(Access == 0xdeadbeef && AccessStatus == 0xdeadbeef,
|
||||
"Access and/or AccessStatus were changed!\n");
|
||||
|
||||
/* Generic access mask - no privilegeset buffer */
|
||||
SetLastError(0xdeadbeef);
|
||||
Access = AccessStatus = 0xdeadbeef;
|
||||
ret = AccessCheck(SecurityDescriptor, Token, GENERIC_READ, &Mapping,
|
||||
NULL, &PrivSetLen, &Access, &AccessStatus);
|
||||
err = GetLastError();
|
||||
ok(!ret && err == ERROR_NOACCESS, "AccessCheck should have failed "
|
||||
"with ERROR_NOACCESS, instead of %d\n", err);
|
||||
ok(Access == 0xdeadbeef && AccessStatus == 0xdeadbeef,
|
||||
"Access and/or AccessStatus were changed!\n");
|
||||
|
||||
/* Generic access mask - no returnlength */
|
||||
SetLastError(0xdeadbeef);
|
||||
Access = AccessStatus = 0xdeadbeef;
|
||||
ret = AccessCheck(SecurityDescriptor, Token, GENERIC_READ, &Mapping,
|
||||
PrivSet, NULL, &Access, &AccessStatus);
|
||||
err = GetLastError();
|
||||
ok(!ret && err == ERROR_NOACCESS, "AccessCheck should have failed "
|
||||
"with ERROR_NOACCESS, instead of %d\n", err);
|
||||
ok(Access == 0xdeadbeef && AccessStatus == 0xdeadbeef,
|
||||
"Access and/or AccessStatus were changed!\n");
|
||||
|
||||
/* Generic access mask - no privilegeset buffer, no returnlength */
|
||||
SetLastError(0xdeadbeef);
|
||||
Access = AccessStatus = 0xdeadbeef;
|
||||
ret = AccessCheck(SecurityDescriptor, Token, GENERIC_READ, &Mapping,
|
||||
NULL, NULL, &Access, &AccessStatus);
|
||||
err = GetLastError();
|
||||
ok(!ret && err == ERROR_NOACCESS, "AccessCheck should have failed "
|
||||
"with ERROR_NOACCESS, instead of %d\n", err);
|
||||
ok(Access == 0xdeadbeef && AccessStatus == 0xdeadbeef,
|
||||
"Access and/or AccessStatus were changed!\n");
|
||||
|
||||
/* sd with no dacl present */
|
||||
Access = AccessStatus = 0xdeadbeef;
|
||||
ret = SetSecurityDescriptorDacl(SecurityDescriptor, FALSE, NULL, FALSE);
|
||||
ok(ret, "SetSecurityDescriptorDacl failed with error %d\n", GetLastError());
|
||||
ret = AccessCheck(SecurityDescriptor, Token, KEY_READ, &Mapping,
|
||||
|
@ -935,7 +974,63 @@ static void test_AccessCheck(void)
|
|||
"AccessCheck failed to grant access with error %d\n",
|
||||
GetLastError());
|
||||
|
||||
/* sd with no dacl present - no privilegeset buffer */
|
||||
SetLastError(0xdeadbeef);
|
||||
Access = AccessStatus = 0xdeadbeef;
|
||||
ret = AccessCheck(SecurityDescriptor, Token, GENERIC_READ, &Mapping,
|
||||
NULL, &PrivSetLen, &Access, &AccessStatus);
|
||||
err = GetLastError();
|
||||
ok(!ret && err == ERROR_NOACCESS, "AccessCheck should have failed "
|
||||
"with ERROR_NOACCESS, instead of %d\n", err);
|
||||
ok(Access == 0xdeadbeef && AccessStatus == 0xdeadbeef,
|
||||
"Access and/or AccessStatus were changed!\n");
|
||||
|
||||
if(pNtAccessCheck)
|
||||
{
|
||||
/* Generic access mask - no privilegeset buffer */
|
||||
SetLastError(0xdeadbeef);
|
||||
Access = ntAccessStatus = 0xdeadbeef;
|
||||
ntret = pNtAccessCheck(SecurityDescriptor, Token, GENERIC_READ, &Mapping,
|
||||
NULL, &PrivSetLen, &Access, &ntAccessStatus);
|
||||
err = GetLastError();
|
||||
ok(ntret == STATUS_ACCESS_VIOLATION,
|
||||
"NtAccessCheck should have failed with STATUS_ACCESS_VIOLATION, got %x\n", ntret);
|
||||
ok(err == 0xdeadbeef,
|
||||
"NtAccessCheck shouldn't set last error, got %d\n", err);
|
||||
ok(Access == 0xdeadbeef && ntAccessStatus == 0xdeadbeef,
|
||||
"Access and/or AccessStatus were changed!\n");
|
||||
|
||||
/* Generic access mask - no returnlength */
|
||||
SetLastError(0xdeadbeef);
|
||||
Access = ntAccessStatus = 0xdeadbeef;
|
||||
ntret = pNtAccessCheck(SecurityDescriptor, Token, GENERIC_READ, &Mapping,
|
||||
PrivSet, NULL, &Access, &ntAccessStatus);
|
||||
err = GetLastError();
|
||||
ok(ntret == STATUS_ACCESS_VIOLATION,
|
||||
"NtAccessCheck should have failed with STATUS_ACCESS_VIOLATION, got %x\n", ntret);
|
||||
ok(err == 0xdeadbeef,
|
||||
"NtAccessCheck shouldn't set last error, got %d\n", err);
|
||||
ok(Access == 0xdeadbeef && ntAccessStatus == 0xdeadbeef,
|
||||
"Access and/or AccessStatus were changed!\n");
|
||||
|
||||
/* Generic access mask - no privilegeset buffer, no returnlength */
|
||||
SetLastError(0xdeadbeef);
|
||||
Access = ntAccessStatus = 0xdeadbeef;
|
||||
ntret = pNtAccessCheck(SecurityDescriptor, Token, GENERIC_READ, &Mapping,
|
||||
NULL, NULL, &Access, &ntAccessStatus);
|
||||
err = GetLastError();
|
||||
ok(ntret == STATUS_ACCESS_VIOLATION,
|
||||
"NtAccessCheck should have failed with STATUS_ACCESS_VIOLATION, got %x\n", ntret);
|
||||
ok(err == 0xdeadbeef,
|
||||
"NtAccessCheck shouldn't set last error, got %d\n", err);
|
||||
ok(Access == 0xdeadbeef && ntAccessStatus == 0xdeadbeef,
|
||||
"Access and/or AccessStatus were changed!\n");
|
||||
}
|
||||
else
|
||||
win_skip("NtAccessCheck unavailable. Skipping.\n");
|
||||
|
||||
/* sd with NULL dacl */
|
||||
Access = AccessStatus = 0xdeadbeef;
|
||||
ret = SetSecurityDescriptorDacl(SecurityDescriptor, TRUE, NULL, FALSE);
|
||||
ok(ret, "SetSecurityDescriptorDacl failed with error %d\n", GetLastError());
|
||||
ret = AccessCheck(SecurityDescriptor, Token, KEY_READ, &Mapping,
|
||||
|
@ -963,6 +1058,7 @@ static void test_AccessCheck(void)
|
|||
ok(res, "AddAccessDeniedAce failed with error %d\n", GetLastError());
|
||||
|
||||
/* sd with dacl */
|
||||
Access = AccessStatus = 0xdeadbeef;
|
||||
ret = AccessCheck(SecurityDescriptor, Token, KEY_READ, &Mapping,
|
||||
PrivSet, &PrivSetLen, &Access, &AccessStatus);
|
||||
ok(ret, "AccessCheck failed with error %d\n", GetLastError());
|
||||
|
@ -980,6 +1076,7 @@ static void test_AccessCheck(void)
|
|||
|
||||
/* Access denied by SD */
|
||||
SetLastError(0xdeadbeef);
|
||||
Access = AccessStatus = 0xdeadbeef;
|
||||
ret = AccessCheck(SecurityDescriptor, Token, KEY_WRITE, &Mapping,
|
||||
PrivSet, &PrivSetLen, &Access, &AccessStatus);
|
||||
ok(ret, "AccessCheck failed with error %d\n", GetLastError());
|
||||
|
@ -1254,7 +1351,7 @@ struct well_known_sid_value
|
|||
/* 74 */ {TRUE, "S-1-5-22"}, {FALSE, "S-1-5-21-12-23-34-45-56-521"}, {TRUE, "S-1-5-32-573"}
|
||||
};
|
||||
|
||||
static void test_CreateWellKnownSid()
|
||||
static void test_CreateWellKnownSid(void)
|
||||
{
|
||||
SID_IDENTIFIER_AUTHORITY ident = { SECURITY_NT_AUTHORITY };
|
||||
PSID domainsid;
|
||||
|
@ -1608,6 +1705,7 @@ static void test_LookupAccountName(void)
|
|||
DWORD sid_size, domain_size, user_size;
|
||||
DWORD sid_save, domain_save;
|
||||
CHAR user_name[UNLEN + 1];
|
||||
CHAR computer_name[UNLEN + 1];
|
||||
SID_NAME_USE sid_use;
|
||||
LPSTR domain, account, sid_dom;
|
||||
PSID psid;
|
||||
|
@ -1728,7 +1826,9 @@ static void test_LookupAccountName(void)
|
|||
sid_use = 0xcafebabe;
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = LookupAccountNameA(NULL, NULL, NULL, &sid_size, NULL, &domain_size, &sid_use);
|
||||
if (!ret && GetLastError() != ERROR_NONE_MAPPED)
|
||||
if (!ret && GetLastError() == ERROR_NONE_MAPPED)
|
||||
win_skip("NULL account name doesn't work on NT4\n");
|
||||
else
|
||||
{
|
||||
ok(!ret, "Expected 0, got %d\n", ret);
|
||||
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
|
||||
|
@ -1753,8 +1853,6 @@ static void test_LookupAccountName(void)
|
|||
HeapFree(GetProcessHeap(), 0, psid);
|
||||
HeapFree(GetProcessHeap(), 0, domain);
|
||||
}
|
||||
else
|
||||
win_skip("NULL account name doesn't work on NT4\n");
|
||||
|
||||
/* try an invalid account name */
|
||||
SetLastError(0xdeadbeef);
|
||||
|
@ -1778,6 +1876,27 @@ static void test_LookupAccountName(void)
|
|||
"Expected RPC_S_SERVER_UNAVAILABLE or RPC_S_INVALID_NET_ADDR, got %d\n", GetLastError());
|
||||
ok(sid_size == 0, "Expected 0, got %d\n", sid_size);
|
||||
ok(domain_size == 0, "Expected 0, got %d\n", domain_size);
|
||||
|
||||
/* try with the computer name as the account name */
|
||||
domain_size = sizeof(computer_name);
|
||||
GetComputerNameA(computer_name, &domain_size);
|
||||
sid_size = 0;
|
||||
domain_size = 0;
|
||||
ret = LookupAccountNameA(NULL, computer_name, NULL, &sid_size, NULL, &domain_size, &sid_use);
|
||||
ok(!ret && (GetLastError() == ERROR_INSUFFICIENT_BUFFER ||
|
||||
broken(GetLastError() == ERROR_TRUSTED_DOMAIN_FAILURE) ||
|
||||
broken(GetLastError() == ERROR_TRUSTED_RELATIONSHIP_FAILURE)),
|
||||
"LookupAccountNameA failed: %d\n", GetLastError());
|
||||
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER)
|
||||
{
|
||||
psid = HeapAlloc(GetProcessHeap(), 0, sid_size);
|
||||
domain = HeapAlloc(GetProcessHeap(), 0, domain_size);
|
||||
ret = LookupAccountNameA(NULL, computer_name, psid, &sid_size, domain, &domain_size, &sid_use);
|
||||
ok(ret, "LookupAccountNameA failed: %d\n", GetLastError());
|
||||
ok(sid_use == SidTypeDomain, "expected SidTypeDomain, got %d\n", sid_use);
|
||||
HeapFree(GetProcessHeap(), 0, domain);
|
||||
HeapFree(GetProcessHeap(), 0, psid);
|
||||
}
|
||||
}
|
||||
|
||||
static void test_security_descriptor(void)
|
||||
|
@ -1870,7 +1989,8 @@ static void test_granted_access(HANDLE handle, ACCESS_MASK access,
|
|||
static void test_process_security(void)
|
||||
{
|
||||
BOOL res;
|
||||
char owner[32], group[32];
|
||||
PTOKEN_OWNER owner;
|
||||
PTOKEN_PRIMARY_GROUP group;
|
||||
PSID AdminSid = NULL, UsersSid = NULL;
|
||||
PACL Acl = NULL;
|
||||
SECURITY_DESCRIPTOR *SecurityDescriptor = NULL;
|
||||
|
@ -1879,7 +1999,7 @@ static void test_process_security(void)
|
|||
STARTUPINFOA startup;
|
||||
SECURITY_ATTRIBUTES psa;
|
||||
HANDLE token, event;
|
||||
DWORD tmp;
|
||||
DWORD size;
|
||||
|
||||
Acl = HeapAlloc(GetProcessHeap(), 0, 256);
|
||||
res = InitializeAcl(Acl, 256, ACL_REVISION);
|
||||
|
@ -1900,16 +2020,31 @@ static void test_process_security(void)
|
|||
return;
|
||||
}
|
||||
|
||||
res = GetTokenInformation( token, TokenOwner, owner, sizeof(owner), &tmp );
|
||||
res = GetTokenInformation( token, TokenOwner, NULL, 0, &size );
|
||||
ok(!res, "Expected failure, got %d\n", res);
|
||||
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
|
||||
"Expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());
|
||||
|
||||
owner = HeapAlloc(GetProcessHeap(), 0, size);
|
||||
res = GetTokenInformation( token, TokenOwner, owner, size, &size );
|
||||
ok(res, "GetTokenInformation failed with error %d\n", GetLastError());
|
||||
AdminSid = ((TOKEN_OWNER*)owner)->Owner;
|
||||
res = GetTokenInformation( token, TokenPrimaryGroup, group, sizeof(group), &tmp );
|
||||
|
||||
res = GetTokenInformation( token, TokenPrimaryGroup, NULL, 0, &size );
|
||||
ok(!res, "Expected failure, got %d\n", res);
|
||||
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
|
||||
"Expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());
|
||||
|
||||
group = HeapAlloc(GetProcessHeap(), 0, size);
|
||||
res = GetTokenInformation( token, TokenPrimaryGroup, group, size, &size );
|
||||
ok(res, "GetTokenInformation failed with error %d\n", GetLastError());
|
||||
UsersSid = ((TOKEN_PRIMARY_GROUP*)group)->PrimaryGroup;
|
||||
|
||||
CloseHandle( token );
|
||||
if (!res)
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, group);
|
||||
HeapFree(GetProcessHeap(), 0, owner);
|
||||
HeapFree(GetProcessHeap(), 0, Acl);
|
||||
return;
|
||||
}
|
||||
|
@ -1969,6 +2104,8 @@ static void test_process_security(void)
|
|||
CloseHandle( info.hProcess );
|
||||
CloseHandle( info.hThread );
|
||||
CloseHandle( event );
|
||||
HeapFree(GetProcessHeap(), 0, group);
|
||||
HeapFree(GetProcessHeap(), 0, owner);
|
||||
HeapFree(GetProcessHeap(), 0, Acl);
|
||||
HeapFree(GetProcessHeap(), 0, SecurityDescriptor);
|
||||
}
|
||||
|
@ -2197,7 +2334,7 @@ static void test_SetEntriesInAcl(void)
|
|||
ExplicitAccess.Trustee.MultipleTrusteeOperation = NO_MULTIPLE_TRUSTEE;
|
||||
ExplicitAccess.Trustee.TrusteeForm = TRUSTEE_IS_SID;
|
||||
ExplicitAccess.Trustee.TrusteeType = TRUSTEE_IS_UNKNOWN;
|
||||
ExplicitAccess.Trustee.ptstrName = (LPWSTR)EveryoneSid;
|
||||
ExplicitAccess.Trustee.ptstrName = EveryoneSid;
|
||||
res = pSetEntriesInAclW(1, &ExplicitAccess, OldAcl, &NewAcl);
|
||||
ok(res == ERROR_SUCCESS, "SetEntriesInAclW failed: %u\n", res);
|
||||
ok(NewAcl != NULL, "returned acl was NULL\n");
|
||||
|
@ -2245,7 +2382,7 @@ static void test_SetEntriesInAcl(void)
|
|||
|
||||
ExplicitAccess.grfAccessMode = REVOKE_ACCESS;
|
||||
ExplicitAccess.Trustee.TrusteeForm = TRUSTEE_IS_SID;
|
||||
ExplicitAccess.Trustee.ptstrName = (LPWSTR)UsersSid;
|
||||
ExplicitAccess.Trustee.ptstrName = UsersSid;
|
||||
res = pSetEntriesInAclW(1, &ExplicitAccess, OldAcl, &NewAcl);
|
||||
ok(res == ERROR_SUCCESS, "SetEntriesInAclW failed: %u\n", res);
|
||||
ok(NewAcl != NULL, "returned acl was NULL\n");
|
||||
|
@ -2291,7 +2428,8 @@ static void test_GetNamedSecurityInfoA(void)
|
|||
|
||||
ret = GetSecurityDescriptorControl(pSecDesc, &control, &revision);
|
||||
ok(ret, "GetSecurityDescriptorControl failed with error %d\n", GetLastError());
|
||||
ok((control & (SE_SELF_RELATIVE|SE_DACL_PRESENT)) == (SE_SELF_RELATIVE|SE_DACL_PRESENT),
|
||||
ok((control & (SE_SELF_RELATIVE|SE_DACL_PRESENT)) == (SE_SELF_RELATIVE|SE_DACL_PRESENT) ||
|
||||
broken((control & (SE_SELF_RELATIVE|SE_DACL_PRESENT)) == SE_DACL_PRESENT), /* NT4 */
|
||||
"control (0x%x) doesn't have (SE_SELF_RELATIVE|SE_DACL_PRESENT) flags set\n", control);
|
||||
ok(revision == SECURITY_DESCRIPTOR_REVISION1, "revision was %d instead of 1\n", revision);
|
||||
ret = GetSecurityDescriptorOwner(pSecDesc, &owner, &owner_defaulted);
|
||||
|
@ -2300,6 +2438,7 @@ static void test_GetNamedSecurityInfoA(void)
|
|||
ret = GetSecurityDescriptorGroup(pSecDesc, &group, &group_defaulted);
|
||||
ok(ret, "GetSecurityDescriptorGroup failed with error %d\n", GetLastError());
|
||||
ok(group != NULL, "group should not be NULL\n");
|
||||
LocalFree(pSecDesc);
|
||||
}
|
||||
|
||||
static void test_ConvertStringSecurityDescriptor(void)
|
||||
|
@ -2447,7 +2586,7 @@ static void test_ConvertStringSecurityDescriptor(void)
|
|||
"Expected ERROR_INVALID_ACL or ERROR_INVALID_SID, got %d\n", GetLastError());
|
||||
}
|
||||
|
||||
static void test_ConvertSecurityDescriptorToString()
|
||||
static void test_ConvertSecurityDescriptorToString(void)
|
||||
{
|
||||
SECURITY_DESCRIPTOR desc;
|
||||
SECURITY_INFORMATION sec_info = OWNER_SECURITY_INFORMATION|GROUP_SECURITY_INFORMATION|DACL_SECURITY_INFORMATION|SACL_SECURITY_INFORMATION;
|
||||
|
@ -2488,17 +2627,17 @@ static void test_ConvertSecurityDescriptorToString()
|
|||
|
||||
size = 4096;
|
||||
pCreateWellKnownSid(WinLocalSid, NULL, sid_buf, &size);
|
||||
SetSecurityDescriptorOwner(&desc, (PSID)sid_buf, FALSE);
|
||||
SetSecurityDescriptorOwner(&desc, sid_buf, FALSE);
|
||||
ok(pConvertSecurityDescriptorToStringSecurityDescriptorA(&desc, SDDL_REVISION_1, sec_info, &string, &len), "Conversion failed\n");
|
||||
CHECK_RESULT_AND_FREE("O:S-1-2-0");
|
||||
|
||||
SetSecurityDescriptorOwner(&desc, (PSID)sid_buf, TRUE);
|
||||
SetSecurityDescriptorOwner(&desc, sid_buf, TRUE);
|
||||
ok(pConvertSecurityDescriptorToStringSecurityDescriptorA(&desc, SDDL_REVISION_1, sec_info, &string, &len), "Conversion failed\n");
|
||||
CHECK_RESULT_AND_FREE("O:S-1-2-0");
|
||||
|
||||
size = sizeof(sid_buf);
|
||||
pCreateWellKnownSid(WinLocalSystemSid, NULL, sid_buf, &size);
|
||||
SetSecurityDescriptorOwner(&desc, (PSID)sid_buf, TRUE);
|
||||
SetSecurityDescriptorOwner(&desc, sid_buf, TRUE);
|
||||
ok(pConvertSecurityDescriptorToStringSecurityDescriptorA(&desc, SDDL_REVISION_1, sec_info, &string, &len), "Conversion failed\n");
|
||||
CHECK_RESULT_AND_FREE("O:SY");
|
||||
|
||||
|
@ -2677,6 +2816,7 @@ static void test_PrivateObjectSecurity(void)
|
|||
"S:(AU;OICINPIOIDSAFA;CCDCLCSWRPRC;;;SU)(AU;NPSA;0x12019f;;;SU)",
|
||||
SDDL_REVISION_1, &sec, &dwDescSize), "Creating descriptor failed\n"); // FIXME: ConvertStringSecurityDescriptorToSecurityDescriptor fails and 'sec' isn't set
|
||||
|
||||
|
||||
test_SetSecurityDescriptorControl(sec);
|
||||
|
||||
LocalFree(sec);
|
||||
|
|
|
@ -60,11 +60,7 @@ static void test_open_scm(void)
|
|||
/* No access rights */
|
||||
SetLastError(0xdeadbeef);
|
||||
scm_handle = OpenSCManagerA(NULL, NULL, 0);
|
||||
ok(scm_handle != NULL, "Expected success\n");
|
||||
ok(GetLastError() == ERROR_SUCCESS /* W2K3, Vista */ ||
|
||||
GetLastError() == 0xdeadbeef /* NT4, XP */ ||
|
||||
GetLastError() == ERROR_IO_PENDING /* W2K */,
|
||||
"Expected ERROR_SUCCESS, ERROR_IO_PENDING or 0xdeadbeef, got %d\n", GetLastError());
|
||||
ok(scm_handle != NULL, "Expected success, got error %u\n", GetLastError());
|
||||
CloseServiceHandle(scm_handle);
|
||||
|
||||
/* Unknown database name */
|
||||
|
@ -84,31 +80,24 @@ static void test_open_scm(void)
|
|||
/* Remote unknown host */
|
||||
SetLastError(0xdeadbeef);
|
||||
scm_handle = OpenSCManagerA("DOESNOTEXIST", SERVICES_ACTIVE_DATABASEA, SC_MANAGER_CONNECT);
|
||||
ok(!scm_handle, "Expected failure\n");
|
||||
todo_wine
|
||||
{
|
||||
ok(!scm_handle, "Expected failure\n");
|
||||
ok(GetLastError() == RPC_S_SERVER_UNAVAILABLE || GetLastError() == RPC_S_INVALID_NET_ADDR /* w2k8 */,
|
||||
"Expected RPC_S_SERVER_UNAVAILABLE or RPC_S_INVALID_NET_ADDR, got %d\n", GetLastError());
|
||||
}
|
||||
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\n");
|
||||
ok(GetLastError() == ERROR_SUCCESS /* W2K3, Vista */ ||
|
||||
GetLastError() == ERROR_ENVVAR_NOT_FOUND /* NT4 */ ||
|
||||
GetLastError() == 0xdeadbeef /* XP */ ||
|
||||
GetLastError() == ERROR_IO_PENDING /* W2K */,
|
||||
"Expected ERROR_SUCCESS, ERROR_IO_PENDING, ERROR_ENVVAR_NOT_FOUND or 0xdeadbeef, got %d\n", GetLastError());
|
||||
ok(scm_handle != NULL, "Expected success, got error %u\n", GetLastError());
|
||||
CloseServiceHandle(scm_handle);
|
||||
|
||||
/* Again a correct one */
|
||||
SetLastError(0xdeadbeef);
|
||||
scm_handle = OpenSCManagerA(NULL, NULL, SC_MANAGER_CONNECT);
|
||||
ok(scm_handle != NULL, "Expected success\n");
|
||||
ok(GetLastError() == ERROR_SUCCESS /* W2K3, Vista */ ||
|
||||
GetLastError() == 0xdeadbeef /* NT4, XP */ ||
|
||||
GetLastError() == ERROR_IO_PENDING /* W2K */,
|
||||
"Expected ERROR_SUCCESS, ERROR_IO_PENDING or 0xdeadbeef, got %d\n", GetLastError());
|
||||
ok(scm_handle != NULL, "Expected success, got error %u\n", GetLastError());
|
||||
CloseServiceHandle(scm_handle);
|
||||
}
|
||||
|
||||
|
@ -151,11 +140,7 @@ static void test_open_svc(void)
|
|||
skip("Not enough rights to get a handle to the service\n");
|
||||
else
|
||||
{
|
||||
ok(svc_handle != NULL, "Expected success\n");
|
||||
ok(GetLastError() == ERROR_SUCCESS /* W2K3, Vista */ ||
|
||||
GetLastError() == ERROR_IO_PENDING /* W2K */ ||
|
||||
GetLastError() == 0xdeadbeef /* XP, NT4 */,
|
||||
"Expected ERROR_SUCCESS or 0xdeadbeef, got %d\n", GetLastError());
|
||||
ok(svc_handle != NULL, "Expected success, got error %u\n", GetLastError());
|
||||
CloseServiceHandle(svc_handle);
|
||||
}
|
||||
|
||||
|
@ -386,10 +371,6 @@ static void test_create_delete_svc(void)
|
|||
svc_handle1 = CreateServiceA(scm_handle, servicename, NULL, 0, SERVICE_WIN32_OWN_PROCESS | SERVICE_INTERACTIVE_PROCESS,
|
||||
SERVICE_DISABLED, 0, pathname, NULL, NULL, NULL, NULL, NULL);
|
||||
ok(svc_handle1 != NULL, "Could not create the service : %d\n", GetLastError());
|
||||
ok(GetLastError() == ERROR_SUCCESS /* W2K3, Vista */ ||
|
||||
GetLastError() == 0xdeadbeef /* NT4, XP */ ||
|
||||
GetLastError() == ERROR_IO_PENDING /* W2K */,
|
||||
"Expected ERROR_SUCCESS, ERROR_IO_PENDING or 0xdeadbeef, got %d\n", GetLastError());
|
||||
|
||||
/* DeleteService however must have proper rights */
|
||||
SetLastError(0xdeadbeef);
|
||||
|
@ -407,14 +388,9 @@ static void test_create_delete_svc(void)
|
|||
/* Now that we have the proper rights, we should be able to delete */
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = DeleteService(svc_handle1);
|
||||
ok(ret, "Expected success\n");
|
||||
ok(GetLastError() == ERROR_SUCCESS /* W2K3 */ ||
|
||||
GetLastError() == 0xdeadbeef /* NT4, XP, Vista */ ||
|
||||
GetLastError() == ERROR_IO_PENDING /* W2K */,
|
||||
"Expected ERROR_SUCCESS, ERROR_IO_PENDING or 0xdeadbeef, got %d\n", GetLastError());
|
||||
ok(ret, "Expected success, got error %u\n", GetLastError());
|
||||
|
||||
CloseServiceHandle(svc_handle1);
|
||||
|
||||
CloseServiceHandle(scm_handle);
|
||||
|
||||
/* Wait a while. One of the following tests also does a CreateService for the
|
||||
|
@ -440,6 +416,8 @@ static void test_get_displayname(void)
|
|||
DWORD displaysize, tempsize, tempsizeW;
|
||||
static const CHAR deadbeef[] = "Deadbeef";
|
||||
static const WCHAR spoolerW[] = {'S','p','o','o','l','e','r',0};
|
||||
static const WCHAR deadbeefW[] = {'D','e','a','d','b','e','e','f',0};
|
||||
static const WCHAR abcW[] = {'A','B','C',0};
|
||||
static const CHAR servicename[] = "Winetest";
|
||||
static const CHAR pathname[] = "we_dont_care.exe";
|
||||
|
||||
|
@ -476,6 +454,85 @@ static void test_get_displayname(void)
|
|||
ok(GetLastError() == ERROR_SERVICE_DOES_NOT_EXIST,
|
||||
"Expected ERROR_SERVICE_DOES_NOT_EXIST, got %d\n", GetLastError());
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = GetServiceDisplayNameA(scm_handle, deadbeef, NULL, &displaysize);
|
||||
ok(!ret, "Expected failure\n");
|
||||
ok(GetLastError() == ERROR_SERVICE_DOES_NOT_EXIST,
|
||||
"Expected ERROR_SERVICE_DOES_NOT_EXIST, got %d\n", GetLastError());
|
||||
todo_wine ok(displaysize == 1, "Service size expected 1, got %d\n", displaysize);
|
||||
|
||||
displaysize = 15;
|
||||
strcpy(displayname, "ABC");
|
||||
ret = GetServiceDisplayNameA(scm_handle, deadbeef, displayname, &displaysize);
|
||||
ok(!ret, "Expected failure\n");
|
||||
ok(GetLastError() == ERROR_SERVICE_DOES_NOT_EXIST,
|
||||
"Expected ERROR_SERVICE_DOES_NOT_EXIST, got %d\n", GetLastError());
|
||||
todo_wine ok(displaysize == 15, "Service size expected 15, got %d\n", displaysize);
|
||||
ok(displayname[0] == 0, "Service name not empty\n");
|
||||
|
||||
displaysize = 15;
|
||||
lstrcpyW( displaynameW, abcW );
|
||||
ret = GetServiceDisplayNameW(scm_handle, deadbeefW, displaynameW, &displaysize);
|
||||
ok(!ret, "Expected failure\n");
|
||||
ok(GetLastError() == ERROR_SERVICE_DOES_NOT_EXIST,
|
||||
"Expected ERROR_SERVICE_DOES_NOT_EXIST, got %d\n", GetLastError());
|
||||
ok(displaysize == 15, "Service size expected 15, got %d\n", displaysize);
|
||||
ok(displaynameW[0] == 0, "Service name not empty\n");
|
||||
|
||||
displaysize = 0;
|
||||
strcpy(displayname, "ABC");
|
||||
ret = GetServiceDisplayNameA(scm_handle, deadbeef, displayname, &displaysize);
|
||||
ok(!ret, "Expected failure\n");
|
||||
ok(GetLastError() == ERROR_SERVICE_DOES_NOT_EXIST,
|
||||
"Expected ERROR_SERVICE_DOES_NOT_EXIST, got %d\n", GetLastError());
|
||||
todo_wine ok(displaysize == 1, "Service size expected 1, got %d\n", displaysize);
|
||||
ok(displayname[0] == 'A', "Service name changed\n");
|
||||
|
||||
displaysize = 0;
|
||||
lstrcpyW( displaynameW, abcW );
|
||||
ret = GetServiceDisplayNameW(scm_handle, deadbeefW, displaynameW, &displaysize);
|
||||
ok(!ret, "Expected failure\n");
|
||||
ok(displaysize == 2, "Service size expected 2, got %d\n", displaysize);
|
||||
ok(GetLastError() == ERROR_SERVICE_DOES_NOT_EXIST,
|
||||
"Expected ERROR_SERVICE_DOES_NOT_EXIST, got %d\n", GetLastError());
|
||||
ok(displaynameW[0] == 'A', "Service name changed\n");
|
||||
|
||||
displaysize = 1;
|
||||
strcpy(displayname, "ABC");
|
||||
ret = GetServiceDisplayNameA(scm_handle, deadbeef, displayname, &displaysize);
|
||||
ok(!ret, "Expected failure\n");
|
||||
ok(GetLastError() == ERROR_SERVICE_DOES_NOT_EXIST,
|
||||
"Expected ERROR_SERVICE_DOES_NOT_EXIST, got %d\n", GetLastError());
|
||||
todo_wine ok(displaysize == 1, "Service size expected 1, got %d\n", displaysize);
|
||||
ok(displayname[0] == 0, "Service name not empty\n");
|
||||
|
||||
displaysize = 1;
|
||||
lstrcpyW( displaynameW, abcW );
|
||||
ret = GetServiceDisplayNameW(scm_handle, deadbeefW, displaynameW, &displaysize);
|
||||
ok(!ret, "Expected failure\n");
|
||||
ok(displaysize == 2, "Service size expected 2, got %d\n", displaysize);
|
||||
ok(GetLastError() == ERROR_SERVICE_DOES_NOT_EXIST,
|
||||
"Expected ERROR_SERVICE_DOES_NOT_EXIST, got %d\n", GetLastError());
|
||||
ok(displaynameW[0] == 'A', "Service name changed\n");
|
||||
|
||||
displaysize = 2;
|
||||
strcpy(displayname, "ABC");
|
||||
ret = GetServiceDisplayNameA(scm_handle, deadbeef, displayname, &displaysize);
|
||||
ok(!ret, "Expected failure\n");
|
||||
ok(GetLastError() == ERROR_SERVICE_DOES_NOT_EXIST,
|
||||
"Expected ERROR_SERVICE_DOES_NOT_EXIST, got %d\n", GetLastError());
|
||||
todo_wine ok(displaysize == 2, "Service size expected 2, got %d\n", displaysize);
|
||||
ok(displayname[0] == 0, "Service name not empty\n");
|
||||
|
||||
displaysize = 2;
|
||||
lstrcpyW( displaynameW, abcW );
|
||||
ret = GetServiceDisplayNameW(scm_handle, deadbeefW, displaynameW, &displaysize);
|
||||
ok(!ret, "Expected failure\n");
|
||||
ok(displaysize == 2, "Service size expected 2, got %d\n", displaysize);
|
||||
ok(GetLastError() == ERROR_SERVICE_DOES_NOT_EXIST,
|
||||
"Expected ERROR_SERVICE_DOES_NOT_EXIST, got %d\n", GetLastError());
|
||||
ok(displaynameW[0] == 0, "Service name not empty\n");
|
||||
|
||||
/* Check if 'Spooler' exists */
|
||||
svc_handle = OpenServiceA(scm_handle, spooler, GENERIC_READ);
|
||||
if (!svc_handle)
|
||||
|
@ -518,33 +575,21 @@ static void test_get_displayname(void)
|
|||
SetLastError(0xdeadbeef);
|
||||
displaysize = (tempsize / 2) + 1;
|
||||
ret = GetServiceDisplayNameA(scm_handle, spooler, displayname, &displaysize);
|
||||
ok(ret, "Expected success\n");
|
||||
ok(ret, "Expected success, got error %u\n", GetLastError());
|
||||
ok(displaysize == ((tempsize / 2) + 1), "Expected no change for the needed buffer size\n");
|
||||
ok(GetLastError() == ERROR_SUCCESS /* W2K3 */ ||
|
||||
GetLastError() == ERROR_IO_PENDING /* W2K */ ||
|
||||
GetLastError() == 0xdeadbeef /* NT4, XP, Vista */,
|
||||
"Expected ERROR_SUCCESS, ERROR_IO_PENDING or 0xdeadbeef, got %d\n", GetLastError());
|
||||
|
||||
/* Now with the original returned size */
|
||||
SetLastError(0xdeadbeef);
|
||||
displaysize = tempsize;
|
||||
ret = GetServiceDisplayNameA(scm_handle, spooler, displayname, &displaysize);
|
||||
ok(ret, "Expected success\n");
|
||||
ok(ret, "Expected success, got error %u\n", GetLastError());
|
||||
ok(displaysize == tempsize, "Expected no change for the needed buffer size\n");
|
||||
ok(GetLastError() == ERROR_SUCCESS /* W2K3 */ ||
|
||||
GetLastError() == ERROR_IO_PENDING /* W2K */ ||
|
||||
GetLastError() == 0xdeadbeef /* NT4, XP, Vista */,
|
||||
"Expected ERROR_SUCCESS, ERROR_IO_PENDING or 0xdeadbeef, got %d\n", GetLastError());
|
||||
|
||||
/* And with a bigger than needed buffer */
|
||||
SetLastError(0xdeadbeef);
|
||||
displaysize = tempsize * 2;
|
||||
ret = GetServiceDisplayNameA(scm_handle, spooler, displayname, &displaysize);
|
||||
ok(ret, "Expected success\n");
|
||||
ok(GetLastError() == ERROR_SUCCESS /* W2K3 */ ||
|
||||
GetLastError() == ERROR_IO_PENDING /* W2K */ ||
|
||||
GetLastError() == 0xdeadbeef /* NT4, XP, Vista */,
|
||||
"Expected ERROR_SUCCESS, ERROR_IO_PENDING or 0xdeadbeef, got %d\n", GetLastError());
|
||||
ok(ret, "Expected success, got error %u\n", GetLastError());
|
||||
/* Test that shows that if the buffersize is enough, it's not changed */
|
||||
ok(displaysize == tempsize * 2, "Expected no change for the needed buffer size\n");
|
||||
ok(lstrlen(displayname) == tempsize/2,
|
||||
|
@ -581,11 +626,7 @@ static void test_get_displayname(void)
|
|||
SetLastError(0xdeadbeef);
|
||||
displaysize = tempsizeW + 1; /* This caters for the null terminating character */
|
||||
ret = GetServiceDisplayNameW(scm_handle, spoolerW, displaynameW, &displaysize);
|
||||
ok(ret, "Expected success\n");
|
||||
ok(GetLastError() == ERROR_SUCCESS /* W2K3 */ ||
|
||||
GetLastError() == ERROR_IO_PENDING /* W2K */ ||
|
||||
GetLastError() == 0xdeadbeef /* NT4, XP, Vista */,
|
||||
"Expected ERROR_SUCCESS, ERROR_IO_PENDING or 0xdeadbeef, got %d\n", GetLastError());
|
||||
ok(ret, "Expected success, got error %u\n", GetLastError());
|
||||
ok(displaysize == tempsizeW, "Expected the needed buffersize\n");
|
||||
ok(lstrlenW(displaynameW) == displaysize,
|
||||
"Expected the buffer to be the length of the string\n") ;
|
||||
|
@ -639,13 +680,9 @@ static void test_get_displayname(void)
|
|||
/* Get the displayname */
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = GetServiceDisplayNameA(scm_handle, servicename, displayname, &displaysize);
|
||||
ok(ret, "Expected success\n");
|
||||
ok(ret, "Expected success, got error %u\n", GetLastError());
|
||||
ok(!lstrcmpi(displayname, servicename),
|
||||
"Expected displayname to be %s, got %s\n", servicename, displayname);
|
||||
ok(GetLastError() == ERROR_SUCCESS /* W2K3 */ ||
|
||||
GetLastError() == ERROR_IO_PENDING /* W2K */ ||
|
||||
GetLastError() == 0xdeadbeef /* NT4, XP, Vista */,
|
||||
"Expected ERROR_SUCCESS, ERROR_IO_PENDING or 0xdeadbeef, got %d\n", GetLastError());
|
||||
|
||||
/* Delete the service */
|
||||
ret = DeleteService(svc_handle);
|
||||
|
@ -669,6 +706,7 @@ static void test_get_servicekeyname(void)
|
|||
BOOL ret;
|
||||
static const CHAR deadbeef[] = "Deadbeef";
|
||||
static const WCHAR deadbeefW[] = {'D','e','a','d','b','e','e','f',0};
|
||||
static const WCHAR abcW[] = {'A','B','C',0};
|
||||
|
||||
/* Having NULL for the size of the buffer will crash on W2K3 */
|
||||
|
||||
|
@ -711,30 +749,74 @@ static void test_get_servicekeyname(void)
|
|||
strcpy(servicename, "ABC");
|
||||
ret = GetServiceKeyNameA(scm_handle, deadbeef, servicename, &servicesize);
|
||||
ok(!ret, "Expected failure\n");
|
||||
ok(GetLastError() == ERROR_SERVICE_DOES_NOT_EXIST,
|
||||
"Expected ERROR_SERVICE_DOES_NOT_EXIST, got %d\n", GetLastError());
|
||||
todo_wine ok(servicesize == 15, "Service size expected 15, got %d\n", servicesize);
|
||||
ok(servicename[0] == 0, "Service name not empty\n");
|
||||
|
||||
servicesize = 15;
|
||||
servicenameW[0] = 'A';
|
||||
lstrcpyW( servicenameW, abcW );
|
||||
ret = GetServiceKeyNameW(scm_handle, deadbeefW, servicenameW, &servicesize);
|
||||
ok(!ret, "Expected failure\n");
|
||||
todo_wine ok(servicesize == 15, "Service size expected 15, got %d\n", servicesize);
|
||||
ok(GetLastError() == ERROR_SERVICE_DOES_NOT_EXIST,
|
||||
"Expected ERROR_SERVICE_DOES_NOT_EXIST, got %d\n", GetLastError());
|
||||
ok(servicesize == 15, "Service size expected 15, got %d\n", servicesize);
|
||||
ok(servicenameW[0] == 0, "Service name not empty\n");
|
||||
|
||||
servicesize = 0;
|
||||
strcpy(servicename, "ABC");
|
||||
ret = GetServiceKeyNameA(scm_handle, deadbeef, servicename, &servicesize);
|
||||
ok(!ret, "Expected failure\n");
|
||||
ok(GetLastError() == ERROR_SERVICE_DOES_NOT_EXIST,
|
||||
"Expected ERROR_SERVICE_DOES_NOT_EXIST, got %d\n", GetLastError());
|
||||
todo_wine ok(servicesize == 1, "Service size expected 1, got %d\n", servicesize);
|
||||
ok(servicename[0] == 'A', "Service name changed\n");
|
||||
|
||||
servicesize = 0;
|
||||
servicenameW[0] = 'A';
|
||||
lstrcpyW( servicenameW, abcW );
|
||||
ret = GetServiceKeyNameW(scm_handle, deadbeefW, servicenameW, &servicesize);
|
||||
ok(!ret, "Expected failure\n");
|
||||
todo_wine ok(servicesize == 2, "Service size expected 2, got %d\n", servicesize);
|
||||
ok(servicesize == 2, "Service size expected 2, got %d\n", servicesize);
|
||||
ok(GetLastError() == ERROR_SERVICE_DOES_NOT_EXIST,
|
||||
"Expected ERROR_SERVICE_DOES_NOT_EXIST, got %d\n", GetLastError());
|
||||
ok(servicenameW[0] == 'A', "Service name changed\n");
|
||||
|
||||
servicesize = 1;
|
||||
strcpy(servicename, "ABC");
|
||||
ret = GetServiceKeyNameA(scm_handle, deadbeef, servicename, &servicesize);
|
||||
ok(!ret, "Expected failure\n");
|
||||
ok(GetLastError() == ERROR_SERVICE_DOES_NOT_EXIST,
|
||||
"Expected ERROR_SERVICE_DOES_NOT_EXIST, got %d\n", GetLastError());
|
||||
todo_wine ok(servicesize == 1, "Service size expected 1, got %d\n", servicesize);
|
||||
ok(servicename[0] == 0, "Service name not empty\n");
|
||||
|
||||
servicesize = 1;
|
||||
lstrcpyW( servicenameW, abcW );
|
||||
ret = GetServiceKeyNameW(scm_handle, deadbeefW, servicenameW, &servicesize);
|
||||
ok(!ret, "Expected failure\n");
|
||||
ok(servicesize == 2, "Service size expected 2, got %d\n", servicesize);
|
||||
ok(GetLastError() == ERROR_SERVICE_DOES_NOT_EXIST,
|
||||
"Expected ERROR_SERVICE_DOES_NOT_EXIST, got %d\n", GetLastError());
|
||||
ok(servicenameW[0] == 'A', "Service name changed\n");
|
||||
|
||||
servicesize = 2;
|
||||
strcpy(servicename, "ABC");
|
||||
ret = GetServiceKeyNameA(scm_handle, deadbeef, servicename, &servicesize);
|
||||
ok(!ret, "Expected failure\n");
|
||||
ok(GetLastError() == ERROR_SERVICE_DOES_NOT_EXIST,
|
||||
"Expected ERROR_SERVICE_DOES_NOT_EXIST, got %d\n", GetLastError());
|
||||
todo_wine ok(servicesize == 2, "Service size expected 2, got %d\n", servicesize);
|
||||
ok(servicename[0] == 0, "Service name not empty\n");
|
||||
|
||||
servicesize = 2;
|
||||
lstrcpyW( servicenameW, abcW );
|
||||
ret = GetServiceKeyNameW(scm_handle, deadbeefW, servicenameW, &servicesize);
|
||||
ok(!ret, "Expected failure\n");
|
||||
ok(servicesize == 2, "Service size expected 2, got %d\n", servicesize);
|
||||
ok(GetLastError() == ERROR_SERVICE_DOES_NOT_EXIST,
|
||||
"Expected ERROR_SERVICE_DOES_NOT_EXIST, got %d\n", GetLastError());
|
||||
ok(servicenameW[0] == 0, "Service name not empty\n");
|
||||
|
||||
/* Check if 'Spooler' exists */
|
||||
svc_handle = OpenServiceA(scm_handle, spooler, GENERIC_READ);
|
||||
if (!svc_handle)
|
||||
|
@ -762,11 +844,7 @@ static void test_get_servicekeyname(void)
|
|||
tempsize = servicesize;
|
||||
servicesize *= 2;
|
||||
ret = GetServiceKeyNameA(scm_handle, displayname, servicename, &servicesize);
|
||||
ok(ret, "Expected success\n");
|
||||
ok(GetLastError() == ERROR_SUCCESS /* W2K3 */ ||
|
||||
GetLastError() == ERROR_IO_PENDING /* W2K */ ||
|
||||
GetLastError() == 0xdeadbeef /* NT4, XP, Vista */,
|
||||
"Expected ERROR_SUCCESS, ERROR_IO_PENDING or 0xdeadbeef, got %d\n", GetLastError());
|
||||
ok(ret, "Expected success, got error %u\n", GetLastError());
|
||||
if (ret)
|
||||
{
|
||||
ok(lstrlen(servicename) == tempsize/2,
|
||||
|
@ -780,11 +858,7 @@ static void test_get_servicekeyname(void)
|
|||
SetLastError(0xdeadbeef);
|
||||
servicesize *= 2;
|
||||
ret = GetServiceKeyNameW(scm_handle, displaynameW, servicenameW, &servicesize);
|
||||
ok(ret, "Expected success\n");
|
||||
ok(GetLastError() == ERROR_SUCCESS /* W2K3 */ ||
|
||||
GetLastError() == ERROR_IO_PENDING /* W2K */ ||
|
||||
GetLastError() == 0xdeadbeef /* NT4, XP, Vista */,
|
||||
"Expected ERROR_SUCCESS, ERROR_IO_PENDING or 0xdeadbeef, got %d\n", GetLastError());
|
||||
ok(ret, "Expected success, got error %u\n", GetLastError());
|
||||
if (ret)
|
||||
{
|
||||
ok(lstrlen(servicename) == tempsize/2,
|
||||
|
@ -854,11 +928,7 @@ static void test_query_svc(void)
|
|||
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = QueryServiceStatus(svc_handle, &status);
|
||||
ok(ret, "Expected success\n");
|
||||
ok(GetLastError() == ERROR_SUCCESS /* W2K3 */ ||
|
||||
GetLastError() == 0xdeadbeef /* NT4, XP and Vista */ ||
|
||||
GetLastError() == ERROR_IO_PENDING /* W2K */,
|
||||
"Unexpected last error %d\n", GetLastError());
|
||||
ok(ret, "Expected success, got error %u\n", GetLastError());
|
||||
|
||||
CloseServiceHandle(svc_handle);
|
||||
|
||||
|
@ -937,11 +1007,7 @@ static void test_query_svc(void)
|
|||
bufsize = sizeof(SERVICE_STATUS_PROCESS);
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = pQueryServiceStatusEx(svc_handle, 0, (BYTE*)statusproc, bufsize, &needed);
|
||||
ok(ret, "Expected success\n");
|
||||
ok(GetLastError() == ERROR_SUCCESS /* W2K3 */ ||
|
||||
GetLastError() == 0xdeadbeef /* NT4, XP and Vista */ ||
|
||||
GetLastError() == ERROR_IO_PENDING /* W2K */,
|
||||
"Unexpected last error %d\n", GetLastError());
|
||||
ok(ret, "Expected success, got error %u\n", GetLastError());
|
||||
if (statusproc->dwCurrentState == SERVICE_RUNNING)
|
||||
ok(statusproc->dwProcessId != 0,
|
||||
"Expect a process id for this running service\n");
|
||||
|
@ -959,7 +1025,7 @@ static void test_enum_svc(void)
|
|||
SC_HANDLE scm_handle;
|
||||
BOOL ret;
|
||||
DWORD bufsize, needed, returned, resume;
|
||||
DWORD tempneeded, tempreturned;
|
||||
DWORD tempneeded, tempreturned, missing;
|
||||
DWORD servicecountactive, servicecountinactive;
|
||||
ENUM_SERVICE_STATUS *services;
|
||||
ENUM_SERVICE_STATUS_PROCESS *exservices;
|
||||
|
@ -1001,7 +1067,8 @@ static void test_enum_svc(void)
|
|||
SetLastError(0xdeadbeef);
|
||||
ret = EnumServicesStatusA(scm_handle, 0, 0, NULL, 0, &needed, NULL, NULL);
|
||||
ok(!ret, "Expected failure\n");
|
||||
ok(needed == 0xdeadbeef, "Expected no change to the needed buffer variable\n");
|
||||
ok(needed == 0xdeadbeef || broken(needed != 0xdeadbeef), /* nt4 */
|
||||
"Expected no change to the needed buffer variable\n");
|
||||
todo_wine
|
||||
ok(GetLastError() == ERROR_INVALID_ADDRESS ||
|
||||
GetLastError() == ERROR_INVALID_PARAMETER /* NT4 */,
|
||||
|
@ -1015,7 +1082,8 @@ static void test_enum_svc(void)
|
|||
ok(!ret, "Expected failure\n");
|
||||
todo_wine
|
||||
{
|
||||
ok(needed == 0, "Expected needed buffer size to be set to 0, got %d\n", needed);
|
||||
ok(needed == 0 || broken(needed != 0), /* nt4 */
|
||||
"Expected needed buffer size to be set to 0, got %d\n", needed);
|
||||
ok(returned == 0, "Expected number of services to be set to 0, got %d\n", returned);
|
||||
ok(GetLastError() == ERROR_INVALID_PARAMETER,
|
||||
"Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
|
||||
|
@ -1029,7 +1097,8 @@ static void test_enum_svc(void)
|
|||
ok(!ret, "Expected failure\n");
|
||||
todo_wine
|
||||
{
|
||||
ok(needed == 0, "Expected needed buffer size to be set to 0, got %d\n", needed);
|
||||
ok(needed == 0 || broken(needed != 0), /* nt4 */
|
||||
"Expected needed buffer size to be set to 0, got %d\n", needed);
|
||||
ok(returned == 0, "Expected number of services to be set to 0, got %d\n", returned);
|
||||
ok(GetLastError() == ERROR_INVALID_PARAMETER,
|
||||
"Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
|
||||
|
@ -1044,7 +1113,8 @@ static void test_enum_svc(void)
|
|||
ok(!ret, "Expected failure\n");
|
||||
todo_wine
|
||||
{
|
||||
ok(needed == 0, "Expected needed buffer size to be set to 0, got %d\n", needed);
|
||||
ok(needed == 0 || broken(needed != 0), /* nt4 */
|
||||
"Expected needed buffer size to be set to 0, got %d\n", needed);
|
||||
ok(returned == 0, "Expected number of services to be set to 0, got %d\n", returned);
|
||||
ok(GetLastError() == ERROR_INVALID_PARAMETER,
|
||||
"Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
|
||||
|
@ -1059,7 +1129,8 @@ static void test_enum_svc(void)
|
|||
ok(!ret, "Expected failure\n");
|
||||
todo_wine
|
||||
{
|
||||
ok(needed == 0, "Expected needed buffer size to be set to 0, got %d\n", needed);
|
||||
ok(needed == 0 || broken(needed != 0), /* nt4 */
|
||||
"Expected needed buffer size to be set to 0, got %d\n", needed);
|
||||
ok(returned == 0, "Expected number of services to be set to 0, got %d\n", returned);
|
||||
}
|
||||
ok(GetLastError() == ERROR_ACCESS_DENIED,
|
||||
|
@ -1097,13 +1168,9 @@ static void test_enum_svc(void)
|
|||
services, bufsize, &needed, &returned, NULL);
|
||||
todo_wine
|
||||
{
|
||||
ok(ret, "Expected success\n");
|
||||
ok(ret, "Expected success, got error %u\n", GetLastError());
|
||||
ok(needed == 0, "Expected needed buffer to be 0 as we are done\n");
|
||||
ok(returned != 0xdeadbeef && returned > 0, "Expected some returned services\n");
|
||||
ok(GetLastError() == ERROR_SUCCESS /* W2K3 */ ||
|
||||
GetLastError() == 0xdeadbeef /* NT4, XP and Vista */ ||
|
||||
GetLastError() == ERROR_IO_PENDING /* W2K */,
|
||||
"Unexpected last error %d\n", GetLastError());
|
||||
}
|
||||
HeapFree(GetProcessHeap(), 0, services);
|
||||
|
||||
|
@ -1111,8 +1178,8 @@ static void test_enum_svc(void)
|
|||
tempreturned = returned;
|
||||
|
||||
/* Allocate less than the needed bytes and don't specify a resume handle */
|
||||
services = HeapAlloc(GetProcessHeap(), 0, tempneeded - 1);
|
||||
bufsize = tempneeded - 1;
|
||||
services = HeapAlloc(GetProcessHeap(), 0, tempneeded);
|
||||
bufsize = (tempreturned - 1) * sizeof(ENUM_SERVICE_STATUS);
|
||||
needed = 0xdeadbeef;
|
||||
returned = 0xdeadbeef;
|
||||
SetLastError(0xdeadbeef);
|
||||
|
@ -1122,15 +1189,13 @@ static void test_enum_svc(void)
|
|||
todo_wine
|
||||
{
|
||||
ok(needed != 0xdeadbeef && needed > 0, "Expected the needed buffer size for this one service\n");
|
||||
ok(returned == (tempreturned - 1), "Expected one service less to be returned\n");
|
||||
ok(returned < tempreturned, "Expected fewer services to be returned\n");
|
||||
ok(GetLastError() == ERROR_MORE_DATA,
|
||||
"Expected ERROR_MORE_DATA, got %d\n", GetLastError());
|
||||
}
|
||||
HeapFree(GetProcessHeap(), 0, services);
|
||||
|
||||
/* Allocate less than the needed bytes, this time with a correct resume handle */
|
||||
services = HeapAlloc(GetProcessHeap(), 0, tempneeded - 1);
|
||||
bufsize = tempneeded - 1;
|
||||
bufsize = (tempreturned - 1) * sizeof(ENUM_SERVICE_STATUS);
|
||||
needed = 0xdeadbeef;
|
||||
returned = 0xdeadbeef;
|
||||
resume = 0;
|
||||
|
@ -1141,15 +1206,14 @@ static void test_enum_svc(void)
|
|||
todo_wine
|
||||
{
|
||||
ok(needed != 0xdeadbeef && needed > 0, "Expected the needed buffer size for this one service\n");
|
||||
ok(returned == (tempreturned - 1), "Expected one service less to be returned\n");
|
||||
ok(returned < tempreturned, "Expected fewer services to be returned\n");
|
||||
ok(resume, "Expected a resume handle\n");
|
||||
ok(GetLastError() == ERROR_MORE_DATA,
|
||||
"Expected ERROR_MORE_DATA, got %d\n", GetLastError());
|
||||
}
|
||||
HeapFree(GetProcessHeap(), 0, services);
|
||||
|
||||
/* Fetch that last service but pass a bigger buffer size */
|
||||
services = HeapAlloc(GetProcessHeap(), 0, tempneeded);
|
||||
/* Fetch the missing services but pass a bigger buffer size */
|
||||
missing = tempreturned - returned;
|
||||
bufsize = tempneeded;
|
||||
needed = 0xdeadbeef;
|
||||
returned = 0xdeadbeef;
|
||||
|
@ -1158,13 +1222,9 @@ static void test_enum_svc(void)
|
|||
services, bufsize, &needed, &returned, &resume);
|
||||
todo_wine
|
||||
{
|
||||
ok(ret, "Expected success\n");
|
||||
ok(ret, "Expected success, got error %u\n", GetLastError());
|
||||
ok(needed == 0, "Expected needed buffer to be 0 as we are done\n");
|
||||
ok(returned == 1, "Expected only 1 service to be returned\n");
|
||||
ok(GetLastError() == ERROR_SUCCESS /* W2K3 */ ||
|
||||
GetLastError() == 0xdeadbeef /* NT4, XP and Vista */ ||
|
||||
GetLastError() == ERROR_IO_PENDING /* W2K */,
|
||||
"Unexpected last error %d\n", GetLastError());
|
||||
ok(returned == missing, "Expected %u services to be returned\n", missing);
|
||||
}
|
||||
ok(resume == 0, "Expected the resume handle to be 0\n");
|
||||
HeapFree(GetProcessHeap(), 0, services);
|
||||
|
@ -1249,8 +1309,8 @@ static void test_enum_svc(void)
|
|||
|
||||
todo_wine
|
||||
{
|
||||
ok(servicecountactive == 0, "Active services mismatch\n");
|
||||
ok(servicecountinactive == 0, "Inactive services mismatch\n");
|
||||
ok(servicecountactive == 0, "Active services mismatch %u\n", servicecountactive);
|
||||
ok(servicecountinactive == 0, "Inactive services mismatch %u\n", servicecountinactive);
|
||||
}
|
||||
|
||||
CloseServiceHandle(scm_handle);
|
||||
|
@ -1290,7 +1350,8 @@ static void test_enum_svc(void)
|
|||
SetLastError(0xdeadbeef);
|
||||
ret = pEnumServicesStatusExA(scm_handle, 0, 0, 0, NULL, 0, &needed, NULL, NULL, NULL);
|
||||
ok(!ret, "Expected failure\n");
|
||||
ok(needed == 0xdeadbeef, "Expected no change to the needed buffer variable\n");
|
||||
ok(needed == 0xdeadbeef || broken(needed != 0xdeadbeef), /* nt4 */
|
||||
"Expected no change to the needed buffer variable\n");
|
||||
todo_wine
|
||||
ok(GetLastError() == ERROR_INVALID_ADDRESS ||
|
||||
GetLastError() == ERROR_INVALID_PARAMETER /* NT4 */,
|
||||
|
@ -1318,7 +1379,8 @@ static void test_enum_svc(void)
|
|||
ok(returned == 0, "Expected number of service to be set to 0, got %d\n", returned);
|
||||
todo_wine
|
||||
{
|
||||
ok(needed == 0, "Expected needed buffer size to be set to 0, got %d\n", needed);
|
||||
ok(needed == 0 || broken(needed != 0), /* nt4 */
|
||||
"Expected needed buffer size to be set to 0, got %d\n", needed);
|
||||
ok(GetLastError() == ERROR_INVALID_PARAMETER,
|
||||
"Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
|
||||
}
|
||||
|
@ -1333,7 +1395,8 @@ static void test_enum_svc(void)
|
|||
ok(returned == 0, "Expected number of service to be set to 0, got %d\n", returned);
|
||||
todo_wine
|
||||
{
|
||||
ok(needed == 0, "Expected needed buffer size to be set to 0, got %d\n", needed);
|
||||
ok(needed == 0 || broken(needed != 0), /* nt4 */
|
||||
"Expected needed buffer size to be set to 0, got %d\n", needed);
|
||||
ok(GetLastError() == ERROR_INVALID_PARAMETER,
|
||||
"Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
|
||||
}
|
||||
|
@ -1348,7 +1411,8 @@ static void test_enum_svc(void)
|
|||
ok(returned == 0, "Expected number of service to be set to 0, got %d\n", returned);
|
||||
todo_wine
|
||||
{
|
||||
ok(needed == 0, "Expected needed buffer size to be set to 0, got %d\n", needed);
|
||||
ok(needed == 0 || broken(needed != 0), /* nt4 */
|
||||
"Expected needed buffer size to be set to 0, got %d\n", needed);
|
||||
ok(GetLastError() == ERROR_INVALID_PARAMETER,
|
||||
"Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
|
||||
}
|
||||
|
@ -1363,7 +1427,8 @@ static void test_enum_svc(void)
|
|||
ok(returned == 0, "Expected number of service to be set to 0, got %d\n", returned);
|
||||
todo_wine
|
||||
{
|
||||
ok(needed == 0, "Expected needed buffer size to be set to 0, got %d\n", needed);
|
||||
ok(needed == 0 || broken(needed != 0), /* nt4 */
|
||||
"Expected needed buffer size to be set to 0, got %d\n", needed);
|
||||
ok(GetLastError() == ERROR_INVALID_PARAMETER,
|
||||
"Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
|
||||
}
|
||||
|
@ -1376,7 +1441,8 @@ static void test_enum_svc(void)
|
|||
NULL, 0, &needed, &returned, NULL, NULL);
|
||||
ok(!ret, "Expected failure\n");
|
||||
todo_wine
|
||||
ok(needed == 0, "Expected needed buffer size to be set to 0, got %d\n", needed);
|
||||
ok(needed == 0 || broken(needed != 0), /* nt4 */
|
||||
"Expected needed buffer size to be set to 0, got %d\n", needed);
|
||||
ok(returned == 0, "Expected number of service to be set to 0, got %d\n", returned);
|
||||
ok(GetLastError() == ERROR_ACCESS_DENIED,
|
||||
"Expected ERROR_ACCESS_DENIED, got %d\n", GetLastError());
|
||||
|
@ -1391,7 +1457,8 @@ static void test_enum_svc(void)
|
|||
NULL, 0, &needed, &returned, NULL, "deadbeef_group");
|
||||
ok(!ret, "Expected failure\n");
|
||||
todo_wine
|
||||
ok(needed == 0, "Expected needed buffer size to be set to 0, got %d\n", needed);
|
||||
ok(needed == 0 || broken(needed != 0), /* nt4 */
|
||||
"Expected needed buffer size to be set to 0, got %d\n", needed);
|
||||
ok(returned == 0, "Expected number of service to be set to 0, got %d\n", returned);
|
||||
ok(GetLastError() == ERROR_ACCESS_DENIED,
|
||||
"Expected ERROR_ACCESS_DENIED, got %d\n", GetLastError());
|
||||
|
@ -1447,13 +1514,9 @@ static void test_enum_svc(void)
|
|||
(BYTE*)exservices, bufsize, &needed, &returned, NULL, NULL);
|
||||
todo_wine
|
||||
{
|
||||
ok(ret, "Expected success\n");
|
||||
ok(ret, "Expected success, got error %u\n", GetLastError());
|
||||
ok(needed == 0, "Expected needed buffer to be 0 as we are done\n");
|
||||
ok(returned == tempreturned, "Expected the same number of service from this function\n");
|
||||
ok(GetLastError() == ERROR_SUCCESS /* W2K3 */ ||
|
||||
GetLastError() == 0xdeadbeef /* NT4, XP and Vista */ ||
|
||||
GetLastError() == ERROR_IO_PENDING /* W2K */,
|
||||
"Unexpected last error %d\n", GetLastError());
|
||||
}
|
||||
HeapFree(GetProcessHeap(), 0, exservices);
|
||||
|
||||
|
@ -1461,8 +1524,8 @@ static void test_enum_svc(void)
|
|||
tempreturned = returned;
|
||||
|
||||
/* Allocate less than the needed bytes and don't specify a resume handle */
|
||||
exservices = HeapAlloc(GetProcessHeap(), 0, tempneeded - 1);
|
||||
bufsize = tempneeded - 1;
|
||||
exservices = HeapAlloc(GetProcessHeap(), 0, tempneeded);
|
||||
bufsize = (tempreturned - 1) * sizeof(ENUM_SERVICE_STATUS);
|
||||
needed = 0xdeadbeef;
|
||||
returned = 0xdeadbeef;
|
||||
SetLastError(0xdeadbeef);
|
||||
|
@ -1472,15 +1535,13 @@ static void test_enum_svc(void)
|
|||
todo_wine
|
||||
{
|
||||
ok(needed != 0xdeadbeef && needed > 0, "Expected the needed buffer size\n");
|
||||
ok(returned == (tempreturned - 1), "Expected one service less to be returned\n");
|
||||
ok(returned < tempreturned, "Expected fewer services to be returned\n");
|
||||
ok(GetLastError() == ERROR_MORE_DATA,
|
||||
"Expected ERROR_MORE_DATA, got %d\n", GetLastError());
|
||||
}
|
||||
HeapFree(GetProcessHeap(), 0, exservices);
|
||||
|
||||
/* Allocate less than the needed bytes, this time with a correct resume handle */
|
||||
exservices = HeapAlloc(GetProcessHeap(), 0, tempneeded - 1);
|
||||
bufsize = tempneeded - 1;
|
||||
bufsize = (tempreturned - 1) * sizeof(ENUM_SERVICE_STATUS);
|
||||
needed = 0xdeadbeef;
|
||||
returned = 0xdeadbeef;
|
||||
resume = 0;
|
||||
|
@ -1491,15 +1552,14 @@ static void test_enum_svc(void)
|
|||
todo_wine
|
||||
{
|
||||
ok(needed != 0xdeadbeef && needed > 0, "Expected the needed buffer size\n");
|
||||
ok(returned == (tempreturned - 1), "Expected one service less to be returned\n");
|
||||
ok(returned < tempreturned, "Expected fewer services to be returned\n");
|
||||
ok(resume, "Expected a resume handle\n");
|
||||
ok(GetLastError() == ERROR_MORE_DATA,
|
||||
"Expected ERROR_MORE_DATA, got %d\n", GetLastError());
|
||||
}
|
||||
HeapFree(GetProcessHeap(), 0, exservices);
|
||||
|
||||
/* Fetch that last service but pass a bigger buffer size */
|
||||
exservices = HeapAlloc(GetProcessHeap(), 0, tempneeded);
|
||||
missing = tempreturned - returned;
|
||||
bufsize = tempneeded;
|
||||
needed = 0xdeadbeef;
|
||||
returned = 0xdeadbeef;
|
||||
|
@ -1508,14 +1568,10 @@ static void test_enum_svc(void)
|
|||
(BYTE*)exservices, bufsize, &needed, &returned, &resume, NULL);
|
||||
todo_wine
|
||||
{
|
||||
ok(ret, "Expected success\n");
|
||||
ok(ret, "Expected success, got error %u\n", GetLastError());
|
||||
ok(needed == 0, "Expected needed buffer to be 0 as we are done\n");
|
||||
ok(returned == 1, "Expected only 1 service to be returned\n");
|
||||
ok(GetLastError() == ERROR_SUCCESS /* W2K3 */ ||
|
||||
GetLastError() == 0xdeadbeef /* NT4, XP and Vista */ ||
|
||||
GetLastError() == ERROR_IO_PENDING /* W2K */,
|
||||
"Unexpected last error %d\n", GetLastError());
|
||||
}
|
||||
ok(returned == missing, "Expected %u services to be returned\n", missing);
|
||||
ok(resume == 0, "Expected the resume handle to be 0\n");
|
||||
HeapFree(GetProcessHeap(), 0, exservices);
|
||||
|
||||
|
@ -1594,7 +1650,8 @@ static void test_enum_svc(void)
|
|||
else
|
||||
{
|
||||
/* We shouldn't have a process id for inactive services */
|
||||
ok(status.dwProcessId == 0, "This service shouldn't have an associated process id\n");
|
||||
ok(status.dwProcessId == 0, "Service %s state %u shouldn't have an associated process id\n",
|
||||
exservices[i].lpServiceName, status.dwCurrentState);
|
||||
|
||||
servicecountinactive--;
|
||||
}
|
||||
|
@ -1602,8 +1659,8 @@ static void test_enum_svc(void)
|
|||
}
|
||||
HeapFree(GetProcessHeap(), 0, exservices);
|
||||
|
||||
ok(servicecountactive == 0, "Active services mismatch\n");
|
||||
ok(servicecountinactive == 0, "Inactive services mismatch\n");
|
||||
ok(servicecountactive == 0, "Active services mismatch %u\n", servicecountactive);
|
||||
ok(servicecountinactive == 0, "Inactive services mismatch %u\n", servicecountinactive);
|
||||
|
||||
CloseServiceHandle(scm_handle);
|
||||
}
|
||||
|
@ -1625,11 +1682,7 @@ static void test_close(void)
|
|||
handle = OpenSCManagerA(NULL, NULL, SC_MANAGER_CONNECT);
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = CloseServiceHandle(handle);
|
||||
ok(ret, "Expected success\n");
|
||||
ok(GetLastError() == ERROR_IO_PENDING /* W2K */ ||
|
||||
GetLastError() == ERROR_SUCCESS /* W2K3 */ ||
|
||||
GetLastError() == 0xdeadbeef /* NT4, XP, Vista */,
|
||||
"Expected ERROR_SUCCESS, ERROR_IO_PENDING or 0xdeadbeef, got %d\n", GetLastError());
|
||||
ok(ret, "Expected success got error %u\n", GetLastError());
|
||||
}
|
||||
|
||||
static void test_sequence(void)
|
||||
|
@ -1708,11 +1761,7 @@ static void test_sequence(void)
|
|||
given = needed;
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = QueryServiceConfigA(svc_handle, config, given, &needed);
|
||||
ok(ret, "Expected success\n");
|
||||
ok(GetLastError() == ERROR_SUCCESS /* W2K3 */||
|
||||
GetLastError() == 0xdeadbeef /* NT4, XP, Vista */ ||
|
||||
GetLastError() == ERROR_IO_PENDING /* W2K */,
|
||||
"Expected ERROR_SUCCESS, ERROR_IO_PENDING or 0xdeadbeef, got %d\n", GetLastError());
|
||||
ok(ret, "Expected success, got error %u\n", GetLastError());
|
||||
todo_wine
|
||||
{
|
||||
ok(given == needed, "Expected the given (%d) and needed (%d) buffersizes to be equal\n", given, needed);
|
||||
|
@ -1754,12 +1803,7 @@ static void test_sequence(void)
|
|||
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = DeleteService(svc_handle);
|
||||
ok(ret, "Expected success\n");
|
||||
ok(GetLastError() == ERROR_SUCCESS /* W2K3 */||
|
||||
GetLastError() == 0xdeadbeef /* NT4, XP, Vista */ ||
|
||||
GetLastError() == ERROR_IO_PENDING /* W2K */,
|
||||
"Expected ERROR_SUCCESS, ERROR_IO_PENDING or 0xdeadbeef, got %d\n", GetLastError());
|
||||
|
||||
ok(ret, "Expected success, got error %u\n", GetLastError());
|
||||
CloseServiceHandle(svc_handle);
|
||||
|
||||
/* Wait a while. The following test does a CreateService again */
|
||||
|
@ -1973,15 +2017,15 @@ static void test_refcount(void)
|
|||
svc_handle1 = CreateServiceA(scm_handle, servicename, NULL, GENERIC_ALL,
|
||||
SERVICE_WIN32_OWN_PROCESS | SERVICE_INTERACTIVE_PROCESS,
|
||||
SERVICE_DISABLED, 0, pathname, NULL, NULL, NULL, NULL, NULL);
|
||||
ok(svc_handle1 != NULL, "Expected success\n");
|
||||
ok(svc_handle1 != NULL, "Expected success, got error %u\n", GetLastError());
|
||||
|
||||
/* Get a handle to this new service */
|
||||
svc_handle2 = OpenServiceA(scm_handle, servicename, GENERIC_READ);
|
||||
ok(svc_handle2 != NULL, "Expected success\n");
|
||||
ok(svc_handle2 != NULL, "Expected success, got error %u\n", GetLastError());
|
||||
|
||||
/* Get another handle to this new service */
|
||||
svc_handle3 = OpenServiceA(scm_handle, servicename, GENERIC_READ);
|
||||
ok(svc_handle3 != NULL, "Expected success\n");
|
||||
ok(svc_handle3 != NULL, "Expected success, got error %u\n", GetLastError());
|
||||
|
||||
/* Check if we can close the handle to the Service Control Manager */
|
||||
ret = CloseServiceHandle(scm_handle);
|
||||
|
@ -1989,11 +2033,11 @@ static void test_refcount(void)
|
|||
|
||||
/* Get a new handle to the Service Control Manager */
|
||||
scm_handle = OpenSCManagerA(NULL, NULL, GENERIC_ALL);
|
||||
ok(scm_handle != NULL, "Expected success\n");
|
||||
ok(scm_handle != NULL, "Expected success, got error %u\n", GetLastError());
|
||||
|
||||
/* Get a handle to this new service */
|
||||
svc_handle4 = OpenServiceA(scm_handle, servicename, GENERIC_ALL);
|
||||
ok(svc_handle4 != NULL, "Expected success\n");
|
||||
ok(svc_handle4 != NULL, "Expected success, got error %u\n", GetLastError());
|
||||
|
||||
/* Delete the service */
|
||||
ret = DeleteService(svc_handle4);
|
||||
|
@ -2040,7 +2084,7 @@ static void test_refcount(void)
|
|||
svc_handle5 = CreateServiceA(scm_handle, servicename, NULL, GENERIC_ALL,
|
||||
SERVICE_WIN32_OWN_PROCESS | SERVICE_INTERACTIVE_PROCESS,
|
||||
SERVICE_DISABLED, 0, pathname, NULL, NULL, NULL, NULL, NULL);
|
||||
ok(svc_handle5 != NULL, "Expected success\n");
|
||||
ok(svc_handle5 != NULL, "Expected success, got error %u\n", GetLastError());
|
||||
|
||||
/* Delete the service */
|
||||
ret = DeleteService(svc_handle5);
|
||||
|
|
Loading…
Reference in a new issue