[PATCH 2/2] wtsapi32: Improve the stub for WTSQuerySessionInformationW.
Hans Leidekker
hans at codeweavers.com
Wed Apr 11 05:05:48 CDT 2018
Signed-off-by: Hans Leidekker <hans at codeweavers.com>
---
dlls/wtsapi32/Makefile.in | 1 +
dlls/wtsapi32/tests/wtsapi.c | 16 ++++++++++++++++
dlls/wtsapi32/wtsapi32.c | 13 +++++++++++++
include/wtsapi32.h | 1 +
4 files changed, 31 insertions(+)
diff --git a/dlls/wtsapi32/Makefile.in b/dlls/wtsapi32/Makefile.in
index 784a91c978..e54c088f21 100644
--- a/dlls/wtsapi32/Makefile.in
+++ b/dlls/wtsapi32/Makefile.in
@@ -1,5 +1,6 @@
MODULE = wtsapi32.dll
IMPORTLIB = wtsapi32
+IMPORTS = advapi32
C_SRCS = \
wtsapi32.c
diff --git a/dlls/wtsapi32/tests/wtsapi.c b/dlls/wtsapi32/tests/wtsapi.c
index 3b7aa1bf09..341d9e605f 100644
--- a/dlls/wtsapi32/tests/wtsapi.c
+++ b/dlls/wtsapi32/tests/wtsapi.c
@@ -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();
}
diff --git a/dlls/wtsapi32/wtsapi32.c b/dlls/wtsapi32/wtsapi32.c
index 736e1995b6..5569502977 100644
--- a/dlls/wtsapi32/wtsapi32.c
+++ b/dlls/wtsapi32/wtsapi32.c
@@ -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;
}
diff --git a/include/wtsapi32.h b/include/wtsapi32.h
index 304a418726..f329bd5cf0 100644
--- a/include/wtsapi32.h
+++ b/include/wtsapi32.h
@@ -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);
--
2.11.0
More information about the wine-devel
mailing list