Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

770 lines
25 KiB

  1. /****************************************************************************/
  2. // icasrv.h
  3. //
  4. // TermSrv types, data, prototypes.
  5. //
  6. // Copyright (C) 1997-2000 Microsoft Corporation
  7. /****************************************************************************/
  8. #include <tssd.h>
  9. #include <tssec.h>
  10. #ifdef __cplusplus
  11. extern "C" {
  12. #endif
  13. #define STR_CITRIX_IDLE_TITLE 249
  14. #define STR_CITRIX_IDLE_MSG_LOGOFF 250
  15. #define STR_CITRIX_LOGON_TITLE 251
  16. #define STR_CITRIX_LOGON_MSG_LOGOFF 252
  17. #define STR_CITRIX_SHADOW_TITLE 253
  18. #define STR_CITRIX_SHADOW_MSG_1 254
  19. #define STR_CITRIX_SHADOW_MSG_2 255
  20. #define STR_TEMP_LICENSE_EXPIRED_MSG 257
  21. #define STR_TEMP_LICENSE_EXPIRATION_MSG 258
  22. #define STR_TEMP_LICENSE_MSG_TITLE 259
  23. #define STR_ALL_LAN_ADAPTERS 260
  24. #define STR_CANNOT_ALLOW_CONCURRENT_MSG 261
  25. #define STR_CITRIX_IDLE_MSG_DISCON 262
  26. #define STR_CITRIX_LOGON_MSG_DISCON 263
  27. #define STR_FUS_REMOTE_DISCONNECT_TITLE 264
  28. #define STR_FUS_REMOTE_DISCONNECT_MSG 265
  29. /*
  30. * Resource definitions for the Licensing Core.
  31. */
  32. #define IDS_LSCORE_RA_NAME 1100
  33. #define IDS_LSCORE_RA_DESC 1101
  34. #define IDS_LSCORE_PERSEAT_NAME 1200
  35. #define IDS_LSCORE_PERSEAT_DESC 1201
  36. #define IDS_LSCORE_CONCURRENT_NAME 1300
  37. #define IDS_LSCORE_CONCURRENT_DESC 1301
  38. /*
  39. * defines for memory allocation
  40. */
  41. #define MemAlloc( _x ) RtlAllocateHeap( IcaHeap, 0, _x )
  42. #define MemFree( _p ) RtlFreeHeap( IcaHeap, 0, _p )
  43. /*
  44. * Prototype for reference lock delete procedure
  45. */
  46. typedef VOID (*PREFLOCKDELETEPROCEDURE)( struct _REFLOCK * );
  47. typedef struct _WINSTATION *PWINSTATION;
  48. /*
  49. * Reference counted lock structure
  50. */
  51. typedef struct _REFLOCK {
  52. HANDLE Mutex; // mutex handle
  53. LONG RefCount; // reference count
  54. BOOLEAN Invalid; // containing struct no longer valid
  55. PREFLOCKDELETEPROCEDURE pDeleteProcedure; // pointer to delete procedure
  56. } REFLOCK, *PREFLOCK;
  57. /*
  58. * Structure used to get the exact credentials used for logon by the client
  59. * We use this to send back the notification to the client
  60. */
  61. typedef struct _CLIENTNOTIFICATIONCREDENTIALS {
  62. WCHAR UserName[EXTENDED_USERNAME_LEN + 1];
  63. WCHAR Domain[EXTENDED_DOMAIN_LEN + 1] ;
  64. } CLIENTNOTIFICATIONCREDENTIALS, *PCLIENTNOTIFICATIONCREDENTIALS;
  65. //
  66. // Private contents of the autoreconnect cookie
  67. //
  68. typedef struct _AUTORECONNECTIONINFO {
  69. BOOLEAN Valid;
  70. BYTE ArcRandomBits[ARC_SC_SECURITY_TOKEN_LEN];
  71. } AUTORECONNECTIONINFO, *PAUTORECONNECTIONINFO;
  72. /*
  73. * Remembered Client address structure
  74. */
  75. typedef struct _REMEMBERED_CLIENT_ADDRESS{
  76. ULONG length;
  77. BYTE addr[1];
  78. } REMEMBERED_CLIENT_ADDRESS, *PREMEMBERED_CLIENT_ADDRESS;
  79. typedef enum _RECONNECT_TYPE {
  80. NeverReconnected = 0,
  81. ManualReconnect,
  82. AutoReconnect
  83. } RECONNECT_TYPE, *PRECONNECT_TYPE;
  84. /*
  85. * Session Manager WinStation struct
  86. */
  87. typedef struct _WINSTATION {
  88. LIST_ENTRY Links;
  89. BOOLEAN Starting; // WinStation is starting
  90. BOOLEAN Terminating; // WinStation is terminating
  91. BOOLEAN NeverConnected; // WinStation not connected yet
  92. REFLOCK Lock;
  93. ULONG LogonId; // Logon Id
  94. WINSTATIONNAME WinStationName; // WinStation Name
  95. WINSTATIONNAME ListenName; // Listen Name (for limits checking)
  96. WINSTATIONCONFIG2 Config; // WinStation Config
  97. WINSTATIONCLIENT Client; // WinStation client data
  98. ULONG State; // current state
  99. ULONG Flags; // WinStation Flags (see WSF_??? below)
  100. PVOID pSecurityDescriptor;
  101. HANDLE CreateEvent;
  102. NTSTATUS CreateStatus;
  103. HANDLE ConnectEvent;
  104. HANDLE hIca; // WinStation's primary Device
  105. HANDLE hStack; // WinStation's primary stack
  106. ULONG ShadowId;
  107. HANDLE hPassthruStack; // passthru (shadow client) stack
  108. HANDLE ShadowBrokenEvent;
  109. HANDLE ShadowDoneEvent;
  110. HANDLE ShadowDisplayChangeEvent;
  111. NTSTATUS ShadowTargetStatus;
  112. BOOLEAN ShadowConnectionWait;
  113. LIST_ENTRY ShadowHead; // head of shadow list
  114. HANDLE WindowsSubSysProcess; // process handle for Win32 SS (csrss)
  115. HANDLE WindowsSubSysProcessId; // process id for Win32 SS
  116. HANDLE InitialCommandProcess; // process handle for initial command
  117. HANDLE InitialCommandProcessId; // process id for initial command
  118. BOOLEAN InitialProcessSet; // Flag for console communication
  119. HANDLE CsrStartEventHandle; // Handle for CsrStartEvent
  120. HANDLE Win32CommandPort;
  121. PORT_MESSAGE Win32CommandPortMsg;
  122. LIST_ENTRY Win32CommandHead; // head of COMMAND_ENTRY list
  123. struct _LPC_CLIENT_CONTEXT *pWin32Context;
  124. PSID pUserSid; // SID for currently logged on user
  125. WCHAR Password[PASSWORD_LENGTH+1]; // password for currently logged on user
  126. UCHAR Seed; // seed for above password
  127. HANDLE UserToken; // User Token
  128. HANDLE hIdleTimer;
  129. HANDLE hLogonTimer;
  130. HANDLE hDisconnectTimer;
  131. ULONG fIdleTimer : 1;
  132. ULONG fLogonTimer : 1;
  133. ULONG fDisconnectTimer : 1;
  134. LARGE_INTEGER ConnectTime;
  135. LARGE_INTEGER DisconnectTime;
  136. LARGE_INTEGER LogonTime;
  137. WCHAR Domain[ DOMAIN_LENGTH + 1 ]; // Domain
  138. WCHAR UserName[USERNAME_LENGTH + 1]; // UserName
  139. BYTE VideoModuleName[9]; // For reconnect checking
  140. HANDLE hConnectThread; // Connect thread for this WinStation
  141. HANDLE hIcaBeepChannel;
  142. HANDLE hIcaThinwireChannel;
  143. PVOID pEndpoint;
  144. ULONG EndpointLength;
  145. struct _WSEXTENSION *pWsx;
  146. PVOID pWsxContext;
  147. BROKENCLASS BrokenReason; // reason/source why this WinStation..
  148. BROKENSOURCECLASS BrokenSource; // ..is being reset/disconnected
  149. ULONG StateFlags; // WinStation State (see WSF_ST_??? below)
  150. ULONG SessionSerialNumber; // Session Id is reused when session is deleted. Serial number not
  151. PSID pProfileSid; // SID for previously logged on user kept for profile cleanup
  152. BOOLEAN fOwnsConsoleTerminal; // session currently connected to the console
  153. WCHAR DisplayDriverName[9];
  154. WCHAR ProtocolName[9];
  155. LPARAM lpLicenseContext; // Licensing context for the winstation
  156. BOOLEAN fUserIsAdmin; // Needed for LLS licensing
  157. // Server pool (cluster) support - disconnected session query results
  158. // and client capabilities for this client.
  159. ULONG bClientSupportsRedirection : 1;
  160. ULONG bRequestedSessionIDFieldValid : 1;
  161. ULONG bClientRequireServerAddr : 1;
  162. UINT32 RequestedSessionID;
  163. unsigned NumClusterDiscSessions;
  164. TSSD_DisconnectedSessionInfo ClusterDiscSessions[TSSD_MaxDisconnectedSessions];
  165. HANDLE hWinmmConsoleAudioEvent; // Event that set if console audio is enabled remotely
  166. // Support for longer UserName and Password during client autologon to a Terminal Server
  167. pExtendedClientCredentials pNewClientCredentials ;
  168. HANDLE hReconnectReadyEvent;
  169. // The following structure is used to send back the logon notification to the client
  170. PCLIENTNOTIFICATIONCREDENTIALS pNewNotificationCredentials;
  171. // Cache original shadow setting when session is created.
  172. // this is to fix a security hole created by Salem/pcHealth in that
  173. // pcHealth dynamically switch shadow to full control without
  174. // user permission and does not reset it, a normal
  175. // termination of Help will trigger Salem sessmgr to reset shadow
  176. // back to original setting, but a bad expert can stop sessmgr service
  177. // and our session's shadow setting will still be FULL CONTROL
  178. // WITHOUT USER PERMISSION, anyone with enough priviledge can then
  179. // start shadow and take control of this session .
  180. SHADOWCLASS OriginalShadowClass;
  181. //termsrv's cached cache statistics
  182. CACHE_STATISTICS Cache;
  183. PREMEMBERED_CLIENT_ADDRESS pRememberedAddress;
  184. AUTORECONNECTIONINFO AutoReconnectInfo;
  185. RECONNECT_TYPE LastReconnectType;
  186. BOOLEAN fDisallowAutoReconnect;
  187. } WINSTATION, *PWINSTATION;
  188. /*
  189. * WinStation Flags
  190. */
  191. #define WSF_CONNECT 0x00000001 // being connected
  192. #define WSF_DISCONNECT 0x00000002 // being disconnected
  193. #define WSF_RESET 0x00000004 // being reset
  194. #define WSF_DELETE 0x00000008 // being deleted
  195. #define WSF_DOWNPENDING 0x00000010 // down pending
  196. #define WSF_LOGOFF 0x00000020 // being logged off
  197. #define WSF_LISTEN 0x00000040 // this is a "listening" WinStation
  198. #define WSF_IDLE 0x00000080 // part of the idle pool
  199. #define WSF_IDLEBUSY 0x00000100 // idle but in process of connecting
  200. #define WSF_AUTORECONNECTING 0x00000200 // autoreconnecting
  201. /*
  202. * WinStation State Flags
  203. */
  204. #define WSF_ST_WINSTATIONTERMINATE 0x00000001 //Called WinstationTerminate for this session
  205. #define WSF_ST_DELAYED_STACK_TERMINATE 0x00000002 //Need to delay stack termination till WinstationDeleProc()
  206. #define WSF_ST_BROKEN_CONNECTION 0x00000004 // received a broken connection indication
  207. #define WSF_ST_CONNECTED_TO_CSRSS 0x00000008 // Connected or reconnected to CSRSS
  208. #define WSF_ST_IN_DISCONNECT 0x00000010 // Disconnect processing is pending
  209. #define WSF_ST_LOGON_NOTIFIED 0x00000020 // Logon notification is received
  210. #define WSF_ST_SHADOW 0x00000200 // In shadow or waiting for user
  211. /*
  212. * Help Assistant Session flag.
  213. * 3 bits, winlogon, msgina, licensing query termsrv in different
  214. * phrase of logon, we don't want to make repeated call, and since
  215. * we can't be sure if a session is a help session until winlogon
  216. * actually logon a user, we need more than TRUE/FALSE bit.
  217. */
  218. #define WSF_ST_HELPSESSION_FLAGS 0xF0000000 // reserved flags.
  219. #define WSF_ST_HELPSESSION_NOTSURE 0x00000000 // No sure it is helpassistant session
  220. #define WSF_ST_HELPSESSION_NOTHELPSESSION 0x20000000 // Detemined not a helpassistant session
  221. #define WSF_ST_HELPSESSION_HELPSESSION 0x40000000 // Session is a helpassistant session
  222. #define WSF_ST_HELPSESSION_HELPSESSIONINVALID 0x80000000 // HelpAssistant logon but ticket is invalid
  223. /*
  224. * Reconnect struct
  225. *
  226. * This structure is used to store WinStation connection information.
  227. * This structure is transferred from one WinStation to another when
  228. * processing a reconnect.
  229. */
  230. typedef struct _RECONNECT_INFO {
  231. WINSTATIONNAME WinStationName; // WinStation Name
  232. WINSTATIONNAME ListenName; // WinStation Name
  233. WINSTATIONCONFIG2 Config; // Registry config data
  234. WINSTATIONCLIENT Client; // WinStation client data
  235. struct _WSEXTENSION *pWsx;
  236. PVOID pWsxContext;
  237. HANDLE hIca; // temp ICA device handle to connect
  238. // stack to while in disconnect state
  239. HANDLE hStack; // handle of stack being reconnected
  240. PVOID pEndpoint; // endpoint data for connection..
  241. ULONG EndpointLength; // ..being reconnected
  242. BOOLEAN fOwnsConsoleTerminal; // session currently connected to the console
  243. WCHAR DisplayDriverName[9];
  244. WCHAR ProtocolName[9];
  245. // The following structure is used to send back the logon notification to the client
  246. PCLIENTNOTIFICATIONCREDENTIALS pNotificationCredentials;
  247. } RECONNECT_INFO, *PRECONNECT_INFO;
  248. /*
  249. * Shadow entry
  250. * There is one of these for each shadow client,
  251. * linked from the target WinStation (ShadowHead).
  252. */
  253. typedef struct _SHADOW_INFO {
  254. LIST_ENTRY Links;
  255. HANDLE hStack;
  256. HANDLE hBrokenEvent;
  257. PVOID pEndpoint;
  258. ULONG EndpointLength;
  259. } SHADOW_INFO, *PSHADOW_INFO;
  260. /*
  261. * Command entry struct
  262. */
  263. typedef struct _COMMAND_ENTRY {
  264. LIST_ENTRY Links;
  265. HANDLE Event;
  266. struct _WINSTATION_APIMSG * pMsg;
  267. } COMMAND_ENTRY, *PCOMMAND_ENTRY;
  268. /*
  269. * Event wait structure
  270. */
  271. typedef struct _EVENT {
  272. LIST_ENTRY EventListEntry;
  273. HANDLE Event;
  274. BOOLEAN fWaiter;
  275. BOOLEAN fClosing;
  276. NTSTATUS WaitResult;
  277. ULONG EventMask;
  278. ULONG EventFlags;
  279. } EVENT, *PEVENT;
  280. /*
  281. * RPC client context structure
  282. */
  283. typedef struct _RPC_CLIENT_CONTEXT{
  284. PEVENT pWaitEvent;
  285. } RPC_CLIENT_CONTEXT, *PRPC_CLIENT_CONTEXT;
  286. /*
  287. * This structure is used to keep track of the client accessing the
  288. * LPC interfaces. This structure is pointed to by the CONTEXT value
  289. * that the NT LPC system maintains for us on a per communication port
  290. * basis.
  291. */
  292. typedef struct _LPC_CLIENT_CONTEXT {
  293. ULONG ClientLogonId;
  294. HANDLE CommunicationPort;
  295. ULONG AccessRights;
  296. PVOID ClientViewBase;
  297. PVOID ClientViewBounds;
  298. PVOID ViewBase;
  299. SIZE_T ViewSize;
  300. PVOID ViewRemoteBase;
  301. } LPC_CLIENT_CONTEXT, *PLPC_CLIENT_CONTEXT;
  302. typedef struct _LOAD_BALANCING_METRICS {
  303. BOOLEAN fInitialized;
  304. // Basic system information
  305. ULONG NumProcessors;
  306. ULONG PageSize;
  307. ULONG PhysicalPages;
  308. // Idle system values to remove base system usage
  309. ULONG BaselineFreePtes ;
  310. ULONG BaselinePagedPool;
  311. ULONG BaselineCommit;
  312. // Minimum usage values to prevent absurdly large estimates
  313. ULONG MinPtesPerUser;
  314. ULONG MinPagedPoolPerUser;
  315. ULONG MinCommitPerUser;
  316. // Live usage values derived from runtime data: totals
  317. ULONG PtesUsed;
  318. ULONG PagedPoolUsed;
  319. ULONG CommitUsed;
  320. // Live usage values derived from runtime data: per user
  321. ULONG AvgPtesPerUser;
  322. ULONG AvgPagedPoolPerUser;
  323. ULONG AvgCommitPerUser;
  324. // Raw and Estimated values for session capacity
  325. ULONG RemainingSessions;
  326. ULONG EstimatedSessions;
  327. // CPU utilization metrics
  328. ULONG AvgIdleCPU;
  329. LARGE_INTEGER TotalCPU;
  330. LARGE_INTEGER IdleCPU;
  331. } LOAD_BALANCING_METRICS, *PLOAD_BALANCING_METRICS;
  332. // TODO: Is there a better place to get this value from?
  333. //
  334. #define MAX_PROCESSORS 32
  335. // Minimum assumed resource usage per user
  336. //
  337. // TODO: Use these as registry defaults, but attempt to read from registry
  338. //
  339. // Floating point optimization: (Avg >> 1) == 0.50 (growth reservation)
  340. #define SimGrowthBias 1
  341. #define SimUserMinimum 5
  342. // DEW (34 threads) = 1434KB (PTE) + 649KB (PP) + 172KB (NPP)
  343. #define DEWAvgPtesPerUser 1434
  344. #define DEWAvgPagedPoolPerUser 649
  345. #define DEWAvgNonPagedPoolPerUser 172
  346. #define DEWCommitPerUser 3481
  347. // KW (65 threads) = 2812KB (PTE) + 987KB (PP) + 460KB (NPP)
  348. #define KWAvgPtesPerUser 2812
  349. #define KWAvgPagedPoolPerUser 987
  350. #define KWAvgNonPagedPoolPerUser 460
  351. #define KWCommitPerUser 7530
  352. #define SimAvgPtesPerUser DEWAvgPtesPerUser
  353. #define SimAvgPagedPoolPerUser DEWAvgPagedPoolPerUser
  354. #define SimAvgNonPagedPoolPerUser DEWAvgNonPagedPoolPerUser
  355. #define SimCommitPerUser DEWCommitPerUser
  356. /*
  357. * Global variables
  358. */
  359. extern BOOLEAN ShutdownInProgress;
  360. //extern BOOLEAN ShutdownTerminateNoWait;
  361. extern ULONG ShutDownFromSessionID;
  362. extern RTL_CRITICAL_SECTION WinStationListLock;
  363. extern RTL_CRITICAL_SECTION WinStationListenersLock;
  364. extern RTL_CRITICAL_SECTION TimerCritSec;
  365. extern LIST_ENTRY SystemEventHead;
  366. extern HANDLE hTrace;
  367. extern BOOL g_bPersonalTS;
  368. extern BOOL g_bPersonalWks;
  369. extern BOOL gbServer;
  370. extern BOOLEAN g_fDenyTSConnectionsPolicy;
  371. /*
  372. * Globals to support load balancing. Since this is queried frequently we can't
  373. * afford to lock the winstation list and count them up.
  374. */
  375. extern ULONG IdleWinStationPoolCount;
  376. extern ULONG WinStationTotalCount;
  377. extern ULONG WinStationDiscCount;
  378. extern LOAD_BALANCING_METRICS gLB;
  379. extern ExtendedClientCredentials g_MprNotifyInfo;
  380. /*
  381. * Function prototypes
  382. */
  383. NTSTATUS InitTermSrv(HKEY);
  384. void StartAllWinStations(HKEY);
  385. NTSTATUS CheckWinStationEnable(LPWSTR);
  386. NTSTATUS SetWinStationEnable(LPWSTR, ULONG);
  387. NTSTATUS
  388. LoadSubSystemsForWinStation(
  389. IN PWINSTATION pWinStation );
  390. VOID
  391. FreeWinStationLists(
  392. PWINSTATION pWinStation );
  393. NTSTATUS
  394. GetProcessLogonId(
  395. IN HANDLE Process,
  396. OUT PULONG pLogonId );
  397. NTSTATUS
  398. SetProcessLogonId(
  399. IN HANDLE Process,
  400. IN ULONG LogonId );
  401. PWINSTATION FindWinStationById( ULONG, BOOLEAN );
  402. PWINSTATION FindWinStationByName( LPWSTR, BOOLEAN );
  403. BOOLEAN LockWinStationByPointer( PWINSTATION );
  404. BOOLEAN IsWinStationLockedByCaller( PWINSTATION );
  405. NTSTATUS QueueWinStationReset( IN ULONG LogonId );
  406. NTSTATUS QueueWinStationDisconnect( IN ULONG LogonId );
  407. VOID ResetGroupByListener( PWINSTATIONNAME );
  408. VOID NotifySystemEvent(ULONG);
  409. NTSTATUS WinStationOpenChannel(
  410. HANDLE IcaDevice,
  411. HANDLE ProcessHandle,
  412. CHANNELCLASS ChannelClass,
  413. PVIRTUALCHANNELNAME pVirtualName,
  414. PHANDLE pDupChannel);
  415. VOID InvalidateTerminateWaitList(VOID);
  416. #define UnlockWinStation( _p ) UnlockRefLock( &_p->Lock )
  417. #define RelockWinStation( _p ) RelockRefLock( &_p->Lock )
  418. #define ReleaseWinStation( _p ) ReleaseRefLock( &_p->Lock )
  419. NTSTATUS InitRefLock( PREFLOCK, PREFLOCKDELETEPROCEDURE );
  420. BOOLEAN LockRefLock( PREFLOCK );
  421. VOID UnlockRefLock( PREFLOCK );
  422. BOOLEAN RelockRefLock( PREFLOCK );
  423. VOID ReleaseRefLock( PREFLOCK );
  424. VOID DeleteRefLock( PREFLOCK );
  425. #if DBG
  426. #define ENTERCRIT(_x) \
  427. { \
  428. ASSERT( (HANDLE)LongToHandle( GetCurrentThreadId() ) != (_x)->OwningThread ); \
  429. RtlEnterCriticalSection(_x); \
  430. }
  431. #define LEAVECRIT(_x) \
  432. { \
  433. ASSERT( (HANDLE)LongToHandle( GetCurrentThreadId() ) == (_x)->OwningThread ); \
  434. RtlLeaveCriticalSection(_x); \
  435. }
  436. #else
  437. #define ENTERCRIT(_x) RtlEnterCriticalSection(_x)
  438. #define LEAVECRIT(_x) RtlLeaveCriticalSection(_x)
  439. #endif
  440. NTSTATUS
  441. MakeUserGlobalPath(
  442. IN OUT PUNICODE_STRING Unicode,
  443. IN ULONG LogonId );
  444. NTSTATUS SendWinStationCommand( PWINSTATION, PWINSTATION_APIMSG, ULONG );
  445. NTSTATUS
  446. WsxStackIoControl(
  447. PVOID pContext,
  448. IN HANDLE pStack,
  449. IN ULONG IoControlCode,
  450. IN PVOID pInBuffer,
  451. IN ULONG InBufferSize,
  452. OUT PVOID pOutBuffer,
  453. IN ULONG OutBufferSize,
  454. OUT PULONG pBytesReturned );
  455. VOID MergeUserConfigData( PWINSTATION pWinStation,
  456. PPOLICY_TS_USER pPolicy,
  457. PUSERCONFIGW pPolicyData,
  458. PUSERCONFIG pUserConfig ) ;
  459. VOID StartLogonTimers( PWINSTATION );
  460. VOID ResetUserConfigData( PWINSTATION );
  461. LONG IcaTimerCreate( ULONG, HANDLE * );
  462. NTSTATUS IcaTimerStart( HANDLE, PVOID, PVOID, ULONG );
  463. BOOLEAN IcaTimerCancel( HANDLE );
  464. BOOLEAN IcaTimerClose( HANDLE );
  465. VOID InitializeTrace(IN PWINSTATION, IN BOOLEAN, OUT PICA_TRACE);
  466. void InitializeSystemTrace(HKEY);
  467. void GetSetSystemParameters(HKEY);
  468. NTSTATUS CdmConnect( ULONG, HANDLE );
  469. NTSTATUS CdmDisconnect( ULONG, HANDLE );
  470. VOID VirtualChannelSecurity( PWINSTATION );
  471. VOID
  472. WinstationUnloadProfile( PWINSTATION pWinStation);
  473. NTSTATUS
  474. WinStationResetWorker(
  475. ULONG LogonId,
  476. BOOLEAN bWait,
  477. BOOLEAN CallerIsRpc,
  478. BOOLEAN bRecreate
  479. );
  480. BOOL StartStopListeners( LPWSTR WinStationName, BOOLEAN bStart );
  481. NTSTATUS WinStationCreateWorker( PWINSTATIONNAME, PULONG );
  482. NTSTATUS ConsoleShadowStart( IN PWINSTATION pWinStation,
  483. IN PWINSTATIONCONFIG2 pClientConfig,
  484. IN PVOID pModuleData,
  485. IN ULONG ModuleDataLength);
  486. NTSTATUS ConsoleShadowStop(PWINSTATION pWinStation);
  487. NTSTATUS TransferConnectionToIdleWinStation(
  488. PWINSTATION pListenWinStation,
  489. PVOID pEndpoint,
  490. ULONG EndpointLength,
  491. PICA_STACK_ADDRESS pStackAddress );
  492. PWINSTATION
  493. GetWinStationFromArcInfo(
  494. PBYTE pClientRandom,
  495. LONG cbClientRandomLen,
  496. PTS_AUTORECONNECTINFO pArc
  497. );
  498. // Why doesn't the compiler complain that each source file is redefining
  499. // a global variable? This file _is_ included by all source files in this
  500. // directory. But these definitions will cause warnings if they show up
  501. // in the licensing core, so give the core the ability to ifdef them out.
  502. #ifndef LSCORE_NO_ICASRV_GLOBALS
  503. PVOID IcaHeap;
  504. PVOID DefaultEnvironment;
  505. HANDLE IcaSmApiPort;
  506. HANDLE hModuleWin;
  507. #endif
  508. #if DBG
  509. #define DBGPRINT(_arg) DbgPrint _arg
  510. #else
  511. #define DBGPRINT(_arg)
  512. #endif
  513. #if DBG
  514. #undef TRACE
  515. #define TRACE(_arg) { if (hTrace) IcaSystemTrace _arg; }
  516. #else
  517. #define TRACE(_arg)
  518. #endif
  519. /*=============================================================================
  520. == TermSrv Server Extension supplied procs
  521. =============================================================================*/
  522. /*
  523. * Macros
  524. */
  525. #define WSX_INITIALIZE "WsxInitialize"
  526. #define WSX_WINSTATIONINITIALIZE "WsxWinStationInitialize"
  527. #define WSX_WINSTATIONREINITIALIZE "WsxWinStationReInitialize"
  528. #define WSX_WINSTATIONRUNDOWN "WsxWinStationRundown"
  529. #define WSX_CDMCONNECT "WsxConnect"
  530. #define WSX_CDMDISCONNECT "WsxDisconnect"
  531. #define WSX_VERIFYCLIENTLICENSE "WsxVerifyClientLicense"
  532. #define WSX_QUERYLICENSE "WsxQueryLicense"
  533. #define WSX_GETLICENSE "WsxGetLicense"
  534. #define WSX_WINSTATIONLOGONANNOYANCE "WsxWinStationLogonAnnoyance"
  535. #define WSX_WINSTATIONGENERATELICENSE "WsxWinStationGenerateLicense"
  536. #define WSX_WINSTATIONINSTALLLICENSE "WsxWinStationInstallLicense"
  537. #define WSX_WINSTATIONENUMERATELICENSES "WsxWinStationEnumerateLicenses"
  538. #define WSX_WINSTATIONACTIVATELICENSE "WsxWinStationActivateLicense"
  539. #define WSX_WINSTATIONREMOVELICENSE "WsxWinStationRemoveLicense"
  540. #define WSX_WINSTATIONSETPOOLCOUNT "WsxWinStationSetPoolCount"
  541. #define WSX_WINSTATIONQUERYUPDATEREQUIRED "WsxWinStationQueryUpdateRequired"
  542. #define WSX_WINSTATIONANNOYANCETHREAD "WsxWinStationAnnoyanceThread"
  543. #define WSX_DUPLICATECONTEXT "WsxDuplicateContext"
  544. #define WSX_COPYCONTEXT "WsxCopyContext"
  545. #define WSX_CLEARCONTEXT "WsxClearContext"
  546. #define WSX_INITIALIZECLIENTDATA "WsxInitializeClientData"
  547. #define WSX_INITIALIZEUSERCONFIG "WsxInitializeUserConfig"
  548. #define WSX_CONVERTPUBLISHEDAPP "WsxConvertPublishedApp"
  549. #define WSX_VIRTUALCHANNELSECURITY "WsxVirtualChannelSecurity"
  550. #define WSX_ICASTACKIOCONTROL "WsxIcaStackIoControl"
  551. #define WSX_BROKENCONNECTION "WsxBrokenConnection"
  552. #define WSX_LOGONNOTIFY "WsxLogonNotify"
  553. #define WSX_SETERRORINFO "WsxSetErrorInfo"
  554. #define WSX_ESCAPE "WsxEscape"
  555. #define WSX_SENDAUTORECONNECTSTATUS "WsxSendAutoReconnectStatus"
  556. /*
  557. * Typedefs and structures
  558. */
  559. typedef struct _WSEXTENSION {
  560. LIST_ENTRY Links; // Links
  561. DLLNAME WsxDLL; // DLL name
  562. HANDLE hInstance; // Handle of the DLL
  563. PVOID Context; // Extension context data
  564. PWSX_INITIALIZE pWsxInitialize;
  565. PWSX_WINSTATIONINITIALIZE pWsxWinStationInitialize;
  566. PWSX_WINSTATIONREINITIALIZE pWsxWinStationReInitialize;
  567. PWSX_WINSTATIONRUNDOWN pWsxWinStationRundown;
  568. PWSX_CDMCONNECT pWsxCdmConnect;
  569. PWSX_CDMDISCONNECT pWsxCdmDisconnect;
  570. PWSX_VERIFYCLIENTLICENSE pWsxVerifyClientLicense;
  571. PWSX_QUERYLICENSE pWsxQueryLicense;
  572. PWSX_GETLICENSE pWsxGetLicense;
  573. PWSX_WINSTATIONLOGONANNOYANCE pWsxWinStationLogonAnnoyance;
  574. PWSX_WINSTATIONGENERATELICENSE pWsxWinStationGenerateLicense;
  575. PWSX_WINSTATIONINSTALLLICENSE pWsxWinStationInstallLicense;
  576. PWSX_WINSTATIONENUMERATELICENSES pWsxWinStationEnumerateLicenses;
  577. PWSX_WINSTATIONACTIVATELICENSE pWsxWinStationActivateLicense;
  578. PWSX_WINSTATIONREMOVELICENSE pWsxWinStationRemoveLicense;
  579. PWSX_WINSTATIONSETPOOLCOUNT pWsxWinStationSetPoolCount;
  580. PWSX_WINSTATIONQUERYUPDATEREQUIRED pWsxWinStationQueryUpdateRequired;
  581. PWSX_WINSTATIONANNOYANCETHREAD pWsxWinStationAnnoyanceThread;
  582. PWSX_DUPLICATECONTEXT pWsxDuplicateContext;
  583. PWSX_COPYCONTEXT pWsxCopyContext;
  584. PWSX_CLEARCONTEXT pWsxClearContext;
  585. PWSX_INITIALIZECLIENTDATA pWsxInitializeClientData;
  586. PWSX_INITIALIZEUSERCONFIG pWsxInitializeUserConfig;
  587. PWSX_CONVERTPUBLISHEDAPP pWsxConvertPublishedApp;
  588. PWSX_VIRTUALCHANNELSECURITY pWsxVirtualChannelSecurity;
  589. PWSX_ICASTACKIOCONTROL pWsxIcaStackIoControl;
  590. PWSX_BROKENCONNECTION pWsxBrokenConnection;
  591. PWSX_LOGONNOTIFY pWsxLogonNotify;
  592. PWSX_SETERRORINFO pWsxSetErrorInfo;
  593. PWSX_SENDAUTORECONNECTSTATUS pWsxSendAutoReconnectStatus;
  594. PWSX_ESCAPE pWsxEscape;
  595. } WSEXTENSION, * PWSEXTENSION;
  596. //
  597. // For disconnect / reconnect completion constants
  598. // Currently we wait 5000 milisecs (12*15) times,
  599. // which make a maximum total wait of 3 minutes.
  600. #define WINSTATION_WAIT_COMPLETE_DURATION 5000
  601. #define WINSTATION_WAIT_COMPLETE_RETRIES (12*15)
  602. // For disconnect completion constant when we do a reconnect
  603. // Currently we wait 2000 milisecs, (5*3) times,
  604. // which make a maximum total wait of 30 seconds
  605. #define WINSTATION_WAIT_DURATION 2000
  606. #define WINSTATION_WAIT_RETRIES (5*3)
  607. #ifdef __cplusplus
  608. }
  609. #endif