1999-01-30 14:24:23 +01:00
|
|
|
/*
|
|
|
|
* 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
|
2002-06-01 01:06:46 +02:00
|
|
|
* prototypes that are used in the many files implementing the
|
1999-01-30 14:24:23 +01:00
|
|
|
* storage functionality
|
|
|
|
*
|
|
|
|
* Copyright 1998,1999 Francis Beaudet
|
|
|
|
* Copyright 1998,1999 Thuy Nguyen
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* 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
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
1999-01-30 14:24:23 +01:00
|
|
|
*/
|
|
|
|
#ifndef __STORAGE32_H__
|
|
|
|
#define __STORAGE32_H__
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
1999-08-18 20:35:57 +02:00
|
|
|
#include "winnt.h"
|
2002-12-05 21:33:07 +01:00
|
|
|
#include "objbase.h"
|
2005-04-24 19:22:26 +02:00
|
|
|
#include "winreg.h"
|
|
|
|
#include "winternl.h"
|
2006-02-21 09:03:36 +01:00
|
|
|
#include "wine/list.h"
|
1999-08-18 20:35:57 +02:00
|
|
|
|
1999-01-30 14:24:23 +01:00
|
|
|
/*
|
|
|
|
* Definitions for the file format offsets.
|
|
|
|
*/
|
|
|
|
static const ULONG OFFSET_BIGBLOCKSIZEBITS = 0x0000001e;
|
|
|
|
static const ULONG OFFSET_SMALLBLOCKSIZEBITS = 0x00000020;
|
|
|
|
static const ULONG OFFSET_BBDEPOTCOUNT = 0x0000002C;
|
|
|
|
static const ULONG OFFSET_ROOTSTARTBLOCK = 0x00000030;
|
|
|
|
static const ULONG OFFSET_SBDEPOTSTART = 0x0000003C;
|
2002-08-16 21:55:14 +02:00
|
|
|
static const ULONG OFFSET_SBDEPOTCOUNT = 0x00000040;
|
1999-01-30 14:24:23 +01:00
|
|
|
static const ULONG OFFSET_EXTBBDEPOTSTART = 0x00000044;
|
|
|
|
static const ULONG OFFSET_EXTBBDEPOTCOUNT = 0x00000048;
|
|
|
|
static const ULONG OFFSET_BBDEPOTSTART = 0x0000004C;
|
1999-02-05 10:21:51 +01:00
|
|
|
static const ULONG OFFSET_PS_NAME = 0x00000000;
|
|
|
|
static const ULONG OFFSET_PS_NAMELENGTH = 0x00000040;
|
|
|
|
static const ULONG OFFSET_PS_PROPERTYTYPE = 0x00000042;
|
|
|
|
static const ULONG OFFSET_PS_PREVIOUSPROP = 0x00000044;
|
2002-06-01 01:06:46 +02:00
|
|
|
static const ULONG OFFSET_PS_NEXTPROP = 0x00000048;
|
1999-02-05 10:21:51 +01:00
|
|
|
static const ULONG OFFSET_PS_DIRPROP = 0x0000004C;
|
|
|
|
static const ULONG OFFSET_PS_GUID = 0x00000050;
|
|
|
|
static const ULONG OFFSET_PS_TSS1 = 0x00000064;
|
|
|
|
static const ULONG OFFSET_PS_TSD1 = 0x00000068;
|
|
|
|
static const ULONG OFFSET_PS_TSS2 = 0x0000006C;
|
|
|
|
static const ULONG OFFSET_PS_TSD2 = 0x00000070;
|
2002-06-01 01:06:46 +02:00
|
|
|
static const ULONG OFFSET_PS_STARTBLOCK = 0x00000074;
|
|
|
|
static const ULONG OFFSET_PS_SIZE = 0x00000078;
|
1999-01-30 14:24:23 +01:00
|
|
|
static const WORD DEF_BIG_BLOCK_SIZE_BITS = 0x0009;
|
|
|
|
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;
|
1999-02-24 11:36:34 +01:00
|
|
|
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;
|
1999-01-30 14:24:23 +01:00
|
|
|
static const ULONG PROPERTY_NULL = 0xFFFFFFFF;
|
|
|
|
|
|
|
|
#define PROPERTY_NAME_MAX_LEN 0x20
|
2002-06-01 01:06:46 +02:00
|
|
|
#define PROPERTY_NAME_BUFFER_LEN 0x40
|
1999-01-30 14:24:23 +01:00
|
|
|
|
|
|
|
#define PROPSET_BLOCK_SIZE 0x00000080
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Property type of relation
|
|
|
|
*/
|
|
|
|
#define PROPERTY_RELATION_PREVIOUS 0
|
|
|
|
#define PROPERTY_RELATION_NEXT 1
|
|
|
|
#define PROPERTY_RELATION_DIR 2
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Property type constants
|
|
|
|
*/
|
|
|
|
#define PROPTYPE_STORAGE 0x01
|
|
|
|
#define PROPTYPE_STREAM 0x02
|
|
|
|
#define PROPTYPE_ROOT 0x05
|
|
|
|
|
|
|
|
/*
|
|
|
|
* These defines assume a hardcoded blocksize. The code will assert
|
|
|
|
* if the blocksize is different. Some changes will have to be done if it
|
|
|
|
* becomes the case.
|
|
|
|
*/
|
|
|
|
#define BIG_BLOCK_SIZE 0x200
|
|
|
|
#define COUNT_BBDEPOTINHEADER 109
|
|
|
|
#define LIMIT_TO_USE_SMALL_BLOCK 0x1000
|
1999-02-24 11:36:34 +01:00
|
|
|
#define NUM_BLOCKS_PER_DEPOT_BLOCK 128
|
1999-01-30 14:24:23 +01:00
|
|
|
|
2005-03-07 13:24:42 +01:00
|
|
|
#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)
|
|
|
|
|
1999-01-30 14:24:23 +01:00
|
|
|
/*
|
|
|
|
* These are signatures to detect the type of Document file.
|
|
|
|
*/
|
|
|
|
static const BYTE STORAGE_magic[8] ={0xd0,0xcf,0x11,0xe0,0xa1,0xb1,0x1a,0xe1};
|
|
|
|
static const BYTE STORAGE_oldmagic[8] ={0xd0,0xcf,0x11,0xe0,0x0e,0x11,0xfc,0x0d};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Forward declarations of all the structures used by the storage
|
|
|
|
* module.
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
typedef struct StorageBaseImpl StorageBaseImpl;
|
|
|
|
typedef struct StorageImpl StorageImpl;
|
1999-01-30 14:24:23 +01:00
|
|
|
typedef struct BlockChainStream BlockChainStream;
|
|
|
|
typedef struct SmallBlockChainStream SmallBlockChainStream;
|
|
|
|
typedef struct IEnumSTATSTGImpl IEnumSTATSTGImpl;
|
|
|
|
typedef struct StgProperty StgProperty;
|
|
|
|
typedef struct StgStreamImpl StgStreamImpl;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This utility structure is used to read/write the information in a storage
|
|
|
|
* property.
|
|
|
|
*/
|
|
|
|
struct StgProperty
|
|
|
|
{
|
|
|
|
WCHAR name[PROPERTY_NAME_MAX_LEN];
|
|
|
|
WORD sizeOfNameString;
|
|
|
|
BYTE propertyType;
|
|
|
|
ULONG previousProperty;
|
|
|
|
ULONG nextProperty;
|
|
|
|
ULONG dirProperty;
|
|
|
|
GUID propertyUniqueID;
|
|
|
|
ULONG timeStampS1;
|
|
|
|
ULONG timeStampD1;
|
|
|
|
ULONG timeStampS2;
|
|
|
|
ULONG timeStampD2;
|
|
|
|
ULONG startingBlock;
|
|
|
|
ULARGE_INTEGER size;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* Big Block File support
|
|
|
|
*
|
|
|
|
* The big block file is an abstraction of a flat file separated in
|
2002-06-01 01:06:46 +02:00
|
|
|
* same sized blocks. The implementation for the methods described in
|
1999-01-30 14:24:23 +01:00
|
|
|
* this section appear in stg_bigblockfile.c
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Declaration of the data structures
|
|
|
|
*/
|
|
|
|
typedef struct BigBlockFile BigBlockFile,*LPBIGBLOCKFILE;
|
|
|
|
typedef struct MappedPage MappedPage,*LPMAPPEDPAGE;
|
|
|
|
|
|
|
|
struct BigBlockFile
|
|
|
|
{
|
1999-05-08 12:05:08 +02:00
|
|
|
BOOL fileBased;
|
1999-01-30 14:24:23 +01:00
|
|
|
ULARGE_INTEGER filesize;
|
|
|
|
ULONG blocksize;
|
1999-02-26 12:11:13 +01:00
|
|
|
HANDLE hfile;
|
|
|
|
HANDLE hfilemap;
|
1999-02-18 16:55:53 +01:00
|
|
|
DWORD flProtect;
|
2000-03-17 16:08:25 +01:00
|
|
|
MappedPage *maplist;
|
|
|
|
MappedPage *victimhead, *victimtail;
|
|
|
|
ULONG num_victim_pages;
|
1999-05-08 12:05:08 +02:00
|
|
|
ILockBytes *pLkbyt;
|
|
|
|
HGLOBAL hbytearray;
|
|
|
|
LPVOID pbytearray;
|
1999-01-30 14:24:23 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Declaration of the functions used to manipulate the BigBlockFile
|
|
|
|
* data structure.
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
BigBlockFile* BIGBLOCKFILE_Construct(HANDLE hFile,
|
1999-05-08 12:05:08 +02:00
|
|
|
ILockBytes* pLkByt,
|
1999-02-18 16:55:53 +01:00
|
|
|
DWORD openFlags,
|
1999-05-08 12:05:08 +02:00
|
|
|
ULONG blocksize,
|
|
|
|
BOOL fileBased);
|
1999-01-30 14:24:23 +01:00
|
|
|
void BIGBLOCKFILE_Destructor(LPBIGBLOCKFILE This);
|
2006-08-03 21:25:14 +02:00
|
|
|
void BIGBLOCKFILE_EnsureExists(LPBIGBLOCKFILE This, ULONG index);
|
1999-01-30 14:24:23 +01:00
|
|
|
void* BIGBLOCKFILE_GetBigBlock(LPBIGBLOCKFILE This, ULONG index);
|
|
|
|
void* BIGBLOCKFILE_GetROBigBlock(LPBIGBLOCKFILE This, ULONG index);
|
|
|
|
void BIGBLOCKFILE_ReleaseBigBlock(LPBIGBLOCKFILE This, void *pBlock);
|
|
|
|
void BIGBLOCKFILE_SetSize(LPBIGBLOCKFILE This, ULARGE_INTEGER newSize);
|
|
|
|
ULARGE_INTEGER BIGBLOCKFILE_GetSize(LPBIGBLOCKFILE This);
|
|
|
|
|
2000-03-24 22:19:02 +01:00
|
|
|
/*************************************************************************
|
|
|
|
* Ole Convert support
|
|
|
|
*/
|
|
|
|
|
|
|
|
void OLECONVERT_CreateOleStream(LPSTORAGE pStorage);
|
|
|
|
HRESULT OLECONVERT_CreateCompObjStream(LPSTORAGE pStorage, LPCSTR strOleTypeName);
|
|
|
|
|
1999-01-30 14:24:23 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Storage32BaseImpl definitions.
|
|
|
|
*
|
2002-01-31 22:01:35 +01:00
|
|
|
* This structure defines the base information contained in all implementations
|
|
|
|
* of IStorage32 contained in this file storage implementation.
|
1999-01-30 14:24:23 +01:00
|
|
|
*
|
|
|
|
* In OOP terms, this is the base class for all the IStorage32 implementations
|
|
|
|
* contained in this file.
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
struct StorageBaseImpl
|
1999-01-30 14:24:23 +01:00
|
|
|
{
|
2005-06-06 21:50:35 +02:00
|
|
|
const IStorageVtbl *lpVtbl; /* Needs to be the first item in the struct
|
1999-10-31 02:59:23 +01:00
|
|
|
* since we want to cast this in a Storage32 pointer */
|
1999-01-30 14:24:23 +01:00
|
|
|
|
2005-06-06 21:50:35 +02:00
|
|
|
const IPropertySetStorageVtbl *pssVtbl; /* interface for adding a properties stream */
|
2005-02-21 21:58:09 +01:00
|
|
|
|
2006-02-21 09:03:36 +01:00
|
|
|
/*
|
|
|
|
* Stream tracking list
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct list strmHead;
|
|
|
|
|
1999-01-30 14:24:23 +01:00
|
|
|
/*
|
|
|
|
* Reference count of this object
|
|
|
|
*/
|
2005-07-05 13:02:54 +02:00
|
|
|
LONG ref;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Ancestor storage (top level)
|
1999-01-30 14:24:23 +01:00
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
StorageImpl* ancestorStorage;
|
|
|
|
|
1999-01-30 14:24:23 +01:00
|
|
|
/*
|
|
|
|
* Index of the property for the root of
|
|
|
|
* this storage
|
|
|
|
*/
|
|
|
|
ULONG rootPropertySetIndex;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
|
|
|
/*
|
1999-01-30 14:24:23 +01:00
|
|
|
* virtual Destructor method.
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
void (*v_destructor)(StorageBaseImpl*);
|
2005-05-13 15:58:43 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* flags that this storage was opened or created with
|
|
|
|
*/
|
|
|
|
DWORD openFlags;
|
1999-01-30 14:24:23 +01:00
|
|
|
};
|
|
|
|
|
2006-02-21 09:03:36 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* StorageBaseImpl stream list handlers
|
|
|
|
*/
|
|
|
|
|
|
|
|
void StorageBaseImpl_RemoveStream(StorageBaseImpl * stg, StgStreamImpl * strm);
|
1999-01-30 14:24:23 +01:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Storage32Impl definitions.
|
|
|
|
*
|
|
|
|
* This implementation of the IStorage32 interface represents a root
|
|
|
|
* storage. Basically, a document file.
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
struct StorageImpl
|
1999-01-30 14:24:23 +01:00
|
|
|
{
|
2005-02-24 20:39:27 +01:00
|
|
|
struct StorageBaseImpl base;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-01-30 14:24:23 +01:00
|
|
|
/*
|
|
|
|
* The following data members are specific to the Storage32Impl
|
|
|
|
* class
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HANDLE hFile; /* Physical support for the Docfile */
|
2002-01-01 01:13:32 +01:00
|
|
|
LPOLESTR pwcsName; /* Full path of the document file */
|
|
|
|
|
2002-01-31 22:01:35 +01:00
|
|
|
/* FIXME: should this be in Storage32BaseImpl ? */
|
|
|
|
WCHAR filename[PROPERTY_NAME_BUFFER_LEN];
|
|
|
|
|
1999-01-30 14:24:23 +01:00
|
|
|
/*
|
|
|
|
* File header
|
|
|
|
*/
|
|
|
|
WORD bigBlockSizeBits;
|
|
|
|
WORD smallBlockSizeBits;
|
|
|
|
ULONG bigBlockSize;
|
|
|
|
ULONG smallBlockSize;
|
|
|
|
ULONG bigBlockDepotCount;
|
|
|
|
ULONG rootStartBlock;
|
|
|
|
ULONG smallBlockDepotStart;
|
|
|
|
ULONG extBigBlockDepotStart;
|
|
|
|
ULONG extBigBlockDepotCount;
|
|
|
|
ULONG bigBlockDepotStart[COUNT_BBDEPOTINHEADER];
|
1999-02-24 11:36:34 +01:00
|
|
|
|
|
|
|
ULONG blockDepotCached[NUM_BLOCKS_PER_DEPOT_BLOCK];
|
|
|
|
ULONG indexBlockDepotCached;
|
1999-03-09 18:40:00 +01:00
|
|
|
ULONG prevFreeBlock;
|
1999-02-24 11:36:34 +01:00
|
|
|
|
1999-01-30 14:24:23 +01:00
|
|
|
/*
|
|
|
|
* Abstraction of the big block chains for the chains of the header.
|
|
|
|
*/
|
|
|
|
BlockChainStream* rootBlockChain;
|
|
|
|
BlockChainStream* smallBlockDepotChain;
|
2002-06-01 01:06:46 +02:00
|
|
|
BlockChainStream* smallBlockRootChain;
|
1999-01-30 14:24:23 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Pointer to the big block file abstraction
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
BigBlockFile* bigBlockFile;
|
1999-01-30 14:24:23 +01:00
|
|
|
};
|
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL StorageImpl_ReadProperty(
|
|
|
|
StorageImpl* This,
|
1999-01-30 14:24:23 +01:00
|
|
|
ULONG index,
|
|
|
|
StgProperty* buffer);
|
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL StorageImpl_WriteProperty(
|
|
|
|
StorageImpl* This,
|
1999-01-30 14:24:23 +01:00
|
|
|
ULONG index,
|
|
|
|
StgProperty* buffer);
|
|
|
|
|
1999-02-13 13:10:15 +01:00
|
|
|
BlockChainStream* Storage32Impl_SmallBlocksToBigBlocks(
|
1999-02-26 12:11:13 +01:00
|
|
|
StorageImpl* This,
|
1999-02-13 13:10:15 +01:00
|
|
|
SmallBlockChainStream** ppsbChain);
|
1999-01-30 14:24:23 +01:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* StgStreamImpl definitions.
|
|
|
|
*
|
|
|
|
* This class imlements the IStream32 inteface and represents a stream
|
|
|
|
* located inside a storage object.
|
|
|
|
*/
|
|
|
|
struct StgStreamImpl
|
|
|
|
{
|
2005-06-06 21:50:35 +02:00
|
|
|
const IStreamVtbl *lpVtbl; /* Needs to be the first item in the struct
|
2005-03-23 14:15:18 +01:00
|
|
|
* since we want to cast this to an IStream pointer */
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2006-02-21 09:03:36 +01:00
|
|
|
/*
|
|
|
|
* We are an entry in the storage object's stream handler list
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct list StrmListEntry;
|
|
|
|
|
1999-01-30 14:24:23 +01:00
|
|
|
/*
|
|
|
|
* Reference count
|
|
|
|
*/
|
2005-07-05 13:02:54 +02:00
|
|
|
LONG ref;
|
1999-01-30 14:24:23 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Storage that is the parent(owner) of the stream
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
StorageBaseImpl* parentStorage;
|
1999-01-30 14:24:23 +01:00
|
|
|
|
2000-02-25 21:58:25 +01:00
|
|
|
/*
|
|
|
|
* Access mode of this stream.
|
|
|
|
*/
|
|
|
|
DWORD grfMode;
|
|
|
|
|
1999-01-30 14:24:23 +01:00
|
|
|
/*
|
|
|
|
* Index of the property that owns (points to) this stream.
|
|
|
|
*/
|
|
|
|
ULONG ownerProperty;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Helper variable that contains the size of the stream
|
|
|
|
*/
|
|
|
|
ULARGE_INTEGER streamSize;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This is the current position of the cursor in the stream
|
|
|
|
*/
|
|
|
|
ULARGE_INTEGER currentPosition;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-01-30 14:24:23 +01:00
|
|
|
/*
|
|
|
|
* The information in the stream is represented by a chain of small blocks
|
|
|
|
* or a chain of large blocks. Depending on the case, one of the two
|
|
|
|
* following variabled points to that information.
|
|
|
|
*/
|
|
|
|
BlockChainStream* bigBlockChain;
|
|
|
|
SmallBlockChainStream* smallBlockChain;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Method definition for the StgStreamImpl class.
|
|
|
|
*/
|
|
|
|
StgStreamImpl* StgStreamImpl_Construct(
|
1999-02-26 12:11:13 +01:00
|
|
|
StorageBaseImpl* parentStorage,
|
2000-02-25 21:58:25 +01:00
|
|
|
DWORD grfMode,
|
|
|
|
ULONG ownerProperty);
|
1999-01-30 14:24:23 +01:00
|
|
|
|
|
|
|
|
2005-04-24 19:22:26 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* Endian conversion macros
|
|
|
|
*/
|
|
|
|
#ifdef WORDS_BIGENDIAN
|
|
|
|
|
|
|
|
#define htole32(x) RtlUlongByteSwap(x)
|
|
|
|
#define htole16(x) RtlUshortByteSwap(x)
|
|
|
|
#define le32toh(x) RtlUlongByteSwap(x)
|
|
|
|
#define le16toh(x) RtlUshortByteSwap(x)
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#define htole32(x) (x)
|
|
|
|
#define htole16(x) (x)
|
|
|
|
#define le32toh(x) (x)
|
|
|
|
#define le16toh(x) (x)
|
|
|
|
|
|
|
|
#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
|
1999-01-30 14:24:23 +01:00
|
|
|
*/
|
2005-03-17 11:25:13 +01:00
|
|
|
void StorageUtl_ReadWord(const BYTE* buffer, ULONG offset, WORD* value);
|
|
|
|
void StorageUtl_WriteWord(BYTE* buffer, ULONG offset, WORD value);
|
|
|
|
void StorageUtl_ReadDWord(const BYTE* buffer, ULONG offset, DWORD* value);
|
|
|
|
void StorageUtl_WriteDWord(BYTE* buffer, ULONG offset, DWORD value);
|
2005-05-14 13:06:44 +02:00
|
|
|
void StorageUtl_ReadULargeInteger(const BYTE* buffer, ULONG offset,
|
|
|
|
ULARGE_INTEGER* value);
|
|
|
|
void StorageUtl_WriteULargeInteger(BYTE* buffer, ULONG offset,
|
|
|
|
const ULARGE_INTEGER *value);
|
2005-03-17 11:25:13 +01:00
|
|
|
void StorageUtl_ReadGUID(const BYTE* buffer, ULONG offset, GUID* value);
|
|
|
|
void StorageUtl_WriteGUID(BYTE* buffer, ULONG offset, const GUID* value);
|
1999-01-30 14:24:23 +01:00
|
|
|
void StorageUtl_CopyPropertyToSTATSTG(STATSTG* destination,
|
|
|
|
StgProperty* source,
|
|
|
|
int statFlags);
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
struct BlockChainStream
|
|
|
|
{
|
1999-02-26 12:11:13 +01:00
|
|
|
StorageImpl* parentStorage;
|
1999-03-12 18:06:46 +01:00
|
|
|
ULONG* headOfStreamPlaceHolder;
|
|
|
|
ULONG ownerPropertyIndex;
|
|
|
|
ULONG lastBlockNoInSequence;
|
|
|
|
ULONG lastBlockNoInSequenceIndex;
|
|
|
|
ULONG tailIndex;
|
|
|
|
ULONG numBlocks;
|
1999-01-30 14:24:23 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Methods for the BlockChainStream class.
|
|
|
|
*/
|
|
|
|
BlockChainStream* BlockChainStream_Construct(
|
2002-06-01 01:06:46 +02:00
|
|
|
StorageImpl* parentStorage,
|
1999-01-30 14:24:23 +01:00
|
|
|
ULONG* headOfStreamPlaceHolder,
|
|
|
|
ULONG propertyIndex);
|
|
|
|
|
|
|
|
void BlockChainStream_Destroy(
|
|
|
|
BlockChainStream* This);
|
|
|
|
|
2006-09-11 12:13:47 +02:00
|
|
|
HRESULT BlockChainStream_ReadAt(
|
1999-01-30 14:24:23 +01:00
|
|
|
BlockChainStream* This,
|
|
|
|
ULARGE_INTEGER offset,
|
|
|
|
ULONG size,
|
|
|
|
void* buffer,
|
|
|
|
ULONG* bytesRead);
|
|
|
|
|
2006-09-11 12:13:47 +02:00
|
|
|
HRESULT BlockChainStream_WriteAt(
|
1999-01-30 14:24:23 +01:00
|
|
|
BlockChainStream* This,
|
|
|
|
ULARGE_INTEGER offset,
|
|
|
|
ULONG size,
|
|
|
|
const void* buffer,
|
|
|
|
ULONG* bytesWritten);
|
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL BlockChainStream_SetSize(
|
1999-01-30 14:24:23 +01:00
|
|
|
BlockChainStream* This,
|
|
|
|
ULARGE_INTEGER newSize);
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* 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
|
|
|
|
{
|
1999-02-26 12:11:13 +01:00
|
|
|
StorageImpl* parentStorage;
|
1999-01-30 14:24:23 +01:00
|
|
|
ULONG ownerPropertyIndex;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Methods of the SmallBlockChainStream class.
|
|
|
|
*/
|
|
|
|
SmallBlockChainStream* SmallBlockChainStream_Construct(
|
2002-06-01 01:06:46 +02:00
|
|
|
StorageImpl* parentStorage,
|
1999-01-30 14:24:23 +01:00
|
|
|
ULONG propertyIndex);
|
|
|
|
|
|
|
|
void SmallBlockChainStream_Destroy(
|
|
|
|
SmallBlockChainStream* This);
|
|
|
|
|
2005-12-22 17:15:05 +01:00
|
|
|
HRESULT SmallBlockChainStream_ReadAt(
|
1999-01-30 14:24:23 +01:00
|
|
|
SmallBlockChainStream* This,
|
|
|
|
ULARGE_INTEGER offset,
|
|
|
|
ULONG size,
|
|
|
|
void* buffer,
|
|
|
|
ULONG* bytesRead);
|
|
|
|
|
2006-09-11 12:13:47 +02:00
|
|
|
HRESULT SmallBlockChainStream_WriteAt(
|
1999-01-30 14:24:23 +01:00
|
|
|
SmallBlockChainStream* This,
|
|
|
|
ULARGE_INTEGER offset,
|
|
|
|
ULONG size,
|
|
|
|
const void* buffer,
|
|
|
|
ULONG* bytesWritten);
|
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL SmallBlockChainStream_SetSize(
|
1999-01-30 14:24:23 +01:00
|
|
|
SmallBlockChainStream* This,
|
|
|
|
ULARGE_INTEGER newSize);
|
|
|
|
|
|
|
|
|
1999-04-22 18:27:50 +02:00
|
|
|
#endif /* __STORAGE32_H__ */
|