ReactOS  0.4.14-dev-41-g31d7680
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/unicode.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 9578 of file storage32.c.

◆ OLESTREAM_MAX_STR_LEN

#define OLESTREAM_MAX_STR_LEN   255

Definition at line 9579 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 10610 of file storage32.c.

10610  {
10611  OleStream_LinkedObject = 0x00000001,
10612  OleStream_Convert = 0x00000004
10613 };

Function Documentation

◆ BlockChainStream_Construct()

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

Definition at line 7262 of file storage32.c.

7266 {
7267  BlockChainStream* newStream;
7268 
7269  newStream = HeapAlloc(GetProcessHeap(), 0, sizeof(BlockChainStream));
7270  if(!newStream)
7271  return NULL;
7272 
7273  newStream->parentStorage = parentStorage;
7274  newStream->headOfStreamPlaceHolder = headOfStreamPlaceHolder;
7275  newStream->ownerDirEntry = dirEntry;
7276  newStream->indexCache = NULL;
7277  newStream->indexCacheLen = 0;
7278  newStream->indexCacheSize = 0;
7279  newStream->cachedBlocks[0].index = 0xffffffff;
7280  newStream->cachedBlocks[0].dirty = FALSE;
7281  newStream->cachedBlocks[1].index = 0xffffffff;
7282  newStream->cachedBlocks[1].dirty = FALSE;
7283  newStream->blockToEvict = 0;
7284 
7285  if (FAILED(BlockChainStream_UpdateIndexCache(newStream)))
7286  {
7287  HeapFree(GetProcessHeap(), 0, newStream->indexCache);
7288  HeapFree(GetProcessHeap(), 0, newStream);
7289  return NULL;
7290  }
7291 
7292  return newStream;
7293 }
ULONG blockToEvict
Definition: storage32.c:211
StorageImpl * parentStorage
Definition: storage32.c:204
BlockChainBlock cachedBlocks[2]
Definition: storage32.c:210
smooth NULL
Definition: ftsmooth.c:416
ULONG * headOfStreamPlaceHolder
Definition: storage32.c:205
ULONG indexCacheLen
Definition: storage32.c:208
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
DirRef ownerDirEntry
Definition: storage32.c:206
ULONG indexCacheSize
Definition: storage32.c:209
static HRESULT BlockChainStream_UpdateIndexCache(BlockChainStream *This)
Definition: storage32.c:7109
struct BlockChainRun * indexCache
Definition: storage32.c:207
#define HeapFree(x, y, z)
Definition: compat.h:394

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

◆ BlockChainStream_Destroy()

void BlockChainStream_Destroy ( BlockChainStream This)
static

Definition at line 7312 of file storage32.c.

7313 {
7314  if (This)
7315  {
7317  HeapFree(GetProcessHeap(), 0, This->indexCache);
7318  }
7319  HeapFree(GetProcessHeap(), 0, This);
7320 }
static HRESULT BlockChainStream_Flush(BlockChainStream *)
Definition: storage32.c:7295
#define GetProcessHeap()
Definition: compat.h:395
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by Storage32Impl_BigBlocksToSmallBlocks(), Storage32Impl_SmallBlocksToBigBlocks(), StorageImpl_DeleteCachedBlockChainStream(), StorageImpl_Destroy(), StorageImpl_GetCachedBlockChainStream(), StorageImpl_GetFreeBlockChainCacheEntry(), and StorageImpl_Refresh().

◆ BlockChainStream_Enlarge()

static BOOL BlockChainStream_Enlarge ( BlockChainStream This,
ULARGE_INTEGER  newSize 
)
static

Definition at line 7420 of file storage32.c.

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

Referenced by BlockChainStream_SetSize(), and SmallBlockChainStream_GetNextFreeBlock().

◆ BlockChainStream_Flush()

HRESULT BlockChainStream_Flush ( BlockChainStream This)
static

Definition at line 7295 of file storage32.c.

7296 {
7297  int i;
7298  if (!This) return S_OK;
7299  for (i=0; i<2; i++)
7300  {
7301  if (This->cachedBlocks[i].dirty)
7302  {
7303  if (StorageImpl_WriteBigBlock(This->parentStorage, This->cachedBlocks[i].sector, This->cachedBlocks[i].data))
7304  This->cachedBlocks[i].dirty = FALSE;
7305  else
7306  return STG_E_WRITEFAULT;
7307  }
7308  }
7309  return S_OK;
7310 }
#define STG_E_WRITEFAULT
Definition: winerror.h:2575
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:59
static BOOL StorageImpl_WriteBigBlock(StorageImpl *This, ULONG blockIndex, const void *buffer)
Definition: storage32.c:3590

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 7215 of file storage32.c.

7217 {
7219  int i;
7220 
7221  for (i=0; i<2; i++)
7222  if (This->cachedBlocks[i].index == index)
7223  {
7224  *sector = This->cachedBlocks[i].sector;
7225  *block = &This->cachedBlocks[i];
7226  return S_OK;
7227  }
7228 
7230  if (*sector == BLOCK_END_OF_CHAIN)
7231  return STG_E_DOCFILECORRUPT;
7232 
7233  if (create)
7234  {
7235  if (This->cachedBlocks[0].index == 0xffffffff)
7236  result = &This->cachedBlocks[0];
7237  else if (This->cachedBlocks[1].index == 0xffffffff)
7238  result = &This->cachedBlocks[1];
7239  else
7240  {
7241  result = &This->cachedBlocks[This->blockToEvict++];
7242  if (This->blockToEvict == 2)
7243  This->blockToEvict = 0;
7244  }
7245 
7246  if (result->dirty)
7247  {
7248  if (!StorageImpl_WriteBigBlock(This->parentStorage, result->sector, result->data))
7249  return STG_E_WRITEFAULT;
7250  result->dirty = FALSE;
7251  }
7252 
7253  result->read = FALSE;
7254  result->index = index;
7255  result->sector = *sector;
7256  }
7257 
7258  *block = result;
7259  return S_OK;
7260 }
static unsigned int block
Definition: xmlmemory.c:118
uint32_t sector
Definition: isohybrid.c:61
#define STG_E_WRITEFAULT
Definition: winerror.h:2575
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
smooth NULL
Definition: ftsmooth.c:416
GLuint index
Definition: glext.h:6031
#define STG_E_DOCFILECORRUPT
Definition: winerror.h:2597
static const struct access_res create[16]
Definition: storage32.c:2013
#define index(s, c)
Definition: various.h:29
#define S_OK
Definition: intsafe.h:59
static ULONG BlockChainStream_GetSectorOfOffset(BlockChainStream *This, ULONG offset)
Definition: storage32.c:7186
GLuint64EXT * result
Definition: glext.h:11304
static BOOL StorageImpl_WriteBigBlock(StorageImpl *This, ULONG blockIndex, const void *buffer)
Definition: storage32.c:3590
static const ULONG BLOCK_END_OF_CHAIN
Definition: storage32.h:84

Referenced by BlockChainStream_ReadAt(), and BlockChainStream_WriteAt().

◆ BlockChainStream_GetCount()

static ULONG BlockChainStream_GetCount ( BlockChainStream This)
inlinestatic

Definition at line 219 of file storage32.c.

220 {
221  return This->numBlocks;
222 }

Referenced by BlockChainStream_GetSize(), SmallBlockChainStream_GetNextFreeBlock(), StorageImpl_CreateDirEntry(), and StorageImpl_SaveFileHeader().

◆ BlockChainStream_GetHeadOfChain()

static ULONG BlockChainStream_GetHeadOfChain ( BlockChainStream This)
static

Definition at line 7086 of file storage32.c.

7087 {
7088  DirEntry chainEntry;
7089  HRESULT hr;
7090 
7091  if (This->headOfStreamPlaceHolder != 0)
7092  return *(This->headOfStreamPlaceHolder);
7093 
7094  if (This->ownerDirEntry != DIRENTRY_NULL)
7095  {
7097  This->parentStorage,
7098  This->ownerDirEntry,
7099  &chainEntry);
7100 
7101  if (SUCCEEDED(hr) && chainEntry.startingBlock < BLOCK_FIRST_SPECIAL)
7102  return chainEntry.startingBlock;
7103  }
7104 
7105  return BLOCK_END_OF_CHAIN;
7106 }
HRESULT hr
Definition: shlfolder.c:183
ULONG startingBlock
Definition: storage32.h:156
static const ULONG DIRENTRY_NULL
Definition: storage32.h:86
static HRESULT StorageImpl_ReadDirEntry(StorageImpl *This, DirRef index, DirEntry *buffer)
Definition: storage32.c:3429
LONG HRESULT
Definition: typedefs.h:77
static const ULONG BLOCK_FIRST_SPECIAL
Definition: storage32.h:81
#define SUCCEEDED(hr)
Definition: intsafe.h:57
static const ULONG BLOCK_END_OF_CHAIN
Definition: storage32.h:84

Referenced by BlockChainStream_Enlarge(), and BlockChainStream_UpdateIndexCache().

◆ BlockChainStream_GetSectorOfOffset()

static ULONG BlockChainStream_GetSectorOfOffset ( BlockChainStream This,
ULONG  offset 
)
static

Definition at line 7186 of file storage32.c.

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

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

◆ BlockChainStream_GetSize()

static ULARGE_INTEGER BlockChainStream_GetSize ( BlockChainStream This)
static

Definition at line 7536 of file storage32.c.

7537 {
7538  DirEntry chainEntry;
7539 
7540  if(This->headOfStreamPlaceHolder == NULL)
7541  {
7542  /*
7543  * This chain has a directory entry so use the size value from there.
7544  */
7546  This->parentStorage,
7547  This->ownerDirEntry,
7548  &chainEntry);
7549 
7550  return chainEntry.size;
7551  }
7552  else
7553  {
7554  /*
7555  * this chain is a chain that does not have a directory entry, figure out the
7556  * size by making the product number of used blocks times the
7557  * size of them
7558  */
7560  result.QuadPart =
7562  This->parentStorage->bigBlockSize;
7563 
7564  return result;
7565  }
7566 }
ULARGE_INTEGER size
Definition: storage32.h:157
smooth NULL
Definition: ftsmooth.c:416
static HRESULT StorageImpl_ReadDirEntry(StorageImpl *This, DirRef index, DirEntry *buffer)
Definition: storage32.c:3429
static ULONG BlockChainStream_GetCount(BlockChainStream *This)
Definition: storage32.c:219
uint64_t ULONGLONG
Definition: typedefs.h:65
GLuint64EXT * result
Definition: glext.h:11304

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 7606 of file storage32.c.

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

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 7578 of file storage32.c.

7581 {
7583 
7584  if (newSize.QuadPart == size.QuadPart)
7585  return TRUE;
7586 
7587  if (newSize.QuadPart < size.QuadPart)
7588  {
7589  BlockChainStream_Shrink(This, newSize);
7590  }
7591  else
7592  {
7593  BlockChainStream_Enlarge(This, newSize);
7594  }
7595 
7596  return TRUE;
7597 }
static ULARGE_INTEGER BlockChainStream_GetSize(BlockChainStream *)
Definition: storage32.c:7536
#define TRUE
Definition: types.h:120
static BOOL BlockChainStream_Shrink(BlockChainStream *This, ULARGE_INTEGER newSize)
Definition: storage32.c:7327
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
GLsizeiptr size
Definition: glext.h:5919
static BOOL BlockChainStream_Enlarge(BlockChainStream *This, ULARGE_INTEGER newSize)
Definition: storage32.c:7420

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 7327 of file storage32.c.

7329 {
7330  ULONG blockIndex;
7331  ULONG numBlocks;
7332  int i;
7333 
7334  /*
7335  * Figure out how many blocks are needed to contain the new size
7336  */
7337  numBlocks = newSize.QuadPart / This->parentStorage->bigBlockSize;
7338 
7339  if ((newSize.QuadPart % This->parentStorage->bigBlockSize) != 0)
7340  numBlocks++;
7341 
7342  if (numBlocks)
7343  {
7344  /*
7345  * Go to the new end of chain
7346  */
7347  blockIndex = BlockChainStream_GetSectorOfOffset(This, numBlocks-1);
7348 
7349  /* Mark the new end of chain */
7351  This->parentStorage,
7352  blockIndex,
7354 
7355  This->tailIndex = blockIndex;
7356  }
7357  else
7358  {
7359  if (This->headOfStreamPlaceHolder != 0)
7360  {
7361  *This->headOfStreamPlaceHolder = BLOCK_END_OF_CHAIN;
7362  }
7363  else
7364  {
7365  DirEntry chainEntry;
7366  assert(This->ownerDirEntry != DIRENTRY_NULL);
7367 
7369  This->parentStorage,
7370  This->ownerDirEntry,
7371  &chainEntry);
7372 
7373  chainEntry.startingBlock = BLOCK_END_OF_CHAIN;
7374 
7376  This->parentStorage,
7377  This->ownerDirEntry,
7378  &chainEntry);
7379  }
7380 
7381  This->tailIndex = BLOCK_END_OF_CHAIN;
7382  }
7383 
7384  This->numBlocks = numBlocks;
7385 
7386  /*
7387  * Mark the extra blocks as free
7388  */
7389  while (This->indexCacheLen && This->indexCache[This->indexCacheLen-1].lastOffset >= numBlocks)
7390  {
7391  struct BlockChainRun *last_run = &This->indexCache[This->indexCacheLen-1];
7392  StorageImpl_FreeBigBlock(This->parentStorage,
7393  last_run->firstSector + last_run->lastOffset - last_run->firstOffset);
7394  if (last_run->lastOffset == last_run->firstOffset)
7395  This->indexCacheLen--;
7396  else
7397  last_run->lastOffset--;
7398  }
7399 
7400  /*
7401  * Reset the last accessed block cache.
7402  */
7403  for (i=0; i<2; i++)
7404  {
7405  if (This->cachedBlocks[i].index >= numBlocks)
7406  {
7407  This->cachedBlocks[i].index = 0xffffffff;
7408  This->cachedBlocks[i].dirty = FALSE;
7409  }
7410  }
7411 
7412  return TRUE;
7413 }
#define TRUE
Definition: types.h:120
ULONG firstSector
Definition: storage32.c:188
ULONG startingBlock
Definition: storage32.h:156
static void StorageImpl_SetNextBlockInChain(StorageImpl *This, ULONG blockIndex, ULONG nextBlock)
Definition: storage32.c:4122
#define assert(x)
Definition: debug.h:53
static void StorageImpl_FreeBigBlock(StorageImpl *This, ULONG blockIndex)
Definition: storage32.c:4315
static HRESULT StorageImpl_WriteDirEntry(StorageImpl *This, DirRef index, const DirEntry *buffer)
Definition: storage32.c:3525
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
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
static const ULONG DIRENTRY_NULL
Definition: storage32.h:86
static HRESULT StorageImpl_ReadDirEntry(StorageImpl *This, DirRef index, DirEntry *buffer)
Definition: storage32.c:3429
ULONG lastOffset
Definition: storage32.c:190
ULONG firstOffset
Definition: storage32.c:189
static ULONG BlockChainStream_GetSectorOfOffset(BlockChainStream *This, ULONG offset)
Definition: storage32.c:7186
unsigned int ULONG
Definition: retypes.h:1
static const ULONG BLOCK_END_OF_CHAIN
Definition: storage32.h:84

Referenced by BlockChainStream_SetSize().

◆ BlockChainStream_UpdateIndexCache()

static HRESULT BlockChainStream_UpdateIndexCache ( BlockChainStream This)
static

Definition at line 7109 of file storage32.c.

7110 {
7111  ULONG next_sector, next_offset;
7112  HRESULT hr;
7113  struct BlockChainRun *last_run;
7114 
7115  if (This->indexCacheLen == 0)
7116  {
7117  last_run = NULL;
7118  next_offset = 0;
7119  next_sector = BlockChainStream_GetHeadOfChain(This);
7120  }
7121  else
7122  {
7123  last_run = &This->indexCache[This->indexCacheLen-1];
7124  next_offset = last_run->lastOffset+1;
7125  hr = StorageImpl_GetNextBlockInChain(This->parentStorage,
7126  last_run->firstSector + last_run->lastOffset - last_run->firstOffset,
7127  &next_sector);
7128  if (FAILED(hr)) return hr;
7129  }
7130 
7131  while (next_sector != BLOCK_END_OF_CHAIN)
7132  {
7133  if (!last_run || next_sector != last_run->firstSector + next_offset - last_run->firstOffset)
7134  {
7135  /* Add the current block to the cache. */
7136  if (This->indexCacheSize == 0)
7137  {
7138  This->indexCache = HeapAlloc(GetProcessHeap(), 0, sizeof(struct BlockChainRun)*16);
7139  if (!This->indexCache) return E_OUTOFMEMORY;
7140  This->indexCacheSize = 16;
7141  }
7142  else if (This->indexCacheSize == This->indexCacheLen)
7143  {
7144  struct BlockChainRun *new_cache;
7145  ULONG new_size;
7146 
7147  new_size = This->indexCacheSize * 2;
7148  new_cache = HeapAlloc(GetProcessHeap(), 0, sizeof(struct BlockChainRun)*new_size);
7149  if (!new_cache) return E_OUTOFMEMORY;
7150  memcpy(new_cache, This->indexCache, sizeof(struct BlockChainRun)*This->indexCacheLen);
7151 
7152  HeapFree(GetProcessHeap(), 0, This->indexCache);
7153  This->indexCache = new_cache;
7154  This->indexCacheSize = new_size;
7155  }
7156 
7157  This->indexCacheLen++;
7158  last_run = &This->indexCache[This->indexCacheLen-1];
7159  last_run->firstSector = next_sector;
7160  last_run->firstOffset = next_offset;
7161  }
7162 
7163  last_run->lastOffset = next_offset;
7164 
7165  /* Find the next block. */
7166  next_offset++;
7167  hr = StorageImpl_GetNextBlockInChain(This->parentStorage, next_sector, &next_sector);
7168  if (FAILED(hr)) return hr;
7169  }
7170 
7171  if (This->indexCacheLen)
7172  {
7173  This->tailIndex = last_run->firstSector + last_run->lastOffset - last_run->firstOffset;
7174  This->numBlocks = last_run->lastOffset+1;
7175  }
7176  else
7177  {
7178  This->tailIndex = BLOCK_END_OF_CHAIN;
7179  This->numBlocks = 0;
7180  }
7181 
7182  return S_OK;
7183 }
ULONG firstSector
Definition: storage32.c:188
HRESULT hr
Definition: shlfolder.c:183
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
smooth NULL
Definition: ftsmooth.c:416
ULONG lastOffset
Definition: storage32.c:190
ULONG firstOffset
Definition: storage32.c:189
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG HRESULT
Definition: typedefs.h:77
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define S_OK
Definition: intsafe.h:59
unsigned int ULONG
Definition: retypes.h:1
#define HeapFree(x, y, z)
Definition: compat.h:394
static HRESULT StorageImpl_GetNextBlockInChain(StorageImpl *This, ULONG blockIndex, ULONG *nextBlockIndex)
Definition: storage32.c:4022
static ULONG BlockChainStream_GetHeadOfChain(BlockChainStream *This)
Definition: storage32.c:7086
static const ULONG BLOCK_END_OF_CHAIN
Definition: storage32.h:84

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 7703 of file storage32.c.

7708 {
7709  ULONG blockNoInSequence = offset.QuadPart / This->parentStorage->bigBlockSize;
7710  ULONG offsetInBlock = offset.QuadPart % This->parentStorage->bigBlockSize;
7711  ULONG bytesToWrite;
7712  ULONG blockIndex;
7713  const BYTE* bufferWalker;
7714  HRESULT hr;
7715  BlockChainBlock *cachedBlock;
7716 
7717  *bytesWritten = 0;
7718  bufferWalker = buffer;
7719 
7720  while (size > 0)
7721  {
7722  ULARGE_INTEGER ulOffset;
7723  DWORD bytesWrittenAt;
7724 
7725  /*
7726  * Calculate how many bytes we can copy to this big block.
7727  */
7728  bytesToWrite =
7729  min(This->parentStorage->bigBlockSize - offsetInBlock, size);
7730 
7731  hr = BlockChainStream_GetBlockAtOffset(This, blockNoInSequence, &cachedBlock, &blockIndex, size == bytesToWrite);
7732 
7733  /* BlockChainStream_SetSize should have already been called to ensure we have
7734  * enough blocks in the chain to write into */
7735  if (FAILED(hr))
7736  {
7737  ERR("not enough blocks in chain to write data\n");
7738  return hr;
7739  }
7740 
7741  if (!cachedBlock)
7742  {
7743  /* Not in cache, and we're going to write past the end of the block. */
7744  ulOffset.QuadPart = StorageImpl_GetBigBlockOffset(This->parentStorage, blockIndex) +
7745  offsetInBlock;
7746 
7747  StorageImpl_WriteAt(This->parentStorage,
7748  ulOffset,
7749  bufferWalker,
7750  bytesToWrite,
7751  &bytesWrittenAt);
7752  }
7753  else
7754  {
7755  if (!cachedBlock->read && bytesToWrite != This->parentStorage->bigBlockSize)
7756  {
7757  ULONG read;
7758  if (FAILED(StorageImpl_ReadBigBlock(This->parentStorage, cachedBlock->sector, cachedBlock->data, &read)) && !read)
7759  return STG_E_READFAULT;
7760  }
7761 
7762  memcpy(cachedBlock->data+offsetInBlock, bufferWalker, bytesToWrite);
7763  bytesWrittenAt = bytesToWrite;
7764  cachedBlock->read = TRUE;
7765  cachedBlock->dirty = TRUE;
7766  }
7767 
7768  blockNoInSequence++;
7769  bufferWalker += bytesWrittenAt;
7770  size -= bytesWrittenAt;
7771  *bytesWritten += bytesWrittenAt;
7772  offsetInBlock = 0; /* There is no offset on the next block */
7773 
7774  if (bytesWrittenAt != bytesToWrite)
7775  break;
7776  }
7777 
7778  return (size == 0) ? S_OK : STG_E_WRITEFAULT;
7779 }
#define TRUE
Definition: types.h:120
#define STG_E_WRITEFAULT
Definition: winerror.h:2575
BYTE data[MAX_BIG_BLOCK_SIZE]
Definition: storage32.c:199
HRESULT hr
Definition: shlfolder.c:183
GLintptr offset
Definition: glext.h:5920
static HRESULT StorageImpl_ReadBigBlock(StorageImpl *This, ULONG blockIndex, void *buffer, ULONG *out_read)
Definition: storage32.c:3547
GLuint buffer
Definition: glext.h:5915
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
static ULONGLONG StorageImpl_GetBigBlockOffset(StorageImpl *This, ULONG index)
Definition: storage32.c:3542
GLsizeiptr size
Definition: glext.h:5919
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
static HRESULT StorageImpl_WriteAt(StorageImpl *This, ULARGE_INTEGER offset, const void *buffer, const ULONG size, ULONG *bytesWritten)
Definition: storage32.c:2880
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
unsigned char BYTE
Definition: mem.h:68
GLenum GLsizei GLuint GLint * bytesWritten
Definition: glext.h:11123
#define ERR(fmt,...)
Definition: debug.h:109
#define S_OK
Definition: intsafe.h:59
#define STG_E_READFAULT
Definition: winerror.h:2576
#define min(a, b)
Definition: monoChain.cc:55
unsigned int ULONG
Definition: retypes.h:1
static HRESULT BlockChainStream_GetBlockAtOffset(BlockChainStream *This, ULONG index, BlockChainBlock **block, ULONG *sector, BOOL create)
Definition: storage32.c:7215
_CRTIMP int __cdecl read(_In_ int _FileHandle, _Out_writes_bytes_(_MaxCharCount) void *_DstBuf, _In_ unsigned int _MaxCharCount)

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 8486 of file storage32.c.

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

Referenced by StgCreateDocfile(), and StgCreateStorageEx().

◆ deleteStorageContents()

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

Definition at line 2427 of file storage32.c.

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

Referenced by StorageBaseImpl_DestroyElement().

◆ deleteStreamContents()

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

Definition at line 2514 of file storage32.c.

2518 {
2519  IStream *pis;
2520  HRESULT hr;
2522  StgStreamImpl *strm, *strm2;
2523 
2524  /* Invalidate any open stream objects. */
2525  LIST_FOR_EACH_ENTRY_SAFE(strm, strm2, &parentStorage->strmHead, StgStreamImpl, StrmListEntry)
2526  {
2527  if (strm->dirEntry == indexToDelete)
2528  {
2529  TRACE("Stream deleted %p\n", strm);
2530  strm->parentStorage = NULL;
2531  list_remove(&strm->StrmListEntry);
2532  }
2533  }
2534 
2535  size.u.HighPart = 0;
2536  size.u.LowPart = 0;
2537 
2538  hr = IStorage_OpenStream(&parentStorage->IStorage_iface,
2539  entryDataToDelete.name, NULL, STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, &pis);
2540 
2541  if (hr!=S_OK)
2542  {
2543  TRACE("<-- %08x\n", hr);
2544  return(hr);
2545  }
2546 
2547  /*
2548  * Zap the stream
2549  */
2550  hr = IStream_SetSize(pis, size);
2551 
2552  if(hr != S_OK)
2553  {
2554  TRACE("<-- %08x\n", hr);
2555  return hr;
2556  }
2557 
2558  /*
2559  * Release the stream object.
2560  */
2561  IStream_Release(pis);
2562  TRACE("<-- %08x\n", hr);
2563  return S_OK;
2564 }
struct list strmHead
Definition: storage32.h:196
HRESULT hr
Definition: shlfolder.c:183
#define STGM_SHARE_EXCLUSIVE
Definition: objbase.h:922
struct list StrmListEntry
Definition: storage32.h:435
IStorage IStorage_iface
Definition: storage32.h:187
DirRef dirEntry
Definition: storage32.h:450
smooth NULL
Definition: ftsmooth.c:416
#define STGM_WRITE
Definition: objbase.h:917
__WINE_SERVER_LIST_INLINE void list_remove(struct list *elem)
Definition: list.h:108
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
LONG HRESULT
Definition: typedefs.h:77
StorageBaseImpl * parentStorage
Definition: storage32.h:440
#define S_OK
Definition: intsafe.h:59
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:204
WCHAR name[DIRENTRY_NAME_MAX_LEN]
Definition: storage32.h:147

Referenced by StorageBaseImpl_DestroyElement().

◆ directwriterlock_AddRef()

static ULONG WINAPI directwriterlock_AddRef ( IDirectWriterLock iface)
static

Definition at line 452 of file storage32.c.

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

◆ directwriterlock_HaveWriteAccess()

static HRESULT WINAPI directwriterlock_HaveWriteAccess ( IDirectWriterLock iface)
static

Definition at line 478 of file storage32.c.

479 {
481  FIXME("(%p): stub\n", This);
482  return E_NOTIMPL;
483 }
#define FIXME(fmt,...)
Definition: debug.h:110
#define E_NOTIMPL
Definition: ddrawi.h:99
static StorageBaseImpl * impl_from_IDirectWriterLock(IDirectWriterLock *iface)
Definition: storage32.c:441

◆ directwriterlock_QueryInterface()

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

Definition at line 446 of file storage32.c.

447 {
449  return IStorage_QueryInterface(&This->IStorage_iface, riid, obj);
450 }
REFIID riid
Definition: precomp.h:44
static StorageBaseImpl * impl_from_IDirectWriterLock(IDirectWriterLock *iface)
Definition: storage32.c:441

◆ directwriterlock_Release()

static ULONG WINAPI directwriterlock_Release ( IDirectWriterLock iface)
static

Definition at line 458 of file storage32.c.

459 {
461  return IStorage_Release(&This->IStorage_iface);
462 }
static StorageBaseImpl * impl_from_IDirectWriterLock(IDirectWriterLock *iface)
Definition: storage32.c:441

◆ directwriterlock_ReleaseWriteAccess()

static HRESULT WINAPI directwriterlock_ReleaseWriteAccess ( IDirectWriterLock iface)
static

Definition at line 471 of file storage32.c.

472 {
474  FIXME("(%p): stub\n", This);
475  return E_NOTIMPL;
476 }
#define FIXME(fmt,...)
Definition: debug.h:110
#define E_NOTIMPL
Definition: ddrawi.h:99
static StorageBaseImpl * impl_from_IDirectWriterLock(IDirectWriterLock *iface)
Definition: storage32.c:441

◆ directwriterlock_WaitForWriteAccess()

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

Definition at line 464 of file storage32.c.

465 {
467  FIXME("(%p)->(%d): stub\n", This, timeout);
468  return E_NOTIMPL;
469 }
Definition: dhcpd.h:245
#define FIXME(fmt,...)
Definition: debug.h:110
#define E_NOTIMPL
Definition: ddrawi.h:99
static StorageBaseImpl * impl_from_IDirectWriterLock(IDirectWriterLock *iface)
Definition: storage32.c:441

◆ entryNameCmp()

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

Definition at line 511 of file storage32.c.

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

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 534 of file storage32.c.

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

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 575 of file storage32.c.

578 {
579  DirRef childEntry;
580  DirEntry childData;
581 
582  /* Read the storage entry to find the root of the tree. */
583  StorageBaseImpl_ReadDirEntry(storage, storageEntry, parentData);
584 
585  *parentEntry = storageEntry;
586  *relation = DIRENTRY_RELATION_DIR;
587 
588  childEntry = parentData->dirRootEntry;
589 
590  while (childEntry != DIRENTRY_NULL)
591  {
592  LONG cmp;
593 
594  StorageBaseImpl_ReadDirEntry(storage, childEntry, &childData);
595 
596  cmp = entryNameCmp(childName, childData.name);
597 
598  if (cmp == 0)
599  /* found it */
600  break;
601 
602  else if (cmp < 0)
603  {
604  *parentData = childData;
605  *parentEntry = childEntry;
606  *relation = DIRENTRY_RELATION_PREVIOUS;
607 
608  childEntry = parentData->leftChild;
609  }
610 
611  else if (cmp > 0)
612  {
613  *parentData = childData;
614  *parentEntry = childEntry;
615  *relation = DIRENTRY_RELATION_NEXT;
616 
617  childEntry = parentData->rightChild;
618  }
619  }
620 
621  if (childEntry == DIRENTRY_NULL)
622  return STG_E_FILENOTFOUND;
623  else
624  return S_OK;
625 }
#define cmp(status, error)
Definition: error.c:114
static LONG entryNameCmp(const OLECHAR *name1, const OLECHAR *name2)
Definition: storage32.c:511
long LONG
Definition: pedump.c:60
#define DIRENTRY_RELATION_NEXT
Definition: storage32.h:102
DirRef dirRootEntry
Definition: storage32.h:152
static const ULONG DIRENTRY_NULL
Definition: storage32.h:86
#define STG_E_FILENOTFOUND
Definition: winerror.h:2565
#define DIRENTRY_RELATION_PREVIOUS
Definition: storage32.h:101
ULONG DirRef
Definition: storage32.h:139
DirRef leftChild
Definition: storage32.h:150
#define S_OK
Definition: intsafe.h:59
#define DIRENTRY_RELATION_DIR
Definition: storage32.h:103
DirRef rightChild
Definition: storage32.h:151
static HRESULT StorageBaseImpl_ReadDirEntry(StorageBaseImpl *This, DirRef index, DirEntry *data)
Definition: storage32.h:290
WCHAR name[DIRENTRY_NAME_MAX_LEN]
Definition: storage32.h:147

Referenced by removeFromTree().

◆ GetAccessModeFromSTGM()

static DWORD GetAccessModeFromSTGM ( DWORD  stgm)
static

Definition at line 398 of file storage32.c.

399 {
400  switch (STGM_ACCESS_MODE(stgm))
401  {
402  case STGM_READ:
403  return GENERIC_READ;
404  case STGM_WRITE:
405  case STGM_READWRITE:
406  return GENERIC_READ | GENERIC_WRITE;
407  }
408  ERR("Invalid access mode!\n");
409  assert(0);
410  return 0;
411 }
#define assert(x)
Definition: debug.h:53
#define GENERIC_WRITE
Definition: nt_native.h:90
#define STGM_WRITE
Definition: objbase.h:917
#define STGM_READ
Definition: objbase.h:916
#define GENERIC_READ
Definition: compat.h:124
#define STGM_READWRITE
Definition: objbase.h:918
#define STGM_ACCESS_MODE(stgm)
Definition: storage32.h:115
#define ERR(fmt,...)
Definition: debug.h:109

Referenced by create_storagefile(), and StgOpenStorage().

◆ GetConvertStg()

HRESULT WINAPI GetConvertStg ( IStorage stg)

Definition at line 10618 of file storage32.c.

10619 {
10620  static const WCHAR stream_1oleW[] = {1,'O','l','e',0};
10621  static const DWORD version_magic = 0x02000001;
10622  DWORD header[2];
10623  IStream *stream;
10624  HRESULT hr;
10625 
10626  TRACE("%p\n", stg);
10627 
10628  if (!stg) return E_INVALIDARG;
10629 
10630  hr = IStorage_OpenStream(stg, stream_1oleW, NULL, STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &stream);
10631  if (FAILED(hr)) return hr;
10632 
10633  hr = IStream_Read(stream, header, sizeof(header), NULL);
10634  IStream_Release(stream);
10635  if (FAILED(hr)) return hr;
10636 
10637  if (header[0] != version_magic)
10638  {
10639  ERR("got wrong version magic for 1Ole stream, 0x%08x\n", header[0]);
10640  return E_FAIL;
10641  }
10642 
10643  return header[1] & OleStream_Convert ? S_OK : S_FALSE;
10644 }
HRESULT hr
Definition: shlfolder.c:183
#define STGM_SHARE_EXCLUSIVE
Definition: objbase.h:922
#define E_FAIL
Definition: ddrawi.h:102
#define S_FALSE
Definition: winerror.h:2357
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
#define STGM_READ
Definition: objbase.h:916
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
Definition: parse.h:22
GLuint GLuint stream
Definition: glext.h:7522
#define ERR(fmt,...)
Definition: debug.h:109
#define S_OK
Definition: intsafe.h:59
struct CFHEADER header
Definition: fdi.c:109

Referenced by test_convert().

◆ GetCreationModeFromSTGM()

static DWORD GetCreationModeFromSTGM ( DWORD  stgm)
static

Definition at line 419 of file storage32.c.

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

Referenced by create_storagefile().

◆ GetShareModeFromSTGM()

static DWORD GetShareModeFromSTGM ( DWORD  stgm)
static

Definition at line 372 of file storage32.c.

373 {
374  switch (STGM_SHARE_MODE(stgm))
375  {
376  case 0:
377  assert(stgm & STGM_TRANSACTED);
378  /* fall-through */
382  return FILE_SHARE_WRITE;
385  return FILE_SHARE_READ;
386  }
387  ERR("Invalid share mode!\n");
388  assert(0);
389  return 0;
390 }
#define STGM_SHARE_DENY_NONE
Definition: objbase.h:919
#define STGM_SHARE_EXCLUSIVE
Definition: objbase.h:922
#define assert(x)
Definition: debug.h:53
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define FILE_SHARE_READ
Definition: compat.h:125
#define STGM_SHARE_MODE(stgm)
Definition: storage32.h:116
#define ERR(fmt,...)
Definition: debug.h:109
#define STGM_TRANSACTED
Definition: objbase.h:914
#define STGM_SHARE_DENY_WRITE
Definition: objbase.h:921
#define STGM_SHARE_DENY_READ
Definition: objbase.h:920

Referenced by create_storagefile(), and StgOpenStorage().

◆ IEnumSTATSTGImpl_AddRef()

static ULONG WINAPI IEnumSTATSTGImpl_AddRef ( IEnumSTATSTG iface)
static

Definition at line 931 of file storage32.c.

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

◆ IEnumSTATSTGImpl_Clone()

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

Definition at line 1137 of file storage32.c.

1140 {
1142  IEnumSTATSTGImpl* newClone;
1143 
1144  TRACE("%p,%p\n", iface, ppenum);
1145 
1146  if (This->parentStorage->reverted)
1147  {
1148  TRACE("<-- STG_E_REVERTED\n");
1149  return STG_E_REVERTED;
1150  }
1151 
1152  if (ppenum==0)
1153  return E_INVALIDARG;
1154 
1155  newClone = IEnumSTATSTGImpl_Construct(This->parentStorage,
1156  This->storageDirEntry);
1157  if (!newClone)
1158  {
1159  *ppenum = NULL;
1160  return E_OUTOFMEMORY;
1161  }
1162 
1163  /*
1164  * The new clone enumeration must point to the same current node as
1165  * the old one.
1166  */
1167  memcpy(newClone->name, This->name, sizeof(newClone->name));
1168 
1169  *ppenum = &newClone->IEnumSTATSTG_iface;
1170 
1171  return S_OK;
1172 }
IEnumSTATSTG IEnumSTATSTG_iface
Definition: storage32.c:884
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
static IEnumSTATSTGImpl * IEnumSTATSTGImpl_Construct(StorageBaseImpl *, DirRef)
Definition: storage32.c:1188
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static IEnumSTATSTGImpl * impl_from_IEnumSTATSTG(IEnumSTATSTG *iface)
Definition: storage32.c:893
WCHAR name[DIRENTRY_NAME_MAX_LEN]
Definition: storage32.c:890
#define S_OK
Definition: intsafe.h:59
#define STG_E_REVERTED
Definition: winerror.h:2590

◆ IEnumSTATSTGImpl_Construct()

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

Definition at line 1188 of file storage32.c.

1191 {
1192  IEnumSTATSTGImpl* newEnumeration;
1193 
1194  newEnumeration = HeapAlloc(GetProcessHeap(), 0, sizeof(IEnumSTATSTGImpl));
1195 
1196  if (newEnumeration)
1197  {
1198  newEnumeration->IEnumSTATSTG_iface.lpVtbl = &IEnumSTATSTGImpl_Vtbl;
1199  newEnumeration->ref = 1;
1200  newEnumeration->name[0] = 0;
1201 
1202  /*
1203  * We want to nail-down the reference to the storage in case the
1204  * enumeration out-lives the storage in the client application.
1205  */
1206  newEnumeration->parentStorage = parentStorage;
1207  IStorage_AddRef(&newEnumeration->parentStorage->IStorage_iface);
1208 
1209  newEnumeration->storageDirEntry = storageDirEntry;
1210  }
1211 
1212  return newEnumeration;
1213 }
IEnumSTATSTG IEnumSTATSTG_iface
Definition: storage32.c:884
DirRef storageDirEntry
Definition: storage32.c:888
IStorage IStorage_iface
Definition: storage32.h:187
StorageBaseImpl * parentStorage
Definition: storage32.c:887
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
WCHAR name[DIRENTRY_NAME_MAX_LEN]
Definition: storage32.c:890
static const IEnumSTATSTGVtbl IEnumSTATSTGImpl_Vtbl
Definition: storage32.c:1177

Referenced by IEnumSTATSTGImpl_Clone(), and StorageBaseImpl_EnumElements().

◆ IEnumSTATSTGImpl_Destroy()

static void IEnumSTATSTGImpl_Destroy ( IEnumSTATSTGImpl This)
static

Definition at line 898 of file storage32.c.

899 {
900  IStorage_Release(&This->parentStorage->IStorage_iface);
902 }
#define GetProcessHeap()
Definition: compat.h:395
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by IEnumSTATSTGImpl_Release().

◆ IEnumSTATSTGImpl_GetNextRef()

static HRESULT IEnumSTATSTGImpl_GetNextRef ( IEnumSTATSTGImpl This,
DirRef ref 
)
static

Definition at line 955 of file storage32.c.

958 {
960  DirRef searchNode;
961  DirEntry entry;
962  HRESULT hr;
963  WCHAR result_name[DIRENTRY_NAME_MAX_LEN];
964 
965  TRACE("%p,%p\n", This, ref);
966 
967  hr = StorageBaseImpl_ReadDirEntry(This->parentStorage,
968  This->parentStorage->storageDirEntry, &entry);
969  searchNode = entry.dirRootEntry;
970 
971  while (SUCCEEDED(hr) && searchNode != DIRENTRY_NULL)
972  {
973  hr = StorageBaseImpl_ReadDirEntry(This->parentStorage, searchNode, &entry);
974 
975  if (SUCCEEDED(hr))
976  {
977  LONG diff = entryNameCmp( entry.name, This->name);
978 
979  if (diff <= 0)
980  {
981  searchNode = entry.rightChild;
982  }
983  else
984  {
985  result = searchNode;
986  memcpy(result_name, entry.name, sizeof(result_name));
987  searchNode = entry.leftChild;
988  }
989  }
990  }
991 
992  if (SUCCEEDED(hr))
993  {
994  *ref = result;
995  if (result != DIRENTRY_NULL)
996  memcpy(This->name, result_name, sizeof(result_name));
997  }
998 
999  TRACE("<-- %08x\n", hr);
1000  return hr;
1001 }
HRESULT hr
Definition: shlfolder.c:183
Definition: send.c:47
static LONG entryNameCmp(const OLECHAR *name1, const OLECHAR *name2)
Definition: storage32.c:511
long LONG
Definition: pedump.c:60
#define DIRENTRY_NAME_MAX_LEN
Definition: storage32.h:88
static const ULONG DIRENTRY_NULL
Definition: storage32.h:86
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
uint32_t entry
Definition: isohybrid.c:63
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
ULONG DirRef
Definition: storage32.h:139
static HRESULT StorageBaseImpl_ReadDirEntry(StorageBaseImpl *This, DirRef index, DirEntry *data)
Definition: storage32.h:290
GLuint64EXT * result
Definition: glext.h:11304
#define SUCCEEDED(hr)
Definition: intsafe.h:57

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 1003 of file storage32.c.

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

◆ IEnumSTATSTGImpl_QueryInterface()

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

Definition at line 904 of file storage32.c.

908 {
910 
911  TRACE("%p,%s,%p\n", iface, debugstr_guid(riid), ppvObject);
912 
913  if (ppvObject==0)
914  return E_INVALIDARG;
915 
916  *ppvObject = 0;
917 
918  if (IsEqualGUID(&IID_IUnknown, riid) ||
920  {
921  *ppvObject = &This->IEnumSTATSTG_iface;
922  IEnumSTATSTG_AddRef(&This->IEnumSTATSTG_iface);
923  TRACE("<-- %p\n", *ppvObject);
924  return S_OK;
925  }
926 
927  TRACE("<-- E_NOINTERFACE\n");
928  return E_NOINTERFACE;
929 }
#define E_NOINTERFACE
Definition: winerror.h:2364
const GUID IID_IEnumSTATSTG
REFIID riid
Definition: precomp.h:44
#define E_INVALIDARG
Definition: ddrawi.h:101
#define debugstr_guid
Definition: kernel32.h:35
#define TRACE(s)
Definition: solgame.cpp:4
const GUID IID_IUnknown
REFIID LPVOID * ppvObject
Definition: precomp.h:44
static IEnumSTATSTGImpl * impl_from_IEnumSTATSTG(IEnumSTATSTG *iface)
Definition: storage32.c:893
#define S_OK
Definition: intsafe.h:59
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4021

◆ IEnumSTATSTGImpl_Release()

static ULONG WINAPI IEnumSTATSTGImpl_Release ( IEnumSTATSTG iface)
static

Definition at line 938 of file storage32.c.

940 {
942 
943  ULONG newRef;
944 
945  newRef = InterlockedDecrement(&This->ref);
946 
947  if (newRef==0)
948  {
950  }
951 
952  return newRef;
953 }
static void IEnumSTATSTGImpl_Destroy(IEnumSTATSTGImpl *This)
Definition: storage32.c:898
#define InterlockedDecrement
Definition: armddk.h:52
static IEnumSTATSTGImpl * impl_from_IEnumSTATSTG(IEnumSTATSTG *iface)
Definition: storage32.c:893
unsigned int ULONG
Definition: retypes.h:1

◆ IEnumSTATSTGImpl_Reset()

static HRESULT WINAPI IEnumSTATSTGImpl_Reset ( IEnumSTATSTG iface)
static

Definition at line 1117 of file storage32.c.

1119 {
1121 
1122  TRACE("%p\n", iface);
1123 
1124  if (This->parentStorage->reverted)
1125  {
1126  TRACE("<-- STG_E_REVERTED\n");
1127  return STG_E_REVERTED;
1128  }
1129 
1130  This->name[0] = 0;
1131 
1132  return S_OK;
1133 }
#define TRACE(s)
Definition: solgame.cpp:4
static IEnumSTATSTGImpl * impl_from_IEnumSTATSTG(IEnumSTATSTG *iface)
Definition: storage32.c:893
#define S_OK
Definition: intsafe.h:59
#define STG_E_REVERTED
Definition: winerror.h:2590

◆ IEnumSTATSTGImpl_Skip()

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

Definition at line 1082 of file storage32.c.

1085 {
1087 
1088  ULONG objectFetched = 0;
1089  DirRef currentSearchNode;
1090  HRESULT hr=S_OK;
1091 
1092  TRACE("%p,%u\n", iface, celt);
1093 
1094  if (This->parentStorage->reverted)
1095  {
1096  TRACE("<-- STG_E_REVERTED\n");
1097  return STG_E_REVERTED;
1098  }
1099 
1100  while ( (objectFetched < celt) )
1101  {
1102  hr = IEnumSTATSTGImpl_GetNextRef(This, &currentSearchNode);
1103 
1104  if (FAILED(hr) || currentSearchNode == DIRENTRY_NULL)
1105  break;
1106 
1107  objectFetched++;
1108  }
1109 
1110  if (SUCCEEDED(hr) && objectFetched != celt)
1111  return S_FALSE;
1112 
1113  TRACE("<-- %08x\n", hr);
1114  return hr;
1115 }
HRESULT hr
Definition: shlfolder.c:183
static HRESULT IEnumSTATSTGImpl_GetNextRef(IEnumSTATSTGImpl *This, DirRef *ref)
Definition: storage32.c:955
#define S_FALSE
Definition: winerror.h:2357
static const ULONG DIRENTRY_NULL
Definition: storage32.h:86
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
ULONG DirRef
Definition: storage32.h:139
static IEnumSTATSTGImpl * impl_from_IEnumSTATSTG(IEnumSTATSTG *iface)
Definition: storage32.c:893
#define S_OK
Definition: intsafe.h:59
#define STG_E_REVERTED
Definition: winerror.h:2590
unsigned int ULONG
Definition: retypes.h:1
#define SUCCEEDED(hr)
Definition: intsafe.h:57

◆ impl_from_IDirectWriterLock()

static StorageBaseImpl* impl_from_IDirectWriterLock ( IDirectWriterLock iface)
inlinestatic

Definition at line 441 of file storage32.c.

442 {
443  return CONTAINING_RECORD(iface, StorageBaseImpl, IDirectWriterLock_iface);
444 }
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560

Referenced by directwriterlock_AddRef(), directwriterlock_HaveWriteAccess(), directwriterlock_QueryInterface(), directwriterlock_Release(), directwriterlock_ReleaseWriteAccess(), and directwriterlock_WaitForWriteAccess().

◆ impl_from_IEnumSTATSTG()

static IEnumSTATSTGImpl* impl_from_IEnumSTATSTG ( IEnumSTATSTG iface)
inlinestatic

Definition at line 893 of file storage32.c.

894 {
895  return CONTAINING_RECORD(iface, IEnumSTATSTGImpl, IEnumSTATSTG_iface);
896 }
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560

Referenced by IEnumSTATSTGImpl_AddRef(), IEnumSTATSTGImpl_Clone(), IEnumSTATSTGImpl_Next(), IEnumSTATSTGImpl_QueryInterface(), IEnumSTATSTGImpl_Release(), IEnumSTATSTGImpl_Reset(), and IEnumSTATSTGImpl_Skip().

◆ impl_from_IStorage()

◆ insertIntoTree()

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

Definition at line 651 of file storage32.c.

655 {
656  DirEntry currentEntry;
657  DirEntry newEntry;
658 
659  /*
660  * Read the inserted entry
661  */
663  newEntryIndex,
664  &newEntry);
665 
666  /*
667  * Read the storage entry
668  */
670  parentStorageIndex,
671  &currentEntry);
672 
673  if (currentEntry.dirRootEntry != DIRENTRY_NULL)
674  {
675  /*
676  * The root storage contains some element, therefore, start the research
677  * for the appropriate location.
678  */
679  BOOL found = FALSE;
680  DirRef current, next, previous, currentEntryId;
681 
682  /*
683  * Keep a reference to the root of the storage's element tree
684  */
685  currentEntryId = currentEntry.dirRootEntry;
686 
687  /*
688  * Read
689  */
691  currentEntry.dirRootEntry,
692  &currentEntry);
693 
694  previous = currentEntry.leftChild;
695  next = currentEntry.rightChild;
696  current = currentEntryId;
697 
698  while (!found)
699  {
700  LONG diff = entryNameCmp( newEntry.name, currentEntry.name);
701 
702  if (diff < 0)
703  {
704  if (previous != DIRENTRY_NULL)
705  {
707  previous,
708  &currentEntry);
709  current = previous;
710  }
711  else
712  {
713  currentEntry.leftChild = newEntryIndex;
715  current,
716  &currentEntry);
717  found = TRUE;
718  }
719  }
720  else if (diff > 0)
721  {
722  if (next != DIRENTRY_NULL)
723  {
725  next,
726  &currentEntry);
727  current = next;
728  }
729  else
730  {
731  currentEntry.rightChild = newEntryIndex;
733  current,
734  &currentEntry);
735  found = TRUE;
736  }
737  }
738  else
739  {
740  /*
741  * Trying to insert an item with the same name in the
742  * subtree structure.
743  */
745  }
746 
747  previous = currentEntry.leftChild;
748  next = currentEntry.rightChild;
749  }
750  }
751  else
752  {
753  /*
754  * The storage is empty, make the new entry the root of its element tree
755  */
756  currentEntry.dirRootEntry = newEntryIndex;
758  parentStorageIndex,
759  &currentEntry);
760  }
761 
762  return S_OK;
763 }
#define TRUE
Definition: types.h:120
static LONG entryNameCmp(const OLECHAR *name1, const OLECHAR *name2)
Definition: storage32.c:511
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
DirRef dirRootEntry
Definition: storage32.h:152
static const ULONG DIRENTRY_NULL
Definition: storage32.h:86
#define STG_E_FILEALREADYEXISTS
Definition: winerror.h:2579
ULONG DirRef
Definition: storage32.h:139
static HRESULT StorageBaseImpl_WriteDirEntry(StorageBaseImpl *This, DirRef index, const DirEntry *data)
Definition: storage32.h:284
DirRef leftChild
Definition: storage32.h:150
#define S_OK
Definition: intsafe.h:59
static unsigned __int64 next
Definition: rand_nt.c:6
DirRef rightChild
Definition: storage32.h:151
static HRESULT StorageBaseImpl_ReadDirEntry(StorageBaseImpl *This, DirRef index, DirEntry *data)
Definition: storage32.h:290
WCHAR name[DIRENTRY_NAME_MAX_LEN]
Definition: storage32.h:147
struct task_struct * current
Definition: linux.c:32

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

◆ OLECONVERT_CreateCompObjStream()

HRESULT OLECONVERT_CreateCompObjStream ( LPSTORAGE  pStorage,
LPCSTR  strOleTypeName 
)

Definition at line 10029 of file storage32.c.

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

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 10215 of file storage32.c.

10216 {
10217  HRESULT hRes;
10218  IStream *pStream;
10219  static const WCHAR wstrStreamName[] = {1, 'O', 'l', 'e', '1', '0', 'N', 'a', 't', 'i', 'v', 'e', 0};
10220 
10221  /* Create the Ole10Native Stream */
10222  hRes = IStorage_CreateStream(pStorage, wstrStreamName,
10223  STGM_CREATE | STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &pStream );
10224 
10225  if(hRes == S_OK)
10226  {
10227  /* Write info to stream */
10228  hRes = IStream_Write(pStream, &dwDataLength, sizeof(dwDataLength), NULL);
10229  hRes = IStream_Write(pStream, pData, dwDataLength, NULL);
10230  IStream_Release(pStream);
10231  }
10232 
10233 }
#define STGM_SHARE_EXCLUSIVE
Definition: objbase.h:922
#define STGM_CREATE
Definition: objbase.h:925
smooth NULL
Definition: ftsmooth.c:416
#define STGM_WRITE
Definition: objbase.h:917
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
#define S_OK
Definition: intsafe.h:59
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827

Referenced by OleConvertOLESTREAMToIStorage().

◆ OLECONVERT_CreateOlePresStream()

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

Definition at line 10131 of file storage32.c.

10132 {
10133  HRESULT hRes;
10134  IStream *pStream;
10135  static const WCHAR wstrStreamName[] = {2, 'O', 'l', 'e', 'P', 'r', 'e', 's', '0', '0', '0', 0};
10136  static const BYTE pOlePresStreamHeader[] =
10137  {
10138  0xFF, 0xFF, 0xFF, 0xFF, 0x03, 0x00, 0x00, 0x00,
10139  0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
10140  0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
10141  0x00, 0x00, 0x00, 0x00
10142  };
10143 
10144  static const BYTE pOlePresStreamHeaderEmpty[] =
10145  {
10146  0x00, 0x00, 0x00, 0x00,
10147  0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
10148  0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
10149  0x00, 0x00, 0x00, 0x00
10150  };
10151 
10152  /* Create the OlePres000 Stream */
10153  hRes = IStorage_CreateStream(pStorage, wstrStreamName,
10154  STGM_CREATE | STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &pStream );
10155 
10156  if(hRes == S_OK)
10157  {
10158  DWORD nHeaderSize;
10160 
10161  memset(&OlePres, 0, sizeof(OlePres));
10162  /* Do we have any metafile data to save */
10163  if(dwDataLength > 0)
10164  {
10165  memcpy(OlePres.byUnknown1, pOlePresStreamHeader, sizeof(pOlePresStreamHeader));
10166  nHeaderSize = sizeof(pOlePresStreamHeader);
10167  }
10168  else
10169  {
10170  memcpy(OlePres.byUnknown1, pOlePresStreamHeaderEmpty, sizeof(pOlePresStreamHeaderEmpty));
10171  nHeaderSize = sizeof(pOlePresStreamHeaderEmpty);
10172  }
10173  /* Set width and height of the metafile */
10174  OlePres.dwExtentX = dwExtentX;
10175  OlePres.dwExtentY = -dwExtentY;
10176 
10177  /* Set Data and Length */
10178  if(dwDataLength > sizeof(METAFILEPICT16))
10179  {
10180  OlePres.dwSize = dwDataLength - sizeof(METAFILEPICT16);
10181  OlePres.pData = &(pData[8]);
10182  }
10183  /* Save OlePres000 Data to Stream */
10184  hRes = IStream_Write(pStream, OlePres.byUnknown1, nHeaderSize, NULL);
10185  hRes = IStream_Write(pStream, &(OlePres.dwExtentX), sizeof(OlePres.dwExtentX), NULL);
10186  hRes = IStream_Write(pStream, &(OlePres.dwExtentY), sizeof(OlePres.dwExtentY), NULL);
10187  hRes = IStream_Write(pStream, &(OlePres.dwSize), sizeof(OlePres.dwSize), NULL);
10188  if(OlePres.dwSize > 0)
10189  {
10190  hRes = IStream_Write(pStream, OlePres.pData, OlePres.dwSize, NULL);
10191  }
10192  IStream_Release(pStream);
10193  }
10194 }
#define STGM_SHARE_EXCLUSIVE
Definition: objbase.h:922
#define STGM_CREATE
Definition: objbase.h:925
smooth NULL
Definition: ftsmooth.c:416
#define STGM_WRITE
Definition: objbase.h:917
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
unsigned char BYTE
Definition: mem.h:68
#define S_OK
Definition: intsafe.h:59
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
#define memset(x, y, z)
Definition: compat.h:39

Referenced by OleConvertOLESTREAMToIStorage().

◆ OLECONVERT_GetOle10PresData()

static void OLECONVERT_GetOle10PresData ( LPSTORAGE  pStorage,
OLECONVERT_OLESTREAM_DATA pOleStreamData 
)
static

Definition at line 10325 of file storage32.c.

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

Referenced by OleConvertIStorageToOLESTREAM().

◆ OLECONVERT_GetOLE10ProgID()

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

Definition at line 10254 of file storage32.c.

10255 {
10256  HRESULT hRes;
10257  IStream *pStream;
10258  LARGE_INTEGER iSeekPos;
10260  static const WCHAR wstrStreamName[] = {1,'C', 'o', 'm', 'p', 'O', 'b', 'j', 0};
10261 
10262  /* Open the CompObj Stream */
10263  hRes = IStorage_OpenStream(pStorage, wstrStreamName, NULL,
10264  STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &pStream );
10265  if(hRes == S_OK)
10266  {
10267 
10268  /*Get the OleType from the CompObj Stream */
10269  iSeekPos.u.LowPart = sizeof(CompObj.byUnknown1) + sizeof(CompObj.clsid);
10270  iSeekPos.u.HighPart = 0;
10271 
10272  IStream_Seek(pStream, iSeekPos, STREAM_SEEK_SET, NULL);
10273  IStream_Read(pStream, &CompObj.dwCLSIDNameLength, sizeof(CompObj.dwCLSIDNameLength), NULL);
10274  iSeekPos.u.LowPart = CompObj.dwCLSIDNameLength;
10275  IStream_Seek(pStream, iSeekPos, STREAM_SEEK_CUR , NULL);
10276  IStream_Read(pStream, &CompObj.dwOleTypeNameLength, sizeof(CompObj.dwOleTypeNameLength), NULL);
10277  iSeekPos.u.LowPart = CompObj.dwOleTypeNameLength;
10278  IStream_Seek(pStream, iSeekPos, STREAM_SEEK_CUR , NULL);
10279 
10280  IStream_Read(pStream, dwSize, sizeof(*dwSize), NULL);
10281  if(*dwSize > 0)
10282  {
10283  IStream_Read(pStream, strProgID, *dwSize, NULL);
10284  }
10285  IStream_Release(pStream);
10286  }
10287  else
10288  {
10289  STATSTG stat;
10290  LPOLESTR wstrProgID;
10291 
10292  /* Get the OleType from the registry */
10293  REFCLSID clsid = &(stat.clsid);
10294  IStorage_Stat(pStorage, &stat, STATFLAG_NONAME);
10295  hRes = ProgIDFromCLSID(clsid, &wstrProgID);
10296  if(hRes == S_OK)
10297  {
10298  *dwSize = WideCharToMultiByte(CP_ACP, 0, wstrProgID, -1, strProgID, *dwSize, NULL, FALSE);
10299  CoTaskMemFree(wstrProgID);
10300  }
10301 
10302  }
10303  return hRes;
10304 }
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:422
#define WideCharToMultiByte
Definition: compat.h:101
#define STGM_SHARE_EXCLUSIVE
Definition: objbase.h:922
#define REFCLSID
Definition: guiddef.h:117
#define CP_ACP
Definition: compat.h:99
static LPOLESTR
Definition: stg_prop.c:27
HRESULT WINAPI DECLSPEC_HOTPATCH ProgIDFromCLSID(REFCLSID clsid, LPOLESTR *ppszProgID)
Definition: compobj.c:2439
struct _LARGE_INTEGER::@2201 u
smooth NULL
Definition: ftsmooth.c:416
#define STGM_READ
Definition: objbase.h:916
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
REFCLSID clsid
Definition: msctf.c:84
Definition: stat.h:55
_CRTIMP int __cdecl stat(const char *_Filename, struct stat *_Stat)
Definition: stat.h:345
#define S_OK
Definition: intsafe.h:59
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54

Referenced by OleConvertIStorageToOLESTREAM().

◆ OLECONVERT_GetOLE20FromOLE10()

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

Definition at line 9920 of file storage32.c.

9921 {
9922  HRESULT hRes;
9923  HANDLE hFile;
9924  IStorage *pTempStorage;
9925  DWORD dwNumOfBytesWritten;
9926  WCHAR wstrTempDir[MAX_PATH], wstrTempFile[MAX_PATH];
9927  static const WCHAR wstrPrefix[] = {'s', 'i', 's', 0};
9928 
9929  /* Create a temp File */
9930  GetTempPathW(MAX_PATH, wstrTempDir);
9931  GetTempFileNameW(wstrTempDir, wstrPrefix, 0, wstrTempFile);
9933 
9935  {
9936  /* Write IStorage Data to File */
9937  WriteFile(hFile, pBuffer, nBufferLength, &dwNumOfBytesWritten, NULL);
9938  CloseHandle(hFile);
9939 
9940  /* Open and copy temp storage to the Dest Storage */
9941  hRes = StgOpenStorage(wstrTempFile, NULL, STGM_READ, NULL, 0, &pTempStorage);
9942  if(hRes == S_OK)
9943  {
9944  hRes = IStorage_CopyTo(pTempStorage, 0, NULL, NULL, pDestStorage);
9945  IStorage_Release(pTempStorage);
9946  }
9947  DeleteFileW(wstrTempFile);
9948  }
9949 }
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
#define CloseHandle
Definition: compat.h:398
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetTempPathW(IN DWORD count, OUT LPWSTR path)
Definition: path.c:2079
#define GENERIC_WRITE
Definition: nt_native.h:90
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
smooth NULL
Definition: ftsmooth.c:416
PVOID pBuffer
_In_ LPCSTR _In_opt_ LPCSTR _In_ DWORD nBufferLength
Definition: winbase.h:3011
#define STGM_READ
Definition: objbase.h:916
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
HRESULT WINAPI StgOpenStorage(const OLECHAR *pwcsName, IStorage *pstgPriority, DWORD grfMode, SNB snbExclude, DWORD reserved, IStorage **ppstgOpen)
Definition: storage32.c:8756
#define MAX_PATH
Definition: compat.h:26
UINT WINAPI GetTempFileNameW(IN LPCWSTR lpPathName, IN LPCWSTR lpPrefixString, IN UINT uUnique, OUT LPWSTR lpTempFileName)
Definition: filename.c:84
unsigned long DWORD
Definition: ntddk_ex.h:95
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
_In_ HANDLE hFile
Definition: mswsock.h:90
#define S_OK
Definition: intsafe.h:59
#define CREATE_ALWAYS
Definition: disk.h:72
#define CreateFileW
Definition: compat.h:400

Referenced by OleConvertOLESTREAMToIStorage().

◆ OLECONVERT_GetOle20PresData()

static void OLECONVERT_GetOle20PresData ( LPSTORAGE  pStorage,
OLECONVERT_OLESTREAM_DATA pOleStreamData 
)
static

Definition at line 10378 of file storage32.c.

10379 {
10380  HRESULT hRes;
10381  IStream *pStream;
10382  OLECONVERT_ISTORAGE_OLEPRES olePress;
10383  static const WCHAR wstrStreamName[] = {2, 'O', 'l', 'e', 'P', 'r', 'e', 's', '0', '0', '0', 0};
10384 
10385  /* Initialize Default data for OLESTREAM */
10386  pOleStreamData[0].dwOleID = OLESTREAM_ID;
10387  pOleStreamData[0].dwTypeID = 2;
10388  pOleStreamData[0].dwMetaFileWidth = 0;
10389  pOleStreamData[0].dwMetaFileHeight = 0;
10390  pOleStreamData[0].dwDataLength = OLECONVERT_WriteOLE20ToBuffer(pStorage, &(pOleStreamData[0].pData));
10391  pOleStreamData[1].dwOleID = OLESTREAM_ID;
10392  pOleStreamData[1].dwTypeID = 0;
10393  pOleStreamData[1].dwOleTypeNameLength = 0;
10394  pOleStreamData[1].strOleTypeName[0] = 0;
10395  pOleStreamData[1].dwMetaFileWidth = 0;
10396  pOleStreamData[1].dwMetaFileHeight = 0;
10397  pOleStreamData[1].pData = NULL;
10398  pOleStreamData[1].dwDataLength = 0;
10399 
10400 
10401  /* Open OlePress000 stream */
10402  hRes = IStorage_OpenStream(pStorage, wstrStreamName, NULL,
10403  STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &pStream );
10404  if(hRes == S_OK)
10405  {
10406  LARGE_INTEGER iSeekPos;
10407  METAFILEPICT16 MetaFilePict;
10408  static const char strMetafilePictName[] = "METAFILEPICT";
10409 
10410  /* Set the TypeID for a Metafile */
10411  pOleStreamData[1].dwTypeID = 5;
10412 
10413  /* Set the OleTypeName to Metafile */
10414  pOleStreamData[1].dwOleTypeNameLength = strlen(strMetafilePictName) +1;
10415  strcpy(pOleStreamData[1].strOleTypeName, strMetafilePictName);
10416 
10417  iSeekPos.u.HighPart = 0;
10418  iSeekPos.u.LowPart = sizeof(olePress.byUnknown1);
10419 
10420  /* Get Presentation Data */
10421  IStream_Seek(pStream, iSeekPos, STREAM_SEEK_SET, NULL);
10422  IStream_Read(pStream, &(olePress.dwExtentX), sizeof(olePress.dwExtentX), NULL);
10423  IStream_Read(pStream, &(olePress.dwExtentY), sizeof(olePress.dwExtentY), NULL);
10424  IStream_Read(pStream, &(olePress.dwSize), sizeof(olePress.dwSize), NULL);
10425 
10426  /*Set width and Height */
10427  pOleStreamData[1].dwMetaFileWidth = olePress.dwExtentX;
10428  pOleStreamData[1].dwMetaFileHeight = -olePress.dwExtentY;
10429  if(olePress.dwSize > 0)
10430  {
10431  /* Set Length */
10432  pOleStreamData[1].dwDataLength = olePress.dwSize + sizeof(METAFILEPICT16);
10433 
10434  /* Set MetaFilePict struct */
10435  MetaFilePict.mm = 8;
10436  MetaFilePict.xExt = olePress.dwExtentX;
10437  MetaFilePict.yExt = olePress.dwExtentY;
10438  MetaFilePict.hMF = 0;
10439 
10440  /* Get Metafile Data */
10441  pOleStreamData[1].pData = HeapAlloc(GetProcessHeap(),0,pOleStreamData[1].dwDataLength);
10442  memcpy(pOleStreamData[1].pData, &MetaFilePict, sizeof(MetaFilePict));
10443  IStream_Read(pStream, &(pOleStreamData[1].pData[sizeof(MetaFilePict)]), pOleStreamData[1].dwDataLength-sizeof(METAFILEPICT16), NULL);
10444  }
10445  IStream_Release(pStream);
10446  }
10447 }
INT16 yExt
Definition: wingdi16.h:59
#define OLESTREAM_ID
Definition: storage32.c:9578
#define STGM_SHARE_EXCLUSIVE
Definition: objbase.h:922
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
INT16 xExt
Definition: wingdi16.h:58
static DWORD OLECONVERT_WriteOLE20ToBuffer(LPSTORAGE pStorage, BYTE **pData)
Definition: storage32.c:9970
struct _LARGE_INTEGER::@2201 u
smooth NULL
Definition: ftsmooth.c:416
#define STGM_READ
Definition: objbase.h:916
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
HMETAFILE16 hMF
Definition: wingdi16.h:60
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define S_OK
Definition: intsafe.h:59
CHAR strOleTypeName[OLESTREAM_MAX_STR_LEN]
Definition: storage32.c:9587
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827

Referenced by OleConvertIStorageToOLESTREAM().

◆ OLECONVERT_LoadOLE10()

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

Definition at line 9641 of file storage32.c.

9642 {
9643  DWORD dwSize;
9644  HRESULT hRes = S_OK;
9645  int nTryCnt=0;
9646  int max_try = 6;
9647 
9648  pData->pData = NULL;
9649  pData->pstrOleObjFileName = NULL;
9650 
9651  for( nTryCnt=0;nTryCnt < max_try; nTryCnt++)
9652  {
9653  /* Get the OleID */
9654  dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwOleID), sizeof(pData->dwOleID));
9655  if(dwSize != sizeof(pData->dwOleID))
9656  {
9658  }
9659  else if(pData->dwOleID != OLESTREAM_ID)
9660  {
9662  }
9663  else
9664  {
9665  hRes = S_OK;
9666  break;
9667  }
9668  }
9669 
9670  if(hRes == S_OK)
9671  {
9672  /* Get the TypeID... more info needed for this field */
9673  dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwTypeID), sizeof(pData->dwTypeID));
9674  if(dwSize != sizeof(pData->dwTypeID))
9675  {
9677  }
9678  }
9679  if(hRes == S_OK)
9680  {
9681  if(pData->dwTypeID != 0)
9682  {
9683  /* Get the length of the OleTypeName */
9684  dwSize = pOleStream->lpstbl->Get(pOleStream, (void *) &(pData->dwOleTypeNameLength), sizeof(pData->dwOleTypeNameLength));
9685  if(dwSize != sizeof(pData->dwOleTypeNameLength))
9686  {
9688  }
9689 
9690  if(hRes == S_OK)
9691  {
9692  if(pData->dwOleTypeNameLength > 0)
9693  {
9694  /* Get the OleTypeName */
9695  dwSize = pOleStream->lpstbl->Get(pOleStream, pData->strOleTypeName, pData->dwOleTypeNameLength);
9696  if(dwSize != pData->dwOleTypeNameLength)
9697  {
9699  }
9700  }
9701  }
9702  if(bStrem1)
9703  {
9704  dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwOleObjFileNameLength), sizeof(pData->dwOleObjFileNameLength));
9705  if(dwSize != sizeof(pData->dwOleObjFileNameLength))
9706  {
9708  }
9709  if(hRes == S_OK)
9710  {
9711  if(pData->dwOleObjFileNameLength < 1) /* there is no file name exist */
9712  pData->dwOleObjFileNameLength = sizeof(pData->dwOleObjFileNameLength);
9713  pData->pstrOleObjFileName = HeapAlloc(GetProcessHeap(), 0, pData->dwOleObjFileNameLength);
9714  if(pData->pstrOleObjFileName)
9715  {
9716  dwSize = pOleStream->lpstbl->Get(pOleStream, pData->pstrOleObjFileName, pData->dwOleObjFileNameLength);
9717  if(dwSize != pData->dwOleObjFileNameLength)
9718  {
9720  }
9721  }
9722  else
9724  }
9725  }
9726  else
9727  {
9728  /* Get the Width of the Metafile */
9729  dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwMetaFileWidth), sizeof(pData->dwMetaFileWidth));
9730  if(dwSize != sizeof(pData->dwMetaFileWidth))
9731  {
9733  }
9734  if(hRes == S_OK)
9735  {
9736  /* Get the Height of the Metafile */
9737  dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwMetaFileHeight), sizeof(pData->dwMetaFileHeight));
9738  if(dwSize != sizeof(pData->dwMetaFileHeight))
9739  {
9741  }
9742  }
9743  }
9744  if(hRes == S_OK)
9745  {
9746  /* Get the Length of the Data */
9747  dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwDataLength), sizeof(pData->dwDataLength));
9748  if(dwSize != sizeof(pData->dwDataLength))
9749  {
9751  }
9752  }
9753 
9754  if(hRes == S_OK) /* I don't know what this 8 byte information is. We have to figure out */
9755  {
9756  if(!bStrem1) /* if it is a second OLE stream data */
9757  {
9758  pData->dwDataLength -= 8;
9759  dwSize = pOleStream->lpstbl->Get(pOleStream, pData->strUnknown, sizeof(pData->strUnknown));
9760  if(dwSize != sizeof(pData->strUnknown))
9761  {
9763  }
9764  }
9765  }
9766  if(hRes == S_OK)
9767  {
9768  if(pData->dwDataLength > 0)
9769  {
9770  pData->pData = HeapAlloc(GetProcessHeap(),0,pData->dwDataLength);
9771 
9772  /* Get Data (ex. IStorage, Metafile, or BMP) */
9773  if(pData->pData)
9774  {
9775  dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)pData->pData, pData->dwDataLength);
9776  if(dwSize != pData->dwDataLength)
9777  {
9779  }
9780  }
9781  else
9782  {
9784  }
9785  }
9786  }
9787  }
9788  }
9789  return hRes;
9790 }
#define OLESTREAM_ID
Definition: storage32.c:9578
smooth NULL
Definition: ftsmooth.c:416
#define CONVERT10_E_OLESTREAM_GET
Definition: winerror.h:2752
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
LPOLESTREAMVTBL lpstbl
Definition: ole.h:206
#define CONVERT10_E_OLESTREAM_FMT
Definition: winerror.h:2754
#define S_OK
Definition: intsafe.h:59
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54

Referenced by OleConvertOLESTREAMToIStorage().

◆ OLECONVERT_SaveOLE10()

static HRESULT OLECONVERT_SaveOLE10 ( OLECONVERT_OLESTREAM_DATA pData,
LPOLESTREAM  pOleStream 
)
static

Definition at line 9809 of file storage32.c.

9810 {
9811  DWORD dwSize;
9812  HRESULT hRes = S_OK;
9813 
9814 
9815  /* Set the OleID */
9816  dwSize = pOleStream->lpstbl->Put(pOleStream, (void *)&(pData->dwOleID), sizeof(pData->dwOleID));
9817  if(dwSize != sizeof(pData->dwOleID))
9818  {
9820  }
9821 
9822  if(hRes == S_OK)
9823  {
9824  /* Set the TypeID */
9825  dwSize = pOleStream->lpstbl->Put(pOleStream, (void *)&(pData->dwTypeID), sizeof(pData->dwTypeID));
9826  if(dwSize != sizeof(pData->dwTypeID))
9827  {
9829  }
9830  }
9831 
9832  if(pData->dwOleID == OLESTREAM_ID && pData->dwTypeID != 0 && hRes == S_OK)
9833  {
9834  /* Set the Length of the OleTypeName */
9835  dwSize = pOleStream->lpstbl->Put(pOleStream, (void *)&(pData->dwOleTypeNameLength), sizeof(pData->dwOleTypeNameLength));
9836  if(dwSize != sizeof(pData->dwOleTypeNameLength))
9837  {
9839  }
9840 
9841  if(hRes == S_OK)
9842  {
9843  if(pData->dwOleTypeNameLength > 0)
9844  {
9845  /* Set the OleTypeName */
9846  dwSize = pOleStream->lpstbl->Put(pOleStream, pData->strOleTypeName, pData->dwOleTypeNameLength);
9847  if(dwSize != pData->dwOleTypeNameLength)
9848  {
9850  }
9851  }
9852  }
9853 
9854  if(hRes == S_OK)
9855  {
9856  /* Set the width of the Metafile */
9857  dwSize = pOleStream->lpstbl->Put(pOleStream, (void *)&(pData->dwMetaFileWidth), sizeof(pData->dwMetaFileWidth));
9858  if(dwSize != sizeof(pData->dwMetaFileWidth))
9859  {
9861  }
9862  }
9863 
9864  if(hRes == S_OK)
9865  {
9866  /* Set the height of the Metafile */
9867  dwSize = pOleStream->lpstbl->Put(pOleStream, (void *)&(pData->dwMetaFileHeight), sizeof(pData->dwMetaFileHeight));
9868  if(dwSize != sizeof(pData->dwMetaFileHeight))
9869  {
9871  }
9872  }
9873 
9874  if(hRes == S_OK)
9875  {
9876  /* Set the length of the Data */
9877  dwSize = pOleStream->lpstbl->Put(pOleStream, (void *)&(pData->dwDataLength), sizeof(pData->dwDataLength));
9878  if(dwSize != sizeof(pData->dwDataLength))
9879  {
9881  }
9882  }
9883 
9884  if(hRes == S_OK)
9885  {
9886  if(pData->dwDataLength > 0)
9887  {
9888  /* Set the Data (eg. IStorage, Metafile, Bitmap) */
9889  dwSize = pOleStream->lpstbl->Put(pOleStream, (void *) pData->pData, pData->dwDataLength);
9890  if(dwSize != pData->dwDataLength)
9891  {
9893  }
9894  }
9895  }
9896  }
9897  return hRes;
9898 }
#define OLESTREAM_ID
Definition: storage32.c:9578
#define CONVERT10_E_OLESTREAM_PUT
Definition: winerror.h:2753
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
LPOLESTREAMVTBL lpstbl
Definition: ole.h:206
#define S_OK
Definition: intsafe.h:59
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54

Referenced by OleConvertIStorageToOLESTREAM().

◆ OLECONVERT_WriteOLE20ToBuffer()

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

Definition at line 9970 of file storage32.c.

9971 {
9972  HANDLE hFile;
9973  HRESULT hRes;
9974  DWORD nDataLength = 0;
9975  IStorage *pTempStorage;
9976  WCHAR wstrTempDir[MAX_PATH], wstrTempFile[MAX_PATH];
9977  static const WCHAR wstrPrefix[] = {'s', 'i', 's', 0};
9978 
9979  *pData = NULL;
9980 
9981  /* Create temp Storage */
9982  GetTempPathW(MAX_PATH, wstrTempDir);
9983  GetTempFileNameW(wstrTempDir, wstrPrefix, 0, wstrTempFile);
9984  hRes = StgCreateDocfile(wstrTempFile, STGM_CREATE | STGM_READWRITE | STGM_SHARE_EXCLUSIVE, 0, &pTempStorage);
9985 
9986  if(hRes == S_OK)
9987  {
9988  /* Copy Src Storage to the Temp Storage */
9989  IStorage_CopyTo(pStorage, 0, NULL, NULL, pTempStorage);
9990  IStorage_Release(pTempStorage);
9991 
9992  /* Open Temp Storage as a file and copy to memory */
9995  {
9996  nDataLength = GetFileSize(hFile, NULL);
9997  *pData = HeapAlloc(GetProcessHeap(),0,nDataLength);
9998  ReadFile(hFile, *pData, nDataLength, &nDataLength, 0);
9999  CloseHandle(hFile);
10000  }
10001  DeleteFileW(wstrTempFile);
10002  }
10003  return nDataLength;
10004 }
#define CloseHandle
Definition: compat.h:398
#define STGM_SHARE_EXCLUSIVE
Definition: objbase.h:922
#define STGM_CREATE
Definition: objbase.h:925
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetTempPathW(IN DWORD count, OUT LPWSTR path)
Definition: path.c:2079