~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/dlls/ole32/storage32.h

Version: ~ [ wine-1.1.33 ] ~ [ wine-1.1.32 ] ~ [ wine-1.1.31 ] ~ [ wine-1.1.30 ] ~ [ wine-1.1.29 ] ~ [ wine-1.1.28 ] ~ [ wine-1.1.27 ] ~ [ wine-1.1.26 ] ~ [ wine-1.1.25 ] ~ [ wine-1.1.24 ] ~ [ wine-1.1.23 ] ~ [ wine-1.1.22 ] ~ [ wine-1.1.21 ] ~ [ wine-1.1.20 ] ~ [ wine-1.1.19 ] ~ [ wine-1.1.18 ] ~ [ wine-1.1.17 ] ~ [ wine-1.1.16 ] ~ [ wine-1.1.15 ] ~ [ wine-1.1.14 ] ~ [ wine-1.1.13 ] ~ [ wine-1.1.12 ] ~ [ wine-1.1.11 ] ~ [ wine-1.1.10 ] ~ [ wine-1.1.9 ] ~ [ wine-1.1.8 ] ~ [ wine-1.1.7 ] ~ [ wine-1.0.1 ] ~ [ wine-1.1.6 ] ~ [ wine-1.1.5 ] ~ [ wine-1.1.4 ] ~ [ wine-1.1.3 ] ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~

  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  * This library is free software; you can redistribute it and/or
 16  * modify it under the terms of the GNU Lesser General Public
 17  * License as published by the Free Software Foundation; either
 18  * version 2.1 of the License, or (at your option) any later version.
 19  *
 20  * This library is distributed in the hope that it will be useful,
 21  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 23  * Lesser General Public License for more details.
 24  *
 25  * You should have received a copy of the GNU Lesser General Public
 26  * License along with this library; if not, write to the Free Software
 27  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 28  */
 29 #ifndef __STORAGE32_H__
 30 #define __STORAGE32_H__
 31 
 32 #include <stdarg.h>
 33 
 34 #include "windef.h"
 35 #include "winbase.h"
 36 #include "winnt.h"
 37 #include "objbase.h"
 38 #include "winreg.h"
 39 #include "winternl.h"
 40 #include "wine/list.h"
 41 
 42 /*
 43  * Definitions for the file format offsets.
 44  */
 45 static const ULONG OFFSET_BIGBLOCKSIZEBITS   = 0x0000001e;
 46 static const ULONG OFFSET_SMALLBLOCKSIZEBITS = 0x00000020;
 47 static const ULONG OFFSET_BBDEPOTCOUNT       = 0x0000002C;
 48 static const ULONG OFFSET_ROOTSTARTBLOCK     = 0x00000030;
 49 static const ULONG OFFSET_SBDEPOTSTART       = 0x0000003C;
 50 static const ULONG OFFSET_SBDEPOTCOUNT       = 0x00000040;
 51 static const ULONG OFFSET_EXTBBDEPOTSTART    = 0x00000044;
 52 static const ULONG OFFSET_EXTBBDEPOTCOUNT    = 0x00000048;
 53 static const ULONG OFFSET_BBDEPOTSTART       = 0x0000004C;
 54 static const ULONG OFFSET_PS_NAME            = 0x00000000;
 55 static const ULONG OFFSET_PS_NAMELENGTH      = 0x00000040;
 56 static const ULONG OFFSET_PS_STGTYPE         = 0x00000042;
 57 static const ULONG OFFSET_PS_LEFTCHILD       = 0x00000044;
 58 static const ULONG OFFSET_PS_RIGHTCHILD      = 0x00000048;
 59 static const ULONG OFFSET_PS_DIRROOT         = 0x0000004C;
 60 static const ULONG OFFSET_PS_GUID            = 0x00000050;
 61 static const ULONG OFFSET_PS_CTIMELOW        = 0x00000064;
 62 static const ULONG OFFSET_PS_CTIMEHIGH       = 0x00000068;
 63 static const ULONG OFFSET_PS_MTIMELOW        = 0x0000006C;
 64 static const ULONG OFFSET_PS_MTIMEHIGH       = 0x00000070;
 65 static const ULONG OFFSET_PS_STARTBLOCK      = 0x00000074;
 66 static const ULONG OFFSET_PS_SIZE            = 0x00000078;
 67 static const WORD  DEF_BIG_BLOCK_SIZE_BITS   = 0x0009;
 68 static const WORD  DEF_SMALL_BLOCK_SIZE_BITS = 0x0006;
 69 static const WORD  DEF_BIG_BLOCK_SIZE        = 0x0200;
 70 static const WORD  DEF_SMALL_BLOCK_SIZE      = 0x0040;
 71 static const ULONG BLOCK_EXTBBDEPOT          = 0xFFFFFFFC;
 72 static const ULONG BLOCK_SPECIAL             = 0xFFFFFFFD;
 73 static const ULONG BLOCK_END_OF_CHAIN        = 0xFFFFFFFE;
 74 static const ULONG BLOCK_UNUSED              = 0xFFFFFFFF;
 75 static const ULONG DIRENTRY_NULL             = 0xFFFFFFFF;
 76 
 77 #define DIRENTRY_NAME_MAX_LEN    0x20
 78 #define DIRENTRY_NAME_BUFFER_LEN 0x40
 79 
 80 #define RAW_DIRENTRY_SIZE 0x00000080
 81 
 82 /*
 83  * Type of child entry link
 84  */
 85 #define DIRENTRY_RELATION_PREVIOUS 0
 86 #define DIRENTRY_RELATION_NEXT     1
 87 #define DIRENTRY_RELATION_DIR      2
 88 
 89 /*
 90  * type constant used in files for the root storage
 91  */
 92 #define STGTY_ROOT 0x05
 93 
 94 /*
 95  * These defines assume a hardcoded blocksize. The code will assert
 96  * if the blocksize is different. Some changes will have to be done if it
 97  * becomes the case.
 98  */
 99 #define BIG_BLOCK_SIZE           0x200
100 #define COUNT_BBDEPOTINHEADER    109
101 #define LIMIT_TO_USE_SMALL_BLOCK 0x1000
102 #define NUM_BLOCKS_PER_DEPOT_BLOCK 128
103 
104 #define STGM_ACCESS_MODE(stgm)   ((stgm)&0x0000f)
105 #define STGM_SHARE_MODE(stgm)    ((stgm)&0x000f0)
106 #define STGM_CREATE_MODE(stgm)   ((stgm)&0x0f000)
107 
108 #define STGM_KNOWN_FLAGS (0xf0ff | \
109      STGM_TRANSACTED | STGM_CONVERT | STGM_PRIORITY | STGM_NOSCRATCH | \
110      STGM_NOSNAPSHOT | STGM_DIRECT_SWMR | STGM_DELETEONRELEASE | STGM_SIMPLE)
111 
112 /*
113  * Forward declarations of all the structures used by the storage
114  * module.
115  */
116 typedef struct StorageBaseImpl     StorageBaseImpl;
117 typedef struct StorageImpl         StorageImpl;
118 typedef struct BlockChainStream      BlockChainStream;
119 typedef struct SmallBlockChainStream SmallBlockChainStream;
120 typedef struct IEnumSTATSTGImpl      IEnumSTATSTGImpl;
121 typedef struct DirEntry              DirEntry;
122 typedef struct StgStreamImpl         StgStreamImpl;
123 
124 /*
125  * This utility structure is used to read/write the information in a directory
126  * entry.
127  */
128 struct DirEntry
129 {
130   WCHAR          name[DIRENTRY_NAME_MAX_LEN];
131   WORD           sizeOfNameString;
132   BYTE           propertyType;
133   ULONG          leftChild;
134   ULONG          rightChild;
135   ULONG          dirRootEntry;
136   GUID           propertyUniqueID;
137   FILETIME       ctime;
138   FILETIME       mtime;
139   ULONG          startingBlock;
140   ULARGE_INTEGER size;
141 };
142 
143 /*************************************************************************
144  * Big Block File support
145  *
146  * The big block file is an abstraction of a flat file separated in
147  * same sized blocks. The implementation for the methods described in
148  * this section appear in stg_bigblockfile.c
149  */
150 
151 typedef struct BigBlockFile BigBlockFile,*LPBIGBLOCKFILE;
152 
153 /*
154  * Declaration of the functions used to manipulate the BigBlockFile
155  * data structure.
156  */
157 BigBlockFile*  BIGBLOCKFILE_Construct(HANDLE hFile,
158                                       ILockBytes* pLkByt,
159                                       DWORD openFlags,
160                                       ULONG blocksize,
161                                       BOOL fileBased);
162 void           BIGBLOCKFILE_Destructor(LPBIGBLOCKFILE This);
163 HRESULT        BIGBLOCKFILE_EnsureExists(LPBIGBLOCKFILE This, ULONG index);
164 HRESULT        BIGBLOCKFILE_SetSize(LPBIGBLOCKFILE This, ULARGE_INTEGER newSize);
165 HRESULT        BIGBLOCKFILE_ReadAt(LPBIGBLOCKFILE This, ULARGE_INTEGER offset,
166            void* buffer, ULONG size, ULONG* bytesRead);
167 HRESULT        BIGBLOCKFILE_WriteAt(LPBIGBLOCKFILE This, ULARGE_INTEGER offset,
168            const void* buffer, ULONG size, ULONG* bytesRead);
169 
170 /*************************************************************************
171  * Ole Convert support
172  */
173 
174 void OLECONVERT_CreateOleStream(LPSTORAGE pStorage);
175 HRESULT OLECONVERT_CreateCompObjStream(LPSTORAGE pStorage, LPCSTR strOleTypeName);
176 
177 /****************************************************************************
178  * Storage32BaseImpl definitions.
179  *
180  * This structure defines the base information contained in all implementations
181  * of IStorage32 contained in this file storage implementation.
182  *
183  * In OOP terms, this is the base class for all the IStorage32 implementations
184  * contained in this file.
185  */
186 struct StorageBaseImpl
187 {
188   const IStorageVtbl *lpVtbl;    /* Needs to be the first item in the struct
189                             * since we want to cast this in a Storage32 pointer */
190 
191   const IPropertySetStorageVtbl *pssVtbl; /* interface for adding a properties stream */
192 
193   /*
194    * Stream tracking list
195    */
196 
197   struct list strmHead;
198 
199   /*
200    * Reference count of this object
201    */
202   LONG ref;
203 
204   /*
205    * Ancestor storage (top level)
206    */
207   StorageImpl* ancestorStorage;
208 
209   /*
210    * Index of the property for the root of
211    * this storage
212    */
213   ULONG rootPropertySetIndex;
214 
215   /*
216    * virtual Destructor method.
217    */
218   void (*v_destructor)(StorageBaseImpl*);
219 
220   /*
221    * flags that this storage was opened or created with
222    */
223   DWORD openFlags;
224 
225   /*
226    * State bits appear to only be preserved while running. No in the stream
227    */
228   DWORD stateBits;
229 };
230 
231 /****************************************************************************
232  * StorageBaseImpl stream list handlers
233  */
234 
235 void StorageBaseImpl_AddStream(StorageBaseImpl * stg, StgStreamImpl * strm);
236 void StorageBaseImpl_RemoveStream(StorageBaseImpl * stg, StgStreamImpl * strm);
237 
238 /****************************************************************************
239  * Storage32Impl definitions.
240  *
241  * This implementation of the IStorage32 interface represents a root
242  * storage. Basically, a document file.
243  */
244 struct StorageImpl
245 {
246   struct StorageBaseImpl base;
247 
248   /*
249    * The following data members are specific to the Storage32Impl
250    * class
251    */
252   HANDLE           hFile;      /* Physical support for the Docfile */
253   LPOLESTR         pwcsName;   /* Full path of the document file */
254   BOOL             create;     /* Was the storage created or opened.
255                                   The behaviour of STGM_SIMPLE depends on this */
256 
257   /* FIXME: should this be in Storage32BaseImpl ? */
258   WCHAR            filename[DIRENTRY_NAME_BUFFER_LEN];
259 
260   /*
261    * File header
262    */
263   WORD  bigBlockSizeBits;
264   WORD  smallBlockSizeBits;
265   ULONG bigBlockSize;
266   ULONG smallBlockSize;
267   ULONG bigBlockDepotCount;
268   ULONG rootStartBlock;
269   ULONG smallBlockDepotStart;
270   ULONG extBigBlockDepotStart;
271   ULONG extBigBlockDepotCount;
272   ULONG bigBlockDepotStart[COUNT_BBDEPOTINHEADER];
273 
274   ULONG blockDepotCached[NUM_BLOCKS_PER_DEPOT_BLOCK];
275   ULONG indexBlockDepotCached;
276   ULONG prevFreeBlock;
277 
278   /*
279    * Abstraction of the big block chains for the chains of the header.
280    */
281   BlockChainStream* rootBlockChain;
282   BlockChainStream* smallBlockDepotChain;
283   BlockChainStream* smallBlockRootChain;
284 
285   /*
286    * Pointer to the big block file abstraction
287    */
288   BigBlockFile* bigBlockFile;
289 };
290 
291 HRESULT StorageImpl_ReadRawDirEntry(
292             StorageImpl *This,
293             ULONG index,
294             BYTE *buffer);
295 
296 void UpdateRawDirEntry(
297     BYTE *buffer,
298     const DirEntry *newData);
299 
300 HRESULT StorageImpl_WriteRawDirEntry(
301             StorageImpl *This,
302             ULONG index,
303             const BYTE *buffer);
304 
305 BOOL StorageImpl_ReadDirEntry(
306             StorageImpl*    This,
307             ULONG           index,
308             DirEntry*       buffer);
309 
310 BOOL StorageImpl_WriteDirEntry(
311             StorageImpl*        This,
312             ULONG               index,
313             const DirEntry*     buffer);
314 
315 BlockChainStream* Storage32Impl_SmallBlocksToBigBlocks(
316                       StorageImpl* This,
317                       SmallBlockChainStream** ppsbChain);
318 
319 SmallBlockChainStream* Storage32Impl_BigBlocksToSmallBlocks(
320                       StorageImpl* This,
321                       BlockChainStream** ppbbChain);
322 
323 /****************************************************************************
324  * StgStreamImpl definitions.
325  *
326  * This class implements the IStream32 interface and represents a stream
327  * located inside a storage object.
328  */
329 struct StgStreamImpl
330 {
331   const IStreamVtbl *lpVtbl;  /* Needs to be the first item in the struct
332                          * since we want to cast this to an IStream pointer */
333 
334   /*
335    * We are an entry in the storage object's stream handler list
336    */
337 
338   struct list StrmListEntry;
339 
340   /*
341    * Reference count
342    */
343   LONG               ref;
344 
345   /*
346    * Storage that is the parent(owner) of the stream
347    */
348   StorageBaseImpl* parentStorage;
349 
350   /*
351    * Access mode of this stream.
352    */
353   DWORD grfMode;
354 
355   /*
356    * Index of the property that owns (points to) this stream.
357    */
358   ULONG              ownerProperty;
359 
360   /*
361    * Helper variable that contains the size of the stream
362    */
363   ULARGE_INTEGER     streamSize;
364 
365   /*
366    * This is the current position of the cursor in the stream
367    */
368   ULARGE_INTEGER     currentPosition;
369 
370   /*
371    * The information in the stream is represented by a chain of small blocks
372    * or a chain of large blocks. Depending on the case, one of the two
373    * following variables points to that information.
374    */
375   BlockChainStream*      bigBlockChain;
376   SmallBlockChainStream* smallBlockChain;
377 };
378 
379 /*
380  * Method definition for the StgStreamImpl class.
381  */
382 StgStreamImpl* StgStreamImpl_Construct(
383                 StorageBaseImpl* parentStorage,
384     DWORD            grfMode,
385     ULONG            ownerProperty);
386 
387 
388 /******************************************************************************
389  * Endian conversion macros
390  */
391 #ifdef WORDS_BIGENDIAN
392 
393 #define htole32(x) RtlUlongByteSwap(x)
394 #define htole16(x) RtlUshortByteSwap(x)
395 #define lendian32toh(x) RtlUlongByteSwap(x)
396 #define lendian16toh(x) RtlUshortByteSwap(x)
397 
398 #else
399 
400 #define htole32(x) (x)
401 #define htole16(x) (x)
402 #define lendian32toh(x) (x)
403 #define lendian16toh(x) (x)
404 
405 #endif
406 
407 /******************************************************************************
408  * The StorageUtl_ functions are miscellaneous utility functions. Most of which
409  * are abstractions used to read values from file buffers without having to
410  * worry about bit order
411  */
412 void StorageUtl_ReadWord(const BYTE* buffer, ULONG offset, WORD* value);
413 void StorageUtl_WriteWord(BYTE* buffer, ULONG offset, WORD value);
414 void StorageUtl_ReadDWord(const BYTE* buffer, ULONG offset, DWORD* value);
415 void StorageUtl_WriteDWord(BYTE* buffer, ULONG offset, DWORD value);
416 void StorageUtl_ReadULargeInteger(const BYTE* buffer, ULONG offset,
417  ULARGE_INTEGER* value);
418 void StorageUtl_WriteULargeInteger(BYTE* buffer, ULONG offset,
419  const ULARGE_INTEGER *value);
420 void StorageUtl_ReadGUID(const BYTE* buffer, ULONG offset, GUID* value);
421 void StorageUtl_WriteGUID(BYTE* buffer, ULONG offset, const GUID* value);
422 void StorageUtl_CopyDirEntryToSTATSTG(STATSTG* destination, const DirEntry* source,
423  int statFlags);
424 
425 /****************************************************************************
426  * BlockChainStream definitions.
427  *
428  * The BlockChainStream class is a utility class that is used to create an
429  * abstraction of the big block chains in the storage file.
430  */
431 struct BlockChainStream
432 {
433   StorageImpl* parentStorage;
434   ULONG*       headOfStreamPlaceHolder;
435   ULONG        ownerPropertyIndex;
436   ULONG        lastBlockNoInSequence;
437   ULONG        lastBlockNoInSequenceIndex;
438   ULONG        tailIndex;
439   ULONG        numBlocks;
440 };
441 
442 /*
443  * Methods for the BlockChainStream class.
444  */
445 BlockChainStream* BlockChainStream_Construct(
446                 StorageImpl* parentStorage,
447                 ULONG*         headOfStreamPlaceHolder,
448                 ULONG          propertyIndex);
449 
450 void BlockChainStream_Destroy(
451                 BlockChainStream* This);
452 
453 HRESULT BlockChainStream_ReadAt(
454                 BlockChainStream* This,
455                 ULARGE_INTEGER offset,
456                 ULONG          size,
457                 void*          buffer,
458                 ULONG*         bytesRead);
459 
460 HRESULT BlockChainStream_WriteAt(
461                 BlockChainStream* This,
462                 ULARGE_INTEGER offset,
463                 ULONG          size,
464                 const void*    buffer,
465                 ULONG*         bytesWritten);
466 
467 BOOL BlockChainStream_SetSize(
468                 BlockChainStream* This,
469                 ULARGE_INTEGER    newSize);
470 
471 /****************************************************************************
472  * SmallBlockChainStream definitions.
473  *
474  * The SmallBlockChainStream class is a utility class that is used to create an
475  * abstraction of the small block chains in the storage file.
476  */
477 struct SmallBlockChainStream
478 {
479   StorageImpl* parentStorage;
480   ULONG          ownerPropertyIndex;
481   ULONG*         headOfStreamPlaceHolder;
482 };
483 
484 /*
485  * Methods of the SmallBlockChainStream class.
486  */
487 SmallBlockChainStream* SmallBlockChainStream_Construct(
488            StorageImpl*   parentStorage,
489            ULONG*         headOfStreamPlaceHolder,
490            ULONG          propertyIndex);
491 
492 void SmallBlockChainStream_Destroy(
493                SmallBlockChainStream* This);
494 
495 HRESULT SmallBlockChainStream_ReadAt(
496                SmallBlockChainStream* This,
497                ULARGE_INTEGER offset,
498                ULONG          size,
499                void*          buffer,
500                ULONG*         bytesRead);
501 
502 HRESULT SmallBlockChainStream_WriteAt(
503                SmallBlockChainStream* This,
504                ULARGE_INTEGER offset,
505                ULONG          size,
506                const void*    buffer,
507                ULONG*         bytesWritten);
508 
509 BOOL SmallBlockChainStream_SetSize(
510                SmallBlockChainStream* This,
511                ULARGE_INTEGER          newSize);
512 
513 
514 #endif /* __STORAGE32_H__ */
515 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.