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.

915 lines
32 KiB

  1. // This is a part of the Microsoft Management Console.
  2. // Copyright (C) 1995-2001 Microsoft Corporation
  3. // All rights reserved.
  4. //
  5. // This source code is only intended as a supplement to the
  6. // Microsoft Management Console and related
  7. // electronic documentation provided with the interfaces.
  8. #ifndef WSECMGR_SNAPMGR_H
  9. #define WSECMGR_SNAPMGR_H
  10. #include "resource.h" // main symbols
  11. #include "attr.h"
  12. #ifdef INITGUID
  13. #undef INITGUID
  14. #endif
  15. #include <gpedit.h>
  16. #include "uithread.h"
  17. #include "hidwnd.h"
  18. #include "wmihooks.h"
  19. #define MAX_CONTEXT_MENU_STRLEN 128
  20. struct MENUDATARES
  21. {
  22. WCHAR szBuffer[MAX_CONTEXT_MENU_STRLEN*2];
  23. UINT uResID;
  24. };
  25. struct MENUMAP
  26. {
  27. MENUDATARES* dataRes;
  28. CONTEXTMENUITEM* ctxMenu;
  29. };
  30. #define DECLARE_MENU(theClass) \
  31. class theClass \
  32. { \
  33. public: \
  34. static LPCONTEXTMENUITEM GetContextMenuItem() { return GetMenuMap()->ctxMenu; }; \
  35. static MENUMAP* GetMenuMap(); \
  36. };
  37. #define BEGIN_MENU(theClass) \
  38. MENUMAP* theClass::GetMenuMap() {
  39. #define BEGIN_CTX static CONTEXTMENUITEM ctx[] = {
  40. #define CTX_ENTRY(cmdID, fFlags, fInsert) { L"",L"", cmdID, CCM_INSERTIONPOINTID_PRIMARY_TOP /*| fInsert*/, fFlags, 0 },
  41. #define END_CTX { NULL, NULL, 0, 0, 0, 0} };
  42. #define BEGIN_RES static MENUDATARES dataRes[] = {
  43. #define RES_ENTRY(resID) {L"", resID},
  44. #define END_RES { NULL, 0 } };
  45. #define END_MENU \
  46. static MENUMAP menuMap = { dataRes, ctx }; \
  47. return &menuMap; }
  48. enum
  49. {
  50. // Identifiers for each of the commands to be inserted into the context menu.
  51. IDM_ABOUT,
  52. IDM_ADD_ENTRY,
  53. IDM_ADD_FILES,
  54. IDM_ADD_GROUPS,
  55. IDM_ADD_REGISTRY,
  56. IDM_ADD_LOC,
  57. IDM_ANALYZE,
  58. IDM_APPLY,
  59. IDM_CUT,
  60. IDM_COPY,
  61. IDM_DELETE,
  62. IDM_GENERATE,
  63. IDM_NEW,
  64. IDM_PASTE,
  65. IDM_REAPPLY,
  66. IDM_REFRESH,
  67. IDM_RELOAD,
  68. IDM_REMOVE,
  69. IDM_REVERT,
  70. IDM_SAVE,
  71. IDM_SAVEAS,
  72. IDM_SUMMARY,
  73. IDM_ADD_FOLDER,
  74. IDM_ADD_ANAL_FILES,
  75. IDM_ADD_ANAL_FOLDER,
  76. IDM_ADD_ANAL_KEY,
  77. IDM_ASSIGN,
  78. IDM_SET_DB,
  79. IDM_NEW_DATABASE,
  80. IDM_OPEN_SYSTEM_DB,
  81. IDM_OPEN_PRIVATE_DB,
  82. IDM_OBJECT_SECURITY,
  83. IDM_DESCRIBE_LOCATION,
  84. IDM_DESCRIBE_PROFILE,
  85. IDM_IMPORT_POLICY,
  86. IDM_IMPORT_LOCAL_POLICY,
  87. IDM_EXPORT_POLICY,
  88. IDM_EXPORT_LOCALPOLICY,
  89. IDM_EXPORT_EFFECTIVE,
  90. IDM_VIEW_LOGFILE,
  91. IDM_SECURE_WIZARD,
  92. IDM_WHAT_ISTHIS
  93. };
  94. static HINSTANCE g_hDsSecDll = NULL;
  95. DECLARE_MENU(CSecmgrNodeMenuHolder)
  96. DECLARE_MENU(CAnalyzeNodeMenuHolder)
  97. DECLARE_MENU(CConfigNodeMenuHolder)
  98. DECLARE_MENU(CLocationNodeMenuHolder)
  99. DECLARE_MENU(CRSOPProfileNodeMenuHolder)
  100. DECLARE_MENU(CSSProfileNodeMenuHolder)
  101. DECLARE_MENU(CLocalPolNodeMenuHolder)
  102. DECLARE_MENU(CProfileNodeMenuHolder)
  103. DECLARE_MENU(CProfileAreaMenuHolder)
  104. DECLARE_MENU(CProfileSubAreaMenuHolder)
  105. DECLARE_MENU(CProfileSubAreaEventLogMenuHolder)
  106. DECLARE_MENU(CAnalyzeAreaMenuHolder)
  107. DECLARE_MENU(CAnalyzeGroupsMenuHolder)
  108. DECLARE_MENU(CAnalyzeRegistryMenuHolder)
  109. DECLARE_MENU(CAnalyzeFilesMenuHolder)
  110. DECLARE_MENU(CProfileGroupsMenuHolder)
  111. DECLARE_MENU(CProfileRegistryMenuHolder)
  112. DECLARE_MENU(CProfileFilesMenuHolder)
  113. DECLARE_MENU(CAnalyzeObjectsMenuHolder)
  114. BOOL LoadContextMenuResources(MENUMAP* pMenuMap);
  115. #define UAV_RESULTITEM_ADD 0x0001
  116. #define UAV_RESULTITEM_REMOVE 0x0002
  117. #define UAV_RESULTITEM_UPDATE 0x0004
  118. #define UAV_RESULTITEM_UPDATEALL 0x0008
  119. #define UAV_RESULTITEM_REDRAWALL 0x0010
  120. class CFolder;
  121. typedef struct _tag_SCE_COLUMNINFO {
  122. int colID; // The column id.
  123. int nCols; // Number of columns
  124. int nWidth; // The width of the column
  125. } SCE_COLUMNINFO, *PSCE_COLUMNINFO;
  126. typedef struct _tag_SCE_COLINFOARRAY {
  127. int iIndex;
  128. int nCols;
  129. int nWidth[1];
  130. } SCE_COLINFOARRAY, *PSCE_COLINFOARRAY;
  131. /////////////////////////////////////////////////////////////////////////////
  132. // Snapin
  133. INTERNAL* ExtractInternalFormat(LPDATAOBJECT lpDataObject);
  134. class CComponentDataImpl:
  135. public IComponentData,
  136. public IExtendPropertySheet,
  137. public IExtendContextMenu,
  138. public IPersistStream,
  139. public ISceSvcAttachmentData,
  140. public ISnapinHelp2,
  141. public CComObjectRoot
  142. {
  143. BEGIN_COM_MAP(CComponentDataImpl)
  144. COM_INTERFACE_ENTRY(IComponentData)
  145. COM_INTERFACE_ENTRY(IExtendPropertySheet)
  146. COM_INTERFACE_ENTRY(IExtendContextMenu)
  147. COM_INTERFACE_ENTRY(IPersistStream)
  148. COM_INTERFACE_ENTRY(ISceSvcAttachmentData)
  149. COM_INTERFACE_ENTRY(ISnapinHelp2)
  150. END_COM_MAP()
  151. friend class CSnapin;
  152. friend class CDataObject;
  153. CComponentDataImpl();
  154. virtual ~CComponentDataImpl();
  155. public:
  156. static DWORD m_GroupMode;
  157. virtual const CLSID& GetCoClassID() = 0; // for both primary and extension implementation
  158. virtual const int GetImplType() = 0; // for both primary and extension implementation
  159. // IComponentData interface members
  160. STDMETHOD(Initialize)(LPUNKNOWN pUnknown);
  161. STDMETHOD(CreateComponent)(LPCOMPONENT* ppComponent);
  162. STDMETHOD(Notify)(LPDATAOBJECT lpDataObject, MMC_NOTIFY_TYPE event, LPARAM arg, LPARAM param);
  163. STDMETHOD(Destroy)();
  164. STDMETHOD(QueryDataObject)(MMC_COOKIE cookie, DATA_OBJECT_TYPES type, LPDATAOBJECT* ppDataObject);
  165. STDMETHOD(GetDisplayInfo)(SCOPEDATAITEM* pScopeDataItem);
  166. STDMETHOD(CompareObjects)(LPDATAOBJECT lpDataObjectA, LPDATAOBJECT lpDataObjectB);
  167. // IExtendPropertySheet interface
  168. public:
  169. STDMETHOD(CreatePropertyPages)(LPPROPERTYSHEETCALLBACK lpProvider,
  170. LONG_PTR handle,
  171. LPDATAOBJECT lpIDataObject);
  172. STDMETHOD(QueryPagesFor)(LPDATAOBJECT lpDataObject);
  173. // IExtendContextMenu
  174. public:
  175. STDMETHOD(AddMenuItems)(LPDATAOBJECT pDataObject, LPCONTEXTMENUCALLBACK pCallbackUnknown, LONG* pInsertionAllowed);
  176. STDMETHOD(Command)(long nCommandID, LPDATAOBJECT pDataObject);
  177. public:
  178. // IPersistStream interface members
  179. STDMETHOD(GetClassID)(CLSID *pClassID);
  180. STDMETHOD(IsDirty)();
  181. STDMETHOD(Load)(IStream *pStm);
  182. STDMETHOD(Save)(IStream *pStm, BOOL fClearDirty);
  183. STDMETHOD(GetSizeMax)(ULARGE_INTEGER *pcbSize);
  184. // ISceSvcAttachmentData
  185. STDMETHOD(GetData)(SCESVC_HANDLE sceHandle,
  186. SCESVC_INFO_TYPE sceType,
  187. PVOID *ppvData,
  188. PSCE_ENUMERATION_CONTEXT psceEnumHandle);
  189. STDMETHOD(Initialize)(LPCTSTR ServiceName,
  190. LPCTSTR TemplateName,
  191. LPSCESVCATTACHMENTPERSISTINFO lpSceSvcPersistInfo,
  192. SCESVC_HANDLE *sceHandle);
  193. STDMETHOD(FreeBuffer)(PVOID pvData);
  194. STDMETHOD(CloseHandle)(SCESVC_HANDLE sceHandle);
  195. // ISnapinHelp2 helper function
  196. STDMETHOD(GetHelpTopic)(LPOLESTR *lpCompiledHelpFile)=0;
  197. STDMETHOD(GetHelpTopic)(LPOLESTR *pszHelpFile,LPCTSTR szFile);
  198. STDMETHOD(GetLinkedTopics)(LPOLESTR* lpCompiledHelpFiles);
  199. // Notify handler declarations
  200. private:
  201. HRESULT OnAdd(LPDATAOBJECT lpDataObject, LPARAM arg, LPARAM param);
  202. HRESULT OnDelete(LPDATAOBJECT lpDataObject, LPARAM arg, LPARAM param);
  203. HRESULT OnRename(LPDATAOBJECT lpDataObject, LPARAM arg, LPARAM param);
  204. HRESULT OnExpand(LPDATAOBJECT lpDataObject, LPARAM arg, LPARAM param);
  205. HRESULT OnSelect(LPDATAOBJECT lpDataObject, LPARAM arg, LPARAM param);
  206. HRESULT OnContextMenu(LPDATAOBJECT lpDataObject, LPARAM arg, LPARAM param);
  207. HRESULT OnProperties(LPARAM param);
  208. HRESULT OnCopyArea(LPCTSTR szTemplate,FOLDER_TYPES ft);
  209. HRESULT OnPasteArea(LPCTSTR szTemplate,FOLDER_TYPES ft);
  210. HRESULT OnOpenDataBase();
  211. HRESULT OnNewDatabase();
  212. HRESULT OnAssignConfiguration( SCESTATUS *pSceStatus);
  213. HRESULT OnSecureWizard();
  214. HRESULT OnSaveConfiguration();
  215. HRESULT OnImportPolicy(LPDATAOBJECT);
  216. HRESULT OnImportLocalPolicy(LPDATAOBJECT);
  217. HRESULT OnExportPolicy(BOOL bEffective);
  218. HRESULT OnAnalyze();
  219. BOOL GetFolderCopyPasteInfo(FOLDER_TYPES Folder,AREA_INFORMATION *Area, UINT *cf);
  220. #if DBG==1
  221. public:
  222. ULONG InternalAddRef()
  223. {
  224. return CComObjectRoot::InternalAddRef();
  225. }
  226. ULONG InternalRelease()
  227. {
  228. return CComObjectRoot::InternalRelease();
  229. }
  230. #endif // DBG==1
  231. // Scope item creation helpers
  232. private:
  233. CFolder* FindObject(MMC_COOKIE cookie, POSITION* thePos );
  234. HRESULT CreateFolderList(CFolder* pFolder, FOLDER_TYPES type, POSITION *pPos, INT *Count);
  235. INT CComponentDataImpl::AddLocationsToFolderList(HKEY hkey, DWORD dwMode, BOOL bCheckForDupes, POSITION *pPos);
  236. BOOL AddTemplateLocation(CFolder *pParent, CString szName, BOOL bIsFileName, BOOL bRefresh);
  237. BOOL IsNameInChildrenScopes(CFolder* pParent, LPCTSTR NameStr, MMC_COOKIE *theCookie);
  238. CFolder* CreateAndAddOneNode(CFolder* pParent, LPCTSTR Name, LPCTSTR Desc,
  239. FOLDER_TYPES type, BOOL bChildren, LPCTSTR szInfFile = NULL,
  240. PVOID pData = NULL,DWORD status = 0);
  241. void DeleteChildrenUnderNode(CFolder* pParent);
  242. void DeleteThisNode(CFolder* pNode);
  243. HRESULT DeleteOneTemplateNodes(MMC_COOKIE cookie);
  244. void DeleteList();
  245. void EnumerateScopePane(MMC_COOKIE cookie, HSCOPEITEM pParent);
  246. BOOL IsScopePaneNode(LPDATAOBJECT lpDataObject);
  247. DWORD GetModeBits()
  248. {
  249. switch (m_Mode)
  250. {
  251. case SCE_MODE_DOMAIN_COMPUTER:
  252. case SCE_MODE_OU_COMPUTER:
  253. case SCE_MODE_LOCAL_COMPUTER:
  254. case SCE_MODE_REMOTE_COMPUTER:
  255. return m_computerModeBits;
  256. break;
  257. case SCE_MODE_REMOTE_USER:
  258. case SCE_MODE_LOCAL_USER:
  259. case SCE_MODE_DOMAIN_USER:
  260. case SCE_MODE_OU_USER:
  261. return m_userModeBits;
  262. break;
  263. default:
  264. return m_computerModeBits;
  265. break;
  266. }
  267. };
  268. public:
  269. PEDITTEMPLATE GetTemplate(LPCTSTR szInfFile,AREA_INFORMATION aiAirea = AREA_ALL, DWORD *idErr = NULL);
  270. BOOL RemovePolicyEntries(PEDITTEMPLATE pet);
  271. HRESULT ReloadLocation(CFolder *pFolder);
  272. void DeleteTemplate(CString infFile);
  273. static BOOL LoadResources();
  274. void LoadSadInfo(BOOL bRequireAnalysis);
  275. void UnloadSadInfo();
  276. void RefreshSadInfo(BOOL fRemoveAnalDlg = TRUE);
  277. BOOL GetSadLoaded() { return SadLoaded; };
  278. PVOID GetSadHandle() { return SadHandle; };
  279. BOOL GetSadTransStarted() { return SadTransStarted; };
  280. void SetSadTransStarted(BOOL bTrans) { SadTransStarted = bTrans; };
  281. BOOL EngineTransactionStarted();
  282. BOOL EngineCommitTransaction();
  283. BOOL EngineRollbackTransaction();
  284. HRESULT AddDsObjectsToList(LPDATAOBJECT lpDataObject, MMC_COOKIE cookie, FOLDER_TYPES folderType, LPTSTR InfFile);
  285. HRESULT AddAnalysisFilesToList(LPDATAOBJECT lpDataObject, MMC_COOKIE cookie, FOLDER_TYPES folderType);
  286. HRESULT AddAnalysisFolderToList(LPDATAOBJECT lpDataObject, MMC_COOKIE cookie, FOLDER_TYPES folderType);
  287. HRESULT UpdateScopeResultObject(LPDATAOBJECT pDataObj,MMC_COOKIE cookie, AREA_INFORMATION area);
  288. void AddPopupDialog(LONG_PTR nID, CDialog *pDlg);
  289. CDialog *GetPopupDialog(LONG_PTR nID);
  290. void RemovePopupDialog(LONG_PTR nID);
  291. CDialog *
  292. MatchNextPopupDialog(
  293. POSITION &pos,
  294. LONG_PTR priKey,
  295. LONG_PTR *thisPos
  296. );
  297. PSCE_COLINFOARRAY GetColumnInfo( FOLDER_TYPES pType );
  298. void SetColumnInfo( FOLDER_TYPES pType, PSCE_COLINFOARRAY pInfo);
  299. DWORD SerializeColumnInfo(IStream *pStm, ULONG *pTotalWrite, BOOL bRead);
  300. void CloseAnalysisPane();
  301. BOOL LockAnalysisPane(BOOL bLock, BOOL fRemoveAnalDlg = TRUE);
  302. HWND GetParentWindow() { return m_hwndParent; }
  303. LPNOTIFY GetNotifier() { return m_pNotifier; }
  304. DWORD UpdateObjectStatus( CFolder *pParent, BOOL bUpdateThis = FALSE );
  305. int
  306. RefreshAllFolders();
  307. public:
  308. //
  309. // Information functions.
  310. //
  311. CFolder *GetAnalFolder()
  312. { return m_AnalFolder; };
  313. LPCONSOLENAMESPACE GetNameSpace()
  314. { return m_pScope; };
  315. DWORD GetComponentMode()
  316. { return m_Mode; };
  317. LPCONSOLE GetConsole()
  318. { return m_pConsole; };
  319. CWMIRsop * GetWMIRsop() {
  320. if (!m_pWMIRsop) {
  321. m_pWMIRsop = new CWMIRsop(m_pRSOPInfo);
  322. }
  323. return m_pWMIRsop;
  324. }
  325. void
  326. SetErroredLogFile( LPCTSTR pszFileName, LONG dwPosLow = 0);
  327. LPCTSTR GetErroredLogFile( LONG *dwPosLow = NULL)
  328. { if(dwPosLow) *dwPosLow = m_ErroredLogPos; return m_pszErroredLogFile; };
  329. void SetFlags( DWORD dwFlags, DWORD dwMask = -1)
  330. { m_dwFlags = dwFlags | (dwMask & m_dwFlags); };
  331. public:
  332. //
  333. // UI add function helpers
  334. //
  335. HRESULT
  336. GetAddObjectSecurity( // Gets valid object security settings
  337. HWND hwndParent,
  338. LPCTSTR strFile,
  339. BOOL bContainer,
  340. SE_OBJECT_TYPE SeType,
  341. PSECURITY_DESCRIPTOR &pSelSD,
  342. SECURITY_INFORMATION &SelSeInfo,
  343. BYTE &ConfigStatus
  344. );
  345. BOOL GetWorkingDir(
  346. GWD_TYPES uIDDir,
  347. LPTSTR *pStr,
  348. BOOL bSet = FALSE,
  349. BOOL bFile = FALSE
  350. );
  351. public:
  352. DWORD GetGroupMode();
  353. enum {
  354. flag_showLogFile = 0x00000001
  355. };
  356. LPRSOPINFORMATION m_pRSOPInfo;
  357. private:
  358. bool m_bEnumerateScopePaneCalled;
  359. LPCONSOLENAMESPACE m_pScope; // My interface pointer to the scope pane
  360. LPCONSOLE m_pConsole;
  361. BOOL m_bIsDirty;
  362. BOOL m_bIsLocked;
  363. CString SadName;
  364. CString SadDescription;
  365. CString SadAnalyzeStamp;
  366. CString SadConfigStamp;
  367. BOOL SadLoaded;
  368. SCESTATUS SadErrored;
  369. PVOID SadHandle;
  370. BOOL SadTransStarted;
  371. DWORD m_nNewTemplateIndex;
  372. DWORD m_Mode; // The Mode we are in
  373. DWORD m_computerModeBits; // Bits describing functionality changes in this mode
  374. DWORD m_userModeBits; // Bits describing functionality changes in this mode
  375. // The name of the template file for MB_SINGLE_TEMPLATE_ONLY modes
  376. LPTSTR m_szSingleTemplateName;
  377. BOOL m_bDeleteSingleTemplate; // True if we need to delete the template on exit
  378. void SetDirty(BOOL b = TRUE) { m_bIsDirty = b; }
  379. void ClearDirty() { m_bIsDirty = FALSE; }
  380. BOOL ThisIsDirty() { return m_bIsDirty; }
  381. void AddScopeItemToResultPane(MMC_COOKIE cookie);
  382. HRESULT AddAttrPropPages(LPPROPERTYSHEETCALLBACK lpProvider,CFolder *pFolder,LONG_PTR handle);
  383. BOOL m_bComputerTemplateDirty;
  384. CMap<CString, LPCTSTR, PEDITTEMPLATE, PEDITTEMPLATE&> m_Templates;
  385. BOOL m_fSvcNotReady;
  386. HWND m_hwndParent;
  387. CHiddenWnd *m_pNotifier;
  388. CFolder * m_AnalFolder;
  389. CFolder * m_ConfigFolder;
  390. CList<CFolder*, CFolder*> m_scopeItemList;
  391. CMap<LONG_PTR, LONG_PTR, CDialog *, CDialog *&> m_scopeItemPopups;
  392. LPGPEINFORMATION m_pGPTInfo;
  393. CWinThread *m_pUIThread; // The thread that creates dialog boxes for this component data item
  394. CString m_strDisplay; // The static display string used for GetDisplayInfo
  395. CString m_strTempFile; // The temporary file name to delete for HTML error pages
  396. LPTSTR m_pszErroredLogFile; // Error log.
  397. LONG m_ErroredLogPos; // The last write position of the error log file.
  398. DWORD m_dwFlags;
  399. CMap<FOLDER_TYPES, FOLDER_TYPES, PSCE_COLINFOARRAY, PSCE_COLINFOARRAY&> m_mapColumns;
  400. CMap<UINT, UINT, LPTSTR, LPTSTR&> m_aDirs;
  401. CWMIRsop *m_pWMIRsop;
  402. CRITICAL_SECTION csAnalysisPane;
  403. };
  404. //
  405. // define classes for differnt class IDs
  406. //
  407. #define SCE_IMPL_TYPE_EXTENSION 1
  408. #define SCE_IMPL_TYPE_SCE 2
  409. #define SCE_IMPL_TYPE_SAV 3
  410. #define SCE_IMPL_TYPE_LS 4
  411. #define SCE_IMPL_TYPE_RSOP 4
  412. // extension snapin implementation
  413. class CComponentDataExtensionImpl : public CComponentDataImpl,
  414. // public ISnapinHelp,
  415. public CComCoClass<CComponentDataExtensionImpl, &CLSID_Snapin>
  416. {
  417. //BEGIN_COM_MAP(CComponentDataExtensionImpl)
  418. // COM_INTERFACE_ENTRY(ISnapinHelp)
  419. //END_COM_MAP()
  420. public:
  421. DECLARE_REGISTRY(CSnapin, _T("Wsecedit.Extension.1"), _T("Wsecedit.Extension"), IDS_EXTENSION_DESC, THREADFLAGS_BOTH)
  422. virtual const CLSID & GetCoClassID() { return CLSID_Snapin; }
  423. virtual const int GetImplType() { return SCE_IMPL_TYPE_EXTENSION; }
  424. // ISnapinHelp2
  425. STDMETHOD(GetHelpTopic)(LPOLESTR *pszHelpFile);
  426. };
  427. // RSOP extension snapin implementation
  428. class CComponentDataRSOPImpl : public CComponentDataImpl,
  429. public CComCoClass<CComponentDataRSOPImpl, &CLSID_RSOPSnapin>
  430. {
  431. //BEGIN_COM_MAP(CComponentDataRSOPImpl)
  432. // COM_INTERFACE_ENTRY(ISnapinHelp)
  433. //END_COM_MAP()
  434. public:
  435. DECLARE_REGISTRY(CSnapin, _T("Wsecedit.RSOP.1"), _T("Wsecedit.RSOP"), IDS_RSOP_DESC, THREADFLAGS_BOTH)
  436. virtual const CLSID & GetCoClassID() { return CLSID_RSOPSnapin; }
  437. virtual const int GetImplType() { return SCE_IMPL_TYPE_RSOP; }
  438. // ISnapinHelp2
  439. STDMETHOD(GetHelpTopic)(LPOLESTR *pszHelpFile);
  440. };
  441. // SCE standalone snapin implementation
  442. class CComponentDataSCEImpl : public CComponentDataImpl,
  443. public CComCoClass<CComponentDataSCEImpl, &CLSID_SCESnapin>
  444. {
  445. //BEGIN_COM_MAP(CComponentDataSCEImpl)
  446. // COM_INTERFACE_ENTRY(ISnapinHelp)
  447. //END_COM_MAP()
  448. public:
  449. DECLARE_REGISTRY(CSnapin, _T("Wsecedit.SCE.1"), _T("Wsecedit.SCE"), IDS_SCE_DESC, THREADFLAGS_BOTH)
  450. virtual const CLSID & GetCoClassID() { return CLSID_SCESnapin; }
  451. virtual const int GetImplType() { return SCE_IMPL_TYPE_SCE; }
  452. // ISnapinHelp2
  453. STDMETHOD(GetHelpTopic)(LPOLESTR *pszHelpFile);
  454. };
  455. // SAV standalone snapin implementation
  456. class CComponentDataSAVImpl : public CComponentDataImpl,
  457. public CComCoClass<CComponentDataSAVImpl, &CLSID_SAVSnapin>
  458. {
  459. //BEGIN_COM_MAP(CComponentDataSAVImpl)
  460. // COM_INTERFACE_ENTRY(ISnapinHelp)
  461. //END_COM_MAP()
  462. public:
  463. DECLARE_REGISTRY(CSnapin, _T("Wsecedit.SAV.1"), _T("Wsecedit.SAV"), IDS_SAV_DESC, THREADFLAGS_BOTH)
  464. virtual const CLSID & GetCoClassID() { return CLSID_SAVSnapin; }
  465. virtual const int GetImplType() { return SCE_IMPL_TYPE_SAV; }
  466. // ISnapinHelp2
  467. STDMETHOD(GetHelpTopic)(LPOLESTR *pszHelpFile);
  468. };
  469. // LS standalone snapin implementation
  470. class CComponentDataLSImpl : public CComponentDataImpl,
  471. public CComCoClass<CComponentDataLSImpl, &CLSID_LSSnapin>
  472. {
  473. //BEGIN_COM_MAP(CComponentDataLSImpl)
  474. // COM_INTERFACE_ENTRY(ISnapinHelp)
  475. //END_COM_MAP()
  476. public:
  477. DECLARE_REGISTRY(CSnapin, _T("Wsecedit.LS.1"), _T("Wsecedit.LS"), IDS_LS_DESC, THREADFLAGS_BOTH)
  478. virtual const CLSID & GetCoClassID() { return CLSID_LSSnapin; }
  479. virtual const int GetImplType() { return SCE_IMPL_TYPE_LS; }
  480. // ISnapinHelp2
  481. STDMETHOD(GetHelpTopic)(LPOLESTR *pszHelpFile);
  482. };
  483. class CSnapin :
  484. public IComponent,
  485. public IExtendContextMenu, // Step 3
  486. public IExtendPropertySheet,
  487. public IExtendControlbar,
  488. public IResultDataCompare,
  489. public CComObjectRoot
  490. {
  491. public:
  492. CSnapin();
  493. virtual ~CSnapin();
  494. BEGIN_COM_MAP(CSnapin)
  495. COM_INTERFACE_ENTRY(IComponent)
  496. COM_INTERFACE_ENTRY(IExtendContextMenu)
  497. COM_INTERFACE_ENTRY(IExtendPropertySheet)
  498. COM_INTERFACE_ENTRY(IExtendControlbar)
  499. COM_INTERFACE_ENTRY(IResultDataCompare)
  500. END_COM_MAP()
  501. friend class CDataObject;
  502. friend class CComponentDataImpl;
  503. static long lDataObjectRefCount;
  504. // IComponent interface members
  505. public:
  506. STDMETHOD(Initialize)(LPCONSOLE lpConsole);
  507. STDMETHOD(Notify)(LPDATAOBJECT lpDataObject, MMC_NOTIFY_TYPE event, LPARAM arg, LPARAM param);
  508. STDMETHOD(Destroy)(MMC_COOKIE cookie);
  509. STDMETHOD(GetResultViewType)(MMC_COOKIE cookie, LPOLESTR* ppViewType, LONG* pViewOptions);
  510. STDMETHOD(QueryDataObject)(MMC_COOKIE cookie, DATA_OBJECT_TYPES type,
  511. LPDATAOBJECT* ppDataObject);
  512. STDMETHOD(GetDisplayInfo)(RESULTDATAITEM* pResultDataItem);
  513. STDMETHOD(CompareObjects)(LPDATAOBJECT lpDataObjectA, LPDATAOBJECT lpDataObjectB);
  514. // IResultDataCompare
  515. STDMETHOD(Compare)(LPARAM lUserParam, MMC_COOKIE cookieA, MMC_COOKIE cookieB, int* pnResult);
  516. // IExtendControlbar
  517. STDMETHOD(SetControlbar)(LPCONTROLBAR pControlbar);
  518. STDMETHOD(ControlbarNotify)(MMC_NOTIFY_TYPE event, MMC_COOKIE arg, MMC_COOKIE param);
  519. // Helpers for CSnapin
  520. public:
  521. void SetIComponentData(CComponentDataImpl* pData);
  522. int GetImplType()
  523. {
  524. CComponentDataImpl *pData =
  525. dynamic_cast<CComponentDataImpl*>(m_pComponentData);
  526. ASSERT(pData != NULL);
  527. if (pData != NULL)
  528. return pData->GetImplType();
  529. return 0;
  530. }
  531. #if DBG==1
  532. public:
  533. int dbg_cRef;
  534. ULONG InternalAddRef()
  535. {
  536. ++dbg_cRef;
  537. return CComObjectRoot::InternalAddRef();
  538. }
  539. ULONG InternalRelease()
  540. {
  541. --dbg_cRef;
  542. return CComObjectRoot::InternalRelease();
  543. }
  544. #endif // DBG==1
  545. // Notify event handlers
  546. protected:
  547. HRESULT OnFolder(MMC_COOKIE cookie, LPARAM arg, LPARAM param);
  548. HRESULT OnShow(LPDATAOBJECT pDataObj, MMC_COOKIE cookie, LPARAM arg, LPARAM param);
  549. HRESULT OnActivate(MMC_COOKIE cookie, LPARAM arg, LPARAM param);
  550. HRESULT OnMinimize(MMC_COOKIE cookie, LPARAM arg, LPARAM param);
  551. HRESULT OnPropertyChange(LPDATAOBJECT lpDataObject); // Step 3
  552. HRESULT OnUpdateView(LPDATAOBJECT lpDataObject,LPARAM data, LPARAM hint);
  553. HRESULT OnDeleteObjects(LPDATAOBJECT lpDataObject,DATA_OBJECT_TYPES cctType, MMC_COOKIE cookie, LPARAM arg, LPARAM param);
  554. // IExtendContextMenu
  555. public:
  556. PEDITTEMPLATE GetTemplate(LPCTSTR szInfFile, AREA_INFORMATION aiArea = AREA_ALL,DWORD *idErr = NULL);
  557. PSCE_PROFILE_INFO GetBaseInfo(PSCE_PROFILE_INFO *pBaseInfo, DWORD dwArea, PSCE_ERROR_LOG_INFO *ErrBuf =NULL );
  558. STDMETHOD(AddMenuItems)(LPDATAOBJECT pDataObject, LPCONTEXTMENUCALLBACK pCallbackUnknown, LONG* pInsertionAllowed);
  559. STDMETHOD(Command)(long nCommandID, LPDATAOBJECT pDataObject);
  560. // IExtendPropertySheet interface
  561. public:
  562. STDMETHOD(CreatePropertyPages)(LPPROPERTYSHEETCALLBACK lpProvider,
  563. LONG_PTR handle,
  564. LPDATAOBJECT lpIDataObject);
  565. STDMETHOD(QueryPagesFor)(LPDATAOBJECT lpDataObject);
  566. // Helper functions
  567. protected:
  568. CResult* FindResult(MMC_COOKIE cookie, POSITION* thePos);
  569. void Construct();
  570. void LoadResources();
  571. HRESULT InitializeHeaders(MMC_COOKIE cookie);
  572. void EnumerateResultPane(MMC_COOKIE cookie, HSCOPEITEM pParent, LPDATAOBJECT pDataObj);
  573. void CreateProfileResultList(MMC_COOKIE cookie, FOLDER_TYPES type, PEDITTEMPLATE pSceInfo,LPDATAOBJECT pDataObj);
  574. void CreateAnalysisResultList(MMC_COOKIE cookie, FOLDER_TYPES type,
  575. PEDITTEMPLATE pSceInfo, PEDITTEMPLATE pBase,LPDATAOBJECT pDataObj);
  576. void CreateLocalPolicyResultList(MMC_COOKIE cookie, FOLDER_TYPES type,
  577. PEDITTEMPLATE pLocal, PEDITTEMPLATE pEffective,LPDATAOBJECT pDataObj);
  578. void CreateObjectResultList(MMC_COOKIE cookie, FOLDER_TYPES type, AREA_INFORMATION Area,
  579. PSCE_OBJECT_CHILDREN pObjList, PVOID pHandle,
  580. LPDATAOBJECT pDataObj );
  581. void CreateProfServiceResultList(MMC_COOKIE cookie, FOLDER_TYPES type, PEDITTEMPLATE pSceInfo,LPDATAOBJECT pDataObj);
  582. void CreateAnalysisServiceResultList(MMC_COOKIE cookie, FOLDER_TYPES type,
  583. PEDITTEMPLATE pSceInfo, PEDITTEMPLATE pBase,
  584. LPDATAOBJECT pDataObj );
  585. void DeleteServiceResultList(MMC_COOKIE);
  586. HRESULT EditThisService(CResult *pData, MMC_COOKIE cookie, RESULT_TYPES rsltType, HWND hwndParent);
  587. HRESULT GetDisplayInfoForServiceNode(RESULTDATAITEM *pResult, CFolder *pFolder, CResult *pData);
  588. void DeleteList(BOOL bDeleteResultItem);
  589. void CreateProfilePolicyResultList(MMC_COOKIE cookie, FOLDER_TYPES type, PEDITTEMPLATE pSceInfo,LPDATAOBJECT pDataObj);
  590. void CreateAnalysisPolicyResultList(MMC_COOKIE cookie, FOLDER_TYPES type,
  591. PEDITTEMPLATE pSceInfo, PEDITTEMPLATE pBase,LPDATAOBJECT pDataObj );
  592. void CreateProfileRegValueList(MMC_COOKIE cookie, PEDITTEMPLATE pSceInfo,LPDATAOBJECT pDataObj );
  593. void CreateAnalysisRegValueList(MMC_COOKIE cookie, PEDITTEMPLATE pSceInfo, PEDITTEMPLATE pBase,LPDATAOBJECT pDataObj,RESULT_TYPES type );
  594. HRESULT EditThisRegistryValue(CResult *pData, MMC_COOKIE cookie, RESULT_TYPES rsltType);
  595. HRESULT AddAttrPropPages(LPPROPERTYSHEETCALLBACK lpProvider,CResult *pResult,LONG_PTR handle);
  596. // Result pane helpers
  597. public:
  598. void SetupLinkServiceNodeToBase(BOOL bAdd, LONG_PTR theNode);
  599. void AddServiceNodeToProfile(PSCE_SERVICES pNode);
  600. int SetAnalysisInfo(ULONG_PTR dwItem, ULONG_PTR dwNew, CResult *pResult = NULL);
  601. int SetLocalPolInfo(ULONG_PTR dwItem, ULONG_PTR dwNew);
  602. void TransferAnalysisName(LONG_PTR dwItem);
  603. BOOL UpdateLocalPolRegValue( CResult * );
  604. LPTSTR GetAnalTimeStamp();
  605. CResult * AddResultItem(LPCTSTR Attrib, LONG_PTR setting, LONG_PTR base,
  606. RESULT_TYPES type, int status,MMC_COOKIE cookie,
  607. BOOL bVerify = FALSE, LPCTSTR unit = NULL, LONG_PTR nID = -1,
  608. PEDITTEMPLATE pBaseInfo = NULL,
  609. LPDATAOBJECT pDataObj = NULL,
  610. CResult *pResult = NULL
  611. );
  612. CResult * AddResultItem(UINT rID, LONG_PTR setting, LONG_PTR base,
  613. RESULT_TYPES type, int status, MMC_COOKIE cookie,
  614. BOOL bVerify = FALSE, PEDITTEMPLATE pBaseInfo = NULL,
  615. LPDATAOBJECT pDataObj = NULL);
  616. void AddResultItem(LPCTSTR szName,PSCE_GROUP_MEMBERSHIP grpTemplate,
  617. PSCE_GROUP_MEMBERSHIP grpInspect,MMC_COOKIE cookie,
  618. LPDATAOBJECT pDataObj);
  619. HRESULT InitializeBitmaps(MMC_COOKIE cookie);
  620. HWND GetParentWindow() { return m_hwndParent; }
  621. BOOL CheckEngineTransaction();
  622. // UI Helpers
  623. void HandleStandardVerbs(LPARAM arg, LPDATAOBJECT lpDataObject);
  624. void HandleExtToolbars(LPARAM arg, LPARAM param);
  625. public:
  626. LPCONSOLE
  627. GetConsole()
  628. { return m_pConsole; };
  629. DWORD
  630. UpdateAnalysisInfo( // Effects priviledge areas only.
  631. CResult *pResult,
  632. BOOL bDelete,
  633. PSCE_PRIVILEGE_ASSIGNMENT *pInfo,
  634. LPCTSTR pszName = NULL
  635. );
  636. DWORD
  637. UpdateLocalPolInfo( // Effects priviledge areas only.
  638. CResult *pResult,
  639. BOOL bDelete,
  640. PSCE_PRIVILEGE_ASSIGNMENT *pInfo,
  641. LPCTSTR pszName = NULL
  642. );
  643. DWORD
  644. GetResultItemIDs(
  645. CResult *pResult,
  646. HRESULTITEM *pIDArray,
  647. int nIDArray
  648. );
  649. LPRESULTDATA
  650. GetResultPane()
  651. { return m_pResult; };
  652. CFolder* GetSelectedFolder()
  653. {
  654. return m_pSelectedFolder;
  655. };
  656. DWORD GetModeBits()
  657. {
  658. switch (((CComponentDataImpl *)m_pComponentData)->m_Mode)
  659. {
  660. case SCE_MODE_DOMAIN_COMPUTER:
  661. case SCE_MODE_OU_COMPUTER:
  662. case SCE_MODE_LOCAL_COMPUTER:
  663. case SCE_MODE_REMOTE_COMPUTER:
  664. return ((CComponentDataImpl *)m_pComponentData)->m_computerModeBits;
  665. break;
  666. case SCE_MODE_REMOTE_USER:
  667. case SCE_MODE_LOCAL_USER:
  668. case SCE_MODE_DOMAIN_USER:
  669. case SCE_MODE_OU_USER:
  670. return ((CComponentDataImpl *)m_pComponentData)->m_userModeBits;
  671. break;
  672. default:
  673. return ((CComponentDataImpl *)m_pComponentData)->m_computerModeBits;
  674. break;
  675. }
  676. }
  677. CWMIRsop* GetWMIRsop()
  678. {
  679. return ((CComponentDataImpl *)m_pComponentData)->GetWMIRsop();
  680. }
  681. // Interface pointers
  682. protected:
  683. LPCONSOLE m_pConsole; // Console's IFrame interface
  684. LPHEADERCTRL m_pHeader; // Result pane's header control interface
  685. LPCOMPONENTDATA m_pComponentData;
  686. LPRESULTDATA m_pResult; // My interface pointer to the result pane
  687. LPIMAGELIST m_pImageResult; // My interface pointer to the result pane image list
  688. LPTOOLBAR m_pToolbar1; // Toolbar for view
  689. LPTOOLBAR m_pToolbar2; // Toolbar for view
  690. LPCONTROLBAR m_pControlbar; // control bar to hold my tool bars
  691. LPCONSOLEVERB m_pConsoleVerb; // pointer the console verb
  692. LPTSTR m_szAnalTimeStamp;
  693. CBitmap* m_pbmpToolbar1; // Imagelist for the first toolbar
  694. CBitmap* m_pbmpToolbar2; // Imagelist for the first toolbar
  695. // Header titles for each nodetype(s)
  696. protected:
  697. CString m_multistrDisplay;
  698. CString m_colName; // Name
  699. CString m_colDesc; // Description
  700. CString m_colAttr; // Attribute
  701. CString m_colBaseAnalysis; // Baseline setting for Analysis
  702. CString m_colBaseTemplate; // Baseline setting for Template
  703. CString m_colLocalPol; // Local policy setting
  704. CString m_colSetting; // Current Setting
  705. // result data
  706. private:
  707. HINSTANCE hinstAclUI;
  708. //CList<CResult*, CResult*> m_resultItemList;
  709. CMap<LONG_PTR, LONG_PTR, CAttribute *, CAttribute *&> m_resultItemPopups;
  710. CMap<LONG_PTR, LONG_PTR, CPropertySheet *, CPropertySheet *&> m_resultItemPropSheets;
  711. MMC_COOKIE m_ShowCookie;
  712. CWinThread *m_pUIThread;
  713. HWND m_hwndParent;
  714. CHiddenWnd *m_pNotifier;
  715. HANDLE m_resultItemHandle;
  716. CFolder *m_pSelectedFolder;
  717. CString m_strDisplay;
  718. int m_nColumns;
  719. };
  720. inline void CSnapin::SetIComponentData(CComponentDataImpl* pData)
  721. {
  722. ASSERT(pData);
  723. ASSERT(m_pComponentData == NULL);
  724. LPUNKNOWN pUnk = pData->GetUnknown();
  725. HRESULT hr;
  726. hr = pUnk->QueryInterface(IID_IComponentData, reinterpret_cast<void**>(&m_pComponentData));
  727. ASSERT(hr == S_OK);
  728. }
  729. #define FREE_INTERNAL(pInternal) \
  730. ASSERT(pInternal != NULL); \
  731. do { if (pInternal != NULL) \
  732. GlobalFree(pInternal); } \
  733. while(0);
  734. void ConvertNameListToString(PSCE_NAME_LIST pList, LPTSTR *sz);
  735. int GetScopeImageIndex( FOLDER_TYPES type, DWORD status = -1 );
  736. int GetResultImageIndex( CFolder* pFolder, CResult* pResult );
  737. // Cliboard Types
  738. // Policy Area includes the Privileges Area
  739. #define CF_SCE_ACCOUNT_AREA TEXT("CF_SCE_ACCOUNT_AREA")
  740. #define CF_SCE_EVENTLOG_AREA TEXT("CF_SCE_EVENTLOG_AREA")
  741. #define CF_SCE_LOCAL_AREA TEXT("CF_SCE_LOCAL_AREA")
  742. #define CF_SCE_GROUPS_AREA TEXT("CF_SCE_GROUPS_AREA")
  743. #define CF_SCE_REGISTRY_AREA TEXT("CF_SCE_REGISTRY_AREA")
  744. #define CF_SCE_FILE_AREA TEXT("CF_SCE_FILE_AREA")
  745. #define CF_SCE_SERVICE_AREA TEXT("CF_SCE_SERVICE_AREA")
  746. extern UINT cfSceAccountArea; // in snapmgr.cpp
  747. extern UINT cfSceEventLogArea; // in snapmgr.cpp
  748. extern UINT cfSceLocalArea; // in snapmgr.cpp
  749. extern UINT cfSceGroupsArea; // in snapmgr.cpp
  750. extern UINT cfSceRegistryArea; // in snapmgr.cpp
  751. extern UINT cfSceFileArea; // in snapmgr.cpp
  752. extern UINT cfSceServiceArea; // in snapmgr.cpp
  753. extern SCE_COLUMNINFO g_columnInfo[]; // Default column information.
  754. #define MB_NO_NATIVE_NODES 0x00000001
  755. #define MB_SINGLE_TEMPLATE_ONLY 0x00000002
  756. #define MB_DS_OBJECTS_SECTION 0x00000004
  757. #define MB_NO_TEMPLATE_VERBS 0x00000008
  758. #define MB_STANDALONE_NAME 0x00000010
  759. #define MB_WRITE_THROUGH 0x00000020
  760. #define MB_ANALYSIS_VIEWER 0x00000040
  761. #define MB_TEMPLATE_EDITOR 0x00000080
  762. #define MB_LOCAL_POLICY 0x00000100
  763. #define MB_GROUP_POLICY 0x00000200
  764. #define MB_LOCALSEC 0x00000400
  765. #define MB_READ_ONLY 0x00000800
  766. #define MB_RSOP 0x00001000
  767. #define GT_COMPUTER_TEMPLATE (TEXT("[[ Computer Template (not for display) ]]"))
  768. #define GT_LAST_INSPECTION (TEXT("[[ Last Inspected Template (not for display) ]]"))
  769. #define GT_LOCAL_POLICY (TEXT("[[ Local Policy Template (not for display) ]]"))
  770. #define GT_LOCAL_POLICY_DELTA (TEXT("[[ Local Policy Template Changes (not for display) ]]"))
  771. #define GT_EFFECTIVE_POLICY (TEXT("[[ Effective Policy Template (not for display) ]]"))
  772. #define GT_DEFAULT_TEMPLATE (TEXT("[[ Default Template (not for display) ]]"))
  773. #define GT_RSOP_TEMPLATE (TEXT("[[ RSOP Template (not for display) ]]"))
  774. #define SCE_REGISTRY_KEY TEXT("Software\\Microsoft\\Windows NT\\CurrentVersion\\SeCEdit")
  775. #define SCE_REGISTRY_DEFAULT_TEMPLATE TEXT("DefaultTemplate")
  776. #define DEFAULT_LOCATIONS_KEY SCE_REGISTRY_KEY TEXT("\\DefaultLocations")
  777. #define CONFIGURE_LOG_LOCATIONS_KEY TEXT("ConfigureLog")
  778. #define ANALYSIS_LOG_LOCATIONS_KEY TEXT("AnalysisLog")
  779. #define OPEN_DATABASE_LOCATIONS_KEY TEXT("Database")
  780. #define IMPORT_TEMPLATE_LOCATIONS_KEY TEXT("ImportTemplate")
  781. #define EXPORT_TEMPLATE_LOCATIONS_KEY TEXT("ExportTemplate")
  782. #endif // !WSECMGR_SNAPMGR_H