[ADVAPI32_WINETEST] Sync with Wine Staging 2.9. CORE-13362

svn path=/trunk/; revision=74911
This commit is contained in:
Amine Khaldi 2017-06-04 14:57:35 +00:00
parent 597e5ae5bd
commit 8fa7e9eda7
6 changed files with 1196 additions and 60 deletions

View File

@ -255,6 +255,9 @@ static void test_incorrect_api_usage(void)
ok (result, "%d\n", GetLastError());
if (!result) return;
result = pCryptDestroyKey(hKey);
ok (result, "%d\n", GetLastError());
result = pCryptGenKey(hProv, CALG_RC4, 0, &hKey2);
ok (result, "%d\n", GetLastError());
if (!result) return;

View File

@ -20,12 +20,15 @@
#include <stdarg.h>
#include "initguid.h"
#include "windef.h"
#include "winbase.h"
#include "winerror.h"
#include "winnt.h"
#include "winreg.h"
#include "sddl.h"
#include "wmistr.h"
#include "evntrace.h"
#include "wine/test.h"
@ -909,6 +912,7 @@ static void test_readwrite(void)
/* Read all events from our created eventlog, one by one */
handle = OpenEventLogA(NULL, eventlogname);
ok(handle != NULL, "Failed to open Event Log, got %d\n", GetLastError());
i = 0;
for (;;)
{
@ -924,14 +928,13 @@ static void test_readwrite(void)
SetLastError(0xdeadbeef);
ret = ReadEventLogA(handle, EVENTLOG_SEQUENTIAL_READ | EVENTLOG_FORWARDS_READ,
0, buf, sizeof(EVENTLOGRECORD), &read, &needed);
if (!ret && GetLastError() == ERROR_HANDLE_EOF)
ok(!ret, "Expected failure\n");
if (!ret && GetLastError() != ERROR_INSUFFICIENT_BUFFER)
{
HeapFree(GetProcessHeap(), 0, buf);
ok(GetLastError() == ERROR_HANDLE_EOF, "record %d, got %d\n", i, GetLastError());
break;
}
ok(!ret, "Expected failure\n");
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
"Expected ERROR_INVALID_PARAMETER, got %d\n",GetLastError());
buf = HeapReAlloc(GetProcessHeap(), 0, buf, needed);
ret = ReadEventLogA(handle, EVENTLOG_SEQUENTIAL_READ | EVENTLOG_FORWARDS_READ,
@ -1010,6 +1013,7 @@ static void test_readwrite(void)
/* Test clearing a real eventlog */
handle = OpenEventLogA(NULL, eventlogname);
ok(handle != NULL, "Failed to open Event Log, got %d\n", GetLastError());
SetLastError(0xdeadbeef);
ret = ClearEventLogA(handle, NULL);
@ -1142,6 +1146,98 @@ static void cleanup_eventlog(void)
ok(bret, "Expected MoveFileEx to succeed: %d\n", GetLastError());
}
static void test_start_trace(void)
{
const char sessionname[] = "wine";
const char filepath[] = "wine.etl";
const char filepath2[] = "eniw.etl";
EVENT_TRACE_PROPERTIES *properties;
TRACEHANDLE handle;
LONG buffersize;
LONG ret;
buffersize = sizeof(EVENT_TRACE_PROPERTIES) + sizeof(sessionname) + sizeof(filepath);
properties = (EVENT_TRACE_PROPERTIES *) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, buffersize);
properties->Wnode.BufferSize = buffersize;
properties->Wnode.Flags = WNODE_FLAG_TRACED_GUID;
properties->LogFileMode = EVENT_TRACE_FILE_MODE_NONE;
properties->LoggerNameOffset = sizeof(EVENT_TRACE_PROPERTIES);
properties->LogFileNameOffset = sizeof(EVENT_TRACE_PROPERTIES) + sizeof(sessionname);
strcpy((char *)properties + properties->LogFileNameOffset, filepath);
properties->Wnode.BufferSize = 0;
ret = StartTraceA(&handle, sessionname, properties);
todo_wine
ok(ret == ERROR_BAD_LENGTH ||
ret == ERROR_INVALID_PARAMETER, /* XP and 2k3 */
"Expected ERROR_BAD_LENGTH, got %d\n", ret);
properties->Wnode.BufferSize = buffersize;
ret = StartTraceA(&handle, "this name is too long", properties);
todo_wine
ok(ret == ERROR_BAD_LENGTH, "Expected ERROR_BAD_LENGTH, got %d\n", ret);
ret = StartTraceA(&handle, sessionname, NULL);
todo_wine
ok(ret == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", ret);
ret = StartTraceA(NULL, sessionname, properties);
todo_wine
ok(ret == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", ret);
properties->LogFileNameOffset = 1;
ret = StartTraceA(&handle, sessionname, properties);
todo_wine
ok(ret == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", ret);
properties->LogFileNameOffset = sizeof(EVENT_TRACE_PROPERTIES) + sizeof(sessionname);
properties->LoggerNameOffset = 1;
ret = StartTraceA(&handle, sessionname, properties);
todo_wine
ok(ret == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", ret);
properties->LoggerNameOffset = sizeof(EVENT_TRACE_PROPERTIES);
properties->LogFileMode = EVENT_TRACE_FILE_MODE_SEQUENTIAL | EVENT_TRACE_FILE_MODE_CIRCULAR;
ret = StartTraceA(&handle, sessionname, properties);
todo_wine
ok(ret == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", ret);
properties->LogFileMode = EVENT_TRACE_FILE_MODE_NONE;
/* XP creates a file we can't delete, so change the filepath to something else */
strcpy((char *)properties + properties->LogFileNameOffset, filepath2);
properties->Wnode.Guid = SystemTraceControlGuid;
ret = StartTraceA(&handle, sessionname, properties);
todo_wine
ok(ret == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", ret);
properties->Wnode.Guid = (GUID){0};
properties->LogFileNameOffset = 0;
ret = StartTraceA(&handle, sessionname, properties);
todo_wine
ok(ret == ERROR_BAD_PATHNAME, "Expected ERROR_BAD_PATHNAME, got %d\n", ret);
properties->LogFileNameOffset = sizeof(EVENT_TRACE_PROPERTIES) + sizeof(sessionname);
ret = StartTraceA(&handle, sessionname, properties);
if (ret == ERROR_ACCESS_DENIED)
{
skip("need admin rights\n");
goto done;
}
ok(ret == ERROR_SUCCESS, "Expected success, got %d\n", ret);
ret = StartTraceA(&handle, sessionname, properties);
todo_wine
ok(ret == ERROR_ALREADY_EXISTS ||
ret == ERROR_SHARING_VIOLATION, /* 2k3 */
"Expected ERROR_ALREADY_EXISTS, got %d\n", ret);
/* clean up */
ControlTraceA(handle, sessionname, properties, EVENT_TRACE_CONTROL_STOP);
done:
HeapFree(GetProcessHeap(), 0, properties);
DeleteFileA(filepath);
}
START_TEST(eventlog)
{
SetLastError(0xdeadbeef);
@ -1171,4 +1267,7 @@ START_TEST(eventlog)
test_autocreation();
cleanup_eventlog();
}
/* Trace tests */
test_start_trace();
}

View File

@ -44,8 +44,10 @@ static NTSTATUS (WINAPI *pLsaFreeMemory)(PVOID);
static NTSTATUS (WINAPI *pLsaOpenPolicy)(PLSA_UNICODE_STRING,PLSA_OBJECT_ATTRIBUTES,ACCESS_MASK,PLSA_HANDLE);
static NTSTATUS (WINAPI *pLsaQueryInformationPolicy)(LSA_HANDLE,POLICY_INFORMATION_CLASS,PVOID*);
static BOOL (WINAPI *pConvertSidToStringSidA)(PSID,LPSTR*);
static BOOL (WINAPI *pConvertStringSidToSidA)(LPCSTR,PSID*);
static NTSTATUS (WINAPI *pLsaLookupNames2)(LSA_HANDLE,ULONG,ULONG,PLSA_UNICODE_STRING,PLSA_REFERENCED_DOMAIN_LIST*,PLSA_TRANSLATED_SID2*);
static NTSTATUS (WINAPI *pLsaLookupSids)(LSA_HANDLE,ULONG,PSID*,LSA_REFERENCED_DOMAIN_LIST**,LSA_TRANSLATED_NAME**);
static PVOID (WINAPI *pFreeSid)(PSID);
static BOOL init(void)
{
@ -57,10 +59,12 @@ static BOOL init(void)
pLsaOpenPolicy = (void*)GetProcAddress(hadvapi32, "LsaOpenPolicy");
pLsaQueryInformationPolicy = (void*)GetProcAddress(hadvapi32, "LsaQueryInformationPolicy");
pConvertSidToStringSidA = (void*)GetProcAddress(hadvapi32, "ConvertSidToStringSidA");
pConvertStringSidToSidA = (void*)GetProcAddress(hadvapi32, "ConvertStringSidToSidA");
pLsaLookupNames2 = (void*)GetProcAddress(hadvapi32, "LsaLookupNames2");
pLsaLookupSids = (void*)GetProcAddress(hadvapi32, "LsaLookupSids");
pFreeSid = (void*)GetProcAddress(hadvapi32, "FreeSid");
if (pLsaClose && pLsaEnumerateAccountRights && pLsaFreeMemory && pLsaOpenPolicy && pLsaQueryInformationPolicy && pConvertSidToStringSidA)
if (pLsaClose && pLsaEnumerateAccountRights && pLsaFreeMemory && pLsaOpenPolicy && pLsaQueryInformationPolicy && pConvertSidToStringSidA && pConvertStringSidToSidA && pFreeSid)
return TRUE;
return FALSE;
@ -68,6 +72,8 @@ static BOOL init(void)
static void test_lsa(void)
{
static WCHAR machineW[] = {'W','i','n','e','N','o','M','a','c','h','i','n','e',0};
LSA_UNICODE_STRING machine;
NTSTATUS status;
LSA_HANDLE handle;
LSA_OBJECT_ATTRIBUTES object_attributes;
@ -75,6 +81,14 @@ static void test_lsa(void)
ZeroMemory(&object_attributes, sizeof(object_attributes));
object_attributes.Length = sizeof(object_attributes);
machine.Buffer = machineW;
machine.Length = sizeof(machineW) - 2;
machine.MaximumLength = sizeof(machineW);
status = pLsaOpenPolicy( &machine, &object_attributes, POLICY_LOOKUP_NAMES, &handle);
ok(status == RPC_NT_SERVER_UNAVAILABLE,
"LsaOpenPolicy(POLICY_LOOKUP_NAMES) for invalid machine returned 0x%08x\n", status);
status = pLsaOpenPolicy( NULL, &object_attributes, POLICY_ALL_ACCESS, &handle);
ok(status == STATUS_SUCCESS || status == STATUS_ACCESS_DENIED,
"LsaOpenPolicy(POLICY_ALL_ACCESS) returned 0x%08x\n", status);
@ -407,6 +421,48 @@ static void test_LsaLookupSids(void)
ok(status == STATUS_SUCCESS, "got 0x%08x\n", status);
}
static void test_LsaLookupSids_NullBuffers(void)
{
LSA_REFERENCED_DOMAIN_LIST *list;
LSA_OBJECT_ATTRIBUTES attrs;
LSA_TRANSLATED_NAME *names;
LSA_HANDLE policy;
NTSTATUS status;
BOOL ret;
PSID sid;
memset(&attrs, 0, sizeof(attrs));
attrs.Length = sizeof(attrs);
status = pLsaOpenPolicy(NULL, &attrs, POLICY_LOOKUP_NAMES, &policy);
ok(status == STATUS_SUCCESS, "got 0x%08x\n", status);
ret = pConvertStringSidToSidA("S-1-1-0", &sid);
ok(ret == TRUE, "pConvertStringSidToSidA returned false\n");
status = pLsaLookupSids(policy, 1, &sid, &list, &names);
ok(status == STATUS_SUCCESS, "got 0x%08x\n", status);
ok(list->Entries > 0, "got %d\n", list->Entries);
if (list->Entries)
{
ok((char*)list->Domains - (char*)list > 0, "%p, %p\n", list, list->Domains);
ok((char*)list->Domains[0].Sid - (char*)list->Domains > 0, "%p, %p\n", list->Domains, list->Domains[0].Sid);
ok(list->Domains[0].Name.MaximumLength > list->Domains[0].Name.Length, "got %d, %d\n", list->Domains[0].Name.MaximumLength,
list->Domains[0].Name.Length);
ok(list->Domains[0].Name.Buffer != NULL, "domain[0] name buffer is null\n");
}
pLsaFreeMemory(names);
pLsaFreeMemory(list);
pFreeSid(sid);
status = pLsaClose(policy);
ok(status == STATUS_SUCCESS, "got 0x%08x\n", status);
}
START_TEST(lsa)
{
if (!init()) {
@ -417,4 +473,5 @@ START_TEST(lsa)
test_lsa();
test_LsaLookupNames2();
test_LsaLookupSids();
test_LsaLookupSids_NullBuffers();
}

View File

@ -30,6 +30,7 @@
#include "winbase.h"
#include "wine/winternl.h"
#include "winreg.h"
#include "winperf.h"
#include "winsvc.h"
#include "winerror.h"
#include "aclapi.h"
@ -774,11 +775,10 @@ cleanup:
static void test_query_value_ex(void)
{
DWORD ret;
DWORD size;
DWORD type;
DWORD ret, size, type;
BYTE buffer[10];
size = sizeof(buffer);
ret = RegQueryValueExA(hkey_main, "TP1_SZ", NULL, &type, NULL, &size);
ok(ret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %d\n", ret);
ok(size == strlen(sTestpath1) + 1, "(%d,%d)\n", (DWORD)strlen(sTestpath1) + 1, size);
@ -1842,7 +1842,7 @@ static void test_reg_query_info(void)
ok(classbufferW[0] == 0x5555, "classbufferW[0] = 0x%x\n", classbufferW[0]);
/* empty key */
sdlen = 0;
sdlen = classlen =0;
ret = RegQueryInfoKeyA(subkey, NULL, &classlen, NULL, &subkeys, &maxsubkeylen, &maxclasslen, &values, &maxvaluenamelen, &maxvaluelen, &sdlen, &lastwrite);
ok(ret == ERROR_SUCCESS, "ret = %d\n", ret);
ok(classlen == strlen(subkey_class), "classlen = %u\n", classlen);
@ -1856,7 +1856,7 @@ static void test_reg_query_info(void)
ok(lastwrite.dwLowDateTime != 0, "lastwrite.dwLowDateTime = %u\n", lastwrite.dwLowDateTime);
ok(lastwrite.dwHighDateTime != 0, "lastwrite.dwHighDateTime = %u\n", lastwrite.dwHighDateTime);
sdlen = 0;
sdlen = classlen = 0;
ret = RegQueryInfoKeyW(subkey, NULL, &classlen, NULL, &subkeys, &maxsubkeylen, &maxclasslen, &values, &maxvaluenamelen, &maxvaluelen, &sdlen, &lastwrite);
ok(ret == ERROR_SUCCESS, "ret = %d\n", ret);
ok(classlen == strlen(subkey_class), "classlen = %u\n", classlen);
@ -1877,7 +1877,7 @@ static void test_reg_query_info(void)
ok(ret == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", ret);
/* with subkey & default value */
sdlen = 0;
sdlen = classlen = 0;
ret = RegQueryInfoKeyA(subkey, NULL, &classlen, NULL, &subkeys, &maxsubkeylen, &maxclasslen, &values, &maxvaluenamelen, &maxvaluelen, &sdlen, &lastwrite);
ok(ret == ERROR_SUCCESS, "ret = %d\n", ret);
ok(classlen == strlen(subkey_class), "classlen = %u\n", classlen);
@ -1891,7 +1891,7 @@ static void test_reg_query_info(void)
ok(lastwrite.dwLowDateTime != 0, "lastwrite.dwLowDateTime = %u\n", lastwrite.dwLowDateTime);
ok(lastwrite.dwHighDateTime != 0, "lastwrite.dwHighDateTime = %u\n", lastwrite.dwHighDateTime);
sdlen = 0;
sdlen = classlen = 0;
ret = RegQueryInfoKeyW(subkey, NULL, &classlen, NULL, &subkeys, &maxsubkeylen, &maxclasslen, &values, &maxvaluenamelen, &maxvaluelen, &sdlen, &lastwrite);
ok(ret == ERROR_SUCCESS, "ret = %d\n", ret);
ok(classlen == strlen(subkey_class), "classlen = %u\n", classlen);
@ -1912,12 +1912,14 @@ static void test_reg_query_info(void)
ok(ret == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", ret);
/* with named value */
classlen = 0;
ret = RegQueryInfoKeyA(subkey, NULL, &classlen, NULL, &subkeys, &maxsubkeylen, &maxclasslen, &values, &maxvaluenamelen, &maxvaluelen, &sdlen, &lastwrite);
ok(ret == ERROR_SUCCESS, "ret = %d\n", ret);
ok(values == 3, "values = %u\n", values);
ok(maxvaluenamelen == strlen("value one"), "maxvaluenamelen = %u\n", maxvaluenamelen);
ok(maxvaluelen == sizeof("second value data") * sizeof(WCHAR), "maxvaluelen = %u\n", maxvaluelen);
classlen = 0;
ret = RegQueryInfoKeyW(subkey, NULL, &classlen, NULL, &subkeys, &maxsubkeylen, &maxclasslen, &values, &maxvaluenamelen, &maxvaluelen, &sdlen, &lastwrite);
ok(ret == ERROR_SUCCESS, "ret = %d\n", ret);
ok(values == 3, "values = %u\n", values);
@ -3301,6 +3303,38 @@ static void test_classesroot_mask(void)
RegCloseKey( hkey );
}
static void test_perflib_key(void)
{
DWORD size;
LONG ret;
HKEY key;
ret = RegOpenKeyA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Perflib\\009", &key);
ok(ret == ERROR_SUCCESS, "RegOpenKeyA failed with error %u\n", ret);
ret = RegQueryValueExA(key, "Counter", NULL, NULL, NULL, &size);
if (ret != ERROR_SUCCESS)
{
skip("Perflib\\009\\Counter does not exist, skipping perflib test\n");
goto done;
}
ok(ret == ERROR_SUCCESS, "RegQueryValueExA failed with error %u\n", ret);
/* Windows only compares the first few characters of the value name.
* On Windows XP / 2003, it is sufficient to use "Cou", newer versions
* require a longer substring. */
ret = RegQueryValueExA(key, "Counters", NULL, NULL, NULL, &size);
ok(ret == ERROR_SUCCESS, "RegQueryValueExA failed with error %u\n", ret);
ret = RegQueryValueExA(key, "Counter2", NULL, NULL, NULL, &size);
todo_wine ok(ret == ERROR_SUCCESS, "RegQueryValueExA failed with error %u\n", ret);
ret = RegQueryValueExA(key, "CounterWine", NULL, NULL, NULL, &size);
todo_wine ok(ret == ERROR_SUCCESS, "RegQueryValueExA failed with error %u\n", ret);
done:
RegCloseKey(key);
}
static void test_deleted_key(void)
{
HKEY hkey, hkey2;
@ -3489,6 +3523,54 @@ static void test_RegNotifyChangeKeyValue(void)
CloseHandle(event);
}
static void test_RegQueryValueExPerformanceData(void)
{
DWORD cbData, len;
BYTE *value;
DWORD dwret;
LONG limit = 6;
PERF_DATA_BLOCK *pdb;
/* Test with data == NULL */
dwret = RegQueryValueExA( HKEY_PERFORMANCE_DATA, "Global", NULL, NULL, NULL, &cbData );
todo_wine ok( dwret == ERROR_MORE_DATA, "expected ERROR_MORE_DATA, got %d\n", dwret );
/* Test ERROR_MORE_DATA, start with small buffer */
len = 10;
value = HeapAlloc(GetProcessHeap(), 0, len);
cbData = len;
dwret = RegQueryValueExA( HKEY_PERFORMANCE_DATA, "Global", NULL, NULL, value, &cbData );
todo_wine ok( dwret == ERROR_MORE_DATA, "expected ERROR_MORE_DATA, got %d\n", dwret );
while( dwret == ERROR_MORE_DATA && limit)
{
len = len * 10;
value = HeapReAlloc( GetProcessHeap(), 0, value, len );
cbData = len;
dwret = RegQueryValueExA( HKEY_PERFORMANCE_DATA, "Global", NULL, NULL, value, &cbData );
limit--;
}
ok(limit > 0, "too many times ERROR_MORE_DATA returned\n");
todo_wine ok(dwret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %d\n", dwret);
/* Check returned data */
if (dwret == ERROR_SUCCESS)
{
todo_wine ok(len >= sizeof(PERF_DATA_BLOCK), "got size %d\n", len);
if (len >= sizeof(PERF_DATA_BLOCK)) {
pdb = (PERF_DATA_BLOCK*) value;
ok(pdb->Signature[0] == 'P', "expected Signature[0] = 'P', got 0x%x\n", pdb->Signature[0]);
ok(pdb->Signature[1] == 'E', "expected Signature[1] = 'E', got 0x%x\n", pdb->Signature[1]);
ok(pdb->Signature[2] == 'R', "expected Signature[2] = 'R', got 0x%x\n", pdb->Signature[2]);
ok(pdb->Signature[3] == 'F', "expected Signature[3] = 'F', got 0x%x\n", pdb->Signature[3]);
/* TODO: check other field */
}
}
HeapFree(GetProcessHeap(), 0, value);
}
START_TEST(registry)
{
/* Load pointers for functions that are not available in all Windows versions */
@ -3513,6 +3595,7 @@ START_TEST(registry)
test_classesroot();
test_classesroot_enum();
test_classesroot_mask();
test_perflib_key();
test_reg_save_key();
test_reg_load_key();
test_reg_unload_key();
@ -3524,6 +3607,7 @@ START_TEST(registry)
test_delete_key_value();
test_RegOpenCurrentUser();
test_RegNotifyChangeKeyValue();
test_RegQueryValueExPerformanceData();
/* cleanup */
delete_key( hkey_main );

File diff suppressed because it is too large Load Diff

View File

@ -382,7 +382,7 @@ static void test_create_delete_svc(void)
{
svc_handle1 = CreateServiceA(scm_handle, servicename, display, 0, SERVICE_WIN32_OWN_PROCESS,
SERVICE_DISABLED, 0, pathname, NULL, NULL, NULL, NULL, NULL);
ok(!svc_handle1, "Expected failure\n");
ok(!svc_handle1, "Expected failure for display name '%s'\n", display);
ok(GetLastError() == ERROR_DUPLICATE_SERVICE_NAME,
"Expected ERROR_DUPLICATE_SERVICE_NAME, got %d\n", GetLastError());
}
@ -1404,7 +1404,7 @@ static void test_enum_svc(void)
/* lpServiceName and lpDisplayName should always be filled */
ok(services[i].lpServiceName[0], "Expected a service name\n");
ok(services[i].lpDisplayName[0], "Expected a display name\n");
ok(services[i].lpDisplayName && services[i].lpDisplayName[0], "Expected a display name\n");
/* Decrement the counters to see if the functions calls return the same
* numbers as the contents of these structures.
@ -1707,7 +1707,7 @@ static void test_enum_svc(void)
/* lpServiceName and lpDisplayName should always be filled */
ok(exservices[i].lpServiceName[0], "Expected a service name\n");
ok(exservices[i].lpDisplayName[0], "Expected a display name\n");
ok(exservices[i].lpDisplayName && exservices[i].lpDisplayName[0], "Expected a display name\n");
/* Decrement the counters to see if the functions calls return the
* same numbers as the contents of these structures.