Signed-off-by: Gijs Vermeulen gijsvrm@gmail.com --- dlls/wtsapi32/wtsapi32.c | 40 ++++++++++++++++------------------------ 1 file changed, 16 insertions(+), 24 deletions(-)
diff --git a/dlls/wtsapi32/wtsapi32.c b/dlls/wtsapi32/wtsapi32.c index ef3e0d10a0f..ae7a6c195f8 100644 --- a/dlls/wtsapi32/wtsapi32.c +++ b/dlls/wtsapi32/wtsapi32.c @@ -20,6 +20,7 @@ #include "windef.h" #include "winbase.h" #include "winnls.h" +#include "lmcons.h" #include "wtsapi32.h" #include "wine/debug.h" #include "wine/heap.h" @@ -330,41 +331,32 @@ BOOL WINAPI WTSQuerySessionInformationA(HANDLE server, DWORD session_id, WTS_INF /************************************************************ * WTSQuerySessionInformationW (WTSAPI32.@) */ -BOOL WINAPI WTSQuerySessionInformationW( - HANDLE hServer, - DWORD SessionId, - WTS_INFO_CLASS WTSInfoClass, - LPWSTR* Buffer, - DWORD* BytesReturned) +BOOL WINAPI WTSQuerySessionInformationW(HANDLE server, DWORD session_id, WTS_INFO_CLASS class, WCHAR **buffer, DWORD *count) { - /* FIXME: Forward request to winsta.dll::WinStationQueryInformationW */ - FIXME("Stub %p 0x%08x %d %p %p\n", hServer, SessionId, WTSInfoClass, - Buffer, BytesReturned); + TRACE("%p 0x%08x %d %p %p\n", server, session_id, class, buffer, count);
- if (!Buffer || !BytesReturned) + if (!buffer || !count) { SetLastError(ERROR_INVALID_USER_BUFFER); return FALSE; }
- if (WTSInfoClass == WTSUserName) + if (class == WTSUserName) { + DWORD size = UNLEN + 1; 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); + + if (!(username = heap_alloc(size * sizeof(WCHAR)))) return FALSE; + GetUserNameW(username, &size); + *buffer = username; + *count = size * sizeof(WCHAR); return TRUE; } - else - { - *Buffer = NULL; - *BytesReturned = 0; - } + + FIXME("Unimplemented class %d\n", class); + + *buffer = NULL; + *count = 0; return FALSE; }
Signed-off-by: Gijs Vermeulen gijsvrm@gmail.com --- dlls/wtsapi32/tests/Makefile.in | 2 +- dlls/wtsapi32/tests/wtsapi.c | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/dlls/wtsapi32/tests/Makefile.in b/dlls/wtsapi32/tests/Makefile.in index a398a8085cd..be0fa8d6772 100644 --- a/dlls/wtsapi32/tests/Makefile.in +++ b/dlls/wtsapi32/tests/Makefile.in @@ -1,5 +1,5 @@ TESTDLL = wtsapi32.dll -IMPORTS = wtsapi32 +IMPORTS = wtsapi32 advapi32
C_SRCS = \ wtsapi.c diff --git a/dlls/wtsapi32/tests/wtsapi.c b/dlls/wtsapi32/tests/wtsapi.c index c9312cd97c5..7cff02de526 100644 --- a/dlls/wtsapi32/tests/wtsapi.c +++ b/dlls/wtsapi32/tests/wtsapi.c @@ -21,6 +21,7 @@ #include <windef.h> #include <winbase.h> #include <winternl.h> +#include <lmcons.h> #include <wtsapi32.h>
#include "wine/test.h" @@ -92,10 +93,10 @@ static void test_WTSEnumerateProcessesW(void)
static void test_WTSQuerySessionInformation(void) { + WCHAR *buf1, usernameW[UNLEN + 1]; + char *buf2, username[UNLEN + 1]; + DWORD count, tempsize; BOOL ret; - WCHAR *buf1; - char *buf2; - DWORD count;
SetLastError(0xdeadbeef); count = 0; @@ -122,6 +123,11 @@ static void test_WTSQuerySessionInformation(void) 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 = UNLEN + 1; + GetUserNameW(usernameW, &tempsize); + /* Windows Vista, 7 and 8 return uppercase username, while the rest return lowercase. */ + ok(!wcsicmp(buf1, usernameW), "expected %s, got %s\n", wine_dbgstr_w(usernameW), wine_dbgstr_w(buf1)); + ok(count == tempsize * sizeof(WCHAR), "expected %u, got %u\n", tempsize * sizeof(WCHAR), count); WTSFreeMemory(buf1);
SetLastError(0xdeadbeef); @@ -149,6 +155,11 @@ static void test_WTSQuerySessionInformation(void) 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 = UNLEN + 1; + GetUserNameA(username, &tempsize); + /* Windows Vista, 7 and 8 return uppercase username, while the rest return lowercase. */ + ok(!stricmp(buf2, username), "expected %s, got %s\n", username, buf2); + ok(count == tempsize, "expected %u, got %u\n", tempsize, count); WTSFreeMemory(buf2); }
From: Louis Lenders xerox.xerox2000x@gmail.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47310 Signed-off-by: Gijs Vermeulen gijsvrm@gmail.com --- 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;