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.

938 lines
24 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1991 - 1992.
  5. //
  6. // File: msf.hxx
  7. //
  8. // Contents: Header for MSF for external use
  9. //
  10. // Classes: CMStream - Main multi-stream object
  11. //
  12. // History: 27-Aug-91 PhilipLa Created.
  13. // 24-Apr-92 AlexT Added constants for minifat/stream
  14. //
  15. //--------------------------------------------------------------------------
  16. #ifndef __MSF_HXX__
  17. #define __MSF_HXX__
  18. #include <dfmsp.hxx>
  19. #include <error.hxx>
  20. #define SECURE
  21. #define msfErr(l, e) ErrJmp(msf, l, e, sc)
  22. #define msfChkTo(l, e) if (FAILED(sc = (e))) msfErr(l, sc) else 1
  23. #define msfHChkTo(l, e) if (FAILED(sc = GetScode(e))) msfErr(l, sc) else 1
  24. #define msfChk(e) msfChkTo(Err, e)
  25. #define msfHChk(e) msfHChkTo(Err, e)
  26. #define msfMemTo(l, e) if ((e) == NULL) msfErr(l, STG_E_INSUFFICIENTMEMORY) else 1
  27. #define msfMem(e) msfMemTo(Err, e)
  28. #if DBG == 1
  29. DECLARE_DEBUG(msf);
  30. #endif
  31. #if DBG == 1
  32. #define msfDebugOut(x) msfInlineDebugOut x
  33. #define msfAssert(e) Win4Assert(e)
  34. #define msfVerify(e) Win4Assert(e)
  35. #else
  36. #define msfDebugOut(x)
  37. #define msfAssert(e)
  38. #define msfVerify(e) (e)
  39. #endif
  40. #if WIN32 == 200
  41. //SECURE_SIMPLE_MODE means streams in simple mode will zero themselves.
  42. #define SECURE_SIMPLE_MODE
  43. //SECURE_STREAMS means streams in regular docfile will zero themselves.
  44. #define SECURE_STREAMS
  45. //SECURE_BUFFER means there is a 4K zero-filled buffer available.
  46. #define SECURE_BUFFER
  47. //SECURE_TAIL means that regular docfile will write over tail portions of
  48. // unused sectors.
  49. #define SECURE_TAIL
  50. #endif
  51. //Enable for testing on all platforms.
  52. //#define SECURE_SIMPLE_MODE
  53. //#define SECURE_STREAMS
  54. //#define SECURE_BUFFER
  55. //#define SECURE_TAIL
  56. #if DBG == 1
  57. #define SECURECHAR 'P'
  58. #else
  59. #define SECURECHAR 0
  60. #endif
  61. #define USE_NEW_GETFREE
  62. #define DIFAT_LOOKUP_ARRAY
  63. #define DIFAT_OPTIMIZATIONS
  64. #define CACHE_ALLOCATE_OPTIMIZATION
  65. //Enable sorting on the page table.
  66. #define SORTPAGETABLE
  67. //Enable no-scratch mode on all platforms.
  68. #define USE_NOSCRATCH
  69. //Enable no-snapshot mode on all platforms.
  70. #define USE_NOSNAPSHOT
  71. //Enable USE_NOSNAPSHOT_ALWAYS for testig purposes only.
  72. //#define USE_NOSNAPSHOT_ALWAYS
  73. //Enable coordinated transaction code on Cairo only.
  74. #if WIN32 == 300
  75. #define COORD
  76. #endif
  77. //Enable coordinated transaction code on other platforms
  78. // For testing only.
  79. #ifndef COORD
  80. //#define COORD
  81. #endif
  82. //Enable single writer multiple reader support
  83. #define DIRECTWRITERLOCK
  84. // MSF entry flags type
  85. typedef DWORD MSENTRYFLAGS;
  86. // MEF_ANY refers to all entries regardless of type
  87. const MSENTRYFLAGS MEF_ANY = 255;
  88. //CWCSTREAMNAME is the maximum length (in wide characters) of
  89. // a stream name.
  90. const USHORT CWCSTREAMNAME = 32;
  91. //OFFSET and SECT are used to determine positions within
  92. //a file.
  93. typedef SHORT OFFSET;
  94. typedef ULONG SECT;
  95. //MAXINDEX type is used to dodge warnings. It is the
  96. // largest type for which array[MAXINDEXTYPE] is valid.
  97. #define MAXINDEXTYPE ULONG
  98. //FSINDEX and FSOFFSET are used to determine the position of a sector
  99. //within the Fat.
  100. typedef ULONG FSINDEX;
  101. typedef USHORT FSOFFSET;
  102. // DIRINDEX and DIROFFSET are used to index directory tables
  103. typedef ULONG DIRINDEX;
  104. typedef USHORT DIROFFSET;
  105. //Size of a mini sector in bytes.
  106. const USHORT MINISECTORSHIFT = 6;
  107. const USHORT MINISECTORSIZE = 1 << MINISECTORSHIFT; //64
  108. //Maximum size of a ministream.
  109. const USHORT MINISTREAMSIZE=4096;
  110. //Size of a single sector in bytes.
  111. const USHORT SECTORSHIFT512 = 9;
  112. //Maximum sector shift
  113. const USHORT MAXSECTORSHIFT = 16;
  114. //Size of header.
  115. const USHORT HEADERSIZE = 1 << SECTORSHIFT512; //512
  116. //Size of single DirEntry
  117. const USHORT DIRENTRYSIZE = HEADERSIZE / 4; //128
  118. //Size of a single sector in a scratch multistream
  119. const USHORT SCRATCHSECTORSHIFT = 12;
  120. const USHORT SCRATCHSECTORSIZE = 1 << SCRATCHSECTORSHIFT; //4096
  121. const ULONGLONG MAX_ULONGLONG = 0xFFFFFFFFFFFFFFFF;
  122. const ULONG MAX_ULONG = 0xFFFFFFFF;
  123. const USHORT MAX_USHORT = 0xFFFF;
  124. //
  125. // Predefined Sector Indices
  126. //
  127. const SECT MAXREGSECT = 0xFFFFFFFA;
  128. const SECT STREAMSECT = 0xFFFFFFFB;
  129. const SECT DIFSECT=0xFFFFFFFC;
  130. const SECT FATSECT=0xFFFFFFFD;
  131. const SECT ENDOFCHAIN=0xFFFFFFFE;
  132. const SECT FREESECT=0xFFFFFFFF;
  133. //Start of Fat chain
  134. const SECT SECTFAT = 0;
  135. //Start of directory chain
  136. const SECT SECTDIR = 1;
  137. //
  138. // Predefined Stream ID's
  139. //
  140. //Return code for Directory
  141. //Used to signal a 'Stream Not Found' condition
  142. const SID NOSTREAM=0xFFFFFFFF;
  143. //Stream ID of FAT chain
  144. const SID SIDFAT=0xFFFFFFFE;
  145. //Stream ID of Directory chain
  146. const SID SIDDIR=0xFFFFFFFD;
  147. //SID for root level object
  148. const SID SIDROOT = 0;
  149. //SID of MiniFat
  150. const SID SIDMINIFAT = 0xFFFFFFFC;
  151. //SID of Double-indirect Fat
  152. const SID SIDDIF = 0xFFFFFFFB;
  153. //Stream ID for MiniStream chain
  154. const SID SIDMINISTREAM = SIDROOT;
  155. //SID of the largest regular (non-control) SID
  156. const SID MAXREGSID = 0xFFFFFFFA;
  157. //CSECTPERBLOCK is used in CDeltaList to determine the granularity
  158. //of the list.
  159. const USHORT CSECTPERBLOCK = 16;
  160. class CMStream;
  161. //Interesting names of things
  162. extern const WCHAR wcsContents[]; //Name of contents stream for
  163. // conversion
  164. extern const WCHAR wcsRootEntry[]; //Name of root directory
  165. // entry
  166. class PSStream;
  167. class CDirectStream;
  168. class CMSFPageTable;
  169. class CStreamCache;
  170. #define FLUSH_ILB TRUE
  171. SAFE_DFBASED_PTR(CBasedMStreamPtr, CMStream);
  172. #pragma warning(disable: 4284)
  173. // disable warning about return type of operator->()
  174. SAFE_DFBASED_PTR(CBasedBytePtr, BYTE);
  175. SAFE_DFBASED_PTR(CBasedILockBytesPtrPtr, ILockBytes*);
  176. #pragma warning(default: 4284)
  177. #include <header.hxx>
  178. #include <fat.hxx>
  179. #include <dir.hxx>
  180. #include <difat.hxx>
  181. #include <cache.hxx>
  182. //+----------------------------------------------------------------------
  183. //
  184. // Class: CMStream (ms)
  185. //
  186. // Purpose: Main interface to multi-streams
  187. //
  188. // Interface: See below
  189. //
  190. // History: 18-Jul-91 PhilipLa Created.
  191. // 26-Aug-82 t-chrisy added init function for
  192. // corrupted mstream
  193. // 26-May-95 SusiA added GetAllTimes
  194. // 26-Nov-95 SusiA added SetAllTimes
  195. // 06-Sep-95 MikeHill Added _fMaintainFLBModifyTimestamp,
  196. // MaintainFLBModifyTimestamp(),
  197. // and SetFileLockBytesTime().
  198. // 26-Apr-99 RogerCh Removed _fMaintainFLBModifyTimestamp,
  199. // MaintainFLBModifyTimestamp()
  200. // Notes:
  201. //
  202. //-----------------------------------------------------------------------
  203. class CMStream : public CMallocBased
  204. {
  205. public:
  206. CMStream(
  207. IMalloc *pMalloc,
  208. ILockBytes **pplstParent,
  209. BOOL fIsScratch,
  210. DFLAGS df,
  211. USHORT uSectorShift);
  212. CMStream(const CMStream *pms);
  213. ~CMStream();
  214. SCODE Init(VOID);
  215. SCODE InitNew(BOOL fDelay, ULARGE_INTEGER uliSize);
  216. SCODE InitConvert(BOOL fDelayConvert);
  217. void InitCopy(CMStream *pms);
  218. SCODE InitScratch(CMStream *pmsBase, BOOL fNew);
  219. void Empty(void);
  220. inline SCODE CreateEntry(
  221. SID const sidParent,
  222. CDfName const *pdfn,
  223. MSENTRYFLAGS const mefFlags,
  224. SID *psid);
  225. // No implementation, currently unused, placeholder
  226. void ReleaseEntry(SID const sid);
  227. inline SCODE DestroyEntry(
  228. SID const sidParent,
  229. CDfName const *pdfn);
  230. #ifdef LARGE_STREAMS
  231. inline SCODE KillStream(SECT sectStart, ULONGLONG ulSize);
  232. #else
  233. inline SCODE KillStream(SECT sectStart, ULONG ulSize);
  234. #endif
  235. inline SCODE RenameEntry(
  236. SID const sidParent,
  237. CDfName const *pdfn,
  238. CDfName const *pdfnNew);
  239. inline SCODE IsEntry(
  240. SID const sidParent,
  241. CDfName const *pdfn,
  242. SEntryBuffer *peb);
  243. inline SCODE StatEntry(
  244. SID const sid,
  245. SIterBuffer *pib,
  246. STATSTGW *pstatstg);
  247. SCODE GetTime(
  248. SID const sid,
  249. WHICHTIME const tt,
  250. TIME_T *pnt);
  251. SCODE GetAllTimes(
  252. SID const sid,
  253. TIME_T *patm,
  254. TIME_T *pmtm,
  255. TIME_T *pctm);
  256. SCODE SetAllTimes(
  257. SID const sid,
  258. TIME_T atm,
  259. TIME_T mtm,
  260. TIME_T ctm);
  261. SCODE SetFileLockBytesTime(
  262. WHICHTIME const tt,
  263. TIME_T nt);
  264. SCODE SetAllFileLockBytesTimes(
  265. TIME_T atm,
  266. TIME_T mtm,
  267. TIME_T ctm);
  268. SCODE SetTime(
  269. SID const sid,
  270. WHICHTIME const tt,
  271. TIME_T nt);
  272. inline SCODE GetClass(SID const sid,
  273. CLSID *pclsid);
  274. inline SCODE SetClass(SID const sid,
  275. REFCLSID clsid);
  276. inline SCODE GetStateBits(SID const sid,
  277. DWORD *pgrfStateBits);
  278. inline SCODE SetStateBits(SID const sid,
  279. DWORD grfStateBits,
  280. DWORD grfMask);
  281. inline void SetScratchMS(CMStream *pmsNoScratch);
  282. inline SCODE GetEntrySize(
  283. SID const sid,
  284. #ifdef LARGE_STREAMS
  285. ULONGLONG *pcbSize);
  286. #else
  287. ULONG *pcbSize);
  288. #endif
  289. inline SCODE GetChild(
  290. SID const sid,
  291. SID *psid);
  292. inline SCODE FindGreaterEntry(
  293. SID sidChildRoot,
  294. CDfName const *pdfn,
  295. SID *psidResult);
  296. SCODE BeginCopyOnWrite(DWORD const dwFlags);
  297. SCODE EndCopyOnWrite(
  298. DWORD const dwCommitFlags,
  299. DFLAGS const df);
  300. SCODE Consolidate();
  301. SCODE BuildConsolidationControlSectList(SECT **ppsectList,
  302. ULONG *pcsectList);
  303. BOOL IsSectorInList(SECT sect,
  304. SECT *psectList,
  305. ULONG csectList);
  306. SCODE ConsolidateStream(CDirEntry *pde, SECT sectLimit);
  307. SCODE MoveSect(SECT sectPrev, SECT sectOld, SECT sectNew);
  308. SCODE ReadSect(
  309. SID sid,
  310. SECT sect,
  311. VOID *pbuf,
  312. ULONG& ulRetval);
  313. SCODE WriteSect(
  314. SID sid,
  315. SECT sect,
  316. VOID *pbuf,
  317. ULONG& ulRetval);
  318. inline SCODE SetSize(VOID);
  319. inline SCODE SetMiniSize(VOID);
  320. SCODE MWrite(
  321. SID sid,
  322. BOOL fIsMiniStream,
  323. #ifdef LARGE_STREAMS
  324. ULONGLONG ulOffset,
  325. #else
  326. ULONG ulOffset,
  327. #endif
  328. VOID const HUGEP *pBuffer,
  329. ULONG ulCount,
  330. CStreamCache *pstmc,
  331. ULONG *pulRetVal);
  332. inline CMSFHeader * GetHeader(VOID) const;
  333. inline CFat * GetFat(VOID) const;
  334. inline CFat * GetMiniFat(VOID) const;
  335. inline CDIFat * GetDIFat(VOID) const;
  336. inline CDirectory * GetDir(VOID) const;
  337. inline CMSFPageTable * GetPageTable(VOID) const;
  338. #ifdef LARGE_DOCFILE
  339. inline ULONGLONG GetParentSize(VOID) const;
  340. #else
  341. inline ULONG GetParentSize(VOID) const;
  342. #endif
  343. inline USHORT GetSectorSize(VOID) const;
  344. inline USHORT GetSectorShift(VOID) const;
  345. inline USHORT GetSectorMask(VOID) const;
  346. SCODE Flush(BOOL fFlushILB);
  347. SCODE FlushHeader(USHORT uForce);
  348. inline BOOL IsScratch(VOID) const;
  349. inline BOOL IsUnconverted(VOID) const;
  350. inline BOOL IsInCOW(VOID) const;
  351. inline BOOL IsShadow(VOID) const;
  352. inline BOOL HasNoScratch(VOID) const;
  353. inline CDirectStream * GetMiniStream(VOID) const;
  354. inline ILockBytes * GetILB(VOID) const;
  355. inline SCODE GetSect(SID sid, SECT sect, SECT *psect);
  356. inline SCODE GetESect(SID sid, SECT sect, SECT *psect);
  357. #ifdef LARGE_STREAMS
  358. inline SCODE GetSize(SID sid, ULONGLONG *pulSize);
  359. #else
  360. inline SCODE GetSize(SID sid, ULONG *pulSize);
  361. #endif
  362. #ifdef MULTIHEAP
  363. IMalloc *GetMalloc(VOID) const;
  364. #else
  365. inline IMalloc *GetMalloc(VOID) const;
  366. #endif
  367. SCODE SecureSect(
  368. const SECT sect,
  369. #ifdef LARGE_STREAMS
  370. const ULONGLONG ulSize,
  371. #else
  372. const ULONG ulSize,
  373. #endif
  374. const BOOL fIsMini);
  375. inline CStreamCache * GetDirCache(void) const;
  376. inline CStreamCache * GetMiniFatCache(void) const;
  377. inline SECT GetStart(SID sid) const;
  378. private:
  379. // The ILockBytes ptr can be a CFileStream or custom ILockBytes from app
  380. // The ILockbytes ptr is unmarshaled and stored in a CPerContext
  381. // The SAFE_ACCESS macros adjust the CDFBasis before every call
  382. // with the correct absolute address ILockBytes pointer values
  383. CBasedILockBytesPtrPtr _pplstParent; // based ptr to an absolute ptr
  384. CBasedMSFPageTablePtr _pmpt;
  385. CMSFHeader _hdr; // align on 8-byte boundary for unbuffered I/O
  386. CDirectory _dir;
  387. CFat _fat;
  388. CDIFat _fatDif;
  389. CFat _fatMini;
  390. CStreamCache _stmcDir;
  391. CStreamCache _stmcMiniFat;
  392. CBasedDirectStreamPtr _pdsministream;
  393. CBasedMStreamPtr _pmsShadow;
  394. CBasedBytePtr _pCopySectBuf;
  395. #if DBG == 1
  396. LONG _uBufferRef;
  397. #endif
  398. BOOL const _fIsScratch;
  399. BOOL _fIsNoScratch; //TRUE if the multistream is being used
  400. //as a scratch MS in NoScratch mode.
  401. CBasedMStreamPtr _pmsScratch;
  402. BOOL _fIsNoSnapshot;
  403. BOOL _fBlockWrite;
  404. BOOL _fTruncate;
  405. BOOL _fBlockHeader;
  406. BOOL _fNewConvert;
  407. BOOL _fIsShadow;
  408. #ifdef LARGE_DOCFILE
  409. ULONGLONG _ulParentSize;
  410. #else
  411. ULONG _ulParentSize;
  412. #endif
  413. USHORT _uSectorSize;
  414. USHORT _uSectorShift;
  415. USHORT _uSectorMask;
  416. IMalloc * const _pMalloc;
  417. SCODE InitCommon(VOID);
  418. SCODE CopySect(
  419. SECT sectOld,
  420. SECT sectNew,
  421. OFFSET oStart,
  422. OFFSET oEnd,
  423. BYTE const HUGEP *pb,
  424. ULONG *pulRetval);
  425. SCODE ConvertILB(SECT sectMax);
  426. friend SCODE DllGetScratchMultiStream(
  427. CMStream **ppms,
  428. BOOL fIsNoScratch,
  429. ILockBytes **pplstStream,
  430. CMStream *pmsMaster);
  431. };
  432. //+-------------------------------------------------------------------------
  433. //
  434. // Method: CMStream::GetSectorSize, public
  435. //
  436. // Synopsis: Returns the current sector size
  437. //
  438. // History: 05-May-92 PhilipLa Created.
  439. //
  440. //--------------------------------------------------------------------------
  441. inline USHORT CMStream::GetSectorSize(VOID) const
  442. {
  443. return _uSectorSize;
  444. }
  445. //+-------------------------------------------------------------------------
  446. //
  447. // Method: CMStream::GetSectorShift, public
  448. //
  449. // Synopsis: Returns the current shift for sector math
  450. //
  451. // History: 05-May-92 PhilipLa Created.
  452. //
  453. //--------------------------------------------------------------------------
  454. inline USHORT CMStream::GetSectorShift(VOID) const
  455. {
  456. return _uSectorShift;
  457. }
  458. //+-------------------------------------------------------------------------
  459. //
  460. // Method: CMStream::GetSectorMask, public
  461. //
  462. // Synopsis: Returns the current mask for sector math
  463. //
  464. // History: 05-May-92 PhilipLa Created.
  465. //
  466. //--------------------------------------------------------------------------
  467. inline USHORT CMStream::GetSectorMask(VOID) const
  468. {
  469. return _uSectorMask;
  470. }
  471. //+-------------------------------------------------------------------------
  472. //
  473. // Method: CMStream::GetHeader, public
  474. //
  475. // Synopsis: Returns a pointer to the current header.
  476. //
  477. // History: 11-Dec-91 PhilipLa Created.
  478. //
  479. //--------------------------------------------------------------------------
  480. inline CMSFHeader * CMStream::GetHeader(VOID) const
  481. {
  482. return (CMSFHeader *)&_hdr;
  483. }
  484. //+-------------------------------------------------------------------------
  485. //
  486. // Method: CMStream::GetFat, public
  487. //
  488. // Synopsis: Returns a pointer to the current Fat
  489. //
  490. // History: 11-May-92 PhilipLa Created.
  491. //
  492. //--------------------------------------------------------------------------
  493. inline CFat * CMStream::GetFat(VOID) const
  494. {
  495. return (CFat *)&_fat;
  496. }
  497. //+-------------------------------------------------------------------------
  498. //
  499. // Member: CMStream::GetMiniFat
  500. //
  501. // Synopsis: Returns a pointer to the current minifat
  502. //
  503. // History: 12-May-92 AlexT Created
  504. //
  505. //--------------------------------------------------------------------------
  506. inline CFat * CMStream::GetMiniFat(VOID) const
  507. {
  508. return (CFat *)&_fatMini;
  509. }
  510. //+-------------------------------------------------------------------------
  511. //
  512. // Method: CMStream::GetDIFat, public
  513. //
  514. // Synopsis: Returns pointer to the current Double Indirect Fat
  515. //
  516. // History: 11-May-92 PhilipLa Created.
  517. //
  518. //--------------------------------------------------------------------------
  519. inline CDIFat * CMStream::GetDIFat(VOID) const
  520. {
  521. return (CDIFat *)&_fatDif;
  522. }
  523. //+-------------------------------------------------------------------------
  524. //
  525. // Member: CMStream::GetDir
  526. //
  527. // Synopsis: Returns a pointer to the current directory
  528. //
  529. // History: 14-May-92 AlexT Created
  530. //
  531. //--------------------------------------------------------------------------
  532. inline CDirectory * CMStream::GetDir(VOID) const
  533. {
  534. return (CDirectory *)&_dir;
  535. }
  536. //+-------------------------------------------------------------------------
  537. //
  538. // Member: CMStream::IsScratch
  539. //
  540. // Synopsis: Returns TRUE for scratch multistreams, else FALSE
  541. //
  542. // History: 14-May-92 AlexT Created
  543. //
  544. //--------------------------------------------------------------------------
  545. inline BOOL CMStream::IsScratch(VOID) const
  546. {
  547. return(_fIsScratch);
  548. }
  549. //+---------------------------------------------------------------------------
  550. //
  551. // Member: CMStream::HasNoScratch, public
  552. //
  553. // Synopsis: Returns TRUE if this multistream is a base MS in no-scratch
  554. // mode.
  555. //
  556. // History: 11-Apr-95 PhilipLa Created
  557. //
  558. //----------------------------------------------------------------------------
  559. inline BOOL CMStream::HasNoScratch(VOID) const
  560. {
  561. return (_pmsScratch != NULL);
  562. }
  563. //+-------------------------------------------------------------------------
  564. //
  565. // Member: CMStream::IsInCOW
  566. //
  567. // Synopsis: Returns TRUE if multistream is in copy-on-write mode
  568. //
  569. // History: 24-Feb-93 PhilipLa Created.
  570. //
  571. //--------------------------------------------------------------------------
  572. inline BOOL CMStream::IsInCOW(VOID) const
  573. {
  574. return _fBlockHeader;
  575. }
  576. //+-------------------------------------------------------------------------
  577. //
  578. // Member: CMStream::IsShadow
  579. //
  580. // Synopsis: Returns TRUE for shadow multistreams, else FALSE
  581. //
  582. // History: 03-Nov-92 PhilipLa Created.
  583. //
  584. //--------------------------------------------------------------------------
  585. inline BOOL CMStream::IsShadow(VOID) const
  586. {
  587. return _fIsShadow;
  588. }
  589. //+-------------------------------------------------------------------------
  590. //
  591. // Method: CMStream::IsUnconverted, public
  592. //
  593. // Synopsis: Returns TRUE if multistream is in unconverted state.
  594. //
  595. // History: 09-Jun-92 PhilipLa Created.
  596. //
  597. //--------------------------------------------------------------------------
  598. inline BOOL CMStream::IsUnconverted(VOID) const
  599. {
  600. return _fBlockWrite;
  601. }
  602. //+-------------------------------------------------------------------------
  603. //
  604. // Member: CMStream::GetMiniStream
  605. //
  606. // Synopsis: Returns pointer to the current ministream
  607. //
  608. // History: 15-May-92 AlexT Created
  609. //
  610. //--------------------------------------------------------------------------
  611. inline CDirectStream * CMStream::GetMiniStream(VOID)
  612. const
  613. {
  614. return BP_TO_P(CDirectStream *, _pdsministream);
  615. }
  616. //+-------------------------------------------------------------------------
  617. //
  618. // Member: CMStream::GetILB
  619. //
  620. // Synopsis: Returns a pointer to the current parent ILockBytes
  621. //
  622. // History: 15-May-92 AlexT Created
  623. //
  624. //--------------------------------------------------------------------------
  625. inline ILockBytes * CMStream::GetILB(VOID) const
  626. {
  627. return(*_pplstParent);
  628. }
  629. //+-------------------------------------------------------------------------
  630. //
  631. // Member: CMStream::GetPageTable
  632. //
  633. // Synopsis: Returns a pointer to the current page table
  634. //
  635. // History: 26-Oct-92 PhilipLa Created
  636. //
  637. //--------------------------------------------------------------------------
  638. inline CMSFPageTable * CMStream::GetPageTable(VOID) const
  639. {
  640. return BP_TO_P(CMSFPageTable *, _pmpt);
  641. }
  642. //+-------------------------------------------------------------------------
  643. //
  644. // Member: CMStream::GetParentSize
  645. //
  646. // Synopsis: Returns the cached parent size for this multistream.
  647. // If this is non-zero, it indicates a commit is in
  648. // progress.
  649. //
  650. // History: 01-Feb-93 PhilipLa Created
  651. //
  652. //--------------------------------------------------------------------------
  653. #ifdef LARGE_DOCFILE
  654. inline ULONGLONG CMStream::GetParentSize(VOID) const
  655. #else
  656. inline ULONG CMStream::GetParentSize(VOID) const
  657. #endif
  658. {
  659. return _ulParentSize;
  660. }
  661. //+---------------------------------------------------------------------------
  662. //
  663. // Member: CMStream::GetDirCache, public
  664. //
  665. // Synopsis: Returns a pointer to the directory cache
  666. //
  667. // History: 01-Jun-94 PhilipLa Created
  668. //----------------------------------------------------------------------------
  669. inline CStreamCache * CMStream::GetDirCache(void) const
  670. {
  671. return (CStreamCache *)&_stmcDir;
  672. }
  673. //+---------------------------------------------------------------------------
  674. //
  675. // Member: CMStream::GetMiniFatCache, public
  676. //
  677. // Synopsis: Returns a pointer to the minifat cache
  678. //
  679. // History: 01-Jun-94 PhilipLa Created
  680. //----------------------------------------------------------------------------
  681. inline CStreamCache * CMStream::GetMiniFatCache(void) const
  682. {
  683. return (CStreamCache *)&_stmcMiniFat;
  684. }
  685. #ifndef STGM_SIMPLE
  686. //STGM_SIMPLE should be in objbase.h - if it isn't, define it here so
  687. // we build.
  688. #define STGM_SIMPLE 0x08000000L
  689. #endif
  690. #ifndef STGM_NOSCRATCH
  691. //STGM_NOSCRATCH should be in objbase.h - if it isn't, define it here so
  692. // we build.
  693. #define STGM_NOSCRATCH 0x00100000L
  694. #endif
  695. #ifndef STGM_NOSNAPSHOT
  696. //STGM_NOSNAPSHOT should be in objbase.h - if it isn't, define it here so
  697. // we build.
  698. #define STGM_NOSNAPSHOT 0x00200000L
  699. #endif
  700. extern SCODE DfCreateSimpDocfile(WCHAR const *pwcsName,
  701. DWORD grfMode,
  702. DWORD reserved,
  703. IStorage **ppstgOpen);
  704. extern SCODE DfOpenSimpDocfile(WCHAR const *pwcsName,
  705. DWORD grfMode,
  706. DWORD reserved,
  707. IStorage **ppstgOpen);
  708. extern SCODE DllMultiStreamFromStream(
  709. IMalloc *pMalloc,
  710. CMStream **ppms,
  711. ILockBytes **pplstStream,
  712. DWORD dwStartFlags,
  713. DFLAGS df);
  714. extern SCODE DllMultiStreamFromCorruptedStream(
  715. CMStream **ppms,
  716. ILockBytes **pplstStream,
  717. DWORD dwFlags);
  718. extern void DllReleaseMultiStream(CMStream *pms);
  719. extern SCODE DllGetScratchMultiStream(
  720. CMStream **ppms,
  721. BOOL fIsNoScratch,
  722. ILockBytes **pplstStream,
  723. CMStream *pmsMaster);
  724. extern SCODE DllIsMultiStream(ILockBytes *plstStream);
  725. extern SCODE DllGetCommitSig(ILockBytes *plst, DFSIGNATURE *psig);
  726. extern SCODE DllSetCommitSig(ILockBytes *plst, DFSIGNATURE sig);
  727. #if DBG == 1
  728. extern VOID SetInfoLevel(ULONG x);
  729. #endif
  730. #define SCRATCHBUFFERSIZE SCRATCHSECTORSIZE
  731. #define MAXBUFFERSIZE 65536
  732. extern BYTE s_bufSecure[MINISTREAMSIZE];
  733. extern BYTE s_bufSafe[SCRATCHBUFFERSIZE];
  734. extern LONG s_bufSafeRef;
  735. #endif //__MSF_HXX__