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.

319 lines
10 KiB

  1. //Copyright (c) 1998 - 1999 Microsoft Corporation
  2. /*********************************************************************************************
  3. *
  4. *
  5. * Module Name:
  6. *
  7. * CfgComp.h
  8. *
  9. * Abstract:
  10. * This contains the declaration for the functions in CfgBkEnd.
  11. *
  12. *
  13. * Author: Arathi Kundapur: a-akunda
  14. *
  15. *
  16. * Revision:
  17. *
  18. *
  19. ************************************************************************************************/
  20. #ifndef __CFGCOMP_H_
  21. #define __CFGCOMP_H_
  22. #include "resource.h" // main symbols
  23. #include "PtrArray.h" // Added by ClassView
  24. extern HINSTANCE g_hInstance;
  25. /////////////////////////////////////////////////////////////////////////////
  26. // CCfgComp
  27. class ATL_NO_VTABLE CCfgComp :
  28. public CComObjectRootEx<CComSingleThreadModel>,
  29. public CComCoClass<CCfgComp, &CLSID_CfgComp>,
  30. public ICfgComp,
  31. public ISettingsComp ,
  32. public IUserSecurity
  33. {
  34. public:
  35. CCfgComp()
  36. {
  37. m_bInitialized = FALSE;
  38. m_bAdmin = FALSE;
  39. lstrcpy( m_szConsole , L"Console" );
  40. /*
  41. LoadString(g_hInstance, IDS_SYSTEM_CONSOLE_NAME,
  42. m_szConsole, WINSTATIONNAME_LENGTH );
  43. */
  44. }
  45. ~CCfgComp()
  46. {
  47. UnInitialize();
  48. }
  49. DECLARE_REGISTRY_RESOURCEID(IDR_CFGCOMP)
  50. DECLARE_NOT_AGGREGATABLE(CCfgComp)
  51. BEGIN_COM_MAP(CCfgComp)
  52. COM_INTERFACE_ENTRY(ICfgComp)
  53. COM_INTERFACE_ENTRY(ISettingsComp)
  54. COM_INTERFACE_ENTRY(IUserSecurity)
  55. END_COM_MAP()
  56. // ICfgComp Methods
  57. public:
  58. // STDMETHOD(SetDefaultSecurity)(ULONG Offset);
  59. // STDMETHOD(GetDefaultSecurity)(ULONG * pDefaultSecurity);
  60. STDMETHOD(SetInternetConLic)(BOOL bInternetConLic , PDWORD );
  61. STDMETHOD(GetInternetConLic)(BOOL * pbInternetConLic , PDWORD );
  62. STDMETHOD(SetLicensingMode)(ULONG ulMode , PDWORD, PDWORD );
  63. STDMETHOD(GetLicensingMode)(ULONG *pulMode , PDWORD );
  64. STDMETHOD(GetLicensingModeInfo)(ULONG ulMode , WCHAR **pwszName, WCHAR **pwszDescription, PDWORD );
  65. STDMETHOD(GetLicensingModeList)(ULONG *pcModes , ULONG **prgulModes, PDWORD );
  66. STDMETHOD(SetUseTempDirPerSession)(BOOL bTempDirPerSession);
  67. STDMETHOD(GetUseTempDirPerSession)(BOOL * pbTempDir);
  68. STDMETHOD(SetDelDirsOnExit)(BOOL bDelDirsOnExit);
  69. STDMETHOD(GetDelDirsOnExit)(BOOL * pDelDirsOnExit);
  70. // STDMETHOD(SetCachedSessions)(DWORD dCachedSessions);
  71. STDMETHOD_(BOOL, IsAsyncDeviceAvailable)(LPCTSTR pDeviceName);
  72. STDMETHOD(DeleteWS)(PWINSTATIONNAME pWs);
  73. STDMETHOD(IsNetWorkConnectionUnique)(WCHAR * WdName, WCHAR * PdName, ULONG LanAdapter , BOOL * pUnique);
  74. STDMETHOD(GetDefaultUserConfig)(WCHAR * WdName,long * pSize,PUSERCONFIG* ppUser);
  75. STDMETHOD(CreateNewWS)(WS WinstationInfo,long UserCnfgSize, PUSERCONFIG pUserConfig, PASYNCCONFIGW pAsyncConfig);
  76. STDMETHOD(GetWSInfo)(PWINSTATIONNAME pWSName, long * Size, WS **ppWS);
  77. STDMETHOD(UpDateWS)( PWS , DWORD Data , PDWORD, BOOLEAN bPerformMerger );
  78. STDMETHOD(GetDefaultSecurityDescriptor)(long * pSize,PSECURITY_DESCRIPTOR *ppSecurityDescriptor);
  79. STDMETHOD(IsSessionReadOnly)(BOOL * pReadOnly);
  80. STDMETHOD(RenameWinstation)(PWINSTATIONNAMEW pOldWinstation, PWINSTATIONNAMEW pNewWinstation);
  81. STDMETHOD(EnableWinstation)(PWINSTATIONNAMEW pWSName, BOOL fEnable);
  82. STDMETHOD(SetUserConfig)(PWINSTATIONNAMEW pWsName, ULONG size, PUSERCONFIG pUserConfig , PDWORD );
  83. STDMETHOD(GetLanAdapterList)(WCHAR * pdName, ULONG * pNumAdapters,ULONG * pSize,WCHAR ** ppData);
  84. STDMETHOD(GetLanAdapterList2)(WCHAR * pdName, ULONG * pNumAdapters, PGUIDTBL *);
  85. STDMETHOD( BuildGuidTable )( PGUIDTBL * , int , WCHAR * );
  86. STDMETHOD(GetTransportTypes)(WCHAR * Name, NameType Type,ULONG *pNumWd,ULONG * pSize, WCHAR **ppData);
  87. STDMETHOD(IsWSNameUnique)(PWINSTATIONNAMEW pWSName,BOOL * pUnique);
  88. STDMETHOD(GetWdTypeList)(ULONG *pNumWd,ULONG * pSize, WCHAR **ppData);
  89. STDMETHOD(GetWinstationList)(ULONG * NumWinstations, ULONG * Size, PWS * ppWS);
  90. STDMETHOD(Initialize)();
  91. STDMETHOD(GetEncryptionLevels)(WCHAR * pName, NameType Type,ULONG * pNumEncryptionLevels,Encryption ** ppEncryption);
  92. STDMETHOD(GetUserConfig)(PWINSTATIONNAMEW pWsName, long * pSize,PUSERCONFIG * ppUser, BOOLEAN bPerformMerger);
  93. STDMETHOD(SetSecurityDescriptor)(PWINSTATIONNAMEW pWsName,DWORD Size,PSECURITY_DESCRIPTOR pSecurityDescriptor);
  94. STDMETHOD(GetSecurityDescriptor)(PWINSTATIONNAMEW pWSName,long * pSize,PSECURITY_DESCRIPTOR *ppSecurityDescriptor);
  95. STDMETHOD( ForceUpdate )( void );
  96. STDMETHOD( Refresh )( void );
  97. STDMETHOD( GetWdType )( PWDNAMEW , PULONG );
  98. STDMETHOD( GetTransportType )( WCHAR * , WCHAR * , DWORD * );
  99. STDMETHOD( IsAsyncUnique )( WCHAR * , WCHAR * , BOOL * );
  100. STDMETHOD( SetAsyncConfig )( WCHAR * , NameType , PASYNCCONFIGW , PDWORD );
  101. STDMETHOD( GetAsyncConfig )( WCHAR * , NameType , PASYNCCONFIGW );
  102. STDMETHOD( GetDeviceList )( WCHAR * , NameType , ULONG * , LPBYTE * );
  103. STDMETHOD( GetConnTypeName )( int , WCHAR * );
  104. STDMETHOD( GetHWReceiveName )( int , WCHAR * );
  105. STDMETHOD( GetHWTransmitName )( int , WCHAR * );
  106. STDMETHOD( GetModemCallbackString )( int , WCHAR * );
  107. STDMETHOD( GetCaps )( WCHAR * , ULONG * );
  108. STDMETHOD( QueryLoggedOnCount )( WCHAR * , LONG * );
  109. STDMETHOD( GetNumofWinStations )(WCHAR *,WCHAR *, PULONG );
  110. STDMETHOD( UpdateSessionDirectory )( PDWORD );
  111. STDMETHOD( GetColorDepth )( /* in */ PWINSTATIONNAMEW pWs, /* out */ BOOL * , /* out */ PDWORD );
  112. STDMETHOD( SetColorDepth )( /* in */ PWINSTATIONNAMEW pWs, /* in */ BOOL, /* out */ PDWORD );
  113. STDMETHOD( GetKeepAliveTimeout )( /* in */ PWINSTATIONNAMEW pWs, /* out */ BOOL * , /* out */ PDWORD );
  114. STDMETHOD( SetKeepAliveTimeout )( /* in */ PWINSTATIONNAMEW pWs, /* in */ BOOL, /* out */ PDWORD );
  115. STDMETHOD( GetProfilePath )( /* out */ BSTR * , /* out */ PDWORD );
  116. STDMETHOD( SetProfilePath )( /* in */ BSTR , /* out */ PDWORD );
  117. STDMETHOD( GetHomeDir )( /* out */ BSTR * , /* out */ PDWORD );
  118. STDMETHOD( SetHomeDir )( /* in */ BSTR , /* out */ PDWORD );
  119. //ISettingComp Methods
  120. // STDMETHOD( GetCachedSessions )(DWORD * );
  121. STDMETHOD( SetActiveDesktopState )( /* in */ BOOL , /* out */ PDWORD );
  122. STDMETHOD( GetActiveDesktopState )( /* out */ PBOOL , /* out */ PDWORD );
  123. STDMETHOD( GetTermSrvMode )( /* out */ PDWORD , /* out */ PDWORD );
  124. STDMETHOD( GetWdKey )( /* in */ WCHAR * , /* out , string */ WCHAR * );
  125. STDMETHOD( GetUserPerm )( /* out */ BOOL * , /* out */ DWORD * );
  126. STDMETHOD( SetUserPerm )( /* in */ BOOL , /* out */ PDWORD );
  127. STDMETHOD( GetSalemHelpMode )( /* out */ BOOL *, /* out */ PDWORD );
  128. STDMETHOD( SetSalemHelpMode )( /* in */ BOOL, /* out */ PDWORD );
  129. STDMETHOD( GetDenyTSConnections )( /* out */ BOOL * , /* out */ PDWORD );
  130. STDMETHOD( SetDenyTSConnections )( /* in */ BOOL, /* out */ PDWORD );
  131. STDMETHOD( GetSingleSessionState )( /* out */ BOOL * , /* out */ PDWORD );
  132. STDMETHOD( SetSingleSessionState )( /* in */ BOOL, /* out */ PDWORD );
  133. //IUserSecurity Methods
  134. STDMETHOD( ModifyUserAccess )( /* in */ WCHAR *pwszWinstaName ,
  135. /* in */ WCHAR *pwszAccountName ,
  136. /* in */ DWORD dwMask ,
  137. /* in */ BOOL fDel ,
  138. /* in */ BOOL fAllow ,
  139. /* in */ BOOL fNew ,
  140. /* in */ BOOL fAuditing ,
  141. /* out*/ PDWORD pdwStatus );
  142. STDMETHOD( ModifyDefaultSecurity )( /* in */ WCHAR *pwszWinstaName ,
  143. /* in */ WCHAR *pwszAccountName ,
  144. /* in */ DWORD dwMask ,
  145. /* in */ BOOL fDel ,
  146. /* in */ BOOL fAllow ,
  147. /* in */ BOOL fAuditing ,
  148. /* out*/ PDWORD pdwStatus );
  149. STDMETHOD( GetUserPermList )( /* in */ WCHAR *pwszWinstaName ,
  150. /* out*/ PDWORD pcbItems ,
  151. /* out*/ PUSERPERMLIST *ppUserPermList,
  152. /* in */ BOOL fAudit );
  153. private:
  154. // PSECURITY_DESCRIPTOR ReadSecurityDescriptor(ULONG index);
  155. // HRESULT SetDefaultSecurityDescriptor(PSECURITY_DESCRIPTOR pSecurity);
  156. DWORD
  157. RemoveUserEntriesInACL(
  158. LPCTSTR pszUserName,
  159. PACL pAcl,
  160. PACL* ppNewAcl
  161. );
  162. DWORD
  163. GetUserSid(
  164. LPCTSTR pszUserName,
  165. PSID* ppUserSid
  166. );
  167. HRESULT
  168. SetSecurityDescriptor(
  169. BOOL bDefaultSecurity,
  170. PWINSTATIONNAMEW pWsName,
  171. DWORD Size,
  172. PSECURITY_DESCRIPTOR pSecurityDescriptor
  173. );
  174. BOOL
  175. ValidDefaultSecurity(
  176. const WCHAR* pwszName
  177. );
  178. HRESULT
  179. ModifyWinstationSecurity(
  180. BOOL bDefaultSecurity,
  181. WCHAR *pwszWinstaName ,
  182. WCHAR *pwszAccountName ,
  183. DWORD dwMask ,
  184. BOOL fDel ,
  185. BOOL fAllow ,
  186. BOOL fNew ,
  187. BOOL fAuditing ,
  188. PDWORD pdwStatus
  189. );
  190. void DeleteWDArray();
  191. STDMETHODIMP FillWdArray();
  192. STDMETHODIMP FillWsArray();
  193. STDMETHODIMP InsertInWSArray( PWINSTATIONNAMEW pWSName,PWINSTATIONCONFIG2W pWSConfig,
  194. PWS * ppObject );
  195. void DeleteWSArray();
  196. PWD GetWdObject(PWDNAMEW pWdName);
  197. PWS GetWSObject(WINSTATIONNAMEW WSName);
  198. STDMETHOD(UnInitialize)();
  199. BOOL GetResourceStrings( int * , int , WCHAR * );
  200. HRESULT GetWinStationSecurity(BOOL bDefault, PWINSTATIONNAMEW pWSName,PSECURITY_DESCRIPTOR *ppSecurityDescriptor);
  201. //Function borrowed from security.c in tscfg project
  202. DWORD ValidateSecurityDescriptor(PSECURITY_DESCRIPTOR pSecurityDescriptor);
  203. // BOOL CompareSD(PSECURITY_DESCRIPTOR pSd1,PSECURITY_DESCRIPTOR pSd2);
  204. BOOL RegServerAccessCheck(REGSAM samDesired);
  205. void GetPdConfig( WDNAME WdKey,WINSTATIONCONFIG2W& WsConfig);
  206. void VerifyGuidsExistence( PGUIDTBL * , int , WCHAR *);
  207. HRESULT AdjustLanaId( PGUIDTBL * , int , int , PDWORD , PDWORD , int* , int );
  208. CPtrArray m_WDArray;
  209. BOOL m_bInitialized;
  210. BOOL m_bAdmin;
  211. CPtrArray m_WSArray;
  212. TCHAR m_szConsole[WINSTATIONNAME_LENGTH + 1];
  213. };
  214. #endif //__CFGCOMP_H_