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.

410 lines
12 KiB

  1. //
  2. // GPE Script SnapIn extension GUIDs
  3. //
  4. // {40B6664F-4972-11d1-A7CA-0000F87571E3}
  5. DEFINE_GUID(CLSID_ScriptSnapInMachine,0x40b6664f, 0x4972, 0x11d1, 0xa7, 0xca, 0x0, 0x0, 0xf8, 0x75, 0x71, 0xe3);
  6. // {40B66650-4972-11d1-A7CA-0000F87571E3}
  7. DEFINE_GUID(CLSID_ScriptSnapInUser,0x40b66650, 0x4972, 0x11d1, 0xa7, 0xca, 0x0, 0x0, 0xf8, 0x75, 0x71, 0xe3);
  8. //
  9. // GPE Script node ids
  10. //
  11. // {40B66651-4972-11d1-A7CA-0000F87571E3}
  12. DEFINE_GUID(NODEID_ScriptRootMachine,0x40b66651, 0x4972, 0x11d1, 0xa7, 0xca, 0x0, 0x0, 0xf8, 0x75, 0x71, 0xe3);
  13. // {40B66652-4972-11d1-A7CA-0000F87571E3}
  14. DEFINE_GUID(NODEID_ScriptRootUser,0x40b66652, 0x4972, 0x11d1, 0xa7, 0xca, 0x0, 0x0, 0xf8, 0x75, 0x71, 0xe3);
  15. // {40B66653-4972-11d1-A7CA-0000F87571E3}
  16. DEFINE_GUID(NODEID_ScriptRoot,0x40b66653, 0x4972, 0x11d1, 0xa7, 0xca, 0x0, 0x0, 0xf8, 0x75, 0x71, 0xe3);
  17. //
  18. // RSOP Script SnapIn extension GUIDs
  19. //
  20. // {40B66660-4972-11d1-A7CA-0000F87571E3}
  21. DEFINE_GUID(CLSID_RSOPScriptSnapInMachine,0x40b66660, 0x4972, 0x11d1, 0xa7, 0xca, 0x0, 0x0, 0xf8, 0x75, 0x71, 0xe3);
  22. // {40B66661-4972-11d1-A7CA-0000F87571E3}
  23. DEFINE_GUID(CLSID_RSOPScriptSnapInUser,0x40b66661, 0x4972, 0x11d1, 0xa7, 0xca, 0x0, 0x0, 0xf8, 0x75, 0x71, 0xe3);
  24. //
  25. // RSOP Script node ids
  26. //
  27. // {40B66662-4972-11d1-A7CA-0000F87571E3}
  28. DEFINE_GUID(NODEID_RSOPScriptRootMachine,0x40b66662, 0x4972, 0x11d1, 0xa7, 0xca, 0x0, 0x0, 0xf8, 0x75, 0x71, 0xe3);
  29. // {40B66663-4972-11d1-A7CA-0000F87571E3}
  30. DEFINE_GUID(NODEID_RSOPScriptRootUser,0x40b66663, 0x4972, 0x11d1, 0xa7, 0xca, 0x0, 0x0, 0xf8, 0x75, 0x71, 0xe3);
  31. // {40B66664-4972-11d1-A7CA-0000F87571E3}
  32. DEFINE_GUID(NODEID_RSOPScriptRoot,0x40b66664, 0x4972, 0x11d1, 0xa7, 0xca, 0x0, 0x0, 0xf8, 0x75, 0x71, 0xe3);
  33. // {40B66665-4972-11d1-A7CA-0000F87571E3}
  34. DEFINE_GUID(NODEID_RSOPLogon,0x40b66665, 0x4972, 0x11d1, 0xa7, 0xca, 0x0, 0x0, 0xf8, 0x75, 0x71, 0xe3);
  35. // {40B66666-4972-11d1-A7CA-0000F87571E3}
  36. DEFINE_GUID(NODEID_RSOPLogoff,0x40b66666, 0x4972, 0x11d1, 0xa7, 0xca, 0x0, 0x0, 0xf8, 0x75, 0x71, 0xe3);
  37. // {40B66667-4972-11d1-A7CA-0000F87571E3}
  38. DEFINE_GUID(NODEID_RSOPStartup,0x40b66667, 0x4972, 0x11d1, 0xa7, 0xca, 0x0, 0x0, 0xf8, 0x75, 0x71, 0xe3);
  39. // {40B66668-4972-11d1-A7CA-0000F87571E3}
  40. DEFINE_GUID(NODEID_RSOPShutdown,0x40b66668, 0x4972, 0x11d1, 0xa7, 0xca, 0x0, 0x0, 0xf8, 0x75, 0x71, 0xe3);
  41. //
  42. // RSOP link list data structures
  43. //
  44. typedef struct tagRSOPSCRIPTITEM {
  45. LPTSTR lpCommandLine;
  46. LPTSTR lpArgs;
  47. LPTSTR lpGPOName;
  48. LPTSTR lpDate;
  49. struct tagRSOPSCRIPTITEM * pNext;
  50. } RSOPSCRIPTITEM, *LPRSOPSCRIPTITEM;
  51. typedef struct tagSCRIPTRESULTITEM {
  52. LPRESULTITEM lpResultItem;
  53. LPRSOPSCRIPTITEM lpRSOPScriptItem;
  54. const GUID *pNodeID;
  55. INT iDescStringID;
  56. } SCRIPTRESULTITEM, *LPSCRIPTRESULTITEM;
  57. //
  58. // CScriptsComponentData class
  59. //
  60. class CScriptsComponentData:
  61. public IComponentData,
  62. public IPersistStreamInit,
  63. public ISnapinHelp {
  64. friend class CScriptsDataObject;
  65. friend class CScriptsSnapIn;
  66. protected:
  67. ULONG m_cRef;
  68. BOOL m_bUserScope;
  69. BOOL m_bRSOP;
  70. HWND m_hwndFrame;
  71. LPCONSOLENAMESPACE m_pScope;
  72. LPCONSOLE2 m_pConsole;
  73. HSCOPEITEM m_hRoot;
  74. LPGPEINFORMATION m_pGPTInformation;
  75. LPRSOPINFORMATION m_pRSOPInformation;
  76. LPTSTR m_pScriptsDir;
  77. LPOLESTR m_pszNamespace;
  78. LPNAMESPACEITEM m_pNameSpaceItems;
  79. DWORD m_dwNameSpaceItemCount;
  80. LPRSOPSCRIPTITEM m_pRSOPLogon;
  81. LPRSOPSCRIPTITEM m_pRSOPLogoff;
  82. LPRSOPSCRIPTITEM m_pRSOPStartup;
  83. LPRSOPSCRIPTITEM m_pRSOPShutdown;
  84. public:
  85. CScriptsComponentData(BOOL bUser, BOOL bRSOP);
  86. ~CScriptsComponentData();
  87. // IUnknown methods
  88. STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
  89. STDMETHODIMP_(ULONG) AddRef();
  90. STDMETHODIMP_(ULONG) Release();
  91. //
  92. // Implemented IComponentData methods
  93. //
  94. STDMETHODIMP Initialize(LPUNKNOWN pUnknown);
  95. STDMETHODIMP CreateComponent(LPCOMPONENT* ppComponent);
  96. STDMETHODIMP QueryDataObject(MMC_COOKIE cookie, DATA_OBJECT_TYPES type, LPDATAOBJECT* ppDataObject);
  97. STDMETHODIMP Destroy(void);
  98. STDMETHODIMP Notify(LPDATAOBJECT lpDataObject, MMC_NOTIFY_TYPE event, LPARAM arg, LPARAM param);
  99. STDMETHODIMP GetDisplayInfo(LPSCOPEDATAITEM pItem);
  100. STDMETHODIMP CompareObjects(LPDATAOBJECT lpDataObjectA, LPDATAOBJECT lpDataObjectB);
  101. //
  102. // Implemented IPersistStreamInit interface members
  103. //
  104. STDMETHODIMP GetClassID(CLSID *pClassID);
  105. STDMETHODIMP IsDirty(VOID);
  106. STDMETHODIMP Load(IStream *pStm);
  107. STDMETHODIMP Save(IStream *pStm, BOOL fClearDirty);
  108. STDMETHODIMP GetSizeMax(ULARGE_INTEGER *pcbSize);
  109. STDMETHODIMP InitNew(VOID);
  110. //
  111. // Implemented ISnapinHelp interface members
  112. //
  113. STDMETHODIMP GetHelpTopic(LPOLESTR *lpCompiledHelpFile);
  114. private:
  115. HRESULT EnumerateScopePane(LPDATAOBJECT lpDataObject, HSCOPEITEM hParent);
  116. BOOL AddRSOPScriptDataNode(LPTSTR lpCommandLine, LPTSTR lpArgs,
  117. LPTSTR lpGPOName, LPTSTR lpDate, UINT uiScriptType);
  118. VOID FreeRSOPScriptData(VOID);
  119. HRESULT InitializeRSOPScriptsData(VOID);
  120. HRESULT GetGPOFriendlyName(IWbemServices *pIWbemServices,
  121. LPTSTR lpGPOID, BSTR pLanguage,
  122. LPTSTR *pGPOName);
  123. VOID DumpRSOPScriptsData(LPRSOPSCRIPTITEM lpList);
  124. };
  125. //
  126. // ComponentData class factory
  127. //
  128. class CScriptsComponentDataCF : public IClassFactory {
  129. protected:
  130. ULONG m_cRef;
  131. BOOL m_bUserScope;
  132. BOOL m_bRSOP;
  133. public:
  134. CScriptsComponentDataCF(BOOL bUser, BOOL bRSOP);
  135. ~CScriptsComponentDataCF();
  136. // IUnknown methods
  137. STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
  138. STDMETHODIMP_(ULONG) AddRef();
  139. STDMETHODIMP_(ULONG) Release();
  140. // IClassFactory methods
  141. STDMETHODIMP CreateInstance(LPUNKNOWN, REFIID, LPVOID FAR *);
  142. STDMETHODIMP LockServer(BOOL);
  143. };
  144. //
  145. // SnapIn class
  146. //
  147. class CScriptsSnapIn:
  148. public IComponent,
  149. public IExtendPropertySheet {
  150. protected:
  151. ULONG m_cRef;
  152. LPCONSOLE m_pConsole; // Console's IFrame interface
  153. CScriptsComponentData *m_pcd;
  154. LPRESULTDATA m_pResult; // Result pane's interface
  155. LPHEADERCTRL m_pHeader; // Result pane's header control interface
  156. LPCONSOLEVERB m_pConsoleVerb; // pointer the console verb
  157. LPDISPLAYHELP m_pDisplayHelp; // IDisplayHelp interface
  158. WCHAR m_column1[40]; // Text for column 1
  159. INT m_nColumn1Size; // Size of column 1
  160. WCHAR m_column2[40]; // Text for column 2
  161. INT m_nColumn2Size; // Size of column 2
  162. WCHAR m_column3[60]; // Text for column 3
  163. INT m_nColumn3Size; // Size of column 3
  164. WCHAR m_column4[40]; // Text for column 4
  165. INT m_nColumn4Size; // Size of column 4
  166. LONG m_lViewMode; // View mode
  167. static unsigned int m_cfNodeType;
  168. public:
  169. CScriptsSnapIn(CScriptsComponentData *pComponent);
  170. ~CScriptsSnapIn();
  171. //
  172. // IUnknown methods
  173. //
  174. STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
  175. STDMETHODIMP_(ULONG) AddRef();
  176. STDMETHODIMP_(ULONG) Release();
  177. //
  178. // Implemented IComponent methods
  179. //
  180. STDMETHODIMP Initialize(LPCONSOLE);
  181. STDMETHODIMP Destroy(MMC_COOKIE);
  182. STDMETHODIMP Notify(LPDATAOBJECT, MMC_NOTIFY_TYPE, LPARAM, LPARAM);
  183. STDMETHODIMP QueryDataObject(MMC_COOKIE, DATA_OBJECT_TYPES, LPDATAOBJECT *);
  184. STDMETHODIMP GetDisplayInfo(LPRESULTDATAITEM);
  185. STDMETHODIMP GetResultViewType(MMC_COOKIE, LPOLESTR*, long*);
  186. STDMETHODIMP CompareObjects(LPDATAOBJECT, LPDATAOBJECT);
  187. //
  188. // Implemented IExtendPropertySheet methods
  189. //
  190. STDMETHODIMP CreatePropertyPages(LPPROPERTYSHEETCALLBACK lpProvider,
  191. LONG_PTR handle, LPDATAOBJECT lpDataObject);
  192. STDMETHODIMP QueryPagesFor(LPDATAOBJECT lpDataObject);
  193. private:
  194. static INT_PTR CALLBACK ScriptDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
  195. BOOL AddScriptToList (HWND hLV, LPTSTR lpName, LPTSTR lpArgs);
  196. LPTSTR GetSectionNames (LPTSTR lpFileName);
  197. BOOL OnApplyNotify (HWND hDlg);
  198. static INT_PTR CALLBACK ScriptEditDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
  199. };
  200. //
  201. // IScriptDataobject interface id
  202. //
  203. // {4c1dd2a5-3a79-4c98-bcb9-c150291fbab1}
  204. DEFINE_GUID(IID_IScriptDataObject,0x4c1dd2a5, 0x3a79, 0x4c98, 0xbc, 0xb9, 0xc1, 0x50, 0x29, 0x1f, 0xba, 0xb1);
  205. //
  206. // This is a private dataobject interface for GPTs.
  207. // When the GPT snapin receives a dataobject and needs to determine
  208. // if it came from the GPT snapin or a different component, it can QI for
  209. // this interface.
  210. //
  211. #undef INTERFACE
  212. #define INTERFACE IScriptDataObject
  213. DECLARE_INTERFACE_(IScriptDataObject, IUnknown)
  214. {
  215. // *** IUnknown methods ***
  216. STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID * ppvObj) PURE;
  217. STDMETHOD_(ULONG,AddRef) (THIS) PURE;
  218. STDMETHOD_(ULONG,Release) (THIS) PURE;
  219. // *** IScriptDataObject methods ***
  220. STDMETHOD(SetType) (THIS_ DATA_OBJECT_TYPES type) PURE;
  221. STDMETHOD(GetType) (THIS_ DATA_OBJECT_TYPES *type) PURE;
  222. STDMETHOD(SetCookie) (THIS_ MMC_COOKIE cookie) PURE;
  223. STDMETHOD(GetCookie) (THIS_ MMC_COOKIE *cookie) PURE;
  224. };
  225. typedef IScriptDataObject *LPSCRIPTDATAOBJECT;
  226. //
  227. // CScriptsDataObject class
  228. //
  229. class CScriptsDataObject : public IDataObject,
  230. public IScriptDataObject {
  231. friend class CScriptsSnapIn;
  232. protected:
  233. ULONG m_cRef;
  234. CScriptsComponentData *m_pcd;
  235. DATA_OBJECT_TYPES m_type;
  236. MMC_COOKIE m_cookie;
  237. MMC_COOKIE m_cookiePrevRes;
  238. //
  239. // Clipboard formats that are required by the console
  240. //
  241. static unsigned int m_cfNodeType;
  242. static unsigned int m_cfNodeTypeString;
  243. static unsigned int m_cfDisplayName;
  244. static unsigned int m_cfCoClass;
  245. static unsigned int m_cfDescription;
  246. static unsigned int m_cfHTMLDetails;
  247. public:
  248. CScriptsDataObject(CScriptsComponentData *pComponent);
  249. ~CScriptsDataObject();
  250. //
  251. // IUnknown methods
  252. //
  253. STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
  254. STDMETHODIMP_(ULONG) AddRef();
  255. STDMETHODIMP_(ULONG) Release();
  256. //
  257. // Implemented IDataObject methods
  258. //
  259. STDMETHOD(GetDataHere)(LPFORMATETC lpFormatetc, LPSTGMEDIUM lpMedium);
  260. //
  261. // Unimplemented IDataObject methods
  262. //
  263. STDMETHOD(GetData)(LPFORMATETC lpFormatetcIn, LPSTGMEDIUM lpMedium)
  264. { return E_NOTIMPL;};
  265. STDMETHOD(EnumFormatEtc)(DWORD dwDirection, LPENUMFORMATETC* ppEnumFormatEtc)
  266. { return E_NOTIMPL;};
  267. STDMETHOD(QueryGetData)(LPFORMATETC lpFormatetc)
  268. { return E_NOTIMPL;};
  269. STDMETHOD(GetCanonicalFormatEtc)(LPFORMATETC lpFormatetcIn, LPFORMATETC lpFormatetcOut)
  270. { return E_NOTIMPL;};
  271. STDMETHOD(SetData)(LPFORMATETC lpFormatetc, LPSTGMEDIUM lpMedium, BOOL bRelease)
  272. { return E_NOTIMPL;};
  273. STDMETHOD(DAdvise)(LPFORMATETC lpFormatetc, DWORD advf,
  274. LPADVISESINK pAdvSink, LPDWORD pdwConnection)
  275. { return E_NOTIMPL;};
  276. STDMETHOD(DUnadvise)(DWORD dwConnection)
  277. { return E_NOTIMPL;};
  278. STDMETHOD(EnumDAdvise)(LPENUMSTATDATA* ppEnumAdvise)
  279. { return E_NOTIMPL;};
  280. //
  281. // Implemented IScriptDataObject methods
  282. //
  283. STDMETHOD(SetType) (DATA_OBJECT_TYPES type)
  284. { m_type = type; return S_OK;};
  285. STDMETHOD(GetType) (DATA_OBJECT_TYPES *type)
  286. { *type = m_type; return S_OK;};
  287. STDMETHOD(SetCookie) (MMC_COOKIE cookie);
  288. STDMETHOD(GetCookie) (MMC_COOKIE *cookie)
  289. { *cookie = m_cookie; return S_OK;};
  290. private:
  291. HRESULT CreateNodeTypeData(LPSTGMEDIUM lpMedium);
  292. HRESULT CreateNodeTypeStringData(LPSTGMEDIUM lpMedium);
  293. HRESULT CreateDisplayName(LPSTGMEDIUM lpMedium);
  294. HRESULT CreateCoClassID(LPSTGMEDIUM lpMedium);
  295. HRESULT Create(LPVOID pBuffer, INT len, LPSTGMEDIUM lpMedium);
  296. };