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. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1992.
  5. //
  6. // File: pbstream.cxx
  7. //
  8. // Contents: CPubStream code
  9. //
  10. // Classes:
  11. //
  12. // Functions:
  13. //
  14. // History: 16-Jan-92 PhilipLa Created.
  15. // 12-Jun-96 MikeHill Renamed FlushNoException to Write,
  16. // and removed the Commit.
  17. // 21-Jun-96 MikeHill Fixed an Assert.
  18. // 01-Jul-96 MikeHill - Removed Win32 SEH from PropSet code.
  19. // - Added propset byte-swapping support.
  20. //
  21. //--------------------------------------------------------------------------
  22. #include "msfhead.cxx"
  23. #pragma hdrstop
  24. #include <sstream.hxx>
  25. #include <publicdf.hxx>
  26. #include <pbstream.hxx>
  27. #include <tstream.hxx>
  28. #include <docfilep.hxx>
  29. #include <reserved.hxx>
  30. #include <propdbg.hxx>
  31. //+---------------------------------------------------------------------------
  32. //
  33. // Member: CPubStream::CPubStream, public
  34. //
  35. // Synopsis: Constructor
  36. //
  37. // History: 16-Jan-92 PhilipLa Created
  38. //
  39. //----------------------------------------------------------------------------
  40. CPubStream::CPubStream(CPubDocFile *ppdf,
  41. DFLAGS df,
  42. CDfName const *pdfn)
  43. #pragma warning(disable: 4355)
  44. : _PubMappedStream(this)
  45. #pragma warning(default: 4355)
  46. {
  47. _psParent = NULL;
  48. _df = df;
  49. _ppdfParent = P_TO_BP(CBasedPubDocFilePtr, ppdf);
  50. _cReferences = 1;
  51. _dfn.Set(pdfn->GetLength(), pdfn->GetBuffer());
  52. _ppdfParent->AddChild(this);
  53. _fDirty = FALSE;
  54. _sig = CPUBSTREAM_SIG;
  55. }
  56. //+---------------------------------------------------------------------------
  57. //
  58. // Member: CPubStream::Init, public
  59. //
  60. // Synopsis: Init function
  61. //
  62. // Arguments: [psParent] - Stream in transaction set
  63. // [dlLUID] - LUID
  64. //
  65. // History: 16-Jan-92 PhilipLa Created
  66. //
  67. //----------------------------------------------------------------------------
  68. void CPubStream::Init(PSStream *psParent,
  69. DFLUID dlLUID)
  70. {
  71. _psParent = P_TO_BP(CBasedSStreamPtr, psParent);
  72. _luid = dlLUID;
  73. }
  74. //+---------------------------------------------------------------------------
  75. //
  76. // Member: CPubStream::~CPubStream, public
  77. //
  78. // Synopsis: Destructor
  79. //
  80. // History: 16-Jan-92 PhilipLa Created
  81. //
  82. //----------------------------------------------------------------------------
  83. CPubStream::~CPubStream()
  84. {
  85. msfAssert(_cReferences == 0);
  86. _sig = CPUBSTREAM_SIGDEL;
  87. if (SUCCEEDED(CheckReverted()))
  88. {
  89. if (_ppdfParent != NULL)
  90. _ppdfParent->ReleaseChild(this);
  91. if (_psParent)
  92. {
  93. _psParent->Release();
  94. }
  95. }
  96. }
  97. //+-------------------------------------------------------------------------
  98. //
  99. // Method: CPubStream::Release, public
  100. //
  101. // Synopsis: Release a pubstream object
  102. //
  103. // Arguments: None.
  104. //
  105. // Returns: S_OK if call completed OK.
  106. //
  107. // Algorithm: Delete 'this' - all real work done by destructor.
  108. //
  109. // History: 24-Jan-92 PhilipLa Created.
  110. //
  111. // Notes:
  112. //
  113. //--------------------------------------------------------------------------
  114. void CPubStream::vRelease(VOID)
  115. {
  116. LONG lRet;
  117. msfDebugOut((DEB_ITRACE,"In CPubStream::Release()\n"));
  118. msfAssert(_cReferences > 0);
  119. lRet = InterlockedDecrement(&_cReferences);
  120. msfAssert(!P_TRANSACTED(_df));
  121. if (lRet == 0)
  122. {
  123. _PubMappedStream.Cleanup();
  124. delete this;
  125. }
  126. msfDebugOut((DEB_ITRACE,"Out CPubStream::Release()\n"));
  127. }
  128. //+--------------------------------------------------------------
  129. //
  130. // Member: CPubStream::Stat, public
  131. //
  132. // Synopsis: Fills in a stat buffer
  133. //
  134. // Arguments: [pstatstg] - Buffer
  135. // [grfStatFlag] - stat flags
  136. //
  137. // Returns: S_OK or error code
  138. //
  139. // Modifies: [pstatstg]
  140. //
  141. // History: 24-Mar-92 DrewB Created
  142. //
  143. //---------------------------------------------------------------
  144. SCODE CPubStream::Stat(STATSTGW *pstatstg, DWORD grfStatFlag)
  145. {
  146. SCODE sc = S_OK;
  147. msfDebugOut((DEB_ITRACE, "In CPubStream::Stat(%p)\n", pstatstg));
  148. msfChk(CheckReverted());
  149. msfAssert(_ppdfParent != NULL);
  150. pstatstg->grfMode = DFlagsToMode(_df);
  151. pstatstg->clsid = CLSID_NULL;
  152. pstatstg->grfStateBits = 0;
  153. pstatstg->pwcsName = NULL;
  154. if ((grfStatFlag & STATFLAG_NONAME) == 0)
  155. {
  156. msfMem(pstatstg->pwcsName = (WCHAR *)TaskMemAlloc(_dfn.GetLength()));
  157. memcpy(pstatstg->pwcsName, _dfn.GetBuffer(), _dfn.GetLength());
  158. }
  159. #ifdef LARGE_STREAMS
  160. ULONGLONG cbSize;
  161. #else
  162. ULONG cbSize;
  163. #endif
  164. _psParent->GetSize(&cbSize);
  165. pstatstg->cbSize.QuadPart = cbSize;
  166. msfDebugOut((DEB_ITRACE, "Out CPubStream::Stat\n"));
  167. Err:
  168. return sc;
  169. }
  170. //+--------------------------------------------------------------
  171. //
  172. // Member: CPubStream::RevertFromAbove, public
  173. //
  174. // Synopsis: Parent has asked for reversion
  175. //
  176. // History: 29-Jan-92 DrewB Created
  177. //
  178. //---------------------------------------------------------------
  179. void CPubStream::RevertFromAbove(void)
  180. {
  181. msfDebugOut((DEB_ITRACE, "In CPubStream::RevertFromAbove:%p()\n", this));
  182. _df |= DF_REVERTED;
  183. _psParent->Release();
  184. #if DBG == 1
  185. _psParent = NULL;
  186. #endif
  187. msfDebugOut((DEB_ITRACE, "Out CPubStream::RevertFromAbove\n"));
  188. }
  189. //+--------------------------------------------------------------
  190. //
  191. // Member: CPubStream::FlushBufferedData, public
  192. //
  193. // Synopsis: Flush out the property buffers.
  194. //
  195. // History: 5-May-1995 BillMo Created
  196. //
  197. //---------------------------------------------------------------
  198. SCODE CPubStream::FlushBufferedData(int recursionlevel)
  199. {
  200. SCODE sc = S_OK;
  201. msfDebugOut((DEB_ITRACE, "In CPubStream::FlushBufferedData:%p()\n", this));
  202. _PubMappedStream.Flush(&sc);
  203. msfDebugOut((DEB_ITRACE, "Out CPubStream::FlushBufferedData\n"));
  204. propDbg((DEB_ITRACE, "CPubStream(%08X):FlushBufferedData returns %08X\n",
  205. this, sc));
  206. return sc;
  207. }
  208. //+---------------------------------------------------------------------------
  209. //
  210. // Member: CPubStream::Commit, public
  211. //
  212. // Synopsis: Flush stream changes to disk in the direct case.
  213. //
  214. // Arguments: None
  215. //
  216. // Returns: Appropriate status code
  217. //
  218. // History: 12-Jan-93 PhilipLa Created
  219. //
  220. //----------------------------------------------------------------------------
  221. SCODE CPubStream::Commit(DWORD dwFlags)
  222. {
  223. SCODE sc = S_OK;
  224. msfDebugOut((DEB_ITRACE, "In CPubStream::Commit:%p()\n", this));
  225. msfAssert(!P_TRANSACTED(_df));
  226. if (SUCCEEDED(sc = CheckReverted()))
  227. {
  228. if (P_WRITE(_df))
  229. {
  230. if (_ppdfParent->GetTransactedDepth() == 0)
  231. {
  232. //Parent is direct, so call commit on it and return.
  233. sc = _ppdfParent->GetBaseMS()->Flush(FLUSH_CACHE(dwFlags));
  234. }
  235. SetClean();
  236. }
  237. }
  238. msfDebugOut((DEB_ITRACE, "Out CPubStream::Commit\n"));
  239. return sc;
  240. }
  241. //+-------------------------------------------------------------------
  242. //
  243. // Member: CPubMappedStream::Open
  244. //
  245. // Synopsis: Opens mapped view of exposed stream. Called by
  246. // NtCreatePropertySet et al.
  247. //
  248. // Notes: Gets the size of the underlying stream and reads it
  249. // into memory so that it can be "mapped."
  250. //
  251. //--------------------------------------------------------------------
  252. VOID CPubMappedStream::Open(IN VOID *powner, OUT LONG *phr)
  253. {
  254. *phr = S_OK;
  255. olAssert(!_fLowMem);
  256. // If given a pointer to the owner of this mapped stream,
  257. // save it. This could be NULL (i.e., when called from
  258. // ReOpen).
  259. if( NULL != powner )
  260. _powner = P_TO_BP( CBasedBytePtr, ((BYTE*) powner) );
  261. if (_pb == NULL)
  262. {
  263. VOID *pv;
  264. #ifdef LARGE_STREAMS
  265. ULONGLONG ulSize;
  266. #else
  267. ULONG ulSize;
  268. #endif
  269. _cbUsed = 0;
  270. *phr = _pst->GetSize(&ulSize);
  271. if (*phr != S_OK)
  272. goto Throw;
  273. if (ulSize > CBMAXPROPSETSTREAM)
  274. {
  275. *phr = STG_E_INVALIDHEADER;
  276. goto Throw;
  277. }
  278. _cbOriginalStreamSize = (ULONG) ulSize;
  279. _cbUsed = _cbOriginalStreamSize;
  280. pv = GetMalloc()->Alloc(_cbOriginalStreamSize);
  281. if (pv == NULL)
  282. {
  283. pv = g_ReservedMemory.LockMemory();
  284. if( NULL == pv )
  285. {
  286. *phr = E_OUTOFMEMORY;
  287. goto Throw;
  288. }
  289. _fLowMem = TRUE;
  290. }
  291. _pb = P_TO_BP(CBasedBytePtr, ((BYTE*)pv));
  292. *phr = _pst->ReadAt(0,
  293. pv,
  294. _cbOriginalStreamSize,
  295. &_cbUsed);
  296. #if BIGENDIAN==1
  297. // Notify our owner that we've read in new data.
  298. if (*phr == S_OK && _powner != NULL && 0 != _cbUsed)
  299. {
  300. *phr = RtlOnMappedStreamEvent( BP_TO_P(VOID*, _powner), pv, _cbUsed );
  301. }
  302. #endif
  303. if (*phr != S_OK)
  304. {
  305. if (_fLowMem)
  306. g_ReservedMemory.UnlockMemory();
  307. else
  308. GetMalloc()->Free(pv);
  309. _pb = NULL;
  310. _cbUsed = 0;
  311. _fLowMem = FALSE;
  312. goto Throw;
  313. }
  314. }
  315. propDbg((DEB_ITRACE, "CPubStream(%08X):Open returns normally\n", this));
  316. return;
  317. Throw:
  318. propDbg((DEB_ERROR, "CPubStream(%08X):Open exception returns %08X\n", this, *phr));
  319. return;
  320. }
  321. //+-------------------------------------------------------------------
  322. //
  323. // Member: CPubMappedStream::Flush
  324. //
  325. // Synopsis: Flush the mapped Stream to the underlying Stream,
  326. // and Commit that Stream.
  327. //
  328. //--------------------------------------------------------------------
  329. VOID CPubMappedStream::Flush(OUT LONG *phr)
  330. {
  331. // Write out any data we have cached to the Stream.
  332. *phr = Write();
  333. // Commite the Stream.
  334. if( SUCCEEDED(*phr) )
  335. {
  336. *phr = _pst->Commit(STGC_DEFAULT);
  337. }
  338. return;
  339. }
  340. //+-------------------------------------------------------------------
  341. //
  342. // Member: CPubMappedStream::Close
  343. //
  344. // Synopsis: Operates on mapped view of exposed stream. Called by
  345. // NtCreatePropertySet et al.
  346. //
  347. // Notes: Does nothing because the object may be mapped in
  348. // another process.
  349. //
  350. //--------------------------------------------------------------------
  351. VOID CPubMappedStream::Close(OUT LONG *phr)
  352. {
  353. // Write the changes. We don't need to Commit them,
  354. // they will be implicitely committed when the
  355. // Stream is Released.
  356. *phr = Write();
  357. if( FAILED(*phr) )
  358. {
  359. propDbg((DEB_ERROR, "CPubStream(%08X)::Close exception returns %08X\n", this, *phr));
  360. }
  361. return;
  362. }
  363. //+-------------------------------------------------------------------
  364. //
  365. // Member: CPubMappedStream::ReOpen
  366. //
  367. // Synopsis: Operates on mapped view of exposed stream. Called by
  368. // NtCreatePropertySet et al.
  369. //
  370. // Notes: Combined open and map.
  371. //
  372. //--------------------------------------------------------------------
  373. VOID CPubMappedStream::ReOpen(IN OUT VOID **ppv, OUT LONG *phr)
  374. {
  375. *ppv = NULL;
  376. Open(NULL, // Unspecified owner.
  377. phr);
  378. if( SUCCEEDED(*phr) )
  379. *ppv = BP_TO_P(VOID*, _pb);
  380. return;
  381. }
  382. //+-------------------------------------------------------------------
  383. //
  384. // Member: CPubMappedStream::Quiesce
  385. //
  386. // Synopsis: Operates on mapped view of exposed stream. Called by
  387. // NtCreatePropertySet et al.
  388. //
  389. // Notes: Meaningless for docfile mapped stream.
  390. //
  391. //--------------------------------------------------------------------
  392. VOID CPubMappedStream::Quiesce(VOID)
  393. {
  394. olAssert(_pb != NULL);
  395. DfpdbgCheckUnusedMemory();
  396. }
  397. //+-------------------------------------------------------------------
  398. //
  399. // Member: CPubMappedStream::Map
  400. //
  401. // Synopsis: Operates on mapped view of exposed stream. Called by
  402. // NtCreatePropertySet et al.
  403. //
  404. // Notes: Return the address of the "mapping" buffer.
  405. //
  406. //--------------------------------------------------------------------
  407. VOID CPubMappedStream::Map(BOOLEAN fCreate, VOID **ppv)
  408. {
  409. olAssert(_pb != NULL);
  410. DfpdbgCheckUnusedMemory();
  411. *ppv = BP_TO_P(VOID*, _pb);
  412. }
  413. //+-------------------------------------------------------------------
  414. //
  415. // Member: CPubMappedStream::Unmap
  416. //
  417. // Synopsis: Operates on mapped view of exposed stream. Called by
  418. // NtCreatePropertySet et al.
  419. //
  420. // Notes: Unmapping is merely zeroing the pointer. We don't
  421. // flush because that's done explicitly by the
  422. // CPropertyStorage class.
  423. //
  424. //
  425. //--------------------------------------------------------------------
  426. VOID CPubMappedStream::Unmap(BOOLEAN fFlush, VOID **pv)
  427. {
  428. DfpdbgCheckUnusedMemory();
  429. *pv = NULL;
  430. }
  431. //+-------------------------------------------------------------------
  432. //
  433. // Member: CPubMappedStream::Write
  434. //
  435. // Synopsis: Writes a mapped view of an exposed Stream to the
  436. // underlying Stream. Used by RtlCreatePropertySet et al.
  437. //
  438. // Notes: The Stream is not commited. To commit the Stream, in
  439. // addition to writing it, the Flush method should be used.
  440. // The Commit is omitted so that it can be skipped in
  441. // the Property Set Close path, thus eliminating a
  442. // performance penalty.
  443. //
  444. //--------------------------------------------------------------------
  445. HRESULT CPubMappedStream::Write ()
  446. {
  447. HRESULT hr;
  448. ULONG cbWritten;
  449. if (!_fDirty)
  450. {
  451. propDbg((DEB_ITRACE, "CPubStream(%08X):Flush returns with not-dirty\n", this));
  452. return S_FALSE; // flushing a stream which isn't a property stream
  453. // this could be optimized by propagating a 'no property streams'
  454. // flag up the storage hierachy such that FlushBufferedData is
  455. // not even called for non-property streams.
  456. }
  457. olAssert( _pst != NULL );
  458. olAssert( _pb != NULL );
  459. olAssert( _powner != NULL );
  460. #if BIGENDIAN==1
  461. // Notify our owner that we're about to perform a Write.
  462. hr = RtlOnMappedStreamEvent( BP_TO_P(VOID*, _powner), BP_TO_P(VOID *, _pb), _cbUsed );
  463. if( S_OK != hr ) goto Exit;
  464. #endif
  465. hr = _pst->WriteAt(0, BP_TO_P(VOID *, _pb), _cbUsed, &cbWritten);
  466. if( S_OK != hr ) goto Exit;
  467. #if BIGENDIAN==1
  468. // Notify our owner that we're done with the Write.
  469. hr = RtlOnMappedStreamEvent( BP_TO_P(VOID*, _powner), BP_TO_P(VOID *, _pb), _cbUsed );
  470. if( S_OK != hr ) goto Exit;
  471. #endif
  472. if (_cbUsed < _cbOriginalStreamSize)
  473. {
  474. // if the stream is shrinking, this is a good time to do it.
  475. hr = _pst->SetSize(_cbUsed);
  476. if( S_OK != hr ) goto Exit;
  477. }
  478. // ----
  479. // Exit
  480. // ----
  481. Exit:
  482. if (hr == S_OK || hr == STG_E_REVERTED)
  483. {
  484. _fDirty = FALSE;
  485. }
  486. propDbg((DEB_ITRACE, "CPubStream(%08X):Flush %s returns hr=%08X\n",
  487. this, hr != S_OK ? "exception" : "", hr));
  488. return hr;
  489. }
  490. //+-------------------------------------------------------------------
  491. //
  492. // Member: CPubMappedStream::GetSize
  493. //
  494. // Synopsis: Returns size of exposed stream. Called by
  495. // NtCreatePropertySet et al.
  496. //
  497. // Notes:
  498. //--------------------------------------------------------------------
  499. ULONG CPubMappedStream::GetSize(OUT LONG *phr)
  500. {
  501. *phr = S_OK;
  502. if (_pb == NULL)
  503. Open(NULL, // Unspecified owner
  504. phr);
  505. if( SUCCEEDED(*phr) )
  506. {
  507. olAssert(_pb != NULL);
  508. DfpdbgCheckUnusedMemory();
  509. }
  510. return _cbUsed;
  511. }
  512. //+-------------------------------------------------------------------
  513. //
  514. // Member: CPubMappedStream::SetSize
  515. //
  516. // Synopsis: Sets size of "map." Called by
  517. // NtCreatePropertySet et al.
  518. //
  519. // Arguments: [cb] -- requested size.
  520. // [fPersistent] -- FALSE if expanding in-memory read-only image
  521. // [ppv] -- new mapped address.
  522. //
  523. // Signals: Not enough disk space.
  524. //
  525. // Notes: In a low memory situation we may not be able to
  526. // get the requested amount of memory. In this
  527. // case we must fall back on disk storage as the
  528. // actual map.
  529. //
  530. //--------------------------------------------------------------------
  531. VOID
  532. CPubMappedStream::SetSize(ULONG cb, IN BOOLEAN fPersistent, VOID **ppv, OUT LONG *phr)
  533. {
  534. VOID *pv;
  535. *phr = S_OK;
  536. olAssert(cb != 0);
  537. DfpdbgCheckUnusedMemory();
  538. //
  539. // if we are growing the data, we should grow the stream
  540. //
  541. if (fPersistent && cb > _cbUsed)
  542. {
  543. *phr = _pst->SetSize(cb);
  544. if (*phr != S_OK)
  545. goto Throw;
  546. }
  547. if (!_fLowMem)
  548. {
  549. pv = GetMalloc()->Realloc(BP_TO_P(VOID*, _pb), cb);
  550. if (pv == NULL)
  551. {
  552. // allocation failed: we need to try using a backup mechanism for
  553. // more memory.
  554. // copy the data to the global reserved chunk... we will wait until
  555. // someone else has released it. it will be released on the way out
  556. // of the property code.
  557. pv = g_ReservedMemory.LockMemory();
  558. if( NULL == pv )
  559. {
  560. *phr = E_OUTOFMEMORY;
  561. goto Throw;
  562. }
  563. _fLowMem = TRUE;
  564. if (NULL != BP_TO_P(BYTE*, _pb))
  565. {
  566. memcpy(pv, BP_TO_P(VOID*, _pb), _cbUsed);
  567. }
  568. GetMalloc()->Free(BP_TO_P(VOID*, _pb));
  569. }
  570. _pb = P_TO_BP(CBasedBytePtr, ((BYTE*)pv));
  571. *ppv = pv;
  572. }
  573. else
  574. {
  575. *ppv = BP_TO_P(VOID*, _pb);
  576. }
  577. _cbUsed = cb;
  578. DfpdbgFillUnusedMemory();
  579. Throw:
  580. propDbg((DEB_ITRACE, "CPubStream(%08X):SetSize %s returns hr=%08X\n",
  581. this, *phr != S_OK ? "exception" : "", *phr));
  582. }
  583. //+-------------------------------------------------------------------
  584. //
  585. // Member: CPubMappedStream::Lock
  586. //
  587. // Synopsis: Operates on mapped view of exposed stream. Called by
  588. // NtCreatePropertySet et al.
  589. //
  590. // Notes:
  591. // the exposed stream has enforced the locking.
  592. //
  593. // we use the lock to indicate whether the object is
  594. // dirty
  595. //
  596. //--------------------------------------------------------------------
  597. NTSTATUS CPubMappedStream::Lock(BOOLEAN fExclusive)
  598. {
  599. return(STATUS_SUCCESS);
  600. }
  601. //+-------------------------------------------------------------------
  602. //
  603. // Member: CPubMappedStream::Unlock
  604. //
  605. // Synopsis: Operates on mapped view of exposed stream. Called by
  606. // NtCreatePropertySet et al.
  607. //
  608. // Notes:
  609. //
  610. //--------------------------------------------------------------------
  611. NTSTATUS CPubMappedStream::Unlock(VOID)
  612. {
  613. // if at the end of the properties set/get call we have the low
  614. // memory region locked, we flush to disk.
  615. HRESULT hr = S_OK;
  616. if (_fLowMem)
  617. {
  618. Flush(&hr);
  619. g_ReservedMemory.UnlockMemory();
  620. _pb = NULL;
  621. _cbUsed = 0;
  622. _fLowMem = FALSE;
  623. propDbg((DEB_ITRACE, "CPubStream(%08X):Unlock low-mem returns NTSTATUS=%08X\n",
  624. this, hr));
  625. }
  626. return(hr);
  627. }
  628. //+-------------------------------------------------------------------
  629. //
  630. // Member: CPubMappedStream::QueryTimeStamps
  631. //
  632. // Synopsis: Operates on mapped view of exposed stream. Called by
  633. // NtCreatePropertySet et al.
  634. //
  635. // Notes:
  636. //
  637. //--------------------------------------------------------------------
  638. VOID CPubMappedStream::QueryTimeStamps(STATPROPSETSTG *pspss, BOOLEAN fNonSimple) const
  639. {
  640. }
  641. //+-------------------------------------------------------------------
  642. //
  643. // Member: CPubMappedStream::QueryModifyTime
  644. //
  645. // Synopsis: Operates on mapped view of exposed stream. Called by
  646. // NtCreatePropertySet et al.
  647. //
  648. // Notes:
  649. //
  650. //--------------------------------------------------------------------
  651. BOOLEAN CPubMappedStream::QueryModifyTime(OUT LONGLONG *pll) const
  652. {
  653. return(FALSE);
  654. }
  655. //+-------------------------------------------------------------------
  656. //
  657. // Member: CPubMappedStream::QuerySecurity
  658. //
  659. // Synopsis: Operates on mapped view of exposed stream. Called by
  660. // NtCreatePropertySet et al.
  661. //
  662. // Notes:
  663. //
  664. //--------------------------------------------------------------------
  665. BOOLEAN CPubMappedStream::QuerySecurity(OUT ULONG *pul) const
  666. {
  667. return(FALSE);
  668. }
  669. //+-------------------------------------------------------------------
  670. //
  671. // Member: CPubMappedStream::QueryTimeStamps
  672. //
  673. // Synopsis: Operates on mapped view of exposed stream. Called by
  674. // NtCreatePropertySet et al.
  675. //
  676. // Notes:
  677. //
  678. //--------------------------------------------------------------------
  679. BOOLEAN CPubMappedStream::IsWriteable() const
  680. {
  681. return TRUE;
  682. }
  683. //+-------------------------------------------------------------------
  684. //
  685. // Member: CPubMappedStream::SetChangePending
  686. //
  687. // Synopsis: Operates on mapped view of exposed stream. Called by
  688. // NtCreatePropertySet et al.
  689. //
  690. // Notes:
  691. //
  692. //--------------------------------------------------------------------
  693. #if DBG == 1
  694. BOOLEAN CPubMappedStream::SetChangePending(BOOLEAN f)
  695. {
  696. BOOLEAN fOld = _fChangePending;
  697. _fChangePending = f;
  698. return(_fChangePending);
  699. }
  700. #endif
  701. //+-------------------------------------------------------------------
  702. //
  703. // Member: CPubMappedStream::IsNtMappedStream
  704. //
  705. // Synopsis: Operates on mapped view of exposed stream. Called by
  706. // NtCreatePropertySet et al.
  707. //
  708. // Notes:
  709. //
  710. //--------------------------------------------------------------------
  711. #if DBG == 1
  712. BOOLEAN CPubMappedStream::IsNtMappedStream(VOID) const
  713. {
  714. return(FALSE);
  715. }
  716. #endif
  717. //+-------------------------------------------------------------------
  718. //
  719. // Member: CPubMappedStream::GetHandle
  720. //
  721. // Synopsis: Operates on mapped view of exposed stream. Called by
  722. // NtCreatePropertySet et al.
  723. //
  724. // Notes:
  725. //
  726. //--------------------------------------------------------------------
  727. HANDLE CPubMappedStream::GetHandle(VOID) const
  728. {
  729. return(INVALID_HANDLE_VALUE);
  730. }
  731. //+-------------------------------------------------------------------
  732. //
  733. // Member: CPubMappedStream::SetModified
  734. //
  735. // Synopsis: Operates on mapped view of exposed stream. Called by
  736. // NtCreatePropertySet et al.
  737. //
  738. // Notes:
  739. //
  740. //--------------------------------------------------------------------
  741. VOID CPubMappedStream::SetModified(OUT LONG *phr)
  742. {
  743. _fDirty = TRUE;
  744. *phr = S_OK;
  745. }
  746. //+-------------------------------------------------------------------
  747. //
  748. // Member: CPubMappedStream::IsModified
  749. //
  750. // Synopsis: Operates on mapped view of exposed stream. Called by
  751. // NtCreatePropertySet et al.
  752. //
  753. // Notes:
  754. //
  755. //--------------------------------------------------------------------
  756. BOOLEAN CPubMappedStream::IsModified(VOID) const
  757. {
  758. return _fDirty;
  759. }
  760. //+-------------------------------------------------------------------
  761. //
  762. // Member: CPubMappedStream::DfpdbgFillUnusedMemory
  763. //
  764. //--------------------------------------------------------------------
  765. #if DBG == 1
  766. VOID CPubMappedStream::DfpdbgFillUnusedMemory(VOID)
  767. {
  768. if (_pb == NULL)
  769. return;
  770. BYTE * pbEndPlusOne = BP_TO_P(BYTE*, _pb) + BytesCommitted();
  771. for (BYTE *pbUnused = BP_TO_P(BYTE*, _pb) + _cbUsed;
  772. pbUnused < pbEndPlusOne;
  773. pbUnused++)
  774. {
  775. *pbUnused = (BYTE)(ULONG_PTR)pbUnused;
  776. }
  777. }
  778. //+-------------------------------------------------------------------
  779. //
  780. // Member: CPubMappedStream::DfpdbgCheckUnusedMemory
  781. //
  782. //--------------------------------------------------------------------
  783. VOID CPubMappedStream::DfpdbgCheckUnusedMemory(VOID)
  784. {
  785. if (_pb == NULL)
  786. return;
  787. if (_cbUsed == 0)
  788. return;
  789. BYTE * pbEndPlusOne = BP_TO_P(BYTE*, _pb) + BytesCommitted();
  790. for (BYTE *pbUnused = BP_TO_P(BYTE*, _pb + _cbUsed) ;
  791. pbUnused < pbEndPlusOne;
  792. pbUnused ++)
  793. {
  794. olAssert(*pbUnused == (BYTE)(ULONG_PTR)pbUnused);
  795. }
  796. }
  797. #endif // DBG