Louis Lenders : wtsapi32: Implement WTSQuerySessionInformation(WTSDomainName).
Alexandre Julliard
julliard at winehq.org
Tue Oct 26 09:40:25 CDT 2021
Module: wine
Branch: stable
Commit: c3a9607a3b6956d9c72206c58190f2520c15fc43
URL: https://source.winehq.org/git/wine.git/?a=commit;h=c3a9607a3b6956d9c72206c58190f2520c15fc43
Author: Louis Lenders <xerox.xerox2000x at gmail.com>
Date: Sun Mar 21 22:50:47 2021 +0100
wtsapi32: Implement WTSQuerySessionInformation(WTSDomainName).
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47310
Signed-off-by: Gijs Vermeulen <gijsvrm at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
(cherry picked from commit c6f133f6351b66b265748fc338385cd29a553a53)
Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>
---
dlls/wtsapi32/tests/wtsapi.c | 30 ++++++++++++++++++++++++++++--
dlls/wtsapi32/wtsapi32.c | 14 ++++++++++++++
2 files changed, 42 insertions(+), 2 deletions(-)
diff --git a/dlls/wtsapi32/tests/wtsapi.c b/dlls/wtsapi32/tests/wtsapi.c
index 7cff02de526..8ce1dc8bf9c 100644
--- a/dlls/wtsapi32/tests/wtsapi.c
+++ b/dlls/wtsapi32/tests/wtsapi.c
@@ -93,8 +93,8 @@ static void test_WTSEnumerateProcessesW(void)
static void test_WTSQuerySessionInformation(void)
{
- WCHAR *buf1, usernameW[UNLEN + 1];
- char *buf2, username[UNLEN + 1];
+ WCHAR *buf1, usernameW[UNLEN + 1], computernameW[MAX_COMPUTERNAME_LENGTH + 1];
+ char *buf2, username[UNLEN + 1], computername[MAX_COMPUTERNAME_LENGTH + 1];
DWORD count, tempsize;
BOOL ret;
@@ -130,6 +130,19 @@ static void test_WTSQuerySessionInformation(void)
ok(count == tempsize * sizeof(WCHAR), "expected %u, got %u\n", tempsize * sizeof(WCHAR), count);
WTSFreeMemory(buf1);
+ count = 0;
+ buf1 = NULL;
+ ret = WTSQuerySessionInformationW(WTS_CURRENT_SERVER_HANDLE, WTS_CURRENT_SESSION, WTSDomainName, &buf1, &count);
+ ok(ret, "got %u\n", GetLastError());
+ ok(buf1 != NULL, "buf not set\n");
+ ok(count == (lstrlenW(buf1) + 1) * sizeof(WCHAR), "expected %u, got %u\n", (lstrlenW(buf1) + 1) * sizeof(WCHAR), count);
+ tempsize = MAX_COMPUTERNAME_LENGTH + 1;
+ GetComputerNameW(computernameW, &tempsize);
+ /* Windows Vista, 7 and 8 return uppercase computername, while the rest return lowercase. */
+ ok(!wcsicmp(buf1, computernameW), "expected %s, got %s\n", wine_dbgstr_w(computernameW), wine_dbgstr_w(buf1));
+ ok(count == (tempsize + 1) * sizeof(WCHAR), "expected %u, got %u\n", (tempsize + 1) * sizeof(WCHAR), count);
+ WTSFreeMemory(buf1);
+
SetLastError(0xdeadbeef);
count = 0;
ret = WTSQuerySessionInformationA(WTS_CURRENT_SERVER_HANDLE, WTS_CURRENT_SESSION, WTSUserName, NULL, &count);
@@ -161,6 +174,19 @@ static void test_WTSQuerySessionInformation(void)
ok(!stricmp(buf2, username), "expected %s, got %s\n", username, buf2);
ok(count == tempsize, "expected %u, got %u\n", tempsize, count);
WTSFreeMemory(buf2);
+
+ count = 0;
+ buf2 = NULL;
+ ret = WTSQuerySessionInformationA(WTS_CURRENT_SERVER_HANDLE, WTS_CURRENT_SESSION, WTSDomainName, &buf2, &count);
+ ok(ret, "got %u\n", GetLastError());
+ ok(buf2 != NULL, "buf not set\n");
+ ok(count == lstrlenA(buf2) + 1, "expected %u, got %u\n", lstrlenA(buf2) + 1, count);
+ tempsize = MAX_COMPUTERNAME_LENGTH + 1;
+ GetComputerNameA(computername, &tempsize);
+ /* Windows Vista, 7 and 8 return uppercase computername, while the rest return lowercase. */
+ ok(!stricmp(buf2, computername), "expected %s, got %s\n", computername, buf2);
+ ok(count == tempsize + 1, "expected %u, got %u\n", tempsize + 1, count);
+ WTSFreeMemory(buf2);
}
static void test_WTSQueryUserToken(void)
diff --git a/dlls/wtsapi32/wtsapi32.c b/dlls/wtsapi32/wtsapi32.c
index ae7a6c195f8..a5c9bf6519f 100644
--- a/dlls/wtsapi32/wtsapi32.c
+++ b/dlls/wtsapi32/wtsapi32.c
@@ -353,6 +353,20 @@ BOOL WINAPI WTSQuerySessionInformationW(HANDLE server, DWORD session_id, WTS_INF
return TRUE;
}
+ if (class == WTSDomainName)
+ {
+ DWORD size = MAX_COMPUTERNAME_LENGTH + 1;
+ WCHAR *computername;
+
+ if (!(computername = heap_alloc(size * sizeof(WCHAR)))) return FALSE;
+ GetComputerNameW(computername, &size);
+ *buffer = computername;
+ /* GetComputerNameW() return size doesn't include terminator */
+ size++;
+ *count = size * sizeof(WCHAR);
+ return TRUE;
+ }
+
FIXME("Unimplemented class %d\n", class);
*buffer = NULL;
More information about the wine-cvs
mailing list