From 2761cef387079513895bc8799347838748512efe Mon Sep 17 00:00:00 2001 From: nogginware Date: Mon, 24 Jun 2013 16:32:12 -0400 Subject: [PATCH 1/5] new file: winpr/include/winpr/wtsapi.h new file: winpr/libwinpr/wtsapi/CMakeLists.txt new file: winpr/libwinpr/wtsapi/ModuleOptions.cmake new file: winpr/libwinpr/wtsapi/wtsapi.c --- winpr/include/winpr/wtsapi.h | 1627 +++++++++++++++++++++ winpr/libwinpr/wtsapi/CMakeLists.txt | 36 + winpr/libwinpr/wtsapi/ModuleOptions.cmake | 9 + winpr/libwinpr/wtsapi/wtsapi.c | 506 +++++++ 4 files changed, 2178 insertions(+) create mode 100644 winpr/include/winpr/wtsapi.h create mode 100644 winpr/libwinpr/wtsapi/CMakeLists.txt create mode 100644 winpr/libwinpr/wtsapi/ModuleOptions.cmake create mode 100644 winpr/libwinpr/wtsapi/wtsapi.c diff --git a/winpr/include/winpr/wtsapi.h b/winpr/include/winpr/wtsapi.h new file mode 100644 index 000000000..b07006b5f --- /dev/null +++ b/winpr/include/winpr/wtsapi.h @@ -0,0 +1,1627 @@ +/** + * WinPR: Windows Portable Runtime + * Windows Terminal Services API (WTSAPI) + * + * Copyright 2013 Mike McDonald + * + * 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. + */ + +#ifndef WINPR_WTSAPI_H +#define WINPR_WTSAPI_H + +#include + +#include +#include +#include +#include + +#ifdef _WIN32 + +#include + +#else + +typedef HANDLE HWND; + +#ifdef __cplusplus +extern "C" { +#endif + + +/*=================================================================== +== Defines +=====================================================================*/ + +/* + * Specifies the current server + */ +#define WTS_CURRENT_SERVER ((HANDLE)NULL) +#define WTS_CURRENT_SERVER_HANDLE ((HANDLE)NULL) +#define WTS_CURRENT_SERVER_NAME (NULL) + +/* + * Specifies the current session (SessionId) + */ +#define WTS_CURRENT_SESSION ((DWORD)-1) + +/* + * Specifies any-session (SessionId) + */ +#define WTS_ANY_SESSION ((DWORD)-2) + +/* + * Possible pResponse values from WTSSendMessage() + */ +#ifndef IDTIMEOUT +#define IDTIMEOUT 32000 +#endif +#ifndef IDASYNC +#define IDASYNC 32001 +#endif + +#ifndef __HYDRIX_H__ +#define USERNAME_LENGTH 20 +#define CLIENTNAME_LENGTH 20 +#define CLIENTADDRESS_LENGTH 30 +#endif +/* + * Shutdown flags + */ +#define WTS_WSD_LOGOFF 0x00000001 // log off all users except + // current user; deletes + // WinStations (a reboot is + // required to recreate the + // WinStations) +#define WTS_WSD_SHUTDOWN 0x00000002 // shutdown system +#define WTS_WSD_REBOOT 0x00000004 // shutdown and reboot +#define WTS_WSD_POWEROFF 0x00000008 // shutdown and power off (on + // machines that support power + // off through software) +#define WTS_WSD_FASTREBOOT 0x00000010 // reboot without logging users + // off or shutting down +#define MAX_ELAPSED_TIME_LENGTH 15 +#define MAX_DATE_TIME_LENGTH 56 +#define WINSTATIONNAME_LENGTH 32 +#define DOMAIN_LENGTH 17 + +#define WTS_DRIVE_LENGTH 3 +#define WTS_LISTENER_NAME_LENGTH 32 +#define WTS_COMMENT_LENGTH 60 + +/* + * Flags for WTSCreateListener + */ +#define WTS_LISTENER_CREATE 0x00000001 +#define WTS_LISTENER_UPDATE 0x00000010 + +/********************************* + * Listener access values + *********************************/ +#define WTS_SECURITY_QUERY_INFORMATION 0x00000001 +#define WTS_SECURITY_SET_INFORMATION 0x00000002 +#define WTS_SECURITY_RESET 0x00000004 +#define WTS_SECURITY_VIRTUAL_CHANNELS 0x00000008 +#define WTS_SECURITY_REMOTE_CONTROL 0x00000010 +#define WTS_SECURITY_LOGON 0x00000020 +#define WTS_SECURITY_LOGOFF 0x00000040 +#define WTS_SECURITY_MESSAGE 0x00000080 +#define WTS_SECURITY_CONNECT 0x00000100 +#define WTS_SECURITY_DISCONNECT 0x00000200 + +#define WTS_SECURITY_GUEST_ACCESS (WTS_SECURITY_LOGON) + +#define WTS_SECURITY_CURRENT_GUEST_ACCESS (WTS_SECURITY_VIRTUAL_CHANNELS | WTS_SECURITY_LOGOFF) + +#define WTS_SECURITY_USER_ACCESS (WTS_SECURITY_CURRENT_GUEST_ACCESS | WTS_SECURITY_QUERY_INFORMATION | WTS_SECURITY_CONNECT ) + +#define WTS_SECURITY_CURRENT_USER_ACCESS (WTS_SECURITY_SET_INFORMATION | WTS_SECURITY_RESET \ + WTS_SECURITY_VIRTUAL_CHANNELS | WTS_SECURITY_LOGOFF \ + WTS_SECURITY_DISCONNECT) + +#define WTS_SECURITY_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | WTS_SECURITY_QUERY_INFORMATION | \ + WTS_SECURITY_SET_INFORMATION | WTS_SECURITY_RESET | \ + WTS_SECURITY_VIRTUAL_CHANNELS | WTS_SECURITY_REMOTE_CONTROL | \ + WTS_SECURITY_LOGON | \ + WTS_SECURITY_MESSAGE | \ + WTS_SECURITY_CONNECT | WTS_SECURITY_DISCONNECT) + +/*=================================================================== +== WTS_CONNECTSTATE_CLASS - Session connect state +=====================================================================*/ + +typedef enum _WTS_CONNECTSTATE_CLASS { + WTSActive, // User logged on to WinStation + WTSConnected, // WinStation connected to client + WTSConnectQuery, // In the process of connecting to client + WTSShadow, // Shadowing another WinStation + WTSDisconnected, // WinStation logged on without client + WTSIdle, // Waiting for client to connect + WTSListen, // WinStation is listening for connection + WTSReset, // WinStation is being reset + WTSDown, // WinStation is down due to error + WTSInit, // WinStation in initialization +} WTS_CONNECTSTATE_CLASS; + +/*===================================================================== +== WTS_SERVER_INFO - returned by WTSEnumerateServers (version 1) +=====================================================================*/ + +/* + * WTSEnumerateServers() returns two variables: pServerInfo and Count. + * The latter is the number of WTS_SERVER_INFO structures contained in + * the former. In order to read each server, iterate i from 0 to + * Count-1 and reference the server name as + * pServerInfo[i].pServerName; for example: + * + * for ( i=0; i < Count; i++ ) { + * _tprintf( TEXT("%s "), pServerInfo[i].pServerName ); + * } + * + * The memory returned looks like the following. P is a pServerInfo + * pointer, and D is the string data for that pServerInfo: + * + * P1 P2 P3 P4 ... Pn D1 D2 D3 D4 ... Dn + * + * This makes it easier to iterate the servers, using code similar to + * the above. + */ + +typedef struct _WTS_SERVER_INFOW { + LPWSTR pServerName; // server name +} WTS_SERVER_INFOW, * PWTS_SERVER_INFOW; + +typedef struct _WTS_SERVER_INFOA { + LPSTR pServerName; // server name +} WTS_SERVER_INFOA, * PWTS_SERVER_INFOA; + +#ifdef UNICODE +#define WTS_SERVER_INFO WTS_SERVER_INFOW +#define PWTS_SERVER_INFO PWTS_SERVER_INFOW +#else +#define WTS_SERVER_INFO WTS_SERVER_INFOA +#define PWTS_SERVER_INFO PWTS_SERVER_INFOA +#endif + + +/*===================================================================== +== WTS_SESSION_INFO - returned by WTSEnumerateSessions (version 1) +=====================================================================*/ + +/* + * WTSEnumerateSessions() returns data in a similar format to the above + * WTSEnumerateServers(). It returns two variables: pSessionInfo and + * Count. The latter is the number of WTS_SESSION_INFO structures + * contained in the former. Iteration is similar, except that there + * are three parts to each entry, so it would look like this: + * + * for ( i=0; i < Count; i++ ) { + * _tprintf( TEXT("%-5u %-20s %u\n"), + pSessionInfo[i].SessionId, + * pSessionInfo[i].pWinStationName, + * pSessionInfo[i].State ); + * } + * + * The memory returned is also segmented as the above, with all the + * structures allocated at the start and the string data at the end. + * We'll use S for the SessionId, P for the pWinStationName pointer + * and D for the string data, and C for the connect State: + * + * S1 P1 C1 S2 P2 C2 S3 P3 C3 S4 P4 C4 ... Sn Pn Cn D1 D2 D3 D4 ... Dn + * + * As above, this makes it easier to iterate the sessions. + */ + +typedef struct _WTS_SESSION_INFOW { + DWORD SessionId; // session id + LPWSTR pWinStationName; // name of WinStation this session is + // connected to + WTS_CONNECTSTATE_CLASS State; // connection state (see enum) +} WTS_SESSION_INFOW, * PWTS_SESSION_INFOW; + +typedef struct _WTS_SESSION_INFOA { + DWORD SessionId; // session id + LPSTR pWinStationName; // name of WinStation this session is + // connected to + WTS_CONNECTSTATE_CLASS State; // connection state (see enum) +} WTS_SESSION_INFOA, * PWTS_SESSION_INFOA; + +typedef struct _WTS_SESSION_INFO_1W { + DWORD ExecEnvId; + WTS_CONNECTSTATE_CLASS State; + DWORD SessionId; + LPWSTR pSessionName; + LPWSTR pHostName; + LPWSTR pUserName; + LPWSTR pDomainName; + LPWSTR pFarmName; +} WTS_SESSION_INFO_1W, * PWTS_SESSION_INFO_1W; + +typedef struct _WTS_SESSION_INFO_1A { + DWORD ExecEnvId; + WTS_CONNECTSTATE_CLASS State; + DWORD SessionId; + LPSTR pSessionName; + LPSTR pHostName; + LPSTR pUserName; + LPSTR pDomainName; + LPSTR pFarmName; +} WTS_SESSION_INFO_1A, * PWTS_SESSION_INFO_1A; + +#ifdef UNICODE +#define WTS_SESSION_INFO WTS_SESSION_INFOW +#define PWTS_SESSION_INFO PWTS_SESSION_INFOW +#define WTS_SESSION_INFO_1 WTS_SESSION_INFO_1W +#define PWTS_SESSION_INFO_1 PWTS_SESSION_INFO_1W +#else +#define WTS_SESSION_INFO WTS_SESSION_INFOA +#define PWTS_SESSION_INFO PWTS_SESSION_INFOA +#define WTS_SESSION_INFO_1 WTS_SESSION_INFO_1A +#define PWTS_SESSION_INFO_1 PWTS_SESSION_INFO_1A +#endif + + +/*===================================================================== +== WTS_PROCESS_INFO - returned by WTSEnumerateProcesses (version 1) +=====================================================================*/ + +/* + * WTSEnumerateProcesses() also returns data similar to + * WTSEnumerateServers(). It returns two variables: pProcessInfo and + * Count. The latter is the number of WTS_PROCESS_INFO structures + * contained in the former. Iteration is similar, except that there + * are four parts to each entry, so it would look like this: + * + * for ( i=0; i < Count; i++ ) { + * GetUserNameFromSid( pProcessInfo[i].pUserSid, UserName, + * sizeof(UserName) ); + * _tprintf( TEXT("%-5u %-20s %-5u %s\n"), + * pProcessInfo[i].SessionId, + * UserName, + * pProcessInfo[i].ProcessId, + * pProcessInfo[i].pProcessName ); + * } + * + * The memory returned is also segmented as the above, with all the + * structures allocated at the start and the string data at the end. + * We'll use S for the SessionId, R for the ProcessId, P for the + * pProcessName pointer and D for the string data, and U for pUserSid: + * + * S1 R1 P1 U1 S2 R2 P2 U2 S3 R3 P3 U3 ... Sn Rn Pn Un D1 D2 D3 ... Dn + * + * As above, this makes it easier to iterate the processes. + */ + +typedef struct _WTS_PROCESS_INFOW { + DWORD SessionId; // session id + DWORD ProcessId; // process id + LPWSTR pProcessName; // name of process + PSID pUserSid; // user's SID +} WTS_PROCESS_INFOW, * PWTS_PROCESS_INFOW; + +typedef struct _WTS_PROCESS_INFOA { + DWORD SessionId; // session id + DWORD ProcessId; // process id + LPSTR pProcessName; // name of process + PSID pUserSid; // user's SID +} WTS_PROCESS_INFOA, * PWTS_PROCESS_INFOA; + +#ifdef UNICODE +#define WTS_PROCESS_INFO WTS_PROCESS_INFOW +#define PWTS_PROCESS_INFO PWTS_PROCESS_INFOW +#else +#define WTS_PROCESS_INFO WTS_PROCESS_INFOA +#define PWTS_PROCESS_INFO PWTS_PROCESS_INFOA +#endif + +/*===================================================================== +== WTS_INFO_CLASS - WTSQuerySessionInformation +== (See additional typedefs for more info on structures) +=====================================================================*/ + +#define WTS_PROTOCOL_TYPE_CONSOLE 0 // Console +#define WTS_PROTOCOL_TYPE_ICA 1 // ICA Protocol +#define WTS_PROTOCOL_TYPE_RDP 2 // RDP Protocol + +typedef enum _WTS_INFO_CLASS { + WTSInitialProgram, + WTSApplicationName, + WTSWorkingDirectory, + WTSOEMId, + WTSSessionId, + WTSUserName, + WTSWinStationName, + WTSDomainName, + WTSConnectState, + WTSClientBuildNumber, + WTSClientName, + WTSClientDirectory, + WTSClientProductId, + WTSClientHardwareId, + WTSClientAddress, + WTSClientDisplay, + WTSClientProtocolType, + WTSIdleTime, + WTSLogonTime, + WTSIncomingBytes, + WTSOutgoingBytes, + WTSIncomingFrames, + WTSOutgoingFrames, + WTSClientInfo, + WTSSessionInfo, + WTSSessionInfoEx, + WTSConfigInfo, + WTSValidationInfo, // Info Class value used to fetch Validation Information through the WTSQuerySessionInformation + WTSSessionAddressV4, + WTSIsRemoteSession +} WTS_INFO_CLASS; + +/*===================================================================== +== WTS Config Information +=====================================================================*/ + +typedef struct _WTSCONFIGINFOW { + ULONG version; + ULONG fConnectClientDrivesAtLogon; + ULONG fConnectPrinterAtLogon; + ULONG fDisablePrinterRedirection; + ULONG fDisableDefaultMainClientPrinter; + ULONG ShadowSettings; + WCHAR LogonUserName[USERNAME_LENGTH + 1 ]; + WCHAR LogonDomain[DOMAIN_LENGTH + 1 ]; + WCHAR WorkDirectory[MAX_PATH + 1 ]; + WCHAR InitialProgram[MAX_PATH + 1 ]; + WCHAR ApplicationName[MAX_PATH + 1 ]; +} WTSCONFIGINFOW, *PWTSCONFIGINFOW; + +typedef struct _WTSCONFIGINFOA { + ULONG version; + ULONG fConnectClientDrivesAtLogon; + ULONG fConnectPrinterAtLogon; + ULONG fDisablePrinterRedirection; + ULONG fDisableDefaultMainClientPrinter; + ULONG ShadowSettings; + CHAR LogonUserName[USERNAME_LENGTH + 1 ]; + CHAR LogonDomain[DOMAIN_LENGTH + 1 ]; + CHAR WorkDirectory[MAX_PATH + 1 ]; + CHAR InitialProgram[MAX_PATH + 1 ]; + CHAR ApplicationName[MAX_PATH + 1 ]; +} WTSCONFIGINFOA, *PWTSCONFIGINFOA; + +/*===================================================================== +== WTS Session Information +=====================================================================*/ +typedef struct _WTSINFOW { + WTS_CONNECTSTATE_CLASS State; // connection state (see enum) + DWORD SessionId; // session id + DWORD IncomingBytes; + DWORD OutgoingBytes; + DWORD IncomingFrames; + DWORD OutgoingFrames; + DWORD IncomingCompressedBytes; + DWORD OutgoingCompressedBytes; + WCHAR WinStationName[WINSTATIONNAME_LENGTH]; + WCHAR Domain[DOMAIN_LENGTH]; + WCHAR UserName[USERNAME_LENGTH+1];// name of WinStation this session is + // connected to + LARGE_INTEGER ConnectTime; + LARGE_INTEGER DisconnectTime; + LARGE_INTEGER LastInputTime; + LARGE_INTEGER LogonTime; + LARGE_INTEGER CurrentTime; + +} WTSINFOW, * PWTSINFOW; + +typedef struct _WTSINFOA { + WTS_CONNECTSTATE_CLASS State; // connection state (see enum) + DWORD SessionId; // session id + DWORD IncomingBytes; + DWORD OutgoingBytes; + DWORD IncomingFrames; + DWORD OutgoingFrames; + DWORD IncomingCompressedBytes; + DWORD OutgoingCompressedBy; + CHAR WinStationName[WINSTATIONNAME_LENGTH]; + CHAR Domain[DOMAIN_LENGTH]; + CHAR UserName[USERNAME_LENGTH+1];// name of WinStation this session is + // connected to + LARGE_INTEGER ConnectTime; + LARGE_INTEGER DisconnectTime; + LARGE_INTEGER LastInputTime; + LARGE_INTEGER LogonTime; + LARGE_INTEGER CurrentTime; + +} WTSINFOA, * PWTSINFOA; + + +/*===================================================================== +== WTS Extended Session State Flags +=====================================================================*/ +#define WTS_SESSIONSTATE_UNKNOWN 0xFFFFFFFF +#define WTS_SESSIONSTATE_LOCK 0x00000000 +#define WTS_SESSIONSTATE_UNLOCK 0x00000001 + +/*===================================================================== +== WTS Extended Session Information +=====================================================================*/ +typedef struct _WTSINFOEX_LEVEL1_W { + ULONG SessionId; + WTS_CONNECTSTATE_CLASS SessionState; + LONG SessionFlags; + WCHAR WinStationName[WINSTATIONNAME_LENGTH + 1] ; + WCHAR UserName[USERNAME_LENGTH + 1]; + WCHAR DomainName[DOMAIN_LENGTH + 1]; + LARGE_INTEGER LogonTime; + LARGE_INTEGER ConnectTime; + LARGE_INTEGER DisconnectTime; + LARGE_INTEGER LastInputTime; + LARGE_INTEGER CurrentTime; + DWORD IncomingBytes; + DWORD OutgoingBytes; + DWORD IncomingFrames; + DWORD OutgoingFrames; + DWORD IncomingCompressedBytes; + DWORD OutgoingCompressedBytes; +} WTSINFOEX_LEVEL1_W, *PWTSINFOEX_LEVEL1_W; + +typedef struct _WTSINFOEX_LEVEL1_A { + ULONG SessionId; + WTS_CONNECTSTATE_CLASS SessionState; + LONG SessionFlags; + CHAR WinStationName[WINSTATIONNAME_LENGTH + 1]; + CHAR UserName[USERNAME_LENGTH + 1]; + CHAR DomainName[DOMAIN_LENGTH + 1]; + LARGE_INTEGER LogonTime; + LARGE_INTEGER ConnectTime; + LARGE_INTEGER DisconnectTime; + LARGE_INTEGER LastInputTime; + LARGE_INTEGER CurrentTime; + DWORD IncomingBytes; + DWORD OutgoingBytes; + DWORD IncomingFrames; + DWORD OutgoingFrames; + DWORD IncomingCompressedBytes; + DWORD OutgoingCompressedBytes; +} WTSINFOEX_LEVEL1_A, *PWTSINFOEX_LEVEL1_A; + +typedef union _WTSINFOEX_LEVEL_W { + WTSINFOEX_LEVEL1_W WTSInfoExLevel1; +} WTSINFOEX_LEVEL_W, *PWTSINFOEX_LEVEL_W; + +typedef union _WTSINFOEX_LEVEL_A { + WTSINFOEX_LEVEL1_A WTSInfoExLevel1; +} WTSINFOEX_LEVEL_A, *PWTSINFOEX_LEVEL_A; + +typedef struct _WTSINFOEXW { + DWORD Level; + WTSINFOEX_LEVEL_W Data; +} WTSINFOEXW, *PWTSINFOEXW; + +typedef struct _WTSINFOEXA { + DWORD Level; + WTSINFOEX_LEVEL_A Data; +} WTSINFOEXA, *PWTSINFOEXA; + + +/*===================================================================== +== WTS Client Information +=====================================================================*/ +typedef struct _WTSCLIENTW { + WCHAR ClientName[ CLIENTNAME_LENGTH + 1 ]; + WCHAR Domain[ DOMAIN_LENGTH + 1 ]; + WCHAR UserName[ USERNAME_LENGTH + 1 ]; + WCHAR WorkDirectory[ MAX_PATH + 1]; + WCHAR InitialProgram[ MAX_PATH + 1]; + BYTE EncryptionLevel; // security level of encryption pd + ULONG ClientAddressFamily; + USHORT ClientAddress[ CLIENTADDRESS_LENGTH + 1 ]; + USHORT HRes; + USHORT VRes; + USHORT ColorDepth; + WCHAR ClientDirectory[ MAX_PATH + 1 ]; + ULONG ClientBuildNumber; + ULONG ClientHardwareId; // client software serial number + USHORT ClientProductId; // client software product id + USHORT OutBufCountHost; // number of outbufs on host + USHORT OutBufCountClient; // number of outbufs on client + USHORT OutBufLength; // length of outbufs in bytes + WCHAR DeviceId[ MAX_PATH + 1]; +} WTSCLIENTW, * PWTSCLIENTW; + + +/*===================================================================== +== WTS Client Information +=====================================================================*/ +typedef struct _WTSCLIENTA { + CHAR ClientName[ CLIENTNAME_LENGTH + 1 ]; + CHAR Domain[ DOMAIN_LENGTH + 1 ]; + CHAR UserName[ USERNAME_LENGTH + 1 ]; + CHAR WorkDirectory[ MAX_PATH + 1]; + CHAR InitialProgram[ MAX_PATH + 1 ]; + BYTE EncryptionLevel; // security level of encryption pd + ULONG ClientAddressFamily; + USHORT ClientAddress[ CLIENTADDRESS_LENGTH + 1 ]; + USHORT HRes; + USHORT VRes; + USHORT ColorDepth; + CHAR ClientDirectory[ MAX_PATH + 1 ]; + ULONG ClientBuildNumber; + ULONG ClientHardwareId; // client software serial number + USHORT ClientProductId; // client software product id + USHORT OutBufCountHost; // number of outbufs on host + USHORT OutBufCountClient; // number of outbufs on client + USHORT OutBufLength; // length of outbufs in bytes + CHAR DeviceId[ MAX_PATH + 1]; +} WTSCLIENTA, * PWTSCLIENTA; + +/*===================================================================== +== WTS License Validation Information - Product Information +=====================================================================*/ + +#define PRODUCTINFO_COMPANYNAME_LENGTH 256 +#define PRODUCTINFO_PRODUCTID_LENGTH 4 + +typedef struct _WTS_PRODUCT_INFOA +{ + CHAR CompanyName[PRODUCTINFO_COMPANYNAME_LENGTH]; + CHAR ProductID[PRODUCTINFO_PRODUCTID_LENGTH]; +} PRODUCT_INFOA; + +typedef struct _WTS_PRODUCT_INFOW +{ + WCHAR CompanyName[PRODUCTINFO_COMPANYNAME_LENGTH]; + WCHAR ProductID[PRODUCTINFO_PRODUCTID_LENGTH]; +} PRODUCT_INFOW; + +/*===================================================================== + WTS License Validation Information + This structure will be returned from WTSQuerySessionInformation when the user + queries for license validation information. +=====================================================================*/ + +#define VALIDATIONINFORMATION_LICENSE_LENGTH 16384 //16 Kb +#define VALIDATIONINFORMATION_HARDWAREID_LENGTH 20 + +typedef struct _WTS_VALIDATION_INFORMATIONA { + PRODUCT_INFOA ProductInfo; + BYTE License[VALIDATIONINFORMATION_LICENSE_LENGTH]; + DWORD LicenseLength; + BYTE HardwareID[VALIDATIONINFORMATION_HARDWAREID_LENGTH]; + DWORD HardwareIDLength; + +} WTS_VALIDATION_INFORMATIONA, * PWTS_VALIDATION_INFORMATIONA; + +typedef struct _WTS_VALIDATION_INFORMATIONW { + PRODUCT_INFOW ProductInfo; + BYTE License[VALIDATIONINFORMATION_LICENSE_LENGTH]; + DWORD LicenseLength; + BYTE HardwareID[VALIDATIONINFORMATION_HARDWAREID_LENGTH]; + DWORD HardwareIDLength; + +} WTS_VALIDATION_INFORMATIONW, * PWTS_VALIDATION_INFORMATIONW; + +#ifdef UNICODE +#define WTSCONFIGINFO WTSCONFIGINFOW +#define PWTSCONFIGINFO PWTSCONFIGINFOW +#define PRODUCT_INFO PRODUCT_INFOW +#define WTS_VALIDATION_INFORMATION WTS_VALIDATION_INFORMATIONW +#define PWTS_VALIDATION_INFORMATION PWTS_VALIDATION_INFORMATIONW +#define WTSINFO WTSINFOW +#define PWTSINFO PWTSINFOW +#define WTSINFOEX WTSINFOEXW +#define PWTSINFOEX PWTSINFOEXW +#define WTSINFOEX_LEVEL WTSINFOEX_LEVEL_W +#define PWTSINFOEX_LEVEL PWTSINFOEX_LEVEL_W +#define WTSINFOEX_LEVEL1 WTSINFOEX_LEVEL1_W +#define PWTSINFOEX_LEVEL1 PWTSINFOEX_LEVEL1_W +#define WTSCLIENT WTSCLIENTW +#define PWTSCLIENT PWTSCLIENTW +#else +#define WTSCONFIGINFO WTSCONFIGINFOA +#define PWTSCONFIGINFO PWTSCONFIGINFOA +#define PRODUCT_INFO PRODUCT_INFOA +#define WTS_VALIDATION_INFORMATION WTS_VALIDATION_INFORMATIONA +#define PWTS_VALIDATION_INFORMATION PWTS_VALIDATION_INFORMATIONA +#define WTSINFO WTSINFOA +#define PWTSINFO PWTSINFOA +#define WTSINFOEX WTSINFOEXA +#define PWTSINFOEX PWTSINFOEXA +#define WTSINFOEX_LEVEL WTSINFOEX_LEVEL_A +#define PWTSINFOEX_LEVEL PWTSINFOEX_LEVEL_A +#define WTSINFOEX_LEVEL1 WTSINFOEX_LEVEL1_A +#define PWTSINFOEX_LEVEL1 PWTSINFOEX_LEVEL1_A +#define WTSCLIENT WTSCLIENTA +#define PWTSCLIENT PWTSCLIENTA + +#endif + + +/*===================================================================== +== WTSQuerySessionInformation - (WTSClientAddress) +=====================================================================*/ + +typedef struct _WTS_CLIENT_ADDRESS { + DWORD AddressFamily; // AF_INET, AF_INET6, AF_IPX, AF_NETBIOS, AF_UNSPEC + BYTE Address[20]; // client network address +} WTS_CLIENT_ADDRESS, * PWTS_CLIENT_ADDRESS; + + +/*===================================================================== +== WTSQuerySessionInformation - (WTSClientDisplay) +=====================================================================*/ + +typedef struct _WTS_CLIENT_DISPLAY { + DWORD HorizontalResolution; // horizontal dimensions, in pixels + DWORD VerticalResolution; // vertical dimensions, in pixels + DWORD ColorDepth; // 1=16, 2=256, 4=64K, 8=16M +} WTS_CLIENT_DISPLAY, * PWTS_CLIENT_DISPLAY; + + +/*===================================================================== +== WTS_CONFIG_CLASS - WTSQueryUserConfig/WTSSetUserConfig +=====================================================================*/ + + +typedef enum _WTS_CONFIG_CLASS { + //Initial program settings + WTSUserConfigInitialProgram, // string returned/expected + WTSUserConfigWorkingDirectory, // string returned/expected + WTSUserConfigfInheritInitialProgram, // DWORD returned/expected + // + WTSUserConfigfAllowLogonTerminalServer, //DWORD returned/expected + //Timeout settings + WTSUserConfigTimeoutSettingsConnections, //DWORD returned/expected + WTSUserConfigTimeoutSettingsDisconnections, //DWORD returned/expected + WTSUserConfigTimeoutSettingsIdle, //DWORD returned/expected + //Client device settings + WTSUserConfigfDeviceClientDrives, //DWORD returned/expected + WTSUserConfigfDeviceClientPrinters, //DWORD returned/expected + WTSUserConfigfDeviceClientDefaultPrinter, //DWORD returned/expected + //Connection settings + WTSUserConfigBrokenTimeoutSettings, //DWORD returned/expected + WTSUserConfigReconnectSettings, //DWORD returned/expected + //Modem settings + WTSUserConfigModemCallbackSettings, //DWORD returned/expected + WTSUserConfigModemCallbackPhoneNumber, // string returned/expected + //Shadow settings + WTSUserConfigShadowingSettings, //DWORD returned/expected + //User Profile settings + WTSUserConfigTerminalServerProfilePath, // string returned/expected + //Terminal Server home directory + WTSUserConfigTerminalServerHomeDir, // string returned/expected + WTSUserConfigTerminalServerHomeDirDrive, // string returned/expected + WTSUserConfigfTerminalServerRemoteHomeDir, // DWORD 0:LOCAL 1:REMOTE + + WTSUserConfigUser, // returns WTSUSERCONFIG struct +} WTS_CONFIG_CLASS; + +typedef enum _WTS_CONFIG_SOURCE { + WTSUserConfigSourceSAM +} WTS_CONFIG_SOURCE; + +typedef struct _WTSUSERCONFIGA { + DWORD Source; + DWORD InheritInitialProgram; + DWORD AllowLogonTerminalServer; + DWORD TimeoutSettingsConnections; + DWORD TimeoutSettingsDisconnections; + DWORD TimeoutSettingsIdle; + DWORD DeviceClientDrives; + DWORD DeviceClientPrinters; + DWORD ClientDefaultPrinter; + DWORD BrokenTimeoutSettings; + DWORD ReconnectSettings; + DWORD ShadowingSettings; + DWORD TerminalServerRemoteHomeDir; + CHAR InitialProgram[ MAX_PATH + 1 ]; + CHAR WorkDirectory[ MAX_PATH + 1 ]; + CHAR TerminalServerProfilePath[ MAX_PATH + 1 ]; + CHAR TerminalServerHomeDir[ MAX_PATH + 1 ]; + CHAR TerminalServerHomeDirDrive[ WTS_DRIVE_LENGTH + 1 ]; +} WTSUSERCONFIGA, * PWTSUSERCONFIGA; + +typedef struct _WTSUSERCONFIGW { + DWORD Source; + DWORD InheritInitialProgram; + DWORD AllowLogonTerminalServer; + DWORD TimeoutSettingsConnections; + DWORD TimeoutSettingsDisconnections; + DWORD TimeoutSettingsIdle; + DWORD DeviceClientDrives; + DWORD DeviceClientPrinters; + DWORD ClientDefaultPrinter; + DWORD BrokenTimeoutSettings; + DWORD ReconnectSettings; + DWORD ShadowingSettings; + DWORD TerminalServerRemoteHomeDir; + WCHAR InitialProgram[ MAX_PATH + 1 ]; + WCHAR WorkDirectory[ MAX_PATH + 1 ]; + WCHAR TerminalServerProfilePath[ MAX_PATH + 1 ]; + WCHAR TerminalServerHomeDir[ MAX_PATH + 1 ]; + WCHAR TerminalServerHomeDirDrive[ WTS_DRIVE_LENGTH + 1 ]; +} WTSUSERCONFIGW, * PWTSUSERCONFIGW; + +#ifdef UNICODE +#define WTSUSERCONFIG WTSUSERCONFIGW +#define PWTSUSERCONFIG PWTSUSERCONFIGW +#else +#define WTSUSERCONFIG WTSUSERCONFIGA +#define PWTSUSERCONFIG PWTSUSERCONFIGA +#endif /* UNICODE */ + + +/*===================================================================== +== WTS_EVENT - Event flags for WTSWaitSystemEvent +=====================================================================*/ + +#define WTS_EVENT_NONE 0x00000000 // return no event +#define WTS_EVENT_CREATE 0x00000001 // new WinStation created +#define WTS_EVENT_DELETE 0x00000002 // existing WinStation deleted +#define WTS_EVENT_RENAME 0x00000004 // existing WinStation renamed +#define WTS_EVENT_CONNECT 0x00000008 // WinStation connect to client +#define WTS_EVENT_DISCONNECT 0x00000010 // WinStation logged on without + // client +#define WTS_EVENT_LOGON 0x00000020 // user logged on to existing + // WinStation +#define WTS_EVENT_LOGOFF 0x00000040 // user logged off from + // existing WinStation +#define WTS_EVENT_STATECHANGE 0x00000080 // WinStation state change +#define WTS_EVENT_LICENSE 0x00000100 // license state change +#define WTS_EVENT_ALL 0x7fffffff // wait for all event types +#define WTS_EVENT_FLUSH 0x80000000 // unblock all waiters + +/*===================================================================== +== Flags for HotkeyModifiers in WTSStartRemoteControlSession +=====================================================================*/ + +#define REMOTECONTROL_KBDSHIFT_HOTKEY 0x1 // Shift key +#define REMOTECONTROL_KBDCTRL_HOTKEY 0x2 // Ctrl key +#define REMOTECONTROL_KBDALT_HOTKEY 0x4 // Alt key + +/*===================================================================== +== WTS_VIRTUAL_CLASS - WTSVirtualChannelQuery +=====================================================================*/ +typedef enum _WTS_VIRTUAL_CLASS { + WTSVirtualClientData, // Virtual channel client module data + // (C2H data) + WTSVirtualFileHandle +} WTS_VIRTUAL_CLASS; + +/*===================================================================== +== WTSQuerySessionInformation - (WTSSessionAddress) +=====================================================================*/ + +typedef struct _WTS_SESSION_ADDRESS { + DWORD AddressFamily; // AF_INET only. + BYTE Address[20]; // client network address +} WTS_SESSION_ADDRESS, * PWTS_SESSION_ADDRESS; + + +/*===================================================================== +== Windows Terminal Server public APIs +=====================================================================*/ + +BOOL WINPR_API +WTSStopRemoteControlSession( + ULONG LogonId + ); + +BOOL WINPR_API +WTSStartRemoteControlSessionW( + LPWSTR pTargetServerName, + ULONG TargetLogonId, + BYTE HotkeyVk, + USHORT HotkeyModifiers + ); + +BOOL WINPR_API +WTSStartRemoteControlSessionA( + LPSTR pTargetServerName, + ULONG TargetLogonId, + BYTE HotkeyVk, + USHORT HotkeyModifiers + ); + +#ifdef UNICODE +#define WTSStartRemoteControlSession WTSStartRemoteControlSessionW +#else +#define WTSStartRemoteControlSession WTSStartRemoteControlSessionA +#endif /* UNICODE */ + +BOOL +WINPR_API +WTSConnectSessionA( + ULONG LogonId, + ULONG TargetLogonId, + PSTR pPassword, + BOOL bWait + ); + +BOOL +WINPR_API +WTSConnectSessionW( + ULONG LogonId, + ULONG TargetLogonId, + PWSTR pPassword, + BOOL bWait + ); + +#ifdef UNICODE +#define WTSConnectSession WTSConnectSessionW +#else +#define WTSConnectSession WTSConnectSessionA +#endif + +BOOL +WINPR_API +WTSEnumerateServersW( + LPWSTR pDomainName, + DWORD Reserved, + DWORD Version, + PWTS_SERVER_INFOW * ppServerInfo, + DWORD * pCount + ); + +BOOL +WINPR_API +WTSEnumerateServersA( + LPSTR pDomainName, + DWORD Reserved, + DWORD Version, + PWTS_SERVER_INFOA * ppServerInfo, + DWORD * pCount + ); + +#ifdef UNICODE +#define WTSEnumerateServers WTSEnumerateServersW +#else +#define WTSEnumerateServers WTSEnumerateServersA +#endif + +/*------------------------------------------------*/ + +HANDLE +WINPR_API +WTSOpenServerW( + LPWSTR pServerName + ); + +HANDLE +WINPR_API +WTSOpenServerA( + LPSTR pServerName + ); + +HANDLE +WINPR_API +WTSOpenServerExW( + LPWSTR pServerName + ); + +HANDLE +WINPR_API +WTSOpenServerExA( + LPSTR pServerName + ); + +#ifdef UNICODE +#define WTSOpenServer WTSOpenServerW +#define WTSOpenServerEx WTSOpenServerExW +#else +#define WTSOpenServer WTSOpenServerA +#define WTSOpenServerEx WTSOpenServerExA +#endif + +/*------------------------------------------------*/ + +VOID +WINPR_API +WTSCloseServer( + HANDLE hServer + ); + +/*------------------------------------------------*/ + +BOOL +WINPR_API +WTSEnumerateSessionsW( + HANDLE hServer, + DWORD Reserved, + DWORD Version, + PWTS_SESSION_INFOW * ppSessionInfo, + DWORD * pCount + ); + +BOOL +WINPR_API +WTSEnumerateSessionsA( + HANDLE hServer, + DWORD Reserved, + DWORD Version, + PWTS_SESSION_INFOA * ppSessionInfo, + DWORD * pCount + ); + +BOOL +WINPR_API +WTSEnumerateSessionsExW( + HANDLE hServer, + DWORD *pLevel, + DWORD Filter, + PWTS_SESSION_INFO_1W * ppSessionInfo, + DWORD * pCount ); + +BOOL +WINPR_API +WTSEnumerateSessionsExA( + HANDLE hServer, + DWORD *pLevel, + DWORD Filter, + PWTS_SESSION_INFO_1A * ppSessionInfo, + DWORD * pCount ); + +#ifdef UNICODE +#define WTSEnumerateSessions WTSEnumerateSessionsW +#define WTSEnumerateSessionsEx WTSEnumerateSessionsExW +#else +#define WTSEnumerateSessions WTSEnumerateSessionsA +#define WTSEnumerateSessionsEx WTSEnumerateSessionsExA +#endif + +/*------------------------------------------------*/ + +BOOL +WINPR_API +WTSEnumerateProcessesW( + HANDLE hServer, + DWORD Reserved, + DWORD Version, + PWTS_PROCESS_INFOW * ppProcessInfo, + DWORD * pCount + ); + +BOOL +WINPR_API +WTSEnumerateProcessesA( + HANDLE hServer, + DWORD Reserved, + DWORD Version, + PWTS_PROCESS_INFOA * ppProcessInfo, + DWORD * pCount + ); + +#ifdef UNICODE +#define WTSEnumerateProcesses WTSEnumerateProcessesW +#else +#define WTSEnumerateProcesses WTSEnumerateProcessesA +#endif + +/*------------------------------------------------*/ + +BOOL +WINPR_API +WTSTerminateProcess( + HANDLE hServer, + DWORD ProcessId, + DWORD ExitCode + ); + + +/*------------------------------------------------*/ + +BOOL +WINPR_API +WTSQuerySessionInformationW( + HANDLE hServer, + DWORD SessionId, + WTS_INFO_CLASS WTSInfoClass, + LPWSTR * ppBuffer, + DWORD * pBytesReturned + ); + +BOOL +WINPR_API +WTSQuerySessionInformationA( + HANDLE hServer, + DWORD SessionId, + WTS_INFO_CLASS WTSInfoClass, + LPSTR * ppBuffer, + DWORD * pBytesReturned + ); + +#ifdef UNICODE +#define WTSQuerySessionInformation WTSQuerySessionInformationW +#else +#define WTSQuerySessionInformation WTSQuerySessionInformationA +#endif + +/*------------------------------------------------*/ + +BOOL +WINPR_API +WTSQueryUserConfigW( + LPWSTR pServerName, + LPWSTR pUserName, + WTS_CONFIG_CLASS WTSConfigClass, + LPWSTR * ppBuffer, + DWORD * pBytesReturned + ); + +BOOL +WINPR_API +WTSQueryUserConfigA( + LPSTR pServerName, + LPSTR pUserName, + WTS_CONFIG_CLASS WTSConfigClass, + LPSTR * ppBuffer, + DWORD * pBytesReturned + ); + +#ifdef UNICODE +#define WTSQueryUserConfig WTSQueryUserConfigW +#else +#define WTSQueryUserConfig WTSQueryUserConfigA +#endif + +/*------------------------------------------------*/ + +BOOL +WINPR_API +WTSSetUserConfigW( + LPWSTR pServerName, + LPWSTR pUserName, + WTS_CONFIG_CLASS WTSConfigClass, + LPWSTR pBuffer, + DWORD DataLength + ); + +BOOL +WINPR_API +WTSSetUserConfigA( + LPSTR pServerName, + LPSTR pUserName, + WTS_CONFIG_CLASS WTSConfigClass, + LPSTR pBuffer, + DWORD DataLength + ); + +#ifdef UNICODE +#define WTSSetUserConfig WTSSetUserConfigW +#else +#define WTSSetUserConfig WTSSetUserConfigA +#endif + +/*------------------------------------------------*/ + +BOOL +WINPR_API +WTSSendMessageW( + HANDLE hServer, + DWORD SessionId, + LPWSTR pTitle, + DWORD TitleLength, + LPWSTR pMessage, + DWORD MessageLength, + DWORD Style, + DWORD Timeout, + DWORD * pResponse, + BOOL bWait + ); + +BOOL +WINPR_API +WTSSendMessageA( + HANDLE hServer, + DWORD SessionId, + LPSTR pTitle, + DWORD TitleLength, + LPSTR pMessage, + DWORD MessageLength, + DWORD Style, + DWORD Timeout, + DWORD * pResponse, + BOOL bWait + ); + +#ifdef UNICODE +#define WTSSendMessage WTSSendMessageW +#else +#define WTSSendMessage WTSSendMessageA +#endif + +/*------------------------------------------------*/ + +BOOL +WINPR_API +WTSDisconnectSession( + HANDLE hServer, + DWORD SessionId, + BOOL bWait + ); + +/*------------------------------------------------*/ + +BOOL +WINPR_API +WTSLogoffSession( + HANDLE hServer, + DWORD SessionId, + BOOL bWait + ); + +/*------------------------------------------------*/ + +BOOL +WINPR_API +WTSShutdownSystem( + HANDLE hServer, + DWORD ShutdownFlag + ); + +/*------------------------------------------------*/ + +BOOL +WINPR_API +WTSWaitSystemEvent( + HANDLE hServer, + DWORD EventMask, + DWORD * pEventFlags + ); + +/*------------------------------------------------*/ + +HANDLE +WINPR_API +WTSVirtualChannelOpen( + HANDLE hServer, + DWORD SessionId, + LPSTR pVirtualName /* ascii name */ + ); + +#define WTS_CHANNEL_OPTION_DYNAMIC 0x00000001 // dynamic channel +#define WTS_CHANNEL_OPTION_DYNAMIC_PRI_LOW 0x00000000 // priorities +#define WTS_CHANNEL_OPTION_DYNAMIC_PRI_MED 0x00000002 +#define WTS_CHANNEL_OPTION_DYNAMIC_PRI_HIGH 0x00000004 +#define WTS_CHANNEL_OPTION_DYNAMIC_PRI_REAL 0x00000006 +#define WTS_CHANNEL_OPTION_DYNAMIC_NO_COMPRESS 0x00000008 + +HANDLE +WINPR_API +WTSVirtualChannelOpenEx( + DWORD SessionId, + LPSTR pVirtualName, /* ascii name */ + DWORD flags + ); + +BOOL +WINPR_API +WTSVirtualChannelClose( + HANDLE hChannelHandle + ); + +BOOL +WINPR_API +WTSVirtualChannelRead( + HANDLE hChannelHandle, + ULONG TimeOut, + PCHAR Buffer, + ULONG BufferSize, + PULONG pBytesRead + ); + +BOOL +WINPR_API +WTSVirtualChannelWrite( + HANDLE hChannelHandle, + PCHAR Buffer, + ULONG Length, + PULONG pBytesWritten + ); + +BOOL +WINPR_API +WTSVirtualChannelPurgeInput( + HANDLE hChannelHandle + ); + +BOOL +WINPR_API +WTSVirtualChannelPurgeOutput( + HANDLE hChannelHandle + ); + + +BOOL +WINPR_API +WTSVirtualChannelQuery( + HANDLE hChannelHandle, + WTS_VIRTUAL_CLASS, + PVOID *ppBuffer, + DWORD *pBytesReturned + ); + +/*------------------------------------------------*/ + + +VOID +WINPR_API +WTSFreeMemory( + PVOID pMemory + ); + +/* Flags for Console Notification */ + +#define NOTIFY_FOR_ALL_SESSIONS 1 +#define NOTIFY_FOR_THIS_SESSION 0 + + +BOOL +WINPR_API +WTSRegisterSessionNotification( + HWND hWnd, + DWORD dwFlags + ); + +BOOL +WINPR_API +WTSUnRegisterSessionNotification( + HWND hWnd + ); + + +BOOL +WINPR_API +WTSRegisterSessionNotificationEx( + HANDLE hServer, + HWND hWnd, + DWORD dwFlags + ); + +BOOL +WINPR_API +WTSUnRegisterSessionNotificationEx( + HANDLE hServer, + HWND hWnd + ); + +BOOL +WINPR_API +WTSQueryUserToken( + ULONG SessionId, + PHANDLE phToken + ); + +#define WTS_PROCESS_INFO_LEVEL_0 0 +#define WTS_PROCESS_INFO_LEVEL_1 1 + +/* +== WTS_PROCESS_INFO_EX - returned by WTSEnumerateProcessesEX +*/ + +typedef struct _WTS_PROCESS_INFO_EXW { + DWORD SessionId; + DWORD ProcessId; + LPWSTR pProcessName; + PSID pUserSid; + DWORD NumberOfThreads; + DWORD HandleCount; + DWORD PagefileUsage; + DWORD PeakPagefileUsage; + DWORD WorkingSetSize; + DWORD PeakWorkingSetSize; + LARGE_INTEGER UserTime; + LARGE_INTEGER KernelTime; +} WTS_PROCESS_INFO_EXW, * PWTS_PROCESS_INFO_EXW; + +typedef struct _WTS_PROCESS_INFO_EXA { + DWORD SessionId; + DWORD ProcessId; + LPSTR pProcessName; + PSID pUserSid; + DWORD NumberOfThreads; + DWORD HandleCount; + DWORD PagefileUsage; + DWORD PeakPagefileUsage; + DWORD WorkingSetSize; + DWORD PeakWorkingSetSize; + LARGE_INTEGER UserTime; + LARGE_INTEGER KernelTime; +} WTS_PROCESS_INFO_EXA, * PWTS_PROCESS_INFO_EXA; + +#ifdef UNICODE +#define WTS_PROCESS_INFO_EX WTS_PROCESS_INFO_EXW +#define PWTS_PROCESS_INFO_EX PWTS_PROCESS_INFO_EXW +#else +#define WTS_PROCESS_INFO_EX WTS_PROCESS_INFO_EXA +#define PWTS_PROCESS_INFO_EX PWTS_PROCESS_INFO_EXA +#endif + +/*------------------------------------------------*/ + +typedef enum _WTS_TYPE_CLASS { + WTSTypeProcessInfoLevel0, + WTSTypeProcessInfoLevel1, + WTSTypeSessionInfoLevel1, +} WTS_TYPE_CLASS; + +BOOL WINPR_API +WTSFreeMemoryExW( + WTS_TYPE_CLASS WTSTypeClass, + PVOID pMemory, + ULONG NumberOfEntries +); + +BOOL WINPR_API +WTSFreeMemoryExA( + WTS_TYPE_CLASS WTSTypeClass, + PVOID pMemory, + ULONG NumberOfEntries +); + +#ifdef UNICODE +#define WTSFreeMemoryEx WTSFreeMemoryExW +#else +#define WTSFreeMemoryEx WTSFreeMemoryExA +#endif + +/*------------------------------------------------*/ + +BOOL WINPR_API +WTSEnumerateProcessesExW +( + HANDLE hServer, + DWORD *pLevel, + DWORD SessionId, + LPWSTR *ppProcessInfo, + DWORD * pCount +); + +BOOL WINPR_API +WTSEnumerateProcessesExA +( + HANDLE hServer, + DWORD *pLevel, + DWORD SessionId, + LPSTR *ppProcessInfo, + DWORD * pCount +); + +#ifdef UNICODE +#define WTSEnumerateProcessesEx WTSEnumerateProcessesExW +#else +#define WTSEnumerateProcessesEx WTSEnumerateProcessesExA +#endif + + +/*------------------------------------------------*/ +// Listener management APIs + +typedef WCHAR WTSLISTENERNAMEW[WTS_LISTENER_NAME_LENGTH + 1 ]; +typedef WTSLISTENERNAMEW *PWTSLISTENERNAMEW; +typedef CHAR WTSLISTENERNAMEA[WTS_LISTENER_NAME_LENGTH + 1 ]; +typedef WTSLISTENERNAMEA *PWTSLISTENERNAMEA; + +#ifdef UNICODE +#define WTSLISTENERNAME WTSLISTENERNAMEW +#define PWTSLISTENERNAME PWTSLISTENERNAMEW +#else +#define WTSLISTENERNAME WTSLISTENERNAMEA +#define PWTSLISTENERNAME PWTSLISTENERNAMEW +#endif + +BOOL WINPR_API +WTSEnumerateListenersW ( + HANDLE hServer, + PVOID pReserved, + DWORD Reserved, + PWTSLISTENERNAMEW pListeners, + DWORD* pCount +); + +BOOL WINPR_API +WTSEnumerateListenersA ( + HANDLE hServer, + PVOID pReserved, + DWORD Reserved, + PWTSLISTENERNAMEA pListeners, + DWORD* pCount +); + +#ifdef UNICODE +#define WTSEnumerateListeners WTSEnumerateListenersW +#else +#define WTSEnumerateListeners WTSEnumerateListenersA +#endif + +/*------------------------------------------------*/ +// Listener Config, used by WTSQueryListenerConfig and WTSCreateListener + +typedef struct _WTSLISTENERCONFIGW{ + ULONG version; + ULONG fEnableListener; + ULONG MaxConnectionCount; + ULONG fPromptForPassword; + ULONG fInheritColorDepth; + ULONG ColorDepth; + ULONG fInheritBrokenTimeoutSettings; + ULONG BrokenTimeoutSettings; + + ULONG fDisablePrinterRedirection; + ULONG fDisableDriveRedirection; + ULONG fDisableComPortRedirection; + ULONG fDisableLPTPortRedirection; + ULONG fDisableClipboardRedirection; + ULONG fDisableAudioRedirection; + ULONG fDisablePNPRedirection; + ULONG fDisableDefaultMainClientPrinter; + + ULONG LanAdapter; + ULONG PortNumber; + + ULONG fInheritShadowSettings; + ULONG ShadowSettings; + + ULONG TimeoutSettingsConnection; + ULONG TimeoutSettingsDisconnection; + ULONG TimeoutSettingsIdle; + + ULONG SecurityLayer; + ULONG MinEncryptionLevel; + ULONG UserAuthentication; + + WCHAR Comment[ WTS_COMMENT_LENGTH + 1 ]; + WCHAR LogonUserName[USERNAME_LENGTH + 1 ]; + WCHAR LogonDomain[DOMAIN_LENGTH + 1 ]; + + WCHAR WorkDirectory[ MAX_PATH + 1 ]; + WCHAR InitialProgram[ MAX_PATH + 1 ]; +} WTSLISTENERCONFIGW, *PWTSLISTENERCONFIGW; + +typedef struct _WTSLISTENERCONFIGA{ + ULONG version; + ULONG fEnableListener; + ULONG MaxConnectionCount; + ULONG fPromptForPassword; + ULONG fInheritColorDepth; + ULONG ColorDepth; + ULONG fInheritBrokenTimeoutSettings; + ULONG BrokenTimeoutSettings; + + ULONG fDisablePrinterRedirection; + ULONG fDisableDriveRedirection; + ULONG fDisableComPortRedirection; + ULONG fDisableLPTPortRedirection; + ULONG fDisableClipboardRedirection; + ULONG fDisableAudioRedirection; + ULONG fDisablePNPRedirection; + ULONG fDisableDefaultMainClientPrinter; + + ULONG LanAdapter; + ULONG PortNumber; + + ULONG fInheritShadowSettings; + ULONG ShadowSettings; + + ULONG TimeoutSettingsConnection; + ULONG TimeoutSettingsDisconnection; + ULONG TimeoutSettingsIdle; + + ULONG SecurityLayer; + ULONG MinEncryptionLevel; + ULONG UserAuthentication; + + CHAR Comment[ WTS_COMMENT_LENGTH + 1 ]; + CHAR LogonUserName[USERNAME_LENGTH + 1 ]; + CHAR LogonDomain[DOMAIN_LENGTH + 1 ]; + + CHAR WorkDirectory[ MAX_PATH + 1 ]; + CHAR InitialProgram[ MAX_PATH + 1 ]; +} WTSLISTENERCONFIGA, *PWTSLISTENERCONFIGA; + +BOOL WINPR_API WTSQueryListenerConfigW ( + HANDLE hServer, + PVOID pReserved, + DWORD Reserved, + LPWSTR pListenerName, + PWTSLISTENERCONFIGW pBuffer +); + +BOOL WINPR_API WTSQueryListenerConfigA ( + HANDLE hServer, + PVOID pReserved, + DWORD Reserved, + LPSTR pListenerName, + PWTSLISTENERCONFIGA pBuffer +); + +BOOL WINPR_API WTSCreateListenerW ( + HANDLE hServer, + PVOID pReserved, + DWORD Reserved, + LPWSTR pListenerName, + PWTSLISTENERCONFIGW pBuffer, + DWORD flag +); + +BOOL WINPR_API WTSCreateListenerA ( + HANDLE hServer, + PVOID pReserved, + DWORD Reserved, + LPSTR pListenerName, + PWTSLISTENERCONFIGA pBuffer, + DWORD flag +); + +BOOL WINPR_API WTSSetListenerSecurityW( + HANDLE hServer, + PVOID pReserved, + DWORD Reserved, + LPWSTR pListenerName, + SECURITY_INFORMATION SecurityInformation, + PSECURITY_DESCRIPTOR pSecurityDescriptor); + +BOOL WINPR_API WTSSetListenerSecurityA( + HANDLE hServer, + PVOID pReserved, + DWORD Reserved, + LPSTR pListenerName, + SECURITY_INFORMATION SecurityInformation, + PSECURITY_DESCRIPTOR pSecurityDescriptor); + +BOOL WINPR_API WTSGetListenerSecurityW( + HANDLE hServer, + PVOID pReserved, + DWORD Reserved, + LPWSTR pListenerName, + SECURITY_INFORMATION SecurityInformation, + PSECURITY_DESCRIPTOR pSecurityDescriptor, + DWORD nLength, + LPDWORD lpnLengthNeeded); + + +BOOL WINPR_API WTSGetListenerSecurityA( + HANDLE hServer, + PVOID pReserved, + DWORD Reserved, + LPSTR pListenerName, + SECURITY_INFORMATION SecurityInformation, + PSECURITY_DESCRIPTOR pSecurityDescriptor, + DWORD nLength, + LPDWORD lpnLengthNeeded); + +#ifdef UNICODE +#define WTSLISTENERCONFIG WTSLISTENERCONFIGW +#define PWTSLISTENERCONFIG PWTSLISTENERCONFIGW +#define WTSQueryListenerConfig WTSQueryListenerConfigW +#define WTSCreateListener WTSCreateListenerW +#define WTSSetListenerSecurity WTSSetListenerSecurityW +#define WTSGetListenerSecurity WTSGetListenerSecurityW +#else +#define WTSLISTENERCONFIG WTSLISTENERCONFIGA +#define PWTSLISTENERCONFIG PWTSLISTENERCONFIGA +#define WTSQueryListenerConfig WTSQueryListenerConfigA +#define WTSCreateListener WTSCreateListenerA +#define WTSSetListenerSecurity WTSSetListenerSecurityA +#define WTSGetListenerSecurity WTSGetListenerSecurityA +#endif + +#ifdef __cplusplus +} +#endif + +#endif + +#endif + + diff --git a/winpr/libwinpr/wtsapi/CMakeLists.txt b/winpr/libwinpr/wtsapi/CMakeLists.txt new file mode 100644 index 000000000..19337721a --- /dev/null +++ b/winpr/libwinpr/wtsapi/CMakeLists.txt @@ -0,0 +1,36 @@ +# WinPR: Windows Portable Runtime +# libwinpr-winhttp cmake build script +# +# Copyright 2012 Marc-Andre Moreau +# +# 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. + +set(MODULE_NAME "winpr-wtsapi") +set(MODULE_PREFIX "WINPR_WTSAPI") + +set(${MODULE_PREFIX}_SRCS + wtsapi.c) + +add_complex_library(MODULE ${MODULE_NAME} TYPE "OBJECT" + MONOLITHIC ${MONOLITHIC_BUILD} + SOURCES ${${MODULE_PREFIX}_SRCS}) + +set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") + +if(MONOLITHIC_BUILD) + +else() + install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) +endif() + +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR") diff --git a/winpr/libwinpr/wtsapi/ModuleOptions.cmake b/winpr/libwinpr/wtsapi/ModuleOptions.cmake new file mode 100644 index 000000000..e0fa34d1b --- /dev/null +++ b/winpr/libwinpr/wtsapi/ModuleOptions.cmake @@ -0,0 +1,9 @@ + +set(MINWIN_LAYER "0") +set(MINWIN_GROUP "none") +set(MINWIN_MAJOR_VERSION "0") +set(MINWIN_MINOR_VERSION "0") +set(MINWIN_SHORT_NAME "winhttp") +set(MINWIN_LONG_NAME "Windows HTTP (WinHTTP)") +set(MODULE_LIBRARY_NAME "${MINWIN_SHORT_NAME}") + diff --git a/winpr/libwinpr/wtsapi/wtsapi.c b/winpr/libwinpr/wtsapi/wtsapi.c new file mode 100644 index 000000000..0efd97d42 --- /dev/null +++ b/winpr/libwinpr/wtsapi/wtsapi.c @@ -0,0 +1,506 @@ +/** + * WinPR: Windows Portable Runtime + * Windows Terminal Services API (WTSAPI) + * + * Copyright 2013 Mike McDonald + * + * 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. + */ + +#include + +BOOL WINPR_API ProcessIdToSessionId( + DWORD ProcessId, + DWORD *pSessionId +) +{ + return FALSE; +} + +VOID WINPR_API WTSCloseServer( + HANDLE hServer +) +{ +} + +BOOL WINPR_API WTSConnectSession( + ULONG LoginId, + ULONG TargetLogonId, + PSTR pPassword, + BOOL bWait +) +{ + return FALSE; +} + +BOOL WINPR_API WTSCreateListener( + HANDLE hServer, + PVOID pReserved, + DWORD Reserved, + LPTSTR pListenerName, + PWTSLISTENERCONFIG pBuffer, + DWORD flag +) +{ + return FALSE; +} + +BOOL WINPR_API WTSDisconnectSession( + HANDLE hServer, + DWORD SessionId, + BOOL bWait +) +{ + return FALSE; +} + +BOOL WINPR_API WTSEnableChildSessions( + BOOL bEnable +) +{ + return FALSE; +} + +BOOL WINPR_API WTSEnumerateListenersA( + HANDLE hServer, + PVOID pReserved, + DWORD Reserved, + PWTSLISTENERNAMEA pListeners, + DWORD *pCount +) +{ + return FALSE; +} + +BOOL WINPR_API WTSEnumerateListenersW( + HANDLE hServer, + PVOID pReserved, + DWORD Reserved, + PWTSLISTENERNAMEW pListeners, + DWORD *pCount +) +{ + return FALSE; +} + +BOOL WINPR_API WTSEnumerateProcesses( + HANDLE hServer, + DWORD Reserved, + DWORD Version, + PWTS_PROCESS_INFO *ppProcessInfo, + DWORD *pCount +) +{ + return FALSE; +} + +BOOL WINPR_API WTSEnumerateProcessesEx( + HANDLE hServer, + DWORD *pLevel, + DWORD SessionId, + LPTSTR *ppProcessInfo, + DWORD *pCount +) +{ + return FALSE; +} + +BOOL WINPR_API WTSEnumerateServers( + LPTSTR pDomainName, + DWORD Reserved, + DWORD Version, + PWTS_SERVER_INFO *ppServerInfo, + DWORD *pCount +) +{ + return FALSE; +} + +BOOL WINPR_API WTSEnumerateSessionsA( + HANDLE hServer, + DWORD Reserved, + DWORD Version, + PWTS_SESSION_INFOA *ppSessionInfo, + DWORD *pCount +) +{ + return FALSE; +} + +BOOL WINPR_API WTSEnumerateSessionsW( + HANDLE hServer, + DWORD Reserved, + DWORD Version, + PWTS_SESSION_INFOW *ppSessionInfo, + DWORD *pCount +) +{ + return FALSE; +} + +BOOL WINPR_API WTSEnumerateSessionsExA( + HANDLE hServer, + DWORD *pLevel, + DWORD Filter, + PWTS_SESSION_INFO_1A *ppSessionInfo, + DWORD *pCount +) +{ + return FALSE; +} + +BOOL WINPR_API WTSEnumerateSessionsExW( + HANDLE hServer, + DWORD *pLevel, + DWORD Filter, + PWTS_SESSION_INFO_1W *ppSessionInfo, + DWORD *pCount +) +{ + return FALSE; +} + +VOID WTSFreeMemory( + PVOID pMemory +) +{ +} + +BOOL WINPR_API WTSFreeMemoryEx( + WTS_TYPE_CLASS WTSTypeClass, + PVOID pMemory, + ULONG NumberOfEntries +) +{ + return FALSE; +} + +DWORD WINPR_API WTSGetActiveConsoleSessionId() +{ + return 0; +} + +BOOL WINPR_API WTSGetChildSessionId( + DWORD *pSessionId +) +{ + return FALSE; +} + +BOOL WINPR_API WTSGetListenerSecurityA( + HANDLE hServer, + PVOID pReserved, + DWORD Reserved, + LPSTR pListenerName, + SECURITY_INFORMATION SecurityInformation, + PSECURITY_DESCRIPTOR pSecurityDescriptor, + DWORD nLength, + LPDWORD lpnLengthNeeded +) +{ + return FALSE; +} + +BOOL WINPR_API WTSGetListenerSecurityW( + HANDLE hServer, + PVOID pReserved, + DWORD Reserved, + LPWSTR pListenerName, + SECURITY_INFORMATION SecurityInformation, + PSECURITY_DESCRIPTOR pSecurityDescriptor, + DWORD nLength, + LPDWORD lpnLengthNeeded +) +{ + return FALSE; +} + +BOOL WINPR_API WTSIsChildSessionsEnabled( + BOOL *pbEnabled +) +{ + return FALSE; +} + +BOOL WINPR_API WTSLogoffSession( + HANDLE hServer, + DWORD SessionId, + BOOL bWait +) +{ + return FALSE; +} + +HANDLE WINPR_API WTSOpenServer( + LPTSTR pServerName +) +{ + return NULL; +} + +HANDLE WINPR_API WTSOpenServerExA( + LPSTR pServerName +) +{ + return NULL; +} + +HANDLE WINPR_API WTSOpenServerExW( + LPWSTR pServerName +) +{ + return NULL; +} + +BOOL WINPR_API WTSQueryListenerConfig( + HANDLE hServer, + PVOID pReserved, + DWORD Reserved, + LPTSTR pListenerName, + PWTSLISTENERCONFIG pBuffer +) +{ + return FALSE; +} + +BOOL WINPR_API WTSQuerySessionInformation( + HANDLE hServer, + DWORD SessionId, + WTS_INFO_CLASS WTSInfoClass, + LPTSTR *ppBuffer, + DWORD *pBytesReturned +) +{ + return FALSE; +} + +BOOL WINPR_API WTSQueryUserConfig( + LPTSTR pServerName, + LPTSTR pUserName, + WTS_CONFIG_CLASS WTSConfigClass, + LPTSTR *ppBuffer, + DWORD *pBytesReturned +) +{ + return FALSE; +} + +BOOL WINPR_API WTSQueryUserToken( + DWORD SessionId, + PHANDLE phToken +) +{ + return FALSE; +} + +BOOL WINPR_API WTSRegisterSessionNotification( + HWND hWnd, + DWORD dwFlags +) +{ + return FALSE; +} + +BOOL WINPR_API WTSRegisterSessionNotificationEx( + HANDLE hServer, + HWND hWnd, + DWORD dwFlags +) +{ + return FALSE; +} + +BOOL WINPR_API WTSSendMessage( + HANDLE hServer, + DWORD SessionId, + LPTSTR pTitle, + DWORD TitleLength, + LPTSTR pMessage, + DWORD MessageLength, + DWORD Style, + DWORD Timeout, + DWORD *pResponse, + BOOL bWait +) +{ + return FALSE; +} + +BOOL WINPR_API WTSSetListenerSecurity( + HANDLE hServer, + PVOID pReserved, + DWORD Reserved, + LPTSTR pListenerName, + SECURITY_INFORMATION SecurityInformation, + PSECURITY_DESCRIPTOR pSecurityDescriptor +) +{ + return FALSE; +} + +BOOL WINPR_API WTSSetUserConfig( + LPTSTR pServerName, + LPTSTR pUserName, + WTS_CONFIG_CLASS WTSConfigClass, + LPTSTR pBuffer, + DWORD DataLength +) +{ + return FALSE; +} + +BOOL WINPR_API WTSShutdownSystem( + HANDLE hServer, + DWORD ShutdownFlag +) +{ + return FALSE; +} + +BOOL WINPR_API WTSStartRemoteControlSession( + LPTSTR pTargetServerName, + ULONG TargetLogonId, + BYTE HotkeyVk, + USHORT HotKeyModifiers +) +{ + return FALSE; +} + +BOOL WINPR_API WTSStopRemoteControlSession( + ULONG LogonId +) +{ + return FALSE; +} + +BOOL WINPR_API WTSTerminateProcess( + HANDLE hServer, + DWORD ProcessId, + DWORD ExitCode +) +{ + return FALSE; +} + +BOOL WINPR_API WTSUnregisterSessionNotification( + HWND hWnd +) +{ + return FALSE; +} + +BOOL WINPR_API WTSUnregisterSessionNotificationEx( + HANDLE hServer, + HWND hWnd +) +{ + return FALSE; +} + +BOOL WINPR_API WTSVirtualChannelClose( + HANDLE hChannelHandle +) +{ + return FALSE; +} + +BOOL WINPR_API WTSVirtualChannelOpenA( + HANDLE hServer, + DWORD SessionId, + LPSTR pVirtualName +) +{ + return FALSE; +} + +BOOL WINPR_API WTSVirtualChannelOpenW( + HANDLE hServer, + DWORD SessionId, + LPWSTR pVirtualName +) +{ + return FALSE; +} + +BOOL WINPR_API WTSVirtualChannelOpenExA( + DWORD SessionId, + LPSTR pVirtualName, + DWORD Flags +) +{ + return FALSE; +} + +BOOL WINPR_API WTSVirtualChannelOpenExW( + DWORD SessionId, + LPWSTR pVirtualName, + DWORD Flags +) +{ + return FALSE; +} + +BOOL WINPR_API WTSVirtualChannelPurgeInput( + HANDLE hChannelHandle +) +{ + return FALSE; +} + +BOOL WINPR_API WTSVirtualChannelPurgeOutput( + HANDLE hChannelHandle +) +{ + return FALSE; +} + +BOOL WINPR_API WTSVirtualChannelQuery( + HANDLE hChannelHandle, + WTS_VIRTUAL_CLASS WTSVirtualClass, + PVOID *ppBuffer, + DWORD *pBytesReturned +) +{ + return FALSE; +} + +BOOL WINPR_API WTSVirtualChannelRead( + HANDLE hChannelHandle, + ULONG TimeOut, + PCHAR Buffer, + ULONG BufferSize, + PULONG pBytesRead +) +{ + return FALSE; +} + +BOOL WINPR_API WTSVirtualChannelWrite( + HANDLE hChannelHandle, + PCHAR Buffer, + ULONG BufferSize, + PULONG pBytesWritten +) +{ + return FALSE; +} + +BOOL WINPR_API WTSWaitSystemEvent( + HANDLE hServer, + DWORD EventMask, + DWORD *pEventFlags +) +{ + return FALSE; +} From 772f738c47cd285197013fff1ea766233a582065 Mon Sep 17 00:00:00 2001 From: Mike McDonald Date: Wed, 28 Aug 2013 21:02:48 -0400 Subject: [PATCH 2/5] Added RDPSND device plugin for iOS --- channels/rdpsnd/client/ios/CMakeLists.txt | 52 +++ channels/rdpsnd/client/ios/TPCircularBuffer.c | 136 ++++++++ channels/rdpsnd/client/ios/TPCircularBuffer.h | 195 ++++++++++++ channels/rdpsnd/client/ios/rdpsnd_ios.c | 300 ++++++++++++++++++ 4 files changed, 683 insertions(+) create mode 100644 channels/rdpsnd/client/ios/CMakeLists.txt create mode 100644 channels/rdpsnd/client/ios/TPCircularBuffer.c create mode 100644 channels/rdpsnd/client/ios/TPCircularBuffer.h create mode 100644 channels/rdpsnd/client/ios/rdpsnd_ios.c diff --git a/channels/rdpsnd/client/ios/CMakeLists.txt b/channels/rdpsnd/client/ios/CMakeLists.txt new file mode 100644 index 000000000..2db67b285 --- /dev/null +++ b/channels/rdpsnd/client/ios/CMakeLists.txt @@ -0,0 +1,52 @@ +# FreeRDP: A Remote Desktop Protocol Implementation +# FreeRDP cmake build script +# +# Copyright 2012 Laxmikant Rashinkar +# Copyright 2012 Marc-Andre Moreau +# Copyright 2013 Corey Clayton +# +# 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. + +define_channel_client_subsystem("rdpsnd" "ios" "") + +FIND_LIBRARY(CORE_AUDIO CoreAudio) +FIND_LIBRARY(AUDIO_TOOL AudioToolbox) +FIND_LIBRARY(CORE_FOUNDATION CoreFoundation) + +set(${MODULE_PREFIX}_SRCS + rdpsnd_ios.c + TPCircularBuffer.c) + +include_directories(..) + +add_channel_client_subsystem_library(${MODULE_PREFIX} ${MODULE_NAME} ${CHANNEL_NAME} "" TRUE "") + +set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "") + +set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS + MONOLITHIC ${MONOLITHIC_BUILD} + MODULE freerdp + MODULES freerdp-utils) + +set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} + ${AUDIO_TOOL} + ${CORE_AUDIO} + ${CORE_FOUNDATION}) + +target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) + +if(NOT STATIC_CHANNELS) + install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH}) +endif() + +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Channels/${CHANNEL_NAME}/Client/ios") diff --git a/channels/rdpsnd/client/ios/TPCircularBuffer.c b/channels/rdpsnd/client/ios/TPCircularBuffer.c new file mode 100644 index 000000000..d9e049ad2 --- /dev/null +++ b/channels/rdpsnd/client/ios/TPCircularBuffer.c @@ -0,0 +1,136 @@ +// +// TPCircularBuffer.c +// Circular/Ring buffer implementation +// +// https://github.com/michaeltyson/TPCircularBuffer +// +// Created by Michael Tyson on 10/12/2011. +// +// Copyright (C) 2012-2013 A Tasty Pixel +// +// This software is provided 'as-is', without any express or implied +// warranty. In no event will the authors be held liable for any damages +// arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it +// freely, subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; you must not +// claim that you wrote the original software. If you use this software +// in a product, an acknowledgment in the product documentation would be +// appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, and must not be +// misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// + +#include "TPCircularBuffer.h" +#include +#include + +#define reportResult(result,operation) (_reportResult((result),(operation),strrchr(__FILE__, '/')+1,__LINE__)) +static inline bool _reportResult(kern_return_t result, const char *operation, const char* file, int line) { + if ( result != ERR_SUCCESS ) { + printf("%s:%d: %s: %s\n", file, line, operation, mach_error_string(result)); + return false; + } + return true; +} + +bool TPCircularBufferInit(TPCircularBuffer *buffer, int length) { + + // Keep trying until we get our buffer, needed to handle race conditions + int retries = 3; + while ( true ) { + + buffer->length = round_page(length); // We need whole page sizes + + // Temporarily allocate twice the length, so we have the contiguous address space to + // support a second instance of the buffer directly after + vm_address_t bufferAddress; + kern_return_t result = vm_allocate(mach_task_self(), + &bufferAddress, + buffer->length * 2, + VM_FLAGS_ANYWHERE); // allocate anywhere it'll fit + if ( result != ERR_SUCCESS ) { + if ( retries-- == 0 ) { + reportResult(result, "Buffer allocation"); + return false; + } + // Try again if we fail + continue; + } + + // Now replace the second half of the allocation with a virtual copy of the first half. Deallocate the second half... + result = vm_deallocate(mach_task_self(), + bufferAddress + buffer->length, + buffer->length); + if ( result != ERR_SUCCESS ) { + if ( retries-- == 0 ) { + reportResult(result, "Buffer deallocation"); + return false; + } + // If this fails somehow, deallocate the whole region and try again + vm_deallocate(mach_task_self(), bufferAddress, buffer->length); + continue; + } + + // Re-map the buffer to the address space immediately after the buffer + vm_address_t virtualAddress = bufferAddress + buffer->length; + vm_prot_t cur_prot, max_prot; + result = vm_remap(mach_task_self(), + &virtualAddress, // mirror target + buffer->length, // size of mirror + 0, // auto alignment + 0, // force remapping to virtualAddress + mach_task_self(), // same task + bufferAddress, // mirror source + 0, // MAP READ-WRITE, NOT COPY + &cur_prot, // unused protection struct + &max_prot, // unused protection struct + VM_INHERIT_DEFAULT); + if ( result != ERR_SUCCESS ) { + if ( retries-- == 0 ) { + reportResult(result, "Remap buffer memory"); + return false; + } + // If this remap failed, we hit a race condition, so deallocate and try again + vm_deallocate(mach_task_self(), bufferAddress, buffer->length); + continue; + } + + if ( virtualAddress != bufferAddress+buffer->length ) { + // If the memory is not contiguous, clean up both allocated buffers and try again + if ( retries-- == 0 ) { + printf("Couldn't map buffer memory to end of buffer\n"); + return false; + } + + vm_deallocate(mach_task_self(), virtualAddress, buffer->length); + vm_deallocate(mach_task_self(), bufferAddress, buffer->length); + continue; + } + + buffer->buffer = (void*)bufferAddress; + buffer->fillCount = 0; + buffer->head = buffer->tail = 0; + + return true; + } + return false; +} + +void TPCircularBufferCleanup(TPCircularBuffer *buffer) { + vm_deallocate(mach_task_self(), (vm_address_t)buffer->buffer, buffer->length * 2); + memset(buffer, 0, sizeof(TPCircularBuffer)); +} + +void TPCircularBufferClear(TPCircularBuffer *buffer) { + int32_t fillCount; + if ( TPCircularBufferTail(buffer, &fillCount) ) { + TPCircularBufferConsume(buffer, fillCount); + } +} diff --git a/channels/rdpsnd/client/ios/TPCircularBuffer.h b/channels/rdpsnd/client/ios/TPCircularBuffer.h new file mode 100644 index 000000000..cd2a4d837 --- /dev/null +++ b/channels/rdpsnd/client/ios/TPCircularBuffer.h @@ -0,0 +1,195 @@ +// +// TPCircularBuffer.h +// Circular/Ring buffer implementation +// +// https://github.com/michaeltyson/TPCircularBuffer +// +// Created by Michael Tyson on 10/12/2011. +// +// +// This implementation makes use of a virtual memory mapping technique that inserts a virtual copy +// of the buffer memory directly after the buffer's end, negating the need for any buffer wrap-around +// logic. Clients can simply use the returned memory address as if it were contiguous space. +// +// The implementation is thread-safe in the case of a single producer and single consumer. +// +// Virtual memory technique originally proposed by Philip Howard (http://vrb.slashusr.org/), and +// adapted to Darwin by Kurt Revis (http://www.snoize.com, +// http://www.snoize.com/Code/PlayBufferedSoundFile.tar.gz) +// +// +// Copyright (C) 2012-2013 A Tasty Pixel +// +// This software is provided 'as-is', without any express or implied +// warranty. In no event will the authors be held liable for any damages +// arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it +// freely, subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; you must not +// claim that you wrote the original software. If you use this software +// in a product, an acknowledgment in the product documentation would be +// appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, and must not be +// misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// + +#ifndef TPCircularBuffer_h +#define TPCircularBuffer_h + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + void *buffer; + int32_t length; + int32_t tail; + int32_t head; + volatile int32_t fillCount; +} TPCircularBuffer; + +/*! + * Initialise buffer + * + * Note that the length is advisory only: Because of the way the + * memory mirroring technique works, the true buffer length will + * be multiples of the device page size (e.g. 4096 bytes) + * + * @param buffer Circular buffer + * @param length Length of buffer + */ +bool TPCircularBufferInit(TPCircularBuffer *buffer, int32_t length); + +/*! + * Cleanup buffer + * + * Releases buffer resources. + */ +void TPCircularBufferCleanup(TPCircularBuffer *buffer); + +/*! + * Clear buffer + * + * Resets buffer to original, empty state. + * + * This is safe for use by consumer while producer is accessing + * buffer. + */ +void TPCircularBufferClear(TPCircularBuffer *buffer); + +// Reading (consuming) + +/*! + * Access end of buffer + * + * This gives you a pointer to the end of the buffer, ready + * for reading, and the number of available bytes to read. + * + * @param buffer Circular buffer + * @param availableBytes On output, the number of bytes ready for reading + * @return Pointer to the first bytes ready for reading, or NULL if buffer is empty + */ +static __inline__ __attribute__((always_inline)) void* TPCircularBufferTail(TPCircularBuffer *buffer, int32_t* availableBytes) { + *availableBytes = buffer->fillCount; + if ( *availableBytes == 0 ) return NULL; + return (void*)((char*)buffer->buffer + buffer->tail); +} + +/*! + * Consume bytes in buffer + * + * This frees up the just-read bytes, ready for writing again. + * + * @param buffer Circular buffer + * @param amount Number of bytes to consume + */ +static __inline__ __attribute__((always_inline)) void TPCircularBufferConsume(TPCircularBuffer *buffer, int32_t amount) { + buffer->tail = (buffer->tail + amount) % buffer->length; + OSAtomicAdd32Barrier(-amount, &buffer->fillCount); + assert(buffer->fillCount >= 0); +} + +/*! + * Version of TPCircularBufferConsume without the memory barrier, for more optimal use in single-threaded contexts + */ +static __inline__ __attribute__((always_inline)) void TPCircularBufferConsumeNoBarrier(TPCircularBuffer *buffer, int32_t amount) { + buffer->tail = (buffer->tail + amount) % buffer->length; + buffer->fillCount -= amount; + assert(buffer->fillCount >= 0); +} + +/*! + * Access front of buffer + * + * This gives you a pointer to the front of the buffer, ready + * for writing, and the number of available bytes to write. + * + * @param buffer Circular buffer + * @param availableBytes On output, the number of bytes ready for writing + * @return Pointer to the first bytes ready for writing, or NULL if buffer is full + */ +static __inline__ __attribute__((always_inline)) void* TPCircularBufferHead(TPCircularBuffer *buffer, int32_t* availableBytes) { + *availableBytes = (buffer->length - buffer->fillCount); + if ( *availableBytes == 0 ) return NULL; + return (void*)((char*)buffer->buffer + buffer->head); +} + +// Writing (producing) + +/*! + * Produce bytes in buffer + * + * This marks the given section of the buffer ready for reading. + * + * @param buffer Circular buffer + * @param amount Number of bytes to produce + */ +static __inline__ __attribute__((always_inline)) void TPCircularBufferProduce(TPCircularBuffer *buffer, int amount) { + buffer->head = (buffer->head + amount) % buffer->length; + OSAtomicAdd32Barrier(amount, &buffer->fillCount); + assert(buffer->fillCount <= buffer->length); +} + +/*! + * Version of TPCircularBufferProduce without the memory barrier, for more optimal use in single-threaded contexts + */ +static __inline__ __attribute__((always_inline)) void TPCircularBufferProduceNoBarrier(TPCircularBuffer *buffer, int amount) { + buffer->head = (buffer->head + amount) % buffer->length; + buffer->fillCount += amount; + assert(buffer->fillCount <= buffer->length); +} + +/*! + * Helper routine to copy bytes to buffer + * + * This copies the given bytes to the buffer, and marks them ready for writing. + * + * @param buffer Circular buffer + * @param src Source buffer + * @param len Number of bytes in source buffer + * @return true if bytes copied, false if there was insufficient space + */ +static __inline__ __attribute__((always_inline)) bool TPCircularBufferProduceBytes(TPCircularBuffer *buffer, const void* src, int32_t len) { + int32_t space; + void *ptr = TPCircularBufferHead(buffer, &space); + if ( space < len ) return false; + memcpy(ptr, src, len); + TPCircularBufferProduce(buffer, len); + return true; +} + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/channels/rdpsnd/client/ios/rdpsnd_ios.c b/channels/rdpsnd/client/ios/rdpsnd_ios.c new file mode 100644 index 000000000..60d6b9655 --- /dev/null +++ b/channels/rdpsnd/client/ios/rdpsnd_ios.c @@ -0,0 +1,300 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Audio Output Virtual Channel + * + * Copyright 2013 Dell Software + * + * 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 + +#include +#include +#include + +#import + +#include "rdpsnd_main.h" +#include "TPCircularBuffer.h" + +#define INPUT_BUFFER_SIZE 32768 +#define CIRCULAR_BUFFER_SIZE (INPUT_BUFFER_SIZE * 4) + +typedef struct rdpsnd_ios_plugin +{ + rdpsndDevicePlugin device; + AudioComponentInstance audio_unit; + TPCircularBuffer buffer; + BOOL is_opened; + BOOL is_playing; +} rdpsndIOSPlugin; + +#define THIS(__ptr) ((rdpsndIOSPlugin*)__ptr) + +static OSStatus rdpsnd_ios_render_cb( + void *inRefCon, + AudioUnitRenderActionFlags __unused *ioActionFlags, + const AudioTimeStamp __unused *inTimeStamp, + UInt32 inBusNumber, + UInt32 __unused inNumberFrames, + AudioBufferList *ioData +) +{ + unsigned int i; + + if (inBusNumber != 0) + { + return noErr; + }; + + rdpsndIOSPlugin *p = THIS(inRefCon); + + for (i = 0; i < ioData->mNumberBuffers; i++) + { + AudioBuffer* target_buffer = &ioData->mBuffers[i]; + + int32_t available_bytes = 0; + const void *buffer = TPCircularBufferTail(&p->buffer, &available_bytes); + if (buffer != NULL && available_bytes > 0) + { + const int bytes_to_copy = MIN((int32_t)target_buffer->mDataByteSize, available_bytes); + + memcpy(target_buffer->mData, buffer, bytes_to_copy); + target_buffer->mDataByteSize = bytes_to_copy; + + TPCircularBufferConsume(&p->buffer, bytes_to_copy); + } + else + { + target_buffer->mDataByteSize = 0; + AudioOutputUnitStop(p->audio_unit); + p->is_playing = 0; + }; + }; + + return noErr; +} + +static BOOL rdpsnd_ios_format_supported(rdpsndDevicePlugin* __unused device, AUDIO_FORMAT* format) +{ + if (format->wFormatTag == WAVE_FORMAT_PCM) + { + return 1; + } + return 0; +} + +static void rdpsnd_ios_set_format(rdpsndDevicePlugin* __unused device, AUDIO_FORMAT* __unused format, int __unused latency) +{ +} + +static void rdpsnd_ios_set_volume(rdpsndDevicePlugin* __unused device, UINT32 __unused value) +{ +} + +static void rdpsnd_ios_start(rdpsndDevicePlugin* device) +{ + rdpsndIOSPlugin *p = THIS(device); + + /* If this device is not playing... */ + if (!p->is_playing) + { + /* Start the device. */ + int32_t available_bytes = 0; + TPCircularBufferTail(&p->buffer, &available_bytes); + if (available_bytes > 0) + { + p->is_playing = 1; + AudioOutputUnitStart(p->audio_unit); + } + } +} + +static void rdpsnd_ios_stop(rdpsndDevicePlugin* __unused device) +{ + rdpsndIOSPlugin *p = THIS(device); + + /* If the device is playing... */ + if (p->is_playing) + { + /* Stop the device. */ + AudioOutputUnitStop(p->audio_unit); + p->is_playing = 0; + + /* Free all buffers. */ + TPCircularBufferClear(&p->buffer); + }; +} + +static void rdpsnd_ios_play(rdpsndDevicePlugin* device, BYTE* data, int size) +{ + rdpsndIOSPlugin *p = THIS(device); + + const BOOL ok = TPCircularBufferProduceBytes(&p->buffer, data, size); + if (!ok) + { + return; + } + + rdpsnd_ios_start(device); + +} + +static void rdpsnd_ios_open(rdpsndDevicePlugin* device, AUDIO_FORMAT* format, int __unused latency) +{ + rdpsndIOSPlugin *p = THIS(device); + + if (p->is_opened) + { + return; + }; + + /* Find the output audio unit. */ + AudioComponentDescription desc; + desc.componentManufacturer = kAudioUnitManufacturer_Apple; + desc.componentType = kAudioUnitType_Output; + desc.componentSubType = kAudioUnitSubType_RemoteIO; + desc.componentFlags = 0; + desc.componentFlagsMask = 0; + + AudioComponent audioComponent = AudioComponentFindNext(NULL, &desc); + if (audioComponent == NULL) return; + + /* Open the audio unit. */ + OSStatus status = AudioComponentInstanceNew(audioComponent, &p->audio_unit); + if (status != 0) return; + + /* Set the format for the AudioUnit. */ + AudioStreamBasicDescription audioFormat = {0}; + audioFormat.mSampleRate = format->nSamplesPerSec; + audioFormat.mFormatID = kAudioFormatLinearPCM; + audioFormat.mFormatFlags = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked; + audioFormat.mFramesPerPacket = 1; /* imminent property of the Linear PCM */ + audioFormat.mChannelsPerFrame = format->nChannels; + audioFormat.mBitsPerChannel = format->wBitsPerSample; + audioFormat.mBytesPerFrame = (format->wBitsPerSample * format->nChannels) / 8; + audioFormat.mBytesPerPacket = audioFormat.mBytesPerFrame * audioFormat.mFramesPerPacket; + + status = AudioUnitSetProperty( + p->audio_unit, + kAudioUnitProperty_StreamFormat, + kAudioUnitScope_Input, + 0, + &audioFormat, + sizeof(audioFormat)); + if (status != 0) + { + AudioComponentInstanceDispose(p->audio_unit); + p->audio_unit = NULL; + return; + } + + /* Set up the AudioUnit callback. */ + AURenderCallbackStruct callbackStruct = {0}; + callbackStruct.inputProc = rdpsnd_ios_render_cb; + callbackStruct.inputProcRefCon = p; + status = AudioUnitSetProperty( + p->audio_unit, + kAudioUnitProperty_SetRenderCallback, + kAudioUnitScope_Input, + 0, + &callbackStruct, + sizeof(callbackStruct)); + if (status != 0) + { + AudioComponentInstanceDispose(p->audio_unit); + p->audio_unit = NULL; + return; + } + + /* Initialize the AudioUnit. */ + status = AudioUnitInitialize(p->audio_unit); + if (status != 0) + { + AudioComponentInstanceDispose(p->audio_unit); + p->audio_unit = NULL; + return; + } + + /* Allocate the circular buffer. */ + const BOOL ok = TPCircularBufferInit(&p->buffer, CIRCULAR_BUFFER_SIZE); + if (!ok) + { + AudioUnitUninitialize(p->audio_unit); + AudioComponentInstanceDispose(p->audio_unit); + p->audio_unit = NULL; + return; + } + + p->is_opened = 1; +} + +static void rdpsnd_ios_close(rdpsndDevicePlugin* device) +{ + rdpsndIOSPlugin *p = THIS(device); + + /* Make sure the device is stopped. */ + rdpsnd_ios_stop(device); + + /* If the device is open... */ + if (p->is_opened) + { + /* Close the device. */ + AudioUnitUninitialize(p->audio_unit); + AudioComponentInstanceDispose(p->audio_unit); + p->audio_unit = NULL; + p->is_opened = 0; + + /* Destroy the circular buffer. */ + TPCircularBufferCleanup(&p->buffer); + } +} + +static void rdpsnd_ios_free(rdpsndDevicePlugin* device) +{ + rdpsndIOSPlugin *p = THIS(device); + + /* Ensure the device is closed. */ + rdpsnd_ios_close(device); + + /* Free memory associated with the device. */ + free(p); +} + +#ifdef STATIC_CHANNELS +#define freerdp_rdpsnd_client_subsystem_entry ios_freerdp_rdpsnd_client_subsystem_entry +#endif + +int freerdp_rdpsnd_client_subsystem_entry(PFREERDP_RDPSND_DEVICE_ENTRY_POINTS pEntryPoints) +{ + rdpsndIOSPlugin *p = (rdpsndIOSPlugin*)malloc(sizeof(rdpsndIOSPlugin)); + memset(p, 0, sizeof(rdpsndIOSPlugin)); + + p->device.Open = rdpsnd_ios_open; + p->device.FormatSupported = rdpsnd_ios_format_supported; + p->device.SetFormat = rdpsnd_ios_set_format; + p->device.SetVolume = rdpsnd_ios_set_volume; + p->device.Play = rdpsnd_ios_play; + p->device.Start = rdpsnd_ios_start; + p->device.Close = rdpsnd_ios_close; + p->device.Free = rdpsnd_ios_free; + + pEntryPoints->pRegisterRdpsndDevice(pEntryPoints->rdpsnd, (rdpsndDevicePlugin*)p); + + return 0; +} \ No newline at end of file From cfe90ae82901b9688c6c4e21a30347abbfb1b40f Mon Sep 17 00:00:00 2001 From: Mike McDonald Date: Wed, 28 Aug 2013 21:03:34 -0400 Subject: [PATCH 3/5] Added RDPSND device plugin for iOS --- channels/rdpsnd/client/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/channels/rdpsnd/client/CMakeLists.txt b/channels/rdpsnd/client/CMakeLists.txt index 63c439548..54f3749a4 100644 --- a/channels/rdpsnd/client/CMakeLists.txt +++ b/channels/rdpsnd/client/CMakeLists.txt @@ -43,6 +43,10 @@ if(WITH_ALSA) add_channel_client_subsystem(${MODULE_PREFIX} ${CHANNEL_NAME} "alsa" "") endif() +if(WITH_IOSAUDIO) + add_channel_client_subsystem($(MODULE_PREFIX) $(CHANNEL_NAME) "ios" "") +endif() + if(WITH_PULSE) add_channel_client_subsystem(${MODULE_PREFIX} ${CHANNEL_NAME} "pulse" "") endif() From 3e1f72a0117d2f3f83665c16fc7e84881748561f Mon Sep 17 00:00:00 2001 From: Mike McDonald Date: Wed, 28 Aug 2013 21:37:45 -0400 Subject: [PATCH 4/5] Fixed minor formatting issues --- channels/rdpsnd/client/ios/rdpsnd_ios.c | 173 ++++++++++++------------ 1 file changed, 86 insertions(+), 87 deletions(-) diff --git a/channels/rdpsnd/client/ios/rdpsnd_ios.c b/channels/rdpsnd/client/ios/rdpsnd_ios.c index 60d6b9655..60da43cc1 100644 --- a/channels/rdpsnd/client/ios/rdpsnd_ios.c +++ b/channels/rdpsnd/client/ios/rdpsnd_ios.c @@ -32,8 +32,8 @@ #include "rdpsnd_main.h" #include "TPCircularBuffer.h" -#define INPUT_BUFFER_SIZE 32768 -#define CIRCULAR_BUFFER_SIZE (INPUT_BUFFER_SIZE * 4) +#define INPUT_BUFFER_SIZE 32768 +#define CIRCULAR_BUFFER_SIZE (INPUT_BUFFER_SIZE * 4) typedef struct rdpsnd_ios_plugin { @@ -47,20 +47,20 @@ typedef struct rdpsnd_ios_plugin #define THIS(__ptr) ((rdpsndIOSPlugin*)__ptr) static OSStatus rdpsnd_ios_render_cb( - void *inRefCon, - AudioUnitRenderActionFlags __unused *ioActionFlags, - const AudioTimeStamp __unused *inTimeStamp, - UInt32 inBusNumber, - UInt32 __unused inNumberFrames, - AudioBufferList *ioData + void *inRefCon, + AudioUnitRenderActionFlags __unused *ioActionFlags, + const AudioTimeStamp __unused *inTimeStamp, + UInt32 inBusNumber, + UInt32 __unused inNumberFrames, + AudioBufferList *ioData ) { - unsigned int i; + unsigned int i; if (inBusNumber != 0) { return noErr; - }; + } rdpsndIOSPlugin *p = THIS(inRefCon); @@ -84,17 +84,17 @@ static OSStatus rdpsnd_ios_render_cb( target_buffer->mDataByteSize = 0; AudioOutputUnitStop(p->audio_unit); p->is_playing = 0; - }; - }; + } + } return noErr; } static BOOL rdpsnd_ios_format_supported(rdpsndDevicePlugin* __unused device, AUDIO_FORMAT* format) { - if (format->wFormatTag == WAVE_FORMAT_PCM) + if (format->wFormatTag == WAVE_FORMAT_PCM) { - return 1; + return 1; } return 0; } @@ -111,10 +111,10 @@ static void rdpsnd_ios_start(rdpsndDevicePlugin* device) { rdpsndIOSPlugin *p = THIS(device); - /* If this device is not playing... */ + /* If this device is not playing... */ if (!p->is_playing) { - /* Start the device. */ + /* Start the device. */ int32_t available_bytes = 0; TPCircularBufferTail(&p->buffer, &available_bytes); if (available_bytes > 0) @@ -129,16 +129,16 @@ static void rdpsnd_ios_stop(rdpsndDevicePlugin* __unused device) { rdpsndIOSPlugin *p = THIS(device); - /* If the device is playing... */ + /* If the device is playing... */ if (p->is_playing) { - /* Stop the device. */ + /* Stop the device. */ AudioOutputUnitStop(p->audio_unit); p->is_playing = 0; - /* Free all buffers. */ - TPCircularBufferClear(&p->buffer); - }; + /* Free all buffers. */ + TPCircularBufferClear(&p->buffer); + } } static void rdpsnd_ios_play(rdpsndDevicePlugin* device, BYTE* data, int size) @@ -151,8 +151,7 @@ static void rdpsnd_ios_play(rdpsndDevicePlugin* device, BYTE* data, int size) return; } - rdpsnd_ios_start(device); - + rdpsnd_ios_start(device); } static void rdpsnd_ios_open(rdpsndDevicePlugin* device, AUDIO_FORMAT* format, int __unused latency) @@ -162,9 +161,9 @@ static void rdpsnd_ios_open(rdpsndDevicePlugin* device, AUDIO_FORMAT* format, in if (p->is_opened) { return; - }; + } - /* Find the output audio unit. */ + /* Find the output audio unit. */ AudioComponentDescription desc; desc.componentManufacturer = kAudioUnitManufacturer_Apple; desc.componentType = kAudioUnitType_Output; @@ -173,13 +172,13 @@ static void rdpsnd_ios_open(rdpsndDevicePlugin* device, AUDIO_FORMAT* format, in desc.componentFlagsMask = 0; AudioComponent audioComponent = AudioComponentFindNext(NULL, &desc); - if (audioComponent == NULL) return; + if (audioComponent == NULL) return; - /* Open the audio unit. */ + /* Open the audio unit. */ OSStatus status = AudioComponentInstanceNew(audioComponent, &p->audio_unit); - if (status != 0) return; + if (status != 0) return; - /* Set the format for the AudioUnit. */ + /* Set the format for the AudioUnit. */ AudioStreamBasicDescription audioFormat = {0}; audioFormat.mSampleRate = format->nSamplesPerSec; audioFormat.mFormatID = kAudioFormatLinearPCM; @@ -191,55 +190,55 @@ static void rdpsnd_ios_open(rdpsndDevicePlugin* device, AUDIO_FORMAT* format, in audioFormat.mBytesPerPacket = audioFormat.mBytesPerFrame * audioFormat.mFramesPerPacket; status = AudioUnitSetProperty( - p->audio_unit, - kAudioUnitProperty_StreamFormat, - kAudioUnitScope_Input, - 0, - &audioFormat, - sizeof(audioFormat)); - if (status != 0) - { - AudioComponentInstanceDispose(p->audio_unit); - p->audio_unit = NULL; - return; - } + p->audio_unit, + kAudioUnitProperty_StreamFormat, + kAudioUnitScope_Input, + 0, + &audioFormat, + sizeof(audioFormat)); + if (status != 0) + { + AudioComponentInstanceDispose(p->audio_unit); + p->audio_unit = NULL; + return; + } - /* Set up the AudioUnit callback. */ + /* Set up the AudioUnit callback. */ AURenderCallbackStruct callbackStruct = {0}; callbackStruct.inputProc = rdpsnd_ios_render_cb; callbackStruct.inputProcRefCon = p; - status = AudioUnitSetProperty( - p->audio_unit, - kAudioUnitProperty_SetRenderCallback, - kAudioUnitScope_Input, - 0, - &callbackStruct, - sizeof(callbackStruct)); - if (status != 0) - { - AudioComponentInstanceDispose(p->audio_unit); - p->audio_unit = NULL; - return; - } + status = AudioUnitSetProperty( + p->audio_unit, + kAudioUnitProperty_SetRenderCallback, + kAudioUnitScope_Input, + 0, + &callbackStruct, + sizeof(callbackStruct)); + if (status != 0) + { + AudioComponentInstanceDispose(p->audio_unit); + p->audio_unit = NULL; + return; + } - /* Initialize the AudioUnit. */ + /* Initialize the AudioUnit. */ status = AudioUnitInitialize(p->audio_unit); - if (status != 0) - { - AudioComponentInstanceDispose(p->audio_unit); - p->audio_unit = NULL; - return; - } + if (status != 0) + { + AudioComponentInstanceDispose(p->audio_unit); + p->audio_unit = NULL; + return; + } - /* Allocate the circular buffer. */ + /* Allocate the circular buffer. */ const BOOL ok = TPCircularBufferInit(&p->buffer, CIRCULAR_BUFFER_SIZE); - if (!ok) - { - AudioUnitUninitialize(p->audio_unit); - AudioComponentInstanceDispose(p->audio_unit); - p->audio_unit = NULL; - return; - } + if (!ok) + { + AudioUnitUninitialize(p->audio_unit); + AudioComponentInstanceDispose(p->audio_unit); + p->audio_unit = NULL; + return; + } p->is_opened = 1; } @@ -248,32 +247,32 @@ static void rdpsnd_ios_close(rdpsndDevicePlugin* device) { rdpsndIOSPlugin *p = THIS(device); - /* Make sure the device is stopped. */ - rdpsnd_ios_stop(device); + /* Make sure the device is stopped. */ + rdpsnd_ios_stop(device); - /* If the device is open... */ - if (p->is_opened) - { - /* Close the device. */ - AudioUnitUninitialize(p->audio_unit); - AudioComponentInstanceDispose(p->audio_unit); - p->audio_unit = NULL; - p->is_opened = 0; + /* If the device is open... */ + if (p->is_opened) + { + /* Close the device. */ + AudioUnitUninitialize(p->audio_unit); + AudioComponentInstanceDispose(p->audio_unit); + p->audio_unit = NULL; + p->is_opened = 0; - /* Destroy the circular buffer. */ - TPCircularBufferCleanup(&p->buffer); - } + /* Destroy the circular buffer. */ + TPCircularBufferCleanup(&p->buffer); + } } static void rdpsnd_ios_free(rdpsndDevicePlugin* device) { rdpsndIOSPlugin *p = THIS(device); - /* Ensure the device is closed. */ - rdpsnd_ios_close(device); + /* Ensure the device is closed. */ + rdpsnd_ios_close(device); - /* Free memory associated with the device. */ - free(p); + /* Free memory associated with the device. */ + free(p); } #ifdef STATIC_CHANNELS From 77e6ebdb73e1ccbcf353ceb901c984ecc627be33 Mon Sep 17 00:00:00 2001 From: Mike McDonald Date: Thu, 29 Aug 2013 16:08:15 -0400 Subject: [PATCH 5/5] Removed WTSAPI files from winpr --- winpr/include/winpr/wtsapi.h | 1627 --------------------- winpr/libwinpr/wtsapi/CMakeLists.txt | 36 - winpr/libwinpr/wtsapi/ModuleOptions.cmake | 9 - winpr/libwinpr/wtsapi/wtsapi.c | 506 ------- 4 files changed, 2178 deletions(-) delete mode 100644 winpr/include/winpr/wtsapi.h delete mode 100644 winpr/libwinpr/wtsapi/CMakeLists.txt delete mode 100644 winpr/libwinpr/wtsapi/ModuleOptions.cmake delete mode 100644 winpr/libwinpr/wtsapi/wtsapi.c diff --git a/winpr/include/winpr/wtsapi.h b/winpr/include/winpr/wtsapi.h deleted file mode 100644 index b07006b5f..000000000 --- a/winpr/include/winpr/wtsapi.h +++ /dev/null @@ -1,1627 +0,0 @@ -/** - * WinPR: Windows Portable Runtime - * Windows Terminal Services API (WTSAPI) - * - * Copyright 2013 Mike McDonald - * - * 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. - */ - -#ifndef WINPR_WTSAPI_H -#define WINPR_WTSAPI_H - -#include - -#include -#include -#include -#include - -#ifdef _WIN32 - -#include - -#else - -typedef HANDLE HWND; - -#ifdef __cplusplus -extern "C" { -#endif - - -/*=================================================================== -== Defines -=====================================================================*/ - -/* - * Specifies the current server - */ -#define WTS_CURRENT_SERVER ((HANDLE)NULL) -#define WTS_CURRENT_SERVER_HANDLE ((HANDLE)NULL) -#define WTS_CURRENT_SERVER_NAME (NULL) - -/* - * Specifies the current session (SessionId) - */ -#define WTS_CURRENT_SESSION ((DWORD)-1) - -/* - * Specifies any-session (SessionId) - */ -#define WTS_ANY_SESSION ((DWORD)-2) - -/* - * Possible pResponse values from WTSSendMessage() - */ -#ifndef IDTIMEOUT -#define IDTIMEOUT 32000 -#endif -#ifndef IDASYNC -#define IDASYNC 32001 -#endif - -#ifndef __HYDRIX_H__ -#define USERNAME_LENGTH 20 -#define CLIENTNAME_LENGTH 20 -#define CLIENTADDRESS_LENGTH 30 -#endif -/* - * Shutdown flags - */ -#define WTS_WSD_LOGOFF 0x00000001 // log off all users except - // current user; deletes - // WinStations (a reboot is - // required to recreate the - // WinStations) -#define WTS_WSD_SHUTDOWN 0x00000002 // shutdown system -#define WTS_WSD_REBOOT 0x00000004 // shutdown and reboot -#define WTS_WSD_POWEROFF 0x00000008 // shutdown and power off (on - // machines that support power - // off through software) -#define WTS_WSD_FASTREBOOT 0x00000010 // reboot without logging users - // off or shutting down -#define MAX_ELAPSED_TIME_LENGTH 15 -#define MAX_DATE_TIME_LENGTH 56 -#define WINSTATIONNAME_LENGTH 32 -#define DOMAIN_LENGTH 17 - -#define WTS_DRIVE_LENGTH 3 -#define WTS_LISTENER_NAME_LENGTH 32 -#define WTS_COMMENT_LENGTH 60 - -/* - * Flags for WTSCreateListener - */ -#define WTS_LISTENER_CREATE 0x00000001 -#define WTS_LISTENER_UPDATE 0x00000010 - -/********************************* - * Listener access values - *********************************/ -#define WTS_SECURITY_QUERY_INFORMATION 0x00000001 -#define WTS_SECURITY_SET_INFORMATION 0x00000002 -#define WTS_SECURITY_RESET 0x00000004 -#define WTS_SECURITY_VIRTUAL_CHANNELS 0x00000008 -#define WTS_SECURITY_REMOTE_CONTROL 0x00000010 -#define WTS_SECURITY_LOGON 0x00000020 -#define WTS_SECURITY_LOGOFF 0x00000040 -#define WTS_SECURITY_MESSAGE 0x00000080 -#define WTS_SECURITY_CONNECT 0x00000100 -#define WTS_SECURITY_DISCONNECT 0x00000200 - -#define WTS_SECURITY_GUEST_ACCESS (WTS_SECURITY_LOGON) - -#define WTS_SECURITY_CURRENT_GUEST_ACCESS (WTS_SECURITY_VIRTUAL_CHANNELS | WTS_SECURITY_LOGOFF) - -#define WTS_SECURITY_USER_ACCESS (WTS_SECURITY_CURRENT_GUEST_ACCESS | WTS_SECURITY_QUERY_INFORMATION | WTS_SECURITY_CONNECT ) - -#define WTS_SECURITY_CURRENT_USER_ACCESS (WTS_SECURITY_SET_INFORMATION | WTS_SECURITY_RESET \ - WTS_SECURITY_VIRTUAL_CHANNELS | WTS_SECURITY_LOGOFF \ - WTS_SECURITY_DISCONNECT) - -#define WTS_SECURITY_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | WTS_SECURITY_QUERY_INFORMATION | \ - WTS_SECURITY_SET_INFORMATION | WTS_SECURITY_RESET | \ - WTS_SECURITY_VIRTUAL_CHANNELS | WTS_SECURITY_REMOTE_CONTROL | \ - WTS_SECURITY_LOGON | \ - WTS_SECURITY_MESSAGE | \ - WTS_SECURITY_CONNECT | WTS_SECURITY_DISCONNECT) - -/*=================================================================== -== WTS_CONNECTSTATE_CLASS - Session connect state -=====================================================================*/ - -typedef enum _WTS_CONNECTSTATE_CLASS { - WTSActive, // User logged on to WinStation - WTSConnected, // WinStation connected to client - WTSConnectQuery, // In the process of connecting to client - WTSShadow, // Shadowing another WinStation - WTSDisconnected, // WinStation logged on without client - WTSIdle, // Waiting for client to connect - WTSListen, // WinStation is listening for connection - WTSReset, // WinStation is being reset - WTSDown, // WinStation is down due to error - WTSInit, // WinStation in initialization -} WTS_CONNECTSTATE_CLASS; - -/*===================================================================== -== WTS_SERVER_INFO - returned by WTSEnumerateServers (version 1) -=====================================================================*/ - -/* - * WTSEnumerateServers() returns two variables: pServerInfo and Count. - * The latter is the number of WTS_SERVER_INFO structures contained in - * the former. In order to read each server, iterate i from 0 to - * Count-1 and reference the server name as - * pServerInfo[i].pServerName; for example: - * - * for ( i=0; i < Count; i++ ) { - * _tprintf( TEXT("%s "), pServerInfo[i].pServerName ); - * } - * - * The memory returned looks like the following. P is a pServerInfo - * pointer, and D is the string data for that pServerInfo: - * - * P1 P2 P3 P4 ... Pn D1 D2 D3 D4 ... Dn - * - * This makes it easier to iterate the servers, using code similar to - * the above. - */ - -typedef struct _WTS_SERVER_INFOW { - LPWSTR pServerName; // server name -} WTS_SERVER_INFOW, * PWTS_SERVER_INFOW; - -typedef struct _WTS_SERVER_INFOA { - LPSTR pServerName; // server name -} WTS_SERVER_INFOA, * PWTS_SERVER_INFOA; - -#ifdef UNICODE -#define WTS_SERVER_INFO WTS_SERVER_INFOW -#define PWTS_SERVER_INFO PWTS_SERVER_INFOW -#else -#define WTS_SERVER_INFO WTS_SERVER_INFOA -#define PWTS_SERVER_INFO PWTS_SERVER_INFOA -#endif - - -/*===================================================================== -== WTS_SESSION_INFO - returned by WTSEnumerateSessions (version 1) -=====================================================================*/ - -/* - * WTSEnumerateSessions() returns data in a similar format to the above - * WTSEnumerateServers(). It returns two variables: pSessionInfo and - * Count. The latter is the number of WTS_SESSION_INFO structures - * contained in the former. Iteration is similar, except that there - * are three parts to each entry, so it would look like this: - * - * for ( i=0; i < Count; i++ ) { - * _tprintf( TEXT("%-5u %-20s %u\n"), - pSessionInfo[i].SessionId, - * pSessionInfo[i].pWinStationName, - * pSessionInfo[i].State ); - * } - * - * The memory returned is also segmented as the above, with all the - * structures allocated at the start and the string data at the end. - * We'll use S for the SessionId, P for the pWinStationName pointer - * and D for the string data, and C for the connect State: - * - * S1 P1 C1 S2 P2 C2 S3 P3 C3 S4 P4 C4 ... Sn Pn Cn D1 D2 D3 D4 ... Dn - * - * As above, this makes it easier to iterate the sessions. - */ - -typedef struct _WTS_SESSION_INFOW { - DWORD SessionId; // session id - LPWSTR pWinStationName; // name of WinStation this session is - // connected to - WTS_CONNECTSTATE_CLASS State; // connection state (see enum) -} WTS_SESSION_INFOW, * PWTS_SESSION_INFOW; - -typedef struct _WTS_SESSION_INFOA { - DWORD SessionId; // session id - LPSTR pWinStationName; // name of WinStation this session is - // connected to - WTS_CONNECTSTATE_CLASS State; // connection state (see enum) -} WTS_SESSION_INFOA, * PWTS_SESSION_INFOA; - -typedef struct _WTS_SESSION_INFO_1W { - DWORD ExecEnvId; - WTS_CONNECTSTATE_CLASS State; - DWORD SessionId; - LPWSTR pSessionName; - LPWSTR pHostName; - LPWSTR pUserName; - LPWSTR pDomainName; - LPWSTR pFarmName; -} WTS_SESSION_INFO_1W, * PWTS_SESSION_INFO_1W; - -typedef struct _WTS_SESSION_INFO_1A { - DWORD ExecEnvId; - WTS_CONNECTSTATE_CLASS State; - DWORD SessionId; - LPSTR pSessionName; - LPSTR pHostName; - LPSTR pUserName; - LPSTR pDomainName; - LPSTR pFarmName; -} WTS_SESSION_INFO_1A, * PWTS_SESSION_INFO_1A; - -#ifdef UNICODE -#define WTS_SESSION_INFO WTS_SESSION_INFOW -#define PWTS_SESSION_INFO PWTS_SESSION_INFOW -#define WTS_SESSION_INFO_1 WTS_SESSION_INFO_1W -#define PWTS_SESSION_INFO_1 PWTS_SESSION_INFO_1W -#else -#define WTS_SESSION_INFO WTS_SESSION_INFOA -#define PWTS_SESSION_INFO PWTS_SESSION_INFOA -#define WTS_SESSION_INFO_1 WTS_SESSION_INFO_1A -#define PWTS_SESSION_INFO_1 PWTS_SESSION_INFO_1A -#endif - - -/*===================================================================== -== WTS_PROCESS_INFO - returned by WTSEnumerateProcesses (version 1) -=====================================================================*/ - -/* - * WTSEnumerateProcesses() also returns data similar to - * WTSEnumerateServers(). It returns two variables: pProcessInfo and - * Count. The latter is the number of WTS_PROCESS_INFO structures - * contained in the former. Iteration is similar, except that there - * are four parts to each entry, so it would look like this: - * - * for ( i=0; i < Count; i++ ) { - * GetUserNameFromSid( pProcessInfo[i].pUserSid, UserName, - * sizeof(UserName) ); - * _tprintf( TEXT("%-5u %-20s %-5u %s\n"), - * pProcessInfo[i].SessionId, - * UserName, - * pProcessInfo[i].ProcessId, - * pProcessInfo[i].pProcessName ); - * } - * - * The memory returned is also segmented as the above, with all the - * structures allocated at the start and the string data at the end. - * We'll use S for the SessionId, R for the ProcessId, P for the - * pProcessName pointer and D for the string data, and U for pUserSid: - * - * S1 R1 P1 U1 S2 R2 P2 U2 S3 R3 P3 U3 ... Sn Rn Pn Un D1 D2 D3 ... Dn - * - * As above, this makes it easier to iterate the processes. - */ - -typedef struct _WTS_PROCESS_INFOW { - DWORD SessionId; // session id - DWORD ProcessId; // process id - LPWSTR pProcessName; // name of process - PSID pUserSid; // user's SID -} WTS_PROCESS_INFOW, * PWTS_PROCESS_INFOW; - -typedef struct _WTS_PROCESS_INFOA { - DWORD SessionId; // session id - DWORD ProcessId; // process id - LPSTR pProcessName; // name of process - PSID pUserSid; // user's SID -} WTS_PROCESS_INFOA, * PWTS_PROCESS_INFOA; - -#ifdef UNICODE -#define WTS_PROCESS_INFO WTS_PROCESS_INFOW -#define PWTS_PROCESS_INFO PWTS_PROCESS_INFOW -#else -#define WTS_PROCESS_INFO WTS_PROCESS_INFOA -#define PWTS_PROCESS_INFO PWTS_PROCESS_INFOA -#endif - -/*===================================================================== -== WTS_INFO_CLASS - WTSQuerySessionInformation -== (See additional typedefs for more info on structures) -=====================================================================*/ - -#define WTS_PROTOCOL_TYPE_CONSOLE 0 // Console -#define WTS_PROTOCOL_TYPE_ICA 1 // ICA Protocol -#define WTS_PROTOCOL_TYPE_RDP 2 // RDP Protocol - -typedef enum _WTS_INFO_CLASS { - WTSInitialProgram, - WTSApplicationName, - WTSWorkingDirectory, - WTSOEMId, - WTSSessionId, - WTSUserName, - WTSWinStationName, - WTSDomainName, - WTSConnectState, - WTSClientBuildNumber, - WTSClientName, - WTSClientDirectory, - WTSClientProductId, - WTSClientHardwareId, - WTSClientAddress, - WTSClientDisplay, - WTSClientProtocolType, - WTSIdleTime, - WTSLogonTime, - WTSIncomingBytes, - WTSOutgoingBytes, - WTSIncomingFrames, - WTSOutgoingFrames, - WTSClientInfo, - WTSSessionInfo, - WTSSessionInfoEx, - WTSConfigInfo, - WTSValidationInfo, // Info Class value used to fetch Validation Information through the WTSQuerySessionInformation - WTSSessionAddressV4, - WTSIsRemoteSession -} WTS_INFO_CLASS; - -/*===================================================================== -== WTS Config Information -=====================================================================*/ - -typedef struct _WTSCONFIGINFOW { - ULONG version; - ULONG fConnectClientDrivesAtLogon; - ULONG fConnectPrinterAtLogon; - ULONG fDisablePrinterRedirection; - ULONG fDisableDefaultMainClientPrinter; - ULONG ShadowSettings; - WCHAR LogonUserName[USERNAME_LENGTH + 1 ]; - WCHAR LogonDomain[DOMAIN_LENGTH + 1 ]; - WCHAR WorkDirectory[MAX_PATH + 1 ]; - WCHAR InitialProgram[MAX_PATH + 1 ]; - WCHAR ApplicationName[MAX_PATH + 1 ]; -} WTSCONFIGINFOW, *PWTSCONFIGINFOW; - -typedef struct _WTSCONFIGINFOA { - ULONG version; - ULONG fConnectClientDrivesAtLogon; - ULONG fConnectPrinterAtLogon; - ULONG fDisablePrinterRedirection; - ULONG fDisableDefaultMainClientPrinter; - ULONG ShadowSettings; - CHAR LogonUserName[USERNAME_LENGTH + 1 ]; - CHAR LogonDomain[DOMAIN_LENGTH + 1 ]; - CHAR WorkDirectory[MAX_PATH + 1 ]; - CHAR InitialProgram[MAX_PATH + 1 ]; - CHAR ApplicationName[MAX_PATH + 1 ]; -} WTSCONFIGINFOA, *PWTSCONFIGINFOA; - -/*===================================================================== -== WTS Session Information -=====================================================================*/ -typedef struct _WTSINFOW { - WTS_CONNECTSTATE_CLASS State; // connection state (see enum) - DWORD SessionId; // session id - DWORD IncomingBytes; - DWORD OutgoingBytes; - DWORD IncomingFrames; - DWORD OutgoingFrames; - DWORD IncomingCompressedBytes; - DWORD OutgoingCompressedBytes; - WCHAR WinStationName[WINSTATIONNAME_LENGTH]; - WCHAR Domain[DOMAIN_LENGTH]; - WCHAR UserName[USERNAME_LENGTH+1];// name of WinStation this session is - // connected to - LARGE_INTEGER ConnectTime; - LARGE_INTEGER DisconnectTime; - LARGE_INTEGER LastInputTime; - LARGE_INTEGER LogonTime; - LARGE_INTEGER CurrentTime; - -} WTSINFOW, * PWTSINFOW; - -typedef struct _WTSINFOA { - WTS_CONNECTSTATE_CLASS State; // connection state (see enum) - DWORD SessionId; // session id - DWORD IncomingBytes; - DWORD OutgoingBytes; - DWORD IncomingFrames; - DWORD OutgoingFrames; - DWORD IncomingCompressedBytes; - DWORD OutgoingCompressedBy; - CHAR WinStationName[WINSTATIONNAME_LENGTH]; - CHAR Domain[DOMAIN_LENGTH]; - CHAR UserName[USERNAME_LENGTH+1];// name of WinStation this session is - // connected to - LARGE_INTEGER ConnectTime; - LARGE_INTEGER DisconnectTime; - LARGE_INTEGER LastInputTime; - LARGE_INTEGER LogonTime; - LARGE_INTEGER CurrentTime; - -} WTSINFOA, * PWTSINFOA; - - -/*===================================================================== -== WTS Extended Session State Flags -=====================================================================*/ -#define WTS_SESSIONSTATE_UNKNOWN 0xFFFFFFFF -#define WTS_SESSIONSTATE_LOCK 0x00000000 -#define WTS_SESSIONSTATE_UNLOCK 0x00000001 - -/*===================================================================== -== WTS Extended Session Information -=====================================================================*/ -typedef struct _WTSINFOEX_LEVEL1_W { - ULONG SessionId; - WTS_CONNECTSTATE_CLASS SessionState; - LONG SessionFlags; - WCHAR WinStationName[WINSTATIONNAME_LENGTH + 1] ; - WCHAR UserName[USERNAME_LENGTH + 1]; - WCHAR DomainName[DOMAIN_LENGTH + 1]; - LARGE_INTEGER LogonTime; - LARGE_INTEGER ConnectTime; - LARGE_INTEGER DisconnectTime; - LARGE_INTEGER LastInputTime; - LARGE_INTEGER CurrentTime; - DWORD IncomingBytes; - DWORD OutgoingBytes; - DWORD IncomingFrames; - DWORD OutgoingFrames; - DWORD IncomingCompressedBytes; - DWORD OutgoingCompressedBytes; -} WTSINFOEX_LEVEL1_W, *PWTSINFOEX_LEVEL1_W; - -typedef struct _WTSINFOEX_LEVEL1_A { - ULONG SessionId; - WTS_CONNECTSTATE_CLASS SessionState; - LONG SessionFlags; - CHAR WinStationName[WINSTATIONNAME_LENGTH + 1]; - CHAR UserName[USERNAME_LENGTH + 1]; - CHAR DomainName[DOMAIN_LENGTH + 1]; - LARGE_INTEGER LogonTime; - LARGE_INTEGER ConnectTime; - LARGE_INTEGER DisconnectTime; - LARGE_INTEGER LastInputTime; - LARGE_INTEGER CurrentTime; - DWORD IncomingBytes; - DWORD OutgoingBytes; - DWORD IncomingFrames; - DWORD OutgoingFrames; - DWORD IncomingCompressedBytes; - DWORD OutgoingCompressedBytes; -} WTSINFOEX_LEVEL1_A, *PWTSINFOEX_LEVEL1_A; - -typedef union _WTSINFOEX_LEVEL_W { - WTSINFOEX_LEVEL1_W WTSInfoExLevel1; -} WTSINFOEX_LEVEL_W, *PWTSINFOEX_LEVEL_W; - -typedef union _WTSINFOEX_LEVEL_A { - WTSINFOEX_LEVEL1_A WTSInfoExLevel1; -} WTSINFOEX_LEVEL_A, *PWTSINFOEX_LEVEL_A; - -typedef struct _WTSINFOEXW { - DWORD Level; - WTSINFOEX_LEVEL_W Data; -} WTSINFOEXW, *PWTSINFOEXW; - -typedef struct _WTSINFOEXA { - DWORD Level; - WTSINFOEX_LEVEL_A Data; -} WTSINFOEXA, *PWTSINFOEXA; - - -/*===================================================================== -== WTS Client Information -=====================================================================*/ -typedef struct _WTSCLIENTW { - WCHAR ClientName[ CLIENTNAME_LENGTH + 1 ]; - WCHAR Domain[ DOMAIN_LENGTH + 1 ]; - WCHAR UserName[ USERNAME_LENGTH + 1 ]; - WCHAR WorkDirectory[ MAX_PATH + 1]; - WCHAR InitialProgram[ MAX_PATH + 1]; - BYTE EncryptionLevel; // security level of encryption pd - ULONG ClientAddressFamily; - USHORT ClientAddress[ CLIENTADDRESS_LENGTH + 1 ]; - USHORT HRes; - USHORT VRes; - USHORT ColorDepth; - WCHAR ClientDirectory[ MAX_PATH + 1 ]; - ULONG ClientBuildNumber; - ULONG ClientHardwareId; // client software serial number - USHORT ClientProductId; // client software product id - USHORT OutBufCountHost; // number of outbufs on host - USHORT OutBufCountClient; // number of outbufs on client - USHORT OutBufLength; // length of outbufs in bytes - WCHAR DeviceId[ MAX_PATH + 1]; -} WTSCLIENTW, * PWTSCLIENTW; - - -/*===================================================================== -== WTS Client Information -=====================================================================*/ -typedef struct _WTSCLIENTA { - CHAR ClientName[ CLIENTNAME_LENGTH + 1 ]; - CHAR Domain[ DOMAIN_LENGTH + 1 ]; - CHAR UserName[ USERNAME_LENGTH + 1 ]; - CHAR WorkDirectory[ MAX_PATH + 1]; - CHAR InitialProgram[ MAX_PATH + 1 ]; - BYTE EncryptionLevel; // security level of encryption pd - ULONG ClientAddressFamily; - USHORT ClientAddress[ CLIENTADDRESS_LENGTH + 1 ]; - USHORT HRes; - USHORT VRes; - USHORT ColorDepth; - CHAR ClientDirectory[ MAX_PATH + 1 ]; - ULONG ClientBuildNumber; - ULONG ClientHardwareId; // client software serial number - USHORT ClientProductId; // client software product id - USHORT OutBufCountHost; // number of outbufs on host - USHORT OutBufCountClient; // number of outbufs on client - USHORT OutBufLength; // length of outbufs in bytes - CHAR DeviceId[ MAX_PATH + 1]; -} WTSCLIENTA, * PWTSCLIENTA; - -/*===================================================================== -== WTS License Validation Information - Product Information -=====================================================================*/ - -#define PRODUCTINFO_COMPANYNAME_LENGTH 256 -#define PRODUCTINFO_PRODUCTID_LENGTH 4 - -typedef struct _WTS_PRODUCT_INFOA -{ - CHAR CompanyName[PRODUCTINFO_COMPANYNAME_LENGTH]; - CHAR ProductID[PRODUCTINFO_PRODUCTID_LENGTH]; -} PRODUCT_INFOA; - -typedef struct _WTS_PRODUCT_INFOW -{ - WCHAR CompanyName[PRODUCTINFO_COMPANYNAME_LENGTH]; - WCHAR ProductID[PRODUCTINFO_PRODUCTID_LENGTH]; -} PRODUCT_INFOW; - -/*===================================================================== - WTS License Validation Information - This structure will be returned from WTSQuerySessionInformation when the user - queries for license validation information. -=====================================================================*/ - -#define VALIDATIONINFORMATION_LICENSE_LENGTH 16384 //16 Kb -#define VALIDATIONINFORMATION_HARDWAREID_LENGTH 20 - -typedef struct _WTS_VALIDATION_INFORMATIONA { - PRODUCT_INFOA ProductInfo; - BYTE License[VALIDATIONINFORMATION_LICENSE_LENGTH]; - DWORD LicenseLength; - BYTE HardwareID[VALIDATIONINFORMATION_HARDWAREID_LENGTH]; - DWORD HardwareIDLength; - -} WTS_VALIDATION_INFORMATIONA, * PWTS_VALIDATION_INFORMATIONA; - -typedef struct _WTS_VALIDATION_INFORMATIONW { - PRODUCT_INFOW ProductInfo; - BYTE License[VALIDATIONINFORMATION_LICENSE_LENGTH]; - DWORD LicenseLength; - BYTE HardwareID[VALIDATIONINFORMATION_HARDWAREID_LENGTH]; - DWORD HardwareIDLength; - -} WTS_VALIDATION_INFORMATIONW, * PWTS_VALIDATION_INFORMATIONW; - -#ifdef UNICODE -#define WTSCONFIGINFO WTSCONFIGINFOW -#define PWTSCONFIGINFO PWTSCONFIGINFOW -#define PRODUCT_INFO PRODUCT_INFOW -#define WTS_VALIDATION_INFORMATION WTS_VALIDATION_INFORMATIONW -#define PWTS_VALIDATION_INFORMATION PWTS_VALIDATION_INFORMATIONW -#define WTSINFO WTSINFOW -#define PWTSINFO PWTSINFOW -#define WTSINFOEX WTSINFOEXW -#define PWTSINFOEX PWTSINFOEXW -#define WTSINFOEX_LEVEL WTSINFOEX_LEVEL_W -#define PWTSINFOEX_LEVEL PWTSINFOEX_LEVEL_W -#define WTSINFOEX_LEVEL1 WTSINFOEX_LEVEL1_W -#define PWTSINFOEX_LEVEL1 PWTSINFOEX_LEVEL1_W -#define WTSCLIENT WTSCLIENTW -#define PWTSCLIENT PWTSCLIENTW -#else -#define WTSCONFIGINFO WTSCONFIGINFOA -#define PWTSCONFIGINFO PWTSCONFIGINFOA -#define PRODUCT_INFO PRODUCT_INFOA -#define WTS_VALIDATION_INFORMATION WTS_VALIDATION_INFORMATIONA -#define PWTS_VALIDATION_INFORMATION PWTS_VALIDATION_INFORMATIONA -#define WTSINFO WTSINFOA -#define PWTSINFO PWTSINFOA -#define WTSINFOEX WTSINFOEXA -#define PWTSINFOEX PWTSINFOEXA -#define WTSINFOEX_LEVEL WTSINFOEX_LEVEL_A -#define PWTSINFOEX_LEVEL PWTSINFOEX_LEVEL_A -#define WTSINFOEX_LEVEL1 WTSINFOEX_LEVEL1_A -#define PWTSINFOEX_LEVEL1 PWTSINFOEX_LEVEL1_A -#define WTSCLIENT WTSCLIENTA -#define PWTSCLIENT PWTSCLIENTA - -#endif - - -/*===================================================================== -== WTSQuerySessionInformation - (WTSClientAddress) -=====================================================================*/ - -typedef struct _WTS_CLIENT_ADDRESS { - DWORD AddressFamily; // AF_INET, AF_INET6, AF_IPX, AF_NETBIOS, AF_UNSPEC - BYTE Address[20]; // client network address -} WTS_CLIENT_ADDRESS, * PWTS_CLIENT_ADDRESS; - - -/*===================================================================== -== WTSQuerySessionInformation - (WTSClientDisplay) -=====================================================================*/ - -typedef struct _WTS_CLIENT_DISPLAY { - DWORD HorizontalResolution; // horizontal dimensions, in pixels - DWORD VerticalResolution; // vertical dimensions, in pixels - DWORD ColorDepth; // 1=16, 2=256, 4=64K, 8=16M -} WTS_CLIENT_DISPLAY, * PWTS_CLIENT_DISPLAY; - - -/*===================================================================== -== WTS_CONFIG_CLASS - WTSQueryUserConfig/WTSSetUserConfig -=====================================================================*/ - - -typedef enum _WTS_CONFIG_CLASS { - //Initial program settings - WTSUserConfigInitialProgram, // string returned/expected - WTSUserConfigWorkingDirectory, // string returned/expected - WTSUserConfigfInheritInitialProgram, // DWORD returned/expected - // - WTSUserConfigfAllowLogonTerminalServer, //DWORD returned/expected - //Timeout settings - WTSUserConfigTimeoutSettingsConnections, //DWORD returned/expected - WTSUserConfigTimeoutSettingsDisconnections, //DWORD returned/expected - WTSUserConfigTimeoutSettingsIdle, //DWORD returned/expected - //Client device settings - WTSUserConfigfDeviceClientDrives, //DWORD returned/expected - WTSUserConfigfDeviceClientPrinters, //DWORD returned/expected - WTSUserConfigfDeviceClientDefaultPrinter, //DWORD returned/expected - //Connection settings - WTSUserConfigBrokenTimeoutSettings, //DWORD returned/expected - WTSUserConfigReconnectSettings, //DWORD returned/expected - //Modem settings - WTSUserConfigModemCallbackSettings, //DWORD returned/expected - WTSUserConfigModemCallbackPhoneNumber, // string returned/expected - //Shadow settings - WTSUserConfigShadowingSettings, //DWORD returned/expected - //User Profile settings - WTSUserConfigTerminalServerProfilePath, // string returned/expected - //Terminal Server home directory - WTSUserConfigTerminalServerHomeDir, // string returned/expected - WTSUserConfigTerminalServerHomeDirDrive, // string returned/expected - WTSUserConfigfTerminalServerRemoteHomeDir, // DWORD 0:LOCAL 1:REMOTE - - WTSUserConfigUser, // returns WTSUSERCONFIG struct -} WTS_CONFIG_CLASS; - -typedef enum _WTS_CONFIG_SOURCE { - WTSUserConfigSourceSAM -} WTS_CONFIG_SOURCE; - -typedef struct _WTSUSERCONFIGA { - DWORD Source; - DWORD InheritInitialProgram; - DWORD AllowLogonTerminalServer; - DWORD TimeoutSettingsConnections; - DWORD TimeoutSettingsDisconnections; - DWORD TimeoutSettingsIdle; - DWORD DeviceClientDrives; - DWORD DeviceClientPrinters; - DWORD ClientDefaultPrinter; - DWORD BrokenTimeoutSettings; - DWORD ReconnectSettings; - DWORD ShadowingSettings; - DWORD TerminalServerRemoteHomeDir; - CHAR InitialProgram[ MAX_PATH + 1 ]; - CHAR WorkDirectory[ MAX_PATH + 1 ]; - CHAR TerminalServerProfilePath[ MAX_PATH + 1 ]; - CHAR TerminalServerHomeDir[ MAX_PATH + 1 ]; - CHAR TerminalServerHomeDirDrive[ WTS_DRIVE_LENGTH + 1 ]; -} WTSUSERCONFIGA, * PWTSUSERCONFIGA; - -typedef struct _WTSUSERCONFIGW { - DWORD Source; - DWORD InheritInitialProgram; - DWORD AllowLogonTerminalServer; - DWORD TimeoutSettingsConnections; - DWORD TimeoutSettingsDisconnections; - DWORD TimeoutSettingsIdle; - DWORD DeviceClientDrives; - DWORD DeviceClientPrinters; - DWORD ClientDefaultPrinter; - DWORD BrokenTimeoutSettings; - DWORD ReconnectSettings; - DWORD ShadowingSettings; - DWORD TerminalServerRemoteHomeDir; - WCHAR InitialProgram[ MAX_PATH + 1 ]; - WCHAR WorkDirectory[ MAX_PATH + 1 ]; - WCHAR TerminalServerProfilePath[ MAX_PATH + 1 ]; - WCHAR TerminalServerHomeDir[ MAX_PATH + 1 ]; - WCHAR TerminalServerHomeDirDrive[ WTS_DRIVE_LENGTH + 1 ]; -} WTSUSERCONFIGW, * PWTSUSERCONFIGW; - -#ifdef UNICODE -#define WTSUSERCONFIG WTSUSERCONFIGW -#define PWTSUSERCONFIG PWTSUSERCONFIGW -#else -#define WTSUSERCONFIG WTSUSERCONFIGA -#define PWTSUSERCONFIG PWTSUSERCONFIGA -#endif /* UNICODE */ - - -/*===================================================================== -== WTS_EVENT - Event flags for WTSWaitSystemEvent -=====================================================================*/ - -#define WTS_EVENT_NONE 0x00000000 // return no event -#define WTS_EVENT_CREATE 0x00000001 // new WinStation created -#define WTS_EVENT_DELETE 0x00000002 // existing WinStation deleted -#define WTS_EVENT_RENAME 0x00000004 // existing WinStation renamed -#define WTS_EVENT_CONNECT 0x00000008 // WinStation connect to client -#define WTS_EVENT_DISCONNECT 0x00000010 // WinStation logged on without - // client -#define WTS_EVENT_LOGON 0x00000020 // user logged on to existing - // WinStation -#define WTS_EVENT_LOGOFF 0x00000040 // user logged off from - // existing WinStation -#define WTS_EVENT_STATECHANGE 0x00000080 // WinStation state change -#define WTS_EVENT_LICENSE 0x00000100 // license state change -#define WTS_EVENT_ALL 0x7fffffff // wait for all event types -#define WTS_EVENT_FLUSH 0x80000000 // unblock all waiters - -/*===================================================================== -== Flags for HotkeyModifiers in WTSStartRemoteControlSession -=====================================================================*/ - -#define REMOTECONTROL_KBDSHIFT_HOTKEY 0x1 // Shift key -#define REMOTECONTROL_KBDCTRL_HOTKEY 0x2 // Ctrl key -#define REMOTECONTROL_KBDALT_HOTKEY 0x4 // Alt key - -/*===================================================================== -== WTS_VIRTUAL_CLASS - WTSVirtualChannelQuery -=====================================================================*/ -typedef enum _WTS_VIRTUAL_CLASS { - WTSVirtualClientData, // Virtual channel client module data - // (C2H data) - WTSVirtualFileHandle -} WTS_VIRTUAL_CLASS; - -/*===================================================================== -== WTSQuerySessionInformation - (WTSSessionAddress) -=====================================================================*/ - -typedef struct _WTS_SESSION_ADDRESS { - DWORD AddressFamily; // AF_INET only. - BYTE Address[20]; // client network address -} WTS_SESSION_ADDRESS, * PWTS_SESSION_ADDRESS; - - -/*===================================================================== -== Windows Terminal Server public APIs -=====================================================================*/ - -BOOL WINPR_API -WTSStopRemoteControlSession( - ULONG LogonId - ); - -BOOL WINPR_API -WTSStartRemoteControlSessionW( - LPWSTR pTargetServerName, - ULONG TargetLogonId, - BYTE HotkeyVk, - USHORT HotkeyModifiers - ); - -BOOL WINPR_API -WTSStartRemoteControlSessionA( - LPSTR pTargetServerName, - ULONG TargetLogonId, - BYTE HotkeyVk, - USHORT HotkeyModifiers - ); - -#ifdef UNICODE -#define WTSStartRemoteControlSession WTSStartRemoteControlSessionW -#else -#define WTSStartRemoteControlSession WTSStartRemoteControlSessionA -#endif /* UNICODE */ - -BOOL -WINPR_API -WTSConnectSessionA( - ULONG LogonId, - ULONG TargetLogonId, - PSTR pPassword, - BOOL bWait - ); - -BOOL -WINPR_API -WTSConnectSessionW( - ULONG LogonId, - ULONG TargetLogonId, - PWSTR pPassword, - BOOL bWait - ); - -#ifdef UNICODE -#define WTSConnectSession WTSConnectSessionW -#else -#define WTSConnectSession WTSConnectSessionA -#endif - -BOOL -WINPR_API -WTSEnumerateServersW( - LPWSTR pDomainName, - DWORD Reserved, - DWORD Version, - PWTS_SERVER_INFOW * ppServerInfo, - DWORD * pCount - ); - -BOOL -WINPR_API -WTSEnumerateServersA( - LPSTR pDomainName, - DWORD Reserved, - DWORD Version, - PWTS_SERVER_INFOA * ppServerInfo, - DWORD * pCount - ); - -#ifdef UNICODE -#define WTSEnumerateServers WTSEnumerateServersW -#else -#define WTSEnumerateServers WTSEnumerateServersA -#endif - -/*------------------------------------------------*/ - -HANDLE -WINPR_API -WTSOpenServerW( - LPWSTR pServerName - ); - -HANDLE -WINPR_API -WTSOpenServerA( - LPSTR pServerName - ); - -HANDLE -WINPR_API -WTSOpenServerExW( - LPWSTR pServerName - ); - -HANDLE -WINPR_API -WTSOpenServerExA( - LPSTR pServerName - ); - -#ifdef UNICODE -#define WTSOpenServer WTSOpenServerW -#define WTSOpenServerEx WTSOpenServerExW -#else -#define WTSOpenServer WTSOpenServerA -#define WTSOpenServerEx WTSOpenServerExA -#endif - -/*------------------------------------------------*/ - -VOID -WINPR_API -WTSCloseServer( - HANDLE hServer - ); - -/*------------------------------------------------*/ - -BOOL -WINPR_API -WTSEnumerateSessionsW( - HANDLE hServer, - DWORD Reserved, - DWORD Version, - PWTS_SESSION_INFOW * ppSessionInfo, - DWORD * pCount - ); - -BOOL -WINPR_API -WTSEnumerateSessionsA( - HANDLE hServer, - DWORD Reserved, - DWORD Version, - PWTS_SESSION_INFOA * ppSessionInfo, - DWORD * pCount - ); - -BOOL -WINPR_API -WTSEnumerateSessionsExW( - HANDLE hServer, - DWORD *pLevel, - DWORD Filter, - PWTS_SESSION_INFO_1W * ppSessionInfo, - DWORD * pCount ); - -BOOL -WINPR_API -WTSEnumerateSessionsExA( - HANDLE hServer, - DWORD *pLevel, - DWORD Filter, - PWTS_SESSION_INFO_1A * ppSessionInfo, - DWORD * pCount ); - -#ifdef UNICODE -#define WTSEnumerateSessions WTSEnumerateSessionsW -#define WTSEnumerateSessionsEx WTSEnumerateSessionsExW -#else -#define WTSEnumerateSessions WTSEnumerateSessionsA -#define WTSEnumerateSessionsEx WTSEnumerateSessionsExA -#endif - -/*------------------------------------------------*/ - -BOOL -WINPR_API -WTSEnumerateProcessesW( - HANDLE hServer, - DWORD Reserved, - DWORD Version, - PWTS_PROCESS_INFOW * ppProcessInfo, - DWORD * pCount - ); - -BOOL -WINPR_API -WTSEnumerateProcessesA( - HANDLE hServer, - DWORD Reserved, - DWORD Version, - PWTS_PROCESS_INFOA * ppProcessInfo, - DWORD * pCount - ); - -#ifdef UNICODE -#define WTSEnumerateProcesses WTSEnumerateProcessesW -#else -#define WTSEnumerateProcesses WTSEnumerateProcessesA -#endif - -/*------------------------------------------------*/ - -BOOL -WINPR_API -WTSTerminateProcess( - HANDLE hServer, - DWORD ProcessId, - DWORD ExitCode - ); - - -/*------------------------------------------------*/ - -BOOL -WINPR_API -WTSQuerySessionInformationW( - HANDLE hServer, - DWORD SessionId, - WTS_INFO_CLASS WTSInfoClass, - LPWSTR * ppBuffer, - DWORD * pBytesReturned - ); - -BOOL -WINPR_API -WTSQuerySessionInformationA( - HANDLE hServer, - DWORD SessionId, - WTS_INFO_CLASS WTSInfoClass, - LPSTR * ppBuffer, - DWORD * pBytesReturned - ); - -#ifdef UNICODE -#define WTSQuerySessionInformation WTSQuerySessionInformationW -#else -#define WTSQuerySessionInformation WTSQuerySessionInformationA -#endif - -/*------------------------------------------------*/ - -BOOL -WINPR_API -WTSQueryUserConfigW( - LPWSTR pServerName, - LPWSTR pUserName, - WTS_CONFIG_CLASS WTSConfigClass, - LPWSTR * ppBuffer, - DWORD * pBytesReturned - ); - -BOOL -WINPR_API -WTSQueryUserConfigA( - LPSTR pServerName, - LPSTR pUserName, - WTS_CONFIG_CLASS WTSConfigClass, - LPSTR * ppBuffer, - DWORD * pBytesReturned - ); - -#ifdef UNICODE -#define WTSQueryUserConfig WTSQueryUserConfigW -#else -#define WTSQueryUserConfig WTSQueryUserConfigA -#endif - -/*------------------------------------------------*/ - -BOOL -WINPR_API -WTSSetUserConfigW( - LPWSTR pServerName, - LPWSTR pUserName, - WTS_CONFIG_CLASS WTSConfigClass, - LPWSTR pBuffer, - DWORD DataLength - ); - -BOOL -WINPR_API -WTSSetUserConfigA( - LPSTR pServerName, - LPSTR pUserName, - WTS_CONFIG_CLASS WTSConfigClass, - LPSTR pBuffer, - DWORD DataLength - ); - -#ifdef UNICODE -#define WTSSetUserConfig WTSSetUserConfigW -#else -#define WTSSetUserConfig WTSSetUserConfigA -#endif - -/*------------------------------------------------*/ - -BOOL -WINPR_API -WTSSendMessageW( - HANDLE hServer, - DWORD SessionId, - LPWSTR pTitle, - DWORD TitleLength, - LPWSTR pMessage, - DWORD MessageLength, - DWORD Style, - DWORD Timeout, - DWORD * pResponse, - BOOL bWait - ); - -BOOL -WINPR_API -WTSSendMessageA( - HANDLE hServer, - DWORD SessionId, - LPSTR pTitle, - DWORD TitleLength, - LPSTR pMessage, - DWORD MessageLength, - DWORD Style, - DWORD Timeout, - DWORD * pResponse, - BOOL bWait - ); - -#ifdef UNICODE -#define WTSSendMessage WTSSendMessageW -#else -#define WTSSendMessage WTSSendMessageA -#endif - -/*------------------------------------------------*/ - -BOOL -WINPR_API -WTSDisconnectSession( - HANDLE hServer, - DWORD SessionId, - BOOL bWait - ); - -/*------------------------------------------------*/ - -BOOL -WINPR_API -WTSLogoffSession( - HANDLE hServer, - DWORD SessionId, - BOOL bWait - ); - -/*------------------------------------------------*/ - -BOOL -WINPR_API -WTSShutdownSystem( - HANDLE hServer, - DWORD ShutdownFlag - ); - -/*------------------------------------------------*/ - -BOOL -WINPR_API -WTSWaitSystemEvent( - HANDLE hServer, - DWORD EventMask, - DWORD * pEventFlags - ); - -/*------------------------------------------------*/ - -HANDLE -WINPR_API -WTSVirtualChannelOpen( - HANDLE hServer, - DWORD SessionId, - LPSTR pVirtualName /* ascii name */ - ); - -#define WTS_CHANNEL_OPTION_DYNAMIC 0x00000001 // dynamic channel -#define WTS_CHANNEL_OPTION_DYNAMIC_PRI_LOW 0x00000000 // priorities -#define WTS_CHANNEL_OPTION_DYNAMIC_PRI_MED 0x00000002 -#define WTS_CHANNEL_OPTION_DYNAMIC_PRI_HIGH 0x00000004 -#define WTS_CHANNEL_OPTION_DYNAMIC_PRI_REAL 0x00000006 -#define WTS_CHANNEL_OPTION_DYNAMIC_NO_COMPRESS 0x00000008 - -HANDLE -WINPR_API -WTSVirtualChannelOpenEx( - DWORD SessionId, - LPSTR pVirtualName, /* ascii name */ - DWORD flags - ); - -BOOL -WINPR_API -WTSVirtualChannelClose( - HANDLE hChannelHandle - ); - -BOOL -WINPR_API -WTSVirtualChannelRead( - HANDLE hChannelHandle, - ULONG TimeOut, - PCHAR Buffer, - ULONG BufferSize, - PULONG pBytesRead - ); - -BOOL -WINPR_API -WTSVirtualChannelWrite( - HANDLE hChannelHandle, - PCHAR Buffer, - ULONG Length, - PULONG pBytesWritten - ); - -BOOL -WINPR_API -WTSVirtualChannelPurgeInput( - HANDLE hChannelHandle - ); - -BOOL -WINPR_API -WTSVirtualChannelPurgeOutput( - HANDLE hChannelHandle - ); - - -BOOL -WINPR_API -WTSVirtualChannelQuery( - HANDLE hChannelHandle, - WTS_VIRTUAL_CLASS, - PVOID *ppBuffer, - DWORD *pBytesReturned - ); - -/*------------------------------------------------*/ - - -VOID -WINPR_API -WTSFreeMemory( - PVOID pMemory - ); - -/* Flags for Console Notification */ - -#define NOTIFY_FOR_ALL_SESSIONS 1 -#define NOTIFY_FOR_THIS_SESSION 0 - - -BOOL -WINPR_API -WTSRegisterSessionNotification( - HWND hWnd, - DWORD dwFlags - ); - -BOOL -WINPR_API -WTSUnRegisterSessionNotification( - HWND hWnd - ); - - -BOOL -WINPR_API -WTSRegisterSessionNotificationEx( - HANDLE hServer, - HWND hWnd, - DWORD dwFlags - ); - -BOOL -WINPR_API -WTSUnRegisterSessionNotificationEx( - HANDLE hServer, - HWND hWnd - ); - -BOOL -WINPR_API -WTSQueryUserToken( - ULONG SessionId, - PHANDLE phToken - ); - -#define WTS_PROCESS_INFO_LEVEL_0 0 -#define WTS_PROCESS_INFO_LEVEL_1 1 - -/* -== WTS_PROCESS_INFO_EX - returned by WTSEnumerateProcessesEX -*/ - -typedef struct _WTS_PROCESS_INFO_EXW { - DWORD SessionId; - DWORD ProcessId; - LPWSTR pProcessName; - PSID pUserSid; - DWORD NumberOfThreads; - DWORD HandleCount; - DWORD PagefileUsage; - DWORD PeakPagefileUsage; - DWORD WorkingSetSize; - DWORD PeakWorkingSetSize; - LARGE_INTEGER UserTime; - LARGE_INTEGER KernelTime; -} WTS_PROCESS_INFO_EXW, * PWTS_PROCESS_INFO_EXW; - -typedef struct _WTS_PROCESS_INFO_EXA { - DWORD SessionId; - DWORD ProcessId; - LPSTR pProcessName; - PSID pUserSid; - DWORD NumberOfThreads; - DWORD HandleCount; - DWORD PagefileUsage; - DWORD PeakPagefileUsage; - DWORD WorkingSetSize; - DWORD PeakWorkingSetSize; - LARGE_INTEGER UserTime; - LARGE_INTEGER KernelTime; -} WTS_PROCESS_INFO_EXA, * PWTS_PROCESS_INFO_EXA; - -#ifdef UNICODE -#define WTS_PROCESS_INFO_EX WTS_PROCESS_INFO_EXW -#define PWTS_PROCESS_INFO_EX PWTS_PROCESS_INFO_EXW -#else -#define WTS_PROCESS_INFO_EX WTS_PROCESS_INFO_EXA -#define PWTS_PROCESS_INFO_EX PWTS_PROCESS_INFO_EXA -#endif - -/*------------------------------------------------*/ - -typedef enum _WTS_TYPE_CLASS { - WTSTypeProcessInfoLevel0, - WTSTypeProcessInfoLevel1, - WTSTypeSessionInfoLevel1, -} WTS_TYPE_CLASS; - -BOOL WINPR_API -WTSFreeMemoryExW( - WTS_TYPE_CLASS WTSTypeClass, - PVOID pMemory, - ULONG NumberOfEntries -); - -BOOL WINPR_API -WTSFreeMemoryExA( - WTS_TYPE_CLASS WTSTypeClass, - PVOID pMemory, - ULONG NumberOfEntries -); - -#ifdef UNICODE -#define WTSFreeMemoryEx WTSFreeMemoryExW -#else -#define WTSFreeMemoryEx WTSFreeMemoryExA -#endif - -/*------------------------------------------------*/ - -BOOL WINPR_API -WTSEnumerateProcessesExW -( - HANDLE hServer, - DWORD *pLevel, - DWORD SessionId, - LPWSTR *ppProcessInfo, - DWORD * pCount -); - -BOOL WINPR_API -WTSEnumerateProcessesExA -( - HANDLE hServer, - DWORD *pLevel, - DWORD SessionId, - LPSTR *ppProcessInfo, - DWORD * pCount -); - -#ifdef UNICODE -#define WTSEnumerateProcessesEx WTSEnumerateProcessesExW -#else -#define WTSEnumerateProcessesEx WTSEnumerateProcessesExA -#endif - - -/*------------------------------------------------*/ -// Listener management APIs - -typedef WCHAR WTSLISTENERNAMEW[WTS_LISTENER_NAME_LENGTH + 1 ]; -typedef WTSLISTENERNAMEW *PWTSLISTENERNAMEW; -typedef CHAR WTSLISTENERNAMEA[WTS_LISTENER_NAME_LENGTH + 1 ]; -typedef WTSLISTENERNAMEA *PWTSLISTENERNAMEA; - -#ifdef UNICODE -#define WTSLISTENERNAME WTSLISTENERNAMEW -#define PWTSLISTENERNAME PWTSLISTENERNAMEW -#else -#define WTSLISTENERNAME WTSLISTENERNAMEA -#define PWTSLISTENERNAME PWTSLISTENERNAMEW -#endif - -BOOL WINPR_API -WTSEnumerateListenersW ( - HANDLE hServer, - PVOID pReserved, - DWORD Reserved, - PWTSLISTENERNAMEW pListeners, - DWORD* pCount -); - -BOOL WINPR_API -WTSEnumerateListenersA ( - HANDLE hServer, - PVOID pReserved, - DWORD Reserved, - PWTSLISTENERNAMEA pListeners, - DWORD* pCount -); - -#ifdef UNICODE -#define WTSEnumerateListeners WTSEnumerateListenersW -#else -#define WTSEnumerateListeners WTSEnumerateListenersA -#endif - -/*------------------------------------------------*/ -// Listener Config, used by WTSQueryListenerConfig and WTSCreateListener - -typedef struct _WTSLISTENERCONFIGW{ - ULONG version; - ULONG fEnableListener; - ULONG MaxConnectionCount; - ULONG fPromptForPassword; - ULONG fInheritColorDepth; - ULONG ColorDepth; - ULONG fInheritBrokenTimeoutSettings; - ULONG BrokenTimeoutSettings; - - ULONG fDisablePrinterRedirection; - ULONG fDisableDriveRedirection; - ULONG fDisableComPortRedirection; - ULONG fDisableLPTPortRedirection; - ULONG fDisableClipboardRedirection; - ULONG fDisableAudioRedirection; - ULONG fDisablePNPRedirection; - ULONG fDisableDefaultMainClientPrinter; - - ULONG LanAdapter; - ULONG PortNumber; - - ULONG fInheritShadowSettings; - ULONG ShadowSettings; - - ULONG TimeoutSettingsConnection; - ULONG TimeoutSettingsDisconnection; - ULONG TimeoutSettingsIdle; - - ULONG SecurityLayer; - ULONG MinEncryptionLevel; - ULONG UserAuthentication; - - WCHAR Comment[ WTS_COMMENT_LENGTH + 1 ]; - WCHAR LogonUserName[USERNAME_LENGTH + 1 ]; - WCHAR LogonDomain[DOMAIN_LENGTH + 1 ]; - - WCHAR WorkDirectory[ MAX_PATH + 1 ]; - WCHAR InitialProgram[ MAX_PATH + 1 ]; -} WTSLISTENERCONFIGW, *PWTSLISTENERCONFIGW; - -typedef struct _WTSLISTENERCONFIGA{ - ULONG version; - ULONG fEnableListener; - ULONG MaxConnectionCount; - ULONG fPromptForPassword; - ULONG fInheritColorDepth; - ULONG ColorDepth; - ULONG fInheritBrokenTimeoutSettings; - ULONG BrokenTimeoutSettings; - - ULONG fDisablePrinterRedirection; - ULONG fDisableDriveRedirection; - ULONG fDisableComPortRedirection; - ULONG fDisableLPTPortRedirection; - ULONG fDisableClipboardRedirection; - ULONG fDisableAudioRedirection; - ULONG fDisablePNPRedirection; - ULONG fDisableDefaultMainClientPrinter; - - ULONG LanAdapter; - ULONG PortNumber; - - ULONG fInheritShadowSettings; - ULONG ShadowSettings; - - ULONG TimeoutSettingsConnection; - ULONG TimeoutSettingsDisconnection; - ULONG TimeoutSettingsIdle; - - ULONG SecurityLayer; - ULONG MinEncryptionLevel; - ULONG UserAuthentication; - - CHAR Comment[ WTS_COMMENT_LENGTH + 1 ]; - CHAR LogonUserName[USERNAME_LENGTH + 1 ]; - CHAR LogonDomain[DOMAIN_LENGTH + 1 ]; - - CHAR WorkDirectory[ MAX_PATH + 1 ]; - CHAR InitialProgram[ MAX_PATH + 1 ]; -} WTSLISTENERCONFIGA, *PWTSLISTENERCONFIGA; - -BOOL WINPR_API WTSQueryListenerConfigW ( - HANDLE hServer, - PVOID pReserved, - DWORD Reserved, - LPWSTR pListenerName, - PWTSLISTENERCONFIGW pBuffer -); - -BOOL WINPR_API WTSQueryListenerConfigA ( - HANDLE hServer, - PVOID pReserved, - DWORD Reserved, - LPSTR pListenerName, - PWTSLISTENERCONFIGA pBuffer -); - -BOOL WINPR_API WTSCreateListenerW ( - HANDLE hServer, - PVOID pReserved, - DWORD Reserved, - LPWSTR pListenerName, - PWTSLISTENERCONFIGW pBuffer, - DWORD flag -); - -BOOL WINPR_API WTSCreateListenerA ( - HANDLE hServer, - PVOID pReserved, - DWORD Reserved, - LPSTR pListenerName, - PWTSLISTENERCONFIGA pBuffer, - DWORD flag -); - -BOOL WINPR_API WTSSetListenerSecurityW( - HANDLE hServer, - PVOID pReserved, - DWORD Reserved, - LPWSTR pListenerName, - SECURITY_INFORMATION SecurityInformation, - PSECURITY_DESCRIPTOR pSecurityDescriptor); - -BOOL WINPR_API WTSSetListenerSecurityA( - HANDLE hServer, - PVOID pReserved, - DWORD Reserved, - LPSTR pListenerName, - SECURITY_INFORMATION SecurityInformation, - PSECURITY_DESCRIPTOR pSecurityDescriptor); - -BOOL WINPR_API WTSGetListenerSecurityW( - HANDLE hServer, - PVOID pReserved, - DWORD Reserved, - LPWSTR pListenerName, - SECURITY_INFORMATION SecurityInformation, - PSECURITY_DESCRIPTOR pSecurityDescriptor, - DWORD nLength, - LPDWORD lpnLengthNeeded); - - -BOOL WINPR_API WTSGetListenerSecurityA( - HANDLE hServer, - PVOID pReserved, - DWORD Reserved, - LPSTR pListenerName, - SECURITY_INFORMATION SecurityInformation, - PSECURITY_DESCRIPTOR pSecurityDescriptor, - DWORD nLength, - LPDWORD lpnLengthNeeded); - -#ifdef UNICODE -#define WTSLISTENERCONFIG WTSLISTENERCONFIGW -#define PWTSLISTENERCONFIG PWTSLISTENERCONFIGW -#define WTSQueryListenerConfig WTSQueryListenerConfigW -#define WTSCreateListener WTSCreateListenerW -#define WTSSetListenerSecurity WTSSetListenerSecurityW -#define WTSGetListenerSecurity WTSGetListenerSecurityW -#else -#define WTSLISTENERCONFIG WTSLISTENERCONFIGA -#define PWTSLISTENERCONFIG PWTSLISTENERCONFIGA -#define WTSQueryListenerConfig WTSQueryListenerConfigA -#define WTSCreateListener WTSCreateListenerA -#define WTSSetListenerSecurity WTSSetListenerSecurityA -#define WTSGetListenerSecurity WTSGetListenerSecurityA -#endif - -#ifdef __cplusplus -} -#endif - -#endif - -#endif - - diff --git a/winpr/libwinpr/wtsapi/CMakeLists.txt b/winpr/libwinpr/wtsapi/CMakeLists.txt deleted file mode 100644 index 19337721a..000000000 --- a/winpr/libwinpr/wtsapi/CMakeLists.txt +++ /dev/null @@ -1,36 +0,0 @@ -# WinPR: Windows Portable Runtime -# libwinpr-winhttp cmake build script -# -# Copyright 2012 Marc-Andre Moreau -# -# 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. - -set(MODULE_NAME "winpr-wtsapi") -set(MODULE_PREFIX "WINPR_WTSAPI") - -set(${MODULE_PREFIX}_SRCS - wtsapi.c) - -add_complex_library(MODULE ${MODULE_NAME} TYPE "OBJECT" - MONOLITHIC ${MONOLITHIC_BUILD} - SOURCES ${${MODULE_PREFIX}_SRCS}) - -set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") - -if(MONOLITHIC_BUILD) - -else() - install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) -endif() - -set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR") diff --git a/winpr/libwinpr/wtsapi/ModuleOptions.cmake b/winpr/libwinpr/wtsapi/ModuleOptions.cmake deleted file mode 100644 index e0fa34d1b..000000000 --- a/winpr/libwinpr/wtsapi/ModuleOptions.cmake +++ /dev/null @@ -1,9 +0,0 @@ - -set(MINWIN_LAYER "0") -set(MINWIN_GROUP "none") -set(MINWIN_MAJOR_VERSION "0") -set(MINWIN_MINOR_VERSION "0") -set(MINWIN_SHORT_NAME "winhttp") -set(MINWIN_LONG_NAME "Windows HTTP (WinHTTP)") -set(MODULE_LIBRARY_NAME "${MINWIN_SHORT_NAME}") - diff --git a/winpr/libwinpr/wtsapi/wtsapi.c b/winpr/libwinpr/wtsapi/wtsapi.c deleted file mode 100644 index 0efd97d42..000000000 --- a/winpr/libwinpr/wtsapi/wtsapi.c +++ /dev/null @@ -1,506 +0,0 @@ -/** - * WinPR: Windows Portable Runtime - * Windows Terminal Services API (WTSAPI) - * - * Copyright 2013 Mike McDonald - * - * 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. - */ - -#include - -BOOL WINPR_API ProcessIdToSessionId( - DWORD ProcessId, - DWORD *pSessionId -) -{ - return FALSE; -} - -VOID WINPR_API WTSCloseServer( - HANDLE hServer -) -{ -} - -BOOL WINPR_API WTSConnectSession( - ULONG LoginId, - ULONG TargetLogonId, - PSTR pPassword, - BOOL bWait -) -{ - return FALSE; -} - -BOOL WINPR_API WTSCreateListener( - HANDLE hServer, - PVOID pReserved, - DWORD Reserved, - LPTSTR pListenerName, - PWTSLISTENERCONFIG pBuffer, - DWORD flag -) -{ - return FALSE; -} - -BOOL WINPR_API WTSDisconnectSession( - HANDLE hServer, - DWORD SessionId, - BOOL bWait -) -{ - return FALSE; -} - -BOOL WINPR_API WTSEnableChildSessions( - BOOL bEnable -) -{ - return FALSE; -} - -BOOL WINPR_API WTSEnumerateListenersA( - HANDLE hServer, - PVOID pReserved, - DWORD Reserved, - PWTSLISTENERNAMEA pListeners, - DWORD *pCount -) -{ - return FALSE; -} - -BOOL WINPR_API WTSEnumerateListenersW( - HANDLE hServer, - PVOID pReserved, - DWORD Reserved, - PWTSLISTENERNAMEW pListeners, - DWORD *pCount -) -{ - return FALSE; -} - -BOOL WINPR_API WTSEnumerateProcesses( - HANDLE hServer, - DWORD Reserved, - DWORD Version, - PWTS_PROCESS_INFO *ppProcessInfo, - DWORD *pCount -) -{ - return FALSE; -} - -BOOL WINPR_API WTSEnumerateProcessesEx( - HANDLE hServer, - DWORD *pLevel, - DWORD SessionId, - LPTSTR *ppProcessInfo, - DWORD *pCount -) -{ - return FALSE; -} - -BOOL WINPR_API WTSEnumerateServers( - LPTSTR pDomainName, - DWORD Reserved, - DWORD Version, - PWTS_SERVER_INFO *ppServerInfo, - DWORD *pCount -) -{ - return FALSE; -} - -BOOL WINPR_API WTSEnumerateSessionsA( - HANDLE hServer, - DWORD Reserved, - DWORD Version, - PWTS_SESSION_INFOA *ppSessionInfo, - DWORD *pCount -) -{ - return FALSE; -} - -BOOL WINPR_API WTSEnumerateSessionsW( - HANDLE hServer, - DWORD Reserved, - DWORD Version, - PWTS_SESSION_INFOW *ppSessionInfo, - DWORD *pCount -) -{ - return FALSE; -} - -BOOL WINPR_API WTSEnumerateSessionsExA( - HANDLE hServer, - DWORD *pLevel, - DWORD Filter, - PWTS_SESSION_INFO_1A *ppSessionInfo, - DWORD *pCount -) -{ - return FALSE; -} - -BOOL WINPR_API WTSEnumerateSessionsExW( - HANDLE hServer, - DWORD *pLevel, - DWORD Filter, - PWTS_SESSION_INFO_1W *ppSessionInfo, - DWORD *pCount -) -{ - return FALSE; -} - -VOID WTSFreeMemory( - PVOID pMemory -) -{ -} - -BOOL WINPR_API WTSFreeMemoryEx( - WTS_TYPE_CLASS WTSTypeClass, - PVOID pMemory, - ULONG NumberOfEntries -) -{ - return FALSE; -} - -DWORD WINPR_API WTSGetActiveConsoleSessionId() -{ - return 0; -} - -BOOL WINPR_API WTSGetChildSessionId( - DWORD *pSessionId -) -{ - return FALSE; -} - -BOOL WINPR_API WTSGetListenerSecurityA( - HANDLE hServer, - PVOID pReserved, - DWORD Reserved, - LPSTR pListenerName, - SECURITY_INFORMATION SecurityInformation, - PSECURITY_DESCRIPTOR pSecurityDescriptor, - DWORD nLength, - LPDWORD lpnLengthNeeded -) -{ - return FALSE; -} - -BOOL WINPR_API WTSGetListenerSecurityW( - HANDLE hServer, - PVOID pReserved, - DWORD Reserved, - LPWSTR pListenerName, - SECURITY_INFORMATION SecurityInformation, - PSECURITY_DESCRIPTOR pSecurityDescriptor, - DWORD nLength, - LPDWORD lpnLengthNeeded -) -{ - return FALSE; -} - -BOOL WINPR_API WTSIsChildSessionsEnabled( - BOOL *pbEnabled -) -{ - return FALSE; -} - -BOOL WINPR_API WTSLogoffSession( - HANDLE hServer, - DWORD SessionId, - BOOL bWait -) -{ - return FALSE; -} - -HANDLE WINPR_API WTSOpenServer( - LPTSTR pServerName -) -{ - return NULL; -} - -HANDLE WINPR_API WTSOpenServerExA( - LPSTR pServerName -) -{ - return NULL; -} - -HANDLE WINPR_API WTSOpenServerExW( - LPWSTR pServerName -) -{ - return NULL; -} - -BOOL WINPR_API WTSQueryListenerConfig( - HANDLE hServer, - PVOID pReserved, - DWORD Reserved, - LPTSTR pListenerName, - PWTSLISTENERCONFIG pBuffer -) -{ - return FALSE; -} - -BOOL WINPR_API WTSQuerySessionInformation( - HANDLE hServer, - DWORD SessionId, - WTS_INFO_CLASS WTSInfoClass, - LPTSTR *ppBuffer, - DWORD *pBytesReturned -) -{ - return FALSE; -} - -BOOL WINPR_API WTSQueryUserConfig( - LPTSTR pServerName, - LPTSTR pUserName, - WTS_CONFIG_CLASS WTSConfigClass, - LPTSTR *ppBuffer, - DWORD *pBytesReturned -) -{ - return FALSE; -} - -BOOL WINPR_API WTSQueryUserToken( - DWORD SessionId, - PHANDLE phToken -) -{ - return FALSE; -} - -BOOL WINPR_API WTSRegisterSessionNotification( - HWND hWnd, - DWORD dwFlags -) -{ - return FALSE; -} - -BOOL WINPR_API WTSRegisterSessionNotificationEx( - HANDLE hServer, - HWND hWnd, - DWORD dwFlags -) -{ - return FALSE; -} - -BOOL WINPR_API WTSSendMessage( - HANDLE hServer, - DWORD SessionId, - LPTSTR pTitle, - DWORD TitleLength, - LPTSTR pMessage, - DWORD MessageLength, - DWORD Style, - DWORD Timeout, - DWORD *pResponse, - BOOL bWait -) -{ - return FALSE; -} - -BOOL WINPR_API WTSSetListenerSecurity( - HANDLE hServer, - PVOID pReserved, - DWORD Reserved, - LPTSTR pListenerName, - SECURITY_INFORMATION SecurityInformation, - PSECURITY_DESCRIPTOR pSecurityDescriptor -) -{ - return FALSE; -} - -BOOL WINPR_API WTSSetUserConfig( - LPTSTR pServerName, - LPTSTR pUserName, - WTS_CONFIG_CLASS WTSConfigClass, - LPTSTR pBuffer, - DWORD DataLength -) -{ - return FALSE; -} - -BOOL WINPR_API WTSShutdownSystem( - HANDLE hServer, - DWORD ShutdownFlag -) -{ - return FALSE; -} - -BOOL WINPR_API WTSStartRemoteControlSession( - LPTSTR pTargetServerName, - ULONG TargetLogonId, - BYTE HotkeyVk, - USHORT HotKeyModifiers -) -{ - return FALSE; -} - -BOOL WINPR_API WTSStopRemoteControlSession( - ULONG LogonId -) -{ - return FALSE; -} - -BOOL WINPR_API WTSTerminateProcess( - HANDLE hServer, - DWORD ProcessId, - DWORD ExitCode -) -{ - return FALSE; -} - -BOOL WINPR_API WTSUnregisterSessionNotification( - HWND hWnd -) -{ - return FALSE; -} - -BOOL WINPR_API WTSUnregisterSessionNotificationEx( - HANDLE hServer, - HWND hWnd -) -{ - return FALSE; -} - -BOOL WINPR_API WTSVirtualChannelClose( - HANDLE hChannelHandle -) -{ - return FALSE; -} - -BOOL WINPR_API WTSVirtualChannelOpenA( - HANDLE hServer, - DWORD SessionId, - LPSTR pVirtualName -) -{ - return FALSE; -} - -BOOL WINPR_API WTSVirtualChannelOpenW( - HANDLE hServer, - DWORD SessionId, - LPWSTR pVirtualName -) -{ - return FALSE; -} - -BOOL WINPR_API WTSVirtualChannelOpenExA( - DWORD SessionId, - LPSTR pVirtualName, - DWORD Flags -) -{ - return FALSE; -} - -BOOL WINPR_API WTSVirtualChannelOpenExW( - DWORD SessionId, - LPWSTR pVirtualName, - DWORD Flags -) -{ - return FALSE; -} - -BOOL WINPR_API WTSVirtualChannelPurgeInput( - HANDLE hChannelHandle -) -{ - return FALSE; -} - -BOOL WINPR_API WTSVirtualChannelPurgeOutput( - HANDLE hChannelHandle -) -{ - return FALSE; -} - -BOOL WINPR_API WTSVirtualChannelQuery( - HANDLE hChannelHandle, - WTS_VIRTUAL_CLASS WTSVirtualClass, - PVOID *ppBuffer, - DWORD *pBytesReturned -) -{ - return FALSE; -} - -BOOL WINPR_API WTSVirtualChannelRead( - HANDLE hChannelHandle, - ULONG TimeOut, - PCHAR Buffer, - ULONG BufferSize, - PULONG pBytesRead -) -{ - return FALSE; -} - -BOOL WINPR_API WTSVirtualChannelWrite( - HANDLE hChannelHandle, - PCHAR Buffer, - ULONG BufferSize, - PULONG pBytesWritten -) -{ - return FALSE; -} - -BOOL WINPR_API WTSWaitSystemEvent( - HANDLE hServer, - DWORD EventMask, - DWORD *pEventFlags -) -{ - return FALSE; -}