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.

127 lines
5.5 KiB

  1. // --------------------------------------------------------------------------
  2. // Module Name: ThemeManagerSessionData.h
  3. //
  4. // Copyright (c) 2000, Microsoft Corporation
  5. //
  6. // This file contains a class that implements information the encapsulates a
  7. // client TS session for the theme server.
  8. //
  9. // History: 2000-10-10 vtan created
  10. // 2000-11-29 vtan moved to separate file
  11. // --------------------------------------------------------------------------
  12. #ifndef _ThemeManagerSessionData_
  13. #define _ThemeManagerSessionData_
  14. #include "APIConnection.h"
  15. // --------------------------------------------------------------------------
  16. // CLoaderProcess
  17. //
  18. // Purpose: Manages per-session process loader data.
  19. //
  20. // Note: all loader methods should be invoked only under session-wide lock.
  21. //
  22. // History: 2002-03-06 scotthan created
  23. // --------------------------------------------------------------------------
  24. class CLoaderProcess
  25. {
  26. public:
  27. CLoaderProcess();
  28. ~CLoaderProcess();
  29. // create, destroy.
  30. NTSTATUS Create(IN PVOID pvSessionData,
  31. IN HANDLE hTokenClient,
  32. IN OPTIONAL LPWSTR pszDesktop,
  33. IN LPCWSTR pszFile,
  34. IN LPCWSTR pszColor,
  35. IN LPCWSTR pszSize,
  36. OUT HANDLE* phLoader);
  37. // section validation, ownership
  38. NTSTATUS ValidateAndCopySection( PVOID pvSessionData, IN HANDLE hSectionIn, OUT HANDLE *phSectionOut );
  39. // section cleanup
  40. void Clear(PVOID pvContext, BOOL fClearHResult);
  41. // query methods
  42. BOOL IsProcessLoader( IN HANDLE hProcess );
  43. BOOL IsAlive() const {return _process_info.hProcess != NULL;}
  44. // access functions
  45. NTSTATUS SetHResult( IN HRESULT hr ) {_hr = hr; return STATUS_SUCCESS;}
  46. HANDLE GetSectionHandle( BOOL fTakeOwnership );
  47. HRESULT GetHResult() const { return _hr; }
  48. private:
  49. // access functions
  50. NTSTATUS SetSectionHandle( IN HANDLE hSection );
  51. // data
  52. PROCESS_INFORMATION _process_info; // secure loader process information.
  53. LPWSTR _pszFile;
  54. LPWSTR _pszColor;
  55. LPWSTR _pszSize;
  56. HANDLE _hSection; // secure theme section handle, valid in service's address space.
  57. // This member is assigned by API_THEMES_SECUREAPPLYTHEME, and propagated
  58. // to caller of API_THEMES_SECURELOADTHEME.
  59. // The lifetime of this value should not exceed that of the
  60. // API_THEMES_SECURELOADTHEME's handler (i.e, uninitialized on handler's entry,
  61. // uninitialized on handler's exit)
  62. HRESULT _hr ; // HRESULT associated with _hSection. Assigned in API_THEMES_SECUREAPPLYTHEME,
  63. // propagated to caller of API_THEMES_SECURELOADTHEME.
  64. };
  65. // --------------------------------------------------------------------------
  66. // CThemeManagerSessionData
  67. //
  68. // Purpose: This class encapsulates all the information that the theme
  69. // manager needs to maintain a client session.
  70. //
  71. // History: 2000-11-17 vtan created
  72. // 2000-11-29 vtan moved to separate file
  73. // --------------------------------------------------------------------------
  74. class CThemeManagerSessionData : public CCountedObject
  75. {
  76. private:
  77. CThemeManagerSessionData (void);
  78. public:
  79. CThemeManagerSessionData (DWORD dwSessionID);
  80. ~CThemeManagerSessionData (void);
  81. void* GetData (void) const;
  82. bool EqualSessionID (DWORD dwSessionID) const;
  83. NTSTATUS Allocate (HANDLE hProcessClient, DWORD dwServerChangeNumber, void *pfnRegister, void *pfnUnregister, void *pfnClearStockObjects, DWORD dwStackSizeReserve, DWORD dwStackSizeCommit);
  84. NTSTATUS Cleanup (void);
  85. NTSTATUS UserLogon (HANDLE hToken);
  86. NTSTATUS UserLogoff (void);
  87. // secure loader process access methods.
  88. // note: all loader methods should be invoked only under session-wide lock.
  89. NTSTATUS GetLoaderProcess( OUT CLoaderProcess** ppLoader );
  90. static void SetAPIConnection (CAPIConnection *pAPIConnection);
  91. static void ReleaseAPIConnection (void);
  92. private:
  93. void SessionTermination (void);
  94. static void CALLBACK CB_SessionTermination (void *pParameter, BOOLEAN TimerOrWaitFired);
  95. static DWORD WINAPI CB_UnregisterWait (void *pParameter);
  96. private:
  97. DWORD _dwSessionID;
  98. void* _pvThemeLoaderData;
  99. HANDLE _hToken;
  100. HANDLE _hProcessClient;
  101. HANDLE _hWait;
  102. CLoaderProcess* _pLoader;
  103. static CAPIConnection* s_pAPIConnection;
  104. };
  105. #endif /* _ThemeManagerSessionData_ */