2005-01-24 20:42:02 +01:00
|
|
|
/* Copyright 2005 Ulrich Czekalla
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2005-01-24 20:42:02 +01:00
|
|
|
*/
|
|
|
|
|
2021-05-26 07:13:42 +02:00
|
|
|
#include "ntstatus.h"
|
|
|
|
#define WIN32_NO_STATUS
|
2005-01-24 20:42:02 +01:00
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
2021-05-26 07:13:42 +02:00
|
|
|
#include "winternl.h"
|
2020-05-28 15:59:26 +02:00
|
|
|
#include "winnls.h"
|
2021-03-21 22:50:45 +01:00
|
|
|
#include "lmcons.h"
|
2005-01-24 20:42:02 +01:00
|
|
|
#include "wtsapi32.h"
|
|
|
|
#include "wine/debug.h"
|
2018-04-11 12:05:47 +02:00
|
|
|
#include "wine/heap.h"
|
2005-01-24 20:42:02 +01:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(wtsapi);
|
|
|
|
|
|
|
|
|
2005-03-16 12:27:05 +01:00
|
|
|
/************************************************************
|
|
|
|
* WTSCloseServer (WTSAPI32.@)
|
|
|
|
*/
|
|
|
|
void WINAPI WTSCloseServer(HANDLE hServer)
|
|
|
|
{
|
|
|
|
FIXME("Stub %p\n", hServer);
|
|
|
|
}
|
|
|
|
|
2010-11-28 17:14:56 +01:00
|
|
|
/************************************************************
|
|
|
|
* WTSConnectSessionA (WTSAPI32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI WTSConnectSessionA(ULONG LogonId, ULONG TargetLogonId, PSTR pPassword, BOOL bWait)
|
|
|
|
{
|
|
|
|
FIXME("Stub %d %d (%s) %d\n", LogonId, TargetLogonId, debugstr_a(pPassword), bWait);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************
|
|
|
|
* WTSConnectSessionW (WTSAPI32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI WTSConnectSessionW(ULONG LogonId, ULONG TargetLogonId, PWSTR pPassword, BOOL bWait)
|
|
|
|
{
|
|
|
|
FIXME("Stub %d %d (%s) %d\n", LogonId, TargetLogonId, debugstr_w(pPassword), bWait);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-03-16 12:27:05 +01:00
|
|
|
/************************************************************
|
|
|
|
* WTSDisconnectSession (WTSAPI32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI WTSDisconnectSession(HANDLE hServer, DWORD SessionId, BOOL bWait)
|
|
|
|
{
|
2006-10-06 23:02:04 +02:00
|
|
|
FIXME("Stub %p 0x%08x %d\n", hServer, SessionId, bWait);
|
2005-03-24 16:08:48 +01:00
|
|
|
return TRUE;
|
2005-03-16 12:27:05 +01:00
|
|
|
}
|
|
|
|
|
2015-04-22 20:48:48 +02:00
|
|
|
/************************************************************
|
|
|
|
* WTSEnableChildSessions (WTSAPI32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI WTSEnableChildSessions(BOOL enable)
|
|
|
|
{
|
|
|
|
FIXME("Stub %d\n", enable);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-08-13 09:17:42 +02:00
|
|
|
|
|
|
|
/************************************************************
|
|
|
|
* WTSEnumerateProcessesExW (WTSAPI32.@)
|
|
|
|
*/
|
2021-05-26 07:13:42 +02:00
|
|
|
BOOL WINAPI WTSEnumerateProcessesExW(HANDLE server, DWORD *level, DWORD session_id,
|
|
|
|
WCHAR **ret_info, DWORD *ret_count)
|
2019-08-13 09:17:42 +02:00
|
|
|
{
|
2021-05-26 07:13:42 +02:00
|
|
|
SYSTEM_PROCESS_INFORMATION *nt_info, *nt_process;
|
|
|
|
WTS_PROCESS_INFOW *info;
|
|
|
|
ULONG nt_size = 4096;
|
|
|
|
DWORD count, size;
|
|
|
|
NTSTATUS status;
|
|
|
|
char *p;
|
|
|
|
|
|
|
|
TRACE("server %p, level %u, session_id %#x, ret_info %p, ret_count %p\n",
|
|
|
|
server, *level, session_id, ret_info, ret_count);
|
|
|
|
|
|
|
|
if (!ret_info || !ret_count)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (session_id != WTS_ANY_SESSION)
|
|
|
|
FIXME("ignoring session id %#x\n", session_id);
|
|
|
|
|
|
|
|
if (*level)
|
|
|
|
{
|
|
|
|
FIXME("unhandled level %u\n", *level);
|
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(nt_info = malloc(nt_size)))
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_OUTOFMEMORY);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
while ((status = NtQuerySystemInformation(SystemProcessInformation, nt_info,
|
|
|
|
nt_size, NULL)) == STATUS_INFO_LENGTH_MISMATCH)
|
|
|
|
{
|
|
|
|
SYSTEM_PROCESS_INFORMATION *new_info;
|
|
|
|
|
|
|
|
nt_size *= 2;
|
|
|
|
if (!(new_info = realloc(nt_info, nt_size)))
|
|
|
|
{
|
|
|
|
free(nt_info);
|
|
|
|
SetLastError(ERROR_OUTOFMEMORY);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
nt_info = new_info;
|
|
|
|
}
|
|
|
|
if (status)
|
|
|
|
{
|
|
|
|
free(nt_info);
|
|
|
|
SetLastError(RtlNtStatusToDosError(status));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
size = 0;
|
|
|
|
count = 0;
|
|
|
|
nt_process = nt_info;
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
size += sizeof(WTS_PROCESS_INFOW) + nt_process->ProcessName.Length + sizeof(WCHAR);
|
|
|
|
size += offsetof(SID, SubAuthority[SID_MAX_SUB_AUTHORITIES]);
|
|
|
|
++count;
|
|
|
|
|
|
|
|
if (!nt_process->NextEntryOffset)
|
|
|
|
break;
|
|
|
|
nt_process = (SYSTEM_PROCESS_INFORMATION *)((char *)nt_process + nt_process->NextEntryOffset);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(info = heap_alloc(size)))
|
|
|
|
{
|
|
|
|
free(nt_info);
|
|
|
|
SetLastError(ERROR_OUTOFMEMORY);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
p = (char *)(info + count);
|
|
|
|
|
|
|
|
count = 0;
|
|
|
|
nt_process = nt_info;
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
HANDLE process, token;
|
|
|
|
|
|
|
|
info[count].SessionId = nt_process->SessionId;
|
|
|
|
info[count].ProcessId = (DWORD_PTR)nt_process->UniqueProcessId;
|
|
|
|
|
|
|
|
info[count].pProcessName = (WCHAR *)p;
|
|
|
|
memcpy(p, nt_process->ProcessName.Buffer, nt_process->ProcessName.Length);
|
|
|
|
info[count].pProcessName[nt_process->ProcessName.Length / sizeof(WCHAR)] = 0;
|
|
|
|
p += nt_process->ProcessName.Length + sizeof(WCHAR);
|
|
|
|
|
|
|
|
info[count].pUserSid = NULL;
|
|
|
|
if ((process = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, info[count].ProcessId)))
|
|
|
|
{
|
|
|
|
if (OpenProcessToken(process, TOKEN_QUERY, &token))
|
|
|
|
{
|
|
|
|
char buffer[sizeof(TOKEN_USER) + offsetof(SID, SubAuthority[SID_MAX_SUB_AUTHORITIES])];
|
|
|
|
TOKEN_USER *user = (TOKEN_USER *)buffer;
|
|
|
|
DWORD size;
|
|
|
|
|
|
|
|
GetTokenInformation(token, TokenUser, buffer, sizeof(buffer), &size);
|
|
|
|
info[count].pUserSid = p;
|
|
|
|
size = GetLengthSid(user->User.Sid);
|
|
|
|
memcpy(p, user->User.Sid, size);
|
|
|
|
p += size;
|
|
|
|
CloseHandle(token);
|
|
|
|
}
|
|
|
|
CloseHandle(process);
|
|
|
|
}
|
|
|
|
|
|
|
|
++count;
|
|
|
|
if (!nt_process->NextEntryOffset)
|
|
|
|
break;
|
|
|
|
nt_process = (SYSTEM_PROCESS_INFORMATION *)((char *)nt_process + nt_process->NextEntryOffset);
|
|
|
|
}
|
|
|
|
|
|
|
|
*ret_info = (WCHAR *)info;
|
|
|
|
*ret_count = count;
|
|
|
|
SetLastError(0);
|
|
|
|
return TRUE;
|
2019-08-13 09:17:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************
|
|
|
|
* WTSEnumerateProcessesExA (WTSAPI32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI WTSEnumerateProcessesExA(HANDLE server, DWORD *level, DWORD session_id, char **info, DWORD *count)
|
|
|
|
{
|
|
|
|
FIXME("Stub %p %p %d %p %p\n", server, level, session_id, info, count);
|
|
|
|
if (count) *count = 0;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2005-03-16 12:27:05 +01:00
|
|
|
/************************************************************
|
|
|
|
* WTSEnumerateProcessesA (WTSAPI32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI WTSEnumerateProcessesA(HANDLE hServer, DWORD Reserved, DWORD Version,
|
|
|
|
PWTS_PROCESS_INFOA* ppProcessInfo, DWORD* pCount)
|
|
|
|
{
|
2006-10-06 23:02:04 +02:00
|
|
|
FIXME("Stub %p 0x%08x 0x%08x %p %p\n", hServer, Reserved, Version,
|
2005-03-16 12:27:05 +01:00
|
|
|
ppProcessInfo, pCount);
|
2005-03-24 16:08:48 +01:00
|
|
|
|
|
|
|
if (!ppProcessInfo || !pCount) return FALSE;
|
|
|
|
|
|
|
|
*pCount = 0;
|
|
|
|
*ppProcessInfo = NULL;
|
|
|
|
|
|
|
|
return TRUE;
|
2005-03-16 12:27:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************
|
|
|
|
* WTSEnumerateProcessesW (WTSAPI32.@)
|
|
|
|
*/
|
2021-05-26 07:13:42 +02:00
|
|
|
BOOL WINAPI WTSEnumerateProcessesW(HANDLE server, DWORD reserved, DWORD version,
|
|
|
|
WTS_PROCESS_INFOW **info, DWORD *count)
|
2005-03-16 12:27:05 +01:00
|
|
|
{
|
2021-05-26 07:13:42 +02:00
|
|
|
DWORD level = 0;
|
2005-03-24 16:08:48 +01:00
|
|
|
|
2021-05-26 07:13:42 +02:00
|
|
|
TRACE("server %p, reserved %#x, version %u, info %p, count %p\n", server, reserved, version, info, count);
|
|
|
|
|
|
|
|
if (reserved || version != 1)
|
2014-03-25 22:53:26 +01:00
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2005-03-24 16:08:48 +01:00
|
|
|
|
2021-05-26 07:13:42 +02:00
|
|
|
return WTSEnumerateProcessesExW(server, &level, WTS_ANY_SESSION, (WCHAR **)info, count);
|
2005-03-16 12:27:05 +01:00
|
|
|
}
|
|
|
|
|
2010-11-28 17:14:56 +01:00
|
|
|
/************************************************************
|
|
|
|
* WTSEnumerateServersA (WTSAPI32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI WTSEnumerateServersA(LPSTR pDomainName, DWORD Reserved, DWORD Version, PWTS_SERVER_INFOA *ppServerInfo, DWORD *pCount)
|
|
|
|
{
|
|
|
|
FIXME("Stub %s 0x%08x 0x%08x %p %p\n", debugstr_a(pDomainName), Reserved, Version, ppServerInfo, pCount);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************
|
|
|
|
* WTSEnumerateServersW (WTSAPI32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI WTSEnumerateServersW(LPWSTR pDomainName, DWORD Reserved, DWORD Version, PWTS_SERVER_INFOW *ppServerInfo, DWORD *pCount)
|
|
|
|
{
|
|
|
|
FIXME("Stub %s 0x%08x 0x%08x %p %p\n", debugstr_w(pDomainName), Reserved, Version, ppServerInfo, pCount);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-08-13 09:17:44 +02:00
|
|
|
/************************************************************
|
|
|
|
* WTSEnumerateEnumerateSessionsExW (WTSAPI32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI WTSEnumerateSessionsExW(HANDLE server, DWORD *level, DWORD filter, WTS_SESSION_INFO_1W* info, DWORD *count)
|
|
|
|
{
|
|
|
|
FIXME("Stub %p %p %d %p %p\n", server, level, filter, info, count);
|
|
|
|
if (count) *count = 0;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************
|
|
|
|
* WTSEnumerateEnumerateSessionsExA (WTSAPI32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI WTSEnumerateSessionsExA(HANDLE server, DWORD *level, DWORD filter, WTS_SESSION_INFO_1A* info, DWORD *count)
|
|
|
|
{
|
|
|
|
FIXME("Stub %p %p %d %p %p\n", server, level, filter, info, count);
|
|
|
|
if (count) *count = 0;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2005-03-16 12:27:05 +01:00
|
|
|
/************************************************************
|
|
|
|
* WTSEnumerateEnumerateSessionsA (WTSAPI32.@)
|
|
|
|
*/
|
2005-03-21 11:32:45 +01:00
|
|
|
BOOL WINAPI WTSEnumerateSessionsA(HANDLE hServer, DWORD Reserved, DWORD Version,
|
2005-03-16 12:27:05 +01:00
|
|
|
PWTS_SESSION_INFOA* ppSessionInfo, DWORD* pCount)
|
|
|
|
{
|
2014-01-28 00:43:00 +01:00
|
|
|
static int once;
|
|
|
|
|
|
|
|
if (!once++) FIXME("Stub %p 0x%08x 0x%08x %p %p\n", hServer, Reserved, Version,
|
2005-03-16 12:27:05 +01:00
|
|
|
ppSessionInfo, pCount);
|
2005-03-24 16:08:48 +01:00
|
|
|
|
|
|
|
if (!ppSessionInfo || !pCount) return FALSE;
|
|
|
|
|
|
|
|
*pCount = 0;
|
|
|
|
*ppSessionInfo = NULL;
|
|
|
|
|
|
|
|
return TRUE;
|
2005-03-16 12:27:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************
|
|
|
|
* WTSEnumerateEnumerateSessionsW (WTSAPI32.@)
|
|
|
|
*/
|
2005-03-21 11:32:45 +01:00
|
|
|
BOOL WINAPI WTSEnumerateSessionsW(HANDLE hServer, DWORD Reserved, DWORD Version,
|
2005-03-16 12:27:05 +01:00
|
|
|
PWTS_SESSION_INFOW* ppSessionInfo, DWORD* pCount)
|
|
|
|
{
|
2006-10-06 23:02:04 +02:00
|
|
|
FIXME("Stub %p 0x%08x 0x%08x %p %p\n", hServer, Reserved, Version,
|
2005-03-16 12:27:05 +01:00
|
|
|
ppSessionInfo, pCount);
|
2005-03-24 16:08:48 +01:00
|
|
|
|
|
|
|
if (!ppSessionInfo || !pCount) return FALSE;
|
|
|
|
|
|
|
|
*pCount = 0;
|
|
|
|
*ppSessionInfo = NULL;
|
|
|
|
|
|
|
|
return TRUE;
|
2005-03-16 12:27:05 +01:00
|
|
|
}
|
|
|
|
|
2005-04-19 14:00:29 +02:00
|
|
|
/************************************************************
|
|
|
|
* WTSFreeMemory (WTSAPI32.@)
|
|
|
|
*/
|
|
|
|
void WINAPI WTSFreeMemory(PVOID pMemory)
|
|
|
|
{
|
2018-04-11 12:05:47 +02:00
|
|
|
heap_free(pMemory);
|
2005-04-19 14:00:29 +02:00
|
|
|
}
|
|
|
|
|
2019-08-13 09:17:47 +02:00
|
|
|
/************************************************************
|
|
|
|
* WTSFreeMemoryExA (WTSAPI32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI WTSFreeMemoryExA(WTS_TYPE_CLASS type, void *ptr, ULONG nmemb)
|
|
|
|
{
|
|
|
|
TRACE("%d %p %d\n", type, ptr, nmemb);
|
|
|
|
heap_free(ptr);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************
|
|
|
|
* WTSFreeMemoryExW (WTSAPI32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI WTSFreeMemoryExW(WTS_TYPE_CLASS type, void *ptr, ULONG nmemb)
|
|
|
|
{
|
|
|
|
TRACE("%d %p %d\n", type, ptr, nmemb);
|
|
|
|
heap_free(ptr);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-07 20:13:59 +01:00
|
|
|
/************************************************************
|
|
|
|
* WTSLogoffSession (WTSAPI32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI WTSLogoffSession(HANDLE hserver, DWORD session_id, BOOL bwait)
|
|
|
|
{
|
|
|
|
FIXME("(%p, 0x%x, %d): stub\n", hserver, session_id, bwait);
|
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-08-13 09:17:45 +02:00
|
|
|
|
|
|
|
/************************************************************
|
|
|
|
* WTSOpenServerExW (WTSAPI32.@)
|
|
|
|
*/
|
|
|
|
HANDLE WINAPI WTSOpenServerExW(WCHAR *server_name)
|
|
|
|
{
|
|
|
|
FIXME("(%s) stub\n", debugstr_w(server_name));
|
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************
|
|
|
|
* WTSOpenServerExA (WTSAPI32.@)
|
|
|
|
*/
|
|
|
|
HANDLE WINAPI WTSOpenServerExA(char *server_name)
|
|
|
|
{
|
|
|
|
FIXME("(%s) stub\n", debugstr_a(server_name));
|
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2006-08-05 00:17:39 +02:00
|
|
|
/************************************************************
|
|
|
|
* WTSOpenServerA (WTSAPI32.@)
|
|
|
|
*/
|
|
|
|
HANDLE WINAPI WTSOpenServerA(LPSTR pServerName)
|
|
|
|
{
|
|
|
|
FIXME("(%s) stub\n", debugstr_a(pServerName));
|
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************
|
|
|
|
* WTSOpenServerW (WTSAPI32.@)
|
|
|
|
*/
|
|
|
|
HANDLE WINAPI WTSOpenServerW(LPWSTR pServerName)
|
|
|
|
{
|
|
|
|
FIXME("(%s) stub\n", debugstr_w(pServerName));
|
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2005-03-16 12:27:05 +01:00
|
|
|
/************************************************************
|
|
|
|
* WTSQuerySessionInformationA (WTSAPI32.@)
|
|
|
|
*/
|
2020-05-28 15:59:26 +02:00
|
|
|
BOOL WINAPI WTSQuerySessionInformationA(HANDLE server, DWORD session_id, WTS_INFO_CLASS class, char **buffer, DWORD *count)
|
2005-03-16 12:27:05 +01:00
|
|
|
{
|
2020-05-28 15:59:26 +02:00
|
|
|
WCHAR *bufferW = NULL;
|
2005-03-16 12:27:05 +01:00
|
|
|
|
2020-05-28 15:59:26 +02:00
|
|
|
TRACE("%p 0x%08x %d %p %p\n", server, session_id, class, buffer, count);
|
|
|
|
|
|
|
|
if (!buffer || !count)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_USER_BUFFER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!WTSQuerySessionInformationW(server, session_id, class, &bufferW, count))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
*count = WideCharToMultiByte(CP_ACP, 0, bufferW, -1, NULL, 0, NULL, NULL);
|
|
|
|
if (!*count)
|
|
|
|
{
|
|
|
|
WTSFreeMemory(bufferW);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(*buffer = heap_alloc(*count)))
|
|
|
|
{
|
|
|
|
WTSFreeMemory(bufferW);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(*count = WideCharToMultiByte(CP_ACP, 0, bufferW, -1, *buffer, *count, NULL, NULL)))
|
|
|
|
{
|
|
|
|
WTSFreeMemory(bufferW);
|
|
|
|
heap_free(*buffer);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
WTSFreeMemory(bufferW);
|
|
|
|
return TRUE;
|
2005-03-16 12:27:05 +01:00
|
|
|
}
|
2005-01-24 20:42:02 +01:00
|
|
|
|
|
|
|
/************************************************************
|
|
|
|
* WTSQuerySessionInformationW (WTSAPI32.@)
|
|
|
|
*/
|
2021-03-21 22:50:45 +01:00
|
|
|
BOOL WINAPI WTSQuerySessionInformationW(HANDLE server, DWORD session_id, WTS_INFO_CLASS class, WCHAR **buffer, DWORD *count)
|
2005-01-24 20:42:02 +01:00
|
|
|
{
|
2021-03-21 22:50:45 +01:00
|
|
|
TRACE("%p 0x%08x %d %p %p\n", server, session_id, class, buffer, count);
|
2005-01-24 20:42:02 +01:00
|
|
|
|
2021-03-21 22:50:45 +01:00
|
|
|
if (!buffer || !count)
|
2020-05-28 15:59:27 +02:00
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_USER_BUFFER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2021-03-21 22:50:45 +01:00
|
|
|
if (class == WTSUserName)
|
2018-04-11 12:05:48 +02:00
|
|
|
{
|
2021-03-21 22:50:45 +01:00
|
|
|
DWORD size = UNLEN + 1;
|
2018-04-11 12:05:48 +02:00
|
|
|
WCHAR *username;
|
2021-03-21 22:50:45 +01:00
|
|
|
|
|
|
|
if (!(username = heap_alloc(size * sizeof(WCHAR)))) return FALSE;
|
|
|
|
GetUserNameW(username, &size);
|
|
|
|
*buffer = username;
|
|
|
|
*count = size * sizeof(WCHAR);
|
2018-04-11 12:05:48 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
2021-03-21 22:50:45 +01:00
|
|
|
|
2021-03-21 22:50:47 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2021-03-21 22:50:45 +01:00
|
|
|
FIXME("Unimplemented class %d\n", class);
|
|
|
|
|
|
|
|
*buffer = NULL;
|
|
|
|
*count = 0;
|
2005-01-24 20:42:02 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************
|
2010-11-28 17:14:56 +01:00
|
|
|
* WTSQueryUserToken (WTSAPI32.@)
|
2005-01-24 20:42:02 +01:00
|
|
|
*/
|
2010-11-28 17:14:56 +01:00
|
|
|
BOOL WINAPI WTSQueryUserToken(ULONG session_id, PHANDLE token)
|
2005-01-24 20:42:02 +01:00
|
|
|
{
|
2019-01-23 03:22:56 +01:00
|
|
|
FIXME("%u %p semi-stub!\n", session_id, token);
|
|
|
|
|
|
|
|
if (!token)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return DuplicateHandle(GetCurrentProcess(), GetCurrentProcessToken(),
|
|
|
|
GetCurrentProcess(), token,
|
|
|
|
0, FALSE, DUPLICATE_SAME_ACCESS);
|
2005-01-24 20:42:02 +01:00
|
|
|
}
|
2007-09-17 20:11:23 +02:00
|
|
|
|
2010-11-28 17:14:56 +01:00
|
|
|
/************************************************************
|
|
|
|
* WTSQueryUserConfigA (WTSAPI32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI WTSQueryUserConfigA(LPSTR pServerName, LPSTR pUserName, WTS_CONFIG_CLASS WTSConfigClass, LPSTR *ppBuffer, DWORD *pBytesReturned)
|
|
|
|
{
|
|
|
|
FIXME("Stub (%s) (%s) 0x%08x %p %p\n", debugstr_a(pServerName), debugstr_a(pUserName), WTSConfigClass,
|
|
|
|
ppBuffer, pBytesReturned);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************
|
|
|
|
* WTSQueryUserConfigW (WTSAPI32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI WTSQueryUserConfigW(LPWSTR pServerName, LPWSTR pUserName, WTS_CONFIG_CLASS WTSConfigClass, LPWSTR *ppBuffer, DWORD *pBytesReturned)
|
|
|
|
{
|
|
|
|
FIXME("Stub (%s) (%s) 0x%08x %p %p\n", debugstr_w(pServerName), debugstr_w(pUserName), WTSConfigClass,
|
|
|
|
ppBuffer, pBytesReturned);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-17 20:11:23 +02:00
|
|
|
/************************************************************
|
|
|
|
* WTSRegisterSessionNotification (WTSAPI32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI WTSRegisterSessionNotification(HWND hWnd, DWORD dwFlags)
|
|
|
|
{
|
|
|
|
FIXME("Stub %p 0x%08x\n", hWnd, dwFlags);
|
2011-09-27 11:39:41 +02:00
|
|
|
return TRUE;
|
2007-09-17 20:11:23 +02:00
|
|
|
}
|
2007-09-17 20:27:09 +02:00
|
|
|
|
2010-11-28 17:14:56 +01:00
|
|
|
/************************************************************
|
2018-01-04 10:10:00 +01:00
|
|
|
* WTSRegisterSessionNotificationEx (WTSAPI32.@)
|
2010-11-28 17:14:56 +01:00
|
|
|
*/
|
|
|
|
BOOL WINAPI WTSRegisterSessionNotificationEx(HANDLE hServer, HWND hWnd, DWORD dwFlags)
|
|
|
|
{
|
|
|
|
FIXME("Stub %p %p 0x%08x\n", hServer, hWnd, dwFlags);
|
2019-12-07 09:06:14 +01:00
|
|
|
return TRUE;
|
2010-11-28 17:14:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/************************************************************
|
|
|
|
* WTSSendMessageA (WTSAPI32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI WTSSendMessageA(HANDLE hServer, DWORD SessionId, LPSTR pTitle, DWORD TitleLength, LPSTR pMessage,
|
|
|
|
DWORD MessageLength, DWORD Style, DWORD Timeout, DWORD *pResponse, BOOL bWait)
|
|
|
|
{
|
|
|
|
FIXME("Stub %p 0x%08x (%s) %d (%s) %d 0x%08x %d %p %d\n", hServer, SessionId, debugstr_a(pTitle), TitleLength, debugstr_a(pMessage), MessageLength, Style, Timeout, pResponse, bWait);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************
|
|
|
|
* WTSSendMessageW (WTSAPI32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI WTSSendMessageW(HANDLE hServer, DWORD SessionId, LPWSTR pTitle, DWORD TitleLength, LPWSTR pMessage,
|
|
|
|
DWORD MessageLength, DWORD Style, DWORD Timeout, DWORD *pResponse, BOOL bWait)
|
|
|
|
{
|
|
|
|
FIXME("Stub %p 0x%08x (%s) %d (%s) %d 0x%08x %d %p %d\n", hServer, SessionId, debugstr_w(pTitle), TitleLength, debugstr_w(pMessage), MessageLength, Style, Timeout, pResponse, bWait);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************
|
|
|
|
* WTSSetUserConfigA (WTSAPI32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI WTSSetUserConfigA(LPSTR pServerName, LPSTR pUserName, WTS_CONFIG_CLASS WTSConfigClass, LPSTR pBuffer, DWORD DataLength)
|
|
|
|
{
|
|
|
|
FIXME("Stub (%s) (%s) 0x%08x %p %d\n", debugstr_a(pServerName), debugstr_a(pUserName), WTSConfigClass,pBuffer, DataLength);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************
|
|
|
|
* WTSSetUserConfigW (WTSAPI32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI WTSSetUserConfigW(LPWSTR pServerName, LPWSTR pUserName, WTS_CONFIG_CLASS WTSConfigClass, LPWSTR pBuffer, DWORD DataLength)
|
|
|
|
{
|
|
|
|
FIXME("Stub (%s) (%s) 0x%08x %p %d\n", debugstr_w(pServerName), debugstr_w(pUserName), WTSConfigClass,pBuffer, DataLength);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************
|
|
|
|
* WTSShutdownSystem (WTSAPI32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI WTSShutdownSystem(HANDLE hServer, DWORD ShutdownFlag)
|
|
|
|
{
|
|
|
|
FIXME("Stub %p 0x%08x\n", hServer,ShutdownFlag);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************
|
|
|
|
* WTSStartRemoteControlSessionA (WTSAPI32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI WTSStartRemoteControlSessionA(LPSTR pTargetServerName, ULONG TargetLogonId, BYTE HotkeyVk, USHORT HotkeyModifiers)
|
|
|
|
{
|
|
|
|
FIXME("Stub (%s) %d %d %d\n", debugstr_a(pTargetServerName), TargetLogonId, HotkeyVk, HotkeyModifiers);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************
|
|
|
|
* WTSStartRemoteControlSessionW (WTSAPI32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI WTSStartRemoteControlSessionW(LPWSTR pTargetServerName, ULONG TargetLogonId, BYTE HotkeyVk, USHORT HotkeyModifiers)
|
|
|
|
{
|
|
|
|
FIXME("Stub (%s) %d %d %d\n", debugstr_w(pTargetServerName), TargetLogonId, HotkeyVk, HotkeyModifiers);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************
|
|
|
|
* WTSStopRemoteControlSession (WTSAPI32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI WTSStopRemoteControlSession(ULONG LogonId)
|
|
|
|
{
|
|
|
|
FIXME("Stub %d\n", LogonId);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************
|
|
|
|
* WTSTerminateProcess (WTSAPI32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI WTSTerminateProcess(HANDLE hServer, DWORD ProcessId, DWORD ExitCode)
|
|
|
|
{
|
|
|
|
FIXME("Stub %p %d %d\n", hServer, ProcessId, ExitCode);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2007-09-17 20:27:09 +02:00
|
|
|
/************************************************************
|
|
|
|
* WTSUnRegisterSessionNotification (WTSAPI32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI WTSUnRegisterSessionNotification(HWND hWnd)
|
|
|
|
{
|
|
|
|
FIXME("Stub %p\n", hWnd);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2010-05-04 09:07:54 +02:00
|
|
|
|
|
|
|
/************************************************************
|
2010-11-28 17:14:56 +01:00
|
|
|
* WTSUnRegisterSessionNotification (WTSAPI32.@)
|
2010-05-04 09:07:54 +02:00
|
|
|
*/
|
2010-11-28 17:14:56 +01:00
|
|
|
BOOL WINAPI WTSUnRegisterSessionNotificationEx(HANDLE hServer, HWND hWnd)
|
2010-05-04 09:07:54 +02:00
|
|
|
{
|
2010-11-28 17:14:56 +01:00
|
|
|
FIXME("Stub %p %p\n", hServer, hWnd);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/************************************************************
|
|
|
|
* WTSVirtualChannelClose (WTSAPI32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI WTSVirtualChannelClose(HANDLE hChannelHandle)
|
|
|
|
{
|
|
|
|
FIXME("Stub %p\n", hChannelHandle);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************
|
|
|
|
* WTSVirtualChannelOpen (WTSAPI32.@)
|
|
|
|
*/
|
|
|
|
HANDLE WINAPI WTSVirtualChannelOpen(HANDLE hServer, DWORD SessionId, LPSTR pVirtualName)
|
|
|
|
{
|
|
|
|
FIXME("Stub %p %d (%s)\n", hServer, SessionId, debugstr_a(pVirtualName));
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************
|
|
|
|
* WTSVirtualChannelOpen (WTSAPI32.@)
|
|
|
|
*/
|
|
|
|
HANDLE WINAPI WTSVirtualChannelOpenEx(DWORD SessionId, LPSTR pVirtualName, DWORD flags)
|
|
|
|
{
|
|
|
|
FIXME("Stub %d (%s) %d\n", SessionId, debugstr_a(pVirtualName), flags);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************
|
|
|
|
* WTSVirtualChannelPurgeInput (WTSAPI32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI WTSVirtualChannelPurgeInput(HANDLE hChannelHandle)
|
|
|
|
{
|
|
|
|
FIXME("Stub %p\n", hChannelHandle);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************
|
|
|
|
* WTSVirtualChannelPurgeOutput (WTSAPI32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI WTSVirtualChannelPurgeOutput(HANDLE hChannelHandle)
|
|
|
|
{
|
|
|
|
FIXME("Stub %p\n", hChannelHandle);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/************************************************************
|
|
|
|
* WTSVirtualChannelQuery (WTSAPI32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI WTSVirtualChannelQuery(HANDLE hChannelHandle, WTS_VIRTUAL_CLASS WtsVirtualClass, PVOID *ppBuffer, DWORD *pBytesReturned)
|
|
|
|
{
|
|
|
|
FIXME("Stub %p %d %p %p\n", hChannelHandle, WtsVirtualClass, ppBuffer, pBytesReturned);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************
|
|
|
|
* WTSVirtualChannelRead (WTSAPI32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI WTSVirtualChannelRead(HANDLE hChannelHandle, ULONG TimeOut, PCHAR Buffer, ULONG BufferSize, PULONG pBytesRead)
|
|
|
|
{
|
|
|
|
FIXME("Stub %p %d %p %d %p\n", hChannelHandle, TimeOut, Buffer, BufferSize, pBytesRead);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************
|
|
|
|
* WTSVirtualChannelWrite (WTSAPI32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI WTSVirtualChannelWrite(HANDLE hChannelHandle, PCHAR Buffer, ULONG Length, PULONG pBytesWritten)
|
|
|
|
{
|
|
|
|
FIXME("Stub %p %p %d %p\n", hChannelHandle, Buffer, Length, pBytesWritten);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************
|
|
|
|
* WTSWaitSystemEvent (WTSAPI32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI WTSWaitSystemEvent(HANDLE hServer, DWORD Mask, DWORD* Flags)
|
|
|
|
{
|
|
|
|
/* FIXME: Forward request to winsta.dll::WinStationWaitSystemEvent */
|
|
|
|
FIXME("Stub %p 0x%08x %p\n", hServer, Mask, Flags);
|
2010-05-04 09:07:54 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|