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.

750 lines
23 KiB

  1. //+--------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1996 - 2001.
  5. //
  6. // File: dataobj.cpp
  7. //
  8. // Contents: Implementation of data object class
  9. //
  10. // History:
  11. //
  12. //---------------------------------------------------------------------------
  13. #include "stdafx.h"
  14. #include "cookie.h"
  15. #include "snapmgr.h"
  16. #include "DataObj.h"
  17. #include <sceattch.h>
  18. #ifdef _DEBUG
  19. #define new DEBUG_NEW
  20. #undef THIS_FILE
  21. static char THIS_FILE[] = __FILE__;
  22. #endif
  23. ///////////////////////////////////////////////////////////////////////////////
  24. // Snap-in NodeType in both GUID format and string format
  25. UINT CDataObject::m_cfNodeType = RegisterClipboardFormat(CCF_NODETYPE);
  26. UINT CDataObject::m_cfNodeTypeString = RegisterClipboardFormat(CCF_SZNODETYPE);
  27. UINT CDataObject::m_cfNodeID = RegisterClipboardFormat(CCF_NODEID2);
  28. UINT CDataObject::m_cfDisplayName = RegisterClipboardFormat(CCF_DISPLAY_NAME);
  29. UINT CDataObject::m_cfSnapinClassID = RegisterClipboardFormat(CCF_SNAPIN_CLASSID);
  30. UINT CDataObject::m_cfInternal = RegisterClipboardFormat(SNAPIN_INTERNAL);
  31. UINT CDataObject::m_cfSceSvcAttachment = RegisterClipboardFormat(CCF_SCESVC_ATTACHMENT);
  32. UINT CDataObject::m_cfSceSvcAttachmentData = RegisterClipboardFormat(CCF_SCESVC_ATTACHMENT_DATA);
  33. UINT CDataObject::m_cfModeType = RegisterClipboardFormat(CCF_SCE_MODE_TYPE);
  34. UINT CDataObject::m_cfGPTUnknown = RegisterClipboardFormat(CCF_SCE_GPT_UNKNOWN);
  35. UINT CDataObject::m_cfRSOPUnknown = RegisterClipboardFormat(CCF_SCE_RSOP_UNKNOWN);
  36. UINT CDataObject::m_cfMultiSelect = ::RegisterClipboardFormat(CCF_OBJECT_TYPES_IN_MULTI_SELECT);
  37. /////////////////////////////////////////////////////////////////////////////
  38. // CDataObject implementations
  39. //+--------------------------------------------------------------------------
  40. //
  41. // Member: CDataObject::GetDataHere
  42. //
  43. // Synopsis: Fill the hGlobal in [lpmedium] with the requested data
  44. //
  45. // History:
  46. //
  47. //---------------------------------------------------------------------------
  48. STDMETHODIMP
  49. CDataObject::GetDataHere(LPFORMATETC lpFormatetc, // In
  50. LPSTGMEDIUM lpMedium) // In
  51. {
  52. HRESULT hr = DV_E_CLIPFORMAT;
  53. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  54. if (!lpFormatetc)
  55. return E_INVALIDARG;
  56. //
  57. // Based on the CLIPFORMAT, write data to the stream
  58. //
  59. const CLIPFORMAT cf = lpFormatetc->cfFormat;
  60. if (cf == m_cfNodeType)
  61. hr = CreateNodeTypeData(lpMedium);
  62. else if (cf == m_cfNodeTypeString)
  63. hr = CreateNodeTypeStringData(lpMedium);
  64. else if (cf == m_cfDisplayName)
  65. hr = CreateDisplayName(lpMedium);
  66. else if (cf == m_cfSnapinClassID)
  67. hr = CreateSnapinClassID(lpMedium);
  68. else if (cf == m_cfInternal)
  69. hr = CreateInternal(lpMedium);
  70. else if (cf == m_cfSceSvcAttachment)
  71. hr = CreateSvcAttachment(lpMedium);
  72. else if (cf == m_cfSceSvcAttachmentData)
  73. hr = CreateSvcAttachmentData(lpMedium);
  74. else if (cf == m_cfModeType)
  75. hr = CreateModeType(lpMedium);
  76. else if (cf == m_cfGPTUnknown)
  77. hr = CreateGPTUnknown(lpMedium);
  78. else if (cf == m_cfRSOPUnknown)
  79. hr = CreateRSOPUnknown(lpMedium);
  80. return hr;
  81. }
  82. //+--------------------------------------------------------------------------
  83. //
  84. // Member: CDataObject::GetData
  85. //
  86. // Synopsis: Support for mutli select is added. First return the mutli
  87. // select GUID information if that is what we are being called for.
  88. // The else if copies the actual mutli-select information.
  89. //
  90. // The function will only copy the mutli select information if
  91. // the FORMATEETC.cfFormat == CDataObject::m_cfInternal and
  92. // FORMATETC.tymed == TYMED_HGLOBAL.
  93. //
  94. // History: 1-14-1999 - a-mthoge
  95. //
  96. //---------------------------------------------------------------------------
  97. STDMETHODIMP
  98. CDataObject::GetData(LPFORMATETC lpFormatetcIn,
  99. LPSTGMEDIUM lpMedium)
  100. {
  101. HRESULT hRet = S_OK;
  102. if (NULL == lpFormatetcIn ||
  103. NULL == lpMedium)
  104. {
  105. return E_POINTER;
  106. }
  107. if(lpFormatetcIn->cfFormat == m_cfMultiSelect &&
  108. lpFormatetcIn->tymed == TYMED_HGLOBAL &&
  109. m_nInternalArray )
  110. {
  111. //
  112. // Need to create a SSMCObjectTypes structure and return this
  113. // to MMC for mutli select.
  114. //
  115. // we only support result items created by SCE.
  116. //
  117. lpMedium->hGlobal = GlobalAlloc(GMEM_SHARE, sizeof(DWORD) + sizeof(GUID) );
  118. if(!lpMedium->hGlobal)
  119. return E_FAIL;
  120. //
  121. // Set count and GUID to 1.
  122. //
  123. SMMCObjectTypes *pTypes = (SMMCObjectTypes *)GlobalLock(lpMedium->hGlobal);
  124. pTypes->count = 1;
  125. //This is a safe usage. yanggao.
  126. memcpy( &(pTypes->guid), &m_internal.m_clsid, sizeof(GUID));
  127. GlobalUnlock(lpMedium->hGlobal);
  128. return S_OK;
  129. }
  130. else if(lpFormatetcIn->cfFormat == m_cfInternal &&
  131. lpFormatetcIn->tymed == TYMED_HGLOBAL &&
  132. m_nInternalArray )
  133. {
  134. //
  135. // Copy the contents of the mutli select to STGMEDIUM
  136. //
  137. lpMedium->hGlobal = GlobalAlloc( GMEM_SHARE, sizeof(INTERNAL) * (m_nInternalArray + 1));
  138. if(!lpMedium->hGlobal)
  139. return E_FAIL;
  140. //
  141. // The first element in the array is set to
  142. // MMC_MUTLI_SELECT_COOKIE and the type is set the count of items after the
  143. // first structure.
  144. //
  145. INTERNAL *pInternal = (INTERNAL *)GlobalLock( lpMedium->hGlobal );
  146. pInternal->m_cookie = (MMC_COOKIE)MMC_MULTI_SELECT_COOKIE;
  147. pInternal->m_type = (DATA_OBJECT_TYPES)m_nInternalArray;
  148. //
  149. // Copy the rest of the INTERNAL structures to this array.
  150. //
  151. pInternal++;
  152. //This is a safe usage.
  153. memcpy(pInternal, m_pInternalArray, sizeof(INTERNAL) * m_nInternalArray);
  154. }
  155. else if (lpFormatetcIn->cfFormat == m_cfNodeID &&
  156. lpFormatetcIn->tymed == TYMED_HGLOBAL )
  157. {
  158. return CreateNodeId(lpMedium);
  159. }
  160. return hRet;
  161. }
  162. //+--------------------------------------------------------------------------
  163. //
  164. // Member: CDataObject::EnumFormatEtc
  165. //
  166. // Synopsis: Not implemented
  167. //
  168. // History:
  169. //
  170. //---------------------------------------------------------------------------
  171. STDMETHODIMP
  172. CDataObject::EnumFormatEtc(DWORD dwDirection,
  173. LPENUMFORMATETC*
  174. ppEnumFormatEtc)
  175. {
  176. return E_NOTIMPL;
  177. }
  178. /////////////////////////////////////////////////////////////////////////////
  179. // CDataObject creation members
  180. //+--------------------------------------------------------------------------
  181. //
  182. // Member: CDataObject::Create
  183. //
  184. // Synopsis: Fill the hGlobal in [lpmedium] with the data in pBuffer
  185. //
  186. // Arguments: [pBuffer] - [in] the data to be written
  187. // [len] - [in] the length of that data
  188. // [lpMedium] - [in,out] where to store the data
  189. // History:
  190. //
  191. //---------------------------------------------------------------------------
  192. HRESULT
  193. CDataObject::Create(const void* pBuffer,
  194. int len,
  195. LPSTGMEDIUM lpMedium)
  196. {
  197. HRESULT hr = DV_E_TYMED;
  198. //
  199. // Do some simple validation
  200. //
  201. if (pBuffer == NULL || lpMedium == NULL)
  202. return E_POINTER;
  203. //
  204. // Make sure the type medium is HGLOBAL
  205. //
  206. if (lpMedium->tymed == TYMED_HGLOBAL)
  207. {
  208. //
  209. // Create the stream on the hGlobal passed in
  210. //
  211. LPSTREAM lpStream;
  212. hr = CreateStreamOnHGlobal(lpMedium->hGlobal, FALSE, &lpStream);
  213. if (SUCCEEDED(hr))
  214. {
  215. //
  216. // Write to the stream the number of bytes
  217. //
  218. ULONG written;
  219. hr = lpStream->Write(pBuffer, len, &written);
  220. //
  221. // Because we told CreateStreamOnHGlobal with 'FALSE',
  222. // only the stream is released here.
  223. // Note - the caller (i.e. snap-in, object) will free the HGLOBAL
  224. // at the correct time. This is according to the IDataObject specification.
  225. //
  226. lpStream->Release();
  227. }
  228. }
  229. return hr;
  230. }
  231. //+--------------------------------------------------------------------------
  232. //
  233. // Member: CDataObject::CreateNodeTypeData
  234. //
  235. // Synopsis: Fill the hGlobal in [lpMedium] with our node type
  236. //
  237. // History:
  238. //
  239. //---------------------------------------------------------------------------
  240. HRESULT
  241. CDataObject::CreateNodeTypeData(LPSTGMEDIUM lpMedium)
  242. {
  243. const GUID *pNodeType;
  244. //
  245. // Create the node type object in GUID format
  246. //
  247. switch (m_internal.m_foldertype)
  248. {
  249. case LOCALPOL:
  250. pNodeType = &cNodetypeSceTemplate;
  251. break;
  252. case PROFILE:
  253. if ( ::IsEqualGUID(m_internal.m_clsid, CLSID_Snapin) ||
  254. ::IsEqualGUID(m_internal.m_clsid, CLSID_RSOPSnapin) )
  255. {
  256. pNodeType = &cNodetypeSceTemplate;
  257. }
  258. else
  259. {
  260. // other areas aren't extensible on this node
  261. // return our generic node type
  262. pNodeType = &cSCENodeType;
  263. }
  264. break;
  265. case AREA_SERVICE_ANALYSIS:
  266. pNodeType = &cNodetypeSceAnalysisServices;
  267. break;
  268. case AREA_SERVICE:
  269. pNodeType = &cNodetypeSceTemplateServices;
  270. break;
  271. default:
  272. if ( ::IsEqualGUID(m_internal.m_clsid, CLSID_Snapin) )
  273. pNodeType = &cNodeType;
  274. else if ( ::IsEqualGUID(m_internal.m_clsid, CLSID_RSOPSnapin) )
  275. pNodeType = &cRSOPNodeType;
  276. else if ( ::IsEqualGUID(m_internal.m_clsid, CLSID_SAVSnapin) )
  277. pNodeType = &cSAVNodeType;
  278. else
  279. pNodeType = &cSCENodeType;
  280. break;
  281. }
  282. return Create(reinterpret_cast<const void*>(pNodeType), sizeof(GUID), lpMedium);
  283. }
  284. //+--------------------------------------------------------------------------
  285. //
  286. // Member: CDataObject::CreateNodeTypeStringData
  287. //
  288. // Synopsis: Fill the hGlobal in [lpMedium] with the string representation
  289. // of our node type
  290. //
  291. // History:
  292. //
  293. //---------------------------------------------------------------------------
  294. HRESULT CDataObject::CreateNodeTypeStringData(LPSTGMEDIUM lpMedium)
  295. {
  296. //
  297. // Create the node type object in GUID string format
  298. //
  299. LPCTSTR pszNodeType;
  300. switch (m_internal.m_foldertype)
  301. {
  302. case AREA_SERVICE_ANALYSIS:
  303. pszNodeType = lstruuidNodetypeSceAnalysisServices;
  304. break;
  305. case AREA_SERVICE:
  306. pszNodeType = lstruuidNodetypeSceTemplateServices;
  307. break;
  308. case LOCALPOL:
  309. pszNodeType = lstruuidNodetypeSceTemplate;
  310. break;
  311. case PROFILE:
  312. if ( ::IsEqualGUID(m_internal.m_clsid, CLSID_Snapin) )
  313. pszNodeType = lstruuidNodetypeSceTemplate;
  314. else if ( ::IsEqualGUID(m_internal.m_clsid, CLSID_RSOPSnapin) )
  315. pszNodeType = lstruuidNodetypeSceTemplate;
  316. else
  317. {
  318. // other snapin types do not allow extensions on this level
  319. // return our generic node type
  320. pszNodeType = cszSCENodeType;
  321. }
  322. break;
  323. default:
  324. if ( ::IsEqualGUID(m_internal.m_clsid, CLSID_Snapin) )
  325. pszNodeType = cszNodeType;
  326. else if ( ::IsEqualGUID(m_internal.m_clsid, CLSID_RSOPSnapin) )
  327. pszNodeType = cszRSOPNodeType;
  328. else if ( ::IsEqualGUID(m_internal.m_clsid, CLSID_SAVSnapin) )
  329. pszNodeType = cszSAVNodeType;
  330. else
  331. pszNodeType = cszSCENodeType;
  332. break;
  333. }
  334. return Create(pszNodeType, ((wcslen(pszNodeType)+1) * sizeof(WCHAR)), lpMedium);
  335. }
  336. //+--------------------------------------------------------------------------
  337. //
  338. // Member: CDataObject::CreateNodeID
  339. //
  340. // Synopsis: Create an hGlobal in [lpMedium] with our node ID
  341. //
  342. // History:
  343. //
  344. //---------------------------------------------------------------------------
  345. HRESULT
  346. CDataObject::CreateNodeId(LPSTGMEDIUM lpMedium)
  347. {
  348. SNodeID2 *nodeID = NULL;
  349. BYTE *id = NULL;
  350. DWORD dwIDSize = 0;
  351. DWORD dwIDNameSize = 0;
  352. LPTSTR szNodeName = NULL;
  353. CFolder *pFolder = NULL;
  354. LPTSTR szMedium = NULL;
  355. //
  356. // Create the node type object in GUID format
  357. //
  358. switch (m_internal.m_foldertype)
  359. {
  360. case LOCATIONS:
  361. case PROFILE:
  362. case REG_OBJECTS:
  363. case FILE_OBJECTS:
  364. //
  365. // There can be many nodes of these types and they will be
  366. // locked to the system so just use the display name
  367. //
  368. if (m_internal.m_cookie)
  369. {
  370. pFolder = reinterpret_cast<CFolder*>(m_internal.m_cookie);
  371. szNodeName = pFolder->GetName();
  372. if( szNodeName == NULL) //Raid 553113, yanggao
  373. return E_FAIL;
  374. dwIDNameSize = (lstrlen(szNodeName)+1)*sizeof(TCHAR);
  375. dwIDSize = sizeof(SNodeID2)+dwIDNameSize;
  376. lpMedium->hGlobal = GlobalAlloc(GMEM_SHARE,dwIDSize);
  377. if(!lpMedium->hGlobal)
  378. return STG_E_MEDIUMFULL;
  379. nodeID = (SNodeID2 *)GlobalLock(lpMedium->hGlobal);
  380. //This is not a safe usage. Need to GlobalUnlock lpMedium->hGlobal, validate szNodeName. Raid 553113. yanggao.
  381. if( nodeID )
  382. {
  383. nodeID->dwFlags = 0;
  384. nodeID->cBytes = dwIDNameSize;
  385. memcpy(nodeID->id,szNodeName,dwIDNameSize);
  386. GlobalUnlock(lpMedium->hGlobal);
  387. }
  388. else
  389. {
  390. GlobalFree(lpMedium->hGlobal);
  391. return STG_E_MEDIUMFULL;
  392. }
  393. }
  394. else
  395. return E_FAIL;
  396. break;
  397. default:
  398. //
  399. // Everything else is unique: there's one and only one node
  400. // of the type per snapin.
  401. //
  402. dwIDSize = sizeof(FOLDER_TYPES)+sizeof(SNodeID2);
  403. lpMedium->hGlobal = GlobalAlloc(GMEM_SHARE,dwIDSize);
  404. if(!lpMedium->hGlobal)
  405. return STG_E_MEDIUMFULL;
  406. nodeID = (SNodeID2 *)GlobalLock(lpMedium->hGlobal);
  407. nodeID->dwFlags = 0;
  408. nodeID->cBytes = sizeof(FOLDER_TYPES);
  409. //This is a safe usage. yanggao.
  410. memcpy(nodeID->id,&(m_internal.m_foldertype),sizeof(FOLDER_TYPES));
  411. GlobalUnlock(lpMedium->hGlobal);
  412. break;
  413. }
  414. return S_OK;
  415. }
  416. //+--------------------------------------------------------------------------
  417. //
  418. // Member: CDataObject::CreateNodeTypeData
  419. //
  420. // Synopsis: Fill the hGlobal in [lpMedium] with SCE's display name,
  421. // which will differ depending on where it's being viewed from
  422. // as reported by the mode bits
  423. //
  424. // History:
  425. //
  426. //---------------------------------------------------------------------------
  427. HRESULT CDataObject::CreateDisplayName(LPSTGMEDIUM lpMedium)
  428. {
  429. //
  430. // This is the display named used in the scope pane and snap-in manager
  431. //
  432. //
  433. // Load the name from resource
  434. // Note - if this is not provided, the console will used the snap-in name
  435. //
  436. CString szDispName;
  437. if ( ::IsEqualGUID(m_internal.m_clsid, CLSID_SAVSnapin) )
  438. szDispName.LoadString(IDS_ANALYSIS_VIEWER_NAME);
  439. else if ( ::IsEqualGUID(m_internal.m_clsid, CLSID_SCESnapin) )
  440. szDispName.LoadString(IDS_TEMPLATE_EDITOR_NAME);
  441. else if ( ::IsEqualGUID(m_internal.m_clsid, CLSID_LSSnapin) )
  442. szDispName.LoadString(IDS_LOCAL_SECURITY_NAME);
  443. else if ( ::IsEqualGUID(m_internal.m_clsid, CLSID_Snapin) )
  444. szDispName.LoadString(IDS_EXTENSION_NAME);
  445. else if ( ::IsEqualGUID(m_internal.m_clsid, CLSID_RSOPSnapin) )
  446. szDispName.LoadString(IDS_EXTENSION_NAME);
  447. else
  448. szDispName.LoadString(IDS_NODENAME);
  449. /* // can't depend on m_ModeBits because it's not set yet
  450. if (m_ModeBits & MB_ANALYSIS_VIEWER) {
  451. szDispName.LoadString(IDS_ANALYSIS_VIEWER_NAME);
  452. } else if (m_ModeBits & MB_TEMPLATE_EDITOR) {
  453. szDispName.LoadString(IDS_TEMPLATE_EDITOR_NAME);
  454. } else if ( (m_ModeBits & MB_NO_NATIVE_NODES) ||
  455. (m_ModeBits & MB_SINGLE_TEMPLATE_ONLY) ) {
  456. szDispName.LoadString(IDS_EXTENSION_NAME);
  457. } else {
  458. szDispName.LoadString(IDS_NODENAME);
  459. }
  460. */
  461. return Create(szDispName, ((szDispName.GetLength()+1) * sizeof(WCHAR)), lpMedium);
  462. }
  463. //+--------------------------------------------------------------------------
  464. //
  465. // Member: CDataObject::CreateSnapinClassID
  466. //
  467. // Synopsis: Fill the hGlobal in [lpMedium] with SCE's class ID
  468. //
  469. // History:
  470. //
  471. //---------------------------------------------------------------------------
  472. HRESULT CDataObject::CreateSnapinClassID(LPSTGMEDIUM lpMedium)
  473. {
  474. //
  475. // Create the snapin classid in CLSID format
  476. //
  477. return Create(reinterpret_cast<const void*>(&m_internal.m_clsid), sizeof(CLSID), lpMedium);
  478. }
  479. //+--------------------------------------------------------------------------
  480. //
  481. // Member: CDataObject::CreateInternal
  482. //
  483. // Synopsis: Fill the hGlobal in [lpMedium] with SCE's internal data type
  484. //
  485. // History:
  486. //
  487. //---------------------------------------------------------------------------
  488. HRESULT CDataObject::CreateInternal(LPSTGMEDIUM lpMedium)
  489. {
  490. return Create(&m_internal, sizeof(INTERNAL), lpMedium);
  491. }
  492. //+--------------------------------------------------------------------------
  493. //
  494. // Member: CDataObject::AddInternal
  495. //
  496. // Synopsis: Adds an INTERNAL object to the array of internal objects.
  497. //
  498. // History: 1-14-1999 a-mthoge
  499. //
  500. //---------------------------------------------------------------------------
  501. void CDataObject::AddInternal( MMC_COOKIE cookie, DATA_OBJECT_TYPES type)
  502. {
  503. //
  504. // Allocate memory for one more internal array.
  505. INTERNAL *hNew = (INTERNAL *)LocalAlloc( 0, sizeof(INTERNAL) * (m_nInternalArray + 1) );
  506. if(!hNew)
  507. return;
  508. m_nInternalArray++;
  509. //
  510. // Copy other internal array information.
  511. //
  512. if( m_pInternalArray )
  513. {
  514. //This is a safe usage.
  515. memcpy(hNew, m_pInternalArray, sizeof(INTERNAL) * (m_nInternalArray - 1) );
  516. LocalFree( m_pInternalArray );
  517. }
  518. //
  519. // Set the new internal array members.
  520. //
  521. hNew[ m_nInternalArray - 1].m_cookie = cookie;
  522. hNew[ m_nInternalArray - 1].m_type = type;
  523. //
  524. // Set the CObjectData internal array pointer.
  525. //
  526. m_pInternalArray = hNew;
  527. }
  528. //+--------------------------------------------------------------------------
  529. //
  530. // Member: CDataObject::CreateSvcAttachment
  531. //
  532. // Synopsis: Fill the hGlobal in [lpMedium] with the name of the inf
  533. // template a service attachment should modify or with an empty
  534. // string for the inf-templateless analysis section
  535. //
  536. // History:
  537. //
  538. //---------------------------------------------------------------------------
  539. HRESULT CDataObject::CreateSvcAttachment(LPSTGMEDIUM lpMedium)
  540. {
  541. LPCTSTR sz = 0;
  542. if ((AREA_SERVICE == m_internal.m_foldertype) ||
  543. (AREA_SERVICE_ANALYSIS == m_internal.m_foldertype))
  544. {
  545. CFolder *pFolder = reinterpret_cast<CFolder *>(m_internal.m_cookie);
  546. if (pFolder)
  547. {
  548. sz = pFolder->GetInfFile();
  549. if (sz)
  550. return Create(sz,(lstrlen(sz)+1)*sizeof(TCHAR),lpMedium);
  551. else
  552. return E_FAIL;
  553. }
  554. else
  555. return E_FAIL;
  556. }
  557. //
  558. // This shouldn't be asked for except in the SERVICE areas
  559. //
  560. return E_UNEXPECTED;
  561. }
  562. //+--------------------------------------------------------------------------
  563. //
  564. // Member: CDataObject::CreateSvcAttachmentData
  565. //
  566. // Synopsis: Fill the hGlobal in [lpMedium] with a pointer to the
  567. // ISceSvcAttachmentData interface that an attachment should use
  568. // to communicate with SCE
  569. //
  570. // History:
  571. //
  572. //---------------------------------------------------------------------------
  573. HRESULT CDataObject::CreateSvcAttachmentData(LPSTGMEDIUM lpMedium)
  574. {
  575. if ((AREA_SERVICE == m_internal.m_foldertype) ||
  576. (AREA_SERVICE_ANALYSIS == m_internal.m_foldertype))
  577. {
  578. return Create(&m_pSceSvcAttachmentData,sizeof(m_pSceSvcAttachmentData),lpMedium);
  579. }
  580. //
  581. // This shouldn't be asked for except in the SERVICE areas
  582. //
  583. return E_UNEXPECTED;
  584. }
  585. //+--------------------------------------------------------------------------
  586. //
  587. // Member: CDataObject::CreateModeType
  588. //
  589. // Synopsis: Fill the hGlobal in [lpMedium] with the Mode that SCE was
  590. // started in
  591. //
  592. // History:
  593. //
  594. //---------------------------------------------------------------------------
  595. HRESULT CDataObject::CreateModeType(LPSTGMEDIUM lpMedium)
  596. {
  597. DWORD mode = m_Mode;
  598. if (mode == SCE_MODE_DOMAIN_COMPUTER_ERROR)
  599. mode = SCE_MODE_DOMAIN_COMPUTER;
  600. return Create(&mode,sizeof(DWORD),lpMedium);
  601. }
  602. //+--------------------------------------------------------------------------
  603. //
  604. // Member: CDataObject::CreateGPTUnknown
  605. //
  606. // Synopsis: Fill the hGlobal in [lpMedium] with a pointer to GPT's
  607. // IUnknown interface. The object requesting this will be
  608. // responsible for Releasing the interface
  609. //
  610. // History:
  611. //
  612. //---------------------------------------------------------------------------
  613. HRESULT CDataObject::CreateGPTUnknown(LPSTGMEDIUM lpMedium)
  614. {
  615. LPUNKNOWN pUnk = 0;
  616. if (!m_pGPTInfo)
  617. {
  618. //
  619. // If we don't have a pointer to a GPT interface then we must not
  620. // be in a mode where we're extending GPT and we can't provide a
  621. // pointer to its IUnknown
  622. //
  623. return E_UNEXPECTED;
  624. }
  625. HRESULT hr = m_pGPTInfo->QueryInterface(IID_IUnknown,
  626. reinterpret_cast<void **>(&pUnk));
  627. if (SUCCEEDED(hr))
  628. return Create(&pUnk,sizeof(pUnk),lpMedium);
  629. else
  630. return hr;
  631. }
  632. //+--------------------------------------------------------------------------
  633. //
  634. // Member: CDataObject::CreateRSOPUnknown
  635. //
  636. // Synopsis: Fill the hGlobal in [lpMedium] with a pointer to RSOP's
  637. // IUnknown interface. The object requesting this will be
  638. // responsible for Releasing the interface
  639. //
  640. // History:
  641. //
  642. //---------------------------------------------------------------------------
  643. HRESULT CDataObject::CreateRSOPUnknown(LPSTGMEDIUM lpMedium)
  644. {
  645. HRESULT hr = E_FAIL;
  646. LPUNKNOWN pUnk = NULL;
  647. if (!m_pRSOPInfo)
  648. {
  649. //
  650. // If we don't have a pointer to a RSOP interface then we must not
  651. // be in a mode where we're extending RSOP and we can't provide a
  652. // pointer to its IUnknown
  653. //
  654. return E_UNEXPECTED;
  655. }
  656. hr = m_pRSOPInfo->QueryInterface(IID_IUnknown,
  657. reinterpret_cast<void **>(&pUnk));
  658. if (SUCCEEDED(hr))
  659. return Create(&pUnk,sizeof(pUnk),lpMedium);
  660. else
  661. return hr;
  662. }