Leaked source code of windows server 2003
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.

184 lines
3.0 KiB

  1. /*
  2. * Session.h
  3. *
  4. * Author: BreenH
  5. *
  6. * The Session class provides a level of separation between the winstation
  7. * structure and the policy modules. It is just a wrapper class; it does not
  8. * create or destroy winstation stuctures.
  9. */
  10. #ifndef __LC_SESSION_H__
  11. #define __LC_SESSION_H__
  12. /*
  13. * Typedefs
  14. */
  15. typedef struct {
  16. CRITICAL_SECTION CritSec;
  17. class CPolicy *pPolicy;
  18. ULONG ulClientProtocolVersion;
  19. HANDLE hProtocolLibContext;
  20. BOOL fTsLicense;
  21. BOOL fLlsLicense;
  22. LS_HANDLE hLlsLicense;
  23. LPARAM lPrivate;
  24. } LCCONTEXT, *LPLCCONTEXT;
  25. /*
  26. * Class Definition
  27. */
  28. class CSession
  29. {
  30. public:
  31. /*
  32. * Creation Functions
  33. */
  34. CSession(
  35. PWINSTATION pWinStation
  36. )
  37. {
  38. m_pWinStation = pWinStation;
  39. }
  40. ~CSession(
  41. )
  42. {
  43. m_pWinStation = NULL;
  44. }
  45. /*
  46. * Get Functions
  47. */
  48. inline HANDLE
  49. GetIcaStack(
  50. ) const
  51. {
  52. return(m_pWinStation->hStack);
  53. }
  54. inline LPLCCONTEXT
  55. GetLicenseContext(
  56. ) const
  57. {
  58. return((LPLCCONTEXT)(m_pWinStation->lpLicenseContext));
  59. }
  60. inline ULONG
  61. GetLogonId(
  62. ) const
  63. {
  64. return(m_pWinStation->LogonId);
  65. }
  66. inline LPCWSTR
  67. GetUserDomain(
  68. ) const
  69. {
  70. return((LPCWSTR)(m_pWinStation->Domain));
  71. }
  72. inline LPCWSTR
  73. GetUserName(
  74. ) const
  75. {
  76. return((LPCWSTR)(m_pWinStation->UserName));
  77. }
  78. /*
  79. * Is Functions
  80. */
  81. inline BOOLEAN
  82. IsConsoleSession(
  83. ) const
  84. {
  85. return((BOOLEAN)(GetCurrentConsoleId() == m_pWinStation->LogonId));
  86. }
  87. inline BOOLEAN
  88. IsSessionZero(
  89. ) const
  90. {
  91. return((BOOLEAN)((0 == m_pWinStation->LogonId)
  92. || (m_pWinStation->bClientSupportsRedirection
  93. && m_pWinStation->bRequestedSessionIDFieldValid
  94. && (0 == m_pWinStation->RequestedSessionID))));
  95. }
  96. inline BOOLEAN
  97. IsUserAdmin(
  98. ) const
  99. {
  100. return(m_pWinStation->fUserIsAdmin);
  101. }
  102. inline BOOL
  103. IsUserHelpAssistant(
  104. ) const
  105. {
  106. return TSIsSessionHelpSession( m_pWinStation, NULL );
  107. }
  108. /*
  109. * Do Functions
  110. */
  111. inline NTSTATUS
  112. SendWinStationCommand(
  113. PWINSTATION_APIMSG pMsg
  114. )
  115. {
  116. //
  117. // Wait time must be zero, or termsrv will release the winstation,
  118. // causing who knows what to happen to our state.
  119. //
  120. return(::SendWinStationCommand(m_pWinStation, pMsg, 0));
  121. }
  122. //
  123. // ASSUMPTION: This function will be
  124. // called with the stack lock already held
  125. //
  126. inline NTSTATUS
  127. SetErrorInfo(
  128. UINT32 dwErr
  129. )
  130. {
  131. if(m_pWinStation->pWsx &&
  132. m_pWinStation->pWsx->pWsxSetErrorInfo &&
  133. m_pWinStation->pWsxContext)
  134. {
  135. return m_pWinStation->pWsx->pWsxSetErrorInfo(
  136. m_pWinStation->pWsxContext,
  137. dwErr,
  138. TRUE); //lock already held
  139. }
  140. else
  141. {
  142. return STATUS_INVALID_PARAMETER;
  143. }
  144. }
  145. /*
  146. * Set Functions
  147. */
  148. private:
  149. PWINSTATION m_pWinStation;
  150. };
  151. #endif