ReactOS 0.4.16-dev-197-g92996da
storage32.c File Reference
#include <assert.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
#include "winuser.h"
#include "wine/debug.h"
#include "storage32.h"
#include "ole2.h"
#include "winreg.h"
#include "wine/wingdi16.h"
#include "compobj_private.h"
Include dependency graph for storage32.c:

Go to the source code of this file.

Classes

struct  StorageInternalImpl
 
struct  TransactedDirEntry
 
struct  TransactedSnapshotImpl
 
struct  TransactedSharedImpl
 
struct  BlockChainRun
 
struct  BlockChainBlock
 
struct  BlockChainStream
 
struct  SmallBlockChainStream
 
struct  IEnumSTATSTGImpl
 
struct  OLECONVERT_OLESTREAM_DATA
 
struct  OLECONVERT_ISTORAGE_COMPOBJ
 
struct  OLECONVERT_ISTORAGE_OLEPRES
 

Macros

#define COBJMACROS
 
#define NONAMELESSUNION
 
#define OLESTREAM_ID   0x501
 
#define OLESTREAM_MAX_STR_LEN   255
 

Typedefs

typedef struct StorageInternalImpl StorageInternalImpl
 
typedef struct TransactedDirEntry TransactedDirEntry
 
typedef struct TransactedSnapshotImpl TransactedSnapshotImpl
 
typedef struct TransactedSharedImpl TransactedSharedImpl
 
typedef struct BlockChainBlock BlockChainBlock
 

Enumerations

enum  stream_1ole_flags { OleStream_LinkedObject = 0x00000001 , OleStream_Convert = 0x00000004 }
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (storage)
 
static StorageInternalImplStorageInternalImpl_Construct (StorageBaseImpl *, DWORD, DirRef)
 
static HRESULT Storage_ConstructTransacted (StorageBaseImpl *, BOOL, StorageBaseImpl **)
 
static ULONG BlockChainStream_GetCount (BlockChainStream *This)
 
static BlockChainStreamBlockChainStream_Construct (StorageImpl *, ULONG *, DirRef)
 
static void BlockChainStream_Destroy (BlockChainStream *)
 
static HRESULT BlockChainStream_ReadAt (BlockChainStream *, ULARGE_INTEGER, ULONG, void *, ULONG *)
 
static HRESULT BlockChainStream_WriteAt (BlockChainStream *, ULARGE_INTEGER, ULONG, const void *, ULONG *)
 
static HRESULT BlockChainStream_Flush (BlockChainStream *)
 
static ULARGE_INTEGER BlockChainStream_GetSize (BlockChainStream *)
 
static BOOL BlockChainStream_SetSize (BlockChainStream *, ULARGE_INTEGER)
 
static SmallBlockChainStreamSmallBlockChainStream_Construct (StorageImpl *, ULONG *, DirRef)
 
static void SmallBlockChainStream_Destroy (SmallBlockChainStream *)
 
static HRESULT SmallBlockChainStream_ReadAt (SmallBlockChainStream *, ULARGE_INTEGER, ULONG, void *, ULONG *)
 
static HRESULT SmallBlockChainStream_WriteAt (SmallBlockChainStream *, ULARGE_INTEGER, ULONG, const void *, ULONG *)
 
static ULARGE_INTEGER SmallBlockChainStream_GetSize (SmallBlockChainStream *)
 
static BOOL SmallBlockChainStream_SetSize (SmallBlockChainStream *, ULARGE_INTEGER)
 
static HRESULT validateSTGM (DWORD stgm)
 
static DWORD GetShareModeFromSTGM (DWORD stgm)
 
static DWORD GetAccessModeFromSTGM (DWORD stgm)
 
static DWORD GetCreationModeFromSTGM (DWORD stgm)
 
static StorageBaseImplimpl_from_IDirectWriterLock (IDirectWriterLock *iface)
 
static HRESULT WINAPI directwriterlock_QueryInterface (IDirectWriterLock *iface, REFIID riid, void **obj)
 
static ULONG WINAPI directwriterlock_AddRef (IDirectWriterLock *iface)
 
static ULONG WINAPI directwriterlock_Release (IDirectWriterLock *iface)
 
static HRESULT WINAPI directwriterlock_WaitForWriteAccess (IDirectWriterLock *iface, DWORD timeout)
 
static HRESULT WINAPI directwriterlock_ReleaseWriteAccess (IDirectWriterLock *iface)
 
static HRESULT WINAPI directwriterlock_HaveWriteAccess (IDirectWriterLock *iface)
 
static LONG entryNameCmp (const OLECHAR *name1, const OLECHAR *name2)
 
static DirRef findElement (StorageBaseImpl *storage, DirRef storageEntry, const OLECHAR *name, DirEntry *data)
 
static HRESULT findTreeParent (StorageBaseImpl *storage, DirRef storageEntry, const OLECHAR *childName, DirEntry *parentData, DirRef *parentEntry, ULONG *relation)
 
static void setEntryLink (DirEntry *entry, ULONG relation, DirRef new_target)
 
static HRESULT insertIntoTree (StorageBaseImpl *This, DirRef parentStorageIndex, DirRef newEntryIndex)
 
static HRESULT removeFromTree (StorageBaseImpl *This, DirRef parentStorageIndex, DirRef deletedIndex)
 
static IEnumSTATSTGImplimpl_from_IEnumSTATSTG (IEnumSTATSTG *iface)
 
static void IEnumSTATSTGImpl_Destroy (IEnumSTATSTGImpl *This)
 
static HRESULT WINAPI IEnumSTATSTGImpl_QueryInterface (IEnumSTATSTG *iface, REFIID riid, void **ppvObject)
 
static ULONG WINAPI IEnumSTATSTGImpl_AddRef (IEnumSTATSTG *iface)
 
static ULONG WINAPI IEnumSTATSTGImpl_Release (IEnumSTATSTG *iface)
 
static HRESULT IEnumSTATSTGImpl_GetNextRef (IEnumSTATSTGImpl *This, DirRef *ref)
 
static HRESULT WINAPI IEnumSTATSTGImpl_Next (IEnumSTATSTG *iface, ULONG celt, STATSTG *rgelt, ULONG *pceltFetched)
 
static HRESULT WINAPI IEnumSTATSTGImpl_Skip (IEnumSTATSTG *iface, ULONG celt)
 
static HRESULT WINAPI IEnumSTATSTGImpl_Reset (IEnumSTATSTG *iface)
 
static IEnumSTATSTGImplIEnumSTATSTGImpl_Construct (StorageBaseImpl *, DirRef)
 
static HRESULT WINAPI IEnumSTATSTGImpl_Clone (IEnumSTATSTG *iface, IEnumSTATSTG **ppenum)
 
static StorageBaseImplimpl_from_IStorage (IStorage *iface)
 
static HRESULT WINAPI StorageBaseImpl_QueryInterface (IStorage *iface, REFIID riid, void **ppvObject)
 
static ULONG WINAPI StorageBaseImpl_AddRef (IStorage *iface)
 
static ULONG WINAPI StorageBaseImpl_Release (IStorage *iface)
 
static HRESULT StorageBaseImpl_CopyStorageEntryTo (StorageBaseImpl *This, DirRef srcEntry, BOOL skip_storage, BOOL skip_stream, SNB snbExclude, IStorage *pstgDest)
 
static HRESULT StorageBaseImpl_CopyChildEntryTo (StorageBaseImpl *This, DirRef srcEntry, BOOL skip_storage, BOOL skip_stream, SNB snbExclude, IStorage *pstgDest)
 
static BOOL StorageBaseImpl_IsStreamOpen (StorageBaseImpl *stg, DirRef streamEntry)
 
static BOOL StorageBaseImpl_IsStorageOpen (StorageBaseImpl *stg, DirRef storageEntry)
 
static HRESULT WINAPI StorageBaseImpl_OpenStream (IStorage *iface, const OLECHAR *pwcsName, void *reserved1, DWORD grfMode, DWORD reserved2, IStream **ppstm)
 
static HRESULT WINAPI StorageBaseImpl_OpenStorage (IStorage *iface, const OLECHAR *pwcsName, IStorage *pstgPriority, DWORD grfMode, SNB snbExclude, DWORD reserved, IStorage **ppstg)
 
static HRESULT WINAPI StorageBaseImpl_EnumElements (IStorage *iface, DWORD reserved1, void *reserved2, DWORD reserved3, IEnumSTATSTG **ppenum)
 
static HRESULT WINAPI StorageBaseImpl_Stat (IStorage *iface, STATSTG *pstatstg, DWORD grfStatFlag)
 
static HRESULT WINAPI StorageBaseImpl_RenameElement (IStorage *iface, const OLECHAR *pwcsOldName, const OLECHAR *pwcsNewName)
 
static HRESULT WINAPI StorageBaseImpl_CreateStream (IStorage *iface, const OLECHAR *pwcsName, DWORD grfMode, DWORD reserved1, DWORD reserved2, IStream **ppstm)
 
static HRESULT WINAPI StorageBaseImpl_SetClass (IStorage *iface, REFCLSID clsid)
 
static HRESULT WINAPI StorageBaseImpl_CreateStorage (IStorage *iface, const OLECHAR *pwcsName, DWORD grfMode, DWORD reserved1, DWORD reserved2, IStorage **ppstg)
 
static HRESULT WINAPI StorageBaseImpl_CopyTo (IStorage *iface, DWORD ciidExclude, const IID *rgiidExclude, SNB snbExclude, IStorage *pstgDest)
 
static HRESULT WINAPI StorageBaseImpl_MoveElementTo (IStorage *iface, const OLECHAR *pwcsName, IStorage *pstgDest, const OLECHAR *pwcsNewName, DWORD grfFlags)
 
static HRESULT WINAPI StorageBaseImpl_Commit (IStorage *iface, DWORD grfCommitFlags)
 
static HRESULT WINAPI StorageBaseImpl_Revert (IStorage *iface)
 
static HRESULT deleteStorageContents (StorageBaseImpl *parentStorage, DirRef indexToDelete, DirEntry entryDataToDelete)
 
static HRESULT deleteStreamContents (StorageBaseImpl *parentStorage, DirRef indexToDelete, DirEntry entryDataToDelete)
 
static HRESULT WINAPI StorageBaseImpl_DestroyElement (IStorage *iface, const OLECHAR *pwcsName)
 
static void StorageBaseImpl_DeleteAll (StorageBaseImpl *stg)
 
static HRESULT WINAPI StorageBaseImpl_SetElementTimes (IStorage *iface, const OLECHAR *pwcsName, const FILETIME *pctime, const FILETIME *patime, const FILETIME *pmtime)
 
static HRESULT WINAPI StorageBaseImpl_SetStateBits (IStorage *iface, DWORD grfStateBits, DWORD grfMask)
 
void StorageBaseImpl_AddStream (StorageBaseImpl *stg, StgStreamImpl *strm)
 
void StorageBaseImpl_RemoveStream (StorageBaseImpl *stg, StgStreamImpl *strm)
 
static HRESULT StorageBaseImpl_CopyStream (StorageBaseImpl *dst, DirRef dst_entry, StorageBaseImpl *src, DirRef src_entry)
 
static HRESULT StorageBaseImpl_DupStorageTree (StorageBaseImpl *dst, DirRef *dst_entry, StorageBaseImpl *src, DirRef src_entry)
 
static HRESULT StorageBaseImpl_CopyStorageTree (StorageBaseImpl *dst, DirRef dst_entry, StorageBaseImpl *src, DirRef src_entry)
 
static HRESULT StorageBaseImpl_DeleteStorageTree (StorageBaseImpl *This, DirRef entry, BOOL include_siblings)
 
static HRESULT StorageImpl_ReadAt (StorageImpl *This, ULARGE_INTEGER offset, void *buffer, ULONG size, ULONG *bytesRead)
 
static HRESULT StorageImpl_WriteAt (StorageImpl *This, ULARGE_INTEGER offset, const void *buffer, const ULONG size, ULONG *bytesWritten)
 
static HRESULT StorageImpl_LoadFileHeader (StorageImpl *This)
 
static void StorageImpl_SaveFileHeader (StorageImpl *This)
 
static HRESULT StorageImpl_ReadRawDirEntry (StorageImpl *This, ULONG index, BYTE *buffer)
 
static HRESULT StorageImpl_WriteRawDirEntry (StorageImpl *This, ULONG index, const BYTE *buffer)
 
static HRESULT StorageImpl_DestroyDirEntry (StorageBaseImpl *base, DirRef index)
 
static void UpdateRawDirEntry (BYTE *buffer, const DirEntry *newData)
 
static HRESULT StorageImpl_CreateDirEntry (StorageBaseImpl *base, const DirEntry *newData, DirRef *index)
 
static HRESULT StorageImpl_ReadDirEntry (StorageImpl *This, DirRef index, DirEntry *buffer)
 
static HRESULT StorageImpl_WriteDirEntry (StorageImpl *This, DirRef index, const DirEntry *buffer)
 
static ULONGLONG StorageImpl_GetBigBlockOffset (StorageImpl *This, ULONG index)
 
static HRESULT StorageImpl_ReadBigBlock (StorageImpl *This, ULONG blockIndex, void *buffer, ULONG *out_read)
 
static BOOL StorageImpl_ReadDWordFromBigBlock (StorageImpl *This, ULONG blockIndex, ULONG offset, DWORD *value)
 
static BOOL StorageImpl_WriteBigBlock (StorageImpl *This, ULONG blockIndex, const void *buffer)
 
static BOOL StorageImpl_WriteDWordToBigBlock (StorageImpl *This, ULONG blockIndex, ULONG offset, DWORD value)
 
static BlockChainStreamStorage32Impl_SmallBlocksToBigBlocks (StorageImpl *This, SmallBlockChainStream **ppsbChain)
 
static SmallBlockChainStreamStorage32Impl_BigBlocksToSmallBlocks (StorageImpl *This, BlockChainStream **ppbbChain, ULARGE_INTEGER newSize)
 
static void Storage32Impl_AddBlockDepot (StorageImpl *This, ULONG blockIndex, ULONG depotIndex)
 
static ULONG Storage32Impl_GetExtDepotBlock (StorageImpl *This, ULONG depotIndex)
 
static void Storage32Impl_SetExtDepotBlock (StorageImpl *This, ULONG depotIndex, ULONG blockIndex)
 
static ULONG Storage32Impl_AddExtBlockDepot (StorageImpl *This)
 
static HRESULT StorageImpl_GetNextBlockInChain (StorageImpl *This, ULONG blockIndex, ULONG *nextBlockIndex)
 
static ULONG Storage32Impl_GetNextExtendedBlock (StorageImpl *This, ULONG blockIndex)
 
static void StorageImpl_SetNextBlockInChain (StorageImpl *This, ULONG blockIndex, ULONG nextBlock)
 
static ULONG StorageImpl_GetNextFreeBigBlock (StorageImpl *This)
 
static void StorageImpl_FreeBigBlock (StorageImpl *This, ULONG blockIndex)
 
static HRESULT StorageImpl_BaseWriteDirEntry (StorageBaseImpl *base, DirRef index, const DirEntry *data)
 
static HRESULT StorageImpl_BaseReadDirEntry (StorageBaseImpl *base, DirRef index, DirEntry *data)
 
static BlockChainStream ** StorageImpl_GetFreeBlockChainCacheEntry (StorageImpl *This)
 
static BlockChainStream ** StorageImpl_GetCachedBlockChainStream (StorageImpl *This, DirRef index)
 
static void StorageImpl_DeleteCachedBlockChainStream (StorageImpl *This, DirRef index)
 
static HRESULT StorageImpl_StreamReadAt (StorageBaseImpl *base, DirRef index, ULARGE_INTEGER offset, ULONG size, void *buffer, ULONG *bytesRead)
 
static HRESULT StorageImpl_StreamSetSize (StorageBaseImpl *base, DirRef index, ULARGE_INTEGER newsize)
 
static HRESULT StorageImpl_StreamWriteAt (StorageBaseImpl *base, DirRef index, ULARGE_INTEGER offset, ULONG size, const void *buffer, ULONG *bytesWritten)
 
static HRESULT StorageImpl_StreamLink (StorageBaseImpl *base, DirRef dst, DirRef src)
 
static HRESULT StorageImpl_Refresh (StorageImpl *This, BOOL new_object, BOOL create)
 
static HRESULT StorageImpl_GetTransactionSig (StorageBaseImpl *base, ULONG *result, BOOL refresh)
 
static HRESULT StorageImpl_SetTransactionSig (StorageBaseImpl *base, ULONG value)
 
static HRESULT StorageImpl_LockRegion (StorageImpl *This, ULARGE_INTEGER offset, ULARGE_INTEGER cb, DWORD dwLockType, BOOL *supported)
 
static HRESULT StorageImpl_UnlockRegion (StorageImpl *This, ULARGE_INTEGER offset, ULARGE_INTEGER cb, DWORD dwLockType)
 
static HRESULT StorageImpl_LockRegionSync (StorageImpl *This, ULARGE_INTEGER offset, ULARGE_INTEGER cb, DWORD dwLockType, BOOL *supported)
 
static HRESULT StorageImpl_LockTransaction (StorageBaseImpl *base, BOOL write)
 
static HRESULT StorageImpl_UnlockTransaction (StorageBaseImpl *base, BOOL write)
 
static HRESULT StorageImpl_GetFilename (StorageBaseImpl *iface, LPWSTR *result)
 
static HRESULT StorageImpl_CheckLockRange (StorageImpl *This, ULONG start, ULONG end, HRESULT fail_hr)
 
static HRESULT StorageImpl_LockOne (StorageImpl *This, ULONG start, ULONG end)
 
static HRESULT StorageImpl_GrabLocks (StorageImpl *This, DWORD openFlags)
 
static HRESULT StorageImpl_Flush (StorageBaseImpl *storage)
 
static void StorageImpl_Invalidate (StorageBaseImpl *iface)
 
static void StorageImpl_Destroy (StorageBaseImpl *iface)
 
static HRESULT StorageImpl_Construct (HANDLE hFile, LPCOLESTR pwcsName, ILockBytes *pLkbyt, DWORD openFlags, BOOL fileBased, BOOL create, ULONG sector_size, StorageImpl **result)
 
static void StorageInternalImpl_Invalidate (StorageBaseImpl *base)
 
static void StorageInternalImpl_Destroy (StorageBaseImpl *iface)
 
static HRESULT StorageInternalImpl_Flush (StorageBaseImpl *iface)
 
static HRESULT StorageInternalImpl_GetFilename (StorageBaseImpl *iface, LPWSTR *result)
 
static HRESULT StorageInternalImpl_CreateDirEntry (StorageBaseImpl *base, const DirEntry *newData, DirRef *index)
 
static HRESULT StorageInternalImpl_WriteDirEntry (StorageBaseImpl *base, DirRef index, const DirEntry *data)
 
static HRESULT StorageInternalImpl_ReadDirEntry (StorageBaseImpl *base, DirRef index, DirEntry *data)
 
static HRESULT StorageInternalImpl_DestroyDirEntry (StorageBaseImpl *base, DirRef index)
 
static HRESULT StorageInternalImpl_StreamReadAt (StorageBaseImpl *base, DirRef index, ULARGE_INTEGER offset, ULONG size, void *buffer, ULONG *bytesRead)
 
static HRESULT StorageInternalImpl_StreamWriteAt (StorageBaseImpl *base, DirRef index, ULARGE_INTEGER offset, ULONG size, const void *buffer, ULONG *bytesWritten)
 
static HRESULT StorageInternalImpl_StreamSetSize (StorageBaseImpl *base, DirRef index, ULARGE_INTEGER newsize)
 
static HRESULT StorageInternalImpl_StreamLink (StorageBaseImpl *base, DirRef dst, DirRef src)
 
static HRESULT StorageInternalImpl_GetTransactionSig (StorageBaseImpl *base, ULONG *result, BOOL refresh)
 
static HRESULT StorageInternalImpl_SetTransactionSig (StorageBaseImpl *base, ULONG value)
 
static HRESULT StorageInternalImpl_LockTransaction (StorageBaseImpl *base, BOOL write)
 
static HRESULT StorageInternalImpl_UnlockTransaction (StorageBaseImpl *base, BOOL write)
 
static HRESULT WINAPI StorageInternalImpl_Commit (IStorage *iface, DWORD grfCommitFlags)
 
static HRESULT WINAPI StorageInternalImpl_Revert (IStorage *iface)
 
static DirRef TransactedSnapshotImpl_FindFreeEntry (TransactedSnapshotImpl *This)
 
static DirRef TransactedSnapshotImpl_CreateStubEntry (TransactedSnapshotImpl *This, DirRef parentEntryRef)
 
static HRESULT TransactedSnapshotImpl_EnsureReadEntry (TransactedSnapshotImpl *This, DirRef entry)
 
static HRESULT TransactedSnapshotImpl_MakeStreamDirty (TransactedSnapshotImpl *This, DirRef entry)
 
static DirRef TransactedSnapshotImpl_FindFirstChild (TransactedSnapshotImpl *This, DirRef parent)
 
static DirRef TransactedSnapshotImpl_FindNextChild (TransactedSnapshotImpl *This, DirRef current)
 
static BOOL TransactedSnapshotImpl_MadeCopy (TransactedSnapshotImpl *This, DirRef entry)
 
static void TransactedSnapshotImpl_DestroyTemporaryCopy (TransactedSnapshotImpl *This, DirRef stop)
 
static HRESULT TransactedSnapshotImpl_CopyTree (TransactedSnapshotImpl *This)
 
static HRESULT WINAPI TransactedSnapshotImpl_Commit (IStorage *iface, DWORD grfCommitFlags)
 
static HRESULT WINAPI TransactedSnapshotImpl_Revert (IStorage *iface)
 
static void TransactedSnapshotImpl_Invalidate (StorageBaseImpl *This)
 
static void TransactedSnapshotImpl_Destroy (StorageBaseImpl *iface)
 
static HRESULT TransactedSnapshotImpl_Flush (StorageBaseImpl *iface)
 
static HRESULT TransactedSnapshotImpl_GetFilename (StorageBaseImpl *iface, LPWSTR *result)
 
static HRESULT TransactedSnapshotImpl_CreateDirEntry (StorageBaseImpl *base, const DirEntry *newData, DirRef *index)
 
static HRESULT TransactedSnapshotImpl_WriteDirEntry (StorageBaseImpl *base, DirRef index, const DirEntry *data)
 
static HRESULT TransactedSnapshotImpl_ReadDirEntry (StorageBaseImpl *base, DirRef index, DirEntry *data)
 
static HRESULT TransactedSnapshotImpl_DestroyDirEntry (StorageBaseImpl *base, DirRef index)
 
static HRESULT TransactedSnapshotImpl_StreamReadAt (StorageBaseImpl *base, DirRef index, ULARGE_INTEGER offset, ULONG size, void *buffer, ULONG *bytesRead)
 
static HRESULT TransactedSnapshotImpl_StreamWriteAt (StorageBaseImpl *base, DirRef index, ULARGE_INTEGER offset, ULONG size, const void *buffer, ULONG *bytesWritten)
 
static HRESULT TransactedSnapshotImpl_StreamSetSize (StorageBaseImpl *base, DirRef index, ULARGE_INTEGER newsize)
 
static HRESULT TransactedSnapshotImpl_StreamLink (StorageBaseImpl *base, DirRef dst, DirRef src)
 
static HRESULT TransactedSnapshotImpl_GetTransactionSig (StorageBaseImpl *base, ULONG *result, BOOL refresh)
 
static HRESULT TransactedSnapshotImpl_SetTransactionSig (StorageBaseImpl *base, ULONG value)
 
static HRESULT TransactedSnapshotImpl_LockTransaction (StorageBaseImpl *base, BOOL write)
 
static HRESULT TransactedSnapshotImpl_UnlockTransaction (StorageBaseImpl *base, BOOL write)
 
static HRESULT TransactedSnapshotImpl_Construct (StorageBaseImpl *parentStorage, TransactedSnapshotImpl **result)
 
static void TransactedSharedImpl_Invalidate (StorageBaseImpl *This)
 
static void TransactedSharedImpl_Destroy (StorageBaseImpl *iface)
 
static HRESULT TransactedSharedImpl_Flush (StorageBaseImpl *iface)
 
static HRESULT TransactedSharedImpl_GetFilename (StorageBaseImpl *iface, LPWSTR *result)
 
static HRESULT TransactedSharedImpl_CreateDirEntry (StorageBaseImpl *base, const DirEntry *newData, DirRef *index)
 
static HRESULT TransactedSharedImpl_WriteDirEntry (StorageBaseImpl *base, DirRef index, const DirEntry *data)
 
static HRESULT TransactedSharedImpl_ReadDirEntry (StorageBaseImpl *base, DirRef index, DirEntry *data)
 
static HRESULT TransactedSharedImpl_DestroyDirEntry (StorageBaseImpl *base, DirRef index)
 
static HRESULT TransactedSharedImpl_StreamReadAt (StorageBaseImpl *base, DirRef index, ULARGE_INTEGER offset, ULONG size, void *buffer, ULONG *bytesRead)
 
static HRESULT TransactedSharedImpl_StreamWriteAt (StorageBaseImpl *base, DirRef index, ULARGE_INTEGER offset, ULONG size, const void *buffer, ULONG *bytesWritten)
 
static HRESULT TransactedSharedImpl_StreamSetSize (StorageBaseImpl *base, DirRef index, ULARGE_INTEGER newsize)
 
static HRESULT TransactedSharedImpl_StreamLink (StorageBaseImpl *base, DirRef dst, DirRef src)
 
static HRESULT TransactedSharedImpl_GetTransactionSig (StorageBaseImpl *base, ULONG *result, BOOL refresh)
 
static HRESULT TransactedSharedImpl_SetTransactionSig (StorageBaseImpl *base, ULONG value)
 
static HRESULT TransactedSharedImpl_LockTransaction (StorageBaseImpl *base, BOOL write)
 
static HRESULT TransactedSharedImpl_UnlockTransaction (StorageBaseImpl *base, BOOL write)
 
static HRESULT WINAPI TransactedSharedImpl_Commit (IStorage *iface, DWORD grfCommitFlags)
 
static HRESULT WINAPI TransactedSharedImpl_Revert (IStorage *iface)
 
static HRESULT TransactedSharedImpl_Construct (StorageBaseImpl *parentStorage, TransactedSharedImpl **result)
 
static HRESULT Storage_Construct (HANDLE hFile, LPCOLESTR pwcsName, ILockBytes *pLkbyt, DWORD openFlags, BOOL fileBased, BOOL create, ULONG sector_size, StorageBaseImpl **result)
 
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)
 
void StorageUtl_ReadULargeInteger (const BYTE *buffer, ULONG offset, ULARGE_INTEGER *value)
 
void StorageUtl_WriteULargeInteger (BYTE *buffer, ULONG offset, const ULARGE_INTEGER *value)
 
void StorageUtl_ReadGUID (const BYTE *buffer, ULONG offset, GUID *value)
 
void StorageUtl_WriteGUID (BYTE *buffer, ULONG offset, const GUID *value)
 
void StorageUtl_CopyDirEntryToSTATSTG (StorageBaseImpl *storage, STATSTG *destination, const DirEntry *source, int statFlags)
 
static ULONG BlockChainStream_GetHeadOfChain (BlockChainStream *This)
 
static HRESULT BlockChainStream_UpdateIndexCache (BlockChainStream *This)
 
static ULONG BlockChainStream_GetSectorOfOffset (BlockChainStream *This, ULONG offset)
 
static HRESULT BlockChainStream_GetBlockAtOffset (BlockChainStream *This, ULONG index, BlockChainBlock **block, ULONG *sector, BOOL create)
 
static BOOL BlockChainStream_Shrink (BlockChainStream *This, ULARGE_INTEGER newSize)
 
static BOOL BlockChainStream_Enlarge (BlockChainStream *This, ULARGE_INTEGER newSize)
 
static ULONG SmallBlockChainStream_GetHeadOfChain (SmallBlockChainStream *This)
 
static HRESULT SmallBlockChainStream_GetNextBlockInChain (SmallBlockChainStream *This, ULONG blockIndex, ULONG *nextBlockInChain)
 
static void SmallBlockChainStream_SetNextBlockInChain (SmallBlockChainStream *This, ULONG blockIndex, ULONG nextBlock)
 
static void SmallBlockChainStream_FreeBlock (SmallBlockChainStream *This, ULONG blockIndex)
 
static ULONG SmallBlockChainStream_GetNextFreeBlock (SmallBlockChainStream *This)
 
static BOOL SmallBlockChainStream_Shrink (SmallBlockChainStream *This, ULARGE_INTEGER newSize)
 
static BOOL SmallBlockChainStream_Enlarge (SmallBlockChainStream *This, ULARGE_INTEGER newSize)
 
static ULONG SmallBlockChainStream_GetCount (SmallBlockChainStream *This)
 
static HRESULT create_storagefile (LPCOLESTR pwcsName, DWORD grfMode, DWORD grfAttrs, STGOPTIONS *pStgOptions, REFIID riid, void **ppstgOpen)
 
HRESULT WINAPI StgCreateDocfile (LPCOLESTR pwcsName, DWORD grfMode, DWORD reserved, IStorage **ppstgOpen)
 
HRESULT WINAPI StgCreateStorageEx (const WCHAR *pwcsName, DWORD grfMode, DWORD stgfmt, DWORD grfAttrs, STGOPTIONS *pStgOptions, void *reserved, REFIID riid, void **ppObjectOpen)
 
HRESULT WINAPI StgCreatePropSetStg (IStorage *pstg, DWORD reserved, IPropertySetStorage **propset)
 
HRESULT WINAPI StgOpenStorageEx (const WCHAR *pwcsName, DWORD grfMode, DWORD stgfmt, DWORD grfAttrs, STGOPTIONS *pStgOptions, void *reserved, REFIID riid, void **ppObjectOpen)
 
HRESULT WINAPI StgOpenStorage (const OLECHAR *pwcsName, IStorage *pstgPriority, DWORD grfMode, SNB snbExclude, DWORD reserved, IStorage **ppstgOpen)
 
HRESULT WINAPI StgCreateDocfileOnILockBytes (ILockBytes *plkbyt, DWORD grfMode, DWORD reserved, IStorage **ppstgOpen)
 
HRESULT WINAPI StgOpenStorageOnILockBytes (ILockBytes *plkbyt, IStorage *pstgPriority, DWORD grfMode, SNB snbExclude, DWORD reserved, IStorage **ppstgOpen)
 
HRESULT WINAPI StgSetTimes (OLECHAR const *str, FILETIME const *pctime, FILETIME const *patime, FILETIME const *pmtime)
 
HRESULT WINAPI StgIsStorageILockBytes (ILockBytes *plkbyt)
 
HRESULT WINAPI WriteClassStg (IStorage *pStg, REFCLSID rclsid)
 
HRESULT WINAPI ReadClassStg (IStorage *pstg, CLSID *pclsid)
 
HRESULT WINAPI OleLoadFromStream (IStream *pStm, REFIID iidInterface, void **ppvObj)
 
HRESULT WINAPI OleSaveToStream (IPersistStream *pPStm, IStream *pStm)
 
HRESULT STORAGE_CreateOleStream (IStorage *storage, DWORD flags)
 
static HRESULT STREAM_WriteString (IStream *stm, LPCWSTR string)
 
static HRESULT STREAM_ReadString (IStream *stm, LPWSTR *string)
 
static HRESULT STORAGE_WriteCompObj (LPSTORAGE pstg, CLSID *clsid, LPCWSTR lpszUserType, LPCWSTR szClipName, LPCWSTR szProgIDName)
 
HRESULT WINAPI WriteFmtUserTypeStg (LPSTORAGE pstg, CLIPFORMAT cf, LPOLESTR lpszUserType)
 
HRESULT WINAPI ReadFmtUserTypeStg (LPSTORAGE pstg, CLIPFORMAT *pcf, LPOLESTR *lplpszUserType)
 
HRESULT WINAPI StgIsStorageFile (LPCOLESTR fn)
 
HRESULT WINAPI WriteClassStm (IStream *pStm, REFCLSID rclsid)
 
HRESULT WINAPI ReadClassStm (IStream *pStm, CLSID *pclsid)
 
static HRESULT OLECONVERT_LoadOLE10 (LPOLESTREAM pOleStream, OLECONVERT_OLESTREAM_DATA *pData, BOOL bStrem1)
 
static HRESULT OLECONVERT_SaveOLE10 (OLECONVERT_OLESTREAM_DATA *pData, LPOLESTREAM pOleStream)
 
static void OLECONVERT_GetOLE20FromOLE10 (LPSTORAGE pDestStorage, const BYTE *pBuffer, DWORD nBufferLength)
 
static DWORD OLECONVERT_WriteOLE20ToBuffer (LPSTORAGE pStorage, BYTE **pData)
 
HRESULT OLECONVERT_CreateCompObjStream (LPSTORAGE pStorage, LPCSTR strOleTypeName)
 
static void OLECONVERT_CreateOlePresStream (LPSTORAGE pStorage, DWORD dwExtentX, DWORD dwExtentY, BYTE *pData, DWORD dwDataLength)
 
static void OLECONVERT_CreateOle10NativeStream (LPSTORAGE pStorage, const BYTE *pData, DWORD dwDataLength)
 
static HRESULT OLECONVERT_GetOLE10ProgID (LPSTORAGE pStorage, char *strProgID, DWORD *dwSize)
 
static void OLECONVERT_GetOle10PresData (LPSTORAGE pStorage, OLECONVERT_OLESTREAM_DATA *pOleStreamData)
 
static void OLECONVERT_GetOle20PresData (LPSTORAGE pStorage, OLECONVERT_OLESTREAM_DATA *pOleStreamData)
 
HRESULT WINAPI OleConvertOLESTREAMToIStorage (LPOLESTREAM pOleStream, LPSTORAGE pstg, const DVTARGETDEVICE *ptd)
 
HRESULT WINAPI OleConvertIStorageToOLESTREAM (LPSTORAGE pstg, LPOLESTREAM pOleStream)
 
HRESULT WINAPI GetConvertStg (IStorage *stg)
 
HRESULT WINAPI SetConvertStg (IStorage *storage, BOOL convert)
 

Variables

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}
 
const IPropertySetStorageVtbl IPropertySetStorage_Vtbl
 
static const IStorageVtbl StorageInternalImpl_Vtbl
 
static const IStorageVtbl TransactedSnapshotImpl_Vtbl
 
static const IDirectWriterLockVtbl DirectWriterLockVtbl
 
static const IEnumSTATSTGVtbl IEnumSTATSTGImpl_Vtbl
 
static const StorageBaseImplVtbl StorageImpl_BaseVtbl
 
static const IStorageVtbl StorageImpl_Vtbl
 
static const StorageBaseImplVtbl StorageInternalImpl_BaseVtbl
 
static const StorageBaseImplVtbl TransactedSnapshotImpl_BaseVtbl
 
static const IStorageVtbl TransactedSharedImpl_Vtbl
 
static const StorageBaseImplVtbl TransactedSharedImpl_BaseVtbl
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 39 of file storage32.c.

◆ NONAMELESSUNION

#define NONAMELESSUNION

Definition at line 40 of file storage32.c.

◆ OLESTREAM_ID

#define OLESTREAM_ID   0x501

Definition at line 9577 of file storage32.c.

◆ OLESTREAM_MAX_STR_LEN

#define OLESTREAM_MAX_STR_LEN   255

Definition at line 9578 of file storage32.c.

Typedef Documentation

◆ BlockChainBlock

◆ StorageInternalImpl

◆ TransactedDirEntry

◆ TransactedSharedImpl

◆ TransactedSnapshotImpl

Enumeration Type Documentation

◆ stream_1ole_flags

Enumerator
OleStream_LinkedObject 
OleStream_Convert 

Definition at line 10609 of file storage32.c.

10609 {
10610 OleStream_LinkedObject = 0x00000001,
10611 OleStream_Convert = 0x00000004
10612};
@ OleStream_Convert
Definition: storage32.c:10611
@ OleStream_LinkedObject
Definition: storage32.c:10610

Function Documentation

◆ BlockChainStream_Construct()

BlockChainStream * BlockChainStream_Construct ( StorageImpl parentStorage,
ULONG headOfStreamPlaceHolder,
DirRef  dirEntry 
)
static

Definition at line 7261 of file storage32.c.

7265{
7266 BlockChainStream* newStream;
7267
7268 newStream = HeapAlloc(GetProcessHeap(), 0, sizeof(BlockChainStream));
7269 if(!newStream)
7270 return NULL;
7271
7272 newStream->parentStorage = parentStorage;
7273 newStream->headOfStreamPlaceHolder = headOfStreamPlaceHolder;
7274 newStream->ownerDirEntry = dirEntry;
7275 newStream->indexCache = NULL;
7276 newStream->indexCacheLen = 0;
7277 newStream->indexCacheSize = 0;
7278 newStream->cachedBlocks[0].index = 0xffffffff;
7279 newStream->cachedBlocks[0].dirty = FALSE;
7280 newStream->cachedBlocks[1].index = 0xffffffff;
7281 newStream->cachedBlocks[1].dirty = FALSE;
7282 newStream->blockToEvict = 0;
7283
7285 {
7286 HeapFree(GetProcessHeap(), 0, newStream->indexCache);
7287 HeapFree(GetProcessHeap(), 0, newStream);
7288 return NULL;
7289 }
7290
7291 return newStream;
7292}
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
static HRESULT BlockChainStream_UpdateIndexCache(BlockChainStream *This)
Definition: storage32.c:7108
#define FAILED(hr)
Definition: intsafe.h:51
ULONG indexCacheSize
Definition: storage32.c:208
ULONG indexCacheLen
Definition: storage32.c:207
StorageImpl * parentStorage
Definition: storage32.c:203
ULONG blockToEvict
Definition: storage32.c:210
struct BlockChainRun * indexCache
Definition: storage32.c:206
DirRef ownerDirEntry
Definition: storage32.c:205
ULONG * headOfStreamPlaceHolder
Definition: storage32.c:204
BlockChainBlock cachedBlocks[2]
Definition: storage32.c:209

Referenced by Storage32Impl_SmallBlocksToBigBlocks(), StorageImpl_GetCachedBlockChainStream(), and StorageImpl_Refresh().

◆ BlockChainStream_Destroy()

void BlockChainStream_Destroy ( BlockChainStream This)
static

◆ BlockChainStream_Enlarge()

static BOOL BlockChainStream_Enlarge ( BlockChainStream This,
ULARGE_INTEGER  newSize 
)
static

Definition at line 7419 of file storage32.c.

7421{
7422 ULONG blockIndex, currentBlock;
7423 ULONG newNumBlocks;
7424 ULONG oldNumBlocks = 0;
7425
7427
7428 /*
7429 * Empty chain. Create the head.
7430 */
7431 if (blockIndex == BLOCK_END_OF_CHAIN)
7432 {
7433 blockIndex = StorageImpl_GetNextFreeBigBlock(This->parentStorage);
7435 blockIndex,
7437
7438 if (This->headOfStreamPlaceHolder != 0)
7439 {
7440 *(This->headOfStreamPlaceHolder) = blockIndex;
7441 }
7442 else
7443 {
7444 DirEntry chainEntry;
7445 assert(This->ownerDirEntry != DIRENTRY_NULL);
7446
7448 This->parentStorage,
7449 This->ownerDirEntry,
7450 &chainEntry);
7451
7452 chainEntry.startingBlock = blockIndex;
7453
7455 This->parentStorage,
7456 This->ownerDirEntry,
7457 &chainEntry);
7458 }
7459
7460 This->tailIndex = blockIndex;
7461 This->numBlocks = 1;
7462 }
7463
7464 /*
7465 * Figure out how many blocks are needed to contain this stream
7466 */
7467 newNumBlocks = newSize.QuadPart / This->parentStorage->bigBlockSize;
7468
7469 if ((newSize.QuadPart % This->parentStorage->bigBlockSize) != 0)
7470 newNumBlocks++;
7471
7472 /*
7473 * Go to the current end of chain
7474 */
7475 if (This->tailIndex == BLOCK_END_OF_CHAIN)
7476 {
7477 currentBlock = blockIndex;
7478
7479 while (blockIndex != BLOCK_END_OF_CHAIN)
7480 {
7481 This->numBlocks++;
7482 currentBlock = blockIndex;
7483
7484 if(FAILED(StorageImpl_GetNextBlockInChain(This->parentStorage, currentBlock,
7485 &blockIndex)))
7486 return FALSE;
7487 }
7488
7489 This->tailIndex = currentBlock;
7490 }
7491
7492 currentBlock = This->tailIndex;
7493 oldNumBlocks = This->numBlocks;
7494
7495 /*
7496 * Add new blocks to the chain
7497 */
7498 if (oldNumBlocks < newNumBlocks)
7499 {
7500 while (oldNumBlocks < newNumBlocks)
7501 {
7502 blockIndex = StorageImpl_GetNextFreeBigBlock(This->parentStorage);
7503
7505 This->parentStorage,
7506 currentBlock,
7507 blockIndex);
7508
7510 This->parentStorage,
7511 blockIndex,
7513
7514 currentBlock = blockIndex;
7515 oldNumBlocks++;
7516 }
7517
7518 This->tailIndex = blockIndex;
7519 This->numBlocks = newNumBlocks;
7520 }
7521
7523 return FALSE;
7524
7525 return TRUE;
7526}
#define TRUE
Definition: types.h:120
static ULONG StorageImpl_GetNextFreeBigBlock(StorageImpl *This)
Definition: storage32.c:4171
static void StorageImpl_SetNextBlockInChain(StorageImpl *This, ULONG blockIndex, ULONG nextBlock)
Definition: storage32.c:4121
static HRESULT StorageImpl_WriteDirEntry(StorageImpl *This, DirRef index, const DirEntry *buffer)
Definition: storage32.c:3524
static HRESULT StorageImpl_GetNextBlockInChain(StorageImpl *This, ULONG blockIndex, ULONG *nextBlockIndex)
Definition: storage32.c:4021
static HRESULT StorageImpl_ReadDirEntry(StorageImpl *This, DirRef index, DirEntry *buffer)
Definition: storage32.c:3428
static ULONG BlockChainStream_GetHeadOfChain(BlockChainStream *This)
Definition: storage32.c:7085
#define assert(x)
Definition: debug.h:53
static const ULONG DIRENTRY_NULL
Definition: storage32.h:86
static const ULONG BLOCK_END_OF_CHAIN
Definition: storage32.h:84
ULONG startingBlock
Definition: storage32.h:156
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
uint32_t ULONG
Definition: typedefs.h:59

Referenced by BlockChainStream_SetSize(), and SmallBlockChainStream_GetNextFreeBlock().

◆ BlockChainStream_Flush()

HRESULT BlockChainStream_Flush ( BlockChainStream This)
static

Definition at line 7294 of file storage32.c.

7295{
7296 int i;
7297 if (!This) return S_OK;
7298 for (i=0; i<2; i++)
7299 {
7300 if (This->cachedBlocks[i].dirty)
7301 {
7302 if (StorageImpl_WriteBigBlock(This->parentStorage, This->cachedBlocks[i].sector, This->cachedBlocks[i].data))
7303 This->cachedBlocks[i].dirty = FALSE;
7304 else
7305 return STG_E_WRITEFAULT;
7306 }
7307 }
7308 return S_OK;
7309}
static BOOL StorageImpl_WriteBigBlock(StorageImpl *This, ULONG blockIndex, const void *buffer)
Definition: storage32.c:3589
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define S_OK
Definition: intsafe.h:52
#define STG_E_WRITEFAULT
Definition: winerror.h:2575

Referenced by BlockChainStream_Destroy(), and StorageImpl_Flush().

◆ BlockChainStream_GetBlockAtOffset()

static HRESULT BlockChainStream_GetBlockAtOffset ( BlockChainStream This,
ULONG  index,
BlockChainBlock **  block,
ULONG sector,
BOOL  create 
)
static

Definition at line 7214 of file storage32.c.

7216{
7218 int i;
7219
7220 for (i=0; i<2; i++)
7221 if (This->cachedBlocks[i].index == index)
7222 {
7223 *sector = This->cachedBlocks[i].sector;
7224 *block = &This->cachedBlocks[i];
7225 return S_OK;
7226 }
7227
7229 if (*sector == BLOCK_END_OF_CHAIN)
7230 return STG_E_DOCFILECORRUPT;
7231
7232 if (create)
7233 {
7234 if (This->cachedBlocks[0].index == 0xffffffff)
7235 result = &This->cachedBlocks[0];
7236 else if (This->cachedBlocks[1].index == 0xffffffff)
7237 result = &This->cachedBlocks[1];
7238 else
7239 {
7240 result = &This->cachedBlocks[This->blockToEvict++];
7241 if (This->blockToEvict == 2)
7242 This->blockToEvict = 0;
7243 }
7244
7245 if (result->dirty)
7246 {
7247 if (!StorageImpl_WriteBigBlock(This->parentStorage, result->sector, result->data))
7248 return STG_E_WRITEFAULT;
7249 result->dirty = FALSE;
7250 }
7251
7252 result->read = FALSE;
7253 result->index = index;
7254 result->sector = *sector;
7255 }
7256
7257 *block = result;
7258 return S_OK;
7259}
#define index(s, c)
Definition: various.h:29
static ULONG BlockChainStream_GetSectorOfOffset(BlockChainStream *This, ULONG offset)
Definition: storage32.c:7185
GLuint index
Definition: glext.h:6031
GLuint64EXT * result
Definition: glext.h:11304
uint32_t sector
Definition: isohybrid.c:61
static const struct access_res create[16]
Definition: package.c:7505
#define STG_E_DOCFILECORRUPT
Definition: winerror.h:2597
static unsigned int block
Definition: xmlmemory.c:101

Referenced by BlockChainStream_ReadAt(), and BlockChainStream_WriteAt().

◆ BlockChainStream_GetCount()

static ULONG BlockChainStream_GetCount ( BlockChainStream This)
inlinestatic

◆ BlockChainStream_GetHeadOfChain()

static ULONG BlockChainStream_GetHeadOfChain ( BlockChainStream This)
static

Definition at line 7085 of file storage32.c.

7086{
7087 DirEntry chainEntry;
7088 HRESULT hr;
7089
7090 if (This->headOfStreamPlaceHolder != 0)
7091 return *(This->headOfStreamPlaceHolder);
7092
7093 if (This->ownerDirEntry != DIRENTRY_NULL)
7094 {
7096 This->parentStorage,
7097 This->ownerDirEntry,
7098 &chainEntry);
7099
7100 if (SUCCEEDED(hr) && chainEntry.startingBlock < BLOCK_FIRST_SPECIAL)
7101 return chainEntry.startingBlock;
7102 }
7103
7104 return BLOCK_END_OF_CHAIN;
7105}
#define SUCCEEDED(hr)
Definition: intsafe.h:50
HRESULT hr
Definition: shlfolder.c:183
static const ULONG BLOCK_FIRST_SPECIAL
Definition: storage32.h:81

Referenced by BlockChainStream_Enlarge(), and BlockChainStream_UpdateIndexCache().

◆ BlockChainStream_GetSectorOfOffset()

static ULONG BlockChainStream_GetSectorOfOffset ( BlockChainStream This,
ULONG  offset 
)
static

Definition at line 7185 of file storage32.c.

7186{
7187 ULONG min_offset = 0, max_offset = This->numBlocks-1;
7188 ULONG min_run = 0, max_run = This->indexCacheLen-1;
7189
7190 if (offset >= This->numBlocks)
7191 return BLOCK_END_OF_CHAIN;
7192
7193 while (min_run < max_run)
7194 {
7195 ULONG run_to_check = min_run + (offset - min_offset) * (max_run - min_run) / (max_offset - min_offset);
7196 if (offset < This->indexCache[run_to_check].firstOffset)
7197 {
7198 max_offset = This->indexCache[run_to_check].firstOffset-1;
7199 max_run = run_to_check-1;
7200 }
7201 else if (offset > This->indexCache[run_to_check].lastOffset)
7202 {
7203 min_offset = This->indexCache[run_to_check].lastOffset+1;
7204 min_run = run_to_check+1;
7205 }
7206 else
7207 /* Block is in this run. */
7208 min_run = max_run = run_to_check;
7209 }
7210
7211 return This->indexCache[min_run].firstSector + offset - This->indexCache[min_run].firstOffset;
7212}
GLintptr offset
Definition: glext.h:5920

Referenced by BlockChainStream_GetBlockAtOffset(), BlockChainStream_ReadAt(), and BlockChainStream_Shrink().

◆ BlockChainStream_GetSize()

static ULARGE_INTEGER BlockChainStream_GetSize ( BlockChainStream This)
static

Definition at line 7535 of file storage32.c.

7536{
7537 DirEntry chainEntry;
7538
7539 if(This->headOfStreamPlaceHolder == NULL)
7540 {
7541 /*
7542 * This chain has a directory entry so use the size value from there.
7543 */
7545 This->parentStorage,
7546 This->ownerDirEntry,
7547 &chainEntry);
7548
7549 return chainEntry.size;
7550 }
7551 else
7552 {
7553 /*
7554 * this chain is a chain that does not have a directory entry, figure out the
7555 * size by making the product number of used blocks times the
7556 * size of them
7557 */
7559 result.QuadPart =
7561 This->parentStorage->bigBlockSize;
7562
7563 return result;
7564 }
7565}
static ULONG BlockChainStream_GetCount(BlockChainStream *This)
Definition: storage32.c:218
ULARGE_INTEGER size
Definition: storage32.h:157
uint64_t ULONGLONG
Definition: typedefs.h:67

Referenced by BlockChainStream_ReadAt(), BlockChainStream_SetSize(), SmallBlockChainStream_GetNextFreeBlock(), and Storage32Impl_BigBlocksToSmallBlocks().

◆ BlockChainStream_ReadAt()

HRESULT BlockChainStream_ReadAt ( BlockChainStream This,
ULARGE_INTEGER  offset,
ULONG  size,
void buffer,
ULONG bytesRead 
)
static

Definition at line 7605 of file storage32.c.

7610{
7611 ULONG blockNoInSequence = offset.QuadPart / This->parentStorage->bigBlockSize;
7612 ULONG offsetInBlock = offset.QuadPart % This->parentStorage->bigBlockSize;
7613 ULONG bytesToReadInBuffer;
7614 ULONG blockIndex;
7615 BYTE* bufferWalker;
7617 HRESULT hr;
7618 BlockChainBlock *cachedBlock;
7619
7620 TRACE("(%p)-> %i %p %i %p\n",This, offset.u.LowPart, buffer, size, bytesRead);
7621
7622 /*
7623 * Find the first block in the stream that contains part of the buffer.
7624 */
7625 blockIndex = BlockChainStream_GetSectorOfOffset(This, blockNoInSequence);
7626
7627 *bytesRead = 0;
7628
7630 if (stream_size.QuadPart > offset.QuadPart)
7631 size = min(stream_size.QuadPart - offset.QuadPart, size);
7632 else
7633 return S_OK;
7634
7635 /*
7636 * Start reading the buffer.
7637 */
7638 bufferWalker = buffer;
7639
7640 while (size > 0)
7641 {
7642 ULARGE_INTEGER ulOffset;
7643 DWORD bytesReadAt;
7644
7645 /*
7646 * Calculate how many bytes we can copy from this big block.
7647 */
7648 bytesToReadInBuffer =
7649 min(This->parentStorage->bigBlockSize - offsetInBlock, size);
7650
7651 hr = BlockChainStream_GetBlockAtOffset(This, blockNoInSequence, &cachedBlock, &blockIndex, size == bytesToReadInBuffer);
7652
7653 if (FAILED(hr))
7654 return hr;
7655
7656 if (!cachedBlock)
7657 {
7658 /* Not in cache, and we're going to read past the end of the block. */
7659 ulOffset.QuadPart = StorageImpl_GetBigBlockOffset(This->parentStorage, blockIndex) +
7660 offsetInBlock;
7661
7662 StorageImpl_ReadAt(This->parentStorage,
7663 ulOffset,
7664 bufferWalker,
7665 bytesToReadInBuffer,
7666 &bytesReadAt);
7667 }
7668 else
7669 {
7670 if (!cachedBlock->read)
7671 {
7672 ULONG read;
7673 if (FAILED(StorageImpl_ReadBigBlock(This->parentStorage, cachedBlock->sector, cachedBlock->data, &read)) && !read)
7674 return STG_E_READFAULT;
7675
7676 cachedBlock->read = TRUE;
7677 }
7678
7679 memcpy(bufferWalker, cachedBlock->data+offsetInBlock, bytesToReadInBuffer);
7680 bytesReadAt = bytesToReadInBuffer;
7681 }
7682
7683 blockNoInSequence++;
7684 bufferWalker += bytesReadAt;
7685 size -= bytesReadAt;
7686 *bytesRead += bytesReadAt;
7687 offsetInBlock = 0; /* There is no offset on the next block */
7688
7689 if (bytesToReadInBuffer != bytesReadAt)
7690 break;
7691 }
7692
7693 return S_OK;
7694}
#define read
Definition: acwin.h:96
static HRESULT BlockChainStream_GetBlockAtOffset(BlockChainStream *This, ULONG index, BlockChainBlock **block, ULONG *sector, BOOL create)
Definition: storage32.c:7214
static HRESULT StorageImpl_ReadAt(StorageImpl *This, ULARGE_INTEGER offset, void *buffer, ULONG size, ULONG *bytesRead)
Definition: storage32.c:2870
static ULONGLONG StorageImpl_GetBigBlockOffset(StorageImpl *This, ULONG index)
Definition: storage32.c:3541
static ULARGE_INTEGER BlockChainStream_GetSize(BlockChainStream *)
Definition: storage32.c:7535
static HRESULT StorageImpl_ReadBigBlock(StorageImpl *This, ULONG blockIndex, void *buffer, ULONG *out_read)
Definition: storage32.c:3546
unsigned long DWORD
Definition: ntddk_ex.h:95
GLsizeiptr size
Definition: glext.h:5919
GLuint buffer
Definition: glext.h:5915
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define min(a, b)
Definition: monoChain.cc:55
int const char int stream_size
Definition: zlib.h:814
#define TRACE(s)
Definition: solgame.cpp:4
BYTE data[MAX_BIG_BLOCK_SIZE]
Definition: storage32.c:198
#define STG_E_READFAULT
Definition: winerror.h:2576
unsigned char BYTE
Definition: xxhash.c:193

Referenced by SmallBlockChainStream_GetNextBlockInChain(), SmallBlockChainStream_GetNextFreeBlock(), SmallBlockChainStream_ReadAt(), Storage32Impl_BigBlocksToSmallBlocks(), StorageImpl_ReadRawDirEntry(), and StorageImpl_StreamReadAt().

◆ BlockChainStream_SetSize()

BOOL BlockChainStream_SetSize ( BlockChainStream This,
ULARGE_INTEGER  newSize 
)
static

Definition at line 7577 of file storage32.c.

7580{
7582
7583 if (newSize.QuadPart == size.QuadPart)
7584 return TRUE;
7585
7586 if (newSize.QuadPart < size.QuadPart)
7587 {
7588 BlockChainStream_Shrink(This, newSize);
7589 }
7590 else
7591 {
7593 }
7594
7595 return TRUE;
7596}
static BOOL BlockChainStream_Shrink(BlockChainStream *This, ULARGE_INTEGER newSize)
Definition: storage32.c:7326
static BOOL BlockChainStream_Enlarge(BlockChainStream *This, ULARGE_INTEGER newSize)
Definition: storage32.c:7419

Referenced by SmallBlockChainStream_GetNextFreeBlock(), Storage32Impl_BigBlocksToSmallBlocks(), Storage32Impl_SmallBlocksToBigBlocks(), StorageImpl_CreateDirEntry(), and StorageImpl_StreamSetSize().

◆ BlockChainStream_Shrink()

static BOOL BlockChainStream_Shrink ( BlockChainStream This,
ULARGE_INTEGER  newSize 
)
static

Definition at line 7326 of file storage32.c.

7328{
7329 ULONG blockIndex;
7330 ULONG numBlocks;
7331 int i;
7332
7333 /*
7334 * Figure out how many blocks are needed to contain the new size
7335 */
7336 numBlocks = newSize.QuadPart / This->parentStorage->bigBlockSize;
7337
7338 if ((newSize.QuadPart % This->parentStorage->bigBlockSize) != 0)
7339 numBlocks++;
7340
7341 if (numBlocks)
7342 {
7343 /*
7344 * Go to the new end of chain
7345 */
7346 blockIndex = BlockChainStream_GetSectorOfOffset(This, numBlocks-1);
7347
7348 /* Mark the new end of chain */
7350 This->parentStorage,
7351 blockIndex,
7353
7354 This->tailIndex = blockIndex;
7355 }
7356 else
7357 {
7358 if (This->headOfStreamPlaceHolder != 0)
7359 {
7360 *This->headOfStreamPlaceHolder = BLOCK_END_OF_CHAIN;
7361 }
7362 else
7363 {
7364 DirEntry chainEntry;
7365 assert(This->ownerDirEntry != DIRENTRY_NULL);
7366
7368 This->parentStorage,
7369 This->ownerDirEntry,
7370 &chainEntry);
7371
7372 chainEntry.startingBlock = BLOCK_END_OF_CHAIN;
7373
7375 This->parentStorage,
7376 This->ownerDirEntry,
7377 &chainEntry);
7378 }
7379
7380 This->tailIndex = BLOCK_END_OF_CHAIN;
7381 }
7382
7383 This->numBlocks = numBlocks;
7384
7385 /*
7386 * Mark the extra blocks as free
7387 */
7388 while (This->indexCacheLen && This->indexCache[This->indexCacheLen-1].lastOffset >= numBlocks)
7389 {
7390 struct BlockChainRun *last_run = &This->indexCache[This->indexCacheLen-1];
7391 StorageImpl_FreeBigBlock(This->parentStorage,
7392 last_run->firstSector + last_run->lastOffset - last_run->firstOffset);
7393 if (last_run->lastOffset == last_run->firstOffset)
7394 This->indexCacheLen--;
7395 else
7396 last_run->lastOffset--;
7397 }
7398
7399 /*
7400 * Reset the last accessed block cache.
7401 */
7402 for (i=0; i<2; i++)
7403 {
7404 if (This->cachedBlocks[i].index >= numBlocks)
7405 {
7406 This->cachedBlocks[i].index = 0xffffffff;
7407 This->cachedBlocks[i].dirty = FALSE;
7408 }
7409 }
7410
7411 return TRUE;
7412}
static void StorageImpl_FreeBigBlock(StorageImpl *This, ULONG blockIndex)
Definition: storage32.c:4314
ULONG firstOffset
Definition: storage32.c:188
ULONG firstSector
Definition: storage32.c:187
ULONG lastOffset
Definition: storage32.c:189

Referenced by BlockChainStream_SetSize().

◆ BlockChainStream_UpdateIndexCache()

static HRESULT BlockChainStream_UpdateIndexCache ( BlockChainStream This)
static

Definition at line 7108 of file storage32.c.

7109{
7110 ULONG next_sector, next_offset;
7111 HRESULT hr;
7112 struct BlockChainRun *last_run;
7113
7114 if (This->indexCacheLen == 0)
7115 {
7116 last_run = NULL;
7117 next_offset = 0;
7119 }
7120 else
7121 {
7122 last_run = &This->indexCache[This->indexCacheLen-1];
7123 next_offset = last_run->lastOffset+1;
7124 hr = StorageImpl_GetNextBlockInChain(This->parentStorage,
7125 last_run->firstSector + last_run->lastOffset - last_run->firstOffset,
7126 &next_sector);
7127 if (FAILED(hr)) return hr;
7128 }
7129
7130 while (next_sector != BLOCK_END_OF_CHAIN)
7131 {
7132 if (!last_run || next_sector != last_run->firstSector + next_offset - last_run->firstOffset)
7133 {
7134 /* Add the current block to the cache. */
7135 if (This->indexCacheSize == 0)
7136 {
7137 This->indexCache = HeapAlloc(GetProcessHeap(), 0, sizeof(struct BlockChainRun)*16);
7138 if (!This->indexCache) return E_OUTOFMEMORY;
7139 This->indexCacheSize = 16;
7140 }
7141 else if (This->indexCacheSize == This->indexCacheLen)
7142 {
7143 struct BlockChainRun *new_cache;
7144 ULONG new_size;
7145
7146 new_size = This->indexCacheSize * 2;
7147 new_cache = HeapAlloc(GetProcessHeap(), 0, sizeof(struct BlockChainRun)*new_size);
7148 if (!new_cache) return E_OUTOFMEMORY;
7149 memcpy(new_cache, This->indexCache, sizeof(struct BlockChainRun)*This->indexCacheLen);
7150
7151 HeapFree(GetProcessHeap(), 0, This->indexCache);
7152 This->indexCache = new_cache;
7153 This->indexCacheSize = new_size;
7154 }
7155
7156 This->indexCacheLen++;
7157 last_run = &This->indexCache[This->indexCacheLen-1];
7158 last_run->firstSector = next_sector;
7159 last_run->firstOffset = next_offset;
7160 }
7161
7162 last_run->lastOffset = next_offset;
7163
7164 /* Find the next block. */
7165 next_offset++;
7166 hr = StorageImpl_GetNextBlockInChain(This->parentStorage, next_sector, &next_sector);
7167 if (FAILED(hr)) return hr;
7168 }
7169
7170 if (This->indexCacheLen)
7171 {
7172 This->tailIndex = last_run->firstSector + last_run->lastOffset - last_run->firstOffset;
7173 This->numBlocks = last_run->lastOffset+1;
7174 }
7175 else
7176 {
7177 This->tailIndex = BLOCK_END_OF_CHAIN;
7178 This->numBlocks = 0;
7179 }
7180
7181 return S_OK;
7182}
#define E_OUTOFMEMORY
Definition: ddrawi.h:100

Referenced by BlockChainStream_Construct(), and BlockChainStream_Enlarge().

◆ BlockChainStream_WriteAt()

HRESULT BlockChainStream_WriteAt ( BlockChainStream This,
ULARGE_INTEGER  offset,
ULONG  size,
const void buffer,
ULONG bytesWritten 
)
static

Definition at line 7702 of file storage32.c.

7707{
7708 ULONG blockNoInSequence = offset.QuadPart / This->parentStorage->bigBlockSize;
7709 ULONG offsetInBlock = offset.QuadPart % This->parentStorage->bigBlockSize;
7710 ULONG bytesToWrite;
7711 ULONG blockIndex;
7712 const BYTE* bufferWalker;
7713 HRESULT hr;
7714 BlockChainBlock *cachedBlock;
7715
7716 *bytesWritten = 0;
7717 bufferWalker = buffer;
7718
7719 while (size > 0)
7720 {
7721 ULARGE_INTEGER ulOffset;
7722 DWORD bytesWrittenAt;
7723
7724 /*
7725 * Calculate how many bytes we can copy to this big block.
7726 */
7727 bytesToWrite =
7728 min(This->parentStorage->bigBlockSize - offsetInBlock, size);
7729
7730 hr = BlockChainStream_GetBlockAtOffset(This, blockNoInSequence, &cachedBlock, &blockIndex, size == bytesToWrite);
7731
7732 /* BlockChainStream_SetSize should have already been called to ensure we have
7733 * enough blocks in the chain to write into */
7734 if (FAILED(hr))
7735 {
7736 ERR("not enough blocks in chain to write data\n");
7737 return hr;
7738 }
7739
7740 if (!cachedBlock)
7741 {
7742 /* Not in cache, and we're going to write past the end of the block. */
7743 ulOffset.QuadPart = StorageImpl_GetBigBlockOffset(This->parentStorage, blockIndex) +
7744 offsetInBlock;
7745
7746 StorageImpl_WriteAt(This->parentStorage,
7747 ulOffset,
7748 bufferWalker,
7749 bytesToWrite,
7750 &bytesWrittenAt);
7751 }
7752 else
7753 {
7754 if (!cachedBlock->read && bytesToWrite != This->parentStorage->bigBlockSize)
7755 {
7756 ULONG read;
7757 if (FAILED(StorageImpl_ReadBigBlock(This->parentStorage, cachedBlock->sector, cachedBlock->data, &read)) && !read)
7758 return STG_E_READFAULT;
7759 }
7760
7761 memcpy(cachedBlock->data+offsetInBlock, bufferWalker, bytesToWrite);
7762 bytesWrittenAt = bytesToWrite;
7763 cachedBlock->read = TRUE;
7764 cachedBlock->dirty = TRUE;
7765 }
7766
7767 blockNoInSequence++;
7768 bufferWalker += bytesWrittenAt;
7769 size -= bytesWrittenAt;
7770 *bytesWritten += bytesWrittenAt;
7771 offsetInBlock = 0; /* There is no offset on the next block */
7772
7773 if (bytesWrittenAt != bytesToWrite)
7774 break;
7775 }
7776
7777 return (size == 0) ? S_OK : STG_E_WRITEFAULT;
7778}
#define ERR(fmt,...)
Definition: precomp.h:57
static HRESULT StorageImpl_WriteAt(StorageImpl *This, ULARGE_INTEGER offset, const void *buffer, const ULONG size, ULONG *bytesWritten)
Definition: storage32.c:2879
GLenum GLsizei GLuint GLint * bytesWritten
Definition: glext.h:11123

Referenced by SmallBlockChainStream_GetNextFreeBlock(), SmallBlockChainStream_SetNextBlockInChain(), SmallBlockChainStream_WriteAt(), Storage32Impl_SmallBlocksToBigBlocks(), StorageImpl_StreamWriteAt(), and StorageImpl_WriteRawDirEntry().

◆ create_storagefile()

static HRESULT create_storagefile ( LPCOLESTR  pwcsName,
DWORD  grfMode,
DWORD  grfAttrs,
STGOPTIONS pStgOptions,
REFIID  riid,
void **  ppstgOpen 
)
static

Definition at line 8485 of file storage32.c.

8492{
8493 StorageBaseImpl* newStorage = 0;
8496 DWORD shareMode;
8497 DWORD accessMode;
8498 DWORD creationMode;
8499 DWORD fileAttributes;
8500 WCHAR tempFileName[MAX_PATH];
8501
8502 if (ppstgOpen == 0)
8503 return STG_E_INVALIDPOINTER;
8504
8505 if (pStgOptions->ulSectorSize != MIN_BIG_BLOCK_SIZE && pStgOptions->ulSectorSize != MAX_BIG_BLOCK_SIZE)
8507
8508 /* if no share mode given then DENY_NONE is the default */
8509 if (STGM_SHARE_MODE(grfMode) == 0)
8510 grfMode |= STGM_SHARE_DENY_NONE;
8511
8512 if ( FAILED( validateSTGM(grfMode) ))
8513 goto end;
8514
8515 /* StgCreateDocFile seems to refuse readonly access, despite MSDN */
8516 switch(STGM_ACCESS_MODE(grfMode))
8517 {
8518 case STGM_WRITE:
8519 case STGM_READWRITE:
8520 break;
8521 default:
8522 goto end;
8523 }
8524
8525 /* in direct mode, can only use SHARE_EXCLUSIVE */
8526 if (!(grfMode & STGM_TRANSACTED) && (STGM_SHARE_MODE(grfMode) != STGM_SHARE_EXCLUSIVE))
8527 goto end;
8528
8529 /* but in transacted mode, any share mode is valid */
8530
8531 /*
8532 * Generate a unique name.
8533 */
8534 if (pwcsName == 0)
8535 {
8536 WCHAR tempPath[MAX_PATH];
8537 static const WCHAR prefix[] = { 'S', 'T', 'O', 0 };
8538
8539 memset(tempPath, 0, sizeof(tempPath));
8540 memset(tempFileName, 0, sizeof(tempFileName));
8541
8542 if ((GetTempPathW(MAX_PATH, tempPath)) == 0 )
8543 tempPath[0] = '.';
8544
8545 if (GetTempFileNameW(tempPath, prefix, 0, tempFileName) != 0)
8546 pwcsName = tempFileName;
8547 else
8548 {
8550 goto end;
8551 }
8552
8553 creationMode = TRUNCATE_EXISTING;
8554 }
8555 else
8556 {
8557 creationMode = GetCreationModeFromSTGM(grfMode);
8558 }
8559
8560 /*
8561 * Interpret the STGM value grfMode
8562 */
8563 shareMode = GetShareModeFromSTGM(grfMode);
8564 accessMode = GetAccessModeFromSTGM(grfMode);
8565
8566 if (grfMode & STGM_DELETEONRELEASE)
8568 else
8570
8571 *ppstgOpen = 0;
8572
8573 hFile = CreateFileW(pwcsName,
8574 accessMode,
8575 shareMode,
8576 NULL,
8577 creationMode,
8578 fileAttributes,
8579 0);
8580
8582 {
8585 else
8586 hr = E_FAIL;
8587 goto end;
8588 }
8589
8590 /*
8591 * Allocate and initialize the new IStorage object.
8592 */
8594 hFile,
8595 pwcsName,
8596 NULL,
8597 grfMode,
8598 TRUE,
8599 TRUE,
8600 pStgOptions->ulSectorSize,
8601 &newStorage);
8602
8603 if (FAILED(hr))
8604 {
8605 goto end;
8606 }
8607
8608 hr = IStorage_QueryInterface(&newStorage->IStorage_iface, riid, ppstgOpen);
8609 IStorage_Release(&newStorage->IStorage_iface);
8610
8611end:
8612 TRACE("<-- %p r = %08x\n", *ppstgOpen, hr);
8613
8614 return hr;
8615}
#define E_FAIL
Definition: ddrawi.h:102
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define MAX_PATH
Definition: compat.h:34
#define CreateFileW
Definition: compat.h:741
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
DWORD WINAPI GetTempPathW(IN DWORD count, OUT LPWSTR path)
Definition: path.c:2080
static HRESULT Storage_Construct(HANDLE hFile, LPCOLESTR pwcsName, ILockBytes *pLkbyt, DWORD openFlags, BOOL fileBased, BOOL create, ULONG sector_size, StorageBaseImpl **result)
Definition: storage32.c:6906
static DWORD GetCreationModeFromSTGM(DWORD stgm)
Definition: storage32.c:418
static DWORD GetAccessModeFromSTGM(DWORD stgm)
Definition: storage32.c:397
static HRESULT validateSTGM(DWORD stgm)
Definition: storage32.c:287
static DWORD GetShareModeFromSTGM(DWORD stgm)
Definition: storage32.c:371
UINT WINAPI GetTempFileNameW(IN LPCWSTR lpPathName, IN LPCWSTR lpPrefixString, IN UINT uUnique, OUT LPWSTR lpTempFileName)
Definition: filename.c:84
GLuint GLuint end
Definition: gl.h:1545
REFIID riid
Definition: atlbase.h:39
#define TRUNCATE_EXISTING
Definition: disk.h:71
#define FILE_FLAG_RANDOM_ACCESS
Definition: disk.h:44
#define FILE_FLAG_DELETE_ON_CLOSE
Definition: disk.h:42
_In_ HANDLE hFile
Definition: mswsock.h:90
#define STGM_SHARE_DENY_NONE
Definition: objbase.h:920
#define STGM_READWRITE
Definition: objbase.h:919
#define STGM_TRANSACTED
Definition: objbase.h:915
#define STGM_SHARE_EXCLUSIVE
Definition: objbase.h:923
#define STGM_DELETEONRELEASE
Definition: objbase.h:925
#define STGM_WRITE
Definition: objbase.h:918
#define memset(x, y, z)
Definition: compat.h:39
#define MIN_BIG_BLOCK_SIZE
Definition: storage32.h:95
#define STGM_SHARE_MODE(stgm)
Definition: storage32.h:116
#define STGM_ACCESS_MODE(stgm)
Definition: storage32.h:115
#define MAX_BIG_BLOCK_SIZE
Definition: storage32.h:96
IStorage IStorage_iface
Definition: storage32.h:187
ULONG ulSectorSize
Definition: objbase.h:942
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define STG_E_INVALIDPOINTER
Definition: winerror.h:2571
#define STG_E_FILEALREADYEXISTS
Definition: winerror.h:2579
#define ERROR_FILE_EXISTS
Definition: winerror.h:165
#define STG_E_INVALIDPARAMETER
Definition: winerror.h:2580
#define STG_E_INVALIDFLAG
Definition: winerror.h:2587
#define STG_E_INSUFFICIENTMEMORY
Definition: winerror.h:2570
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by StgCreateDocfile(), and StgCreateStorageEx().

◆ deleteStorageContents()

static HRESULT deleteStorageContents ( StorageBaseImpl parentStorage,
DirRef  indexToDelete,
DirEntry  entryDataToDelete 
)
static

Definition at line 2426 of file storage32.c.

2430{
2431 IEnumSTATSTG *elements = 0;
2432 IStorage *childStorage = 0;
2433 STATSTG currentElement;
2434 HRESULT hr;
2435 HRESULT destroyHr = S_OK;
2436 StorageInternalImpl *stg, *stg2;
2437
2438 TRACE("%p,%d\n", parentStorage, indexToDelete);
2439
2440 /* Invalidate any open storage objects. */
2441 LIST_FOR_EACH_ENTRY_SAFE(stg, stg2, &parentStorage->storageHead, StorageInternalImpl, ParentListEntry)
2442 {
2443 if (stg->base.storageDirEntry == indexToDelete)
2444 {
2446 }
2447 }
2448
2449 /*
2450 * Open the storage and enumerate it
2451 */
2452 hr = IStorage_OpenStorage(
2453 &parentStorage->IStorage_iface,
2454 entryDataToDelete.name,
2455 0,
2457 0,
2458 0,
2459 &childStorage);
2460
2461 if (hr != S_OK)
2462 {
2463 TRACE("<-- %08x\n", hr);
2464 return hr;
2465 }
2466
2467 /*
2468 * Enumerate the elements
2469 */
2470 hr = IStorage_EnumElements(childStorage, 0, 0, 0, &elements);
2471 if (FAILED(hr))
2472 {
2473 IStorage_Release(childStorage);
2474 TRACE("<-- %08x\n", hr);
2475 return hr;
2476 }
2477
2478 do
2479 {
2480 /*
2481 * Obtain the next element
2482 */
2483 hr = IEnumSTATSTG_Next(elements, 1, &currentElement, NULL);
2484 if (hr==S_OK)
2485 {
2486 destroyHr = IStorage_DestroyElement(childStorage, currentElement.pwcsName);
2487
2488 CoTaskMemFree(currentElement.pwcsName);
2489 }
2490
2491 /*
2492 * We need to Reset the enumeration every time because we delete elements
2493 * and the enumeration could be invalid
2494 */
2495 IEnumSTATSTG_Reset(elements);
2496
2497 } while ((hr == S_OK) && (destroyHr == S_OK));
2498
2499 IStorage_Release(childStorage);
2500 IEnumSTATSTG_Release(elements);
2501
2502 TRACE("%08x\n", hr);
2503 return destroyHr;
2504}
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:204
static void StorageBaseImpl_Invalidate(StorageBaseImpl *This)
Definition: storage32.h:263
WCHAR name[DIRENTRY_NAME_MAX_LEN]
Definition: storage32.h:147
struct list storageHead
Definition: storage32.h:201
struct StorageBaseImpl base
Definition: storage32.c:76

Referenced by StorageBaseImpl_DestroyElement().

◆ deleteStreamContents()

static HRESULT deleteStreamContents ( StorageBaseImpl parentStorage,
DirRef  indexToDelete,
DirEntry  entryDataToDelete 
)
static

Definition at line 2513 of file storage32.c.

2517{
2518 IStream *pis;
2519 HRESULT hr;
2521 StgStreamImpl *strm, *strm2;
2522
2523 /* Invalidate any open stream objects. */
2524 LIST_FOR_EACH_ENTRY_SAFE(strm, strm2, &parentStorage->strmHead, StgStreamImpl, StrmListEntry)
2525 {
2526 if (strm->dirEntry == indexToDelete)
2527 {
2528 TRACE("Stream deleted %p\n", strm);
2529 strm->parentStorage = NULL;
2530 list_remove(&strm->StrmListEntry);
2531 }
2532 }
2533
2534 size.u.HighPart = 0;
2535 size.u.LowPart = 0;
2536
2537 hr = IStorage_OpenStream(&parentStorage->IStorage_iface,
2538 entryDataToDelete.name, NULL, STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, &pis);
2539
2540 if (hr!=S_OK)
2541 {
2542 TRACE("<-- %08x\n", hr);
2543 return(hr);
2544 }
2545
2546 /*
2547 * Zap the stream
2548 */
2549 hr = IStream_SetSize(pis, size);
2550
2551 if(hr != S_OK)
2552 {
2553 TRACE("<-- %08x\n", hr);
2554 return hr;
2555 }
2556
2557 /*
2558 * Release the stream object.
2559 */
2560 IStream_Release(pis);
2561 TRACE("<-- %08x\n", hr);
2562 return S_OK;
2563}
static void list_remove(struct list_entry *entry)
Definition: list.h:90
struct list StrmListEntry
Definition: storage32.h:435
StorageBaseImpl * parentStorage
Definition: storage32.h:440
DirRef dirEntry
Definition: storage32.h:450
struct list strmHead
Definition: storage32.h:196

Referenced by StorageBaseImpl_DestroyElement().

◆ directwriterlock_AddRef()

static ULONG WINAPI directwriterlock_AddRef ( IDirectWriterLock iface)
static

Definition at line 451 of file storage32.c.

452{
454 return IStorage_AddRef(&This->IStorage_iface);
455}
static StorageBaseImpl * impl_from_IDirectWriterLock(IDirectWriterLock *iface)
Definition: storage32.c:440

◆ directwriterlock_HaveWriteAccess()

static HRESULT WINAPI directwriterlock_HaveWriteAccess ( IDirectWriterLock iface)
static

Definition at line 477 of file storage32.c.

478{
480 FIXME("(%p): stub\n", This);
481 return E_NOTIMPL;
482}
#define FIXME(fmt,...)
Definition: precomp.h:53
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ directwriterlock_QueryInterface()

static HRESULT WINAPI directwriterlock_QueryInterface ( IDirectWriterLock iface,
REFIID  riid,
void **  obj 
)
static

Definition at line 445 of file storage32.c.

446{
448 return IStorage_QueryInterface(&This->IStorage_iface, riid, obj);
449}

◆ directwriterlock_Release()

static ULONG WINAPI directwriterlock_Release ( IDirectWriterLock iface)
static

Definition at line 457 of file storage32.c.

458{
460 return IStorage_Release(&This->IStorage_iface);
461}

◆ directwriterlock_ReleaseWriteAccess()

static HRESULT WINAPI directwriterlock_ReleaseWriteAccess ( IDirectWriterLock iface)
static

Definition at line 470 of file storage32.c.

471{
473 FIXME("(%p): stub\n", This);
474 return E_NOTIMPL;
475}

◆ directwriterlock_WaitForWriteAccess()

static HRESULT WINAPI directwriterlock_WaitForWriteAccess ( IDirectWriterLock iface,
DWORD  timeout 
)
static

Definition at line 463 of file storage32.c.

464{
466 FIXME("(%p)->(%d): stub\n", This, timeout);
467 return E_NOTIMPL;
468}
Definition: dhcpd.h:245

◆ entryNameCmp()

static LONG entryNameCmp ( const OLECHAR name1,
const OLECHAR name2 
)
static

Definition at line 510 of file storage32.c.

513{
514 LONG diff = lstrlenW(name1) - lstrlenW(name2);
515
516 while (diff == 0 && *name1 != 0)
517 {
518 /*
519 * We compare the string themselves only when they are of the same length
520 */
521 diff = towupper(*name1++) - towupper(*name2++);
522 }
523
524 return diff;
525}
#define lstrlenW
Definition: compat.h:750
static WCHAR name1[]
Definition: record.c:34
static WCHAR name2[]
Definition: record.c:35
long LONG
Definition: pedump.c:60
#define towupper(c)
Definition: wctype.h:99

Referenced by findElement(), findTreeParent(), IEnumSTATSTGImpl_GetNextRef(), and insertIntoTree().

◆ findElement()

static DirRef findElement ( StorageBaseImpl storage,
DirRef  storageEntry,
const OLECHAR name,
DirEntry data 
)
static

Definition at line 533 of file storage32.c.

535{
536 DirRef currentEntry;
537
538 /* Read the storage entry to find the root of the tree. */
540
541 currentEntry = data->dirRootEntry;
542
543 while (currentEntry != DIRENTRY_NULL)
544 {
545 LONG cmp;
546
548
550
551 if (cmp == 0)
552 /* found it */
553 break;
554
555 else if (cmp < 0)
556 currentEntry = data->leftChild;
557
558 else if (cmp > 0)
559 currentEntry = data->rightChild;
560 }
561
562 return currentEntry;
563}
static LONG entryNameCmp(const OLECHAR *name1, const OLECHAR *name2)
Definition: storage32.c:510
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define cmp(status, error)
Definition: error.c:114
ULONG DirRef
Definition: storage32.h:139
static HRESULT StorageBaseImpl_ReadDirEntry(StorageBaseImpl *This, DirRef index, DirEntry *data)
Definition: storage32.h:290
Definition: name.c:39
WCHAR * name
Definition: name.c:42

Referenced by StorageBaseImpl_CreateStorage(), StorageBaseImpl_CreateStream(), StorageBaseImpl_DestroyElement(), StorageBaseImpl_OpenStorage(), StorageBaseImpl_OpenStream(), and StorageBaseImpl_RenameElement().

◆ findTreeParent()

static HRESULT findTreeParent ( StorageBaseImpl storage,
DirRef  storageEntry,
const OLECHAR childName,
DirEntry parentData,
DirRef parentEntry,
ULONG relation 
)
static

Definition at line 574 of file storage32.c.

577{
578 DirRef childEntry;
579 DirEntry childData;
580
581 /* Read the storage entry to find the root of the tree. */
582 StorageBaseImpl_ReadDirEntry(storage, storageEntry, parentData);
583
584 *parentEntry = storageEntry;
585 *relation = DIRENTRY_RELATION_DIR;
586
587 childEntry = parentData->dirRootEntry;
588
589 while (childEntry != DIRENTRY_NULL)
590 {
591 LONG cmp;
592
593 StorageBaseImpl_ReadDirEntry(storage, childEntry, &childData);
594
595 cmp = entryNameCmp(childName, childData.name);
596
597 if (cmp == 0)
598 /* found it */
599 break;
600
601 else if (cmp < 0)
602 {
603 *parentData = childData;
604 *parentEntry = childEntry;
605 *relation = DIRENTRY_RELATION_PREVIOUS;
606
607 childEntry = parentData->leftChild;
608 }
609
610 else if (cmp > 0)
611 {
612 *parentData = childData;
613 *parentEntry = childEntry;
614 *relation = DIRENTRY_RELATION_NEXT;
615
616 childEntry = parentData->rightChild;
617 }
618 }
619
620 if (childEntry == DIRENTRY_NULL)
621 return STG_E_FILENOTFOUND;
622 else
623 return S_OK;
624}
#define DIRENTRY_RELATION_PREVIOUS
Definition: storage32.h:101
#define DIRENTRY_RELATION_NEXT
Definition: storage32.h:102
#define DIRENTRY_RELATION_DIR
Definition: storage32.h:103
DirRef dirRootEntry
Definition: storage32.h:152
DirRef rightChild
Definition: storage32.h:151
DirRef leftChild
Definition: storage32.h:150
#define STG_E_FILENOTFOUND
Definition: winerror.h:2565

Referenced by removeFromTree().

◆ GetAccessModeFromSTGM()

static DWORD GetAccessModeFromSTGM ( DWORD  stgm)
static

Definition at line 397 of file storage32.c.

398{
399 switch (STGM_ACCESS_MODE(stgm))
400 {
401 case STGM_READ:
402 return GENERIC_READ;
403 case STGM_WRITE:
404 case STGM_READWRITE:
406 }
407 ERR("Invalid access mode!\n");
408 assert(0);
409 return 0;
410}
#define GENERIC_READ
Definition: compat.h:135
#define GENERIC_WRITE
Definition: nt_native.h:90
#define STGM_READ
Definition: objbase.h:917

Referenced by create_storagefile(), and StgOpenStorage().

◆ GetConvertStg()

HRESULT WINAPI GetConvertStg ( IStorage stg)

Definition at line 10617 of file storage32.c.

10618{
10619 static const WCHAR stream_1oleW[] = {1,'O','l','e',0};
10620 static const DWORD version_magic = 0x02000001;
10621 DWORD header[2];
10622 IStream *stream;
10623 HRESULT hr;
10624
10625 TRACE("%p\n", stg);
10626
10627 if (!stg) return E_INVALIDARG;
10628
10629 hr = IStorage_OpenStream(stg, stream_1oleW, NULL, STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &stream);
10630 if (FAILED(hr)) return hr;
10631
10632 hr = IStream_Read(stream, header, sizeof(header), NULL);
10633 IStream_Release(stream);
10634 if (FAILED(hr)) return hr;
10635
10636 if (header[0] != version_magic)
10637 {
10638 ERR("got wrong version magic for 1Ole stream, 0x%08x\n", header[0]);
10639 return E_FAIL;
10640 }
10641
10642 return header[1] & OleStream_Convert ? S_OK : S_FALSE;
10643}
#define E_INVALIDARG
Definition: ddrawi.h:101
Definition: parse.h:23
#define S_FALSE
Definition: winerror.h:2357

Referenced by test_convert().

◆ GetCreationModeFromSTGM()

static DWORD GetCreationModeFromSTGM ( DWORD  stgm)
static

Definition at line 418 of file storage32.c.

419{
420 switch(STGM_CREATE_MODE(stgm))
421 {
422 case STGM_CREATE:
423 return CREATE_ALWAYS;
424 case STGM_CONVERT:
425 FIXME("STGM_CONVERT not implemented!\n");
426 return CREATE_NEW;
427 case STGM_FAILIFTHERE:
428 return CREATE_NEW;
429 }
430 ERR("Invalid create mode!\n");
431 assert(0);
432 return 0;
433}
#define CREATE_ALWAYS
Definition: disk.h:72
#define CREATE_NEW
Definition: disk.h:69
#define STGM_CREATE
Definition: objbase.h:926
#define STGM_CONVERT
Definition: objbase.h:927
#define STGM_FAILIFTHERE
Definition: objbase.h:928
#define STGM_CREATE_MODE(stgm)
Definition: storage32.h:117

Referenced by create_storagefile().

◆ GetShareModeFromSTGM()

static DWORD GetShareModeFromSTGM ( DWORD  stgm)
static

Definition at line 371 of file storage32.c.

372{
373 switch (STGM_SHARE_MODE(stgm))
374 {
375 case 0:
376 assert(stgm & STGM_TRANSACTED);
377 /* fall-through */
381 return FILE_SHARE_WRITE;
384 return FILE_SHARE_READ;
385 }
386 ERR("Invalid share mode!\n");
387 assert(0);
388 return 0;
389}
#define FILE_SHARE_READ
Definition: compat.h:136
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define STGM_SHARE_DENY_WRITE
Definition: objbase.h:922
#define STGM_SHARE_DENY_READ
Definition: objbase.h:921

Referenced by create_storagefile(), and StgOpenStorage().

◆ IEnumSTATSTGImpl_AddRef()

static ULONG WINAPI IEnumSTATSTGImpl_AddRef ( IEnumSTATSTG iface)
static

Definition at line 930 of file storage32.c.

932{
934 return InterlockedIncrement(&This->ref);
935}
#define InterlockedIncrement
Definition: armddk.h:53
static IEnumSTATSTGImpl * impl_from_IEnumSTATSTG(IEnumSTATSTG *iface)
Definition: storage32.c:892

◆ IEnumSTATSTGImpl_Clone()

static HRESULT WINAPI IEnumSTATSTGImpl_Clone ( IEnumSTATSTG iface,
IEnumSTATSTG **  ppenum 
)
static

Definition at line 1136 of file storage32.c.

1139{
1141 IEnumSTATSTGImpl* newClone;
1142
1143 TRACE("%p,%p\n", iface, ppenum);
1144
1145 if (This->parentStorage->reverted)
1146 {
1147 TRACE("<-- STG_E_REVERTED\n");
1148 return STG_E_REVERTED;
1149 }
1150
1151 if (ppenum==0)
1152 return E_INVALIDARG;
1153
1154 newClone = IEnumSTATSTGImpl_Construct(This->parentStorage,
1155 This->storageDirEntry);
1156 if (!newClone)
1157 {
1158 *ppenum = NULL;
1159 return E_OUTOFMEMORY;
1160 }
1161
1162 /*
1163 * The new clone enumeration must point to the same current node as
1164 * the old one.
1165 */
1166 memcpy(newClone->name, This->name, sizeof(newClone->name));
1167
1168 *ppenum = &newClone->IEnumSTATSTG_iface;
1169
1170 return S_OK;
1171}
static IEnumSTATSTGImpl * IEnumSTATSTGImpl_Construct(StorageBaseImpl *, DirRef)
Definition: storage32.c:1187
IEnumSTATSTG IEnumSTATSTG_iface
Definition: storage32.c:883
WCHAR name[DIRENTRY_NAME_MAX_LEN]
Definition: storage32.c:889
#define STG_E_REVERTED
Definition: winerror.h:2590

◆ IEnumSTATSTGImpl_Construct()

static IEnumSTATSTGImpl * IEnumSTATSTGImpl_Construct ( StorageBaseImpl parentStorage,
DirRef  storageDirEntry 
)
static

Definition at line 1187 of file storage32.c.

1190{
1191 IEnumSTATSTGImpl* newEnumeration;
1192
1193 newEnumeration = HeapAlloc(GetProcessHeap(), 0, sizeof(IEnumSTATSTGImpl));
1194
1195 if (newEnumeration)
1196 {
1197 newEnumeration->IEnumSTATSTG_iface.lpVtbl = &IEnumSTATSTGImpl_Vtbl;
1198 newEnumeration->ref = 1;
1199 newEnumeration->name[0] = 0;
1200
1201 /*
1202 * We want to nail-down the reference to the storage in case the
1203 * enumeration out-lives the storage in the client application.
1204 */
1205 newEnumeration->parentStorage = parentStorage;
1206 IStorage_AddRef(&newEnumeration->parentStorage->IStorage_iface);
1207
1208 newEnumeration->storageDirEntry = storageDirEntry;
1209 }
1210
1211 return newEnumeration;
1212}
static const IEnumSTATSTGVtbl IEnumSTATSTGImpl_Vtbl
Definition: storage32.c:1176
StorageBaseImpl * parentStorage
Definition: storage32.c:886
DirRef storageDirEntry
Definition: storage32.c:887

Referenced by IEnumSTATSTGImpl_Clone(), and StorageBaseImpl_EnumElements().

◆ IEnumSTATSTGImpl_Destroy()

static void IEnumSTATSTGImpl_Destroy ( IEnumSTATSTGImpl This)
static

Definition at line 897 of file storage32.c.

898{
899 IStorage_Release(&This->parentStorage->IStorage_iface);
901}

Referenced by IEnumSTATSTGImpl_Release().

◆ IEnumSTATSTGImpl_GetNextRef()

static HRESULT IEnumSTATSTGImpl_GetNextRef ( IEnumSTATSTGImpl This,
DirRef ref 
)
static

Definition at line 954 of file storage32.c.

957{
959 DirRef searchNode;
961 HRESULT hr;
962 WCHAR result_name[DIRENTRY_NAME_MAX_LEN];
963
964 TRACE("%p,%p\n", This, ref);
965
966 hr = StorageBaseImpl_ReadDirEntry(This->parentStorage,
967 This->parentStorage->storageDirEntry, &entry);
968 searchNode = entry.dirRootEntry;
969
970 while (SUCCEEDED(hr) && searchNode != DIRENTRY_NULL)
971 {
972 hr = StorageBaseImpl_ReadDirEntry(This->parentStorage, searchNode, &entry);
973
974 if (SUCCEEDED(hr))
975 {
976 LONG diff = entryNameCmp( entry.name, This->name);
977
978 if (diff <= 0)
979 {
980 searchNode = entry.rightChild;
981 }
982 else
983 {
984 result = searchNode;
985 memcpy(result_name, entry.name, sizeof(result_name));
986 searchNode = entry.leftChild;
987 }
988 }
989 }
990
991 if (SUCCEEDED(hr))
992 {
993 *ref = result;
994 if (result != DIRENTRY_NULL)
995 memcpy(This->name, result_name, sizeof(result_name));
996 }
997
998 TRACE("<-- %08x\n", hr);
999 return hr;
1000}
uint32_t entry
Definition: isohybrid.c:63
#define DIRENTRY_NAME_MAX_LEN
Definition: storage32.h:88
Definition: send.c:48

Referenced by IEnumSTATSTGImpl_Next(), and IEnumSTATSTGImpl_Skip().

◆ IEnumSTATSTGImpl_Next()

static HRESULT WINAPI IEnumSTATSTGImpl_Next ( IEnumSTATSTG iface,
ULONG  celt,
STATSTG *  rgelt,
ULONG pceltFetched 
)
static

Definition at line 1002 of file storage32.c.

1007{
1009
1010 DirEntry currentEntry;
1011 STATSTG* currentReturnStruct = rgelt;
1012 ULONG objectFetched = 0;
1013 DirRef currentSearchNode;
1014 HRESULT hr=S_OK;
1015
1016 TRACE("%p,%u,%p,%p\n", iface, celt, rgelt, pceltFetched);
1017
1018 if ( (rgelt==0) || ( (celt!=1) && (pceltFetched==0) ) )
1019 return E_INVALIDARG;
1020
1021 if (This->parentStorage->reverted)
1022 {
1023 TRACE("<-- STG_E_REVERTED\n");
1024 return STG_E_REVERTED;
1025 }
1026
1027 /*
1028 * To avoid the special case, get another pointer to a ULONG value if
1029 * the caller didn't supply one.
1030 */
1031 if (pceltFetched==0)
1032 pceltFetched = &objectFetched;
1033
1034 /*
1035 * Start the iteration, we will iterate until we hit the end of the
1036 * linked list or until we hit the number of items to iterate through
1037 */
1038 *pceltFetched = 0;
1039
1040 while ( *pceltFetched < celt )
1041 {
1042 hr = IEnumSTATSTGImpl_GetNextRef(This, &currentSearchNode);
1043
1044 if (FAILED(hr) || currentSearchNode == DIRENTRY_NULL)
1045 {
1046 memset(currentReturnStruct, 0, sizeof(*currentReturnStruct));
1047 break;
1048 }
1049
1050 /*
1051 * Read the entry from the storage.
1052 */
1053 hr = StorageBaseImpl_ReadDirEntry(This->parentStorage,
1054 currentSearchNode,
1055 &currentEntry);
1056 if (FAILED(hr)) break;
1057
1058 /*
1059 * Copy the information to the return buffer.
1060 */
1062 currentReturnStruct,
1063 &currentEntry,
1064 STATFLAG_DEFAULT);
1065
1066 /*
1067 * Step to the next item in the iteration
1068 */
1069 (*pceltFetched)++;
1070 currentReturnStruct++;
1071 }
1072
1073 if (SUCCEEDED(hr) && *pceltFetched != celt)
1074 hr = S_FALSE;
1075
1076 TRACE("<-- %08x (asked %u, got %u)\n", hr, celt, *pceltFetched);
1077 return hr;
1078}
void StorageUtl_CopyDirEntryToSTATSTG(StorageBaseImpl *storage, STATSTG *destination, const DirEntry *source, int statFlags)
Definition: storage32.c:7017
static HRESULT IEnumSTATSTGImpl_GetNextRef(IEnumSTATSTGImpl *This, DirRef *ref)
Definition: storage32.c:954

◆ IEnumSTATSTGImpl_QueryInterface()

static HRESULT WINAPI IEnumSTATSTGImpl_QueryInterface ( IEnumSTATSTG iface,
REFIID  riid,
void **  ppvObject 
)
static

Definition at line 903 of file storage32.c.

907{
909
910 TRACE("%p,%s,%p\n", iface, debugstr_guid(riid), ppvObject);
911
912 if (ppvObject==0)
913 return E_INVALIDARG;
914
915 *ppvObject = 0;
916
919 {
920 *ppvObject = &This->IEnumSTATSTG_iface;
921 IEnumSTATSTG_AddRef(&This->IEnumSTATSTG_iface);
922 TRACE("<-- %p\n", *ppvObject);
923 return S_OK;
924 }
925
926 TRACE("<-- E_NOINTERFACE\n");
927 return E_NOINTERFACE;
928}
const GUID IID_IUnknown
#define debugstr_guid
Definition: kernel32.h:35
const GUID IID_IEnumSTATSTG
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
_In_ void _In_ PCCERT_CONTEXT _In_opt_ LPFILETIME _In_ DWORD _In_ DWORD _Outptr_opt_ void ** ppvObject
Definition: wincrypt.h:6082
#define E_NOINTERFACE
Definition: winerror.h:2364

◆ IEnumSTATSTGImpl_Release()

static ULONG WINAPI IEnumSTATSTGImpl_Release ( IEnumSTATSTG iface)
static

Definition at line 937 of file storage32.c.

939{
941
942 ULONG newRef;
943
944 newRef = InterlockedDecrement(&This->ref);
945
946 if (newRef==0)
947 {
949 }
950
951 return newRef;
952}
#define InterlockedDecrement
Definition: armddk.h:52
static void IEnumSTATSTGImpl_Destroy(IEnumSTATSTGImpl *This)
Definition: storage32.c:897

◆ IEnumSTATSTGImpl_Reset()

static HRESULT WINAPI IEnumSTATSTGImpl_Reset ( IEnumSTATSTG iface)
static

Definition at line 1116 of file storage32.c.

1118{
1120
1121 TRACE("%p\n", iface);
1122
1123 if (This->parentStorage->reverted)
1124 {
1125 TRACE("<-- STG_E_REVERTED\n");
1126 return STG_E_REVERTED;
1127 }
1128
1129 This->name[0] = 0;
1130
1131 return S_OK;
1132}

◆ IEnumSTATSTGImpl_Skip()

static HRESULT WINAPI IEnumSTATSTGImpl_Skip ( IEnumSTATSTG iface,
ULONG  celt 
)
static

Definition at line 1081 of file storage32.c.

1084{
1086
1087 ULONG objectFetched = 0;
1088 DirRef currentSearchNode;
1089 HRESULT hr=S_OK;
1090
1091 TRACE("%p,%u\n", iface, celt);
1092
1093 if (This->parentStorage->reverted)
1094 {
1095 TRACE("<-- STG_E_REVERTED\n");
1096 return STG_E_REVERTED;
1097 }
1098
1099 while ( (objectFetched < celt) )
1100 {
1101 hr = IEnumSTATSTGImpl_GetNextRef(This, &currentSearchNode);
1102
1103 if (FAILED(hr) || currentSearchNode == DIRENTRY_NULL)
1104 break;
1105
1106 objectFetched++;
1107 }
1108
1109 if (SUCCEEDED(hr) && objectFetched != celt)
1110 return S_FALSE;
1111
1112 TRACE("<-- %08x\n", hr);
1113 return hr;
1114}

◆ impl_from_IDirectWriterLock()

static StorageBaseImpl * impl_from_IDirectWriterLock ( IDirectWriterLock iface)
inlinestatic

◆ impl_from_IEnumSTATSTG()

static IEnumSTATSTGImpl * impl_from_IEnumSTATSTG ( IEnumSTATSTG iface)
inlinestatic

◆ impl_from_IStorage()

◆ insertIntoTree()

static HRESULT insertIntoTree ( StorageBaseImpl This,
DirRef  parentStorageIndex,
DirRef  newEntryIndex 
)
static

Definition at line 650 of file storage32.c.

654{
655 DirEntry currentEntry;
656 DirEntry newEntry;
657
658 /*
659 * Read the inserted entry
660 */
662 newEntryIndex,
663 &newEntry);
664
665 /*
666 * Read the storage entry
667 */
669 parentStorageIndex,
670 &currentEntry);
671
672 if (currentEntry.dirRootEntry != DIRENTRY_NULL)
673 {
674 /*
675 * The root storage contains some element, therefore, start the research
676 * for the appropriate location.
677 */
678 BOOL found = FALSE;
679 DirRef current, next, previous, currentEntryId;
680
681 /*
682 * Keep a reference to the root of the storage's element tree
683 */
684 currentEntryId = currentEntry.dirRootEntry;
685
686 /*
687 * Read
688 */
690 currentEntry.dirRootEntry,
691 &currentEntry);
692
693 previous = currentEntry.leftChild;
694 next = currentEntry.rightChild;
695 current = currentEntryId;
696
697 while (!found)
698 {
699 LONG diff = entryNameCmp( newEntry.name, currentEntry.name);
700
701 if (diff < 0)
702 {
703 if (previous != DIRENTRY_NULL)
704 {
706 previous,
707 &currentEntry);
708 current = previous;
709 }
710 else
711 {
712 currentEntry.leftChild = newEntryIndex;
714 current,
715 &currentEntry);
716 found = TRUE;
717 }
718 }
719 else if (diff > 0)
720 {
721 if (next != DIRENTRY_NULL)
722 {
724 next,
725 &currentEntry);
726 current = next;
727 }
728 else
729 {
730 currentEntry.rightChild = newEntryIndex;
732 current,
733 &currentEntry);
734 found = TRUE;
735 }
736 }
737 else
738 {
739 /*
740 * Trying to insert an item with the same name in the
741 * subtree structure.
742 */
744 }
745
746 previous = currentEntry.leftChild;
747 next = currentEntry.rightChild;
748 }
749 }
750 else
751 {
752 /*
753 * The storage is empty, make the new entry the root of its element tree
754 */
755 currentEntry.dirRootEntry = newEntryIndex;
757 parentStorageIndex,
758 &currentEntry);
759 }
760
761 return S_OK;
762}
unsigned int BOOL
Definition: ntddk_ex.h:94
struct task_struct * current
Definition: linux.c:32
static unsigned __int64 next
Definition: rand_nt.c:6
static HRESULT StorageBaseImpl_WriteDirEntry(StorageBaseImpl *This, DirRef index, const DirEntry *data)
Definition: storage32.h:284

Referenced by StorageBaseImpl_CreateStorage(), StorageBaseImpl_CreateStream(), and StorageBaseImpl_RenameElement().

◆ OLECONVERT_CreateCompObjStream()

HRESULT OLECONVERT_CreateCompObjStream ( LPSTORAGE  pStorage,
LPCSTR  strOleTypeName 
)

Definition at line 10028 of file storage32.c.

10029{
10030 IStream *pStream;
10031 HRESULT hStorageRes, hRes = S_OK;
10032 OLECONVERT_ISTORAGE_COMPOBJ IStorageCompObj;
10033 static const WCHAR wstrStreamName[] = {1,'C', 'o', 'm', 'p', 'O', 'b', 'j', 0};
10035
10036 static const BYTE pCompObjUnknown1[] = {0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF};
10037 static const BYTE pCompObjUnknown2[] = {0xF4, 0x39, 0xB2, 0x71};
10038
10039 /* Initialize the CompObj structure */
10040 memset(&IStorageCompObj, 0, sizeof(IStorageCompObj));
10041 memcpy(IStorageCompObj.byUnknown1, pCompObjUnknown1, sizeof(pCompObjUnknown1));
10042 memcpy(IStorageCompObj.byUnknown2, pCompObjUnknown2, sizeof(pCompObjUnknown2));
10043
10044
10045 /* Create a CompObj stream if it doesn't exist */
10046 hStorageRes = IStorage_CreateStream(pStorage, wstrStreamName,
10047 STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &pStream );
10048 if(hStorageRes == S_OK)
10049 {
10050 /* copy the OleTypeName to the compobj struct */
10051 IStorageCompObj.dwOleTypeNameLength = strlen(strOleTypeName)+1;
10052 strcpy(IStorageCompObj.strOleTypeName, strOleTypeName);
10053
10054 /* copy the OleTypeName to the compobj struct */
10055 /* Note: in the test made, these were Identical */
10056 IStorageCompObj.dwProgIDNameLength = strlen(strOleTypeName)+1;
10057 strcpy(IStorageCompObj.strProgIDName, strOleTypeName);
10058
10059 /* Get the CLSID */
10060 MultiByteToWideChar( CP_ACP, 0, IStorageCompObj.strProgIDName, -1,
10061 bufferW, OLESTREAM_MAX_STR_LEN );
10062 hRes = CLSIDFromProgID(bufferW, &(IStorageCompObj.clsid));
10063
10064 if(hRes == S_OK)
10065 {
10066 HKEY hKey;
10067 LONG hErr;
10068 /* Get the CLSID Default Name from the Registry */
10070 if(hErr == ERROR_SUCCESS)
10071 {
10072 char strTemp[OLESTREAM_MAX_STR_LEN];
10073 IStorageCompObj.dwCLSIDNameLength = OLESTREAM_MAX_STR_LEN;
10074 hErr = RegQueryValueA(hKey, NULL, strTemp, (LONG*) &(IStorageCompObj.dwCLSIDNameLength));
10075 if(hErr == ERROR_SUCCESS)
10076 {
10077 strcpy(IStorageCompObj.strCLSIDName, strTemp);
10078 }
10080 }
10081 }
10082
10083 /* Write CompObj Structure to stream */
10084 hRes = IStream_Write(pStream, IStorageCompObj.byUnknown1, sizeof(IStorageCompObj.byUnknown1), NULL);
10085
10086 WriteClassStm(pStream,&(IStorageCompObj.clsid));
10087
10088 hRes = IStream_Write(pStream, &(IStorageCompObj.dwCLSIDNameLength), sizeof(IStorageCompObj.dwCLSIDNameLength), NULL);
10089 if(IStorageCompObj.dwCLSIDNameLength > 0)
10090 {
10091 hRes = IStream_Write(pStream, IStorageCompObj.strCLSIDName, IStorageCompObj.dwCLSIDNameLength, NULL);
10092 }
10093 hRes = IStream_Write(pStream, &(IStorageCompObj.dwOleTypeNameLength) , sizeof(IStorageCompObj.dwOleTypeNameLength), NULL);
10094 if(IStorageCompObj.dwOleTypeNameLength > 0)
10095 {
10096 hRes = IStream_Write(pStream, IStorageCompObj.strOleTypeName , IStorageCompObj.dwOleTypeNameLength, NULL);
10097 }
10098 hRes = IStream_Write(pStream, &(IStorageCompObj.dwProgIDNameLength) , sizeof(IStorageCompObj.dwProgIDNameLength), NULL);
10099 if(IStorageCompObj.dwProgIDNameLength > 0)
10100 {
10101 hRes = IStream_Write(pStream, IStorageCompObj.strProgIDName , IStorageCompObj.dwProgIDNameLength, NULL);
10102 }
10103 hRes = IStream_Write(pStream, IStorageCompObj.byUnknown2 , sizeof(IStorageCompObj.byUnknown2), NULL);
10104 IStream_Release(pStream);
10105 }
10106 return hRes;
10107}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
LSTATUS WINAPI RegQueryValueA(HKEY hkey, LPCSTR name, LPSTR data, LPLONG count)
Definition: reg.c:4212
#define CP_ACP
Definition: compat.h:109
#define MultiByteToWideChar
Definition: compat.h:110
HRESULT WINAPI DECLSPEC_HOTPATCH CLSIDFromProgID(LPCOLESTR progid, LPCLSID clsid)
Definition: compobj.c:2602
LSTATUS open_classes_key(HKEY hkey, const WCHAR *name, REGSAM access, HKEY *retkey)
Definition: compobj.c:420
HRESULT WINAPI WriteClassStm(IStream *pStm, REFCLSID rclsid)
Definition: storage32.c:9525
#define OLESTREAM_MAX_STR_LEN
Definition: storage32.c:9578
FxAutoRegKey hKey
#define MAXIMUM_ALLOWED
Definition: nt_native.h:83
CHAR strCLSIDName[OLESTREAM_MAX_STR_LEN]
Definition: storage32.c:9602
CHAR strOleTypeName[OLESTREAM_MAX_STR_LEN]
Definition: storage32.c:9604
CHAR strProgIDName[OLESTREAM_MAX_STR_LEN]
Definition: storage32.c:9606
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10

Referenced by OleConvertOLESTREAMToIStorage(), and render_embed_source_hack().

◆ OLECONVERT_CreateOle10NativeStream()

static void OLECONVERT_CreateOle10NativeStream ( LPSTORAGE  pStorage,
const BYTE pData,
DWORD  dwDataLength 
)
static

Definition at line 10214 of file storage32.c.

10215{
10216 HRESULT hRes;
10217 IStream *pStream;
10218 static const WCHAR wstrStreamName[] = {1, 'O', 'l', 'e', '1', '0', 'N', 'a', 't', 'i', 'v', 'e', 0};
10219
10220 /* Create the Ole10Native Stream */
10221 hRes = IStorage_CreateStream(pStorage, wstrStreamName,
10222 STGM_CREATE | STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &pStream );
10223
10224 if(hRes == S_OK)
10225 {
10226 /* Write info to stream */
10227 hRes = IStream_Write(pStream, &dwDataLength, sizeof(dwDataLength), NULL);
10228 hRes = IStream_Write(pStream, pData, dwDataLength, NULL);
10229 IStream_Release(pStream);
10230 }
10231
10232}
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1830

Referenced by OleConvertOLESTREAMToIStorage().

◆ OLECONVERT_CreateOlePresStream()

static void OLECONVERT_CreateOlePresStream ( LPSTORAGE  pStorage,
DWORD  dwExtentX,
DWORD  dwExtentY,
BYTE pData,
DWORD  dwDataLength 
)
static

Definition at line 10130 of file storage32.c.

10131{
10132 HRESULT hRes;
10133 IStream *pStream;
10134 static const WCHAR wstrStreamName[] = {2, 'O', 'l', 'e', 'P', 'r', 'e', 's', '0', '0', '0', 0};
10135 static const BYTE pOlePresStreamHeader[] =
10136 {
10137 0xFF, 0xFF, 0xFF, 0xFF, 0x03, 0x00, 0x00, 0x00,
10138 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
10139 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
10140 0x00, 0x00, 0x00, 0x00
10141 };
10142
10143 static const BYTE pOlePresStreamHeaderEmpty[] =
10144 {
10145 0x00, 0x00, 0x00, 0x00,
10146 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
10147 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
10148 0x00, 0x00, 0x00, 0x00
10149 };
10150
10151 /* Create the OlePres000 Stream */
10152 hRes = IStorage_CreateStream(pStorage, wstrStreamName,
10153 STGM_CREATE | STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &pStream );
10154
10155 if(hRes == S_OK)
10156 {
10157 DWORD nHeaderSize;
10159
10160 memset(&OlePres, 0, sizeof(OlePres));
10161 /* Do we have any metafile data to save */
10162 if(dwDataLength > 0)
10163 {
10164 memcpy(OlePres.byUnknown1, pOlePresStreamHeader, sizeof(pOlePresStreamHeader));
10165 nHeaderSize = sizeof(pOlePresStreamHeader);
10166 }
10167 else
10168 {
10169 memcpy(OlePres.byUnknown1, pOlePresStreamHeaderEmpty, sizeof(pOlePresStreamHeaderEmpty));
10170 nHeaderSize = sizeof(pOlePresStreamHeaderEmpty);
10171 }
10172 /* Set width and height of the metafile */
10173 OlePres.dwExtentX = dwExtentX;
10174 OlePres.dwExtentY = -dwExtentY;
10175
10176 /* Set Data and Length */
10177 if(dwDataLength > sizeof(METAFILEPICT16))
10178 {
10179 OlePres.dwSize = dwDataLength - sizeof(METAFILEPICT16);
10180 OlePres.pData = &(pData[8]);
10181 }
10182 /* Save OlePres000 Data to Stream */
10183 hRes = IStream_Write(pStream, OlePres.byUnknown1, nHeaderSize, NULL);
10184 hRes = IStream_Write(pStream, &(OlePres.dwExtentX), sizeof(OlePres.dwExtentX), NULL);
10185 hRes = IStream_Write(pStream, &(OlePres.dwExtentY), sizeof(OlePres.dwExtentY), NULL);
10186 hRes = IStream_Write(pStream, &(OlePres.dwSize), sizeof(OlePres.dwSize), NULL);
10187 if(OlePres.dwSize > 0)
10188 {
10189 hRes = IStream_Write(pStream, OlePres.pData, OlePres.dwSize, NULL);
10190 }
10191 IStream_Release(pStream);
10192 }
10193}

Referenced by OleConvertOLESTREAMToIStorage().

◆ OLECONVERT_GetOle10PresData()

static void OLECONVERT_GetOle10PresData ( LPSTORAGE  pStorage,
OLECONVERT_OLESTREAM_DATA pOleStreamData 
)
static

Definition at line 10324 of file storage32.c.

10325{
10326
10327 HRESULT hRes;
10328 IStream *pStream;
10329 static const WCHAR wstrStreamName[] = {1, 'O', 'l', 'e', '1', '0', 'N', 'a', 't', 'i', 'v', 'e', 0};
10330
10331 /* Initialize Default data for OLESTREAM */
10332 pOleStreamData[0].dwOleID = OLESTREAM_ID;
10333 pOleStreamData[0].dwTypeID = 2;
10334 pOleStreamData[1].dwOleID = OLESTREAM_ID;
10335 pOleStreamData[1].dwTypeID = 0;
10336 pOleStreamData[0].dwMetaFileWidth = 0;
10337 pOleStreamData[0].dwMetaFileHeight = 0;
10338 pOleStreamData[0].pData = NULL;
10339 pOleStreamData[1].pData = NULL;
10340
10341 /* Open Ole10Native Stream */
10342 hRes = IStorage_OpenStream(pStorage, wstrStreamName, NULL,
10343 STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &pStream );
10344 if(hRes == S_OK)
10345 {
10346
10347 /* Read Size and Data */
10348 IStream_Read(pStream, &(pOleStreamData->dwDataLength), sizeof(pOleStreamData->dwDataLength), NULL);
10349 if(pOleStreamData->dwDataLength > 0)
10350 {
10351 pOleStreamData->pData = HeapAlloc(GetProcessHeap(),0,pOleStreamData->dwDataLength);
10352 IStream_Read(pStream, pOleStreamData->pData, pOleStreamData->dwDataLength, NULL);
10353 }
10354 IStream_Release(pStream);
10355 }
10356
10357}
#define OLESTREAM_ID
Definition: storage32.c:9577

Referenced by OleConvertIStorageToOLESTREAM().

◆ OLECONVERT_GetOLE10ProgID()

static HRESULT OLECONVERT_GetOLE10ProgID ( LPSTORAGE  pStorage,
char strProgID,
DWORD dwSize 
)
static

Definition at line 10253 of file storage32.c.

10254{
10255 HRESULT hRes;
10256 IStream *pStream;
10257 LARGE_INTEGER iSeekPos;
10259 static const WCHAR wstrStreamName[] = {1,'C', 'o', 'm', 'p', 'O', 'b', 'j', 0};
10260
10261 /* Open the CompObj Stream */
10262 hRes = IStorage_OpenStream(pStorage, wstrStreamName, NULL,
10263 STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &pStream );
10264 if(hRes == S_OK)
10265 {
10266
10267 /*Get the OleType from the CompObj Stream */
10268 iSeekPos.u.LowPart = sizeof(CompObj.byUnknown1) + sizeof(CompObj.clsid);
10269 iSeekPos.u.HighPart = 0;
10270
10271 IStream_Seek(pStream, iSeekPos, STREAM_SEEK_SET, NULL);
10272 IStream_Read(pStream, &CompObj.dwCLSIDNameLength, sizeof(CompObj.dwCLSIDNameLength), NULL);
10273 iSeekPos.u.LowPart = CompObj.dwCLSIDNameLength;
10274 IStream_Seek(pStream, iSeekPos, STREAM_SEEK_CUR , NULL);
10275 IStream_Read(pStream, &CompObj.dwOleTypeNameLength, sizeof(CompObj.dwOleTypeNameLength), NULL);
10276 iSeekPos.u.LowPart = CompObj.dwOleTypeNameLength;
10277 IStream_Seek(pStream, iSeekPos, STREAM_SEEK_CUR , NULL);
10278
10279 IStream_Read(pStream, dwSize, sizeof(*dwSize), NULL);
10280 if(*dwSize > 0)
10281 {
10282 IStream_Read(pStream, strProgID, *dwSize, NULL);
10283 }
10284 IStream_Release(pStream);
10285 }
10286 else
10287 {
10288 STATSTG stat;
10289 LPOLESTR wstrProgID;
10290
10291 /* Get the OleType from the registry */
10292 REFCLSID clsid = &(stat.clsid);
10293 IStorage_Stat(pStorage, &stat, STATFLAG_NONAME);
10294 hRes = ProgIDFromCLSID(clsid, &wstrProgID);
10295 if(hRes == S_OK)
10296 {
10297 *dwSize = WideCharToMultiByte(CP_ACP, 0, wstrProgID, -1, strProgID, *dwSize, NULL, FALSE);
10298 CoTaskMemFree(wstrProgID);
10299 }
10300
10301 }
10302 return hRes;
10303}
#define stat
Definition: acwin.h:99
#define WideCharToMultiByte
Definition: compat.h:111
HRESULT WINAPI DECLSPEC_HOTPATCH ProgIDFromCLSID(REFCLSID clsid, LPOLESTR *ppszProgID)
Definition: compobj.c:2530
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
static LPOLESTR
Definition: stg_prop.c:27
REFCLSID clsid
Definition: msctf.c:82
#define REFCLSID
Definition: guiddef.h:117
Definition: stat.h:55
struct _LARGE_INTEGER::@2299 u

Referenced by OleConvertIStorageToOLESTREAM().

◆ OLECONVERT_GetOLE20FromOLE10()

static void OLECONVERT_GetOLE20FromOLE10 ( LPSTORAGE  pDestStorage,
const BYTE pBuffer,
DWORD  nBufferLength 
)
static

Definition at line 9919 of file storage32.c.

9920{
9921 HRESULT hRes;
9922 HANDLE hFile;
9923 IStorage *pTempStorage;
9924 DWORD dwNumOfBytesWritten;
9925 WCHAR wstrTempDir[MAX_PATH], wstrTempFile[MAX_PATH];
9926 static const WCHAR wstrPrefix[] = {'s', 'i', 's', 0};
9927
9928 /* Create a temp File */
9929 GetTempPathW(MAX_PATH, wstrTempDir);
9930 GetTempFileNameW(wstrTempDir, wstrPrefix, 0, wstrTempFile);
9932
9934 {
9935 /* Write IStorage Data to File */
9936 WriteFile(hFile, pBuffer, nBufferLength, &dwNumOfBytesWritten, NULL);
9938
9939 /* Open and copy temp storage to the Dest Storage */
9940 hRes = StgOpenStorage(wstrTempFile, NULL, STGM_READ, NULL, 0, &pTempStorage);
9941 if(hRes == S_OK)
9942 {
9943 hRes = IStorage_CopyTo(pTempStorage, 0, NULL, NULL, pDestStorage);
9944 IStorage_Release(pTempStorage);
9945 }
9946 DeleteFileW(wstrTempFile);
9947 }
9948}
#define CloseHandle
Definition: compat.h:739
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
HRESULT WINAPI StgOpenStorage(const OLECHAR *pwcsName, IStorage *pstgPriority, DWORD grfMode, SNB snbExclude, DWORD reserved, IStorage **ppstgOpen)
Definition: storage32.c:8755
PVOID pBuffer
_In_ LPCSTR _In_opt_ LPCSTR _In_ DWORD nBufferLength
Definition: winbase.h:3097

Referenced by OleConvertOLESTREAMToIStorage().

◆ OLECONVERT_GetOle20PresData()

static void OLECONVERT_GetOle20PresData ( LPSTORAGE  pStorage,
OLECONVERT_OLESTREAM_DATA pOleStreamData 
)
static

Definition at line 10377 of file storage32.c.

10378{
10379 HRESULT hRes;
10380 IStream *pStream;
10382 static const WCHAR wstrStreamName[] = {2, 'O', 'l', 'e', 'P', 'r', 'e', 's', '0', '0', '0', 0};
10383
10384 /* Initialize Default data for OLESTREAM */
10385 pOleStreamData[0].dwOleID = OLESTREAM_ID;
10386 pOleStreamData[0].dwTypeID = 2;
10387 pOleStreamData[0].dwMetaFileWidth = 0;
10388 pOleStreamData[0].dwMetaFileHeight = 0;
10389 pOleStreamData[0].dwDataLength = OLECONVERT_WriteOLE20ToBuffer(pStorage, &(pOleStreamData[0].pData));
10390 pOleStreamData[1].dwOleID = OLESTREAM_ID;
10391 pOleStreamData[1].dwTypeID = 0;
10392 pOleStreamData[1].dwOleTypeNameLength = 0;
10393 pOleStreamData[1].strOleTypeName[0] = 0;
10394 pOleStreamData[1].dwMetaFileWidth = 0;
10395 pOleStreamData[1].dwMetaFileHeight = 0;
10396 pOleStreamData[1].pData = NULL;
10397 pOleStreamData[1].dwDataLength = 0;
10398
10399
10400 /* Open OlePress000 stream */
10401 hRes = IStorage_OpenStream(pStorage, wstrStreamName, NULL,
10402 STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &pStream );
10403 if(hRes == S_OK)
10404 {
10405 LARGE_INTEGER iSeekPos;
10406 METAFILEPICT16 MetaFilePict;
10407 static const char strMetafilePictName[] = "METAFILEPICT";
10408
10409 /* Set the TypeID for a Metafile */
10410 pOleStreamData[1].dwTypeID = 5;
10411
10412 /* Set the OleTypeName to Metafile */
10413 pOleStreamData[1].dwOleTypeNameLength = strlen(strMetafilePictName) +1;
10414 strcpy(pOleStreamData[1].strOleTypeName, strMetafilePictName);
10415
10416 iSeekPos.u.HighPart = 0;
10417 iSeekPos.u.LowPart = sizeof(olePress.byUnknown1);
10418
10419 /* Get Presentation Data */
10420 IStream_Seek(pStream, iSeekPos, STREAM_SEEK_SET, NULL);
10421 IStream_Read(pStream, &(olePress.dwExtentX), sizeof(olePress.dwExtentX), NULL);
10422 IStream_Read(pStream, &(olePress.dwExtentY), sizeof(olePress.dwExtentY), NULL);
10423 IStream_Read(pStream, &(olePress.dwSize), sizeof(olePress.dwSize), NULL);
10424
10425 /*Set width and Height */
10426 pOleStreamData[1].dwMetaFileWidth = olePress.dwExtentX;
10427 pOleStreamData[1].dwMetaFileHeight = -olePress.dwExtentY;
10428 if(olePress.dwSize > 0)
10429 {
10430 /* Set Length */
10431 pOleStreamData[1].dwDataLength = olePress.dwSize + sizeof(METAFILEPICT16);
10432
10433 /* Set MetaFilePict struct */
10434 MetaFilePict.mm = 8;
10435 MetaFilePict.xExt = olePress.dwExtentX;
10436 MetaFilePict.yExt = olePress.dwExtentY;
10437 MetaFilePict.hMF = 0;
10438
10439 /* Get Metafile Data */
10440 pOleStreamData[1].pData = HeapAlloc(GetProcessHeap(),0,pOleStreamData[1].dwDataLength);
10441 memcpy(pOleStreamData[1].pData, &MetaFilePict, sizeof(MetaFilePict));
10442 IStream_Read(pStream, &(pOleStreamData[1].pData[sizeof(MetaFilePict)]), pOleStreamData[1].dwDataLength-sizeof(METAFILEPICT16), NULL);
10443 }
10444 IStream_Release(pStream);
10445 }
10446}
static DWORD OLECONVERT_WriteOLE20ToBuffer(LPSTORAGE pStorage, BYTE **pData)
Definition: storage32.c:9969
INT16 xExt
Definition: wingdi16.h:58
INT16 yExt
Definition: wingdi16.h:59
HMETAFILE16 hMF
Definition: wingdi16.h:60
CHAR strOleTypeName[OLESTREAM_MAX_STR_LEN]
Definition: storage32.c:9586

Referenced by OleConvertIStorageToOLESTREAM().

◆ OLECONVERT_LoadOLE10()

static HRESULT OLECONVERT_LoadOLE10 ( LPOLESTREAM  pOleStream,
OLECONVERT_OLESTREAM_DATA pData,
BOOL  bStrem1 
)
static

Definition at line 9640 of file storage32.c.

9641{
9642 DWORD dwSize;
9643 HRESULT hRes = S_OK;
9644 int nTryCnt=0;
9645 int max_try = 6;
9646
9647 pData->pData = NULL;
9648 pData->pstrOleObjFileName = NULL;
9649
9650 for( nTryCnt=0;nTryCnt < max_try; nTryCnt++)
9651 {
9652 /* Get the OleID */
9653 dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwOleID), sizeof(pData->dwOleID));
9654 if(dwSize != sizeof(pData->dwOleID))
9655 {
9657 }
9658 else if(pData->dwOleID != OLESTREAM_ID)
9659 {
9661 }
9662 else
9663 {
9664 hRes = S_OK;
9665 break;
9666 }
9667 }
9668
9669 if(hRes == S_OK)
9670 {
9671 /* Get the TypeID... more info needed for this field */
9672 dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwTypeID), sizeof(pData->dwTypeID));
9673 if(dwSize != sizeof(pData->dwTypeID))
9674 {
9676 }
9677 }
9678 if(hRes == S_OK)
9679 {
9680 if(pData->dwTypeID != 0)
9681 {
9682 /* Get the length of the OleTypeName */
9683 dwSize = pOleStream->lpstbl->Get(pOleStream, (void *) &(pData->dwOleTypeNameLength), sizeof(pData->dwOleTypeNameLength));
9684 if(dwSize != sizeof(pData->dwOleTypeNameLength))
9685 {
9687 }
9688
9689 if(hRes == S_OK)
9690 {
9691 if(pData->dwOleTypeNameLength > 0)
9692 {
9693 /* Get the OleTypeName */
9694 dwSize = pOleStream->lpstbl->Get(pOleStream, pData->strOleTypeName, pData->dwOleTypeNameLength);
9695 if(dwSize != pData->dwOleTypeNameLength)
9696 {
9698 }
9699 }
9700 }
9701 if(bStrem1)
9702 {
9703 dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwOleObjFileNameLength), sizeof(pData->dwOleObjFileNameLength));
9704 if(dwSize != sizeof(pData->dwOleObjFileNameLength))
9705 {
9707 }
9708 if(hRes == S_OK)
9709 {
9710 if(pData->dwOleObjFileNameLength < 1) /* there is no file name exist */
9711 pData->dwOleObjFileNameLength = sizeof(pData->dwOleObjFileNameLength);
9712 pData->pstrOleObjFileName = HeapAlloc(GetProcessHeap(), 0, pData->dwOleObjFileNameLength);
9713 if(pData->pstrOleObjFileName)
9714 {
9715 dwSize = pOleStream->lpstbl->Get(pOleStream, pData->pstrOleObjFileName, pData->dwOleObjFileNameLength);
9716 if(dwSize != pData->dwOleObjFileNameLength)
9717 {
9719 }
9720 }
9721 else
9723 }
9724 }
9725 else
9726 {
9727 /* Get the Width of the Metafile */
9728 dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwMetaFileWidth), sizeof(pData->dwMetaFileWidth));
9729 if(dwSize != sizeof(pData->dwMetaFileWidth))
9730 {
9732 }
9733 if(hRes == S_OK)
9734 {
9735 /* Get the Height of the Metafile */
9736 dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwMetaFileHeight), sizeof(pData->dwMetaFileHeight));
9737 if(dwSize != sizeof(pData->dwMetaFileHeight))
9738 {
9740 }
9741 }
9742 }
9743 if(hRes == S_OK)
9744 {
9745 /* Get the Length of the Data */
9746 dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwDataLength), sizeof(pData->dwDataLength));
9747 if(dwSize != sizeof(pData->dwDataLength))
9748 {
9750 }
9751 }
9752
9753 if(hRes == S_OK) /* I don't know what this 8 byte information is. We have to figure out */
9754 {
9755 if(!bStrem1) /* if it is a second OLE stream data */
9756 {
9757 pData->dwDataLength -= 8;
9758 dwSize = pOleStream->lpstbl->Get(pOleStream, pData->strUnknown, sizeof(pData->strUnknown));
9759 if(dwSize != sizeof(pData->strUnknown))
9760 {
9762 }
9763 }
9764 }
9765 if(hRes == S_OK)
9766 {
9767 if(pData->dwDataLength > 0)
9768 {
9769 pData->pData = HeapAlloc(GetProcessHeap(),0,pData->dwDataLength);
9770
9771 /* Get Data (ex. IStorage, Metafile, or BMP) */
9772 if(pData->pData)
9773 {
9774 dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)pData->pData, pData->dwDataLength);
9775 if(dwSize != pData->dwDataLength)
9776 {
9778 }
9779 }
9780 else
9781 {
9783 }
9784 }
9785 }
9786 }
9787 }
9788 return hRes;
9789}
LPOLESTREAMVTBL lpstbl
Definition: ole.h:206
#define CONVERT10_E_OLESTREAM_GET
Definition: winerror.h:2752
#define CONVERT10_E_OLESTREAM_FMT
Definition: winerror.h:2754

Referenced by OleConvertOLESTREAMToIStorage().

◆ OLECONVERT_SaveOLE10()

static HRESULT OLECONVERT_SaveOLE10 ( OLECONVERT_OLESTREAM_DATA pData,
LPOLESTREAM  pOleStream 
)
static

Definition at line 9808 of file storage32.c.

9809{
9810 DWORD dwSize;
9811 HRESULT hRes = S_OK;
9812
9813
9814 /* Set the OleID */
9815 dwSize = pOleStream->lpstbl->Put(pOleStream, (void *)&(pData->dwOleID), sizeof(pData->dwOleID));
9816 if(dwSize != sizeof(pData->dwOleID))
9817 {
9819 }
9820
9821 if(hRes == S_OK)
9822 {
9823 /* Set the TypeID */
9824 dwSize = pOleStream->lpstbl->Put(pOleStream, (void *)&(pData->dwTypeID), sizeof(pData->dwTypeID));
9825 if(dwSize != sizeof(pData->dwTypeID))
9826 {
9828 }
9829 }
9830
9831 if(pData->dwOleID == OLESTREAM_ID && pData->dwTypeID != 0 && hRes == S_OK)
9832 {
9833 /* Set the Length of the OleTypeName */
9834 dwSize = pOleStream->lpstbl->Put(pOleStream, (void *)&(pData->dwOleTypeNameLength), sizeof(pData->dwOleTypeNameLength));
9835 if(dwSize != sizeof(pData->dwOleTypeNameLength))
9836 {
9838 }
9839
9840 if(hRes == S_OK)
9841 {
9842 if(pData->dwOleTypeNameLength > 0)
9843 {
9844 /* Set the OleTypeName */
9845 dwSize = pOleStream->lpstbl->Put(pOleStream, pData->strOleTypeName, pData->dwOleTypeNameLength);
9846 if(dwSize != pData->dwOleTypeNameLength)
9847 {
9849 }
9850 }
9851 }
9852
9853 if(hRes == S_OK)
9854 {
9855 /* Set the width of the Metafile */
9856 dwSize = pOleStream->lpstbl->Put(pOleStream, (void *)&(pData->dwMetaFileWidth), sizeof(pData->dwMetaFileWidth));
9857 if(dwSize != sizeof(pData->dwMetaFileWidth))
9858 {
9860 }
9861 }
9862
9863 if(hRes == S_OK)
9864 {
9865 /* Set the height of the Metafile */
9866 dwSize = pOleStream->lpstbl->Put(pOleStream, (void *)&(pData->dwMetaFileHeight), sizeof(pData->dwMetaFileHeight));
9867 if(dwSize != sizeof(pData->dwMetaFileHeight))
9868 {
9870 }
9871 }
9872
9873 if(hRes == S_OK)
9874 {
9875 /* Set the length of the Data */
9876 dwSize = pOleStream->lpstbl->Put(pOleStream, (void *)&(pData->dwDataLength), sizeof(pData->dwDataLength));
9877 if(dwSize != sizeof(pData->dwDataLength))
9878 {
9880 }
9881 }
9882
9883 if(hRes == S_OK)
9884 {
9885 if(pData->dwDataLength > 0)
9886 {
9887 /* Set the Data (eg. IStorage, Metafile, Bitmap) */
9888 dwSize = pOleStream->lpstbl->Put(pOleStream, (void *) pData->pData, pData->dwDataLength);
9889 if(dwSize != pData->dwDataLength)
9890 {
9892 }
9893 }
9894 }
9895 }
9896 return hRes;
9897}
#define CONVERT10_E_OLESTREAM_PUT
Definition: winerror.h:2753

Referenced by OleConvertIStorageToOLESTREAM().

◆ OLECONVERT_WriteOLE20ToBuffer()

static DWORD OLECONVERT_WriteOLE20ToBuffer ( LPSTORAGE  pStorage,
BYTE **  pData 
)
static

Definition at line 9969 of file storage32.c.

9970{
9971 HANDLE hFile;
9972 HRESULT hRes;
9973 DWORD nDataLength = 0;
9974 IStorage *pTempStorage;
9975 WCHAR wstrTempDir[MAX_PATH], wstrTempFile[MAX_PATH];
9976 static const WCHAR wstrPrefix[] = {'s', 'i', 's', 0};
9977
9978 *pData = NULL;
9979
9980 /* Create temp Storage */
9981 GetTempPathW(MAX_PATH, wstrTempDir);
9982 GetTempFileNameW(wstrTempDir, wstrPrefix, 0, wstrTempFile);
9983 hRes = StgCreateDocfile(wstrTempFile, STGM_CREATE | STGM_READWRITE | STGM_SHARE_EXCLUSIVE, 0, &pTempStorage);
9984
9985 if(hRes == S_OK)
9986 {
9987 /* Copy Src Storage to the Temp Storage */
9988 IStorage_CopyTo(pStorage, 0, NULL, NULL, pTempStorage);
9989 IStorage_Release(pTempStorage);
9990
9991 /* Open Temp Storage as a file and copy to memory */
9994 {
9995 nDataLength = GetFileSize(hFile, NULL);
9996 *pData = HeapAlloc(GetProcessHeap(),0,nDataLength);
9997 ReadFile(hFile, *pData, nDataLength, &nDataLength, 0);
9999 }
10000 DeleteFileW(wstrTempFile);
10001 }
10002 return nDataLength;
10003}
#define OPEN_EXISTING
Definition: compat.h:775
#define ReadFile(a, b, c, d, e)
Definition: compat.h:742
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:331
HRESULT WINAPI StgCreateDocfile(LPCOLESTR pwcsName, DWORD grfMode, DWORD reserved, IStorage **ppstgOpen)
Definition: storage32.c:8636

Referenced by OLECONVERT_GetOle20PresData().

◆ OleConvertIStorageToOLESTREAM()

HRESULT WINAPI OleConvertIStorageToOLESTREAM ( LPSTORAGE  pstg,
LPOLESTREAM  pOleStream 
)

Definition at line 10551 of file storage32.c.

10554{
10555 int i;
10556 HRESULT hRes = S_OK;
10557 IStream *pStream;
10558 OLECONVERT_OLESTREAM_DATA pOleStreamData[2];
10559 static const WCHAR wstrStreamName[] = {1, 'O', 'l', 'e', '1', '0', 'N', 'a', 't', 'i', 'v', 'e', 0};
10560
10561 TRACE("%p %p\n", pstg, pOleStream);
10562
10563 memset(pOleStreamData, 0, sizeof(pOleStreamData));
10564
10565 if(pstg == NULL || pOleStream == NULL)
10566 {
10567 hRes = E_INVALIDARG;
10568 }
10569 if(hRes == S_OK)
10570 {
10571 /* Get the ProgID */
10572 pOleStreamData[0].dwOleTypeNameLength = OLESTREAM_MAX_STR_LEN;
10573 hRes = OLECONVERT_GetOLE10ProgID(pstg, pOleStreamData[0].strOleTypeName, &(pOleStreamData[0].dwOleTypeNameLength));
10574 }
10575 if(hRes == S_OK)
10576 {
10577 /* Was it originally Ole10 */
10578 hRes = IStorage_OpenStream(pstg, wstrStreamName, 0, STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &pStream);
10579 if(hRes == S_OK)
10580 {
10581 IStream_Release(pStream);
10582 /* Get Presentation Data for Ole10Native */
10583 OLECONVERT_GetOle10PresData(pstg, pOleStreamData);
10584 }
10585 else
10586 {
10587 /* Get Presentation Data (OLE20) */
10588 OLECONVERT_GetOle20PresData(pstg, pOleStreamData);
10589 }
10590
10591 /* Save OLESTREAM */
10592 hRes = OLECONVERT_SaveOLE10(&(pOleStreamData[0]), pOleStream);
10593 if(hRes == S_OK)
10594 {
10595 hRes = OLECONVERT_SaveOLE10(&(pOleStreamData[1]), pOleStream);
10596 }
10597
10598 }
10599
10600 /* Free allocated memory */
10601 for(i=0; i < 2; i++)
10602 {
10603 HeapFree(GetProcessHeap(),0,pOleStreamData[i].pData);
10604 }
10605
10606 return hRes;
10607}
static void OLECONVERT_GetOle10PresData(LPSTORAGE pStorage, OLECONVERT_OLESTREAM_DATA *pOleStreamData)
Definition: storage32.c:10324
static HRESULT OLECONVERT_SaveOLE10(OLECONVERT_OLESTREAM_DATA *pData, LPOLESTREAM pOleStream)
Definition: storage32.c:9808
static void OLECONVERT_GetOle20PresData(LPSTORAGE pStorage, OLECONVERT_OLESTREAM_DATA *pOleStreamData)
Definition: storage32.c:10377
static HRESULT OLECONVERT_GetOLE10ProgID(LPSTORAGE pStorage, char *strProgID, DWORD *dwSize)
Definition: storage32.c:10253

◆ OleConvertOLESTREAMToIStorage()

HRESULT WINAPI OleConvertOLESTREAMToIStorage ( LPOLESTREAM  pOleStream,
LPSTORAGE  pstg,
const DVTARGETDEVICE *  ptd 
)

Definition at line 10460 of file storage32.c.

10464{
10465 int i;
10466 HRESULT hRes=S_OK;
10467 OLECONVERT_OLESTREAM_DATA pOleStreamData[2];
10468
10469 TRACE("%p %p %p\n", pOleStream, pstg, ptd);
10470
10471 memset(pOleStreamData, 0, sizeof(pOleStreamData));
10472
10473 if(ptd != NULL)
10474 {
10475 FIXME("DVTARGETDEVICE is not NULL, unhandled parameter\n");
10476 }
10477
10478 if(pstg == NULL || pOleStream == NULL)
10479 {
10480 hRes = E_INVALIDARG;
10481 }
10482
10483 if(hRes == S_OK)
10484 {
10485 /* Load the OLESTREAM to Memory */
10486 hRes = OLECONVERT_LoadOLE10(pOleStream, &pOleStreamData[0], TRUE);
10487 }
10488
10489 if(hRes == S_OK)
10490 {
10491 /* Load the OLESTREAM to Memory (part 2)*/
10492 hRes = OLECONVERT_LoadOLE10(pOleStream, &pOleStreamData[1], FALSE);
10493 }
10494
10495 if(hRes == S_OK)
10496 {
10497
10498 if(pOleStreamData[0].dwDataLength > sizeof(STORAGE_magic))
10499 {
10500 /* Do we have the IStorage Data in the OLESTREAM */
10501 if(memcmp(pOleStreamData[0].pData, STORAGE_magic, sizeof(STORAGE_magic)) ==0)
10502 {
10503 OLECONVERT_GetOLE20FromOLE10(pstg, pOleStreamData[0].pData, pOleStreamData[0].dwDataLength);
10504 OLECONVERT_CreateOlePresStream(pstg, pOleStreamData[1].dwMetaFileWidth, pOleStreamData[1].dwMetaFileHeight, pOleStreamData[1].pData, pOleStreamData[1].dwDataLength);
10505 }
10506 else
10507 {
10508 /* It must be an original OLE 1.0 source */
10509 OLECONVERT_CreateOle10NativeStream(pstg, pOleStreamData[0].pData, pOleStreamData[0].dwDataLength);
10510 }
10511 }
10512 else
10513 {
10514 /* It must be an original OLE 1.0 source */
10515 OLECONVERT_CreateOle10NativeStream(pstg, pOleStreamData[0].pData, pOleStreamData[0].dwDataLength);
10516 }
10517
10518 /* Create CompObj Stream if necessary */
10519 hRes = OLECONVERT_CreateCompObjStream(pstg, pOleStreamData[0].strOleTypeName);
10520 if(hRes == S_OK)
10521 {
10522 /*Create the Ole Stream if necessary */
10523 STORAGE_CreateOleStream(pstg, 0);
10524 }
10525 }
10526
10527
10528 /* Free allocated memory */
10529 for(i=0; i < 2; i++)
10530 {
10531 HeapFree(GetProcessHeap(),0,pOleStreamData[i].pData);
10532 HeapFree(GetProcessHeap(),0,pOleStreamData[i].pstrOleObjFileName);
10533 pOleStreamData[i].pstrOleObjFileName = NULL;
10534 }
10535 return hRes;
10536}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
static void OLECONVERT_CreateOle10NativeStream(LPSTORAGE pStorage, const BYTE *pData, DWORD dwDataLength)
Definition: storage32.c:10214
HRESULT OLECONVERT_CreateCompObjStream(LPSTORAGE pStorage, LPCSTR strOleTypeName)
Definition: storage32.c:10028
static HRESULT OLECONVERT_LoadOLE10(LPOLESTREAM pOleStream, OLECONVERT_OLESTREAM_DATA *pData, BOOL bStrem1)
Definition: storage32.c:9640
static const BYTE STORAGE_magic[8]
Definition: storage32.c:61
static void OLECONVERT_GetOLE20FromOLE10(LPSTORAGE pDestStorage, const BYTE *pBuffer, DWORD nBufferLength)
Definition: storage32.c:9919
HRESULT STORAGE_CreateOleStream(IStorage *storage, DWORD flags)
Definition: storage32.c:9207
static void OLECONVERT_CreateOlePresStream(LPSTORAGE pStorage, DWORD dwExtentX, DWORD dwExtentY, BYTE *pData, DWORD dwDataLength)
Definition: storage32.c:10130

◆ OleLoadFromStream()

HRESULT WINAPI OleLoadFromStream ( IStream pStm,
REFIID  iidInterface,
void **  ppvObj 
)

Definition at line 9129 of file storage32.c.

9130{
9131 CLSID clsid;
9132 HRESULT res;
9133 LPPERSISTSTREAM xstm;
9134
9135 TRACE("(%p,%s,%p)\n",pStm,debugstr_guid(iidInterface),ppvObj);
9136
9137 res=ReadClassStm(pStm,&clsid);
9138 if (FAILED(res))
9139 return res;
9140 res=CoCreateInstance(&clsid,NULL,CLSCTX_INPROC_SERVER,iidInterface,ppvObj);
9141 if (FAILED(res))
9142 return res;
9143 res=IUnknown_QueryInterface((IUnknown*)*ppvObj,&IID_IPersistStream,(LPVOID*)&xstm);
9144 if (FAILED(res)) {
9145 IUnknown_Release((IUnknown*)*ppvObj);
9146 return res;
9147 }
9148 res=IPersistStream_Load(xstm,pStm);
9149 IPersistStream_Release(xstm);
9150 /* FIXME: all refcounts ok at this point? I think they should be:
9151 * pStm : unchanged
9152 * ppvObj : 1
9153 * xstm : 0 (released)
9154 */
9155 return res;
9156}
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
HRESULT WINAPI ReadClassStm(IStream *pStm, CLSID *pclsid)
Definition: storage32.c:9548
GLuint res
Definition: glext.h:9613
interface IPersistStream * LPPERSISTSTREAM
Definition: objfwd.h:16
const GUID IID_IPersistStream
Definition: proxy.cpp:13

Referenced by CompositeMonikerImpl_Load(), HlinkClone(), IPersistStream_fnLoad(), and CTrayBandSite::OnLoad().

◆ OleSaveToStream()

HRESULT WINAPI OleSaveToStream ( IPersistStream pPStm,
IStream pStm 
)

Definition at line 9164 of file storage32.c.

9165{
9166
9167 CLSID clsid;
9168 HRESULT res;
9169
9170 TRACE("(%p,%p)\n",pPStm,pStm);
9171
9172 res=IPersistStream_GetClassID(pPStm,&clsid);
9173
9174 if (SUCCEEDED(res)){
9175
9176 res=WriteClassStm(pStm,&clsid);
9177
9178 if (SUCCEEDED(res))
9179
9180 res=IPersistStream_Save(pPStm,pStm,TRUE);
9181 }
9182
9183 TRACE("Finished Save\n");
9184 return res;
9185}

Referenced by CompositeMonikerImpl_Save(), HlinkClone(), and IPersistStream_fnSave().

◆ ReadClassStg()

HRESULT WINAPI ReadClassStg ( IStorage pstg,
CLSID pclsid 
)

Definition at line 9103 of file storage32.c.

9103 {
9104
9105 STATSTG pstatstg;
9106 HRESULT hRes;
9107
9108 TRACE("(%p, %p)\n", pstg, pclsid);
9109
9110 if(!pstg || !pclsid)
9111 return E_INVALIDARG;
9112
9113 /*
9114 * read a STATSTG structure (contains the clsid) from the storage
9115 */
9116 hRes=IStorage_Stat(pstg,&pstatstg,STATFLAG_NONAME);
9117
9118 if(SUCCEEDED(hRes))
9119 *pclsid=pstatstg.clsid;
9120
9121 return hRes;
9122}

Referenced by DataCache_InitNew(), DataCache_Load(), GetClassFile(), render_embed_source_hack(), and test_writeclassstg().

◆ ReadClassStm()

HRESULT WINAPI ReadClassStm ( IStream pStm,
CLSID pclsid 
)

Definition at line 9548 of file storage32.c.

9549{
9550 ULONG nbByte;
9551 HRESULT res;
9552
9553 TRACE("(%p,%p)\n",pStm,pclsid);
9554
9555 if (!pStm || !pclsid)
9556 return E_INVALIDARG;
9557
9558 /* clear the output args */
9559 *pclsid = CLSID_NULL;
9560
9561 res = IStream_Read(pStm, pclsid, sizeof(CLSID), &nbByte);
9562
9563 if (FAILED(res))
9564 return res;
9565
9566 if (nbByte != sizeof(CLSID))
9567 return STG_E_READFAULT;
9568 else
9569 return S_OK;
9570}
#define CLSID_NULL
Definition: guiddef.h:99

Referenced by OleLoadFromStream(), ReadFmtUserTypeStg(), and test_ReadClassStm().

◆ ReadFmtUserTypeStg()

HRESULT WINAPI ReadFmtUserTypeStg ( LPSTORAGE  pstg,
CLIPFORMAT *  pcf,
LPOLESTR lplpszUserType 
)

Definition at line 9399 of file storage32.c.

9400{
9401 HRESULT r;
9402 IStream *stm = 0;
9403 static const WCHAR szCompObj[] = { 1, 'C','o','m','p','O','b','j', 0 };
9404 unsigned char unknown1[12];
9405 unsigned char unknown2[16];
9406 DWORD count;
9407 LPWSTR szProgIDName = NULL, szCLSIDName = NULL, szOleTypeName = NULL;
9408 CLSID clsid;
9409
9410 TRACE("(%p,%p,%p)\n", pstg, pcf, lplpszUserType);
9411
9412 r = IStorage_OpenStream( pstg, szCompObj, NULL,
9413 STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &stm );
9414 if( FAILED ( r ) )
9415 {
9416 WARN("Failed to open stream r = %08x\n", r);
9417 return r;
9418 }
9419
9420 /* read the various parts of the structure */
9421 r = IStream_Read( stm, unknown1, sizeof(unknown1), &count );
9422 if( FAILED( r ) || ( count != sizeof(unknown1) ) )
9423 goto end;
9424 r = ReadClassStm( stm, &clsid );
9425 if( FAILED( r ) )
9426 goto end;
9427
9428 r = STREAM_ReadString( stm, &szCLSIDName );
9429 if( FAILED( r ) )
9430 goto end;
9431
9432 r = STREAM_ReadString( stm, &szOleTypeName );
9433 if( FAILED( r ) )
9434 goto end;
9435
9436 r = STREAM_ReadString( stm, &szProgIDName );
9437 if( FAILED( r ) )
9438 goto end;
9439
9440 r = IStream_Read( stm, unknown2, sizeof(unknown2), &count );
9441 if( FAILED( r ) || ( count != sizeof(unknown2) ) )
9442 goto end;
9443
9444 /* ok, success... now we just need to store what we found */
9445 if( pcf )
9446 *pcf = RegisterClipboardFormatW( szOleTypeName );
9447
9448 if( lplpszUserType )
9449 {
9450 *lplpszUserType = szCLSIDName;
9451 szCLSIDName = NULL;
9452 }
9453
9454end:
9455 CoTaskMemFree( szCLSIDName );
9456 CoTaskMemFree( szOleTypeName );
9457 CoTaskMemFree( szProgIDName );
9458 IStream_Release( stm );
9459
9460 return r;
9461}
#define WARN(fmt,...)
Definition: precomp.h:61
static HRESULT STREAM_ReadString(IStream *stm, LPWSTR *string)
Definition: storage32.c:9261
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
UINT WINAPI RegisterClipboardFormatW(_In_ LPCWSTR)
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by OleDoAutoConvert().

◆ removeFromTree()

static HRESULT removeFromTree ( StorageBaseImpl This,
DirRef  parentStorageIndex,
DirRef  deletedIndex 
)
static

Definition at line 771 of file storage32.c.

775{
776 DirEntry entryToDelete;
777 DirEntry parentEntry;
778 DirRef parentEntryRef;
779 ULONG typeOfRelation;
780 HRESULT hr;
781
782 hr = StorageBaseImpl_ReadDirEntry(This, deletedIndex, &entryToDelete);
783
784 if (hr != S_OK)
785 return hr;
786
787 /*
788 * Find the element that links to the one we want to delete.
789 */
790 hr = findTreeParent(This, parentStorageIndex, entryToDelete.name,
791 &parentEntry, &parentEntryRef, &typeOfRelation);
792
793 if (hr != S_OK)
794 return hr;
795
796 if (entryToDelete.leftChild != DIRENTRY_NULL)
797 {
798 /*
799 * Replace the deleted entry with its left child
800 */
801 setEntryLink(&parentEntry, typeOfRelation, entryToDelete.leftChild);
802
804 This,
805 parentEntryRef,
806 &parentEntry);
807 if(FAILED(hr))
808 {
809 return hr;
810 }
811
812 if (entryToDelete.rightChild != DIRENTRY_NULL)
813 {
814 /*
815 * We need to reinsert the right child somewhere. We already know it and
816 * its children are greater than everything in the left tree, so we
817 * insert it at the rightmost point in the left tree.
818 */
819 DirRef newRightChildParent = entryToDelete.leftChild;
820 DirEntry newRightChildParentEntry;
821
822 do
823 {
825 This,
826 newRightChildParent,
827 &newRightChildParentEntry);
828 if (FAILED(hr))
829 {
830 return hr;
831 }
832
833 if (newRightChildParentEntry.rightChild != DIRENTRY_NULL)
834 newRightChildParent = newRightChildParentEntry.rightChild;
835 } while (newRightChildParentEntry.rightChild != DIRENTRY_NULL);
836
837 newRightChildParentEntry.rightChild = entryToDelete.rightChild;
838
840 This,
841 newRightChildParent,
842 &newRightChildParentEntry);
843 if (FAILED(hr))
844 {
845 return hr;
846 }
847 }
848 }
849 else
850 {
851 /*
852 * Replace the deleted entry with its right child
853 */
854 setEntryLink(&parentEntry, typeOfRelation, entryToDelete.rightChild);
855
857 This,
858 parentEntryRef,
859 &parentEntry);
860 if(FAILED(hr))
861 {
862 return hr;
863 }
864 }
865
866 return hr;
867}
static void setEntryLink(DirEntry *entry, ULONG relation, DirRef new_target)
Definition: storage32.c:626
static HRESULT findTreeParent(StorageBaseImpl *storage, DirRef storageEntry, const OLECHAR *childName, DirEntry *parentData, DirRef *parentEntry, ULONG *relation)
Definition: storage32.c:574

Referenced by StorageBaseImpl_DestroyElement(), and StorageBaseImpl_RenameElement().

◆ SetConvertStg()

HRESULT WINAPI SetConvertStg ( IStorage storage,
BOOL  convert 
)

Definition at line 10648 of file storage32.c.

10649{
10650 static const WCHAR stream_1oleW[] = {1,'O','l','e',0};
10652 IStream *stream;
10653 DWORD header[2];
10654 HRESULT hr;
10655
10656 TRACE("(%p, %d)\n", storage, convert);
10657
10658 hr = IStorage_OpenStream(storage, stream_1oleW, NULL, STGM_READWRITE | STGM_SHARE_EXCLUSIVE, 0, &stream);
10659 if (FAILED(hr))
10660 {
10661 if (hr != STG_E_FILENOTFOUND)
10662 return hr;
10663
10665 }
10666
10667 hr = IStream_Read(stream, header, sizeof(header), NULL);
10668 if (FAILED(hr))
10669 {
10670 IStream_Release(stream);
10671 return hr;
10672 }
10673
10674 /* update flag if differs */
10675 if ((header[1] ^ flags) & OleStream_Convert)
10676 {
10677 LARGE_INTEGER pos = {{0}};
10678
10679 if (header[1] & OleStream_Convert)
10680 flags = header[1] & ~OleStream_Convert;
10681 else
10683
10684 pos.QuadPart = sizeof(DWORD);
10685 hr = IStream_Seek(stream, pos, STREAM_SEEK_SET, NULL);
10686 if (FAILED(hr))
10687 {
10688 IStream_Release(stream);
10689 return hr;
10690 }
10691
10692 hr = IStream_Write(stream, &flags, sizeof(flags), NULL);
10693 }
10694
10695 IStream_Release(stream);
10696 return hr;
10697}
GLbitfield flags
Definition: glext.h:7161
int convert
Definition: msacm.c:1374
#define DWORD
Definition: nt_native.h:44

Referenced by OleDoAutoConvert(), test_convert(), and test_OleDoAutoConvert().

◆ setEntryLink()

static void setEntryLink ( DirEntry entry,
ULONG  relation,
DirRef  new_target 
)
static

Definition at line 626 of file storage32.c.

627{
628 switch (relation)
629 {
631 entry->leftChild = new_target;
632 break;
634 entry->rightChild = new_target;
635 break;
637 entry->dirRootEntry = new_target;
638 break;
639 default:
640 assert(0);
641 }
642}

Referenced by removeFromTree().

◆ SmallBlockChainStream_Construct()

SmallBlockChainStream * SmallBlockChainStream_Construct ( StorageImpl parentStorage,
ULONG headOfStreamPlaceHolder,
DirRef  dirEntry 
)
static

Definition at line 7785 of file storage32.c.

7789{
7790 SmallBlockChainStream* newStream;
7791
7792 newStream = HeapAlloc(GetProcessHeap(), 0, sizeof(SmallBlockChainStream));
7793
7794 newStream->parentStorage = parentStorage;
7795 newStream->headOfStreamPlaceHolder = headOfStreamPlaceHolder;
7796 newStream->ownerDirEntry = dirEntry;
7797
7798 return newStream;
7799}
ULONG * headOfStreamPlaceHolder
Definition: storage32.c:243
StorageImpl * parentStorage
Definition: storage32.c:241

Referenced by Storage32Impl_BigBlocksToSmallBlocks(), StorageImpl_StreamReadAt(), StorageImpl_StreamSetSize(), and StorageImpl_StreamWriteAt().

◆ SmallBlockChainStream_Destroy()

◆ SmallBlockChainStream_Enlarge()

static BOOL SmallBlockChainStream_Enlarge ( SmallBlockChainStream This,
ULARGE_INTEGER  newSize 
)
static

Definition at line 8315 of file storage32.c.

8318{
8319 ULONG blockIndex, currentBlock;
8320 ULONG newNumBlocks;
8321 ULONG oldNumBlocks = 0;
8322
8324
8325 /*
8326 * Empty chain. Create the head.
8327 */
8328 if (blockIndex == BLOCK_END_OF_CHAIN)
8329 {
8332 This,
8333 blockIndex,
8335
8336 if (This->headOfStreamPlaceHolder != NULL)
8337 {
8338 *(This->headOfStreamPlaceHolder) = blockIndex;
8339 }
8340 else
8341 {
8342 DirEntry chainEntry;
8343
8344 StorageImpl_ReadDirEntry(This->parentStorage, This->ownerDirEntry,
8345 &chainEntry);
8346
8347 chainEntry.startingBlock = blockIndex;
8348
8349 StorageImpl_WriteDirEntry(This->parentStorage, This->ownerDirEntry,
8350 &chainEntry);
8351 }
8352 }
8353
8354 currentBlock = blockIndex;
8355
8356 /*
8357 * Figure out how many blocks are needed to contain this stream
8358 */
8359 newNumBlocks = newSize.u.LowPart / This->parentStorage->smallBlockSize;
8360
8361 if ((newSize.u.LowPart % This->parentStorage->smallBlockSize) != 0)
8362 newNumBlocks++;
8363
8364 /*
8365 * Go to the current end of chain
8366 */
8367 while (blockIndex != BLOCK_END_OF_CHAIN)
8368 {
8369 oldNumBlocks++;
8370 currentBlock = blockIndex;
8371 if(FAILED(SmallBlockChainStream_GetNextBlockInChain(This, currentBlock, &blockIndex)))
8372 return FALSE;
8373 }
8374
8375 /*
8376 * Add new blocks to the chain
8377 */
8378 while (oldNumBlocks < newNumBlocks)
8379 {
8381 SmallBlockChainStream_SetNextBlockInChain(This, currentBlock, blockIndex);
8382
8384 This,
8385 blockIndex,
8387
8388 currentBlock = blockIndex;
8389 oldNumBlocks++;
8390 }
8391
8392 return TRUE;
8393}
static HRESULT SmallBlockChainStream_GetNextBlockInChain(SmallBlockChainStream *This, ULONG blockIndex, ULONG *nextBlockInChain)
Definition: storage32.c:7844
static ULONG SmallBlockChainStream_GetNextFreeBlock(SmallBlockChainStream *This)
Definition: storage32.c:7931
static void SmallBlockChainStream_SetNextBlockInChain(SmallBlockChainStream *This, ULONG blockIndex, ULONG nextBlock)
Definition: storage32.c:7888
static ULONG SmallBlockChainStream_GetHeadOfChain(SmallBlockChainStream *This)
Definition: storage32.c:7812
struct _ULARGE_INTEGER::@4136 u

Referenced by SmallBlockChainStream_SetSize().

◆ SmallBlockChainStream_FreeBlock()

static void SmallBlockChainStream_FreeBlock ( SmallBlockChainStream This,
ULONG  blockIndex 
)
static

Definition at line 7917 of file storage32.c.

7920{
7922}
static const ULONG BLOCK_UNUSED
Definition: storage32.h:85

Referenced by SmallBlockChainStream_Shrink().

◆ SmallBlockChainStream_GetCount()

static ULONG SmallBlockChainStream_GetCount ( SmallBlockChainStream This)
static

Definition at line 8433 of file storage32.c.

8434{
8435 ULONG blockIndex;
8436 ULONG count = 0;
8437
8439
8440 while(blockIndex != BLOCK_END_OF_CHAIN)
8441 {
8442 count++;
8443
8445 blockIndex, &blockIndex)))
8446 return 0;
8447 }
8448
8449 return count;
8450}

Referenced by SmallBlockChainStream_GetSize().

◆ SmallBlockChainStream_GetHeadOfChain()

static ULONG SmallBlockChainStream_GetHeadOfChain ( SmallBlockChainStream This)
static

Definition at line 7812 of file storage32.c.

7814{
7815 DirEntry chainEntry;
7816 HRESULT hr;
7817
7818 if (This->headOfStreamPlaceHolder != NULL)
7819 return *(This->headOfStreamPlaceHolder);
7820
7821 if (This->ownerDirEntry)
7822 {
7824 This->parentStorage,
7825 This->ownerDirEntry,
7826 &chainEntry);
7827
7828 if (SUCCEEDED(hr) && chainEntry.startingBlock < BLOCK_FIRST_SPECIAL)
7829 return chainEntry.startingBlock;
7830 }
7831
7832 return BLOCK_END_OF_CHAIN;
7833}

Referenced by SmallBlockChainStream_Enlarge(), SmallBlockChainStream_GetCount(), SmallBlockChainStream_ReadAt(), SmallBlockChainStream_Shrink(), and SmallBlockChainStream_WriteAt().

◆ SmallBlockChainStream_GetNextBlockInChain()

static HRESULT SmallBlockChainStream_GetNextBlockInChain ( SmallBlockChainStream This,
ULONG  blockIndex,
ULONG nextBlockInChain 
)
static

Definition at line 7844 of file storage32.c.

7848{
7849 ULARGE_INTEGER offsetOfBlockInDepot;
7850 DWORD buffer;
7851 ULONG bytesRead;
7852 HRESULT res;
7853
7854 *nextBlockInChain = BLOCK_END_OF_CHAIN;
7855
7856 offsetOfBlockInDepot.QuadPart = (ULONGLONG)blockIndex * sizeof(ULONG);
7857
7858 /*
7859 * Read those bytes in the buffer from the small block file.
7860 */
7862 This->parentStorage->smallBlockDepotChain,
7863 offsetOfBlockInDepot,
7864 sizeof(DWORD),
7865 &buffer,
7866 &bytesRead);
7867
7868 if (SUCCEEDED(res) && bytesRead != sizeof(DWORD))
7870
7871 if (SUCCEEDED(res))
7872 {
7873 StorageUtl_ReadDWord((BYTE *)&buffer, 0, nextBlockInChain);
7874 return S_OK;
7875 }
7876
7877 return res;
7878}
static HRESULT BlockChainStream_ReadAt(BlockChainStream *, ULARGE_INTEGER, ULONG, void *, ULONG *)
Definition: storage32.c:7605
void StorageUtl_ReadDWord(const BYTE *buffer, ULONG offset, DWORD *value)
Definition: storage32.c:6957

Referenced by SmallBlockChainStream_Enlarge(), SmallBlockChainStream_GetCount(), SmallBlockChainStream_ReadAt(), SmallBlockChainStream_Shrink(), and SmallBlockChainStream_WriteAt().

◆ SmallBlockChainStream_GetNextFreeBlock()

static ULONG SmallBlockChainStream_GetNextFreeBlock ( SmallBlockChainStream This)
static

Definition at line 7931 of file storage32.c.

7933{
7934 ULARGE_INTEGER offsetOfBlockInDepot;
7935 DWORD buffer;
7936 ULONG bytesRead;
7937 ULONG blockIndex = This->parentStorage->firstFreeSmallBlock;
7938 ULONG nextBlockIndex = BLOCK_END_OF_CHAIN;
7939 HRESULT res = S_OK;
7940 ULONG smallBlocksPerBigBlock;
7941 DirEntry rootEntry;
7942 ULONG blocksRequired;
7943 ULARGE_INTEGER old_size, size_required;
7944
7945 offsetOfBlockInDepot.u.HighPart = 0;
7946
7947 /*
7948 * Scan the small block depot for a free block
7949 */
7950 while (nextBlockIndex != BLOCK_UNUSED)
7951 {
7952 offsetOfBlockInDepot.QuadPart = (ULONGLONG)blockIndex * sizeof(ULONG);
7953
7955 This->parentStorage->smallBlockDepotChain,
7956 offsetOfBlockInDepot,
7957 sizeof(DWORD),
7958 &buffer,
7959 &bytesRead);
7960
7961 /*
7962 * If we run out of space for the small block depot, enlarge it
7963 */
7964 if (SUCCEEDED(res) && bytesRead == sizeof(DWORD))
7965 {
7966 StorageUtl_ReadDWord((BYTE *)&buffer, 0, &nextBlockIndex);
7967
7968 if (nextBlockIndex != BLOCK_UNUSED)
7969 blockIndex++;
7970 }
7971 else
7972 {
7973 ULONG count =
7974 BlockChainStream_GetCount(This->parentStorage->smallBlockDepotChain);
7975
7976 BYTE smallBlockDepot[MAX_BIG_BLOCK_SIZE];
7977 ULARGE_INTEGER newSize, offset;
7979
7980 newSize.QuadPart = (ULONGLONG)(count + 1) * This->parentStorage->bigBlockSize;
7981 BlockChainStream_Enlarge(This->parentStorage->smallBlockDepotChain, newSize);
7982
7983 /*
7984 * Initialize all the small blocks to free
7985 */
7986 memset(smallBlockDepot, BLOCK_UNUSED, This->parentStorage->bigBlockSize);
7987 offset.QuadPart = (ULONGLONG)count * This->parentStorage->bigBlockSize;
7988 BlockChainStream_WriteAt(This->parentStorage->smallBlockDepotChain,
7989 offset, This->parentStorage->bigBlockSize, smallBlockDepot, &bytesWritten);
7990
7991 StorageImpl_SaveFileHeader(This->parentStorage);
7992 }
7993 }
7994
7995 This->parentStorage->firstFreeSmallBlock = blockIndex+1;
7996
7997 smallBlocksPerBigBlock =
7998 This->parentStorage->bigBlockSize / This->parentStorage->smallBlockSize;
7999
8000 /*
8001 * Verify if we have to allocate big blocks to contain small blocks
8002 */
8003 blocksRequired = (blockIndex / smallBlocksPerBigBlock) + 1;
8004
8005 size_required.QuadPart = (ULONGLONG)blocksRequired * This->parentStorage->bigBlockSize;
8006
8007 old_size = BlockChainStream_GetSize(This->parentStorage->smallBlockRootChain);
8008
8009 if (size_required.QuadPart > old_size.QuadPart)
8010 {
8012 This->parentStorage->smallBlockRootChain,
8013 size_required);
8014
8016 This->parentStorage,
8017 This->parentStorage->base.storageDirEntry,
8018 &rootEntry);
8019
8020 rootEntry.size = size_required;
8021
8023 This->parentStorage,
8024 This->parentStorage->base.storageDirEntry,
8025 &rootEntry);
8026 }
8027
8028 return blockIndex;
8029}
static BOOL BlockChainStream_SetSize(BlockChainStream *, ULARGE_INTEGER)
Definition: storage32.c:7577
static void StorageImpl_SaveFileHeader(StorageImpl *This)
Definition: storage32.c:3014
static HRESULT BlockChainStream_WriteAt(BlockChainStream *, ULARGE_INTEGER, ULONG, const void *, ULONG *)
Definition: storage32.c:7702

Referenced by SmallBlockChainStream_Enlarge().

◆ SmallBlockChainStream_GetSize()

static ULARGE_INTEGER SmallBlockChainStream_GetSize ( SmallBlockChainStream This)
static

Definition at line 8457 of file storage32.c.

8458{
8459 DirEntry chainEntry;
8460
8461 if(This->headOfStreamPlaceHolder != NULL)
8462 {
8464 result.u.HighPart = 0;
8465
8467 This->parentStorage->smallBlockSize;
8468
8469 return result;
8470 }
8471
8473 This->parentStorage,
8474 This->ownerDirEntry,
8475 &chainEntry);
8476
8477 return chainEntry.size;
8478}
static ULONG SmallBlockChainStream_GetCount(SmallBlockChainStream *This)
Definition: storage32.c:8433

Referenced by SmallBlockChainStream_ReadAt(), SmallBlockChainStream_SetSize(), and Storage32Impl_SmallBlocksToBigBlocks().

◆ SmallBlockChainStream_ReadAt()

HRESULT SmallBlockChainStream_ReadAt ( SmallBlockChainStream This,
ULARGE_INTEGER  offset,
ULONG  size,
void buffer,
ULONG bytesRead 
)
static

Definition at line 8038 of file storage32.c.

8044{
8045 HRESULT rc = S_OK;
8046 ULARGE_INTEGER offsetInBigBlockFile;
8047 ULONG blockNoInSequence =
8048 offset.u.LowPart / This->parentStorage->smallBlockSize;
8049
8050 ULONG offsetInBlock = offset.u.LowPart % This->parentStorage->smallBlockSize;
8051 ULONG bytesToReadInBuffer;
8052 ULONG blockIndex;
8053 ULONG bytesReadFromBigBlockFile;
8054 BYTE* bufferWalker;
8056
8057 /*
8058 * This should never happen on a small block file.
8059 */
8060 assert(offset.u.HighPart==0);
8061
8062 *bytesRead = 0;
8063
8065 if (stream_size.QuadPart > offset.QuadPart)
8066 size = min(stream_size.QuadPart - offset.QuadPart, size);
8067 else
8068 return S_OK;
8069
8070 /*
8071 * Find the first block in the stream that contains part of the buffer.
8072 */
8074
8075 while ( (blockNoInSequence > 0) && (blockIndex != BLOCK_END_OF_CHAIN))
8076 {
8077 rc = SmallBlockChainStream_GetNextBlockInChain(This, blockIndex, &blockIndex);
8078 if(FAILED(rc))
8079 return rc;
8080 blockNoInSequence--;
8081 }
8082
8083 /*
8084 * Start reading the buffer.
8085 */
8086 bufferWalker = buffer;
8087
8088 while ( (size > 0) && (blockIndex != BLOCK_END_OF_CHAIN) )
8089 {
8090 /*
8091 * Calculate how many bytes we can copy from this small block.
8092 */
8093 bytesToReadInBuffer =
8094 min(This->parentStorage->smallBlockSize - offsetInBlock, size);
8095
8096 /*
8097 * Calculate the offset of the small block in the small block file.
8098 */
8099 offsetInBigBlockFile.QuadPart =
8100 (ULONGLONG)blockIndex * This->parentStorage->smallBlockSize;
8101
8102 offsetInBigBlockFile.QuadPart += offsetInBlock;
8103
8104 /*
8105 * Read those bytes in the buffer from the small block file.
8106 * The small block has already been identified so it shouldn't fail
8107 * unless the file is corrupt.
8108 */
8109 rc = BlockChainStream_ReadAt(This->parentStorage->smallBlockRootChain,
8110 offsetInBigBlockFile,
8111 bytesToReadInBuffer,
8112 bufferWalker,
8113 &bytesReadFromBigBlockFile);
8114
8115 if (FAILED(rc))
8116 return rc;
8117
8118 if (!bytesReadFromBigBlockFile)
8119 return STG_E_DOCFILECORRUPT;
8120
8121 /*
8122 * Step to the next big block.
8123 */
8124 rc = SmallBlockChainStream_GetNextBlockInChain(This, blockIndex, &blockIndex);
8125 if(FAILED(rc))
8126 return STG_E_DOCFILECORRUPT;
8127
8128 bufferWalker += bytesReadFromBigBlockFile;
8129 size -= bytesReadFromBigBlockFile;
8130 *bytesRead += bytesReadFromBigBlockFile;
8131 offsetInBlock = (offsetInBlock + bytesReadFromBigBlockFile) % This->parentStorage->smallBlockSize;
8132 }
8133
8134 return S_OK;
8135}
static ULARGE_INTEGER SmallBlockChainStream_GetSize(SmallBlockChainStream *)
Definition: storage32.c:8457

Referenced by Storage32Impl_SmallBlocksToBigBlocks(), and StorageImpl_StreamReadAt().

◆ SmallBlockChainStream_SetNextBlockInChain()

static void SmallBlockChainStream_SetNextBlockInChain ( SmallBlockChainStream This,
ULONG  blockIndex,
ULONG  nextBlock 
)
static

Definition at line 7888 of file storage32.c.

7892{
7893 ULARGE_INTEGER offsetOfBlockInDepot;
7894 DWORD buffer;
7896
7897 offsetOfBlockInDepot.QuadPart = (ULONGLONG)blockIndex * sizeof(ULONG);
7898
7899 StorageUtl_WriteDWord((BYTE *)&buffer, 0, nextBlock);
7900
7901 /*
7902 * Read those bytes in the buffer from the small block file.
7903 */
7905 This->parentStorage->smallBlockDepotChain,
7906 offsetOfBlockInDepot,
7907 sizeof(DWORD),
7908 &buffer,
7909 &bytesWritten);
7910}
void StorageUtl_WriteDWord(BYTE *buffer, ULONG offset, DWORD value)
Definition: storage32.c:6965

Referenced by SmallBlockChainStream_Enlarge(), SmallBlockChainStream_FreeBlock(), and SmallBlockChainStream_Shrink().

◆ SmallBlockChainStream_SetSize()

BOOL SmallBlockChainStream_SetSize ( SmallBlockChainStream This,
ULARGE_INTEGER  newSize 
)
static

Definition at line 8405 of file storage32.c.

8408{
8410
8411 if (newSize.u.LowPart == size.u.LowPart)
8412 return TRUE;
8413
8414 if (newSize.u.LowPart < size.u.LowPart)
8415 {
8417 }
8418 else
8419 {
8421 }
8422
8423 return TRUE;
8424}
static BOOL SmallBlockChainStream_Enlarge(SmallBlockChainStream *This, ULARGE_INTEGER newSize)
Definition: storage32.c:8315
static BOOL SmallBlockChainStream_Shrink(SmallBlockChainStream *This, ULARGE_INTEGER newSize)
Definition: storage32.c:8231

Referenced by Storage32Impl_BigBlocksToSmallBlocks(), Storage32Impl_SmallBlocksToBigBlocks(), and StorageImpl_StreamSetSize().

◆ SmallBlockChainStream_Shrink()

static BOOL SmallBlockChainStream_Shrink ( SmallBlockChainStream This,
ULARGE_INTEGER  newSize 
)
static

Definition at line 8231 of file storage32.c.

8234{
8235 ULONG blockIndex, extraBlock;
8236 ULONG numBlocks;
8237 ULONG count = 0;
8238
8239 numBlocks = newSize.u.LowPart / This->parentStorage->smallBlockSize;
8240
8241 if ((newSize.u.LowPart % This->parentStorage->smallBlockSize) != 0)
8242 numBlocks++;
8243
8245
8246 /*
8247 * Go to the new end of chain
8248 */
8249 while (count < numBlocks)
8250 {
8252 &blockIndex)))
8253 return FALSE;
8254 count++;
8255 }
8256
8257 /*
8258 * If the count is 0, we have a special case, the head of the chain was
8259 * just freed.
8260 */
8261 if (count == 0)
8262 {
8263 DirEntry chainEntry;
8264
8265 StorageImpl_ReadDirEntry(This->parentStorage,
8266 This->ownerDirEntry,
8267 &chainEntry);
8268
8269 chainEntry.startingBlock = BLOCK_END_OF_CHAIN;
8270
8271 StorageImpl_WriteDirEntry(This->parentStorage,
8272 This->ownerDirEntry,
8273 &chainEntry);
8274
8275 /*
8276 * We start freeing the chain at the head block.
8277 */
8278 extraBlock = blockIndex;
8279 }
8280 else
8281 {
8282 /* Get the next block before marking the new end */
8284 &extraBlock)))
8285 return FALSE;
8286
8287 /* Mark the new end of chain */
8289 This,
8290 blockIndex,
8292 }
8293
8294 /*
8295 * Mark the extra blocks as free
8296 */
8297 while (extraBlock != BLOCK_END_OF_CHAIN)
8298 {
8300 &blockIndex)))
8301 return FALSE;
8303 This->parentStorage->firstFreeSmallBlock = min(This->parentStorage->firstFreeSmallBlock, extraBlock);
8304 extraBlock = blockIndex;
8305 }
8306
8307 return TRUE;
8308}
static void SmallBlockChainStream_FreeBlock(SmallBlockChainStream *This, ULONG blockIndex)
Definition: storage32.c:7917

Referenced by SmallBlockChainStream_SetSize().

◆ SmallBlockChainStream_WriteAt()

HRESULT SmallBlockChainStream_WriteAt ( SmallBlockChainStream This,
ULARGE_INTEGER  offset,
ULONG  size,
const void buffer,
ULONG bytesWritten 
)
static

Definition at line 8143 of file storage32.c.

8149{
8150 ULARGE_INTEGER offsetInBigBlockFile;
8151 ULONG blockNoInSequence =
8152 offset.u.LowPart / This->parentStorage->smallBlockSize;
8153
8154 ULONG offsetInBlock = offset.u.LowPart % This->parentStorage->smallBlockSize;
8155 ULONG bytesToWriteInBuffer;
8156 ULONG blockIndex;
8157 ULONG bytesWrittenToBigBlockFile;
8158 const BYTE* bufferWalker;
8159 HRESULT res;
8160
8161 /*
8162 * This should never happen on a small block file.
8163 */
8164 assert(offset.u.HighPart==0);
8165
8166 /*
8167 * Find the first block in the stream that contains part of the buffer.
8168 */
8170
8171 while ( (blockNoInSequence > 0) && (blockIndex != BLOCK_END_OF_CHAIN))
8172 {
8173 if(FAILED(SmallBlockChainStream_GetNextBlockInChain(This, blockIndex, &blockIndex)))
8174 return STG_E_DOCFILECORRUPT;
8175 blockNoInSequence--;
8176 }
8177
8178 /*
8179 * Start writing the buffer.
8180 */
8181 *bytesWritten = 0;
8182 bufferWalker = buffer;
8183 while ( (size > 0) && (blockIndex != BLOCK_END_OF_CHAIN) )
8184 {
8185 /*
8186 * Calculate how many bytes we can copy to this small block.
8187 */
8188 bytesToWriteInBuffer =
8189 min(This->parentStorage->smallBlockSize - offsetInBlock, size);
8190
8191 /*
8192 * Calculate the offset of the small block in the small block file.
8193 */
8194 offsetInBigBlockFile.QuadPart =
8195 (ULONGLONG)blockIndex * This->parentStorage->smallBlockSize;
8196
8197 offsetInBigBlockFile.QuadPart += offsetInBlock;
8198
8199 /*
8200 * Write those bytes in the buffer to the small block file.
8201 */
8203 This->parentStorage->smallBlockRootChain,
8204 offsetInBigBlockFile,
8205 bytesToWriteInBuffer,
8206 bufferWalker,
8207 &bytesWrittenToBigBlockFile);
8208 if (FAILED(res))
8209 return res;
8210
8211 /*
8212 * Step to the next big block.
8213 */
8214 res = SmallBlockChainStream_GetNextBlockInChain(This, blockIndex, &blockIndex);
8215 if (FAILED(res))
8216 return res;
8217 bufferWalker += bytesWrittenToBigBlockFile;
8218 size -= bytesWrittenToBigBlockFile;
8219 *bytesWritten += bytesWrittenToBigBlockFile;
8220 offsetInBlock = (offsetInBlock + bytesWrittenToBigBlockFile) % This->parentStorage->smallBlockSize;
8221 }
8222
8223 return (size == 0) ? S_OK : STG_E_WRITEFAULT;
8224}

Referenced by Storage32Impl_BigBlocksToSmallBlocks(), and StorageImpl_StreamWriteAt().

◆ StgCreateDocfile()

HRESULT WINAPI StgCreateDocfile ( LPCOLESTR  pwcsName,
DWORD  grfMode,
DWORD  reserved,
IStorage **  ppstgOpen 
)

Definition at line 8636 of file storage32.c.

8641{
8642 STGOPTIONS stgoptions = {1, 0, 512};
8643
8644 TRACE("(%s, %x, %d, %p)\n",
8645 debugstr_w(pwcsName), grfMode,
8646 reserved, ppstgOpen);
8647
8648 if (ppstgOpen == 0)
8649 return STG_E_INVALIDPOINTER;
8650 if (reserved != 0)
8652
8653 return create_storagefile(pwcsName, grfMode, 0, &stgoptions, &IID_IStorage, (void**)ppstgOpen);
8654}
static HRESULT create_storagefile(LPCOLESTR pwcsName, DWORD grfMode, DWORD grfAttrs, STGOPTIONS *pStgOptions, REFIID riid, void **ppstgOpen)
Definition: storage32.c:8485
r reserved
Definition: btrfs.c:3006
#define debugstr_w
Definition: kernel32.h:32

Referenced by create_patch(), create_storage(), create_storage_from_def(), generate_transform_manual(), MSI_OpenDatabaseW(), OLECONVERT_WriteOLE20ToBuffer(), setup_richedit_olecallback(), START_TEST(), test_access(), test_convert(), test_copyto(), test_copyto_iidexclusions_storage(), test_copyto_iidexclusions_stream(), test_copyto_locking(), test_copyto_recursive(), test_copyto_snbexclusions(), test_create_database_binary(), test_create_storage_modes(), test_data_cache(), test_data_cache_contents(), test_data_cache_initnew(), test_direct_swmr(), test_DPA_LoadStream(), test_DPA_SaveStream(), test_fmtusertypestg(), test_getdatahere(), test_locking(), test_nonroot_transacted(), test_OleLoad(), test_open_storage(), test_overwrite(), test_parent_free(), test_readonly(), test_references(), test_rename(), test_revert(), test_simple(), test_storage_refcount(), test_storage_stream(), test_storage_suminfo(), test_streamenum(), test_substorage_enum(), test_substorage_share(), test_toplevel_stat(), test_transact(), test_transacted_shared(), test_writeclassstg(), testCodepage(), testPropsHelper(), TransactedSnapshotImpl_Construct(), and write_substorage_to_file().

◆ StgCreateDocfileOnILockBytes()

HRESULT WINAPI StgCreateDocfileOnILockBytes ( ILockBytes plkbyt,
DWORD  grfMode,
DWORD  reserved,
IStorage **  ppstgOpen 
)

Definition at line 8946 of file storage32.c.

8951{
8952 StorageBaseImpl* newStorage = 0;
8953 HRESULT hr = S_OK;
8954
8955 if ((ppstgOpen == 0) || (plkbyt == 0))
8956 return STG_E_INVALIDPOINTER;
8957
8958 /*
8959 * Allocate and initialize the new IStorage object.
8960 */
8962 0,
8963 0,
8964 plkbyt,
8965 grfMode,
8966 FALSE,
8967 TRUE,
8968 512,
8969 &newStorage);
8970
8971 if (FAILED(hr))
8972 {
8973 return hr;
8974 }
8975
8976 *ppstgOpen = &newStorage->IStorage_iface;
8977
8978 return hr;
8979}

Referenced by create_storage(), DataObjectImpl_CreateComplex(), get_data_from_storage(), render_embed_source_hack(), test_custom_lockbytes(), test_data_cache_save(), test_data_cache_save_data(), test_hglobal_storage_creation(), test_hglobal_storage_stat(), and test_OleCreateStaticFromData().

◆ StgCreatePropSetStg()

HRESULT WINAPI StgCreatePropSetStg ( IStorage pstg,
DWORD  reserved,
IPropertySetStorage **  propset 
)

Definition at line 8698 of file storage32.c.

8700{
8701 TRACE("(%p, 0x%x, %p)\n", pstg, reserved, propset);
8702 if (reserved)
8704
8705 return IStorage_QueryInterface(pstg, &IID_IPropertySetStorage, (void**)propset);
8706}

◆ StgCreateStorageEx()

HRESULT WINAPI StgCreateStorageEx ( const WCHAR pwcsName,
DWORD  grfMode,
DWORD  stgfmt,
DWORD  grfAttrs,
STGOPTIONS pStgOptions,
void reserved,
REFIID  riid,
void **  ppObjectOpen 
)

Definition at line 8659 of file storage32.c.

8660{
8661 TRACE("(%s, %x, %x, %x, %p, %p, %p, %p)\n", debugstr_w(pwcsName),
8662 grfMode, stgfmt, grfAttrs, pStgOptions, reserved, riid, ppObjectOpen);
8663
8664 if (stgfmt != STGFMT_FILE && grfAttrs != 0)
8665 {
8666 ERR("grfAttrs must be 0 if stgfmt != STGFMT_FILE\n");
8668 }
8669
8670 if (stgfmt == STGFMT_FILE && grfAttrs != 0 && grfAttrs != FILE_FLAG_NO_BUFFERING)
8671 {
8672 ERR("grfAttrs must be 0 or FILE_FLAG_NO_BUFFERING if stgfmt == STGFMT_FILE\n");
8674 }
8675
8676 if (stgfmt == STGFMT_FILE)
8677 {
8678 ERR("Cannot use STGFMT_FILE - this is NTFS only\n");
8680 }
8681
8682 if (stgfmt == STGFMT_STORAGE || stgfmt == STGFMT_DOCFILE)
8683 {
8684 STGOPTIONS defaultOptions = {1, 0, 512};
8685
8686 if (!pStgOptions) pStgOptions = &defaultOptions;
8687 return create_storagefile(pwcsName, grfMode, grfAttrs, pStgOptions, riid, ppObjectOpen);
8688 }
8689
8690
8691 ERR("Invalid stgfmt argument\n");
8693}
#define FILE_FLAG_NO_BUFFERING
Definition: disk.h:45
#define STGFMT_DOCFILE
Definition: objbase.h:936
#define STGFMT_FILE
Definition: objbase.h:934
#define STGFMT_STORAGE
Definition: objbase.h:933

Referenced by create_shortcut(), and TransactedSharedImpl_Construct().

◆ StgIsStorageFile()

HRESULT WINAPI StgIsStorageFile ( LPCOLESTR  fn)

Definition at line 9475 of file storage32.c.

9476{
9477 HANDLE hf;
9478 BYTE magic[8];
9479 DWORD bytes_read;
9480
9481 TRACE("%s\n", debugstr_w(fn));
9485
9486 if (hf == INVALID_HANDLE_VALUE)
9487 return STG_E_FILENOTFOUND;
9488
9489 if (!ReadFile(hf, magic, 8, &bytes_read, NULL))
9490 {
9491 WARN(" unable to read file\n");
9492 CloseHandle(hf);
9493 return S_FALSE;
9494 }
9495
9496 CloseHandle(hf);
9497
9498 if (bytes_read != 8) {
9499 TRACE(" too short\n");
9500 return S_FALSE;
9501 }
9502
9503 if (!memcmp(magic,STORAGE_magic,8)) {
9504 TRACE(" -> YES\n");
9505 return S_OK;
9506 }
9507
9508 TRACE(" -> Invalid header.\n");
9509 return S_FALSE;
9510}
u32_t magic(void)
#define FILE_SHARE_DELETE
Definition: nt_native.h:682
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159

Referenced by GetClassFile().

◆ StgIsStorageILockBytes()

HRESULT WINAPI StgIsStorageILockBytes ( ILockBytes plkbyt)

Definition at line 9056 of file storage32.c.

9057{
9058 BYTE sig[sizeof(STORAGE_magic)];
9060 ULONG read = 0;
9061
9062 offset.u.HighPart = 0;
9063 offset.u.LowPart = 0;
9064
9065 ILockBytes_ReadAt(plkbyt, offset, sig, sizeof(sig), &read);
9066
9067 if (read == sizeof(sig) && memcmp(sig, STORAGE_magic, sizeof(sig)) == 0)
9068 return S_OK;
9069
9070 return S_FALSE;
9071}

Referenced by get_stgmed_for_storage(), and test_hglobal_storage_stat().

◆ StgOpenStorage()

HRESULT WINAPI StgOpenStorage ( const OLECHAR pwcsName,
IStorage pstgPriority,
DWORD  grfMode,
SNB  snbExclude,
DWORD  reserved,
IStorage **  ppstgOpen 
)

Definition at line 8755 of file storage32.c.

8762{
8763 StorageBaseImpl* newStorage = 0;
8764 HRESULT hr = S_OK;
8765 HANDLE hFile = 0;
8766 DWORD shareMode;
8767 DWORD accessMode;
8769
8770 TRACE("(%s, %p, %x, %p, %d, %p)\n",
8771 debugstr_w(pwcsName), pstgPriority, grfMode,
8772 snbExclude, reserved, ppstgOpen);
8773
8774 if (pstgPriority)
8775 {
8776 /* FIXME: Copy ILockBytes instead? But currently for STGM_PRIORITY it'll be read-only. */
8778 if (FAILED(hr)) goto end;
8779 pwcsName = temp_name;
8780 TRACE("using filename %s\n", debugstr_w(temp_name));
8781 }
8782
8783 if (pwcsName == 0)
8784 {
8786 goto end;
8787 }
8788
8789 if (ppstgOpen == 0)
8790 {
8792 goto end;
8793 }
8794
8795 if (reserved)
8796 {
8798 goto end;
8799 }
8800
8801 if (grfMode & STGM_PRIORITY)
8802 {
8804 return STG_E_INVALIDFLAG;
8805 if (grfMode & STGM_DELETEONRELEASE)
8806 return STG_E_INVALIDFUNCTION;
8807 if(STGM_ACCESS_MODE(grfMode) != STGM_READ)
8808 return STG_E_INVALIDFLAG;
8809 grfMode &= ~0xf0; /* remove the existing sharing mode */
8810 grfMode |= STGM_SHARE_DENY_NONE;
8811 }
8812
8813 /*
8814 * Validate the sharing mode
8815 */
8816 if (grfMode & STGM_DIRECT_SWMR)
8817 {
8818 if ((STGM_SHARE_MODE(grfMode) != STGM_SHARE_DENY_WRITE) &&
8820 {
8822 goto end;
8823 }
8824 }
8825 else if (!(grfMode & (STGM_TRANSACTED|STGM_PRIORITY)))
8826 switch(STGM_SHARE_MODE(grfMode))
8827 {
8830 break;
8831 default:
8833 goto end;
8834 }
8835
8836 if ( FAILED( validateSTGM(grfMode) ) ||
8837 (grfMode&STGM_CREATE))
8838 {
8840 goto end;
8841 }
8842
8843 /* shared reading requires transacted or single writer mode */
8844 if( STGM_SHARE_MODE(grfMode) == STGM_SHARE_DENY_WRITE &&
8845 STGM_ACCESS_MODE(grfMode) == STGM_READWRITE &&
8846 !(grfMode & STGM_TRANSACTED) && !(grfMode & STGM_DIRECT_SWMR))
8847 {
8849 goto end;
8850 }
8851
8852 /*
8853 * Interpret the STGM value grfMode
8854 */
8855 shareMode = GetShareModeFromSTGM(grfMode);
8856 accessMode = GetAccessModeFromSTGM(grfMode);
8857
8858 *ppstgOpen = 0;
8859
8860 hFile = CreateFileW( pwcsName,
8861 accessMode,
8862 shareMode,
8863 NULL,
8866 0);
8867
8869 {
8871
8872 hr = E_FAIL;
8873
8874 switch (last_error)
8875 {
8878 break;
8879
8882 break;
8883
8887 break;
8888
8891 break;
8892
8893 default:
8894 hr = E_FAIL;
8895 }
8896
8897 goto end;
8898 }
8899
8900 /*
8901 * Refuse to open the file if it's too small to be a structured storage file
8902 * FIXME: verify the file when reading instead of here
8903 */
8905 {
8908 goto end;
8909 }
8910
8911 /*
8912 * Allocate and initialize the new IStorage object.
8913 */
8915 hFile,
8916 pwcsName,
8917 NULL,
8918 grfMode,
8919 TRUE,
8920 FALSE,
8921 512,
8922 &newStorage);
8923
8924 if (FAILED(hr))
8925 {
8926 /*
8927 * According to the docs if the file is not a storage, return STG_E_FILEALREADYEXISTS
8928 */
8929 if(hr == STG_E_INVALIDHEADER)
8931 goto end;
8932 }
8933
8934 *ppstgOpen = &newStorage->IStorage_iface;
8935
8936end:
8938 if (pstgPriority) IStorage_Release(pstgPriority);
8939 TRACE("<-- %08x, IStorage %p\n", hr, ppstgOpen ? *ppstgOpen : NULL);
8940 return hr;
8941}
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
#define HEADER_SIZE
Definition: fontview.h:6
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define STGM_DIRECT_SWMR
Definition: objbase.h:931
#define STGM_NOSNAPSHOT
Definition: objbase.h:930
#define STGM_SIMPLE
Definition: objbase.h:916
#define STGM_PRIORITY
Definition: objbase.h:924
#define STGM_NOSCRATCH
Definition: objbase.h:929
char * temp_name
Definition: widl.c:150
static HRESULT StorageBaseImpl_GetFilename(StorageBaseImpl *This, LPWSTR *result)
Definition: storage32.h:273
#define STG_E_SHAREVIOLATION
Definition: winerror.h:2577
#define STG_E_PATHNOTFOUND
Definition: winerror.h:2566
#define ERROR_SHARING_VIOLATION
Definition: winerror.h:135
#define STG_E_INVALIDNAME
Definition: winerror.h:2584
#define STG_E_INVALIDHEADER
Definition: winerror.h:2583
#define ERROR_PATH_NOT_FOUND
Definition: winerror.h:106
#define ERROR_WRITE_PROTECT
Definition: winerror.h:122
#define STG_E_ACCESSDENIED
Definition: winerror.h:2568
#define STG_E_INVALIDFUNCTION
Definition: winerror.h:2564

Referenced by add_cabinet_storage(), FileMonikerImpl_BindToStorage(), GetClassFile(), MSI_DatabaseApplyTransformW(), MSI_OpenDatabaseW(), MsiSIPGetSignedDataMsg(), MsiSIPIsMyTypeOfFile(), OLECONVERT_GetOLE20FromOLE10(), set_admin_property_stream(), StgOpenStorageEx(), StgSetTimes(), test_access(), test_defaultdatabase(), test_direct_swmr(), test_locking(), test_open_storage(), test_overwrite(), test_readonly(), test_references(), test_simple(), test_storage_refcount(), test_storage_stream(), test_storages_table(), test_streamenum(), test_stringtable(), test_toplevel_stat(), test_transact(), test_transacted_shared(), and testPropsHelper().

◆ StgOpenStorageEx()

HRESULT WINAPI StgOpenStorageEx ( const WCHAR pwcsName,
DWORD  grfMode,
DWORD  stgfmt,
DWORD  grfAttrs,
STGOPTIONS pStgOptions,
void reserved,
REFIID  riid,
void **  ppObjectOpen 
)

Definition at line 8711 of file storage32.c.

8712{
8713 TRACE("(%s, %x, %x, %x, %p, %p, %p, %p)\n", debugstr_w(pwcsName),
8714 grfMode, stgfmt, grfAttrs, pStgOptions, reserved, riid, ppObjectOpen);
8715
8716 if (stgfmt != STGFMT_DOCFILE && grfAttrs != 0)
8717 {
8718 ERR("grfAttrs must be 0 if stgfmt != STGFMT_DOCFILE\n");
8720 }
8721
8722 switch (stgfmt)
8723 {
8724 case STGFMT_FILE:
8725 ERR("Cannot use STGFMT_FILE - this is NTFS only\n");
8727
8728 case STGFMT_STORAGE:
8729 break;
8730
8731 case STGFMT_DOCFILE:
8732 if (grfAttrs && grfAttrs != FILE_FLAG_NO_BUFFERING)
8733 {
8734 ERR("grfAttrs must be 0 or FILE_FLAG_NO_BUFFERING if stgfmt == STGFMT_DOCFILE\n");
8736 }
8737 FIXME("Stub: calling StgOpenStorage, but ignoring pStgOptions and grfAttrs\n");
8738 break;
8739
8740 case STGFMT_ANY:
8741 WARN("STGFMT_ANY assuming storage\n");
8742 break;
8743
8744 default:
8746 }
8747
8748 return StgOpenStorage(pwcsName, NULL, grfMode, NULL, 0, (IStorage **)ppObjectOpen);
8749}
#define STGFMT_ANY
Definition: objbase.h:935

◆ StgOpenStorageOnILockBytes()

HRESULT WINAPI StgOpenStorageOnILockBytes ( ILockBytes plkbyt,
IStorage pstgPriority,
DWORD  grfMode,
SNB  snbExclude,
DWORD  reserved,
IStorage **  ppstgOpen 
)

Definition at line 8984 of file storage32.c.

8991{
8992 StorageBaseImpl* newStorage = 0;
8993 HRESULT hr = S_OK;
8994
8995 if ((plkbyt == 0) || (ppstgOpen == 0))
8996 return STG_E_INVALIDPOINTER;
8997
8998 if ( FAILED( validateSTGM(grfMode) ))
8999 return STG_E_INVALIDFLAG;
9000
9001 *ppstgOpen = 0;
9002
9003 /*
9004 * Allocate and initialize the new IStorage object.
9005 */
9007 0,
9008 0,
9009 plkbyt,
9010 grfMode,
9011 FALSE,
9012 FALSE,
9013 512,
9014 &newStorage);
9015
9016 if (FAILED(hr))
9017 {
9018 return hr;
9019 }
9020
9021 *ppstgOpen = &newStorage->IStorage_iface;
9022
9023 return hr;
9024}

Referenced by get_stgmed_for_storage(), stream_to_storage(), and test_hglobal_storage_creation().

◆ StgSetTimes()

HRESULT WINAPI StgSetTimes ( OLECHAR const str,
FILETIME const pctime,
FILETIME const patime,
FILETIME const pmtime 
)

Definition at line 9032 of file storage32.c.

9034{
9035 IStorage *stg = NULL;
9036 HRESULT r;
9037
9038 TRACE("%s %p %p %p\n", debugstr_w(str), pctime, patime, pmtime);
9039
9041 0, 0, &stg);
9042 if( SUCCEEDED(r) )
9043 {
9044 r = IStorage_SetElementTimes(stg, NULL, pctime, patime, pmtime);
9045 IStorage_Release(stg);
9046 }
9047
9048 return r;
9049}
const WCHAR * str

◆ Storage32Impl_AddBlockDepot()

static void Storage32Impl_AddBlockDepot ( StorageImpl This,
ULONG  blockIndex,
ULONG  depotIndex 
)
static

Definition at line 3835 of file storage32.c.

3836{
3837 BYTE blockBuffer[MAX_BIG_BLOCK_SIZE];
3838 ULONG rangeLockIndex = RANGELOCK_FIRST / This->bigBlockSize - 1;
3839 ULONG blocksPerDepot = This->bigBlockSize / sizeof(ULONG);
3840 ULONG rangeLockDepot = rangeLockIndex / blocksPerDepot;
3841
3842 /*
3843 * Initialize blocks as free
3844 */
3845 memset(blockBuffer, BLOCK_UNUSED, This->bigBlockSize);
3846
3847 /* Reserve the range lock sector */
3848 if (depotIndex == rangeLockDepot)
3849 {
3850 ((ULONG*)blockBuffer)[rangeLockIndex % blocksPerDepot] = BLOCK_END_OF_CHAIN;
3851 }
3852
3853 StorageImpl_WriteBigBlock(This, blockIndex, blockBuffer);
3854}
#define RANGELOCK_FIRST
Definition: storage32.h:519

Referenced by StorageImpl_GetNextFreeBigBlock().

◆ Storage32Impl_AddExtBlockDepot()

static ULONG Storage32Impl_AddExtBlockDepot ( StorageImpl This)
static

Definition at line 3940 of file storage32.c.

3941{
3942 ULONG numExtBlocks = This->extBigBlockDepotCount;
3943 ULONG nextExtBlock = This->extBigBlockDepotStart;
3944 BYTE depotBuffer[MAX_BIG_BLOCK_SIZE];
3946 ULONG nextBlockOffset = This->bigBlockSize - sizeof(ULONG);
3947 ULONG blocksPerDepotBlock = This->bigBlockSize / sizeof(ULONG);
3948 ULONG depotBlocksPerExtBlock = blocksPerDepotBlock - 1;
3949
3950 index = (COUNT_BBDEPOTINHEADER + (numExtBlocks * depotBlocksPerExtBlock)) *
3951 blocksPerDepotBlock;
3952
3953 if ((numExtBlocks == 0) && (nextExtBlock == BLOCK_END_OF_CHAIN))
3954 {
3955 /*
3956 * The first extended block.
3957 */
3958 This->extBigBlockDepotStart = index;
3959 }
3960 else
3961 {
3962 /*
3963 * Find the last existing extended block.
3964 */
3965 nextExtBlock = This->extBigBlockDepotLocations[This->extBigBlockDepotCount-1];
3966
3967 /*
3968 * Add the new extended block to the chain.
3969 */
3970 StorageImpl_WriteDWordToBigBlock(This, nextExtBlock, nextBlockOffset,
3971 index);
3972 }
3973
3974 /*
3975 * Initialize this block.
3976 */
3977 memset(depotBuffer, BLOCK_UNUSED, This->bigBlockSize);
3978 StorageImpl_WriteBigBlock(This, index, depotBuffer);
3979
3980 /* Add the block to our cache. */
3981 if (This->extBigBlockDepotLocationsSize == numExtBlocks)
3982 {
3983 ULONG new_cache_size = (This->extBigBlockDepotLocationsSize+1)*2;
3984 ULONG *new_cache = HeapAlloc(GetProcessHeap(), 0, sizeof(ULONG) * new_cache_size);
3985
3986 memcpy(new_cache, This->extBigBlockDepotLocations, sizeof(ULONG) * This->extBigBlockDepotLocationsSize);
3987 HeapFree(GetProcessHeap(), 0, This->extBigBlockDepotLocations);
3988
3989 This->extBigBlockDepotLocations = new_cache;
3990 This->extBigBlockDepotLocationsSize = new_cache_size;
3991 }
3992 This->extBigBlockDepotLocations[numExtBlocks] = index;
3993
3994 return index;
3995}
static BOOL StorageImpl_WriteDWordToBigBlock(StorageImpl *This, ULONG blockIndex, ULONG offset, DWORD value)
Definition: storage32.c:3603
#define COUNT_BBDEPOTINHEADER
Definition: storage32.h:110

Referenced by StorageImpl_GetNextFreeBigBlock().

◆ Storage32Impl_BigBlocksToSmallBlocks()

static SmallBlockChainStream * Storage32Impl_BigBlocksToSmallBlocks ( StorageImpl This,
BlockChainStream **  ppbbChain,
ULARGE_INTEGER  newSize 
)
static

Definition at line 3746 of file storage32.c.

3750{
3751 ULARGE_INTEGER size, offset, cbTotalRead;
3752 ULONG cbRead, cbWritten, sbHeadOfChain = BLOCK_END_OF_CHAIN;
3753 DirRef streamEntryRef;
3754 HRESULT resWrite = S_OK, resRead = S_OK;
3755 DirEntry streamEntry;
3756 BYTE* buffer;
3757 SmallBlockChainStream* sbTempChain;
3758
3759 TRACE("%p %p\n", This, ppbbChain);
3760
3761 sbTempChain = SmallBlockChainStream_Construct(This, &sbHeadOfChain,
3763
3764 if(!sbTempChain)
3765 return NULL;
3766
3767 SmallBlockChainStream_SetSize(sbTempChain, newSize);
3768 size = BlockChainStream_GetSize(*ppbbChain);
3769 size.QuadPart = min(size.QuadPart, newSize.QuadPart);
3770
3771 offset.u.HighPart = 0;
3772 offset.u.LowPart = 0;
3773 cbTotalRead.QuadPart = 0;
3774 buffer = HeapAlloc(GetProcessHeap(), 0, This->bigBlockSize);
3775 while(cbTotalRead.QuadPart < size.QuadPart)
3776 {
3777 resRead = BlockChainStream_ReadAt(*ppbbChain, offset,
3778 min(This->bigBlockSize, size.u.LowPart - offset.u.LowPart),
3779 buffer, &cbRead);
3780
3781 if(FAILED(resRead))
3782 break;
3783
3784 if(cbRead > 0)
3785 {
3786 cbTotalRead.QuadPart += cbRead;
3787
3788 resWrite = SmallBlockChainStream_WriteAt(sbTempChain, offset,
3789 cbRead, buffer, &cbWritten);
3790
3791 if(FAILED(resWrite))
3792 break;
3793
3794 offset.u.LowPart += cbRead;
3795 }
3796 else
3797 {
3798 resRead = STG_E_READFAULT;
3799 break;
3800 }
3801 }
3803
3804 size.u.HighPart = 0;
3805 size.u.LowPart = 0;
3806
3807 if(FAILED(resRead) || FAILED(resWrite))
3808 {
3809 ERR("conversion failed: resRead = 0x%08x, resWrite = 0x%08x\n", resRead, resWrite);
3810 SmallBlockChainStream_SetSize(sbTempChain, size);
3811 SmallBlockChainStream_Destroy(sbTempChain);
3812 return NULL;
3813 }
3814
3815 /* destroy the original big block chain */
3816 streamEntryRef = (*ppbbChain)->ownerDirEntry;
3817 BlockChainStream_SetSize(*ppbbChain, size);
3818 BlockChainStream_Destroy(*ppbbChain);
3819 *ppbbChain = NULL;
3820
3821 StorageImpl_ReadDirEntry(This, streamEntryRef, &streamEntry);
3822 streamEntry.startingBlock = sbHeadOfChain;
3823 StorageImpl_WriteDirEntry(This, streamEntryRef, &streamEntry);
3824
3825 SmallBlockChainStream_Destroy(sbTempChain);
3826 return SmallBlockChainStream_Construct(This, NULL, streamEntryRef);
3827}
static HRESULT SmallBlockChainStream_WriteAt(SmallBlockChainStream *, ULARGE_INTEGER, ULONG, const void *, ULONG *)
Definition: storage32.c:8143
static void SmallBlockChainStream_Destroy(SmallBlockChainStream *)
Definition: storage32.c:7801
static BOOL SmallBlockChainStream_SetSize(SmallBlockChainStream *, ULARGE_INTEGER)
Definition: storage32.c:8405
static void BlockChainStream_Destroy(BlockChainStream *)
Definition: storage32.c:7311
static SmallBlockChainStream * SmallBlockChainStream_Construct(StorageImpl *, ULONG *, DirRef)
Definition: storage32.c:7785

Referenced by StorageImpl_StreamSetSize().

◆ Storage32Impl_GetExtDepotBlock()

static ULONG Storage32Impl_GetExtDepotBlock ( StorageImpl This,
ULONG  depotIndex 
)
static

Definition at line 3863 of file storage32.c.

3864{
3865 ULONG depotBlocksPerExtBlock = (This->bigBlockSize / sizeof(ULONG)) - 1;
3866 ULONG numExtBlocks = depotIndex - COUNT_BBDEPOTINHEADER;
3867 ULONG extBlockCount = numExtBlocks / depotBlocksPerExtBlock;
3868 ULONG extBlockOffset = numExtBlocks % depotBlocksPerExtBlock;
3869 ULONG blockIndex = BLOCK_UNUSED;
3870 ULONG extBlockIndex;
3871 BYTE depotBuffer[MAX_BIG_BLOCK_SIZE];
3872 int index, num_blocks;
3873
3874 assert(depotIndex >= COUNT_BBDEPOTINHEADER);
3875
3876 if (extBlockCount >= This->extBigBlockDepotCount)
3877 return BLOCK_UNUSED;
3878
3879 if (This->indexExtBlockDepotCached != extBlockCount)
3880 {
3881 extBlockIndex = This->extBigBlockDepotLocations[extBlockCount];
3882
3883 StorageImpl_ReadBigBlock(This, extBlockIndex, depotBuffer, NULL);
3884
3885 num_blocks = This->bigBlockSize / 4;
3886
3887 for (index = 0; index < num_blocks; index++)
3888 {
3889 StorageUtl_ReadDWord(depotBuffer, index*sizeof(ULONG), &blockIndex);
3890 This->extBlockDepotCached[index] = blockIndex;
3891 }
3892
3893 This->indexExtBlockDepotCached = extBlockCount;
3894 }
3895
3896 blockIndex = This->extBlockDepotCached[extBlockOffset];
3897
3898 return blockIndex;
3899}
JBLOCKROW JDIMENSION num_blocks
Definition: jpegint.h:423

Referenced by StorageImpl_GetNextBlockInChain(), StorageImpl_GetNextFreeBigBlock(), and StorageImpl_SetNextBlockInChain().

◆ Storage32Impl_GetNextExtendedBlock()

static ULONG Storage32Impl_GetNextExtendedBlock ( StorageImpl This,
ULONG  blockIndex 
)
static

Definition at line 4096 of file storage32.c.

4097{
4098 ULONG nextBlockIndex = BLOCK_SPECIAL;
4099 ULONG depotBlockOffset = This->bigBlockSize - sizeof(ULONG);
4100
4101 StorageImpl_ReadDWordFromBigBlock(This, blockIndex, depotBlockOffset,
4102 &nextBlockIndex);
4103
4104 return nextBlockIndex;
4105}
static BOOL StorageImpl_ReadDWordFromBigBlock(StorageImpl *This, ULONG blockIndex, ULONG offset, DWORD *value)
Definition: storage32.c:3571
static const ULONG BLOCK_SPECIAL
Definition: storage32.h:83

Referenced by StorageImpl_Refresh().

◆ Storage32Impl_SetExtDepotBlock()

static void Storage32Impl_SetExtDepotBlock ( StorageImpl This,
ULONG  depotIndex,
ULONG  blockIndex 
)
static

Definition at line 3908 of file storage32.c.

3909{
3910 ULONG depotBlocksPerExtBlock = (This->bigBlockSize / sizeof(ULONG)) - 1;
3911 ULONG numExtBlocks = depotIndex - COUNT_BBDEPOTINHEADER;
3912 ULONG extBlockCount = numExtBlocks / depotBlocksPerExtBlock;
3913 ULONG extBlockOffset = numExtBlocks % depotBlocksPerExtBlock;
3914 ULONG extBlockIndex;
3915
3916 assert(depotIndex >= COUNT_BBDEPOTINHEADER);
3917
3918 assert(extBlockCount < This->extBigBlockDepotCount);
3919
3920 extBlockIndex = This->extBigBlockDepotLocations[extBlockCount];
3921
3922 if (extBlockIndex != BLOCK_UNUSED)
3923 {
3925 extBlockOffset * sizeof(ULONG),
3926 blockIndex);
3927 }
3928
3929 if (This->indexExtBlockDepotCached == extBlockCount)
3930 {
3931 This->extBlockDepotCached[extBlockOffset] = blockIndex;
3932 }
3933}

Referenced by StorageImpl_GetNextFreeBigBlock().

◆ Storage32Impl_SmallBlocksToBigBlocks()

static BlockChainStream * Storage32Impl_SmallBlocksToBigBlocks ( StorageImpl This,
SmallBlockChainStream **  ppsbChain 
)
static

Definition at line 3626 of file storage32.c.

3629{
3630 ULONG bbHeadOfChain = BLOCK_END_OF_CHAIN;
3632 ULONG cbRead, cbWritten;
3633 ULARGE_INTEGER cbTotalRead;
3634 DirRef streamEntryRef;
3635 HRESULT resWrite = S_OK;
3636 HRESULT resRead;
3637 DirEntry streamEntry;
3638 BYTE *buffer;
3639 BlockChainStream *bbTempChain = NULL;
3640 BlockChainStream *bigBlockChain = NULL;
3641
3642 /*
3643 * Create a temporary big block chain that doesn't have
3644 * an associated directory entry. This temporary chain will be
3645 * used to copy data from small blocks to big blocks.
3646 */
3647 bbTempChain = BlockChainStream_Construct(This,
3648 &bbHeadOfChain,
3650 if(!bbTempChain) return NULL;
3651 /*
3652 * Grow the big block chain.
3653 */
3654 size = SmallBlockChainStream_GetSize(*ppsbChain);
3655 BlockChainStream_SetSize(bbTempChain, size);
3656
3657 /*
3658 * Copy the contents of the small block chain to the big block chain
3659 * by small block size increments.
3660 */
3661 offset.u.LowPart = 0;
3662 offset.u.HighPart = 0;
3663 cbTotalRead.QuadPart = 0;
3664
3666 do
3667 {
3668 resRead = SmallBlockChainStream_ReadAt(*ppsbChain,
3669 offset,
3670 min(This->smallBlockSize, size.u.LowPart - offset.u.LowPart),
3671 buffer,
3672 &cbRead);
3673 if (FAILED(resRead))
3674 break;
3675
3676 if (cbRead > 0)
3677 {
3678 cbTotalRead.QuadPart += cbRead;
3679
3680 resWrite = BlockChainStream_WriteAt(bbTempChain,
3681 offset,
3682 cbRead,
3683 buffer,
3684 &cbWritten);
3685
3686 if (FAILED(resWrite))
3687 break;
3688
3689 offset.u.LowPart += cbRead;
3690 }
3691 else
3692 {
3693 resRead = STG_E_READFAULT;
3694 break;
3695 }
3696 } while (cbTotalRead.QuadPart < size.QuadPart);
3698
3699 size.u.HighPart = 0;
3700 size.u.LowPart = 0;
3701
3702 if (FAILED(resRead) || FAILED(resWrite))
3703 {
3704 ERR("conversion failed: resRead = 0x%08x, resWrite = 0x%08x\n", resRead, resWrite);
3705 BlockChainStream_SetSize(bbTempChain, size);
3706 BlockChainStream_Destroy(bbTempChain);
3707 return NULL;
3708 }
3709
3710 /*
3711 * Destroy the small block chain.
3712 */
3713 streamEntryRef = (*ppsbChain)->ownerDirEntry;
3716 *ppsbChain = 0;
3717
3718 /*
3719 * Change the directory entry. This chain is now a big block chain
3720 * and it doesn't reside in the small blocks chain anymore.
3721 */
3722 StorageImpl_ReadDirEntry(This, streamEntryRef, &streamEntry);
3723
3724 streamEntry.startingBlock = bbHeadOfChain;
3725
3726 StorageImpl_WriteDirEntry(This, streamEntryRef, &streamEntry);
3727
3728 /*
3729 * Destroy the temporary entryless big block chain.
3730 * Create a new big block chain associated with this entry.
3731 */
3732 BlockChainStream_Destroy(bbTempChain);
3733 bigBlockChain = BlockChainStream_Construct(This,
3734 NULL,
3735 streamEntryRef);
3736
3737 return bigBlockChain;
3738}
static HRESULT SmallBlockChainStream_ReadAt(SmallBlockChainStream *, ULARGE_INTEGER, ULONG, void *, ULONG *)
Definition: storage32.c:8038
static BlockChainStream * BlockChainStream_Construct(StorageImpl *, ULONG *, DirRef)
Definition: storage32.c:7261
static const WORD DEF_SMALL_BLOCK_SIZE
Definition: storage32.h:80

Referenced by StorageImpl_StreamSetSize().

◆ Storage_Construct()

static HRESULT Storage_Construct ( HANDLE  hFile,
LPCOLESTR  pwcsName,
ILockBytes pLkbyt,
DWORD  openFlags,
BOOL  fileBased,
BOOL  create,
ULONG  sector_size,
StorageBaseImpl **  result 
)
static

Definition at line 6906 of file storage32.c.

6915{
6916 StorageImpl *newStorage;
6917 StorageBaseImpl *newTransactedStorage;
6918 HRESULT hr;
6919
6920 hr = StorageImpl_Construct(hFile, pwcsName, pLkbyt, openFlags, fileBased, create, sector_size, &newStorage);
6921 if (FAILED(hr)) goto end;
6922
6923 if (openFlags & STGM_TRANSACTED)
6924 {
6925 hr = Storage_ConstructTransacted(&newStorage->base, TRUE, &newTransactedStorage);
6926 if (FAILED(hr))
6927 IStorage_Release(&newStorage->base.IStorage_iface);
6928 else
6929 *result = newTransactedStorage;
6930 }
6931 else
6932 *result = &newStorage->base;
6933
6934end:
6935 return hr;
6936}
static HRESULT Storage_ConstructTransacted(StorageBaseImpl *, BOOL, StorageBaseImpl **)
Definition: storage32.c:6883
static HRESULT StorageImpl_Construct(HANDLE hFile, LPCOLESTR pwcsName, ILockBytes *pLkbyt, DWORD openFlags, BOOL fileBased, BOOL create, ULONG sector_size, StorageImpl **result)
Definition: storage32.c:5268
__u8 sector_size[2]
Definition: mkdosfs.c:3
struct StorageBaseImpl base
Definition: storage32.h:373

Referenced by create_storagefile(), StgCreateDocfileOnILockBytes(), StgOpenStorage(), and StgOpenStorageOnILockBytes().

◆ Storage_ConstructTransacted()

static HRESULT Storage_ConstructTransacted ( StorageBaseImpl parentStorage,
BOOL  toplevel,
StorageBaseImpl **  result 
)
static

Definition at line 6883 of file storage32.c.

6885{
6886 static int fixme_flags=STGM_NOSCRATCH|STGM_NOSNAPSHOT;
6887
6888 if (parentStorage->openFlags & fixme_flags)
6889 {
6890 fixme_flags &= ~parentStorage->openFlags;
6891 FIXME("Unimplemented flags %x\n", parentStorage->openFlags);
6892 }
6893
6894 if (toplevel && !(parentStorage->openFlags & STGM_NOSNAPSHOT) &&
6895 STGM_SHARE_MODE(parentStorage->openFlags) != STGM_SHARE_DENY_WRITE &&
6897 {
6898 /* Need to create a temp file for the snapshot */
6900 }
6901
6902 return TransactedSnapshotImpl_Construct(parentStorage,
6904}
static HRESULT TransactedSnapshotImpl_Construct(StorageBaseImpl *parentStorage, TransactedSnapshotImpl **result)
Definition: storage32.c:6476
static HRESULT TransactedSharedImpl_Construct(StorageBaseImpl *parentStorage, TransactedSharedImpl **result)
Definition: storage32.c:6812
jmp_buf toplevel
Definition: main.c:95

Referenced by Storage_Construct(), and StorageBaseImpl_OpenStorage().

◆ STORAGE_CreateOleStream()

HRESULT STORAGE_CreateOleStream ( IStorage storage,
DWORD  flags 
)

Definition at line 9207 of file storage32.c.

9208{
9209 static const WCHAR stream_1oleW[] = {1,'O','l','e',0};
9210 static const DWORD version_magic = 0x02000001;
9211 IStream *stream;
9212 HRESULT hr;
9213
9214 hr = IStorage_CreateStream(storage, stream_1oleW, STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &stream);
9215 if (hr == S_OK)
9216 {
9217 struct empty_1ole_stream {
9218 DWORD version_magic;
9219 DWORD flags;
9220 DWORD update_options;
9222 DWORD mon_stream_size;
9223 };
9224 struct empty_1ole_stream stream_data;
9225
9226 stream_data.version_magic = version_magic;
9227 stream_data.flags = flags;
9228 stream_data.update_options = 0;
9229 stream_data.reserved = 0;
9230 stream_data.mon_stream_size = 0;
9231
9232 hr = IStream_Write(stream, &stream_data, sizeof(stream_data), NULL);
9233 IStream_Release(stream);
9234 }
9235
9236 return hr;
9237}
static const char stream_data[]
Definition: mlang.c:2327

Referenced by DefaultHandler_IPersistStorage_InitNew(), load_ole_stream(), OleConvertOLESTREAMToIStorage(), render_embed_source_hack(), and SetConvertStg().

◆ STORAGE_WriteCompObj()

static HRESULT STORAGE_WriteCompObj ( LPSTORAGE  pstg,
CLSID clsid,
LPCWSTR  lpszUserType,
LPCWSTR  szClipName,
LPCWSTR  szProgIDName 
)
static

Definition at line 9309 of file storage32.c.

9311{
9312 IStream *pstm;
9313 HRESULT r = S_OK;
9314 static const WCHAR szwStreamName[] = {1, 'C', 'o', 'm', 'p', 'O', 'b', 'j', 0};
9315
9316 static const BYTE unknown1[12] =
9317 { 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
9318 0xFF, 0xFF, 0xFF, 0xFF};
9319 static const BYTE unknown2[16] =
9320 { 0xF4, 0x39, 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00,
9321 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
9322
9323 TRACE("%p %s %s %s %s\n", pstg, debugstr_guid(clsid),
9324 debugstr_w(lpszUserType), debugstr_w(szClipName),
9325 debugstr_w(szProgIDName));
9326
9327 /* Create a CompObj stream */
9328 r = IStorage_CreateStream(pstg, szwStreamName,
9329 STGM_CREATE | STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &pstm );
9330 if( FAILED (r) )
9331 return r;
9332
9333 /* Write CompObj Structure to stream */
9334 r = IStream_Write(pstm, unknown1, sizeof(unknown1), NULL);
9335
9336 if( SUCCEEDED( r ) )
9337 r = WriteClassStm( pstm, clsid );
9338
9339 if( SUCCEEDED( r ) )
9340 r = STREAM_WriteString( pstm, lpszUserType );
9341 if( SUCCEEDED( r ) )
9342 r = STREAM_WriteString( pstm, szClipName );
9343 if( SUCCEEDED( r ) )
9344 r = STREAM_WriteString( pstm, szProgIDName );
9345 if( SUCCEEDED( r ) )
9346 r = IStream_Write(pstm, unknown2, sizeof(unknown2), NULL);
9347
9348 IStream_Release( pstm );
9349
9350 return r;
9351}
static HRESULT STREAM_WriteString(IStream *stm, LPCWSTR string)
Definition: storage32.c:9240

Referenced by WriteFmtUserTypeStg().

◆ StorageBaseImpl_AddRef()

static ULONG WINAPI StorageBaseImpl_AddRef ( IStorage iface)
static

Definition at line 1279 of file storage32.c.

1281{
1284
1285 TRACE("(%p) AddRef to %d\n", This, ref);
1286
1287 return ref;
1288}
static StorageBaseImpl * impl_from_IStorage(IStorage *iface)
Definition: storage32.c:1219

◆ StorageBaseImpl_AddStream()

void StorageBaseImpl_AddStream ( StorageBaseImpl stg,
StgStreamImpl strm 
)

Definition at line 2714 of file storage32.c.

2715{
2716 TRACE("Stream added (stg=%p strm=%p)\n", stg, strm);
2717 list_add_tail(&stg->strmHead,&strm->StrmListEntry);
2718}
static void list_add_tail(struct list_entry *head, struct list_entry *entry)
Definition: list.h:83

Referenced by StgStreamImpl_Construct().

◆ StorageBaseImpl_Commit()

static HRESULT WINAPI StorageBaseImpl_Commit ( IStorage iface,
DWORD  grfCommitFlags 
)
static

Definition at line 2398 of file storage32.c.

2401{
2403 TRACE("(%p %d)\n", iface, grfCommitFlags);
2405}
static HRESULT StorageBaseImpl_Flush(StorageBaseImpl *This)
Definition: storage32.h:268

◆ StorageBaseImpl_CopyChildEntryTo()

static HRESULT StorageBaseImpl_CopyChildEntryTo ( StorageBaseImpl This,
DirRef  srcEntry,
BOOL  skip_storage,
BOOL  skip_stream,
SNB  snbExclude,
IStorage pstgDest 
)
static

Definition at line 1324 of file storage32.c.

1327{
1328 DirEntry data;
1329 HRESULT hr;
1330 BOOL skip = FALSE;
1331 IStorage *pstgTmp;
1332 IStream *pstrChild, *pstrTmp;
1333 STATSTG strStat;
1334
1335 if (srcEntry == DIRENTRY_NULL)
1336 return S_OK;
1337
1338 hr = StorageBaseImpl_ReadDirEntry( This, srcEntry, &data );
1339
1340 if (FAILED(hr))
1341 return hr;
1342
1343 if ( snbExclude )
1344 {
1345 WCHAR **snb = snbExclude;
1346
1347 while ( *snb != NULL && !skip )
1348 {
1349 if ( wcscmp(data.name, *snb) == 0 )
1350 skip = TRUE;
1351 ++snb;
1352 }
1353 }
1354
1355 if (!skip)
1356 {
1357 if (data.stgType == STGTY_STORAGE && !skip_storage)
1358 {
1359 /*
1360 * create a new storage in destination storage
1361 */
1362 hr = IStorage_CreateStorage( pstgDest, data.name,
1364 0, 0,
1365 &pstgTmp );
1366
1367 /*
1368 * if it already exist, don't create a new one use this one
1369 */
1371 {
1372 hr = IStorage_OpenStorage( pstgDest, data.name, NULL,
1374 NULL, 0, &pstgTmp );
1375 }
1376
1377 if (SUCCEEDED(hr))
1378 {
1379 hr = StorageBaseImpl_CopyStorageEntryTo( This, srcEntry, skip_storage,
1380 skip_stream, NULL, pstgTmp );
1381
1382 IStorage_Release(pstgTmp);
1383 }
1384 }
1385 else if (data.stgType == STGTY_STREAM && !skip_stream)
1386 {
1387 /*
1388 * create a new stream in destination storage. If the stream already
1389 * exist, it will be deleted and a new one will be created.
1390 */
1391 hr = IStorage_CreateStream( pstgDest, data.name,
1393 0, 0, &pstrTmp );
1394
1395 /*
1396 * open child stream storage. This operation must succeed even if the
1397 * stream is already open, so we use internal functions to do it.
1398 */
1399 if (hr == S_OK)
1400 {
1402
1403 if (streamimpl)
1404 {
1405 pstrChild = &streamimpl->IStream_iface;
1406 if (pstrChild)
1407 IStream_AddRef(pstrChild);
1408 }
1409 else
1410 {
1411 pstrChild = NULL;
1412 hr = E_OUTOFMEMORY;
1413 }
1414 }
1415
1416 if (hr == S_OK)
1417 {
1418 /*
1419 * Get the size of the source stream
1420 */
1421 IStream_Stat( pstrChild, &strStat, STATFLAG_NONAME );
1422
1423 /*
1424 * Set the size of the destination stream.
1425 */
1426 IStream_SetSize(pstrTmp, strStat.cbSize);
1427
1428 /*
1429 * do the copy
1430 */
1431 hr = IStream_CopyTo( pstrChild, pstrTmp, strStat.cbSize,
1432 NULL, NULL );
1433
1434 IStream_Release( pstrChild );
1435 }
1436
1437 IStream_Release( pstrTmp );
1438 }
1439 }
1440
1441 /* copy siblings */
1442 if (SUCCEEDED(hr))
1443 hr = StorageBaseImpl_CopyChildEntryTo( This, data.leftChild, skip_storage,
1444 skip_stream, snbExclude, pstgDest );
1445
1446 if (SUCCEEDED(hr))
1447 hr = StorageBaseImpl_CopyChildEntryTo( This, data.rightChild, skip_storage,
1448 skip_stream, snbExclude, pstgDest );
1449
1450 TRACE("<-- %08x\n", hr);
1451 return hr;
1452}
#define skip(...)
Definition: atltest.h:64
static HRESULT StorageBaseImpl_CopyStorageEntryTo(StorageBaseImpl *This, DirRef srcEntry, BOOL skip_storage, BOOL skip_stream, SNB snbExclude, IStorage *pstgDest)
Definition: storage32.c:2265
static HRESULT StorageBaseImpl_CopyChildEntryTo(StorageBaseImpl *This, DirRef srcEntry, BOOL skip_storage, BOOL skip_stream, SNB snbExclude, IStorage *pstgDest)
Definition: storage32.c:1324
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
StgStreamImpl * StgStreamImpl_Construct(StorageBaseImpl *parentStorage, DWORD grfMode, DirRef dirEntry)
Definition: stg_stream.c:666
IStream IStream_iface
Definition: storage32.h:429

Referenced by StorageBaseImpl_CopyChildEntryTo(), and StorageBaseImpl_CopyStorageEntryTo().

◆ StorageBaseImpl_CopyStorageEntryTo()

static HRESULT StorageBaseImpl_CopyStorageEntryTo ( StorageBaseImpl This,
DirRef  srcEntry,
BOOL  skip_storage,
BOOL  skip_stream,
SNB  snbExclude,
IStorage pstgDest 
)
static

Definition at line 2265 of file storage32.c.

2268{
2269 DirEntry data;
2270 HRESULT hr;
2271
2272 hr = StorageBaseImpl_ReadDirEntry( This, srcEntry, &data );
2273
2274 if (SUCCEEDED(hr))
2275 hr = IStorage_SetClass( pstgDest, &data.clsid );
2276
2277 if (SUCCEEDED(hr))
2278 hr = StorageBaseImpl_CopyChildEntryTo( This, data.dirRootEntry, skip_storage,
2279 skip_stream, snbExclude, pstgDest );
2280
2281 TRACE("<-- %08x\n", hr);
2282 return hr;
2283}

Referenced by StorageBaseImpl_CopyChildEntryTo(), and StorageBaseImpl_CopyTo().

◆ StorageBaseImpl_CopyStorageTree()

static HRESULT StorageBaseImpl_CopyStorageTree ( StorageBaseImpl dst,
DirRef  dst_entry,
StorageBaseImpl src,
DirRef  src_entry 
)
static

Definition at line 2804 of file storage32.c.

2807{
2808 HRESULT hr;
2809 DirEntry src_data, dst_data;
2810 DirRef new_root_entry;
2811
2812 hr = StorageBaseImpl_ReadDirEntry(src, src_entry, &src_data);
2813
2814 if (SUCCEEDED(hr))
2815 {
2816 hr = StorageBaseImpl_DupStorageTree(dst, &new_root_entry, src, src_data.dirRootEntry);
2817 }
2818
2819 if (SUCCEEDED(hr))
2820 {
2822 dst_data.clsid = src_data.clsid;
2823 dst_data.ctime = src_data.ctime;
2824 dst_data.mtime = src_data.mtime;
2825 dst_data.dirRootEntry = new_root_entry;
2826 }
2827
2828 if (SUCCEEDED(hr))
2830
2831 return hr;
2832}
static HRESULT StorageBaseImpl_DupStorageTree(StorageBaseImpl *dst, DirRef *dst_entry, StorageBaseImpl *src, DirRef src_entry)
Definition: storage32.c:2765
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
GUID clsid
Definition: storage32.h:153
FILETIME ctime
Definition: storage32.h:154
FILETIME mtime
Definition: storage32.h:155
Definition: tcpcore.h:1673

Referenced by TransactedSharedImpl_Construct().

◆ StorageBaseImpl_CopyStream()

static HRESULT StorageBaseImpl_CopyStream ( StorageBaseImpl dst,
DirRef  dst_entry,
StorageBaseImpl src,
DirRef  src_entry 
)
static

Definition at line 2726 of file storage32.c.

2729{
2730 HRESULT hr;
2731 BYTE data[4096];
2732 DirEntry srcdata;
2733 ULARGE_INTEGER bytes_copied;
2734 ULONG bytestocopy, bytesread, byteswritten;
2735
2736 hr = StorageBaseImpl_ReadDirEntry(src, src_entry, &srcdata);
2737
2738 if (SUCCEEDED(hr))
2739 {
2741
2742 bytes_copied.QuadPart = 0;
2743 while (bytes_copied.QuadPart < srcdata.size.QuadPart && SUCCEEDED(hr))
2744 {
2745 bytestocopy = min(4096, srcdata.size.QuadPart - bytes_copied.QuadPart);
2746
2747 hr = StorageBaseImpl_StreamReadAt(src, src_entry, bytes_copied, bytestocopy,
2748 data, &bytesread);
2749 if (SUCCEEDED(hr) && bytesread != bytestocopy) hr = STG_E_READFAULT;
2750
2751 if (SUCCEEDED(hr))
2752 hr = StorageBaseImpl_StreamWriteAt(dst, dst_entry, bytes_copied, bytestocopy,
2753 data, &byteswritten);
2754 if (SUCCEEDED(hr))
2755 {
2756 if (byteswritten != bytestocopy) hr = STG_E_WRITEFAULT;
2757 bytes_copied.QuadPart += byteswritten;
2758 }
2759 }
2760 }
2761
2762 return hr;
2763}
static HRESULT StorageBaseImpl_StreamSetSize(StorageBaseImpl *This, DirRef index, ULARGE_INTEGER newsize)
Definition: storage32.h:317
static HRESULT StorageBaseImpl_StreamReadAt(StorageBaseImpl *This, DirRef index, ULARGE_INTEGER offset, ULONG size, void *buffer, ULONG *bytesRead)
Definition: storage32.h:303
static HRESULT StorageBaseImpl_StreamWriteAt(StorageBaseImpl *This, DirRef index, ULARGE_INTEGER offset, ULONG size, const void *buffer, ULONG *bytesWritten)
Definition: storage32.h:311

Referenced by StorageBaseImpl_DupStorageTree(), TransactedSnapshotImpl_CopyTree(), and TransactedSnapshotImpl_MakeStreamDirty().

◆ StorageBaseImpl_CopyTo()

static HRESULT WINAPI StorageBaseImpl_CopyTo ( IStorage iface,
DWORD  ciidExclude,
const IID rgiidExclude,
SNB  snbExclude,
IStorage pstgDest 
)
static

Definition at line 2288 of file storage32.c.

2294{
2296
2297 BOOL skip_storage = FALSE, skip_stream = FALSE;
2298 DWORD i;
2299
2300 TRACE("(%p, %d, %p, %p, %p)\n",
2301 iface, ciidExclude, rgiidExclude,
2302 snbExclude, pstgDest);
2303
2304 if ( pstgDest == 0 )
2305 return STG_E_INVALIDPOINTER;
2306
2307 for(i = 0; i < ciidExclude; ++i)
2308 {
2309 if(IsEqualGUID(&IID_IStorage, &rgiidExclude[i]))
2310 skip_storage = TRUE;
2311 else if(IsEqualGUID(&IID_IStream, &rgiidExclude[i]))
2312 skip_stream = TRUE;
2313 else
2314 WARN("Unknown excluded GUID: %s\n", debugstr_guid(&rgiidExclude[i]));
2315 }
2316
2317 if (!skip_storage)
2318 {
2319 /* Give up early if it looks like this would be infinitely recursive.
2320 * Oddly enough, this includes some cases that aren't really recursive, like
2321 * copying to a transacted child. */
2322 IStorage *pstgDestAncestor = pstgDest;
2323 IStorage *pstgDestAncestorChild = NULL;
2324
2325 /* Go up the chain from the destination until we find the source storage. */
2326 while (pstgDestAncestor != iface) {
2327 pstgDestAncestorChild = pstgDest;
2328
2329 if (pstgDestAncestor->lpVtbl == &TransactedSnapshotImpl_Vtbl)
2330 {
2332
2333 pstgDestAncestor = &snapshot->transactedParent->IStorage_iface;
2334 }
2335 else if (pstgDestAncestor->lpVtbl == &StorageInternalImpl_Vtbl)
2336 {
2337 StorageInternalImpl *internal = (StorageInternalImpl*) pstgDestAncestor;
2338
2339 pstgDestAncestor = &internal->parentStorage->IStorage_iface;
2340 }
2341 else
2342 break;
2343 }
2344
2345 if (pstgDestAncestor == iface)
2346 {
2347 BOOL fail = TRUE;
2348
2349 if (pstgDestAncestorChild && snbExclude)
2350 {
2351 StorageBaseImpl *ancestorChildBase = (StorageBaseImpl*)pstgDestAncestorChild;
2352 DirEntry data;
2353 WCHAR **snb = snbExclude;
2354
2355 StorageBaseImpl_ReadDirEntry(ancestorChildBase, ancestorChildBase->storageDirEntry, &data);
2356
2357 while ( *snb != NULL && fail )
2358 {
2359 if ( wcscmp(data.name, *snb) == 0 )
2360 fail = FALSE;
2361 ++snb;
2362 }
2363 }
2364
2365 if (fail)
2366 return STG_E_ACCESSDENIED;
2367 }
2368 }
2369
2370 return StorageBaseImpl_CopyStorageEntryTo( This, This->storageDirEntry,
2371 skip_storage, skip_stream, snbExclude, pstgDest );
2372}
ios_base &_STLP_CALL internal(ios_base &__s)
Definition: _ios_base.h:311
static const IStorageVtbl StorageInternalImpl_Vtbl
Definition: storage32.c:86
static const IStorageVtbl TransactedSnapshotImpl_Vtbl
Definition: storage32.c:155
DirRef storageDirEntry
Definition: storage32.h:211

◆ StorageBaseImpl_CreateStorage()

static HRESULT WINAPI StorageBaseImpl_CreateStorage ( IStorage iface,
const OLECHAR pwcsName,
DWORD  grfMode,
DWORD  reserved1,
DWORD  reserved2,
IStorage **  ppstg 
)
static

Definition at line 2117 of file storage32.c.

2124{
2126
2127 DirEntry currentEntry;
2128 DirEntry newEntry;
2129 DirRef currentEntryRef;
2130 DirRef newEntryRef;
2131 HRESULT hr;
2132
2133 TRACE("(%p, %s, %x, %d, %d, %p)\n",
2134 iface, debugstr_w(pwcsName), grfMode,
2135 reserved1, reserved2, ppstg);
2136
2137 if (ppstg == 0)
2138 return STG_E_INVALIDPOINTER;
2139
2140 if (This->openFlags & STGM_SIMPLE)
2141 {
2142 return STG_E_INVALIDFUNCTION;
2143 }
2144
2145 if (pwcsName == 0)
2146 return STG_E_INVALIDNAME;
2147
2148 *ppstg = NULL;
2149
2150 if ( FAILED( validateSTGM(grfMode) ) ||
2151 (grfMode & STGM_DELETEONRELEASE) )
2152 {
2153 WARN("bad grfMode: 0x%x\n", grfMode);
2154 return STG_E_INVALIDFLAG;
2155 }
2156
2157 if (This->reverted)
2158 return STG_E_REVERTED;
2159
2160 /*
2161 * Check that we're compatible with the parent's storage mode
2162 */
2163 if ( !(This->openFlags & STGM_TRANSACTED) &&
2164 STGM_ACCESS_MODE( grfMode ) > STGM_ACCESS_MODE( This->openFlags ) )
2165 {
2166 WARN("access denied\n");
2167 return STG_E_ACCESSDENIED;
2168 }
2169
2170 currentEntryRef = findElement(This,
2171 This->storageDirEntry,
2172 pwcsName,
2173 &currentEntry);
2174
2175 if (currentEntryRef != DIRENTRY_NULL)
2176 {
2177 /*
2178 * An element with this name already exists
2179 */
2180 if (STGM_CREATE_MODE(grfMode) == STGM_CREATE &&
2181 ((This->openFlags & STGM_TRANSACTED) ||
2182 STGM_ACCESS_MODE(This->openFlags) != STGM_READ))
2183 {
2184 hr = IStorage_DestroyElement(iface, pwcsName);
2185 if (FAILED(hr))
2186 return hr;
2187 }
2188 else
2189 {
2190 WARN("file already exists\n");
2192 }
2193 }
2194 else if (!(This->openFlags & STGM_TRANSACTED) &&
2195 STGM_ACCESS_MODE(This->openFlags) == STGM_READ)
2196 {
2197 WARN("read-only storage\n");
2198 return STG_E_ACCESSDENIED;
2199 }
2200
2201 memset(&newEntry, 0, sizeof(DirEntry));
2202
2203 newEntry.sizeOfNameString = (lstrlenW(pwcsName)+1)*sizeof(WCHAR);
2204
2206 {
2207 FIXME("name too long\n");
2208 return STG_E_INVALIDNAME;
2209 }
2210
2211 lstrcpyW(newEntry.name, pwcsName);
2212
2213 newEntry.stgType = STGTY_STORAGE;
2215 newEntry.size.u.LowPart = 0;
2216 newEntry.size.u.HighPart = 0;
2217
2218 newEntry.leftChild = DIRENTRY_NULL;
2219 newEntry.rightChild = DIRENTRY_NULL;
2220 newEntry.dirRootEntry = DIRENTRY_NULL;
2221
2222 /* call CoFileTime to get the current time
2223 newEntry.ctime
2224 newEntry.mtime
2225 */
2226
2227 /* newEntry.clsid */
2228
2229 /*
2230 * Create a new directory entry for the storage
2231 */
2232 hr = StorageBaseImpl_CreateDirEntry(This, &newEntry, &newEntryRef);
2233 if (FAILED(hr))
2234 return hr;
2235
2236 /*
2237 * Insert the new directory entry into the parent storage's tree
2238 */
2240 This,
2241 This->storageDirEntry,
2242 newEntryRef);
2243 if (FAILED(hr))
2244 {
2246 return hr;
2247 }
2248
2249 /*
2250 * Open it to get a pointer to return.
2251 */
2252 hr = IStorage_OpenStorage(iface, pwcsName, 0, grfMode, 0, 0, ppstg);
2253
2254 if( (hr != S_OK) || (*ppstg == NULL))
2255 {
2256 return hr;
2257 }
2258
2259 if (SUCCEEDED(hr))
2261
2262 return S_OK;
2263}
#define lstrcpyW
Definition: compat.h:749
static DirRef findElement(StorageBaseImpl *storage, DirRef storageEntry, const OLECHAR *name, DirEntry *data)
Definition: storage32.c:533
static HRESULT insertIntoTree(StorageBaseImpl *This, DirRef parentStorageIndex, DirRef newEntryIndex)
Definition: storage32.c:650
uint8_t reserved2[12]
Definition: fsck.fat.h:23
static HRESULT StorageBaseImpl_DestroyDirEntry(StorageBaseImpl *This, DirRef index)
Definition: storage32.h:296
#define DIRENTRY_NAME_BUFFER_LEN
Definition: storage32.h:89
static HRESULT StorageBaseImpl_CreateDirEntry(StorageBaseImpl *This, const DirEntry *newData, DirRef *index)
Definition: storage32.h:278
BYTE stgType
Definition: storage32.h:149
WORD sizeOfNameString
Definition: storage32.h:148

◆ StorageBaseImpl_CreateStream()

static HRESULT WINAPI StorageBaseImpl_CreateStream ( IStorage iface,
const OLECHAR pwcsName,
DWORD  grfMode,
DWORD  reserved1,
DWORD  reserved2,
IStream **  ppstm 
)
static

Definition at line 1924 of file storage32.c.

1931{
1933 StgStreamImpl* newStream;
1934 DirEntry currentEntry, newStreamEntry;
1935 DirRef currentEntryRef, newStreamEntryRef;
1936 HRESULT hr;
1937
1938 TRACE("(%p, %s, %x, %d, %d, %p)\n",
1939 iface, debugstr_w(pwcsName), grfMode,
1940 reserved1, reserved2, ppstm);
1941
1942 if (ppstm == 0)
1943 return STG_E_INVALIDPOINTER;
1944
1945 if (pwcsName == 0)
1946 return STG_E_INVALIDNAME;
1947
1948 if (reserved1 || reserved2)
1950
1951 if ( FAILED( validateSTGM(grfMode) ))
1952 return STG_E_INVALIDFLAG;
1953
1954 if (STGM_SHARE_MODE(grfMode) != STGM_SHARE_EXCLUSIVE)
1955 return STG_E_INVALIDFLAG;
1956
1957 if (This->reverted)
1958 return STG_E_REVERTED;
1959
1960 /*
1961 * As documented.
1962 */
1963 if ((grfMode & STGM_DELETEONRELEASE) ||
1964 (grfMode & STGM_TRANSACTED))
1965 return STG_E_INVALIDFUNCTION;
1966
1967 /*
1968 * Don't worry about permissions in transacted mode, as we can always write
1969 * changes; we just can't always commit them.
1970 */
1971 if(!(This->openFlags & STGM_TRANSACTED)) {
1972 /* Can't create a stream on read-only storage */
1973 if ( STGM_ACCESS_MODE( This->openFlags ) == STGM_READ )
1974 return STG_E_ACCESSDENIED;
1975
1976 /* Can't create a stream with greater access than the parent. */
1977 if ( STGM_ACCESS_MODE( grfMode ) > STGM_ACCESS_MODE( This->openFlags ) )
1978 return STG_E_ACCESSDENIED;
1979 }
1980
1981 if(This->openFlags & STGM_SIMPLE)
1982 if(grfMode & STGM_CREATE) return STG_E_INVALIDFLAG;
1983
1984 *ppstm = 0;
1985
1986 currentEntryRef = findElement(This,
1987 This->storageDirEntry,
1988 pwcsName,
1989 &currentEntry);
1990
1991 if (currentEntryRef != DIRENTRY_NULL)
1992 {
1993 /*
1994 * An element with this name already exists
1995 */
1996 if (STGM_CREATE_MODE(grfMode) == STGM_CREATE)
1997 {
1998 IStorage_DestroyElement(iface, pwcsName);
1999 }
2000 else
2002 }
2003
2004 /*
2005 * memset the empty entry
2006 */
2007 memset(&newStreamEntry, 0, sizeof(DirEntry));
2008
2009 newStreamEntry.sizeOfNameString =
2010 ( lstrlenW(pwcsName)+1 ) * sizeof(WCHAR);
2011
2012 if (newStreamEntry.sizeOfNameString > DIRENTRY_NAME_BUFFER_LEN)
2013 return STG_E_INVALIDNAME;
2014
2015 lstrcpyW(newStreamEntry.name, pwcsName);
2016
2017 newStreamEntry.stgType = STGTY_STREAM;
2018 newStreamEntry.startingBlock = BLOCK_END_OF_CHAIN;
2019 newStreamEntry.size.u.LowPart = 0;
2020 newStreamEntry.size.u.HighPart = 0;
2021
2022 newStreamEntry.leftChild = DIRENTRY_NULL;
2023 newStreamEntry.rightChild = DIRENTRY_NULL;
2024 newStreamEntry.dirRootEntry = DIRENTRY_NULL;
2025
2026 /* call CoFileTime to get the current time
2027 newStreamEntry.ctime
2028 newStreamEntry.mtime
2029 */
2030
2031 /* newStreamEntry.clsid */
2032
2033 /*
2034 * Create an entry with the new data
2035 */
2036 hr = StorageBaseImpl_CreateDirEntry(This, &newStreamEntry, &newStreamEntryRef);
2037 if (FAILED(hr))
2038 return hr;
2039
2040 /*
2041 * Insert the new entry in the parent storage's tree.
2042 */
2044 This,
2045 This->storageDirEntry,
2046 newStreamEntryRef);
2047 if (FAILED(hr))
2048 {
2049 StorageBaseImpl_DestroyDirEntry(This, newStreamEntryRef);
2050 return hr;
2051 }
2052
2053 /*
2054 * Open the stream to return it.
2055 */
2056 newStream = StgStreamImpl_Construct(This, grfMode, newStreamEntryRef);
2057
2058 if (newStream)
2059 {
2060 *ppstm = &newStream->IStream_iface;
2061 IStream_AddRef(*ppstm);
2062 }
2063 else
2064 {
2066 }
2067
2069}

◆ StorageBaseImpl_DeleteAll()

static void StorageBaseImpl_DeleteAll ( StorageBaseImpl stg)
static

Definition at line 2653 of file storage32.c.

2654{
2655 struct list *cur, *cur2;
2656 StgStreamImpl *strm=NULL;
2657 StorageInternalImpl *childstg=NULL;
2658
2659 LIST_FOR_EACH_SAFE(cur, cur2, &stg->strmHead) {
2660 strm = LIST_ENTRY(cur,StgStreamImpl,StrmListEntry);
2661 TRACE("Streams invalidated (stg=%p strm=%p next=%p prev=%p)\n", stg,strm,cur->next,cur->prev);
2662 strm->parentStorage = NULL;
2664 }
2665
2666 LIST_FOR_EACH_SAFE(cur, cur2, &stg->storageHead) {
2667 childstg = LIST_ENTRY(cur,StorageInternalImpl,ParentListEntry);
2668 StorageBaseImpl_Invalidate( &childstg->base );
2669 }
2670
2671 if (stg->transactedChild)
2672 {
2674
2675 stg->transactedChild = NULL;
2676 }
2677}
Definition: list.h:37
FxCollectionEntry * cur
#define LIST_FOR_EACH_SAFE(cursor, cursor2, list)
Definition: list.h:192
StorageBaseImpl * transactedChild
Definition: storage32.h:234
#define LIST_ENTRY(type)
Definition: queue.h:175

Referenced by StorageImpl_Invalidate(), StorageInternalImpl_Invalidate(), TransactedSharedImpl_Invalidate(), TransactedSharedImpl_Revert(), TransactedSnapshotImpl_Invalidate(), and TransactedSnapshotImpl_Revert().

◆ StorageBaseImpl_DeleteStorageTree()

static HRESULT StorageBaseImpl_DeleteStorageTree ( StorageBaseImpl This,
DirRef  entry,
BOOL  include_siblings 
)
static

Definition at line 2834 of file storage32.c.

2835{
2836 HRESULT hr;
2837 DirEntry data;
2839
2840 if (entry == DIRENTRY_NULL)
2841 return S_OK;
2842
2843 zero.QuadPart = 0;
2844
2846
2847 if (SUCCEEDED(hr) && include_siblings)
2849
2850 if (SUCCEEDED(hr) && include_siblings)
2852
2853 if (SUCCEEDED(hr))
2855
2856 if (SUCCEEDED(hr) && data.stgType == STGTY_STREAM)
2858
2859 if (SUCCEEDED(hr))
2861
2862 return hr;
2863}
static HRESULT StorageBaseImpl_DeleteStorageTree(StorageBaseImpl *This, DirRef entry, BOOL include_siblings)
Definition: storage32.c:2834
int zero
Definition: sehframes.cpp:29

Referenced by StorageBaseImpl_DeleteStorageTree(), and TransactedSharedImpl_Commit().

◆ StorageBaseImpl_DestroyElement()

static HRESULT WINAPI StorageBaseImpl_DestroyElement ( IStorage iface,
const OLECHAR pwcsName 
)
static

Definition at line 2576 of file storage32.c.

2579{
2581
2582 HRESULT hr = S_OK;
2583 DirEntry entryToDelete;
2584 DirRef entryToDeleteRef;
2585
2586 TRACE("(%p, %s)\n",
2587 iface, debugstr_w(pwcsName));
2588
2589 if (pwcsName==NULL)
2590 return STG_E_INVALIDPOINTER;
2591
2592 if (This->reverted)
2593 return STG_E_REVERTED;
2594
2595 if ( !(This->openFlags & STGM_TRANSACTED) &&
2596 STGM_ACCESS_MODE( This->openFlags ) == STGM_READ )
2597 return STG_E_ACCESSDENIED;
2598
2599 entryToDeleteRef = findElement(
2600 This,
2601 This->storageDirEntry,
2602 pwcsName,
2603 &entryToDelete);
2604
2605 if ( entryToDeleteRef == DIRENTRY_NULL )
2606 {
2607 TRACE("<-- STG_E_FILENOTFOUND\n");
2608 return STG_E_FILENOTFOUND;
2609 }
2610
2611 if ( entryToDelete.stgType == STGTY_STORAGE )
2612 {
2614 This,
2615 entryToDeleteRef,
2616 entryToDelete);
2617 }
2618 else if ( entryToDelete.stgType == STGTY_STREAM )
2619 {
2621 This,
2622 entryToDeleteRef,
2623 entryToDelete);
2624 }
2625
2626 if (hr!=S_OK)
2627 {
2628 TRACE("<-- %08x\n", hr);
2629 return hr;
2630 }
2631
2632 /*
2633 * Remove the entry from its parent storage
2634 */
2636 This,
2637 This->storageDirEntry,
2638 entryToDeleteRef);
2639
2640 /*
2641 * Invalidate the entry
2642 */
2643 if (SUCCEEDED(hr))
2644 StorageBaseImpl_DestroyDirEntry(This, entryToDeleteRef);
2645
2646 if (SUCCEEDED(hr))
2648
2649 TRACE("<-- %08x\n", hr);
2650 return hr;
2651}
static HRESULT deleteStreamContents(StorageBaseImpl *parentStorage, DirRef indexToDelete, DirEntry entryDataToDelete)
Definition: storage32.c:2513
static HRESULT removeFromTree(StorageBaseImpl *This, DirRef parentStorageIndex, DirRef deletedIndex)
Definition: storage32.c:771
static HRESULT deleteStorageContents(StorageBaseImpl *parentStorage, DirRef indexToDelete, DirEntry entryDataToDelete)
Definition: storage32.c:2426

◆ StorageBaseImpl_DupStorageTree()

static HRESULT StorageBaseImpl_DupStorageTree ( StorageBaseImpl dst,
DirRef dst_entry,
StorageBaseImpl src,
DirRef  src_entry 
)
static

Definition at line 2765 of file storage32.c.

2768{
2769 HRESULT hr;
2770 DirEntry data;
2771 BOOL has_stream=FALSE;
2772
2773 if (src_entry == DIRENTRY_NULL)
2774 {
2776 return S_OK;
2777 }
2778
2779 hr = StorageBaseImpl_ReadDirEntry(src, src_entry, &data);
2780 if (SUCCEEDED(hr))
2781 {
2782 has_stream = (data.stgType == STGTY_STREAM && data.size.QuadPart != 0);
2783 data.startingBlock = BLOCK_END_OF_CHAIN;
2784 data.size.QuadPart = 0;
2785
2786 hr = StorageBaseImpl_DupStorageTree(dst, &data.leftChild, src, data.leftChild);
2787 }
2788
2789 if (SUCCEEDED(hr))
2790 hr = StorageBaseImpl_DupStorageTree(dst, &data.rightChild, src, data.rightChild);
2791
2792 if (SUCCEEDED(hr))
2793 hr = StorageBaseImpl_DupStorageTree(dst, &data.dirRootEntry, src, data.dirRootEntry);
2794
2795 if (SUCCEEDED(hr))
2797
2798 if (SUCCEEDED(hr) && has_stream)
2800
2801 return hr;
2802}
static HRESULT StorageBaseImpl_CopyStream(StorageBaseImpl *dst, DirRef dst_entry, StorageBaseImpl *src, DirRef src_entry)
Definition: storage32.c:2726

Referenced by StorageBaseImpl_CopyStorageTree(), StorageBaseImpl_DupStorageTree(), and TransactedSharedImpl_Commit().

◆ StorageBaseImpl_EnumElements()

static HRESULT WINAPI StorageBaseImpl_EnumElements ( IStorage iface,
DWORD  reserved1,
void reserved2,
DWORD  reserved3,
IEnumSTATSTG **  ppenum 
)
static

Definition at line 1747 of file storage32.c.

1753{
1755 IEnumSTATSTGImpl* newEnum;
1756
1757 TRACE("(%p, %d, %p, %d, %p)\n",
1758 iface, reserved1, reserved2, reserved3, ppenum);
1759
1760 if (!ppenum)
1761 return E_INVALIDARG;
1762
1763 if (This->reverted)
1764 return STG_E_REVERTED;
1765
1767 This,
1768 This->storageDirEntry);
1769
1770 if (newEnum)
1771 {
1772 *ppenum = &newEnum->IEnumSTATSTG_iface;
1773 return S_OK;
1774 }
1775
1776 return E_OUTOFMEMORY;
1777}
uint8_t reserved3
Definition: fsck.fat.h:26

◆ StorageBaseImpl_IsStorageOpen()

static BOOL StorageBaseImpl_IsStorageOpen ( StorageBaseImpl stg,
DirRef  storageEntry 
)
static

Definition at line 1471 of file storage32.c.

1472{
1473 StorageInternalImpl *childstg;
1474
1475 TRACE("%p,%d\n", stg, storageEntry);
1476
1477 LIST_FOR_EACH_ENTRY(childstg, &stg->storageHead, StorageInternalImpl, ParentListEntry)
1478 {
1479 if (childstg->base.storageDirEntry == storageEntry)
1480 {
1481 return TRUE;
1482 }
1483 }
1484
1485 return FALSE;
1486}
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198

Referenced by StorageBaseImpl_OpenStorage(), and StorageBaseImpl_RenameElement().

◆ StorageBaseImpl_IsStreamOpen()

static BOOL StorageBaseImpl_IsStreamOpen ( StorageBaseImpl stg,
DirRef  streamEntry 
)
static

Definition at line 1454 of file storage32.c.

1455{
1456 StgStreamImpl *strm;
1457
1458 TRACE("%p,%d\n", stg, streamEntry);
1459
1460 LIST_FOR_EACH_ENTRY(strm, &stg->strmHead, StgStreamImpl, StrmListEntry)
1461 {
1462 if (strm->dirEntry == streamEntry)
1463 {
1464 return TRUE;
1465 }
1466 }
1467
1468 return FALSE;
1469}

Referenced by StorageBaseImpl_OpenStream(), and StorageBaseImpl_RenameElement().

◆ StorageBaseImpl_MoveElementTo()

static HRESULT WINAPI StorageBaseImpl_MoveElementTo ( IStorage iface,
const OLECHAR pwcsName,
IStorage pstgDest,
const OLECHAR pwcsNewName,
DWORD  grfFlags 
)
static

Definition at line 2377 of file storage32.c.

2383{
2384 FIXME("(%p %s %p %s %u): stub\n", iface,
2385 debugstr_w(pwcsName), pstgDest,
2386 debugstr_w(pwcsNewName), grfFlags);
2387 return E_NOTIMPL;
2388}

◆ StorageBaseImpl_OpenStorage()

static HRESULT WINAPI StorageBaseImpl_OpenStorage ( IStorage iface,
const OLECHAR pwcsName,
IStorage pstgPriority,
DWORD  grfMode,
SNB  snbExclude,
DWORD  reserved,
IStorage **  ppstg 
)
static

Definition at line 1609 of file storage32.c.

1617{
1619 StorageInternalImpl* newStorage;
1620 StorageBaseImpl* newTransactedStorage;
1621 DirEntry currentEntry;
1622 DirRef storageEntryRef;
1624
1625 TRACE("(%p, %s, %p, %x, %p, %d, %p)\n",
1626 iface, debugstr_w(pwcsName), pstgPriority,
1627 grfMode, snbExclude, reserved, ppstg);
1628
1629 if ((pwcsName==NULL) || (ppstg==0) )
1630 {
1631 res = E_INVALIDARG;
1632 goto end;
1633 }
1634
1635 if (This->openFlags & STGM_SIMPLE)
1636 {
1638 goto end;
1639 }
1640
1641 /* as documented */
1642 if (snbExclude != NULL)
1643 {
1645 goto end;
1646 }
1647
1648 if ( FAILED( validateSTGM(grfMode) ))
1649 {
1651 goto end;
1652 }
1653
1654 /*
1655 * As documented.
1656 */
1657 if ( STGM_SHARE_MODE(grfMode) != STGM_SHARE_EXCLUSIVE ||
1658 (grfMode & STGM_DELETEONRELEASE) ||
1659 (grfMode & STGM_PRIORITY) )
1660 {
1662 goto end;
1663 }
1664
1665 if (This->reverted)
1666 return STG_E_REVERTED;
1667
1668 /*
1669 * Check that we're compatible with the parent's storage mode,
1670 * but only if we are not transacted
1671 */
1672 if(!(This->openFlags & STGM_TRANSACTED)) {
1673 if ( STGM_ACCESS_MODE( grfMode ) > STGM_ACCESS_MODE( This->openFlags ) )
1674 {
1676 goto end;
1677 }
1678 }
1679
1680 *ppstg = NULL;
1681
1682 storageEntryRef = findElement(
1683 This,
1684 This->storageDirEntry,
1685 pwcsName,
1686 &currentEntry);
1687
1688 if ( (storageEntryRef!=DIRENTRY_NULL) &&
1689 (currentEntry.stgType==STGTY_STORAGE) )
1690 {
1691 if (StorageBaseImpl_IsStorageOpen(This, storageEntryRef))
1692 {
1693 /* A single storage cannot be opened a second time. */
1695 goto end;
1696 }
1697
1698 newStorage = StorageInternalImpl_Construct(
1699 This,
1700 grfMode,
1701 storageEntryRef);
1702
1703 if (newStorage != 0)
1704 {
1705 if (grfMode & STGM_TRANSACTED)
1706 {
1707 res = Storage_ConstructTransacted(&newStorage->base, FALSE, &newTransactedStorage);
1708
1709 if (FAILED(res))
1710 {
1711 HeapFree(GetProcessHeap(), 0, newStorage);
1712 goto end;
1713 }
1714
1715 *ppstg = &newTransactedStorage->IStorage_iface;
1716 }
1717 else
1718 {
1719 *ppstg = &newStorage->base.IStorage_iface;
1720 }
1721
1722 list_add_tail(&This->storageHead, &newStorage->ParentListEntry);
1723
1724 res = S_OK;
1725 goto end;
1726 }
1727
1729 goto end;
1730 }
1731
1733
1734end:
1735 TRACE("<-- %08x\n", res);
1736 return res;
1737}
static StorageInternalImpl * StorageInternalImpl_Construct(StorageBaseImpl *, DWORD, DirRef)
Definition: storage32.c:5566
static BOOL StorageBaseImpl_IsStorageOpen(StorageBaseImpl *stg, DirRef storageEntry)
Definition: storage32.c:1471
struct list ParentListEntry
Definition: storage32.c:81
#define STG_E_UNKNOWN
Definition: winerror.h:2585

◆ StorageBaseImpl_OpenStream()

static HRESULT WINAPI StorageBaseImpl_OpenStream ( IStorage iface,
const OLECHAR pwcsName,
void reserved1,
DWORD  grfMode,
DWORD  reserved2,
IStream **  ppstm 
)
static

Definition at line 1495 of file storage32.c.

1502{
1504 StgStreamImpl* newStream;
1505 DirEntry currentEntry;
1506 DirRef streamEntryRef;
1508
1509 TRACE("(%p, %s, %p, %x, %d, %p)\n",
1510 iface, debugstr_w(pwcsName), reserved1, grfMode, reserved2, ppstm);
1511
1512 if ( (pwcsName==NULL) || (ppstm==0) )
1513 {
1514 res = E_INVALIDARG;
1515 goto end;
1516 }
1517
1518 *ppstm = NULL;
1519
1520 if ( FAILED( validateSTGM(grfMode) ) ||
1522 {
1524 goto end;
1525 }
1526
1527 /*
1528 * As documented.
1529 */
1530 if ( (grfMode & STGM_DELETEONRELEASE) || (grfMode & STGM_TRANSACTED) )
1531 {
1533 goto end;
1534 }
1535
1536 if (This->reverted)
1537 {
1539 goto end;
1540 }
1541
1542 /*
1543 * Check that we're compatible with the parent's storage mode, but
1544 * only if we are not in transacted mode
1545 */
1546 if(!(This->openFlags & STGM_TRANSACTED)) {
1547 if ( STGM_ACCESS_MODE( grfMode ) > STGM_ACCESS_MODE( This->openFlags ) )
1548 {
1550 goto end;
1551 }
1552 }
1553
1554 /*
1555 * Search for the element with the given name
1556 */
1557 streamEntryRef = findElement(
1558 This,
1559 This->storageDirEntry,
1560 pwcsName,
1561 &currentEntry);
1562
1563 /*
1564 * If it was found, construct the stream object and return a pointer to it.
1565 */
1566 if ( (streamEntryRef!=DIRENTRY_NULL) &&
1567 (currentEntry.stgType==STGTY_STREAM) )
1568 {
1569 if (StorageBaseImpl_IsStreamOpen(This, streamEntryRef))
1570 {
1571 /* A single stream cannot be opened a second time. */
1573 goto end;
1574 }
1575
1576 newStream = StgStreamImpl_Construct(This, grfMode, streamEntryRef);
1577
1578 if (newStream)
1579 {
1580 newStream->grfMode = grfMode;
1581 *ppstm = &newStream->IStream_iface;
1582
1583 IStream_AddRef(*ppstm);
1584
1585 res = S_OK;
1586 goto end;
1587 }
1588
1590 goto end;
1591 }
1592
1594
1595end:
1596 if (res == S_OK)
1597 TRACE("<-- IStream %p\n", *ppstm);
1598 TRACE("<-- %08x\n", res);
1599 return res;
1600}
static BOOL StorageBaseImpl_IsStreamOpen(StorageBaseImpl *stg, DirRef streamEntry)
Definition: storage32.c:1454
DWORD grfMode
Definition: storage32.h:445

◆ StorageBaseImpl_QueryInterface()

static HRESULT WINAPI StorageBaseImpl_QueryInterface ( IStorage iface,
REFIID  riid,
void **  ppvObject 
)
static

Definition at line 1232 of file storage32.c.

1236{
1238
1239 TRACE("%p,%s,%p\n", iface, debugstr_guid(riid), ppvObject);
1240
1241 if (!ppvObject)
1242 return E_INVALIDARG;
1243
1244 *ppvObject = 0;
1245
1246 if (IsEqualGUID(&IID_IUnknown, riid) ||
1247 IsEqualGUID(&IID_IStorage, riid))
1248 {
1249 *ppvObject = &This->IStorage_iface;
1250 }
1251 else if (IsEqualGUID(&IID_IPropertySetStorage, riid))
1252 {
1253 *ppvObject = &This->IPropertySetStorage_iface;
1254 }
1255 /* locking interface is reported for writer only */
1256 else if (IsEqualGUID(&IID_IDirectWriterLock, riid) && This->lockingrole == SWMR_Writer)
1257 {
1258 *ppvObject = &This->IDirectWriterLock_iface;
1259 }
1260 else
1261 {
1262 TRACE("<-- E_NOINTERFACE\n");
1263 return E_NOINTERFACE;
1264 }
1265
1266 IStorage_AddRef(iface);
1267 TRACE("<-- %p\n", *ppvObject);
1268 return S_OK;
1269}
@ SWMR_Writer
Definition: storage32.h:172

◆ StorageBaseImpl_Release()

static ULONG WINAPI StorageBaseImpl_Release ( IStorage iface)
static

Definition at line 1298 of file storage32.c.

1300{
1302
1304
1305 TRACE("(%p) ReleaseRef to %d\n", This, ref);
1306
1307 if (ref == 0)
1308 {
1309 /*
1310 * Since we are using a system of base-classes, we want to call the
1311 * destructor of the appropriate derived class. To do this, we are
1312 * using virtual functions to implement the destructor.
1313 */
1315 }
1316
1317 return ref;
1318}
static void StorageBaseImpl_Destroy(StorageBaseImpl *This)
Definition: storage32.h:258

◆ StorageBaseImpl_RemoveStream()

void StorageBaseImpl_RemoveStream ( StorageBaseImpl stg,
StgStreamImpl strm 
)

Definition at line 2720 of file storage32.c.

2721{
2722 TRACE("Stream removed (stg=%p strm=%p)\n", stg,strm);
2723 list_remove(&(strm->StrmListEntry));
2724}

Referenced by StgStreamImpl_Release().

◆ StorageBaseImpl_RenameElement()

static HRESULT WINAPI StorageBaseImpl_RenameElement ( IStorage iface,
const OLECHAR pwcsOldName,
const OLECHAR pwcsNewName 
)
static

Definition at line 1843 of file storage32.c.

1847{
1849 DirEntry currentEntry;
1850 DirRef currentEntryRef;
1851
1852 TRACE("(%p, %s, %s)\n",
1853 iface, debugstr_w(pwcsOldName), debugstr_w(pwcsNewName));
1854
1855 if (This->reverted)
1856 return STG_E_REVERTED;
1857
1858 currentEntryRef = findElement(This,
1859 This->storageDirEntry,
1860 pwcsNewName,
1861 &currentEntry);
1862
1863 if (currentEntryRef != DIRENTRY_NULL)
1864 {
1865 /*
1866 * There is already an element with the new name
1867 */
1869 }
1870
1871 /*
1872 * Search for the old element name
1873 */
1874 currentEntryRef = findElement(This,
1875 This->storageDirEntry,
1876 pwcsOldName,
1877 &currentEntry);
1878
1879 if (currentEntryRef != DIRENTRY_NULL)
1880 {
1881 if (StorageBaseImpl_IsStreamOpen(This, currentEntryRef) ||
1882 StorageBaseImpl_IsStorageOpen(This, currentEntryRef))
1883 {
1884 WARN("Element is already open; cannot rename.\n");
1885 return STG_E_ACCESSDENIED;
1886 }
1887
1888 /* Remove the element from its current position in the tree */
1889 removeFromTree(This, This->storageDirEntry,
1890 currentEntryRef);
1891
1892 /* Change the name of the element */
1893 lstrcpyW(currentEntry.name, pwcsNewName);
1894
1895 /* Delete any sibling links */
1896 currentEntry.leftChild = DIRENTRY_NULL;
1897 currentEntry.rightChild = DIRENTRY_NULL;
1898
1899 StorageBaseImpl_WriteDirEntry(This, currentEntryRef,
1900 &currentEntry);
1901
1902 /* Insert the element in a new position in the tree */
1903 insertIntoTree(This, This->storageDirEntry,
1904 currentEntryRef);
1905 }
1906 else
1907 {
1908 /*
1909 * There is no element with the old name
1910 */
1911 return STG_E_FILENOTFOUND;
1912 }
1913
1915}

◆ StorageBaseImpl_Revert()

static HRESULT WINAPI StorageBaseImpl_Revert ( IStorage iface)
static

Definition at line 2412 of file storage32.c.

2414{
2415 TRACE("(%p)\n", iface);
2416 return S_OK;
2417}

◆ StorageBaseImpl_SetClass()

static HRESULT WINAPI StorageBaseImpl_SetClass ( IStorage iface,
REFCLSID  clsid 
)
static

Definition at line 2079 of file storage32.c.

2082{
2084 HRESULT hRes;
2085 DirEntry currentEntry;
2086
2087 TRACE("(%p, %s)\n", iface, wine_dbgstr_guid(clsid));
2088
2089 if (This->reverted)
2090 return STG_E_REVERTED;
2091
2093 This->storageDirEntry,
2094 &currentEntry);
2095 if (SUCCEEDED(hRes))
2096 {
2097 currentEntry.clsid = *clsid;
2098
2100 This->storageDirEntry,
2101 &currentEntry);
2102 }
2103
2104 if (SUCCEEDED(hRes))
2106
2107 return hRes;
2108}
static __inline const char * wine_dbgstr_guid(const GUID *id)
Definition: debug.h:197

◆ StorageBaseImpl_SetElementTimes()

static HRESULT WINAPI StorageBaseImpl_SetElementTimes ( IStorage iface,
const OLECHAR pwcsName,
const FILETIME pctime,
const FILETIME patime,
const FILETIME pmtime 
)
static

Definition at line 2682 of file storage32.c.

2688{
2689 FIXME("(%s,...), stub!\n",debugstr_w(pwcsName));
2690 return S_OK;
2691}

◆ StorageBaseImpl_SetStateBits()

static HRESULT WINAPI StorageBaseImpl_SetStateBits ( IStorage iface,
DWORD  grfStateBits,
DWORD  grfMask 
)
static

Definition at line 2696 of file storage32.c.

2700{
2702
2703 if (This->reverted)
2704 return STG_E_REVERTED;
2705
2706 This->stateBits = (This->stateBits & ~grfMask) | (grfStateBits & grfMask);
2707 return S_OK;
2708}

◆ StorageBaseImpl_Stat()

static HRESULT WINAPI StorageBaseImpl_Stat ( IStorage iface,
STATSTG *  pstatstg,
DWORD  grfStatFlag 
)
static

Definition at line 1786 of file storage32.c.

1790{
1792 DirEntry currentEntry;
1794
1795 TRACE("(%p, %p, %x)\n",
1796 iface, pstatstg, grfStatFlag);
1797
1798 if (!pstatstg)
1799 {
1800 res = E_INVALIDARG;
1801 goto end;
1802 }
1803
1804 if (This->reverted)
1805 {
1807 goto end;
1808 }
1809
1811 This,
1812 This->storageDirEntry,
1813 &currentEntry);
1814
1815 if (SUCCEEDED(res))
1816 {
1818 This,
1819 pstatstg,
1820 &currentEntry,
1821 grfStatFlag);
1822
1823 pstatstg->grfMode = This->openFlags;
1824 pstatstg->grfStateBits = This->stateBits;
1825 }
1826
1827end:
1828 if (res == S_OK)
1829 {
1830 TRACE("<-- STATSTG: pwcsName: %s, type: %d, cbSize.Low/High: %d/%d, grfMode: %08x, grfLocksSupported: %d, grfStateBits: %08x\n", debugstr_w(pstatstg->pwcsName), pstatstg->type, pstatstg->cbSize.u.LowPart, pstatstg->cbSize.u.HighPart, pstatstg->grfMode, pstatstg->grfLocksSupported, pstatstg->grfStateBits);
1831 }
1832 TRACE("<-- %08x\n", res);
1833 return res;
1834}

◆ StorageImpl_BaseReadDirEntry()

static HRESULT StorageImpl_BaseReadDirEntry ( StorageBaseImpl base,
DirRef  index,
DirEntry data 
)
static

Definition at line 4332 of file storage32.c.

◆ StorageImpl_BaseWriteDirEntry()

static HRESULT StorageImpl_BaseWriteDirEntry ( StorageBaseImpl base,
DirRef  index,
const DirEntry data 
)
static

Definition at line 4325 of file storage32.c.

4327{
4330}

◆ StorageImpl_CheckLockRange()

static HRESULT StorageImpl_CheckLockRange ( StorageImpl This,
ULONG  start,
ULONG  end,
HRESULT  fail_hr 
)
static

Definition at line 5023 of file storage32.c.

5025{
5026 HRESULT hr;
5028
5029 offset.QuadPart = start;
5030 cb.QuadPart = 1 + end - start;
5031
5032 hr = StorageImpl_LockRegion(This, offset, cb, LOCK_ONLYONCE, NULL);
5033 if (SUCCEEDED(hr)) StorageImpl_UnlockRegion(This, offset, cb, LOCK_ONLYONCE);
5034
5035 if (FAILED(hr))
5036 return fail_hr;
5037 else
5038 return S_OK;
5039}
static HRESULT StorageImpl_LockRegion(StorageImpl *This, ULARGE_INTEGER offset, ULARGE_INTEGER cb, DWORD dwLockType, BOOL *supported)
Definition: storage32.c:4888
static HRESULT StorageImpl_UnlockRegion(StorageImpl *This, ULARGE_INTEGER offset, ULARGE_INTEGER cb, DWORD dwLockType)
Definition: storage32.c:4901
GLuint start
Definition: gl.h:1545
static HMODULE MODULEINFO DWORD cb
Definition: module.c:33

Referenced by StorageImpl_GrabLocks().

◆ StorageImpl_Construct()

static HRESULT StorageImpl_Construct ( HANDLE  hFile,
LPCOLESTR  pwcsName,
ILockBytes pLkbyt,
DWORD  openFlags,
BOOL  fileBased,
BOOL  create,
ULONG  sector_size,
StorageImpl **  result 
)
static

Definition at line 5268 of file storage32.c.

5277{
5279 HRESULT hr = S_OK;
5280 STATSTG stat;
5281
5282 if ( FAILED( validateSTGM(openFlags) ))
5283 return STG_E_INVALIDFLAG;
5284
5285 This = HeapAlloc(GetProcessHeap(), 0, sizeof(StorageImpl));
5286 if (!This)
5287 return E_OUTOFMEMORY;
5288
5289 memset(This, 0, sizeof(StorageImpl));
5290
5291 list_init(&This->base.strmHead);
5292
5293 list_init(&This->base.storageHead);
5294
5295 This->base.IStorage_iface.lpVtbl = &StorageImpl_Vtbl;
5296 This->base.IPropertySetStorage_iface.lpVtbl = &IPropertySetStorage_Vtbl;
5297 This->base.IDirectWriterLock_iface.lpVtbl = &DirectWriterLockVtbl;
5298 This->base.baseVtbl = &StorageImpl_BaseVtbl;
5299 This->base.openFlags = (openFlags & ~STGM_CREATE);
5300 This->base.ref = 1;
5301 This->base.create = create;
5302
5304 This->base.lockingrole = SWMR_Writer;
5306 This->base.lockingrole = SWMR_Reader;
5307 else
5308 This->base.lockingrole = SWMR_None;
5309
5310 This->base.reverted = FALSE;
5311
5312 /*
5313 * Initialize the big block cache.
5314 */
5315 This->bigBlockSize = sector_size;
5316 This->smallBlockSize = DEF_SMALL_BLOCK_SIZE;
5317 if (hFile)
5318 hr = FileLockBytesImpl_Construct(hFile, openFlags, pwcsName, &This->lockBytes);
5319 else
5320 {
5321 This->lockBytes = pLkbyt;
5322 ILockBytes_AddRef(pLkbyt);
5323 }
5324
5325 if (SUCCEEDED(hr))
5326 hr = ILockBytes_Stat(This->lockBytes, &stat, STATFLAG_NONAME);
5327
5328 if (SUCCEEDED(hr))
5329 {
5330 This->locks_supported = stat.grfLocksSupported;
5331 if (!hFile)
5332 /* Don't try to use wine-internal locking flag with custom ILockBytes */
5333 This->locks_supported &= ~WINE_LOCK_READ;
5334
5335 hr = StorageImpl_GrabLocks(This, openFlags);
5336 }
5337
5338 if (SUCCEEDED(hr))
5340
5341 if (FAILED(hr))
5342 {
5343 IStorage_Release(&This->base.IStorage_iface);
5344 *result = NULL;
5345 }
5346 else
5347 {
5348 StorageImpl_Flush(&This->base);
5349 *result = This;
5350 }
5351
5352 return hr;
5353}
static void list_init(struct list_entry *head)
Definition: list.h:51
const IPropertySetStorageVtbl IPropertySetStorage_Vtbl
Definition: stg_prop.c:2557
static HRESULT StorageImpl_GrabLocks(StorageImpl *This, DWORD openFlags)
Definition: storage32.c:5072
static const StorageBaseImplVtbl StorageImpl_BaseVtbl
Definition: storage32.c:5222
static const IStorageVtbl StorageImpl_Vtbl
Definition: storage32.c:5246
static HRESULT StorageImpl_Flush(StorageBaseImpl *storage)
Definition: storage32.c:5152
static HRESULT StorageImpl_Refresh(StorageImpl *This, BOOL new_object, BOOL create)
Definition: storage32.c:4623
static const IDirectWriterLockVtbl DirectWriterLockVtbl
Definition: storage32.c:484
HRESULT FileLockBytesImpl_Construct(HANDLE hFile, DWORD openFlags, LPCWSTR pwcsName, ILockBytes **pLockBytes)
Definition: filelockbytes.c:89
if(dx< 0)
Definition: linetemp.h:194
@ SWMR_Reader
Definition: storage32.h:173
@ SWMR_None
Definition: storage32.h:171

Referenced by Storage_Construct().

◆ StorageImpl_CreateDirEntry()

static HRESULT StorageImpl_CreateDirEntry ( StorageBaseImpl base,
const DirEntry newData,
DirRef index 
)
static

Definition at line 3317 of file storage32.c.

3321{
3323 ULONG currentEntryIndex = 0;
3324 ULONG newEntryIndex = DIRENTRY_NULL;
3325 HRESULT hr = S_OK;
3326 BYTE currentData[RAW_DIRENTRY_SIZE];
3327 WORD sizeOfNameString;
3328
3329 do
3330 {
3332 currentEntryIndex,
3333 currentData);
3334
3335 if (SUCCEEDED(hr))
3336 {
3338 currentData,
3340 &sizeOfNameString);
3341
3342 if (sizeOfNameString == 0)
3343 {
3344 /*
3345 * The entry exists and is available, we found it.
3346 */
3347 newEntryIndex = currentEntryIndex;
3348 }
3349 }
3350 else
3351 {
3352 /*
3353 * We exhausted the directory entries, we will create more space below
3354 */
3355 newEntryIndex = currentEntryIndex;
3356 }
3357 currentEntryIndex++;
3358
3359 } while (newEntryIndex == DIRENTRY_NULL);
3360
3361 /*
3362 * grow the directory stream
3363 */
3364 if (FAILED(hr))
3365 {
3366 BYTE emptyData[RAW_DIRENTRY_SIZE];
3367 ULARGE_INTEGER newSize;
3368 ULONG entryIndex;
3369 ULONG lastEntry = 0;
3370 ULONG blockCount = 0;
3371
3372 /*
3373 * obtain the new count of blocks in the directory stream
3374 */
3375 blockCount = BlockChainStream_GetCount(
3376 storage->rootBlockChain)+1;
3377
3378 /*
3379 * initialize the size used by the directory stream
3380 */
3381 newSize.QuadPart = (ULONGLONG)storage->bigBlockSize * blockCount;
3382
3383 /*
3384 * add a block to the directory stream
3385 */
3386 BlockChainStream_SetSize(storage->rootBlockChain, newSize);
3387
3388 /*
3389 * memset the empty entry in order to initialize the unused newly
3390 * created entries
3391 */
3392 memset(emptyData, 0, RAW_DIRENTRY_SIZE);
3393
3394 /*
3395 * initialize them
3396 */
3397 lastEntry = storage->bigBlockSize / RAW_DIRENTRY_SIZE * blockCount;
3398
3399 for(
3400 entryIndex = newEntryIndex + 1;
3401 entryIndex < lastEntry;
3402 entryIndex++)
3403 {
3405 storage,
3406 entryIndex,
3407 emptyData);
3408 }
3409
3411 }
3412
3413 UpdateRawDirEntry(currentData, newData);
3414
3415 hr = StorageImpl_WriteRawDirEntry(storage, newEntryIndex, currentData);
3416
3417 if (SUCCEEDED(hr))
3418 *index = newEntryIndex;
3419
3420 return hr;
3421}
void StorageUtl_ReadWord(const BYTE *buffer, ULONG offset, WORD *value)
Definition: storage32.c:6943
static HRESULT StorageImpl_ReadRawDirEntry(StorageImpl *This, ULONG index, BYTE *buffer)
Definition: storage32.c:3171
static HRESULT StorageImpl_WriteRawDirEntry(StorageImpl *This, ULONG index, const BYTE *buffer)
Definition: storage32.c:3199
static void UpdateRawDirEntry(BYTE *buffer, const DirEntry *newData)
Definition: storage32.c:3239
unsigned short WORD
Definition: ntddk_ex.h:93
#define RAW_DIRENTRY_SIZE
Definition: storage32.h:91
static const ULONG OFFSET_PS_NAMELENGTH
Definition: storage32.h:62

◆ StorageImpl_DeleteCachedBlockChainStream()

static void StorageImpl_DeleteCachedBlockChainStream ( StorageImpl This,
DirRef  index 
)
static

Definition at line 4396 of file storage32.c.

4397{
4398 int i;
4399
4400 for (i=0; i<BLOCKCHAIN_CACHE_SIZE; i++)
4401 {
4402 if (This->blockChainCache[i] && This->blockChainCache[i]->ownerDirEntry == index)
4403 {
4404 BlockChainStream_Destroy(This->blockChainCache[i]);
4405 This->blockChainCache[i] = NULL;
4406 return;
4407 }
4408 }
4409}
#define BLOCKCHAIN_CACHE_SIZE
Definition: storage32.h:363

Referenced by StorageImpl_StreamLink().

◆ StorageImpl_Destroy()

static void StorageImpl_Destroy ( StorageBaseImpl iface)
static

Definition at line 5186 of file storage32.c.

5187{
5188 StorageImpl *This = (StorageImpl*) iface;
5189 int i;
5190 TRACE("(%p)\n", This);
5191
5192 StorageImpl_Flush(iface);
5193
5195
5196 HeapFree(GetProcessHeap(), 0, This->extBigBlockDepotLocations);
5197
5198 BlockChainStream_Destroy(This->smallBlockRootChain);
5199 BlockChainStream_Destroy(This->rootBlockChain);
5200 BlockChainStream_Destroy(This->smallBlockDepotChain);
5201
5202 for (i = 0; i < BLOCKCHAIN_CACHE_SIZE; i++)
5203 BlockChainStream_Destroy(This->blockChainCache[i]);
5204
5205 for (i = 0; i < ARRAY_SIZE(This->locked_bytes); i++)
5206 {
5208 cb.QuadPart = 1;
5209 if (This->locked_bytes[i] != 0)
5210 {
5211 offset.QuadPart = This->locked_bytes[i];
5212 StorageImpl_UnlockRegion(This, offset, cb, LOCK_ONLYONCE);
5213 }
5214 }
5215
5216 if (This->lockBytes)
5217 ILockBytes_Release(This->lockBytes);
5219}
#define ARRAY_SIZE(A)
Definition: main.h:20
static void StorageImpl_Invalidate(StorageBaseImpl *iface)
Definition: storage32.c:5177

◆ StorageImpl_DestroyDirEntry()

static HRESULT StorageImpl_DestroyDirEntry ( StorageBaseImpl base,
DirRef  index 
)
static

Definition at line 3220 of file storage32.c.

3223{
3224 BYTE emptyData[RAW_DIRENTRY_SIZE];
3226
3227 memset(emptyData, 0, RAW_DIRENTRY_SIZE);
3228
3229 return StorageImpl_WriteRawDirEntry(storage, index, emptyData);
3230}

◆ StorageImpl_Flush()

static HRESULT StorageImpl_Flush ( StorageBaseImpl storage)
static

Definition at line 5152 of file storage32.c.

5153{
5155 int i;
5156 HRESULT hr;
5157 TRACE("(%p)\n", This);
5158
5159 hr = BlockChainStream_Flush(This->smallBlockRootChain);
5160
5161 if (SUCCEEDED(hr))
5162 hr = BlockChainStream_Flush(This->rootBlockChain);
5163
5164 if (SUCCEEDED(hr))
5165 hr = BlockChainStream_Flush(This->smallBlockDepotChain);
5166
5167 for (i=0; SUCCEEDED(hr) && i<BLOCKCHAIN_CACHE_SIZE; i++)
5168 if (This->blockChainCache[i])
5169 hr = BlockChainStream_Flush(This->blockChainCache[i]);
5170
5171 if (SUCCEEDED(hr))
5172 hr = ILockBytes_Flush(This->lockBytes);
5173
5174 return hr;
5175}

Referenced by StorageImpl_Construct(), and StorageImpl_Destroy().

◆ StorageImpl_FreeBigBlock()

static void StorageImpl_FreeBigBlock ( StorageImpl This,
ULONG  blockIndex 
)
static

Definition at line 4314 of file storage32.c.

4317{
4319
4320 if (blockIndex < This->prevFreeBlock)
4321 This->prevFreeBlock = blockIndex;
4322}

Referenced by BlockChainStream_Shrink().

◆ StorageImpl_GetBigBlockOffset()

static ULONGLONG StorageImpl_GetBigBlockOffset ( StorageImpl This,
ULONG  index 
)
static

◆ StorageImpl_GetCachedBlockChainStream()

static BlockChainStream ** StorageImpl_GetCachedBlockChainStream ( StorageImpl This,
DirRef  index 
)
static

Definition at line 4363 of file storage32.c.

4365{
4366 int i, free_index=-1;
4367
4368 for (i=0; i<BLOCKCHAIN_CACHE_SIZE; i++)
4369 {
4370 if (!This->blockChainCache[i])
4371 {
4372 if (free_index == -1) free_index = i;
4373 }
4374 else if (This->blockChainCache[i]->ownerDirEntry == index)
4375 {
4376 return &This->blockChainCache[i];
4377 }
4378 }
4379
4380 if (free_index == -1)
4381 {
4382 free_index = This->blockChainToEvict;
4383
4384 BlockChainStream_Destroy(This->blockChainCache[free_index]);
4385 This->blockChainCache[free_index] = NULL;
4386
4387 This->blockChainToEvict++;
4388 if (This->blockChainToEvict == BLOCKCHAIN_CACHE_SIZE)
4389 This->blockChainToEvict = 0;
4390 }
4391
4392 This->blockChainCache[free_index] = BlockChainStream_Construct(This, NULL, index);
4393 return &This->blockChainCache[free_index];
4394}

Referenced by StorageImpl_StreamReadAt(), StorageImpl_StreamSetSize(), and StorageImpl_StreamWriteAt().

◆ StorageImpl_GetFilename()

static HRESULT StorageImpl_GetFilename ( StorageBaseImpl iface,
LPWSTR result 
)
static

Definition at line 5010 of file storage32.c.

5011{
5012 StorageImpl *This = (StorageImpl*) iface;
5013 STATSTG statstg;
5014 HRESULT hr;
5015
5016 hr = ILockBytes_Stat(This->lockBytes, &statstg, 0);
5017
5018 *result = statstg.pwcsName;
5019
5020 return hr;
5021}

◆ StorageImpl_GetFreeBlockChainCacheEntry()

static BlockChainStream ** StorageImpl_GetFreeBlockChainCacheEntry ( StorageImpl This)
static

Definition at line 4339 of file storage32.c.

4340{
4341 int i;
4342
4343 for (i=0; i<BLOCKCHAIN_CACHE_SIZE; i++)
4344 {
4345 if (!This->blockChainCache[i])
4346 {
4347 return &This->blockChainCache[i];
4348 }
4349 }
4350
4351 i = This->blockChainToEvict;
4352
4353 BlockChainStream_Destroy(This->blockChainCache[i]);
4354 This->blockChainCache[i] = NULL;
4355
4356 This->blockChainToEvict++;
4357 if (This->blockChainToEvict == BLOCKCHAIN_CACHE_SIZE)
4358 This->blockChainToEvict = 0;
4359
4360 return &This->blockChainCache[i];
4361}

Referenced by StorageImpl_StreamSetSize().

◆ StorageImpl_GetNextBlockInChain()

static HRESULT StorageImpl_GetNextBlockInChain ( StorageImpl This,
ULONG  blockIndex,
ULONG nextBlockIndex 
)
static

Definition at line 4021 of file storage32.c.

4025{
4026 ULONG offsetInDepot = blockIndex * sizeof (ULONG);
4027 ULONG depotBlockCount = offsetInDepot / This->bigBlockSize;
4028 ULONG depotBlockOffset = offsetInDepot % This->bigBlockSize;
4029 BYTE depotBuffer[MAX_BIG_BLOCK_SIZE];
4030 ULONG read;
4031 ULONG depotBlockIndexPos;
4032 int index, num_blocks;
4033
4034 *nextBlockIndex = BLOCK_SPECIAL;
4035
4036 if(depotBlockCount >= This->bigBlockDepotCount)
4037 {
4038 WARN("depotBlockCount %d, bigBlockDepotCount %d\n", depotBlockCount,
4039 This->bigBlockDepotCount);
4040 return STG_E_READFAULT;
4041 }
4042
4043 /*
4044 * Cache the currently accessed depot block.
4045 */
4046 if (depotBlockCount != This->indexBlockDepotCached)
4047 {
4048 This->indexBlockDepotCached = depotBlockCount;
4049
4050 if (depotBlockCount < COUNT_BBDEPOTINHEADER)
4051 {
4052 depotBlockIndexPos = This->bigBlockDepotStart[depotBlockCount];
4053 }
4054 else
4055 {
4056 /*
4057 * We have to look in the extended depot.
4058 */
4059 depotBlockIndexPos = Storage32Impl_GetExtDepotBlock(This, depotBlockCount);
4060 }
4061
4062 StorageImpl_ReadBigBlock(This, depotBlockIndexPos, depotBuffer, &read);
4063
4064 if (!read)
4065 return STG_E_READFAULT;
4066
4067 num_blocks = This->bigBlockSize / 4;
4068
4069 for (index = 0; index < num_blocks; index++)
4070 {
4071 StorageUtl_ReadDWord(depotBuffer, index*sizeof(ULONG), nextBlockIndex);
4072 This->blockDepotCached[index] = *nextBlockIndex;
4073 }
4074 }
4075
4076 *nextBlockIndex = This->blockDepotCached[depotBlockOffset/sizeof(ULONG)];
4077
4078 return S_OK;
4079}
static ULONG Storage32Impl_GetExtDepotBlock(StorageImpl *This, ULONG depotIndex)
Definition: storage32.c:3863

Referenced by BlockChainStream_Enlarge(), and BlockChainStream_UpdateIndexCache().

◆ StorageImpl_GetNextFreeBigBlock()

static ULONG StorageImpl_GetNextFreeBigBlock ( StorageImpl This)
static

Definition at line 4171 of file storage32.c.

4173{
4174 ULONG depotBlockIndexPos;
4175 BYTE depotBuffer[MAX_BIG_BLOCK_SIZE];
4176 ULONG depotBlockOffset;
4177 ULONG blocksPerDepot = This->bigBlockSize / sizeof(ULONG);
4178 ULONG nextBlockIndex = BLOCK_SPECIAL;
4179 int depotIndex = 0;
4180 ULONG freeBlock = BLOCK_UNUSED;
4181 ULONG read;
4182 ULARGE_INTEGER neededSize;
4183 STATSTG statstg;
4184
4185 depotIndex = This->prevFreeBlock / blocksPerDepot;
4186 depotBlockOffset = (This->prevFreeBlock % blocksPerDepot) * sizeof(ULONG);
4187
4188 /*
4189 * Scan the entire big block depot until we find a block marked free
4190 */
4191 while (nextBlockIndex != BLOCK_UNUSED)
4192 {
4193 if (depotIndex < COUNT_BBDEPOTINHEADER)
4194 {
4195 depotBlockIndexPos = This->bigBlockDepotStart[depotIndex];
4196
4197 /*
4198 * Grow the primary depot.
4199 */
4200 if (depotBlockIndexPos == BLOCK_UNUSED)
4201 {
4202 depotBlockIndexPos = depotIndex*blocksPerDepot;
4203
4204 /*
4205 * Add a block depot.
4206 */
4207 Storage32Impl_AddBlockDepot(This, depotBlockIndexPos, depotIndex);
4208 This->bigBlockDepotCount++;
4209 This->bigBlockDepotStart[depotIndex] = depotBlockIndexPos;
4210
4211 /*
4212 * Flag it as a block depot.
4213 */
4215 depotBlockIndexPos,
4217
4218 /* Save new header information.
4219 */
4221 }
4222 }
4223 else
4224 {
4225 depotBlockIndexPos = Storage32Impl_GetExtDepotBlock(This, depotIndex);
4226
4227 if (depotBlockIndexPos == BLOCK_UNUSED)
4228 {
4229 /*
4230 * Grow the extended depot.
4231 */
4232 ULONG extIndex = BLOCK_UNUSED;
4233 ULONG numExtBlocks = depotIndex - COUNT_BBDEPOTINHEADER;
4234 ULONG extBlockOffset = numExtBlocks % (blocksPerDepot - 1);
4235
4236 if (extBlockOffset == 0)
4237 {
4238 /* We need an extended block.
4239 */
4241 This->extBigBlockDepotCount++;
4242 depotBlockIndexPos = extIndex + 1;
4243 }
4244 else
4245 depotBlockIndexPos = depotIndex * blocksPerDepot;
4246
4247 /*
4248 * Add a block depot and mark it in the extended block.
4249 */
4250 Storage32Impl_AddBlockDepot(This, depotBlockIndexPos, depotIndex);
4251 This->bigBlockDepotCount++;
4252 Storage32Impl_SetExtDepotBlock(This, depotIndex, depotBlockIndexPos);
4253
4254 /* Flag the block depot.
4255 */
4257 depotBlockIndexPos,
4259
4260 /* If necessary, flag the extended depot block.
4261 */
4262 if (extIndex != BLOCK_UNUSED)
4264
4265 /* Save header information.
4266 */
4268 }
4269 }
4270
4271 StorageImpl_ReadBigBlock(This, depotBlockIndexPos, depotBuffer, &read);
4272
4273 if (read)
4274 {
4275 while ( ( (depotBlockOffset/sizeof(ULONG) ) < blocksPerDepot) &&
4276 ( nextBlockIndex != BLOCK_UNUSED))
4277 {
4278 StorageUtl_ReadDWord(depotBuffer, depotBlockOffset, &nextBlockIndex);
4279
4280 if (nextBlockIndex == BLOCK_UNUSED)
4281 {
4282 freeBlock = (depotIndex * blocksPerDepot) +
4283 (depotBlockOffset/sizeof(ULONG));
4284 }
4285
4286 depotBlockOffset += sizeof(ULONG);
4287 }
4288 }
4289
4290 depotIndex++;
4291 depotBlockOffset = 0;
4292 }
4293
4294 /*
4295 * make sure that the block physically exists before using it
4296 */
4297 neededSize.QuadPart = StorageImpl_GetBigBlockOffset(This, freeBlock)+This->bigBlockSize;
4298
4299 ILockBytes_Stat(This->lockBytes, &statstg, STATFLAG_NONAME);
4300
4301 if (neededSize.QuadPart > statstg.cbSize.QuadPart)
4302 ILockBytes_SetSize(This->lockBytes, neededSize);
4303
4304 This->prevFreeBlock = freeBlock;
4305
4306 return freeBlock;
4307}
static void Storage32Impl_AddBlockDepot(StorageImpl *This, ULONG blockIndex, ULONG depotIndex)
Definition: storage32.c:3835
static ULONG Storage32Impl_AddExtBlockDepot(StorageImpl *This)
Definition: storage32.c:3940
static void Storage32Impl_SetExtDepotBlock(StorageImpl *This, ULONG depotIndex, ULONG blockIndex)
Definition: storage32.c:3908
static const ULONG BLOCK_EXTBBDEPOT
Definition: storage32.h:82

Referenced by BlockChainStream_Enlarge().

◆ StorageImpl_GetTransactionSig()

static HRESULT StorageImpl_GetTransactionSig ( StorageBaseImpl base,
ULONG result,
BOOL  refresh 
)
static

Definition at line 4838 of file storage32.c.

4840{
4842 HRESULT hr=S_OK;
4843 DWORD oldTransactionSig = This->transactionSig;
4844
4845 if (refresh)
4846 {
4848 ULONG bytes_read;
4849 BYTE data[4];
4850
4851 offset.u.HighPart = 0;
4852 offset.u.LowPart = OFFSET_TRANSACTIONSIG;
4853 hr = StorageImpl_ReadAt(This, offset, data, 4, &bytes_read);
4854
4855 if (SUCCEEDED(hr))
4856 {
4857 StorageUtl_ReadDWord(data, 0, &This->transactionSig);
4858
4859 if (oldTransactionSig != This->transactionSig)
4860 {
4861 /* Someone else wrote to this, so toss all cached information. */
4862 TRACE("signature changed\n");
4863
4865 }
4866
4867 if (FAILED(hr))
4868 This->transactionSig = oldTransactionSig;
4869 }
4870 }
4871
4872 *result = This->transactionSig;
4873
4874 return hr;
4875}
static const ULONG OFFSET_TRANSACTIONSIG
Definition: storage32.h:54

◆ StorageImpl_GrabLocks()

static HRESULT StorageImpl_GrabLocks ( StorageImpl This,
DWORD  openFlags 
)
static

Definition at line 5072 of file storage32.c.

5073{
5074 HRESULT hr;
5077 DWORD share_mode = STGM_SHARE_MODE(openFlags);
5078 BOOL supported;
5079
5080 if (openFlags & STGM_NOSNAPSHOT)
5081 {
5082 /* STGM_NOSNAPSHOT implies deny write */
5083 if (share_mode == STGM_SHARE_DENY_READ) share_mode = STGM_SHARE_EXCLUSIVE;
5084 else if (share_mode != STGM_SHARE_EXCLUSIVE) share_mode = STGM_SHARE_DENY_WRITE;
5085 }
5086
5087 /* Wrap all other locking inside a single lock so we can check ranges safely */
5088 offset.QuadPart = RANGELOCK_CHECKLOCKS;
5089 cb.QuadPart = 1;
5090 hr = StorageImpl_LockRegionSync(This, offset, cb, LOCK_ONLYONCE, &supported);
5091
5092 /* If the ILockBytes doesn't support locking that's ok. */
5093 if (!supported) return S_OK;
5094 else if (FAILED(hr)) return hr;
5095
5096 hr = S_OK;
5097
5098 /* First check for any conflicting locks. */
5099 if ((openFlags & STGM_PRIORITY) == STGM_PRIORITY)
5101
5102 if (SUCCEEDED(hr) && (STGM_ACCESS_MODE(openFlags) != STGM_WRITE))
5104
5105 if (SUCCEEDED(hr) && (STGM_ACCESS_MODE(openFlags) != STGM_READ))
5107
5108 if (SUCCEEDED(hr) && (share_mode == STGM_SHARE_DENY_READ || share_mode == STGM_SHARE_EXCLUSIVE))
5110
5111 if (SUCCEEDED(hr) && (share_mode == STGM_SHARE_DENY_WRITE || share_mode == STGM_SHARE_EXCLUSIVE))
5113
5114 if (SUCCEEDED(hr) && STGM_ACCESS_MODE(openFlags) == STGM_READ && share_mode == STGM_SHARE_EXCLUSIVE)
5115 {
5117
5118 if (SUCCEEDED(hr))
5120 }
5121
5122 /* Then grab our locks. */
5123 if (SUCCEEDED(hr) && (openFlags & STGM_PRIORITY) == STGM_PRIORITY)
5124 {
5126 if (SUCCEEDED(hr))
5128 }
5129
5130 if (SUCCEEDED(hr) && (STGM_ACCESS_MODE(openFlags) != STGM_WRITE))
5132
5133 if (SUCCEEDED(hr) && (STGM_ACCESS_MODE(openFlags) != STGM_READ))
5135
5136 if (SUCCEEDED(hr) && (share_mode == STGM_SHARE_DENY_READ || share_mode == STGM_SHARE_EXCLUSIVE))
5138
5139 if (SUCCEEDED(hr) && (share_mode == STGM_SHARE_DENY_WRITE || share_mode == STGM_SHARE_EXCLUSIVE))
5141
5142 if (SUCCEEDED(hr) && (openFlags & STGM_NOSNAPSHOT) == STGM_NOSNAPSHOT)
5144
5145 offset.QuadPart = RANGELOCK_CHECKLOCKS;
5146 cb.QuadPart = 1;
5147 StorageImpl_UnlockRegion(This, offset, cb, LOCK_ONLYONCE);
5148
5149 return hr;
5150}
static HRESULT StorageImpl_LockRegionSync(StorageImpl *This, ULARGE_INTEGER offset, ULARGE_INTEGER cb, DWORD dwLockType, BOOL *supported)
Definition: storage32.c:4911
static HRESULT StorageImpl_CheckLockRange(StorageImpl *This, ULONG start, ULONG end, HRESULT fail_hr)
Definition: storage32.c:5023
static HRESULT StorageImpl_LockOne(StorageImpl *This, ULONG start, ULONG end)
Definition: storage32.c:5041
#define RANGELOCK_LAST
Definition: storage32.h:520
#define RANGELOCK_PRIORITY2_FIRST
Definition: storage32.h:504
#define RANGELOCK_CHECKLOCKS
Definition: storage32.h:506
#define RANGELOCK_READ_FIRST
Definition: storage32.h:507
#define RANGELOCK_DENY_WRITE_LAST
Definition: storage32.h:514
#define RANGELOCK_NOSNAPSHOT_LAST
Definition: storage32.h:502
#define RANGELOCK_NOSNAPSHOT_FIRST
Definition: storage32.h:501
#define RANGELOCK_WRITE_LAST
Definition: storage32.h:510
#define RANGELOCK_READ_LAST
Definition: storage32.h:508
#define RANGELOCK_DENY_READ_FIRST
Definition: storage32.h:511
#define RANGELOCK_DENY_READ_LAST
Definition: storage32.h:512
#define RANGELOCK_PRIORITY1_FIRST
Definition: storage32.h:499
#define RANGELOCK_PRIORITY2_LAST
Definition: storage32.h:505
#define RANGELOCK_WRITE_FIRST
Definition: storage32.h:509
#define RANGELOCK_COMMIT
Definition: storage32.h:503
#define RANGELOCK_DENY_WRITE_FIRST
Definition: storage32.h:513
#define RANGELOCK_PRIORITY1_LAST
Definition: storage32.h:500
#define STG_E_LOCKVIOLATION
Definition: winerror.h:2578

Referenced by StorageImpl_Construct().

◆ StorageImpl_Invalidate()

static void StorageImpl_Invalidate ( StorageBaseImpl iface)
static

Definition at line 5177 of file storage32.c.

5178{
5179 StorageImpl *This = (StorageImpl*) iface;
5180
5182
5183 This->base.reverted = TRUE;
5184}
static void StorageBaseImpl_DeleteAll(StorageBaseImpl *stg)
Definition: storage32.c:2653

Referenced by StorageImpl_Destroy().

◆ StorageImpl_LoadFileHeader()

static HRESULT StorageImpl_LoadFileHeader ( StorageImpl This)
static

Definition at line 2893 of file storage32.c.

2895{
2896 HRESULT hr;
2897 BYTE headerBigBlock[HEADER_SIZE];
2898 int index;
2900 DWORD bytes_read;
2901
2902 TRACE("\n");
2903 /*
2904 * Get a pointer to the big block of data containing the header.
2905 */
2906 offset.u.HighPart = 0;
2907 offset.u.LowPart = 0;
2908 hr = StorageImpl_ReadAt(This, offset, headerBigBlock, HEADER_SIZE, &bytes_read);
2909 if (SUCCEEDED(hr) && bytes_read != HEADER_SIZE)
2911
2912 /*
2913 * Extract the information from the header.
2914 */
2915 if (SUCCEEDED(hr))
2916 {
2917 /*
2918 * Check for the "magic number" signature and return an error if it is not
2919 * found.
2920 */
2921 if (memcmp(headerBigBlock, STORAGE_oldmagic, sizeof(STORAGE_oldmagic))==0)
2922 {
2923 return STG_E_OLDFORMAT;
2924 }
2925
2926 if (memcmp(headerBigBlock, STORAGE_magic, sizeof(STORAGE_magic))!=0)
2927 {
2928 return STG_E_INVALIDHEADER;
2929 }
2930
2932 headerBigBlock,
2934 &This->bigBlockSizeBits);
2935
2937 headerBigBlock,
2939 &This->smallBlockSizeBits);
2940
2942 headerBigBlock,
2944 &This->bigBlockDepotCount);
2945
2947 headerBigBlock,
2949 &This->rootStartBlock);
2950
2952 headerBigBlock,
2954 &This->transactionSig);
2955
2957 headerBigBlock,
2959 &This->smallBlockLimit);
2960
2962 headerBigBlock,
2964 &This->smallBlockDepotStart);
2965
2967 headerBigBlock,
2969 &This->extBigBlockDepotStart);
2970
2972 headerBigBlock,
2974 &This->extBigBlockDepotCount);
2975
2976 for (index = 0; index < COUNT_BBDEPOTINHEADER; index ++)
2977 {
2979 headerBigBlock,
2980 OFFSET_BBDEPOTSTART + (sizeof(ULONG)*index),
2981 &(This->bigBlockDepotStart[index]));
2982 }
2983
2984 /*
2985 * Make the bitwise arithmetic to get the size of the blocks in bytes.
2986 */
2987 This->bigBlockSize = 0x000000001 << (DWORD)This->bigBlockSizeBits;
2988 This->smallBlockSize = 0x000000001 << (DWORD)This->smallBlockSizeBits;
2989
2990 /*
2991 * Right now, the code is making some assumptions about the size of the
2992 * blocks, just make sure they are what we're expecting.
2993 */
2994 if ((This->bigBlockSize != MIN_BIG_BLOCK_SIZE && This->bigBlockSize != MAX_BIG_BLOCK_SIZE) ||
2995 This->smallBlockSize != DEF_SMALL_BLOCK_SIZE ||
2996 This->smallBlockLimit != LIMIT_TO_USE_SMALL_BLOCK)
2997 {
2998 FIXME("Broken OLE storage file? bigblock=0x%x, smallblock=0x%x, sblimit=0x%x\n",
2999 This->bigBlockSize, This->smallBlockSize, This->smallBlockLimit);
3001 }
3002 else
3003 hr = S_OK;
3004 }
3005
3006 return hr;
3007}
static const BYTE STORAGE_oldmagic[8]
Definition: storage32.c:62
static const ULONG OFFSET_BIGBLOCKSIZEBITS
Definition: storage32.h:49
static const ULONG OFFSET_SMALLBLOCKLIMIT
Definition: storage32.h:55
static const ULONG OFFSET_EXTBBDEPOTCOUNT
Definition: storage32.h:59
static const ULONG OFFSET_SBDEPOTSTART
Definition: storage32.h:56
static const ULONG OFFSET_BBDEPOTSTART
Definition: storage32.h:60
#define LIMIT_TO_USE_SMALL_BLOCK
Definition: storage32.h:113
static const ULONG OFFSET_ROOTSTARTBLOCK
Definition: storage32.h:53
static const ULONG OFFSET_EXTBBDEPOTSTART
Definition: storage32.h:58
static const ULONG OFFSET_SMALLBLOCKSIZEBITS
Definition: storage32.h:50
static const ULONG OFFSET_BBDEPOTCOUNT
Definition: storage32.h:52
#define STG_E_OLDFORMAT
Definition: winerror.h:2592

Referenced by StorageImpl_Refresh().

◆ StorageImpl_LockOne()

static HRESULT StorageImpl_LockOne ( StorageImpl This,
ULONG  start,
ULONG  end 
)
static

Definition at line 5041 of file storage32.c.

5042{
5043 HRESULT hr=S_OK;
5044 int i, j;
5046
5047 cb.QuadPart = 1;
5048
5049 for (i=start; i<=end; i++)
5050 {
5051 offset.QuadPart = i;
5052 hr = StorageImpl_LockRegion(This, offset, cb, LOCK_ONLYONCE, NULL);
5054 break;
5055 }
5056
5057 if (SUCCEEDED(hr))
5058 {
5059 for (j = 0; j < ARRAY_SIZE(This->locked_bytes); j++)
5060 {
5061 if (This->locked_bytes[j] == 0)
5062 {
5063 This->locked_bytes[j] = i;
5064 break;
5065 }
5066 }
5067 }
5068
5069 return hr;
5070}
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250

Referenced by StorageImpl_GrabLocks().

◆ StorageImpl_LockRegion()

static HRESULT StorageImpl_LockRegion ( StorageImpl This,
ULARGE_INTEGER  offset,
ULARGE_INTEGER  cb,
DWORD  dwLockType,
BOOL supported 
)
static

Definition at line 4888 of file storage32.c.

4890{
4891 if ((dwLockType & This->locks_supported) == 0)
4892 {
4893 if (supported) *supported = FALSE;
4894 return S_OK;
4895 }
4896
4897 if (supported) *supported = TRUE;
4898 return ILockBytes_LockRegion(This->lockBytes, offset, cb, dwLockType);
4899}

Referenced by StorageImpl_CheckLockRange(), StorageImpl_LockOne(), and StorageImpl_LockRegionSync().

◆ StorageImpl_LockRegionSync()

static HRESULT StorageImpl_LockRegionSync ( StorageImpl This,
ULARGE_INTEGER  offset,
ULARGE_INTEGER  cb,
DWORD  dwLockType,
BOOL supported 
)
static

Definition at line 4911 of file storage32.c.

4913{
4914 HRESULT hr;
4915 int delay = 0;
4916 DWORD start_time = GetTickCount();
4917 DWORD last_sanity_check = start_time;
4918 ULARGE_INTEGER sanity_offset, sanity_cb;
4919
4920 sanity_offset.QuadPart = RANGELOCK_UNK1_FIRST;
4922
4923 do
4924 {
4925 hr = StorageImpl_LockRegion(This, offset, cb, dwLockType, supported);
4926
4928 {
4929 DWORD current_time = GetTickCount();
4930 if (current_time - start_time >= 20000)
4931 {
4932 /* timeout */
4933 break;
4934 }
4935 if (current_time - last_sanity_check >= 500)
4936 {
4937 /* Any storage implementation with the file open in a
4938 * shared mode should not lock these bytes for writing. However,
4939 * some programs (LibreOffice Writer) will keep ALL bytes locked
4940 * when opening in exclusive mode. We can use a read lock to
4941 * detect this case early, and not hang a full 20 seconds.
4942 *
4943 * This can collide with another attempt to open the file in
4944 * exclusive mode, but it's unlikely, and someone would fail anyway. */
4945 hr = StorageImpl_LockRegion(This, sanity_offset, sanity_cb, WINE_LOCK_READ, NULL);
4947 break;
4948 if (SUCCEEDED(hr))
4949 {
4950 StorageImpl_UnlockRegion(This, sanity_offset, sanity_cb, WINE_LOCK_READ);
4952 }
4953
4954 last_sanity_check = current_time;
4955 }
4956 Sleep(delay);
4957 if (delay < 150) delay++;
4958 }
4959 } while (hr == STG_E_ACCESSDENIED || hr == STG_E_LOCKVIOLATION);
4960
4961 return hr;
4962}
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:455
#define RANGELOCK_UNK1_LAST
Definition: storage32.h:498
#define WINE_LOCK_READ
Definition: storage32.h:523
#define RANGELOCK_UNK1_FIRST
Definition: storage32.h:497
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790

Referenced by StorageImpl_GrabLocks(), and StorageImpl_LockTransaction().

◆ StorageImpl_LockTransaction()

static HRESULT StorageImpl_LockTransaction ( StorageBaseImpl base,
BOOL  write 
)
static

Definition at line 4964 of file storage32.c.

4965{
4967 HRESULT hr;
4969
4970 if (write)
4971 {
4972 /* Synchronous grab of second priority range, the commit lock, and the
4973 * lock-checking lock. */
4976 }
4977 else
4978 {
4979 offset.QuadPart = RANGELOCK_COMMIT;
4980 cb.QuadPart = 1;
4981 }
4982
4983 hr = StorageImpl_LockRegionSync(This, offset, cb, LOCK_ONLYONCE, NULL);
4984
4985 return hr;
4986}
#define write
Definition: acwin.h:97
#define RANGELOCK_TRANSACTION_LAST
Definition: storage32.h:518
#define RANGELOCK_TRANSACTION_FIRST
Definition: storage32.h:517

◆ StorageImpl_ReadAt()

static HRESULT StorageImpl_ReadAt ( StorageImpl This,
ULARGE_INTEGER  offset,
void buffer,
ULONG  size,
ULONG bytesRead 
)
static

◆ StorageImpl_ReadBigBlock()

static HRESULT StorageImpl_ReadBigBlock ( StorageImpl This,
ULONG  blockIndex,
void buffer,
ULONG out_read 
)
static

Definition at line 3546 of file storage32.c.

3551{
3552 ULARGE_INTEGER ulOffset;
3553 DWORD read=0;
3554 HRESULT hr;
3555
3556 ulOffset.QuadPart = StorageImpl_GetBigBlockOffset(This, blockIndex);
3557
3558 hr = StorageImpl_ReadAt(This, ulOffset, buffer, This->bigBlockSize, &read);
3559
3560 if (SUCCEEDED(hr) && read < This->bigBlockSize)
3561 {
3562 /* File ends during this block; fill the rest with 0's. */
3563 memset((LPBYTE)buffer+read, 0, This->bigBlockSize-read);
3564 }
3565
3566 if (out_read) *out_read = read;
3567
3568 return hr;
3569}
unsigned char * LPBYTE
Definition: typedefs.h:53

Referenced by BlockChainStream_ReadAt(), BlockChainStream_WriteAt(), Storage32Impl_GetExtDepotBlock(), StorageImpl_GetNextBlockInChain(), and StorageImpl_GetNextFreeBigBlock().

◆ StorageImpl_ReadDirEntry()

static HRESULT StorageImpl_ReadDirEntry ( StorageImpl This,
DirRef  index,
DirEntry buffer 
)
static

Definition at line 3428 of file storage32.c.

3432{
3433 BYTE currentEntry[RAW_DIRENTRY_SIZE];
3434 HRESULT readRes;
3435
3436 readRes = StorageImpl_ReadRawDirEntry(This, index, currentEntry);
3437
3438 if (SUCCEEDED(readRes))
3439 {
3440 memset(buffer->name, 0, sizeof(buffer->name));
3441 memcpy(
3442 buffer->name,
3443 (WCHAR *)currentEntry+OFFSET_PS_NAME,
3445 TRACE("storage name: %s\n", debugstr_w(buffer->name));
3446
3447 memcpy(&buffer->stgType, currentEntry + OFFSET_PS_STGTYPE, 1);
3448
3450 currentEntry,
3452 &buffer->sizeOfNameString);
3453
3455 currentEntry,
3457 &buffer->leftChild);
3458
3460 currentEntry,
3462 &buffer->rightChild);
3463
3465 currentEntry,
3467 &buffer->dirRootEntry);
3468
3470 currentEntry,
3472 &buffer->clsid);
3473
3475 currentEntry,
3477 &buffer->ctime.dwLowDateTime);
3478
3480 currentEntry,
3482 &buffer->ctime.dwHighDateTime);
3483
3485 currentEntry,
3487 &buffer->mtime.dwLowDateTime);
3488
3490 currentEntry,
3492 &buffer->mtime.dwHighDateTime);
3493
3495 currentEntry,
3497 &buffer->startingBlock);
3498
3500 currentEntry,
3502 &buffer->size.u.LowPart);
3503
3504 if (This->bigBlockSize < 4096)
3505 {
3506 /* Version 3 files may have junk in the high part of size. */
3507 buffer->size.u.HighPart = 0;
3508 }
3509 else
3510 {
3512 currentEntry,
3514 &buffer->size.u.HighPart);
3515 }
3516 }
3517
3518 return readRes;
3519}
void StorageUtl_ReadGUID(const BYTE *buffer, ULONG offset, GUID *value)
Definition: storage32.c:6999
static const ULONG OFFSET_PS_CTIMELOW
Definition: storage32.h:68
static const ULONG OFFSET_PS_STGTYPE
Definition: storage32.h:63
static const ULONG OFFSET_PS_LEFTCHILD
Definition: storage32.h:64
static const ULONG OFFSET_PS_MTIMELOW
Definition: storage32.h:70
static const ULONG OFFSET_PS_MTIMEHIGH
Definition: storage32.h:71
static const ULONG OFFSET_PS_CTIMEHIGH
Definition: storage32.h:69
static const ULONG OFFSET_PS_SIZE_HIGH
Definition: storage32.h:74
static const ULONG OFFSET_PS_DIRROOT
Definition: storage32.h:66
static const ULONG OFFSET_PS_NAME
Definition: storage32.h:61
static const ULONG OFFSET_PS_SIZE
Definition: storage32.h:73
static const ULONG OFFSET_PS_RIGHTCHILD
Definition: storage32.h:65
static const ULONG OFFSET_PS_STARTBLOCK
Definition: storage32.h:72
static const ULONG OFFSET_PS_GUID
Definition: storage32.h:67

Referenced by BlockChainStream_Enlarge(), BlockChainStream_GetHeadOfChain(), BlockChainStream_GetSize(), BlockChainStream_Shrink(), SmallBlockChainStream_Enlarge(), SmallBlockChainStream_GetHeadOfChain(), SmallBlockChainStream_GetNextFreeBlock(), SmallBlockChainStream_GetSize(), SmallBlockChainStream_Shrink(), Storage32Impl_BigBlocksToSmallBlocks(), Storage32Impl_SmallBlocksToBigBlocks(), StorageImpl_BaseReadDirEntry(), StorageImpl_Refresh(), StorageImpl_StreamLink(), StorageImpl_StreamReadAt(), StorageImpl_StreamSetSize(), and StorageImpl_StreamWriteAt().

◆ StorageImpl_ReadDWordFromBigBlock()

static BOOL StorageImpl_ReadDWordFromBigBlock ( StorageImpl This,
ULONG  blockIndex,
ULONG  offset,
DWORD value 
)
static

Definition at line 3571 of file storage32.c.

3576{
3577 ULARGE_INTEGER ulOffset;
3578 DWORD read;
3579 DWORD tmp;
3580
3581 ulOffset.QuadPart = StorageImpl_GetBigBlockOffset(This, blockIndex);
3582 ulOffset.QuadPart += offset;
3583
3584 StorageImpl_ReadAt(This, ulOffset, &tmp, sizeof(DWORD), &read);
3585 *value = lendian32toh(tmp);
3586 return (read == sizeof(DWORD));
3587}
#define lendian32toh(x)
Definition: storage32.h:548
Definition: pdh_main.c:94

Referenced by Storage32Impl_GetNextExtendedBlock().

◆ StorageImpl_ReadRawDirEntry()

static HRESULT StorageImpl_ReadRawDirEntry ( StorageImpl This,
ULONG  index,
BYTE buffer 
)
static

Definition at line 3171 of file storage32.c.

3172{
3174 HRESULT hr;
3175 ULONG bytesRead;
3176
3178
3180 This->rootBlockChain,
3181 offset,
3183 buffer,
3184 &bytesRead);
3185
3186 if (bytesRead != RAW_DIRENTRY_SIZE)
3187 return STG_E_READFAULT;
3188
3189 return hr;
3190}

Referenced by StorageImpl_CreateDirEntry(), and StorageImpl_ReadDirEntry().

◆ StorageImpl_Refresh()

static HRESULT StorageImpl_Refresh ( StorageImpl This,
BOOL  new_object,
BOOL  create 
)
static

Definition at line 4623 of file storage32.c.

4624{
4625 HRESULT hr=S_OK;
4626 DirEntry currentEntry;
4627 DirRef currentEntryRef;
4628 BlockChainStream *blockChainStream;
4629
4630 if (create)
4631 {
4633 BYTE bigBlockBuffer[MAX_BIG_BLOCK_SIZE];
4634
4635 /* Discard any existing data. */
4636 size.QuadPart = 0;
4637 ILockBytes_SetSize(This->lockBytes, size);
4638
4639 /*
4640 * Initialize all header variables:
4641 * - The big block depot consists of one block and it is at block 0
4642 * - The directory table starts at block 1
4643 * - There is no small block depot
4644 */
4645 memset( This->bigBlockDepotStart,
4647 sizeof(This->bigBlockDepotStart));
4648
4649 This->bigBlockDepotCount = 1;
4650 This->bigBlockDepotStart[0] = 0;
4651 This->rootStartBlock = 1;
4652 This->smallBlockLimit = LIMIT_TO_USE_SMALL_BLOCK;
4653 This->smallBlockDepotStart = BLOCK_END_OF_CHAIN;
4654 if (This->bigBlockSize == 4096)
4655 This->bigBlockSizeBits = MAX_BIG_BLOCK_SIZE_BITS;
4656 else
4657 This->bigBlockSizeBits = MIN_BIG_BLOCK_SIZE_BITS;
4658 This->smallBlockSizeBits = DEF_SMALL_BLOCK_SIZE_BITS;
4659 This->extBigBlockDepotStart = BLOCK_END_OF_CHAIN;
4660 This->extBigBlockDepotCount = 0;
4661
4663
4664 /*
4665 * Add one block for the big block depot and one block for the directory table
4666 */
4667 size.u.HighPart = 0;
4668 size.u.LowPart = This->bigBlockSize * 3;
4669 ILockBytes_SetSize(This->lockBytes, size);
4670
4671 /*
4672 * Initialize the big block depot
4673 */
4674 memset(bigBlockBuffer, BLOCK_UNUSED, This->bigBlockSize);
4675 StorageUtl_WriteDWord(bigBlockBuffer, 0, BLOCK_SPECIAL);
4676 StorageUtl_WriteDWord(bigBlockBuffer, sizeof(ULONG), BLOCK_END_OF_CHAIN);
4677 StorageImpl_WriteBigBlock(This, 0, bigBlockBuffer);
4678 }
4679 else
4680 {
4681 /*
4682 * Load the header for the file.
4683 */
4685
4686 if (FAILED(hr))
4687 {
4688 return hr;
4689 }
4690 }
4691
4692 /*
4693 * There is no block depot cached yet.
4694 */
4695 This->indexBlockDepotCached = 0xFFFFFFFF;
4696 This->indexExtBlockDepotCached = 0xFFFFFFFF;
4697
4698 /*
4699 * Start searching for free blocks with block 0.
4700 */
4701 This->prevFreeBlock = 0;
4702
4703 This->firstFreeSmallBlock = 0;
4704
4705 /* Read the extended big block depot locations. */
4706 if (This->extBigBlockDepotCount != 0)
4707 {
4708 ULONG current_block = This->extBigBlockDepotStart;
4709 ULONG cache_size = This->extBigBlockDepotCount * 2;
4710 ULONG i;
4711
4712 This->extBigBlockDepotLocations = HeapAlloc(GetProcessHeap(), 0, sizeof(ULONG) * cache_size);
4713 if (!This->extBigBlockDepotLocations)
4714 {
4715 return E_OUTOFMEMORY;
4716 }
4717
4718 This->extBigBlockDepotLocationsSize = cache_size;
4719
4720 for (i=0; i<This->extBigBlockDepotCount; i++)
4721 {
4722 if (current_block == BLOCK_END_OF_CHAIN)
4723 {
4724 WARN("File has too few extended big block depot blocks.\n");
4725 return STG_E_DOCFILECORRUPT;
4726 }
4727 This->extBigBlockDepotLocations[i] = current_block;
4728 current_block = Storage32Impl_GetNextExtendedBlock(This, current_block);
4729 }
4730 }
4731 else
4732 {
4733 This->extBigBlockDepotLocations = NULL;
4734 This->extBigBlockDepotLocationsSize = 0;
4735 }
4736
4737 /*
4738 * Create the block chain abstractions.
4739 */
4740 if(!(blockChainStream =
4742 {
4743 return STG_E_READFAULT;
4744 }
4745 if (!new_object)
4746 BlockChainStream_Destroy(This->rootBlockChain);
4747 This->rootBlockChain = blockChainStream;
4748
4749 if(!(blockChainStream =
4750 BlockChainStream_Construct(This, &This->smallBlockDepotStart,
4751 DIRENTRY_NULL)))
4752 {
4753 return STG_E_READFAULT;
4754 }
4755 if (!new_object)
4756 BlockChainStream_Destroy(This->smallBlockDepotChain);
4757 This->smallBlockDepotChain = blockChainStream;
4758
4759 /*
4760 * Write the root storage entry (memory only)
4761 */
4762 if (create)
4763 {
4764 static const WCHAR rootentryW[] = {'R','o','o','t',' ','E','n','t','r','y',0};
4765 DirEntry rootEntry;
4766 /*
4767 * Initialize the directory table
4768 */
4769 memset(&rootEntry, 0, sizeof(rootEntry));
4770 lstrcpyW(rootEntry.name, rootentryW);
4771 rootEntry.sizeOfNameString = sizeof(rootentryW);
4772 rootEntry.stgType = STGTY_ROOT;
4773 rootEntry.leftChild = DIRENTRY_NULL;
4774 rootEntry.rightChild = DIRENTRY_NULL;
4775 rootEntry.dirRootEntry = DIRENTRY_NULL;
4777 rootEntry.size.u.HighPart = 0;
4778 rootEntry.size.u.LowPart = 0;
4779
4780 StorageImpl_WriteDirEntry(This, 0, &rootEntry);
4781 }
4782
4783 /*
4784 * Find the ID of the root storage.
4785 */
4786 currentEntryRef = 0;
4787
4788 do
4789 {
4791 This,
4792 currentEntryRef,
4793 &currentEntry);
4794
4795 if (SUCCEEDED(hr))
4796 {
4797 if ( (currentEntry.sizeOfNameString != 0 ) &&
4798 (currentEntry.stgType == STGTY_ROOT) )
4799 {
4800 This->base.storageDirEntry = currentEntryRef;
4801 }
4802 }
4803
4804 currentEntryRef++;
4805
4806 } while (SUCCEEDED(hr) && (This->base.storageDirEntry == DIRENTRY_NULL) );
4807
4808 if (FAILED(hr))
4809 {
4810 return STG_E_READFAULT;
4811 }
4812
4813 /*
4814 * Create the block chain abstraction for the small block root chain.
4815 */
4816 if(!(blockChainStream =
4817 BlockChainStream_Construct(This, NULL, This->base.storageDirEntry)))
4818 {
4819 return STG_E_READFAULT;
4820 }
4821 if (!new_object)
4822 BlockChainStream_Destroy(This->smallBlockRootChain);
4823 This->smallBlockRootChain = blockChainStream;
4824
4825 if (!new_object)
4826 {
4827 int i;
4828 for (i=0; i<BLOCKCHAIN_CACHE_SIZE; i++)
4829 {
4830 BlockChainStream_Destroy(This->blockChainCache[i]);
4831 This->blockChainCache[i] = NULL;
4832 }
4833 }
4834
4835 return hr;
4836}
static ULONG Storage32Impl_GetNextExtendedBlock(StorageImpl *This, ULONG blockIndex)
Definition: storage32.c:4096
static HRESULT StorageImpl_LoadFileHeader(StorageImpl *This)
Definition: storage32.c:2893
HCRYPTKEY new_object(struct handle_table *lpTable, size_t cbSize, DWORD dwType, DESTRUCTOR destructor, OBJECTHDR **ppObject)
Definition: handle.c:353
static const WORD MIN_BIG_BLOCK_SIZE_BITS
Definition: storage32.h:76
#define STGTY_ROOT
Definition: storage32.h:108
static const WORD DEF_SMALL_BLOCK_SIZE_BITS
Definition: storage32.h:78
static const WORD MAX_BIG_BLOCK_SIZE_BITS
Definition: storage32.h:77

Referenced by StorageImpl_Construct(), and StorageImpl_GetTransactionSig().

◆ StorageImpl_SaveFileHeader()

static void StorageImpl_SaveFileHeader ( StorageImpl This)
static

Definition at line 3014 of file storage32.c.

3016{
3017 BYTE headerBigBlock[HEADER_SIZE];
3018 int index;
3019 HRESULT hr;
3021 DWORD bytes_read, bytes_written;
3022 DWORD major_version, dirsectorcount;
3023
3024 /*
3025 * Get a pointer to the big block of data containing the header.
3026 */
3027 offset.u.HighPart = 0;
3028 offset.u.LowPart = 0;
3029 hr = StorageImpl_ReadAt(This, offset, headerBigBlock, HEADER_SIZE, &bytes_read);
3030 if (SUCCEEDED(hr) && bytes_read != HEADER_SIZE)
3032
3033 if (This->bigBlockSizeBits == 0x9)
3034 major_version = 3;
3035 else if (This->bigBlockSizeBits == 0xc)
3036 major_version = 4;
3037 else
3038 {
3039 ERR("invalid big block shift 0x%x\n", This->bigBlockSizeBits);
3040 major_version = 4;
3041 }
3042
3043 /*
3044 * If the block read failed, the file is probably new.
3045 */
3046 if (FAILED(hr))
3047 {
3048 /*
3049 * Initialize for all unknown fields.
3050 */
3051 memset(headerBigBlock, 0, HEADER_SIZE);
3052
3053 /*
3054 * Initialize the magic number.
3055 */
3056 memcpy(headerBigBlock, STORAGE_magic, sizeof(STORAGE_magic));
3057 }
3058
3059 /*
3060 * Write the information to the header.
3061 */
3063 headerBigBlock,
3065 0x3e);
3066
3068 headerBigBlock,
3070 major_version);
3071
3073 headerBigBlock,
3075 (WORD)-2);
3076
3078 headerBigBlock,
3080 This->bigBlockSizeBits);
3081
3083 headerBigBlock,
3085 This->smallBlockSizeBits);
3086
3087 if (major_version >= 4)
3088 {
3089 if (This->rootBlockChain)
3090 dirsectorcount = BlockChainStream_GetCount(This->rootBlockChain);
3091 else
3092 /* This file is being created, and it will start out with one block. */
3093 dirsectorcount = 1;
3094 }
3095 else
3096 /* This field must be 0 in versions older than 4 */
3097 dirsectorcount = 0;
3098
3100 headerBigBlock,
3102 dirsectorcount);
3103
3105 headerBigBlock,
3107 This->bigBlockDepotCount);
3108
3110 headerBigBlock,
3112 This->rootStartBlock);
3113
3115 headerBigBlock,
3117 This->transactionSig);
3118
3120 headerBigBlock,
3122 This->smallBlockLimit);
3123
3125 headerBigBlock,
3127 This->smallBlockDepotStart);
3128
3130 headerBigBlock,
3132 This->smallBlockDepotChain ?
3133 BlockChainStream_GetCount(This->smallBlockDepotChain) : 0);
3134
3136 headerBigBlock,
3138 This->extBigBlockDepotStart);
3139
3141 headerBigBlock,
3143 This->extBigBlockDepotCount);
3144
3145 for (index = 0; index < COUNT_BBDEPOTINHEADER; index ++)
3146 {
3148 headerBigBlock,
3149 OFFSET_BBDEPOTSTART + (sizeof(ULONG)*index),
3150 (This->bigBlockDepotStart[index]));
3151 }
3152
3153 /*
3154 * Write the big block back to the file.
3155 */
3156 StorageImpl_WriteAt(This, offset, headerBigBlock, HEADER_SIZE, &bytes_written);
3157}
void StorageUtl_WriteWord(BYTE *buffer, ULONG offset, WORD value)
Definition: storage32.c:6951
static const ULONG OFFSET_MAJORVERSION
Definition: storage32.h:47
static const ULONG OFFSET_MINORVERSION
Definition: storage32.h:46
static const ULONG OFFSET_DIRSECTORCOUNT
Definition: storage32.h:51
static const ULONG OFFSET_SBDEPOTCOUNT
Definition: storage32.h:57
static const ULONG OFFSET_BYTEORDERMARKER
Definition: storage32.h:48

Referenced by SmallBlockChainStream_GetNextFreeBlock(), StorageImpl_CreateDirEntry(), StorageImpl_GetNextFreeBigBlock(), StorageImpl_Refresh(), and StorageImpl_SetTransactionSig().

◆ StorageImpl_SetNextBlockInChain()

static void StorageImpl_SetNextBlockInChain ( StorageImpl This,
ULONG  blockIndex,
ULONG  nextBlock 
)
static

Definition at line 4121 of file storage32.c.

4125{
4126 ULONG offsetInDepot = blockIndex * sizeof (ULONG);
4127 ULONG depotBlockCount = offsetInDepot / This->bigBlockSize;
4128 ULONG depotBlockOffset = offsetInDepot % This->bigBlockSize;
4129 ULONG depotBlockIndexPos;
4130
4131 assert(depotBlockCount < This->bigBlockDepotCount);
4132 assert(blockIndex != nextBlock);
4133
4134 if (blockIndex == (RANGELOCK_FIRST / This->bigBlockSize) - 1)
4135 /* This should never happen (storage file format spec forbids it), but
4136 * older versions of Wine may have generated broken files. We don't want to
4137 * assert and potentially lose data, but we do want to know if this ever
4138 * happens in a newly-created file. */
4139 ERR("Using range lock page\n");
4140
4141 if (depotBlockCount < COUNT_BBDEPOTINHEADER)
4142 {
4143 depotBlockIndexPos = This->bigBlockDepotStart[depotBlockCount];
4144 }
4145 else
4146 {
4147 /*
4148 * We have to look in the extended depot.
4149 */
4150 depotBlockIndexPos = Storage32Impl_GetExtDepotBlock(This, depotBlockCount);
4151 }
4152
4153 StorageImpl_WriteDWordToBigBlock(This, depotBlockIndexPos, depotBlockOffset,
4154 nextBlock);
4155 /*
4156 * Update the cached block depot, if necessary.
4157 */
4158 if (depotBlockCount == This->indexBlockDepotCached)
4159 {
4160 This->blockDepotCached[depotBlockOffset/sizeof(ULONG)] = nextBlock;
4161 }
4162}

Referenced by BlockChainStream_Enlarge(), BlockChainStream_Shrink(), StorageImpl_FreeBigBlock(), and StorageImpl_GetNextFreeBigBlock().

◆ StorageImpl_SetTransactionSig()

static HRESULT StorageImpl_SetTransactionSig ( StorageBaseImpl base,
ULONG  value 
)
static

Definition at line 4877 of file storage32.c.

4879{
4881
4882 This->transactionSig = value;
4884
4885 return S_OK;
4886}

◆ StorageImpl_StreamLink()

static HRESULT StorageImpl_StreamLink ( StorageBaseImpl base,
DirRef  dst,
DirRef  src 
)
static

Definition at line 4599 of file storage32.c.

4601{
4603 DirEntry dst_data, src_data;
4604 HRESULT hr;
4605
4606 hr = StorageImpl_ReadDirEntry(This, dst, &dst_data);
4607
4608 if (SUCCEEDED(hr))
4609 hr = StorageImpl_ReadDirEntry(This, src, &src_data);
4610
4611 if (SUCCEEDED(hr))
4612 {
4614 dst_data.startingBlock = src_data.startingBlock;
4615 dst_data.size = src_data.size;
4616
4617 hr = StorageImpl_WriteDirEntry(This, dst, &dst_data);
4618 }
4619
4620 return hr;
4621}
static void StorageImpl_DeleteCachedBlockChainStream(StorageImpl *This, DirRef index)
Definition: storage32.c:4396

◆ StorageImpl_StreamReadAt()

static HRESULT StorageImpl_StreamReadAt ( StorageBaseImpl base,
DirRef  index,
ULARGE_INTEGER  offset,
ULONG  size,
void buffer,
ULONG bytesRead 
)
static

Definition at line 4411 of file storage32.c.

4413{
4415 DirEntry data;
4416 HRESULT hr;
4417 ULONG bytesToRead;
4418
4420 if (FAILED(hr)) return hr;
4421
4422 if (data.size.QuadPart == 0)
4423 {
4424 *bytesRead = 0;
4425 return S_OK;
4426 }
4427
4428 if (offset.QuadPart + size > data.size.QuadPart)
4429 {
4430 bytesToRead = data.size.QuadPart - offset.QuadPart;
4431 }
4432 else
4433 {
4434 bytesToRead = size;
4435 }
4436
4437 if (data.size.QuadPart < LIMIT_TO_USE_SMALL_BLOCK)
4438 {
4440
4442 if (!stream) return E_OUTOFMEMORY;
4443
4444 hr = SmallBlockChainStream_ReadAt(stream, offset, bytesToRead, buffer, bytesRead);
4445
4447
4448 return hr;
4449 }
4450 else
4451 {
4453
4455 if (!stream) return E_OUTOFMEMORY;
4456
4457 hr = BlockChainStream_ReadAt(stream, offset, bytesToRead, buffer, bytesRead);
4458
4459 return hr;
4460 }
4461}
static BlockChainStream ** StorageImpl_GetCachedBlockChainStream(StorageImpl *This, DirRef index)
Definition: storage32.c:4363

◆ StorageImpl_StreamSetSize()

static HRESULT StorageImpl_StreamSetSize ( StorageBaseImpl base,
DirRef  index,
ULARGE_INTEGER  newsize 
)
static

Definition at line 4463 of file storage32.c.

4465{
4467 DirEntry data;
4468 HRESULT hr;
4469 SmallBlockChainStream *smallblock=NULL;
4470 BlockChainStream **pbigblock=NULL, *bigblock=NULL;
4471
4473 if (FAILED(hr)) return hr;
4474
4475 /* In simple mode keep the stream size above the small block limit */
4476 if (This->base.openFlags & STGM_SIMPLE)
4477 newsize.QuadPart = max(newsize.QuadPart, LIMIT_TO_USE_SMALL_BLOCK);
4478
4479 if (data.size.QuadPart == newsize.QuadPart)
4480 return S_OK;
4481
4482 /* Create a block chain object of the appropriate type */
4483 if (data.size.QuadPart == 0)
4484 {
4485 if (newsize.QuadPart < LIMIT_TO_USE_SMALL_BLOCK)
4486 {
4488 if (!smallblock) return E_OUTOFMEMORY;
4489 }
4490 else
4491 {
4493 bigblock = *pbigblock;
4494 if (!bigblock) return E_OUTOFMEMORY;
4495 }
4496 }
4497 else if (data.size.QuadPart < LIMIT_TO_USE_SMALL_BLOCK)
4498 {
4500 if (!smallblock) return E_OUTOFMEMORY;
4501 }
4502 else
4503 {
4505 bigblock = *pbigblock;
4506 if (!bigblock) return E_OUTOFMEMORY;
4507 }
4508
4509 /* Change the block chain type if necessary. */
4510 if (smallblock && newsize.QuadPart >= LIMIT_TO_USE_SMALL_BLOCK)
4511 {
4512 bigblock = Storage32Impl_SmallBlocksToBigBlocks(This, &smallblock);
4513 if (!bigblock)
4514 {
4516 return E_FAIL;
4517 }
4518
4520 *pbigblock = bigblock;
4521 }
4522 else if (bigblock && newsize.QuadPart < LIMIT_TO_USE_SMALL_BLOCK)
4523 {
4524 smallblock = Storage32Impl_BigBlocksToSmallBlocks(This, pbigblock, newsize);
4525 if (!smallblock)
4526 return E_FAIL;
4527 }
4528
4529 /* Set the size of the block chain. */
4530 if (smallblock)
4531 {
4532 SmallBlockChainStream_SetSize(smallblock, newsize);
4534 }
4535 else
4536 {
4537 BlockChainStream_SetSize(bigblock, newsize);
4538 }
4539
4540 /* Set the size in the directory entry. */
4542 if (SUCCEEDED(hr))
4543 {
4544 data.size = newsize;
4545
4547 }
4548 return hr;
4549}
static BlockChainStream * Storage32Impl_SmallBlocksToBigBlocks(StorageImpl *This, SmallBlockChainStream **ppsbChain)
Definition: storage32.c:3626
static SmallBlockChainStream * Storage32Impl_BigBlocksToSmallBlocks(StorageImpl *This, BlockChainStream **ppbbChain, ULARGE_INTEGER newSize)
Definition: storage32.c:3746
static BlockChainStream ** StorageImpl_GetFreeBlockChainCacheEntry(StorageImpl *This)
Definition: storage32.c:4339
#define max(a, b)
Definition: svc.c:63

Referenced by StorageImpl_StreamWriteAt().

◆ StorageImpl_StreamWriteAt()

static HRESULT StorageImpl_StreamWriteAt ( StorageBaseImpl base,
DirRef  index,
ULARGE_INTEGER  offset,
ULONG  size,
const void buffer,
ULONG bytesWritten 
)
static

Definition at line 4551 of file storage32.c.

4553{
4555 DirEntry data;
4556 HRESULT hr;
4557 ULARGE_INTEGER newSize;
4558
4560 if (FAILED(hr)) return hr;
4561
4562 /* Grow the stream if necessary */
4563 newSize.QuadPart = offset.QuadPart + size;
4564
4565 if (newSize.QuadPart > data.size.QuadPart)
4566 {
4568 if (FAILED(hr))
4569 return hr;
4570
4572 if (FAILED(hr)) return hr;
4573 }
4574
4575 if (data.size.QuadPart < LIMIT_TO_USE_SMALL_BLOCK)
4576 {
4578
4580 if (!stream) return E_OUTOFMEMORY;
4581
4583
4585
4586 return hr;
4587 }
4588 else
4589 {
4591
4593 if (!stream) return E_OUTOFMEMORY;
4594
4596 }
4597}
static HRESULT StorageImpl_StreamSetSize(StorageBaseImpl *base, DirRef index, ULARGE_INTEGER newsize)
Definition: storage32.c:4463

◆ StorageImpl_UnlockRegion()

static HRESULT StorageImpl_UnlockRegion ( StorageImpl This,
ULARGE_INTEGER  offset,
ULARGE_INTEGER  cb,
DWORD  dwLockType 
)
static

Definition at line 4901 of file storage32.c.

4903{
4904 if ((dwLockType & This->locks_supported) == 0)
4905 return S_OK;
4906
4907 return ILockBytes_UnlockRegion(This->lockBytes, offset, cb, dwLockType);
4908}

Referenced by StorageImpl_CheckLockRange(), StorageImpl_Destroy(), StorageImpl_GrabLocks(), StorageImpl_LockRegionSync(), and StorageImpl_UnlockTransaction().

◆ StorageImpl_UnlockTransaction()

static HRESULT StorageImpl_UnlockTransaction ( StorageBaseImpl base,
BOOL  write 
)
static

Definition at line 4988 of file storage32.c.

4989{
4991 HRESULT hr;
4993
4994 if (write)
4995 {
4998 }
4999 else
5000 {
5001 offset.QuadPart = RANGELOCK_COMMIT;
5002 cb.QuadPart = 1;
5003 }
5004
5005 hr = StorageImpl_UnlockRegion(This, offset, cb, LOCK_ONLYONCE);
5006
5007 return hr;
5008}

◆ StorageImpl_WriteAt()

static HRESULT StorageImpl_WriteAt ( StorageImpl This,
ULARGE_INTEGER  offset,
const void buffer,
const ULONG  size,
ULONG bytesWritten 
)
static

Definition at line 2879 of file storage32.c.

2884{
2885 return ILockBytes_WriteAt(This->lockBytes,offset,buffer,size,bytesWritten);
2886}

Referenced by BlockChainStream_WriteAt(), StorageImpl_SaveFileHeader(), StorageImpl_WriteBigBlock(), and StorageImpl_WriteDWordToBigBlock().

◆ StorageImpl_WriteBigBlock()

static BOOL StorageImpl_WriteBigBlock ( StorageImpl This,
ULONG  blockIndex,
const void buffer 
)
static

Definition at line 3589 of file storage32.c.

3593{
3594 ULARGE_INTEGER ulOffset;
3595 DWORD wrote;
3596
3597 ulOffset.QuadPart = StorageImpl_GetBigBlockOffset(This, blockIndex);
3598
3599 StorageImpl_WriteAt(This, ulOffset, buffer, This->bigBlockSize, &wrote);
3600 return (wrote == This->bigBlockSize);
3601}

Referenced by BlockChainStream_Flush(), BlockChainStream_GetBlockAtOffset(), Storage32Impl_AddBlockDepot(), Storage32Impl_AddExtBlockDepot(), and StorageImpl_Refresh().

◆ StorageImpl_WriteDirEntry()

◆ StorageImpl_WriteDWordToBigBlock()

static BOOL StorageImpl_WriteDWordToBigBlock ( StorageImpl This,
ULONG  blockIndex,
ULONG  offset,
DWORD  value 
)
static

Definition at line 3603 of file storage32.c.

3608{
3609 ULARGE_INTEGER ulOffset;
3610 DWORD wrote;
3611
3612 ulOffset.QuadPart = StorageImpl_GetBigBlockOffset(This, blockIndex);
3613 ulOffset.QuadPart += offset;
3614
3615 value = htole32(value);
3616 StorageImpl_WriteAt(This, ulOffset, &value, sizeof(DWORD), &wrote);
3617 return (wrote == sizeof(DWORD));
3618}
#define htole32(x)
Definition: storage32.h:543

Referenced by Storage32Impl_AddExtBlockDepot(), Storage32Impl_SetExtDepotBlock(), and StorageImpl_SetNextBlockInChain().

◆ StorageImpl_WriteRawDirEntry()

static HRESULT StorageImpl_WriteRawDirEntry ( StorageImpl This,
ULONG  index,
const BYTE buffer 
)
static

Definition at line 3199 of file storage32.c.

3200{
3202 ULONG bytesRead;
3203
3205
3207 This->rootBlockChain,
3208 offset,
3210 buffer,
3211 &bytesRead);
3212}

Referenced by StorageImpl_CreateDirEntry(), StorageImpl_DestroyDirEntry(), and StorageImpl_WriteDirEntry().

◆ StorageInternalImpl_Commit()

static HRESULT WINAPI StorageInternalImpl_Commit ( IStorage iface,
DWORD  grfCommitFlags 
)
static

Definition at line 5500 of file storage32.c.

5503{
5505 TRACE("(%p,%x)\n", iface, grfCommitFlags);
5507}

◆ StorageInternalImpl_Construct()

static StorageInternalImpl * StorageInternalImpl_Construct ( StorageBaseImpl parentStorage,
DWORD  openFlags,
DirRef  storageDirEntry 
)
static

Definition at line 5566 of file storage32.c.

5570{
5571 StorageInternalImpl* newStorage;
5572
5574
5575 if (newStorage!=0)
5576 {
5577 list_init(&newStorage->base.strmHead);
5578
5579 list_init(&newStorage->base.storageHead);
5580
5581 /*
5582 * Initialize the virtual function table.
5583 */
5584 newStorage->base.IStorage_iface.lpVtbl = &StorageInternalImpl_Vtbl;
5585 newStorage->base.IPropertySetStorage_iface.lpVtbl = &IPropertySetStorage_Vtbl;
5586 newStorage->base.baseVtbl = &StorageInternalImpl_BaseVtbl;
5587 newStorage->base.openFlags = (openFlags & ~STGM_CREATE);
5588
5589 newStorage->base.reverted = FALSE;
5590
5591 newStorage->base.ref = 1;
5592
5593 newStorage->parentStorage = parentStorage;
5594
5595 /*
5596 * Keep a reference to the directory entry of this storage
5597 */
5598 newStorage->base.storageDirEntry = storageDirEntry;
5599
5600 newStorage->base.create = FALSE;
5601
5602 return newStorage;
5603 }
5604
5605 return 0;
5606}
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
static const StorageBaseImplVtbl StorageInternalImpl_BaseVtbl
Definition: storage32.c:5546
StorageBaseImpl * parentStorage
Definition: storage32.c:83

Referenced by StorageBaseImpl_OpenStorage().

◆ StorageInternalImpl_CreateDirEntry()

static HRESULT StorageInternalImpl_CreateDirEntry ( StorageBaseImpl base,
const DirEntry newData,
DirRef index 
)
static

Definition at line 5401 of file storage32.c.

5403{
5405
5406 return StorageBaseImpl_CreateDirEntry(This->parentStorage,
5407 newData, index);
5408}

◆ StorageInternalImpl_Destroy()

static void StorageInternalImpl_Destroy ( StorageBaseImpl iface)
static

Definition at line 5378 of file storage32.c.

5379{
5381
5383
5385}
static void StorageInternalImpl_Invalidate(StorageBaseImpl *base)
Definition: storage32.c:5360

◆ StorageInternalImpl_DestroyDirEntry()

static HRESULT StorageInternalImpl_DestroyDirEntry ( StorageBaseImpl base,
DirRef  index 
)
static

Definition at line 5428 of file storage32.c.

5430{
5432
5433 return StorageBaseImpl_DestroyDirEntry(This->parentStorage,
5434 index);
5435}

◆ StorageInternalImpl_Flush()

static HRESULT StorageInternalImpl_Flush ( StorageBaseImpl iface)
static

Definition at line 5387 of file storage32.c.

5388{
5390
5391 return StorageBaseImpl_Flush(This->parentStorage);
5392}

◆ StorageInternalImpl_GetFilename()

static HRESULT StorageInternalImpl_GetFilename ( StorageBaseImpl iface,
LPWSTR result 
)
static

Definition at line 5394 of file storage32.c.

5395{
5397
5398 return StorageBaseImpl_GetFilename(This->parentStorage, result);
5399}

◆ StorageInternalImpl_GetTransactionSig()

static HRESULT StorageInternalImpl_GetTransactionSig ( StorageBaseImpl base,
ULONG result,
BOOL  refresh 
)
static

Definition at line 5473 of file storage32.c.

5475{
5476 return E_NOTIMPL;
5477}

◆ StorageInternalImpl_Invalidate()

static void StorageInternalImpl_Invalidate ( StorageBaseImpl base)
static

Definition at line 5360 of file storage32.c.

5361{
5363
5364 if (!This->base.reverted)
5365 {
5366 TRACE("Storage invalidated (stg=%p)\n", This);
5367
5368 This->base.reverted = TRUE;
5369
5370 This->parentStorage = NULL;
5371
5373
5374 list_remove(&This->ParentListEntry);
5375 }
5376}

Referenced by StorageInternalImpl_Destroy().

◆ StorageInternalImpl_LockTransaction()

static HRESULT StorageInternalImpl_LockTransaction ( StorageBaseImpl base,
BOOL  write 
)
static

Definition at line 5485 of file storage32.c.

5486{
5487 return E_NOTIMPL;
5488}

◆ StorageInternalImpl_ReadDirEntry()

static HRESULT StorageInternalImpl_ReadDirEntry ( StorageBaseImpl base,
DirRef  index,
DirEntry data 
)
static

Definition at line 5419 of file storage32.c.

5421{
5423
5424 return StorageBaseImpl_ReadDirEntry(This->parentStorage,
5425 index, data);
5426}

◆ StorageInternalImpl_Revert()

static HRESULT WINAPI StorageInternalImpl_Revert ( IStorage iface)
static

Definition at line 5514 of file storage32.c.

5516{
5517 FIXME("(%p): stub\n", iface);
5518 return S_OK;
5519}

◆ StorageInternalImpl_SetTransactionSig()

static HRESULT StorageInternalImpl_SetTransactionSig ( StorageBaseImpl base,
ULONG  value 
)
static

Definition at line 5479 of file storage32.c.

5481{
5482 return E_NOTIMPL;
5483}

◆ StorageInternalImpl_StreamLink()

static HRESULT StorageInternalImpl_StreamLink ( StorageBaseImpl base,
DirRef  dst,
DirRef  src 
)
static

Definition at line 5464 of file storage32.c.

5466{
5468
5469 return StorageBaseImpl_StreamLink(This->parentStorage,
5470 dst, src);
5471}
static HRESULT StorageBaseImpl_StreamLink(StorageBaseImpl *This, DirRef dst, DirRef src)
Definition: storage32.h:327

◆ StorageInternalImpl_StreamReadAt()

static HRESULT StorageInternalImpl_StreamReadAt ( StorageBaseImpl base,
DirRef  index,
ULARGE_INTEGER  offset,
ULONG  size,
void buffer,
ULONG bytesRead 
)
static

Definition at line 5437 of file storage32.c.

5439{
5441
5442 return StorageBaseImpl_StreamReadAt(This->parentStorage,
5443 index, offset, size, buffer, bytesRead);
5444}

◆ StorageInternalImpl_StreamSetSize()

static HRESULT StorageInternalImpl_StreamSetSize ( StorageBaseImpl base,
DirRef  index,
ULARGE_INTEGER  newsize 
)
static

Definition at line 5455 of file storage32.c.

5457{
5459
5460 return StorageBaseImpl_StreamSetSize(This->parentStorage,
5461 index, newsize);
5462}

◆ StorageInternalImpl_StreamWriteAt()

static HRESULT StorageInternalImpl_StreamWriteAt ( StorageBaseImpl base,
DirRef  index,
ULARGE_INTEGER  offset,
ULONG  size,
const void buffer,
ULONG bytesWritten 
)
static

Definition at line 5446 of file storage32.c.

5448{
5450
5451 return StorageBaseImpl_StreamWriteAt(This->parentStorage,
5453}

◆ StorageInternalImpl_UnlockTransaction()

static HRESULT StorageInternalImpl_UnlockTransaction ( StorageBaseImpl base,
BOOL  write 
)
static

Definition at line 5490 of file storage32.c.

5491{
5492 return E_NOTIMPL;
5493}

◆ StorageInternalImpl_WriteDirEntry()

static HRESULT StorageInternalImpl_WriteDirEntry ( StorageBaseImpl base,
DirRef  index,
const DirEntry data 
)
static

Definition at line 5410 of file storage32.c.

5412{
5414
5415 return StorageBaseImpl_WriteDirEntry(This->parentStorage,
5416 index, data);
5417}

◆ StorageUtl_CopyDirEntryToSTATSTG()

void StorageUtl_CopyDirEntryToSTATSTG ( StorageBaseImpl storage,
STATSTG *  destination,
const DirEntry source,
int  statFlags 
)

Definition at line 7017 of file storage32.c.

7022{
7023 /*
7024 * The copy of the string occurs only when the flag is not set
7025 */
7026 if (!(statFlags & STATFLAG_NONAME) && source->stgType == STGTY_ROOT)
7027 {
7028 /* Use the filename for the root storage. */
7029 destination->pwcsName = 0;
7030 StorageBaseImpl_GetFilename(storage, &destination->pwcsName);
7031 }
7032 else if( ((statFlags & STATFLAG_NONAME) != 0) ||
7033 (source->name[0] == 0) )
7034 {
7035 destination->pwcsName = 0;
7036 }
7037 else
7038 {
7039 destination->pwcsName =
7040 CoTaskMemAlloc((lstrlenW(source->name)+1)*sizeof(WCHAR));
7041
7042 lstrcpyW(destination->pwcsName, source->name);
7043 }
7044
7045 switch (source->stgType)
7046 {
7047 case STGTY_STORAGE:
7048 case STGTY_ROOT:
7049 destination->type = STGTY_STORAGE;
7050 break;
7051 case STGTY_STREAM:
7052 destination->type = STGTY_STREAM;
7053 break;
7054 default:
7055 destination->type = STGTY_STREAM;
7056 break;
7057 }
7058
7059 destination->cbSize = source->size;
7060/*
7061 currentReturnStruct->mtime = {0}; TODO
7062 currentReturnStruct->ctime = {0};
7063 currentReturnStruct->atime = {0};
7064*/
7065 destination->grfMode = 0;
7066 destination->grfLocksSupported = 0;
7067 destination->clsid = source->clsid;
7068 destination->grfStateBits = 0;
7069 destination->reserved = 0;
7070}
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:426

Referenced by IEnumSTATSTGImpl_Next(), StgStreamImpl_Stat(), and StorageBaseImpl_Stat().

◆ StorageUtl_ReadDWord()

◆ StorageUtl_ReadGUID()

void StorageUtl_ReadGUID ( const BYTE buffer,
ULONG  offset,
GUID value 
)

Definition at line 6999 of file storage32.c.

7000{
7002 StorageUtl_ReadWord(buffer, offset+4, &(value->Data2));
7003 StorageUtl_ReadWord(buffer, offset+6, &(value->Data3));
7004
7005 memcpy(value->Data4, buffer+offset+8, sizeof(value->Data4));
7006}

Referenced by PropertyStorage_ReadFmtIdOffsetFromStream(), PropertyStorage_ReadHeaderFromStream(), and StorageImpl_ReadDirEntry().

◆ StorageUtl_ReadULargeInteger()

void StorageUtl_ReadULargeInteger ( const BYTE buffer,
ULONG  offset,
ULARGE_INTEGER value 
)

Definition at line 6971 of file storage32.c.

6973{
6974#ifdef WORDS_BIGENDIAN
6975 ULARGE_INTEGER tmp;
6976
6977 memcpy(&tmp, buffer + offset, sizeof(ULARGE_INTEGER));
6978 value->u.LowPart = htole32(tmp.u.HighPart);
6979 value->u.HighPart = htole32(tmp.u.LowPart);
6980#else
6982#endif
6983}

Referenced by PropertyStorage_ReadProperty().

◆ StorageUtl_ReadWord()

void StorageUtl_ReadWord ( const BYTE buffer,
ULONG  offset,
WORD value 
)

◆ StorageUtl_WriteDWord()

◆ StorageUtl_WriteGUID()

void StorageUtl_WriteGUID ( BYTE buffer,
ULONG  offset,
const GUID value 
)

◆ StorageUtl_WriteULargeInteger()

void StorageUtl_WriteULargeInteger ( BYTE buffer,
ULONG  offset,
const ULARGE_INTEGER value 
)

Definition at line 6985 of file storage32.c.

6987{
6988#ifdef WORDS_BIGENDIAN
6989 ULARGE_INTEGER tmp;
6990
6991 tmp.u.LowPart = htole32(value->u.HighPart);
6992 tmp.u.HighPart = htole32(value->u.LowPart);
6993 memcpy(buffer + offset, &tmp, sizeof(ULARGE_INTEGER));
6994#else
6996#endif
6997}

Referenced by PropertyStorage_WritePropertyToStream().

◆ StorageUtl_WriteWord()

void StorageUtl_WriteWord ( BYTE buffer,
ULONG  offset,
WORD  value 
)

◆ STREAM_ReadString()

static HRESULT STREAM_ReadString ( IStream stm,
LPWSTR string 
)
static

Definition at line 9261 of file storage32.c.

9262{
9263 HRESULT r;
9264 DWORD len, count = 0;
9265 LPSTR str;
9266 LPWSTR wstr;
9267
9268 r = IStream_Read( stm, &len, sizeof(len), &count );
9269 if( FAILED( r ) )
9270 return r;
9271 if( count != sizeof(len) )
9272 return E_OUTOFMEMORY;
9273
9274 TRACE("%d bytes\n",len);
9275
9276 str = CoTaskMemAlloc( len );
9277 if( !str )
9278 return E_OUTOFMEMORY;
9279 count = 0;
9280 r = IStream_Read( stm, str, len, &count );
9281 if( FAILED( r ) )
9282 {
9283 CoTaskMemFree( str );
9284 return r;
9285 }
9286 if( count != len )
9287 {
9288 CoTaskMemFree( str );
9289 return E_OUTOFMEMORY;
9290 }
9291
9292 TRACE("Read string %s\n",debugstr_an(str,len));
9293
9295 wstr = CoTaskMemAlloc( (len + 1)*sizeof (WCHAR) );
9296 if( wstr )
9297 {
9298 MultiByteToWideChar( CP_ACP, 0, str, count, wstr, len );
9299 wstr[len] = 0;
9300 }
9301 CoTaskMemFree( str );
9302
9303 *string = wstr;
9304
9305 return r;
9306}
static __inline const char * debugstr_an(const char *s, int n)
Definition: compat.h:55
GLenum GLsizei len
Definition: glext.h:6722
char * LPSTR
Definition: xmlstorage.h:182

Referenced by ReadFmtUserTypeStg().

◆ STREAM_WriteString()

static HRESULT STREAM_WriteString ( IStream stm,
LPCWSTR  string 
)
static

Definition at line 9240 of file storage32.c.

9241{
9242 HRESULT r;
9243 LPSTR str;
9244 DWORD len = 0;
9245
9246 if( string )
9247 len = WideCharToMultiByte( CP_ACP, 0, string, -1, NULL, 0, NULL, NULL);
9248 r = IStream_Write( stm, &len, sizeof(len), NULL);
9249 if( FAILED( r ) )
9250 return r;
9251 if(len == 0)
9252 return r;
9253 str = CoTaskMemAlloc( len );
9254 WideCharToMultiByte( CP_ACP, 0, string, -1, str, len, NULL, NULL);
9255 r = IStream_Write( stm, str, len, NULL);
9256 CoTaskMemFree( str );
9257 return r;
9258}

Referenced by STORAGE_WriteCompObj().

◆ TransactedSharedImpl_Commit()

static HRESULT WINAPI TransactedSharedImpl_Commit ( IStorage iface,
DWORD  grfCommitFlags 
)
static

Definition at line 6675 of file storage32.c.

6678{
6680 DirRef new_storage_ref, prev_storage_ref;
6681 DirEntry src_data, dst_data;
6682 HRESULT hr;
6683 ULONG transactionSig;
6684
6685 TRACE("(%p,%x)\n", iface, grfCommitFlags);
6686
6687 /* Cannot commit a read-only transacted storage */
6688 if ( STGM_ACCESS_MODE( This->base.openFlags ) == STGM_READ )
6689 return STG_E_ACCESSDENIED;
6690
6691 hr = StorageBaseImpl_LockTransaction(This->transactedParent, TRUE);
6692 if (hr == E_NOTIMPL) hr = S_OK;
6693 if (SUCCEEDED(hr))
6694 {
6695 hr = StorageBaseImpl_GetTransactionSig(This->transactedParent, &transactionSig, TRUE);
6696 if (SUCCEEDED(hr))
6697 {
6698 if ((grfCommitFlags & STGC_ONLYIFCURRENT) && transactionSig != This->lastTransactionSig)
6700
6701 if (SUCCEEDED(hr))
6702 hr = StorageBaseImpl_SetTransactionSig(This->transactedParent, transactionSig+1);
6703 }
6704 else if (hr == E_NOTIMPL)
6705 hr = S_OK;
6706
6707 if (SUCCEEDED(hr))
6708 hr = StorageBaseImpl_ReadDirEntry(&This->scratch->base, This->scratch->base.storageDirEntry, &src_data);
6709
6710 /* FIXME: If we're current, we should be able to copy only the changes in scratch. */
6711 if (SUCCEEDED(hr))
6712 hr = StorageBaseImpl_DupStorageTree(This->transactedParent, &new_storage_ref, &This->scratch->base, src_data.dirRootEntry);
6713
6714 if (SUCCEEDED(hr))
6715 hr = StorageBaseImpl_Flush(This->transactedParent);
6716
6717 if (SUCCEEDED(hr))
6718 hr = StorageBaseImpl_ReadDirEntry(This->transactedParent, This->transactedParent->storageDirEntry, &dst_data);
6719
6720 if (SUCCEEDED(hr))
6721 {
6722 prev_storage_ref = dst_data.dirRootEntry;
6723 dst_data.dirRootEntry = new_storage_ref;
6724 dst_data.clsid = src_data.clsid;
6725 dst_data.ctime = src_data.ctime;
6726 dst_data.mtime = src_data.mtime;
6727 hr = StorageBaseImpl_WriteDirEntry(This->transactedParent, This->transactedParent->storageDirEntry, &dst_data);
6728 }
6729
6730 if (SUCCEEDED(hr))
6731 {
6732 /* Try to flush after updating the root storage, but if the flush fails, keep
6733 * going, on the theory that it'll either succeed later or the subsequent
6734 * writes will fail. */
6735 StorageBaseImpl_Flush(This->transactedParent);
6736
6737 hr = StorageBaseImpl_DeleteStorageTree(This->transactedParent, prev_storage_ref, TRUE);
6738 }
6739
6740 if (SUCCEEDED(hr))
6741 hr = StorageBaseImpl_Flush(This->transactedParent);
6742
6743 StorageBaseImpl_UnlockTransaction(This->transactedParent, TRUE);
6744
6745 if (SUCCEEDED(hr))
6746 hr = IStorage_Commit(&This->scratch->base.IStorage_iface, STGC_DEFAULT);
6747
6748 if (SUCCEEDED(hr))
6749 {
6750 This->lastTransactionSig = transactionSig+1;
6751 }
6752 }
6753 TRACE("<-- %08x\n", hr);
6754 return hr;
6755}
static HRESULT StorageBaseImpl_LockTransaction(StorageBaseImpl *This, BOOL write)
Definition: storage32.h:345
static HRESULT StorageBaseImpl_GetTransactionSig(StorageBaseImpl *This, ULONG *result, BOOL refresh)
Definition: storage32.h:333
static HRESULT StorageBaseImpl_SetTransactionSig(StorageBaseImpl *This, ULONG value)
Definition: storage32.h:339
static HRESULT StorageBaseImpl_UnlockTransaction(StorageBaseImpl *This, BOOL write)
Definition: storage32.h:350
#define STG_E_NOTCURRENT
Definition: winerror.h:2589

◆ TransactedSharedImpl_Construct()

static HRESULT TransactedSharedImpl_Construct ( StorageBaseImpl parentStorage,
TransactedSharedImpl **  result 
)
static

Definition at line 6812 of file storage32.c.

6814{
6815 HRESULT hr;
6816
6818 if (*result)
6819 {
6820 IStorage *scratch;
6821
6822 (*result)->base.IStorage_iface.lpVtbl = &TransactedSharedImpl_Vtbl;
6823
6824 /* This is OK because the property set storage functions use the IStorage functions. */
6825 (*result)->base.IPropertySetStorage_iface.lpVtbl = parentStorage->IPropertySetStorage_iface.lpVtbl;
6826 (*result)->base.baseVtbl = &TransactedSharedImpl_BaseVtbl;
6827
6828 list_init(&(*result)->base.strmHead);
6829
6830 list_init(&(*result)->base.storageHead);
6831
6832 (*result)->base.ref = 1;
6833
6834 (*result)->base.openFlags = parentStorage->openFlags;
6835
6836 hr = StorageBaseImpl_LockTransaction(parentStorage, FALSE);
6837
6838 if (SUCCEEDED(hr))
6839 {
6840 STGOPTIONS stgo;
6841
6842 /* This cannot fail, except with E_NOTIMPL in which case we don't care */
6843 StorageBaseImpl_GetTransactionSig(parentStorage, &(*result)->lastTransactionSig, FALSE);
6844
6845 stgo.usVersion = 1;
6846 stgo.reserved = 0;
6847 stgo.ulSectorSize = 4096;
6848 stgo.pwcsTemplateFile = NULL;
6849
6850 /* Create a new temporary storage to act as the scratch file. */
6852 STGFMT_DOCFILE, 0, &stgo, NULL, &IID_IStorage, (void**)&scratch);
6853 (*result)->scratch = (TransactedSnapshotImpl*)impl_from_IStorage(scratch);
6854
6855 if (SUCCEEDED(hr))
6856 {
6857 hr = StorageBaseImpl_CopyStorageTree(&(*result)->scratch->base, (*result)->scratch->base.storageDirEntry,
6858 parentStorage, parentStorage->storageDirEntry);
6859
6860 if (SUCCEEDED(hr))
6861 {
6862 hr = IStorage_Commit(scratch, STGC_DEFAULT);
6863
6864 (*result)->base.storageDirEntry = (*result)->scratch->base.storageDirEntry;
6865 (*result)->transactedParent = parentStorage;
6866 }
6867
6868 if (FAILED(hr))
6869 IStorage_Release(scratch);
6870 }
6871
6873 }
6874
6875 if (FAILED(hr)) HeapFree(GetProcessHeap(), 0, *result);
6876
6877 return hr;
6878 }
6879 else
6880 return E_OUTOFMEMORY;
6881}
static HRESULT StorageBaseImpl_CopyStorageTree(StorageBaseImpl *dst, DirRef dst_entry, StorageBaseImpl *src, DirRef src_entry)
Definition: storage32.c:2804
static const StorageBaseImplVtbl TransactedSharedImpl_BaseVtbl
Definition: storage32.c:6792
static const IStorageVtbl TransactedSharedImpl_Vtbl
Definition: storage32.c:6770
HRESULT WINAPI StgCreateStorageEx(const WCHAR *pwcsName, DWORD grfMode, DWORD stgfmt, DWORD grfAttrs, STGOPTIONS *pStgOptions, void *reserved, REFIID riid, void **ppObjectOpen)
Definition: storage32.c:8659
IPropertySetStorage IPropertySetStorage_iface
Definition: storage32.h:188
USHORT reserved
Definition: objbase.h:941
const WCHAR * pwcsTemplateFile
Definition: objbase.h:943
USHORT usVersion
Definition: objbase.h:940

Referenced by Storage_ConstructTransacted().

◆ TransactedSharedImpl_CreateDirEntry()

static HRESULT TransactedSharedImpl_CreateDirEntry ( StorageBaseImpl base,
const DirEntry newData,
DirRef index 
)
static

Definition at line 6581 of file storage32.c.

6583{
6585
6586 return StorageBaseImpl_CreateDirEntry(&This->scratch->base,
6587 newData, index);
6588}

◆ TransactedSharedImpl_Destroy()

static void TransactedSharedImpl_Destroy ( StorageBaseImpl iface)
static

Definition at line 6558 of file storage32.c.

6559{
6561
6563 IStorage_Release(&This->transactedParent->IStorage_iface);
6564 IStorage_Release(&This->scratch->base.IStorage_iface);
6566}
static void TransactedSharedImpl_Invalidate(StorageBaseImpl *This)
Definition: storage32.c:6546

◆ TransactedSharedImpl_DestroyDirEntry()

static HRESULT TransactedSharedImpl_DestroyDirEntry ( StorageBaseImpl base,
DirRef  index 
)
static

Definition at line 6608 of file storage32.c.

6610{
6612
6613 return StorageBaseImpl_DestroyDirEntry(&This->scratch->base,
6614 index);
6615}

◆ TransactedSharedImpl_Flush()

static HRESULT TransactedSharedImpl_Flush ( StorageBaseImpl iface)
static

Definition at line 6568 of file storage32.c.

6569{
6570 /* We only need to flush when committing. */
6571 return S_OK;
6572}

◆ TransactedSharedImpl_GetFilename()

static HRESULT TransactedSharedImpl_GetFilename ( StorageBaseImpl iface,
LPWSTR result 
)
static

Definition at line 6574 of file storage32.c.

6575{
6577
6578 return StorageBaseImpl_GetFilename(This->transactedParent, result);
6579}

◆ TransactedSharedImpl_GetTransactionSig()

static HRESULT TransactedSharedImpl_GetTransactionSig ( StorageBaseImpl base,
ULONG result,
BOOL  refresh 
)
static

Definition at line 6653 of file storage32.c.

6655{
6656 return E_NOTIMPL;
6657}

◆ TransactedSharedImpl_Invalidate()

static void TransactedSharedImpl_Invalidate ( StorageBaseImpl This)
static

Definition at line 6546 of file storage32.c.

6547{
6548 if (!This->reverted)
6549 {
6550 TRACE("Storage invalidated (stg=%p)\n", This);
6551
6552 This->reverted = TRUE;
6553
6555 }
6556}

Referenced by TransactedSharedImpl_Destroy().

◆ TransactedSharedImpl_LockTransaction()

static HRESULT TransactedSharedImpl_LockTransaction ( StorageBaseImpl base,
BOOL  write 
)
static

Definition at line 6665 of file storage32.c.

6666{
6667 return E_NOTIMPL;
6668}

◆ TransactedSharedImpl_ReadDirEntry()

static HRESULT TransactedSharedImpl_ReadDirEntry ( StorageBaseImpl base,
DirRef  index,
DirEntry data 
)
static

Definition at line 6599 of file storage32.c.

6601{
6603
6604 return StorageBaseImpl_ReadDirEntry(&This->scratch->base,
6605 index, data);
6606}

◆ TransactedSharedImpl_Revert()

static HRESULT WINAPI TransactedSharedImpl_Revert ( IStorage iface)
static

Definition at line 6757 of file storage32.c.

6759{
6761
6762 TRACE("(%p)\n", iface);
6763
6764 /* Destroy the open objects. */
6766
6767 return IStorage_Revert(&This->scratch->base.IStorage_iface);
6768}

◆ TransactedSharedImpl_SetTransactionSig()

static HRESULT TransactedSharedImpl_SetTransactionSig ( StorageBaseImpl base,
ULONG  value 
)
static

Definition at line 6659 of file storage32.c.

6661{
6662 return E_NOTIMPL;
6663}

◆ TransactedSharedImpl_StreamLink()

static HRESULT TransactedSharedImpl_StreamLink ( StorageBaseImpl base,
DirRef  dst,
DirRef  src 
)
static

Definition at line 6644 of file storage32.c.

6646{
6648
6649 return StorageBaseImpl_StreamLink(&This->scratch->base,
6650 dst, src);
6651}

◆ TransactedSharedImpl_StreamReadAt()

static HRESULT TransactedSharedImpl_StreamReadAt ( StorageBaseImpl base,
DirRef  index,
ULARGE_INTEGER  offset,
ULONG  size,
void buffer,
ULONG bytesRead 
)
static

Definition at line 6617 of file storage32.c.

6619{
6621
6622 return StorageBaseImpl_StreamReadAt(&This->scratch->base,
6623 index, offset, size, buffer, bytesRead);
6624}

◆ TransactedSharedImpl_StreamSetSize()

static HRESULT TransactedSharedImpl_StreamSetSize ( StorageBaseImpl base,
DirRef  index,
ULARGE_INTEGER  newsize 
)
static

Definition at line 6635 of file storage32.c.

6637{
6639
6640 return StorageBaseImpl_StreamSetSize(&This->scratch->base,
6641 index, newsize);
6642}

◆ TransactedSharedImpl_StreamWriteAt()

static HRESULT TransactedSharedImpl_StreamWriteAt ( StorageBaseImpl base,
DirRef  index,
ULARGE_INTEGER  offset,
ULONG  size,
const void buffer,
ULONG bytesWritten 
)
static

Definition at line 6626 of file storage32.c.

6628{
6630
6631 return StorageBaseImpl_StreamWriteAt(&This->scratch->base,
6633}

◆ TransactedSharedImpl_UnlockTransaction()

static HRESULT TransactedSharedImpl_UnlockTransaction ( StorageBaseImpl base,
BOOL  write 
)
static

Definition at line 6670 of file storage32.c.

6671{
6672 return E_NOTIMPL;
6673}

◆ TransactedSharedImpl_WriteDirEntry()

static HRESULT TransactedSharedImpl_WriteDirEntry ( StorageBaseImpl base,
DirRef  index,
const DirEntry data 
)
static

Definition at line 6590 of file storage32.c.

6592{
6594
6595 return StorageBaseImpl_WriteDirEntry(&This->scratch->base,
6596 index, data);
6597}

◆ TransactedSnapshotImpl_Commit()

static HRESULT WINAPI TransactedSnapshotImpl_Commit ( IStorage iface,
DWORD  grfCommitFlags 
)
static

Definition at line 5957 of file storage32.c.

5960{
5962 TransactedDirEntry *root_entry;
5963 DirRef i, dir_root_ref;
5964 DirEntry data;
5966 HRESULT hr;
5967 ULONG transactionSig;
5968
5969 zero.QuadPart = 0;
5970
5971 TRACE("(%p,%x)\n", iface, grfCommitFlags);
5972
5973 /* Cannot commit a read-only transacted storage */
5974 if ( STGM_ACCESS_MODE( This->base.openFlags ) == STGM_READ )
5975 return STG_E_ACCESSDENIED;
5976
5977 hr = StorageBaseImpl_LockTransaction(This->transactedParent, TRUE);
5978 if (hr == E_NOTIMPL) hr = S_OK;
5979 if (SUCCEEDED(hr))
5980 {
5981 hr = StorageBaseImpl_GetTransactionSig(This->transactedParent, &transactionSig, TRUE);
5982 if (SUCCEEDED(hr))
5983 {
5984 if (transactionSig != This->lastTransactionSig)
5985 {
5986 ERR("file was externally modified\n");
5988 }
5989
5990 if (SUCCEEDED(hr))
5991 {
5992 This->lastTransactionSig = transactionSig+1;
5993 hr = StorageBaseImpl_SetTransactionSig(This->transactedParent, This->lastTransactionSig);
5994 }
5995 }
5996 else if (hr == E_NOTIMPL)
5997 hr = S_OK;
5998
5999 if (FAILED(hr)) goto end;
6000
6001 /* To prevent data loss, we create the new structure in the file before we
6002 * delete the old one, so that in case of errors the old data is intact. We
6003 * shouldn't do this if STGC_OVERWRITE is set, but that flag should only be
6004 * needed in the rare situation where we have just enough free disk space to
6005 * overwrite the existing data. */
6006
6007 root_entry = &This->entries[This->base.storageDirEntry];
6008
6009 if (!root_entry->read)
6010 goto end;
6011
6013 if (FAILED(hr)) goto end;
6014
6015 if (root_entry->data.dirRootEntry == DIRENTRY_NULL)
6016 dir_root_ref = DIRENTRY_NULL;
6017 else
6018 dir_root_ref = This->entries[root_entry->data.dirRootEntry].newTransactedParentEntry;
6019
6020 hr = StorageBaseImpl_Flush(This->transactedParent);
6021
6022 /* Update the storage to use the new data in one step. */
6023 if (SUCCEEDED(hr))
6024 hr = StorageBaseImpl_ReadDirEntry(This->transactedParent,
6025 root_entry->transactedParentEntry, &data);
6026
6027 if (SUCCEEDED(hr))
6028 {
6029 data.dirRootEntry = dir_root_ref;
6030 data.clsid = root_entry->data.clsid;
6031 data.ctime = root_entry->data.ctime;
6032 data.mtime = root_entry->data.mtime;
6033
6034 hr = StorageBaseImpl_WriteDirEntry(This->transactedParent,
6035 root_entry->transactedParentEntry, &data);
6036 }
6037
6038 /* Try to flush after updating the root storage, but if the flush fails, keep
6039 * going, on the theory that it'll either succeed later or the subsequent
6040 * writes will fail. */
6041 StorageBaseImpl_Flush(This->transactedParent);
6042
6043 if (SUCCEEDED(hr))
6044 {
6045 /* Destroy the old now-orphaned data. */
6046 for (i=0; i<This->entries_size; i++)
6047 {
6048 TransactedDirEntry *entry = &This->entries[i];
6049 if (entry->inuse)
6050 {
6051 if (entry->deleted)
6052 {
6053 StorageBaseImpl_StreamSetSize(This->transactedParent,
6054 entry->transactedParentEntry, zero);
6055 StorageBaseImpl_DestroyDirEntry(This->transactedParent,
6056 entry->transactedParentEntry);
6057 memset(entry, 0, sizeof(TransactedDirEntry));
6058 This->firstFreeEntry = min(i, This->firstFreeEntry);
6059 }
6060 else if (entry->read && entry->transactedParentEntry != entry->newTransactedParentEntry)
6061 {
6062 if (entry->transactedParentEntry != DIRENTRY_NULL)
6063 StorageBaseImpl_DestroyDirEntry(This->transactedParent,
6064 entry->transactedParentEntry);
6065 if (entry->stream_dirty)
6066 {
6067 StorageBaseImpl_StreamSetSize(This->scratch, entry->stream_entry, zero);
6068 StorageBaseImpl_DestroyDirEntry(This->scratch, entry->stream_entry);
6069 entry->stream_dirty = FALSE;
6070 }
6071 entry->dirty = FALSE;
6072 entry->transactedParentEntry = entry->newTransactedParentEntry;
6073 }
6074 }
6075 }
6076 }
6077 else
6078 {
6080 }
6081
6082 if (SUCCEEDED(hr))
6083 hr = StorageBaseImpl_Flush(This->transactedParent);
6084end:
6085 StorageBaseImpl_UnlockTransaction(This->transactedParent, TRUE);
6086 }
6087
6088 TRACE("<-- %08x\n", hr);
6089 return hr;
6090}
static void TransactedSnapshotImpl_DestroyTemporaryCopy(TransactedSnapshotImpl *This, DirRef stop)
Definition: storage32.c:5835
static HRESULT TransactedSnapshotImpl_CopyTree(TransactedSnapshotImpl *This)
Definition: storage32.c:5875
DirRef transactedParentEntry
Definition: storage32.c:93

◆ TransactedSnapshotImpl_Construct()

static HRESULT TransactedSnapshotImpl_Construct ( StorageBaseImpl parentStorage,
TransactedSnapshotImpl **  result 
)
static

Definition at line 6476 of file storage32.c.

6478{
6479 HRESULT hr;
6480
6482 if (*result)
6483 {
6484 IStorage *scratch;
6485
6486 (*result)->base.IStorage_iface.lpVtbl = &TransactedSnapshotImpl_Vtbl;
6487
6488 /* This is OK because the property set storage functions use the IStorage functions. */
6489 (*result)->base.IPropertySetStorage_iface.lpVtbl = parentStorage->IPropertySetStorage_iface.lpVtbl;
6490 (*result)->base.baseVtbl = &TransactedSnapshotImpl_BaseVtbl;
6491
6492 list_init(&(*result)->base.strmHead);
6493
6494 list_init(&(*result)->base.storageHead);
6495
6496 (*result)->base.ref = 1;
6497
6498 (*result)->base.openFlags = parentStorage->openFlags;
6499
6500 /* This cannot fail, except with E_NOTIMPL in which case we don't care */
6501 StorageBaseImpl_GetTransactionSig(parentStorage, &(*result)->lastTransactionSig, FALSE);
6502
6503 /* Create a new temporary storage to act as the scratch file. */
6505 0, &scratch);
6506 (*result)->scratch = impl_from_IStorage(scratch);
6507
6508 if (SUCCEEDED(hr))
6509 {
6510 ULONG num_entries = 20;
6511
6512 (*result)->entries = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(TransactedDirEntry) * num_entries);
6513 (*result)->entries_size = num_entries;
6514 (*result)->firstFreeEntry = 0;
6515
6516 if ((*result)->entries)
6517 {
6518 /* parentStorage already has 1 reference, which we take over here. */
6519 (*result)->transactedParent = parentStorage;
6520
6521 parentStorage->transactedChild = &(*result)->base;
6522
6524 }
6525 else
6526 {
6527 IStorage_Release(scratch);
6528
6529 hr = E_OUTOFMEMORY;
6530 }
6531 }
6532
6533 if (FAILED(hr)) HeapFree(GetProcessHeap(), 0, *result);
6534
6535 return hr;
6536 }
6537 else
6538 return E_OUTOFMEMORY;
6539}
static const StorageBaseImplVtbl TransactedSnapshotImpl_BaseVtbl
Definition: storage32.c:6456
static DirRef TransactedSnapshotImpl_CreateStubEntry(TransactedSnapshotImpl *This, DirRef parentEntryRef)
Definition: storage32.c:5642

Referenced by Storage_ConstructTransacted().

◆ TransactedSnapshotImpl_CopyTree()

static HRESULT TransactedSnapshotImpl_CopyTree ( TransactedSnapshotImpl This)
static

Definition at line 5875 of file storage32.c.

5876{
5877 DirRef cursor;
5879 HRESULT hr = S_OK;
5880
5881 cursor = This->base.storageDirEntry;
5882 entry = &This->entries[cursor];
5883 entry->parent = DIRENTRY_NULL;
5884 entry->newTransactedParentEntry = entry->transactedParentEntry;
5885
5886 if (entry->data.dirRootEntry == DIRENTRY_NULL)
5887 return S_OK;
5888
5889 This->entries[entry->data.dirRootEntry].parent = DIRENTRY_NULL;
5890
5892 entry = &This->entries[cursor];
5893
5894 while (cursor != DIRENTRY_NULL)
5895 {
5896 /* Make a copy of this entry in the transacted parent. */
5897 if (!entry->read ||
5898 (!entry->dirty && !entry->stream_dirty &&
5899 !TransactedSnapshotImpl_MadeCopy(This, entry->data.leftChild) &&
5900 !TransactedSnapshotImpl_MadeCopy(This, entry->data.rightChild) &&
5901 !TransactedSnapshotImpl_MadeCopy(This, entry->data.dirRootEntry)))
5902 entry->newTransactedParentEntry = entry->transactedParentEntry;
5903 else
5904 {
5905 DirEntry newData;
5906
5907 memcpy(&newData, &entry->data, sizeof(DirEntry));
5908
5909 newData.size.QuadPart = 0;
5911
5912 if (newData.leftChild != DIRENTRY_NULL)
5913 newData.leftChild = This->entries[newData.leftChild].newTransactedParentEntry;
5914
5915 if (newData.rightChild != DIRENTRY_NULL)
5916 newData.rightChild = This->entries[newData.rightChild].newTransactedParentEntry;
5917
5918 if (newData.dirRootEntry != DIRENTRY_NULL)
5919 newData.dirRootEntry = This->entries[newData.dirRootEntry].newTransactedParentEntry;
5920
5921 hr = StorageBaseImpl_CreateDirEntry(This->transactedParent, &newData,
5922 &entry->newTransactedParentEntry);
5923 if (FAILED(hr))
5924 {
5926 return hr;
5927 }
5928
5929 if (entry->stream_dirty)
5930 {
5932 This->transactedParent, entry->newTransactedParentEntry,
5933 This->scratch, entry->stream_entry);
5934 }
5935 else if (entry->data.size.QuadPart)
5936 {
5938 This->transactedParent, entry->newTransactedParentEntry,
5939 entry->transactedParentEntry);
5940 }
5941
5942 if (FAILED(hr))
5943 {
5946 return hr;
5947 }
5948 }
5949
5951 entry = &This->entries[cursor];
5952 }
5953
5954 return hr;
5955}
static DirRef TransactedSnapshotImpl_FindFirstChild(TransactedSnapshotImpl *This, DirRef parent)
Definition: storage32.c:5760
static DirRef TransactedSnapshotImpl_FindNextChild(TransactedSnapshotImpl *This, DirRef current)
Definition: storage32.c:5799
static BOOL TransactedSnapshotImpl_MadeCopy(TransactedSnapshotImpl *This, DirRef entry)
Definition: storage32.c:5827
const char cursor[]
Definition: icontest.c:13

Referenced by TransactedSnapshotImpl_Commit().

◆ TransactedSnapshotImpl_CreateDirEntry()

static HRESULT TransactedSnapshotImpl_CreateDirEntry ( StorageBaseImpl base,
const DirEntry newData,
DirRef index 
)
static

Definition at line 6161 of file storage32.c.

6163{
6165 DirRef new_ref;
6166 TransactedDirEntry *new_entry;
6167
6169 if (new_ref == DIRENTRY_NULL)
6170 return E_OUTOFMEMORY;
6171
6172 new_entry = &This->entries[new_ref];
6173
6175 new_entry->read = TRUE;
6176 new_entry->dirty = TRUE;
6177 memcpy(&new_entry->data, newData, sizeof(DirEntry));
6178
6179 *index = new_ref;
6180
6181 TRACE("%s l=%x r=%x d=%x <-- %x\n", debugstr_w(newData->name), newData->leftChild, newData->rightChild, newData->dirRootEntry, *index);
6182
6183 return S_OK;
6184}
static DirRef TransactedSnapshotImpl_FindFreeEntry(TransactedSnapshotImpl *This)
Definition: storage32.c:5613
DirRef newTransactedParentEntry
Definition: storage32.c:124

◆ TransactedSnapshotImpl_CreateStubEntry()

static DirRef TransactedSnapshotImpl_CreateStubEntry ( TransactedSnapshotImpl This,
DirRef  parentEntryRef 
)
static

Definition at line 5642 of file storage32.c.

5644{
5645 DirRef stubEntryRef;
5647
5649
5650 if (stubEntryRef != DIRENTRY_NULL)
5651 {
5652 entry = &This->entries[stubEntryRef];
5653
5654 entry->newTransactedParentEntry = entry->transactedParentEntry = parentEntryRef;
5655
5656 entry->read = FALSE;
5657 }
5658
5659 return stubEntryRef;
5660}

Referenced by TransactedSnapshotImpl_Construct(), TransactedSnapshotImpl_EnsureReadEntry(), TransactedSnapshotImpl_MakeStreamDirty(), TransactedSnapshotImpl_Revert(), TransactedSnapshotImpl_StreamSetSize(), and TransactedSnapshotImpl_WriteDirEntry().

◆ TransactedSnapshotImpl_Destroy()

static void TransactedSnapshotImpl_Destroy ( StorageBaseImpl iface)
static

Definition at line 6137 of file storage32.c.

6138{
6140
6141 IStorage_Revert(&This->base.IStorage_iface);
6142 IStorage_Release(&This->transactedParent->IStorage_iface);
6143 IStorage_Release(&This->scratch->IStorage_iface);
6144 HeapFree(GetProcessHeap(), 0, This->entries);
6146}

◆ TransactedSnapshotImpl_DestroyDirEntry()

static HRESULT TransactedSnapshotImpl_DestroyDirEntry ( StorageBaseImpl base,
DirRef  index 
)
static

Definition at line 6245 of file storage32.c.

6247{
6249
6250 if (This->entries[index].transactedParentEntry == DIRENTRY_NULL ||
6251 This->entries[index].data.size.QuadPart != 0)
6252 {
6253 /* If we deleted this entry while it has stream data. We must have left the
6254 * data because some other entry is using it, and we need to leave the
6255 * original entry alone. */
6256 memset(&This->entries[index], 0, sizeof(TransactedDirEntry));
6257 This->firstFreeEntry = min(index, This->firstFreeEntry);
6258 }
6259 else
6260 {
6261 This->entries[index].deleted = TRUE;
6262 }
6263
6264 return S_OK;
6265}

◆ TransactedSnapshotImpl_DestroyTemporaryCopy()

static void TransactedSnapshotImpl_DestroyTemporaryCopy ( TransactedSnapshotImpl This,
DirRef  stop 
)
static

Definition at line 5835 of file storage32.c.

5837{
5838 DirRef cursor;
5841
5842 zero.QuadPart = 0;
5843
5844 if (!This->entries[This->base.storageDirEntry].read)
5845 return;
5846
5847 cursor = This->entries[This->base.storageDirEntry].data.dirRootEntry;
5848
5849 if (cursor == DIRENTRY_NULL)
5850 return;
5851
5853
5854 while (cursor != DIRENTRY_NULL && cursor != stop)
5855 {
5857 {
5858 entry = &This->entries[cursor];
5859
5860 if (entry->stream_dirty)
5861 StorageBaseImpl_StreamSetSize(This->transactedParent,
5862 entry->newTransactedParentEntry, zero);
5863
5864 StorageBaseImpl_DestroyDirEntry(This->transactedParent,
5865 entry->newTransactedParentEntry);
5866
5867 entry->newTransactedParentEntry = entry->transactedParentEntry;
5868 }
5869
5871 }
5872}

Referenced by TransactedSnapshotImpl_Commit(), and TransactedSnapshotImpl_CopyTree().

◆ TransactedSnapshotImpl_EnsureReadEntry()

static HRESULT TransactedSnapshotImpl_EnsureReadEntry ( TransactedSnapshotImpl This,
DirRef  entry 
)
static

Definition at line 5662 of file storage32.c.

5664{
5665 HRESULT hr=S_OK;
5666 DirEntry data;
5667
5668 if (!This->entries[entry].read)
5669 {
5670 hr = StorageBaseImpl_ReadDirEntry(This->transactedParent,
5671 This->entries[entry].transactedParentEntry,
5672 &data);
5673
5674 if (SUCCEEDED(hr) && data.leftChild != DIRENTRY_NULL)
5675 {
5676 data.leftChild = TransactedSnapshotImpl_CreateStubEntry(This, data.leftChild);
5677
5678 if (data.leftChild == DIRENTRY_NULL)
5679 hr = E_OUTOFMEMORY;
5680 }
5681
5682 if (SUCCEEDED(hr) && data.rightChild != DIRENTRY_NULL)
5683 {
5684 data.rightChild = TransactedSnapshotImpl_CreateStubEntry(This, data.rightChild);
5685
5686 if (data.rightChild == DIRENTRY_NULL)
5687 hr = E_OUTOFMEMORY;
5688 }
5689
5690 if (SUCCEEDED(hr) && data.dirRootEntry != DIRENTRY_NULL)
5691 {
5692 data.dirRootEntry = TransactedSnapshotImpl_CreateStubEntry(This, data.dirRootEntry);
5693
5694 if (data.dirRootEntry == DIRENTRY_NULL)
5695 hr = E_OUTOFMEMORY;
5696 }
5697
5698 if (SUCCEEDED(hr))
5699 {
5700 memcpy(&This->entries[entry].data, &data, sizeof(DirEntry));
5701 This->entries[entry].read = TRUE;
5702 }
5703 }
5704
5705 return hr;
5706}

Referenced by TransactedSnapshotImpl_ReadDirEntry(), TransactedSnapshotImpl_StreamLink(), TransactedSnapshotImpl_StreamSetSize(), TransactedSnapshotImpl_StreamWriteAt(), and TransactedSnapshotImpl_WriteDirEntry().

◆ TransactedSnapshotImpl_FindFirstChild()

static DirRef TransactedSnapshotImpl_FindFirstChild ( TransactedSnapshotImpl This,
DirRef  parent 
)
static

Definition at line 5760 of file storage32.c.

5762{
5763 DirRef cursor, prev;
5765
5766 cursor = parent;
5767 entry = &This->entries[cursor];
5768 while (entry->read)
5769 {
5770 if (entry->data.leftChild != DIRENTRY_NULL)
5771 {
5772 prev = cursor;
5773 cursor = entry->data.leftChild;
5774 entry = &This->entries[cursor];
5775 entry->parent = prev;
5776 }
5777 else if (entry->data.rightChild != DIRENTRY_NULL)
5778 {
5779 prev = cursor;
5780 cursor = entry->data.rightChild;
5781 entry = &This->entries[cursor];
5782 entry->parent = prev;
5783 }
5784 else if (entry->data.dirRootEntry != DIRENTRY_NULL)
5785 {
5786 prev = cursor;
5787 cursor = entry->data.dirRootEntry;
5788 entry = &This->entries[cursor];
5789 entry->parent = prev;
5790 }
5791 else
5792 break;
5793 }
5794
5795 return cursor;
5796}
r parent
Definition: btrfs.c:3010

Referenced by TransactedSnapshotImpl_CopyTree(), TransactedSnapshotImpl_DestroyTemporaryCopy(), and TransactedSnapshotImpl_FindNextChild().

◆ TransactedSnapshotImpl_FindFreeEntry()

static DirRef TransactedSnapshotImpl_FindFreeEntry ( TransactedSnapshotImpl This)
static

Definition at line 5613 of file storage32.c.

5614{
5615 DirRef result=This->firstFreeEntry;
5616
5617 while (result < This->entries_size && This->entries[result].inuse)
5618 result++;
5619
5620 if (result == This->entries_size)
5621 {
5622 ULONG new_size = This->entries_size * 2;
5623 TransactedDirEntry *new_entries;
5624
5625 new_entries = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(TransactedDirEntry) * new_size);
5626 if (!new_entries) return DIRENTRY_NULL;
5627
5628 memcpy(new_entries, This->entries, sizeof(TransactedDirEntry) * This->entries_size);
5629 HeapFree(GetProcessHeap(), 0, This->entries);
5630
5631 This->entries = new_entries;
5632 This->entries_size = new_size;
5633 }
5634
5635 This->entries[result].inuse = TRUE;
5636
5637 This->firstFreeEntry = result+1;
5638
5639 return result;
5640}

Referenced by TransactedSnapshotImpl_CreateDirEntry(), and TransactedSnapshotImpl_CreateStubEntry().

◆ TransactedSnapshotImpl_FindNextChild()

static DirRef TransactedSnapshotImpl_FindNextChild ( TransactedSnapshotImpl This,
DirRef  current 
)
static

Definition at line 5799 of file storage32.c.

5801{
5802 DirRef parent;
5803 TransactedDirEntry *parent_entry;
5804
5805 parent = This->entries[current].parent;
5806 parent_entry = &This->entries[parent];
5807
5808 if (parent != DIRENTRY_NULL && parent_entry->data.dirRootEntry != current)
5809 {
5810 if (parent_entry->data.rightChild != current && parent_entry->data.rightChild != DIRENTRY_NULL)
5811 {
5812 This->entries[parent_entry->data.rightChild].parent = parent;
5814 }
5815
5816 if (parent_entry->data.dirRootEntry != DIRENTRY_NULL)
5817 {
5818 This->entries[parent_entry->data.dirRootEntry].parent = parent;
5820 }
5821 }
5822
5823 return parent;
5824}

Referenced by TransactedSnapshotImpl_CopyTree(), and TransactedSnapshotImpl_DestroyTemporaryCopy().

◆ TransactedSnapshotImpl_Flush()

static HRESULT TransactedSnapshotImpl_Flush ( StorageBaseImpl iface)
static

Definition at line 6148 of file storage32.c.

6149{
6150 /* We only need to flush when committing. */
6151 return S_OK;
6152}

◆ TransactedSnapshotImpl_GetFilename()

static HRESULT TransactedSnapshotImpl_GetFilename ( StorageBaseImpl iface,
LPWSTR result 
)
static

Definition at line 6154 of file storage32.c.

6155{
6157
6158 return StorageBaseImpl_GetFilename(This->transactedParent, result);
6159}

◆ TransactedSnapshotImpl_GetTransactionSig()

static HRESULT TransactedSnapshotImpl_GetTransactionSig ( StorageBaseImpl base,
ULONG result,
BOOL  refresh 
)
static

Definition at line 6412 of file storage32.c.

6414{
6415 return E_NOTIMPL;
6416}

◆ TransactedSnapshotImpl_Invalidate()

static void TransactedSnapshotImpl_Invalidate ( StorageBaseImpl This)
static

Definition at line 6125 of file storage32.c.

6126{
6127 if (!This->reverted)
6128 {
6129 TRACE("Storage invalidated (stg=%p)\n", This);
6130
6131 This->reverted = TRUE;
6132
6134 }
6135}

◆ TransactedSnapshotImpl_LockTransaction()

static HRESULT TransactedSnapshotImpl_LockTransaction ( StorageBaseImpl base,
BOOL  write 
)
static

Definition at line 6424 of file storage32.c.

6425{
6426 return E_NOTIMPL;
6427}

◆ TransactedSnapshotImpl_MadeCopy()

static BOOL TransactedSnapshotImpl_MadeCopy ( TransactedSnapshotImpl This,
DirRef  entry 
)
inlinestatic

Definition at line 5827 of file storage32.c.

5829{
5830 return entry != DIRENTRY_NULL &&
5831 This->entries[entry].newTransactedParentEntry != This->entries[entry].transactedParentEntry;
5832}

Referenced by TransactedSnapshotImpl_CopyTree(), and TransactedSnapshotImpl_DestroyTemporaryCopy().

◆ TransactedSnapshotImpl_MakeStreamDirty()

static HRESULT TransactedSnapshotImpl_MakeStreamDirty ( TransactedSnapshotImpl This,
DirRef  entry 
)
static

Definition at line 5708 of file storage32.c.

5710{
5711 HRESULT hr = S_OK;
5712
5713 if (!This->entries[entry].stream_dirty)
5714 {
5715 DirEntry new_entrydata;
5716
5717 memset(&new_entrydata, 0, sizeof(DirEntry));
5718 new_entrydata.name[0] = 'S';
5719 new_entrydata.sizeOfNameString = 1;
5720 new_entrydata.stgType = STGTY_STREAM;
5721 new_entrydata.startingBlock = BLOCK_END_OF_CHAIN;
5722 new_entrydata.leftChild = DIRENTRY_NULL;
5723 new_entrydata.rightChild = DIRENTRY_NULL;
5724 new_entrydata.dirRootEntry = DIRENTRY_NULL;
5725
5726 hr = StorageBaseImpl_CreateDirEntry(This->scratch, &new_entrydata,
5727 &This->entries[entry].stream_entry);
5728
5729 if (SUCCEEDED(hr) && This->entries[entry].transactedParentEntry != DIRENTRY_NULL)
5730 {
5732 This->scratch, This->entries[entry].stream_entry,
5733 This->transactedParent, This->entries[entry].transactedParentEntry);
5734
5735 if (FAILED(hr))
5736 StorageBaseImpl_DestroyDirEntry(This->scratch, This->entries[entry].stream_entry);
5737 }
5738
5739 if (SUCCEEDED(hr))
5740 This->entries[entry].stream_dirty = TRUE;
5741
5742 if (This->entries[entry].transactedParentEntry != DIRENTRY_NULL)
5743 {
5744 /* Since this entry is modified, and we aren't using its stream data, we
5745 * no longer care about the original entry. */
5746 DirRef delete_ref;
5747 delete_ref = TransactedSnapshotImpl_CreateStubEntry(This, This->entries[entry].transactedParentEntry);
5748
5749 if (delete_ref != DIRENTRY_NULL)
5750 This->entries[delete_ref].deleted = TRUE;
5751
5752 This->entries[entry].transactedParentEntry = This->entries[entry].newTransactedParentEntry = DIRENTRY_NULL;
5753 }
5754 }
5755
5756 return hr;
5757}

Referenced by TransactedSnapshotImpl_StreamSetSize(), and TransactedSnapshotImpl_StreamWriteAt().

◆ TransactedSnapshotImpl_ReadDirEntry()

static HRESULT TransactedSnapshotImpl_ReadDirEntry ( StorageBaseImpl base,
DirRef  index,
DirEntry data 
)
static

Definition at line 6225 of file storage32.c.

6227{
6229 HRESULT hr;
6230
6232 if (FAILED(hr))
6233 {
6234 TRACE("<-- %08x\n", hr);
6235 return hr;
6236 }
6237
6238 memcpy(data, &This->entries[index].data, sizeof(DirEntry));
6239
6240 TRACE("%x %s l=%x r=%x d=%x\n", index, debugstr_w(data->name), data->leftChild, data->rightChild, data->dirRootEntry);
6241
6242 return S_OK;
6243}
static HRESULT TransactedSnapshotImpl_EnsureReadEntry(TransactedSnapshotImpl *This, DirRef entry)
Definition: storage32.c:5662

◆ TransactedSnapshotImpl_Revert()

static HRESULT WINAPI TransactedSnapshotImpl_Revert ( IStorage iface)
static

Definition at line 6092 of file storage32.c.

6094{
6097 ULONG i;
6098
6099 TRACE("(%p)\n", iface);
6100
6101 /* Destroy the open objects. */
6103
6104 /* Clear out the scratch file. */
6105 zero.QuadPart = 0;
6106 for (i=0; i<This->entries_size; i++)
6107 {
6108 if (This->entries[i].stream_dirty)
6109 {
6110 StorageBaseImpl_StreamSetSize(This->scratch, This->entries[i].stream_entry,
6111 zero);
6112
6113 StorageBaseImpl_DestroyDirEntry(This->scratch, This->entries[i].stream_entry);
6114 }
6115 }
6116
6117 memset(This->entries, 0, sizeof(TransactedDirEntry) * This->entries_size);
6118
6119 This->firstFreeEntry = 0;
6120 This->base.storageDirEntry = TransactedSnapshotImpl_CreateStubEntry(This, This->transactedParent->storageDirEntry);
6121
6122 return S_OK;
6123}

◆ TransactedSnapshotImpl_SetTransactionSig()

static HRESULT TransactedSnapshotImpl_SetTransactionSig ( StorageBaseImpl base,
ULONG  value 
)
static

Definition at line 6418 of file storage32.c.

6420{
6421 return E_NOTIMPL;
6422}

◆ TransactedSnapshotImpl_StreamLink()

static HRESULT TransactedSnapshotImpl_StreamLink ( StorageBaseImpl base,
DirRef  dst,
DirRef  src 
)
static

Definition at line 6379 of file storage32.c.

6381{
6383 HRESULT hr;
6384 TransactedDirEntry *dst_entry, *src_entry;
6385
6387 if (FAILED(hr))
6388 {
6389 TRACE("<-- %08x\n", hr);
6390 return hr;
6391 }
6392
6394 if (FAILED(hr))
6395 {
6396 TRACE("<-- %08x\n", hr);
6397 return hr;
6398 }
6399
6400 dst_entry = &This->entries[dst];
6401 src_entry = &This->entries[src];
6402
6403 dst_entry->stream_dirty = src_entry->stream_dirty;
6404 dst_entry->stream_entry = src_entry->stream_entry;
6405 dst_entry->transactedParentEntry = src_entry->transactedParentEntry;
6406 dst_entry->newTransactedParentEntry = src_entry->newTransactedParentEntry;
6407 dst_entry->data.size = src_entry->data.size;
6408
6409 return S_OK;
6410}

◆ TransactedSnapshotImpl_StreamReadAt()

static HRESULT TransactedSnapshotImpl_StreamReadAt ( StorageBaseImpl base,
DirRef  index,
ULARGE_INTEGER  offset,
ULONG  size,
void buffer,
ULONG bytesRead 
)
static

Definition at line 6267 of file storage32.c.

6269{
6271
6272 if (This->entries[index].stream_dirty)
6273 {
6274 return StorageBaseImpl_StreamReadAt(This->scratch,
6275 This->entries[index].stream_entry, offset, size, buffer, bytesRead);
6276 }
6277 else if (This->entries[index].transactedParentEntry == DIRENTRY_NULL)
6278 {
6279 /* This stream doesn't live in the parent, and we haven't allocated storage
6280 * for it yet */
6281 *bytesRead = 0;
6282 return S_OK;
6283 }
6284 else
6285 {
6286 return StorageBaseImpl_StreamReadAt(This->transactedParent,
6287 This->entries[index].transactedParentEntry, offset, size, buffer, bytesRead);
6288 }
6289}

◆ TransactedSnapshotImpl_StreamSetSize()

static HRESULT TransactedSnapshotImpl_StreamSetSize ( StorageBaseImpl base,
DirRef  index,
ULARGE_INTEGER  newsize 
)
static

Definition at line 6323 of file storage32.c.

6325{
6327 HRESULT hr;
6328
6330 if (FAILED(hr))
6331 {
6332 TRACE("<-- %08x\n", hr);
6333 return hr;
6334 }
6335
6336 if (This->entries[index].data.size.QuadPart == newsize.QuadPart)
6337 return S_OK;
6338
6339 if (newsize.QuadPart == 0)
6340 {
6341 /* Destroy any parent references or entries in the scratch file. */
6342 if (This->entries[index].stream_dirty)
6343 {
6345 zero.QuadPart = 0;
6347 This->entries[index].stream_entry, zero);
6349 This->entries[index].stream_entry);
6350 This->entries[index].stream_dirty = FALSE;
6351 }
6352 else if (This->entries[index].transactedParentEntry != DIRENTRY_NULL)
6353 {
6354 DirRef delete_ref;
6355 delete_ref = TransactedSnapshotImpl_CreateStubEntry(This, This->entries[index].transactedParentEntry);
6356
6357 if (delete_ref != DIRENTRY_NULL)
6358 This->entries[delete_ref].deleted = TRUE;
6359
6360 This->entries[index].transactedParentEntry = This->entries[index].newTransactedParentEntry = DIRENTRY_NULL;
6361 }
6362 }
6363 else
6364 {
6366 if (FAILED(hr)) return hr;
6367
6369 This->entries[index].stream_entry, newsize);
6370 }
6371
6372 if (SUCCEEDED(hr))
6373 This->entries[index].data.size = newsize;
6374
6375 TRACE("<-- %08x\n", hr);
6376 return hr;
6377}
static HRESULT TransactedSnapshotImpl_MakeStreamDirty(TransactedSnapshotImpl *This, DirRef entry)
Definition: storage32.c:5708

◆ TransactedSnapshotImpl_StreamWriteAt()

static HRESULT TransactedSnapshotImpl_StreamWriteAt ( StorageBaseImpl base,
DirRef  index,
ULARGE_INTEGER  offset,
ULONG  size,
const void buffer,
ULONG bytesWritten 
)
static

Definition at line 6291 of file storage32.c.

6293{
6295 HRESULT hr;
6296
6298 if (FAILED(hr))
6299 {
6300 TRACE("<-- %08x\n", hr);
6301 return hr;
6302 }
6303
6305 if (FAILED(hr))
6306 {
6307 TRACE("<-- %08x\n", hr);
6308 return hr;
6309 }
6310
6312 This->entries[index].stream_entry, offset, size, buffer, bytesWritten);
6313
6314 if (SUCCEEDED(hr) && size != 0)
6315 This->entries[index].data.size.QuadPart = max(
6316 This->entries[index].data.size.QuadPart,
6317 offset.QuadPart + size);
6318
6319 TRACE("<-- %08x\n", hr);
6320 return hr;
6321}

◆ TransactedSnapshotImpl_UnlockTransaction()

static HRESULT TransactedSnapshotImpl_UnlockTransaction ( StorageBaseImpl base,
BOOL  write 
)
static

Definition at line 6429 of file storage32.c.

6430{
6431 return E_NOTIMPL;
6432}

◆ TransactedSnapshotImpl_WriteDirEntry()

static HRESULT TransactedSnapshotImpl_WriteDirEntry ( StorageBaseImpl base,
DirRef  index,
const DirEntry data 
)
static

Definition at line 6186 of file storage32.c.

6188{
6190 HRESULT hr;
6191
6192 TRACE("%x %s l=%x r=%x d=%x\n", index, debugstr_w(data->name), data->leftChild, data->rightChild, data->dirRootEntry);
6193
6195 if (FAILED(hr))
6196 {
6197 TRACE("<-- %08x\n", hr);
6198 return hr;
6199 }
6200
6201 memcpy(&This->entries[index].data, data, sizeof(DirEntry));
6202
6203 if (index != This->base.storageDirEntry)
6204 {
6205 This->entries[index].dirty = TRUE;
6206
6207 if (data->size.QuadPart == 0 &&
6208 This->entries[index].transactedParentEntry != DIRENTRY_NULL)
6209 {
6210 /* Since this entry is modified, and we aren't using its stream data, we
6211 * no longer care about the original entry. */
6212 DirRef delete_ref;
6213 delete_ref = TransactedSnapshotImpl_CreateStubEntry(This, This->entries[index].transactedParentEntry);
6214
6215 if (delete_ref != DIRENTRY_NULL)
6216 This->entries[delete_ref].deleted = TRUE;
6217
6218 This->entries[index].transactedParentEntry = This->entries[index].newTransactedParentEntry = DIRENTRY_NULL;
6219 }
6220 }
6221 TRACE("<-- S_OK\n");
6222 return S_OK;
6223}

◆ UpdateRawDirEntry()

static void UpdateRawDirEntry ( BYTE buffer,
const DirEntry newData 
)
static

Definition at line 3239 of file storage32.c.

3240{
3242
3243 memcpy(
3245 newData->name,
3247
3248 memcpy(buffer + OFFSET_PS_STGTYPE, &newData->stgType, 1);
3249
3251 buffer,
3253 newData->sizeOfNameString);
3254
3256 buffer,
3258 newData->leftChild);
3259
3261 buffer,
3263 newData->rightChild);
3264
3266 buffer,
3268 newData->dirRootEntry);
3269
3271 buffer,
3273 &newData->clsid);
3274
3276 buffer,
3278 newData->ctime.dwLowDateTime);
3279
3281 buffer,
3283 newData->ctime.dwHighDateTime);
3284
3286 buffer,
3288 newData->mtime.dwLowDateTime);
3289
3291 buffer,
3293 newData->ctime.dwHighDateTime);
3294
3296 buffer,
3298 newData->startingBlock);
3299
3301 buffer,
3303 newData->size.u.LowPart);
3304
3306 buffer,
3308 newData->size.u.HighPart);
3309}
void StorageUtl_WriteGUID(BYTE *buffer, ULONG offset, const GUID *value)
Definition: storage32.c:7008
DWORD dwHighDateTime
Definition: mapidefs.h:66
DWORD dwLowDateTime
Definition: mapidefs.h:65

Referenced by StorageImpl_CreateDirEntry(), and StorageImpl_WriteDirEntry().

◆ validateSTGM()

static HRESULT validateSTGM ( DWORD  stgm)
static

Definition at line 287 of file storage32.c.

288{
290 DWORD share = STGM_SHARE_MODE(stgm);
292
293 if (stgm&~STGM_KNOWN_FLAGS)
294 {
295 ERR("unknown flags %08x\n", stgm);
296 return E_FAIL;
297 }
298
299 switch (access)
300 {
301 case STGM_READ:
302 case STGM_WRITE:
303 case STGM_READWRITE:
304 break;
305 default:
306 return E_FAIL;
307 }
308
309 switch (share)
310 {
315 break;
316 case 0:
317 if (!(stgm & STGM_TRANSACTED))
318 return E_FAIL;
319 break;
320 default:
321 return E_FAIL;
322 }
323
324 switch (create)
325 {
326 case STGM_CREATE:
327 case STGM_FAILIFTHERE:
328 break;
329 default:
330 return E_FAIL;
331 }
332
333 /*
334 * STGM_DIRECT | STGM_TRANSACTED | STGM_SIMPLE
335 */
336 if ( (stgm & STGM_TRANSACTED) && (stgm & STGM_SIMPLE) )
337 return E_FAIL;
338
339 /*
340 * STGM_CREATE | STGM_CONVERT
341 * if both are false, STGM_FAILIFTHERE is set to TRUE
342 */
343 if ( create == STGM_CREATE && (stgm & STGM_CONVERT) )
344 return E_FAIL;
345
346 /*
347 * STGM_NOSCRATCH requires STGM_TRANSACTED
348 */
349 if ( (stgm & STGM_NOSCRATCH) && !(stgm & STGM_TRANSACTED) )
350 return E_FAIL;
351
352 /*
353 * STGM_NOSNAPSHOT requires STGM_TRANSACTED and
354 * not STGM_SHARE_EXCLUSIVE or STGM_SHARE_DENY_WRITE`
355 */
356 if ( (stgm & STGM_NOSNAPSHOT) &&
357 (!(stgm & STGM_TRANSACTED) ||
358 share == STGM_SHARE_EXCLUSIVE ||
359 share == STGM_SHARE_DENY_WRITE) )
360 return E_FAIL;
361
362 return S_OK;
363}
GLuint GLint GLboolean GLint GLenum access
Definition: glext.h:7866
#define STGM_KNOWN_FLAGS
Definition: storage32.h:119

Referenced by create_storagefile(), StgOpenStorage(), StgOpenStorageOnILockBytes(), StorageBaseImpl_CreateStorage(), StorageBaseImpl_CreateStream(), StorageBaseImpl_OpenStorage(), StorageBaseImpl_OpenStream(), and StorageImpl_Construct().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( storage  )

◆ WriteClassStg()

HRESULT WINAPI WriteClassStg ( IStorage pStg,
REFCLSID  rclsid 
)

Definition at line 9078 of file storage32.c.

9079{
9080 if(!pStg)
9081 return E_INVALIDARG;
9082
9083 if(!rclsid)
9084 return STG_E_INVALIDPOINTER;
9085
9086 return IStorage_SetClass(pStg, rclsid);
9087}

Referenced by OleCreateStaticFromData(), OleSave(), test_hglobal_storage_stat(), test_overwrite(), test_storage_refcount(), test_streamenum(), test_transacted_shared(), and test_writeclassstg().

◆ WriteClassStm()

HRESULT WINAPI WriteClassStm ( IStream pStm,
REFCLSID  rclsid 
)

Definition at line 9525 of file storage32.c.

9526{
9527 TRACE("(%p,%p)\n",pStm,rclsid);
9528
9529 if (!pStm || !rclsid)
9530 return E_INVALIDARG;
9531
9532 return IStream_Write(pStm,rclsid,sizeof(CLSID),NULL);
9533}

Referenced by OLECONVERT_CreateCompObjStream(), OleSaveToStream(), STORAGE_WriteCompObj(), and test_ReadClassStm().

◆ WriteFmtUserTypeStg()

HRESULT WINAPI WriteFmtUserTypeStg ( LPSTORAGE  pstg,
CLIPFORMAT  cf,
LPOLESTR  lpszUserType 
)

Definition at line 9356 of file storage32.c.

9358{
9359 STATSTG stat;
9360 HRESULT r;
9361 WCHAR szwClipName[0x40];
9362 CLSID clsid;
9363 LPWSTR wstrProgID = NULL;
9364 DWORD n;
9365
9366 TRACE("(%p,%x,%s)\n",pstg,cf,debugstr_w(lpszUserType));
9367
9368 /* get the clipboard format name */
9369 if( cf )
9370 {
9371 n = GetClipboardFormatNameW(cf, szwClipName, ARRAY_SIZE(szwClipName));
9372 szwClipName[n]=0;
9373 }
9374
9375 TRACE("Clipboard name is %s\n", debugstr_w(szwClipName));
9376
9377 r = IStorage_Stat(pstg, &stat, STATFLAG_NONAME);
9378 if(SUCCEEDED(r))
9379 clsid = stat.clsid;
9380 else
9381 clsid = CLSID_NULL;
9382
9383 ProgIDFromCLSID(&clsid, &wstrProgID);
9384
9385 TRACE("progid is %s\n",debugstr_w(wstrProgID));
9386
9387 r = STORAGE_WriteCompObj( pstg, &clsid, lpszUserType,
9388 cf ? szwClipName : NULL, wstrProgID );
9389
9390 CoTaskMemFree(wstrProgID);
9391
9392 return r;
9393}
static HRESULT STORAGE_WriteCompObj(LPSTORAGE pstg, CLSID *clsid, LPCWSTR lpszUserType, LPCWSTR szClipName, LPCWSTR szProgIDName)
Definition: storage32.c:9309
GLdouble n
Definition: glext.h:7729
int WINAPI GetClipboardFormatNameW(_In_ UINT format, _Out_writes_(cchMaxCount) LPWSTR lpszFormatName, _In_ int cchMaxCount)

Referenced by OleCreateStaticFromData(), OleDoAutoConvert(), test_fmtusertypestg(), and test_OleDoAutoConvert().

Variable Documentation

◆ DirectWriterLockVtbl

const IDirectWriterLockVtbl DirectWriterLockVtbl
static
Initial value:
=
{
}
static HRESULT WINAPI directwriterlock_QueryInterface(IDirectWriterLock *iface, REFIID riid, void **obj)
Definition: storage32.c:445
static HRESULT WINAPI directwriterlock_HaveWriteAccess(IDirectWriterLock *iface)
Definition: storage32.c:477
static HRESULT WINAPI directwriterlock_ReleaseWriteAccess(IDirectWriterLock *iface)
Definition: storage32.c:470
static HRESULT WINAPI directwriterlock_WaitForWriteAccess(IDirectWriterLock *iface, DWORD timeout)
Definition: storage32.c:463
static ULONG WINAPI directwriterlock_Release(IDirectWriterLock *iface)
Definition: storage32.c:457
static ULONG WINAPI directwriterlock_AddRef(IDirectWriterLock *iface)
Definition: storage32.c:451

Definition at line 484 of file storage32.c.

Referenced by StorageImpl_Construct().

◆ IEnumSTATSTGImpl_Vtbl

const IEnumSTATSTGVtbl IEnumSTATSTGImpl_Vtbl
static
Initial value:
=
{
}
static ULONG WINAPI IEnumSTATSTGImpl_AddRef(IEnumSTATSTG *iface)
Definition: storage32.c:930
static HRESULT WINAPI IEnumSTATSTGImpl_Skip(IEnumSTATSTG *iface, ULONG celt)
Definition: storage32.c:1081
static ULONG WINAPI IEnumSTATSTGImpl_Release(IEnumSTATSTG *iface)
Definition: storage32.c:937
static HRESULT WINAPI IEnumSTATSTGImpl_QueryInterface(IEnumSTATSTG *iface, REFIID riid, void **ppvObject)
Definition: storage32.c:903
static HRESULT WINAPI IEnumSTATSTGImpl_Clone(IEnumSTATSTG *iface, IEnumSTATSTG **ppenum)
Definition: storage32.c:1136
static HRESULT WINAPI IEnumSTATSTGImpl_Reset(IEnumSTATSTG *iface)
Definition: storage32.c:1116
static HRESULT WINAPI IEnumSTATSTGImpl_Next(IEnumSTATSTG *iface, ULONG celt, STATSTG *rgelt, ULONG *pceltFetched)
Definition: storage32.c:1002

Definition at line 1176 of file storage32.c.

Referenced by IEnumSTATSTGImpl_Construct().

◆ IPropertySetStorage_Vtbl

const IPropertySetStorageVtbl IPropertySetStorage_Vtbl
extern

Definition at line 2557 of file stg_prop.c.

Referenced by StorageImpl_Construct(), and StorageInternalImpl_Construct().

◆ STORAGE_magic

const BYTE STORAGE_magic[8] ={0xd0,0xcf,0x11,0xe0,0xa1,0xb1,0x1a,0xe1}
static

◆ STORAGE_oldmagic

const BYTE STORAGE_oldmagic[8] ={0xd0,0xcf,0x11,0xe0,0x0e,0x11,0xfc,0x0d}
static

Definition at line 62 of file storage32.c.

Referenced by StorageImpl_LoadFileHeader().

◆ StorageImpl_BaseVtbl

const StorageBaseImplVtbl StorageImpl_BaseVtbl
static
Initial value:
=
{
}
static HRESULT StorageImpl_StreamReadAt(StorageBaseImpl *base, DirRef index, ULARGE_INTEGER offset, ULONG size, void *buffer, ULONG *bytesRead)
Definition: storage32.c:4411
static HRESULT StorageImpl_BaseReadDirEntry(StorageBaseImpl *base, DirRef index, DirEntry *data)
Definition: storage32.c:4332
static HRESULT StorageImpl_BaseWriteDirEntry(StorageBaseImpl *base, DirRef index, const DirEntry *data)
Definition: storage32.c:4325
static HRESULT StorageImpl_SetTransactionSig(StorageBaseImpl *base, ULONG value)
Definition: storage32.c:4877
static HRESULT StorageImpl_DestroyDirEntry(StorageBaseImpl *base, DirRef index)
Definition: storage32.c:3220
static HRESULT StorageImpl_LockTransaction(StorageBaseImpl *base, BOOL write)
Definition: storage32.c:4964
static HRESULT StorageImpl_StreamLink(StorageBaseImpl *base, DirRef dst, DirRef src)
Definition: storage32.c:4599
static HRESULT StorageImpl_UnlockTransaction(StorageBaseImpl *base, BOOL write)
Definition: storage32.c:4988
static void StorageImpl_Destroy(StorageBaseImpl *iface)
Definition: storage32.c:5186
static HRESULT StorageImpl_StreamWriteAt(StorageBaseImpl *base, DirRef index, ULARGE_INTEGER offset, ULONG size, const void *buffer, ULONG *bytesWritten)
Definition: storage32.c:4551
static HRESULT StorageImpl_GetFilename(StorageBaseImpl *iface, LPWSTR *result)
Definition: storage32.c:5010
static HRESULT StorageImpl_CreateDirEntry(StorageBaseImpl *base, const DirEntry *newData, DirRef *index)
Definition: storage32.c:3317
static HRESULT StorageImpl_GetTransactionSig(StorageBaseImpl *base, ULONG *result, BOOL refresh)
Definition: storage32.c:4838

Definition at line 5222 of file storage32.c.

Referenced by StorageImpl_Construct().

◆ StorageImpl_Vtbl

const IStorageVtbl StorageImpl_Vtbl
static
Initial value:
=
{
}
static HRESULT WINAPI StorageBaseImpl_DestroyElement(IStorage *iface, const OLECHAR *pwcsName)
Definition: storage32.c:2576
static HRESULT WINAPI StorageBaseImpl_Revert(IStorage *iface)
Definition: storage32.c:2412
static HRESULT WINAPI StorageBaseImpl_CreateStream(IStorage *iface, const OLECHAR *pwcsName, DWORD grfMode, DWORD reserved1, DWORD reserved2, IStream **ppstm)
Definition: storage32.c:1924
static HRESULT WINAPI StorageBaseImpl_MoveElementTo(IStorage *iface, const OLECHAR *pwcsName, IStorage *pstgDest, const OLECHAR *pwcsNewName, DWORD grfFlags)
Definition: storage32.c:2377
static HRESULT WINAPI StorageBaseImpl_OpenStorage(IStorage *iface, const OLECHAR *pwcsName, IStorage *pstgPriority, DWORD grfMode, SNB snbExclude, DWORD reserved, IStorage **ppstg)
Definition: storage32.c:1609
static ULONG WINAPI StorageBaseImpl_AddRef(IStorage *iface)
Definition: storage32.c:1279
static HRESULT WINAPI StorageBaseImpl_EnumElements(IStorage *iface, DWORD reserved1, void *reserved2, DWORD reserved3, IEnumSTATSTG **ppenum)
Definition: storage32.c:1747
static ULONG WINAPI StorageBaseImpl_Release(IStorage *iface)
Definition: storage32.c:1298
static HRESULT WINAPI StorageBaseImpl_RenameElement(IStorage *iface, const OLECHAR *pwcsOldName, const OLECHAR *pwcsNewName)
Definition: storage32.c:1843
static HRESULT WINAPI StorageBaseImpl_Commit(IStorage *iface, DWORD grfCommitFlags)
Definition: storage32.c:2398
static HRESULT WINAPI StorageBaseImpl_CreateStorage(IStorage *iface, const OLECHAR *pwcsName, DWORD grfMode, DWORD reserved1, DWORD reserved2, IStorage **ppstg)
Definition: storage32.c:2117
static HRESULT WINAPI StorageBaseImpl_OpenStream(IStorage *iface, const OLECHAR *pwcsName, void *reserved1, DWORD grfMode, DWORD reserved2, IStream **ppstm)
Definition: storage32.c:1495
static HRESULT WINAPI StorageBaseImpl_SetClass(IStorage *iface, REFCLSID clsid)
Definition: storage32.c:2079
static HRESULT WINAPI StorageBaseImpl_SetElementTimes(IStorage *iface, const OLECHAR *pwcsName, const FILETIME *pctime, const FILETIME *patime, const FILETIME *pmtime)
Definition: storage32.c:2682
static HRESULT WINAPI StorageBaseImpl_Stat(IStorage *iface, STATSTG *pstatstg, DWORD grfStatFlag)
Definition: storage32.c:1786
static HRESULT WINAPI StorageBaseImpl_CopyTo(IStorage *iface, DWORD ciidExclude, const IID *rgiidExclude, SNB snbExclude, IStorage *pstgDest)
Definition: storage32.c:2288
static HRESULT WINAPI StorageBaseImpl_SetStateBits(IStorage *iface, DWORD grfStateBits, DWORD grfMask)
Definition: storage32.c:2696
static HRESULT WINAPI StorageBaseImpl_QueryInterface(IStorage *iface, REFIID riid, void **ppvObject)
Definition: storage32.c:1232

Definition at line 5246 of file storage32.c.

Referenced by StorageImpl_Construct().

◆ StorageInternalImpl_BaseVtbl

const StorageBaseImplVtbl StorageInternalImpl_BaseVtbl
static
Initial value:
=
{
}
static HRESULT StorageInternalImpl_GetFilename(StorageBaseImpl *iface, LPWSTR *result)
Definition: storage32.c:5394
static HRESULT StorageInternalImpl_GetTransactionSig(StorageBaseImpl *base, ULONG *result, BOOL refresh)
Definition: storage32.c:5473
static HRESULT StorageInternalImpl_LockTransaction(StorageBaseImpl *base, BOOL write)
Definition: storage32.c:5485
static HRESULT StorageInternalImpl_Flush(StorageBaseImpl *iface)
Definition: storage32.c:5387
static HRESULT StorageInternalImpl_StreamLink(StorageBaseImpl *base, DirRef dst, DirRef src)
Definition: storage32.c:5464
static HRESULT StorageInternalImpl_SetTransactionSig(StorageBaseImpl *base, ULONG value)
Definition: storage32.c:5479
static void StorageInternalImpl_Destroy(StorageBaseImpl *iface)
Definition: storage32.c:5378
static HRESULT StorageInternalImpl_ReadDirEntry(StorageBaseImpl *base, DirRef index, DirEntry *data)
Definition: storage32.c:5419
static HRESULT StorageInternalImpl_WriteDirEntry(StorageBaseImpl *base, DirRef index, const DirEntry *data)
Definition: storage32.c:5410
static HRESULT StorageInternalImpl_CreateDirEntry(StorageBaseImpl *base, const DirEntry *newData, DirRef *index)
Definition: storage32.c:5401
static HRESULT StorageInternalImpl_StreamWriteAt(StorageBaseImpl *base, DirRef index, ULARGE_INTEGER offset, ULONG size, const void *buffer, ULONG *bytesWritten)
Definition: storage32.c:5446
static HRESULT StorageInternalImpl_DestroyDirEntry(StorageBaseImpl *base, DirRef index)
Definition: storage32.c:5428
static HRESULT StorageInternalImpl_UnlockTransaction(StorageBaseImpl *base, BOOL write)
Definition: storage32.c:5490
static HRESULT StorageInternalImpl_StreamSetSize(StorageBaseImpl *base, DirRef index, ULARGE_INTEGER newsize)
Definition: storage32.c:5455
static HRESULT StorageInternalImpl_StreamReadAt(StorageBaseImpl *base, DirRef index, ULARGE_INTEGER offset, ULONG size, void *buffer, ULONG *bytesRead)
Definition: storage32.c:5437

Definition at line 5546 of file storage32.c.

Referenced by StorageInternalImpl_Construct().

◆ StorageInternalImpl_Vtbl

◆ TransactedSharedImpl_BaseVtbl

const StorageBaseImplVtbl TransactedSharedImpl_BaseVtbl
static
Initial value:
=
{
}
static HRESULT TransactedSharedImpl_StreamLink(StorageBaseImpl *base, DirRef dst, DirRef src)
Definition: storage32.c:6644
static HRESULT TransactedSharedImpl_DestroyDirEntry(StorageBaseImpl *base, DirRef index)
Definition: storage32.c:6608
static HRESULT TransactedSharedImpl_GetFilename(StorageBaseImpl *iface, LPWSTR *result)
Definition: storage32.c:6574
static void TransactedSharedImpl_Destroy(StorageBaseImpl *iface)
Definition: storage32.c:6558
static HRESULT TransactedSharedImpl_StreamSetSize(StorageBaseImpl *base, DirRef index, ULARGE_INTEGER newsize)
Definition: storage32.c:6635
static HRESULT TransactedSharedImpl_StreamReadAt(StorageBaseImpl *base, DirRef index, ULARGE_INTEGER offset, ULONG size, void *buffer, ULONG *bytesRead)
Definition: storage32.c:6617
static HRESULT TransactedSharedImpl_UnlockTransaction(StorageBaseImpl *base, BOOL write)
Definition: storage32.c:6670
static HRESULT TransactedSharedImpl_LockTransaction(StorageBaseImpl *base, BOOL write)
Definition: storage32.c:6665
static HRESULT TransactedSharedImpl_Flush(StorageBaseImpl *iface)
Definition: storage32.c:6568
static HRESULT TransactedSharedImpl_GetTransactionSig(StorageBaseImpl *base, ULONG *result, BOOL refresh)
Definition: storage32.c:6653
static HRESULT TransactedSharedImpl_StreamWriteAt(StorageBaseImpl *base, DirRef index, ULARGE_INTEGER offset, ULONG size, const void *buffer, ULONG *bytesWritten)
Definition: storage32.c:6626
static HRESULT TransactedSharedImpl_CreateDirEntry(StorageBaseImpl *base, const DirEntry *newData, DirRef *index)
Definition: storage32.c:6581
static HRESULT TransactedSharedImpl_SetTransactionSig(StorageBaseImpl *base, ULONG value)
Definition: storage32.c:6659
static HRESULT TransactedSharedImpl_ReadDirEntry(StorageBaseImpl *base, DirRef index, DirEntry *data)
Definition: storage32.c:6599
static HRESULT TransactedSharedImpl_WriteDirEntry(StorageBaseImpl *base, DirRef index, const DirEntry *data)
Definition: storage32.c:6590

Definition at line 6792 of file storage32.c.

Referenced by TransactedSharedImpl_Construct().

◆ TransactedSharedImpl_Vtbl

◆ TransactedSnapshotImpl_BaseVtbl

const StorageBaseImplVtbl TransactedSnapshotImpl_BaseVtbl
static
Initial value:
=
{
}
static HRESULT TransactedSnapshotImpl_StreamWriteAt(StorageBaseImpl *base, DirRef index, ULARGE_INTEGER offset, ULONG size, const void *buffer, ULONG *bytesWritten)
Definition: storage32.c:6291
static void TransactedSnapshotImpl_Invalidate(StorageBaseImpl *This)
Definition: storage32.c:6125
static HRESULT TransactedSnapshotImpl_GetTransactionSig(StorageBaseImpl *base, ULONG *result, BOOL refresh)
Definition: storage32.c:6412
static HRESULT TransactedSnapshotImpl_DestroyDirEntry(StorageBaseImpl *base, DirRef index)
Definition: storage32.c:6245
static HRESULT TransactedSnapshotImpl_SetTransactionSig(StorageBaseImpl *base, ULONG value)
Definition: storage32.c:6418
static HRESULT TransactedSnapshotImpl_WriteDirEntry(StorageBaseImpl *base, DirRef index, const DirEntry *data)
Definition: storage32.c:6186
static HRESULT TransactedSnapshotImpl_UnlockTransaction(StorageBaseImpl *base, BOOL write)
Definition: storage32.c:6429
static HRESULT TransactedSnapshotImpl_StreamLink(StorageBaseImpl *base, DirRef dst, DirRef src)
Definition: storage32.c:6379
static HRESULT TransactedSnapshotImpl_GetFilename(StorageBaseImpl *iface, LPWSTR *result)
Definition: storage32.c:6154
static HRESULT TransactedSnapshotImpl_ReadDirEntry(StorageBaseImpl *base, DirRef index, DirEntry *data)
Definition: storage32.c:6225
static HRESULT TransactedSnapshotImpl_StreamReadAt(StorageBaseImpl *base, DirRef index, ULARGE_INTEGER offset, ULONG size, void *buffer, ULONG *bytesRead)
Definition: storage32.c:6267
static void TransactedSnapshotImpl_Destroy(StorageBaseImpl *iface)
Definition: storage32.c:6137
static HRESULT TransactedSnapshotImpl_StreamSetSize(StorageBaseImpl *base, DirRef index, ULARGE_INTEGER newsize)
Definition: storage32.c:6323
static HRESULT TransactedSnapshotImpl_Flush(StorageBaseImpl *iface)
Definition: storage32.c:6148
static HRESULT TransactedSnapshotImpl_LockTransaction(StorageBaseImpl *base, BOOL write)
Definition: storage32.c:6424
static HRESULT TransactedSnapshotImpl_CreateDirEntry(StorageBaseImpl *base, const DirEntry *newData, DirRef *index)
Definition: storage32.c:6161

Definition at line 6456 of file storage32.c.

Referenced by TransactedSnapshotImpl_Construct().

◆ TransactedSnapshotImpl_Vtbl