ReactOS 0.4.15-dev-8102-g108db8f
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:7644
#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: debug.h:113
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: debug.h:114
#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. */
539 StorageBaseImpl_ReadDirEntry(storage, storageEntry, data);
540
541 currentEntry = data->dirRootEntry;
542
543 while (currentEntry != DIRENTRY_NULL)
544 {
545 LONG cmp;
546
547 StorageBaseImpl_ReadDirEntry(storage, currentEntry, data);
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:3073

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: debug.h:115
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
10664 return STORAGE_CreateOleStream(storage, flags);
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::@4144 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 */