Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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