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.

947 lines
25 KiB

  1. //+============================================================================
  2. //
  3. // File: SSMapStm.cxx
  4. //
  5. // Purpose: This file defines the CSSMappedStream class.
  6. // This class provdes a IMappedStream implementation
  7. // which maps an IStream from a Compound File.
  8. //
  9. // History:
  10. //
  11. // 5/6/98 MikeHill
  12. // - Use CoTaskMem rather than new/delete.
  13. //
  14. //+============================================================================
  15. // --------
  16. // Includes
  17. // --------
  18. #include <pch.cxx>
  19. #include "SSMapStm.hxx"
  20. #include <privguid.h> // IID_IMappedStream
  21. #ifdef _MAC_NODOC
  22. ASSERTDATA // File-specific data for FnAssert
  23. #endif
  24. //+----------------------------------------------------------------------------
  25. //
  26. // Method: CSSMappedStream::Initialize
  27. //
  28. // Synopsis: Zero-out all of the member data.
  29. //
  30. // Arguments: None
  31. //
  32. // Returns: None
  33. //
  34. //
  35. //+----------------------------------------------------------------------------
  36. VOID
  37. CSSMappedStream::Initialize()
  38. {
  39. propDbg(( DEB_ITRACE, "CSSMappedStream::Initialize\n" ));
  40. _pstm = NULL;
  41. _pbMappedStream = NULL;
  42. _cbMappedStream = 0;
  43. _cbActualStreamSize = 0;
  44. _powner = NULL;
  45. _fLowMem = FALSE;
  46. _fDirty = FALSE;
  47. #if DBGPROP
  48. _fChangePending = FALSE;
  49. #endif
  50. } // CSSMappedStream::Initialize()
  51. //+----------------------------------------------------------------------------
  52. //
  53. // Member: Constructor/Destructor
  54. //
  55. // Synopsis: Initialize/cleanup this object.
  56. //
  57. //+----------------------------------------------------------------------------
  58. CSSMappedStream::CSSMappedStream( IStream *pstm )
  59. {
  60. DfpAssert( NULL != pstm );
  61. // Initialize the member data.
  62. Initialize();
  63. // Keep a copy of the Stream that we're mapping.
  64. _pstm = pstm;
  65. _pstm->AddRef();
  66. _cRefs = 1;
  67. }
  68. CSSMappedStream::~CSSMappedStream( )
  69. {
  70. // Just to be safe, free the mapping buffer (it should have
  71. // already been freed).
  72. DfpAssert( NULL == _pbMappedStream );
  73. CoTaskMemFree( _pbMappedStream );
  74. // If we've got the global reserved buffer locked,
  75. // free it now.
  76. if (_fLowMem)
  77. {
  78. g_ReservedMemory.UnlockMemory();
  79. }
  80. // Free the stream which we were mapping.
  81. if( NULL != _pstm )
  82. _pstm->Release();
  83. }
  84. //+-------------------------------------------------------------------
  85. //
  86. // Member: CSSMappedStream::QueryInterface, AddRef, Release
  87. //
  88. // Synopsis: IUnknown members
  89. //
  90. //--------------------------------------------------------------------
  91. HRESULT CSSMappedStream::QueryInterface( REFIID riid, void **ppvObject)
  92. {
  93. HRESULT hr = S_OK;
  94. // Validate the inputs
  95. VDATEREADPTRIN( &riid, IID );
  96. VDATEPTROUT( ppvObject, void* );
  97. // -----------------
  98. // Perform the Query
  99. // -----------------
  100. *ppvObject = NULL;
  101. if (IsEqualIID(riid,IID_IMappedStream) || IsEqualIID(riid,IID_IUnknown))
  102. {
  103. *ppvObject = (IMappedStream *)this;
  104. CSSMappedStream::AddRef();
  105. }
  106. else
  107. {
  108. hr = E_NOINTERFACE;
  109. }
  110. return(hr);
  111. }
  112. ULONG CSSMappedStream::AddRef(void)
  113. {
  114. InterlockedIncrement(&_cRefs);
  115. return(_cRefs);
  116. }
  117. ULONG CSSMappedStream::Release(void)
  118. {
  119. LONG lRet;
  120. lRet = InterlockedDecrement(&_cRefs);
  121. if (lRet == 0)
  122. {
  123. delete this;
  124. }
  125. else
  126. if (lRet <0)
  127. {
  128. lRet = 0;
  129. }
  130. return(lRet);
  131. }
  132. //+----------------------------------------------------------------------------
  133. //
  134. // Method: CSSMappedStream::Open
  135. //
  136. // Synopsis: Open up the Stream which we're mapping, and
  137. // read it's data into a buffer.
  138. //
  139. // Arguments: [VOID*] powner
  140. // The owner of this Stream. We use this for the
  141. // PrOnMappedStreamEvent call.
  142. // [HRESULT*] phr
  143. // The return code.
  144. //
  145. // Returns: Nothing.
  146. //
  147. //+----------------------------------------------------------------------------
  148. VOID
  149. CSSMappedStream::Open( IN VOID *powner,
  150. OUT HRESULT *phr )
  151. {
  152. HRESULT &hr = *phr;
  153. VOID *pv = NULL;
  154. DfpAssert(!_fLowMem);
  155. hr = S_OK;
  156. propITrace( "CSSMappedStream::Open" );
  157. // If given a pointer to the owner of this mapped stream,
  158. // save it. This could be NULL (i.e., when called from
  159. // ReOpen).
  160. if( NULL != powner )
  161. _powner = powner;
  162. // If we haven't already read the stream, read it now.
  163. if( NULL == _pbMappedStream )
  164. {
  165. STATSTG statstg;
  166. LARGE_INTEGER liSeek;
  167. DfpAssert( NULL != _pstm );
  168. DfpAssert( 0 == _cbMappedStream );
  169. DfpAssert( 0 == _cbActualStreamSize );
  170. // Get and validate the size of the Stream.
  171. *phr = _pstm->Stat( &statstg, STATFLAG_NONAME );
  172. if( FAILED(*phr) ) goto Exit;
  173. if( statstg.cbSize.HighPart != 0
  174. ||
  175. statstg.cbSize.LowPart > CBMAXPROPSETSTREAM )
  176. {
  177. *phr = STG_E_INVALIDHEADER;
  178. goto Exit;
  179. }
  180. _cbMappedStream = _cbActualStreamSize = statstg.cbSize.LowPart;
  181. // Allocate a buffer to hold the Stream. If there isn't sufficient
  182. // memory in the system, lock and get the reserved buffer. In the
  183. // end, 'pv' points to the appropriate buffer.
  184. pv = CoTaskMemAlloc( _cbActualStreamSize );
  185. if (pv == NULL)
  186. {
  187. pv = g_ReservedMemory.LockMemory(); // could wait until previous
  188. // property call completes
  189. _fLowMem = TRUE;
  190. }
  191. _pbMappedStream = (BYTE*) pv;
  192. // Seek to the start of the Stream.
  193. liSeek.HighPart = 0;
  194. liSeek.LowPart = 0;
  195. *phr = _pstm->Seek( liSeek, STREAM_SEEK_SET, NULL );
  196. if( FAILED(*phr) ) goto Exit;
  197. // Read in the Stream. But only if it is non-zero; some
  198. // stream implementations (namely the Mac StreamOnHGlobal imp)
  199. // don't allow 0-length reads.
  200. if( 0 != _cbActualStreamSize )
  201. {
  202. *phr = _pstm->Read(
  203. _pbMappedStream,
  204. _cbActualStreamSize,
  205. &_cbMappedStream);
  206. if( FAILED(*phr) ) goto Exit;
  207. // Ensure that we got all the bytes we requested.
  208. if( _cbMappedStream != _cbActualStreamSize )
  209. {
  210. propDbg((DEBTRACE_ERROR,
  211. "CSSMappedStream(%08X)::Open bytes-read (%lu) doesn't match bytes-requested (%lu)\n",
  212. this, _cbMappedStream, _cbActualStreamSize ));
  213. *phr = STG_E_INVALIDHEADER;
  214. goto Exit;
  215. }
  216. }
  217. #if BIGENDIAN==1
  218. // Notify our owner that we've read in new data.
  219. if( _powner != NULL && 0 != _cbMappedStream )
  220. {
  221. *phr = PrOnMappedStreamEvent( _powner, _pbMappedStream, _cbMappedStream );
  222. if( FAILED(*phr) ) goto Exit;
  223. }
  224. #endif
  225. } // if( NULL == _pbMappedStream )
  226. // ----
  227. // Exit
  228. // ----
  229. Exit:
  230. // If there was an error, free any memory we have.
  231. if( FAILED(*phr) )
  232. {
  233. propDbg((DEB_ERROR, "CSSMappedStream(%08X):Open exception returns %08X\n", this, *phr));
  234. if (_fLowMem)
  235. g_ReservedMemory.UnlockMemory();
  236. else
  237. CoTaskMemFree( pv );
  238. _pbMappedStream = NULL;
  239. _cbMappedStream = 0;
  240. _cbActualStreamSize = 0;
  241. _fLowMem = FALSE;
  242. }
  243. return;
  244. } // CSSMappedStream::Open
  245. //+-------------------------------------------------------------------
  246. //
  247. // Member: CSSMappedStream::Flush
  248. //
  249. // Synopsis: Write out the mapping buffer to the Stream,
  250. // and Commit it.
  251. //
  252. // Arguments: [LONG*] phr
  253. // An HRESULT return code.
  254. //
  255. // Returns: None.
  256. //
  257. //--------------------------------------------------------------------
  258. VOID CSSMappedStream::Flush(OUT LONG *phr)
  259. {
  260. HRESULT &hr = *phr;
  261. propITrace( "CSSMappedStream::Flush" );
  262. // Write out any data we have cached to the Stream.
  263. hr = Write();
  264. // Commit the Stream.
  265. if( SUCCEEDED(hr) )
  266. {
  267. hr = _pstm->Commit(STGC_DEFAULT);
  268. }
  269. return;
  270. }
  271. //+-------------------------------------------------------------------
  272. //
  273. // Member: CSSMappedStream::Close
  274. //
  275. // Synopsis: Close the mapped stream by writing out
  276. // the mapping buffer and then freeing it.
  277. //
  278. // Arguments: [LONG*] phr
  279. // An HRESULT error code.
  280. //
  281. // Returns: None.
  282. //
  283. //--------------------------------------------------------------------
  284. VOID CSSMappedStream::Close(OUT LONG *phr)
  285. {
  286. // Write the changes. We don't need to Commit them,
  287. // they will be implicitely committed when the
  288. // Stream is Released.
  289. HRESULT &hr = *phr;
  290. propITrace( "CSSMappedStream::Close" );
  291. hr = Write();
  292. // Even if we fail the write, we must free the memory.
  293. // (PrClosePropertySet deletes everything whether or not
  294. // there was an error here, so we must free the memory.
  295. // There's no danger of this happenning due to out-of-
  296. // disk-space conditions, because the propset code
  297. // pre-allocates).
  298. CoTaskMemFree( _pbMappedStream );
  299. _pstm->Release();
  300. // Re-zero the member data.
  301. Initialize();
  302. return;
  303. }
  304. //+-------------------------------------------------------------------
  305. //
  306. // Member: CSSMappedStream::ReOpen
  307. //
  308. // Synopsis: Gets the caller a pointer to the already-opened
  309. // mapping buffer. If it isn't already opened, then
  310. // it is opened here.
  311. //
  312. // Arguments: [VOID**] ppv
  313. // Used to return the mapping buffer.
  314. // [LONG*] phr
  315. // Used to return an HRESULT.
  316. //
  317. // Returns: None.
  318. //
  319. //--------------------------------------------------------------------
  320. VOID CSSMappedStream::ReOpen(IN OUT VOID **ppv, OUT LONG *phr)
  321. {
  322. *ppv = NULL;
  323. Open(NULL, // Unspecified owner.
  324. phr);
  325. if( SUCCEEDED(*phr) )
  326. *ppv = _pbMappedStream;
  327. return;
  328. }
  329. //+-------------------------------------------------------------------
  330. //
  331. // Member: CSSMappedStream::Quiesce
  332. //
  333. // Synopsis: Unnecessary for this IMappedStream implementation.
  334. //
  335. //--------------------------------------------------------------------
  336. VOID CSSMappedStream::Quiesce(VOID)
  337. {
  338. DfpAssert(_pbMappedStream != NULL);
  339. }
  340. //+-------------------------------------------------------------------
  341. //
  342. // Member: CSSMappedStream::Map
  343. //
  344. // Synopsis: Used to get a pointer to the current mapping.
  345. //
  346. // Arguments: [BOOLEAN] fCreate
  347. // Not used by this IMappedStream implementation.
  348. // [VOID**] ppv
  349. // Used to return the mapping buffer.
  350. //
  351. // Returns: None.
  352. //
  353. //--------------------------------------------------------------------
  354. VOID CSSMappedStream::Map(BOOLEAN fCreate, VOID **ppv)
  355. {
  356. DfpAssert(_pbMappedStream != NULL);
  357. *ppv = _pbMappedStream;
  358. }
  359. //+-------------------------------------------------------------------
  360. //
  361. // Member: CSSMappedStream::Unmap
  362. //
  363. // Synopsis: Unnecessary for this IMappedStream implementation.
  364. //
  365. //--------------------------------------------------------------------
  366. VOID CSSMappedStream::Unmap(BOOLEAN fFlush, VOID **ppv)
  367. {
  368. *ppv = NULL;
  369. }
  370. //+-------------------------------------------------------------------
  371. //
  372. // Member: CSSMappedStream::Write
  373. //
  374. // Synopsis: Writes the mapping buffer out to the original
  375. // Stream.
  376. //
  377. // Arguments: None.
  378. //
  379. // Returns: [HRESULT]
  380. // S_FALSE => Nothing needed to be written
  381. //
  382. //--------------------------------------------------------------------
  383. #define STACK_BYTES 16
  384. HRESULT CSSMappedStream::Write ()
  385. {
  386. HRESULT hr;
  387. ULONG cbWritten;
  388. LARGE_INTEGER liSeek;
  389. BOOL fOwnerSignaled = FALSE;
  390. propITrace( "CSSMappedStream::Write" );
  391. // We can return right away if there's nothing to write.
  392. // (_pbMappedStream may be NULL in the error path of our
  393. // caller).
  394. if (!_fDirty || NULL == _pbMappedStream )
  395. {
  396. propDbg((DEB_PROP_INFO, "CPubStream(%08X):Flush returns with not-dirty\n", this));
  397. return S_FALSE;
  398. }
  399. DfpAssert( _pstm != NULL );
  400. #if BIGENDIAN==1
  401. // Notify our owner that we're about to perform a Write.
  402. // Note that there are no goto Exit calls prior to this point, because
  403. // we making a corresponding call to PrOnMappedStreamEvent (for byte-swapping)
  404. // in the Exit.
  405. hr = PrOnMappedStreamEvent( _powner, _pbMappedStream, _cbMappedStream );
  406. if( S_OK != hr ) goto Exit;
  407. fOwnerSignaled = TRUE;
  408. #endif
  409. // Seek to the start of the Stream.
  410. liSeek.HighPart = 0;
  411. liSeek.LowPart = 0;
  412. hr = _pstm->Seek( liSeek, STREAM_SEEK_SET, NULL );
  413. if( FAILED(hr) ) goto Exit;
  414. // Write out the mapping buffer.
  415. hr = _pstm->Write(_pbMappedStream, _cbMappedStream, &cbWritten);
  416. if( S_OK != hr ) goto Exit;
  417. if( cbWritten != _cbMappedStream )
  418. {
  419. propDbg((DEB_ERROR,
  420. "CSSMappedStream(%08X)::Write bytes-written (%lu) doesn't match bytes-requested (%lu)\n",
  421. this, cbWritten, _cbMappedStream ));
  422. hr = STG_E_INVALIDHEADER;
  423. goto Exit;
  424. }
  425. // If the buffer is shrinking, this is a good time to shrink the Stream.
  426. if (_cbMappedStream < _cbActualStreamSize)
  427. {
  428. ULARGE_INTEGER uli;
  429. uli.HighPart = 0;
  430. uli.LowPart = _cbMappedStream;
  431. hr = _pstm->SetSize(uli);
  432. if( S_OK == hr )
  433. {
  434. _cbActualStreamSize = _cbMappedStream;
  435. }
  436. }
  437. //
  438. // If we changed the buffer size and it is less than the
  439. // actual underlying stream, then we need to zero out the memory
  440. // above the currrent size.
  441. //
  442. if (_cbMappedStream < _cbActualStreamSize)
  443. {
  444. PBYTE pTemp;
  445. LARGE_INTEGER li;
  446. DWORD cbWrite = _cbActualStreamSize - _cbMappedStream;
  447. li.HighPart = 0;
  448. li.LowPart = _cbMappedStream;
  449. hr = _pstm->Seek(li,STREAM_SEEK_SET,NULL);
  450. if (SUCCEEDED(hr))
  451. {
  452. pTemp = reinterpret_cast<PBYTE>( CoTaskMemAlloc( cbWrite ));
  453. if (pTemp != NULL)
  454. {
  455. memset(pTemp,0,cbWrite);
  456. //
  457. // Successfully allocated memory for the write. Write the
  458. // zeros out all at once.
  459. //
  460. hr = _pstm->Write(pTemp, cbWrite, NULL);
  461. if (FAILED(hr))
  462. {
  463. propDbg((DEB_ERROR, "CSSMappedStream::Write "
  464. "write failure\n",hr));
  465. goto Exit;
  466. }
  467. CoTaskMemFree( pTemp );
  468. }
  469. else
  470. {
  471. //
  472. // We couldn't allocate memory. So we will use a small
  473. // stack buffer instead.
  474. //
  475. BYTE stackBuf[STACK_BYTES];
  476. memset(stackBuf, 0, STACK_BYTES);
  477. while (cbWrite >= STACK_BYTES)
  478. {
  479. hr = _pstm->Write(stackBuf, STACK_BYTES, NULL);
  480. if (FAILED(hr))
  481. {
  482. propDbg((DEB_ERROR, "CSSMappedStream::Write write failure\n",hr));
  483. goto Exit;
  484. }
  485. cbWrite -= STACK_BYTES;
  486. }
  487. if (cbWrite < STACK_BYTES)
  488. {
  489. hr = _pstm->Write(stackBuf, cbWrite, NULL);
  490. if (FAILED(hr))
  491. {
  492. propDbg((DEB_ERROR, "CSSMappedStream::Write write failure\n",hr));
  493. goto Exit;
  494. }
  495. }
  496. }
  497. }
  498. else
  499. {
  500. propDbg((DEB_ERROR, "CSSMappedStream::Write seek failure\n",hr));
  501. goto Exit;
  502. }
  503. }
  504. // ----
  505. // Exit
  506. // ----
  507. Exit:
  508. // Notify our owner that we're done with the Write. We do this
  509. // whether or not there was an error, because _pbMappedStream is
  510. // not modified, and therefore intact even in the error path.
  511. // This call allows the owner to correct the byte-order of the header.
  512. #if BIGENDIAN==1
  513. if( fOwnerSignaled )
  514. DfpVerify( PrOnMappedStreamEvent( _powner, _pbMappedStream, _cbMappedStream ));
  515. #endif
  516. if (hr == S_OK || hr == STG_E_REVERTED)
  517. {
  518. _fDirty = FALSE;
  519. }
  520. return hr;
  521. }
  522. //+-------------------------------------------------------------------
  523. //
  524. // Member: CSSMappedStream::GetSize
  525. //
  526. // Synopsis: Returns the current size of the mapped stream.
  527. //
  528. // Arguments: [LONG*] phr
  529. // Used to return an HRESULT.
  530. //
  531. // Returns: [ULONG]
  532. // The current size.
  533. //
  534. //--------------------------------------------------------------------
  535. ULONG CSSMappedStream::GetSize(OUT LONG *phr)
  536. {
  537. HRESULT &hr = *phr;
  538. hr = S_OK;
  539. propITrace( "CSSMappedStream::GetSize" );
  540. // If necessary, open the Stream.
  541. if( NULL == _pbMappedStream )
  542. {
  543. Open(NULL, // Unspecified owner
  544. phr);
  545. }
  546. if( SUCCEEDED(*phr) )
  547. {
  548. DfpAssert( NULL != _pbMappedStream );
  549. }
  550. // Return the size of the mapped stream. If there was an
  551. // Open error, it will be zero, and *phr will be set.
  552. propDbg(( DEB_ITRACE, "CSSMappedStream::GetSize, size is %d\n", _cbMappedStream ));
  553. return _cbMappedStream;
  554. }
  555. //+-------------------------------------------------------------------
  556. //
  557. // Member: CSSMappedStream::SetSize
  558. //
  559. // Synopsis: Set the size of the mapped stream.
  560. //
  561. // Arguments: [ULONG] cb
  562. // The new size.
  563. // [BOOLEAN] fPersistent
  564. // If not set, then this change will not be stored -
  565. // thus the mapping buffer must be set, but the
  566. // Stream itself must not. This was added so that
  567. // CPropertySetStream could grow the buffer for internal
  568. // processing, when the Stream itself is read-only.
  569. // [VOID**] ppv
  570. // Used to return the new mapping buffer location.
  571. //
  572. // Returns: None.
  573. //
  574. // Pre-Conditions:
  575. // cb is below the maximum property set size.
  576. //
  577. //--------------------------------------------------------------------
  578. VOID
  579. CSSMappedStream::SetSize(ULONG cb,
  580. IN BOOLEAN fPersistent,
  581. VOID **ppv, OUT LONG *phr)
  582. {
  583. BYTE *pv;
  584. HRESULT &hr = *phr;
  585. hr = S_OK;
  586. DfpAssert(cb != 0);
  587. DfpAssert(cb <= CBMAXPROPSETSTREAM);
  588. propITrace( "CSSMappedStream::SetSize" );
  589. propTraceParameters(( "cb=%lu, fPersistent=%s, ppv=%p", cb, fPersistent?"True":"False" ));
  590. //
  591. // if we are growing the data, we should grow the stream
  592. //
  593. if (fPersistent && cb > _cbActualStreamSize)
  594. {
  595. ULARGE_INTEGER uli;
  596. uli.HighPart = 0;
  597. uli.LowPart = cb;
  598. //----------------
  599. // Need to Grow!
  600. //----------------
  601. propDbg(( DEB_ITRACE, "Growing from %d to %d\n", _cbActualStreamSize, cb ));
  602. *phr = _pstm->SetSize( uli );
  603. if (FAILED(*phr) )
  604. goto Exit;
  605. else
  606. _cbActualStreamSize = cb;
  607. }
  608. //
  609. // We only get here if we either (1) didn't want to grow the
  610. // underlying stream, or (2) we successfully grew the underlying stream.
  611. //
  612. //
  613. // Re-size the buffer to the size specified in cb.
  614. //
  615. if ( _fLowMem )
  616. {
  617. // If we want to grow the buffer In low-memory conditions,
  618. // no realloc is necessary, because
  619. // _pbMappedStream is already large enough for the largest
  620. // property set.
  621. *ppv = _pbMappedStream;
  622. }
  623. else if ( cb != _cbMappedStream )
  624. {
  625. // We must re-alloc the buffer.
  626. pv = reinterpret_cast<BYTE*>( CoTaskMemAlloc( cb ));
  627. if ((pv == NULL) )
  628. {
  629. // allocation failed: we need to try using a backup mechanism for
  630. // more memory.
  631. // copy the data to the global reserved chunk... we will wait until
  632. // someone else has released it. it will be released on the way out
  633. // of the property code.
  634. _fLowMem = TRUE;
  635. pv = g_ReservedMemory.LockMemory();
  636. if ( NULL == pv)
  637. {
  638. *phr = E_OUTOFMEMORY;
  639. goto Exit;
  640. }
  641. else if( NULL != _pbMappedStream)
  642. {
  643. memcpy( pv, _pbMappedStream, min(cb,_cbMappedStream) );
  644. }
  645. CoTaskMemFree( _pbMappedStream );
  646. }
  647. else
  648. {
  649. memcpy( pv, _pbMappedStream, min(cb,_cbMappedStream) );
  650. CoTaskMemFree( _pbMappedStream );
  651. }
  652. _pbMappedStream = pv;
  653. *ppv = pv;
  654. }
  655. _cbMappedStream = cb;
  656. // ----
  657. // Exit
  658. // ----
  659. Exit:
  660. propDbg((DbgFlag(*phr,DEB_TRACE), "CSSMappedStream(%08X):SetSize %s returns hr=%08X\n",
  661. this, *phr != S_OK ? "exception" : "", *phr));
  662. }
  663. //+-------------------------------------------------------------------
  664. //
  665. // Member: CSSMappedStream::Lock
  666. //
  667. // Synopsis: Locking is not supported by this class.
  668. //
  669. //--------------------------------------------------------------------
  670. NTSTATUS CSSMappedStream::Lock(BOOLEAN fExclusive)
  671. {
  672. return(STATUS_SUCCESS);
  673. }
  674. //+-------------------------------------------------------------------
  675. //
  676. // Member: CSSMappedStream::Unlock
  677. //
  678. // Synopsis: Locking is not supported by this class.
  679. // However, this method still must check to
  680. // see if the reserved memory pool should be
  681. // freed for use by another property set.
  682. //
  683. //--------------------------------------------------------------------
  684. NTSTATUS CSSMappedStream::Unlock(VOID)
  685. {
  686. // if at the end of the properties set/get call we have the low
  687. // memory region locked, we flush to disk.
  688. HRESULT hr = S_OK;
  689. if (_fLowMem)
  690. {
  691. Flush(&hr);
  692. g_ReservedMemory.UnlockMemory();
  693. _pbMappedStream = NULL;
  694. _cbMappedStream = 0;
  695. _fLowMem = FALSE;
  696. propDbg((DEB_ERROR, "CPubStream(%08X):Unlock low-mem returns NTSTATUS=%08X\n",
  697. this, hr));
  698. }
  699. return(hr);
  700. }
  701. //+-------------------------------------------------------------------
  702. //
  703. // Member: CSSMappedStream::QueryTimeStamps
  704. //
  705. // Synopsis: Not used by this IMappedStream derivation.
  706. //
  707. //--------------------------------------------------------------------
  708. VOID CSSMappedStream::QueryTimeStamps(STATPROPSETSTG *pspss, BOOLEAN fNonSimple) const
  709. {
  710. }
  711. //+-------------------------------------------------------------------
  712. //
  713. // Member: CSSMappedStream::QueryModifyTime
  714. //
  715. // Synopsis: Not used by this IMappedStream derivation.
  716. //
  717. // Notes:
  718. //
  719. //--------------------------------------------------------------------
  720. BOOLEAN CSSMappedStream::QueryModifyTime(OUT LONGLONG *pll) const
  721. {
  722. return(FALSE);
  723. }
  724. //+-------------------------------------------------------------------
  725. //
  726. // Member: Unused methods by this IMappedStream implementation:
  727. // QuerySecurity, IsWritable, GetHandle
  728. //
  729. //--------------------------------------------------------------------
  730. BOOLEAN CSSMappedStream::QuerySecurity(OUT ULONG *pul) const
  731. {
  732. return(FALSE);
  733. }
  734. BOOLEAN CSSMappedStream::IsWriteable() const
  735. {
  736. return TRUE;
  737. }
  738. HANDLE CSSMappedStream::GetHandle(VOID) const
  739. {
  740. return(INVALID_HANDLE_VALUE);
  741. }
  742. //+-------------------------------------------------------------------
  743. //
  744. // Member: CSSMappedStream::SetModified/IsModified
  745. //
  746. //--------------------------------------------------------------------
  747. VOID CSSMappedStream::SetModified(OUT LONG *phr)
  748. {
  749. _fDirty = TRUE;
  750. *phr = S_OK;
  751. }
  752. BOOLEAN CSSMappedStream::IsModified(VOID) const
  753. {
  754. propDbg(( DEB_ITRACE, "CSSMappedStream::IsModified (%s)\n", _fDirty?"TRUE":"FALSE" ));
  755. return (BOOLEAN) _fDirty;
  756. }
  757. //+-------------------------------------------------------------------
  758. //
  759. // Member: CSSMappedStream::IsNtMappedStream/SetChangePending
  760. //
  761. // Synopsis: Debug routines.
  762. //
  763. //--------------------------------------------------------------------
  764. #if DBGPROP
  765. BOOLEAN CSSMappedStream::IsNtMappedStream(VOID) const
  766. {
  767. return(FALSE);
  768. }
  769. #endif
  770. #if DBGPROP
  771. BOOLEAN CSSMappedStream::SetChangePending(BOOLEAN f)
  772. {
  773. BOOL fOld = _fChangePending;
  774. _fChangePending = f;
  775. return((BOOLEAN)_fChangePending);
  776. }
  777. #endif