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