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