FreeRDP
wtsapi.h
1 
22 #ifndef WINPR_WTSAPI_H
23 #define WINPR_WTSAPI_H
24 
25 #include <winpr/winpr.h>
26 #include <winpr/wtypes.h>
27 
28 #include <winpr/file.h>
29 
30 #define CHANNEL_CHUNK_MAX_LENGTH 16256
31 
32 WINPR_PRAGMA_DIAG_PUSH
33 WINPR_PRAGMA_DIAG_IGNORED_RESERVED_IDENTIFIER
34 
35 #ifdef _WIN32
36 
37 #define CurrentTime _CurrentTime /* Workaround for X11 "CurrentTime" header conflict */
38 
39 #endif
40 
41 #if defined(_WIN32) && !defined(_UWP)
42 
43 #include <pchannel.h>
44 
45 #else
46 
51 #define CHANNEL_CHUNK_LENGTH 1600
52 
53 #define CHANNEL_PDU_LENGTH (CHANNEL_CHUNK_LENGTH + sizeof(CHANNEL_PDU_HEADER))
54 
55 #define CHANNEL_FLAG_FIRST 0x01
56 #define CHANNEL_FLAG_LAST 0x02
57 #define CHANNEL_FLAG_ONLY (CHANNEL_FLAG_FIRST | CHANNEL_FLAG_LAST)
58 #define CHANNEL_FLAG_MIDDLE 0
59 #define CHANNEL_FLAG_FAIL 0x100
60 
61 #define CHANNEL_OPTION_INITIALIZED 0x80000000
62 
63 #define CHANNEL_OPTION_ENCRYPT_RDP 0x40000000
64 #define CHANNEL_OPTION_ENCRYPT_SC 0x20000000
65 #define CHANNEL_OPTION_ENCRYPT_CS 0x10000000
66 #define CHANNEL_OPTION_PRI_HIGH 0x08000000
67 #define CHANNEL_OPTION_PRI_MED 0x04000000
68 #define CHANNEL_OPTION_PRI_LOW 0x02000000
69 #define CHANNEL_OPTION_COMPRESS_RDP 0x00800000
70 #define CHANNEL_OPTION_COMPRESS 0x00400000
71 #define CHANNEL_OPTION_SHOW_PROTOCOL 0x00200000
72 #define CHANNEL_OPTION_REMOTE_CONTROL_PERSISTENT 0x00100000
73 
74 #define CHANNEL_MAX_COUNT 31
75 #define CHANNEL_NAME_LEN 7
76 
77 typedef struct tagCHANNEL_DEF
78 {
79  char name[CHANNEL_NAME_LEN + 1];
80  ULONG options;
81 } CHANNEL_DEF;
82 typedef CHANNEL_DEF* PCHANNEL_DEF;
84 
85 typedef struct tagCHANNEL_PDU_HEADER
86 {
87  UINT32 length;
88  UINT32 flags;
89 } CHANNEL_PDU_HEADER, *PCHANNEL_PDU_HEADER;
90 
91 #endif /* _WIN32 */
92 
97 #ifndef CHANNEL_FLAG_SHOW_PROTOCOL
98 #define CHANNEL_FLAG_SHOW_PROTOCOL 0x10
99 #endif
100 #ifndef CHANNEL_FLAG_SUSPEND
101 #define CHANNEL_FLAG_SUSPEND 0x20
102 #endif
103 #ifndef CHANNEL_FLAG_RESUME
104 #define CHANNEL_FLAG_RESUME 0x40
105 #endif
106 #ifndef CHANNEL_FLAG_SHADOW_PERSISTENT
107 #define CHANNEL_FLAG_SHADOW_PERSISTENT 0x80
108 #endif
109 
110 #if !defined(_WIN32) || !defined(H_CCHANNEL)
111 
116 #ifdef _WIN32
117 #define VCAPITYPE __stdcall
118 #define VCEXPORT
119 #else
120 #define VCAPITYPE CALLBACK
121 #define VCEXPORT __export
122 #endif
123 
124 typedef VOID VCAPITYPE CHANNEL_INIT_EVENT_FN(LPVOID pInitHandle, UINT event, LPVOID pData,
125  UINT dataLength);
126 
127 typedef CHANNEL_INIT_EVENT_FN* PCHANNEL_INIT_EVENT_FN;
128 
129 typedef VOID VCAPITYPE CHANNEL_INIT_EVENT_EX_FN(LPVOID lpUserParam, LPVOID pInitHandle, UINT event,
130  LPVOID pData, UINT dataLength);
131 
132 typedef CHANNEL_INIT_EVENT_EX_FN* PCHANNEL_INIT_EVENT_EX_FN;
133 
134 #define CHANNEL_EVENT_INITIALIZED 0
135 #define CHANNEL_EVENT_CONNECTED 1
136 #define CHANNEL_EVENT_V1_CONNECTED 2
137 #define CHANNEL_EVENT_DISCONNECTED 3
138 #define CHANNEL_EVENT_TERMINATED 4
139 #define CHANNEL_EVENT_REMOTE_CONTROL_START 5
140 #define CHANNEL_EVENT_REMOTE_CONTROL_STOP 6
141 #define CHANNEL_EVENT_ATTACHED 7
142 #define CHANNEL_EVENT_DETACHED 8
143 #define CHANNEL_EVENT_DATA_RECEIVED 10
144 #define CHANNEL_EVENT_WRITE_COMPLETE 11
145 #define CHANNEL_EVENT_WRITE_CANCELLED 12
146 
147 typedef VOID VCAPITYPE CHANNEL_OPEN_EVENT_FN(DWORD openHandle, UINT event, LPVOID pData,
148  UINT32 dataLength, UINT32 totalLength,
149  UINT32 dataFlags);
150 
151 typedef CHANNEL_OPEN_EVENT_FN* PCHANNEL_OPEN_EVENT_FN;
152 
153 typedef VOID VCAPITYPE CHANNEL_OPEN_EVENT_EX_FN(LPVOID lpUserParam, DWORD openHandle, UINT event,
154  LPVOID pData, UINT32 dataLength, UINT32 totalLength,
155  UINT32 dataFlags);
156 
157 typedef CHANNEL_OPEN_EVENT_EX_FN* PCHANNEL_OPEN_EVENT_EX_FN;
158 
159 #define CHANNEL_RC_OK 0
160 #define CHANNEL_RC_ALREADY_INITIALIZED 1
161 #define CHANNEL_RC_NOT_INITIALIZED 2
162 #define CHANNEL_RC_ALREADY_CONNECTED 3
163 #define CHANNEL_RC_NOT_CONNECTED 4
164 #define CHANNEL_RC_TOO_MANY_CHANNELS 5
165 #define CHANNEL_RC_BAD_CHANNEL 6
166 #define CHANNEL_RC_BAD_CHANNEL_HANDLE 7
167 #define CHANNEL_RC_NO_BUFFER 8
168 #define CHANNEL_RC_BAD_INIT_HANDLE 9
169 #define CHANNEL_RC_NOT_OPEN 10
170 #define CHANNEL_RC_BAD_PROC 11
171 #define CHANNEL_RC_NO_MEMORY 12
172 #define CHANNEL_RC_UNKNOWN_CHANNEL_NAME 13
173 #define CHANNEL_RC_ALREADY_OPEN 14
174 #define CHANNEL_RC_NOT_IN_VIRTUALCHANNELENTRY 15
175 #define CHANNEL_RC_NULL_DATA 16
176 #define CHANNEL_RC_ZERO_LENGTH 17
177 #define CHANNEL_RC_INVALID_INSTANCE 18
178 #define CHANNEL_RC_UNSUPPORTED_VERSION 19
179 #define CHANNEL_RC_INITIALIZATION_ERROR 20
180 
181 #define VIRTUAL_CHANNEL_VERSION_WIN2000 1
182 
183 typedef UINT VCAPITYPE VIRTUALCHANNELINIT(LPVOID* ppInitHandle, PCHANNEL_DEF pChannel,
184  INT channelCount, ULONG versionRequested,
185  PCHANNEL_INIT_EVENT_FN pChannelInitEventProc);
186 
187 typedef VIRTUALCHANNELINIT* PVIRTUALCHANNELINIT;
188 
189 typedef UINT VCAPITYPE VIRTUALCHANNELINITEX(LPVOID lpUserParam, LPVOID clientContext,
190  LPVOID pInitHandle, PCHANNEL_DEF pChannel,
191  INT channelCount, ULONG versionRequested,
192  PCHANNEL_INIT_EVENT_EX_FN pChannelInitEventProcEx);
193 
194 typedef VIRTUALCHANNELINITEX* PVIRTUALCHANNELINITEX;
195 
196 typedef UINT VCAPITYPE VIRTUALCHANNELOPEN(LPVOID pInitHandle, LPDWORD pOpenHandle,
197  PCHAR pChannelName,
198  PCHANNEL_OPEN_EVENT_FN pChannelOpenEventProc);
199 
200 typedef VIRTUALCHANNELOPEN* PVIRTUALCHANNELOPEN;
201 
202 typedef UINT VCAPITYPE VIRTUALCHANNELOPENEX(LPVOID pInitHandle, LPDWORD pOpenHandle,
203  PCHAR pChannelName,
204  PCHANNEL_OPEN_EVENT_EX_FN pChannelOpenEventProcEx);
205 
206 typedef VIRTUALCHANNELOPENEX* PVIRTUALCHANNELOPENEX;
207 
208 typedef UINT VCAPITYPE VIRTUALCHANNELCLOSE(DWORD openHandle);
209 
210 typedef VIRTUALCHANNELCLOSE* PVIRTUALCHANNELCLOSE;
211 
212 typedef UINT VCAPITYPE VIRTUALCHANNELCLOSEEX(LPVOID pInitHandle, DWORD openHandle);
213 
214 typedef VIRTUALCHANNELCLOSEEX* PVIRTUALCHANNELCLOSEEX;
215 
216 typedef UINT VCAPITYPE VIRTUALCHANNELWRITE(DWORD openHandle, LPVOID pData, ULONG dataLength,
217  LPVOID pUserData);
218 
219 typedef VIRTUALCHANNELWRITE* PVIRTUALCHANNELWRITE;
220 
221 typedef UINT VCAPITYPE VIRTUALCHANNELWRITEEX(LPVOID pInitHandle, DWORD openHandle, LPVOID pData,
222  ULONG dataLength, LPVOID pUserData);
223 
224 typedef VIRTUALCHANNELWRITEEX* PVIRTUALCHANNELWRITEEX;
225 
226 typedef struct tagCHANNEL_ENTRY_POINTS
227 {
228  DWORD cbSize;
229  DWORD protocolVersion;
230  PVIRTUALCHANNELINIT pVirtualChannelInit;
231  PVIRTUALCHANNELOPEN pVirtualChannelOpen;
232  PVIRTUALCHANNELCLOSE pVirtualChannelClose;
233  PVIRTUALCHANNELWRITE pVirtualChannelWrite;
234 } CHANNEL_ENTRY_POINTS, *PCHANNEL_ENTRY_POINTS;
235 
236 typedef struct tagCHANNEL_ENTRY_POINTS_EX
237 {
238  DWORD cbSize;
239  DWORD protocolVersion;
240  PVIRTUALCHANNELINITEX pVirtualChannelInitEx;
241  PVIRTUALCHANNELOPENEX pVirtualChannelOpenEx;
242  PVIRTUALCHANNELCLOSEEX pVirtualChannelCloseEx;
243  PVIRTUALCHANNELWRITEEX pVirtualChannelWriteEx;
244 } CHANNEL_ENTRY_POINTS_EX, *PCHANNEL_ENTRY_POINTS_EX;
245 
246 typedef BOOL VCAPITYPE VIRTUALCHANNELENTRY(PCHANNEL_ENTRY_POINTS pEntryPoints);
247 
248 typedef VIRTUALCHANNELENTRY* PVIRTUALCHANNELENTRY;
249 
250 typedef BOOL VCAPITYPE VIRTUALCHANNELENTRYEX(PCHANNEL_ENTRY_POINTS_EX pEntryPointsEx,
251  PVOID pInitHandle);
252 
253 typedef VIRTUALCHANNELENTRYEX* PVIRTUALCHANNELENTRYEX;
254 
255 typedef HRESULT(VCAPITYPE* PFNVCAPIGETINSTANCE)(REFIID refiid, PULONG pNumObjs, PVOID* ppObjArray);
256 
257 #endif
258 
259 #if !defined(_WIN32) || !defined(_INC_WTSAPI)
260 
265 #define WTS_CURRENT_SERVER ((HANDLE)NULL)
266 #define WTS_CURRENT_SERVER_HANDLE ((HANDLE)NULL)
267 #define WTS_CURRENT_SERVER_NAME (NULL)
268 
269 #define WTS_CURRENT_SESSION ((DWORD)-1)
270 
271 #define WTS_ANY_SESSION ((DWORD)-2)
272 
273 #define IDTIMEOUT 32000
274 #define IDASYNC 32001
275 
276 #define USERNAME_LENGTH 20
277 #define CLIENTNAME_LENGTH 20
278 #define CLIENTADDRESS_LENGTH 30
279 
280 #define WTS_WSD_LOGOFF 0x00000001
281 #define WTS_WSD_SHUTDOWN 0x00000002
282 #define WTS_WSD_REBOOT 0x00000004
283 #define WTS_WSD_POWEROFF 0x00000008
284 #define WTS_WSD_FASTREBOOT 0x00000010
285 
286 #define MAX_ELAPSED_TIME_LENGTH 15
287 #define MAX_DATE_TIME_LENGTH 56
288 #define WINSTATIONNAME_LENGTH 32
289 #define DOMAIN_LENGTH 17
290 
291 #define WTS_DRIVE_LENGTH 3
292 #define WTS_LISTENER_NAME_LENGTH 32
293 #define WTS_COMMENT_LENGTH 60
294 
295 #define WTS_LISTENER_CREATE 0x00000001
296 #define WTS_LISTENER_UPDATE 0x00000010
297 
298 #define WTS_SECURITY_QUERY_INFORMATION 0x00000001
299 #define WTS_SECURITY_SET_INFORMATION 0x00000002
300 #define WTS_SECURITY_RESET 0x00000004
301 #define WTS_SECURITY_VIRTUAL_CHANNELS 0x00000008
302 #define WTS_SECURITY_REMOTE_CONTROL 0x00000010
303 #define WTS_SECURITY_LOGON 0x00000020
304 #define WTS_SECURITY_LOGOFF 0x00000040
305 #define WTS_SECURITY_MESSAGE 0x00000080
306 #define WTS_SECURITY_CONNECT 0x00000100
307 #define WTS_SECURITY_DISCONNECT 0x00000200
308 
309 #define WTS_SECURITY_GUEST_ACCESS (WTS_SECURITY_LOGON)
310 
311 #define WTS_SECURITY_CURRENT_GUEST_ACCESS (WTS_SECURITY_VIRTUAL_CHANNELS | WTS_SECURITY_LOGOFF)
312 
313 #define WTS_SECURITY_USER_ACCESS \
314  (WTS_SECURITY_CURRENT_GUEST_ACCESS | WTS_SECURITY_QUERY_INFORMATION | WTS_SECURITY_CONNECT)
315 
316 #define WTS_SECURITY_CURRENT_USER_ACCESS \
317  (WTS_SECURITY_SET_INFORMATION | WTS_SECURITY_RESET WTS_SECURITY_VIRTUAL_CHANNELS | \
318  WTS_SECURITY_LOGOFF WTS_SECURITY_DISCONNECT)
319 
320 #define WTS_SECURITY_ALL_ACCESS \
321  (STANDARD_RIGHTS_REQUIRED | WTS_SECURITY_QUERY_INFORMATION | WTS_SECURITY_SET_INFORMATION | \
322  WTS_SECURITY_RESET | WTS_SECURITY_VIRTUAL_CHANNELS | WTS_SECURITY_REMOTE_CONTROL | \
323  WTS_SECURITY_LOGON | WTS_SECURITY_MESSAGE | WTS_SECURITY_CONNECT | WTS_SECURITY_DISCONNECT)
324 
325 typedef enum
326 {
327  WTSActive,
328  WTSConnected,
329  WTSConnectQuery,
330  WTSShadow,
331  WTSDisconnected,
332  WTSIdle,
333  WTSListen,
334  WTSReset,
335  WTSDown,
336  WTSInit
337 } WTS_CONNECTSTATE_CLASS;
338 
339 typedef struct
340 {
341  LPWSTR pServerName;
343 
344 typedef struct
345 {
346  LPSTR pServerName;
348 
349 typedef struct
350 {
351  DWORD SessionId;
352  LPWSTR pWinStationName;
353  WTS_CONNECTSTATE_CLASS State;
355 
356 typedef struct
357 {
358  DWORD SessionId;
359  LPSTR pWinStationName;
360  WTS_CONNECTSTATE_CLASS State;
362 
363 typedef struct
364 {
365  DWORD ExecEnvId;
366  WTS_CONNECTSTATE_CLASS State;
367  DWORD SessionId;
368  LPWSTR pSessionName;
369  LPWSTR pHostName;
370  LPWSTR pUserName;
371  LPWSTR pDomainName;
372  LPWSTR pFarmName;
374 
375 typedef struct
376 {
377  DWORD ExecEnvId;
378  WTS_CONNECTSTATE_CLASS State;
379  DWORD SessionId;
380  LPSTR pSessionName;
381  LPSTR pHostName;
382  LPSTR pUserName;
383  LPSTR pDomainName;
384  LPSTR pFarmName;
386 
387 typedef struct
388 {
389  DWORD SessionId;
390  DWORD ProcessId;
391  LPWSTR pProcessName;
392  PSID pUserSid;
394 
395 typedef struct
396 {
397  DWORD SessionId;
398  DWORD ProcessId;
399  LPSTR pProcessName;
400  PSID pUserSid;
402 
403 #define WTS_PROTOCOL_TYPE_CONSOLE 0
404 #define WTS_PROTOCOL_TYPE_ICA 1
405 #define WTS_PROTOCOL_TYPE_RDP 2
406 
407 typedef enum
408 {
409  WTSInitialProgram,
410  WTSApplicationName,
411  WTSWorkingDirectory,
412  WTSOEMId,
413  WTSSessionId,
414  WTSUserName,
415  WTSWinStationName,
416  WTSDomainName,
417  WTSConnectState,
418  WTSClientBuildNumber,
419  WTSClientName,
420  WTSClientDirectory,
421  WTSClientProductId,
422  WTSClientHardwareId,
423  WTSClientAddress,
424  WTSClientDisplay,
425  WTSClientProtocolType,
426  WTSIdleTime,
427  WTSLogonTime,
428  WTSIncomingBytes,
429  WTSOutgoingBytes,
430  WTSIncomingFrames,
431  WTSOutgoingFrames,
432  WTSClientInfo,
433  WTSSessionInfo,
434  WTSSessionInfoEx,
435  WTSConfigInfo,
436  WTSValidationInfo,
437  WTSSessionAddressV4,
438  WTSIsRemoteSession
439 } WTS_INFO_CLASS;
440 
441 typedef struct
442 {
443  ULONG version;
444  ULONG fConnectClientDrivesAtLogon;
445  ULONG fConnectPrinterAtLogon;
446  ULONG fDisablePrinterRedirection;
447  ULONG fDisableDefaultMainClientPrinter;
448  ULONG ShadowSettings;
449  WCHAR LogonUserName[USERNAME_LENGTH + 1];
450  WCHAR LogonDomain[DOMAIN_LENGTH + 1];
451  WCHAR WorkDirectory[MAX_PATH + 1];
452  WCHAR InitialProgram[MAX_PATH + 1];
453  WCHAR ApplicationName[MAX_PATH + 1];
455 
456 typedef struct
457 {
458  ULONG version;
459  ULONG fConnectClientDrivesAtLogon;
460  ULONG fConnectPrinterAtLogon;
461  ULONG fDisablePrinterRedirection;
462  ULONG fDisableDefaultMainClientPrinter;
463  ULONG ShadowSettings;
464  CHAR LogonUserName[USERNAME_LENGTH + 1];
465  CHAR LogonDomain[DOMAIN_LENGTH + 1];
466  CHAR WorkDirectory[MAX_PATH + 1];
467  CHAR InitialProgram[MAX_PATH + 1];
468  CHAR ApplicationName[MAX_PATH + 1];
470 
471 typedef struct
472 {
473  WTS_CONNECTSTATE_CLASS State;
474  DWORD SessionId;
475  DWORD IncomingBytes;
476  DWORD OutgoingBytes;
477  DWORD IncomingFrames;
478  DWORD OutgoingFrames;
479  DWORD IncomingCompressedBytes;
480  DWORD OutgoingCompressedBytes;
481  WCHAR WinStationName[WINSTATIONNAME_LENGTH];
482  WCHAR Domain[DOMAIN_LENGTH];
483  WCHAR UserName[USERNAME_LENGTH + 1];
484  LARGE_INTEGER ConnectTime;
485  LARGE_INTEGER DisconnectTime;
486  LARGE_INTEGER LastInputTime;
487  LARGE_INTEGER LogonTime;
488  LARGE_INTEGER _CurrentTime; /* Conflicts with X11 headers */
489 } WTSINFOW, *PWTSINFOW;
490 
491 typedef struct
492 {
493  WTS_CONNECTSTATE_CLASS State;
494  DWORD SessionId;
495  DWORD IncomingBytes;
496  DWORD OutgoingBytes;
497  DWORD IncomingFrames;
498  DWORD OutgoingFrames;
499  DWORD IncomingCompressedBytes;
500  DWORD OutgoingCompressedBy;
501  CHAR WinStationName[WINSTATIONNAME_LENGTH];
502  CHAR Domain[DOMAIN_LENGTH];
503  CHAR UserName[USERNAME_LENGTH + 1];
504  LARGE_INTEGER ConnectTime;
505  LARGE_INTEGER DisconnectTime;
506  LARGE_INTEGER LastInputTime;
507  LARGE_INTEGER LogonTime;
508  LARGE_INTEGER _CurrentTime; /* Conflicts with X11 headers */
509 } WTSINFOA, *PWTSINFOA;
510 
511 #define WTS_SESSIONSTATE_UNKNOWN 0xFFFFFFFF
512 #define WTS_SESSIONSTATE_LOCK 0x00000000
513 #define WTS_SESSIONSTATE_UNLOCK 0x00000001
514 
515 typedef struct
516 {
517  ULONG SessionId;
518  WTS_CONNECTSTATE_CLASS SessionState;
519  LONG SessionFlags;
520  WCHAR WinStationName[WINSTATIONNAME_LENGTH + 1];
521  WCHAR UserName[USERNAME_LENGTH + 1];
522  WCHAR DomainName[DOMAIN_LENGTH + 1];
523  LARGE_INTEGER LogonTime;
524  LARGE_INTEGER ConnectTime;
525  LARGE_INTEGER DisconnectTime;
526  LARGE_INTEGER LastInputTime;
527  LARGE_INTEGER _CurrentTime; /* Conflicts with X11 headers */
528  DWORD IncomingBytes;
529  DWORD OutgoingBytes;
530  DWORD IncomingFrames;
531  DWORD OutgoingFrames;
532  DWORD IncomingCompressedBytes;
533  DWORD OutgoingCompressedBytes;
535 
536 typedef struct
537 {
538  ULONG SessionId;
539  WTS_CONNECTSTATE_CLASS SessionState;
540  LONG SessionFlags;
541  CHAR WinStationName[WINSTATIONNAME_LENGTH + 1];
542  CHAR UserName[USERNAME_LENGTH + 1];
543  CHAR DomainName[DOMAIN_LENGTH + 1];
544  LARGE_INTEGER LogonTime;
545  LARGE_INTEGER ConnectTime;
546  LARGE_INTEGER DisconnectTime;
547  LARGE_INTEGER LastInputTime;
548  LARGE_INTEGER _CurrentTime; /* Conflicts with X11 headers */
549  DWORD IncomingBytes;
550  DWORD OutgoingBytes;
551  DWORD IncomingFrames;
552  DWORD OutgoingFrames;
553  DWORD IncomingCompressedBytes;
554  DWORD OutgoingCompressedBytes;
556 
557 typedef union
558 {
559  WTSINFOEX_LEVEL1_W WTSInfoExLevel1;
561 
562 typedef union
563 {
564  WTSINFOEX_LEVEL1_A WTSInfoExLevel1;
566 
567 typedef struct
568 {
569  DWORD Level;
570  WTSINFOEX_LEVEL_W Data;
572 
573 typedef struct
574 {
575  DWORD Level;
576  WTSINFOEX_LEVEL_A Data;
578 
579 typedef struct
580 {
581  WCHAR ClientName[CLIENTNAME_LENGTH + 1];
582  WCHAR Domain[DOMAIN_LENGTH + 1];
583  WCHAR UserName[USERNAME_LENGTH + 1];
584  WCHAR WorkDirectory[MAX_PATH + 1];
585  WCHAR InitialProgram[MAX_PATH + 1];
586  BYTE EncryptionLevel;
587  ULONG ClientAddressFamily;
588  USHORT ClientAddress[CLIENTADDRESS_LENGTH + 1];
589  USHORT HRes;
590  USHORT VRes;
591  USHORT ColorDepth;
592  WCHAR ClientDirectory[MAX_PATH + 1];
593  ULONG ClientBuildNumber;
594  ULONG ClientHardwareId;
595  USHORT ClientProductId;
596  USHORT OutBufCountHost;
597  USHORT OutBufCountClient;
598  USHORT OutBufLength;
599  WCHAR DeviceId[MAX_PATH + 1];
601 
602 typedef struct
603 {
604  CHAR ClientName[CLIENTNAME_LENGTH + 1];
605  CHAR Domain[DOMAIN_LENGTH + 1];
606  CHAR UserName[USERNAME_LENGTH + 1];
607  CHAR WorkDirectory[MAX_PATH + 1];
608  CHAR InitialProgram[MAX_PATH + 1];
609  BYTE EncryptionLevel;
610  ULONG ClientAddressFamily;
611  USHORT ClientAddress[CLIENTADDRESS_LENGTH + 1];
612  USHORT HRes;
613  USHORT VRes;
614  USHORT ColorDepth;
615  CHAR ClientDirectory[MAX_PATH + 1];
616  ULONG ClientBuildNumber;
617  ULONG ClientHardwareId;
618  USHORT ClientProductId;
619  USHORT OutBufCountHost;
620  USHORT OutBufCountClient;
621  USHORT OutBufLength;
622  CHAR DeviceId[MAX_PATH + 1];
624 
625 #define PRODUCTINFO_COMPANYNAME_LENGTH 256
626 #define PRODUCTINFO_PRODUCTID_LENGTH 4
627 
628 typedef struct
629 {
630  CHAR CompanyName[PRODUCTINFO_COMPANYNAME_LENGTH];
631  CHAR ProductID[PRODUCTINFO_PRODUCTID_LENGTH];
632 } PRODUCT_INFOA;
633 
634 typedef struct
635 {
636  WCHAR CompanyName[PRODUCTINFO_COMPANYNAME_LENGTH];
637  WCHAR ProductID[PRODUCTINFO_PRODUCTID_LENGTH];
638 } PRODUCT_INFOW;
639 
640 #define VALIDATIONINFORMATION_LICENSE_LENGTH 16384
641 #define VALIDATIONINFORMATION_HARDWAREID_LENGTH 20
642 
643 typedef struct
644 {
645  PRODUCT_INFOA ProductInfo;
646  BYTE License[VALIDATIONINFORMATION_LICENSE_LENGTH];
647  DWORD LicenseLength;
648  BYTE HardwareID[VALIDATIONINFORMATION_HARDWAREID_LENGTH];
649  DWORD HardwareIDLength;
651 
652 typedef struct
653 {
654  PRODUCT_INFOW ProductInfo;
655  BYTE License[VALIDATIONINFORMATION_LICENSE_LENGTH];
656  DWORD LicenseLength;
657  BYTE HardwareID[VALIDATIONINFORMATION_HARDWAREID_LENGTH];
658  DWORD HardwareIDLength;
660 
661 typedef struct
662 {
663  DWORD AddressFamily;
664  BYTE Address[20];
666 
667 typedef struct
668 {
669  DWORD HorizontalResolution;
670  DWORD VerticalResolution;
671  DWORD ColorDepth;
673 
674 typedef enum
675 {
676  WTSUserConfigInitialProgram,
677  WTSUserConfigWorkingDirectory,
678  WTSUserConfigfInheritInitialProgram,
679  WTSUserConfigfAllowLogonTerminalServer,
680  WTSUserConfigTimeoutSettingsConnections,
681  WTSUserConfigTimeoutSettingsDisconnections,
682  WTSUserConfigTimeoutSettingsIdle,
683  WTSUserConfigfDeviceClientDrives,
684  WTSUserConfigfDeviceClientPrinters,
685  WTSUserConfigfDeviceClientDefaultPrinter,
686  WTSUserConfigBrokenTimeoutSettings,
687  WTSUserConfigReconnectSettings,
688  WTSUserConfigModemCallbackSettings,
689  WTSUserConfigModemCallbackPhoneNumber,
690  WTSUserConfigShadowingSettings,
691  WTSUserConfigTerminalServerProfilePath,
692  WTSUserConfigTerminalServerHomeDir,
693  WTSUserConfigTerminalServerHomeDirDrive,
694  WTSUserConfigfTerminalServerRemoteHomeDir,
695  WTSUserConfigUser
696 } WTS_CONFIG_CLASS;
697 
698 typedef enum
699 {
700  WTSUserConfigSourceSAM
701 } WTS_CONFIG_SOURCE;
702 
703 typedef struct
704 {
705  DWORD Source;
706  DWORD InheritInitialProgram;
707  DWORD AllowLogonTerminalServer;
708  DWORD TimeoutSettingsConnections;
709  DWORD TimeoutSettingsDisconnections;
710  DWORD TimeoutSettingsIdle;
711  DWORD DeviceClientDrives;
712  DWORD DeviceClientPrinters;
713  DWORD ClientDefaultPrinter;
714  DWORD BrokenTimeoutSettings;
715  DWORD ReconnectSettings;
716  DWORD ShadowingSettings;
717  DWORD TerminalServerRemoteHomeDir;
718  CHAR InitialProgram[MAX_PATH + 1];
719  CHAR WorkDirectory[MAX_PATH + 1];
720  CHAR TerminalServerProfilePath[MAX_PATH + 1];
721  CHAR TerminalServerHomeDir[MAX_PATH + 1];
722  CHAR TerminalServerHomeDirDrive[WTS_DRIVE_LENGTH + 1];
724 
725 typedef struct
726 {
727  DWORD Source;
728  DWORD InheritInitialProgram;
729  DWORD AllowLogonTerminalServer;
730  DWORD TimeoutSettingsConnections;
731  DWORD TimeoutSettingsDisconnections;
732  DWORD TimeoutSettingsIdle;
733  DWORD DeviceClientDrives;
734  DWORD DeviceClientPrinters;
735  DWORD ClientDefaultPrinter;
736  DWORD BrokenTimeoutSettings;
737  DWORD ReconnectSettings;
738  DWORD ShadowingSettings;
739  DWORD TerminalServerRemoteHomeDir;
740  WCHAR InitialProgram[MAX_PATH + 1];
741  WCHAR WorkDirectory[MAX_PATH + 1];
742  WCHAR TerminalServerProfilePath[MAX_PATH + 1];
743  WCHAR TerminalServerHomeDir[MAX_PATH + 1];
744  WCHAR TerminalServerHomeDirDrive[WTS_DRIVE_LENGTH + 1];
746 
747 #define WTS_EVENT_NONE 0x00000000
748 #define WTS_EVENT_CREATE 0x00000001
749 #define WTS_EVENT_DELETE 0x00000002
750 #define WTS_EVENT_RENAME 0x00000004
751 #define WTS_EVENT_CONNECT 0x00000008
752 #define WTS_EVENT_DISCONNECT 0x00000010
753 #define WTS_EVENT_LOGON 0x00000020
754 #define WTS_EVENT_LOGOFF 0x00000040
755 #define WTS_EVENT_STATECHANGE 0x00000080
756 #define WTS_EVENT_LICENSE 0x00000100
757 #define WTS_EVENT_ALL 0x7FFFFFFF
758 #define WTS_EVENT_FLUSH 0x80000000
759 
760 #define REMOTECONTROL_KBDSHIFT_HOTKEY 0x1
761 #define REMOTECONTROL_KBDCTRL_HOTKEY 0x2
762 #define REMOTECONTROL_KBDALT_HOTKEY 0x4
763 
764 typedef enum
765 {
766  WTSVirtualClientData,
767  WTSVirtualFileHandle,
768  WTSVirtualEventHandle, /* Extended */
769  WTSVirtualChannelReady, /* Extended */
770  WTSVirtualChannelOpenStatus /* Extended */
771 } WTS_VIRTUAL_CLASS;
772 
773 typedef struct
774 {
775  DWORD AddressFamily;
776  BYTE Address[20];
778 
779 #define WTS_CHANNEL_OPTION_DYNAMIC 0x00000001
780 #define WTS_CHANNEL_OPTION_DYNAMIC_PRI_LOW 0x00000000
781 #define WTS_CHANNEL_OPTION_DYNAMIC_PRI_MED 0x00000002
782 #define WTS_CHANNEL_OPTION_DYNAMIC_PRI_HIGH 0x00000004
783 #define WTS_CHANNEL_OPTION_DYNAMIC_PRI_REAL 0x00000006
784 #define WTS_CHANNEL_OPTION_DYNAMIC_NO_COMPRESS 0x00000008
785 
786 #define NOTIFY_FOR_ALL_SESSIONS 1
787 #define NOTIFY_FOR_THIS_SESSION 0
788 
789 #define WTS_PROCESS_INFO_LEVEL_0 0
790 #define WTS_PROCESS_INFO_LEVEL_1 1
791 
792 typedef struct
793 {
794  DWORD SessionId;
795  DWORD ProcessId;
796  LPWSTR pProcessName;
797  PSID pUserSid;
798  DWORD NumberOfThreads;
799  DWORD HandleCount;
800  DWORD PagefileUsage;
801  DWORD PeakPagefileUsage;
802  DWORD WorkingSetSize;
803  DWORD PeakWorkingSetSize;
804  LARGE_INTEGER UserTime;
805  LARGE_INTEGER KernelTime;
807 
808 typedef struct
809 {
810  DWORD SessionId;
811  DWORD ProcessId;
812  LPSTR pProcessName;
813  PSID pUserSid;
814  DWORD NumberOfThreads;
815  DWORD HandleCount;
816  DWORD PagefileUsage;
817  DWORD PeakPagefileUsage;
818  DWORD WorkingSetSize;
819  DWORD PeakWorkingSetSize;
820  LARGE_INTEGER UserTime;
821  LARGE_INTEGER KernelTime;
823 
824 typedef enum
825 {
826  WTSTypeProcessInfoLevel0,
827  WTSTypeProcessInfoLevel1,
828  WTSTypeSessionInfoLevel1
829 } WTS_TYPE_CLASS;
830 
831 typedef WCHAR WTSLISTENERNAMEW[WTS_LISTENER_NAME_LENGTH + 1];
832 typedef WTSLISTENERNAMEW* PWTSLISTENERNAMEW;
833 typedef CHAR WTSLISTENERNAMEA[WTS_LISTENER_NAME_LENGTH + 1];
834 typedef WTSLISTENERNAMEA* PWTSLISTENERNAMEA;
835 
836 typedef struct
837 {
838  ULONG version;
839  ULONG fEnableListener;
840  ULONG MaxConnectionCount;
841  ULONG fPromptForPassword;
842  ULONG fInheritColorDepth;
843  ULONG ColorDepth;
844  ULONG fInheritBrokenTimeoutSettings;
845  ULONG BrokenTimeoutSettings;
846  ULONG fDisablePrinterRedirection;
847  ULONG fDisableDriveRedirection;
848  ULONG fDisableComPortRedirection;
849  ULONG fDisableLPTPortRedirection;
850  ULONG fDisableClipboardRedirection;
851  ULONG fDisableAudioRedirection;
852  ULONG fDisablePNPRedirection;
853  ULONG fDisableDefaultMainClientPrinter;
854  ULONG LanAdapter;
855  ULONG PortNumber;
856  ULONG fInheritShadowSettings;
857  ULONG ShadowSettings;
858  ULONG TimeoutSettingsConnection;
859  ULONG TimeoutSettingsDisconnection;
860  ULONG TimeoutSettingsIdle;
861  ULONG SecurityLayer;
862  ULONG MinEncryptionLevel;
863  ULONG UserAuthentication;
864  WCHAR Comment[WTS_COMMENT_LENGTH + 1];
865  WCHAR LogonUserName[USERNAME_LENGTH + 1];
866  WCHAR LogonDomain[DOMAIN_LENGTH + 1];
867  WCHAR WorkDirectory[MAX_PATH + 1];
868  WCHAR InitialProgram[MAX_PATH + 1];
870 
871 typedef struct
872 {
873  ULONG version;
874  ULONG fEnableListener;
875  ULONG MaxConnectionCount;
876  ULONG fPromptForPassword;
877  ULONG fInheritColorDepth;
878  ULONG ColorDepth;
879  ULONG fInheritBrokenTimeoutSettings;
880  ULONG BrokenTimeoutSettings;
881  ULONG fDisablePrinterRedirection;
882  ULONG fDisableDriveRedirection;
883  ULONG fDisableComPortRedirection;
884  ULONG fDisableLPTPortRedirection;
885  ULONG fDisableClipboardRedirection;
886  ULONG fDisableAudioRedirection;
887  ULONG fDisablePNPRedirection;
888  ULONG fDisableDefaultMainClientPrinter;
889  ULONG LanAdapter;
890  ULONG PortNumber;
891  ULONG fInheritShadowSettings;
892  ULONG ShadowSettings;
893  ULONG TimeoutSettingsConnection;
894  ULONG TimeoutSettingsDisconnection;
895  ULONG TimeoutSettingsIdle;
896  ULONG SecurityLayer;
897  ULONG MinEncryptionLevel;
898  ULONG UserAuthentication;
899  CHAR Comment[WTS_COMMENT_LENGTH + 1];
900  CHAR LogonUserName[USERNAME_LENGTH + 1];
901  CHAR LogonDomain[DOMAIN_LENGTH + 1];
902  CHAR WorkDirectory[MAX_PATH + 1];
903  CHAR InitialProgram[MAX_PATH + 1];
905 
906 #ifdef UNICODE
907 #define WTS_SERVER_INFO WTS_SERVER_INFOW
908 #define PWTS_SERVER_INFO PWTS_SERVER_INFOW
909 #define WTS_SESSION_INFO WTS_SESSION_INFOW
910 #define PWTS_SESSION_INFO PWTS_SESSION_INFOW
911 #define WTS_SESSION_INFO_1 WTS_SESSION_INFO_1W
912 #define PWTS_SESSION_INFO_1 PWTS_SESSION_INFO_1W
913 #define WTS_PROCESS_INFO WTS_PROCESS_INFOW
914 #define PWTS_PROCESS_INFO PWTS_PROCESS_INFOW
915 #define WTSCONFIGINFO WTSCONFIGINFOW
916 #define PWTSCONFIGINFO PWTSCONFIGINFOW
917 #define WTSINFO WTSINFOW
918 #define PWTSINFO PWTSINFOW
919 #define WTSINFOEX WTSINFOEXW
920 #define PWTSINFOEX PWTSINFOEXW
921 #define WTSINFOEX_LEVEL WTSINFOEX_LEVEL_W
922 #define PWTSINFOEX_LEVEL PWTSINFOEX_LEVEL_W
923 #define WTSINFOEX_LEVEL1 WTSINFOEX_LEVEL1_W
924 #define PWTSINFOEX_LEVEL1 PWTSINFOEX_LEVEL1_W
925 #define WTSCLIENT WTSCLIENTW
926 #define PWTSCLIENT PWTSCLIENTW
927 #define PRODUCT_INFO PRODUCT_INFOW
928 #define WTS_VALIDATION_INFORMATION WTS_VALIDATION_INFORMATIONW
929 #define PWTS_VALIDATION_INFORMATION PWTS_VALIDATION_INFORMATIONW
930 #define WTSUSERCONFIG WTSUSERCONFIGW
931 #define PWTSUSERCONFIG PWTSUSERCONFIGW
932 #define WTS_PROCESS_INFO_EX WTS_PROCESS_INFO_EXW
933 #define PWTS_PROCESS_INFO_EX PWTS_PROCESS_INFO_EXW
934 #define WTSLISTENERNAME WTSLISTENERNAMEW
935 #define PWTSLISTENERNAME PWTSLISTENERNAMEW
936 #define WTSLISTENERCONFIG WTSLISTENERCONFIGW
937 #define PWTSLISTENERCONFIG PWTSLISTENERCONFIGW
938 #else
939 #define WTS_SERVER_INFO WTS_SERVER_INFOA
940 #define PWTS_SERVER_INFO PWTS_SERVER_INFOA
941 #define WTS_SESSION_INFO WTS_SESSION_INFOA
942 #define PWTS_SESSION_INFO PWTS_SESSION_INFOA
943 #define WTS_SESSION_INFO_1 WTS_SESSION_INFO_1A
944 #define PWTS_SESSION_INFO_1 PWTS_SESSION_INFO_1A
945 #define WTS_PROCESS_INFO WTS_PROCESS_INFOA
946 #define PWTS_PROCESS_INFO PWTS_PROCESS_INFOA
947 #define WTSCONFIGINFO WTSCONFIGINFOA
948 #define PWTSCONFIGINFO PWTSCONFIGINFOA
949 #define WTSINFO WTSINFOA
950 #define PWTSINFO PWTSINFOA
951 #define WTSINFOEX WTSINFOEXA
952 #define PWTSINFOEX PWTSINFOEXA
953 #define WTSINFOEX_LEVEL WTSINFOEX_LEVEL_A
954 #define PWTSINFOEX_LEVEL PWTSINFOEX_LEVEL_A
955 #define WTSINFOEX_LEVEL1 WTSINFOEX_LEVEL1_A
956 #define PWTSINFOEX_LEVEL1 PWTSINFOEX_LEVEL1_A
957 #define WTSCLIENT WTSCLIENTA
958 #define PWTSCLIENT PWTSCLIENTA
959 #define PRODUCT_INFO PRODUCT_INFOA
960 #define WTS_VALIDATION_INFORMATION WTS_VALIDATION_INFORMATIONA
961 #define PWTS_VALIDATION_INFORMATION PWTS_VALIDATION_INFORMATIONA
962 #define WTSUSERCONFIG WTSUSERCONFIGA
963 #define PWTSUSERCONFIG PWTSUSERCONFIGA
964 #define WTS_PROCESS_INFO_EX WTS_PROCESS_INFO_EXA
965 #define PWTS_PROCESS_INFO_EX PWTS_PROCESS_INFO_EXA
966 #define WTSLISTENERNAME WTSLISTENERNAMEA
967 #define PWTSLISTENERNAME PWTSLISTENERNAMEA
968 #define WTSLISTENERCONFIG WTSLISTENERCONFIGA
969 #define PWTSLISTENERCONFIG PWTSLISTENERCONFIGA
970 #endif
971 
972 #define REMOTECONTROL_FLAG_DISABLE_KEYBOARD 0x00000001
973 #define REMOTECONTROL_FLAG_DISABLE_MOUSE 0x00000002
974 #define REMOTECONTROL_FLAG_DISABLE_INPUT \
975  REMOTECONTROL_FLAG_DISABLE_KEYBOARD | REMOTECONTROL_FLAG_DISABLE_MOUSE
976 
977 #ifdef __cplusplus
978 extern "C"
979 {
980 #endif
981 
982  WINPR_API BOOL WINAPI WTSStopRemoteControlSession(ULONG LogonId);
983 
984  WINPR_API BOOL WINAPI WTSStartRemoteControlSessionW(LPWSTR pTargetServerName,
985  ULONG TargetLogonId, BYTE HotkeyVk,
986  USHORT HotkeyModifiers);
987  WINPR_API BOOL WINAPI WTSStartRemoteControlSessionA(LPSTR pTargetServerName,
988  ULONG TargetLogonId, BYTE HotkeyVk,
989  USHORT HotkeyModifiers);
990 
991  WINPR_API BOOL WINAPI WTSStartRemoteControlSessionExW(LPWSTR pTargetServerName,
992  ULONG TargetLogonId, BYTE HotkeyVk,
993  USHORT HotkeyModifiers, DWORD flags);
994  WINPR_API BOOL WINAPI WTSStartRemoteControlSessionExA(LPSTR pTargetServerName,
995  ULONG TargetLogonId, BYTE HotkeyVk,
996  USHORT HotkeyModifiers, DWORD flags);
997 
998  WINPR_API BOOL WINAPI WTSConnectSessionW(ULONG LogonId, ULONG TargetLogonId, PWSTR pPassword,
999  BOOL bWait);
1000  WINPR_API BOOL WINAPI WTSConnectSessionA(ULONG LogonId, ULONG TargetLogonId, PSTR pPassword,
1001  BOOL bWait);
1002 
1003  WINPR_API BOOL WINAPI WTSEnumerateServersW(LPWSTR pDomainName, DWORD Reserved, DWORD Version,
1004  PWTS_SERVER_INFOW* ppServerInfo, DWORD* pCount);
1005  WINPR_API BOOL WINAPI WTSEnumerateServersA(LPSTR pDomainName, DWORD Reserved, DWORD Version,
1006  PWTS_SERVER_INFOA* ppServerInfo, DWORD* pCount);
1007 
1008  WINPR_API VOID WINAPI WTSCloseServer(HANDLE hServer);
1009 
1010  WINPR_ATTR_MALLOC(WTSCloseServer, 1)
1011  WINPR_API HANDLE WINAPI WTSOpenServerW(LPWSTR pServerName);
1012 
1013  WINPR_ATTR_MALLOC(WTSCloseServer, 1)
1014  WINPR_API HANDLE WINAPI WTSOpenServerA(LPSTR pServerName);
1015 
1016  WINPR_ATTR_MALLOC(WTSCloseServer, 1)
1017  WINPR_API HANDLE WINAPI WTSOpenServerExW(LPWSTR pServerName);
1018 
1019  WINPR_ATTR_MALLOC(WTSCloseServer, 1)
1020  WINPR_API HANDLE WINAPI WTSOpenServerExA(LPSTR pServerName);
1021 
1022  WINPR_API BOOL WINAPI WTSEnumerateSessionsW(HANDLE hServer, DWORD Reserved, DWORD Version,
1023  PWTS_SESSION_INFOW* ppSessionInfo, DWORD* pCount);
1024  WINPR_API BOOL WINAPI WTSEnumerateSessionsA(HANDLE hServer, DWORD Reserved, DWORD Version,
1025  PWTS_SESSION_INFOA* ppSessionInfo, DWORD* pCount);
1026 
1027  WINPR_API BOOL WINAPI WTSEnumerateSessionsExW(HANDLE hServer, DWORD* pLevel, DWORD Filter,
1028  PWTS_SESSION_INFO_1W* ppSessionInfo,
1029  DWORD* pCount);
1030  WINPR_API BOOL WINAPI WTSEnumerateSessionsExA(HANDLE hServer, DWORD* pLevel, DWORD Filter,
1031  PWTS_SESSION_INFO_1A* ppSessionInfo,
1032  DWORD* pCount);
1033 
1034  WINPR_API BOOL WINAPI WTSEnumerateProcessesW(HANDLE hServer, DWORD Reserved, DWORD Version,
1035  PWTS_PROCESS_INFOW* ppProcessInfo, DWORD* pCount);
1036  WINPR_API BOOL WINAPI WTSEnumerateProcessesA(HANDLE hServer, DWORD Reserved, DWORD Version,
1037  PWTS_PROCESS_INFOA* ppProcessInfo, DWORD* pCount);
1038 
1039  WINPR_API BOOL WINAPI WTSTerminateProcess(HANDLE hServer, DWORD ProcessId, DWORD ExitCode);
1040 
1041  WINPR_API BOOL WINAPI WTSQuerySessionInformationW(HANDLE hServer, DWORD SessionId,
1042  WTS_INFO_CLASS WTSInfoClass, LPWSTR* ppBuffer,
1043  DWORD* pBytesReturned);
1044  WINPR_API BOOL WINAPI WTSQuerySessionInformationA(HANDLE hServer, DWORD SessionId,
1045  WTS_INFO_CLASS WTSInfoClass, LPSTR* ppBuffer,
1046  DWORD* pBytesReturned);
1047 
1048  WINPR_API BOOL WINAPI WTSQueryUserConfigW(LPWSTR pServerName, LPWSTR pUserName,
1049  WTS_CONFIG_CLASS WTSConfigClass, LPWSTR* ppBuffer,
1050  DWORD* pBytesReturned);
1051  WINPR_API BOOL WINAPI WTSQueryUserConfigA(LPSTR pServerName, LPSTR pUserName,
1052  WTS_CONFIG_CLASS WTSConfigClass, LPSTR* ppBuffer,
1053  DWORD* pBytesReturned);
1054 
1055  WINPR_API BOOL WINAPI WTSSetUserConfigW(LPWSTR pServerName, LPWSTR pUserName,
1056  WTS_CONFIG_CLASS WTSConfigClass, LPWSTR pBuffer,
1057  DWORD DataLength);
1058  WINPR_API BOOL WINAPI WTSSetUserConfigA(LPSTR pServerName, LPSTR pUserName,
1059  WTS_CONFIG_CLASS WTSConfigClass, LPSTR pBuffer,
1060  DWORD DataLength);
1061 
1062  WINPR_API BOOL WINAPI WTSSendMessageW(HANDLE hServer, DWORD SessionId, LPWSTR pTitle,
1063  DWORD TitleLength, LPWSTR pMessage, DWORD MessageLength,
1064  DWORD Style, DWORD Timeout, DWORD* pResponse, BOOL bWait);
1065  WINPR_API BOOL WINAPI WTSSendMessageA(HANDLE hServer, DWORD SessionId, LPSTR pTitle,
1066  DWORD TitleLength, LPSTR pMessage, DWORD MessageLength,
1067  DWORD Style, DWORD Timeout, DWORD* pResponse, BOOL bWait);
1068 
1069  WINPR_API BOOL WINAPI WTSDisconnectSession(HANDLE hServer, DWORD SessionId, BOOL bWait);
1070 
1071  WINPR_API BOOL WINAPI WTSLogoffSession(HANDLE hServer, DWORD SessionId, BOOL bWait);
1072 
1073  WINPR_API BOOL WINAPI WTSShutdownSystem(HANDLE hServer, DWORD ShutdownFlag);
1074 
1075  WINPR_API BOOL WINAPI WTSWaitSystemEvent(HANDLE hServer, DWORD EventMask, DWORD* pEventFlags);
1076 
1077  WINPR_API BOOL WINAPI WTSVirtualChannelClose(HANDLE hChannelHandle);
1078 
1079  WINPR_ATTR_MALLOC(WTSVirtualChannelClose, 1)
1080  WINPR_API HANDLE WINAPI WTSVirtualChannelOpen(HANDLE hServer, DWORD SessionId,
1081  LPSTR pVirtualName);
1082 
1083  WINPR_ATTR_MALLOC(WTSVirtualChannelClose, 1)
1084  WINPR_API HANDLE WINAPI WTSVirtualChannelOpenEx(DWORD SessionId, LPSTR pVirtualName,
1085  DWORD flags);
1086 
1087  WINPR_API BOOL WINAPI WTSVirtualChannelRead(HANDLE hChannelHandle, ULONG TimeOut, PCHAR Buffer,
1088  ULONG BufferSize, PULONG pBytesRead);
1089 
1090  WINPR_API BOOL WINAPI WTSVirtualChannelWrite(HANDLE hChannelHandle, PCHAR Buffer, ULONG Length,
1091  PULONG pBytesWritten);
1092 
1093  WINPR_API BOOL WINAPI WTSVirtualChannelPurgeInput(HANDLE hChannelHandle);
1094 
1095  WINPR_API BOOL WINAPI WTSVirtualChannelPurgeOutput(HANDLE hChannelHandle);
1096 
1097  WINPR_API BOOL WINAPI WTSVirtualChannelQuery(HANDLE hChannelHandle,
1098  WTS_VIRTUAL_CLASS WtsVirtualClass, PVOID* ppBuffer,
1099  DWORD* pBytesReturned);
1100 
1101  WINPR_API VOID WINAPI WTSFreeMemory(PVOID pMemory);
1102 
1103  WINPR_API BOOL WINAPI WTSRegisterSessionNotification(HWND hWnd, DWORD dwFlags);
1104 
1105  WINPR_API BOOL WINAPI WTSUnRegisterSessionNotification(HWND hWnd);
1106 
1107  WINPR_API BOOL WINAPI WTSRegisterSessionNotificationEx(HANDLE hServer, HWND hWnd,
1108  DWORD dwFlags);
1109 
1110  WINPR_API BOOL WINAPI WTSUnRegisterSessionNotificationEx(HANDLE hServer, HWND hWnd);
1111 
1112  WINPR_API BOOL WINAPI WTSQueryUserToken(ULONG SessionId, PHANDLE phToken);
1113 
1114  WINPR_API BOOL WINAPI WTSFreeMemoryExW(WTS_TYPE_CLASS WTSTypeClass, PVOID pMemory,
1115  ULONG NumberOfEntries);
1116  WINPR_API BOOL WINAPI WTSFreeMemoryExA(WTS_TYPE_CLASS WTSTypeClass, PVOID pMemory,
1117  ULONG NumberOfEntries);
1118 
1119  WINPR_API BOOL WINAPI WTSEnumerateProcessesExW(HANDLE hServer, DWORD* pLevel, DWORD SessionId,
1120  LPWSTR* ppProcessInfo, DWORD* pCount);
1121  WINPR_API BOOL WINAPI WTSEnumerateProcessesExA(HANDLE hServer, DWORD* pLevel, DWORD SessionId,
1122  LPSTR* ppProcessInfo, DWORD* pCount);
1123 
1124  WINPR_API BOOL WINAPI WTSEnumerateListenersW(HANDLE hServer, PVOID pReserved, DWORD Reserved,
1125  PWTSLISTENERNAMEW pListeners, DWORD* pCount);
1126  WINPR_API BOOL WINAPI WTSEnumerateListenersA(HANDLE hServer, PVOID pReserved, DWORD Reserved,
1127  PWTSLISTENERNAMEA pListeners, DWORD* pCount);
1128 
1129  WINPR_API BOOL WINAPI WTSQueryListenerConfigW(HANDLE hServer, PVOID pReserved, DWORD Reserved,
1130  LPWSTR pListenerName,
1131  PWTSLISTENERCONFIGW pBuffer);
1132  WINPR_API BOOL WINAPI WTSQueryListenerConfigA(HANDLE hServer, PVOID pReserved, DWORD Reserved,
1133  LPSTR pListenerName, PWTSLISTENERCONFIGA pBuffer);
1134 
1135  WINPR_API BOOL WINAPI WTSCreateListenerW(HANDLE hServer, PVOID pReserved, DWORD Reserved,
1136  LPWSTR pListenerName, PWTSLISTENERCONFIGW pBuffer,
1137  DWORD flag);
1138  WINPR_API BOOL WINAPI WTSCreateListenerA(HANDLE hServer, PVOID pReserved, DWORD Reserved,
1139  LPSTR pListenerName, PWTSLISTENERCONFIGA pBuffer,
1140  DWORD flag);
1141 
1142  WINPR_API BOOL WINAPI WTSSetListenerSecurityW(HANDLE hServer, PVOID pReserved, DWORD Reserved,
1143  LPWSTR pListenerName,
1144  SECURITY_INFORMATION SecurityInformation,
1145  PSECURITY_DESCRIPTOR pSecurityDescriptor);
1146  WINPR_API BOOL WINAPI WTSSetListenerSecurityA(HANDLE hServer, PVOID pReserved, DWORD Reserved,
1147  LPSTR pListenerName,
1148  SECURITY_INFORMATION SecurityInformation,
1149  PSECURITY_DESCRIPTOR pSecurityDescriptor);
1150 
1151  WINPR_API BOOL WINAPI WTSGetListenerSecurityW(HANDLE hServer, PVOID pReserved, DWORD Reserved,
1152  LPWSTR pListenerName,
1153  SECURITY_INFORMATION SecurityInformation,
1154  PSECURITY_DESCRIPTOR pSecurityDescriptor,
1155  DWORD nLength, LPDWORD lpnLengthNeeded);
1156  WINPR_API BOOL WINAPI WTSGetListenerSecurityA(HANDLE hServer, PVOID pReserved, DWORD Reserved,
1157  LPSTR pListenerName,
1158  SECURITY_INFORMATION SecurityInformation,
1159  PSECURITY_DESCRIPTOR pSecurityDescriptor,
1160  DWORD nLength, LPDWORD lpnLengthNeeded);
1161 
1168  WINPR_API BOOL CDECL WTSEnableChildSessions(BOOL bEnable);
1169 
1170  WINPR_API BOOL CDECL WTSIsChildSessionsEnabled(PBOOL pbEnabled);
1171 
1172  WINPR_API BOOL CDECL WTSGetChildSessionId(PULONG pSessionId);
1173 
1174  WINPR_API BOOL CDECL WTSLogonUser(HANDLE hServer, LPCSTR username, LPCSTR password,
1175  LPCSTR domain);
1176 
1177  WINPR_API BOOL CDECL WTSLogoffUser(HANDLE hServer);
1178 
1179 #ifdef __cplusplus
1180 }
1181 #endif
1182 
1183 #ifdef UNICODE
1184 #define WTSStartRemoteControlSession WTSStartRemoteControlSessionW
1185 #define WTSStartRemoteControlSessionEx WTSStartRemoteControlSessionExW
1186 #define WTSConnectSession WTSConnectSessionW
1187 #define WTSEnumerateServers WTSEnumerateServersW
1188 #define WTSOpenServer WTSOpenServerW
1189 #define WTSOpenServerEx WTSOpenServerExW
1190 #define WTSEnumerateSessions WTSEnumerateSessionsW
1191 #define WTSEnumerateSessionsEx WTSEnumerateSessionsExW
1192 #define WTSEnumerateProcesses WTSEnumerateProcessesW
1193 #define WTSQuerySessionInformation WTSQuerySessionInformationW
1194 #define WTSQueryUserConfig WTSQueryUserConfigW
1195 #define WTSSetUserConfig WTSSetUserConfigW
1196 #define WTSSendMessage WTSSendMessageW
1197 #define WTSFreeMemoryEx WTSFreeMemoryExW
1198 #define WTSEnumerateProcessesEx WTSEnumerateProcessesExW
1199 #define WTSEnumerateListeners WTSEnumerateListenersW
1200 #define WTSQueryListenerConfig WTSQueryListenerConfigW
1201 #define WTSCreateListener WTSCreateListenerW
1202 #define WTSSetListenerSecurity WTSSetListenerSecurityW
1203 #define WTSGetListenerSecurity WTSGetListenerSecurityW
1204 #else
1205 #define WTSStartRemoteControlSession WTSStartRemoteControlSessionA
1206 #define WTSStartRemoteControlSessionEx WTSStartRemoteControlSessionExA
1207 #define WTSConnectSession WTSConnectSessionA
1208 #define WTSEnumerateServers WTSEnumerateServersA
1209 #define WTSOpenServer WTSOpenServerA
1210 #define WTSOpenServerEx WTSOpenServerExA
1211 #define WTSEnumerateSessions WTSEnumerateSessionsA
1212 #define WTSEnumerateSessionsEx WTSEnumerateSessionsExA
1213 #define WTSEnumerateProcesses WTSEnumerateProcessesA
1214 #define WTSQuerySessionInformation WTSQuerySessionInformationA
1215 #define WTSQueryUserConfig WTSQueryUserConfigA
1216 #define WTSSetUserConfig WTSSetUserConfigA
1217 #define WTSSendMessage WTSSendMessageA
1218 #define WTSFreeMemoryEx WTSFreeMemoryExA
1219 #define WTSEnumerateProcessesEx WTSEnumerateProcessesExA
1220 #define WTSEnumerateListeners WTSEnumerateListenersA
1221 #define WTSQueryListenerConfig WTSQueryListenerConfigA
1222 #define WTSCreateListener WTSCreateListenerA
1223 #define WTSSetListenerSecurity WTSSetListenerSecurityA
1224 #define WTSGetListenerSecurity WTSGetListenerSecurityA
1225 #endif
1226 
1227 #endif
1228 
1229 #ifndef _WIN32
1230 
1236 WINPR_API DWORD WINAPI WTSGetActiveConsoleSessionId(void);
1237 
1238 #endif
1239 
1240 typedef BOOL(WINAPI* WTS_STOP_REMOTE_CONTROL_SESSION_FN)(ULONG LogonId);
1241 
1242 typedef BOOL(WINAPI* WTS_START_REMOTE_CONTROL_SESSION_FN_W)(LPWSTR pTargetServerName,
1243  ULONG TargetLogonId, BYTE HotkeyVk,
1244  USHORT HotkeyModifiers);
1245 typedef BOOL(WINAPI* WTS_START_REMOTE_CONTROL_SESSION_FN_A)(LPSTR pTargetServerName,
1246  ULONG TargetLogonId, BYTE HotkeyVk,
1247  USHORT HotkeyModifiers);
1248 
1249 typedef BOOL(WINAPI* WTS_START_REMOTE_CONTROL_SESSION_EX_FN_W)(LPWSTR pTargetServerName,
1250  ULONG TargetLogonId, BYTE HotkeyVk,
1251  USHORT HotkeyModifiers, DWORD flags);
1252 typedef BOOL(WINAPI* WTS_START_REMOTE_CONTROL_SESSION_EX_FN_A)(LPSTR pTargetServerName,
1253  ULONG TargetLogonId, BYTE HotkeyVk,
1254  USHORT HotkeyModifiers, DWORD flags);
1255 
1256 typedef BOOL(WINAPI* WTS_CONNECT_SESSION_FN_W)(ULONG LogonId, ULONG TargetLogonId, PWSTR pPassword,
1257  BOOL bWait);
1258 typedef BOOL(WINAPI* WTS_CONNECT_SESSION_FN_A)(ULONG LogonId, ULONG TargetLogonId, PSTR pPassword,
1259  BOOL bWait);
1260 
1261 typedef BOOL(WINAPI* WTS_ENUMERATE_SERVERS_FN_W)(LPWSTR pDomainName, DWORD Reserved, DWORD Version,
1262  PWTS_SERVER_INFOW* ppServerInfo, DWORD* pCount);
1263 typedef BOOL(WINAPI* WTS_ENUMERATE_SERVERS_FN_A)(LPSTR pDomainName, DWORD Reserved, DWORD Version,
1264  PWTS_SERVER_INFOA* ppServerInfo, DWORD* pCount);
1265 
1266 typedef HANDLE(WINAPI* WTS_OPEN_SERVER_FN_W)(LPWSTR pServerName);
1267 typedef HANDLE(WINAPI* WTS_OPEN_SERVER_FN_A)(LPSTR pServerName);
1268 
1269 typedef HANDLE(WINAPI* WTS_OPEN_SERVER_EX_FN_W)(LPWSTR pServerName);
1270 typedef HANDLE(WINAPI* WTS_OPEN_SERVER_EX_FN_A)(LPSTR pServerName);
1271 
1272 typedef VOID(WINAPI* WTS_CLOSE_SERVER_FN)(HANDLE hServer);
1273 
1274 typedef BOOL(WINAPI* WTS_ENUMERATE_SESSIONS_FN_W)(HANDLE hServer, DWORD Reserved, DWORD Version,
1275  PWTS_SESSION_INFOW* ppSessionInfo, DWORD* pCount);
1276 typedef BOOL(WINAPI* WTS_ENUMERATE_SESSIONS_FN_A)(HANDLE hServer, DWORD Reserved, DWORD Version,
1277  PWTS_SESSION_INFOA* ppSessionInfo, DWORD* pCount);
1278 
1279 typedef BOOL(WINAPI* WTS_ENUMERATE_SESSIONS_EX_FN_W)(HANDLE hServer, DWORD* pLevel, DWORD Filter,
1280  PWTS_SESSION_INFO_1W* ppSessionInfo,
1281  DWORD* pCount);
1282 typedef BOOL(WINAPI* WTS_ENUMERATE_SESSIONS_EX_FN_A)(HANDLE hServer, DWORD* pLevel, DWORD Filter,
1283  PWTS_SESSION_INFO_1A* ppSessionInfo,
1284  DWORD* pCount);
1285 
1286 typedef BOOL(WINAPI* WTS_ENUMERATE_PROCESSES_FN_W)(HANDLE hServer, DWORD Reserved, DWORD Version,
1287  PWTS_PROCESS_INFOW* ppProcessInfo,
1288  DWORD* pCount);
1289 typedef BOOL(WINAPI* WTS_ENUMERATE_PROCESSES_FN_A)(HANDLE hServer, DWORD Reserved, DWORD Version,
1290  PWTS_PROCESS_INFOA* ppProcessInfo,
1291  DWORD* pCount);
1292 
1293 typedef BOOL(WINAPI* WTS_TERMINATE_PROCESS_FN)(HANDLE hServer, DWORD ProcessId, DWORD ExitCode);
1294 
1295 typedef BOOL(WINAPI* WTS_QUERY_SESSION_INFORMATION_FN_W)(HANDLE hServer, DWORD SessionId,
1296  WTS_INFO_CLASS WTSInfoClass,
1297  LPWSTR* ppBuffer, DWORD* pBytesReturned);
1298 typedef BOOL(WINAPI* WTS_QUERY_SESSION_INFORMATION_FN_A)(HANDLE hServer, DWORD SessionId,
1299  WTS_INFO_CLASS WTSInfoClass,
1300  LPSTR* ppBuffer, DWORD* pBytesReturned);
1301 
1302 typedef BOOL(WINAPI* WTS_QUERY_USER_CONFIG_FN_W)(LPWSTR pServerName, LPWSTR pUserName,
1303  WTS_CONFIG_CLASS WTSConfigClass, LPWSTR* ppBuffer,
1304  DWORD* pBytesReturned);
1305 typedef BOOL(WINAPI* WTS_QUERY_USER_CONFIG_FN_A)(LPSTR pServerName, LPSTR pUserName,
1306  WTS_CONFIG_CLASS WTSConfigClass, LPSTR* ppBuffer,
1307  DWORD* pBytesReturned);
1308 
1309 typedef BOOL(WINAPI* WTS_SET_USER_CONFIG_FN_W)(LPWSTR pServerName, LPWSTR pUserName,
1310  WTS_CONFIG_CLASS WTSConfigClass, LPWSTR pBuffer,
1311  DWORD DataLength);
1312 typedef BOOL(WINAPI* WTS_SET_USER_CONFIG_FN_A)(LPSTR pServerName, LPSTR pUserName,
1313  WTS_CONFIG_CLASS WTSConfigClass, LPSTR pBuffer,
1314  DWORD DataLength);
1315 
1316 typedef BOOL(WINAPI* WTS_SEND_MESSAGE_FN_W)(HANDLE hServer, DWORD SessionId, LPWSTR pTitle,
1317  DWORD TitleLength, LPWSTR pMessage, DWORD MessageLength,
1318  DWORD Style, DWORD Timeout, DWORD* pResponse,
1319  BOOL bWait);
1320 typedef BOOL(WINAPI* WTS_SEND_MESSAGE_FN_A)(HANDLE hServer, DWORD SessionId, LPSTR pTitle,
1321  DWORD TitleLength, LPSTR pMessage, DWORD MessageLength,
1322  DWORD Style, DWORD Timeout, DWORD* pResponse,
1323  BOOL bWait);
1324 
1325 typedef BOOL(WINAPI* WTS_DISCONNECT_SESSION_FN)(HANDLE hServer, DWORD SessionId, BOOL bWait);
1326 
1327 typedef BOOL(WINAPI* WTS_LOGOFF_SESSION_FN)(HANDLE hServer, DWORD SessionId, BOOL bWait);
1328 
1329 typedef BOOL(WINAPI* WTS_SHUTDOWN_SYSTEM_FN)(HANDLE hServer, DWORD ShutdownFlag);
1330 
1331 typedef BOOL(WINAPI* WTS_WAIT_SYSTEM_EVENT_FN)(HANDLE hServer, DWORD EventMask, DWORD* pEventFlags);
1332 
1333 typedef HANDLE(WINAPI* WTS_VIRTUAL_CHANNEL_OPEN_FN)(HANDLE hServer, DWORD SessionId,
1334  LPSTR pVirtualName);
1335 
1336 typedef HANDLE(WINAPI* WTS_VIRTUAL_CHANNEL_OPEN_EX_FN)(DWORD SessionId, LPSTR pVirtualName,
1337  DWORD flags);
1338 
1339 typedef BOOL(WINAPI* WTS_VIRTUAL_CHANNEL_CLOSE_FN)(HANDLE hChannelHandle);
1340 
1341 typedef BOOL(WINAPI* WTS_VIRTUAL_CHANNEL_READ_FN)(HANDLE hChannelHandle, ULONG TimeOut,
1342  PCHAR Buffer, ULONG BufferSize,
1343  PULONG pBytesRead);
1344 
1345 typedef BOOL(WINAPI* WTS_VIRTUAL_CHANNEL_WRITE_FN)(HANDLE hChannelHandle, PCHAR Buffer,
1346  ULONG Length, PULONG pBytesWritten);
1347 
1348 typedef BOOL(WINAPI* WTS_VIRTUAL_CHANNEL_PURGE_INPUT_FN)(HANDLE hChannelHandle);
1349 
1350 typedef BOOL(WINAPI* WTS_VIRTUAL_CHANNEL_PURGE_OUTPUT_FN)(HANDLE hChannelHandle);
1351 
1352 typedef BOOL(WINAPI* WTS_VIRTUAL_CHANNEL_QUERY_FN)(HANDLE hChannelHandle,
1353  WTS_VIRTUAL_CLASS WtsVirtualClass,
1354  PVOID* ppBuffer, DWORD* pBytesReturned);
1355 
1356 typedef VOID(WINAPI* WTS_FREE_MEMORY_FN)(PVOID pMemory);
1357 
1358 typedef BOOL(WINAPI* WTS_REGISTER_SESSION_NOTIFICATION_FN)(HWND hWnd, DWORD dwFlags);
1359 
1360 typedef BOOL(WINAPI* WTS_UNREGISTER_SESSION_NOTIFICATION_FN)(HWND hWnd);
1361 
1362 typedef BOOL(WINAPI* WTS_REGISTER_SESSION_NOTIFICATION_EX_FN)(HANDLE hServer, HWND hWnd,
1363  DWORD dwFlags);
1364 
1365 typedef BOOL(WINAPI* WTS_UNREGISTER_SESSION_NOTIFICATION_EX_FN)(HANDLE hServer, HWND hWnd);
1366 
1367 typedef BOOL(WINAPI* WTS_QUERY_USER_TOKEN_FN)(ULONG SessionId, PHANDLE phToken);
1368 
1369 typedef BOOL(WINAPI* WTS_FREE_MEMORY_EX_FN_W)(WTS_TYPE_CLASS WTSTypeClass, PVOID pMemory,
1370  ULONG NumberOfEntries);
1371 typedef BOOL(WINAPI* WTS_FREE_MEMORY_EX_FN_A)(WTS_TYPE_CLASS WTSTypeClass, PVOID pMemory,
1372  ULONG NumberOfEntries);
1373 
1374 typedef BOOL(WINAPI* WTS_ENUMERATE_PROCESSES_EX_FN_W)(HANDLE hServer, DWORD* pLevel,
1375  DWORD SessionId, LPWSTR* ppProcessInfo,
1376  DWORD* pCount);
1377 typedef BOOL(WINAPI* WTS_ENUMERATE_PROCESSES_EX_FN_A)(HANDLE hServer, DWORD* pLevel,
1378  DWORD SessionId, LPSTR* ppProcessInfo,
1379  DWORD* pCount);
1380 
1381 typedef BOOL(WINAPI* WTS_ENUMERATE_LISTENERS_FN_W)(HANDLE hServer, PVOID pReserved, DWORD Reserved,
1382  PWTSLISTENERNAMEW pListeners, DWORD* pCount);
1383 typedef BOOL(WINAPI* WTS_ENUMERATE_LISTENERS_FN_A)(HANDLE hServer, PVOID pReserved, DWORD Reserved,
1384  PWTSLISTENERNAMEA pListeners, DWORD* pCount);
1385 
1386 typedef BOOL(WINAPI* WTS_QUERY_LISTENER_CONFIG_FN_W)(HANDLE hServer, PVOID pReserved,
1387  DWORD Reserved, LPWSTR pListenerName,
1388  PWTSLISTENERCONFIGW pBuffer);
1389 typedef BOOL(WINAPI* WTS_QUERY_LISTENER_CONFIG_FN_A)(HANDLE hServer, PVOID pReserved,
1390  DWORD Reserved, LPSTR pListenerName,
1391  PWTSLISTENERCONFIGA pBuffer);
1392 
1393 typedef BOOL(WINAPI* WTS_CREATE_LISTENER_FN_W)(HANDLE hServer, PVOID pReserved, DWORD Reserved,
1394  LPWSTR pListenerName, PWTSLISTENERCONFIGW pBuffer,
1395  DWORD flag);
1396 typedef BOOL(WINAPI* WTS_CREATE_LISTENER_FN_A)(HANDLE hServer, PVOID pReserved, DWORD Reserved,
1397  LPSTR pListenerName, PWTSLISTENERCONFIGA pBuffer,
1398  DWORD flag);
1399 
1400 typedef BOOL(WINAPI* WTS_SET_LISTENER_SECURITY_FN_W)(HANDLE hServer, PVOID pReserved,
1401  DWORD Reserved, LPWSTR pListenerName,
1402  SECURITY_INFORMATION SecurityInformation,
1403  PSECURITY_DESCRIPTOR pSecurityDescriptor);
1404 typedef BOOL(WINAPI* WTS_SET_LISTENER_SECURITY_FN_A)(HANDLE hServer, PVOID pReserved,
1405  DWORD Reserved, LPSTR pListenerName,
1406  SECURITY_INFORMATION SecurityInformation,
1407  PSECURITY_DESCRIPTOR pSecurityDescriptor);
1408 
1409 typedef BOOL(WINAPI* WTS_GET_LISTENER_SECURITY_FN_W)(HANDLE hServer, PVOID pReserved,
1410  DWORD Reserved, LPWSTR pListenerName,
1411  SECURITY_INFORMATION SecurityInformation,
1412  PSECURITY_DESCRIPTOR pSecurityDescriptor,
1413  DWORD nLength, LPDWORD lpnLengthNeeded);
1414 typedef BOOL(WINAPI* WTS_GET_LISTENER_SECURITY_FN_A)(HANDLE hServer, PVOID pReserved,
1415  DWORD Reserved, LPSTR pListenerName,
1416  SECURITY_INFORMATION SecurityInformation,
1417  PSECURITY_DESCRIPTOR pSecurityDescriptor,
1418  DWORD nLength, LPDWORD lpnLengthNeeded);
1419 
1420 typedef BOOL(CDECL* WTS_ENABLE_CHILD_SESSIONS_FN)(BOOL bEnable);
1421 
1422 typedef BOOL(CDECL* WTS_IS_CHILD_SESSIONS_ENABLED_FN)(PBOOL pbEnabled);
1423 
1424 typedef BOOL(CDECL* WTS_GET_CHILD_SESSION_ID_FN)(PULONG pSessionId);
1425 
1426 typedef DWORD(WINAPI* WTS_GET_ACTIVE_CONSOLE_SESSION_ID_FN)(void);
1427 
1428 typedef BOOL(WINAPI* WTS_LOGON_USER_FN)(HANDLE hServer, LPCSTR username, LPCSTR password,
1429  LPCSTR domain);
1430 
1431 typedef BOOL(WINAPI* WTS_LOGOFF_USER_FN)(HANDLE hServer);
1432 
1433 typedef struct
1434 {
1435  DWORD dwVersion;
1436  DWORD dwFlags;
1437 
1438  WTS_STOP_REMOTE_CONTROL_SESSION_FN pStopRemoteControlSession;
1439  WTS_START_REMOTE_CONTROL_SESSION_FN_W pStartRemoteControlSessionW;
1440  WTS_START_REMOTE_CONTROL_SESSION_FN_A pStartRemoteControlSessionA;
1441  WTS_CONNECT_SESSION_FN_W pConnectSessionW;
1442  WTS_CONNECT_SESSION_FN_A pConnectSessionA;
1443  WTS_ENUMERATE_SERVERS_FN_W pEnumerateServersW;
1444  WTS_ENUMERATE_SERVERS_FN_A pEnumerateServersA;
1445  WTS_OPEN_SERVER_FN_W pOpenServerW;
1446  WTS_OPEN_SERVER_FN_A pOpenServerA;
1447  WTS_OPEN_SERVER_EX_FN_W pOpenServerExW;
1448  WTS_OPEN_SERVER_EX_FN_A pOpenServerExA;
1449  WTS_CLOSE_SERVER_FN pCloseServer;
1450  WTS_ENUMERATE_SESSIONS_FN_W pEnumerateSessionsW;
1451  WTS_ENUMERATE_SESSIONS_FN_A pEnumerateSessionsA;
1452  WTS_ENUMERATE_SESSIONS_EX_FN_W pEnumerateSessionsExW;
1453  WTS_ENUMERATE_SESSIONS_EX_FN_A pEnumerateSessionsExA;
1454  WTS_ENUMERATE_PROCESSES_FN_W pEnumerateProcessesW;
1455  WTS_ENUMERATE_PROCESSES_FN_A pEnumerateProcessesA;
1456  WTS_TERMINATE_PROCESS_FN pTerminateProcess;
1457  WTS_QUERY_SESSION_INFORMATION_FN_W pQuerySessionInformationW;
1458  WTS_QUERY_SESSION_INFORMATION_FN_A pQuerySessionInformationA;
1459  WTS_QUERY_USER_CONFIG_FN_W pQueryUserConfigW;
1460  WTS_QUERY_USER_CONFIG_FN_A pQueryUserConfigA;
1461  WTS_SET_USER_CONFIG_FN_W pSetUserConfigW;
1462  WTS_SET_USER_CONFIG_FN_A pSetUserConfigA;
1463  WTS_SEND_MESSAGE_FN_W pSendMessageW;
1464  WTS_SEND_MESSAGE_FN_A pSendMessageA;
1465  WTS_DISCONNECT_SESSION_FN pDisconnectSession;
1466  WTS_LOGOFF_SESSION_FN pLogoffSession;
1467  WTS_SHUTDOWN_SYSTEM_FN pShutdownSystem;
1468  WTS_WAIT_SYSTEM_EVENT_FN pWaitSystemEvent;
1469  WTS_VIRTUAL_CHANNEL_OPEN_FN pVirtualChannelOpen;
1470  WTS_VIRTUAL_CHANNEL_OPEN_EX_FN pVirtualChannelOpenEx;
1471  WTS_VIRTUAL_CHANNEL_CLOSE_FN pVirtualChannelClose;
1472  WTS_VIRTUAL_CHANNEL_READ_FN pVirtualChannelRead;
1473  WTS_VIRTUAL_CHANNEL_WRITE_FN pVirtualChannelWrite;
1474  WTS_VIRTUAL_CHANNEL_PURGE_INPUT_FN pVirtualChannelPurgeInput;
1475  WTS_VIRTUAL_CHANNEL_PURGE_OUTPUT_FN pVirtualChannelPurgeOutput;
1476  WTS_VIRTUAL_CHANNEL_QUERY_FN pVirtualChannelQuery;
1477  WTS_FREE_MEMORY_FN pFreeMemory;
1478  WTS_REGISTER_SESSION_NOTIFICATION_FN pRegisterSessionNotification;
1479  WTS_UNREGISTER_SESSION_NOTIFICATION_FN pUnRegisterSessionNotification;
1480  WTS_REGISTER_SESSION_NOTIFICATION_EX_FN pRegisterSessionNotificationEx;
1481  WTS_UNREGISTER_SESSION_NOTIFICATION_EX_FN pUnRegisterSessionNotificationEx;
1482  WTS_QUERY_USER_TOKEN_FN pQueryUserToken;
1483  WTS_FREE_MEMORY_EX_FN_W pFreeMemoryExW;
1484  WTS_FREE_MEMORY_EX_FN_A pFreeMemoryExA;
1485  WTS_ENUMERATE_PROCESSES_EX_FN_W pEnumerateProcessesExW;
1486  WTS_ENUMERATE_PROCESSES_EX_FN_A pEnumerateProcessesExA;
1487  WTS_ENUMERATE_LISTENERS_FN_W pEnumerateListenersW;
1488  WTS_ENUMERATE_LISTENERS_FN_A pEnumerateListenersA;
1489  WTS_QUERY_LISTENER_CONFIG_FN_W pQueryListenerConfigW;
1490  WTS_QUERY_LISTENER_CONFIG_FN_A pQueryListenerConfigA;
1491  WTS_CREATE_LISTENER_FN_W pCreateListenerW;
1492  WTS_CREATE_LISTENER_FN_A pCreateListenerA;
1493  WTS_SET_LISTENER_SECURITY_FN_W pSetListenerSecurityW;
1494  WTS_SET_LISTENER_SECURITY_FN_A pSetListenerSecurityA;
1495  WTS_GET_LISTENER_SECURITY_FN_W pGetListenerSecurityW;
1496  WTS_GET_LISTENER_SECURITY_FN_A pGetListenerSecurityA;
1497  WTS_ENABLE_CHILD_SESSIONS_FN pEnableChildSessions;
1498  WTS_IS_CHILD_SESSIONS_ENABLED_FN pIsChildSessionsEnabled;
1499  WTS_GET_CHILD_SESSION_ID_FN pGetChildSessionId;
1500  WTS_GET_ACTIVE_CONSOLE_SESSION_ID_FN pGetActiveConsoleSessionId;
1501  WTS_LOGON_USER_FN pLogonUser;
1502  WTS_LOGOFF_USER_FN pLogoffUser;
1503  WTS_START_REMOTE_CONTROL_SESSION_EX_FN_W pStartRemoteControlSessionExW;
1504  WTS_START_REMOTE_CONTROL_SESSION_EX_FN_A pStartRemoteControlSessionExA;
1507 
1508 typedef const WtsApiFunctionTable*(CDECL* INIT_WTSAPI_FN)(void);
1509 
1510 #ifdef __cplusplus
1511 extern "C"
1512 {
1513 #endif
1514 
1515  WINPR_API BOOL WTSRegisterWtsApiFunctionTable(const WtsApiFunctionTable* table);
1516  WINPR_API const CHAR* WTSErrorToString(UINT error);
1517  WINPR_API const CHAR* WTSSessionStateToString(WTS_CONNECTSTATE_CLASS state);
1518 
1519 #ifdef __cplusplus
1520 }
1521 #endif
1522 
1523 WINPR_PRAGMA_DIAG_POP
1524 
1525 #endif /* WINPR_WTSAPI_H */
Definition: wtsapi.h:237
Definition: wtsapi.h:227