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.

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