Gijs Vermeulen : wtsapi32: Avoid calling GetUserNameW() twice in WTSQuerySessionInformationW(WTSUserName).
Alexandre Julliard
julliard at winehq.org
Mon Mar 22 17:15:50 CDT 2021
Module: wine
Branch: master
Commit: 6a822d4708ee229a1982bca8d8b01fc5abf74e2f
URL: https://source.winehq.org/git/wine.git/?a=commit;h=6a822d4708ee229a1982bca8d8b01fc5abf74e2f
Author: Gijs Vermeulen <gijsvrm at gmail.com>
Date: Sun Mar 21 22:50:45 2021 +0100
wtsapi32: Avoid calling GetUserNameW() twice in WTSQuerySessionInformationW(WTSUserName).
Signed-off-by: Gijs Vermeulen <gijsvrm at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
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;
}
More information about the wine-cvs
mailing list