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.

444 lines
11 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. // stdafx.h : include file for standard system include files,
  9. // or project specific include files that are used frequently,
  10. // but are changed infrequently
  11. #ifndef STDAFX_H
  12. #define STDAFX_H
  13. #pragma warning(push,3)
  14. #include <afxwin.h>
  15. #include <afxdisp.h>
  16. #include <afxcmn.h>
  17. #include <atlbase.h>
  18. #include <afxdlgs.h>
  19. #include <afxole.h>
  20. #include <shlobj.h>
  21. #include <tchar.h>
  22. #include "resource.h"
  23. //#include <xstring>
  24. #include <list>
  25. #include <vector>
  26. #include <algorithm>
  27. #include <functional>
  28. #include <string>
  29. #include <dsgetdc.h>
  30. #include <sceattch.h>
  31. #include <io.h>
  32. #include <basetsd.h>
  33. #include <lm.h>
  34. #include <shlwapi.h>
  35. #include <shlwapip.h>
  36. using namespace std;
  37. //You may derive a class from CComModule and use it if you want to override
  38. //something, but do not change the name of _Module
  39. extern CComModule _Module;
  40. #include <atlcom.h>
  41. #pragma comment(lib, "mmc")
  42. #include <mmc.h>
  43. #include "afxtempl.h"
  44. /* Bug 424909, Yanggao, 6/29/2001
  45. * Define/include the stuff we need for WTL::CImageList. We need prototypes
  46. * for IsolationAwareImageList_Read and IsolationAwareImageList_Write here
  47. * because commctrl.h only declares them if __IStream_INTERFACE_DEFINED__
  48. * is defined. __IStream_INTERFACE_DEFINED__ is defined by objidl.h, which
  49. * we can't include before including afx.h because it ends up including
  50. * windows.h, which afx.h expects to include itself. Ugh.
  51. */
  52. HIMAGELIST WINAPI IsolationAwareImageList_Read(LPSTREAM pstm);
  53. BOOL WINAPI IsolationAwareImageList_Write(HIMAGELIST himl,LPSTREAM pstm);
  54. #define _WTL_NO_AUTOMATIC_NAMESPACE
  55. #include <atlapp.h>
  56. #include <atlwin.h>
  57. #include <atlctrls.h>
  58. extern"C" {
  59. #include <wtypes.h>
  60. #include <ntsecapi.h>
  61. #include <secedit.h>
  62. #include "edittemp.h"
  63. #include <scesvc.h>
  64. #include <compuuid.h> // UUIDS for computer management
  65. #include "hlpids.h"
  66. #include "hlparray.h"
  67. #include <stdlib.h>
  68. #include <wbemidl.h>
  69. #include <aclapi.h>
  70. #include <activeds.h>
  71. #include <sddl.h>
  72. #include <winldap.h>
  73. #include <afxmt.h>
  74. }
  75. #include <comdef.h>
  76. #include <accctrl.h>
  77. #include <dssec.h>
  78. #include <gpedit.h>
  79. #include <objsel.h>
  80. #include <aclui.h>
  81. // for theme-enabling
  82. #include <shfusion.h>
  83. #include "debug.h"
  84. #pragma warning(pop)
  85. const long UNINITIALIZED = -1;
  86. // This should be in secedit.h, but isn't
  87. // is now! const SCE_FOREVER_VALUE = -1;
  88. // Security Area types
  89. enum FOLDER_TYPES
  90. {
  91. STATIC = 0x8000,
  92. ROOT,
  93. ANALYSIS,
  94. CONFIGURATION,
  95. LOCATIONS,
  96. PROFILE,
  97. LOCALPOL,
  98. AREA_POLICY,
  99. POLICY_ACCOUNT,
  100. POLICY_LOCAL,
  101. POLICY_EVENTLOG,
  102. POLICY_PASSWORD,
  103. POLICY_KERBEROS,
  104. POLICY_LOCKOUT,
  105. POLICY_AUDIT,
  106. POLICY_OTHER,
  107. POLICY_LOG,
  108. AREA_PRIVILEGE,
  109. AREA_GROUPS,
  110. AREA_SERVICE,
  111. AREA_REGISTRY,
  112. AREA_FILESTORE,
  113. AREA_POLICY_ANALYSIS,
  114. POLICY_ACCOUNT_ANALYSIS,
  115. POLICY_LOCAL_ANALYSIS,
  116. POLICY_EVENTLOG_ANALYSIS,
  117. POLICY_PASSWORD_ANALYSIS,
  118. POLICY_KERBEROS_ANALYSIS,
  119. POLICY_LOCKOUT_ANALYSIS,
  120. POLICY_AUDIT_ANALYSIS,
  121. POLICY_OTHER_ANALYSIS,
  122. POLICY_LOG_ANALYSIS,
  123. AREA_PRIVILEGE_ANALYSIS,
  124. AREA_GROUPS_ANALYSIS,
  125. AREA_SERVICE_ANALYSIS ,
  126. AREA_REGISTRY_ANALYSIS,
  127. AREA_FILESTORE_ANALYSIS ,
  128. REG_OBJECTS,
  129. FILE_OBJECTS,
  130. AREA_LOCALPOL,
  131. LOCALPOL_ACCOUNT,
  132. LOCALPOL_LOCAL,
  133. LOCALPOL_EVENTLOG,
  134. LOCALPOL_PASSWORD,
  135. LOCALPOL_KERBEROS,
  136. LOCALPOL_LOCKOUT,
  137. LOCALPOL_AUDIT,
  138. LOCALPOL_OTHER,
  139. LOCALPOL_LOG,
  140. LOCALPOL_PRIVILEGE,
  141. LOCALPOL_LAST,
  142. AREA_LAST,
  143. NONE = 0xFFFF
  144. };
  145. enum RESULT_TYPES
  146. {
  147. ITEM_FIRST_POLICY = 0x8000,
  148. ITEM_BOOL,
  149. ITEM_DW,
  150. ITEM_SZ,
  151. ITEM_RET,
  152. ITEM_BON,
  153. ITEM_B2ON,
  154. ITEM_REGCHOICE,
  155. ITEM_REGFLAGS,
  156. ITEM_REGVALUE,
  157. ITEM_PROF_BOOL,
  158. ITEM_PROF_DW,
  159. ITEM_PROF_SZ,
  160. ITEM_PROF_RET,
  161. ITEM_PROF_BON,
  162. ITEM_PROF_B2ON,
  163. ITEM_PROF_REGCHOICE,
  164. ITEM_PROF_REGFLAGS,
  165. ITEM_PROF_REGVALUE,
  166. ITEM_LOCALPOL_BOOL,
  167. ITEM_LOCALPOL_DW,
  168. ITEM_LOCALPOL_SZ,
  169. ITEM_LOCALPOL_RET,
  170. ITEM_LOCALPOL_BON,
  171. ITEM_LOCALPOL_B2ON,
  172. ITEM_LOCALPOL_REGCHOICE,
  173. ITEM_LOCALPOL_REGFLAGS,
  174. ITEM_LOCALPOL_REGVALUE,
  175. ITEM_LAST_POLICY,
  176. ITEM_LOCALPOL_PRIVS,
  177. ITEM_PROF_PRIVS,
  178. ITEM_PRIVS,
  179. ITEM_GROUP,
  180. ITEM_GROUP_MEMBERS,
  181. ITEM_GROUP_MEMBEROF,
  182. ITEM_GROUPSTATUS,
  183. ITEM_PROF_GROUP,
  184. ITEM_PROF_GROUPSTATUS,
  185. ITEM_REGSD,
  186. ITEM_PROF_REGSD,
  187. ITEM_FILESD,
  188. ITEM_PROF_FILESD,
  189. ITEM_PROF_SERV,
  190. ITEM_ANAL_SERV,
  191. ITEM_OTHER = 0xFFFF
  192. };
  193. enum EVENT_TYPES
  194. {
  195. EVENT_TYPE_SYSTEM = 0,
  196. EVENT_TYPE_SECURITY = 1,
  197. EVENT_TYPE_APP = 2,
  198. };
  199. enum POLICY_SETTINGS {
  200. AUDIT_SUCCESS = 1,
  201. AUDIT_FAILURE = 2,
  202. };
  203. enum RETENTION {
  204. SCE_RETAIN_AS_NEEDED = 0,
  205. SCE_RETAIN_BY_DAYS = 1,
  206. SCE_RETAIN_MANUALLY = 2,
  207. };
  208. enum GWD_TYPES {
  209. GWD_CONFIGURE_LOG = 1,
  210. GWD_ANALYSIS_LOG,
  211. GWD_OPEN_DATABASE,
  212. GWD_IMPORT_TEMPLATE,
  213. GWD_EXPORT_TEMPLATE
  214. };
  215. // Note - This is the offset in my image list that represents the folder
  216. #define IMOFFSET_MISMATCH 1
  217. #define IMOFFSET_GOOD 2
  218. #define IMOFFSET_NOT_ANALYZED 3
  219. #define IMOFFSET_ERROR 4
  220. const CONFIG_LOCAL_IDX = 0;
  221. const MISMATCH_LOCAL_IDX = 1;
  222. const MATCH_LOCAL_IDX = 2;
  223. const CONFIG_ACCOUNT_IDX = 5;
  224. const MISMATCH_ACCOUNT_IDX = 6;
  225. const MATCH_ACCOUNT_IDX = 7;
  226. const CONFIG_FILE_IDX = 10;
  227. const MISMATCH_FILE_IDX = 11;
  228. const MATCH_FILE_IDX = 12;
  229. const FOLDER_IMAGE_IDX = 15;
  230. const MISMATCH_FOLDER_IDX = 16;
  231. const MATCH_FOLDER_IDX = 17;
  232. const CONFIG_GROUP_IDX = 20;
  233. const MISMATCH_GROUP_IDX = 21;
  234. const MATCH_GROUP_IDX = 22;
  235. const CONFIG_REG_IDX = 25;
  236. const MISMATCH_REG_IDX = 26;
  237. const MATCH_REG_IDX = 27;
  238. const CONFIG_SERVICE_IDX = 30;
  239. const MISMATCH_SERVICE_IDX = 31;
  240. const MATCH_SERVICE_IDX = 32;
  241. const CONFIG_POLICY_IDX = 35;
  242. const MISMATCH_POLICY_IDX = 36;
  243. const MATCH_POLICY_IDX = 37;
  244. const BLANK_IMAGE_IDX = 45;
  245. const SCE_OK_IDX = 46;
  246. const SCE_CRITICAL_IDX = 47;
  247. const SCE_IMAGE_IDX = 50;
  248. const CONFIG_FOLDER_IDX = 51;
  249. const TEMPLATES_IDX = 52;
  250. const LAST_IC_IMAGE_IDX = 53;
  251. const OPEN_FOLDER_IMAGE_IDX = 54;
  252. const LOCALSEC_POLICY_IDX = CONFIG_ACCOUNT_IDX;
  253. const LOCALSEC_LOCAL_IDX = CONFIG_LOCAL_IDX;
  254. /////////////////////////////////////////////////////////////////////////////
  255. // Helper functions
  256. template<class TYPE>
  257. inline void SAFE_RELEASE(TYPE*& pObj)
  258. {
  259. if (pObj != NULL)
  260. {
  261. pObj->Release();
  262. pObj = NULL;
  263. }
  264. else
  265. {
  266. TRACE(_T("Release called on NULL interface ptr\n"));
  267. }
  268. }
  269. // security settings (extension of GPE)
  270. extern const CLSID CLSID_Snapin; // In-Proc server GUID
  271. extern const GUID cNodeType; // Main NodeType GUID on numeric format
  272. extern const wchar_t* cszNodeType; // Main NodeType GUID on string format
  273. // security settings (extension of RSOP)
  274. extern const CLSID CLSID_RSOPSnapin; // In-Proc server GUID
  275. extern const GUID cRSOPNodeType; // Main NodeType GUID on numeric format
  276. extern const wchar_t* cszRSOPNodeType; // Main NodeType GUID on string format
  277. // SCE (standalone)
  278. extern const CLSID CLSID_SCESnapin; // In-Proc server GUID
  279. extern const GUID cSCENodeType; // Main NodeType GUID on numeric format
  280. extern const wchar_t* cszSCENodeType; // Main NodeType GUID on string format
  281. // SAV (standalone)
  282. extern const CLSID CLSID_SAVSnapin; // In-Proc server GUID
  283. extern const GUID cSAVNodeType; // Main NodeType GUID on numeric format
  284. extern const wchar_t* cszSAVNodeType; // Main NodeType GUID on string format
  285. // Local security (standalone)
  286. extern const CLSID CLSID_LSSnapin; // In-Proc server GUID
  287. extern const GUID cLSNodeType; // Main NodeType GUID on numeric format
  288. extern const wchar_t* cszLSNodeType; // Main NodeType GUID on string format
  289. extern const CLSID CLSID_SCEAbout;
  290. extern const CLSID CLSID_SCMAbout;
  291. extern const CLSID CLSID_SSAbout;
  292. extern const CLSID CLSID_LSAbout;
  293. extern const CLSID CLSID_RSOPAbout;
  294. // New Clipboard format that has the Type and Cookie
  295. extern const wchar_t* SNAPIN_INTERNAL;
  296. EXTERN_C const TCHAR SNAPINS_KEY[];
  297. EXTERN_C const TCHAR NODE_TYPES_KEY[];
  298. EXTERN_C const TCHAR g_szExtensions[];
  299. EXTERN_C const TCHAR g_szNameSpace[];
  300. struct INTERNAL
  301. {
  302. INTERNAL()
  303. {
  304. m_type = CCT_UNINITIALIZED;
  305. m_cookie = -1;
  306. m_foldertype = NONE;
  307. };
  308. virtual ~INTERNAL()
  309. {
  310. }
  311. DATA_OBJECT_TYPES m_type; // What context is the data object.
  312. MMC_COOKIE m_cookie; // What object the cookie represents
  313. FOLDER_TYPES m_foldertype;
  314. CLSID m_clsid; // Class ID of who created this data object
  315. INTERNAL & operator=(const INTERNAL& rhs)
  316. {
  317. if (&rhs == this)
  318. return *this;
  319. m_type = rhs.m_type;
  320. m_cookie = rhs.m_cookie;
  321. m_foldertype = rhs.m_foldertype;
  322. memcpy(&m_clsid, &rhs.m_clsid, sizeof(CLSID));
  323. return *this;
  324. }
  325. BOOL operator==(const INTERNAL& rhs)
  326. {
  327. return rhs.m_cookie == m_cookie;
  328. }
  329. };
  330. typedef struct {
  331. LPTSTR TemplateName;
  332. LPTSTR ServiceName;
  333. } SCESVCP_HANDLE, *PSCESVCP_HANDLE;
  334. typedef struct RegChoiceList{
  335. LPTSTR szName;
  336. DWORD dwValue;
  337. struct RegChoiceList *pNext;
  338. } REGCHOICE, *PREGCHOICE, REGFLAGS, *PREGFLAGS;
  339. // Debug instance counter
  340. #ifdef _DEBUG
  341. inline void DbgInstanceRemaining(char * pszClassName, int cInstRem)
  342. {
  343. char buf[100];
  344. wsprintfA(buf, "%s has %d instances left over.", pszClassName, cInstRem);
  345. ::MessageBoxA(NULL, buf, "Memory Leak!!!", MB_OK);
  346. }
  347. #define DEBUG_DECLARE_INSTANCE_COUNTER(cls) extern int s_cInst_##cls = 0;
  348. #define DEBUG_INCREMENT_INSTANCE_COUNTER(cls) ++(s_cInst_##cls);
  349. #define DEBUG_DECREMENT_INSTANCE_COUNTER(cls) --(s_cInst_##cls);
  350. #define DEBUG_VERIFY_INSTANCE_COUNT(cls) \
  351. extern int s_cInst_##cls; \
  352. if (s_cInst_##cls) DbgInstanceRemaining(#cls, s_cInst_##cls);
  353. #else
  354. #define DEBUG_DECLARE_INSTANCE_COUNTER(cls)
  355. #define DEBUG_INCREMENT_INSTANCE_COUNTER(cls)
  356. #define DEBUG_DECREMENT_INSTANCE_COUNTER(cls)
  357. #define DEBUG_VERIFY_INSTANCE_COUNT(cls)
  358. #endif
  359. // For theme-enabling
  360. #ifndef ARRAYSIZE
  361. #define ARRAYSIZE(x) (sizeof(x)/sizeof(x[0]))
  362. #endif
  363. #define SCE_MODE_DOMAIN_COMPUTER_ERROR 9999999
  364. #ifdef UNICODE
  365. #define PROPSHEETPAGE_V3 PROPSHEETPAGEW_V3
  366. #else
  367. #define PROPSHEETPAGE_V3 PROPSHEETPAGEA_V3
  368. #endif
  369. HPROPSHEETPAGE MyCreatePropertySheetPage(AFX_OLDPROPSHEETPAGE* psp);
  370. class CThemeContextActivator
  371. {
  372. public:
  373. CThemeContextActivator() : m_ulActivationCookie(0)
  374. { SHActivateContext (&m_ulActivationCookie); }
  375. ~CThemeContextActivator()
  376. { SHDeactivateContext (m_ulActivationCookie); }
  377. private:
  378. ULONG_PTR m_ulActivationCookie;
  379. };
  380. #endif // STDAFX_H