2005-07-31 12:11:56 +00: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
|
|
|
|
* prototypes that are used in the many files implementing the
|
|
|
|
* storage functionality
|
|
|
|
*
|
|
|
|
* Copyright 1998,1999 Francis Beaudet
|
|
|
|
* Copyright 1998,1999 Thuy Nguyen
|
Finish the Wine sync. These components are not just rc file changes
atl, comctl32, comdlg32, dwmapi, fusion, gdiplus, jscript, mpr, mshtml, msi, msimtf, msxml3, ole32, oleaut32, riched20, shdocvw, shlwapi, urlmon, usp10, version and windowscodecs
Seems to build and boot. /me hides
svn path=/trunk/; revision=48273
2010-07-26 02:26:04 +00:00
|
|
|
* Copyright 2010 Vincent Povirk for CodeWeavers
|
2005-07-31 12:11:56 +00: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
|
2007-04-20 12:23:52 +00:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2005-07-31 12:11:56 +00:00
|
|
|
*/
|
|
|
|
#ifndef __STORAGE32_H__
|
|
|
|
#define __STORAGE32_H__
|
|
|
|
|
2018-03-20 11:38:17 +00:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winnt.h"
|
|
|
|
#include "objbase.h"
|
|
|
|
#include "winreg.h"
|
|
|
|
#include "winternl.h"
|
|
|
|
#include "wine/list.h"
|
|
|
|
|
2005-07-31 12:11:56 +00:00
|
|
|
/*
|
|
|
|
* Definitions for the file format offsets.
|
|
|
|
*/
|
Finish the Wine sync. These components are not just rc file changes
atl, comctl32, comdlg32, dwmapi, fusion, gdiplus, jscript, mpr, mshtml, msi, msimtf, msxml3, ole32, oleaut32, riched20, shdocvw, shlwapi, urlmon, usp10, version and windowscodecs
Seems to build and boot. /me hides
svn path=/trunk/; revision=48273
2010-07-26 02:26:04 +00:00
|
|
|
static const ULONG OFFSET_MINORVERSION = 0x00000018;
|
|
|
|
static const ULONG OFFSET_MAJORVERSION = 0x0000001a;
|
|
|
|
static const ULONG OFFSET_BYTEORDERMARKER = 0x0000001c;
|
2005-07-31 12:11:56 +00:00
|
|
|
static const ULONG OFFSET_BIGBLOCKSIZEBITS = 0x0000001e;
|
|
|
|
static const ULONG OFFSET_SMALLBLOCKSIZEBITS = 0x00000020;
|
Finish the Wine sync. These components are not just rc file changes
atl, comctl32, comdlg32, dwmapi, fusion, gdiplus, jscript, mpr, mshtml, msi, msimtf, msxml3, ole32, oleaut32, riched20, shdocvw, shlwapi, urlmon, usp10, version and windowscodecs
Seems to build and boot. /me hides
svn path=/trunk/; revision=48273
2010-07-26 02:26:04 +00:00
|
|
|
static const ULONG OFFSET_DIRSECTORCOUNT = 0x00000028;
|
2005-07-31 12:11:56 +00:00
|
|
|
static const ULONG OFFSET_BBDEPOTCOUNT = 0x0000002C;
|
|
|
|
static const ULONG OFFSET_ROOTSTARTBLOCK = 0x00000030;
|
2014-10-03 11:44:27 +00:00
|
|
|
static const ULONG OFFSET_TRANSACTIONSIG = 0x00000034;
|
2010-04-20 17:36:44 +00:00
|
|
|
static const ULONG OFFSET_SMALLBLOCKLIMIT = 0x00000038;
|
2005-07-31 12:11:56 +00:00
|
|
|
static const ULONG OFFSET_SBDEPOTSTART = 0x0000003C;
|
|
|
|
static const ULONG OFFSET_SBDEPOTCOUNT = 0x00000040;
|
|
|
|
static const ULONG OFFSET_EXTBBDEPOTSTART = 0x00000044;
|
|
|
|
static const ULONG OFFSET_EXTBBDEPOTCOUNT = 0x00000048;
|
|
|
|
static const ULONG OFFSET_BBDEPOTSTART = 0x0000004C;
|
|
|
|
static const ULONG OFFSET_PS_NAME = 0x00000000;
|
|
|
|
static const ULONG OFFSET_PS_NAMELENGTH = 0x00000040;
|
2010-03-10 14:28:56 +00:00
|
|
|
static const ULONG OFFSET_PS_STGTYPE = 0x00000042;
|
|
|
|
static const ULONG OFFSET_PS_LEFTCHILD = 0x00000044;
|
|
|
|
static const ULONG OFFSET_PS_RIGHTCHILD = 0x00000048;
|
|
|
|
static const ULONG OFFSET_PS_DIRROOT = 0x0000004C;
|
2005-07-31 12:11:56 +00:00
|
|
|
static const ULONG OFFSET_PS_GUID = 0x00000050;
|
2010-03-10 14:28:56 +00:00
|
|
|
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;
|
2005-07-31 12:11:56 +00:00
|
|
|
static const ULONG OFFSET_PS_STARTBLOCK = 0x00000074;
|
|
|
|
static const ULONG OFFSET_PS_SIZE = 0x00000078;
|
2014-10-03 11:44:27 +00:00
|
|
|
static const ULONG OFFSET_PS_SIZE_HIGH = 0x0000007C;
|
2005-07-31 12:11:56 +00:00
|
|
|
static const WORD DEF_BIG_BLOCK_SIZE_BITS = 0x0009;
|
2010-04-20 17:36:44 +00:00
|
|
|
static const WORD MIN_BIG_BLOCK_SIZE_BITS = 0x0009;
|
|
|
|
static const WORD MAX_BIG_BLOCK_SIZE_BITS = 0x000c;
|
2005-07-31 12:11:56 +00:00
|
|
|
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;
|
2015-03-09 19:57:38 +00:00
|
|
|
static const ULONG BLOCK_FIRST_SPECIAL = 0xFFFFFFFB;
|
2005-07-31 12:11:56 +00: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;
|
2010-03-10 14:28:56 +00:00
|
|
|
static const ULONG DIRENTRY_NULL = 0xFFFFFFFF;
|
2005-07-31 12:11:56 +00:00
|
|
|
|
2010-03-10 14:28:56 +00:00
|
|
|
#define DIRENTRY_NAME_MAX_LEN 0x20
|
|
|
|
#define DIRENTRY_NAME_BUFFER_LEN 0x40
|
2005-07-31 12:11:56 +00:00
|
|
|
|
2010-03-10 14:28:56 +00:00
|
|
|
#define RAW_DIRENTRY_SIZE 0x00000080
|
2005-07-31 12:11:56 +00:00
|
|
|
|
2010-03-21 13:00:22 +00:00
|
|
|
#define HEADER_SIZE 512
|
|
|
|
|
|
|
|
#define MIN_BIG_BLOCK_SIZE 0x200
|
|
|
|
#define MAX_BIG_BLOCK_SIZE 0x1000
|
|
|
|
|
2005-07-31 12:11:56 +00:00
|
|
|
/*
|
2010-03-10 14:28:56 +00:00
|
|
|
* Type of child entry link
|
2005-07-31 12:11:56 +00:00
|
|
|
*/
|
2010-03-10 14:28:56 +00:00
|
|
|
#define DIRENTRY_RELATION_PREVIOUS 0
|
|
|
|
#define DIRENTRY_RELATION_NEXT 1
|
|
|
|
#define DIRENTRY_RELATION_DIR 2
|
2005-07-31 12:11:56 +00:00
|
|
|
|
|
|
|
/*
|
2010-03-10 14:28:56 +00:00
|
|
|
* type constant used in files for the root storage
|
2005-07-31 12:11:56 +00:00
|
|
|
*/
|
2010-03-10 14:28:56 +00:00
|
|
|
#define STGTY_ROOT 0x05
|
2005-07-31 12:11:56 +00:00
|
|
|
|
|
|
|
#define COUNT_BBDEPOTINHEADER 109
|
2010-04-20 17:36:44 +00:00
|
|
|
|
|
|
|
/* FIXME: This value is stored in the header, but we hard-code it to 0x1000. */
|
2005-07-31 12:11:56 +00:00
|
|
|
#define LIMIT_TO_USE_SMALL_BLOCK 0x1000
|
|
|
|
|
|
|
|
#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)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Forward declarations of all the structures used by the storage
|
|
|
|
* module.
|
|
|
|
*/
|
|
|
|
typedef struct StorageBaseImpl StorageBaseImpl;
|
2010-03-10 14:28:56 +00:00
|
|
|
typedef struct StorageBaseImplVtbl StorageBaseImplVtbl;
|
2005-07-31 12:11:56 +00:00
|
|
|
typedef struct StorageImpl StorageImpl;
|
|
|
|
typedef struct BlockChainStream BlockChainStream;
|
|
|
|
typedef struct SmallBlockChainStream SmallBlockChainStream;
|
|
|
|
typedef struct IEnumSTATSTGImpl IEnumSTATSTGImpl;
|
2010-03-10 14:28:56 +00:00
|
|
|
typedef struct DirEntry DirEntry;
|
2005-07-31 12:11:56 +00:00
|
|
|
typedef struct StgStreamImpl StgStreamImpl;
|
|
|
|
|
|
|
|
/*
|
2010-03-10 14:28:56 +00:00
|
|
|
* A reference to a directory entry in the file or a transacted cache.
|
2005-07-31 12:11:56 +00:00
|
|
|
*/
|
2010-03-10 14:28:56 +00:00
|
|
|
typedef ULONG DirRef;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This utility structure is used to read/write the information in a directory
|
|
|
|
* entry.
|
|
|
|
*/
|
|
|
|
struct DirEntry
|
2005-07-31 12:11:56 +00:00
|
|
|
{
|
2010-03-10 14:28:56 +00:00
|
|
|
WCHAR name[DIRENTRY_NAME_MAX_LEN];
|
2005-07-31 12:11:56 +00:00
|
|
|
WORD sizeOfNameString;
|
2010-03-10 14:28:56 +00:00
|
|
|
BYTE stgType;
|
|
|
|
DirRef leftChild;
|
|
|
|
DirRef rightChild;
|
|
|
|
DirRef dirRootEntry;
|
|
|
|
GUID clsid;
|
|
|
|
FILETIME ctime;
|
|
|
|
FILETIME mtime;
|
2005-07-31 12:11:56 +00:00
|
|
|
ULONG startingBlock;
|
|
|
|
ULARGE_INTEGER size;
|
|
|
|
};
|
|
|
|
|
2012-05-17 15:16:51 +00:00
|
|
|
HRESULT FileLockBytesImpl_Construct(HANDLE hFile, DWORD openFlags, LPCWSTR pwcsName, ILockBytes **pLockBytes) DECLSPEC_HIDDEN;
|
2005-07-31 12:11:56 +00:00
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* Ole Convert support
|
|
|
|
*/
|
|
|
|
|
2012-12-12 21:01:41 +00:00
|
|
|
HRESULT STORAGE_CreateOleStream(IStorage*, DWORD) DECLSPEC_HIDDEN;
|
2012-05-17 15:16:51 +00:00
|
|
|
HRESULT OLECONVERT_CreateCompObjStream(LPSTORAGE pStorage, LPCSTR strOleTypeName) DECLSPEC_HIDDEN;
|
2005-07-31 12:11:56 +00:00
|
|
|
|
2013-09-26 13:58:03 +00:00
|
|
|
enum swmr_mode
|
|
|
|
{
|
|
|
|
SWMR_None,
|
|
|
|
SWMR_Writer,
|
|
|
|
SWMR_Reader
|
|
|
|
};
|
2010-03-10 14:28:56 +00:00
|
|
|
|
2005-07-31 12:11:56 +00:00
|
|
|
/****************************************************************************
|
2012-12-12 21:01:41 +00:00
|
|
|
* StorageBaseImpl definitions.
|
2005-07-31 12:11:56 +00:00
|
|
|
*
|
|
|
|
* This structure defines the base information contained in all implementations
|
2012-12-12 21:01:41 +00:00
|
|
|
* of IStorage contained in this file storage implementation.
|
2005-07-31 12:11:56 +00:00
|
|
|
*
|
2012-12-12 21:01:41 +00:00
|
|
|
* In OOP terms, this is the base class for all the IStorage implementations
|
2005-07-31 12:11:56 +00:00
|
|
|
* contained in this file.
|
|
|
|
*/
|
|
|
|
struct StorageBaseImpl
|
|
|
|
{
|
2012-12-12 21:01:41 +00:00
|
|
|
IStorage IStorage_iface;
|
|
|
|
IPropertySetStorage IPropertySetStorage_iface; /* interface for adding a properties stream */
|
2013-09-26 13:58:03 +00:00
|
|
|
IDirectWriterLock IDirectWriterLock_iface;
|
2012-12-12 21:01:41 +00:00
|
|
|
LONG ref;
|
2005-07-31 12:11:56 +00:00
|
|
|
|
2007-04-20 12:23:52 +00:00
|
|
|
/*
|
|
|
|
* Stream tracking list
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct list strmHead;
|
|
|
|
|
2010-03-10 14:28:56 +00:00
|
|
|
/*
|
|
|
|
* Storage tracking list
|
|
|
|
*/
|
|
|
|
struct list storageHead;
|
|
|
|
|
2005-07-31 12:11:56 +00:00
|
|
|
/*
|
2010-03-10 14:28:56 +00:00
|
|
|
* TRUE if this object has been invalidated
|
2005-07-31 12:11:56 +00:00
|
|
|
*/
|
2014-04-24 12:14:13 +00:00
|
|
|
BOOL reverted;
|
2005-07-31 12:11:56 +00:00
|
|
|
|
|
|
|
/*
|
2010-03-10 14:28:56 +00:00
|
|
|
* Index of the directory entry of this storage
|
2005-07-31 12:11:56 +00:00
|
|
|
*/
|
2010-03-10 14:28:56 +00:00
|
|
|
DirRef storageDirEntry;
|
2005-07-31 12:11:56 +00:00
|
|
|
|
|
|
|
/*
|
2010-03-10 14:28:56 +00:00
|
|
|
* virtual methods.
|
2005-07-31 12:11:56 +00:00
|
|
|
*/
|
2010-03-10 14:28:56 +00:00
|
|
|
const StorageBaseImplVtbl *baseVtbl;
|
2005-07-31 12:11:56 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* flags that this storage was opened or created with
|
|
|
|
*/
|
|
|
|
DWORD openFlags;
|
2007-07-27 09:49:52 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* State bits appear to only be preserved while running. No in the stream
|
|
|
|
*/
|
|
|
|
DWORD stateBits;
|
2010-03-10 14:28:56 +00:00
|
|
|
|
2014-04-24 12:14:13 +00:00
|
|
|
BOOL create; /* Was the storage created or opened.
|
|
|
|
The behaviour of STGM_SIMPLE depends on this */
|
2010-03-10 14:28:56 +00:00
|
|
|
/*
|
|
|
|
* If this storage was opened in transacted mode, the object that implements
|
|
|
|
* the transacted snapshot or cache.
|
|
|
|
*/
|
|
|
|
StorageBaseImpl *transactedChild;
|
2013-09-26 13:58:03 +00:00
|
|
|
enum swmr_mode lockingrole;
|
2010-03-10 14:28:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* virtual methods for StorageBaseImpl objects */
|
|
|
|
struct StorageBaseImplVtbl {
|
|
|
|
void (*Destroy)(StorageBaseImpl*);
|
|
|
|
void (*Invalidate)(StorageBaseImpl*);
|
Finish the Wine sync. These components are not just rc file changes
atl, comctl32, comdlg32, dwmapi, fusion, gdiplus, jscript, mpr, mshtml, msi, msimtf, msxml3, ole32, oleaut32, riched20, shdocvw, shlwapi, urlmon, usp10, version and windowscodecs
Seems to build and boot. /me hides
svn path=/trunk/; revision=48273
2010-07-26 02:26:04 +00:00
|
|
|
HRESULT (*Flush)(StorageBaseImpl*);
|
|
|
|
HRESULT (*GetFilename)(StorageBaseImpl*,LPWSTR*);
|
2010-03-10 14:28:56 +00:00
|
|
|
HRESULT (*CreateDirEntry)(StorageBaseImpl*,const DirEntry*,DirRef*);
|
|
|
|
HRESULT (*WriteDirEntry)(StorageBaseImpl*,DirRef,const DirEntry*);
|
|
|
|
HRESULT (*ReadDirEntry)(StorageBaseImpl*,DirRef,DirEntry*);
|
|
|
|
HRESULT (*DestroyDirEntry)(StorageBaseImpl*,DirRef);
|
|
|
|
HRESULT (*StreamReadAt)(StorageBaseImpl*,DirRef,ULARGE_INTEGER,ULONG,void*,ULONG*);
|
|
|
|
HRESULT (*StreamWriteAt)(StorageBaseImpl*,DirRef,ULARGE_INTEGER,ULONG,const void*,ULONG*);
|
|
|
|
HRESULT (*StreamSetSize)(StorageBaseImpl*,DirRef,ULARGE_INTEGER);
|
2010-05-29 11:34:57 +00:00
|
|
|
HRESULT (*StreamLink)(StorageBaseImpl*,DirRef,DirRef);
|
2014-10-03 11:44:27 +00:00
|
|
|
HRESULT (*GetTransactionSig)(StorageBaseImpl*,ULONG*,BOOL);
|
|
|
|
HRESULT (*SetTransactionSig)(StorageBaseImpl*,ULONG);
|
|
|
|
HRESULT (*LockTransaction)(StorageBaseImpl*,BOOL);
|
|
|
|
HRESULT (*UnlockTransaction)(StorageBaseImpl*,BOOL);
|
2005-07-31 12:11:56 +00:00
|
|
|
};
|
|
|
|
|
2010-03-10 14:28:56 +00:00
|
|
|
static inline void StorageBaseImpl_Destroy(StorageBaseImpl *This)
|
|
|
|
{
|
|
|
|
This->baseVtbl->Destroy(This);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void StorageBaseImpl_Invalidate(StorageBaseImpl *This)
|
|
|
|
{
|
|
|
|
This->baseVtbl->Invalidate(This);
|
|
|
|
}
|
|
|
|
|
Finish the Wine sync. These components are not just rc file changes
atl, comctl32, comdlg32, dwmapi, fusion, gdiplus, jscript, mpr, mshtml, msi, msimtf, msxml3, ole32, oleaut32, riched20, shdocvw, shlwapi, urlmon, usp10, version and windowscodecs
Seems to build and boot. /me hides
svn path=/trunk/; revision=48273
2010-07-26 02:26:04 +00:00
|
|
|
static inline HRESULT StorageBaseImpl_Flush(StorageBaseImpl *This)
|
|
|
|
{
|
|
|
|
return This->baseVtbl->Flush(This);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline HRESULT StorageBaseImpl_GetFilename(StorageBaseImpl *This, LPWSTR *result)
|
|
|
|
{
|
|
|
|
return This->baseVtbl->GetFilename(This, result);
|
|
|
|
}
|
|
|
|
|
2010-03-10 14:28:56 +00:00
|
|
|
static inline HRESULT StorageBaseImpl_CreateDirEntry(StorageBaseImpl *This,
|
|
|
|
const DirEntry *newData, DirRef *index)
|
|
|
|
{
|
|
|
|
return This->baseVtbl->CreateDirEntry(This, newData, index);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline HRESULT StorageBaseImpl_WriteDirEntry(StorageBaseImpl *This,
|
|
|
|
DirRef index, const DirEntry *data)
|
|
|
|
{
|
|
|
|
return This->baseVtbl->WriteDirEntry(This, index, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline HRESULT StorageBaseImpl_ReadDirEntry(StorageBaseImpl *This,
|
|
|
|
DirRef index, DirEntry *data)
|
|
|
|
{
|
|
|
|
return This->baseVtbl->ReadDirEntry(This, index, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline HRESULT StorageBaseImpl_DestroyDirEntry(StorageBaseImpl *This,
|
|
|
|
DirRef index)
|
|
|
|
{
|
|
|
|
return This->baseVtbl->DestroyDirEntry(This, index);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 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);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Write size bytes to this directory entry's stream at the given offset,
|
|
|
|
* growing the stream if necessary. */
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline HRESULT StorageBaseImpl_StreamSetSize(StorageBaseImpl *This,
|
|
|
|
DirRef index, ULARGE_INTEGER newsize)
|
|
|
|
{
|
|
|
|
return This->baseVtbl->StreamSetSize(This, index, newsize);
|
|
|
|
}
|
|
|
|
|
2010-05-29 11:34:57 +00:00
|
|
|
/* 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);
|
|
|
|
}
|
|
|
|
|
2014-10-03 11:44:27 +00:00
|
|
|
static inline HRESULT StorageBaseImpl_GetTransactionSig(StorageBaseImpl *This,
|
|
|
|
ULONG* result, BOOL refresh)
|
|
|
|
{
|
|
|
|
return This->baseVtbl->GetTransactionSig(This, result, refresh);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline HRESULT StorageBaseImpl_SetTransactionSig(StorageBaseImpl *This,
|
|
|
|
ULONG value)
|
|
|
|
{
|
|
|
|
return This->baseVtbl->SetTransactionSig(This, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline HRESULT StorageBaseImpl_LockTransaction(StorageBaseImpl *This, BOOL write)
|
|
|
|
{
|
|
|
|
return This->baseVtbl->LockTransaction(This, write);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline HRESULT StorageBaseImpl_UnlockTransaction(StorageBaseImpl *This, BOOL write)
|
|
|
|
{
|
|
|
|
return This->baseVtbl->UnlockTransaction(This, write);
|
|
|
|
}
|
|
|
|
|
2007-04-20 12:23:52 +00:00
|
|
|
/****************************************************************************
|
|
|
|
* StorageBaseImpl stream list handlers
|
|
|
|
*/
|
|
|
|
|
2012-05-17 15:16:51 +00:00
|
|
|
void StorageBaseImpl_AddStream(StorageBaseImpl * stg, StgStreamImpl * strm) DECLSPEC_HIDDEN;
|
|
|
|
void StorageBaseImpl_RemoveStream(StorageBaseImpl * stg, StgStreamImpl * strm) DECLSPEC_HIDDEN;
|
2005-07-31 12:11:56 +00:00
|
|
|
|
2010-03-10 14:28:56 +00:00
|
|
|
/* Number of BlockChainStream objects to cache in a StorageImpl */
|
|
|
|
#define BLOCKCHAIN_CACHE_SIZE 4
|
|
|
|
|
2005-07-31 12:11:56 +00:00
|
|
|
/****************************************************************************
|
2015-07-19 23:10:53 +00:00
|
|
|
* StorageImpl definitions.
|
2005-07-31 12:11:56 +00:00
|
|
|
*
|
2015-07-19 23:10:53 +00:00
|
|
|
* This implementation of the IStorage interface represents a root
|
2005-07-31 12:11:56 +00:00
|
|
|
* storage. Basically, a document file.
|
|
|
|
*/
|
|
|
|
struct StorageImpl
|
|
|
|
{
|
|
|
|
struct StorageBaseImpl base;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* File header
|
|
|
|
*/
|
|
|
|
WORD bigBlockSizeBits;
|
|
|
|
WORD smallBlockSizeBits;
|
|
|
|
ULONG bigBlockSize;
|
|
|
|
ULONG smallBlockSize;
|
|
|
|
ULONG bigBlockDepotCount;
|
|
|
|
ULONG rootStartBlock;
|
2010-04-20 17:36:44 +00:00
|
|
|
ULONG smallBlockLimit;
|
2005-07-31 12:11:56 +00:00
|
|
|
ULONG smallBlockDepotStart;
|
|
|
|
ULONG extBigBlockDepotStart;
|
2012-05-17 15:16:51 +00:00
|
|
|
ULONG *extBigBlockDepotLocations;
|
|
|
|
ULONG extBigBlockDepotLocationsSize;
|
2005-07-31 12:11:56 +00:00
|
|
|
ULONG extBigBlockDepotCount;
|
|
|
|
ULONG bigBlockDepotStart[COUNT_BBDEPOTINHEADER];
|
2014-10-03 11:44:27 +00:00
|
|
|
ULONG transactionSig;
|
2005-07-31 12:11:56 +00:00
|
|
|
|
2012-05-17 15:16:51 +00:00
|
|
|
ULONG extBlockDepotCached[MAX_BIG_BLOCK_SIZE / 4];
|
|
|
|
ULONG indexExtBlockDepotCached;
|
|
|
|
|
2010-03-21 13:00:22 +00:00
|
|
|
ULONG blockDepotCached[MAX_BIG_BLOCK_SIZE / 4];
|
2005-07-31 12:11:56 +00:00
|
|
|
ULONG indexBlockDepotCached;
|
|
|
|
ULONG prevFreeBlock;
|
|
|
|
|
2010-04-20 17:36:44 +00:00
|
|
|
/* All small blocks before this one are known to be in use. */
|
|
|
|
ULONG firstFreeSmallBlock;
|
|
|
|
|
2005-07-31 12:11:56 +00:00
|
|
|
/*
|
|
|
|
* Abstraction of the big block chains for the chains of the header.
|
|
|
|
*/
|
|
|
|
BlockChainStream* rootBlockChain;
|
|
|
|
BlockChainStream* smallBlockDepotChain;
|
|
|
|
BlockChainStream* smallBlockRootChain;
|
|
|
|
|
2010-03-10 14:28:56 +00:00
|
|
|
/* Cache of block chain streams objects for directory entries */
|
|
|
|
BlockChainStream* blockChainCache[BLOCKCHAIN_CACHE_SIZE];
|
|
|
|
UINT blockChainToEvict;
|
|
|
|
|
2015-07-19 23:10:53 +00:00
|
|
|
ULONG locks_supported;
|
|
|
|
|
Finish the Wine sync. These components are not just rc file changes
atl, comctl32, comdlg32, dwmapi, fusion, gdiplus, jscript, mpr, mshtml, msi, msimtf, msxml3, ole32, oleaut32, riched20, shdocvw, shlwapi, urlmon, usp10, version and windowscodecs
Seems to build and boot. /me hides
svn path=/trunk/; revision=48273
2010-07-26 02:26:04 +00:00
|
|
|
ILockBytes* lockBytes;
|
2014-10-03 11:44:27 +00:00
|
|
|
|
|
|
|
ULONG locked_bytes[8];
|
2005-07-31 12:11:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* StgStreamImpl definitions.
|
|
|
|
*
|
2012-12-12 21:01:41 +00:00
|
|
|
* This class implements the IStream interface and represents a stream
|
2005-07-31 12:11:56 +00:00
|
|
|
* located inside a storage object.
|
|
|
|
*/
|
|
|
|
struct StgStreamImpl
|
|
|
|
{
|
2012-12-12 21:01:41 +00:00
|
|
|
IStream IStream_iface;
|
|
|
|
LONG ref;
|
2005-07-31 12:11:56 +00:00
|
|
|
|
2007-04-20 12:23:52 +00:00
|
|
|
/*
|
|
|
|
* We are an entry in the storage object's stream handler list
|
|
|
|
*/
|
|
|
|
struct list StrmListEntry;
|
|
|
|
|
2005-07-31 12:11:56 +00:00
|
|
|
/*
|
|
|
|
* Storage that is the parent(owner) of the stream
|
|
|
|
*/
|
|
|
|
StorageBaseImpl* parentStorage;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Access mode of this stream.
|
|
|
|
*/
|
|
|
|
DWORD grfMode;
|
|
|
|
|
|
|
|
/*
|
2010-03-10 14:28:56 +00:00
|
|
|
* Index of the directory entry that owns (points to) this stream.
|
2005-07-31 12:11:56 +00:00
|
|
|
*/
|
2010-03-10 14:28:56 +00:00
|
|
|
DirRef dirEntry;
|
2005-07-31 12:11:56 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This is the current position of the cursor in the stream
|
|
|
|
*/
|
|
|
|
ULARGE_INTEGER currentPosition;
|
|
|
|
};
|
|
|
|
|
2012-12-12 21:01:41 +00:00
|
|
|
static inline StgStreamImpl *impl_from_IStream( IStream *iface )
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, StgStreamImpl, IStream_iface);
|
|
|
|
}
|
|
|
|
|
2005-07-31 12:11:56 +00:00
|
|
|
/*
|
|
|
|
* Method definition for the StgStreamImpl class.
|
|
|
|
*/
|
|
|
|
StgStreamImpl* StgStreamImpl_Construct(
|
|
|
|
StorageBaseImpl* parentStorage,
|
|
|
|
DWORD grfMode,
|
2012-05-17 15:16:51 +00:00
|
|
|
DirRef dirEntry) DECLSPEC_HIDDEN;
|
2005-07-31 12:11:56 +00:00
|
|
|
|
|
|
|
|
2014-10-03 11:44:27 +00:00
|
|
|
/* Range lock constants.
|
|
|
|
*
|
|
|
|
* The storage format reserves the region from 0x7fffff00-0x7fffffff for
|
2015-07-19 23:10:53 +00:00
|
|
|
* locking and synchronization. Because it reserves the entire block containing
|
|
|
|
* that range, and the minimum block size is 512 bytes, 0x7ffffe00-0x7ffffeff
|
|
|
|
* also cannot be used for any other purpose.
|
|
|
|
* Unfortunately, the spec doesn't say which bytes
|
2014-10-03 11:44:27 +00:00
|
|
|
* within that range are used, and for what. These are guesses based on testing.
|
|
|
|
* In particular, ends of ranges may be wrong.
|
|
|
|
|
|
|
|
0x0 through 0x57: Unknown. Causes read-only exclusive opens to fail.
|
|
|
|
0x58 through 0x6b: Priority mode.
|
|
|
|
0x6c through 0x7f: No snapshot mode.
|
|
|
|
0x80: Commit lock.
|
|
|
|
0x81 through 0x91: Priority mode, again. Not sure why it uses two regions.
|
|
|
|
0x92: Lock-checking lock. Held while opening so ranges can be tested without
|
|
|
|
causing spurious failures if others try to grab or test those ranges at the
|
|
|
|
same time.
|
|
|
|
0x93 through 0xa6: Read mode.
|
|
|
|
0xa7 through 0xba: Write mode.
|
|
|
|
0xbb through 0xce: Deny read.
|
|
|
|
0xcf through 0xe2: Deny write.
|
|
|
|
0xe2 through 0xff: Unknown. Causes read-only exclusive opens to fail.
|
|
|
|
*/
|
|
|
|
|
2015-07-19 23:10:53 +00:00
|
|
|
#define RANGELOCK_UNK1_FIRST 0x7ffffe00
|
2014-10-03 11:44:27 +00:00
|
|
|
#define RANGELOCK_UNK1_LAST 0x7fffff57
|
|
|
|
#define RANGELOCK_PRIORITY1_FIRST 0x7fffff58
|
|
|
|
#define RANGELOCK_PRIORITY1_LAST 0x7fffff6b
|
|
|
|
#define RANGELOCK_NOSNAPSHOT_FIRST 0x7fffff6c
|
|
|
|
#define RANGELOCK_NOSNAPSHOT_LAST 0x7fffff7f
|
|
|
|
#define RANGELOCK_COMMIT 0x7fffff80
|
|
|
|
#define RANGELOCK_PRIORITY2_FIRST 0x7fffff81
|
|
|
|
#define RANGELOCK_PRIORITY2_LAST 0x7fffff91
|
|
|
|
#define RANGELOCK_CHECKLOCKS 0x7fffff92
|
|
|
|
#define RANGELOCK_READ_FIRST 0x7fffff93
|
|
|
|
#define RANGELOCK_READ_LAST 0x7fffffa6
|
|
|
|
#define RANGELOCK_WRITE_FIRST 0x7fffffa7
|
|
|
|
#define RANGELOCK_WRITE_LAST 0x7fffffba
|
|
|
|
#define RANGELOCK_DENY_READ_FIRST 0x7fffffbb
|
|
|
|
#define RANGELOCK_DENY_READ_LAST 0x7fffffce
|
|
|
|
#define RANGELOCK_DENY_WRITE_FIRST 0x7fffffcf
|
|
|
|
#define RANGELOCK_DENY_WRITE_LAST 0x7fffffe2
|
|
|
|
#define RANGELOCK_UNK2_FIRST 0x7fffffe3
|
|
|
|
#define RANGELOCK_UNK2_LAST 0x7fffffff
|
|
|
|
#define RANGELOCK_TRANSACTION_FIRST RANGELOCK_COMMIT
|
|
|
|
#define RANGELOCK_TRANSACTION_LAST RANGELOCK_CHECKLOCKS
|
|
|
|
#define RANGELOCK_FIRST RANGELOCK_UNK1_FIRST
|
|
|
|
#define RANGELOCK_LAST RANGELOCK_UNK2_LAST
|
|
|
|
|
2015-07-19 23:10:53 +00:00
|
|
|
/* internal value for LockRegion/UnlockRegion */
|
|
|
|
#define WINE_LOCK_READ 0x80000000
|
|
|
|
|
2014-10-03 11:44:27 +00:00
|
|
|
|
2005-07-31 12:11:56 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* Endian conversion macros
|
|
|
|
*/
|
|
|
|
#ifdef WORDS_BIGENDIAN
|
|
|
|
|
2018-01-20 11:57:25 +00:00
|
|
|
#ifndef htole32
|
2005-07-31 12:11:56 +00:00
|
|
|
#define htole32(x) RtlUlongByteSwap(x)
|
2018-01-20 11:57:25 +00:00
|
|
|
#endif
|
|
|
|
#ifndef htole16
|
2005-07-31 12:11:56 +00:00
|
|
|
#define htole16(x) RtlUshortByteSwap(x)
|
2018-01-20 11:57:25 +00:00
|
|
|
#endif
|
2009-05-05 15:31:02 +00:00
|
|
|
#define lendian32toh(x) RtlUlongByteSwap(x)
|
|
|
|
#define lendian16toh(x) RtlUshortByteSwap(x)
|
2005-07-31 12:11:56 +00:00
|
|
|
|
|
|
|
#else
|
|
|
|
|
2018-01-20 11:57:25 +00:00
|
|
|
#ifndef htole32
|
2005-07-31 12:11:56 +00:00
|
|
|
#define htole32(x) (x)
|
2018-01-20 11:57:25 +00:00
|
|
|
#endif
|
|
|
|
#ifndef htole16
|
2005-07-31 12:11:56 +00:00
|
|
|
#define htole16(x) (x)
|
2018-01-20 11:57:25 +00:00
|
|
|
#endif
|
2009-05-05 15:31:02 +00:00
|
|
|
#define lendian32toh(x) (x)
|
|
|
|
#define lendian16toh(x) (x)
|
2005-07-31 12:11:56 +00:00
|
|
|
|
|
|
|
#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
|
|
|
|
*/
|
2012-05-17 15:16:51 +00:00
|
|
|
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;
|
2005-07-31 12:11:56 +00:00
|
|
|
void StorageUtl_ReadULargeInteger(const BYTE* buffer, ULONG offset,
|
2012-05-17 15:16:51 +00:00
|
|
|
ULARGE_INTEGER* value) DECLSPEC_HIDDEN;
|
2005-07-31 12:11:56 +00:00
|
|
|
void StorageUtl_WriteULargeInteger(BYTE* buffer, ULONG offset,
|
2012-05-17 15:16:51 +00:00
|
|
|
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;
|
2010-03-10 14:28:56 +00:00
|
|
|
void StorageUtl_CopyDirEntryToSTATSTG(StorageBaseImpl *storage,STATSTG* destination,
|
2012-05-17 15:16:51 +00:00
|
|
|
const DirEntry* source, int statFlags) DECLSPEC_HIDDEN;
|
2005-07-31 12:11:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
#endif /* __STORAGE32_H__ */
|