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.

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