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

Go to the source code of this file.

Classes

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

Macros

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

Typedefs

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

Enumerations

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

Functions

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

Variables

static const BYTE STORAGE_magic [8] ={0xd0,0xcf,0x11,0xe0,0xa1,0xb1,0x1a,0xe1}
 
static const BYTE STORAGE_oldmagic [8] ={0xd0,0xcf,0x11,0xe0,0x0e,0x11,0xfc,0x0d}
 
const IPropertySetStorageVtbl IPropertySetStorage_Vtbl
 
static const IStorageVtbl StorageInternalImpl_Vtbl
 
static const IStorageVtbl TransactedSnapshotImpl_Vtbl
 
static const IDirectWriterLockVtbl DirectWriterLockVtbl
 
static const IEnumSTATSTGVtbl IEnumSTATSTGImpl_Vtbl
 
static const StorageBaseImplVtbl StorageImpl_BaseVtbl
 
static const IStorageVtbl StorageImpl_Vtbl
 
static const StorageBaseImplVtbl StorageInternalImpl_BaseVtbl
 
static const StorageBaseImplVtbl TransactedSnapshotImpl_BaseVtbl
 
static const IStorageVtbl TransactedSharedImpl_Vtbl
 
static const StorageBaseImplVtbl TransactedSharedImpl_BaseVtbl
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 39 of file storage32.c.

◆ NONAMELESSUNION

#define NONAMELESSUNION

Definition at line 40 of file storage32.c.

◆ OLESTREAM_ID

#define OLESTREAM_ID   0x501

Definition at line 9577 of file storage32.c.

◆ OLESTREAM_MAX_STR_LEN

#define OLESTREAM_MAX_STR_LEN   255

Definition at line 9578 of file storage32.c.

Typedef Documentation

◆ BlockChainBlock

◆ StorageInternalImpl

◆ TransactedDirEntry

◆ TransactedSharedImpl

◆ TransactedSnapshotImpl

Enumeration Type Documentation

◆ stream_1ole_flags

Enumerator
OleStream_LinkedObject 
OleStream_Convert 

Definition at line 10609 of file storage32.c.

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

Function Documentation

◆ BlockChainStream_Construct()

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

Definition at line 7261 of file storage32.c.

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

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

◆ BlockChainStream_Destroy()

void BlockChainStream_Destroy ( BlockChainStream This)
static

Definition at line 7311 of file storage32.c.

7312 {
7313  if (This)
7314  {
7316  HeapFree(GetProcessHeap(), 0, This->indexCache);
7317  }
7318  HeapFree(GetProcessHeap(), 0, This);
7319 }
static HRESULT BlockChainStream_Flush(BlockChainStream *)
Definition: storage32.c:7294
#define GetProcessHeap()
Definition: compat.h:403
#define HeapFree(x, y, z)
Definition: compat.h:402

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

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

7295 {
7296  int i;
7297  if (!This) return S_OK;
7298  for (i=0; i<2; i++)
7299  {
7300  if (This->cachedBlocks[i].dirty)
7301  {
7302  if (StorageImpl_WriteBigBlock(This->parentStorage, This->cachedBlocks[i].sector, This->cachedBlocks[i].data))
7303  This->cachedBlocks[i].dirty = FALSE;
7304  else
7305  return STG_E_WRITEFAULT;
7306  }
7307  }
7308  return S_OK;
7309 }
#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:3589

Referenced by BlockChainStream_Destroy(), and StorageImpl_Flush().

◆ BlockChainStream_GetBlockAtOffset()

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

Definition at line 7214 of file storage32.c.

7216 {
7218  int i;
7219 
7220  for (i=0; i<2; i++)
7221  if (This->cachedBlocks[i].index == index)
7222  {
7223  *sector = This->cachedBlocks[i].sector;
7224  *block = &This->cachedBlocks[i];
7225  return S_OK;
7226  }
7227 
7229  if (*sector == BLOCK_END_OF_CHAIN)
7230  return STG_E_DOCFILECORRUPT;
7231 
7232  if (create)
7233  {
7234  if (This->cachedBlocks[0].index == 0xffffffff)
7235  result = &This->cachedBlocks[0];
7236  else if (This->cachedBlocks[1].index == 0xffffffff)
7237  result = &This->cachedBlocks[1];
7238  else
7239  {
7240  result = &This->cachedBlocks[This->blockToEvict++];
7241  if (This->blockToEvict == 2)
7242  This->blockToEvict = 0;
7243  }
7244 
7245  if (result->dirty)
7246  {
7247  if (!StorageImpl_WriteBigBlock(This->parentStorage, result->sector, result->data))
7248  return STG_E_WRITEFAULT;
7249  result->dirty = FALSE;
7250  }
7251 
7252  result->read = FALSE;
7253  result->index = index;
7254  result->sector = *sector;
7255  }
7256 
7257  *block = result;
7258  return S_OK;
7259 }
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:7185
GLuint64EXT * result
Definition: glext.h:11304
static BOOL StorageImpl_WriteBigBlock(StorageImpl *This, ULONG blockIndex, const void *buffer)
Definition: storage32.c:3589
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 218 of file storage32.c.

219 {
220  return This->numBlocks;
221 }

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

◆ BlockChainStream_GetHeadOfChain()

static ULONG BlockChainStream_GetHeadOfChain ( BlockChainStream This)
static

Definition at line 7085 of file storage32.c.

7086 {
7087  DirEntry chainEntry;
7088  HRESULT hr;
7089 
7090  if (This->headOfStreamPlaceHolder != 0)
7091  return *(This->headOfStreamPlaceHolder);
7092 
7093  if (This->ownerDirEntry != DIRENTRY_NULL)
7094  {
7096  This->parentStorage,
7097  This->ownerDirEntry,
7098  &chainEntry);
7099 
7100  if (SUCCEEDED(hr) && chainEntry.startingBlock < BLOCK_FIRST_SPECIAL)
7101  return chainEntry.startingBlock;
7102  }
7103 
7104  return BLOCK_END_OF_CHAIN;
7105 }
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:3428
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 7185 of file storage32.c.

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

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

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

7580 {
7582 
7583  if (newSize.QuadPart == size.QuadPart)
7584  return TRUE;
7585 
7586  if (newSize.QuadPart < size.QuadPart)
7587  {
7588  BlockChainStream_Shrink(This, newSize);
7589  }
7590  else
7591  {
7592  BlockChainStream_Enlarge(This, newSize);
7593  }
7594 
7595  return TRUE;
7596 }
static ULARGE_INTEGER BlockChainStream_GetSize(BlockChainStream *)
Definition: storage32.c:7535
#define TRUE
Definition: types.h:120
static BOOL BlockChainStream_Shrink(BlockChainStream *This, ULARGE_INTEGER newSize)
Definition: storage32.c:7326
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:7419

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

◆ BlockChainStream_Shrink()

static BOOL BlockChainStream_Shrink ( BlockChainStream This,
ULARGE_INTEGER  newSize 
)
static

Definition at line 7326 of file storage32.c.

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

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

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

8492 {
8493  StorageBaseImpl* newStorage = 0;
8496  DWORD shareMode;
8497  DWORD accessMode;
8498  DWORD creationMode;
8499  DWORD fileAttributes;
8500  WCHAR tempFileName[MAX_PATH];
8501 
8502  if (ppstgOpen == 0)
8503  return STG_E_INVALIDPOINTER;
8504 
8505  if (pStgOptions->ulSectorSize != MIN_BIG_BLOCK_SIZE && pStgOptions->ulSectorSize != MAX_BIG_BLOCK_SIZE)
8506  return STG_E_INVALIDPARAMETER;
8507 
8508  /* if no share mode given then DENY_NONE is the default */
8509  if (STGM_SHARE_MODE(grfMode) == 0)
8510  grfMode |= STGM_SHARE_DENY_NONE;
8511 
8512  if ( FAILED( validateSTGM(grfMode) ))
8513  goto end;
8514 
8515  /* StgCreateDocFile seems to refuse readonly access, despite MSDN */
8516  switch(STGM_ACCESS_MODE(grfMode))
8517  {
8518  case STGM_WRITE:
8519  case STGM_READWRITE:
8520  break;
8521  default:
8522  goto end;
8523  }
8524 
8525  /* in direct mode, can only use SHARE_EXCLUSIVE */
8526  if (!(grfMode & STGM_TRANSACTED) && (STGM_SHARE_MODE(grfMode) != STGM_SHARE_EXCLUSIVE))
8527  goto end;
8528 
8529  /* but in transacted mode, any share mode is valid */
8530 
8531  /*
8532  * Generate a unique name.
8533  */
8534  if (pwcsName == 0)
8535  {
8536  WCHAR tempPath[MAX_PATH];
8537  static const WCHAR prefix[] = { 'S', 'T', 'O', 0 };
8538 
8539  memset(tempPath, 0, sizeof(tempPath));
8540  memset(tempFileName, 0, sizeof(tempFileName));
8541 
8542  if ((GetTempPathW(MAX_PATH, tempPath)) == 0 )
8543  tempPath[0] = '.';
8544 
8545  if (GetTempFileNameW(tempPath, prefix, 0, tempFileName) != 0)
8546  pwcsName = tempFileName;
8547  else
8548  {
8550  goto end;
8551  }
8552 
8553  creationMode = TRUNCATE_EXISTING;
8554  }
8555  else
8556  {
8557  creationMode = GetCreationModeFromSTGM(grfMode);
8558  }
8559 
8560  /*
8561  * Interpret the STGM value grfMode
8562  */
8563  shareMode = GetShareModeFromSTGM(grfMode);
8564  accessMode = GetAccessModeFromSTGM(grfMode);
8565 
8566  if (grfMode & STGM_DELETEONRELEASE)
8568  else
8570 
8571  *ppstgOpen = 0;
8572 
8573  hFile = CreateFileW(pwcsName,
8574  accessMode,
8575  shareMode,
8576  NULL,
8577  creationMode,
8578  fileAttributes,
8579  0);
8580 
8581  if (hFile == INVALID_HANDLE_VALUE)
8582  {
8585  else
8586  hr = E_FAIL;
8587  goto end;
8588  }
8589 
8590  /*
8591  * Allocate and initialize the new IStorage object.
8592  */
8594  hFile,
8595  pwcsName,
8596  NULL,
8597  grfMode,
8598  TRUE,
8599  TRUE,
8600  pStgOptions->ulSectorSize,
8601  &newStorage);
8602 
8603  if (FAILED(hr))
8604  {
8605  goto end;
8606  }
8607 
8608  hr = IStorage_QueryInterface(&newStorage->IStorage_iface, riid, ppstgOpen);
8609  IStorage_Release(&newStorage->IStorage_iface);
8610 
8611 end:
8612  TRACE("<-- %p r = %08x\n", *ppstgOpen, hr);
8613 
8614  return hr;
8615 }
#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:397
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:399
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:371
static DWORD GetCreationModeFromSTGM(DWORD stgm)
Definition: storage32.c:418
#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:6906
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:287
#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:408
#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 2426 of file storage32.c.

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

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

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

◆ directwriterlock_HaveWriteAccess()

static HRESULT WINAPI directwriterlock_HaveWriteAccess ( IDirectWriterLock iface)
static

Definition at line 477 of file storage32.c.

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

◆ directwriterlock_QueryInterface()

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

Definition at line 445 of file storage32.c.

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

◆ directwriterlock_Release()

static ULONG WINAPI directwriterlock_Release ( IDirectWriterLock iface)
static

Definition at line 457 of file storage32.c.

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

◆ directwriterlock_ReleaseWriteAccess()

static HRESULT WINAPI directwriterlock_ReleaseWriteAccess ( IDirectWriterLock iface)
static

Definition at line 470 of file storage32.c.

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

◆ directwriterlock_WaitForWriteAccess()

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

Definition at line 463 of file storage32.c.

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

◆ entryNameCmp()

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

Definition at line 510 of file storage32.c.

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

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

◆ findElement()

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

Definition at line 533 of file storage32.c.

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

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

◆ findTreeParent()

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

Definition at line 574 of file storage32.c.

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

398 {
399  switch (STGM_ACCESS_MODE(stgm))
400  {
401  case STGM_READ:
402  return GENERIC_READ;
403  case STGM_WRITE:
404  case STGM_READWRITE:
405  return GENERIC_READ | GENERIC_WRITE;
406  }
407  ERR("Invalid access mode!\n");
408  assert(0);
409  return 0;
410 }
#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 10617 of file storage32.c.

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

Referenced by test_convert().

◆ GetCreationModeFromSTGM()

static DWORD GetCreationModeFromSTGM ( DWORD  stgm)
static

Definition at line 418 of file storage32.c.

419 {
420  switch(STGM_CREATE_MODE(stgm))
421  {
422  case STGM_CREATE:
423  return CREATE_ALWAYS;
424  case STGM_CONVERT:
425  FIXME("STGM_CONVERT not implemented!\n");
426  return CREATE_NEW;
427  case STGM_FAILIFTHERE:
428  return CREATE_NEW;
429  }
430  ERR("Invalid create mode!\n");
431  assert(0);
432  return 0;
433 }
#define 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 371 of file storage32.c.

372 {
373  switch (STGM_SHARE_MODE(stgm))
374  {
375  case 0:
376  assert(stgm & STGM_TRANSACTED);
377  /* fall-through */
381  return FILE_SHARE_WRITE;
384  return FILE_SHARE_READ;
385  }
386  ERR("Invalid share mode!\n");
387  assert(0);
388  return 0;
389 }
#define 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 930 of file storage32.c.

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

◆ IEnumSTATSTGImpl_Clone()

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

Definition at line 1136 of file storage32.c.

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

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

Referenced by IEnumSTATSTGImpl_Clone(), and StorageBaseImpl_EnumElements().

◆ IEnumSTATSTGImpl_Destroy()

static void IEnumSTATSTGImpl_Destroy ( IEnumSTATSTGImpl This)
static

Definition at line 897 of file storage32.c.

898 {
899  IStorage_Release(&This->parentStorage->IStorage_iface);
901 }
#define GetProcessHeap()
Definition: compat.h:403
#define HeapFree(x, y, z)
Definition: compat.h:402

Referenced by IEnumSTATSTGImpl_Release().

◆ IEnumSTATSTGImpl_GetNextRef()

static HRESULT IEnumSTATSTGImpl_GetNextRef ( IEnumSTATSTGImpl This,
DirRef ref 
)
static

Definition at line 954 of file storage32.c.

957 {
959  DirRef searchNode;
960  DirEntry entry;
961  HRESULT hr;
962  WCHAR result_name[DIRENTRY_NAME_MAX_LEN];
963 
964  TRACE("%p,%p\n", This, ref);
965 
966  hr = StorageBaseImpl_ReadDirEntry(This->parentStorage,
967  This->parentStorage->storageDirEntry, &entry);
968  searchNode = entry.dirRootEntry;
969 
970  while (SUCCEEDED(hr) && searchNode != DIRENTRY_NULL)
971  {
972  hr = StorageBaseImpl_ReadDirEntry(This->parentStorage, searchNode, &entry);
973 
974  if (SUCCEEDED(hr))
975  {
976  LONG diff = entryNameCmp( entry.name, This->name);
977 
978  if (diff <= 0)
979  {
980  searchNode = entry.rightChild;
981  }
982  else
983  {
984  result = searchNode;
985  memcpy(result_name, entry.name, sizeof(result_name));
986  searchNode = entry.leftChild;
987  }
988  }
989  }
990 
991  if (SUCCEEDED(hr))
992  {
993  *ref = result;
994  if (result != DIRENTRY_NULL)
995  memcpy(This->name, result_name, sizeof(result_name));
996  }
997 
998  TRACE("<-- %08x\n", hr);
999  return hr;
1000 }
HRESULT hr
Definition: shlfolder.c:183
Definition: send.c:47
static LONG entryNameCmp(const OLECHAR *name1, const OLECHAR *name2)
Definition: storage32.c:510
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 1002 of file storage32.c.

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

907 {
909 
910  TRACE("%p,%s,%p\n", iface, debugstr_guid(riid), ppvObject);
911 
912  if (ppvObject==0)
913  return E_INVALIDARG;
914 
915  *ppvObject = 0;
916 
917  if (IsEqualGUID(&IID_IUnknown, riid) ||
919  {
920  *ppvObject = &This->IEnumSTATSTG_iface;
921  IEnumSTATSTG_AddRef(&This->IEnumSTATSTG_iface);
922  TRACE("<-- %p\n", *ppvObject);
923  return S_OK;
924  }
925 
926  TRACE("<-- E_NOINTERFACE\n");
927  return E_NOINTERFACE;
928 }
#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:892
#define S_OK
Definition: intsafe.h:59
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112

◆ IEnumSTATSTGImpl_Release()

static ULONG WINAPI IEnumSTATSTGImpl_Release ( IEnumSTATSTG iface)
static

Definition at line 937 of file storage32.c.

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

◆ IEnumSTATSTGImpl_Reset()

static HRESULT WINAPI IEnumSTATSTGImpl_Reset ( IEnumSTATSTG iface)
static

Definition at line 1116 of file storage32.c.

1118 {
1120 
1121  TRACE("%p\n", iface);
1122 
1123  if (This->parentStorage->reverted)
1124  {
1125  TRACE("<-- STG_E_REVERTED\n");
1126  return STG_E_REVERTED;
1127  }
1128 
1129  This->name[0] = 0;
1130 
1131  return S_OK;
1132 }
#define TRACE(s)
Definition: solgame.cpp:4
static IEnumSTATSTGImpl * impl_from_IEnumSTATSTG(IEnumSTATSTG *iface)
Definition: storage32.c:892
#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 1081 of file storage32.c.

1084 {
1086 
1087  ULONG objectFetched = 0;
1088  DirRef currentSearchNode;
1089  HRESULT hr=S_OK;
1090 
1091  TRACE("%p,%u\n", iface, celt);
1092 
1093  if (This->parentStorage->reverted)
1094  {
1095  TRACE("<-- STG_E_REVERTED\n");
1096  return STG_E_REVERTED;
1097  }
1098 
1099  while ( (objectFetched < celt) )
1100  {
1101  hr = IEnumSTATSTGImpl_GetNextRef(This, &currentSearchNode);
1102 
1103  if (FAILED(hr) || currentSearchNode == DIRENTRY_NULL)
1104  break;
1105 
1106  objectFetched++;
1107  }
1108 
1109  if (SUCCEEDED(hr) && objectFetched != celt)
1110  return S_FALSE;
1111 
1112  TRACE("<-- %08x\n", hr);
1113  return hr;
1114 }
HRESULT hr
Definition: shlfolder.c:183
static HRESULT IEnumSTATSTGImpl_GetNextRef(IEnumSTATSTGImpl *This, DirRef *ref)
Definition: storage32.c:954
#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:892
#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 440 of file storage32.c.

441 {
442  return CONTAINING_RECORD(iface, StorageBaseImpl, IDirectWriterLock_iface);
443 }
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 892 of file storage32.c.

893 {
894  return CONTAINING_RECORD(iface, IEnumSTATSTGImpl, IEnumSTATSTG_iface);
895 }
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 650 of file storage32.c.

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

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

10215 {
10216  HRESULT hRes;
10217  IStream *pStream;
10218  static const WCHAR wstrStreamName[] = {1, 'O', 'l', 'e', '1', '0', 'N', 'a', 't', 'i', 'v', 'e', 0};
10219 
10220  /* Create the Ole10Native Stream */
10221  hRes = IStorage_CreateStream(pStorage, wstrStreamName,
10222  STGM_CREATE | STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &pStream );
10223 
10224  if(hRes == S_OK)
10225  {
10226  /* Write info to stream */
10227  hRes = IStream_Write(pStream, &dwDataLength, sizeof(dwDataLength), NULL);
10228  hRes = IStream_Write(pStream, pData, dwDataLength, NULL);
10229  IStream_Release(pStream);
10230  }
10231 
10232 }
#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 10130 of file storage32.c.

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

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

10254 {
10255  HRESULT hRes;
10256  IStream *pStream;
10257  LARGE_INTEGER iSeekPos;
10259  static const WCHAR wstrStreamName[] = {1,'C', 'o', 'm', 'p', 'O', 'b', 'j', 0};
10260 
10261  /* Open the CompObj Stream */
10262  hRes = IStorage_OpenStream(pStorage, wstrStreamName, NULL,
10263  STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &pStream );
10264  if(hRes == S_OK)
10265  {
10266 
10267  /*Get the OleType from the CompObj Stream */
10268  iSeekPos.u.LowPart = sizeof(CompObj.byUnknown1) + sizeof(CompObj.clsid);
10269  iSeekPos.u.HighPart = 0;
10270 
10271  IStream_Seek(pStream, iSeekPos, STREAM_SEEK_SET, NULL);
10272  IStream_Read(pStream, &CompObj.dwCLSIDNameLength, sizeof(CompObj.dwCLSIDNameLength), NULL);
10273  iSeekPos.u.LowPart = CompObj.dwCLSIDNameLength;
10274  IStream_Seek(pStream, iSeekPos, STREAM_SEEK_CUR , NULL);
10275  IStream_Read(pStream, &CompObj.dwOleTypeNameLength, sizeof(CompObj.dwOleTypeNameLength), NULL);
10276  iSeekPos.u.LowPart = CompObj.dwOleTypeNameLength;
10277  IStream_Seek(pStream, iSeekPos, STREAM_SEEK_CUR , NULL);
10278 
10279  IStream_Read(pStream, dwSize, sizeof(*dwSize), NULL);
10280  if(*dwSize > 0)
10281  {
10282  IStream_Read(pStream, strProgID, *dwSize, NULL);
10283  }
10284  IStream_Release(pStream);
10285  }
10286  else
10287  {
10288  STATSTG stat;
10289  LPOLESTR wstrProgID;
10290 
10291  /* Get the OleType from the registry */
10292  REFCLSID clsid = &(stat.clsid);
10293  IStorage_Stat(pStorage, &stat, STATFLAG_NONAME);
10294  hRes = ProgIDFromCLSID(clsid, &wstrProgID);
10295  if(hRes == S_OK)
10296  {
10297  *dwSize = WideCharToMultiByte(CP_ACP, 0, wstrProgID, -1, strProgID, *dwSize, NULL, FALSE);
10298  CoTaskMemFree(wstrProgID);
10299  }
10300 
10301  }
10302  return hRes;
10303 }
struct _LARGE_INTEGER::@2220 u
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:420
#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:2530
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:82
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 9919 of file storage32.c.

9920 {
9921  HRESULT hRes;
9922  HANDLE hFile;
9923  IStorage *pTempStorage;
9924  DWORD dwNumOfBytesWritten;
9925  WCHAR wstrTempDir[MAX_PATH], wstrTempFile[MAX_PATH];
9926  static const WCHAR wstrPrefix[] = {'s', 'i', 's', 0};
9927 
9928  /* Create a temp File */
9929  GetTempPathW(MAX_PATH, wstrTempDir);
9930  GetTempFileNameW(wstrTempDir, wstrPrefix, 0, wstrTempFile);
9932 
9934  {
9935  /* Write IStorage Data to File */
9936  WriteFile(hFile, pBuffer, nBufferLength, &dwNumOfBytesWritten, NULL);
9937  CloseHandle(hFile);
9938 
9939  /* Open and copy temp storage to the Dest Storage */
9940  hRes = StgOpenStorage(wstrTempFile, NULL, STGM_READ, NULL, 0, &pTempStorage);
9941  if(hRes == S_OK)
9942  {
9943  hRes = IStorage_CopyTo(pTempStorage, 0, NULL, NULL, pDestStorage);
9944  IStorage_Release(pTempStorage);
9945  }
9946  DeleteFileW(wstrTempFile);
9947  }
9948 }
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:406
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
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:3028
#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:8755
#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:408

Referenced by OleConvertOLESTREAMToIStorage().

◆ OLECONVERT_GetOle20PresData()

static void OLECONVERT_GetOle20PresData ( LPSTORAGE  pStorage,
OLECONVERT_OLESTREAM_DATA pOleStreamData 
)
static

Definition at line 10377 of file storage32.c.

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

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

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

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