storage32.h 19 KB
Newer Older
1 2 3 4 5 6 7 8
/*
 * Compound Storage (32 bit version)
 *
 * Implemented using the documentation of the LAOLA project at
 * <URL:http://wwwwbs.cs.tu-berlin.de/~schwartz/pmh/index.html>
 * (Thanks to Martin Schwartz <schwartz@cs.tu-berlin.de>)
 *
 * This include file contains definitions of types and function
9
 * prototypes that are used in the many files implementing the
10 11 12 13
 * storage functionality
 *
 * Copyright 1998,1999 Francis Beaudet
 * Copyright 1998,1999 Thuy Nguyen
14
 * Copyright 2010 Vincent Povirk for CodeWeavers
15 16 17 18 19 20 21 22 23 24 25 26 27
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
28
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
29 30 31 32
 */
#ifndef __STORAGE32_H__
#define __STORAGE32_H__

33 34 35 36
#include <stdarg.h>

#include "windef.h"
#include "winbase.h"
37
#include "winnt.h"
38
#include "objbase.h"
39 40
#include "winreg.h"
#include "winternl.h"
41
#include "wine/list.h"
42

43 44 45
/*
 * Definitions for the file format offsets.
 */
46 47 48
static const ULONG OFFSET_MINORVERSION       = 0x00000018;
static const ULONG OFFSET_MAJORVERSION       = 0x0000001a;
static const ULONG OFFSET_BYTEORDERMARKER    = 0x0000001c;
49 50
static const ULONG OFFSET_BIGBLOCKSIZEBITS   = 0x0000001e;
static const ULONG OFFSET_SMALLBLOCKSIZEBITS = 0x00000020;
51
static const ULONG OFFSET_DIRSECTORCOUNT     = 0x00000028;
52 53
static const ULONG OFFSET_BBDEPOTCOUNT	     = 0x0000002C;
static const ULONG OFFSET_ROOTSTARTBLOCK     = 0x00000030;
54
static const ULONG OFFSET_SMALLBLOCKLIMIT    = 0x00000038;
55
static const ULONG OFFSET_SBDEPOTSTART	     = 0x0000003C;
56
static const ULONG OFFSET_SBDEPOTCOUNT       = 0x00000040;
57 58 59
static const ULONG OFFSET_EXTBBDEPOTSTART    = 0x00000044;
static const ULONG OFFSET_EXTBBDEPOTCOUNT    = 0x00000048;
static const ULONG OFFSET_BBDEPOTSTART	     = 0x0000004C;
60 61
static const ULONG OFFSET_PS_NAME            = 0x00000000;
static const ULONG OFFSET_PS_NAMELENGTH	     = 0x00000040;
62
static const ULONG OFFSET_PS_STGTYPE         = 0x00000042;
63 64
static const ULONG OFFSET_PS_LEFTCHILD       = 0x00000044;
static const ULONG OFFSET_PS_RIGHTCHILD      = 0x00000048;
65
static const ULONG OFFSET_PS_DIRROOT	     = 0x0000004C;
66
static const ULONG OFFSET_PS_GUID            = 0x00000050;
67 68 69 70
static const ULONG OFFSET_PS_CTIMELOW        = 0x00000064;
static const ULONG OFFSET_PS_CTIMEHIGH       = 0x00000068;
static const ULONG OFFSET_PS_MTIMELOW        = 0x0000006C;
static const ULONG OFFSET_PS_MTIMEHIGH       = 0x00000070;
71 72
static const ULONG OFFSET_PS_STARTBLOCK	     = 0x00000074;
static const ULONG OFFSET_PS_SIZE	     = 0x00000078;
73
static const WORD  DEF_BIG_BLOCK_SIZE_BITS   = 0x0009;
74 75
static const WORD  MIN_BIG_BLOCK_SIZE_BITS   = 0x0009;
static const WORD  MAX_BIG_BLOCK_SIZE_BITS   = 0x000c;
76 77 78
static const WORD  DEF_SMALL_BLOCK_SIZE_BITS = 0x0006;
static const WORD  DEF_BIG_BLOCK_SIZE        = 0x0200;
static const WORD  DEF_SMALL_BLOCK_SIZE      = 0x0040;
79 80 81 82
static const ULONG BLOCK_EXTBBDEPOT          = 0xFFFFFFFC;
static const ULONG BLOCK_SPECIAL             = 0xFFFFFFFD;
static const ULONG BLOCK_END_OF_CHAIN        = 0xFFFFFFFE;
static const ULONG BLOCK_UNUSED              = 0xFFFFFFFF;
83
static const ULONG DIRENTRY_NULL             = 0xFFFFFFFF;
84

85 86
#define DIRENTRY_NAME_MAX_LEN    0x20
#define DIRENTRY_NAME_BUFFER_LEN 0x40
87

88
#define RAW_DIRENTRY_SIZE 0x00000080
89

90 91
#define HEADER_SIZE 512

92 93 94
#define MIN_BIG_BLOCK_SIZE 0x200
#define MAX_BIG_BLOCK_SIZE 0x1000

95
/*
96
 * Type of child entry link
97
 */
98 99 100
#define DIRENTRY_RELATION_PREVIOUS 0
#define DIRENTRY_RELATION_NEXT     1
#define DIRENTRY_RELATION_DIR      2
101 102

/*
103
 * type constant used in files for the root storage
104
 */
105
#define STGTY_ROOT 0x05
106 107

#define COUNT_BBDEPOTINHEADER    109
108 109

/* FIXME: This value is stored in the header, but we hard-code it to 0x1000. */
110 111
#define LIMIT_TO_USE_SMALL_BLOCK 0x1000

112 113 114 115 116 117 118 119
#define STGM_ACCESS_MODE(stgm)   ((stgm)&0x0000f)
#define STGM_SHARE_MODE(stgm)    ((stgm)&0x000f0)
#define STGM_CREATE_MODE(stgm)   ((stgm)&0x0f000)

#define STGM_KNOWN_FLAGS (0xf0ff | \
     STGM_TRANSACTED | STGM_CONVERT | STGM_PRIORITY | STGM_NOSCRATCH | \
     STGM_NOSNAPSHOT | STGM_DIRECT_SWMR | STGM_DELETEONRELEASE | STGM_SIMPLE)

120 121 122 123
/*
 * Forward declarations of all the structures used by the storage
 * module.
 */
124
typedef struct StorageBaseImpl     StorageBaseImpl;
125
typedef struct StorageBaseImplVtbl StorageBaseImplVtbl;
126
typedef struct StorageImpl         StorageImpl;
127 128 129
typedef struct BlockChainStream      BlockChainStream;
typedef struct SmallBlockChainStream SmallBlockChainStream;
typedef struct IEnumSTATSTGImpl      IEnumSTATSTGImpl;
130
typedef struct DirEntry              DirEntry;
131 132
typedef struct StgStreamImpl         StgStreamImpl;

133 134 135 136 137
/*
 * A reference to a directory entry in the file or a transacted cache.
 */
typedef ULONG DirRef;

138
/*
139 140
 * This utility structure is used to read/write the information in a directory
 * entry.
141
 */
142
struct DirEntry
143
{
144
  WCHAR	         name[DIRENTRY_NAME_MAX_LEN];
145
  WORD	         sizeOfNameString;
146
  BYTE	         stgType;
147 148 149
  DirRef         leftChild;
  DirRef         rightChild;
  DirRef         dirRootEntry;
150
  GUID           clsid;
151 152
  FILETIME       ctime;
  FILETIME       mtime;
153 154 155 156
  ULONG          startingBlock;
  ULARGE_INTEGER size;
};

157
HRESULT FileLockBytesImpl_Construct(HANDLE hFile, DWORD openFlags, LPCWSTR pwcsName, ILockBytes **pLockBytes) DECLSPEC_HIDDEN;
158

Patrik Stridvall's avatar
Patrik Stridvall committed
159 160 161 162
/*************************************************************************
 * Ole Convert support
 */

163
HRESULT STORAGE_CreateOleStream(IStorage*, DWORD) DECLSPEC_HIDDEN;
164
HRESULT OLECONVERT_CreateCompObjStream(LPSTORAGE pStorage, LPCSTR strOleTypeName) DECLSPEC_HIDDEN;
Patrik Stridvall's avatar
Patrik Stridvall committed
165

166

167
/****************************************************************************
168
 * StorageBaseImpl definitions.
169
 *
Alexandre Julliard's avatar
Alexandre Julliard committed
170
 * This structure defines the base information contained in all implementations
171
 * of IStorage contained in this file storage implementation.
172
 *
173
 * In OOP terms, this is the base class for all the IStorage implementations
174 175
 * contained in this file.
 */
176
struct StorageBaseImpl
177
{
178
  IStorage IStorage_iface;
179
  IPropertySetStorage IPropertySetStorage_iface; /* interface for adding a properties stream */
180
  LONG ref;
181

182 183 184 185 186 187
  /*
   * Stream tracking list
   */

  struct list strmHead;

188 189 190 191 192
  /*
   * Storage tracking list
   */
  struct list storageHead;

193 194 195 196 197
  /*
   * TRUE if this object has been invalidated
   */
  int reverted;

198
  /*
199
   * Index of the directory entry of this storage
200
   */
201
  DirRef storageDirEntry;
202 203

  /*
204
   * virtual methods.
205
   */
206
  const StorageBaseImplVtbl *baseVtbl;
207 208 209 210 211

  /*
   * flags that this storage was opened or created with
   */
  DWORD openFlags;
212 213 214 215 216

  /*
   * State bits appear to only be preserved while running. No in the stream
   */
  DWORD stateBits;
217 218 219

  BOOL             create;     /* Was the storage created or opened.
                                  The behaviour of STGM_SIMPLE depends on this */
220 221 222 223 224
  /*
   * If this storage was opened in transacted mode, the object that implements
   * the transacted snapshot or cache.
   */
  StorageBaseImpl *transactedChild;
225 226
};

227 228 229
/* virtual methods for StorageBaseImpl objects */
struct StorageBaseImplVtbl {
  void (*Destroy)(StorageBaseImpl*);
230
  void (*Invalidate)(StorageBaseImpl*);
231
  HRESULT (*Flush)(StorageBaseImpl*);
232
  HRESULT (*GetFilename)(StorageBaseImpl*,LPWSTR*);
233
  HRESULT (*CreateDirEntry)(StorageBaseImpl*,const DirEntry*,DirRef*);
234
  HRESULT (*WriteDirEntry)(StorageBaseImpl*,DirRef,const DirEntry*);
235
  HRESULT (*ReadDirEntry)(StorageBaseImpl*,DirRef,DirEntry*);
236
  HRESULT (*DestroyDirEntry)(StorageBaseImpl*,DirRef);
237
  HRESULT (*StreamReadAt)(StorageBaseImpl*,DirRef,ULARGE_INTEGER,ULONG,void*,ULONG*);
238
  HRESULT (*StreamWriteAt)(StorageBaseImpl*,DirRef,ULARGE_INTEGER,ULONG,const void*,ULONG*);
239
  HRESULT (*StreamSetSize)(StorageBaseImpl*,DirRef,ULARGE_INTEGER);
240
  HRESULT (*StreamLink)(StorageBaseImpl*,DirRef,DirRef);
241 242 243 244 245 246 247
};

static inline void StorageBaseImpl_Destroy(StorageBaseImpl *This)
{
  This->baseVtbl->Destroy(This);
}

248 249 250 251 252
static inline void StorageBaseImpl_Invalidate(StorageBaseImpl *This)
{
  This->baseVtbl->Invalidate(This);
}

253 254 255 256 257
static inline HRESULT StorageBaseImpl_Flush(StorageBaseImpl *This)
{
  return This->baseVtbl->Flush(This);
}

258 259 260 261 262
static inline HRESULT StorageBaseImpl_GetFilename(StorageBaseImpl *This, LPWSTR *result)
{
  return This->baseVtbl->GetFilename(This, result);
}

263 264 265 266 267 268
static inline HRESULT StorageBaseImpl_CreateDirEntry(StorageBaseImpl *This,
  const DirEntry *newData, DirRef *index)
{
  return This->baseVtbl->CreateDirEntry(This, newData, index);
}

269 270 271 272 273 274
static inline HRESULT StorageBaseImpl_WriteDirEntry(StorageBaseImpl *This,
  DirRef index, const DirEntry *data)
{
  return This->baseVtbl->WriteDirEntry(This, index, data);
}

275 276 277 278 279 280
static inline HRESULT StorageBaseImpl_ReadDirEntry(StorageBaseImpl *This,
  DirRef index, DirEntry *data)
{
  return This->baseVtbl->ReadDirEntry(This, index, data);
}

281 282 283 284 285 286
static inline HRESULT StorageBaseImpl_DestroyDirEntry(StorageBaseImpl *This,
  DirRef index)
{
  return This->baseVtbl->DestroyDirEntry(This, index);
}

287 288 289 290 291 292 293
/* Read up to size bytes from this directory entry's stream at the given offset. */
static inline HRESULT StorageBaseImpl_StreamReadAt(StorageBaseImpl *This,
  DirRef index, ULARGE_INTEGER offset, ULONG size, void *buffer, ULONG *bytesRead)
{
  return This->baseVtbl->StreamReadAt(This, index, offset, size, buffer, bytesRead);
}

294 295
/* Write size bytes to this directory entry's stream at the given offset,
 * growing the stream if necessary. */
296 297 298 299 300 301
static inline HRESULT StorageBaseImpl_StreamWriteAt(StorageBaseImpl *This,
  DirRef index, ULARGE_INTEGER offset, ULONG size, const void *buffer, ULONG *bytesWritten)
{
  return This->baseVtbl->StreamWriteAt(This, index, offset, size, buffer, bytesWritten);
}

302 303 304 305 306 307
static inline HRESULT StorageBaseImpl_StreamSetSize(StorageBaseImpl *This,
  DirRef index, ULARGE_INTEGER newsize)
{
  return This->baseVtbl->StreamSetSize(This, index, newsize);
}

308 309 310 311 312 313 314 315 316 317
/* Make dst point to the same stream that src points to. Other stream operations
 * will not work properly for entries that point to the same stream, so this
 * must be a very temporary state, and only one entry pointing to a given stream
 * may be reachable at any given time. */
static inline HRESULT StorageBaseImpl_StreamLink(StorageBaseImpl *This,
  DirRef dst, DirRef src)
{
  return This->baseVtbl->StreamLink(This, dst, src);
}

318 319 320 321
/****************************************************************************
 * StorageBaseImpl stream list handlers
 */

322 323
void StorageBaseImpl_AddStream(StorageBaseImpl * stg, StgStreamImpl * strm) DECLSPEC_HIDDEN;
void StorageBaseImpl_RemoveStream(StorageBaseImpl * stg, StgStreamImpl * strm) DECLSPEC_HIDDEN;
324

325 326 327
/* Number of BlockChainStream objects to cache in a StorageImpl */
#define BLOCKCHAIN_CACHE_SIZE 4

328 329 330 331 332 333
/****************************************************************************
 * Storage32Impl definitions.
 *
 * This implementation of the IStorage32 interface represents a root
 * storage. Basically, a document file.
 */
334
struct StorageImpl
335
{
336
  struct StorageBaseImpl base;
337

338 339 340 341 342 343 344 345 346
  /*
   * File header
   */
  WORD  bigBlockSizeBits;
  WORD  smallBlockSizeBits;
  ULONG bigBlockSize;
  ULONG smallBlockSize;
  ULONG bigBlockDepotCount;
  ULONG rootStartBlock;
347
  ULONG smallBlockLimit;
348 349
  ULONG smallBlockDepotStart;
  ULONG extBigBlockDepotStart;
350 351
  ULONG *extBigBlockDepotLocations;
  ULONG extBigBlockDepotLocationsSize;
352 353
  ULONG extBigBlockDepotCount;
  ULONG bigBlockDepotStart[COUNT_BBDEPOTINHEADER];
354

355 356 357
  ULONG extBlockDepotCached[MAX_BIG_BLOCK_SIZE / 4];
  ULONG indexExtBlockDepotCached;

358
  ULONG blockDepotCached[MAX_BIG_BLOCK_SIZE / 4];
359
  ULONG indexBlockDepotCached;
360
  ULONG prevFreeBlock;
361

362 363 364
  /* All small blocks before this one are known to be in use. */
  ULONG firstFreeSmallBlock;

365 366 367 368 369
  /*
   * Abstraction of the big block chains for the chains of the header.
   */
  BlockChainStream* rootBlockChain;
  BlockChainStream* smallBlockDepotChain;
370
  BlockChainStream* smallBlockRootChain;
371

372 373 374 375
  /* Cache of block chain streams objects for directory entries */
  BlockChainStream* blockChainCache[BLOCKCHAIN_CACHE_SIZE];
  UINT blockChainToEvict;

376
  ILockBytes* lockBytes;
377 378
};

379 380 381
HRESULT StorageImpl_ReadRawDirEntry(
            StorageImpl *This,
            ULONG index,
382
            BYTE *buffer) DECLSPEC_HIDDEN;
383

384 385
void UpdateRawDirEntry(
    BYTE *buffer,
386
    const DirEntry *newData) DECLSPEC_HIDDEN;
387

388 389 390
HRESULT StorageImpl_WriteRawDirEntry(
            StorageImpl *This,
            ULONG index,
391
            const BYTE *buffer) DECLSPEC_HIDDEN;
392

393
HRESULT StorageImpl_ReadDirEntry(
394
            StorageImpl*    This,
395
            DirRef          index,
396
            DirEntry*       buffer) DECLSPEC_HIDDEN;
397

398
HRESULT StorageImpl_WriteDirEntry(
399
            StorageImpl*        This,
400
            DirRef              index,
401
            const DirEntry*     buffer) DECLSPEC_HIDDEN;
402

403
BlockChainStream* Storage32Impl_SmallBlocksToBigBlocks(
404
                      StorageImpl* This,
405
                      SmallBlockChainStream** ppsbChain) DECLSPEC_HIDDEN;
406

407 408
SmallBlockChainStream* Storage32Impl_BigBlocksToSmallBlocks(
                      StorageImpl* This,
409
                      BlockChainStream** ppbbChain,
410
                      ULARGE_INTEGER newSize) DECLSPEC_HIDDEN;
411

412 413 414
/****************************************************************************
 * StgStreamImpl definitions.
 *
415
 * This class implements the IStream interface and represents a stream
416 417 418 419
 * located inside a storage object.
 */
struct StgStreamImpl
{
420 421
  IStream IStream_iface;
  LONG ref;
422

423 424 425 426 427
  /*
   * We are an entry in the storage object's stream handler list
   */
  struct list StrmListEntry;

428 429 430
  /*
   * Storage that is the parent(owner) of the stream
   */
431
  StorageBaseImpl* parentStorage;
432

433 434 435 436 437
  /*
   * Access mode of this stream.
   */
  DWORD grfMode;

438
  /*
439
   * Index of the directory entry that owns (points to) this stream.
440
   */
441
  DirRef             dirEntry;
442 443 444 445 446 447 448

  /*
   * This is the current position of the cursor in the stream
   */
  ULARGE_INTEGER     currentPosition;
};

449 450 451 452 453
static inline StgStreamImpl *impl_from_IStream( IStream *iface )
{
    return CONTAINING_RECORD(iface, StgStreamImpl, IStream_iface);
}

454 455 456 457
/*
 * Method definition for the StgStreamImpl class.
 */
StgStreamImpl* StgStreamImpl_Construct(
458
		StorageBaseImpl* parentStorage,
459
    DWORD            grfMode,
460
    DirRef           dirEntry) DECLSPEC_HIDDEN;
461 462


463 464 465 466 467 468 469
/******************************************************************************
 * Endian conversion macros
 */
#ifdef WORDS_BIGENDIAN

#define htole32(x) RtlUlongByteSwap(x)
#define htole16(x) RtlUshortByteSwap(x)
470 471
#define lendian32toh(x) RtlUlongByteSwap(x)
#define lendian16toh(x) RtlUshortByteSwap(x)
472 473 474 475 476

#else

#define htole32(x) (x)
#define htole16(x) (x)
477 478
#define lendian32toh(x) (x)
#define lendian16toh(x) (x)
479 480 481 482 483 484 485

#endif

/******************************************************************************
 * The StorageUtl_ functions are miscellaneous utility functions. Most of which
 * are abstractions used to read values from file buffers without having to
 * worry about bit order
486
 */
487 488 489 490
void StorageUtl_ReadWord(const BYTE* buffer, ULONG offset, WORD* value) DECLSPEC_HIDDEN;
void StorageUtl_WriteWord(BYTE* buffer, ULONG offset, WORD value) DECLSPEC_HIDDEN;
void StorageUtl_ReadDWord(const BYTE* buffer, ULONG offset, DWORD* value) DECLSPEC_HIDDEN;
void StorageUtl_WriteDWord(BYTE* buffer, ULONG offset, DWORD value) DECLSPEC_HIDDEN;
Juan Lang's avatar
Juan Lang committed
491
void StorageUtl_ReadULargeInteger(const BYTE* buffer, ULONG offset,
492
 ULARGE_INTEGER* value) DECLSPEC_HIDDEN;
Juan Lang's avatar
Juan Lang committed
493
void StorageUtl_WriteULargeInteger(BYTE* buffer, ULONG offset,
494 495 496
 const ULARGE_INTEGER *value) DECLSPEC_HIDDEN;
void StorageUtl_ReadGUID(const BYTE* buffer, ULONG offset, GUID* value) DECLSPEC_HIDDEN;
void StorageUtl_WriteGUID(BYTE* buffer, ULONG offset, const GUID* value) DECLSPEC_HIDDEN;
497
void StorageUtl_CopyDirEntryToSTATSTG(StorageBaseImpl *storage,STATSTG* destination,
498
 const DirEntry* source, int statFlags) DECLSPEC_HIDDEN;
499 500 501 502 503 504 505

/****************************************************************************
 * BlockChainStream definitions.
 *
 * The BlockChainStream class is a utility class that is used to create an
 * abstraction of the big block chains in the storage file.
 */
506 507 508 509 510 511 512 513
struct BlockChainRun
{
  /* This represents a range of blocks that happen reside in consecutive sectors. */
  ULONG firstSector;
  ULONG firstOffset;
  ULONG lastOffset;
};

514 515 516 517 518 519 520 521 522
typedef struct BlockChainBlock
{
  ULONG index;
  ULONG sector;
  int read;
  int dirty;
  BYTE data[MAX_BIG_BLOCK_SIZE];
} BlockChainBlock;

523 524
struct BlockChainStream
{
525
  StorageImpl* parentStorage;
Thuy Nguyen's avatar
Thuy Nguyen committed
526
  ULONG*       headOfStreamPlaceHolder;
527
  DirRef       ownerDirEntry;
528 529 530
  struct BlockChainRun* indexCache;
  ULONG        indexCacheLen;
  ULONG        indexCacheSize;
531 532
  BlockChainBlock cachedBlocks[2];
  ULONG        blockToEvict;
Thuy Nguyen's avatar
Thuy Nguyen committed
533 534
  ULONG        tailIndex;
  ULONG        numBlocks;
535 536 537 538 539 540
};

/*
 * Methods for the BlockChainStream class.
 */
BlockChainStream* BlockChainStream_Construct(
541
		StorageImpl* parentStorage,
542
		ULONG*         headOfStreamPlaceHolder,
543
		DirRef         dirEntry) DECLSPEC_HIDDEN;
544 545

void BlockChainStream_Destroy(
546
		BlockChainStream* This) DECLSPEC_HIDDEN;
547

548
HRESULT BlockChainStream_ReadAt(
549 550 551 552
		BlockChainStream* This,
		ULARGE_INTEGER offset,
		ULONG          size,
		void*          buffer,
553
		ULONG*         bytesRead) DECLSPEC_HIDDEN;
554

555
HRESULT BlockChainStream_WriteAt(
556 557 558 559
		BlockChainStream* This,
		ULARGE_INTEGER offset,
		ULONG          size,
		const void*    buffer,
560
		ULONG*         bytesWritten) DECLSPEC_HIDDEN;
561

562
BOOL BlockChainStream_SetSize(
563
		BlockChainStream* This,
564
		ULARGE_INTEGER    newSize) DECLSPEC_HIDDEN;
565

566
HRESULT BlockChainStream_Flush(
567
                BlockChainStream* This) DECLSPEC_HIDDEN;
568

569 570 571 572 573 574 575 576
/****************************************************************************
 * SmallBlockChainStream definitions.
 *
 * The SmallBlockChainStream class is a utility class that is used to create an
 * abstraction of the small block chains in the storage file.
 */
struct SmallBlockChainStream
{
577
  StorageImpl* parentStorage;
578
  DirRef         ownerDirEntry;
579
  ULONG*         headOfStreamPlaceHolder;
580 581 582 583 584 585
};

/*
 * Methods of the SmallBlockChainStream class.
 */
SmallBlockChainStream* SmallBlockChainStream_Construct(
586 587
           StorageImpl*   parentStorage,
           ULONG*         headOfStreamPlaceHolder,
588
           DirRef         dirEntry) DECLSPEC_HIDDEN;
589 590

void SmallBlockChainStream_Destroy(
591
	       SmallBlockChainStream* This) DECLSPEC_HIDDEN;
592

593
HRESULT SmallBlockChainStream_ReadAt(
594 595 596 597
	       SmallBlockChainStream* This,
	       ULARGE_INTEGER offset,
	       ULONG          size,
	       void*          buffer,
598
	       ULONG*         bytesRead) DECLSPEC_HIDDEN;
599

600
HRESULT SmallBlockChainStream_WriteAt(
601 602 603 604
	       SmallBlockChainStream* This,
	       ULARGE_INTEGER offset,
	       ULONG          size,
	       const void*    buffer,
605
	       ULONG*         bytesWritten) DECLSPEC_HIDDEN;
606

607
BOOL SmallBlockChainStream_SetSize(
608
	       SmallBlockChainStream* This,
609
	       ULARGE_INTEGER          newSize) DECLSPEC_HIDDEN;
610 611


612
#endif /* __STORAGE32_H__ */