mirror of
https://github.com/ApfelTeeSaft/reactos.git
synced 2026-08-26 19:33:31 +00:00
[ADVAPI32_WINETEST] Sync to advapi32 winetest to wine-10.0
- [ADVAPI32_WINETEST] Sync to wine-10.0 - [ADVAPI32_WINETEST] Remove obsolete ReactOS hacks - [ADVAPI32_WINETEST] Add new hacks for Windows Server 2003+ and ReactOS
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
|
||||
remove_definitions(-DWINVER=0x502 -D_WIN32_WINNT=0x502)
|
||||
add_definitions(-DWINVER=0x0A00 -D_WIN32_WINNT=0x0A00 -DNTDDI_VERSION=0x0A000000)
|
||||
include_directories(BEFORE ${REACTOS_SOURCE_DIR}/sdk/include/wine)
|
||||
|
||||
list(APPEND SOURCE
|
||||
@@ -10,6 +12,7 @@ list(APPEND SOURCE
|
||||
crypt_sha.c
|
||||
eventlog.c
|
||||
lsa.c
|
||||
perf.c
|
||||
registry.c
|
||||
security.c
|
||||
service.c)
|
||||
@@ -22,10 +25,17 @@ add_executable(advapi32_winetest
|
||||
${PCH_SKIP_SOURCE})
|
||||
|
||||
if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
||||
target_compile_options(advapi32_winetest PRIVATE "-Wno-format")
|
||||
target_compile_options(advapi32_winetest PRIVATE
|
||||
-Wno-format
|
||||
-Wno-unused-function
|
||||
-Wno-old-style-declaration)
|
||||
endif()
|
||||
|
||||
set_module_type(advapi32_winetest win32cui)
|
||||
add_importlibs(advapi32_winetest advapi32 ole32 user32 msvcrt kernel32 ntdll)
|
||||
add_pch(advapi32_winetest precomp.h "${PCH_SKIP_SOURCE}")
|
||||
add_rostests_file(TARGET advapi32_winetest)
|
||||
target_compile_definitions(advapi32_winetest PRIVATE
|
||||
strcmpi=_strcmpi
|
||||
wcsnicmp=_wcsnicmp
|
||||
wcsicmp=_wcsicmp)
|
||||
|
||||
@@ -51,19 +51,19 @@ static void test_CredReadA(void)
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = pCredReadA(TEST_TARGET_NAME, -1, 0, &cred);
|
||||
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
|
||||
"CredReadA should have failed with ERROR_INVALID_PARAMETER instead of %d\n",
|
||||
"CredReadA should have failed with ERROR_INVALID_PARAMETER instead of %ld\n",
|
||||
GetLastError());
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = pCredReadA(TEST_TARGET_NAME, CRED_TYPE_GENERIC, 0xdeadbeef, &cred);
|
||||
ok(!ret && ( GetLastError() == ERROR_INVALID_FLAGS || GetLastError() == ERROR_INVALID_PARAMETER ),
|
||||
"CredReadA should have failed with ERROR_INVALID_FLAGS or ERROR_INVALID_PARAMETER instead of %d\n",
|
||||
"CredReadA should have failed with ERROR_INVALID_FLAGS or ERROR_INVALID_PARAMETER instead of %ld\n",
|
||||
GetLastError());
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = pCredReadA(NULL, CRED_TYPE_GENERIC, 0, &cred);
|
||||
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
|
||||
"CredReadA should have failed with ERROR_INVALID_PARAMETER instead of %d\n",
|
||||
"CredReadA should have failed with ERROR_INVALID_PARAMETER instead of %ld\n",
|
||||
GetLastError());
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ static void test_CredWriteA(void)
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = pCredWriteA(NULL, 0);
|
||||
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
|
||||
"CredWriteA should have failed with ERROR_INVALID_PARAMETER instead of %d\n",
|
||||
"CredWriteA should have failed with ERROR_INVALID_PARAMETER instead of %ld\n",
|
||||
GetLastError());
|
||||
|
||||
new_cred.Flags = 0;
|
||||
@@ -93,7 +93,7 @@ static void test_CredWriteA(void)
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = pCredWriteA(&new_cred, 0);
|
||||
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
|
||||
"CredWriteA should have failed with ERROR_INVALID_PARAMETER instead of %d\n",
|
||||
"CredWriteA should have failed with ERROR_INVALID_PARAMETER instead of %ld\n",
|
||||
GetLastError());
|
||||
|
||||
new_cred.TargetName = (char *)TEST_TARGET_NAME;
|
||||
@@ -105,63 +105,63 @@ static void test_CredWriteA(void)
|
||||
{
|
||||
ok(GetLastError() == ERROR_SUCCESS ||
|
||||
GetLastError() == ERROR_IO_PENDING, /* Vista */
|
||||
"Expected ERROR_IO_PENDING, got %d\n", GetLastError());
|
||||
"Expected ERROR_IO_PENDING, got %ld\n", GetLastError());
|
||||
}
|
||||
else
|
||||
{
|
||||
ok(GetLastError() == ERROR_BAD_USERNAME ||
|
||||
GetLastError() == ERROR_NO_SUCH_LOGON_SESSION, /* Vista */
|
||||
"CredWrite with username without domain should return ERROR_BAD_USERNAME"
|
||||
"or ERROR_NO_SUCH_LOGON_SESSION not %d\n", GetLastError());
|
||||
"or ERROR_NO_SUCH_LOGON_SESSION not %ld\n", GetLastError());
|
||||
}
|
||||
|
||||
new_cred.UserName = NULL;
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = pCredWriteA(&new_cred, 0);
|
||||
ok(!ret && GetLastError() == ERROR_BAD_USERNAME,
|
||||
"CredWriteA with NULL username should have failed with ERROR_BAD_USERNAME instead of %d\n",
|
||||
"CredWriteA with NULL username should have failed with ERROR_BAD_USERNAME instead of %ld\n",
|
||||
GetLastError());
|
||||
|
||||
new_cred.UserName = (char *)"winetest";
|
||||
new_cred.Persist = CRED_PERSIST_LOCAL_MACHINE;
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = pCredWriteA(&new_cred, 0);
|
||||
ok(ret || broken(!ret), "CredWriteA failed with error %u\n", GetLastError());
|
||||
ok(ret || broken(!ret), "CredWriteA failed with error %lu\n", GetLastError());
|
||||
if (ret)
|
||||
{
|
||||
ret = pCredDeleteA(TEST_TARGET_NAME, CRED_TYPE_DOMAIN_PASSWORD, 0);
|
||||
ok(ret, "CredDeleteA failed with error %u\n", GetLastError());
|
||||
ok(ret, "CredDeleteA failed with error %lu\n", GetLastError());
|
||||
}
|
||||
new_cred.Type = CRED_TYPE_GENERIC;
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = pCredWriteA(&new_cred, 0);
|
||||
ok(ret || broken(!ret), "CredWriteA failed with error %u\n", GetLastError());
|
||||
ok(ret || broken(!ret), "CredWriteA failed with error %lu\n", GetLastError());
|
||||
if (ret)
|
||||
{
|
||||
ret = pCredDeleteA(TEST_TARGET_NAME, CRED_TYPE_GENERIC, 0);
|
||||
ok(ret, "CredDeleteA failed with error %u\n", GetLastError());
|
||||
ok(ret, "CredDeleteA failed with error %lu\n", GetLastError());
|
||||
}
|
||||
new_cred.Persist = CRED_PERSIST_SESSION;
|
||||
ret = pCredWriteA(&new_cred, 0);
|
||||
ok(ret, "CredWriteA failed with error %u\n", GetLastError());
|
||||
ok(ret, "CredWriteA failed with error %lu\n", GetLastError());
|
||||
|
||||
ret = pCredDeleteA(TEST_TARGET_NAME, CRED_TYPE_GENERIC, 0);
|
||||
ok(ret, "CredDeleteA failed with error %u\n", GetLastError());
|
||||
ok(ret, "CredDeleteA failed with error %lu\n", GetLastError());
|
||||
|
||||
new_cred.Type = CRED_TYPE_DOMAIN_PASSWORD;
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = pCredWriteA(&new_cred, 0);
|
||||
ok(ret || broken(!ret), "CredWriteA failed with error %u\n", GetLastError());
|
||||
ok(ret || broken(!ret), "CredWriteA failed with error %lu\n", GetLastError());
|
||||
if (ret)
|
||||
{
|
||||
ret = pCredDeleteA(TEST_TARGET_NAME, CRED_TYPE_DOMAIN_PASSWORD, 0);
|
||||
ok(ret, "CredDeleteA failed with error %u\n", GetLastError());
|
||||
ok(ret, "CredDeleteA failed with error %lu\n", GetLastError());
|
||||
}
|
||||
new_cred.UserName = NULL;
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = pCredWriteA(&new_cred, 0);
|
||||
ok(!ret, "CredWriteA succeeded\n");
|
||||
ok(GetLastError() == ERROR_BAD_USERNAME, "got %u\n", GetLastError());
|
||||
ok(GetLastError() == ERROR_BAD_USERNAME, "got %lu\n", GetLastError());
|
||||
}
|
||||
|
||||
static void test_CredDeleteA(void)
|
||||
@@ -171,13 +171,13 @@ static void test_CredDeleteA(void)
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = pCredDeleteA(TEST_TARGET_NAME, -1, 0);
|
||||
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
|
||||
"CredDeleteA should have failed with ERROR_INVALID_PARAMETER instead of %d\n",
|
||||
"CredDeleteA should have failed with ERROR_INVALID_PARAMETER instead of %ld\n",
|
||||
GetLastError());
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = pCredDeleteA(TEST_TARGET_NAME, CRED_TYPE_GENERIC, 0xdeadbeef);
|
||||
ok(!ret && ( GetLastError() == ERROR_INVALID_FLAGS || GetLastError() == ERROR_INVALID_PARAMETER /* Vista */ ),
|
||||
"CredDeleteA should have failed with ERROR_INVALID_FLAGS or ERROR_INVALID_PARAMETER instead of %d\n",
|
||||
"CredDeleteA should have failed with ERROR_INVALID_FLAGS or ERROR_INVALID_PARAMETER instead of %ld\n",
|
||||
GetLastError());
|
||||
}
|
||||
|
||||
@@ -208,7 +208,7 @@ if(0)
|
||||
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",
|
||||
"CredReadDomainCredentialsA should have failed with ERROR_INVALID_PARAMETER instead of %ld\n",
|
||||
GetLastError());
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
@@ -216,7 +216,7 @@ if(0)
|
||||
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",
|
||||
"CredReadDomainCredentialsA should have failed with ERROR_NOT_FOUND instead of %ld\n",
|
||||
GetLastError());
|
||||
ok(count ==0 && creds == NULL, "CredReadDomainCredentialsA must not return any result\n");
|
||||
|
||||
@@ -227,7 +227,7 @@ if(0)
|
||||
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",
|
||||
"Expected ERROR_NOT_FOUND or ERROR_INVALID_PARAMETER instead of %ld\n",
|
||||
GetLastError());
|
||||
|
||||
info.DnsServerName = NULL;
|
||||
@@ -237,7 +237,7 @@ if(0)
|
||||
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",
|
||||
"Expected ERROR_NOT_FOUND or ERROR_INVALID_PARAMETER instead of %ld\n",
|
||||
GetLastError());
|
||||
}
|
||||
|
||||
@@ -245,15 +245,15 @@ static void check_blob(int line, DWORD cred_type, PCREDENTIALA cred)
|
||||
{
|
||||
if (cred_type == CRED_TYPE_DOMAIN_PASSWORD)
|
||||
{
|
||||
todo_ros
|
||||
ok_(__FILE__, line)(cred->CredentialBlobSize == 0, "expected CredentialBlobSize of 0 but got %d\n", cred->CredentialBlobSize);
|
||||
todo_ros
|
||||
todo_wine
|
||||
ok_(__FILE__, line)(cred->CredentialBlobSize == 0, "expected CredentialBlobSize of 0 but got %ld\n", cred->CredentialBlobSize);
|
||||
todo_wine
|
||||
ok_(__FILE__, line)(!cred->CredentialBlob, "expected NULL credentials but got %p\n", cred->CredentialBlob);
|
||||
}
|
||||
else
|
||||
{
|
||||
DWORD size=sizeof(TEST_PASSWORD);
|
||||
ok_(__FILE__, line)(cred->CredentialBlobSize == size, "expected CredentialBlobSize of %u but got %u\n", size, cred->CredentialBlobSize);
|
||||
ok_(__FILE__, line)(cred->CredentialBlobSize == size, "expected CredentialBlobSize of %lu but got %lu\n", size, cred->CredentialBlobSize);
|
||||
ok_(__FILE__, line)(cred->CredentialBlob != NULL, "CredentialBlob should be present\n");
|
||||
if (cred->CredentialBlob)
|
||||
ok_(__FILE__, line)(!memcmp(cred->CredentialBlob, TEST_PASSWORD, size), "wrong CredentialBlob\n");
|
||||
@@ -283,7 +283,7 @@ static void test_generic(void)
|
||||
|
||||
ret = pCredWriteA(&new_cred, 0);
|
||||
ok(ret || broken(GetLastError() == ERROR_NO_SUCH_LOGON_SESSION),
|
||||
"CredWriteA failed with error %d\n", GetLastError());
|
||||
"CredWriteA failed with error %ld\n", GetLastError());
|
||||
if (!ret)
|
||||
{
|
||||
skip("couldn't write generic credentials, skipping tests\n");
|
||||
@@ -291,7 +291,7 @@ static void test_generic(void)
|
||||
}
|
||||
|
||||
ret = pCredEnumerateA(NULL, 0, &count, &creds);
|
||||
ok(ret, "CredEnumerateA failed with error %d\n", GetLastError());
|
||||
ok(ret, "CredEnumerateA failed with error %ld\n", GetLastError());
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
@@ -299,12 +299,12 @@ static void test_generic(void)
|
||||
{
|
||||
ok(creds[i]->Type == CRED_TYPE_GENERIC ||
|
||||
creds[i]->Type == CRED_TYPE_DOMAIN_PASSWORD, /* Vista */
|
||||
"expected creds[%d]->Type CRED_TYPE_GENERIC or CRED_TYPE_DOMAIN_PASSWORD but got %d\n", i, creds[i]->Type);
|
||||
ok(!creds[i]->Flags, "expected creds[%d]->Flags 0 but got 0x%x\n", i, creds[i]->Flags);
|
||||
ok(!strcmp(creds[i]->Comment, "Comment"), "expected creds[%d]->Comment \"Comment\" but got \"%s\"\n", i, creds[i]->Comment);
|
||||
"expected creds[%ld]->Type CRED_TYPE_GENERIC or CRED_TYPE_DOMAIN_PASSWORD but got %ld\n", i, creds[i]->Type);
|
||||
ok(!creds[i]->Flags, "expected creds[%ld]->Flags 0 but got 0x%lx\n", i, creds[i]->Flags);
|
||||
ok(!strcmp(creds[i]->Comment, "Comment"), "expected creds[%ld]->Comment \"Comment\" but got \"%s\"\n", i, creds[i]->Comment);
|
||||
check_blob(__LINE__, creds[i]->Type, creds[i]);
|
||||
ok(creds[i]->Persist, "expected creds[%d]->Persist CRED_PERSIST_ENTERPRISE but got %d\n", i, creds[i]->Persist);
|
||||
ok(!strcmp(creds[i]->UserName, "winetest"), "expected creds[%d]->UserName \"winetest\" but got \"%s\"\n", i, creds[i]->UserName);
|
||||
ok(creds[i]->Persist, "expected creds[%ld]->Persist CRED_PERSIST_ENTERPRISE but got %ld\n", i, creds[i]->Persist);
|
||||
ok(!strcmp(creds[i]->UserName, "winetest"), "expected creds[%ld]->UserName \"winetest\" but got \"%s\"\n", i, creds[i]->UserName);
|
||||
found = TRUE;
|
||||
}
|
||||
}
|
||||
@@ -312,11 +312,11 @@ static void test_generic(void)
|
||||
ok(found, "credentials not found\n");
|
||||
|
||||
ret = pCredReadA(TEST_TARGET_NAME, CRED_TYPE_GENERIC, 0, &cred);
|
||||
ok(ret, "CredReadA failed with error %d\n", GetLastError());
|
||||
ok(ret, "CredReadA failed with error %ld\n", GetLastError());
|
||||
pCredFree(cred);
|
||||
|
||||
ret = pCredDeleteA(TEST_TARGET_NAME, CRED_TYPE_GENERIC, 0);
|
||||
ok(ret, "CredDeleteA failed with error %d\n", GetLastError());
|
||||
ok(ret, "CredDeleteA failed with error %ld\n", GetLastError());
|
||||
}
|
||||
|
||||
static void test_domain_password(DWORD cred_type)
|
||||
@@ -346,21 +346,21 @@ static void test_domain_password(DWORD cred_type)
|
||||
"or are disabled. Skipping\n");
|
||||
return;
|
||||
}
|
||||
ok(ret, "CredWriteA failed with error %d\n", GetLastError());
|
||||
ok(ret, "CredWriteA failed with error %ld\n", GetLastError());
|
||||
|
||||
ret = pCredEnumerateA(NULL, 0, &count, &creds);
|
||||
ok(ret, "CredEnumerateA failed with error %d\n", GetLastError());
|
||||
ok(ret, "CredEnumerateA failed with error %ld\n", GetLastError());
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
if (creds[i]->TargetName && !strcmp(creds[i]->TargetName, TEST_TARGET_NAME))
|
||||
{
|
||||
ok(creds[i]->Type == cred_type, "expected creds[%d]->Type CRED_TYPE_DOMAIN_PASSWORD but got %d\n", i, creds[i]->Type);
|
||||
ok(!creds[i]->Flags, "expected creds[%d]->Flags 0 but got 0x%x\n", i, creds[i]->Flags);
|
||||
ok(!strcmp(creds[i]->Comment, "Comment"), "expected creds[%d]->Comment \"Comment\" but got \"%s\"\n", i, creds[i]->Comment);
|
||||
ok(creds[i]->Type == cred_type, "expected creds[%ld]->Type CRED_TYPE_DOMAIN_PASSWORD but got %ld\n", i, creds[i]->Type);
|
||||
ok(!creds[i]->Flags, "expected creds[%ld]->Flags 0 but got 0x%lx\n", i, creds[i]->Flags);
|
||||
ok(!strcmp(creds[i]->Comment, "Comment"), "expected creds[%ld]->Comment \"Comment\" but got \"%s\"\n", i, creds[i]->Comment);
|
||||
check_blob(__LINE__, cred_type, creds[i]);
|
||||
ok(creds[i]->Persist, "expected creds[%d]->Persist CRED_PERSIST_ENTERPRISE but got %d\n", i, creds[i]->Persist);
|
||||
ok(!strcmp(creds[i]->UserName, "test\\winetest"), "expected creds[%d]->UserName \"winetest\" but got \"%s\"\n", i, creds[i]->UserName);
|
||||
ok(creds[i]->Persist, "expected creds[%ld]->Persist CRED_PERSIST_ENTERPRISE but got %ld\n", i, creds[i]->Persist);
|
||||
ok(!strcmp(creds[i]->UserName, "test\\winetest"), "expected creds[%ld]->UserName \"winetest\" but got \"%s\"\n", i, creds[i]->UserName);
|
||||
found = TRUE;
|
||||
}
|
||||
}
|
||||
@@ -368,7 +368,7 @@ static void test_domain_password(DWORD cred_type)
|
||||
ok(found, "credentials not found\n");
|
||||
|
||||
ret = pCredReadA(TEST_TARGET_NAME, cred_type, 0, &cred);
|
||||
ok(ret, "CredReadA failed with error %d\n", GetLastError());
|
||||
ok(ret, "CredReadA failed with error %ld\n", GetLastError());
|
||||
if (ret) /* don't check the values of cred, if CredReadA failed. */
|
||||
{
|
||||
check_blob(__LINE__, cred_type, cred);
|
||||
@@ -376,7 +376,7 @@ static void test_domain_password(DWORD cred_type)
|
||||
}
|
||||
|
||||
ret = pCredDeleteA(TEST_TARGET_NAME, cred_type, 0);
|
||||
ok(ret, "CredDeleteA failed with error %d\n", GetLastError());
|
||||
ok(ret, "CredDeleteA failed with error %ld\n", GetLastError());
|
||||
}
|
||||
|
||||
static void test_CredMarshalCredentialA(void)
|
||||
@@ -397,7 +397,7 @@ static void test_CredMarshalCredentialA(void)
|
||||
ret = pCredMarshalCredentialA( 0, NULL, NULL );
|
||||
error = GetLastError();
|
||||
ok( !ret, "unexpected success\n" );
|
||||
ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
|
||||
ok( error == ERROR_INVALID_PARAMETER, "got %lu\n", error );
|
||||
|
||||
memset( cert.rgbHashOfCert, 0, sizeof(cert.rgbHashOfCert) );
|
||||
cert.cbSize = sizeof(cert);
|
||||
@@ -405,28 +405,28 @@ static void test_CredMarshalCredentialA(void)
|
||||
ret = pCredMarshalCredentialA( 0, &cert, NULL );
|
||||
error = GetLastError();
|
||||
ok( !ret, "unexpected success\n" );
|
||||
ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
|
||||
ok( error == ERROR_INVALID_PARAMETER, "got %lu\n", error );
|
||||
|
||||
str = (char *)0xdeadbeef;
|
||||
SetLastError( 0xdeadbeef );
|
||||
ret = pCredMarshalCredentialA( 0, &cert, &str );
|
||||
error = GetLastError();
|
||||
ok( !ret, "unexpected success\n" );
|
||||
ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
|
||||
ok( error == ERROR_INVALID_PARAMETER, "got %lu\n", error );
|
||||
ok( str == (char *)0xdeadbeef, "got %p\n", str );
|
||||
|
||||
SetLastError( 0xdeadbeef );
|
||||
ret = pCredMarshalCredentialA( CertCredential, NULL, NULL );
|
||||
error = GetLastError();
|
||||
ok( !ret, "unexpected success\n" );
|
||||
ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
|
||||
ok( error == ERROR_INVALID_PARAMETER, "got %lu\n", error );
|
||||
|
||||
if (0) { /* crash */
|
||||
SetLastError( 0xdeadbeef );
|
||||
ret = pCredMarshalCredentialA( CertCredential, &cert, NULL );
|
||||
error = GetLastError();
|
||||
ok( !ret, "unexpected success\n" );
|
||||
ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
|
||||
ok( error == ERROR_INVALID_PARAMETER, "got %lu\n", error );
|
||||
}
|
||||
|
||||
cert.cbSize = 0;
|
||||
@@ -435,13 +435,13 @@ static void test_CredMarshalCredentialA(void)
|
||||
ret = pCredMarshalCredentialA( CertCredential, &cert, &str );
|
||||
error = GetLastError();
|
||||
ok( !ret, "unexpected success\n" );
|
||||
ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
|
||||
ok( error == ERROR_INVALID_PARAMETER, "got %lu\n", error );
|
||||
ok( str == (char *)0xdeadbeef, "got %p\n", str );
|
||||
|
||||
cert.cbSize = sizeof(cert) + 4;
|
||||
str = NULL;
|
||||
ret = pCredMarshalCredentialA( CertCredential, &cert, &str );
|
||||
ok( ret, "unexpected failure %u\n", GetLastError() );
|
||||
ok( ret, "unexpected failure %lu\n", GetLastError() );
|
||||
ok( str != NULL, "str not set\n" );
|
||||
ok( !lstrcmpA( str, "@@BAAAAAAAAAAAAAAAAAAAAAAAAAAA" ), "got %s\n", str );
|
||||
pCredFree( str );
|
||||
@@ -450,7 +450,7 @@ static void test_CredMarshalCredentialA(void)
|
||||
cert.rgbHashOfCert[0] = 2;
|
||||
str = NULL;
|
||||
ret = pCredMarshalCredentialA( CertCredential, &cert, &str );
|
||||
ok( ret, "unexpected failure %u\n", GetLastError() );
|
||||
ok( ret, "unexpected failure %lu\n", GetLastError() );
|
||||
ok( str != NULL, "str not set\n" );
|
||||
ok( !lstrcmpA( str, "@@BCAAAAAAAAAAAAAAAAAAAAAAAAAA" ), "got %s\n", str );
|
||||
pCredFree( str );
|
||||
@@ -458,7 +458,7 @@ static void test_CredMarshalCredentialA(void)
|
||||
cert.rgbHashOfCert[0] = 255;
|
||||
str = NULL;
|
||||
ret = pCredMarshalCredentialA( CertCredential, &cert, &str );
|
||||
ok( ret, "unexpected failure %u\n", GetLastError() );
|
||||
ok( ret, "unexpected failure %lu\n", GetLastError() );
|
||||
ok( str != NULL, "str not set\n" );
|
||||
ok( !lstrcmpA( str, "@@B-DAAAAAAAAAAAAAAAAAAAAAAAAA" ), "got %s\n", str );
|
||||
pCredFree( str );
|
||||
@@ -467,7 +467,7 @@ static void test_CredMarshalCredentialA(void)
|
||||
cert.rgbHashOfCert[1] = 1;
|
||||
str = NULL;
|
||||
ret = pCredMarshalCredentialA( CertCredential, &cert, &str );
|
||||
ok( ret, "unexpected failure %u\n", GetLastError() );
|
||||
ok( ret, "unexpected failure %lu\n", GetLastError() );
|
||||
ok( str != NULL, "str not set\n" );
|
||||
ok( !lstrcmpA( str, "@@BBEAAAAAAAAAAAAAAAAAAAAAAAAA" ), "got %s\n", str );
|
||||
pCredFree( str );
|
||||
@@ -477,7 +477,7 @@ static void test_CredMarshalCredentialA(void)
|
||||
cert.rgbHashOfCert[2] = 1;
|
||||
str = NULL;
|
||||
ret = pCredMarshalCredentialA( CertCredential, &cert, &str );
|
||||
ok( ret, "unexpected failure %u\n", GetLastError() );
|
||||
ok( ret, "unexpected failure %lu\n", GetLastError() );
|
||||
ok( str != NULL, "str not set\n" );
|
||||
ok( !lstrcmpA( str, "@@BBEQAAAAAAAAAAAAAAAAAAAAAAAA" ), "got %s\n", str );
|
||||
pCredFree( str );
|
||||
@@ -489,7 +489,7 @@ static void test_CredMarshalCredentialA(void)
|
||||
cert.rgbHashOfCert[3] = 'e';
|
||||
str = NULL;
|
||||
ret = pCredMarshalCredentialA( CertCredential, &cert, &str );
|
||||
ok( ret, "unexpected failure %u\n", GetLastError() );
|
||||
ok( ret, "unexpected failure %lu\n", GetLastError() );
|
||||
ok( str != NULL, "str not set\n" );
|
||||
ok( !lstrcmpA( str, "@@BXlmblBAAAAAAAAAAAAAAAAAAAAA" ), "got %s\n", str );
|
||||
pCredFree( str );
|
||||
@@ -497,7 +497,7 @@ static void test_CredMarshalCredentialA(void)
|
||||
memset( cert.rgbHashOfCert, 0xff, sizeof(cert.rgbHashOfCert) );
|
||||
str = NULL;
|
||||
ret = pCredMarshalCredentialA( CertCredential, &cert, &str );
|
||||
ok( ret, "unexpected failure %u\n", GetLastError() );
|
||||
ok( ret, "unexpected failure %lu\n", GetLastError() );
|
||||
ok( str != NULL, "str not set\n" );
|
||||
ok( !lstrcmpA( str, "@@B--------------------------P" ), "got %s\n", str );
|
||||
pCredFree( str );
|
||||
@@ -508,7 +508,7 @@ static void test_CredMarshalCredentialA(void)
|
||||
ret = pCredMarshalCredentialA( UsernameTargetCredential, &username, &str );
|
||||
error = GetLastError();
|
||||
ok( !ret, "unexpected success\n" );
|
||||
ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
|
||||
ok( error == ERROR_INVALID_PARAMETER, "got %lu\n", error );
|
||||
ok( str == (char *)0xdeadbeef, "got %p\n", str );
|
||||
|
||||
username.UserName = emptyW;
|
||||
@@ -517,13 +517,13 @@ static void test_CredMarshalCredentialA(void)
|
||||
ret = pCredMarshalCredentialA( UsernameTargetCredential, &username, &str );
|
||||
error = GetLastError();
|
||||
ok( !ret, "unexpected success\n" );
|
||||
ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
|
||||
ok( error == ERROR_INVALID_PARAMETER, "got %lu\n", error );
|
||||
ok( str == (char *)0xdeadbeef, "got %p\n", str );
|
||||
|
||||
username.UserName = tW;
|
||||
str = NULL;
|
||||
ret = pCredMarshalCredentialA( UsernameTargetCredential, &username, &str );
|
||||
ok( ret, "unexpected failure %u\n", GetLastError() );
|
||||
ok( ret, "unexpected failure %lu\n", GetLastError() );
|
||||
ok( str != NULL, "str not set\n" );
|
||||
ok( !lstrcmpA( str, "@@CCAAAAA0BA" ), "got %s\n", str );
|
||||
pCredFree( str );
|
||||
@@ -531,7 +531,7 @@ static void test_CredMarshalCredentialA(void)
|
||||
username.UserName = teW;
|
||||
str = NULL;
|
||||
ret = pCredMarshalCredentialA( UsernameTargetCredential, &username, &str );
|
||||
ok( ret, "unexpected failure %u\n", GetLastError() );
|
||||
ok( ret, "unexpected failure %lu\n", GetLastError() );
|
||||
ok( str != NULL, "str not set\n" );
|
||||
ok( !lstrcmpA( str, "@@CEAAAAA0BQZAA" ), "got %s\n", str );
|
||||
pCredFree( str );
|
||||
@@ -539,7 +539,7 @@ static void test_CredMarshalCredentialA(void)
|
||||
username.UserName = tesW;
|
||||
str = NULL;
|
||||
ret = pCredMarshalCredentialA( UsernameTargetCredential, &username, &str );
|
||||
ok( ret, "unexpected failure %u\n", GetLastError() );
|
||||
ok( ret, "unexpected failure %lu\n", GetLastError() );
|
||||
ok( str != NULL, "str not set\n" );
|
||||
ok( !lstrcmpA( str, "@@CGAAAAA0BQZAMHA" ), "got %s\n", str );
|
||||
pCredFree( str );
|
||||
@@ -547,7 +547,7 @@ static void test_CredMarshalCredentialA(void)
|
||||
username.UserName = testW;
|
||||
str = NULL;
|
||||
ret = pCredMarshalCredentialA( UsernameTargetCredential, &username, &str );
|
||||
ok( ret, "unexpected failure %u\n", GetLastError() );
|
||||
ok( ret, "unexpected failure %lu\n", GetLastError() );
|
||||
ok( str != NULL, "str not set\n" );
|
||||
ok( !lstrcmpA( str, "@@CIAAAAA0BQZAMHA0BA" ), "got %s\n", str );
|
||||
pCredFree( str );
|
||||
@@ -555,7 +555,7 @@ static void test_CredMarshalCredentialA(void)
|
||||
username.UserName = test1W;
|
||||
str = NULL;
|
||||
ret = pCredMarshalCredentialA( UsernameTargetCredential, &username, &str );
|
||||
ok( ret, "unexpected failure %u\n", GetLastError() );
|
||||
ok( ret, "unexpected failure %lu\n", GetLastError() );
|
||||
ok( str != NULL, "str not set\n" );
|
||||
ok( !lstrcmpA( str, "@@CKAAAAA0BQZAMHA0BQMAA" ), "got %s\n", str );
|
||||
pCredFree( str );
|
||||
@@ -627,14 +627,14 @@ static void test_CredUnmarshalCredentialA(void)
|
||||
ret = pCredUnmarshalCredentialA( NULL, NULL, NULL );
|
||||
error = GetLastError();
|
||||
ok( !ret, "unexpected success\n" );
|
||||
ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
|
||||
ok( error == ERROR_INVALID_PARAMETER, "got %lu\n", error );
|
||||
|
||||
cert = NULL;
|
||||
SetLastError( 0xdeadbeef );
|
||||
ret = pCredUnmarshalCredentialA( NULL, NULL, (void **)&cert );
|
||||
error = GetLastError();
|
||||
ok( !ret, "unexpected success\n" );
|
||||
ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
|
||||
ok( error == ERROR_INVALID_PARAMETER, "got %lu\n", error );
|
||||
|
||||
type = 0;
|
||||
cert = NULL;
|
||||
@@ -642,23 +642,23 @@ static void test_CredUnmarshalCredentialA(void)
|
||||
ret = pCredUnmarshalCredentialA( NULL, &type, (void **)&cert );
|
||||
error = GetLastError();
|
||||
ok( !ret, "unexpected success\n" );
|
||||
ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
|
||||
ok( error == ERROR_INVALID_PARAMETER, "got %lu\n", error );
|
||||
|
||||
if (0) { /* crash */
|
||||
SetLastError( 0xdeadbeef );
|
||||
ret = pCredUnmarshalCredentialA( "@@BAAAAAAAAAAAAAAAAAAAAAAAAAAA", &type, NULL );
|
||||
error = GetLastError();
|
||||
ok( !ret, "unexpected success\n" );
|
||||
ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
|
||||
ok( error == ERROR_INVALID_PARAMETER, "got %lu\n", error );
|
||||
|
||||
SetLastError( 0xdeadbeef );
|
||||
ret = pCredUnmarshalCredentialA( "@@BAAAAAAAAAAAAAAAAAAAAAAAAAAA", NULL, (void **)&cert );
|
||||
error = GetLastError();
|
||||
ok( !ret, "unexpected success\n" );
|
||||
ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
|
||||
ok( error == ERROR_INVALID_PARAMETER, "got %lu\n", error );
|
||||
}
|
||||
|
||||
for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++)
|
||||
for (i = 0; i < ARRAY_SIZE(tests); i++)
|
||||
{
|
||||
SetLastError(0xdeadbeef);
|
||||
type = 0;
|
||||
@@ -667,7 +667,7 @@ static void test_CredUnmarshalCredentialA(void)
|
||||
error = GetLastError();
|
||||
if (tests[i].unmarshaled)
|
||||
{
|
||||
ok(ret, "[%u] unexpected failure %u\n", i, error);
|
||||
ok(ret, "[%u] unexpected failure %lu\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)
|
||||
@@ -675,7 +675,7 @@ static void test_CredUnmarshalCredentialA(void)
|
||||
cert = p;
|
||||
hash = tests[i].unmarshaled;
|
||||
ok(cert->cbSize == sizeof(*cert),
|
||||
"[%u] wrong size %u\n", i, cert->cbSize);
|
||||
"[%u] wrong size %lu\n", i, cert->cbSize);
|
||||
for (j = 0; j < sizeof(cert->rgbHashOfCert); j++)
|
||||
ok(cert->rgbHashOfCert[j] == hash[j], "[%u] wrong data\n", i);
|
||||
}
|
||||
@@ -690,7 +690,7 @@ static void test_CredUnmarshalCredentialA(void)
|
||||
else
|
||||
{
|
||||
ok(!ret, "[%u] unexpected success\n", i);
|
||||
ok(error == ERROR_INVALID_PARAMETER, "[%u] got %u\n", i, error);
|
||||
ok(error == ERROR_INVALID_PARAMETER, "[%u] got %lu\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);
|
||||
}
|
||||
@@ -752,11 +752,11 @@ static void test_CredIsMarshaledCredentialA(void)
|
||||
SetLastError(0xdeadbeef);
|
||||
res = pCredIsMarshaledCredentialA(ptr[i]);
|
||||
if (expected)
|
||||
ok(res != FALSE, "%d: got %d and %u for %s (expected TRUE)\n", i, res, GetLastError(), ptr[i]);
|
||||
ok(res != FALSE, "%d: got %d and %lu for %s (expected TRUE)\n", i, res, GetLastError(), ptr[i]);
|
||||
else
|
||||
{
|
||||
/* Windows returns ERROR_INVALID_PARAMETER here, but that's not documented */
|
||||
ok(!res, "%d: got %d and %u for %s (expected FALSE)\n", i, res, GetLastError(), ptr[i]);
|
||||
ok(!res, "%d: got %d and %lu for %s (expected FALSE)\n", i, res, GetLastError(), ptr[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -789,10 +789,10 @@ START_TEST(cred)
|
||||
BOOL ret;
|
||||
DWORD i;
|
||||
ret = pCredGetSessionTypes(CRED_TYPE_MAXIMUM, persists);
|
||||
ok(ret, "CredGetSessionTypes failed with error %d\n", GetLastError());
|
||||
ok(persists[0] == CRED_PERSIST_NONE, "persists[0] = %u instead of CRED_PERSIST_NONE\n", persists[0]);
|
||||
ok(ret, "CredGetSessionTypes failed with error %ld\n", GetLastError());
|
||||
ok(persists[0] == CRED_PERSIST_NONE, "persists[0] = %lu instead of CRED_PERSIST_NONE\n", persists[0]);
|
||||
for (i=0; i < CRED_TYPE_MAXIMUM; i++)
|
||||
ok(persists[i] <= CRED_PERSIST_ENTERPRISE, "bad value for persists[%u]: %u\n", i, persists[i]);
|
||||
ok(persists[i] <= CRED_PERSIST_ENTERPRISE, "bad value for persists[%lu]: %lu\n", i, persists[i]);
|
||||
}
|
||||
else
|
||||
memset(persists, CRED_PERSIST_ENTERPRISE, sizeof(persists));
|
||||
@@ -809,7 +809,7 @@ START_TEST(cred)
|
||||
else
|
||||
test_generic();
|
||||
|
||||
trace("domain password:\n");
|
||||
trace("domain password:\n");
|
||||
if (persists[CRED_TYPE_DOMAIN_PASSWORD] == CRED_PERSIST_NONE)
|
||||
skip("CRED_TYPE_DOMAIN_PASSWORD credentials are not supported or are disabled. Skipping\n");
|
||||
else
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -287,18 +287,18 @@ static void test_SystemFunction004(void)
|
||||
r = pSystemFunction002(out.Buffer, key.Buffer, output);
|
||||
ok(r == STATUS_SUCCESS, "function failed\n");
|
||||
|
||||
ok(((unsigned int*)output)[0] == in.Length, "crypted length wrong\n");
|
||||
ok(((unsigned int*)output)[1] == 1, "crypted value wrong\n");
|
||||
ok(((unsigned int*)output)[0] == in.Length, "encrypted length wrong\n");
|
||||
ok(((unsigned int*)output)[1] == 1, "encrypted value wrong\n");
|
||||
|
||||
memset(output, 0, sizeof output);
|
||||
r = pSystemFunction002(out.Buffer+8, key.Buffer, output);
|
||||
ok(r == STATUS_SUCCESS, "function failed\n");
|
||||
ok(!memcmp(output, inbuf, sizeof output), "crypted data wrong\n");
|
||||
ok(!memcmp(output, inbuf, sizeof output), "encrypted data wrong\n");
|
||||
|
||||
memset(output, 0, sizeof output);
|
||||
r = pSystemFunction002(out.Buffer+16, key.Buffer, output);
|
||||
ok(r == STATUS_SUCCESS, "function failed\n");
|
||||
ok(!memcmp(output, inbuf, sizeof output), "crypted data wrong\n");
|
||||
ok(!memcmp(output, inbuf, sizeof output), "encrypted data wrong\n");
|
||||
}
|
||||
|
||||
static void test_SystemFunction005(void)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -2,6 +2,7 @@
|
||||
* Unit tests for lsa functions
|
||||
*
|
||||
* Copyright (c) 2006 Robert Reif
|
||||
* Copyright (c) 2020 Dmitry Timoshkov
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -26,26 +27,22 @@
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "winreg.h"
|
||||
#ifndef __REACTOS__
|
||||
#include "ntsecapi.h"
|
||||
#endif
|
||||
#include "sddl.h"
|
||||
#include "winnls.h"
|
||||
#include "objbase.h"
|
||||
#include "initguid.h"
|
||||
#include "wine/test.h"
|
||||
#include "winternl.h"
|
||||
#ifdef __REACTOS__
|
||||
#include <ntsecapi.h>
|
||||
#endif
|
||||
#include "ntlsa.h"
|
||||
|
||||
DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
|
||||
|
||||
static BOOL (WINAPI *pGetSystemPreferredUILanguages)(DWORD, ULONG*, WCHAR*, ULONG*);
|
||||
static NTSTATUS (WINAPI *pLsaGetUserName)(PUNICODE_STRING *user, PUNICODE_STRING *domain);
|
||||
|
||||
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;
|
||||
@@ -53,23 +50,15 @@ 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 = LsaOpenPolicy( &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 = LsaOpenPolicy( NULL, &object_attributes, POLICY_ALL_ACCESS, &handle);
|
||||
ok(status == STATUS_SUCCESS || status == STATUS_ACCESS_DENIED,
|
||||
"LsaOpenPolicy(POLICY_ALL_ACCESS) returned 0x%08x\n", status);
|
||||
"LsaOpenPolicy(POLICY_ALL_ACCESS) returned 0x%08lx\n", status);
|
||||
|
||||
/* try a more restricted access mask if necessary */
|
||||
if (status == STATUS_ACCESS_DENIED) {
|
||||
trace("LsaOpenPolicy(POLICY_ALL_ACCESS) failed, trying POLICY_VIEW_LOCAL_INFORMATION|POLICY_LOOKUP_NAMES\n");
|
||||
status = LsaOpenPolicy( NULL, &object_attributes, POLICY_VIEW_LOCAL_INFORMATION|POLICY_LOOKUP_NAMES, &handle);
|
||||
ok(status == STATUS_SUCCESS, "LsaOpenPolicy(POLICY_VIEW_LOCAL_INFORMATION|POLICY_LOOKUP_NAMES) returned 0x%08x\n", status);
|
||||
ok(status == STATUS_SUCCESS, "LsaOpenPolicy(POLICY_VIEW_LOCAL_INFORMATION|POLICY_LOOKUP_NAMES) returned 0x%08lx\n", status);
|
||||
}
|
||||
|
||||
if (status == STATUS_SUCCESS) {
|
||||
@@ -84,12 +73,12 @@ static void test_lsa(void)
|
||||
if (status == STATUS_ACCESS_DENIED)
|
||||
skip("Not enough rights to retrieve PolicyAuditEventsInformation\n");
|
||||
else
|
||||
ok(status == STATUS_SUCCESS, "LsaQueryInformationPolicy(PolicyAuditEventsInformation) failed, returned 0x%08x\n", status);
|
||||
ok(status == STATUS_SUCCESS, "LsaQueryInformationPolicy(PolicyAuditEventsInformation) failed, returned 0x%08lx\n", status);
|
||||
if (status == STATUS_SUCCESS)
|
||||
LsaFreeMemory(audit_events_info);
|
||||
|
||||
status = LsaQueryInformationPolicy(handle, PolicyPrimaryDomainInformation, (void **)&primary_domain_info);
|
||||
ok(status == STATUS_SUCCESS, "LsaQueryInformationPolicy(PolicyPrimaryDomainInformation) failed, returned 0x%08x\n", status);
|
||||
ok(status == STATUS_SUCCESS, "LsaQueryInformationPolicy(PolicyPrimaryDomainInformation) failed, returned 0x%08lx\n", status);
|
||||
if (status == STATUS_SUCCESS) {
|
||||
if (primary_domain_info->Sid) {
|
||||
LPSTR strsid;
|
||||
@@ -116,29 +105,22 @@ static void test_lsa(void)
|
||||
}
|
||||
|
||||
status = LsaQueryInformationPolicy(handle, PolicyAccountDomainInformation, (void **)&account_domain_info);
|
||||
ok(status == STATUS_SUCCESS, "LsaQueryInformationPolicy(PolicyAccountDomainInformation) failed, returned 0x%08x\n", status);
|
||||
ok(status == STATUS_SUCCESS, "LsaQueryInformationPolicy(PolicyAccountDomainInformation) failed, returned 0x%08lx\n", status);
|
||||
if (status == STATUS_SUCCESS)
|
||||
LsaFreeMemory(account_domain_info);
|
||||
|
||||
/* This isn't supported in NT4 */
|
||||
status = LsaQueryInformationPolicy(handle, PolicyDnsDomainInformation, (void **)&dns_domain_info);
|
||||
ok(status == STATUS_SUCCESS || status == STATUS_INVALID_PARAMETER,
|
||||
"LsaQueryInformationPolicy(PolicyDnsDomainInformation) failed, returned 0x%08x\n", status);
|
||||
"LsaQueryInformationPolicy(PolicyDnsDomainInformation) failed, returned 0x%08lx\n", status);
|
||||
if (status == STATUS_SUCCESS) {
|
||||
if (dns_domain_info->Sid || !IsEqualGUID(&dns_domain_info->DomainGuid, &GUID_NULL)) {
|
||||
LPSTR strsid = NULL;
|
||||
LPSTR name = NULL;
|
||||
LPSTR domain = NULL;
|
||||
LPSTR forest = NULL;
|
||||
LPSTR guidstr = NULL;
|
||||
WCHAR guidstrW[64];
|
||||
UINT len;
|
||||
guidstrW[0] = '\0';
|
||||
ConvertSidToStringSidA(dns_domain_info->Sid, &strsid);
|
||||
StringFromGUID2(&dns_domain_info->DomainGuid, guidstrW, sizeof(guidstrW)/sizeof(WCHAR));
|
||||
len = WideCharToMultiByte( CP_ACP, 0, guidstrW, -1, NULL, 0, NULL, NULL );
|
||||
guidstr = LocalAlloc( 0, len );
|
||||
WideCharToMultiByte( CP_ACP, 0, guidstrW, -1, guidstr, len, NULL, NULL );
|
||||
if (dns_domain_info->Name.Buffer) {
|
||||
len = WideCharToMultiByte( CP_ACP, 0, dns_domain_info->Name.Buffer, -1, NULL, 0, NULL, NULL );
|
||||
name = LocalAlloc( 0, len );
|
||||
@@ -155,12 +137,11 @@ static void test_lsa(void)
|
||||
WideCharToMultiByte( CP_ACP, 0, dns_domain_info->DnsForestName.Buffer, -1, forest, len, NULL, NULL );
|
||||
}
|
||||
trace(" name: %s domain: %s forest: %s guid: %s sid: %s\n",
|
||||
name ? name : "NULL", domain ? domain : "NULL",
|
||||
forest ? forest : "NULL", guidstr, strsid ? strsid : "NULL");
|
||||
debugstr_a(name), debugstr_a(domain), debugstr_a(forest),
|
||||
debugstr_guid(&dns_domain_info->DomainGuid), debugstr_a(strsid));
|
||||
LocalFree( name );
|
||||
LocalFree( forest );
|
||||
LocalFree( domain );
|
||||
LocalFree( guidstr );
|
||||
LocalFree( strsid );
|
||||
}
|
||||
else
|
||||
@@ -170,15 +151,15 @@ static void test_lsa(void)
|
||||
|
||||
/* We need a valid SID to pass to LsaEnumerateAccountRights */
|
||||
ret = OpenProcessToken( GetCurrentProcess(), TOKEN_QUERY, &token );
|
||||
ok(ret, "Unable to obtain process token, error %u\n", GetLastError( ));
|
||||
ok(ret, "Unable to obtain process token, error %lu\n", GetLastError( ));
|
||||
if (ret) {
|
||||
char buffer[64];
|
||||
DWORD len;
|
||||
TOKEN_USER *token_user = (TOKEN_USER *) buffer;
|
||||
ret = GetTokenInformation( token, TokenUser, (LPVOID) token_user, sizeof(buffer), &len );
|
||||
ok(ret || GetLastError( ) == ERROR_INSUFFICIENT_BUFFER, "Unable to obtain token information, error %u\n", GetLastError( ));
|
||||
ok(ret || GetLastError( ) == ERROR_INSUFFICIENT_BUFFER, "Unable to obtain token information, error %lu\n", GetLastError( ));
|
||||
if (! ret && GetLastError( ) == ERROR_INSUFFICIENT_BUFFER) {
|
||||
trace("Resizing buffer to %u.\n", len);
|
||||
trace("Resizing buffer to %lu.\n", len);
|
||||
token_user = LocalAlloc( 0, len );
|
||||
if (token_user != NULL)
|
||||
ret = GetTokenInformation( token, TokenUser, (LPVOID) token_user, len, &len );
|
||||
@@ -190,7 +171,7 @@ static void test_lsa(void)
|
||||
rights = (PLSA_UNICODE_STRING) 0xdeadbeaf;
|
||||
rights_count = 0xcafecafe;
|
||||
status = LsaEnumerateAccountRights(handle, token_user->User.Sid, &rights, &rights_count);
|
||||
ok(status == STATUS_SUCCESS || status == STATUS_OBJECT_NAME_NOT_FOUND, "Unexpected status 0x%x\n", status);
|
||||
ok(status == STATUS_SUCCESS || status == STATUS_OBJECT_NAME_NOT_FOUND, "Unexpected status 0x%lx\n", status);
|
||||
if (status == STATUS_SUCCESS)
|
||||
LsaFreeMemory( rights );
|
||||
else
|
||||
@@ -202,7 +183,7 @@ static void test_lsa(void)
|
||||
}
|
||||
|
||||
status = LsaClose(handle);
|
||||
ok(status == STATUS_SUCCESS, "LsaClose() failed, returned 0x%08x\n", status);
|
||||
ok(status == STATUS_SUCCESS, "LsaClose() failed, returned 0x%08lx\n", status);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,7 +200,7 @@ static void get_sid_info(PSID psid, LPSTR *user, LPSTR *dom)
|
||||
user_size = dom_size = 257;
|
||||
account[0] = domain[0] = 0;
|
||||
ret = LookupAccountSidA(NULL, psid, account, &user_size, domain, &dom_size, &use);
|
||||
ok(ret, "LookupAccountSidA failed %u\n", GetLastError());
|
||||
ok(ret, "LookupAccountSidA failed %lu\n", GetLastError());
|
||||
}
|
||||
|
||||
static void test_LsaLookupNames2(void)
|
||||
@@ -247,14 +228,14 @@ static void test_LsaLookupNames2(void)
|
||||
|
||||
status = LsaOpenPolicy(NULL, &attrs, POLICY_ALL_ACCESS, &handle);
|
||||
ok(status == STATUS_SUCCESS || status == STATUS_ACCESS_DENIED,
|
||||
"LsaOpenPolicy(POLICY_ALL_ACCESS) returned 0x%08x\n", status);
|
||||
"LsaOpenPolicy(POLICY_ALL_ACCESS) returned 0x%08lx\n", status);
|
||||
|
||||
/* try a more restricted access mask if necessary */
|
||||
if (status == STATUS_ACCESS_DENIED)
|
||||
{
|
||||
trace("LsaOpenPolicy(POLICY_ALL_ACCESS) failed, trying POLICY_VIEW_LOCAL_INFORMATION\n");
|
||||
status = LsaOpenPolicy(NULL, &attrs, POLICY_LOOKUP_NAMES, &handle);
|
||||
ok(status == STATUS_SUCCESS, "LsaOpenPolicy(POLICY_VIEW_LOCAL_INFORMATION) returned 0x%08x\n", status);
|
||||
ok(status == STATUS_SUCCESS, "LsaOpenPolicy(POLICY_VIEW_LOCAL_INFORMATION) returned 0x%08lx\n", status);
|
||||
}
|
||||
if (status != STATUS_SUCCESS)
|
||||
{
|
||||
@@ -262,15 +243,15 @@ static void test_LsaLookupNames2(void)
|
||||
return;
|
||||
}
|
||||
|
||||
name[0].Buffer = HeapAlloc(GetProcessHeap(), 0, sizeof(n1));
|
||||
name[0].Buffer = malloc(sizeof(n1));
|
||||
name[0].Length = name[0].MaximumLength = sizeof(n1);
|
||||
memcpy(name[0].Buffer, n1, sizeof(n1));
|
||||
|
||||
name[1].Buffer = HeapAlloc(GetProcessHeap(), 0, sizeof(n1));
|
||||
name[1].Buffer = malloc(sizeof(n1));
|
||||
name[1].Length = name[1].MaximumLength = sizeof(n1) - sizeof(WCHAR);
|
||||
memcpy(name[1].Buffer, n1, sizeof(n1) - sizeof(WCHAR));
|
||||
|
||||
name[2].Buffer = HeapAlloc(GetProcessHeap(), 0, sizeof(n2));
|
||||
name[2].Buffer = malloc(sizeof(n2));
|
||||
name[2].Length = name[2].MaximumLength = sizeof(n2);
|
||||
memcpy(name[2].Buffer, n2, sizeof(n2));
|
||||
|
||||
@@ -278,10 +259,10 @@ static void test_LsaLookupNames2(void)
|
||||
sids = NULL;
|
||||
domains = NULL;
|
||||
status = LsaLookupNames2(handle, 0, 1, &name[0], &domains, &sids);
|
||||
ok(status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %x)\n", status);
|
||||
ok(status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %lx)\n", status);
|
||||
ok(sids[0].Use == SidTypeWellKnownGroup, "expected SidTypeWellKnownGroup, got %u\n", sids[0].Use);
|
||||
ok(sids[0].Flags == 0, "expected 0, got 0x%08x\n", sids[0].Flags);
|
||||
ok(domains->Entries == 1, "expected 1, got %u\n", domains->Entries);
|
||||
ok(sids[0].Flags == 0, "expected 0, got 0x%08lx\n", sids[0].Flags);
|
||||
ok(domains->Entries == 1, "expected 1, got %lu\n", domains->Entries);
|
||||
get_sid_info(sids[0].Sid, &account, &sid_dom);
|
||||
ok(!strcmp(account, "LOCAL SERVICE"), "expected \"LOCAL SERVICE\", got \"%s\"\n", account);
|
||||
ok(!strcmp(sid_dom, "NT AUTHORITY"), "expected \"NT AUTHORITY\", got \"%s\"\n", sid_dom);
|
||||
@@ -292,10 +273,10 @@ static void test_LsaLookupNames2(void)
|
||||
sids = NULL;
|
||||
domains = NULL;
|
||||
status = LsaLookupNames2(handle, 0, 1, &name[1], &domains, &sids);
|
||||
ok(status == STATUS_NONE_MAPPED, "expected STATUS_NONE_MAPPED, got %x)\n", status);
|
||||
ok(status == STATUS_NONE_MAPPED, "expected STATUS_NONE_MAPPED, got %lx)\n", status);
|
||||
ok(sids[0].Use == SidTypeUnknown, "expected SidTypeUnknown, got %u\n", sids[0].Use);
|
||||
ok(sids[0].Flags == 0, "expected 0, got 0x%08x\n", sids[0].Flags);
|
||||
ok(domains->Entries == 0, "expected 0, got %u\n", domains->Entries);
|
||||
ok(sids[0].Flags == 0, "expected 0, got 0x%08lx\n", sids[0].Flags);
|
||||
ok(domains->Entries == 0, "expected 0, got %lu\n", domains->Entries);
|
||||
LsaFreeMemory(sids);
|
||||
LsaFreeMemory(domains);
|
||||
|
||||
@@ -303,10 +284,10 @@ static void test_LsaLookupNames2(void)
|
||||
sids = NULL;
|
||||
domains = NULL;
|
||||
status = LsaLookupNames2(handle, 0, 1, &name[2], &domains, &sids);
|
||||
ok(status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %x)\n", status);
|
||||
ok(status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %lx)\n", status);
|
||||
ok(sids[0].Use == SidTypeWellKnownGroup, "expected SidTypeWellKnownGroup, got %u\n", sids[0].Use);
|
||||
ok(sids[0].Flags == 0, "expected 0, got 0x%08x\n", sids[0].Flags);
|
||||
ok(domains->Entries == 1, "expected 1, got %u\n", domains->Entries);
|
||||
ok(sids[0].Flags == 0, "expected 0, got 0x%08lx\n", sids[0].Flags);
|
||||
ok(domains->Entries == 1, "expected 1, got %lu\n", domains->Entries);
|
||||
get_sid_info(sids[0].Sid, &account, &sid_dom);
|
||||
ok(!strcmp(account, "LOCAL SERVICE"), "expected \"LOCAL SERVICE\", got \"%s\"\n", account);
|
||||
ok(!strcmp(sid_dom, "NT AUTHORITY"), "expected \"NT AUTHORITY\", got \"%s\"\n", sid_dom);
|
||||
@@ -317,95 +298,140 @@ static void test_LsaLookupNames2(void)
|
||||
sids = NULL;
|
||||
domains = NULL;
|
||||
status = LsaLookupNames2(handle, 0, 3, name, &domains, &sids);
|
||||
ok(status == STATUS_SOME_NOT_MAPPED, "expected STATUS_SOME_NOT_MAPPED, got %x)\n", status);
|
||||
ok(status == STATUS_SOME_NOT_MAPPED, "expected STATUS_SOME_NOT_MAPPED, got %lx)\n", status);
|
||||
ok(sids[0].Use == SidTypeWellKnownGroup, "expected SidTypeWellKnownGroup, got %u\n", sids[0].Use);
|
||||
ok(sids[1].Use == SidTypeUnknown, "expected SidTypeUnknown, got %u\n", sids[1].Use);
|
||||
ok(sids[2].Use == SidTypeWellKnownGroup, "expected SidTypeWellKnownGroup, got %u\n", sids[2].Use);
|
||||
ok(sids[0].DomainIndex == 0, "expected 0, got %u\n", sids[0].DomainIndex);
|
||||
ok(domains->Entries == 1, "expected 1, got %u\n", domains->Entries);
|
||||
ok(sids[0].DomainIndex == 0, "expected 0, got %lu\n", sids[0].DomainIndex);
|
||||
ok(domains->Entries == 1, "expected 1, got %lu\n", domains->Entries);
|
||||
LsaFreeMemory(sids);
|
||||
LsaFreeMemory(domains);
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, name[0].Buffer);
|
||||
HeapFree(GetProcessHeap(), 0, name[1].Buffer);
|
||||
HeapFree(GetProcessHeap(), 0, name[2].Buffer);
|
||||
free(name[0].Buffer);
|
||||
free(name[1].Buffer);
|
||||
free(name[2].Buffer);
|
||||
|
||||
status = LsaClose(handle);
|
||||
ok(status == STATUS_SUCCESS, "LsaClose() failed, returned 0x%08x\n", status);
|
||||
ok(status == STATUS_SUCCESS, "LsaClose() failed, returned 0x%08lx\n", status);
|
||||
}
|
||||
|
||||
static void check_unicode_string_(int line, const LSA_UNICODE_STRING *string, const WCHAR *expect)
|
||||
{
|
||||
ok_(__FILE__, line)(string->Length == wcslen(string->Buffer) * sizeof(WCHAR),
|
||||
"expected %Iu, got %u\n", wcslen(string->Buffer) * sizeof(WCHAR), string->Length);
|
||||
ok_(__FILE__, line)(string->MaximumLength == string->Length + sizeof(WCHAR),
|
||||
"expected %Iu, got %u\n", string->Length + sizeof(WCHAR), string->MaximumLength);
|
||||
ok_(__FILE__, line)(!wcsicmp(string->Buffer, expect), "expected %s, got %s\n",
|
||||
debugstr_w(expect), debugstr_w(string->Buffer));
|
||||
}
|
||||
#define check_unicode_string(a, b) check_unicode_string_(__LINE__, a, b)
|
||||
|
||||
static void test_LsaLookupSids(void)
|
||||
{
|
||||
WCHAR langW[32];
|
||||
char user_buffer[64];
|
||||
LSA_OBJECT_ATTRIBUTES attrs = {sizeof(attrs)};
|
||||
TOKEN_USER *user = (TOKEN_USER *)user_buffer;
|
||||
WCHAR computer_name[64], user_name[64];
|
||||
LSA_REFERENCED_DOMAIN_LIST *list;
|
||||
LSA_OBJECT_ATTRIBUTES attrs;
|
||||
LSA_TRANSLATED_NAME *names;
|
||||
LSA_HANDLE policy;
|
||||
TOKEN_USER *user;
|
||||
NTSTATUS status;
|
||||
HANDLE token;
|
||||
DWORD size;
|
||||
DWORD num, size;
|
||||
BOOL ret;
|
||||
PSID sid;
|
||||
|
||||
memset(&attrs, 0, sizeof(attrs));
|
||||
attrs.Length = sizeof(attrs);
|
||||
|
||||
status = LsaOpenPolicy(NULL, &attrs, POLICY_LOOKUP_NAMES, &policy);
|
||||
ok(status == STATUS_SUCCESS, "got 0x%08x\n", status);
|
||||
ok(status == STATUS_SUCCESS, "got 0x%08lx\n", status);
|
||||
|
||||
ret = OpenProcessToken(GetCurrentProcess(), MAXIMUM_ALLOWED, &token);
|
||||
ok(ret, "got %d\n", ret);
|
||||
ok(ret, "OpenProcessToken() failed, error %lu\n", GetLastError());
|
||||
|
||||
ret = GetTokenInformation(token, TokenUser, NULL, 0, &size);
|
||||
ok(!ret, "got %d\n", ret);
|
||||
ret = GetTokenInformation(token, TokenUser, user, sizeof(user_buffer), &size);
|
||||
ok(ret, "GetTokenInformation() failed, error %lu\n", GetLastError());
|
||||
|
||||
user = HeapAlloc(GetProcessHeap(), 0, size);
|
||||
ret = GetTokenInformation(token, TokenUser, user, size, &size);
|
||||
ok(ret, "got %d\n", ret);
|
||||
size = ARRAY_SIZE(computer_name);
|
||||
ret = GetComputerNameW(computer_name, &size);
|
||||
ok(ret, "GetComputerName() failed, error %lu\n", GetLastError());
|
||||
|
||||
size = ARRAY_SIZE(user_name);
|
||||
ret = GetUserNameW(user_name, &size);
|
||||
ok(ret, "GetUserName() failed, error %lu\n", GetLastError());
|
||||
|
||||
status = LsaLookupSids(policy, 1, &user->User.Sid, &list, &names);
|
||||
ok(status == STATUS_SUCCESS, "got 0x%08x\n", status);
|
||||
ok(status == STATUS_SUCCESS, "got 0x%08lx\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->Entries == 1, "got %ld\n", list->Entries);
|
||||
check_unicode_string(&list->Domains[0].Name, computer_name);
|
||||
|
||||
ok(names[0].Use == SidTypeUser, "got type %u\n", names[0].Use);
|
||||
ok(!names[0].DomainIndex, "got index %lu\n", names[0].DomainIndex);
|
||||
check_unicode_string(&names[0].Name, user_name);
|
||||
|
||||
LsaFreeMemory(names);
|
||||
LsaFreeMemory(list);
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, user);
|
||||
|
||||
CloseHandle(token);
|
||||
|
||||
ret = ConvertStringSidToSidA("S-1-1-0", &sid);
|
||||
ok(ret == TRUE, "ConvertStringSidToSidA returned false\n");
|
||||
ok(ret, "ConvertStringSidToSidA() failed, error %lu\n", GetLastError());
|
||||
|
||||
status = LsaLookupSids(policy, 1, &sid, &list, &names);
|
||||
ok(status == STATUS_SUCCESS, "got 0x%08x\n", status);
|
||||
ok(status == STATUS_SUCCESS, "got 0x%08lx\n", status);
|
||||
|
||||
ok(list->Entries > 0, "got %d\n", list->Entries);
|
||||
ok(list->Entries == 1, "got %ld\n", list->Entries);
|
||||
check_unicode_string(&list->Domains[0].Name, L"");
|
||||
|
||||
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");
|
||||
}
|
||||
ok(names[0].Use == SidTypeWellKnownGroup, "got type %u\n", names[0].Use);
|
||||
ok(!names[0].DomainIndex, "got index %lu\n", names[0].DomainIndex);
|
||||
|
||||
/* The group name gets translated... but not in all locales */
|
||||
size = ARRAY_SIZE(langW);
|
||||
if (!pGetSystemPreferredUILanguages ||
|
||||
!pGetSystemPreferredUILanguages(MUI_LANGUAGE_ID, &num, langW, &size))
|
||||
langW[0] = 0;
|
||||
if (wcscmp(langW, L"0409") == 0 || wcscmp(langW, L"0411") == 0)
|
||||
/* English and Japanese */
|
||||
check_unicode_string(&names[0].Name, L"Everyone");
|
||||
else if (wcscmp(langW, L"0407") == 0) /* German */
|
||||
todo_wine ok(!wcsicmp(names[0].Name.Buffer, L"Jeder"), "missing translation %s\n",
|
||||
debugstr_w(names[0].Name.Buffer));
|
||||
else if (wcscmp(langW, L"040C") == 0) /* French */
|
||||
todo_wine ok(!wcsicmp(names[0].Name.Buffer, L"Tout le monde"), "missing translation %s\n",
|
||||
debugstr_w(names[0].Name.Buffer));
|
||||
else
|
||||
trace("<Everyone-group>.Name=%s\n", debugstr_w(names[0].Name.Buffer));
|
||||
|
||||
LsaFreeMemory(names);
|
||||
LsaFreeMemory(list);
|
||||
FreeSid(sid);
|
||||
|
||||
ret = ConvertStringSidToSidA("S-1-1234-5678-1234-5678", &sid);
|
||||
ok(ret, "ConvertStringSidToSidA() failed, error %lu\n", GetLastError());
|
||||
|
||||
status = LsaLookupSids(policy, 1, &sid, &list, &names);
|
||||
ok(status == STATUS_NONE_MAPPED, "got 0x%08lx\n", status);
|
||||
|
||||
ok(!list->Entries, "got %ld\n", list->Entries);
|
||||
|
||||
#ifdef __REACTOS__
|
||||
if (!names) {
|
||||
ok(FALSE, "names should not be null!\n");
|
||||
} else {
|
||||
#endif
|
||||
ok(names[0].Use == SidTypeUnknown, "got type %u\n", names[0].Use);
|
||||
ok(names[0].DomainIndex == -1, "got index %lu\n", names[0].DomainIndex);
|
||||
check_unicode_string(&names[0].Name, L"S-1-1234-5678-1234-5678");
|
||||
#ifdef __REACTOS__
|
||||
}
|
||||
#endif
|
||||
|
||||
LsaFreeMemory(names);
|
||||
LsaFreeMemory(list);
|
||||
FreeSid(sid);
|
||||
|
||||
status = LsaClose(policy);
|
||||
ok(status == STATUS_SUCCESS, "got 0x%08x\n", status);
|
||||
ok(status == STATUS_SUCCESS, "got 0x%08lx\n", status);
|
||||
}
|
||||
|
||||
static void test_LsaLookupPrivilegeName(void)
|
||||
@@ -420,31 +446,86 @@ static void test_LsaLookupPrivilegeName(void)
|
||||
attrs.Length = sizeof(attrs);
|
||||
|
||||
status = LsaOpenPolicy(NULL, &attrs, POLICY_LOOKUP_NAMES, &policy);
|
||||
ok(status == STATUS_SUCCESS, "Failed to open policy, %#x.\n", status);
|
||||
ok(status == STATUS_SUCCESS, "Failed to open policy, %#lx.\n", status);
|
||||
|
||||
name = (void *)0xdeadbeef;
|
||||
status = LsaLookupPrivilegeName(policy, NULL, &name);
|
||||
ok(status != STATUS_SUCCESS, "Unexpected status %#x.\n", status);
|
||||
ok(status != STATUS_SUCCESS, "Unexpected status %#lx.\n", status);
|
||||
ok(name == (void *)0xdeadbeef, "Unexpected name pointer.\n");
|
||||
|
||||
name = (void *)0xdeadbeef;
|
||||
luid.HighPart = 1;
|
||||
luid.LowPart = SE_CREATE_TOKEN_PRIVILEGE;
|
||||
status = LsaLookupPrivilegeName(policy, &luid, &name);
|
||||
ok(status == STATUS_NO_SUCH_PRIVILEGE, "Unexpected status %#x.\n", status);
|
||||
ok(status == STATUS_NO_SUCH_PRIVILEGE, "Unexpected status %#lx.\n", status);
|
||||
ok(name == NULL, "Unexpected name pointer.\n");
|
||||
|
||||
luid.HighPart = 0;
|
||||
luid.LowPart = SE_CREATE_TOKEN_PRIVILEGE;
|
||||
status = LsaLookupPrivilegeName(policy, &luid, &name);
|
||||
ok(status == 0, "got %#x.\n", status);
|
||||
ok(status == 0, "got %#lx.\n", status);
|
||||
LsaFreeMemory(name);
|
||||
}
|
||||
|
||||
static void test_LsaGetUserName(void)
|
||||
{
|
||||
NTSTATUS status;
|
||||
BOOL ret;
|
||||
UNICODE_STRING *lsa_user, *lsa_domain;
|
||||
WCHAR user[256], computer[256];
|
||||
DWORD size;
|
||||
|
||||
if (!pLsaGetUserName)
|
||||
{
|
||||
skip("LsaGetUserName is not available on this platform\n");
|
||||
return;
|
||||
}
|
||||
|
||||
size = ARRAY_SIZE(user);
|
||||
ret = GetUserNameW(user, &size);
|
||||
ok(ret, "GetUserName error %lu\n", GetLastError());
|
||||
|
||||
size = ARRAY_SIZE(computer);
|
||||
ret = GetComputerNameW(computer, &size);
|
||||
ok(ret, "GetComputerName error %lu\n", GetLastError());
|
||||
|
||||
if (0) /* crashes under Windows */
|
||||
status = pLsaGetUserName(NULL, NULL);
|
||||
|
||||
if (0) /* crashes under Windows */
|
||||
status = pLsaGetUserName(NULL, &lsa_domain);
|
||||
|
||||
status = pLsaGetUserName(&lsa_user, NULL);
|
||||
ok(!status, "got %#lx\n", status);
|
||||
#ifdef __REACTOS__
|
||||
if (status == STATUS_NOT_IMPLEMENTED) {
|
||||
skip("FIXME: LsaGetUserName not implemented on ReactOS!\n");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
check_unicode_string(lsa_user, user);
|
||||
LsaFreeMemory(lsa_user);
|
||||
|
||||
status = pLsaGetUserName(&lsa_user, &lsa_domain);
|
||||
ok(!status, "got %#lx\n", status);
|
||||
ok(!lstrcmpW(user, lsa_user->Buffer), "%s != %s\n", wine_dbgstr_w(user), wine_dbgstr_wn(lsa_user->Buffer, lsa_user->Length/sizeof(WCHAR)));
|
||||
check_unicode_string(lsa_user, user);
|
||||
check_unicode_string(lsa_domain, computer);
|
||||
LsaFreeMemory(lsa_user);
|
||||
LsaFreeMemory(lsa_domain);
|
||||
}
|
||||
|
||||
START_TEST(lsa)
|
||||
{
|
||||
HMODULE hkernel32 = GetModuleHandleA("kernel32.dll");
|
||||
HMODULE hadvapi32 = GetModuleHandleA("advapi32.dll");
|
||||
|
||||
pGetSystemPreferredUILanguages = (void*)GetProcAddress(hkernel32, "GetSystemPreferredUILanguages");
|
||||
pLsaGetUserName = (void *)GetProcAddress(hadvapi32, "LsaGetUserName");
|
||||
|
||||
test_lsa();
|
||||
test_LsaLookupNames2();
|
||||
test_LsaLookupSids();
|
||||
test_LsaLookupPrivilegeName();
|
||||
test_LsaGetUserName();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,305 @@
|
||||
/*
|
||||
* Unit tests for Perflib functions
|
||||
*
|
||||
* Copyright (c) 2021 Paul Gofman for CodeWeavers
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "winerror.h"
|
||||
#include "perflib.h"
|
||||
#include "winperf.h"
|
||||
#include "winternl.h"
|
||||
|
||||
#include "wine/test.h"
|
||||
|
||||
#include "initguid.h"
|
||||
|
||||
ULONG (WINAPI *pPerfCloseQueryHandle)(HANDLE);
|
||||
ULONG (WINAPI *pPerfOpenQueryHandle)(const WCHAR*, HANDLE*);
|
||||
ULONG (WINAPI *pPerfAddCounters)(HANDLE, PERF_COUNTER_IDENTIFIER*, DWORD);
|
||||
ULONG (WINAPI *pPerfQueryCounterData)(HANDLE, PERF_DATA_HEADER*, DWORD, DWORD*);
|
||||
|
||||
static void init_functions(void)
|
||||
{
|
||||
HANDLE hadvapi = GetModuleHandleA("advapi32.dll");
|
||||
|
||||
#define GET_FUNCTION(name) p##name = (void *)GetProcAddress(hadvapi, #name)
|
||||
GET_FUNCTION(PerfCloseQueryHandle);
|
||||
GET_FUNCTION(PerfOpenQueryHandle);
|
||||
GET_FUNCTION(PerfAddCounters);
|
||||
GET_FUNCTION(PerfQueryCounterData);
|
||||
#undef GET_FUNCTION
|
||||
}
|
||||
|
||||
static ULONG WINAPI test_provider_callback(ULONG code, void *buffer, ULONG size)
|
||||
{
|
||||
ok(0, "Provider callback called.\n");
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
void test_provider_init(void)
|
||||
{
|
||||
#ifdef __REACTOS__
|
||||
skip("test_provider_init() can't be built until ReactOS has implementations for Perf* functions.\n");
|
||||
#else
|
||||
static GUID test_set_guid = {0xdeadbeef, 0x0002, 0x0003, {0x0f, 0x04, 0x05, 0x06, 0x07, 0x08, 0x00 ,0x0a}};
|
||||
static GUID test_set_guid2 = {0xdeadbeef, 0x0003, 0x0003, {0x0f, 0x04, 0x05, 0x06, 0x07, 0x08, 0x00 ,0x0a}};
|
||||
static GUID test_guid = {0xdeadbeef, 0x0001, 0x0002, {0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x00 ,0x0a}};
|
||||
static struct
|
||||
{
|
||||
PERF_COUNTERSET_INFO counterset;
|
||||
PERF_COUNTER_INFO counter[2];
|
||||
}
|
||||
pc_template =
|
||||
{
|
||||
{{0}},
|
||||
{
|
||||
{1, PERF_COUNTER_COUNTER, PERF_ATTRIB_BY_REFERENCE, sizeof(PERF_COUNTER_INFO),
|
||||
PERF_DETAIL_NOVICE, 0, 0xdeadbeef},
|
||||
{2, PERF_COUNTER_COUNTER, PERF_ATTRIB_BY_REFERENCE, sizeof(PERF_COUNTER_INFO),
|
||||
PERF_DETAIL_NOVICE, 0, 0xdeadbeef},
|
||||
},
|
||||
};
|
||||
|
||||
PERF_COUNTERSET_INSTANCE *instance;
|
||||
PERF_PROVIDER_CONTEXT prov_context;
|
||||
UINT64 counter1, counter2;
|
||||
HANDLE prov, prov2;
|
||||
ULONG ret, size;
|
||||
BOOL bret;
|
||||
|
||||
prov = (HANDLE)0xdeadbeef;
|
||||
ret = PerfStartProvider(NULL, test_provider_callback, &prov);
|
||||
ok(ret == ERROR_INVALID_PARAMETER, "Got unexpected ret %lu.\n", ret);
|
||||
ok(prov == (HANDLE)0xdeadbeef, "Got unexpected prov %p.\n", prov);
|
||||
|
||||
prov = (HANDLE)0xdeadbeef;
|
||||
ret = PerfStartProvider(&test_guid, test_provider_callback, NULL);
|
||||
ok(ret == ERROR_INVALID_PARAMETER, "Got unexpected ret %lu.\n", ret);
|
||||
ok(prov == (HANDLE)0xdeadbeef, "Got unexpected prov %p.\n", prov);
|
||||
|
||||
prov = (HANDLE)0xdeadbeef;
|
||||
ret = PerfStartProvider(&test_guid, test_provider_callback, &prov);
|
||||
ok(!ret, "Got unexpected ret %lu.\n", ret);
|
||||
ok(prov != (HANDLE)0xdeadbeef, "Provider handle is not set.\n");
|
||||
|
||||
prov2 = prov;
|
||||
ret = PerfStartProvider(&test_guid, test_provider_callback, &prov2);
|
||||
ok(!ret, "Got unexpected ret %lu.\n", ret);
|
||||
ok(prov2 != prov, "Got the same provider handle.\n");
|
||||
|
||||
ret = PerfStopProvider(prov2);
|
||||
ok(!ret, "Got unexpected ret %lu.\n", ret);
|
||||
|
||||
if (0)
|
||||
{
|
||||
/* Access violation on Windows. */
|
||||
PerfStopProvider(prov2);
|
||||
}
|
||||
|
||||
/* Provider handle is a pointer and not a kernel object handle. */
|
||||
bret = DuplicateHandle(GetCurrentProcess(), prov, GetCurrentProcess(), &prov2, 0, FALSE, DUPLICATE_SAME_ACCESS);
|
||||
ok(!bret && GetLastError() == ERROR_INVALID_HANDLE, "Got unexpected bret %d, err %lu.\n", bret, GetLastError());
|
||||
bret = IsBadWritePtr(prov, 8);
|
||||
ok(!bret, "Handle does not point to the data.\n");
|
||||
|
||||
pc_template.counterset.CounterSetGuid = test_set_guid;
|
||||
pc_template.counterset.ProviderGuid = test_guid;
|
||||
pc_template.counterset.NumCounters = 0;
|
||||
pc_template.counterset.InstanceType = PERF_COUNTERSET_SINGLE_INSTANCE;
|
||||
ret = PerfSetCounterSetInfo(prov, &pc_template.counterset, sizeof(pc_template.counterset));
|
||||
ok(ret == ERROR_INVALID_PARAMETER, "Got unexpected ret %lu.\n", ret);
|
||||
|
||||
pc_template.counterset.CounterSetGuid = test_set_guid;
|
||||
pc_template.counterset.ProviderGuid = test_guid;
|
||||
pc_template.counterset.NumCounters = 2;
|
||||
pc_template.counterset.InstanceType = PERF_COUNTERSET_SINGLE_INSTANCE;
|
||||
ret = PerfSetCounterSetInfo(prov, &pc_template.counterset, sizeof(pc_template));
|
||||
ok(!ret, "Got unexpected ret %lu.\n", ret);
|
||||
|
||||
pc_template.counterset.CounterSetGuid = test_set_guid2;
|
||||
/* Looks like ProviderGuid doesn't need to match provider. */
|
||||
pc_template.counterset.ProviderGuid = test_set_guid;
|
||||
pc_template.counterset.NumCounters = 1;
|
||||
pc_template.counterset.InstanceType = PERF_COUNTERSET_SINGLE_INSTANCE;
|
||||
ret = PerfSetCounterSetInfo(prov, &pc_template.counterset, sizeof(pc_template));
|
||||
ok(!ret, "Got unexpected ret %lu.\n", ret);
|
||||
|
||||
ret = PerfSetCounterSetInfo(prov, &pc_template.counterset, sizeof(pc_template));
|
||||
ok(ret == ERROR_ALREADY_EXISTS, "Got unexpected ret %lu.\n", ret);
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
instance = PerfCreateInstance(prov, NULL, L"1", 1);
|
||||
ok(!instance, "Got unexpected instance %p.\n", instance);
|
||||
ok(GetLastError() == ERROR_INVALID_PARAMETER, "Got unexpected error %lu.\n", GetLastError());
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
instance = PerfCreateInstance(prov, &test_guid, L"1", 1);
|
||||
ok(!instance, "Got unexpected instance %p.\n", instance);
|
||||
ok(GetLastError() == ERROR_NOT_FOUND, "Got unexpected error %lu.\n", GetLastError());
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
instance = PerfCreateInstance(prov, &test_guid, NULL, 1);
|
||||
ok(!instance, "Got unexpected instance %p.\n", instance);
|
||||
ok(GetLastError() == ERROR_INVALID_PARAMETER, "Got unexpected error %lu.\n", GetLastError());
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
instance = PerfCreateInstance(prov, &test_set_guid, L"11", 1);
|
||||
ok(!!instance, "Got NULL instance.\n");
|
||||
ok(GetLastError() == 0xdeadbeef, "Got unexpected error %lu.\n", GetLastError());
|
||||
ok(instance->InstanceId == 1, "Got unexpected InstanceId %lu.\n", instance->InstanceId);
|
||||
ok(instance->InstanceNameSize == 6, "Got unexpected InstanceNameSize %lu.\n", instance->InstanceNameSize);
|
||||
ok(IsEqualGUID(&instance->CounterSetGuid, &test_set_guid), "Got unexpected guid %s.\n",
|
||||
debugstr_guid(&instance->CounterSetGuid));
|
||||
|
||||
ok(instance->InstanceNameOffset == sizeof(*instance) + sizeof(UINT64) * 2,
|
||||
"Got unexpected InstanceNameOffset %lu.\n", instance->InstanceNameOffset);
|
||||
ok(!lstrcmpW((WCHAR *)((BYTE *)instance + instance->InstanceNameOffset), L"11"),
|
||||
"Got unexpected instance name %s.\n",
|
||||
debugstr_w((WCHAR *)((BYTE *)instance + instance->InstanceNameOffset)));
|
||||
size = ((sizeof(*instance) + sizeof(UINT64) * 2 + instance->InstanceNameSize) + 7) & ~7;
|
||||
ok(size == instance->dwSize, "Got unexpected size %lu, instance->dwSize %lu.\n", size, instance->dwSize);
|
||||
|
||||
ret = PerfSetCounterRefValue(prov, instance, 1, &counter1);
|
||||
ok(!ret, "Got unexpected ret %lu.\n", ret);
|
||||
ret = PerfSetCounterRefValue(prov, instance, 2, &counter2);
|
||||
ok(!ret, "Got unexpected ret %lu.\n", ret);
|
||||
|
||||
ret = PerfSetCounterRefValue(prov, instance, 0, &counter2);
|
||||
ok(ret == ERROR_NOT_FOUND, "Got unexpected ret %lu.\n", ret);
|
||||
|
||||
ok(*(void **)(instance + 1) == &counter1, "Got unexpected counter value %p.\n",
|
||||
*(void **)(instance + 1));
|
||||
ok(*(void **)((BYTE *)instance + sizeof(*instance) + sizeof(UINT64)) == &counter2,
|
||||
"Got unexpected counter value %p.\n", *(void **)(instance + 1));
|
||||
|
||||
ret = PerfDeleteInstance(prov, instance);
|
||||
ok(!ret, "Got unexpected ret %lu.\n", ret);
|
||||
|
||||
ret = PerfStopProvider(prov);
|
||||
ok(!ret, "Got unexpected ret %lu.\n", ret);
|
||||
|
||||
memset( &prov_context, 0, sizeof(prov_context) );
|
||||
prov = (HANDLE)0xdeadbeef;
|
||||
ret = PerfStartProviderEx( &test_guid, &prov_context, &prov );
|
||||
ok(ret == ERROR_INVALID_PARAMETER, "Got unexpected ret %lu.\n", ret);
|
||||
ok(prov == (HANDLE)0xdeadbeef, "Got unexpected prov %p.\n", prov);
|
||||
|
||||
prov_context.ContextSize = sizeof(prov_context) + 1;
|
||||
ret = PerfStartProviderEx( &test_guid, &prov_context, &prov );
|
||||
ok(!ret, "Got unexpected ret %lu.\n", ret);
|
||||
ok(prov != (HANDLE)0xdeadbeef, "Provider handle is not set.\n");
|
||||
|
||||
ret = PerfStopProvider(prov);
|
||||
ok(!ret, "Got unexpected ret %lu.\n", ret);
|
||||
#endif
|
||||
}
|
||||
|
||||
DEFINE_GUID(TestCounterGUID, 0x12345678, 0x1234, 0x5678, 0x12, 0x34, 0x11, 0x11, 0x22, 0x22, 0x33, 0x33);
|
||||
|
||||
static ULONG64 trunc_nttime_ms(ULONG64 t)
|
||||
{
|
||||
return (t / 10000) * 10000;
|
||||
}
|
||||
|
||||
static void test_perf_counters(void)
|
||||
{
|
||||
LARGE_INTEGER freq, qpc1, qpc2, nttime1, nttime2, systime;
|
||||
char buffer[sizeof(PERF_COUNTER_IDENTIFIER) + 8];
|
||||
PERF_COUNTER_IDENTIFIER *counter_id;
|
||||
PERF_DATA_HEADER dh;
|
||||
HANDLE query;
|
||||
DWORD size;
|
||||
ULONG ret;
|
||||
|
||||
if (!pPerfOpenQueryHandle)
|
||||
{
|
||||
win_skip("PerfOpenQueryHandle not found.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
ret = pPerfOpenQueryHandle(NULL, NULL);
|
||||
ok(ret == ERROR_INVALID_PARAMETER, "got ret %lu.\n", ret);
|
||||
ret = pPerfOpenQueryHandle(NULL, &query);
|
||||
ok(!ret, "got ret %lu.\n", ret);
|
||||
|
||||
counter_id = (PERF_COUNTER_IDENTIFIER *)buffer;
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
|
||||
counter_id->CounterSetGuid = TestCounterGUID;
|
||||
counter_id->CounterId = PERF_WILDCARD_COUNTER;
|
||||
counter_id->InstanceId = PERF_WILDCARD_COUNTER;
|
||||
|
||||
ret = pPerfAddCounters(query, counter_id, sizeof(*counter_id));
|
||||
ok(ret == ERROR_INVALID_PARAMETER, "got ret %lu.\n", ret);
|
||||
|
||||
counter_id->Size = sizeof(*counter_id);
|
||||
ret = pPerfAddCounters(query, counter_id, 8);
|
||||
ok(ret == ERROR_INVALID_PARAMETER, "got ret %lu.\n", ret);
|
||||
ret = pPerfAddCounters(query, counter_id, sizeof(*counter_id));
|
||||
ok(!ret, "got ret %lu.\n", ret);
|
||||
ok(counter_id->Status == ERROR_WMI_GUID_NOT_FOUND, "got Status %#lx.\n", counter_id->Status);
|
||||
|
||||
ret = pPerfQueryCounterData(query, NULL, 0, NULL);
|
||||
ok(ret == ERROR_INVALID_PARAMETER, "got ret %lu.\n", ret);
|
||||
|
||||
size = 0xdeadbeef;
|
||||
ret = pPerfQueryCounterData(query, NULL, 0, &size);
|
||||
ok(ret == ERROR_NOT_ENOUGH_MEMORY, "got ret %lu.\n", ret);
|
||||
ok(size == sizeof(dh), "got size %lu.\n", size);
|
||||
|
||||
ret = pPerfQueryCounterData(query, &dh, sizeof(dh), NULL);
|
||||
ok(ret == ERROR_INVALID_PARAMETER, "got ret %lu.\n", ret);
|
||||
|
||||
QueryPerformanceFrequency(&freq);
|
||||
QueryPerformanceCounter(&qpc1);
|
||||
NtQuerySystemTime(&nttime1);
|
||||
|
||||
size = 0xdeadbeef;
|
||||
ret = pPerfQueryCounterData(query, &dh, sizeof(dh), &size);
|
||||
QueryPerformanceCounter(&qpc2);
|
||||
NtQuerySystemTime(&nttime2);
|
||||
SystemTimeToFileTime(&dh.SystemTime, (FILETIME *)&systime);
|
||||
ok(!ret, "got ret %lu.\n", ret);
|
||||
ok(size == sizeof(dh), "got size %lu.\n", size);
|
||||
ok(dh.dwTotalSize == sizeof(dh), "got dwTotalSize %lu.\n", dh.dwTotalSize);
|
||||
ok(!dh.dwNumCounters, "got dwNumCounters %lu.\n", dh.dwNumCounters);
|
||||
ok(dh.PerfFreq == freq.QuadPart, "got PerfFreq %I64u.\n", dh.PerfFreq);
|
||||
ok(dh.PerfTimeStamp >= qpc1.QuadPart && dh.PerfTimeStamp <= qpc2.QuadPart,
|
||||
"got PerfTimeStamp %I64u, qpc1 %I64u, qpc2 %I64u.\n",
|
||||
dh.PerfTimeStamp, qpc1.QuadPart, qpc2.QuadPart);
|
||||
ok(dh.PerfTime100NSec >= nttime1.QuadPart && dh.PerfTime100NSec <= nttime2.QuadPart,
|
||||
"got PerfTime100NSec %I64u, nttime1 %I64u, nttime2 %I64u.\n",
|
||||
dh.PerfTime100NSec, nttime1.QuadPart, nttime2.QuadPart);
|
||||
ok(systime.QuadPart >= trunc_nttime_ms(nttime1.QuadPart) && systime.QuadPart <= trunc_nttime_ms(nttime2.QuadPart),
|
||||
"got systime %I64u, nttime1 %I64u, nttime2 %I64u, %d.\n",
|
||||
systime.QuadPart, nttime1.QuadPart, nttime2.QuadPart, dh.SystemTime.wMilliseconds);
|
||||
|
||||
ret = pPerfCloseQueryHandle(query);
|
||||
ok(!ret, "got ret %lu.\n", ret);
|
||||
}
|
||||
|
||||
START_TEST(perf)
|
||||
{
|
||||
init_functions();
|
||||
|
||||
test_provider_init();
|
||||
test_perf_counters();
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user