wtsapi32: Avoid calling GetUserNameW() twice in WTSQuerySessionInformationW(WTSUserName).
Signed-off-by: Gijs Vermeulen <gijsvrm@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
(cherry picked from commit 6a822d4708
)
Signed-off-by: Michael Stefaniuc <mstefani@winehq.org>
This commit is contained in:
parent
fa78f4a2da
commit
d2d42b9cc5
|
@ -20,6 +20,7 @@
|
||||||
#include "windef.h"
|
#include "windef.h"
|
||||||
#include "winbase.h"
|
#include "winbase.h"
|
||||||
#include "winnls.h"
|
#include "winnls.h"
|
||||||
|
#include "lmcons.h"
|
||||||
#include "wtsapi32.h"
|
#include "wtsapi32.h"
|
||||||
#include "wine/debug.h"
|
#include "wine/debug.h"
|
||||||
#include "wine/heap.h"
|
#include "wine/heap.h"
|
||||||
|
@ -330,41 +331,32 @@ BOOL WINAPI WTSQuerySessionInformationA(HANDLE server, DWORD session_id, WTS_INF
|
||||||
/************************************************************
|
/************************************************************
|
||||||
* WTSQuerySessionInformationW (WTSAPI32.@)
|
* WTSQuerySessionInformationW (WTSAPI32.@)
|
||||||
*/
|
*/
|
||||||
BOOL WINAPI WTSQuerySessionInformationW(
|
BOOL WINAPI WTSQuerySessionInformationW(HANDLE server, DWORD session_id, WTS_INFO_CLASS class, WCHAR **buffer, DWORD *count)
|
||||||
HANDLE hServer,
|
|
||||||
DWORD SessionId,
|
|
||||||
WTS_INFO_CLASS WTSInfoClass,
|
|
||||||
LPWSTR* Buffer,
|
|
||||||
DWORD* BytesReturned)
|
|
||||||
{
|
{
|
||||||
/* FIXME: Forward request to winsta.dll::WinStationQueryInformationW */
|
TRACE("%p 0x%08x %d %p %p\n", server, session_id, class, buffer, count);
|
||||||
FIXME("Stub %p 0x%08x %d %p %p\n", hServer, SessionId, WTSInfoClass,
|
|
||||||
Buffer, BytesReturned);
|
|
||||||
|
|
||||||
if (!Buffer || !BytesReturned)
|
if (!buffer || !count)
|
||||||
{
|
{
|
||||||
SetLastError(ERROR_INVALID_USER_BUFFER);
|
SetLastError(ERROR_INVALID_USER_BUFFER);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (WTSInfoClass == WTSUserName)
|
if (class == WTSUserName)
|
||||||
{
|
{
|
||||||
|
DWORD size = UNLEN + 1;
|
||||||
WCHAR *username;
|
WCHAR *username;
|
||||||
DWORD count = 0;
|
|
||||||
|
|
||||||
GetUserNameW(NULL, &count);
|
if (!(username = heap_alloc(size * sizeof(WCHAR)))) return FALSE;
|
||||||
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) return FALSE;
|
GetUserNameW(username, &size);
|
||||||
if (!(username = heap_alloc(count * sizeof(WCHAR)))) return FALSE;
|
*buffer = username;
|
||||||
GetUserNameW(username, &count);
|
*count = size * sizeof(WCHAR);
|
||||||
*Buffer = username;
|
|
||||||
*BytesReturned = count * sizeof(WCHAR);
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
FIXME("Unimplemented class %d\n", class);
|
||||||
*Buffer = NULL;
|
|
||||||
*BytesReturned = 0;
|
*buffer = NULL;
|
||||||
}
|
*count = 0;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue