Revision Summary Date Revision History Revision Class Comments 7/20/2007 0.1 Major MCPP Milestone 5 Initial Availability 9/28/2007 0.2 Minor Made changes to technical and editorial content based on feedback. 10/23/2007 0.3 Made technical and editorial changes based on feedback. 11/30/2007 0.4 Made technical and editorial changes based on feedback. 1/25/2008 1.0 Major Updated and revised the technical content. 3/14/2008 2.0 IDL files and data typing revised. 5/16/2008 2.0.1 Editorial Changed language and formatting in the technical content. 6/20/2008 3.0 Updated and revised the technical content. 7/25/2008 4.0 Updated and revised the
technical content. 8/29/2008 5.0 Major Updated and revised the technical content. 10/24/2008 6.0 Major Updated and revised the technical content. 12/5/2008 7.0 Major Updated and revised the technical content. 1/16/2009 7.1 Minor Clarified the meaning of the technical content. 2/27/2009 8.0 Major Updated and revised the technical content. 4/10/2009 8.1 Minor Clarified the meaning of the technical content. 5/22/2009 8.1.1 Editorial Changed language and formatting in the technical content. 7/2/2009 9.0 Updated and revised the technical content. 8/14/2009 9.1 Minor Clarified the meaning of the technical content. 9/25/2009 9.2 Minor Clarified the meaning of the
or formatting of the technical content. 10/25/2012 18.0 None No changes to the meaning, language, or formatting of the technical content. 1/31/2013 18.0 None No changes to the meaning, language, or formatting of the technical content. 8/8/2013 19.0 Major Updated and revised the technical content. 11/14/2013 20.0 Major Updated and revised the technical content. 2/13/2014 21.0 Major Updated and revised the technical content. 5/15/2014 21.0 None No changes to the meaning, language, or formatting of the technical content. 6/30/2015 22.0 Major Significantly changed the technical content. 10/16/2015 23.0 Major Significantly changed
the technical content. 7/14/2016 24.0 Major Significantly changed the technical content. 6/1/2017 24.0 None No changes to the meaning, language, or formatting of the technical content. 9/15/2017 25.0 Significantly changed the technical content. 12/1/2017 25.0 None No changes to the meaning, language, or formatting of the technical content.
} TermSrv Listener (RCMPublic.idl)<11> { } \PIPE\TermSrv_API_service Legacy (Legacy.idl) { } \PIPE\Ctx_WinStation_API_service TSVIPPublic (TSVIPRpc.idl) \PIPE\TSVIP_Service SessEnvPublicRpc (SessEnvRpc.idl) \PIPE\SessEnvPublicRpc
WTS_NOTIFY_CREATE 0x1 Session creation notification WTS_NOTIFY_CONNECT 0x2 Session connection notification WTS_NOTIFY_DISCONNECT 0x4 Session disconnection notification WTS_NOTIFY_LOGON 0x8 Session logon notification WTS_NOTIFY_LOGOFF 0x10 Session logoff notification WTS_NOTIFY_SHADOW_START 0x20 Session shadow start notification WTS_NOTIFY_SHADOW_STOP 0x40 Session shadow stop notification WTS_NOTIFY_TERMINATE 0x80 Session termination notification WTS_NOTIFY_CONSOLE_CONNECT 0x100 Console session connection notification WTS_NOTIFY_CONSOLE_DISCONNECT 0x200 Console session disconnect notification WTS_NOTIFY_LOCK 0x400 Session lock notification WTS_NOTIFY_UNLOCK 0x800 Session unlock notification WTS_NOTIFY_ALL 0xffffffff All notifications NOTIFY_HANDLE A to a notification object. Used in asynchronous calls such as and . This type is declared as follows: typedef [context_handle] void* NOTIFY_HANDLE;
*PSessionInfo_Ex; SessionEnum_Level1: A SESSIONENUM_LEVEL1 structure containing a level of information about sessions running on a computer. SessionEnum_Level2: A SESSIONENUM_LEVEL2 structure containing a of information about sessions running on a computer. SessionEnum_Level3: A SESSIONENUM_LEVEL3 structure containing a level of information about sessions running on a computer. PEXECENVDATA PEXECENVDATA is a pointer to a structure containing information about the running on the and the sessions running on virtual machines hosted on the server.<47> It is returned by . typedef struct _EXECENVDATA { DWORD Level; [switch_is(Level)] ExecEnvData Data; } EXECENVDATA, *PEXECENVDATA; Level: The level of information contained in Data; the valid values are 1 and 2. Meaning 1 The union has the structure. 2 The union ExecEnvData has the structure. Data: Contains information at a specified level of detail about sessions running on a computer. This is of type ExecEnvData. ExecEnvData The ExecEnvData is a union of structures, each structure providing different levels of detail about sessions running on a computer and sessions running on virtual machines hosted on the server,<48> as specified in sections and respectively. typedef [switch_type(DWORD)] union _ExecEnvData { [case(1)] EXECENVDATA_LEVEL1 ExecEnvEnum_Level1; [case(2)] EXECENVDATA_LEVEL2 ExecEnvEnum_Level2; } ExecEnvData, *PExecEnvData; ExecEnvEnum_Level1: An EXECENVDATA_LEVEL1 structure containing a of information about sessions running on a computer and virtual machines hosted on the computer.<49> ExecEnvEnum_Level2: An EXECENVDATA_LEVEL2 structure containing a level of information about sessions running on a computer and virtual machines hosted on the computer.<50> EXECENVDATA_LEVEL1
SessionId; SpareUl3; SIZE_T PeakVirtualSize; SIZE_T VirtualSize; ULONG PageFaultCount; ULONG PeakWorkingSetSize; WorkingSetSize; SIZE_T QuotaPeakPagedPoolUsage; SIZE_T QuotaPagedPoolUsage; SIZE_T QuotaPeakNonPagedPoolUsage; SIZE_T QuotaNonPagedPoolUsage; SIZE_T PagefileUsage; SIZE_T PeakPagefileUsage; SIZE_T PrivatePageCount; } TS_SYS_PROCESS_INFORMATION, *PTS_SYS_PROCESS_INFORMATION; NextEntryOffset: Offset to the start of data for the next process. NumberOfThreads: Number of threads in the process. SpareLi1: Reserved. SpareLi2: Reserved. SpareLi3: Reserved. CreateTime: Creation time of the process. Time is measured as the number of 100-nanosecond intervals since January 1, 1601 (UTC). UserTime: Amount of time in milliseconds the process has spent running in user mode. KernelTime: Amount of time in milliseconds the process has spent running in kernel mode. ImageName: String containing the process's name. BasePriority: Base priority of the process. UniqueProcessId: Process's unique process ID. InheritedFromUniqueProcessId: Parent process's unique process ID. HandleCount: Current number of handles open in the process. SessionId: Session identifier of the process session. SpareUl3: Reserved. PeakVirtualSize: Peak size of virtual memory, in bytes, used by the process. VirtualSize: Current size of virtual memory, in used by the process. PageFaultCount: Number of page faults in the process. PeakWorkingSetSize: Peak size of the working set in kilobytes of the process. WorkingSetSize: Current size, in bytes, of the working set of the process. QuotaPeakPagedPoolUsage: Peak quota charged to the process for paged pool usage. QuotaPagedPoolUsage: Current quota charged to the process for paged pool usage. QuotaPeakNonPagedPoolUsage: Peak quota charged to the process for nonpaged pool usage.
DLLNAME DLLNAME WsxDLL; ULONG WdFlag; ULONG WdInputBufferLength; DLLNAME CfgDLL; WDPREFIX WdPrefix; } WDCONFIG, *PWDCONFIG; WdName: The descriptive name of the WinStation driver. The driver's image name. WsxDLL: Used by the service to communicate with the WinStation driver.<99> WdFlag: Driver flags. It MUST be any bitwise OR combination of the following values. Value Meaning WDF_UNUSED 0x00000001 Not used. WDF_SHADOW_SOURCE 0x00000002 Valid shadow source. WDF_SHADOW_TARGET 0x00000004 Valid shadow target. WDF_OTHER 0x00000008 Other protocol. WDF_TSHARE 0x00000010 Remote Protocol used by Terminal Services. WDF_DYNAMIC_RECONNECT 0x00000020 Session can resize display at reconnect.<100> WDF_USER_VCIOCTL 0x00000040 User mode applications can send virtual channel IOCTL. WDF_SUBDESKTOP 0x00008000 Sub-desktop session.<101> WdInputBufferLength: Length, in bytes, of the input buffer used by the driver. Defaults to 2048. CfgDLL: Configuration DLL used by Terminal Services administrative tools for configuring the driver.<102> WdPrefix: Used as the prefix of the WinStation name generated for the connected sessions with this WinStation driver.<103> WDNAME The WDNAME data type. typedef WCHAR WDNAME[WDNAME_LENGTH + 1]; typedef WCHAR* PWDNAME;
0x00000000 S_OK Successful completion. RpcGetTerminalName 6) The RpcGetTerminalName method gets the name of the terminal associated with the specified session on the . This method MUST be called after . The caller MUST have WINSTATION_QUERY permission for the session. The method checks whether the caller has WINSTATION_QUERY permission (section ) by setting it as the Access Request mask, and fails if the caller does not have the permission. HRESULT RpcGetTerminalName( [in] SESSION_HANDLE hSession, [out, string] WCHAR** pszTerminalName ); hSession: The to the session returned by RpcOpenSession. This is of type . pszTerminalName: The name of the terminal associated with the specific session. Return Values: The method MUST return S_OK (0x00000000) on success; otherwise, it MUST return an implementation-specific negative value. Return value/code Description 0x00000000 S_OK Successful completion. RpcGetState (Opnum 7) The RpcGetState method gets the state of the specified session on the . This method MUST be called after . The caller MUST have WINSTATION_QUERY permission for the session. The method checks whether the caller has WINSTATION_QUERY permission (section ) by setting it as the Access Request mask, and fails if the caller does not have the permission. HRESULT RpcGetState( [in] SESSION_HANDLE hSession, [out] LONG* plState ); hSession: The to the session returned by RpcOpenSession. This is of type . plState: The current of the session as defined in . Return Values: The method MUST return S_OK (0x00000000) on success; otherwise, it MUST return an implementation-specific negative value. Return Description 0x00000000 S_OK Successful completion.
WEVENT_NONE 0x00000000 The client requests to clear its event wait block. This MUST be called when completing waiting for the event. When RpcWinStationCloseServer is called for hServer, this method and mask value is called on the client's behalf. WEVENT_CREATE 0x00000001 Wait for a new session to be created. WEVENT_DELETE 0x00000002 Wait for an existing session to be deleted. WEVENT_RENAME 0x00000004 Wait for a session to be renamed. WEVENT_CONNECT 0x00000008 The session connected to a client. WEVENT_DISCONNECT 0x00000010 A client disconnected from the session. WEVENT_LOGON 0x00000020 A user logged on to the session. WEVENT_LOGOFF 0x00000040 A user logged off from the session. WEVENT_STATECHANGE 0x00000080 The session state changed. WEVENT_LICENSE 0x00000100 The license state changed.<183> WEVENT_ALL 0x7fffffff Wait for all event types. WEVENT_FLUSH 0x80000000 Release all waiting clients. pEventFlags: Pointer to a variable to receive a bitmask that is a subset of EventMask indicating which events actually occurred during this wait operation. Return Values: Returns TRUE if the call succeeded, or if the method failed. On failure, pResult indicates the failure status code. Return value/code Description 0x01 TRUE Successful completion. 0x00 FALSE Method call failed. RpcWinStationShadow (Opnum 17)
The RpcGetSessionIP method retrieves the IP address assigned to the session. This MUST be called by an or the same user who logged onto the session.<212> The method performs access checks as defined in section and . The method fails if both checks fail. HRESULT RpcGetSessionIP( [in] handle_t hBinding, [in] USHORT Family, [in] DWORD SessionId, [ref, out] TSVIPSession* ppVIPSession ); hBinding: The binding . For more information, see . Family: MUST be AF_INET. SessionId: The identifier of the session to open. This session MUST be present on the . This MUST NOT be the session ID of any of the sessions. ppVIPSession: The session structure containing the IP address assigned to the session. This is of type . Return Values: The method MUST return S_OK (0x00000000) on success; otherwise, it MUST return an implementation-specific negative value. Return value/code Description 0x00000000 S_OK Successful completion. Timer Events None. Other Local Events None. SessEnv Details Abstract Data Model None. Timers None. Initialization Parameters necessary to initialize the RPC protocol are specified in section .
Protocol Examples LSM Enumeration Example The following example shows how to enumerate sessions on a . This example uses from section 4.3. Get the LSM Binding. HANDLE GetLSMBinding(LPWSTR pszServerName) { HANDLE hLSMBinding = NULL; RPC_STATUS rpcStatus = RPC_S_OK; //ASSERT( NULL != pszServerName ); rpcStatus = TermSrvBindSecure( gpszPublicUuid, gpszRemoteProtocolSequence, pszServerName, TSRPC_REMOTE_ENDPOINT, gpszOptions, &hLSMBinding ); if( rpcStatus != RPC_S_OK || hLSMBinding == NULL) { wprintf(L"ERR: TermSrvBindSecure failed: %d\n", rpcStatus ); SetLastError( rpcStatus ); } return hLSMBinding; } Enumerate the sessions. RpcTryExcept { hr = RpcOpenEnum( hLSMBind, &hEnum ); if(hr == S_OK) { hr = RpcGetEnumResult( hEnum, &pAllSessions, CURRENT_ENUM_LEVEL, &Entries ); if(hr == S_OK) { for(ULONG i=0;i<Entries;i++) { wprintf(L"%-10d %-20s %-40s\n", pAllSessions[i].Data.SessionEnum_Level3.SessionId, WinstationStateClassNames[pAllSessions[i].Data. SessionEnum_Level3.State], pAllSessions[i].Data.SessionEnum_Level3.Name); if( NULL != pAllSessions[i].Data.SessionEnum_Level3. pProtocolData ) { MIDL_user_free( pAllSessions[i].Data. SessionEnum_Level3.pProtocolData ); } } rv1 = TRUE; } else
Index A Abstract data model client ( 95, 119, 131) 131 95 119 175 server ( 95, 119, 131) 131 95 119 176 94 15 207 59 62 B 80 C 57 48 94 16 66 66 243 Client abstract data model ( 95, 119, 131) initialization ( 95, 119, 131) legacy 131 131 131 131 131 131 131 local events ( 95, 119, 131) local session manager 95 95 95 95 95 95 95 131 131 TermSrv 119 119 119 119 119 119 119 timer events ( 95, 119, 131) timers ( 95, 119, 131) virtual IP 175 175 176 176 176 176 175 43 82 17 61 D Data model - abstract client ( 95, 119, 131) 131 95 119 175 server ( 95, 119, 131) 131 95 119 176 Data types 17 27 189 94 86 E 86 189 189 Events local 131 175 95 119 119 131 176 177 local - client ( 95, 119, 131) local - server ( 119, 131, 175) timer 131 175 95 119 119 130 176 177 timer - client ( 95, 119, 131)
- server ( 119, 130, 175) Examples 189 189 187 187 180 180 182 182 184 184 31 32 32 33 33 77 F 16 60 60 192 G 10 I 192 94 191 191 14 Initialization client ( 95, 119, 131) 131 95 119 175 server ( 98, 121, 134) 134 98 121 176 10 L Legacy client 131 131 131 131 131 131 131 187 187 Legacy server 131 134 175 134 134 175 134 134 36 37 75 events client ( 95, 119, 131) 131 95 119 176 server ( 119, 131, 175) 175 119 131 177 LSM client 95 95 95 95 95 95 95 180 180 LSM server 95 98 119 98 98 119 98 35 34 35 M Message processing 131 131 95 119 176 server ( 121, 134) 134 98 121 176 Messages 17 17 Methods 134 128 121 93 N
62 59 12 42 O 63 160 14 P 191 191 59 80 57 66 82 61 63 63 58 82 94 31 32 32 33 33 77 60 36 37 35 34 35 62 59 63 68 63 63 58 82 68 56 55 56 81 15 15 58 230 92 Protocol Details 94 56 55 27 56 81 28 30 29 29 29 37 42 58 38 40 43 44 38 38 41 78 58 57 83 84 85 45 82 65 83 49 81 67 67 67 54 74 76 86 77 75 74 85 74 Q 27 R 81 128 121 61 23 12 14 12 15 58 113 129 100 100 172 101 114 114 115 113
176 177 176 81 27 28 30 29 29 29 37 25 25 26 26 22 76 16 27 42 T 182 182 TermSrv client 119 119 119 119 119 119 119 TermSrv server 119 121 131 121 121 130 121 184 184 58 Timer events client ( 95, 119, 131) 131 95 119 176 server ( 119, 130, 175) 175 119 130 177 Timers client ( 95, 119, 131) 131 95 119 175 server ( 98, 121, 134) 134 98 121 176 243 61 17 38 40 43 44 38 38 41 53 52 78 40 58 57 88 83 84 85 U 45 87 V 82 16 16 Virtual IP client 175 175 176 176 176 176 175 Virtual IP server 176 176 177 176 176 177 176 W 65 83 49 81 67 67 67 19 54 74 76 86 77 75