wtsapi32: Improve WTSQuerySessionInformationW stub.

Signed-off-by: Gijs Vermeulen <gijsvrm@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
feature/deterministic
Gijs Vermeulen 2020-05-28 15:59:27 +02:00 committed by Alexandre Julliard
parent 1db2b56336
commit 116890da12
2 changed files with 30 additions and 0 deletions

View File

@ -97,6 +97,25 @@ static void test_WTSQuerySessionInformation(void)
char *buf2;
DWORD count;
SetLastError(0xdeadbeef);
count = 0;
ret = WTSQuerySessionInformationW(WTS_CURRENT_SERVER_HANDLE, WTS_CURRENT_SESSION, WTSUserName, NULL, &count);
ok(!ret, "got %u\n", GetLastError());
ok(count == 0, "got %u\n", count);
ok(GetLastError() == ERROR_INVALID_USER_BUFFER, "got %u\n", GetLastError());
SetLastError(0xdeadbeef);
count = 1;
ret = WTSQuerySessionInformationW(WTS_CURRENT_SERVER_HANDLE, WTS_CURRENT_SESSION, WTSUserName, NULL, &count);
ok(!ret, "got %u\n", GetLastError());
ok(count == 1, "got %u\n", count);
ok(GetLastError() == ERROR_INVALID_USER_BUFFER, "got %u\n", GetLastError());
SetLastError(0xdeadbeef);
ret = WTSQuerySessionInformationW(WTS_CURRENT_SERVER_HANDLE, WTS_CURRENT_SESSION, WTSUserName, &buf1, NULL);
ok(!ret, "got %u\n", GetLastError());
ok(GetLastError() == ERROR_INVALID_USER_BUFFER, "got %u\n", GetLastError());
count = 0;
buf1 = NULL;
ret = WTSQuerySessionInformationW(WTS_CURRENT_SERVER_HANDLE, WTS_CURRENT_SESSION, WTSUserName, &buf1, &count);

View File

@ -341,6 +341,12 @@ BOOL WINAPI WTSQuerySessionInformationW(
FIXME("Stub %p 0x%08x %d %p %p\n", hServer, SessionId, WTSInfoClass,
Buffer, BytesReturned);
if (!Buffer || !BytesReturned)
{
SetLastError(ERROR_INVALID_USER_BUFFER);
return FALSE;
}
if (WTSInfoClass == WTSUserName)
{
WCHAR *username;
@ -354,6 +360,11 @@ BOOL WINAPI WTSQuerySessionInformationW(
*BytesReturned = count * sizeof(WCHAR);
return TRUE;
}
else
{
*Buffer = NULL;
*BytesReturned = 0;
}
return FALSE;
}