- New implementation of SendMessage, ReceiveMessage, ReplyMessage functions
[wine] / ole / storage32.h
1 /*
2  * Compound Storage (32 bit version)
3  *
4  * Implemented using the documentation of the LAOLA project at
5  * <URL:http://wwwwbs.cs.tu-berlin.de/~schwartz/pmh/index.html>
6  * (Thanks to Martin Schwartz <schwartz@cs.tu-berlin.de>)
7  *
8  * This include file contains definitions of types and function
9  * prototypes that are used in the many files implementing the 
10  * storage functionality
11  *
12  * Copyright 1998,1999 Francis Beaudet
13  * Copyright 1998,1999 Thuy Nguyen
14  */
15 #ifndef __STORAGE32_H__
16 #define __STORAGE32_H__
17
18 /*
19  * Definitions for the file format offsets.
20  */
21 static const ULONG OFFSET_BIGBLOCKSIZEBITS   = 0x0000001e;
22 static const ULONG OFFSET_SMALLBLOCKSIZEBITS = 0x00000020;
23 static const ULONG OFFSET_BBDEPOTCOUNT       = 0x0000002C;
24 static const ULONG OFFSET_ROOTSTARTBLOCK     = 0x00000030;
25 static const ULONG OFFSET_SBDEPOTSTART       = 0x0000003C;
26 static const ULONG OFFSET_EXTBBDEPOTSTART    = 0x00000044;
27 static const ULONG OFFSET_EXTBBDEPOTCOUNT    = 0x00000048;
28 static const ULONG OFFSET_BBDEPOTSTART       = 0x0000004C;
29 static const ULONG OFFSET_PS_NAME            = 0x00000000;
30 static const ULONG OFFSET_PS_NAMELENGTH      = 0x00000040;
31 static const ULONG OFFSET_PS_PROPERTYTYPE    = 0x00000042;
32 static const ULONG OFFSET_PS_BLOCKTYPE       = 0x00000043;
33 static const ULONG OFFSET_PS_PREVIOUSPROP    = 0x00000044;
34 static const ULONG OFFSET_PS_NEXTPROP        = 0x00000048;   
35 static const ULONG OFFSET_PS_DIRPROP         = 0x0000004C;
36 static const ULONG OFFSET_PS_GUID            = 0x00000050;
37 static const ULONG OFFSET_PS_TSS1            = 0x00000064;
38 static const ULONG OFFSET_PS_TSD1            = 0x00000068;
39 static const ULONG OFFSET_PS_TSS2            = 0x0000006C;
40 static const ULONG OFFSET_PS_TSD2            = 0x00000070;
41 static const ULONG OFFSET_PS_STARTBLOCK      = 0x00000074; 
42 static const ULONG OFFSET_PS_SIZE            = 0x00000078; 
43 static const WORD  DEF_BIG_BLOCK_SIZE_BITS   = 0x0009;
44 static const WORD  DEF_SMALL_BLOCK_SIZE_BITS = 0x0006;
45 static const WORD  DEF_BIG_BLOCK_SIZE        = 0x0200;
46 static const WORD  DEF_SMALL_BLOCK_SIZE      = 0x0040;
47 static const ULONG BLOCK_SPECIAL             = 0xFFFFFFFD;
48 static const ULONG BLOCK_END_OF_CHAIN        = 0xFFFFFFFE;
49 static const ULONG BLOCK_UNUSED              = 0xFFFFFFFF;
50 static const ULONG PROPERTY_NULL             = 0xFFFFFFFF;
51
52 #define PROPERTY_NAME_MAX_LEN    0x20
53 #define PROPERTY_NAME_BUFFER_LEN 0x40             
54
55 #define PROPSET_BLOCK_SIZE 0x00000080
56
57 /*
58  * Property type of relation
59  */
60 #define PROPERTY_RELATION_PREVIOUS 0
61 #define PROPERTY_RELATION_NEXT     1
62 #define PROPERTY_RELATION_DIR      2
63
64 /*
65  * Property type constants
66  */
67 #define PROPTYPE_STORAGE 0x01
68 #define PROPTYPE_STREAM  0x02
69 #define PROPTYPE_ROOT    0x05
70
71 /*
72  * These defines assume a hardcoded blocksize. The code will assert
73  * if the blocksize is different. Some changes will have to be done if it
74  * becomes the case.
75  */
76 #define BIG_BLOCK_SIZE           0x200
77 #define COUNT_BBDEPOTINHEADER    109
78 #define LIMIT_TO_USE_SMALL_BLOCK 0x1000
79
80 /*
81  * These are signatures to detect the type of Document file.
82  */
83 static const BYTE STORAGE_magic[8]    ={0xd0,0xcf,0x11,0xe0,0xa1,0xb1,0x1a,0xe1};
84 static const BYTE STORAGE_oldmagic[8] ={0xd0,0xcf,0x11,0xe0,0x0e,0x11,0xfc,0x0d};
85
86 /*
87  * Forward declarations of all the structures used by the storage
88  * module.
89  */
90 typedef struct Storage32BaseImpl     Storage32BaseImpl;
91 typedef struct Storage32Impl         Storage32Impl;
92 typedef struct Storage32InternalImpl Storage32InternalImpl;
93 typedef struct BlockChainStream      BlockChainStream;
94 typedef struct SmallBlockChainStream SmallBlockChainStream;
95 typedef struct IEnumSTATSTGImpl      IEnumSTATSTGImpl;
96 typedef struct StgProperty           StgProperty;
97 typedef struct StgStreamImpl         StgStreamImpl;
98
99 /*
100  * This utility structure is used to read/write the information in a storage
101  * property.
102  */
103 struct StgProperty
104 {
105   WCHAR          name[PROPERTY_NAME_MAX_LEN];
106   WORD           sizeOfNameString;
107   BYTE           propertyType;
108   ULONG          previousProperty;
109   ULONG          nextProperty;
110   ULONG          dirProperty;
111   GUID           propertyUniqueID;
112   ULONG          timeStampS1;
113   ULONG          timeStampD1;
114   ULONG          timeStampS2;
115   ULONG          timeStampD2;
116   ULONG          startingBlock;
117   ULARGE_INTEGER size;
118 };
119
120 /*************************************************************************
121  * Big Block File support
122  *
123  * The big block file is an abstraction of a flat file separated in
124  * same sized blocks. The implementation for the methods described in 
125  * this section appear in stg_bigblockfile.c
126  */
127
128 /*
129  * Declaration of the data structures
130  */
131 typedef struct BigBlockFile BigBlockFile,*LPBIGBLOCKFILE;
132 typedef struct MappedPage   MappedPage,*LPMAPPEDPAGE;
133 typedef struct BigBlock     BigBlock,*LPBIGBLOCK;
134
135 struct BigBlockFile
136 {
137   ULARGE_INTEGER filesize;
138   ULONG blocksize;
139   HANDLE32 hfile;
140   HANDLE32 hfilemap;
141   DWORD flProtect;
142   MappedPage *headmap_ro;
143   MappedPage *headmap_w;
144   BigBlock *headblock;
145 };
146
147 /*
148  * Declaration of the functions used to manipulate the BigBlockFile
149  * data structure.
150  */
151 BigBlockFile*  BIGBLOCKFILE_Construct(HANDLE32 hFile,
152                                       DWORD openFlags,
153                                       ULONG blocksize);
154 void           BIGBLOCKFILE_Destructor(LPBIGBLOCKFILE This);
155 void*          BIGBLOCKFILE_GetBigBlock(LPBIGBLOCKFILE This, ULONG index);
156 void*          BIGBLOCKFILE_GetROBigBlock(LPBIGBLOCKFILE This, ULONG index);
157 void           BIGBLOCKFILE_ReleaseBigBlock(LPBIGBLOCKFILE This, void *pBlock);
158 void           BIGBLOCKFILE_SetSize(LPBIGBLOCKFILE This, ULARGE_INTEGER newSize);
159 ULARGE_INTEGER BIGBLOCKFILE_GetSize(LPBIGBLOCKFILE This);
160
161 /****************************************************************************
162  * Storage32BaseImpl definitions.
163  *
164  * This stucture defines the base information contained in all implementations
165  * of IStorage32 contained in this filee storage implementation.
166  *
167  * In OOP terms, this is the base class for all the IStorage32 implementations
168  * contained in this file.
169  */
170 struct Storage32BaseImpl
171 {
172   ICOM_VTABLE(IStorage32)*  lpvtbl;   /* Needs to be the first item in the stuct
173                                        * since we want to cast this in a Storage32 pointer */
174
175   /*
176    * Reference count of this object
177    */
178   ULONG ref;
179   
180   /* 
181    * Ancestor storage (top level) 
182    */
183   Storage32Impl* ancestorStorage;                
184   
185   /*
186    * Index of the property for the root of
187    * this storage
188    */
189   ULONG rootPropertySetIndex;
190   
191   /* 
192    * virtual Destructor method.
193    */
194   void (*v_destructor)(Storage32BaseImpl*);
195 };
196
197
198 /*
199  * Prototypes for the methods of the Storage32BaseImpl class.
200  */
201 HRESULT WINAPI Storage32BaseImpl_QueryInterface(
202             IStorage32*        iface,
203             REFIID             riid,
204             void**             ppvObject);
205         
206 ULONG WINAPI Storage32BaseImpl_AddRef( 
207             IStorage32*        iface);
208         
209 ULONG WINAPI Storage32BaseImpl_Release( 
210             IStorage32*        iface);
211         
212 HRESULT WINAPI Storage32BaseImpl_OpenStream( 
213             IStorage32*        iface,
214             const OLECHAR32*   pwcsName,  /* [string][in] */
215             void*              reserved1, /* [unique][in] */
216             DWORD              grfMode,   /* [in] */        
217             DWORD              reserved2, /* [in] */        
218             IStream32**        ppstm);    /* [out] */   
219     
220 HRESULT WINAPI Storage32BaseImpl_OpenStorage( 
221             IStorage32*        iface,
222             const OLECHAR32*   pwcsName,      /* [string][unique][in] */ 
223             IStorage32*        pstgPriority,  /* [unique][in] */         
224             DWORD              grfMode,       /* [in] */                 
225             SNB32              snbExclude,    /* [unique][in] */         
226             DWORD              reserved,      /* [in] */                 
227             IStorage32**       ppstg);        /* [out] */                
228           
229 HRESULT WINAPI Storage32BaseImpl_EnumElements( 
230             IStorage32*        iface,
231             DWORD              reserved1, /* [in] */                  
232             void*              reserved2, /* [size_is][unique][in] */ 
233             DWORD              reserved3, /* [in] */                  
234             IEnumSTATSTG**     ppenum);   /* [out] */   
235
236 HRESULT WINAPI Storage32BaseImpl_Stat( 
237             IStorage32*        iface,
238             STATSTG*           pstatstg,     /* [out] */ 
239             DWORD              grfStatFlag); /* [in] */  
240
241 HRESULT WINAPI Storage32BaseImpl_RenameElement(
242             IStorage32*        iface,
243             const OLECHAR32*   pwcsOldName,  /* [string][in] */
244             const OLECHAR32*   pwcsNewName); /* [string][in] */
245
246 HRESULT WINAPI Storage32BaseImpl_CreateStream(
247             IStorage32*        iface,
248             const OLECHAR32*   pwcsName,  /* [string][in] */
249             DWORD              grfMode,   /* [in] */
250             DWORD              reserved1, /* [in] */
251             DWORD              reserved2, /* [in] */
252             IStream32**        ppstm);    /* [out] */
253
254 HRESULT WINAPI Storage32BaseImpl_SetClass(
255             IStorage32*        iface,
256             REFCLSID           clsid);  /* [in] */
257
258 /****************************************************************************
259  * Storage32Impl definitions.
260  *
261  * This implementation of the IStorage32 interface represents a root
262  * storage. Basically, a document file.
263  */
264 struct Storage32Impl
265 {
266   ICOM_VTABLE(IStorage32) *lpvtbl;   /* Needs to be the first item in the stuct
267                                       * since we want to cast this in a Storage32 pointer */
268
269   /*
270    * Declare the member of the Storage32BaseImpl class to allow
271    * casting as a Storage32BaseImpl
272    */
273   ULONG                 ref;
274   struct Storage32Impl* ancestorStorage;                 
275   ULONG                 rootPropertySetIndex;
276   void (*v_destructor)(struct Storage32Impl*);
277   
278   /*
279    * The following data members are specific to the Storage32Impl
280    * class
281    */
282   HANDLE32           hFile;      /* Physical support for the Docfile */
283   
284   /*
285    * File header
286    */
287   WORD  bigBlockSizeBits;
288   WORD  smallBlockSizeBits;
289   ULONG bigBlockSize;
290   ULONG smallBlockSize;
291   ULONG bigBlockDepotCount;
292   ULONG rootStartBlock;
293   ULONG smallBlockDepotStart;
294   ULONG extBigBlockDepotStart;
295   ULONG extBigBlockDepotCount;
296   ULONG bigBlockDepotStart[COUNT_BBDEPOTINHEADER];
297   
298   /*
299    * Abstraction of the big block chains for the chains of the header.
300    */
301   BlockChainStream* rootBlockChain;
302   BlockChainStream* smallBlockDepotChain;
303   BlockChainStream* smallBlockRootChain;  
304
305   /*
306    * Pointer to the big block file abstraction
307    */
308   BigBlockFile* bigBlockFile; 
309 };
310
311 /*
312  * Method declaration for the Storage32Impl class
313  */        
314
315 HRESULT WINAPI Storage32Impl_CreateStorage( 
316             IStorage32*      iface,
317             const OLECHAR32* pwcsName,  /* [string][in] */ 
318             DWORD            grfMode,   /* [in] */ 
319             DWORD            dwStgFmt,  /* [in] */ 
320             DWORD            reserved2, /* [in] */ 
321             IStorage32**     ppstg);    /* [out] */ 
322         
323 HRESULT WINAPI Storage32Impl_CopyTo( 
324             IStorage32*      iface,
325             DWORD          ciidExclude,  /* [in] */ 
326             const IID*     rgiidExclude, /* [size_is][unique][in] */ 
327             SNB32            snbExclude, /* [unique][in] */ 
328             IStorage32*    pstgDest);    /* [unique][in] */ 
329         
330 HRESULT WINAPI Storage32Impl_MoveElementTo( 
331             IStorage32*      iface,
332             const OLECHAR32* pwcsName,    /* [string][in] */ 
333             IStorage32*      pstgDest,    /* [unique][in] */ 
334             const OLECHAR32* pwcsNewName, /* [string][in] */ 
335             DWORD            grfFlags);   /* [in] */ 
336         
337 HRESULT WINAPI Storage32Impl_Commit( 
338             IStorage32*      iface,
339             DWORD          grfCommitFlags); /* [in] */ 
340         
341 HRESULT WINAPI Storage32Impl_Revert( 
342             IStorage32*      iface);
343         
344 HRESULT WINAPI Storage32Impl_DestroyElement( 
345             IStorage32*      iface,
346             const OLECHAR32* pwcsName); /* [string][in] */ 
347         
348 HRESULT WINAPI Storage32Impl_SetElementTimes( 
349             IStorage32*      iface,
350             const OLECHAR32* pwcsName, /* [string][in] */ 
351             const FILETIME*  pctime,   /* [in] */ 
352             const FILETIME*  patime,   /* [in] */ 
353             const FILETIME*  pmtime);  /* [in] */ 
354
355 HRESULT WINAPI Storage32Impl_SetStateBits( 
356             IStorage32*      iface,
357             DWORD          grfStateBits, /* [in] */ 
358             DWORD          grfMask);     /* [in] */ 
359         
360 void Storage32Impl_Destroy(
361             Storage32Impl* This);
362
363 HRESULT Storage32Impl_Construct(
364             Storage32Impl* This,
365             HANDLE32       hFile,
366             DWORD          openFlags);
367
368 BOOL32 Storage32Impl_ReadBigBlock(
369             Storage32Impl* This,
370             ULONG          blockIndex,
371             void*          buffer);
372
373 BOOL32 Storage32Impl_WriteBigBlock(
374             Storage32Impl* This,
375             ULONG          blockIndex,
376             void*          buffer);
377
378 void* Storage32Impl_GetROBigBlock(
379             Storage32Impl* This,
380             ULONG          blockIndex);
381
382 void* Storage32Impl_GetBigBlock(
383             Storage32Impl* This,
384             ULONG          blockIndex);
385
386 void Storage32Impl_ReleaseBigBlock(
387             Storage32Impl* This,
388             void*          pBigBlock);
389
390 ULONG Storage32Impl_GetNextFreeBigBlock(
391             Storage32Impl* This);
392
393 void Storage32Impl_FreeBigBlock(
394             Storage32Impl* This,
395             ULONG blockIndex);
396
397 ULONG Storage32Impl_GetNextBlockInChain(
398             Storage32Impl* This,
399             ULONG blockIndex);
400
401 void Storage32Impl_SetNextBlockInChain(
402             Storage32Impl* This,
403             ULONG blockIndex,
404       ULONG nextBlock);
405
406 HRESULT Storage32Impl_LoadFileHeader(
407             Storage32Impl* This);
408
409 void Storage32Impl_SaveFileHeader(
410             Storage32Impl* This);
411
412 BOOL32 Storage32Impl_ReadProperty(
413             Storage32Impl* This,
414             ULONG          index,
415             StgProperty*    buffer);
416
417 BOOL32 Storage32Impl_WriteProperty(
418             Storage32Impl* This,
419             ULONG          index,
420             StgProperty*   buffer);
421
422 BlockChainStream* Storage32Impl_SmallBlocksToBigBlocks(
423                       Storage32Impl* This,
424                       SmallBlockChainStream** ppsbChain);
425
426 /****************************************************************************
427  * Storage32InternalImpl definitions.
428  *
429  * Definition of the implementation structure for the IStorage32 interface.
430  * This one implements the IStorage32 interface for storage that are
431  * inside another storage.
432  */
433 struct Storage32InternalImpl
434 {
435   ICOM_VTABLE(IStorage32) *lpvtbl;      /* Needs to be the first item in the stuct
436                                          * since we want to cast this in a Storage32 pointer */
437
438   /*
439    * Declare the member of the Storage32BaseImpl class to allow
440    * casting as a Storage32BaseImpl
441    */
442   ULONG                      ref;
443   struct Storage32Impl* ancestorStorage;                 
444   ULONG                    rootPropertySetIndex;
445   void (*v_destructor)(struct Storage32InternalImpl*);
446
447   /*
448    * There is no specific data for this class.
449    */
450 };
451
452 /*
453  * Method definitions for the Storage32InternalImpl class.
454  */
455 Storage32InternalImpl* Storage32InternalImpl_Construct(
456             Storage32Impl* ancestorStorage,     
457             ULONG          rootTropertyIndex);
458
459 void Storage32InternalImpl_Destroy(
460             Storage32InternalImpl* This);
461
462 HRESULT WINAPI Storage32InternalImpl_Commit( 
463             IStorage32*            iface,
464             DWORD                  grfCommitFlags); /* [in] */ 
465
466 HRESULT WINAPI Storage32InternalImpl_Revert( 
467             IStorage32*            iface);
468
469
470 /****************************************************************************
471  * IEnumSTATSTGImpl definitions.
472  *
473  * Definition of the implementation structure for the IEnumSTATSTGImpl interface.
474  * This class allows iterating through the content of a storage and to find
475  * specific items inside it.
476  */
477 struct IEnumSTATSTGImpl
478 {
479   ICOM_VTABLE(IEnumSTATSTG) *lpvtbl;    /* Needs to be the first item in the stuct
480                                          * since we want to cast this in a IEnumSTATSTG pointer */
481   
482   ULONG          ref;                   /* Reference count */
483   Storage32Impl* parentStorage;         /* Reference to the parent storage */
484   ULONG          firstPropertyNode;     /* Index of the root of the storage to enumerate */
485
486   /*
487    * The current implementation of the IEnumSTATSTGImpl class uses a stack
488    * to walk the property sets to get the content of a storage. This stack
489    * is implemented by the following 3 data members
490    */
491   ULONG          stackSize;
492   ULONG          stackMaxSize;
493   ULONG*         stackToVisit;
494
495 #define ENUMSTATSGT_SIZE_INCREMENT 10
496 };
497
498 /*
499  * Method definitions for the IEnumSTATSTGImpl class.
500  */
501 HRESULT WINAPI IEnumSTATSTGImpl_QueryInterface(
502             IEnumSTATSTG*     iface,
503             REFIID            riid,
504             void**            ppvObject);
505         
506 ULONG WINAPI IEnumSTATSTGImpl_AddRef(
507             IEnumSTATSTG*     iface); 
508         
509 ULONG WINAPI IEnumSTATSTGImpl_Release(
510             IEnumSTATSTG*     iface);
511         
512 HRESULT WINAPI IEnumSTATSTGImpl_Next(
513             IEnumSTATSTG*     iface,
514             ULONG             celt,
515             STATSTG*          rgelt,
516             ULONG*            pceltFetched);
517         
518 HRESULT WINAPI IEnumSTATSTGImpl_Skip(
519             IEnumSTATSTG*     iface,
520             ULONG             celt);
521         
522 HRESULT WINAPI IEnumSTATSTGImpl_Reset(
523             IEnumSTATSTG* iface);
524         
525 HRESULT WINAPI IEnumSTATSTGImpl_Clone(
526             IEnumSTATSTG*     iface,
527             IEnumSTATSTG**    ppenum);
528
529 IEnumSTATSTGImpl* IEnumSTATSTGImpl_Construct(
530             Storage32Impl* This,
531             ULONG          firstPropertyNode);
532
533 void IEnumSTATSTGImpl_Destroy(
534             IEnumSTATSTGImpl* This);
535
536 void IEnumSTATSTGImpl_PushSearchNode(
537             IEnumSTATSTGImpl* This,
538             ULONG             nodeToPush);
539
540 ULONG IEnumSTATSTGImpl_PopSearchNode(
541             IEnumSTATSTGImpl* This,
542             BOOL32            remove);
543
544 ULONG IEnumSTATSTGImpl_FindProperty(
545             IEnumSTATSTGImpl* This,
546             const OLECHAR32*  lpszPropName,
547             StgProperty*      buffer);
548
549 INT32 IEnumSTATSTGImpl_FindParentProperty(
550   IEnumSTATSTGImpl *This,
551   ULONG             childProperty,
552   StgProperty      *currentProperty,
553   ULONG            *propertyId);
554
555
556 /****************************************************************************
557  * StgStreamImpl definitions.
558  *
559  * This class imlements the IStream32 inteface and represents a stream
560  * located inside a storage object.
561  */
562 struct StgStreamImpl
563 {
564   ICOM_VTABLE(IStream32) *lpvtbl;  /* Needs to be the first item in the stuct
565                                     * since we want to cast this in a IStream pointer */
566   
567   /*
568    * Reference count
569    */
570   ULONG              ref;
571
572   /*
573    * Storage that is the parent(owner) of the stream
574    */
575   Storage32BaseImpl* parentStorage;
576
577   /*
578    * Index of the property that owns (points to) this stream.
579    */
580   ULONG              ownerProperty;
581
582   /*
583    * Helper variable that contains the size of the stream
584    */
585   ULARGE_INTEGER     streamSize;
586
587   /*
588    * This is the current position of the cursor in the stream
589    */
590   ULARGE_INTEGER     currentPosition;
591   
592   /*
593    * The information in the stream is represented by a chain of small blocks
594    * or a chain of large blocks. Depending on the case, one of the two
595    * following variabled points to that information.
596    */
597   BlockChainStream*      bigBlockChain;
598   SmallBlockChainStream* smallBlockChain;
599   
600 };
601
602 /*
603  * Method definition for the StgStreamImpl class.
604  */
605 StgStreamImpl* StgStreamImpl_Construct(
606                 Storage32BaseImpl* parentStorage,
607                 ULONG              ownerProperty);
608
609 void StgStreamImpl_Destroy(
610                 StgStreamImpl* This);
611
612 void StgStreamImpl_OpenBlockChain(
613                 StgStreamImpl* This);
614
615 HRESULT WINAPI StgStreamImpl_QueryInterface(
616                 IStream32*      iface,
617                 REFIID         riid,            /* [in] */          
618                 void**         ppvObject);  /* [iid_is][out] */ 
619         
620 ULONG WINAPI StgStreamImpl_AddRef(
621                 IStream32*      iface);
622         
623 ULONG WINAPI StgStreamImpl_Release(
624                 IStream32*      iface);
625         
626 HRESULT WINAPI StgStreamImpl_Read( 
627                 IStream32*      iface,
628                 void*          pv,        /* [length_is][size_is][out] */
629                 ULONG          cb,        /* [in] */                     
630                 ULONG*         pcbRead);  /* [out] */                    
631         
632 HRESULT WINAPI StgStreamImpl_Write(
633                 IStream32*      iface,
634                 const void*    pv,          /* [size_is][in] */ 
635                 ULONG          cb,          /* [in] */          
636                 ULONG*         pcbWritten); /* [out] */         
637         
638 HRESULT WINAPI StgStreamImpl_Seek( 
639                 IStream32*      iface,
640                 LARGE_INTEGER   dlibMove,         /* [in] */ 
641                 DWORD           dwOrigin,         /* [in] */ 
642                 ULARGE_INTEGER* plibNewPosition); /* [out] */
643         
644 HRESULT WINAPI StgStreamImpl_SetSize( 
645                 IStream32*      iface,
646                 ULARGE_INTEGER  libNewSize);  /* [in] */ 
647         
648 HRESULT WINAPI StgStreamImpl_CopyTo( 
649                 IStream32*      iface,
650                 IStream32*      pstm,         /* [unique][in] */ 
651                 ULARGE_INTEGER  cb,           /* [in] */         
652                 ULARGE_INTEGER* pcbRead,      /* [out] */        
653                 ULARGE_INTEGER* pcbWritten);  /* [out] */        
654
655 HRESULT WINAPI StgStreamImpl_Commit( 
656                 IStream32*      iface,
657                 DWORD           grfCommitFlags); /* [in] */ 
658         
659 HRESULT WINAPI StgStreamImpl_Revert( 
660                 IStream32*  iface);
661         
662 HRESULT WINAPI StgStreamImpl_LockRegion( 
663                 IStream32*     iface,
664                 ULARGE_INTEGER libOffset,   /* [in] */ 
665                 ULARGE_INTEGER cb,          /* [in] */ 
666                 DWORD          dwLockType); /* [in] */ 
667         
668 HRESULT WINAPI StgStreamImpl_UnlockRegion( 
669                 IStream32*     iface,
670                 ULARGE_INTEGER libOffset,   /* [in] */ 
671                 ULARGE_INTEGER cb,          /* [in] */ 
672                 DWORD          dwLockType); /* [in] */ 
673         
674 HRESULT WINAPI StgStreamImpl_Stat( 
675                 IStream32*     iface,
676                 STATSTG*       pstatstg,     /* [out] */
677                 DWORD          grfStatFlag); /* [in] */ 
678         
679 HRESULT WINAPI StgStreamImpl_Clone( 
680                 IStream32*     iface,
681                 IStream32**    ppstm);       /* [out] */ 
682
683
684 /********************************************************************************
685  * The StorageUtl_ functions are miscelaneous utility functions. Most of which are
686  * abstractions used to read values from file buffers without having to worry 
687  * about bit order
688  */
689 void StorageUtl_ReadWord(void* buffer, ULONG offset, WORD* value);
690 void StorageUtl_WriteWord(void* buffer, ULONG offset, WORD value);
691 void StorageUtl_ReadDWord(void* buffer, ULONG offset, DWORD* value);
692 void StorageUtl_WriteDWord(void* buffer, ULONG offset, DWORD value);
693 void StorageUtl_ReadGUID(void* buffer, ULONG offset, GUID* value);
694 void StorageUtl_WriteGUID(void* buffer, ULONG offset, GUID* value);
695 void StorageUtl_CopyPropertyToSTATSTG(STATSTG*     destination,
696                                              StgProperty* source,
697                                              int          statFlags);
698
699 /****************************************************************************
700  * BlockChainStream definitions.
701  *
702  * The BlockChainStream class is a utility class that is used to create an
703  * abstraction of the big block chains in the storage file.
704  */
705 struct BlockChainStream
706 {
707   Storage32Impl* parentStorage;
708   ULONG*         headOfStreamPlaceHolder;
709   ULONG          ownerPropertyIndex;
710 };
711
712 /*
713  * Methods for the BlockChainStream class.
714  */
715 BlockChainStream* BlockChainStream_Construct(
716                 Storage32Impl* parentStorage,   
717                 ULONG*         headOfStreamPlaceHolder,
718                 ULONG          propertyIndex);
719
720 void BlockChainStream_Destroy(
721                 BlockChainStream* This);
722
723 ULONG BlockChainStream_GetHeadOfChain(
724                 BlockChainStream* This);
725
726 BOOL32 BlockChainStream_ReadAt(
727                 BlockChainStream* This,
728                 ULARGE_INTEGER offset,
729                 ULONG          size,
730                 void*          buffer,
731                 ULONG*         bytesRead);
732
733 BOOL32 BlockChainStream_WriteAt(
734                 BlockChainStream* This,
735                 ULARGE_INTEGER offset,
736                 ULONG          size,
737                 const void*    buffer,
738                 ULONG*         bytesWritten);
739
740 BOOL32 BlockChainStream_SetSize(
741                 BlockChainStream* This,
742                 ULARGE_INTEGER    newSize);
743
744 ULARGE_INTEGER BlockChainStream_GetSize(
745     BlockChainStream* This);
746
747 ULONG BlockChainStream_GetCount(
748     BlockChainStream* This);
749
750 /****************************************************************************
751  * SmallBlockChainStream definitions.
752  *
753  * The SmallBlockChainStream class is a utility class that is used to create an
754  * abstraction of the small block chains in the storage file.
755  */
756 struct SmallBlockChainStream
757 {
758   Storage32Impl* parentStorage;
759   ULONG          ownerPropertyIndex;
760 };
761
762 /*
763  * Methods of the SmallBlockChainStream class.
764  */
765 SmallBlockChainStream* SmallBlockChainStream_Construct(
766                Storage32Impl* parentStorage,    
767                ULONG          propertyIndex);
768
769 void SmallBlockChainStream_Destroy(
770                SmallBlockChainStream* This);
771
772 ULONG SmallBlockChainStream_GetHeadOfChain(
773                SmallBlockChainStream* This);
774
775 ULONG SmallBlockChainStream_GetNextBlockInChain(
776                SmallBlockChainStream* This,
777                ULONG                  blockIndex);
778
779 void SmallBlockChainStream_SetNextBlockInChain(
780          SmallBlockChainStream* This,
781          ULONG                  blockIndex,
782          ULONG                  nextBlock);
783
784 void SmallBlockChainStream_FreeBlock(
785          SmallBlockChainStream* This,
786          ULONG                  blockIndex);
787
788 ULONG SmallBlockChainStream_GetNextFreeBlock(
789          SmallBlockChainStream* This);
790
791 BOOL32 SmallBlockChainStream_ReadAt(
792                SmallBlockChainStream* This,
793                ULARGE_INTEGER offset,
794                ULONG          size,
795                void*          buffer,
796                ULONG*         bytesRead);
797
798 BOOL32 SmallBlockChainStream_WriteAt(
799                SmallBlockChainStream* This,
800                ULARGE_INTEGER offset,
801                ULONG          size,
802                const void*    buffer,
803                ULONG*         bytesWritten);
804
805 BOOL32 SmallBlockChainStream_SetSize(
806                SmallBlockChainStream* This,
807                ULARGE_INTEGER          newSize);
808
809 ULARGE_INTEGER SmallBlockChainStream_GetSize(
810          SmallBlockChainStream* This);
811
812 ULONG SmallBlockChainStream_GetCount(
813          SmallBlockChainStream* This);
814
815
816 #endif __STORAGE32_H__
817
818
819