wtsapi32: Improve the stub for WTSQuerySessionInformationW.

Signed-off-by: Hans Leidekker <hans@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Hans Leidekker 2018-04-11 12:05:48 +02:00 committed by Alexandre Julliard
parent 90681e3a76
commit a389b33c25
4 changed files with 31 additions and 0 deletions

View File

@ -1,5 +1,6 @@
MODULE = wtsapi32.dll
IMPORTLIB = wtsapi32
IMPORTS = advapi32
C_SRCS = \
wtsapi32.c

View File

@ -90,7 +90,23 @@ static void test_WTSEnumerateProcessesW(void)
WTSFreeMemory(info);
}
static void test_WTSQuerySessionInformationW(void)
{
BOOL ret;
WCHAR *buf;
DWORD count;
count = 0;
buf = NULL;
ret = WTSQuerySessionInformationW(WTS_CURRENT_SERVER_HANDLE, WTS_CURRENT_SESSION, WTSUserName, &buf, &count);
ok(ret, "got %u\n", GetLastError());
ok(buf != NULL, "buf not set\n");
ok(count == (lstrlenW(buf) + 1) * sizeof(WCHAR), "got %u\n", count);
WTSFreeMemory(buf);
}
START_TEST (wtsapi)
{
test_WTSEnumerateProcessesW();
test_WTSQuerySessionInformationW();
}

View File

@ -233,6 +233,19 @@ BOOL WINAPI WTSQuerySessionInformationW(
FIXME("Stub %p 0x%08x %d %p %p\n", hServer, SessionId, WTSInfoClass,
Buffer, BytesReturned);
if (WTSInfoClass == WTSUserName)
{
WCHAR *username;
DWORD count = 0;
GetUserNameW(NULL, &count);
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) return FALSE;
if (!(username = heap_alloc(count * sizeof(WCHAR)))) return FALSE;
GetUserNameW(username, &count);
*Buffer = username;
*BytesReturned = count * sizeof(WCHAR);
return TRUE;
}
return FALSE;
}

View File

@ -136,6 +136,7 @@ DECL_WINELIB_TYPE_AW(WTS_SERVER_INFO)
DECL_WINELIB_TYPE_AW(PWTS_SERVER_INFO)
#define WTS_CURRENT_SERVER_HANDLE ((HANDLE)NULL)
#define WTS_CURRENT_SESSION (~0u)
void WINAPI WTSCloseServer(HANDLE);
BOOL WINAPI WTSConnectSessionA(ULONG, ULONG, PSTR, BOOL);