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.

1156 lines
44 KiB

  1. //
  2. // Current ADM version
  3. //
  4. // Version 1 -> Windows 95
  5. // Version 2 -> Windows NT v4.0
  6. // Version 3 -> Windows 2000
  7. // Version 4 -> Windows Whistler
  8. //
  9. #define CURRENT_ADM_VERSION 4
  10. //
  11. // Add/Remove template entry
  12. //
  13. typedef struct tagTEMPLATEENTRY {
  14. LPTSTR lpFileName;
  15. DWORD dwSize;
  16. FILETIME ftTime;
  17. } TEMPLATEENTRY, *LPTEMPLATEENTRY;
  18. //
  19. // Supported On strings
  20. //
  21. typedef struct tagSUPPORTEDENTRY {
  22. LPTSTR lpString;
  23. BOOL bEnabled;
  24. BOOL bNull;
  25. struct tagSUPPORTEDENTRY * pNext;
  26. } SUPPORTEDENTRY, *LPSUPPORTEDENTRY;
  27. //
  28. // RSOP link list data structures
  29. //
  30. typedef struct tagRSOPREGITEM {
  31. LPTSTR lpKeyName;
  32. LPTSTR lpValueName;
  33. LPTSTR lpGPOName;
  34. DWORD dwType;
  35. DWORD dwSize;
  36. LPBYTE lpData;
  37. BOOL bFoundInADM;
  38. UINT uiPrecedence;
  39. BOOL bDeleted;
  40. struct tagRSOPREGITEM * pNext;
  41. } RSOPREGITEM, *LPRSOPREGITEM;
  42. typedef struct tagRSOPADMFILE {
  43. TCHAR szFileName[100];
  44. TCHAR szFullFileName[MAX_PATH];
  45. FILETIME FileTime;
  46. DWORD dwError;
  47. struct tagRSOPADMFILE * pNext;
  48. } RSOPADMFILE, *LPRSOPADMFILE;
  49. //
  50. // From admincfg.h
  51. //
  52. #define REGBUFLEN 255
  53. #define MAXSTRLEN 1024
  54. #define SMALLBUF 48
  55. #define ERROR_ALREADY_DISPLAYED 0xFFFF
  56. #define GETNAMEPTR(x) (x->uOffsetName ? ((TCHAR *)((BYTE *) x + x->uOffsetName)) : NULL)
  57. #define GETKEYNAMEPTR(x) (x->uOffsetKeyName ? ((TCHAR *)((BYTE *) x + x->uOffsetKeyName)) : NULL)
  58. #define GETVALUENAMEPTR(x) (x->uOffsetValueName ? ((TCHAR *)((BYTE *) x + x->uOffsetValueName)) : NULL)
  59. #define GETOBJECTDATAPTR(x) (x->uOffsetObjectData ? ((BYTE *) x + x->uOffsetObjectData) : NULL)
  60. #define GETVALUESTRPTR(x) (x->uOffsetValueStr ? ((TCHAR *)((BYTE *) x + x->uOffsetValueStr)) : NULL)
  61. #define GETSUPPORTEDPTR(x) (x->uOffsetSupported ? ((TCHAR *)((BYTE *) x + x->uOffsetSupported)) : NULL)
  62. //
  63. // From memory.h
  64. //
  65. #define DEFAULT_ENUM_BUF_SIZE 256
  66. // Entry type ID's
  67. #define ETYPE_CATEGORY 0x0001
  68. #define ETYPE_POLICY 0x0002
  69. #define ETYPE_SETTING 0x0004
  70. #define ETYPE_ROOT 0x0008
  71. #define ETYPE_REGITEM 0x0010
  72. #define ETYPE_MASK 0x001F
  73. // Setting type ID's
  74. #define STYPE_TEXT 0x0010
  75. #define STYPE_CHECKBOX 0x0020
  76. #define STYPE_ENUM 0x0040
  77. #define STYPE_EDITTEXT 0x0080
  78. #define STYPE_NUMERIC 0x0100
  79. #define STYPE_COMBOBOX 0x0200
  80. #define STYPE_DROPDOWNLIST 0x0400
  81. #define STYPE_LISTBOX 0x0800
  82. #define STYPE_MASK 0xFFF0
  83. // Flags
  84. #define DF_REQUIRED 0x0001 // text or numeric field required to have entry
  85. #define DF_USEDEFAULT 0x0002 // use specified text or numeric value
  86. #define DF_DEFCHECKED 0x0004 // initialize checkbox or radio button as checked
  87. #define DF_TXTCONVERT 0x0008 // save numeric values as text rather than binary
  88. #define DF_ADDITIVE 0x0010 // listbox is additive, rather than destructive
  89. #define DF_EXPLICITVALNAME 0x0020 // listbox value names need to be specified for each entry
  90. #define DF_NOSORT 0x0040 // listbox is not sorted alphabetically. Uses order in ADM.
  91. #define DF_EXPANDABLETEXT 0x0080 // write REG_EXPAND_SZ text value
  92. #define VF_ISNUMERIC 0x0100 // value is numeric (rather than text)
  93. #define VF_DELETE 0x0200 // value should be deleted
  94. #define VF_SOFT 0x0400 // value is soft (only propagated if doesn't exist on destination)
  95. // generic table entry
  96. typedef struct tagTABLEENTRY {
  97. DWORD dwSize;
  98. DWORD dwType;
  99. struct tagTABLEENTRY * pNext; // ptr to next sibling in node
  100. struct tagTABLEENTRY * pPrev; // ptr to previous sibling in node
  101. struct tagTABLEENTRY * pChild; // ptr to child node
  102. UINT uOffsetName; // offset from beginning of struct to name
  103. UINT uOffsetKeyName; // offset from beginning of struct to key name
  104. // table entry information here
  105. } TABLEENTRY;
  106. typedef struct tagACTION {
  107. DWORD dwFlags; // can be VF_ISNUMERIC, VF_DELETE, VF_SOFT
  108. UINT uOffsetKeyName;
  109. UINT uOffsetValueName;
  110. union {
  111. UINT uOffsetValue; // offset to value, if text
  112. DWORD dwValue; // value, if numeric
  113. };
  114. UINT uOffsetNextAction;
  115. // key name, value name, value stored here
  116. } ACTION;
  117. typedef struct tagACTIONLIST {
  118. UINT nActionItems;
  119. ACTION Action[1];
  120. } ACTIONLIST;
  121. typedef struct tagSTATEVALUE {
  122. DWORD dwFlags; // can be VF_ISNUMERIC, VF_DELETE, VF_SOFT
  123. union {
  124. TCHAR szValue[1]; // value, if text
  125. DWORD dwValue; // value, if numeric
  126. };
  127. } STATEVALUE;
  128. // specialized nodes -- CATEGORY, POLICY, SETTING and REGITEM can all be cast to TABLEENTRY
  129. typedef struct tagCATEGORY {
  130. DWORD dwSize; // size of this struct (including variable-length name)
  131. DWORD dwType;
  132. struct tagTABLEENTRY * pNext; // ptr to next sibling in node
  133. struct tagTABLEENTRY * pPrev; // ptr to previous sibling in node
  134. struct tagTABLEENTRY * pChild; // ptr to child node
  135. UINT uOffsetName; // offset from beginning of struct to name
  136. UINT uOffsetKeyName; // offset from beginning of struct to key name
  137. UINT uOffsetHelp; // offset from beginning of struct to help text
  138. // category name stored here
  139. // category registry key name stored here
  140. } CATEGORY;
  141. typedef struct tagPOLICY {
  142. DWORD dwSize; // size of this struct (including variable-length name)
  143. DWORD dwType;
  144. struct tagTABLEENTRY * pNext; // ptr to next sibling in node
  145. struct tagTABLEENTRY * pPrev; // ptr to previous sibling in node
  146. struct tagTABLEENTRY * pChild; // ptr to child node
  147. UINT uOffsetName; // offset from beginning of struct to name
  148. UINT uOffsetKeyName; // offset from beginning of struct to key name
  149. UINT uOffsetValueName; // offset from beginning of struct to value name
  150. UINT uDataIndex; // index into user's data buffer for this setting
  151. UINT uOffsetValue_On; // offset to STATEVALUE for ON state
  152. UINT uOffsetValue_Off; // offset to STATEVALUE for OFF state
  153. UINT uOffsetActionList_On; // offset to ACTIONLIST for ON state
  154. UINT uOffsetActionList_Off; // offset to ACTIONLIST for OFF state
  155. UINT uOffsetHelp; // offset from beginning of struct to help text
  156. UINT uOffsetClientExt; // offset from beginning of struct to clientext text
  157. BOOL bTruePolicy; // something located under the Policies key
  158. UINT uOffsetSupported; // list of supported products
  159. // name stored here
  160. // policy registry key name stored here
  161. } POLICY;
  162. typedef struct tagSETTINGS {
  163. DWORD dwSize; // size of this struct (including variable-length data)
  164. DWORD dwType;
  165. struct tagTABLEENTRY * pNext; // ptr to next sibling in node
  166. struct tagTABLEENTRY * pPrev; // ptr to previous sibling in node
  167. struct tagTABLEENTRY * pChild; // ptr to child node
  168. UINT uOffsetName; // offset from beginning of struct to name
  169. UINT uOffsetKeyName; // offset from beginning of struct to key name
  170. UINT uOffsetValueName; // offset from beginning of struct to value name
  171. UINT uDataIndex; // index into user's data buffer for this setting
  172. UINT uOffsetObjectData; // offset to object data
  173. UINT uOffsetClientExt; // offset from beginning of struct to clientext text
  174. DWORD dwFlags; // can be DF_REQUIRED, DF_USEDEFAULT, DF_DEFCHECKED,
  175. // VF_SOFT, DF_NO_SORT
  176. // settings registry value name stored here
  177. // object-dependent data stored here (a CHECKBOXINFO,
  178. // RADIOBTNINFO, EDITTEXTINFO, or NUMERICINFO struct)
  179. } SETTINGS;
  180. typedef struct tagREGITEM {
  181. DWORD dwSize;
  182. DWORD dwType;
  183. struct tagTABLEENTRY * pNext; // ptr to next sibling in node
  184. struct tagTABLEENTRY * pPrev; // ptr to previous sibling in node
  185. struct tagTABLEENTRY * pChild; // ptr to child node
  186. UINT uOffsetName; // offset from beginning of struct to name
  187. UINT uOffsetKeyName; // offset from beginning of struct to key name
  188. UINT uOffsetValueStr; // offset from beginning of struct to the value in string format
  189. BOOL bTruePolicy; // something located under the Policies key
  190. LPRSOPREGITEM lpItem; // Pointer to a rsop registry item
  191. // Name and keyname information here
  192. } REGITEM;
  193. typedef struct tagCHECKBOXINFO {
  194. UINT uOffsetValue_On; // offset to STATEVALUE for ON state
  195. UINT uOffsetValue_Off; // offset to STATEVALUE for OFF state
  196. UINT uOffsetActionList_On; // offset to ACTIONLIST for ON state
  197. UINT uOffsetActionList_Off; // offset to ACTIONLIST for OFF state
  198. } CHECKBOXINFO;
  199. typedef struct tagEDITTEXTINFO {
  200. UINT uOffsetDefText;
  201. UINT nMaxLen; // max len of edit field
  202. } EDITTEXTINFO;
  203. typedef struct tagPOLICYCOMBOBOXINFO {
  204. UINT uOffsetDefText;
  205. UINT nMaxLen; // max len of edit field
  206. UINT uOffsetSuggestions;
  207. } POLICYCOMBOBOXINFO;
  208. typedef struct tagNUMERICINFO {
  209. UINT uDefValue; // default value
  210. UINT uMaxValue; // minimum value
  211. UINT uMinValue; // maximum value
  212. UINT uSpinIncrement; // if 0, spin box is not displayed.
  213. } NUMERICINFO;
  214. typedef struct tagCLASSLIST {
  215. TABLEENTRY * pMachineCategoryList; // per-machine category list
  216. UINT nMachineDataItems;
  217. TABLEENTRY * pUserCategoryList; // per-user category table
  218. UINT nUserDataItems;
  219. } CLASSLIST;
  220. typedef struct tagDROPDOWNINFO {
  221. UINT uOffsetItemName;
  222. UINT uDefaultItemIndex; // only used in 1st DROPDOWNINFO struct in list
  223. DWORD dwFlags;
  224. union {
  225. UINT uOffsetValue;
  226. DWORD dwValue;
  227. };
  228. UINT uOffsetActionList;
  229. UINT uOffsetNextDropdowninfo;
  230. } DROPDOWNINFO;
  231. typedef struct tagLISTBOXINFO {
  232. UINT uOffsetPrefix; // offset to prefix to use for value names (e.g
  233. // "stuff" -> "stuff1", "stuff2", etc
  234. UINT uOffsetValue; // offset to STATEVALUE to use for value data for each entry
  235. // (can't have both a data value and a prefix)
  236. } LISTBOXINFO;
  237. //
  238. // From policy.h
  239. //
  240. #define NO_DATA_INDEX (UINT) -1
  241. #define DEF_CONTROLS 10
  242. typedef struct tagPOLICYCTRLINFO {
  243. HWND hwnd;
  244. DWORD dwType;
  245. UINT uDataIndex; // index into user's data buffer
  246. SETTINGS * pSetting;
  247. } POLICYCTRLINFO;
  248. typedef struct tagSTRDATA {
  249. DWORD dwSize; // size of structure incl. variable-len data
  250. TCHAR szData[1]; // variable-length data
  251. } STRDATA;
  252. typedef struct tagPOLICYDLGINFO {
  253. TABLEENTRY * pEntryRoot; // root template
  254. SETTINGS * pCurrentSettings; // template for current settings
  255. HWND hwndSettings;
  256. HWND hwndApp;
  257. BOOL fActive;
  258. POLICYCTRLINFO * pControlTable;
  259. DWORD dwControlTableSize;
  260. UINT nControls;
  261. } POLICYDLGINFO;
  262. //
  263. // From settings.h
  264. //
  265. #define WT_CLIP 1
  266. #define WT_SETTINGS 2
  267. #define SSTYLE_STATIC WS_CHILD | WS_VISIBLE
  268. #define SSTYLE_CHECKBOX WS_CHILD | WS_VISIBLE | BS_CHECKBOX
  269. #define SSTYLE_EDITTEXT WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL | WS_BORDER
  270. #define SSTYLE_UPDOWN WS_CHILD | WS_VISIBLE | UDS_NOTHOUSANDS
  271. #define SSTYLE_COMBOBOX WS_CHILD | WS_VISIBLE | CBS_AUTOHSCROLL | CBS_DROPDOWN \
  272. | WS_BORDER | CBS_SORT | WS_VSCROLL
  273. #define SSTYLE_DROPDOWNLIST WS_CHILD | WS_VISIBLE | CBS_AUTOHSCROLL | CBS_DROPDOWNLIST \
  274. | WS_BORDER | CBS_SORT | WS_VSCROLL
  275. #define SSTYLE_LISTVIEW WS_CHILD | WS_VISIBLE | WS_BORDER
  276. #define SSTYLE_LBBUTTON WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON
  277. #define LISTBOX_BTN_WIDTH 100
  278. #define LISTBOX_BTN_HEIGHT 20
  279. #define SC_XSPACING 5
  280. #define SC_YSPACING 5
  281. #define SC_YPAD 8
  282. #define SC_EDITWIDTH 220
  283. #define SC_UPDOWNWIDTH 60
  284. #define SC_UPDOWNWIDTH2 30
  285. #define SC_XLEADING 5
  286. #define SC_XINDENT 5
  287. #define SC_YTEXTDROP 3
  288. #define SC_YCONTROLWRAP 1
  289. //
  290. // From parse.h
  291. //
  292. #define KYWD_ID_KEYNAME 1
  293. #define KYWD_ID_VALUENAME 2
  294. #define KYWD_ID_CATEGORY 3
  295. #define KYWD_ID_POLICY 4
  296. #define KYWD_ID_PART 5
  297. #define KYWD_ID_CHECKBOX 6
  298. #define KYWD_ID_TEXT 7
  299. #define KYWD_ID_EDITTEXT 8
  300. #define KYWD_ID_NUMERIC 9
  301. #define KYWD_ID_DEFCHECKED 10
  302. #define KYWD_ID_MAXLENGTH 11
  303. #define KYWD_ID_MIN 12
  304. #define KYWD_ID_MAX 13
  305. #define KYWD_ID_SPIN 14
  306. #define KYWD_ID_REQUIRED 15
  307. #define KYWD_ID_EDITTEXT_DEFAULT 16
  308. #define KYWD_ID_COMBOBOX_DEFAULT 17
  309. #define KYWD_ID_NUMERIC_DEFAULT 18
  310. #define KYWD_ID_OEMCONVERT 19
  311. #define KYWD_ID_CLASS 20
  312. #define KYWD_ID_USER 21
  313. #define KYWD_ID_MACHINE 22
  314. #define KYWD_ID_TXTCONVERT 23
  315. #define KYWD_ID_VALUE 24
  316. #define KYWD_ID_VALUEON 25
  317. #define KYWD_ID_VALUEOFF 26
  318. #define KYWD_ID_ACTIONLIST 27
  319. #define KYWD_ID_ACTIONLISTON 28
  320. #define KYWD_ID_ACTIONLISTOFF 29
  321. #define KYWD_ID_DELETE 30
  322. #define KYWD_ID_COMBOBOX 31
  323. #define KYWD_ID_SUGGESTIONS 32
  324. #define KYWD_ID_DROPDOWNLIST 33
  325. #define KYWD_ID_NAME 34
  326. #define KYWD_ID_ITEMLIST 35
  327. #define KYWD_ID_DEFAULT 36
  328. #define KYWD_ID_SOFT 37
  329. #define KYWD_ID_STRINGSSECT 38
  330. #define KYWD_ID_LISTBOX 39
  331. #define KYWD_ID_VALUEPREFIX 40
  332. #define KYWD_ID_ADDITIVE 41
  333. #define KYWD_ID_EXPLICITVALUE 42
  334. #define KYWD_ID_VERSION 43
  335. #define KYWD_ID_GT 44
  336. #define KYWD_ID_GTE 45
  337. #define KYWD_ID_LT 46
  338. #define KYWD_ID_LTE 47
  339. #define KYWD_ID_EQ 48
  340. #define KYWD_ID_NE 49
  341. #define KYWD_ID_END 50
  342. #define KYWD_ID_NOSORT 51
  343. #define KYWD_ID_EXPANDABLETEXT 52
  344. #define KYWD_ID_HELP 53
  345. #define KYWD_ID_CLIENTEXT 54
  346. #define KYWD_ID_SUPPORTED 55
  347. #define KYWD_DONE 100
  348. #define DEFAULT_TMP_BUF_SIZE 512
  349. #define STRINGS_BUF_SIZE 8096
  350. #define WORDBUFSIZE 255
  351. #define FILEBUFSIZE 8192
  352. #define HELPBUFSIZE 4096
  353. typedef struct tagKEYWORDINFO {
  354. LPCTSTR pWord;
  355. UINT nID;
  356. } KEYWORDINFO;
  357. typedef struct tagENTRYDATA {
  358. BOOL fHasKey;
  359. BOOL fHasValue;
  360. BOOL fParentHasKey;
  361. } ENTRYDATA;
  362. typedef struct tagPARSEPROCSTRUCT {
  363. HGLOBAL hTable; // handle of current table
  364. TABLEENTRY *pTableEntry; // pointer to struct for current entry
  365. DWORD *pdwBufSize; // size of buffer of pTableEntry
  366. ENTRYDATA *pData; // used to maintain state between calls to parseproc
  367. KEYWORDINFO *pEntryCmpList;
  368. } PARSEPROCSTRUCT;
  369. typedef UINT (* PARSEPROC) (CPolicyComponentData *, UINT,PARSEPROCSTRUCT *,BOOL *,BOOL *, LPTSTR);
  370. typedef struct tagPARSEENTRYSTRUCT {
  371. TABLEENTRY * pParent;
  372. DWORD dwEntryType;
  373. KEYWORDINFO *pEntryCmpList;
  374. KEYWORDINFO *pTypeCmpList;
  375. PARSEPROC pParseProc;
  376. DWORD dwStructSize;
  377. BOOL fHasSubtable;
  378. BOOL fParentHasKey;
  379. } PARSEENTRYSTRUCT;
  380. //
  381. // From load.c
  382. //
  383. // flags for detected settings
  384. #define FS_PRESENT 0x0001
  385. #define FS_DELETED 0x0002
  386. #define FS_DISABLED 0x0004
  387. #define WM_MYCHANGENOTIFY (WM_USER + 123)
  388. #define WM_MOVEFOCUS (WM_USER + 124)
  389. #define WM_UPDATEITEM (WM_USER + 125)
  390. #define WM_SETPREVNEXT (WM_USER + 126)
  391. #define WM_MYREFRESH (WM_USER + 127)
  392. //
  393. // GPE root node ids
  394. //
  395. // {8FC0B739-A0E1-11d1-A7D3-0000F87571E3}
  396. DEFINE_GUID(NODEID_MachineRoot, 0x8fc0b739, 0xa0e1, 0x11d1, 0xa7, 0xd3, 0x0, 0x0, 0xf8, 0x75, 0x71, 0xe3);
  397. // {8FC0B73B-A0E1-11d1-A7D3-0000F87571E3}
  398. DEFINE_GUID(NODEID_UserRoot, 0x8fc0b73b, 0xa0e1, 0x11d1, 0xa7, 0xd3, 0x0, 0x0, 0xf8, 0x75, 0x71, 0xe3);
  399. //
  400. // RSOP root node ids
  401. //
  402. // {e753a11a-66cc-4816-8dd8-3cbe46717fd3}
  403. DEFINE_GUID(NODEID_RSOPMachineRoot, 0xe753a11a, 0x66cc, 0x4816, 0x8d, 0xd8, 0x3c, 0xbe, 0x46, 0x71, 0x7f, 0xd3);
  404. //
  405. // {99d5b872-1ad0-4d87-acf1-82125d317653}
  406. DEFINE_GUID(NODEID_RSOPUserRoot, 0x99d5b872, 0x1ad0, 0x4d87, 0xac, 0xf1, 0x82, 0x12, 0x5d, 0x31, 0x76, 0x53);
  407. //
  408. // GPE Policy SnapIn extension GUIDs
  409. //
  410. // {0F6B957D-509E-11d1-A7CC-0000F87571E3}
  411. DEFINE_GUID(CLSID_PolicySnapInMachine,0xf6b957d, 0x509e, 0x11d1, 0xa7, 0xcc, 0x0, 0x0, 0xf8, 0x75, 0x71, 0xe3);
  412. // {0F6B957E-509E-11d1-A7CC-0000F87571E3}
  413. DEFINE_GUID(CLSID_PolicySnapInUser,0xf6b957e, 0x509e, 0x11d1, 0xa7, 0xcc, 0x0, 0x0, 0xf8, 0x75, 0x71, 0xe3);
  414. //
  415. // RSOP SnapIn extension GUIDs
  416. //
  417. // {B6F9C8AE-EF3A-41c8-A911-37370C331DD4}
  418. DEFINE_GUID(CLSID_RSOPolicySnapInMachine,0xb6f9c8ae, 0xef3a, 0x41c8, 0xa9, 0x11, 0x37, 0x37, 0xc, 0x33, 0x1d, 0xd4);
  419. // {B6F9C8AF-EF3A-41c8-A911-37370C331DD4}
  420. DEFINE_GUID(CLSID_RSOPolicySnapInUser,0xb6f9c8af, 0xef3a, 0x41c8, 0xa9, 0x11, 0x37, 0x37, 0xc, 0x33, 0x1d, 0xd4);
  421. //
  422. // GPE Policy node ids
  423. //
  424. // {0F6B957F-509E-11d1-A7CC-0000F87571E3}
  425. DEFINE_GUID(NODEID_PolicyRootMachine,0xf6b957f, 0x509e, 0x11d1, 0xa7, 0xcc, 0x0, 0x0, 0xf8, 0x75, 0x71, 0xe3);
  426. // {0F6B9580-509E-11d1-A7CC-0000F87571E3}
  427. DEFINE_GUID(NODEID_PolicyRootUser,0xf6b9580, 0x509e, 0x11d1, 0xa7, 0xcc, 0x0, 0x0, 0xf8, 0x75, 0x71, 0xe3);
  428. //
  429. // RSOP node ids
  430. //
  431. // {B6F9C8B0-EF3A-41c8-A911-37370C331DD4}
  432. DEFINE_GUID(NODEID_RSOPolicyRootMachine,0xb6f9c8b0, 0xef3a, 0x41c8, 0xa9, 0x11, 0x37, 0x37, 0xc, 0x33, 0x1d, 0xd4);
  433. // {B6F9C8B1-EF3A-41c8-A911-37370C331DD4}
  434. DEFINE_GUID(NODEID_RSOPolicyRootUser,0xb6f9c8b1, 0xef3a, 0x41c8, 0xa9, 0x11, 0x37, 0x37, 0xc, 0x33, 0x1d, 0xd4);
  435. #define ROOT_NAME_SIZE 50
  436. //
  437. // CPolicyComponentData class
  438. //
  439. class CPolicyComponentData:
  440. public IComponentData,
  441. public IExtendContextMenu,
  442. public IPersistStreamInit,
  443. public ISnapinHelp
  444. {
  445. friend class CPolicyDataObject;
  446. friend class CPolicySnapIn;
  447. protected:
  448. ULONG m_cRef;
  449. HWND m_hwndFrame;
  450. LPCONSOLENAMESPACE2 m_pScope;
  451. LPCONSOLE m_pConsole;
  452. HSCOPEITEM m_hRoot;
  453. HSCOPEITEM m_hSWPolicies;
  454. LPGPEINFORMATION m_pGPTInformation;
  455. LPRSOPINFORMATION m_pRSOPInformation;
  456. LPRSOPREGITEM m_pRSOPRegistryData;
  457. LPOLESTR m_pszNamespace;
  458. DWORD m_bTemplatesColumn;
  459. BOOL m_bUserScope;
  460. BOOL m_bRSOP;
  461. TCHAR m_szRootName[ROOT_NAME_SIZE];
  462. HANDLE m_ADMEvent;
  463. HANDLE m_hTemplateThread;
  464. INT m_iSWPoliciesLen;
  465. INT m_iWinPoliciesLen;
  466. BOOL m_bShowConfigPoliciesOnly;
  467. BOOL m_bUseSupportedOnFilter;
  468. CPolicySnapIn * m_pSnapin;
  469. REGITEM * m_pExtraSettingsRoot;
  470. BOOL m_bExtraSettingsInitialized;
  471. //
  472. // Parsing globals (review)
  473. //
  474. UINT m_nFileLine;
  475. TABLEENTRY *m_pMachineCategoryList; // per-machine category list
  476. UINT m_nMachineDataItems;
  477. TABLEENTRY *m_pUserCategoryList; // per-user category table
  478. UINT m_nUserDataItems;
  479. LPSUPPORTEDENTRY m_pSupportedStrings;
  480. TABLEENTRY *m_pListCurrent; // Current category list (either user or machine)
  481. UINT *m_pnDataItemCount;
  482. BOOL m_bRetrieveString;
  483. LPTSTR m_pszParseFileName; // Template currently being parsed or NULL
  484. // buffer to read .INF file into
  485. TCHAR *m_pFilePtr;
  486. TCHAR *m_pFileEnd;
  487. TCHAR *m_pDefaultStrings;
  488. TCHAR *m_pLanguageStrings;
  489. TCHAR *m_pLocaleStrings;
  490. BOOL m_fInComment;
  491. public:
  492. CPolicyComponentData(BOOL bUser, BOOL bRSOP);
  493. ~CPolicyComponentData();
  494. // IUnknown methods
  495. STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
  496. STDMETHODIMP_(ULONG) AddRef();
  497. STDMETHODIMP_(ULONG) Release();
  498. //
  499. // Implemented IComponentData methods
  500. //
  501. STDMETHODIMP Initialize(LPUNKNOWN pUnknown);
  502. STDMETHODIMP CreateComponent(LPCOMPONENT* ppComponent);
  503. STDMETHODIMP QueryDataObject(MMC_COOKIE cookie, DATA_OBJECT_TYPES type, LPDATAOBJECT* ppDataObject);
  504. STDMETHODIMP Destroy(void);
  505. STDMETHODIMP Notify(LPDATAOBJECT lpDataObject, MMC_NOTIFY_TYPE event, LPARAM arg, LPARAM param);
  506. STDMETHODIMP GetDisplayInfo(LPSCOPEDATAITEM pItem);
  507. STDMETHODIMP CompareObjects(LPDATAOBJECT lpDataObjectA, LPDATAOBJECT lpDataObjectB);
  508. //
  509. // Implemented IExtendContextMenu methods
  510. //
  511. STDMETHODIMP AddMenuItems(LPDATAOBJECT piDataObject, LPCONTEXTMENUCALLBACK pCallback,
  512. LONG *pInsertionAllowed);
  513. STDMETHODIMP Command(LONG lCommandID, LPDATAOBJECT piDataObject);
  514. //
  515. // Implemented IPersistStreamInit interface members
  516. //
  517. STDMETHODIMP GetClassID(CLSID *pClassID);
  518. STDMETHODIMP IsDirty(VOID);
  519. STDMETHODIMP Load(IStream *pStm);
  520. STDMETHODIMP Save(IStream *pStm, BOOL fClearDirty);
  521. STDMETHODIMP GetSizeMax(ULARGE_INTEGER *pcbSize);
  522. STDMETHODIMP InitNew(VOID);
  523. //
  524. // Implemented ISnapinHelp interface members
  525. //
  526. STDMETHODIMP GetHelpTopic(LPOLESTR *lpCompiledHelpFile);
  527. private:
  528. HRESULT EnumerateScopePane(LPDATAOBJECT lpDataObject, HSCOPEITEM hParent);
  529. BOOL CheckForChildCategories (TABLEENTRY *pParent);
  530. #if DBG
  531. VOID DumpEntry (TABLEENTRY * pEntry, UINT uIndent);
  532. VOID DumpCurrentTable (void);
  533. #endif
  534. VOID FreeTemplates (void);
  535. static DWORD LoadTemplatesThread (CPolicyComponentData * pCD);
  536. void AddTemplates(LPTSTR lpDest, LPCTSTR lpValueName, UINT idRes);
  537. void AddDefaultTemplates(LPTSTR lpDest);
  538. void AddNewADMsToExistingGPO (LPTSTR lpDest);
  539. void UpdateExistingTemplates(LPTSTR lpDest);
  540. HRESULT LoadGPOTemplates (void);
  541. BOOL IsSlowLink (LPTSTR lpFileName);
  542. HRESULT AddADMFile (LPTSTR lpFileName, LPTSTR lpFullFileName,
  543. FILETIME *pFileTime, DWORD dwErr, LPRSOPADMFILE *lpHead);
  544. HRESULT LoadRSOPTemplates (void);
  545. HRESULT LoadTemplates (void);
  546. BOOL ParseTemplate (LPTSTR lpFileName);
  547. UINT ParseClass(BOOL *pfMore);
  548. TABLEENTRY * FindCategory(TABLEENTRY *pParent, LPTSTR lpName);
  549. UINT ParseEntry(PARSEENTRYSTRUCT *ppes,BOOL *pfMore, LPTSTR pKeyName);
  550. UINT ParseCategory(TABLEENTRY * pParent, BOOL fParentHasKey,BOOL *pfMore,LPTSTR pKeyName);
  551. static UINT CategoryParseProc(CPolicyComponentData *, UINT nMsg,PARSEPROCSTRUCT * ppps,
  552. BOOL * pfMore,BOOL * pfFoundEnd,LPTSTR pKeyName);
  553. UINT ParsePolicy(TABLEENTRY * pParent,
  554. BOOL fParentHasKey,BOOL *pfMore,LPTSTR pKeyName);
  555. static UINT PolicyParseProc(CPolicyComponentData *, UINT nMsg,PARSEPROCSTRUCT * ppps,
  556. BOOL * pfMore,BOOL * pfFoundEnd,LPTSTR pKeyName);
  557. UINT ParseSettings(TABLEENTRY * pParent,
  558. BOOL fParentHasKey,BOOL *pfMore,LPTSTR pKeyName);
  559. static UINT SettingsParseProc(CPolicyComponentData *pCD, UINT nMsg,PARSEPROCSTRUCT * ppps,
  560. BOOL * pfMore,BOOL * pfFoundEnd,LPTSTR pKeyName);
  561. UINT InitSettingsParse(PARSEPROCSTRUCT *ppps,DWORD dwType,DWORD dwSize,
  562. KEYWORDINFO * pKeyList,SETTINGS ** ppSettings,BYTE **ppObjectData);
  563. UINT ParseValue_W(PARSEPROCSTRUCT * ppps,TCHAR * pszWordBuf,
  564. DWORD cbWordBuf,DWORD * pdwValue,DWORD * pdwFlags,
  565. BOOL * pfMore);
  566. UINT ParseValue(PARSEPROCSTRUCT * ppps,UINT * puOffsetData,
  567. TABLEENTRY ** ppTableEntryNew,BOOL * pfMore);
  568. UINT ParseSuggestions(PARSEPROCSTRUCT * ppps,UINT * puOffsetData,
  569. TABLEENTRY ** ppTableEntryNew,BOOL * pfMore);
  570. UINT ParseActionList(PARSEPROCSTRUCT * ppps,UINT * puOffsetData,
  571. TABLEENTRY ** ppTableEntryNew,
  572. LPCTSTR pszKeyword,BOOL * pfMore);
  573. UINT ParseItemList(PARSEPROCSTRUCT * ppps,UINT * puOffsetData,
  574. BOOL * pfMore);
  575. BOOL AddActionListString(TCHAR * pszData,DWORD cbData,BYTE ** ppBase,UINT * puOffset,
  576. DWORD * pdwAlloc,DWORD *pdwUsed);
  577. BYTE * AddDataToEntry(TABLEENTRY * pTableEntry, BYTE * pData,UINT cbData,
  578. UINT * puOffsetData,DWORD * pdwBufSize);
  579. BOOL CompareKeyword(TCHAR * szWord,KEYWORDINFO *pKeywordList, UINT * pnListIndex);
  580. TCHAR * GetNextWord(TCHAR * szBuf,UINT cbBuf,BOOL * pfMore,
  581. UINT * puErr);
  582. TCHAR * GetNextSectionWord(TCHAR * szBuf,UINT cbBuf,
  583. KEYWORDINFO * pKeywordList, UINT *pnListIndex,
  584. BOOL * pfMore,UINT * puErr);
  585. UINT GetNextSectionNumericWord(UINT * pnVal);
  586. TCHAR * GetNextChar(BOOL * pfMore,UINT * puErr);
  587. BOOL GetString (LPTSTR pStringSection, LPTSTR lpStringName,
  588. LPTSTR lpResult, DWORD dwSize);
  589. BOOL IsComment(TCHAR * pBuf);
  590. BOOL IsQuote(TCHAR * pBuf);
  591. BOOL IsEndOfLine(TCHAR * pBuf);
  592. BOOL IsWhitespace(TCHAR * pBuf);
  593. BOOL IsLocalizedString(TCHAR * pBuf);
  594. VOID DisplayKeywordError(UINT uErrorID,TCHAR * szFound,KEYWORDINFO * pExpectedList);
  595. int MsgBox(HWND hWnd,UINT nResource,UINT uIcon,UINT uButtons);
  596. int MsgBoxSz(HWND hWnd,LPTSTR szText,UINT uIcon,UINT uButtons);
  597. int MsgBoxParam(HWND hWnd,UINT nResource,TCHAR * szReplaceText,UINT uIcon,UINT uButtons);
  598. LPTSTR LoadSz(UINT idString,LPTSTR lpszBuf,UINT cbBuf);
  599. UINT FindMatchingDirective(BOOL *pfMore,BOOL fElseOK);
  600. UINT ProcessIfdefs(TCHAR * pBuf,UINT cbBuf,BOOL * pfMore);
  601. BOOL FreeTable(TABLEENTRY * pTableEntry);
  602. LPTSTR GetStringSection (LPCTSTR lpSection, LPCTSTR lpFileName);
  603. static INT TemplatesSortCallback (LPARAM lParam1, LPARAM lParam2, LPARAM lColumn);
  604. BOOL FillADMFiles (HWND hDlg);
  605. BOOL InitializeTemplatesDlg (HWND hDlg);
  606. BOOL AddTemplates(HWND hDlg);
  607. BOOL RemoveTemplates(HWND hDlg);
  608. static INT_PTR CALLBACK TemplatesDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
  609. BOOL AddRSOPRegistryDataNode(LPTSTR lpKeyName, LPTSTR lpValueName, DWORD dwType,
  610. DWORD dwDataSize, LPBYTE lpData, UINT uiPrecedence,
  611. LPTSTR lpGPOName, BOOL bDeleted);
  612. VOID FreeRSOPRegistryData(VOID);
  613. HRESULT InitializeRSOPRegistryData(VOID);
  614. HRESULT GetGPOFriendlyName(IWbemServices *pIWbemServices,
  615. LPTSTR lpGPOID, BSTR pLanguage,
  616. LPTSTR *pGPOName);
  617. UINT ReadRSOPRegistryValue(HKEY uiPrecedence, TCHAR * pszKeyName,TCHAR * pszValueName,
  618. LPBYTE pData, DWORD dwMaxSize, DWORD *dwType,
  619. LPTSTR *lpGPOName, LPRSOPREGITEM lpItem);
  620. UINT EnumRSOPRegistryValues(HKEY uiPrecedence, TCHAR * pszKeyName,
  621. TCHAR * pszValueName, DWORD dwMaxSize,
  622. LPRSOPREGITEM *lpEnum);
  623. UINT FindRSOPRegistryEntry(HKEY uiPrecedence, TCHAR * pszKeyName,
  624. TCHAR * pszValueName, LPRSOPREGITEM *lpEnum);
  625. VOID DumpRSOPRegistryData (VOID);
  626. VOID InitializeExtraSettings (VOID);
  627. BOOL FindEntryInActionList(POLICY * pPolicy, ACTIONLIST *pActionList, LPTSTR lpKeyName, LPTSTR lpValueName);
  628. BOOL FindEntryInTable(TABLEENTRY * pTable, LPTSTR lpKeyName, LPTSTR lpValueName);
  629. VOID AddEntryToList (TABLEENTRY *pItem);
  630. BOOL DoesNodeExist (LPSUPPORTEDENTRY *pList, LPTSTR lpString);
  631. BOOL CheckSupportedFilter (POLICY *pPolicy);
  632. BOOL IsAnyPolicyAllowedPastFilter(TABLEENTRY * pCategory);
  633. VOID AddSupportedNode (LPSUPPORTEDENTRY *pList, LPTSTR lpString, BOOL bNull);
  634. VOID FreeSupportedData(LPSUPPORTEDENTRY lpList);
  635. VOID InitializeSupportInfo(TABLEENTRY * pTable, LPSUPPORTEDENTRY *pList);
  636. };
  637. //
  638. // ComponentData class factory
  639. //
  640. class CPolicyComponentDataCF : public IClassFactory
  641. {
  642. protected:
  643. ULONG m_cRef;
  644. BOOL m_bUser;
  645. BOOL m_bRSOP;
  646. public:
  647. CPolicyComponentDataCF(BOOL bUser, BOOL bRSOP);
  648. ~CPolicyComponentDataCF();
  649. // IUnknown methods
  650. STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
  651. STDMETHODIMP_(ULONG) AddRef();
  652. STDMETHODIMP_(ULONG) Release();
  653. // IClassFactory methods
  654. STDMETHODIMP CreateInstance(LPUNKNOWN, REFIID, LPVOID FAR *);
  655. STDMETHODIMP LockServer(BOOL);
  656. };
  657. //
  658. // SnapIn class
  659. //
  660. class CPolicySnapIn:
  661. public IComponent,
  662. public IExtendContextMenu,
  663. public IExtendPropertySheet
  664. {
  665. protected:
  666. ULONG m_cRef;
  667. LPCONSOLE m_pConsole; // Console's IFrame interface
  668. CPolicyComponentData *m_pcd;
  669. LPRESULTDATA m_pResult; // Result pane's interface
  670. LPHEADERCTRL m_pHeader; // Result pane's header control interface
  671. LPCONSOLEVERB m_pConsoleVerb; // pointer the console verb
  672. LPDISPLAYHELP m_pDisplayHelp; // IDisplayHelp interface
  673. WCHAR m_pName[40]; // Name text
  674. WCHAR m_pState[40]; // State text
  675. WCHAR m_pSetting[40]; // Setting text
  676. WCHAR m_pGPOName[40]; // GPO Name text
  677. WCHAR m_pMultipleGPOs[75]; // Multiple GPOs text
  678. INT m_nColumn1Size; // Size of column 1
  679. INT m_nColumn2Size; // Size of column 2
  680. INT m_nColumn3Size; // Size of column 3
  681. LONG m_lViewMode; // View mode
  682. WCHAR m_pEnabled[30]; // Enabled text
  683. WCHAR m_pDisabled[30]; // Disabled text
  684. WCHAR m_pNotConfigured[30]; // Not configured text
  685. BOOL m_bPolicyOnly; // Show policies only
  686. DWORD m_dwPolicyOnlyPolicy; // Policy for enforcing Show Policies Only
  687. HWND m_hMsgWindow; // Hidden message window
  688. POLICY *m_pCurrentPolicy; // Currently selected policy
  689. HWND m_hPropDlg; // Properties dialog
  690. HICON m_hPolicyIcon; // Policy icon
  691. HICON m_hPreferenceIcon; // Preference icon
  692. BOOL m_bDirty; // Has something changed in the policy UI
  693. HHOOK m_hKbdHook; // Keyboard hook handle
  694. static unsigned int m_cfNodeType;
  695. public:
  696. UINT m_uiRefreshMsg; // Reload the adm namespace
  697. CPolicySnapIn(CPolicyComponentData *pComponent);
  698. ~CPolicySnapIn();
  699. //
  700. // IUnknown methods
  701. //
  702. STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
  703. STDMETHODIMP_(ULONG) AddRef();
  704. STDMETHODIMP_(ULONG) Release();
  705. //
  706. // Implemented IComponent methods
  707. //
  708. STDMETHODIMP Initialize(LPCONSOLE);
  709. STDMETHODIMP Destroy(MMC_COOKIE);
  710. STDMETHODIMP Notify(LPDATAOBJECT, MMC_NOTIFY_TYPE, LPARAM, LPARAM);
  711. STDMETHODIMP QueryDataObject(MMC_COOKIE, DATA_OBJECT_TYPES, LPDATAOBJECT *);
  712. STDMETHODIMP GetDisplayInfo(LPRESULTDATAITEM);
  713. STDMETHODIMP GetResultViewType(MMC_COOKIE, LPOLESTR*, long*);
  714. STDMETHODIMP CompareObjects(LPDATAOBJECT, LPDATAOBJECT);
  715. //
  716. // Implemented IExtendContextMenu methods
  717. //
  718. STDMETHODIMP AddMenuItems(LPDATAOBJECT piDataObject, LPCONTEXTMENUCALLBACK pCallback,
  719. LONG *pInsertionAllowed);
  720. STDMETHODIMP Command(LONG lCommandID, LPDATAOBJECT piDataObject);
  721. //
  722. // Implemented IExtendPropertySheet methods
  723. //
  724. STDMETHODIMP CreatePropertyPages(LPPROPERTYSHEETCALLBACK lpProvider,
  725. LONG_PTR handle, LPDATAOBJECT lpDataObject);
  726. STDMETHODIMP QueryPagesFor(LPDATAOBJECT lpDataObject);
  727. BOOL IsAnyPolicyEnabled(TABLEENTRY * pCategory);
  728. private:
  729. VOID RefreshSettingsControls(HWND hDlg);
  730. HRESULT UpdateItemWorker (VOID);
  731. HRESULT MoveFocusWorker (BOOL bPrevious);
  732. HRESULT MoveFocus (HWND hDlg, BOOL bPrevious);
  733. HRESULT SetPrevNextButtonState (HWND hDlg);
  734. HRESULT SetPrevNextButtonStateWorker (HWND hDlg);
  735. static INT_PTR CALLBACK PolicyDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
  736. static INT_PTR CALLBACK PolicyHelpDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
  737. static INT_PTR CALLBACK PolicyPrecedenceDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
  738. static LRESULT CALLBACK KeyboardHookProc(int nCode, WPARAM wParam,LPARAM lParam);
  739. VOID SetKeyboardHook(HWND hDlg);
  740. VOID RemoveKeyboardHook(VOID);
  741. INT GetPolicyState (TABLEENTRY *pTableEntry, UINT uiPrecedence, LPTSTR *lpGPOName);
  742. BOOL CheckActionList (POLICY * pPolicy, HKEY hKeyRoot, BOOL bActionListOn, LPTSTR *lpGPOName);
  743. UINT LoadSettings(TABLEENTRY * pTableEntry,HKEY hkeyRoot,
  744. DWORD * pdwFound, LPTSTR *lpGPOName);
  745. UINT LoadListboxData(TABLEENTRY * pTableEntry,HKEY hkeyRoot,
  746. TCHAR * pszCurrentKeyName,DWORD * pdwFound, HGLOBAL * phGlobal, LPTSTR *lpGPOName);
  747. BOOL ReadCustomValue(HKEY hkeyRoot,TCHAR * pszKeyName,TCHAR * pszValueName,
  748. TCHAR * pszValue,UINT cbValue,DWORD * pdwValue,DWORD * pdwFlags,LPTSTR *lpGPOName);
  749. BOOL CompareCustomValue(HKEY hkeyRoot,TCHAR * pszKeyName,TCHAR * pszValueName,
  750. STATEVALUE * pStateValue,DWORD * pdwFound, LPTSTR *lpGPOName);
  751. BOOL ReadStandardValue(HKEY hkeyRoot,TCHAR * pszKeyName,TCHAR * pszValueName,
  752. TABLEENTRY * pTableEntry,DWORD * pdwData,DWORD * pdwFound, LPTSTR *lpGPOName);
  753. VOID PrependValueName(TCHAR * pszValueName,DWORD dwFlags,TCHAR * pszNewValueName,
  754. UINT cbNewValueName);
  755. UINT WriteRegistryDWordValue(HKEY hkeyRoot,TCHAR * pszKeyName,TCHAR * pszValueName, DWORD dwValue);
  756. UINT ReadRegistryDWordValue(HKEY hkeyRoot,TCHAR * pszKeyName,TCHAR * pszValueName,
  757. DWORD * pdwValue, LPTSTR *lpGPOName);
  758. UINT WriteRegistryStringValue(HKEY hkeyRoot,TCHAR * pszKeyName,TCHAR * pszValueName,
  759. TCHAR * pszValue, BOOL bExpandable);
  760. UINT ReadRegistryStringValue(HKEY hkeyRoot,TCHAR * pszKeyName,TCHAR * pszValueName,
  761. TCHAR * pszValue,UINT cbValue, LPTSTR *lpGPOName);
  762. UINT DeleteRegistryValue(HKEY hkeyRoot,TCHAR * pszKeyName,TCHAR * pszValueName);
  763. UINT WriteCustomValue_W(HKEY hkeyRoot,TCHAR * pszKeyName,TCHAR * pszValueName,
  764. TCHAR * pszValue,DWORD dwValue,DWORD dwFlags,BOOL fErase);
  765. UINT WriteCustomValue(HKEY hkeyRoot,TCHAR * pszKeyName,TCHAR * pszValueName,
  766. STATEVALUE * pStateValue,BOOL fErase);
  767. UINT WriteStandardValue(HKEY hkeyRoot,TCHAR * pszKeyName,TCHAR * pszValueName,
  768. TABLEENTRY * pTableEntry,DWORD dwData,BOOL fErase,
  769. BOOL fWriteZero);
  770. TCHAR * ResizeBuffer(TCHAR *pBuf,HGLOBAL hBuf,DWORD dwNeeded,DWORD * pdwCurSize);
  771. static LRESULT CALLBACK MessageWndProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam);
  772. static LRESULT CALLBACK ClipWndProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam);
  773. VOID ProcessCommand(HWND hWnd,WPARAM wParam,HWND hwndCtrl, POLICYDLGINFO * pdi);
  774. VOID EnsureSettingControlVisible(HWND hDlg,HWND hwndCtrl);
  775. VOID ProcessScrollBar(HWND hWnd,WPARAM wParam,BOOL bVert);
  776. VOID FreeSettingsControls(HWND hDlg);
  777. VOID InsertComboboxItems(HWND hwndControl,TCHAR * pSuggestionList);
  778. BOOL CreateSettingsControls(HWND hDlg,SETTINGS * pSetting,BOOL fEnable);
  779. HWND CreateSetting(POLICYDLGINFO * pdi,TCHAR * pszClassName,TCHAR * pszWindowName,
  780. DWORD dwExStyle,DWORD dwStyle,int x,int y,int cx,int cy,DWORD dwType,UINT uIndex,
  781. SETTINGS * pSetting, HFONT hFontDlg);
  782. BOOL SetWindowData(POLICYDLGINFO * pdi,HWND hwndControl,DWORD dwType,
  783. UINT uDataIndex,SETTINGS * pSetting);
  784. int AddControlHwnd(POLICYDLGINFO * pdi,POLICYCTRLINFO * pPolicyCtrlInfo);
  785. BOOL AdjustWindowToText(HWND hWnd,TCHAR * szText,UINT xStart,UINT yStart,
  786. UINT yPad,UINT * pnWidth,UINT * pnHeight, HFONT hFontDlg);
  787. BOOL GetTextSize(HWND hWnd,TCHAR * szText,SIZE * pSize, HFONT hFontDlg);
  788. HRESULT SaveSettings(HWND hDlg);
  789. VOID DeleteOldListboxData(SETTINGS * pSetting,HKEY hkeyRoot, TCHAR * pszCurrentKeyName);
  790. UINT SaveListboxData(HGLOBAL hData,SETTINGS * pSetting,HKEY hkeyRoot,
  791. TCHAR * pszCurrentKeyName,BOOL fErase,BOOL fMarkDeleted, BOOL bEnabled, BOOL *bFoundNone);
  792. UINT ProcessCheckboxActionLists(HKEY hkeyRoot,TABLEENTRY * pTableEntry,
  793. TCHAR * pszCurrentKeyName,DWORD dwData,
  794. BOOL fErase, BOOL fMarkAsDeleted,BOOL bPolicy);
  795. UINT WriteActionList(HKEY hkeyRoot,ACTIONLIST * pActionList,
  796. LPTSTR pszCurrentKeyName,BOOL fErase, BOOL fMarkAsDeleted);
  797. int FindComboboxItemData(HWND hwndControl,UINT nData);
  798. HRESULT InitializeSettingsControls(HWND hDlg, BOOL fEnable);
  799. VOID ShowListbox(HWND hParent,SETTINGS * pSettings);
  800. static INT_PTR CALLBACK ShowListboxDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam,
  801. LPARAM lParam);
  802. BOOL InitShowlistboxDlg(HWND hDlg);
  803. BOOL ProcessShowlistboxDlg(HWND hDlg);
  804. VOID EnableShowListboxButtons(HWND hDlg);
  805. VOID ListboxRemove(HWND hDlg,HWND hwndListbox);
  806. VOID ListboxAdd(HWND hwndListbox, BOOL fExplicitValName,BOOL fValuePrefix);
  807. static INT_PTR CALLBACK ListboxAddDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
  808. void InitializeFilterDialog (HWND hDlg);
  809. static INT_PTR CALLBACK FilterDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
  810. LRESULT CallNextHook(int nCode, WPARAM wParam, LPARAM lParam);
  811. };
  812. //
  813. // Structure passed to Settings / Properties dialog
  814. //
  815. typedef struct tagSETTINGSINFO {
  816. CPolicySnapIn * pCS;
  817. POLICYDLGINFO * pdi;
  818. HFONT hFontDlg;
  819. } SETTINGSINFO, *LPSETTINGSINFO;
  820. //
  821. // From listbox.c
  822. //
  823. typedef struct tagLISTBOXDLGINFO {
  824. CPolicySnapIn * pCS;
  825. SETTINGS * pSettings;
  826. HGLOBAL hData;
  827. } LISTBOXDLGINFO;
  828. typedef struct tagADDITEMINFO {
  829. CPolicySnapIn * pCS;
  830. BOOL fExplicitValName;
  831. BOOL fValPrefix;
  832. HWND hwndListbox;
  833. TCHAR szValueName[MAX_PATH+1]; // only used if fExplicitValName is set
  834. TCHAR szValueData[MAX_PATH+1];
  835. } ADDITEMINFO;
  836. //
  837. // IPolicyDataObject interface id
  838. //
  839. // {0F6B9580-509E-11d1-A7CC-0000F87571E3}
  840. DEFINE_GUID(IID_IPolicyDataObject,0xf6b9580, 0x509e, 0x11d1, 0xa7, 0xcc, 0x0, 0x0, 0xf8, 0x75, 0x71, 0xe3);
  841. //
  842. // This is a private dataobject interface for GPTs.
  843. // When the GPT snapin receives a dataobject and needs to determine
  844. // if it came from the GPT snapin or a different component, it can QI for
  845. // this interface.
  846. //
  847. #undef INTERFACE
  848. #define INTERFACE IPolicyDataObject
  849. DECLARE_INTERFACE_(IPolicyDataObject, IUnknown)
  850. {
  851. // *** IUnknown methods ***
  852. STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID * ppvObj) PURE;
  853. STDMETHOD_(ULONG,AddRef) (THIS) PURE;
  854. STDMETHOD_(ULONG,Release) (THIS) PURE;
  855. // *** IPolicyDataObject methods ***
  856. STDMETHOD(SetType) (THIS_ DATA_OBJECT_TYPES type) PURE;
  857. STDMETHOD(GetType) (THIS_ DATA_OBJECT_TYPES *type) PURE;
  858. STDMETHOD(SetCookie) (THIS_ MMC_COOKIE cookie) PURE;
  859. STDMETHOD(GetCookie) (THIS_ MMC_COOKIE *cookie) PURE;
  860. };
  861. typedef IPolicyDataObject *LPPOLICYDATAOBJECT;
  862. //
  863. // CPolicyDataObject class
  864. //
  865. class CPolicyDataObject : public IDataObject,
  866. public IPolicyDataObject
  867. {
  868. friend class CPolicySnapIn;
  869. protected:
  870. ULONG m_cRef;
  871. CPolicyComponentData *m_pcd;
  872. DATA_OBJECT_TYPES m_type;
  873. MMC_COOKIE m_cookie;
  874. //
  875. // Clipboard formats that are required by the console
  876. //
  877. static unsigned int m_cfNodeType;
  878. static unsigned int m_cfNodeTypeString;
  879. static unsigned int m_cfDisplayName;
  880. static unsigned int m_cfCoClass;
  881. static unsigned int m_cfDescription;
  882. static unsigned int m_cfHTMLDetails;
  883. public:
  884. CPolicyDataObject(CPolicyComponentData *pComponent);
  885. ~CPolicyDataObject();
  886. //
  887. // IUnknown methods
  888. //
  889. STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
  890. STDMETHODIMP_(ULONG) AddRef();
  891. STDMETHODIMP_(ULONG) Release();
  892. //
  893. // Implemented IDataObject methods
  894. //
  895. STDMETHOD(GetDataHere)(LPFORMATETC lpFormatetc, LPSTGMEDIUM lpMedium);
  896. //
  897. // Unimplemented IDataObject methods
  898. //
  899. STDMETHOD(GetData)(LPFORMATETC lpFormatetcIn, LPSTGMEDIUM lpMedium)
  900. { return E_NOTIMPL; };
  901. STDMETHOD(EnumFormatEtc)(DWORD dwDirection, LPENUMFORMATETC* ppEnumFormatEtc)
  902. { return E_NOTIMPL; };
  903. STDMETHOD(QueryGetData)(LPFORMATETC lpFormatetc)
  904. { return E_NOTIMPL; };
  905. STDMETHOD(GetCanonicalFormatEtc)(LPFORMATETC lpFormatetcIn, LPFORMATETC lpFormatetcOut)
  906. { return E_NOTIMPL; };
  907. STDMETHOD(SetData)(LPFORMATETC lpFormatetc, LPSTGMEDIUM lpMedium, BOOL bRelease)
  908. { return E_NOTIMPL; };
  909. STDMETHOD(DAdvise)(LPFORMATETC lpFormatetc, DWORD advf,
  910. LPADVISESINK pAdvSink, LPDWORD pdwConnection)
  911. { return E_NOTIMPL; };
  912. STDMETHOD(DUnadvise)(DWORD dwConnection)
  913. { return E_NOTIMPL; };
  914. STDMETHOD(EnumDAdvise)(LPENUMSTATDATA* ppEnumAdvise)
  915. { return E_NOTIMPL; };
  916. //
  917. // Implemented IPolicyDataObject methods
  918. //
  919. STDMETHOD(SetType) (DATA_OBJECT_TYPES type)
  920. { m_type = type; return S_OK; };
  921. STDMETHOD(GetType) (DATA_OBJECT_TYPES *type)
  922. { *type = m_type; return S_OK; };
  923. STDMETHOD(SetCookie) (MMC_COOKIE cookie)
  924. { m_cookie = cookie; return S_OK; };
  925. STDMETHOD(GetCookie) (MMC_COOKIE *cookie)
  926. { *cookie = m_cookie; return S_OK; };
  927. private:
  928. HRESULT CreateNodeTypeData(LPSTGMEDIUM lpMedium);
  929. HRESULT CreateNodeTypeStringData(LPSTGMEDIUM lpMedium);
  930. HRESULT CreateDisplayName(LPSTGMEDIUM lpMedium);
  931. HRESULT CreateCoClassID(LPSTGMEDIUM lpMedium);
  932. HRESULT Create(LPVOID pBuffer, INT len, LPSTGMEDIUM lpMedium);
  933. };
  934. VOID LoadMessage (DWORD dwID, LPTSTR lpBuffer, DWORD dwSize);
  935. BOOL ReportAdmError (HWND hParent, DWORD dwError, UINT idMsg, ...);