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.

948 lines
24 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. HRESULT hr;
  446. LARGE_INTEGER li;
  447. DWORD cbWrite = _cbActualStreamSize - _cbMappedStream;
  448. li.HighPart = 0;
  449. li.LowPart = _cbMappedStream;
  450. hr = _pstm->Seek(li,STREAM_SEEK_SET,NULL);
  451. if (SUCCEEDED(hr))
  452. {
  453. pTemp = reinterpret_cast<PBYTE>( CoTaskMemAlloc( cbWrite ));
  454. if (pTemp != NULL)
  455. {
  456. memset(pTemp,0,cbWrite);
  457. //
  458. // Successfully allocated memory for the write. Write the
  459. // zeros out all at once.
  460. //
  461. hr = _pstm->Write(pTemp, cbWrite, NULL);
  462. if (FAILED(hr))
  463. {
  464. propDbg((DEB_ERROR, "CSSMappedStream::Write "
  465. "write failure\n",hr));
  466. goto Exit;
  467. }
  468. CoTaskMemFree( pTemp );
  469. }
  470. else
  471. {
  472. //
  473. // We couldn't allocate memory. So we will use a small
  474. // stack buffer instead.
  475. //
  476. BYTE stackBuf[STACK_BYTES];
  477. memset(stackBuf, 0, STACK_BYTES);
  478. while (cbWrite >= STACK_BYTES)
  479. {
  480. hr = _pstm->Write(stackBuf, STACK_BYTES, NULL);
  481. if (FAILED(hr))
  482. {
  483. propDbg((DEB_ERROR, "CSSMappedStream::Write write failure\n",hr));
  484. goto Exit;
  485. }
  486. cbWrite -= STACK_BYTES;
  487. }
  488. if (cbWrite < STACK_BYTES)
  489. {
  490. hr = _pstm->Write(stackBuf, cbWrite, NULL);
  491. if (FAILED(hr))
  492. {
  493. propDbg((DEB_ERROR, "CSSMappedStream::Write write failure\n",hr));
  494. goto Exit;
  495. }
  496. }
  497. }
  498. }
  499. else
  500. {
  501. propDbg((DEB_ERROR, "CSSMappedStream::Write seek failure\n",hr));
  502. goto Exit;
  503. }
  504. }
  505. // ----
  506. // Exit
  507. // ----
  508. Exit:
  509. // Notify our owner that we're done with the Write. We do this
  510. // whether or not there was an error, because _pbMappedStream is
  511. // not modified, and therefore intact even in the error path.
  512. // This call allows the owner to correct the byte-order of the header.
  513. #if BIGENDIAN==1
  514. if( fOwnerSignaled )
  515. DfpVerify( PrOnMappedStreamEvent( _powner, _pbMappedStream, _cbMappedStream ));
  516. #endif
  517. if (hr == S_OK || hr == STG_E_REVERTED)
  518. {
  519. _fDirty = FALSE;
  520. }
  521. return hr;
  522. }
  523. //+-------------------------------------------------------------------
  524. //
  525. // Member: CSSMappedStream::GetSize
  526. //
  527. // Synopsis: Returns the current size of the mapped stream.
  528. //
  529. // Arguments: [LONG*] phr
  530. // Used to return an HRESULT.
  531. //
  532. // Returns: [ULONG]
  533. // The current size.
  534. //
  535. //--------------------------------------------------------------------
  536. ULONG CSSMappedStream::GetSize(OUT LONG *phr)
  537. {
  538. HRESULT &hr = *phr;
  539. hr = S_OK;
  540. propITrace( "CSSMappedStream::GetSize" );
  541. // If necessary, open the Stream.
  542. if( NULL == _pbMappedStream )
  543. {
  544. Open(NULL, // Unspecified owner
  545. phr);
  546. }
  547. if( SUCCEEDED(*phr) )
  548. {
  549. DfpAssert( NULL != _pbMappedStream );
  550. }
  551. // Return the size of the mapped stream. If there was an
  552. // Open error, it will be zero, and *phr will be set.
  553. propDbg(( DEB_ITRACE, "CSSMappedStream::GetSize, size is %d\n", _cbMappedStream ));
  554. return _cbMappedStream;
  555. }
  556. //+-------------------------------------------------------------------
  557. //
  558. // Member: CSSMappedStream::SetSize
  559. //
  560. // Synopsis: Set the size of the mapped stream.
  561. //
  562. // Arguments: [ULONG] cb
  563. // The new size.
  564. // [BOOLEAN] fPersistent
  565. // If not set, then this change will not be stored -
  566. // thus the mapping buffer must be set, but the
  567. // Stream itself must not. This was added so that
  568. // CPropertySetStream could grow the buffer for internal
  569. // processing, when the Stream itself is read-only.
  570. // [VOID**] ppv
  571. // Used to return the new mapping buffer location.
  572. //
  573. // Returns: None.
  574. //
  575. // Pre-Conditions:
  576. // cb is below the maximum property set size.
  577. //
  578. //--------------------------------------------------------------------
  579. VOID
  580. CSSMappedStream::SetSize(ULONG cb,
  581. IN BOOLEAN fPersistent,
  582. VOID **ppv, OUT LONG *phr)
  583. {
  584. BYTE *pv;
  585. HRESULT &hr = *phr;
  586. hr = S_OK;
  587. DfpAssert(cb != 0);
  588. DfpAssert(cb <= CBMAXPROPSETSTREAM);
  589. propITrace( "CSSMappedStream::SetSize" );
  590. propTraceParameters(( "cb=%lu, fPersistent=%s, ppv=%p", cb, fPersistent?"True":"False" ));
  591. //
  592. // if we are growing the data, we should grow the stream
  593. //
  594. if (fPersistent && cb > _cbActualStreamSize)
  595. {
  596. ULARGE_INTEGER uli;
  597. uli.HighPart = 0;
  598. uli.LowPart = cb;
  599. //----------------
  600. // Need to Grow!
  601. //----------------
  602. propDbg(( DEB_ITRACE, "Growing from %d to %d\n", _cbActualStreamSize, cb ));
  603. *phr = _pstm->SetSize( uli );
  604. if (FAILED(*phr) )
  605. goto Exit;
  606. else
  607. _cbActualStreamSize = cb;
  608. }
  609. //
  610. // We only get here if we either (1) didn't want to grow the
  611. // underlying stream, or (2) we successfully grew the underlying stream.
  612. //
  613. //
  614. // Re-size the buffer to the size specified in cb.
  615. //
  616. if ( _fLowMem )
  617. {
  618. // If we want to grow the buffer In low-memory conditions,
  619. // no realloc is necessary, because
  620. // _pbMappedStream is already large enough for the largest
  621. // property set.
  622. *ppv = _pbMappedStream;
  623. }
  624. else if ( cb != _cbMappedStream )
  625. {
  626. // We must re-alloc the buffer.
  627. pv = reinterpret_cast<BYTE*>( CoTaskMemAlloc( cb ));
  628. if ((pv == NULL) )
  629. {
  630. // allocation failed: we need to try using a backup mechanism for
  631. // more memory.
  632. // copy the data to the global reserved chunk... we will wait until
  633. // someone else has released it. it will be released on the way out
  634. // of the property code.
  635. _fLowMem = TRUE;
  636. pv = g_ReservedMemory.LockMemory();
  637. if ( NULL == pv)
  638. {
  639. *phr = E_OUTOFMEMORY;
  640. goto Exit;
  641. }
  642. else if( NULL != _pbMappedStream)
  643. {
  644. memcpy( pv, _pbMappedStream, min(cb,_cbMappedStream) );
  645. }
  646. CoTaskMemFree( _pbMappedStream );
  647. }
  648. else
  649. {
  650. memcpy( pv, _pbMappedStream, min(cb,_cbMappedStream) );
  651. CoTaskMemFree( _pbMappedStream );
  652. }
  653. _pbMappedStream = pv;
  654. *ppv = pv;
  655. }
  656. _cbMappedStream = cb;
  657. // ----
  658. // Exit
  659. // ----
  660. Exit:
  661. propDbg((DbgFlag(*phr,DEB_TRACE), "CSSMappedStream(%08X):SetSize %s returns hr=%08X\n",
  662. this, *phr != S_OK ? "exception" : "", *phr));
  663. }
  664. //+-------------------------------------------------------------------
  665. //
  666. // Member: CSSMappedStream::Lock
  667. //
  668. // Synopsis: Locking is not supported by this class.
  669. //
  670. //--------------------------------------------------------------------
  671. NTSTATUS CSSMappedStream::Lock(BOOLEAN fExclusive)
  672. {
  673. return(STATUS_SUCCESS);
  674. }
  675. //+-------------------------------------------------------------------
  676. //
  677. // Member: CSSMappedStream::Unlock
  678. //
  679. // Synopsis: Locking is not supported by this class.
  680. // However, this method still must check to
  681. // see if the reserved memory pool should be
  682. // freed for use by another property set.
  683. //
  684. //--------------------------------------------------------------------
  685. NTSTATUS CSSMappedStream::Unlock(VOID)
  686. {
  687. // if at the end of the properties set/get call we have the low
  688. // memory region locked, we flush to disk.
  689. HRESULT hr = S_OK;
  690. if (_fLowMem)
  691. {
  692. Flush(&hr);
  693. g_ReservedMemory.UnlockMemory();
  694. _pbMappedStream = NULL;
  695. _cbMappedStream = 0;
  696. _fLowMem = FALSE;
  697. propDbg((DEB_ERROR, "CPubStream(%08X):Unlock low-mem returns NTSTATUS=%08X\n",
  698. this, hr));
  699. }
  700. return(hr);
  701. }
  702. //+-------------------------------------------------------------------
  703. //
  704. // Member: CSSMappedStream::QueryTimeStamps
  705. //
  706. // Synopsis: Not used by this IMappedStream derivation.
  707. //
  708. //--------------------------------------------------------------------
  709. VOID CSSMappedStream::QueryTimeStamps(STATPROPSETSTG *pspss, BOOLEAN fNonSimple) const
  710. {
  711. }
  712. //+-------------------------------------------------------------------
  713. //
  714. // Member: CSSMappedStream::QueryModifyTime
  715. //
  716. // Synopsis: Not used by this IMappedStream derivation.
  717. //
  718. // Notes:
  719. //
  720. //--------------------------------------------------------------------
  721. BOOLEAN CSSMappedStream::QueryModifyTime(OUT LONGLONG *pll) const
  722. {
  723. return(FALSE);
  724. }
  725. //+-------------------------------------------------------------------
  726. //
  727. // Member: Unused methods by this IMappedStream implementation:
  728. // QuerySecurity, IsWritable, GetHandle
  729. //
  730. //--------------------------------------------------------------------
  731. BOOLEAN CSSMappedStream::QuerySecurity(OUT ULONG *pul) const
  732. {
  733. return(FALSE);
  734. }
  735. BOOLEAN CSSMappedStream::IsWriteable() const
  736. {
  737. return TRUE;
  738. }
  739. HANDLE CSSMappedStream::GetHandle(VOID) const
  740. {
  741. return(INVALID_HANDLE_VALUE);
  742. }
  743. //+-------------------------------------------------------------------
  744. //
  745. // Member: CSSMappedStream::SetModified/IsModified
  746. //
  747. //--------------------------------------------------------------------
  748. VOID CSSMappedStream::SetModified(OUT LONG *phr)
  749. {
  750. _fDirty = TRUE;
  751. *phr = S_OK;
  752. }
  753. BOOLEAN CSSMappedStream::IsModified(VOID) const
  754. {
  755. propDbg(( DEB_ITRACE, "CSSMappedStream::IsModified (%s)\n", _fDirty?"TRUE":"FALSE" ));
  756. return (BOOLEAN) _fDirty;
  757. }
  758. //+-------------------------------------------------------------------
  759. //
  760. // Member: CSSMappedStream::IsNtMappedStream/SetChangePending
  761. //
  762. // Synopsis: Debug routines.
  763. //
  764. //--------------------------------------------------------------------
  765. #if DBGPROP
  766. BOOLEAN CSSMappedStream::IsNtMappedStream(VOID) const
  767. {
  768. return(FALSE);
  769. }
  770. #endif
  771. #if DBGPROP
  772. BOOLEAN CSSMappedStream::SetChangePending(BOOLEAN f)
  773. {
  774. BOOL fOld = _fChangePending;
  775. _fChangePending = f;
  776. return((BOOLEAN)_fChangePending);
  777. }
  778. #endif