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.

956 lines
25 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. _psParent = NULL;
  185. msfDebugOut((DEB_ITRACE, "Out CPubStream::RevertFromAbove\n"));
  186. }
  187. //+--------------------------------------------------------------
  188. //
  189. // Member: CPubStream::FlushBufferedData, public
  190. //
  191. // Synopsis: Flush out the property buffers.
  192. //
  193. // History: 5-May-1995 BillMo Created
  194. //
  195. //---------------------------------------------------------------
  196. SCODE CPubStream::FlushBufferedData(int recursionlevel)
  197. {
  198. SCODE sc = S_OK;
  199. msfDebugOut((DEB_ITRACE, "In CPubStream::FlushBufferedData:%p()\n", this));
  200. _PubMappedStream.Flush(&sc);
  201. msfDebugOut((DEB_ITRACE, "Out CPubStream::FlushBufferedData\n"));
  202. propDbg((DEB_ITRACE, "CPubStream(%08X):FlushBufferedData returns %08X\n",
  203. this, sc));
  204. return sc;
  205. }
  206. //+---------------------------------------------------------------------------
  207. //
  208. // Member: CPubStream::Commit, public
  209. //
  210. // Synopsis: Flush stream changes to disk in the direct case.
  211. //
  212. // Arguments: None
  213. //
  214. // Returns: Appropriate status code
  215. //
  216. // History: 12-Jan-93 PhilipLa Created
  217. //
  218. //----------------------------------------------------------------------------
  219. SCODE CPubStream::Commit(DWORD dwFlags)
  220. {
  221. SCODE sc = S_OK;
  222. msfDebugOut((DEB_ITRACE, "In CPubStream::Commit:%p()\n", this));
  223. msfAssert(!P_TRANSACTED(_df));
  224. if (SUCCEEDED(sc = CheckReverted()))
  225. {
  226. if (P_WRITE(_df))
  227. {
  228. if (_ppdfParent->GetTransactedDepth() == 0)
  229. {
  230. //Parent is direct, so call commit on it and return.
  231. sc = _ppdfParent->GetBaseMS()->Flush(FLUSH_CACHE(dwFlags));
  232. }
  233. SetClean();
  234. }
  235. }
  236. msfDebugOut((DEB_ITRACE, "Out CPubStream::Commit\n"));
  237. return sc;
  238. }
  239. //+-------------------------------------------------------------------
  240. //
  241. // Member: CPubMappedStream::Open
  242. //
  243. // Synopsis: Opens mapped view of exposed stream. Called by
  244. // NtCreatePropertySet et al.
  245. //
  246. // Notes: Gets the size of the underlying stream and reads it
  247. // into memory so that it can be "mapped."
  248. //
  249. //--------------------------------------------------------------------
  250. VOID CPubMappedStream::Open(IN VOID *powner, OUT LONG *phr)
  251. {
  252. *phr = S_OK;
  253. olAssert(!_fLowMem);
  254. // If given a pointer to the owner of this mapped stream,
  255. // save it. This could be NULL (i.e., when called from
  256. // ReOpen).
  257. if( NULL != powner )
  258. _powner = P_TO_BP( CBasedBytePtr, ((BYTE*) powner) );
  259. if (_pb == NULL)
  260. {
  261. VOID *pv;
  262. #ifdef LARGE_STREAMS
  263. ULONGLONG ulSize;
  264. #else
  265. ULONG ulSize;
  266. #endif
  267. _cbUsed = 0;
  268. *phr = _pst->GetSize(&ulSize);
  269. if (*phr != S_OK)
  270. goto Throw;
  271. if (ulSize > CBMAXPROPSETSTREAM)
  272. {
  273. *phr = STG_E_INVALIDHEADER;
  274. goto Throw;
  275. }
  276. _cbOriginalStreamSize = (ULONG) ulSize;
  277. _cbUsed = _cbOriginalStreamSize;
  278. pv = GetMalloc()->Alloc(_cbOriginalStreamSize);
  279. if (pv == NULL)
  280. {
  281. pv = g_ReservedMemory.LockMemory();
  282. if( NULL == pv )
  283. {
  284. *phr = E_OUTOFMEMORY;
  285. goto Throw;
  286. }
  287. _fLowMem = TRUE;
  288. }
  289. _pb = P_TO_BP(CBasedBytePtr, ((BYTE*)pv));
  290. *phr = _pst->ReadAt(0,
  291. pv,
  292. _cbOriginalStreamSize,
  293. &_cbUsed);
  294. #if BIGENDIAN==1
  295. // Notify our owner that we've read in new data.
  296. if (*phr == S_OK && _powner != NULL && 0 != _cbUsed)
  297. {
  298. *phr = RtlOnMappedStreamEvent( BP_TO_P(VOID*, _powner), pv, _cbUsed );
  299. }
  300. #endif
  301. if (*phr != S_OK)
  302. {
  303. if (_fLowMem)
  304. g_ReservedMemory.UnlockMemory();
  305. else
  306. GetMalloc()->Free(pv);
  307. _pb = NULL;
  308. _cbUsed = 0;
  309. _fLowMem = FALSE;
  310. goto Throw;
  311. }
  312. }
  313. propDbg((DEB_ITRACE, "CPubStream(%08X):Open returns normally\n", this));
  314. return;
  315. Throw:
  316. propDbg((DEB_ERROR, "CPubStream(%08X):Open exception returns %08X\n", this, *phr));
  317. return;
  318. }
  319. //+-------------------------------------------------------------------
  320. //
  321. // Member: CPubMappedStream::Flush
  322. //
  323. // Synopsis: Flush the mapped Stream to the underlying Stream,
  324. // and Commit that Stream.
  325. //
  326. //--------------------------------------------------------------------
  327. VOID CPubMappedStream::Flush(OUT LONG *phr)
  328. {
  329. // Write out any data we have cached to the Stream.
  330. *phr = Write();
  331. // Commite the Stream.
  332. if( SUCCEEDED(*phr) )
  333. {
  334. *phr = _pst->Commit(STGC_DEFAULT);
  335. }
  336. return;
  337. }
  338. //+-------------------------------------------------------------------
  339. //
  340. // Member: CPubMappedStream::Close
  341. //
  342. // Synopsis: Operates on mapped view of exposed stream. Called by
  343. // NtCreatePropertySet et al.
  344. //
  345. // Notes: Does nothing because the object may be mapped in
  346. // another process.
  347. //
  348. //--------------------------------------------------------------------
  349. VOID CPubMappedStream::Close(OUT LONG *phr)
  350. {
  351. // Write the changes. We don't need to Commit them,
  352. // they will be implicitely committed when the
  353. // Stream is Released.
  354. *phr = Write();
  355. if( FAILED(*phr) )
  356. {
  357. propDbg((DEB_ERROR, "CPubStream(%08X)::Close exception returns %08X\n", this, *phr));
  358. }
  359. return;
  360. }
  361. //+-------------------------------------------------------------------
  362. //
  363. // Member: CPubMappedStream::ReOpen
  364. //
  365. // Synopsis: Operates on mapped view of exposed stream. Called by
  366. // NtCreatePropertySet et al.
  367. //
  368. // Notes: Combined open and map.
  369. //
  370. //--------------------------------------------------------------------
  371. VOID CPubMappedStream::ReOpen(IN OUT VOID **ppv, OUT LONG *phr)
  372. {
  373. *ppv = NULL;
  374. Open(NULL, // Unspecified owner.
  375. phr);
  376. if( SUCCEEDED(*phr) )
  377. *ppv = BP_TO_P(VOID*, _pb);
  378. return;
  379. }
  380. //+-------------------------------------------------------------------
  381. //
  382. // Member: CPubMappedStream::Quiesce
  383. //
  384. // Synopsis: Operates on mapped view of exposed stream. Called by
  385. // NtCreatePropertySet et al.
  386. //
  387. // Notes: Meaningless for docfile mapped stream.
  388. //
  389. //--------------------------------------------------------------------
  390. VOID CPubMappedStream::Quiesce(VOID)
  391. {
  392. olAssert(_pb != NULL);
  393. DfpdbgCheckUnusedMemory();
  394. }
  395. //+-------------------------------------------------------------------
  396. //
  397. // Member: CPubMappedStream::Map
  398. //
  399. // Synopsis: Operates on mapped view of exposed stream. Called by
  400. // NtCreatePropertySet et al.
  401. //
  402. // Notes: Return the address of the "mapping" buffer.
  403. //
  404. //--------------------------------------------------------------------
  405. VOID CPubMappedStream::Map(BOOLEAN fCreate, VOID **ppv)
  406. {
  407. olAssert(_pb != NULL);
  408. DfpdbgCheckUnusedMemory();
  409. *ppv = BP_TO_P(VOID*, _pb);
  410. }
  411. //+-------------------------------------------------------------------
  412. //
  413. // Member: CPubMappedStream::Unmap
  414. //
  415. // Synopsis: Operates on mapped view of exposed stream. Called by
  416. // NtCreatePropertySet et al.
  417. //
  418. // Notes: Unmapping is merely zeroing the pointer. We don't
  419. // flush because that's done explicitly by the
  420. // CPropertyStorage class.
  421. //
  422. //
  423. //--------------------------------------------------------------------
  424. VOID CPubMappedStream::Unmap(BOOLEAN fFlush, VOID **pv)
  425. {
  426. DfpdbgCheckUnusedMemory();
  427. *pv = NULL;
  428. }
  429. //+-------------------------------------------------------------------
  430. //
  431. // Member: CPubMappedStream::Write
  432. //
  433. // Synopsis: Writes a mapped view of an exposed Stream to the
  434. // underlying Stream. Used by RtlCreatePropertySet et al.
  435. //
  436. // Notes: The Stream is not commited. To commit the Stream, in
  437. // addition to writing it, the Flush method should be used.
  438. // The Commit is omitted so that it can be skipped in
  439. // the Property Set Close path, thus eliminating a
  440. // performance penalty.
  441. //
  442. //--------------------------------------------------------------------
  443. HRESULT CPubMappedStream::Write ()
  444. {
  445. HRESULT hr;
  446. ULONG cbWritten;
  447. if (!_fDirty)
  448. {
  449. propDbg((DEB_ITRACE, "CPubStream(%08X):Flush returns with not-dirty\n", this));
  450. return S_FALSE; // flushing a stream which isn't a property stream
  451. // this could be optimized by propagating a 'no property streams'
  452. // flag up the storage hierachy such that FlushBufferedData is
  453. // not even called for non-property streams.
  454. }
  455. olAssert( _pst != NULL );
  456. olAssert( _pb != NULL );
  457. olAssert( _powner != NULL );
  458. #if BIGENDIAN==1
  459. // Notify our owner that we're about to perform a Write.
  460. hr = RtlOnMappedStreamEvent( BP_TO_P(VOID*, _powner), BP_TO_P(VOID *, _pb), _cbUsed );
  461. if( S_OK != hr ) goto Exit;
  462. #endif
  463. hr = _pst->WriteAt(0, BP_TO_P(VOID *, _pb), _cbUsed, &cbWritten);
  464. if( S_OK != hr ) goto Exit;
  465. #if BIGENDIAN==1
  466. // Notify our owner that we're done with the Write.
  467. hr = RtlOnMappedStreamEvent( BP_TO_P(VOID*, _powner), BP_TO_P(VOID *, _pb), _cbUsed );
  468. if( S_OK != hr ) goto Exit;
  469. #endif
  470. if (_cbUsed < _cbOriginalStreamSize)
  471. {
  472. // if the stream is shrinking, this is a good time to do it.
  473. hr = _pst->SetSize(_cbUsed);
  474. if( S_OK != hr ) goto Exit;
  475. }
  476. // ----
  477. // Exit
  478. // ----
  479. Exit:
  480. if (hr == S_OK || hr == STG_E_REVERTED)
  481. {
  482. _fDirty = FALSE;
  483. }
  484. propDbg((DEB_ITRACE, "CPubStream(%08X):Flush %s returns hr=%08X\n",
  485. this, hr != S_OK ? "exception" : "", hr));
  486. return hr;
  487. }
  488. //+-------------------------------------------------------------------
  489. //
  490. // Member: CPubMappedStream::GetSize
  491. //
  492. // Synopsis: Returns size of exposed stream. Called by
  493. // NtCreatePropertySet et al.
  494. //
  495. // Notes:
  496. //--------------------------------------------------------------------
  497. ULONG CPubMappedStream::GetSize(OUT LONG *phr)
  498. {
  499. *phr = S_OK;
  500. if (_pb == NULL)
  501. Open(NULL, // Unspecified owner
  502. phr);
  503. if( SUCCEEDED(*phr) )
  504. {
  505. olAssert(_pb != NULL);
  506. DfpdbgCheckUnusedMemory();
  507. }
  508. return _cbUsed;
  509. }
  510. //+-------------------------------------------------------------------
  511. //
  512. // Member: CPubMappedStream::SetSize
  513. //
  514. // Synopsis: Sets size of "map." Called by
  515. // NtCreatePropertySet et al.
  516. //
  517. // Arguments: [cb] -- requested size.
  518. // [fPersistent] -- FALSE if expanding in-memory read-only image
  519. // [ppv] -- new mapped address.
  520. //
  521. // Signals: Not enough disk space.
  522. //
  523. // Notes: In a low memory situation we may not be able to
  524. // get the requested amount of memory. In this
  525. // case we must fall back on disk storage as the
  526. // actual map.
  527. //
  528. //--------------------------------------------------------------------
  529. VOID
  530. CPubMappedStream::SetSize(ULONG cb, IN BOOLEAN fPersistent, VOID **ppv, OUT LONG *phr)
  531. {
  532. VOID *pv;
  533. *phr = S_OK;
  534. olAssert(cb != 0);
  535. DfpdbgCheckUnusedMemory();
  536. //
  537. // if we are growing the data, we should grow the stream
  538. //
  539. if (fPersistent && cb > _cbUsed)
  540. {
  541. *phr = _pst->SetSize(cb);
  542. if (*phr != S_OK)
  543. goto Throw;
  544. }
  545. if (!_fLowMem)
  546. {
  547. pv = GetMalloc()->Realloc(BP_TO_P(VOID*, _pb), cb);
  548. if (pv == NULL)
  549. {
  550. // allocation failed: we need to try using a backup mechanism for
  551. // more memory.
  552. // copy the data to the global reserved chunk... we will wait until
  553. // someone else has released it. it will be released on the way out
  554. // of the property code.
  555. pv = g_ReservedMemory.LockMemory();
  556. if( NULL == pv )
  557. {
  558. *phr = E_OUTOFMEMORY;
  559. goto Throw;
  560. }
  561. _fLowMem = TRUE;
  562. if (NULL != BP_TO_P(BYTE*, _pb))
  563. {
  564. __try
  565. {
  566. memcpy(pv, BP_TO_P(VOID*, _pb), _cbUsed);
  567. }
  568. __except (EXCEPTION_EXECUTE_HANDLER)
  569. {
  570. g_ReservedMemory.UnlockMemory();
  571. _fLowMem = FALSE;
  572. *phr = E_OUTOFMEMORY;
  573. goto Throw;
  574. }
  575. }
  576. GetMalloc()->Free(BP_TO_P(VOID*, _pb));
  577. }
  578. _pb = P_TO_BP(CBasedBytePtr, ((BYTE*)pv));
  579. *ppv = pv;
  580. }
  581. else
  582. {
  583. *ppv = BP_TO_P(VOID*, _pb);
  584. }
  585. _cbUsed = cb;
  586. DfpdbgFillUnusedMemory();
  587. Throw:
  588. propDbg((DEB_ITRACE, "CPubStream(%08X):SetSize %s returns hr=%08X\n",
  589. this, *phr != S_OK ? "exception" : "", *phr));
  590. }
  591. //+-------------------------------------------------------------------
  592. //
  593. // Member: CPubMappedStream::Lock
  594. //
  595. // Synopsis: Operates on mapped view of exposed stream. Called by
  596. // NtCreatePropertySet et al.
  597. //
  598. // Notes:
  599. // the exposed stream has enforced the locking.
  600. //
  601. // we use the lock to indicate whether the object is
  602. // dirty
  603. //
  604. //--------------------------------------------------------------------
  605. NTSTATUS CPubMappedStream::Lock(BOOLEAN fExclusive)
  606. {
  607. return(STATUS_SUCCESS);
  608. }
  609. //+-------------------------------------------------------------------
  610. //
  611. // Member: CPubMappedStream::Unlock
  612. //
  613. // Synopsis: Operates on mapped view of exposed stream. Called by
  614. // NtCreatePropertySet et al.
  615. //
  616. // Notes:
  617. //
  618. //--------------------------------------------------------------------
  619. NTSTATUS CPubMappedStream::Unlock(VOID)
  620. {
  621. // if at the end of the properties set/get call we have the low
  622. // memory region locked, we flush to disk.
  623. HRESULT hr = S_OK;
  624. if (_fLowMem)
  625. {
  626. Flush(&hr);
  627. g_ReservedMemory.UnlockMemory();
  628. _pb = NULL;
  629. _cbUsed = 0;
  630. _fLowMem = FALSE;
  631. propDbg((DEB_ITRACE, "CPubStream(%08X):Unlock low-mem returns NTSTATUS=%08X\n",
  632. this, hr));
  633. }
  634. return(hr);
  635. }
  636. //+-------------------------------------------------------------------
  637. //
  638. // Member: CPubMappedStream::QueryTimeStamps
  639. //
  640. // Synopsis: Operates on mapped view of exposed stream. Called by
  641. // NtCreatePropertySet et al.
  642. //
  643. // Notes:
  644. //
  645. //--------------------------------------------------------------------
  646. VOID CPubMappedStream::QueryTimeStamps(STATPROPSETSTG *pspss, BOOLEAN fNonSimple) const
  647. {
  648. }
  649. //+-------------------------------------------------------------------
  650. //
  651. // Member: CPubMappedStream::QueryModifyTime
  652. //
  653. // Synopsis: Operates on mapped view of exposed stream. Called by
  654. // NtCreatePropertySet et al.
  655. //
  656. // Notes:
  657. //
  658. //--------------------------------------------------------------------
  659. BOOLEAN CPubMappedStream::QueryModifyTime(OUT LONGLONG *pll) const
  660. {
  661. return(FALSE);
  662. }
  663. //+-------------------------------------------------------------------
  664. //
  665. // Member: CPubMappedStream::QuerySecurity
  666. //
  667. // Synopsis: Operates on mapped view of exposed stream. Called by
  668. // NtCreatePropertySet et al.
  669. //
  670. // Notes:
  671. //
  672. //--------------------------------------------------------------------
  673. BOOLEAN CPubMappedStream::QuerySecurity(OUT ULONG *pul) const
  674. {
  675. return(FALSE);
  676. }
  677. //+-------------------------------------------------------------------
  678. //
  679. // Member: CPubMappedStream::QueryTimeStamps
  680. //
  681. // Synopsis: Operates on mapped view of exposed stream. Called by
  682. // NtCreatePropertySet et al.
  683. //
  684. // Notes:
  685. //
  686. //--------------------------------------------------------------------
  687. BOOLEAN CPubMappedStream::IsWriteable() const
  688. {
  689. return TRUE;
  690. }
  691. //+-------------------------------------------------------------------
  692. //
  693. // Member: CPubMappedStream::SetChangePending
  694. //
  695. // Synopsis: Operates on mapped view of exposed stream. Called by
  696. // NtCreatePropertySet et al.
  697. //
  698. // Notes:
  699. //
  700. //--------------------------------------------------------------------
  701. #if DBG == 1
  702. BOOLEAN CPubMappedStream::SetChangePending(BOOLEAN f)
  703. {
  704. BOOLEAN fOld = _fChangePending;
  705. _fChangePending = f;
  706. return(_fChangePending);
  707. }
  708. #endif
  709. //+-------------------------------------------------------------------
  710. //
  711. // Member: CPubMappedStream::IsNtMappedStream
  712. //
  713. // Synopsis: Operates on mapped view of exposed stream. Called by
  714. // NtCreatePropertySet et al.
  715. //
  716. // Notes:
  717. //
  718. //--------------------------------------------------------------------
  719. #if DBG == 1
  720. BOOLEAN CPubMappedStream::IsNtMappedStream(VOID) const
  721. {
  722. return(FALSE);
  723. }
  724. #endif
  725. //+-------------------------------------------------------------------
  726. //
  727. // Member: CPubMappedStream::GetHandle
  728. //
  729. // Synopsis: Operates on mapped view of exposed stream. Called by
  730. // NtCreatePropertySet et al.
  731. //
  732. // Notes:
  733. //
  734. //--------------------------------------------------------------------
  735. HANDLE CPubMappedStream::GetHandle(VOID) const
  736. {
  737. return(INVALID_HANDLE_VALUE);
  738. }
  739. //+-------------------------------------------------------------------
  740. //
  741. // Member: CPubMappedStream::SetModified
  742. //
  743. // Synopsis: Operates on mapped view of exposed stream. Called by
  744. // NtCreatePropertySet et al.
  745. //
  746. // Notes:
  747. //
  748. //--------------------------------------------------------------------
  749. VOID CPubMappedStream::SetModified(OUT LONG *phr)
  750. {
  751. _fDirty = TRUE;
  752. *phr = S_OK;
  753. }
  754. //+-------------------------------------------------------------------
  755. //
  756. // Member: CPubMappedStream::IsModified
  757. //
  758. // Synopsis: Operates on mapped view of exposed stream. Called by
  759. // NtCreatePropertySet et al.
  760. //
  761. // Notes:
  762. //
  763. //--------------------------------------------------------------------
  764. BOOLEAN CPubMappedStream::IsModified(VOID) const
  765. {
  766. return _fDirty;
  767. }
  768. //+-------------------------------------------------------------------
  769. //
  770. // Member: CPubMappedStream::DfpdbgFillUnusedMemory
  771. //
  772. //--------------------------------------------------------------------
  773. #if DBG == 1
  774. VOID CPubMappedStream::DfpdbgFillUnusedMemory(VOID)
  775. {
  776. if (_pb == NULL)
  777. return;
  778. BYTE * pbEndPlusOne = BP_TO_P(BYTE*, _pb) + BytesCommitted();
  779. for (BYTE *pbUnused = BP_TO_P(BYTE*, _pb) + _cbUsed;
  780. pbUnused < pbEndPlusOne;
  781. pbUnused++)
  782. {
  783. *pbUnused = (BYTE)(ULONG_PTR)pbUnused;
  784. }
  785. }
  786. //+-------------------------------------------------------------------
  787. //
  788. // Member: CPubMappedStream::DfpdbgCheckUnusedMemory
  789. //
  790. //--------------------------------------------------------------------
  791. VOID CPubMappedStream::DfpdbgCheckUnusedMemory(VOID)
  792. {
  793. if (_pb == NULL)
  794. return;
  795. if (_cbUsed == 0)
  796. return;
  797. BYTE * pbEndPlusOne = BP_TO_P(BYTE*, _pb) + BytesCommitted();
  798. for (BYTE *pbUnused = BP_TO_P(BYTE*, _pb + _cbUsed) ;
  799. pbUnused < pbEndPlusOne;
  800. pbUnused ++)
  801. {
  802. olAssert(*pbUnused == (BYTE)(ULONG_PTR)pbUnused);
  803. }
  804. }
  805. #endif // DBG