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.

373 lines
10 KiB

  1. #ifndef RC_INVOKED
  2. #include <nt.h>
  3. #include <ntrtl.h>
  4. #include <nturtl.h>
  5. #endif
  6. #include <windows.h>
  7. #include <lm.h>
  8. #include <ole2.h>
  9. #include <olectl.h>
  10. #include <shellapi.h>
  11. #include <shlobj.h>
  12. #include <commctrl.h>
  13. #include <commdlg.h>
  14. #include <prsht.h>
  15. #include <mmc.h>
  16. #include <activeds.h>
  17. #include <gpedit.h>
  18. #define _USERENV_NO_LINK_APIS_ 1
  19. #include <userenv.h>
  20. #include <userenvp.h>
  21. #include <wbemcli.h>
  22. #include <tchar.h>
  23. #include <winsock2.h>
  24. class CScriptsSnapIn;
  25. class CPolicyComponentData;
  26. #include "debug.h"
  27. #include "util.h"
  28. //
  29. // From comctrlp.h
  30. //
  31. #if (_WIN32_IE >= 0x0501)
  32. #define UDS_UNSIGNED 0x0200
  33. #endif
  34. //
  35. // Resource ids
  36. //
  37. #define IDS_SCRIPTS_NAME 1
  38. #define IDS_SCRIPTS_NAME_MACHINE 2
  39. #define IDS_SCRIPTS_NAME_USER 3
  40. #define IDS_NAME 4
  41. #define IDS_STATE 5
  42. #define IDS_SETTING 6
  43. #define IDS_PARAMETERS 7
  44. #define IDS_ENABLED 8
  45. #define IDS_DISABLED 9
  46. #define IDS_NOTCONFIGURED 10
  47. #define IDS_LOGON 11
  48. #define IDS_LOGOFF 12
  49. #define IDS_STARTUP 13
  50. #define IDS_SHUTDOWN 14
  51. #define IDS_BROWSEFILTER 15
  52. #define IDS_BROWSE 16
  53. #define IDS_SCRIPT_EDIT 17
  54. #define IDS_SCRIPT_FILTER 18
  55. #define IDS_POLICY_NAME 19
  56. #define IDS_POLICY_NAME_MACHINE 20
  57. #define IDS_POLICY_NAME_USER 21
  58. #define IDS_TEMPLATES 22
  59. #define IDS_TEMPLATESDESC 23
  60. #define IDS_SIZE 24
  61. #define IDS_MODIFIED 25
  62. #define IDS_POLICYFILTER 26
  63. #define IDS_POLICYTITLE 27
  64. #define IDS_DEFAULTTEMPLATES 28
  65. #define IDS_LISTBOX_SHOW 29
  66. #define IDS_VALUE 31
  67. #define IDS_VALUENAME 32
  68. #define IDS_VALUENAMENOTUNIQUE 33
  69. #define IDS_EMPTYVALUENAME 34
  70. #define IDS_VALUEDATANOTUNIQUE 35
  71. #define IDS_EMPTYVALUEDATA 36
  72. #define IDS_FILTERING 37
  73. #define IDS_FILTERINGDESC 38
  74. #define IDS_ADDITIONALTTEMPLATES 39
  75. #define IDS_GPONAME 41
  76. #define IDS_MULTIPLEGPOS 42
  77. #define IDS_DESCTEXT 43
  78. #define IDS_LASTEXECUTED 44
  79. #define IDS_SAVEFAILED 45
  80. #define IDS_DISPLAYPROPERTIES 46
  81. #define IDS_EXTRAREGSETTINGS 47
  82. #define IDS_STRINGTOOLONG 48
  83. #define IDS_WORDTOOLONG 49
  84. #define IDS_ErrOUTOFMEMORY 50
  85. #define IDS_ParseErr_UNEXPECTED_KEYWORD 51
  86. #define IDS_ParseErr_UNEXPECTED_EOF 52
  87. #define IDS_ParseErr_DUPLICATE_KEYNAME 53
  88. #define IDS_ParseErr_DUPLICATE_VALUENAME 54
  89. #define IDS_ParseErr_NO_KEYNAME 55
  90. #define IDS_ParseErr_NO_VALUENAME 56
  91. #define IDS_ParseErr_NO_VALUE 57
  92. #define IDS_ParseErr_NOT_NUMERIC 58
  93. #define IDS_ParseErr_DUPLICATE_ITEMNAME 59
  94. #define IDS_ParseErr_NO_ITEMNAME 60
  95. #define IDS_ParseErr_DUPLICATE_ACTIONLIST 61
  96. #define IDS_ParseErr_STRING_NOT_FOUND 62
  97. #define IDS_ParseErr_UNMATCHED_DIRECTIVE 63
  98. #define IDS_ParseErr_DUPLICATE_HELP 64
  99. #define IDS_ParseErr_DUPLICATE_CLIENTEXT 65
  100. #define IDS_ParseErr_INVALID_CLIENTEXT 66
  101. #define IDS_ParseErr_DUPLICATE_SUPPORTED 67
  102. #define IDS_ParseErr_MISSINGVALUEON_OR_OFF 68
  103. #define IDS_ParseFmt_MSG_FORMAT 90
  104. #define IDS_ParseFmt_FOUND 91
  105. #define IDS_ParseFmt_EXPECTED 92
  106. #define IDS_ParseFmt_FATAL 93
  107. #define IDS_ENTRYREQUIRED 100
  108. #define IDS_INVALIDNUM 101
  109. #define IDS_NUMBERTOOLARGE 102
  110. #define IDS_NUMBERTOOSMALL 103
  111. #define IDS_POLICYCHANGEDFAILED 104
  112. #define IDS_INVALIDADMFILE 105
  113. #define IDS_IPSEC_NAME 200
  114. #define IDS_PSCHED_NAME 201
  115. #define IDS_LOGON_DESC 225
  116. #define IDS_LOGOFF_DESC 226
  117. #define IDS_STARTUP_DESC 227
  118. #define IDS_SHUTDOWN_DESC 228
  119. #define IDS_SCRIPTS_DESC 229
  120. #define IDS_SCRIPTS_USER_DESC 230
  121. #define IDS_SCRIPTS_COMPUTER_DESC 231
  122. #define IDS_SCRIPTS_LOGON 232
  123. #define IDS_SCRIPTS_LOGOFF 233
  124. #define IDS_SCRIPTS_STARTUP 234
  125. #define IDS_SCRIPTS_SHUTDOWN 235
  126. #define IDS_POLICY_DESC 236
  127. #define IDS_NONE 237
  128. #define IDS_RSOP_ADMFAILED 238
  129. #define IDS_BINARYDATA 240
  130. #define IDS_UNKNOWNDATA 241
  131. #define IDS_EXSETROOT_DESC 242
  132. #define IDS_EXSET_DESC 243
  133. #define IDS_PREFERENCE 246
  134. #define IDS_SUPPORTEDDESC 247
  135. #define IDS_NOSUPPORTINFO 248
  136. #define IDS_FAILED_RSOPFMT 250
  137. //
  138. // Menus
  139. //
  140. #define IDM_TEMPLATES 1
  141. #define IDM_TEMPLATES2 3
  142. #define IDM_FILTERING 4
  143. //
  144. // Icons
  145. //
  146. #define IDI_POLICY 1
  147. #define IDI_POLICY2 2
  148. #define IDI_POLICY3 3
  149. #define IDI_DOCUMENT 4
  150. #define IDI_SCRIPT 5
  151. #define IDI_FILTER 6
  152. //
  153. // Bitmaps
  154. //
  155. #define IDB_16x16 1
  156. #define IDB_32x32 2
  157. //
  158. // Dialogs
  159. //
  160. #define IDD_SCRIPT 100
  161. #define IDC_SCRIPT_TITLE 101
  162. #define IDC_SCRIPT_HEADING 102
  163. #define IDC_SCRIPT_LIST 103
  164. #define IDC_SCRIPT_UP 104
  165. #define IDC_SCRIPT_DOWN 105
  166. #define IDC_SCRIPT_ADD 106
  167. #define IDC_SCRIPT_EDIT 107
  168. #define IDC_SCRIPT_REMOVE 108
  169. #define IDC_SCRIPT_SHOW 109
  170. #define IDD_SCRIPT_EDIT 150
  171. #define IDC_SCRIPT_NAME 151
  172. #define IDC_SCRIPT_ARGS 152
  173. #define IDC_SCRIPT_BROWSE 153
  174. #define IDD_POLICY 200
  175. #define IDC_POLICY 201
  176. #define IDC_POLICY_TITLE 202
  177. #define IDC_POLICY_SETTINGS 203
  178. #define IDC_POLICY_PREVIOUS 204
  179. #define IDC_POLICY_NEXT 205
  180. #define IDC_POLICYICON 206
  181. #define IDC_NOCONFIG 207
  182. #define IDC_ENABLED 208
  183. #define IDC_DISABLED 209
  184. #define IDC_SUPPORTED 210
  185. #define IDC_SUPPORTEDTITLE 211
  186. #define IDD_SETTINGCTRL 1000
  187. #define IDD_POLICY_HELP 225
  188. #define IDC_POLICY_HELP 226
  189. #define IDD_POLICY_PRECEDENCE 275
  190. #define IDC_POLICY_PRECEDENCE 276
  191. #define IDD_TEMPLATES 300
  192. #define IDC_TEMPLATE_TEXT 301
  193. #define IDC_TEMPLATELIST 302
  194. #define IDC_ADDTEMPLATES 303
  195. #define IDC_REMOVETEMPLATES 304
  196. #define IDD_POLICY_LBADD 400
  197. #define IDD_POLICY_LBADD2 401
  198. #define IDC_POLICY_VALUENAME 402
  199. #define IDC_POLICY_VALUEDATA 403
  200. #define IDD_POLICY_SHOWLISTBOX 500
  201. #define IDC_POLICY_LISTBOX 501
  202. #define IDC_POLICY_ADD 502
  203. #define IDC_POLICY_REMOVE 503
  204. #define IDD_POLICY_FILTERING 600
  205. #define IDC_SUPPORTEDOPTION 601
  206. #define IDC_FILTERLIST 602
  207. #define IDC_SELECTALL 603
  208. #define IDC_DESELECTALL 604
  209. #define IDC_SHOWCONFIG 605
  210. #define IDC_SHOWPOLICIES 606
  211. #define IDC_SUPPORTEDONTITLE 607
  212. #define IDC_STATIC 608
  213. #define IDC_FILTERING_ICON 609
  214. //
  215. // Help ids
  216. //
  217. #define IDH_SCRIPT_TITLE 1
  218. #define IDH_SCRIPT_HEADING 2
  219. #define IDH_SCRIPT_LIST 3
  220. #define IDH_SCRIPT_UP 4
  221. #define IDH_SCRIPT_DOWN 5
  222. #define IDH_SCRIPT_ADD 6
  223. #define IDH_SCRIPT_EDIT 7
  224. #define IDH_SCRIPT_REMOVE 8
  225. #define IDH_SCRIPT_SHOW 9
  226. #define IDH_SCRIPT_NAME 10
  227. #define IDH_SCRIPT_ARGS 11
  228. #define IDH_SCRIPT_BROWSE 12
  229. //
  230. // Error dialog defines
  231. //
  232. #define IDD_ERROR_ADMTEMPLATES 800
  233. #define IDC_ERRORTEXT 801
  234. #define IDC_DETAILSBORDER 802
  235. #define IDC_DETAILSTEXT 803
  236. #define IDC_ERROR_ICON 804
  237. //
  238. // Global variables
  239. //
  240. extern LONG g_cRefThisDll;
  241. extern HINSTANCE g_hInstance;
  242. extern TCHAR g_szSnapInLocation[];
  243. extern CRITICAL_SECTION g_ADMCritSec;
  244. extern TCHAR g_szDisplayProperties[];
  245. //
  246. // Macros
  247. //
  248. #define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0]))
  249. #ifndef NORM_STOP_ON_NULL
  250. #define NORM_STOP_ON_NULL 0x10000000
  251. #endif
  252. //
  253. // Help
  254. //
  255. #define HELP_FILE TEXT("gptext.hlp")
  256. #define IDH_HELPFIRST 5000
  257. //
  258. // Structures
  259. //
  260. #define MAX_DISPLAYNAME_SIZE 100
  261. typedef struct _RESULTITEM
  262. {
  263. DWORD dwID;
  264. DWORD dwNameSpaceItem;
  265. INT iStringID;
  266. INT iDescStringID;
  267. INT iImage;
  268. TCHAR szDisplayName[MAX_DISPLAYNAME_SIZE];
  269. } RESULTITEM, *LPRESULTITEM;
  270. typedef struct _NAMESPACEITEM
  271. {
  272. DWORD dwID;
  273. DWORD dwParent;
  274. INT iStringID;
  275. INT iDescStringID;
  276. INT cChildren;
  277. TCHAR szDisplayName[MAX_DISPLAYNAME_SIZE];
  278. INT cResultItems;
  279. LPRESULTITEM pResultItems;
  280. const GUID *pNodeID;
  281. } NAMESPACEITEM, *LPNAMESPACEITEM;
  282. //
  283. // Functions to create class factories
  284. //
  285. HRESULT CreateScriptsComponentDataClassFactory (REFCLSID rclsid, REFIID riid, LPVOID* ppv);
  286. BOOL InitScriptsNameSpace();
  287. HRESULT RegisterScripts(void);
  288. HRESULT UnregisterScripts(void);
  289. HRESULT CreatePolicyComponentDataClassFactory (REFCLSID rclsid, REFIID riid, LPVOID* ppv);
  290. HRESULT RegisterPolicy(void);
  291. HRESULT UnregisterPolicy(void);
  292. HRESULT RegisterIPSEC(void);
  293. HRESULT UnregisterIPSEC(void);
  294. HRESULT RegisterPSCHED(void);
  295. HRESULT UnregisterPSCHED(void);
  296. HRESULT RegisterWireless(void);
  297. HRESULT UnregisterWireless(void);
  298. //
  299. // Private message that refreshes the button status
  300. //
  301. #define WM_REFRESHDISPLAY (WM_USER + 532)