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.

1035 lines
28 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 2000 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // CreateServices.h
  7. //
  8. // Description:
  9. // CreateServices implementation.
  10. //
  11. // Maintained By:
  12. // Geoffrey Pease (GPease) 15-JUN-2000
  13. //
  14. //////////////////////////////////////////////////////////////////////////////
  15. #include "pch.h"
  16. #include "GroupHandle.h"
  17. #include "ResourceEntry.h"
  18. #include "IPrivatePostCfgResource.h"
  19. #include "CreateServices.h"
  20. DEFINE_THISCLASS("CCreateServices")
  21. // ************************************************************************
  22. //
  23. // Constructor / Destructor
  24. //
  25. // ************************************************************************
  26. //////////////////////////////////////////////////////////////////////////////
  27. //
  28. // HRESULT
  29. // CCreateServices::S_HrCreateInstance(
  30. // IUnknown ** ppunkOut
  31. // )
  32. //
  33. //////////////////////////////////////////////////////////////////////////////
  34. HRESULT
  35. CCreateServices::S_HrCreateInstance(
  36. IUnknown ** ppunkOut
  37. )
  38. {
  39. TraceFunc( "" );
  40. HRESULT hr = E_UNEXPECTED;
  41. Assert( ppunkOut != NULL );
  42. CCreateServices * pdummy = new CCreateServices;
  43. if ( pdummy != NULL )
  44. {
  45. hr = THR( pdummy->HrInit( ) );
  46. if ( SUCCEEDED( hr ) )
  47. {
  48. hr = THR( pdummy->TypeSafeQI( IUnknown, ppunkOut ) );
  49. }
  50. pdummy->Release( );
  51. }
  52. else
  53. {
  54. hr = E_OUTOFMEMORY;
  55. }
  56. HRETURN( hr );
  57. } // S_HrCreateInstance( )
  58. //////////////////////////////////////////////////////////////////////////////
  59. //
  60. // CCreateServices::CCreateServices( void )
  61. //
  62. //////////////////////////////////////////////////////////////////////////////
  63. CCreateServices::CCreateServices( void )
  64. {
  65. TraceFunc( "" );
  66. InterlockedIncrement( &g_cObjects );
  67. TraceFuncExit();
  68. } // CCreateServices( )
  69. //////////////////////////////////////////////////////////////////////////////
  70. //
  71. // HRESULT
  72. // CCreateServices::HrInit( void )
  73. //
  74. //////////////////////////////////////////////////////////////////////////////
  75. HRESULT
  76. CCreateServices::HrInit( void )
  77. {
  78. TraceFunc( "" );
  79. HRESULT hr = S_OK;
  80. // IUnknown stuff
  81. Assert( m_cRef == 0 );
  82. AddRef( ); // Add one count
  83. // Resource
  84. Assert( m_presentry == NULL );
  85. HRETURN( hr );
  86. } // HrInit( )
  87. //////////////////////////////////////////////////////////////////////////////
  88. //
  89. // CCreateServices::~CCreateServices( )
  90. //
  91. //////////////////////////////////////////////////////////////////////////////
  92. CCreateServices::~CCreateServices( )
  93. {
  94. TraceFunc( "" );
  95. InterlockedDecrement( &g_cObjects );
  96. TraceFuncExit();
  97. } // ~CCreateServices( )
  98. // ************************************************************************
  99. //
  100. // IUnknown
  101. //
  102. // ************************************************************************
  103. //////////////////////////////////////////////////////////////////////////////
  104. //
  105. // STDMETHODIMP
  106. // CCreateServices::QueryInterface(
  107. // REFIID riid,
  108. // LPVOID *ppv
  109. // )
  110. //
  111. //////////////////////////////////////////////////////////////////////////////
  112. STDMETHODIMP
  113. CCreateServices::QueryInterface(
  114. REFIID riid,
  115. LPVOID *ppv
  116. )
  117. {
  118. TraceQIFunc( riid, ppv );
  119. HRESULT hr = E_NOINTERFACE;
  120. if ( IsEqualIID( riid, IID_IUnknown ) )
  121. {
  122. *ppv = static_cast< IClusCfgResourceCreate * >( this );
  123. hr = S_OK;
  124. } // if: IUnknown
  125. else if ( IsEqualIID( riid, IID_IClusCfgResourceCreate ) )
  126. {
  127. *ppv = TraceInterface( __THISCLASS__, IClusCfgResourceCreate, this, 0 );
  128. hr = S_OK;
  129. } // else if: IClusCfgResourceCreate
  130. else if ( IsEqualIID( riid, IID_IPrivatePostCfgResource ) )
  131. {
  132. *ppv = TraceInterface( __THISCLASS__, IPrivatePostCfgResource, this, 0 );
  133. hr = S_OK;
  134. } // else if: IPrivatePostCfgResource
  135. if ( SUCCEEDED( hr ) )
  136. {
  137. ((IUnknown*) *ppv)->AddRef( );
  138. } // if: success
  139. QIRETURN( hr, riid );
  140. } // QueryInterface( )
  141. //////////////////////////////////////////////////////////////////////////////
  142. //
  143. // STDMETHODIMP_(ULONG)
  144. // CCreateServices::AddRef( void )
  145. //
  146. //////////////////////////////////////////////////////////////////////////////
  147. STDMETHODIMP_(ULONG)
  148. CCreateServices::AddRef( void )
  149. {
  150. TraceFunc( "[IUnknown]" );
  151. m_cRef ++; // apartment model
  152. RETURN( m_cRef );
  153. } // AddRef( )
  154. //////////////////////////////////////////////////////////////////////////////
  155. //
  156. // STDMETHODIMP_(ULONG)
  157. // CCreateServices::Release( void )
  158. //
  159. //////////////////////////////////////////////////////////////////////////////
  160. STDMETHODIMP_(ULONG)
  161. CCreateServices::Release( void )
  162. {
  163. TraceFunc( "[IUnknown]" );
  164. m_cRef --; // apartment model
  165. if ( m_cRef )
  166. RETURN( m_cRef );
  167. TraceDo( delete this );
  168. RETURN(0);
  169. } // Release( )
  170. //****************************************************************************
  171. //
  172. // IClusCfgResourceCreate
  173. //
  174. //****************************************************************************
  175. //////////////////////////////////////////////////////////////////////////////
  176. //
  177. // STDMETHODIMP
  178. // CCreateServices::SetPropertyBinary(
  179. // LPCWSTR pcszNameIn,
  180. // const DWORD cbSizeIn,
  181. // const BYTE * pbyteIn
  182. // )
  183. //
  184. //////////////////////////////////////////////////////////////////////////////
  185. STDMETHODIMP
  186. CCreateServices::SetPropertyBinary(
  187. LPCWSTR pcszNameIn,
  188. const DWORD cbSizeIn,
  189. const BYTE * pbyteIn
  190. )
  191. {
  192. TraceFunc( "[IClusCfgResourceCreate]" );
  193. HRESULT hr;
  194. DWORD cbSize;
  195. DWORD cbName;
  196. DWORD cbProp;
  197. DWORD cbValue;
  198. LPBYTE pbBuf;
  199. CLUSPROP_LIST * plist;
  200. CLUSPROP_BINARY * pbin;
  201. CLUSPROP_VALUE * pvalue;
  202. //
  203. // Parameter validation
  204. //
  205. if ( pcszNameIn == NULL
  206. || pbyteIn == NULL
  207. || cbSizeIn == 0
  208. )
  209. {
  210. goto InvalidArg;
  211. }
  212. cbName = ( wcslen( pcszNameIn ) + 1 ) * sizeof(WCHAR);
  213. cbProp = sizeof(CLUSPROP_PROPERTY_NAME) // name property
  214. + ALIGN_CLUSPROP( cbName ) // name
  215. ;
  216. cbValue = sizeof(CLUSPROP_BINARY) // binary property
  217. + ALIGN_CLUSPROP( cbSizeIn ) // binary data
  218. ;
  219. cbSize = sizeof(DWORD) // count
  220. + cbProp // name property and name
  221. + cbValue // data property and data
  222. + sizeof(CLUSPROP_VALUE) // endmark
  223. ;
  224. pbBuf = (LPBYTE) TraceAlloc( HEAP_ZERO_MEMORY, cbSize );
  225. if ( pbBuf == NULL )
  226. goto OutOfMemory;
  227. plist = (CLUSPROP_LIST *) pbBuf;
  228. plist->nPropertyCount = 1;
  229. plist->PropertyName.cbLength = cbName;
  230. plist->PropertyName.Syntax.dw = CLUSPROP_SYNTAX_NAME;
  231. CopyMemory( plist->PropertyName.sz, pcszNameIn, cbName );
  232. pbin = (CLUSPROP_BINARY *)( pbBuf + cbProp + sizeof(DWORD) );
  233. pbin->cbLength = cbSizeIn;
  234. pbin->Syntax.dw = CLUSPROP_SYNTAX_LIST_VALUE_BINARY;
  235. CopyMemory( pbin->rgb, pbyteIn, cbSizeIn );
  236. pvalue = (CLUSPROP_VALUE *)( pbBuf + cbProp + cbValue );
  237. pvalue->Syntax.dw = CLUSPROP_SYNTAX_ENDMARK;
  238. hr = THR( m_presentry->StoreClusterResourceControl( CLUSCTL_RESOURCE_SET_PRIVATE_PROPERTIES,
  239. (LPVOID) pbBuf,
  240. cbSize
  241. ) );
  242. TraceFree( pbBuf );
  243. Cleanup:
  244. HRETURN( hr );
  245. InvalidArg:
  246. hr = THR( E_INVALIDARG );
  247. goto Cleanup;
  248. OutOfMemory:
  249. hr = E_OUTOFMEMORY;
  250. goto Cleanup;
  251. } // SetPropertyBinary( )
  252. //////////////////////////////////////////////////////////////////////////////
  253. //
  254. // STDMETHODIMP
  255. // CCreateServices::SetPropertyDWORD(
  256. // LPCWSTR pcszNameIn,
  257. // const DWORD dwDWORDIn
  258. // )
  259. //
  260. //////////////////////////////////////////////////////////////////////////////
  261. STDMETHODIMP
  262. CCreateServices::SetPropertyDWORD(
  263. LPCWSTR pcszNameIn,
  264. const DWORD dwDWORDIn
  265. )
  266. {
  267. TraceFunc( "[IClusCfgResourceCreate]" );
  268. HRESULT hr;
  269. DWORD cbSize;
  270. DWORD cbName;
  271. DWORD cbProp;
  272. DWORD cbValue;
  273. LPBYTE pbBuf;
  274. CLUSPROP_LIST * plist;
  275. CLUSPROP_DWORD * pdword;
  276. CLUSPROP_VALUE * pvalue;
  277. //
  278. // Parameter validation
  279. //
  280. if ( pcszNameIn == NULL )
  281. goto InvalidArg;
  282. cbName = ( wcslen( pcszNameIn ) + 1 ) * sizeof(WCHAR);
  283. cbProp = sizeof(CLUSPROP_PROPERTY_NAME) // name property
  284. + ALIGN_CLUSPROP( cbName ) // name
  285. ;
  286. cbValue = sizeof(CLUSPROP_DWORD) // dword property
  287. + ALIGN_CLUSPROP( sizeof(DWORD) ) // dword data
  288. ;
  289. cbSize = sizeof(DWORD) // count
  290. + cbProp // name property and name
  291. + cbValue // data property and data
  292. + sizeof(CLUSPROP_VALUE) // endmark
  293. ;
  294. pbBuf = (LPBYTE) TraceAlloc( HEAP_ZERO_MEMORY, cbSize );
  295. if ( pbBuf == NULL )
  296. goto OutOfMemory;
  297. plist = (CLUSPROP_LIST *) pbBuf;
  298. plist->nPropertyCount = 1;
  299. plist->PropertyName.cbLength = cbName;
  300. plist->PropertyName.Syntax.dw = CLUSPROP_SYNTAX_NAME;
  301. CopyMemory( plist->PropertyName.sz, pcszNameIn, cbName );
  302. pdword = (CLUSPROP_DWORD *)( pbBuf + cbProp + sizeof(DWORD) );
  303. pdword->cbLength = sizeof(DWORD);
  304. pdword->Syntax.dw = CLUSPROP_SYNTAX_LIST_VALUE_DWORD;
  305. pdword->dw = dwDWORDIn;
  306. pvalue = (CLUSPROP_VALUE *)( pbBuf + cbProp + cbValue );
  307. pvalue->Syntax.dw = CLUSPROP_SYNTAX_ENDMARK;
  308. hr = THR( m_presentry->StoreClusterResourceControl( CLUSCTL_RESOURCE_SET_PRIVATE_PROPERTIES,
  309. (LPVOID) pbBuf,
  310. cbSize
  311. ) );
  312. TraceFree( pbBuf );
  313. Cleanup:
  314. HRETURN( hr );
  315. InvalidArg:
  316. hr = THR( E_INVALIDARG );
  317. goto Cleanup;
  318. OutOfMemory:
  319. hr = E_OUTOFMEMORY;
  320. goto Cleanup;
  321. } // SetPropertyDWORD( )
  322. //////////////////////////////////////////////////////////////////////////////
  323. //
  324. // STDMETHODIMP
  325. // CCreateServices::SetPropertyString(
  326. // LPCWSTR pcszNameIn,
  327. // LPCWSTR pcszStringIn
  328. // )
  329. //
  330. //////////////////////////////////////////////////////////////////////////////
  331. STDMETHODIMP
  332. CCreateServices::SetPropertyString(
  333. LPCWSTR pcszNameIn,
  334. LPCWSTR pcszStringIn
  335. )
  336. {
  337. TraceFunc( "[IClusCfgResourceCreate]" );
  338. HRESULT hr;
  339. DWORD cbSize;
  340. DWORD cbName;
  341. DWORD cbProp;
  342. DWORD cbValue;
  343. DWORD cbValueSz;
  344. LPBYTE pbBuf;
  345. CLUSPROP_LIST * plist;
  346. CLUSPROP_SZ * pSz;
  347. CLUSPROP_VALUE * pvalue;
  348. //
  349. // Parameter validation
  350. //
  351. if ( pcszNameIn == NULL
  352. || pcszStringIn == NULL
  353. )
  354. {
  355. goto InvalidArg;
  356. }
  357. cbName = ( wcslen( pcszNameIn ) + 1 ) * sizeof(WCHAR);
  358. cbValueSz = ( wcslen( pcszStringIn ) + 1 ) * sizeof(WCHAR);
  359. cbProp = sizeof(CLUSPROP_PROPERTY_NAME) // name property
  360. + ALIGN_CLUSPROP( cbName ) // name
  361. ;
  362. cbValue = sizeof(CLUSPROP_SZ) // string property
  363. + ALIGN_CLUSPROP( cbValueSz ) // string data
  364. ;
  365. cbSize = sizeof(DWORD) // count
  366. + cbProp // name property and name
  367. + cbValue // data property and data
  368. + sizeof(CLUSPROP_VALUE) // endmark
  369. ;
  370. pbBuf = (LPBYTE) TraceAlloc( HEAP_ZERO_MEMORY, cbSize );
  371. if ( pbBuf == NULL )
  372. goto OutOfMemory;
  373. plist = (CLUSPROP_LIST *) pbBuf;
  374. plist->nPropertyCount = 1;
  375. plist->PropertyName.cbLength = cbName;
  376. plist->PropertyName.Syntax.dw = CLUSPROP_SYNTAX_NAME;
  377. CopyMemory( plist->PropertyName.sz, pcszNameIn, cbName );
  378. pSz = (CLUSPROP_SZ *)( pbBuf + cbProp + sizeof(DWORD) );
  379. pSz->cbLength = cbValueSz;
  380. pSz->Syntax.dw = CLUSPROP_SYNTAX_LIST_VALUE_SZ;
  381. CopyMemory( pSz->sz, pcszStringIn, cbValueSz );
  382. pvalue = (CLUSPROP_VALUE *)( pbBuf + cbProp + cbValue );
  383. pvalue->Syntax.dw = CLUSPROP_SYNTAX_ENDMARK;
  384. hr = THR( m_presentry->StoreClusterResourceControl( CLUSCTL_RESOURCE_SET_PRIVATE_PROPERTIES,
  385. (LPVOID) pbBuf,
  386. cbSize
  387. ) );
  388. TraceFree( pbBuf );
  389. Cleanup:
  390. HRETURN( hr );
  391. InvalidArg:
  392. hr = THR( E_INVALIDARG );
  393. goto Cleanup;
  394. OutOfMemory:
  395. hr = E_OUTOFMEMORY;
  396. goto Cleanup;
  397. } // SetPropertyString( )
  398. //////////////////////////////////////////////////////////////////////////////
  399. //
  400. // STDMETHODIMP
  401. // CCreateServices::SetPropertyExpandString(
  402. // LPCWSTR pcszNameIn,
  403. // LPCWSTR pcszStringIn
  404. // )
  405. //
  406. //////////////////////////////////////////////////////////////////////////////
  407. STDMETHODIMP
  408. CCreateServices::SetPropertyExpandString(
  409. LPCWSTR pcszNameIn,
  410. LPCWSTR pcszStringIn
  411. )
  412. {
  413. TraceFunc( "[IClusCfgResourceCreate]" );
  414. HRESULT hr;
  415. DWORD cbSize;
  416. DWORD cbName;
  417. DWORD cbProp;
  418. DWORD cbValue;
  419. DWORD cbValueSz;
  420. LPBYTE pbBuf;
  421. CLUSPROP_LIST * plist;
  422. CLUSPROP_SZ * pSz;
  423. CLUSPROP_VALUE * pvalue;
  424. //
  425. // Parameter validation
  426. //
  427. if ( pcszNameIn == NULL
  428. || pcszStringIn == NULL
  429. )
  430. {
  431. goto InvalidArg;
  432. }
  433. cbName = ( wcslen( pcszNameIn ) + 1 ) * sizeof(WCHAR);
  434. cbValueSz = ( wcslen( pcszStringIn ) + 1 ) * sizeof(WCHAR);
  435. cbProp = sizeof(CLUSPROP_PROPERTY_NAME) // name property
  436. + ALIGN_CLUSPROP( cbName ) // name
  437. ;
  438. cbValue = sizeof(CLUSPROP_SZ) // string property
  439. + ALIGN_CLUSPROP( cbValueSz ) // string data
  440. ;
  441. cbSize = sizeof(DWORD) // count
  442. + cbProp // name property and name
  443. + cbValue // data property and data
  444. + sizeof(CLUSPROP_VALUE) // endmark
  445. ;
  446. pbBuf = (LPBYTE) TraceAlloc( HEAP_ZERO_MEMORY, cbSize );
  447. if ( pbBuf == NULL )
  448. goto OutOfMemory;
  449. plist = (CLUSPROP_LIST *) pbBuf;
  450. plist->nPropertyCount = 1;
  451. plist->PropertyName.cbLength = cbName;
  452. plist->PropertyName.Syntax.dw = CLUSPROP_SYNTAX_NAME;
  453. CopyMemory( plist->PropertyName.sz, pcszNameIn, cbName );
  454. pSz = (CLUSPROP_SZ *)( pbBuf + cbProp + sizeof(DWORD) );
  455. pSz->cbLength = cbValueSz;
  456. pSz->Syntax.dw = CLUSPROP_SYNTAX_LIST_VALUE_EXPAND_SZ;
  457. CopyMemory( pSz->sz, pcszStringIn, cbValueSz );
  458. pvalue = (CLUSPROP_VALUE *)( pbBuf + cbProp + cbValue );
  459. pvalue->Syntax.dw = CLUSPROP_SYNTAX_ENDMARK;
  460. hr = THR( m_presentry->StoreClusterResourceControl( CLUSCTL_RESOURCE_SET_PRIVATE_PROPERTIES,
  461. (LPVOID) pbBuf,
  462. cbSize
  463. ) );
  464. TraceFree( pbBuf );
  465. Cleanup:
  466. HRETURN( hr );
  467. InvalidArg:
  468. hr = THR( E_INVALIDARG );
  469. goto Cleanup;
  470. OutOfMemory:
  471. hr = E_OUTOFMEMORY;
  472. goto Cleanup;
  473. } // SetPropertyExpandString( )
  474. //////////////////////////////////////////////////////////////////////////////
  475. //
  476. // STDMETHODIMP
  477. // CCreateServices::SetPropertyMultiString(
  478. // LPCWSTR pcszNameIn,
  479. // const DWORD cbSizeIn,
  480. // LPCWSTR pcszStringIn
  481. // )
  482. //
  483. //////////////////////////////////////////////////////////////////////////////
  484. STDMETHODIMP
  485. CCreateServices::SetPropertyMultiString(
  486. LPCWSTR pcszNameIn,
  487. const DWORD cbSizeIn,
  488. LPCWSTR pcszStringIn
  489. )
  490. {
  491. TraceFunc( "[IClusCfgResourceCreate]" );
  492. HRESULT hr;
  493. DWORD cbSize;
  494. DWORD cbName;
  495. DWORD cbProp;
  496. DWORD cbValue;
  497. LPBYTE pbBuf;
  498. CLUSPROP_LIST * plist;
  499. CLUSPROP_SZ * pSz;
  500. CLUSPROP_VALUE * pvalue;
  501. //
  502. // Parameter validation
  503. //
  504. if ( pcszNameIn == NULL
  505. || pcszStringIn == NULL
  506. )
  507. {
  508. goto InvalidArg;
  509. }
  510. cbName = ( wcslen( pcszNameIn ) + 1 ) * sizeof(WCHAR);
  511. cbProp = sizeof(CLUSPROP_PROPERTY_NAME) // name property
  512. + ALIGN_CLUSPROP( cbName ) // name
  513. ;
  514. cbValue = sizeof(CLUSPROP_SZ) // string property
  515. + ALIGN_CLUSPROP( cbSizeIn ) // string data
  516. ;
  517. cbSize = sizeof(DWORD) // count
  518. + cbProp // name property and name
  519. + cbValue // data property and data
  520. + sizeof(CLUSPROP_VALUE) // endmark
  521. ;
  522. pbBuf = (LPBYTE) TraceAlloc( HEAP_ZERO_MEMORY, cbSize );
  523. if ( pbBuf == NULL )
  524. goto OutOfMemory;
  525. plist = (CLUSPROP_LIST *) pbBuf;
  526. plist->nPropertyCount = 1;
  527. plist->PropertyName.cbLength = cbName;
  528. plist->PropertyName.Syntax.dw = CLUSPROP_SYNTAX_NAME;
  529. CopyMemory( plist->PropertyName.sz, pcszNameIn, cbName );
  530. pSz = (CLUSPROP_SZ *)( pbBuf + cbProp + sizeof(DWORD) );
  531. pSz->cbLength = cbSizeIn;
  532. pSz->Syntax.dw = CLUSPROP_SYNTAX_LIST_VALUE_MULTI_SZ;
  533. CopyMemory( pSz->sz, pcszStringIn, cbSizeIn );
  534. pvalue = (CLUSPROP_VALUE *)( pbBuf + cbProp + cbValue );
  535. pvalue->Syntax.dw = CLUSPROP_SYNTAX_ENDMARK;
  536. hr = THR( m_presentry->StoreClusterResourceControl( CLUSCTL_RESOURCE_SET_PRIVATE_PROPERTIES,
  537. (LPVOID) pbBuf,
  538. cbSize
  539. ) );
  540. TraceFree( pbBuf );
  541. Cleanup:
  542. HRETURN( hr );
  543. InvalidArg:
  544. hr = THR( E_INVALIDARG );
  545. goto Cleanup;
  546. OutOfMemory:
  547. hr = E_OUTOFMEMORY;
  548. goto Cleanup;
  549. } // SetPropertyMultiString( )
  550. //////////////////////////////////////////////////////////////////////////////
  551. //
  552. // STDMETHODIMP
  553. // CCreateServices::SetPropertyUnsignedLargeInt(
  554. // LPCWSTR pcszNameIn,
  555. // const ULARGE_INTEGER ulIntIn
  556. // )
  557. //
  558. //////////////////////////////////////////////////////////////////////////////
  559. STDMETHODIMP
  560. CCreateServices::SetPropertyUnsignedLargeInt(
  561. LPCWSTR pcszNameIn,
  562. const ULARGE_INTEGER ulIntIn
  563. )
  564. {
  565. TraceFunc( "[IClusCfgResourceCreate]" );
  566. HRESULT hr;
  567. DWORD cbSize;
  568. DWORD cbName;
  569. DWORD cbProp;
  570. DWORD cbValue;
  571. LPBYTE pbBuf;
  572. CLUSPROP_LIST * plist;
  573. CLUSPROP_ULARGE_INTEGER * pulint;
  574. CLUSPROP_VALUE * pvalue;
  575. //
  576. // Parameter validation
  577. //
  578. if ( pcszNameIn == NULL )
  579. goto InvalidArg;
  580. cbName = ( wcslen( pcszNameIn ) + 1 ) * sizeof(WCHAR);
  581. cbProp = sizeof(CLUSPROP_PROPERTY_NAME) // name property
  582. + ALIGN_CLUSPROP( cbName ) // name
  583. ;
  584. cbValue = sizeof(CLUSPROP_ULARGE_INTEGER) // string property
  585. + ALIGN_CLUSPROP(sizeof(ULARGE_INTEGER)) // string data
  586. ;
  587. cbSize = sizeof(DWORD) // count
  588. + cbProp // name property and name
  589. + cbValue // data property and data
  590. + sizeof(CLUSPROP_VALUE) // endmark
  591. ;
  592. pbBuf = (LPBYTE) TraceAlloc( HEAP_ZERO_MEMORY, cbSize );
  593. if ( pbBuf == NULL )
  594. goto OutOfMemory;
  595. plist = (CLUSPROP_LIST *) pbBuf;
  596. plist->nPropertyCount = 1;
  597. plist->PropertyName.cbLength = cbName;
  598. plist->PropertyName.Syntax.dw = CLUSPROP_SYNTAX_NAME;
  599. CopyMemory( plist->PropertyName.sz, pcszNameIn, cbName );
  600. pulint = (CLUSPROP_ULARGE_INTEGER *)( pbBuf + cbProp + sizeof(DWORD) );
  601. pulint->cbLength = sizeof(ULARGE_INTEGER);
  602. pulint->Syntax.dw = CLUSPROP_SYNTAX_LIST_VALUE_LARGE_INTEGER;
  603. pulint->li = ulIntIn;
  604. pvalue = (CLUSPROP_VALUE *)( pbBuf + cbProp + cbValue );
  605. pvalue->Syntax.dw = CLUSPROP_SYNTAX_ENDMARK;
  606. hr = THR( m_presentry->StoreClusterResourceControl( CLUSCTL_RESOURCE_SET_PRIVATE_PROPERTIES,
  607. (LPVOID) pbBuf,
  608. cbSize
  609. ) );
  610. TraceFree( pbBuf );
  611. Cleanup:
  612. HRETURN( hr );
  613. InvalidArg:
  614. hr = THR( E_INVALIDARG );
  615. goto Cleanup;
  616. OutOfMemory:
  617. hr = E_OUTOFMEMORY;
  618. goto Cleanup;
  619. } // SetPropertyUnsignedLargeInt( )
  620. //////////////////////////////////////////////////////////////////////////////
  621. //
  622. // STDMETHODIMP
  623. // CCreateServices::SetPropertyLong(
  624. // LPCWSTR pcszNameIn,
  625. // const LONG lLongIn
  626. // )
  627. //
  628. //////////////////////////////////////////////////////////////////////////////
  629. STDMETHODIMP
  630. CCreateServices::SetPropertyLong(
  631. LPCWSTR pcszNameIn,
  632. const LONG lLongIn
  633. )
  634. {
  635. TraceFunc( "[IClusCfgResourceCreate]" );
  636. HRESULT hr;
  637. DWORD cbSize;
  638. DWORD cbName;
  639. DWORD cbProp;
  640. DWORD cbValue;
  641. LPBYTE pbBuf;
  642. CLUSPROP_LIST * plist;
  643. CLUSPROP_DWORD * pdword;
  644. CLUSPROP_VALUE * pvalue;
  645. //
  646. // Parameter validation
  647. //
  648. if ( pcszNameIn == NULL )
  649. goto InvalidArg;
  650. cbName = ( wcslen( pcszNameIn ) + 1 ) * sizeof(WCHAR);
  651. cbProp = sizeof(CLUSPROP_PROPERTY_NAME) // name property
  652. + ALIGN_CLUSPROP( cbName ) // name
  653. ;
  654. cbValue = sizeof(CLUSPROP_DWORD) // dword property
  655. + ALIGN_CLUSPROP( sizeof(DWORD) ) // dword data
  656. ;
  657. cbSize = sizeof(DWORD) // count
  658. + cbProp // name property and name
  659. + cbValue // data property and data
  660. + sizeof(CLUSPROP_VALUE) // endmark
  661. ;
  662. pbBuf = (LPBYTE) TraceAlloc( HEAP_ZERO_MEMORY, cbSize );
  663. if ( pbBuf == NULL )
  664. goto OutOfMemory;
  665. plist = (CLUSPROP_LIST *) pbBuf;
  666. plist->nPropertyCount = 1;
  667. plist->PropertyName.cbLength = cbName;
  668. plist->PropertyName.Syntax.dw = CLUSPROP_SYNTAX_NAME;
  669. CopyMemory( plist->PropertyName.sz, pcszNameIn, cbName );
  670. pdword = (CLUSPROP_DWORD *)( pbBuf + cbProp + sizeof(DWORD) );
  671. pdword->cbLength = sizeof(DWORD);
  672. pdword->Syntax.dw = CLUSPROP_SYNTAX_LIST_VALUE_LONG;
  673. pdword->dw = lLongIn;
  674. pvalue = (CLUSPROP_VALUE *)( pbBuf + cbProp + cbValue );
  675. pvalue->Syntax.dw = CLUSPROP_SYNTAX_ENDMARK;
  676. hr = THR( m_presentry->StoreClusterResourceControl( CLUSCTL_RESOURCE_SET_PRIVATE_PROPERTIES,
  677. (LPVOID) pbBuf,
  678. cbSize
  679. ) );
  680. TraceFree( pbBuf );
  681. Cleanup:
  682. HRETURN( hr );
  683. InvalidArg:
  684. hr = THR( E_INVALIDARG );
  685. goto Cleanup;
  686. OutOfMemory:
  687. hr = E_OUTOFMEMORY;
  688. goto Cleanup;
  689. } // SetPropertyLong( )
  690. //////////////////////////////////////////////////////////////////////////////
  691. //
  692. // STDMETHODIMP
  693. // CCreateServices::SetPropertySecurityDescriptor(
  694. // LPCWSTR pcszNameIn,
  695. // const SECURITY_DESCRIPTOR * pcsdIn
  696. // )
  697. //
  698. //////////////////////////////////////////////////////////////////////////////
  699. STDMETHODIMP
  700. CCreateServices::SetPropertySecurityDescriptor(
  701. LPCWSTR pcszNameIn,
  702. const SECURITY_DESCRIPTOR * pcsdIn
  703. )
  704. {
  705. TraceFunc( "[IClusCfgResourceCreate]" );
  706. HRESULT hr = THR( E_NOTIMPL );
  707. HRETURN( hr );
  708. } // SetPropertySecurityDescriptor( )
  709. //////////////////////////////////////////////////////////////////////////////
  710. //
  711. // STDMETHODIMP
  712. // CCreateServices::SetPropertyLargeInt(
  713. // LPCWSTR pcszNameIn,
  714. // const LARGE_INTEGER lIntIn
  715. // )
  716. //
  717. //////////////////////////////////////////////////////////////////////////////
  718. STDMETHODIMP
  719. CCreateServices::SetPropertyLargeInt(
  720. LPCWSTR pcszNameIn,
  721. const LARGE_INTEGER lIntIn
  722. )
  723. {
  724. TraceFunc( "[IClusCfgResourceCreate]" );
  725. HRESULT hr;
  726. DWORD cbSize;
  727. DWORD cbName;
  728. DWORD cbProp;
  729. DWORD cbValue;
  730. LPBYTE pbBuf;
  731. CLUSPROP_LIST * plist;
  732. CLUSPROP_ULARGE_INTEGER * pulint;
  733. CLUSPROP_VALUE * pvalue;
  734. //
  735. // Parameter validation
  736. //
  737. if ( pcszNameIn == NULL )
  738. goto InvalidArg;
  739. cbName = ( wcslen( pcszNameIn ) + 1 ) * sizeof(WCHAR);
  740. cbProp = sizeof(CLUSPROP_PROPERTY_NAME) // name property
  741. + ALIGN_CLUSPROP( cbName ) // name
  742. ;
  743. cbValue = sizeof(CLUSPROP_ULARGE_INTEGER) // string property
  744. + ALIGN_CLUSPROP(sizeof(LARGE_INTEGER)) // string data
  745. ;
  746. cbSize = sizeof(DWORD) // count
  747. + cbProp // name property and name
  748. + cbValue // data property and data
  749. + sizeof(CLUSPROP_VALUE) // endmark
  750. ;
  751. pbBuf = (LPBYTE) TraceAlloc( HEAP_ZERO_MEMORY, cbSize );
  752. if ( pbBuf == NULL )
  753. goto OutOfMemory;
  754. plist = (CLUSPROP_LIST *) pbBuf;
  755. plist->nPropertyCount = 1;
  756. plist->PropertyName.cbLength = cbName;
  757. plist->PropertyName.Syntax.dw = CLUSPROP_SYNTAX_NAME;
  758. CopyMemory( plist->PropertyName.sz, pcszNameIn, cbName );
  759. pulint = (CLUSPROP_ULARGE_INTEGER *)( pbBuf + cbProp + sizeof(DWORD) );
  760. pulint->cbLength = sizeof(LARGE_INTEGER);
  761. pulint->Syntax.dw = CLUSPROP_SYNTAX_LIST_VALUE_LARGE_INTEGER;
  762. CopyMemory( &pulint->li, &lIntIn, sizeof(LARGE_INTEGER) );
  763. pvalue = (CLUSPROP_VALUE *)( pbBuf + cbProp + cbValue );
  764. pvalue->Syntax.dw = CLUSPROP_SYNTAX_ENDMARK;
  765. hr = THR( m_presentry->StoreClusterResourceControl( CLUSCTL_RESOURCE_SET_PRIVATE_PROPERTIES,
  766. (LPVOID) pbBuf,
  767. cbSize
  768. ) );
  769. TraceFree( pbBuf );
  770. Cleanup:
  771. HRETURN( hr );
  772. InvalidArg:
  773. hr = THR( E_INVALIDARG );
  774. goto Cleanup;
  775. OutOfMemory:
  776. hr = E_OUTOFMEMORY;
  777. goto Cleanup;
  778. } // SetPropertyLargeInt( )
  779. //////////////////////////////////////////////////////////////////////////////
  780. //
  781. // STDMETHODIMP
  782. // CCreateServices::SendResourceControl(
  783. // DWORD dwControlCode,
  784. // LPVOID lpInBuffer,
  785. // DWORD cbInBufferSize
  786. // )
  787. //
  788. //////////////////////////////////////////////////////////////////////////////
  789. STDMETHODIMP
  790. CCreateServices::SendResourceControl(
  791. DWORD dwControlCode,
  792. LPVOID lpInBuffer,
  793. DWORD cbInBufferSize
  794. )
  795. {
  796. TraceFunc( "[IClusCfgResourceCreate]" );
  797. HRESULT hr;
  798. hr = THR( m_presentry->StoreClusterResourceControl( dwControlCode,
  799. lpInBuffer,
  800. cbInBufferSize
  801. ) );
  802. HRETURN( hr );
  803. } // SendResourceControl( )
  804. //****************************************************************************
  805. //
  806. // IPrivatePostCfgResource
  807. //
  808. //****************************************************************************
  809. //////////////////////////////////////////////////////////////////////////////
  810. //
  811. // STDMETHODIMP
  812. // CCreateServices::SetEntry(
  813. // CResourceEntry * presentryIn
  814. // )
  815. //
  816. //////////////////////////////////////////////////////////////////////////////
  817. STDMETHODIMP
  818. CCreateServices::SetEntry(
  819. CResourceEntry * presentryIn
  820. )
  821. {
  822. TraceFunc( "[IPrivatePostCfgResource]" );
  823. HRESULT hr = S_OK;
  824. Assert( presentryIn != NULL );
  825. m_presentry = presentryIn;
  826. HRETURN( hr );
  827. } // SetEntry( )