Commit 116890da authored by Gijs Vermeulen's avatar Gijs Vermeulen Committed by Alexandre Julliard

wtsapi32: Improve WTSQuerySessionInformationW stub.

parent 1db2b563
......@@ -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);
......
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment