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.

192 lines
5.6 KiB

  1. #pragma once
  2. #include <windows.h>
  3. #include <objbase.h>
  4. #include <objsel.h>
  5. #include <shlobj.h>
  6. //
  7. #define TSCFG_MUTEXNAME TEXT("Global\\TerminalServerConfigMutex")
  8. //***************************************************************************************
  9. //class CRemoteUsersDialog
  10. //***************************************************************************************
  11. class CRemoteUsersDialog
  12. {
  13. private:
  14. HINSTANCE m_hInst;
  15. HWND m_hDlg;
  16. HWND m_hList;
  17. WCHAR m_szRemoteGroupName[MAX_PATH+1];
  18. WCHAR m_szLocalCompName[MAX_PATH+1];
  19. BOOL m_bCanShowDialog;
  20. //image indexes
  21. int m_iLocUser,m_iGlobUser,m_iLocGroup,m_iGlobGroup,m_iUnknown;
  22. public:
  23. CRemoteUsersDialog(HINSTANCE hInst);
  24. INT_PTR DoDialog(HWND hwndParent);
  25. BOOL CanShowDialog(LPBOOL pbAccessDenied);
  26. void OnInitDialog(HWND hDlg);
  27. void OnLink(WPARAM wParam);
  28. BOOL OnOk();
  29. void OnItemChanged(LPARAM lParam);
  30. void OnDestroyWindow();
  31. void AddUsers();
  32. void RemoveUsers();
  33. private:
  34. void AddPickerItems(DS_SELECTION_LIST *selections);
  35. int FindItemBySid(PSID pSid);
  36. void ReloadList();
  37. BOOL IsLocal(LPWSTR wszDomainandname);
  38. void InitAccessMessage();
  39. };
  40. INT_PTR APIENTRY RemoteUsersDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
  41. //***************************************************************************************
  42. //class CRemotePage
  43. //***************************************************************************************
  44. class CRemotePage : public IShellExtInit, IShellPropSheetExt
  45. {
  46. private:
  47. //reference counter
  48. ULONG m_cref;
  49. BOOL m_bProfessional;
  50. DWORD m_dwPageType;
  51. HINSTANCE m_hInst;
  52. HWND m_hDlg;
  53. DWORD m_dwInitialState;
  54. BOOL m_bDisableChkBox;
  55. BOOL m_bDisableButtons;
  56. BOOL m_bShowAccessDeniedWarning;
  57. WORD m_TemplateId;
  58. CRemoteUsersDialog m_RemoteUsersDialog;
  59. public:
  60. CRemotePage(HINSTANCE hinst);
  61. ~CRemotePage();
  62. ///////////////////////////////
  63. // Interface IUnknown
  64. ///////////////////////////////
  65. STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
  66. STDMETHODIMP_(ULONG) AddRef();
  67. STDMETHODIMP_(ULONG) Release();
  68. ///////////////////////////////
  69. // Interface IShellExtInit
  70. ///////////////////////////////
  71. STDMETHODIMP Initialize(LPCITEMIDLIST , LPDATAOBJECT , HKEY );
  72. ///////////////////////////////
  73. // Interface IShellPropSheetExt
  74. ///////////////////////////////
  75. STDMETHODIMP AddPages( LPFNADDPROPSHEETPAGE , LPARAM );
  76. STDMETHODIMP ReplacePage( UINT , LPFNADDPROPSHEETPAGE , LPARAM );
  77. ///////////////////////////////
  78. // Internal functions
  79. ///////////////////////////////
  80. void OnInitDialog(HWND hDlg);
  81. void OnSetActive();
  82. BOOL OnApply();
  83. void OnLink(WPARAM wParam);
  84. BOOL OnRemoteEnable();
  85. void OnRemoteSelectUsers();
  86. void RemoteEnableWarning();
  87. private:
  88. BOOL CanShowRemotePage();
  89. };
  90. INT_PTR APIENTRY RemoteDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
  91. #define PAGE_TYPE_UNKNOWN 0
  92. #define PAGE_TYPE_PTS 1
  93. #define PAGE_TYPE_APPSERVER 2
  94. #define PAGE_TYPE_PERSONAL 3
  95. //***************************************************************************************
  96. //class CWaitCursor
  97. //***************************************************************************************
  98. class CWaitCursor
  99. {
  100. private:
  101. HCURSOR m_hOldCursor;
  102. public:
  103. CWaitCursor()
  104. {
  105. m_hOldCursor=SetCursor(LoadCursor(NULL,IDC_WAIT));
  106. }
  107. ~CWaitCursor()
  108. {
  109. SetCursor(m_hOldCursor);
  110. }
  111. };
  112. //***************************************************************************************
  113. //class CMutex
  114. //***************************************************************************************
  115. class CMutex
  116. {
  117. private:
  118. HANDLE m_hMutex;
  119. public:
  120. CMutex() : m_hMutex(NULL)
  121. {
  122. m_hMutex=CreateMutex(NULL,TRUE,TSCFG_MUTEXNAME);
  123. if(m_hMutex)
  124. {
  125. //wait up to 30 sec.
  126. WaitForSingleObject(m_hMutex,30000);
  127. }
  128. }
  129. ~CMutex()
  130. {
  131. if(m_hMutex)
  132. {
  133. ReleaseMutex(m_hMutex);
  134. CloseHandle(m_hMutex);
  135. }
  136. }
  137. };
  138. //***************************************************************************************
  139. //class COfflineFilesDialog
  140. //***************************************************************************************
  141. class COfflineFilesDialog
  142. {
  143. private:
  144. HINSTANCE m_hInst;
  145. HWND m_hDlg;
  146. public:
  147. COfflineFilesDialog(HINSTANCE hInst);
  148. INT_PTR DoDialog(HWND hwndParent);
  149. void OnInitDialog(HWND hDlg);
  150. void OnLink(WPARAM wParam);
  151. };
  152. INT_PTR APIENTRY OfflineFilesDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
  153. //***************************************************************************************
  154. //Global functions
  155. //***************************************************************************************
  156. BOOL
  157. getGroupMembershipPickerSettings(
  158. DSOP_SCOPE_INIT_INFO*& infos,
  159. ULONG& infoCount);
  160. HRESULT VariantToSid(VARIANT* var, PSID *ppSid);
  161. BOOL TestUserForAdmin();
  162. void DisplayError(HINSTANCE hInst, HWND hDlg, UINT ErrID, UINT MsgID, UINT TitleID, ...);
  163. BOOL LookupSid(IN PSID pSid, OUT LPWSTR *ppName, OUT SID_NAME_USE *peUse);
  164. BOOL GetTokenUserName(IN HANDLE hToken,OUT LPWSTR *ppName);
  165. BOOL GetRDPSecurityDescriptor(OUT PSECURITY_DESCRIPTOR *ppSD);
  166. BOOL CheckWinstationLogonAccess(IN HANDLE hToken,IN PSECURITY_DESCRIPTOR pSD);