[ADVAPI32_WINETEST]

* Sync with Wine 1.7.17.
CORE-8080

svn path=/trunk/; revision=62781
This commit is contained in:
Amine Khaldi 2014-04-18 21:58:58 +00:00
parent 8b86c3ee99
commit 7417488583
7 changed files with 1132 additions and 278 deletions

View file

@ -187,7 +187,7 @@ static void test_CredReadDomainCredentialsA(void)
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_CredMarshalCredentialA(void)
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 @@ static void test_CredUnmarshalCredentialA(void)
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 @@ static void test_CredUnmarshalCredentialA(void)
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 );
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);
}
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 );
if (ret)
pCredFree(p);
}
}
static void test_CredIsMarshaledCredentialA(void)
@ -744,18 +764,19 @@ static void test_CredIsMarshaledCredentialA(void)
START_TEST(cred)
{
DWORD persists[CRED_TYPE_MAXIMUM];
HMODULE mod = GetModuleHandleA("advapi32.dll");
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");
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)
{

View file

@ -474,21 +474,21 @@ static BOOL FindProvRegVals(DWORD dwIndex, DWORD *pdwProvType, LPSTR *pszProvNam
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 @@ static BOOL FindProvTypesRegVals(DWORD *pdwIndex, DWORD *pdwProvType, LPSTR *psz
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 @@ static BOOL FindProvTypesRegVals(DWORD *pdwIndex, DWORD *pdwProvType, LPSTR *psz
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 @@ static BOOL FindProvTypesRegVals(DWORD *pdwIndex, DWORD *pdwProvType, LPSTR *psz
*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 @@ static BOOL FindDfltProvRegVals(DWORD dwProvType, DWORD dwFlags, LPSTR *pszProvN
} 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 @@ static BOOL FindDfltProvRegVals(DWORD dwProvType, DWORD dwFlags, LPSTR *pszProvN
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 @@ static void test_set_provider_ex(void)
ok(result, "%d\n", GetLastError());
/* check pdwReserved for NULL */
result = pCryptSetProviderExA(MS_DEF_PROV, PROV_RSA_FULL, &notNull, CRYPT_MACHINE_DEFAULT);
result = pCryptSetProviderExA(MS_DEF_PROV_A, PROV_RSA_FULL, &notNull, 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 @@ static void test_set_provider_ex(void)
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 @@ static void test_set_provider_ex(void)
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 @@ static void test_rc2_keylen(void)
}
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 @@ static void test_SystemFunction036(void)
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 @@ START_TEST(crypt)
test_incorrect_api_usage();
test_verify_sig();
test_machine_guid();
test_container_sd();
clean_up_environment();
}

View file

@ -49,17 +49,27 @@ static void init_function_pointers(void)
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);
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(GetFileAttributesA(filename) != INVALID_FILE_ATTRIBUTES, "Expected a backup file\n");
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 @@ static void test_count(void)
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
if (create_backup(backup))
{
ok(ret, "Expected success\n");
ok(count != 0xdeadbeef, "Expected the number of records\n");
}
handle = OpenBackupEventLogA(NULL, backup);
todo_wine
ok(handle != NULL, "Expected a handle, le=%d\n", GetLastError());
CloseEventLog(handle);
DeleteFileA(backup);
/* 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 @@ static void test_oldest(void)
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
if (create_backup(backup))
{
ok(ret, "Expected success\n");
ok(oldest != 0xdeadbeef, "Expected the number of the oldest record\n");
}
handle = OpenBackupEventLogA(NULL, backup);
todo_wine
ok(handle != NULL, "Expected a handle\n");
CloseEventLog(handle);
DeleteFileA(backup);
/* 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 @@ static void test_backup(void)
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,39 +534,40 @@ static void test_openbackup(void)
"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)
if (create_backup(backup))
{
skip("We don't have a backup eventlog to work with\n");
return;
/* 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);
}
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);
CloseHandle(file);
@ -585,7 +604,8 @@ static void test_clear(void)
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 @@ static void test_readwrite(void)
}
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 @@ static void test_readwrite(void)
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;

View file

@ -49,7 +49,7 @@ static NTSTATUS (WINAPI *pLsaLookupSids)(LSA_HANDLE,ULONG,PSID*,LSA_REFERENCED_D
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 @@ static void test_LsaLookupSids(void)
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);

View file

@ -1087,8 +1087,8 @@ static void test_reg_create_key(void)
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 @@ static void test_reg_create_key(void)
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 @@ static void test_reg_create_key(void)
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 @@ static void test_reg_delete_key(void)
{
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 @@ static void test_reg_save_key(void)
{
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 @@ static void test_reg_load_key(void)
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 @@ static void test_reg_unload_key(void)
{
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 @@ static BOOL set_privileges(LPCSTR privilege, BOOL set)
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 @@ static void test_rw_order(void)
{
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 @@ static void test_rw_order(void)
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 @@ static void test_symlinks(void)
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 _check_key_value( int line, HANDLE root, const char *name, DWORD fla
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 @@ static void test_redirection(void)
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 @@ static void test_classesroot(void)
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");
@ -2142,6 +2175,8 @@ static void test_classesroot(void)
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"));
ok(res == ERROR_SUCCESS, "RegSetValueExA failed: %d, GLE=%x\n", res, GetLastError());
@ -2364,7 +2399,7 @@ static void test_classesroot(void)
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 @@ static void test_classesroot(void)
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 @@ static void test_classesroot_mask(void)
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 );

File diff suppressed because it is too large Load diff

View file

@ -104,7 +104,6 @@ static void test_open_scm(void)
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 @@ static void test_open_scm(void)
/* 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 @@ static void test_open_svc(void)
/* 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 @@ static void test_create_delete_svc(void)
/* 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 @@ static void test_get_displayname(void)
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 @@ static void test_get_servicekeyname(void)
{
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 @@ static void test_enum_svc(void)
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 @@ static void test_enum_svc(void)
/* 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 @@ static void test_enum_svc(void)
"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 @@ static void test_enum_svc(void)
/* 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 @@ static void test_enum_svc(void)
"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;