Commit 6c3399a9 authored by Paul Gofman's avatar Paul Gofman Committed by Alexandre Julliard

wtsapi32: Improve WTSEnumerateSessionsW() stub.

parent 7c94e424
...@@ -306,6 +306,38 @@ static void test_WTSQueryUserToken(void) ...@@ -306,6 +306,38 @@ static void test_WTSQueryUserToken(void)
ok(GetLastError()==ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER got: %ld\n", GetLastError()); ok(GetLastError()==ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER got: %ld\n", GetLastError());
} }
static void test_WTSEnumerateSessions(void)
{
BOOL console_found = FALSE, services_found = FALSE;
WTS_SESSION_INFOW *info;
unsigned int i;
DWORD count;
BOOL bret;
bret = WTSEnumerateSessionsW(WTS_CURRENT_SERVER_HANDLE, 0, 1, &info, &count);
ok(bret, "got error %lu.\n", GetLastError());
todo_wine_if(count == 1) ok(count >= 2, "got %lu.\n", count);
for (i = 0; i < count; ++i)
{
trace("SessionId %lu, name %s, State %d.\n", info[i].SessionId, debugstr_w(info[i].pWinStationName), info[i].State);
if (!wcscmp(info[i].pWinStationName, L"Console"))
{
console_found = TRUE;
ok(info[i].State == WTSActive, "got State %d.\n", info[i].State);
}
else if (!wcscmp(info[i].pWinStationName, L"Services"))
{
services_found = TRUE;
ok(info[i].State == WTSDisconnected, "got State %d.\n", info[i].State);
}
}
ok(console_found, "Console session not found.\n");
todo_wine ok(services_found, "Services session not found.\n");
WTSFreeMemory(info);
}
START_TEST (wtsapi) START_TEST (wtsapi)
{ {
pWTSEnumerateProcessesExW = (void *)GetProcAddress(GetModuleHandleA("wtsapi32"), "WTSEnumerateProcessesExW"); pWTSEnumerateProcessesExW = (void *)GetProcAddress(GetModuleHandleA("wtsapi32"), "WTSEnumerateProcessesExW");
...@@ -314,4 +346,5 @@ START_TEST (wtsapi) ...@@ -314,4 +346,5 @@ START_TEST (wtsapi)
test_WTSEnumerateProcessesW(); test_WTSEnumerateProcessesW();
test_WTSQuerySessionInformation(); test_WTSQuerySessionInformation();
test_WTSQueryUserToken(); test_WTSQueryUserToken();
test_WTSEnumerateSessions();
} }
...@@ -309,16 +309,29 @@ BOOL WINAPI WTSEnumerateSessionsA(HANDLE hServer, DWORD Reserved, DWORD Version, ...@@ -309,16 +309,29 @@ BOOL WINAPI WTSEnumerateSessionsA(HANDLE hServer, DWORD Reserved, DWORD Version,
/************************************************************ /************************************************************
* WTSEnumerateEnumerateSessionsW (WTSAPI32.@) * WTSEnumerateEnumerateSessionsW (WTSAPI32.@)
*/ */
BOOL WINAPI WTSEnumerateSessionsW(HANDLE hServer, DWORD Reserved, DWORD Version, BOOL WINAPI WTSEnumerateSessionsW(HANDLE server, DWORD reserved, DWORD version,
PWTS_SESSION_INFOW* ppSessionInfo, DWORD* pCount) PWTS_SESSION_INFOW *session_info, DWORD *count)
{ {
FIXME("Stub %p 0x%08lx 0x%08lx %p %p\n", hServer, Reserved, Version, static const WCHAR session_name[] = L"Console";
ppSessionInfo, pCount);
if (!ppSessionInfo || !pCount) return FALSE; FIXME("%p 0x%08lx 0x%08lx %p %p semi-stub.\n", server, reserved, version, session_info, count);
*pCount = 0; if (!session_info || !count) return FALSE;
*ppSessionInfo = NULL;
if (!(*session_info = heap_alloc(sizeof(**session_info) + sizeof(session_name))))
{
SetLastError(ERROR_OUTOFMEMORY);
return FALSE;
}
if (!ProcessIdToSessionId( GetCurrentProcessId(), &(*session_info)->SessionId))
{
WTSFreeMemory(*session_info);
return FALSE;
}
*count = 1;
(*session_info)->State = WTSActive;
(*session_info)->pWinStationName = (WCHAR *)((char *)*session_info + sizeof(**session_info));
memcpy((*session_info)->pWinStationName, session_name, sizeof(session_name));
return TRUE; return TRUE;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment