"Fossies" - the Fresh Open Source Software Archive

Member "dmd2/src/druntime/src/core/sys/windows/wtsapi32.d" (20 Nov 2020, 15371 Bytes) of package /linux/misc/dmd.2.094.2.linux.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) D source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 /**
    2  * Windows API header module
    3  *
    4  * Translated from MinGW-w64 API
    5  *
    6  * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
    7  * Source: $(DRUNTIMESRC src/core/sys/windows/_wtsapi32.d)
    8  */
    9 module core.sys.windows.wtsapi32;
   10 version (Windows):
   11 @system:
   12 
   13 version (ANSI) {} else version = Unicode;
   14 pragma(lib, "wtsapi32");
   15 private import core.sys.windows.w32api;
   16 import core.sys.windows.windef;
   17 
   18 enum {
   19     WTS_CURRENT_SERVER        = null,
   20     WTS_CURRENT_SERVER_HANDLE = null,
   21     WTS_CURRENT_SERVER_NAME   = null
   22 }
   23 
   24 enum DWORD WTS_CURRENT_SESSION = cast(DWORD) -1;
   25 
   26 enum {
   27     IDTIMEOUT = 32000,
   28     IDASYNC   = 32001
   29 }
   30 
   31 enum {
   32     WTS_WSD_LOGOFF     = 0x01,
   33     WTS_WSD_SHUTDOWN   = 0x02,
   34     WTS_WSD_REBOOT     = 0x04,
   35     WTS_WSD_POWEROFF   = 0x08,
   36     WTS_WSD_FASTREBOOT = 0x10
   37 }
   38 
   39 enum WTS_CONNECTSTATE_CLASS {
   40     WTSActive,
   41     WTSConnected,
   42     WTSConnectQuery,
   43     WTSShadow,
   44     WTSDisconnected,
   45     WTSIdle,
   46     WTSListen,
   47     WTSReset,
   48     WTSDown,
   49     WTSInit
   50 }
   51 
   52 struct WTS_SERVER_INFOW {
   53     LPWSTR pServerName;
   54 }
   55 alias WTS_SERVER_INFOW* PWTS_SERVER_INFOW;
   56 
   57 struct WTS_SERVER_INFOA {
   58     LPSTR pServerName;
   59 }
   60 alias WTS_SERVER_INFOA* PWTS_SERVER_INFOA;
   61 
   62 version (Unicode) {
   63     alias WTS_SERVER_INFOW  WTS_SERVER_INFO;
   64     alias PWTS_SERVER_INFOW PWTS_SERVER_INFO;
   65 } else {
   66     alias WTS_SERVER_INFOA  WTS_SERVER_INFO;
   67     alias PWTS_SERVER_INFOA PWTS_SERVER_INFO;
   68 }
   69 
   70 struct WTS_SESSION_INFOW {
   71     DWORD SessionId;
   72     LPWSTR pWinStationName;
   73     WTS_CONNECTSTATE_CLASS State;
   74 }
   75 alias WTS_SESSION_INFOW* PWTS_SESSION_INFOW;
   76 
   77 struct WTS_SESSION_INFOA {
   78     DWORD SessionId;
   79     LPSTR pWinStationName;
   80     WTS_CONNECTSTATE_CLASS State;
   81 }
   82 alias WTS_SESSION_INFOA* PWTS_SESSION_INFOA;
   83 
   84 version (Unicode) {
   85     alias WTS_SESSION_INFOW  WTS_SESSION_INFO;
   86     alias PWTS_SESSION_INFOW PWTS_SESSION_INFO;
   87 } else {
   88     alias WTS_SESSION_INFOA  WTS_SESSION_INFO;
   89     alias PWTS_SESSION_INFOA PWTS_SESSION_INFO;
   90 }
   91 
   92 struct WTS_PROCESS_INFOW {
   93     DWORD SessionId;
   94     DWORD ProcessId;
   95     LPWSTR pProcessName;
   96     PSID pUserSid;
   97 }
   98 alias WTS_PROCESS_INFOW* PWTS_PROCESS_INFOW;
   99 
  100 struct WTS_PROCESS_INFOA {
  101     DWORD SessionId;
  102     DWORD ProcessId;
  103     LPSTR pProcessName;
  104     PSID pUserSid;
  105 }
  106 alias WTS_PROCESS_INFOA* PWTS_PROCESS_INFOA;
  107 
  108 version (Unicode) {
  109     alias WTS_PROCESS_INFOW  WTS_PROCESS_INFO;
  110     alias PWTS_PROCESS_INFOW PWTS_PROCESS_INFO;
  111 } else {
  112     alias WTS_PROCESS_INFOA  WTS_PROCESS_INFO;
  113     alias PWTS_PROCESS_INFOA PWTS_PROCESS_INFO;
  114 }
  115 
  116 enum {
  117     WTS_PROTOCOL_TYPE_CONSOLE,
  118     WTS_PROTOCOL_TYPE_ICA,
  119     WTS_PROTOCOL_TYPE_RDP
  120 }
  121 
  122 enum WTS_INFO_CLASS {
  123     WTSInitialProgram,
  124     WTSApplicationName,
  125     WTSWorkingDirectory,
  126     WTSOEMId,
  127     WTSSessionId,
  128     WTSUserName,
  129     WTSWinStationName,
  130     WTSDomainName,
  131     WTSConnectState,
  132     WTSClientBuildNumber,
  133     WTSClientName,
  134     WTSClientDirectory,
  135     WTSClientProductId,
  136     WTSClientHardwareId,
  137     WTSClientAddress,
  138     WTSClientDisplay,
  139     WTSClientProtocolType,
  140     WTSIdleTime,
  141     WTSLogonTime,
  142     WTSIncomingBytes,
  143     WTSOutgoingBytes,
  144     WTSIncomingFrames,
  145     WTSOutgoingFrames,
  146     WTSClientInfo,
  147     WTSSessionInfo, // = 24
  148 }
  149 
  150 struct WTS_CLIENT_ADDRESS {
  151     DWORD    AddressFamily;
  152     BYTE[20] Address;
  153 }
  154 alias WTS_CLIENT_ADDRESS* PWTS_CLIENT_ADDRESS;
  155 
  156 struct WTS_CLIENT_DISPLAY {
  157     DWORD HorizontalResolution;
  158     DWORD VerticalResolution;
  159     DWORD ColorDepth;
  160 }
  161 alias WTS_CLIENT_DISPLAY* PWTS_CLIENT_DISPLAY;
  162 
  163 enum WTS_CONFIG_CLASS {
  164     WTSUserConfigInitialProgram,
  165     WTSUserConfigWorkingDirectory,
  166     WTSUserConfigfInheritInitialProgram,
  167     WTSUserConfigfAllowLogonTerminalServer,
  168     WTSUserConfigTimeoutSettingsConnections,
  169     WTSUserConfigTimeoutSettingsDisconnections,
  170     WTSUserConfigTimeoutSettingsIdle,
  171     WTSUserConfigfDeviceClientDrives,
  172     WTSUserConfigfDeviceClientPrinters,
  173     WTSUserConfigfDeviceClientDefaultPrinter,
  174     WTSUserConfigBrokenTimeoutSettings,
  175     WTSUserConfigReconnectSettings,
  176     WTSUserConfigModemCallbackSettings,
  177     WTSUserConfigModemCallbackPhoneNumber,
  178     WTSUserConfigShadowingSettings,
  179     WTSUserConfigTerminalServerProfilePath,
  180     WTSUserConfigTerminalServerHomeDir,
  181     WTSUserConfigTerminalServerHomeDirDrive,
  182     WTSUserConfigfTerminalServerRemoteHomeDir
  183 }
  184 
  185 enum {
  186     WTS_EVENT_NONE        = 0x0,
  187     WTS_EVENT_CREATE      = 0x1,
  188     WTS_EVENT_DELETE      = 0x2,
  189     WTS_EVENT_RENAME      = 0x4,
  190     WTS_EVENT_CONNECT     = 0x8,
  191     WTS_EVENT_DISCONNECT  = 0x10,
  192     WTS_EVENT_LOGON       = 0x20,
  193     WTS_EVENT_LOGOFF      = 0x40,
  194     WTS_EVENT_STATECHANGE = 0x80,
  195     WTS_EVENT_LICENSE     = 0x100,
  196     WTS_EVENT_ALL         = 0x7fffffff,
  197     WTS_EVENT_FLUSH       = 0x80000000
  198 }
  199 
  200 enum WTS_VIRTUAL_CLASS {
  201     WTSVirtualClientData,
  202     WTSVirtualFileHandle
  203 }
  204 
  205 version (Unicode) {
  206     alias WTSEnumerateServersW WTSEnumerateServers;
  207     alias WTSOpenServerW WTSOpenServer;
  208     alias WTSEnumerateSessionsW WTSEnumerateSessions;
  209     alias WTSEnumerateProcessesW WTSEnumerateProcesses;
  210     alias WTSQuerySessionInformationW WTSQuerySessionInformation;
  211     alias WTSQueryUserConfigW WTSQueryUserConfig;
  212     alias WTSSetUserConfigW WTSSetUserConfig;
  213     alias WTSSendMessageW WTSSendMessage;
  214 } else {
  215     alias WTSEnumerateServersA WTSEnumerateServers;
  216     alias WTSOpenServerA WTSOpenServer;
  217     alias WTSEnumerateSessionsA WTSEnumerateSessions;
  218     alias WTSEnumerateProcessesA WTSEnumerateProcesses;
  219     alias WTSQuerySessionInformationA WTSQuerySessionInformation;
  220     alias WTSQueryUserConfigA WTSQueryUserConfig;
  221     alias WTSSetUserConfigA WTSSetUserConfig;
  222     alias WTSSendMessageA WTSSendMessage;
  223 }
  224 
  225 extern(Windows) {
  226     WINBOOL WTSEnumerateServersW(LPWSTR pDomainName, DWORD Reserved, DWORD Version, PWTS_SERVER_INFOW* ppServerInfo, DWORD* pCount);
  227     WINBOOL WTSEnumerateServersA(LPSTR pDomainName, DWORD Reserved, DWORD Version, PWTS_SERVER_INFOA* ppServerInfo, DWORD* pCount);
  228     HANDLE WTSOpenServerW(LPWSTR pServerName);
  229     HANDLE WTSOpenServerA(LPSTR pServerName);
  230     VOID WTSCloseServer(HANDLE hServer);
  231     WINBOOL WTSEnumerateSessionsW(HANDLE hServer, DWORD Reserved, DWORD Version, PWTS_SESSION_INFOW* ppSessionInfo, DWORD* pCount);
  232     WINBOOL WTSEnumerateSessionsA(HANDLE hServer, DWORD Reserved, DWORD Version, PWTS_SESSION_INFOA* ppSessionInfo, DWORD* pCount);
  233     WINBOOL WTSEnumerateProcessesW(HANDLE hServer, DWORD Reserved, DWORD Version, PWTS_PROCESS_INFOW* ppProcessInfo, DWORD* pCount);
  234     WINBOOL WTSEnumerateProcessesA(HANDLE hServer, DWORD Reserved, DWORD Version, PWTS_PROCESS_INFOA* ppProcessInfo, DWORD* pCount);
  235     WINBOOL WTSTerminateProcess(HANDLE hServer, DWORD ProcessId, DWORD ExitCode);
  236     WINBOOL WTSQuerySessionInformationW(HANDLE hServer, DWORD SessionId, WTS_INFO_CLASS WTSInfoClass, LPWSTR* ppBuffer, DWORD* pBytesReturned);
  237     WINBOOL WTSQuerySessionInformationA(HANDLE hServer, DWORD SessionId, WTS_INFO_CLASS WTSInfoClass, LPSTR* ppBuffer, DWORD* pBytesReturned);
  238     WINBOOL WTSQueryUserConfigW(LPWSTR pServerName, LPWSTR pUserName, WTS_CONFIG_CLASS WTSConfigClass, LPWSTR* ppBuffer, DWORD* pBytesReturned);
  239     WINBOOL WTSQueryUserConfigA(LPSTR pServerName, LPSTR pUserName, WTS_CONFIG_CLASS WTSConfigClass, LPSTR* ppBuffer, DWORD* pBytesReturned);
  240     WINBOOL WTSSetUserConfigW(LPWSTR pServerName, LPWSTR pUserName, WTS_CONFIG_CLASS WTSConfigClass, LPWSTR pBuffer, DWORD DataLength);
  241     WINBOOL WTSSetUserConfigA(LPSTR pServerName, LPSTR pUserName, WTS_CONFIG_CLASS WTSConfigClass, LPSTR pBuffer, DWORD DataLength);
  242     WINBOOL WTSSendMessageW(HANDLE hServer, DWORD SessionId, LPWSTR pTitle, DWORD TitleLength, LPWSTR pMessage, DWORD MessageLength, DWORD Style, DWORD Timeout, DWORD* pResponse, WINBOOL bWait);
  243     WINBOOL WTSSendMessageA(HANDLE hServer, DWORD SessionId, LPSTR pTitle, DWORD TitleLength, LPSTR pMessage, DWORD MessageLength, DWORD Style, DWORD Timeout, DWORD* pResponse, WINBOOL bWait);
  244     WINBOOL WTSDisconnectSession(HANDLE hServer, DWORD SessionId, WINBOOL bWait);
  245     WINBOOL WTSLogoffSession(HANDLE hServer, DWORD SessionId, WINBOOL bWait);
  246     WINBOOL WTSShutdownSystem(HANDLE hServer, DWORD ShutdownFlag);
  247     WINBOOL WTSWaitSystemEvent(HANDLE hServer, DWORD EventMask, DWORD* pEventFlags);
  248     HANDLE WTSVirtualChannelOpen(HANDLE hServer, DWORD SessionId, LPSTR pVirtualName);
  249     WINBOOL WTSVirtualChannelClose(HANDLE hChannelHandle);
  250     WINBOOL WTSVirtualChannelRead(HANDLE hChannelHandle, ULONG TimeOut, PCHAR Buffer, ULONG BufferSize, PULONG pBytesRead);
  251     WINBOOL WTSVirtualChannelWrite(HANDLE hChannelHandle, PCHAR Buffer, ULONG Length, PULONG pBytesWritten);
  252     WINBOOL WTSVirtualChannelPurgeInput(HANDLE hChannelHandle);
  253     WINBOOL WTSVirtualChannelPurgeOutput(HANDLE hChannelHandle);
  254     WINBOOL WTSVirtualChannelQuery(HANDLE hChannelHandle, WTS_VIRTUAL_CLASS, PVOID* ppBuffer, DWORD* pBytesReturned);
  255     VOID WTSFreeMemory(PVOID pMemory);
  256 
  257     WINBOOL WTSRegisterSessionNotification(HWND hWnd, DWORD dwFlags);
  258     WINBOOL WTSUnRegisterSessionNotification(HWND hWnd);
  259     WINBOOL WTSQueryUserToken(ULONG SessionId, PHANDLE phToken);
  260 }
  261 
  262 enum {
  263     NOTIFY_FOR_ALL_SESSIONS = 1,
  264     NOTIFY_FOR_THIS_SESSION = 0
  265 }
  266 
  267 enum {
  268     USERNAME_LENGTH       = 20,
  269     CLIENTNAME_LENGTH     = 20,
  270     CLIENTADDRESS_LENGTH  = 30,
  271     WINSTATIONNAME_LENGTH = 32,
  272     DOMAIN_LENGTH         = 17
  273 }
  274 
  275 static if (_WIN32_WINNT >= 0x600) {
  276     struct WTSCLIENTW {
  277         WCHAR[CLIENTNAME_LENGTH + 1]      ClientName = 0;
  278         WCHAR[DOMAIN_LENGTH + 1]          Domain = 0;
  279         WCHAR[USERNAME_LENGTH + 1]        UserName = 0;
  280         WCHAR[MAX_PATH + 1]               WorkDirectory = 0;
  281         WCHAR[MAX_PATH + 1]               InitialProgram = 0;
  282         BYTE                              EncryptionLevel;
  283         ULONG                             ClientAddressFamily;
  284         USHORT[CLIENTADDRESS_LENGTH + 1]  ClientAddress;
  285         USHORT                            HRes;
  286         USHORT                            VRes;
  287         USHORT                            ColorDepth;
  288         WCHAR[MAX_PATH + 1]               ClientDirectory = 0;
  289         ULONG                             ClientBuildNumber;
  290         ULONG                             ClientHardwareId;
  291         USHORT                            ClientProductId;
  292         USHORT                            OutBufCountHost;
  293         USHORT                            OutBufCountClient;
  294         USHORT                            OutBufLength;
  295         WCHAR[MAX_PATH + 1]               DeviceId = 0;
  296     }
  297     alias WTSCLIENTW* PWTSCLIENTW;
  298 
  299     struct WTSCLIENTA {
  300         CHAR[CLIENTNAME_LENGTH + 1]       ClientName = 0;
  301         CHAR[DOMAIN_LENGTH + 1 ]          Domain = 0;
  302         CHAR[USERNAME_LENGTH + 1]         UserName = 0;
  303         CHAR[MAX_PATH + 1]                WorkDirectory = 0;
  304         CHAR[MAX_PATH + 1]                InitialProgram = 0;
  305         BYTE                              EncryptionLevel;
  306         ULONG                             ClientAddressFamily;
  307         USHORT[CLIENTADDRESS_LENGTH + 1]  ClientAddress;
  308         USHORT                            HRes;
  309         USHORT                            VRes;
  310         USHORT                            ColorDepth;
  311         CHAR[MAX_PATH + 1]                ClientDirectory = 0;
  312         ULONG                             ClientBuildNumber;
  313         ULONG                             ClientHardwareId;
  314         USHORT                            ClientProductId;
  315         USHORT                            OutBufCountHost;
  316         USHORT                            OutBufCountClient;
  317         USHORT                            OutBufLength;
  318         CHAR[MAX_PATH + 1]                DeviceId = 0;
  319     }
  320     alias WTSCLIENTA* PWTSCLIENTA;
  321 
  322     version (Unicode) {
  323         alias WTSCLIENTW  WTSCLIENT;
  324         alias PWTSCLIENTW PWTSCLIENT;
  325     } else {
  326         alias WTSCLIENTA  WTSCLIENT;
  327         alias PWTSCLIENTA PWTSCLIENT;
  328     }
  329 
  330     struct WTSINFOW {
  331         WTS_CONNECTSTATE_CLASS       State;
  332         DWORD                        SessionId;
  333         DWORD                        IncomingBytes;
  334         DWORD                        OutgoingBytes;
  335         DWORD                        IncomingFrames;
  336         DWORD                        OutgoingFrames;
  337         DWORD                        IncomingCompressedBytes;
  338         DWORD                        OutgoingCompressedBytes;
  339         WCHAR[WINSTATIONNAME_LENGTH] WinStationName = 0;
  340         WCHAR[DOMAIN_LENGTH]         Domain = 0;
  341         WCHAR[USERNAME_LENGTH+1]     UserName = 0;
  342         LARGE_INTEGER                ConnectTime;
  343         LARGE_INTEGER                DisconnectTime;
  344         LARGE_INTEGER                LastInputTime;
  345         LARGE_INTEGER                LogonTime;
  346         LARGE_INTEGER                CurrentTime;
  347     }
  348     alias WTSINFOW* PWTSINFOW;
  349 
  350     struct WTSINFOA {
  351         WTS_CONNECTSTATE_CLASS      State;
  352         DWORD                       SessionId;
  353         DWORD                       IncomingBytes;
  354         DWORD                       OutgoingBytes;
  355         DWORD                       IncomingFrames;
  356         DWORD                       OutgoingFrames;
  357         DWORD                       IncomingCompressedBytes;
  358         DWORD                       OutgoingCompressedBytes;
  359         CHAR[WINSTATIONNAME_LENGTH] WinStationName = 0;
  360         CHAR[DOMAIN_LENGTH]         Domain = 0;
  361         CHAR[USERNAME_LENGTH+1]     UserName = 0;
  362         LARGE_INTEGER               ConnectTime;
  363         LARGE_INTEGER               DisconnectTime;
  364         LARGE_INTEGER               LastInputTime;
  365         LARGE_INTEGER               LogonTime;
  366         LARGE_INTEGER               CurrentTime;
  367     }
  368     alias WTSINFOA* PWTSINFOA;
  369 
  370     version (Unicode) {
  371         alias WTSINFOW  WTSINFO;
  372         alias PWTSINFOW PWTSINFO;
  373     } else {
  374         alias WTSINFOA  WTSINFO;
  375         alias PWTSINFOA PWTSINFO;
  376     }
  377 
  378     extern(Windows) {
  379         WINBOOL WTSConnectSessionA(
  380             ULONG LogonId,
  381             ULONG TargetLogonId,
  382             PSTR   pPassword,
  383             WINBOOL bWait
  384         );
  385 
  386         WINBOOL WTSConnectSessionW(
  387             ULONG LogonId,
  388             ULONG TargetLogonId,
  389             PWSTR  pPassword,
  390             WINBOOL bWait
  391         );
  392 
  393         WINBOOL WTSRegisterSessionNotificationEx(
  394             HANDLE hServer,
  395             HWND hWnd,
  396             DWORD dwFlags
  397         );
  398 
  399         WINBOOL WTSStartRemoteControlSessionA(
  400             LPSTR pTargetServerName,
  401             ULONG TargetLogonId,
  402             BYTE HotkeyVk,
  403             USHORT HotkeyModifiers
  404         );
  405 
  406         WINBOOL WTSStartRemoteControlSessionW(
  407             LPWSTR pTargetServerName,
  408             ULONG TargetLogonId,
  409             BYTE HotkeyVk,
  410             USHORT HotkeyModifiers
  411         );
  412 
  413         version (Unicode) {
  414             alias WTSStartRemoteControlSessionW WTSStartRemoteControlSession;
  415             alias WTSConnectSessionW WTSConnectSession;
  416         } else {
  417             alias WTSStartRemoteControlSessionA WTSStartRemoteControlSession;
  418             alias WTSConnectSessionA WTSConnectSession;
  419         }
  420 
  421         WINBOOL WTSStopRemoteControlSession(
  422             ULONG LogonId
  423         );
  424 
  425         WINBOOL WTSUnRegisterSessionNotificationEx(
  426             HANDLE hServer,
  427             HWND hWnd
  428         );
  429 
  430         HANDLE WTSVirtualChannelOpenEx(
  431             DWORD SessionId,
  432             LPSTR pVirtualName,
  433             DWORD flags
  434         );
  435     } /* extern(Windows) */
  436 } /* static if (_WIN32_WINNT >= 0x600) */