2013-08-20 03:18:31 +04:00
|
|
|
/**
|
|
|
|
* WinPR: Windows Portable Runtime
|
|
|
|
* Windows Terminal Services API
|
|
|
|
*
|
|
|
|
* Copyright 2013 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
2015-02-09 17:30:18 +03:00
|
|
|
* Copyright 2015 DI (FH) Martin Haimberger <martin.haimberger@thincast.com>
|
2015-02-16 14:16:54 +03:00
|
|
|
* Copyright 2015 Copyright 2015 Thincast Technologies GmbH
|
2013-08-20 03:18:31 +04:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <winpr/crt.h>
|
2014-03-25 08:32:05 +04:00
|
|
|
#include <winpr/ini.h>
|
|
|
|
#include <winpr/path.h>
|
2013-09-17 01:10:27 +04:00
|
|
|
#include <winpr/synch.h>
|
2014-03-01 09:32:23 +04:00
|
|
|
#include <winpr/library.h>
|
2014-03-17 20:16:07 +04:00
|
|
|
#include <winpr/environment.h>
|
2013-08-20 03:18:31 +04:00
|
|
|
|
|
|
|
#include <winpr/wtsapi.h>
|
|
|
|
|
2014-10-13 18:55:11 +04:00
|
|
|
#ifdef _WIN32
|
|
|
|
#include "wtsapi_win32.h"
|
|
|
|
#endif
|
|
|
|
|
2014-08-18 19:22:22 +04:00
|
|
|
#include "../log.h"
|
2014-08-18 20:57:08 +04:00
|
|
|
#define TAG WINPR_TAG("wtsapi")
|
2014-08-18 19:22:22 +04:00
|
|
|
|
2013-08-20 23:22:31 +04:00
|
|
|
/**
|
|
|
|
* Remote Desktop Services API Functions:
|
|
|
|
* http://msdn.microsoft.com/en-us/library/windows/desktop/aa383464/
|
|
|
|
*/
|
|
|
|
|
2014-03-01 09:32:23 +04:00
|
|
|
static HMODULE g_WtsApiModule = NULL;
|
|
|
|
|
2014-02-17 05:41:19 +04:00
|
|
|
static PWtsApiFunctionTable g_WtsApi = NULL;
|
2014-02-17 04:38:12 +04:00
|
|
|
|
2020-03-10 15:36:41 +03:00
|
|
|
#if defined(_WIN32)
|
2014-07-26 23:23:39 +04:00
|
|
|
static HMODULE g_WtsApi32Module = NULL;
|
2018-11-22 19:28:31 +03:00
|
|
|
static WtsApiFunctionTable WtsApi32_WtsApiFunctionTable = { 0 };
|
2014-07-26 23:23:39 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
#define WTSAPI32_LOAD_PROC(_name, _type) \
|
|
|
|
WtsApi32_WtsApiFunctionTable.p##_name = (##_type)GetProcAddress(g_WtsApi32Module, "WT" \
|
|
|
|
"S" #_name);
|
2014-07-26 23:23:39 +04:00
|
|
|
|
2019-11-20 13:30:14 +03:00
|
|
|
static BOOL WtsApi32_InitializeWtsApi(void)
|
2014-07-26 23:23:39 +04:00
|
|
|
{
|
|
|
|
g_WtsApi32Module = LoadLibraryA("wtsapi32.dll");
|
|
|
|
|
|
|
|
if (!g_WtsApi32Module)
|
2016-05-30 18:54:59 +03:00
|
|
|
return FALSE;
|
2014-07-26 23:23:39 +04:00
|
|
|
|
|
|
|
WTSAPI32_LOAD_PROC(StopRemoteControlSession, WTS_STOP_REMOTE_CONTROL_SESSION_FN);
|
|
|
|
WTSAPI32_LOAD_PROC(StartRemoteControlSessionW, WTS_START_REMOTE_CONTROL_SESSION_FN_W);
|
|
|
|
WTSAPI32_LOAD_PROC(StartRemoteControlSessionA, WTS_START_REMOTE_CONTROL_SESSION_FN_A);
|
|
|
|
WTSAPI32_LOAD_PROC(ConnectSessionW, WTS_CONNECT_SESSION_FN_W);
|
|
|
|
WTSAPI32_LOAD_PROC(ConnectSessionA, WTS_CONNECT_SESSION_FN_A);
|
|
|
|
WTSAPI32_LOAD_PROC(EnumerateServersW, WTS_ENUMERATE_SERVERS_FN_W);
|
|
|
|
WTSAPI32_LOAD_PROC(EnumerateServersA, WTS_ENUMERATE_SERVERS_FN_A);
|
|
|
|
WTSAPI32_LOAD_PROC(OpenServerW, WTS_OPEN_SERVER_FN_W);
|
|
|
|
WTSAPI32_LOAD_PROC(OpenServerA, WTS_OPEN_SERVER_FN_A);
|
|
|
|
WTSAPI32_LOAD_PROC(OpenServerExW, WTS_OPEN_SERVER_EX_FN_W);
|
|
|
|
WTSAPI32_LOAD_PROC(OpenServerExA, WTS_OPEN_SERVER_EX_FN_A);
|
|
|
|
WTSAPI32_LOAD_PROC(CloseServer, WTS_CLOSE_SERVER_FN);
|
|
|
|
WTSAPI32_LOAD_PROC(EnumerateSessionsW, WTS_ENUMERATE_SESSIONS_FN_W);
|
|
|
|
WTSAPI32_LOAD_PROC(EnumerateSessionsA, WTS_ENUMERATE_SESSIONS_FN_A);
|
|
|
|
WTSAPI32_LOAD_PROC(EnumerateSessionsExW, WTS_ENUMERATE_SESSIONS_EX_FN_W);
|
|
|
|
WTSAPI32_LOAD_PROC(EnumerateSessionsExA, WTS_ENUMERATE_SESSIONS_EX_FN_A);
|
|
|
|
WTSAPI32_LOAD_PROC(EnumerateProcessesW, WTS_ENUMERATE_PROCESSES_FN_W);
|
|
|
|
WTSAPI32_LOAD_PROC(EnumerateProcessesA, WTS_ENUMERATE_PROCESSES_FN_A);
|
|
|
|
WTSAPI32_LOAD_PROC(TerminateProcess, WTS_TERMINATE_PROCESS_FN);
|
|
|
|
WTSAPI32_LOAD_PROC(QuerySessionInformationW, WTS_QUERY_SESSION_INFORMATION_FN_W);
|
|
|
|
WTSAPI32_LOAD_PROC(QuerySessionInformationA, WTS_QUERY_SESSION_INFORMATION_FN_A);
|
|
|
|
WTSAPI32_LOAD_PROC(QueryUserConfigW, WTS_QUERY_USER_CONFIG_FN_W);
|
|
|
|
WTSAPI32_LOAD_PROC(QueryUserConfigA, WTS_QUERY_USER_CONFIG_FN_A);
|
|
|
|
WTSAPI32_LOAD_PROC(SetUserConfigW, WTS_SET_USER_CONFIG_FN_W);
|
|
|
|
WTSAPI32_LOAD_PROC(SetUserConfigA, WTS_SET_USER_CONFIG_FN_A);
|
|
|
|
WTSAPI32_LOAD_PROC(SendMessageW, WTS_SEND_MESSAGE_FN_W);
|
|
|
|
WTSAPI32_LOAD_PROC(SendMessageA, WTS_SEND_MESSAGE_FN_A);
|
|
|
|
WTSAPI32_LOAD_PROC(DisconnectSession, WTS_DISCONNECT_SESSION_FN);
|
|
|
|
WTSAPI32_LOAD_PROC(LogoffSession, WTS_LOGOFF_SESSION_FN);
|
|
|
|
WTSAPI32_LOAD_PROC(ShutdownSystem, WTS_SHUTDOWN_SYSTEM_FN);
|
|
|
|
WTSAPI32_LOAD_PROC(WaitSystemEvent, WTS_WAIT_SYSTEM_EVENT_FN);
|
|
|
|
WTSAPI32_LOAD_PROC(VirtualChannelOpen, WTS_VIRTUAL_CHANNEL_OPEN_FN);
|
|
|
|
WTSAPI32_LOAD_PROC(VirtualChannelOpenEx, WTS_VIRTUAL_CHANNEL_OPEN_EX_FN);
|
|
|
|
WTSAPI32_LOAD_PROC(VirtualChannelClose, WTS_VIRTUAL_CHANNEL_CLOSE_FN);
|
|
|
|
WTSAPI32_LOAD_PROC(VirtualChannelRead, WTS_VIRTUAL_CHANNEL_READ_FN);
|
|
|
|
WTSAPI32_LOAD_PROC(VirtualChannelWrite, WTS_VIRTUAL_CHANNEL_WRITE_FN);
|
|
|
|
WTSAPI32_LOAD_PROC(VirtualChannelPurgeInput, WTS_VIRTUAL_CHANNEL_PURGE_INPUT_FN);
|
|
|
|
WTSAPI32_LOAD_PROC(VirtualChannelPurgeOutput, WTS_VIRTUAL_CHANNEL_PURGE_OUTPUT_FN);
|
|
|
|
WTSAPI32_LOAD_PROC(VirtualChannelQuery, WTS_VIRTUAL_CHANNEL_QUERY_FN);
|
|
|
|
WTSAPI32_LOAD_PROC(FreeMemory, WTS_FREE_MEMORY_FN);
|
|
|
|
WTSAPI32_LOAD_PROC(RegisterSessionNotification, WTS_REGISTER_SESSION_NOTIFICATION_FN);
|
|
|
|
WTSAPI32_LOAD_PROC(UnRegisterSessionNotification, WTS_UNREGISTER_SESSION_NOTIFICATION_FN);
|
|
|
|
WTSAPI32_LOAD_PROC(RegisterSessionNotificationEx, WTS_REGISTER_SESSION_NOTIFICATION_EX_FN);
|
|
|
|
WTSAPI32_LOAD_PROC(UnRegisterSessionNotificationEx, WTS_UNREGISTER_SESSION_NOTIFICATION_EX_FN);
|
|
|
|
WTSAPI32_LOAD_PROC(QueryUserToken, WTS_QUERY_USER_TOKEN_FN);
|
|
|
|
WTSAPI32_LOAD_PROC(FreeMemoryExW, WTS_FREE_MEMORY_EX_FN_W);
|
|
|
|
WTSAPI32_LOAD_PROC(FreeMemoryExA, WTS_FREE_MEMORY_EX_FN_A);
|
|
|
|
WTSAPI32_LOAD_PROC(EnumerateProcessesExW, WTS_ENUMERATE_PROCESSES_EX_FN_W);
|
|
|
|
WTSAPI32_LOAD_PROC(EnumerateProcessesExA, WTS_ENUMERATE_PROCESSES_EX_FN_A);
|
|
|
|
WTSAPI32_LOAD_PROC(EnumerateListenersW, WTS_ENUMERATE_LISTENERS_FN_W);
|
|
|
|
WTSAPI32_LOAD_PROC(EnumerateListenersA, WTS_ENUMERATE_LISTENERS_FN_A);
|
|
|
|
WTSAPI32_LOAD_PROC(QueryListenerConfigW, WTS_QUERY_LISTENER_CONFIG_FN_W);
|
|
|
|
WTSAPI32_LOAD_PROC(QueryListenerConfigA, WTS_QUERY_LISTENER_CONFIG_FN_A);
|
|
|
|
WTSAPI32_LOAD_PROC(CreateListenerW, WTS_CREATE_LISTENER_FN_W);
|
|
|
|
WTSAPI32_LOAD_PROC(CreateListenerA, WTS_CREATE_LISTENER_FN_A);
|
|
|
|
WTSAPI32_LOAD_PROC(SetListenerSecurityW, WTS_SET_LISTENER_SECURITY_FN_W);
|
|
|
|
WTSAPI32_LOAD_PROC(SetListenerSecurityA, WTS_SET_LISTENER_SECURITY_FN_A);
|
|
|
|
WTSAPI32_LOAD_PROC(GetListenerSecurityW, WTS_GET_LISTENER_SECURITY_FN_W);
|
|
|
|
WTSAPI32_LOAD_PROC(GetListenerSecurityA, WTS_GET_LISTENER_SECURITY_FN_A);
|
|
|
|
WTSAPI32_LOAD_PROC(EnableChildSessions, WTS_ENABLE_CHILD_SESSIONS_FN);
|
|
|
|
WTSAPI32_LOAD_PROC(IsChildSessionsEnabled, WTS_IS_CHILD_SESSIONS_ENABLED_FN);
|
|
|
|
WTSAPI32_LOAD_PROC(GetChildSessionId, WTS_GET_CHILD_SESSION_ID_FN);
|
|
|
|
WTSAPI32_LOAD_PROC(GetActiveConsoleSessionId, WTS_GET_ACTIVE_CONSOLE_SESSION_ID_FN);
|
2014-10-17 02:07:44 +04:00
|
|
|
|
|
|
|
Win32_InitializeWinSta(&WtsApi32_WtsApiFunctionTable);
|
2014-10-13 18:55:11 +04:00
|
|
|
|
2014-10-17 02:07:44 +04:00
|
|
|
g_WtsApi = &WtsApi32_WtsApiFunctionTable;
|
|
|
|
|
2016-05-30 18:54:59 +03:00
|
|
|
return TRUE;
|
2014-07-26 23:23:39 +04:00
|
|
|
}
|
2020-03-10 15:36:41 +03:00
|
|
|
#endif
|
2014-07-26 23:23:39 +04:00
|
|
|
|
|
|
|
/* WtsApi Functions */
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
static BOOL CALLBACK InitializeWtsApiStubs(PINIT_ONCE once, PVOID param, PVOID* context);
|
2016-05-30 18:54:59 +03:00
|
|
|
static INIT_ONCE wtsapiInitOnce = INIT_ONCE_STATIC_INIT;
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
#define WTSAPI_STUB_CALL_VOID(_name, ...) \
|
2016-05-30 18:54:59 +03:00
|
|
|
InitOnceExecuteOnce(&wtsapiInitOnce, InitializeWtsApiStubs, NULL, NULL); \
|
2019-11-06 17:24:51 +03:00
|
|
|
if (!g_WtsApi || !g_WtsApi->p##_name) \
|
|
|
|
return; \
|
|
|
|
g_WtsApi->p##_name(__VA_ARGS__)
|
2016-05-30 18:54:59 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
#define WTSAPI_STUB_CALL_BOOL(_name, ...) \
|
2016-05-30 18:54:59 +03:00
|
|
|
InitOnceExecuteOnce(&wtsapiInitOnce, InitializeWtsApiStubs, NULL, NULL); \
|
2019-11-06 17:24:51 +03:00
|
|
|
if (!g_WtsApi || !g_WtsApi->p##_name) \
|
|
|
|
return FALSE; \
|
|
|
|
return g_WtsApi->p##_name(__VA_ARGS__)
|
2016-05-30 18:54:59 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
#define WTSAPI_STUB_CALL_HANDLE(_name, ...) \
|
2016-05-30 18:54:59 +03:00
|
|
|
InitOnceExecuteOnce(&wtsapiInitOnce, InitializeWtsApiStubs, NULL, NULL); \
|
2019-11-06 17:24:51 +03:00
|
|
|
if (!g_WtsApi || !g_WtsApi->p##_name) \
|
|
|
|
return NULL; \
|
|
|
|
return g_WtsApi->p##_name(__VA_ARGS__)
|
2016-05-30 18:54:59 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
BOOL WINAPI WTSStartRemoteControlSessionW(LPWSTR pTargetServerName, ULONG TargetLogonId,
|
|
|
|
BYTE HotkeyVk, USHORT HotkeyModifiers)
|
2013-08-20 04:38:43 +04:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
WTSAPI_STUB_CALL_BOOL(StartRemoteControlSessionW, pTargetServerName, TargetLogonId, HotkeyVk,
|
|
|
|
HotkeyModifiers);
|
2013-08-20 04:38:43 +04:00
|
|
|
}
|
2013-08-20 03:18:31 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
BOOL WINAPI WTSStartRemoteControlSessionA(LPSTR pTargetServerName, ULONG TargetLogonId,
|
|
|
|
BYTE HotkeyVk, USHORT HotkeyModifiers)
|
2013-08-20 04:38:43 +04:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
WTSAPI_STUB_CALL_BOOL(StartRemoteControlSessionA, pTargetServerName, TargetLogonId, HotkeyVk,
|
|
|
|
HotkeyModifiers);
|
2013-08-20 04:38:43 +04:00
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
BOOL WINAPI WTSStartRemoteControlSessionExW(LPWSTR pTargetServerName, ULONG TargetLogonId,
|
|
|
|
BYTE HotkeyVk, USHORT HotkeyModifiers, DWORD flags)
|
2015-02-16 14:16:54 +03:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
WTSAPI_STUB_CALL_BOOL(StartRemoteControlSessionExW, pTargetServerName, TargetLogonId, HotkeyVk,
|
|
|
|
HotkeyModifiers, flags);
|
2015-02-16 14:16:54 +03:00
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
BOOL WINAPI WTSStartRemoteControlSessionExA(LPSTR pTargetServerName, ULONG TargetLogonId,
|
|
|
|
BYTE HotkeyVk, USHORT HotkeyModifiers, DWORD flags)
|
2015-02-16 14:16:54 +03:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
WTSAPI_STUB_CALL_BOOL(StartRemoteControlSessionExA, pTargetServerName, TargetLogonId, HotkeyVk,
|
|
|
|
HotkeyModifiers, flags);
|
2015-02-16 14:16:54 +03:00
|
|
|
}
|
|
|
|
|
2014-02-28 23:49:57 +04:00
|
|
|
BOOL WINAPI WTSStopRemoteControlSession(ULONG LogonId)
|
2013-08-20 04:38:43 +04:00
|
|
|
{
|
2014-03-01 09:32:23 +04:00
|
|
|
WTSAPI_STUB_CALL_BOOL(StopRemoteControlSession, LogonId);
|
2013-08-20 04:38:43 +04:00
|
|
|
}
|
|
|
|
|
2014-02-28 23:49:57 +04:00
|
|
|
BOOL WINAPI WTSConnectSessionW(ULONG LogonId, ULONG TargetLogonId, PWSTR pPassword, BOOL bWait)
|
2013-08-20 04:38:43 +04:00
|
|
|
{
|
2014-03-01 09:32:23 +04:00
|
|
|
WTSAPI_STUB_CALL_BOOL(ConnectSessionW, LogonId, TargetLogonId, pPassword, bWait);
|
2013-08-20 04:38:43 +04:00
|
|
|
}
|
|
|
|
|
2014-02-28 23:49:57 +04:00
|
|
|
BOOL WINAPI WTSConnectSessionA(ULONG LogonId, ULONG TargetLogonId, PSTR pPassword, BOOL bWait)
|
2013-08-20 04:38:43 +04:00
|
|
|
{
|
2014-03-01 09:32:23 +04:00
|
|
|
WTSAPI_STUB_CALL_BOOL(ConnectSessionA, LogonId, TargetLogonId, pPassword, bWait);
|
2013-08-20 04:38:43 +04:00
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
BOOL WINAPI WTSEnumerateServersW(LPWSTR pDomainName, DWORD Reserved, DWORD Version,
|
|
|
|
PWTS_SERVER_INFOW* ppServerInfo, DWORD* pCount)
|
2013-08-20 04:38:43 +04:00
|
|
|
{
|
2014-03-01 09:32:23 +04:00
|
|
|
WTSAPI_STUB_CALL_BOOL(EnumerateServersW, pDomainName, Reserved, Version, ppServerInfo, pCount);
|
2013-08-20 04:38:43 +04:00
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
BOOL WINAPI WTSEnumerateServersA(LPSTR pDomainName, DWORD Reserved, DWORD Version,
|
|
|
|
PWTS_SERVER_INFOA* ppServerInfo, DWORD* pCount)
|
2013-08-20 04:38:43 +04:00
|
|
|
{
|
2014-03-01 09:32:23 +04:00
|
|
|
WTSAPI_STUB_CALL_BOOL(EnumerateServersA, pDomainName, Reserved, Version, ppServerInfo, pCount);
|
2013-08-20 04:38:43 +04:00
|
|
|
}
|
|
|
|
|
2014-02-28 23:49:57 +04:00
|
|
|
HANDLE WINAPI WTSOpenServerW(LPWSTR pServerName)
|
2013-08-20 04:38:43 +04:00
|
|
|
{
|
2014-03-01 09:32:23 +04:00
|
|
|
WTSAPI_STUB_CALL_HANDLE(OpenServerW, pServerName);
|
2013-08-20 04:38:43 +04:00
|
|
|
}
|
|
|
|
|
2014-02-28 23:49:57 +04:00
|
|
|
HANDLE WINAPI WTSOpenServerA(LPSTR pServerName)
|
2013-08-20 04:38:43 +04:00
|
|
|
{
|
2014-03-01 09:32:23 +04:00
|
|
|
WTSAPI_STUB_CALL_HANDLE(OpenServerA, pServerName);
|
2013-08-20 04:38:43 +04:00
|
|
|
}
|
|
|
|
|
2014-02-28 23:49:57 +04:00
|
|
|
HANDLE WINAPI WTSOpenServerExW(LPWSTR pServerName)
|
2013-08-20 04:38:43 +04:00
|
|
|
{
|
2014-03-01 09:32:23 +04:00
|
|
|
WTSAPI_STUB_CALL_HANDLE(OpenServerExW, pServerName);
|
2013-08-20 04:38:43 +04:00
|
|
|
}
|
|
|
|
|
2014-02-28 23:49:57 +04:00
|
|
|
HANDLE WINAPI WTSOpenServerExA(LPSTR pServerName)
|
2013-08-20 04:38:43 +04:00
|
|
|
{
|
2014-03-01 09:32:23 +04:00
|
|
|
WTSAPI_STUB_CALL_HANDLE(OpenServerExA, pServerName);
|
2013-08-20 04:38:43 +04:00
|
|
|
}
|
|
|
|
|
2014-02-28 23:49:57 +04:00
|
|
|
VOID WINAPI WTSCloseServer(HANDLE hServer)
|
2013-08-20 04:38:43 +04:00
|
|
|
{
|
2014-03-01 09:32:23 +04:00
|
|
|
WTSAPI_STUB_CALL_VOID(CloseServer, hServer);
|
2013-08-20 04:38:43 +04:00
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
BOOL WINAPI WTSEnumerateSessionsW(HANDLE hServer, DWORD Reserved, DWORD Version,
|
|
|
|
PWTS_SESSION_INFOW* ppSessionInfo, DWORD* pCount)
|
2013-08-20 04:38:43 +04:00
|
|
|
{
|
2014-03-01 09:32:23 +04:00
|
|
|
WTSAPI_STUB_CALL_BOOL(EnumerateSessionsW, hServer, Reserved, Version, ppSessionInfo, pCount);
|
2013-08-20 04:38:43 +04:00
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
BOOL WINAPI WTSEnumerateSessionsA(HANDLE hServer, DWORD Reserved, DWORD Version,
|
|
|
|
PWTS_SESSION_INFOA* ppSessionInfo, DWORD* pCount)
|
2013-08-20 04:38:43 +04:00
|
|
|
{
|
2014-03-01 09:32:23 +04:00
|
|
|
WTSAPI_STUB_CALL_BOOL(EnumerateSessionsA, hServer, Reserved, Version, ppSessionInfo, pCount);
|
2013-08-20 04:38:43 +04:00
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
BOOL WINAPI WTSEnumerateSessionsExW(HANDLE hServer, DWORD* pLevel, DWORD Filter,
|
|
|
|
PWTS_SESSION_INFO_1W* ppSessionInfo, DWORD* pCount)
|
2013-08-20 04:38:43 +04:00
|
|
|
{
|
2014-03-01 09:32:23 +04:00
|
|
|
WTSAPI_STUB_CALL_BOOL(EnumerateSessionsExW, hServer, pLevel, Filter, ppSessionInfo, pCount);
|
2013-08-20 04:38:43 +04:00
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
BOOL WINAPI WTSEnumerateSessionsExA(HANDLE hServer, DWORD* pLevel, DWORD Filter,
|
|
|
|
PWTS_SESSION_INFO_1A* ppSessionInfo, DWORD* pCount)
|
2013-08-20 04:38:43 +04:00
|
|
|
{
|
2014-03-01 09:32:23 +04:00
|
|
|
WTSAPI_STUB_CALL_BOOL(EnumerateSessionsExA, hServer, pLevel, Filter, ppSessionInfo, pCount);
|
2013-08-20 04:38:43 +04:00
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
BOOL WINAPI WTSEnumerateProcessesW(HANDLE hServer, DWORD Reserved, DWORD Version,
|
|
|
|
PWTS_PROCESS_INFOW* ppProcessInfo, DWORD* pCount)
|
2013-08-20 04:38:43 +04:00
|
|
|
{
|
2014-03-01 09:32:23 +04:00
|
|
|
WTSAPI_STUB_CALL_BOOL(EnumerateProcessesW, hServer, Reserved, Version, ppProcessInfo, pCount);
|
2013-08-20 04:38:43 +04:00
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
BOOL WINAPI WTSEnumerateProcessesA(HANDLE hServer, DWORD Reserved, DWORD Version,
|
|
|
|
PWTS_PROCESS_INFOA* ppProcessInfo, DWORD* pCount)
|
2013-08-20 04:38:43 +04:00
|
|
|
{
|
2014-03-01 09:32:23 +04:00
|
|
|
WTSAPI_STUB_CALL_BOOL(EnumerateProcessesA, hServer, Reserved, Version, ppProcessInfo, pCount);
|
2013-08-20 04:38:43 +04:00
|
|
|
}
|
|
|
|
|
2014-02-28 23:49:57 +04:00
|
|
|
BOOL WINAPI WTSTerminateProcess(HANDLE hServer, DWORD ProcessId, DWORD ExitCode)
|
2013-08-20 04:38:43 +04:00
|
|
|
{
|
2014-03-01 09:32:23 +04:00
|
|
|
WTSAPI_STUB_CALL_BOOL(TerminateProcess, hServer, ProcessId, ExitCode);
|
2013-08-20 04:38:43 +04:00
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
BOOL WINAPI WTSQuerySessionInformationW(HANDLE hServer, DWORD SessionId,
|
|
|
|
WTS_INFO_CLASS WTSInfoClass, LPWSTR* ppBuffer,
|
|
|
|
DWORD* pBytesReturned)
|
2013-08-20 04:38:43 +04:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
WTSAPI_STUB_CALL_BOOL(QuerySessionInformationW, hServer, SessionId, WTSInfoClass, ppBuffer,
|
|
|
|
pBytesReturned);
|
2013-08-20 04:38:43 +04:00
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
BOOL WINAPI WTSQuerySessionInformationA(HANDLE hServer, DWORD SessionId,
|
|
|
|
WTS_INFO_CLASS WTSInfoClass, LPSTR* ppBuffer,
|
|
|
|
DWORD* pBytesReturned)
|
2013-08-20 04:38:43 +04:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
WTSAPI_STUB_CALL_BOOL(QuerySessionInformationA, hServer, SessionId, WTSInfoClass, ppBuffer,
|
|
|
|
pBytesReturned);
|
2013-08-20 04:38:43 +04:00
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
BOOL WINAPI WTSQueryUserConfigW(LPWSTR pServerName, LPWSTR pUserName,
|
|
|
|
WTS_CONFIG_CLASS WTSConfigClass, LPWSTR* ppBuffer,
|
|
|
|
DWORD* pBytesReturned)
|
2013-08-20 04:38:43 +04:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
WTSAPI_STUB_CALL_BOOL(QueryUserConfigW, pServerName, pUserName, WTSConfigClass, ppBuffer,
|
|
|
|
pBytesReturned);
|
2013-08-20 04:38:43 +04:00
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
BOOL WINAPI WTSQueryUserConfigA(LPSTR pServerName, LPSTR pUserName, WTS_CONFIG_CLASS WTSConfigClass,
|
|
|
|
LPSTR* ppBuffer, DWORD* pBytesReturned)
|
2013-08-20 04:38:43 +04:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
WTSAPI_STUB_CALL_BOOL(QueryUserConfigA, pServerName, pUserName, WTSConfigClass, ppBuffer,
|
|
|
|
pBytesReturned);
|
2013-08-20 04:38:43 +04:00
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
BOOL WINAPI WTSSetUserConfigW(LPWSTR pServerName, LPWSTR pUserName, WTS_CONFIG_CLASS WTSConfigClass,
|
|
|
|
LPWSTR pBuffer, DWORD DataLength)
|
2013-08-20 04:38:43 +04:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
WTSAPI_STUB_CALL_BOOL(SetUserConfigW, pServerName, pUserName, WTSConfigClass, pBuffer,
|
|
|
|
DataLength);
|
2013-08-20 04:38:43 +04:00
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
BOOL WINAPI WTSSetUserConfigA(LPSTR pServerName, LPSTR pUserName, WTS_CONFIG_CLASS WTSConfigClass,
|
|
|
|
LPSTR pBuffer, DWORD DataLength)
|
2013-08-20 04:38:43 +04:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
WTSAPI_STUB_CALL_BOOL(SetUserConfigA, pServerName, pUserName, WTSConfigClass, pBuffer,
|
|
|
|
DataLength);
|
2013-08-20 04:38:43 +04:00
|
|
|
}
|
|
|
|
|
2014-02-28 23:49:57 +04:00
|
|
|
BOOL WINAPI WTSSendMessageW(HANDLE hServer, DWORD SessionId, LPWSTR pTitle, DWORD TitleLength,
|
2019-11-06 17:24:51 +03:00
|
|
|
LPWSTR pMessage, DWORD MessageLength, DWORD Style, DWORD Timeout,
|
|
|
|
DWORD* pResponse, BOOL bWait)
|
2013-08-20 04:38:43 +04:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
WTSAPI_STUB_CALL_BOOL(SendMessageW, hServer, SessionId, pTitle, TitleLength, pMessage,
|
|
|
|
MessageLength, Style, Timeout, pResponse, bWait);
|
2013-08-20 04:38:43 +04:00
|
|
|
}
|
|
|
|
|
2014-02-28 23:49:57 +04:00
|
|
|
BOOL WINAPI WTSSendMessageA(HANDLE hServer, DWORD SessionId, LPSTR pTitle, DWORD TitleLength,
|
2019-11-06 17:24:51 +03:00
|
|
|
LPSTR pMessage, DWORD MessageLength, DWORD Style, DWORD Timeout,
|
|
|
|
DWORD* pResponse, BOOL bWait)
|
2013-08-20 04:38:43 +04:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
WTSAPI_STUB_CALL_BOOL(SendMessageA, hServer, SessionId, pTitle, TitleLength, pMessage,
|
|
|
|
MessageLength, Style, Timeout, pResponse, bWait);
|
2013-08-20 04:38:43 +04:00
|
|
|
}
|
|
|
|
|
2014-02-28 23:49:57 +04:00
|
|
|
BOOL WINAPI WTSDisconnectSession(HANDLE hServer, DWORD SessionId, BOOL bWait)
|
2013-08-20 04:38:43 +04:00
|
|
|
{
|
2014-03-01 09:32:23 +04:00
|
|
|
WTSAPI_STUB_CALL_BOOL(DisconnectSession, hServer, SessionId, bWait);
|
2013-08-20 04:38:43 +04:00
|
|
|
}
|
|
|
|
|
2014-02-28 23:49:57 +04:00
|
|
|
BOOL WINAPI WTSLogoffSession(HANDLE hServer, DWORD SessionId, BOOL bWait)
|
2013-08-20 04:38:43 +04:00
|
|
|
{
|
2014-03-01 09:32:23 +04:00
|
|
|
WTSAPI_STUB_CALL_BOOL(LogoffSession, hServer, SessionId, bWait);
|
2013-08-20 04:38:43 +04:00
|
|
|
}
|
|
|
|
|
2014-02-28 23:49:57 +04:00
|
|
|
BOOL WINAPI WTSShutdownSystem(HANDLE hServer, DWORD ShutdownFlag)
|
2013-08-20 04:38:43 +04:00
|
|
|
{
|
2014-03-01 09:32:23 +04:00
|
|
|
WTSAPI_STUB_CALL_BOOL(ShutdownSystem, hServer, ShutdownFlag);
|
2013-08-20 04:38:43 +04:00
|
|
|
}
|
|
|
|
|
2014-08-18 21:34:47 +04:00
|
|
|
BOOL WINAPI WTSWaitSystemEvent(HANDLE hServer, DWORD EventMask, DWORD* pEventFlags)
|
2013-08-20 04:38:43 +04:00
|
|
|
{
|
2014-03-01 09:32:23 +04:00
|
|
|
WTSAPI_STUB_CALL_BOOL(WaitSystemEvent, hServer, EventMask, pEventFlags);
|
2013-08-20 04:38:43 +04:00
|
|
|
}
|
|
|
|
|
2014-02-28 23:49:57 +04:00
|
|
|
HANDLE WINAPI WTSVirtualChannelOpen(HANDLE hServer, DWORD SessionId, LPSTR pVirtualName)
|
2013-08-20 04:38:43 +04:00
|
|
|
{
|
2014-03-01 09:32:23 +04:00
|
|
|
WTSAPI_STUB_CALL_HANDLE(VirtualChannelOpen, hServer, SessionId, pVirtualName);
|
2013-08-20 04:38:43 +04:00
|
|
|
}
|
|
|
|
|
2014-02-28 23:49:57 +04:00
|
|
|
HANDLE WINAPI WTSVirtualChannelOpenEx(DWORD SessionId, LPSTR pVirtualName, DWORD flags)
|
2013-08-20 04:38:43 +04:00
|
|
|
{
|
2014-03-01 09:32:23 +04:00
|
|
|
WTSAPI_STUB_CALL_HANDLE(VirtualChannelOpenEx, SessionId, pVirtualName, flags);
|
2013-08-20 04:38:43 +04:00
|
|
|
}
|
|
|
|
|
2014-02-28 23:49:57 +04:00
|
|
|
BOOL WINAPI WTSVirtualChannelClose(HANDLE hChannelHandle)
|
2013-08-20 04:38:43 +04:00
|
|
|
{
|
2014-03-01 09:32:23 +04:00
|
|
|
WTSAPI_STUB_CALL_BOOL(VirtualChannelClose, hChannelHandle);
|
2013-08-20 04:38:43 +04:00
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
BOOL WINAPI WTSVirtualChannelRead(HANDLE hChannelHandle, ULONG TimeOut, PCHAR Buffer,
|
|
|
|
ULONG BufferSize, PULONG pBytesRead)
|
2013-08-20 04:38:43 +04:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
WTSAPI_STUB_CALL_BOOL(VirtualChannelRead, hChannelHandle, TimeOut, Buffer, BufferSize,
|
|
|
|
pBytesRead);
|
2013-08-20 04:38:43 +04:00
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
BOOL WINAPI WTSVirtualChannelWrite(HANDLE hChannelHandle, PCHAR Buffer, ULONG Length,
|
|
|
|
PULONG pBytesWritten)
|
2013-08-20 04:38:43 +04:00
|
|
|
{
|
2014-03-01 09:32:23 +04:00
|
|
|
WTSAPI_STUB_CALL_BOOL(VirtualChannelWrite, hChannelHandle, Buffer, Length, pBytesWritten);
|
2013-08-23 03:20:59 +04:00
|
|
|
}
|
|
|
|
|
2014-02-28 23:49:57 +04:00
|
|
|
BOOL WINAPI WTSVirtualChannelPurgeInput(HANDLE hChannelHandle)
|
2013-08-23 03:20:59 +04:00
|
|
|
{
|
2014-03-01 09:32:23 +04:00
|
|
|
WTSAPI_STUB_CALL_BOOL(VirtualChannelPurgeInput, hChannelHandle);
|
2013-08-20 04:38:43 +04:00
|
|
|
}
|
|
|
|
|
2014-02-28 23:49:57 +04:00
|
|
|
BOOL WINAPI WTSVirtualChannelPurgeOutput(HANDLE hChannelHandle)
|
2013-08-20 04:38:43 +04:00
|
|
|
{
|
2014-03-01 09:32:23 +04:00
|
|
|
WTSAPI_STUB_CALL_BOOL(VirtualChannelPurgeOutput, hChannelHandle);
|
2013-08-20 04:38:43 +04:00
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
BOOL WINAPI WTSVirtualChannelQuery(HANDLE hChannelHandle, WTS_VIRTUAL_CLASS WtsVirtualClass,
|
|
|
|
PVOID* ppBuffer, DWORD* pBytesReturned)
|
2013-08-20 04:38:43 +04:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
WTSAPI_STUB_CALL_BOOL(VirtualChannelQuery, hChannelHandle, WtsVirtualClass, ppBuffer,
|
|
|
|
pBytesReturned);
|
2013-08-20 04:38:43 +04:00
|
|
|
}
|
|
|
|
|
2014-02-28 23:49:57 +04:00
|
|
|
VOID WINAPI WTSFreeMemory(PVOID pMemory)
|
2013-08-20 04:38:43 +04:00
|
|
|
{
|
2014-03-01 09:32:23 +04:00
|
|
|
WTSAPI_STUB_CALL_VOID(FreeMemory, pMemory);
|
2013-08-20 04:38:43 +04:00
|
|
|
}
|
|
|
|
|
2014-02-28 23:49:57 +04:00
|
|
|
BOOL WINAPI WTSFreeMemoryExW(WTS_TYPE_CLASS WTSTypeClass, PVOID pMemory, ULONG NumberOfEntries)
|
2013-08-20 04:38:43 +04:00
|
|
|
{
|
2014-03-01 09:32:23 +04:00
|
|
|
WTSAPI_STUB_CALL_BOOL(FreeMemoryExW, WTSTypeClass, pMemory, NumberOfEntries);
|
2013-08-20 04:38:43 +04:00
|
|
|
}
|
|
|
|
|
2014-02-28 23:49:57 +04:00
|
|
|
BOOL WINAPI WTSFreeMemoryExA(WTS_TYPE_CLASS WTSTypeClass, PVOID pMemory, ULONG NumberOfEntries)
|
2013-08-20 04:38:43 +04:00
|
|
|
{
|
2014-03-01 09:32:23 +04:00
|
|
|
WTSAPI_STUB_CALL_BOOL(FreeMemoryExA, WTSTypeClass, pMemory, NumberOfEntries);
|
2013-08-20 04:38:43 +04:00
|
|
|
}
|
|
|
|
|
2014-02-28 23:49:57 +04:00
|
|
|
BOOL WINAPI WTSRegisterSessionNotification(HWND hWnd, DWORD dwFlags)
|
2013-08-23 08:06:22 +04:00
|
|
|
{
|
2014-03-01 09:32:23 +04:00
|
|
|
WTSAPI_STUB_CALL_BOOL(RegisterSessionNotification, hWnd, dwFlags);
|
2013-08-23 08:06:22 +04:00
|
|
|
}
|
|
|
|
|
2014-02-28 23:49:57 +04:00
|
|
|
BOOL WINAPI WTSUnRegisterSessionNotification(HWND hWnd)
|
2013-08-23 08:06:22 +04:00
|
|
|
{
|
2014-03-01 09:32:23 +04:00
|
|
|
WTSAPI_STUB_CALL_BOOL(UnRegisterSessionNotification, hWnd);
|
2013-08-23 08:06:22 +04:00
|
|
|
}
|
|
|
|
|
2014-02-28 23:49:57 +04:00
|
|
|
BOOL WINAPI WTSRegisterSessionNotificationEx(HANDLE hServer, HWND hWnd, DWORD dwFlags)
|
2013-08-23 08:06:22 +04:00
|
|
|
{
|
2014-03-01 09:32:23 +04:00
|
|
|
WTSAPI_STUB_CALL_BOOL(RegisterSessionNotificationEx, hServer, hWnd, dwFlags);
|
2013-08-23 08:06:22 +04:00
|
|
|
}
|
|
|
|
|
2014-02-28 23:49:57 +04:00
|
|
|
BOOL WINAPI WTSUnRegisterSessionNotificationEx(HANDLE hServer, HWND hWnd)
|
2013-08-23 08:06:22 +04:00
|
|
|
{
|
2014-03-01 09:32:23 +04:00
|
|
|
WTSAPI_STUB_CALL_BOOL(UnRegisterSessionNotificationEx, hServer, hWnd);
|
2013-08-23 08:06:22 +04:00
|
|
|
}
|
|
|
|
|
2014-02-28 23:49:57 +04:00
|
|
|
BOOL WINAPI WTSQueryUserToken(ULONG SessionId, PHANDLE phToken)
|
2013-08-23 08:06:22 +04:00
|
|
|
{
|
2014-03-01 09:32:23 +04:00
|
|
|
WTSAPI_STUB_CALL_BOOL(QueryUserToken, SessionId, phToken);
|
2013-08-23 08:06:22 +04:00
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
BOOL WINAPI WTSEnumerateProcessesExW(HANDLE hServer, DWORD* pLevel, DWORD SessionId,
|
|
|
|
LPWSTR* ppProcessInfo, DWORD* pCount)
|
2013-08-20 04:38:43 +04:00
|
|
|
{
|
2014-03-01 09:32:23 +04:00
|
|
|
WTSAPI_STUB_CALL_BOOL(EnumerateProcessesExW, hServer, pLevel, SessionId, ppProcessInfo, pCount);
|
2013-08-20 04:38:43 +04:00
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
BOOL WINAPI WTSEnumerateProcessesExA(HANDLE hServer, DWORD* pLevel, DWORD SessionId,
|
|
|
|
LPSTR* ppProcessInfo, DWORD* pCount)
|
2013-08-20 04:38:43 +04:00
|
|
|
{
|
2014-03-01 09:32:23 +04:00
|
|
|
WTSAPI_STUB_CALL_BOOL(EnumerateProcessesExA, hServer, pLevel, SessionId, ppProcessInfo, pCount);
|
2013-08-20 04:38:43 +04:00
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
BOOL WINAPI WTSEnumerateListenersW(HANDLE hServer, PVOID pReserved, DWORD Reserved,
|
|
|
|
PWTSLISTENERNAMEW pListeners, DWORD* pCount)
|
2013-08-20 04:38:43 +04:00
|
|
|
{
|
2014-03-01 09:32:23 +04:00
|
|
|
WTSAPI_STUB_CALL_BOOL(EnumerateListenersW, hServer, pReserved, Reserved, pListeners, pCount);
|
2013-08-20 04:38:43 +04:00
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
BOOL WINAPI WTSEnumerateListenersA(HANDLE hServer, PVOID pReserved, DWORD Reserved,
|
|
|
|
PWTSLISTENERNAMEA pListeners, DWORD* pCount)
|
2013-08-20 04:38:43 +04:00
|
|
|
{
|
2014-03-01 09:32:23 +04:00
|
|
|
WTSAPI_STUB_CALL_BOOL(EnumerateListenersA, hServer, pReserved, Reserved, pListeners, pCount);
|
2013-08-20 04:38:43 +04:00
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
BOOL WINAPI WTSQueryListenerConfigW(HANDLE hServer, PVOID pReserved, DWORD Reserved,
|
|
|
|
LPWSTR pListenerName, PWTSLISTENERCONFIGW pBuffer)
|
2013-08-20 04:38:43 +04:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
WTSAPI_STUB_CALL_BOOL(QueryListenerConfigW, hServer, pReserved, Reserved, pListenerName,
|
|
|
|
pBuffer);
|
2013-08-20 04:38:43 +04:00
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
BOOL WINAPI WTSQueryListenerConfigA(HANDLE hServer, PVOID pReserved, DWORD Reserved,
|
|
|
|
LPSTR pListenerName, PWTSLISTENERCONFIGA pBuffer)
|
2013-08-20 04:38:43 +04:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
WTSAPI_STUB_CALL_BOOL(QueryListenerConfigA, hServer, pReserved, Reserved, pListenerName,
|
|
|
|
pBuffer);
|
2013-08-20 04:38:43 +04:00
|
|
|
}
|
|
|
|
|
2014-02-28 23:49:57 +04:00
|
|
|
BOOL WINAPI WTSCreateListenerW(HANDLE hServer, PVOID pReserved, DWORD Reserved,
|
2019-11-06 17:24:51 +03:00
|
|
|
LPWSTR pListenerName, PWTSLISTENERCONFIGW pBuffer, DWORD flag)
|
2013-08-20 04:38:43 +04:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
WTSAPI_STUB_CALL_BOOL(CreateListenerW, hServer, pReserved, Reserved, pListenerName, pBuffer,
|
|
|
|
flag);
|
2013-08-20 04:38:43 +04:00
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
BOOL WINAPI WTSCreateListenerA(HANDLE hServer, PVOID pReserved, DWORD Reserved, LPSTR pListenerName,
|
|
|
|
PWTSLISTENERCONFIGA pBuffer, DWORD flag)
|
2013-08-20 04:38:43 +04:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
WTSAPI_STUB_CALL_BOOL(CreateListenerA, hServer, pReserved, Reserved, pListenerName, pBuffer,
|
|
|
|
flag);
|
2013-08-20 04:38:43 +04:00
|
|
|
}
|
|
|
|
|
2014-02-28 23:49:57 +04:00
|
|
|
BOOL WINAPI WTSSetListenerSecurityW(HANDLE hServer, PVOID pReserved, DWORD Reserved,
|
2019-11-06 17:24:51 +03:00
|
|
|
LPWSTR pListenerName, SECURITY_INFORMATION SecurityInformation,
|
|
|
|
PSECURITY_DESCRIPTOR pSecurityDescriptor)
|
2013-08-20 04:38:43 +04:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
WTSAPI_STUB_CALL_BOOL(SetListenerSecurityW, hServer, pReserved, Reserved, pListenerName,
|
|
|
|
SecurityInformation, pSecurityDescriptor);
|
2013-08-20 04:38:43 +04:00
|
|
|
}
|
|
|
|
|
2014-02-28 23:49:57 +04:00
|
|
|
BOOL WINAPI WTSSetListenerSecurityA(HANDLE hServer, PVOID pReserved, DWORD Reserved,
|
2019-11-06 17:24:51 +03:00
|
|
|
LPSTR pListenerName, SECURITY_INFORMATION SecurityInformation,
|
|
|
|
PSECURITY_DESCRIPTOR pSecurityDescriptor)
|
2013-08-20 04:38:43 +04:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
WTSAPI_STUB_CALL_BOOL(SetListenerSecurityA, hServer, pReserved, Reserved, pListenerName,
|
|
|
|
SecurityInformation, pSecurityDescriptor);
|
2013-08-20 04:38:43 +04:00
|
|
|
}
|
|
|
|
|
2014-02-28 23:49:57 +04:00
|
|
|
BOOL WINAPI WTSGetListenerSecurityW(HANDLE hServer, PVOID pReserved, DWORD Reserved,
|
2019-11-06 17:24:51 +03:00
|
|
|
LPWSTR pListenerName, SECURITY_INFORMATION SecurityInformation,
|
|
|
|
PSECURITY_DESCRIPTOR pSecurityDescriptor, DWORD nLength,
|
|
|
|
LPDWORD lpnLengthNeeded)
|
2013-08-20 04:38:43 +04:00
|
|
|
{
|
2014-03-01 09:32:23 +04:00
|
|
|
WTSAPI_STUB_CALL_BOOL(GetListenerSecurityW, hServer, pReserved, Reserved, pListenerName,
|
2019-11-06 17:24:51 +03:00
|
|
|
SecurityInformation, pSecurityDescriptor, nLength, lpnLengthNeeded);
|
2013-08-20 04:38:43 +04:00
|
|
|
}
|
|
|
|
|
2014-02-28 23:49:57 +04:00
|
|
|
BOOL WINAPI WTSGetListenerSecurityA(HANDLE hServer, PVOID pReserved, DWORD Reserved,
|
2019-11-06 17:24:51 +03:00
|
|
|
LPSTR pListenerName, SECURITY_INFORMATION SecurityInformation,
|
|
|
|
PSECURITY_DESCRIPTOR pSecurityDescriptor, DWORD nLength,
|
|
|
|
LPDWORD lpnLengthNeeded)
|
2013-08-20 04:38:43 +04:00
|
|
|
{
|
2014-03-01 09:32:23 +04:00
|
|
|
WTSAPI_STUB_CALL_BOOL(GetListenerSecurityA, hServer, pReserved, Reserved, pListenerName,
|
2019-11-06 17:24:51 +03:00
|
|
|
SecurityInformation, pSecurityDescriptor, nLength, lpnLengthNeeded);
|
2013-08-20 04:38:43 +04:00
|
|
|
}
|
|
|
|
|
2014-02-28 23:49:57 +04:00
|
|
|
BOOL CDECL WTSEnableChildSessions(BOOL bEnable)
|
2013-08-20 04:38:43 +04:00
|
|
|
{
|
2014-03-01 09:32:23 +04:00
|
|
|
WTSAPI_STUB_CALL_BOOL(EnableChildSessions, bEnable);
|
2013-08-20 04:38:43 +04:00
|
|
|
}
|
|
|
|
|
2014-02-28 23:49:57 +04:00
|
|
|
BOOL CDECL WTSIsChildSessionsEnabled(PBOOL pbEnabled)
|
2013-08-20 04:38:43 +04:00
|
|
|
{
|
2014-03-01 09:32:23 +04:00
|
|
|
WTSAPI_STUB_CALL_BOOL(IsChildSessionsEnabled, pbEnabled);
|
2013-08-20 04:38:43 +04:00
|
|
|
}
|
|
|
|
|
2014-02-28 23:49:57 +04:00
|
|
|
BOOL CDECL WTSGetChildSessionId(PULONG pSessionId)
|
2013-08-20 04:38:43 +04:00
|
|
|
{
|
2014-03-01 09:32:23 +04:00
|
|
|
WTSAPI_STUB_CALL_BOOL(GetChildSessionId, pSessionId);
|
2013-08-20 04:38:43 +04:00
|
|
|
}
|
2013-08-20 03:18:31 +04:00
|
|
|
|
2015-02-09 17:30:18 +03:00
|
|
|
BOOL CDECL WTSLogonUser(HANDLE hServer, LPCSTR username, LPCSTR password, LPCSTR domain)
|
|
|
|
{
|
|
|
|
WTSAPI_STUB_CALL_BOOL(LogonUser, hServer, username, password, domain);
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL CDECL WTSLogoffUser(HANDLE hServer)
|
|
|
|
{
|
|
|
|
WTSAPI_STUB_CALL_BOOL(LogoffUser, hServer);
|
|
|
|
}
|
|
|
|
|
2014-02-28 23:49:57 +04:00
|
|
|
#ifndef _WIN32
|
|
|
|
|
|
|
|
/**
|
|
|
|
* WTSGetActiveConsoleSessionId is declared in WinBase.h and exported by kernel32.dll
|
|
|
|
*/
|
|
|
|
|
|
|
|
DWORD WINAPI WTSGetActiveConsoleSessionId(void)
|
2014-02-17 05:12:45 +04:00
|
|
|
{
|
2016-05-30 18:54:59 +03:00
|
|
|
InitOnceExecuteOnce(&wtsapiInitOnce, InitializeWtsApiStubs, NULL, NULL);
|
2014-03-01 09:32:23 +04:00
|
|
|
|
|
|
|
if (!g_WtsApi || !g_WtsApi->pGetActiveConsoleSessionId)
|
2014-02-17 05:12:45 +04:00
|
|
|
return 0xFFFFFFFF;
|
|
|
|
|
2014-03-01 09:32:23 +04:00
|
|
|
return g_WtsApi->pGetActiveConsoleSessionId();
|
2014-02-17 05:12:45 +04:00
|
|
|
}
|
|
|
|
|
2013-08-20 03:18:31 +04:00
|
|
|
#endif
|
2014-02-17 04:38:12 +04:00
|
|
|
|
2015-01-20 13:03:21 +03:00
|
|
|
const CHAR* WTSErrorToString(UINT error)
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
switch (error)
|
2015-01-20 13:03:21 +03:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
case CHANNEL_RC_OK:
|
|
|
|
return "CHANNEL_RC_OK";
|
2015-01-20 13:03:21 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
case CHANNEL_RC_ALREADY_INITIALIZED:
|
|
|
|
return "CHANNEL_RC_ALREADY_INITIALIZED";
|
2015-01-20 13:03:21 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
case CHANNEL_RC_NOT_INITIALIZED:
|
|
|
|
return "CHANNEL_RC_NOT_INITIALIZED";
|
2015-01-20 13:03:21 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
case CHANNEL_RC_ALREADY_CONNECTED:
|
|
|
|
return "CHANNEL_RC_ALREADY_CONNECTED";
|
2015-01-20 13:03:21 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
case CHANNEL_RC_NOT_CONNECTED:
|
|
|
|
return "CHANNEL_RC_NOT_CONNECTED";
|
2015-01-20 13:03:21 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
case CHANNEL_RC_TOO_MANY_CHANNELS:
|
|
|
|
return "CHANNEL_RC_TOO_MANY_CHANNELS";
|
2015-01-20 13:03:21 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
case CHANNEL_RC_BAD_CHANNEL:
|
|
|
|
return "CHANNEL_RC_BAD_CHANNEL";
|
2015-01-20 13:03:21 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
case CHANNEL_RC_BAD_CHANNEL_HANDLE:
|
|
|
|
return "CHANNEL_RC_BAD_CHANNEL_HANDLE";
|
2015-01-20 13:03:21 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
case CHANNEL_RC_NO_BUFFER:
|
|
|
|
return "CHANNEL_RC_NO_BUFFER";
|
2015-01-20 13:03:21 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
case CHANNEL_RC_BAD_INIT_HANDLE:
|
|
|
|
return "CHANNEL_RC_BAD_INIT_HANDLE";
|
2015-01-20 13:03:21 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
case CHANNEL_RC_NOT_OPEN:
|
|
|
|
return "CHANNEL_RC_NOT_OPEN";
|
2015-01-20 13:03:21 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
case CHANNEL_RC_BAD_PROC:
|
|
|
|
return "CHANNEL_RC_BAD_PROC";
|
2015-01-20 13:03:21 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
case CHANNEL_RC_NO_MEMORY:
|
|
|
|
return "CHANNEL_RC_NO_MEMORY";
|
2015-01-20 13:03:21 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
case CHANNEL_RC_UNKNOWN_CHANNEL_NAME:
|
|
|
|
return "CHANNEL_RC_UNKNOWN_CHANNEL_NAME";
|
2015-01-20 13:03:21 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
case CHANNEL_RC_ALREADY_OPEN:
|
|
|
|
return "CHANNEL_RC_ALREADY_OPEN";
|
2015-01-20 13:03:21 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
case CHANNEL_RC_NOT_IN_VIRTUALCHANNELENTRY:
|
|
|
|
return "CHANNEL_RC_NOT_IN_VIRTUALCHANNELENTRY";
|
2015-01-20 13:03:21 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
case CHANNEL_RC_NULL_DATA:
|
|
|
|
return "CHANNEL_RC_NULL_DATA";
|
2015-01-20 13:03:21 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
case CHANNEL_RC_ZERO_LENGTH:
|
|
|
|
return "CHANNEL_RC_ZERO_LENGTH";
|
2015-01-20 13:03:21 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
case CHANNEL_RC_INVALID_INSTANCE:
|
|
|
|
return "CHANNEL_RC_INVALID_INSTANCE";
|
2015-01-20 13:03:21 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
case CHANNEL_RC_UNSUPPORTED_VERSION:
|
|
|
|
return "CHANNEL_RC_UNSUPPORTED_VERSION";
|
2015-01-20 13:03:21 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
case CHANNEL_RC_INITIALIZATION_ERROR:
|
|
|
|
return "CHANNEL_RC_INITIALIZATION_ERROR";
|
2015-01-20 13:03:21 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
default:
|
|
|
|
return "UNKNOWN";
|
2015-01-20 13:03:21 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-30 18:54:59 +03:00
|
|
|
const CHAR* WTSSessionStateToString(WTS_CONNECTSTATE_CLASS state)
|
|
|
|
{
|
|
|
|
switch (state)
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
case WTSActive:
|
|
|
|
return "WTSActive";
|
|
|
|
case WTSConnected:
|
|
|
|
return "WTSConnected";
|
|
|
|
case WTSConnectQuery:
|
|
|
|
return "WTSConnectQuery";
|
|
|
|
case WTSShadow:
|
|
|
|
return "WTSShadow";
|
|
|
|
case WTSDisconnected:
|
|
|
|
return "WTSDisconnected";
|
|
|
|
case WTSIdle:
|
|
|
|
return "WTSIdle";
|
|
|
|
case WTSListen:
|
|
|
|
return "WTSListen";
|
|
|
|
case WTSReset:
|
|
|
|
return "WTSReset";
|
|
|
|
case WTSDown:
|
|
|
|
return "WTSDown";
|
|
|
|
case WTSInit:
|
|
|
|
return "WTSInit";
|
2016-05-30 18:54:59 +03:00
|
|
|
}
|
|
|
|
return "INVALID_STATE";
|
|
|
|
}
|
|
|
|
|
2014-02-17 04:38:12 +04:00
|
|
|
BOOL WTSRegisterWtsApiFunctionTable(PWtsApiFunctionTable table)
|
|
|
|
{
|
2016-11-24 12:35:36 +03:00
|
|
|
/* Use InitOnceExecuteOnce here as well - otherwise a table set with this
|
|
|
|
function is overriden on the first use of a WTS* API call (due to
|
|
|
|
wtsapiInitOnce not being set). */
|
|
|
|
InitOnceExecuteOnce(&wtsapiInitOnce, InitializeWtsApiStubs, (PVOID)table, NULL);
|
|
|
|
if (!g_WtsApi)
|
|
|
|
return FALSE;
|
2014-02-17 04:38:12 +04:00
|
|
|
return TRUE;
|
|
|
|
}
|
2014-03-01 09:32:23 +04:00
|
|
|
|
2014-08-18 21:34:47 +04:00
|
|
|
static BOOL LoadAndInitialize(char* library)
|
2014-03-01 09:32:23 +04:00
|
|
|
{
|
|
|
|
INIT_WTSAPI_FN pInitWtsApi;
|
2014-04-28 18:46:07 +04:00
|
|
|
g_WtsApiModule = LoadLibraryA(library);
|
2014-03-01 09:32:23 +04:00
|
|
|
|
2014-04-28 18:46:07 +04:00
|
|
|
if (!g_WtsApiModule)
|
|
|
|
return FALSE;
|
2014-03-01 09:32:23 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
pInitWtsApi = (INIT_WTSAPI_FN)GetProcAddress(g_WtsApiModule, "InitWtsApi");
|
2014-03-17 20:16:07 +04:00
|
|
|
|
2014-04-28 18:46:07 +04:00
|
|
|
if (!pInitWtsApi)
|
2014-03-17 20:16:07 +04:00
|
|
|
{
|
2014-04-28 18:46:07 +04:00
|
|
|
return FALSE;
|
2014-03-17 20:16:07 +04:00
|
|
|
}
|
2014-08-18 19:22:22 +04:00
|
|
|
|
2014-04-28 18:46:07 +04:00
|
|
|
g_WtsApi = pInitWtsApi();
|
|
|
|
return TRUE;
|
|
|
|
}
|
2014-03-17 20:16:07 +04:00
|
|
|
|
2016-05-30 18:54:59 +03:00
|
|
|
static void InitializeWtsApiStubs_Env()
|
2014-04-28 18:46:07 +04:00
|
|
|
{
|
|
|
|
DWORD nSize;
|
2019-11-06 17:24:51 +03:00
|
|
|
char* env = NULL;
|
2017-03-03 14:37:27 +03:00
|
|
|
LPCSTR wts = "WTSAPI_LIBRARY";
|
2014-03-01 09:32:23 +04:00
|
|
|
|
2014-04-28 18:46:07 +04:00
|
|
|
if (g_WtsApi)
|
2014-03-01 09:32:23 +04:00
|
|
|
return;
|
|
|
|
|
2017-03-03 14:37:27 +03:00
|
|
|
nSize = GetEnvironmentVariableA(wts, NULL, 0);
|
2014-03-01 09:32:23 +04:00
|
|
|
|
2014-04-28 18:46:07 +04:00
|
|
|
if (!nSize)
|
|
|
|
return;
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
env = (LPSTR)malloc(nSize);
|
2014-04-28 18:46:07 +04:00
|
|
|
if (env)
|
2015-04-03 17:21:01 +03:00
|
|
|
{
|
2017-03-03 14:37:27 +03:00
|
|
|
if (GetEnvironmentVariableA(wts, env, nSize) == nSize - 1)
|
2015-04-03 17:21:01 +03:00
|
|
|
LoadAndInitialize(env);
|
|
|
|
free(env);
|
|
|
|
}
|
2014-03-01 09:32:23 +04:00
|
|
|
}
|
2014-03-25 08:32:05 +04:00
|
|
|
|
2014-04-28 18:54:58 +04:00
|
|
|
#define FREERDS_LIBRARY_NAME "libfreerds-fdsapi.so"
|
2014-07-26 23:23:39 +04:00
|
|
|
|
2016-05-30 18:54:59 +03:00
|
|
|
static void InitializeWtsApiStubs_FreeRDS()
|
2014-03-25 08:32:05 +04:00
|
|
|
{
|
2014-08-18 21:34:47 +04:00
|
|
|
wIniFile* ini;
|
2014-10-03 02:45:53 +04:00
|
|
|
const char* prefix;
|
|
|
|
const char* libdir;
|
2014-08-18 19:22:22 +04:00
|
|
|
|
2014-03-25 08:32:05 +04:00
|
|
|
if (g_WtsApi)
|
|
|
|
return;
|
2014-08-18 19:22:22 +04:00
|
|
|
|
2014-03-25 08:32:05 +04:00
|
|
|
ini = IniFile_New();
|
|
|
|
|
2014-10-03 02:45:53 +04:00
|
|
|
if (IniFile_ReadFile(ini, "/var/run/freerds.instance") < 0)
|
2014-03-25 08:32:05 +04:00
|
|
|
{
|
2014-04-28 18:54:58 +04:00
|
|
|
IniFile_Free(ini);
|
2014-08-18 20:57:08 +04:00
|
|
|
WLog_ERR(TAG, "failed to parse freerds.instance");
|
2014-04-28 18:54:58 +04:00
|
|
|
LoadAndInitialize(FREERDS_LIBRARY_NAME);
|
|
|
|
return;
|
2014-03-25 08:32:05 +04:00
|
|
|
}
|
2014-08-18 19:22:22 +04:00
|
|
|
|
2014-03-25 08:32:05 +04:00
|
|
|
prefix = IniFile_GetKeyValueString(ini, "FreeRDS", "prefix");
|
|
|
|
libdir = IniFile_GetKeyValueString(ini, "FreeRDS", "libdir");
|
2014-08-18 20:57:08 +04:00
|
|
|
WLog_INFO(TAG, "FreeRDS (prefix / libdir): %s / %s", prefix, libdir);
|
2014-08-18 19:22:22 +04:00
|
|
|
|
2014-03-25 08:32:05 +04:00
|
|
|
if (prefix && libdir)
|
|
|
|
{
|
2014-08-18 21:34:47 +04:00
|
|
|
char* prefix_libdir;
|
|
|
|
char* wtsapi_library;
|
2014-03-25 08:32:05 +04:00
|
|
|
prefix_libdir = GetCombinedPath(prefix, libdir);
|
2014-04-28 18:54:58 +04:00
|
|
|
wtsapi_library = GetCombinedPath(prefix_libdir, FREERDS_LIBRARY_NAME);
|
2014-08-18 19:22:22 +04:00
|
|
|
|
2014-03-25 08:32:05 +04:00
|
|
|
if (wtsapi_library)
|
|
|
|
{
|
2014-04-28 18:46:07 +04:00
|
|
|
LoadAndInitialize(wtsapi_library);
|
2014-03-25 08:32:05 +04:00
|
|
|
}
|
2014-08-18 19:22:22 +04:00
|
|
|
|
2014-03-25 08:32:05 +04:00
|
|
|
free(prefix_libdir);
|
|
|
|
free(wtsapi_library);
|
|
|
|
}
|
2014-08-18 19:22:22 +04:00
|
|
|
|
2014-03-25 08:32:05 +04:00
|
|
|
IniFile_Free(ini);
|
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
static BOOL CALLBACK InitializeWtsApiStubs(PINIT_ONCE once, PVOID param, PVOID* context)
|
2016-05-30 18:54:59 +03:00
|
|
|
{
|
2018-11-22 19:28:31 +03:00
|
|
|
WINPR_UNUSED(once);
|
|
|
|
WINPR_UNUSED(context);
|
2016-11-24 12:35:36 +03:00
|
|
|
if (param)
|
|
|
|
{
|
|
|
|
g_WtsApi = (PWtsApiFunctionTable)param;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2014-03-25 08:32:05 +04:00
|
|
|
InitializeWtsApiStubs_Env();
|
2014-10-13 18:55:11 +04:00
|
|
|
|
2014-07-26 23:23:39 +04:00
|
|
|
#ifdef _WIN32
|
|
|
|
WtsApi32_InitializeWtsApi();
|
|
|
|
#endif
|
|
|
|
|
2014-03-25 08:32:05 +04:00
|
|
|
if (!g_WtsApi)
|
|
|
|
InitializeWtsApiStubs_FreeRDS();
|
2014-04-28 18:46:07 +04:00
|
|
|
|
2016-05-30 18:54:59 +03:00
|
|
|
return TRUE;
|
2014-03-25 08:32:05 +04:00
|
|
|
}
|