ReactOS 0.4.16-dev-297-gc569aee
stream.c File Reference
#include "wine/debug.h"
#include "windef.h"
#include "winbase.h"
#include "winreg.h"
#include "objbase.h"
#include "shlwapi.h"
#include "wincodecs_private.h"
Include dependency graph for stream.c:

Go to the source code of this file.

Classes

struct  StreamOnMemory
 
struct  StreamOnFileHandle
 
struct  StreamOnStreamRange
 
struct  IWICStreamImpl
 

Macros

#define COBJMACROS
 

Typedefs

typedef struct StreamOnMemory StreamOnMemory
 
typedef struct StreamOnFileHandle StreamOnFileHandle
 
typedef struct StreamOnStreamRange StreamOnStreamRange
 
typedef struct IWICStreamImpl IWICStreamImpl
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (wincodecs)
 
static StreamOnMemoryStreamOnMemory_from_IStream (IStream *iface)
 
static HRESULT WINAPI StreamOnMemory_QueryInterface (IStream *iface, REFIID iid, void **ppv)
 
static ULONG WINAPI StreamOnMemory_AddRef (IStream *iface)
 
static ULONG WINAPI StreamOnMemory_Release (IStream *iface)
 
static HRESULT WINAPI StreamOnMemory_Read (IStream *iface, void *pv, ULONG cb, ULONG *pcbRead)
 
static HRESULT WINAPI StreamOnMemory_Write (IStream *iface, void const *pv, ULONG cb, ULONG *pcbWritten)
 
static HRESULT WINAPI StreamOnMemory_Seek (IStream *iface, LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
 
static HRESULT WINAPI StreamOnMemory_SetSize (IStream *iface, ULARGE_INTEGER libNewSize)
 
static HRESULT WINAPI StreamOnMemory_CopyTo (IStream *iface, IStream *pstm, ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten)
 
static HRESULT WINAPI StreamOnMemory_Commit (IStream *iface, DWORD grfCommitFlags)
 
static HRESULT WINAPI StreamOnMemory_Revert (IStream *iface)
 
static HRESULT WINAPI StreamOnMemory_LockRegion (IStream *iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
 
static HRESULT WINAPI StreamOnMemory_UnlockRegion (IStream *iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
 
static HRESULT WINAPI StreamOnMemory_Stat (IStream *iface, STATSTG *pstatstg, DWORD grfStatFlag)
 
static HRESULT WINAPI StreamOnMemory_Clone (IStream *iface, IStream **ppstm)
 
static StreamOnFileHandleStreamOnFileHandle_from_IStream (IStream *iface)
 
static HRESULT WINAPI StreamOnFileHandle_QueryInterface (IStream *iface, REFIID iid, void **ppv)
 
static ULONG WINAPI StreamOnFileHandle_AddRef (IStream *iface)
 
static ULONG WINAPI StreamOnFileHandle_Release (IStream *iface)
 
static HRESULT WINAPI StreamOnFileHandle_Read (IStream *iface, void *pv, ULONG cb, ULONG *pcbRead)
 
static HRESULT WINAPI StreamOnFileHandle_Write (IStream *iface, void const *pv, ULONG cb, ULONG *pcbWritten)
 
static HRESULT WINAPI StreamOnFileHandle_Seek (IStream *iface, LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
 
static HRESULT WINAPI StreamOnFileHandle_SetSize (IStream *iface, ULARGE_INTEGER libNewSize)
 
static HRESULT WINAPI StreamOnFileHandle_CopyTo (IStream *iface, IStream *pstm, ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten)
 
static HRESULT WINAPI StreamOnFileHandle_Commit (IStream *iface, DWORD grfCommitFlags)
 
static HRESULT WINAPI StreamOnFileHandle_Revert (IStream *iface)
 
static HRESULT WINAPI StreamOnFileHandle_LockRegion (IStream *iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
 
static HRESULT WINAPI StreamOnFileHandle_UnlockRegion (IStream *iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
 
static HRESULT WINAPI StreamOnFileHandle_Stat (IStream *iface, STATSTG *pstatstg, DWORD grfStatFlag)
 
static HRESULT WINAPI StreamOnFileHandle_Clone (IStream *iface, IStream **ppstm)
 
static StreamOnStreamRangeStreamOnStreamRange_from_IStream (IStream *iface)
 
static HRESULT WINAPI StreamOnStreamRange_QueryInterface (IStream *iface, REFIID iid, void **ppv)
 
static ULONG WINAPI StreamOnStreamRange_AddRef (IStream *iface)
 
static ULONG WINAPI StreamOnStreamRange_Release (IStream *iface)
 
static HRESULT WINAPI StreamOnStreamRange_Read (IStream *iface, void *pv, ULONG cb, ULONG *pcbRead)
 
static HRESULT WINAPI StreamOnStreamRange_Write (IStream *iface, void const *pv, ULONG cb, ULONG *pcbWritten)
 
static HRESULT WINAPI StreamOnStreamRange_Seek (IStream *iface, LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
 
static HRESULT WINAPI StreamOnStreamRange_SetSize (IStream *iface, ULARGE_INTEGER libNewSize)
 
static HRESULT WINAPI StreamOnStreamRange_CopyTo (IStream *iface, IStream *pstm, ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten)
 
static HRESULT WINAPI StreamOnStreamRange_Commit (IStream *iface, DWORD grfCommitFlags)
 
static HRESULT WINAPI StreamOnStreamRange_Revert (IStream *iface)
 
static HRESULT WINAPI StreamOnStreamRange_LockRegion (IStream *iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
 
static HRESULT WINAPI StreamOnStreamRange_UnlockRegion (IStream *iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
 
static HRESULT WINAPI StreamOnStreamRange_Stat (IStream *iface, STATSTG *pstatstg, DWORD grfStatFlag)
 
static HRESULT WINAPI StreamOnStreamRange_Clone (IStream *iface, IStream **ppstm)
 
static IWICStreamImplimpl_from_IWICStream (IWICStream *iface)
 
static HRESULT WINAPI IWICStreamImpl_QueryInterface (IWICStream *iface, REFIID iid, void **ppv)
 
static ULONG WINAPI IWICStreamImpl_AddRef (IWICStream *iface)
 
static ULONG WINAPI IWICStreamImpl_Release (IWICStream *iface)
 
static HRESULT WINAPI IWICStreamImpl_Read (IWICStream *iface, void *pv, ULONG cb, ULONG *pcbRead)
 
static HRESULT WINAPI IWICStreamImpl_Write (IWICStream *iface, void const *pv, ULONG cb, ULONG *pcbWritten)
 
static HRESULT WINAPI IWICStreamImpl_Seek (IWICStream *iface, LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
 
static HRESULT WINAPI IWICStreamImpl_SetSize (IWICStream *iface, ULARGE_INTEGER libNewSize)
 
static HRESULT WINAPI IWICStreamImpl_CopyTo (IWICStream *iface, IStream *pstm, ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten)
 
static HRESULT WINAPI IWICStreamImpl_Commit (IWICStream *iface, DWORD grfCommitFlags)
 
static HRESULT WINAPI IWICStreamImpl_Revert (IWICStream *iface)
 
static HRESULT WINAPI IWICStreamImpl_LockRegion (IWICStream *iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
 
static HRESULT WINAPI IWICStreamImpl_UnlockRegion (IWICStream *iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
 
static HRESULT WINAPI IWICStreamImpl_Stat (IWICStream *iface, STATSTG *pstatstg, DWORD grfStatFlag)
 
static HRESULT WINAPI IWICStreamImpl_Clone (IWICStream *iface, IStream **ppstm)
 
static HRESULT WINAPI IWICStreamImpl_InitializeFromIStream (IWICStream *iface, IStream *stream)
 
static HRESULT WINAPI IWICStreamImpl_InitializeFromFilename (IWICStream *iface, LPCWSTR wzFileName, DWORD dwDesiredAccess)
 
static HRESULT WINAPI IWICStreamImpl_InitializeFromMemory (IWICStream *iface, BYTE *pbBuffer, DWORD cbBufferSize)
 
static HRESULT map_file (HANDLE file, HANDLE *map, void **mem, LARGE_INTEGER *size)
 
HRESULT stream_initialize_from_filehandle (IWICStream *iface, HANDLE file)
 
static HRESULT WINAPI IWICStreamImpl_InitializeFromIStreamRegion (IWICStream *iface, IStream *pIStream, ULARGE_INTEGER ulOffset, ULARGE_INTEGER ulMaxSize)
 
HRESULT StreamImpl_Create (IWICStream **stream)
 

Variables

static const IStreamVtbl StreamOnMemory_Vtbl
 
static const IStreamVtbl StreamOnFileHandle_Vtbl
 
static const IStreamVtbl StreamOnStreamRange_Vtbl
 
static const IWICStreamVtbl WICStream_Vtbl
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 21 of file stream.c.

Typedef Documentation

◆ IWICStreamImpl

◆ StreamOnFileHandle

◆ StreamOnMemory

◆ StreamOnStreamRange

Function Documentation

◆ impl_from_IWICStream()

◆ IWICStreamImpl_AddRef()

static ULONG WINAPI IWICStreamImpl_AddRef ( IWICStream iface)
static

Definition at line 779 of file stream.c.

780{
783
784 TRACE("(%p) refcount=%u\n", iface, ref);
785
786 return ref;
787}
#define InterlockedIncrement
Definition: armddk.h:53
static IWICStreamImpl * impl_from_IWICStream(IWICStream *iface)
Definition: stream.c:752
#define TRACE(s)
Definition: solgame.cpp:4
Definition: send.c:48
uint32_t ULONG
Definition: typedefs.h:59

◆ IWICStreamImpl_Clone()

static HRESULT WINAPI IWICStreamImpl_Clone ( IWICStream iface,
IStream **  ppstm 
)
static

Definition at line 905 of file stream.c.

907{
909 TRACE("(%p, %p)\n", This, ppstm);
910
911 if (!This->pStream) return WINCODEC_ERR_NOTINITIALIZED;
912 return IStream_Clone(This->pStream, ppstm);
913}
#define WINCODEC_ERR_NOTINITIALIZED
Definition: winerror.h:3285

◆ IWICStreamImpl_Commit()

static HRESULT WINAPI IWICStreamImpl_Commit ( IWICStream iface,
DWORD  grfCommitFlags 
)
static

Definition at line 854 of file stream.c.

856{
858 TRACE("(%p, %#x)\n", This, grfCommitFlags);
859
860 if (!This->pStream) return WINCODEC_ERR_NOTINITIALIZED;
861 return IStream_Commit(This->pStream, grfCommitFlags);
862}

◆ IWICStreamImpl_CopyTo()

static HRESULT WINAPI IWICStreamImpl_CopyTo ( IWICStream iface,
IStream pstm,
ULARGE_INTEGER  cb,
ULARGE_INTEGER pcbRead,
ULARGE_INTEGER pcbWritten 
)
static

Definition at line 844 of file stream.c.

846{
848 TRACE("(%p, %p, %s, %p, %p)\n", This, pstm, wine_dbgstr_longlong(cb.QuadPart), pcbRead, pcbWritten);
849
850 if (!This->pStream) return WINCODEC_ERR_NOTINITIALIZED;
851 return IStream_CopyTo(This->pStream, pstm, cb, pcbRead, pcbWritten);
852}
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49
static HMODULE MODULEINFO DWORD cb
Definition: module.c:33

◆ IWICStreamImpl_InitializeFromFilename()

static HRESULT WINAPI IWICStreamImpl_InitializeFromFilename ( IWICStream iface,
LPCWSTR  wzFileName,
DWORD  dwDesiredAccess 
)
static

Definition at line 937 of file stream.c.

939{
941 HRESULT hr;
942 DWORD dwMode;
944
945 TRACE("(%p, %s, %u)\n", iface, debugstr_w(wzFileName), dwDesiredAccess);
946
947 if (This->pStream) return WINCODEC_ERR_WRONGSTATE;
948
949 if(dwDesiredAccess & GENERIC_WRITE)
951 else if(dwDesiredAccess & GENERIC_READ)
953 else
954 return E_INVALIDARG;
955
956 hr = SHCreateStreamOnFileW(wzFileName, dwMode, &stream);
957
958 if (SUCCEEDED(hr))
959 {
960 if (InterlockedCompareExchangePointer((void**)&This->pStream, stream, NULL))
961 {
962 /* Some other thread set the stream first. */
963 IStream_Release(stream);
965 }
966 }
967
968 return hr;
969}
#define E_INVALIDARG
Definition: ddrawi.h:101
#define NULL
Definition: types.h:112
#define GENERIC_READ
Definition: compat.h:135
HRESULT WINAPI SHCreateStreamOnFileW(LPCWSTR lpszPath, DWORD dwMode, IStream **lppStream)
Definition: istream.c:484
unsigned long DWORD
Definition: ntddk_ex.h:95
#define InterlockedCompareExchangePointer
Definition: interlocked.h:129
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define debugstr_w
Definition: kernel32.h:32
#define GENERIC_WRITE
Definition: nt_native.h:90
#define STGM_CREATE
Definition: objbase.h:926
#define STGM_FAILIFTHERE
Definition: objbase.h:928
#define STGM_SHARE_DENY_WRITE
Definition: objbase.h:922
#define STGM_WRITE
Definition: objbase.h:918
#define STGM_READ
Definition: objbase.h:917
HRESULT hr
Definition: shlfolder.c:183
Definition: parse.h:23
#define WINCODEC_ERR_WRONGSTATE
Definition: winerror.h:3281

◆ IWICStreamImpl_InitializeFromIStream()

static HRESULT WINAPI IWICStreamImpl_InitializeFromIStream ( IWICStream iface,
IStream stream 
)
static

Definition at line 915 of file stream.c.

916{
918 HRESULT hr = S_OK;
919
920 TRACE("(%p, %p)\n", iface, stream);
921
922 if (!stream) return E_INVALIDARG;
923 if (This->pStream) return WINCODEC_ERR_WRONGSTATE;
924
925 IStream_AddRef(stream);
926
927 if (InterlockedCompareExchangePointer((void **)&This->pStream, stream, NULL))
928 {
929 /* Some other thread set the stream first. */
930 IStream_Release(stream);
932 }
933
934 return hr;
935}
#define S_OK
Definition: intsafe.h:52

◆ IWICStreamImpl_InitializeFromIStreamRegion()

static HRESULT WINAPI IWICStreamImpl_InitializeFromIStreamRegion ( IWICStream iface,
IStream pIStream,
ULARGE_INTEGER  ulOffset,
ULARGE_INTEGER  ulMaxSize 
)
static

Definition at line 1088 of file stream.c.

1090{
1093
1094 TRACE("(%p,%p,%s,%s)\n", iface, pIStream, wine_dbgstr_longlong(ulOffset.QuadPart),
1095 wine_dbgstr_longlong(ulMaxSize.QuadPart));
1096
1097 if (!pIStream) return E_INVALIDARG;
1098 if (This->pStream) return WINCODEC_ERR_WRONGSTATE;
1099
1101 if (!pObject) return E_OUTOFMEMORY;
1102
1103 pObject->IStream_iface.lpVtbl = &StreamOnStreamRange_Vtbl;
1104 pObject->ref = 1;
1105 IStream_AddRef(pIStream);
1106 pObject->stream = pIStream;
1107 pObject->pos.QuadPart = 0;
1108 pObject->offset = ulOffset;
1109 pObject->max_size = ulMaxSize;
1111 pObject->lock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": StreamOnStreamRange.lock");
1112
1113 if (InterlockedCompareExchangePointer((void**)&This->pStream, pObject, NULL))
1114 {
1115 /* Some other thread set the stream first. */
1116 IStream_Release(&pObject->IStream_iface);
1118 }
1119
1120 return S_OK;
1121}
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
static const IStreamVtbl StreamOnStreamRange_Vtbl
Definition: stream.c:718
FxObject * pObject
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:751
#define DWORD_PTR
Definition: treelist.c:76

◆ IWICStreamImpl_InitializeFromMemory()

static HRESULT WINAPI IWICStreamImpl_InitializeFromMemory ( IWICStream iface,
BYTE pbBuffer,
DWORD  cbBufferSize 
)
static

Definition at line 987 of file stream.c.

989{
992 TRACE("(%p, %p, %u)\n", iface, pbBuffer, cbBufferSize);
993
994 if (!pbBuffer) return E_INVALIDARG;
995 if (This->pStream) return WINCODEC_ERR_WRONGSTATE;
996
998 if (!pObject) return E_OUTOFMEMORY;
999
1000 pObject->IStream_iface.lpVtbl = &StreamOnMemory_Vtbl;
1001 pObject->ref = 1;
1002 pObject->pbMemory = pbBuffer;
1003 pObject->dwMemsize = cbBufferSize;
1004 pObject->dwCurPos = 0;
1006 pObject->lock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": StreamOnMemory.lock");
1007
1008 if (InterlockedCompareExchangePointer((void**)&This->pStream, pObject, NULL))
1009 {
1010 /* Some other thread set the stream first. */
1011 IStream_Release(&pObject->IStream_iface);
1013 }
1014
1015 return S_OK;
1016}
static const IStreamVtbl StreamOnMemory_Vtbl
Definition: stream.c:249

Referenced by stream_initialize_from_filehandle().

◆ IWICStreamImpl_LockRegion()

static HRESULT WINAPI IWICStreamImpl_LockRegion ( IWICStream iface,
ULARGE_INTEGER  libOffset,
ULARGE_INTEGER  cb,
DWORD  dwLockType 
)
static

Definition at line 873 of file stream.c.

875{
877 TRACE("(%p, %s, %s, %d)\n", This, wine_dbgstr_longlong(libOffset.QuadPart),
878 wine_dbgstr_longlong(cb.QuadPart), dwLockType);
879
880 if (!This->pStream) return WINCODEC_ERR_NOTINITIALIZED;
881 return IStream_LockRegion(This->pStream, libOffset, cb, dwLockType);
882}

◆ IWICStreamImpl_QueryInterface()

static HRESULT WINAPI IWICStreamImpl_QueryInterface ( IWICStream iface,
REFIID  iid,
void **  ppv 
)
static

Definition at line 757 of file stream.c.

759{
761 TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
762
763 if (!ppv) return E_INVALIDARG;
764
765 if (IsEqualIID(&IID_IUnknown, iid) || IsEqualIID(&IID_IStream, iid) ||
766 IsEqualIID(&IID_ISequentialStream, iid) || IsEqualIID(&IID_IWICStream, iid))
767 {
768 *ppv = &This->IWICStream_iface;
769 IUnknown_AddRef((IUnknown*)*ppv);
770 return S_OK;
771 }
772 else
773 {
774 *ppv = NULL;
775 return E_NOINTERFACE;
776 }
777}
const GUID IID_IUnknown
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define debugstr_guid
Definition: kernel32.h:35
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define E_NOINTERFACE
Definition: winerror.h:2364

◆ IWICStreamImpl_Read()

static HRESULT WINAPI IWICStreamImpl_Read ( IWICStream iface,
void pv,
ULONG  cb,
ULONG pcbRead 
)
static

Definition at line 803 of file stream.c.

805{
807 TRACE("(%p, %p, %u, %p)\n", This, pv, cb, pcbRead);
808
809 if (!This->pStream) return WINCODEC_ERR_NOTINITIALIZED;
810 return IStream_Read(This->pStream, pv, cb, pcbRead);
811}

◆ IWICStreamImpl_Release()

static ULONG WINAPI IWICStreamImpl_Release ( IWICStream iface)
static

Definition at line 789 of file stream.c.

790{
793
794 TRACE("(%p) refcount=%u\n", iface, ref);
795
796 if (ref == 0) {
797 if (This->pStream) IStream_Release(This->pStream);
799 }
800 return ref;
801}
#define InterlockedDecrement
Definition: armddk.h:52
#define HeapFree(x, y, z)
Definition: compat.h:735

◆ IWICStreamImpl_Revert()

static HRESULT WINAPI IWICStreamImpl_Revert ( IWICStream iface)
static

Definition at line 864 of file stream.c.

865{
867 TRACE("(%p)\n", This);
868
869 if (!This->pStream) return WINCODEC_ERR_NOTINITIALIZED;
870 return IStream_Revert(This->pStream);
871}

◆ IWICStreamImpl_Seek()

static HRESULT WINAPI IWICStreamImpl_Seek ( IWICStream iface,
LARGE_INTEGER  dlibMove,
DWORD  dwOrigin,
ULARGE_INTEGER plibNewPosition 
)
static

Definition at line 823 of file stream.c.

825{
827 TRACE("(%p, %s, %d, %p)\n", This, wine_dbgstr_longlong(dlibMove.QuadPart),
828 dwOrigin, plibNewPosition);
829
830 if (!This->pStream) return WINCODEC_ERR_NOTINITIALIZED;
831 return IStream_Seek(This->pStream, dlibMove, dwOrigin, plibNewPosition);
832}
LONGLONG QuadPart
Definition: typedefs.h:114

◆ IWICStreamImpl_SetSize()

static HRESULT WINAPI IWICStreamImpl_SetSize ( IWICStream iface,
ULARGE_INTEGER  libNewSize 
)
static

Definition at line 834 of file stream.c.

836{
838 TRACE("(%p, %s)\n", This, wine_dbgstr_longlong(libNewSize.QuadPart));
839
840 if (!This->pStream) return WINCODEC_ERR_NOTINITIALIZED;
841 return IStream_SetSize(This->pStream, libNewSize);
842}

◆ IWICStreamImpl_Stat()

static HRESULT WINAPI IWICStreamImpl_Stat ( IWICStream iface,
STATSTG *  pstatstg,
DWORD  grfStatFlag 
)
static

Definition at line 895 of file stream.c.

897{
899 TRACE("(%p, %p, %#x)\n", This, pstatstg, grfStatFlag);
900
901 if (!This->pStream) return WINCODEC_ERR_NOTINITIALIZED;
902 return IStream_Stat(This->pStream, pstatstg, grfStatFlag);
903}

◆ IWICStreamImpl_UnlockRegion()

static HRESULT WINAPI IWICStreamImpl_UnlockRegion ( IWICStream iface,
ULARGE_INTEGER  libOffset,
ULARGE_INTEGER  cb,
DWORD  dwLockType 
)
static

Definition at line 884 of file stream.c.

886{
888 TRACE("(%p, %s, %s, %d)\n", This, wine_dbgstr_longlong(libOffset.QuadPart),
889 wine_dbgstr_longlong(cb.QuadPart), dwLockType);
890
891 if (!This->pStream) return WINCODEC_ERR_NOTINITIALIZED;
892 return IStream_UnlockRegion(This->pStream, libOffset, cb, dwLockType);
893}

◆ IWICStreamImpl_Write()

static HRESULT WINAPI IWICStreamImpl_Write ( IWICStream iface,
void const pv,
ULONG  cb,
ULONG pcbWritten 
)
static

Definition at line 813 of file stream.c.

815{
817 TRACE("(%p, %p, %u, %p)\n", This, pv, cb, pcbWritten);
818
819 if (!This->pStream) return WINCODEC_ERR_NOTINITIALIZED;
820 return IStream_Write(This->pStream, pv, cb, pcbWritten);
821}

◆ map_file()

static HRESULT map_file ( HANDLE  file,
HANDLE map,
void **  mem,
LARGE_INTEGER size 
)
static

Definition at line 1018 of file stream.c.

1019{
1020 *map = NULL;
1022 if (size->u.HighPart)
1023 {
1024 WARN("file too large\n");
1025 return E_FAIL;
1026 }
1027 if (!(*map = CreateFileMappingW(file, NULL, PAGE_READONLY, 0, size->u.LowPart, NULL)))
1028 {
1030 }
1031 if (!(*mem = MapViewOfFile(*map, FILE_MAP_READ, 0, 0, size->u.LowPart)))
1032 {
1033 CloseHandle(*map);
1035 }
1036 return S_OK;
1037}
#define WARN(fmt,...)
Definition: precomp.h:61
Definition: _map.h:48
#define E_FAIL
Definition: ddrawi.h:102
#define CloseHandle
Definition: compat.h:739
#define PAGE_READONLY
Definition: compat.h:138
#define CreateFileMappingW(a, b, c, d, e, f)
Definition: compat.h:744
#define FILE_MAP_READ
Definition: compat.h:776
#define GetFileSizeEx
Definition: compat.h:757
#define MapViewOfFile
Definition: compat.h:745
GLsizeiptr size
Definition: glext.h:5919
Definition: fci.c:127
Definition: mem.c:349
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92

Referenced by stream_initialize_from_filehandle().

◆ stream_initialize_from_filehandle()

HRESULT stream_initialize_from_filehandle ( IWICStream iface,
HANDLE  file 
)

Definition at line 1039 of file stream.c.

1040{
1044 HANDLE map;
1045 void *mem;
1047 HRESULT hr;
1048 TRACE("(%p,%p)\n", iface, file);
1049
1050 if (This->pStream) return WINCODEC_ERR_WRONGSTATE;
1051
1052 hr = map_file(file, &map, &mem, &size);
1053 if (FAILED(hr)) return hr;
1054
1056 if (FAILED(hr)) goto error;
1057
1059 if (FAILED(hr)) goto error;
1060
1062 if (!pObject)
1063 {
1064 hr = E_OUTOFMEMORY;
1065 goto error;
1066 }
1067 pObject->IStream_iface.lpVtbl = &StreamOnFileHandle_Vtbl;
1068 pObject->ref = 1;
1069 pObject->map = map;
1070 pObject->mem = mem;
1071 pObject->stream = stream;
1072
1073 if (InterlockedCompareExchangePointer((void**)&This->pStream, pObject, NULL))
1074 {
1075 /* Some other thread set the stream first. */
1076 IStream_Release(&pObject->IStream_iface);
1078 }
1079 return S_OK;
1080
1081error:
1082 if (stream) IWICStream_Release(stream);
1085 return hr;
1086}
#define UnmapViewOfFile
Definition: compat.h:746
static HRESULT map_file(HANDLE file, HANDLE *map, void **mem, LARGE_INTEGER *size)
Definition: stream.c:1018
static const IStreamVtbl StreamOnFileHandle_Vtbl
Definition: stream.c:419
HRESULT StreamImpl_Create(IWICStream **stream)
Definition: stream.c:1150
static HRESULT WINAPI IWICStreamImpl_InitializeFromMemory(IWICStream *iface, BYTE *pbBuffer, DWORD cbBufferSize)
Definition: stream.c:987
#define FAILED(hr)
Definition: intsafe.h:51
#define error(str)
Definition: mkdosfs.c:1605

Referenced by ImagingFactory_CreateDecoderFromFileHandle().

◆ StreamImpl_Create()

HRESULT StreamImpl_Create ( IWICStream **  stream)

Definition at line 1150 of file stream.c.

1151{
1153
1154 if( !stream ) return E_INVALIDARG;
1155
1157 if( !pObject ) {
1158 *stream = NULL;
1159 return E_OUTOFMEMORY;
1160 }
1161
1162 pObject->IWICStream_iface.lpVtbl = &WICStream_Vtbl;
1163 pObject->ref = 1;
1164 pObject->pStream = NULL;
1165
1166 *stream = &pObject->IWICStream_iface;
1167
1168 return S_OK;
1169}
static const IWICStreamVtbl WICStream_Vtbl
Definition: stream.c:1124

Referenced by IcoDecoder_GetFrame(), ImagingFactory_CreateDecoderFromFileHandle(), ImagingFactory_CreateDecoderFromFilename(), ImagingFactory_CreateStream(), and stream_initialize_from_filehandle().

◆ StreamOnFileHandle_AddRef()

static ULONG WINAPI StreamOnFileHandle_AddRef ( IStream iface)
static

Definition at line 309 of file stream.c.

310{
313
314 TRACE("(%p) refcount=%u\n", iface, ref);
315
316 return ref;
317}
static StreamOnFileHandle * StreamOnFileHandle_from_IStream(IStream *iface)
Definition: stream.c:283

◆ StreamOnFileHandle_Clone()

static HRESULT WINAPI StreamOnFileHandle_Clone ( IStream iface,
IStream **  ppstm 
)
static

Definition at line 412 of file stream.c.

414{
415 TRACE("(%p, %p)\n", iface, ppstm);
416 return E_NOTIMPL;
417}
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ StreamOnFileHandle_Commit()

static HRESULT WINAPI StreamOnFileHandle_Commit ( IStream iface,
DWORD  grfCommitFlags 
)
static

Definition at line 374 of file stream.c.

376{
377 TRACE("(%p, %#x)\n", iface, grfCommitFlags);
378 return E_NOTIMPL;
379}

◆ StreamOnFileHandle_CopyTo()

static HRESULT WINAPI StreamOnFileHandle_CopyTo ( IStream iface,
IStream pstm,
ULARGE_INTEGER  cb,
ULARGE_INTEGER pcbRead,
ULARGE_INTEGER pcbWritten 
)
static

Definition at line 367 of file stream.c.

369{
370 TRACE("(%p, %p, %s, %p, %p)\n", iface, pstm, wine_dbgstr_longlong(cb.QuadPart), pcbRead, pcbWritten);
371 return E_NOTIMPL;
372}

◆ StreamOnFileHandle_from_IStream()

static StreamOnFileHandle * StreamOnFileHandle_from_IStream ( IStream iface)
inlinestatic

◆ StreamOnFileHandle_LockRegion()

static HRESULT WINAPI StreamOnFileHandle_LockRegion ( IStream iface,
ULARGE_INTEGER  libOffset,
ULARGE_INTEGER  cb,
DWORD  dwLockType 
)
static

Definition at line 387 of file stream.c.

389{
390 TRACE("(%p, %s, %s, %d)\n", iface, wine_dbgstr_longlong(libOffset.QuadPart),
391 wine_dbgstr_longlong(cb.QuadPart), dwLockType);
392 return E_NOTIMPL;
393}

◆ StreamOnFileHandle_QueryInterface()

static HRESULT WINAPI StreamOnFileHandle_QueryInterface ( IStream iface,
REFIID  iid,
void **  ppv 
)
static

Definition at line 288 of file stream.c.

290{
291 TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
292
293 if (!ppv) return E_INVALIDARG;
294
295 if (IsEqualIID(&IID_IUnknown, iid) || IsEqualIID(&IID_IStream, iid) ||
296 IsEqualIID(&IID_ISequentialStream, iid))
297 {
298 *ppv = iface;
299 IUnknown_AddRef((IUnknown*)*ppv);
300 return S_OK;
301 }
302 else
303 {
304 *ppv = NULL;
305 return E_NOINTERFACE;
306 }
307}

◆ StreamOnFileHandle_Read()

static HRESULT WINAPI StreamOnFileHandle_Read ( IStream iface,
void pv,
ULONG  cb,
ULONG pcbRead 
)
static

Definition at line 335 of file stream.c.

337{
339 TRACE("(%p, %p, %u, %p)\n", This, pv, cb, pcbRead);
340
341 return IWICStream_Read(This->stream, pv, cb, pcbRead);
342}

◆ StreamOnFileHandle_Release()

static ULONG WINAPI StreamOnFileHandle_Release ( IStream iface)
static

Definition at line 319 of file stream.c.

320{
323
324 TRACE("(%p) refcount=%u\n", iface, ref);
325
326 if (ref == 0) {
327 IWICStream_Release(This->stream);
328 UnmapViewOfFile(This->mem);
329 CloseHandle(This->map);
331 }
332 return ref;
333}

◆ StreamOnFileHandle_Revert()

static HRESULT WINAPI StreamOnFileHandle_Revert ( IStream iface)
static

Definition at line 381 of file stream.c.

382{
383 TRACE("(%p)\n", iface);
384 return E_NOTIMPL;
385}

◆ StreamOnFileHandle_Seek()

static HRESULT WINAPI StreamOnFileHandle_Seek ( IStream iface,
LARGE_INTEGER  dlibMove,
DWORD  dwOrigin,
ULARGE_INTEGER plibNewPosition 
)
static

Definition at line 351 of file stream.c.

353{
355 TRACE("(%p, %s, %d, %p)\n", This, wine_dbgstr_longlong(dlibMove.QuadPart), dwOrigin, plibNewPosition);
356
357 return IWICStream_Seek(This->stream, dlibMove, dwOrigin, plibNewPosition);
358}

◆ StreamOnFileHandle_SetSize()

static HRESULT WINAPI StreamOnFileHandle_SetSize ( IStream iface,
ULARGE_INTEGER  libNewSize 
)
static

Definition at line 360 of file stream.c.

362{
363 TRACE("(%p, %s)\n", iface, wine_dbgstr_longlong(libNewSize.QuadPart));
364 return E_NOTIMPL;
365}

◆ StreamOnFileHandle_Stat()

static HRESULT WINAPI StreamOnFileHandle_Stat ( IStream iface,
STATSTG *  pstatstg,
DWORD  grfStatFlag 
)
static

Definition at line 403 of file stream.c.

405{
407 TRACE("(%p, %p, %#x)\n", This, pstatstg, grfStatFlag);
408
409 return IWICStream_Stat(This->stream, pstatstg, grfStatFlag);
410}

◆ StreamOnFileHandle_UnlockRegion()

static HRESULT WINAPI StreamOnFileHandle_UnlockRegion ( IStream iface,
ULARGE_INTEGER  libOffset,
ULARGE_INTEGER  cb,
DWORD  dwLockType 
)
static

Definition at line 395 of file stream.c.

397{
398 TRACE("(%p, %s, %s, %d)\n", iface, wine_dbgstr_longlong(libOffset.QuadPart),
399 wine_dbgstr_longlong(cb.QuadPart), dwLockType);
400 return E_NOTIMPL;
401}

◆ StreamOnFileHandle_Write()

static HRESULT WINAPI StreamOnFileHandle_Write ( IStream iface,
void const pv,
ULONG  cb,
ULONG pcbWritten 
)
static

Definition at line 344 of file stream.c.

346{
347 ERR("(%p, %p, %u, %p)\n", iface, pv, cb, pcbWritten);
349}
#define ERR(fmt,...)
Definition: precomp.h:57
#define ERROR_ACCESS_DENIED
Definition: compat.h:97

◆ StreamOnMemory_AddRef()

static ULONG WINAPI StreamOnMemory_AddRef ( IStream iface)
static

Definition at line 74 of file stream.c.

75{
78
79 TRACE("(%p) refcount=%u\n", iface, ref);
80
81 return ref;
82}
static StreamOnMemory * StreamOnMemory_from_IStream(IStream *iface)
Definition: stream.c:48

◆ StreamOnMemory_Clone()

static HRESULT WINAPI StreamOnMemory_Clone ( IStream iface,
IStream **  ppstm 
)
static

Definition at line 241 of file stream.c.

243{
244 TRACE("(%p, %p)\n", iface, ppstm);
245 return E_NOTIMPL;
246}

◆ StreamOnMemory_Commit()

static HRESULT WINAPI StreamOnMemory_Commit ( IStream iface,
DWORD  grfCommitFlags 
)
static

Definition at line 193 of file stream.c.

195{
196 TRACE("(%p, %#x)\n", iface, grfCommitFlags);
197 return E_NOTIMPL;
198}

◆ StreamOnMemory_CopyTo()

static HRESULT WINAPI StreamOnMemory_CopyTo ( IStream iface,
IStream pstm,
ULARGE_INTEGER  cb,
ULARGE_INTEGER pcbRead,
ULARGE_INTEGER pcbWritten 
)
static

Definition at line 185 of file stream.c.

187{
188 TRACE("(%p, %p, %s, %p, %p)\n", iface, pstm, wine_dbgstr_longlong(cb.QuadPart), pcbRead, pcbWritten);
189 return E_NOTIMPL;
190}

◆ StreamOnMemory_from_IStream()

static StreamOnMemory * StreamOnMemory_from_IStream ( IStream iface)
inlinestatic

◆ StreamOnMemory_LockRegion()

static HRESULT WINAPI StreamOnMemory_LockRegion ( IStream iface,
ULARGE_INTEGER  libOffset,
ULARGE_INTEGER  cb,
DWORD  dwLockType 
)
static

Definition at line 208 of file stream.c.

210{
211 TRACE("(%p, %s, %s, %d)\n", iface, wine_dbgstr_longlong(libOffset.QuadPart),
212 wine_dbgstr_longlong(cb.QuadPart), dwLockType);
213 return E_NOTIMPL;
214}

◆ StreamOnMemory_QueryInterface()

static HRESULT WINAPI StreamOnMemory_QueryInterface ( IStream iface,
REFIID  iid,
void **  ppv 
)
static

Definition at line 53 of file stream.c.

55{
56 TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
57
58 if (!ppv) return E_INVALIDARG;
59
60 if (IsEqualIID(&IID_IUnknown, iid) || IsEqualIID(&IID_IStream, iid) ||
61 IsEqualIID(&IID_ISequentialStream, iid))
62 {
63 *ppv = iface;
64 IUnknown_AddRef((IUnknown*)*ppv);
65 return S_OK;
66 }
67 else
68 {
69 *ppv = NULL;
70 return E_NOINTERFACE;
71 }
72}

◆ StreamOnMemory_Read()

static HRESULT WINAPI StreamOnMemory_Read ( IStream iface,
void pv,
ULONG  cb,
ULONG pcbRead 
)
static

Definition at line 99 of file stream.c.

101{
103 ULONG uBytesRead;
104
105 TRACE("(%p, %p, %u, %p)\n", This, pv, cb, pcbRead);
106
107 if (!pv) return E_INVALIDARG;
108
110 uBytesRead = min(cb, This->dwMemsize - This->dwCurPos);
111 memmove(pv, This->pbMemory + This->dwCurPos, uBytesRead);
112 This->dwCurPos += uBytesRead;
114
115 if (pcbRead) *pcbRead = uBytesRead;
116
117 return S_OK;
118}
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
#define min(a, b)
Definition: monoChain.cc:55
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)

◆ StreamOnMemory_Release()

static ULONG WINAPI StreamOnMemory_Release ( IStream iface)
static

Definition at line 84 of file stream.c.

85{
88
89 TRACE("(%p) refcount=%u\n", iface, ref);
90
91 if (ref == 0) {
92 This->lock.DebugInfo->Spare[0] = 0;
95 }
96 return ref;
97}
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)

◆ StreamOnMemory_Revert()

static HRESULT WINAPI StreamOnMemory_Revert ( IStream iface)
static

Definition at line 201 of file stream.c.

202{
203 TRACE("(%p)\n", iface);
204 return E_NOTIMPL;
205}

◆ StreamOnMemory_Seek()

static HRESULT WINAPI StreamOnMemory_Seek ( IStream iface,
LARGE_INTEGER  dlibMove,
DWORD  dwOrigin,
ULARGE_INTEGER plibNewPosition 
)
static

Definition at line 145 of file stream.c.

147{
149 LARGE_INTEGER NewPosition;
151
152 TRACE("(%p, %s, %d, %p)\n", This, wine_dbgstr_longlong(dlibMove.QuadPart), dwOrigin, plibNewPosition);
153
155 if (dwOrigin == STREAM_SEEK_SET) NewPosition.QuadPart = dlibMove.QuadPart;
156 else if (dwOrigin == STREAM_SEEK_CUR) NewPosition.QuadPart = This->dwCurPos + dlibMove.QuadPart;
157 else if (dwOrigin == STREAM_SEEK_END) NewPosition.QuadPart = This->dwMemsize + dlibMove.QuadPart;
158 else hr = E_INVALIDARG;
159
160 if (SUCCEEDED(hr)) {
161 if (NewPosition.u.HighPart) hr = HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW);
162 else if (NewPosition.QuadPart > This->dwMemsize) hr = E_INVALIDARG;
163 else if (NewPosition.QuadPart < 0) hr = E_INVALIDARG;
164 }
165
166 if (SUCCEEDED(hr)) {
167 This->dwCurPos = NewPosition.u.LowPart;
168
169 if(plibNewPosition) plibNewPosition->QuadPart = This->dwCurPos;
170 }
172
173 return hr;
174}
struct _LARGE_INTEGER::@2302 u
#define ERROR_ARITHMETIC_OVERFLOW
Definition: winerror.h:351

◆ StreamOnMemory_SetSize()

static HRESULT WINAPI StreamOnMemory_SetSize ( IStream iface,
ULARGE_INTEGER  libNewSize 
)
static

Definition at line 177 of file stream.c.

179{
180 TRACE("(%p, %s)\n", iface, wine_dbgstr_longlong(libNewSize.QuadPart));
181 return E_NOTIMPL;
182}

◆ StreamOnMemory_Stat()

static HRESULT WINAPI StreamOnMemory_Stat ( IStream iface,
STATSTG *  pstatstg,
DWORD  grfStatFlag 
)
static

Definition at line 225 of file stream.c.

227{
229 TRACE("(%p, %p, %#x)\n", This, pstatstg, grfStatFlag);
230
231 if (!pstatstg) return E_INVALIDARG;
232
233 ZeroMemory(pstatstg, sizeof(STATSTG));
234 pstatstg->type = STGTY_STREAM;
235 pstatstg->cbSize.QuadPart = This->dwMemsize;
236
237 return S_OK;
238}
#define ZeroMemory
Definition: winbase.h:1737

◆ StreamOnMemory_UnlockRegion()

static HRESULT WINAPI StreamOnMemory_UnlockRegion ( IStream iface,
ULARGE_INTEGER  libOffset,
ULARGE_INTEGER  cb,
DWORD  dwLockType 
)
static

Definition at line 217 of file stream.c.

219{
220 TRACE("(%p, %s, %s, %d)\n", iface, wine_dbgstr_longlong(libOffset.QuadPart),
221 wine_dbgstr_longlong(cb.QuadPart), dwLockType);
222 return E_NOTIMPL;
223}

◆ StreamOnMemory_Write()

static HRESULT WINAPI StreamOnMemory_Write ( IStream iface,
void const pv,
ULONG  cb,
ULONG pcbWritten 
)
static

Definition at line 120 of file stream.c.

122{
124 HRESULT hr;
125
126 TRACE("(%p, %p, %u, %p)\n", This, pv, cb, pcbWritten);
127
128 if (!pv) return E_INVALIDARG;
129
131 if (cb > This->dwMemsize - This->dwCurPos) {
133 }
134 else {
135 memmove(This->pbMemory + This->dwCurPos, pv, cb);
136 This->dwCurPos += cb;
137 hr = S_OK;
138 if (pcbWritten) *pcbWritten = cb;
139 }
141
142 return hr;
143}
#define STG_E_MEDIUMFULL
Definition: winerror.h:2581

◆ StreamOnStreamRange_AddRef()

static ULONG WINAPI StreamOnStreamRange_AddRef ( IStream iface)
static

Definition at line 484 of file stream.c.

485{
488
489 TRACE("(%p) refcount=%u\n", iface, ref);
490
491 return ref;
492}
static StreamOnStreamRange * StreamOnStreamRange_from_IStream(IStream *iface)
Definition: stream.c:458

◆ StreamOnStreamRange_Clone()

static HRESULT WINAPI StreamOnStreamRange_Clone ( IStream iface,
IStream **  ppstm 
)
static

Definition at line 711 of file stream.c.

713{
714 TRACE("(%p, %p)\n", iface, ppstm);
715 return E_NOTIMPL;
716}

◆ StreamOnStreamRange_Commit()

static HRESULT WINAPI StreamOnStreamRange_Commit ( IStream iface,
DWORD  grfCommitFlags 
)
static

Definition at line 655 of file stream.c.

657{
658 TRACE("(%p, %#x)\n", iface, grfCommitFlags);
659 return E_NOTIMPL;
660}

◆ StreamOnStreamRange_CopyTo()

static HRESULT WINAPI StreamOnStreamRange_CopyTo ( IStream iface,
IStream pstm,
ULARGE_INTEGER  cb,
ULARGE_INTEGER pcbRead,
ULARGE_INTEGER pcbWritten 
)
static

Definition at line 646 of file stream.c.

648{
649 TRACE("(%p, %p, %s, %p, %p)\n", iface, pstm, wine_dbgstr_longlong(cb.QuadPart),
650 pcbRead, pcbWritten);
651 return E_NOTIMPL;
652}

◆ StreamOnStreamRange_from_IStream()

static StreamOnStreamRange * StreamOnStreamRange_from_IStream ( IStream iface)
inlinestatic

◆ StreamOnStreamRange_LockRegion()

static HRESULT WINAPI StreamOnStreamRange_LockRegion ( IStream iface,
ULARGE_INTEGER  libOffset,
ULARGE_INTEGER  cb,
DWORD  dwLockType 
)
static

Definition at line 670 of file stream.c.

672{
673 TRACE("(%p, %s, %s, %d)\n", iface, wine_dbgstr_longlong(libOffset.QuadPart),
674 wine_dbgstr_longlong(cb.QuadPart), dwLockType);
675 return E_NOTIMPL;
676}

◆ StreamOnStreamRange_QueryInterface()

static HRESULT WINAPI StreamOnStreamRange_QueryInterface ( IStream iface,
REFIID  iid,
void **  ppv 
)
static

Definition at line 463 of file stream.c.

465{
466 TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
467
468 if (!ppv) return E_INVALIDARG;
469
470 if (IsEqualIID(&IID_IUnknown, iid) || IsEqualIID(&IID_IStream, iid) ||
471 IsEqualIID(&IID_ISequentialStream, iid))
472 {
473 *ppv = iface;
474 IUnknown_AddRef((IUnknown*)*ppv);
475 return S_OK;
476 }
477 else
478 {
479 *ppv = NULL;
480 return E_NOINTERFACE;
481 }
482}

◆ StreamOnStreamRange_Read()

static HRESULT WINAPI StreamOnStreamRange_Read ( IStream iface,
void pv,
ULONG  cb,
ULONG pcbRead 
)
static

Definition at line 510 of file stream.c.

512{
514 ULONG uBytesRead=0;
515 HRESULT hr;
516 ULARGE_INTEGER OldPosition;
517 LARGE_INTEGER SetPosition;
518
519 TRACE("(%p, %p, %u, %p)\n", This, pv, cb, pcbRead);
520
521 if (!pv) return E_INVALIDARG;
522
524 SetPosition.QuadPart = 0;
525 hr = IStream_Seek(This->stream, SetPosition, STREAM_SEEK_CUR, &OldPosition);
526 if (SUCCEEDED(hr))
527 {
528 SetPosition.QuadPart = This->pos.QuadPart + This->offset.QuadPart;
529 hr = IStream_Seek(This->stream, SetPosition, STREAM_SEEK_SET, NULL);
530 }
531 if (SUCCEEDED(hr))
532 {
533 if (This->pos.QuadPart + cb > This->max_size.QuadPart)
534 {
535 /* This would read past the end of the stream. */
536 if (This->pos.QuadPart > This->max_size.QuadPart)
537 cb = 0;
538 else
539 cb = This->max_size.QuadPart - This->pos.QuadPart;
540 }
541 hr = IStream_Read(This->stream, pv, cb, &uBytesRead);
542 SetPosition.QuadPart = OldPosition.QuadPart;
543 IStream_Seek(This->stream, SetPosition, STREAM_SEEK_SET, NULL);
544 }
545 if (SUCCEEDED(hr))
546 This->pos.QuadPart += uBytesRead;
548
549 if (SUCCEEDED(hr) && pcbRead) *pcbRead = uBytesRead;
550
551 return hr;
552}

◆ StreamOnStreamRange_Release()

static ULONG WINAPI StreamOnStreamRange_Release ( IStream iface)
static

Definition at line 494 of file stream.c.

495{
498
499 TRACE("(%p) refcount=%u\n", iface, ref);
500
501 if (ref == 0) {
502 This->lock.DebugInfo->Spare[0] = 0;
504 IStream_Release(This->stream);
506 }
507 return ref;
508}

◆ StreamOnStreamRange_Revert()

static HRESULT WINAPI StreamOnStreamRange_Revert ( IStream iface)
static

Definition at line 663 of file stream.c.

664{
665 TRACE("(%p)\n", iface);
666 return E_NOTIMPL;
667}

◆ StreamOnStreamRange_Seek()

static HRESULT WINAPI StreamOnStreamRange_Seek ( IStream iface,
LARGE_INTEGER  dlibMove,
DWORD  dwOrigin,
ULARGE_INTEGER plibNewPosition 
)
static

Definition at line 597 of file stream.c.

599{
601 ULARGE_INTEGER NewPosition, actual_size;
603 STATSTG statstg;
604 TRACE("(%p, %s, %d, %p)\n", This, wine_dbgstr_longlong(dlibMove.QuadPart), dwOrigin, plibNewPosition);
605
607 actual_size = This->max_size;
608 if (dwOrigin == STREAM_SEEK_SET)
609 NewPosition.QuadPart = dlibMove.QuadPart;
610 else if (dwOrigin == STREAM_SEEK_CUR)
611 NewPosition.QuadPart = This->pos.QuadPart + dlibMove.QuadPart;
612 else if (dwOrigin == STREAM_SEEK_END)
613 {
614 hr = IStream_Stat(This->stream, &statstg, STATFLAG_NONAME);
615 if (SUCCEEDED(hr))
616 {
617 if (This->max_size.QuadPart + This->offset.QuadPart > statstg.cbSize.QuadPart)
618 actual_size.QuadPart = statstg.cbSize.QuadPart - This->offset.QuadPart;
619 NewPosition.QuadPart = dlibMove.QuadPart + actual_size.QuadPart;
620 }
621 }
622 else hr = E_INVALIDARG;
623
624 if (SUCCEEDED(hr) && (NewPosition.u.HighPart != 0 || NewPosition.QuadPart > actual_size.QuadPart))
626
627 if (SUCCEEDED(hr)) {
628 This->pos.QuadPart = NewPosition.QuadPart;
629
630 if(plibNewPosition) plibNewPosition->QuadPart = This->pos.QuadPart;
631 }
633
634 return hr;
635}
struct _ULARGE_INTEGER::@4140 u
#define WINCODEC_ERR_VALUEOUTOFRANGE
Definition: winerror.h:3282

◆ StreamOnStreamRange_SetSize()

static HRESULT WINAPI StreamOnStreamRange_SetSize ( IStream iface,
ULARGE_INTEGER  libNewSize 
)
static

Definition at line 638 of file stream.c.

640{
641 TRACE("(%p, %s)\n", iface, wine_dbgstr_longlong(libNewSize.QuadPart));
642 return E_NOTIMPL;
643}

◆ StreamOnStreamRange_Stat()

static HRESULT WINAPI StreamOnStreamRange_Stat ( IStream iface,
STATSTG *  pstatstg,
DWORD  grfStatFlag 
)
static

Definition at line 687 of file stream.c.

689{
691 HRESULT hr;
692 TRACE("(%p, %p, %#x)\n", This, pstatstg, grfStatFlag);
693
694 if (!pstatstg) return E_INVALIDARG;
695
697 hr = IStream_Stat(This->stream, pstatstg, grfStatFlag);
698 if (SUCCEEDED(hr))
699 {
700 pstatstg->cbSize.QuadPart -= This->offset.QuadPart;
701 if (This->max_size.QuadPart < pstatstg->cbSize.QuadPart)
702 pstatstg->cbSize.QuadPart = This->max_size.QuadPart;
703 }
704
706
707 return hr;
708}

◆ StreamOnStreamRange_UnlockRegion()

static HRESULT WINAPI StreamOnStreamRange_UnlockRegion ( IStream iface,
ULARGE_INTEGER  libOffset,
ULARGE_INTEGER  cb,
DWORD  dwLockType 
)
static

Definition at line 679 of file stream.c.

681{
682 TRACE("(%p, %s, %s, %d)\n", iface, wine_dbgstr_longlong(libOffset.QuadPart),
683 wine_dbgstr_longlong(cb.QuadPart), dwLockType);
684 return E_NOTIMPL;
685}

◆ StreamOnStreamRange_Write()

static HRESULT WINAPI StreamOnStreamRange_Write ( IStream iface,
void const pv,
ULONG  cb,
ULONG pcbWritten 
)
static

Definition at line 554 of file stream.c.

556{
558 HRESULT hr;
559 ULARGE_INTEGER OldPosition;
560 LARGE_INTEGER SetPosition;
561 ULONG uBytesWritten=0;
562 TRACE("(%p, %p, %u, %p)\n", This, pv, cb, pcbWritten);
563
564 if (!pv) return E_INVALIDARG;
565
567 SetPosition.QuadPart = 0;
568 hr = IStream_Seek(This->stream, SetPosition, STREAM_SEEK_CUR, &OldPosition);
569 if (SUCCEEDED(hr))
570 {
571 SetPosition.QuadPart = This->pos.QuadPart + This->offset.QuadPart;
572 hr = IStream_Seek(This->stream, SetPosition, STREAM_SEEK_SET, NULL);
573 }
574 if (SUCCEEDED(hr))
575 {
576 if (This->pos.QuadPart + cb > This->max_size.QuadPart)
577 {
578 /* This would read past the end of the stream. */
579 if (This->pos.QuadPart > This->max_size.QuadPart)
580 cb = 0;
581 else
582 cb = This->max_size.QuadPart - This->pos.QuadPart;
583 }
584 hr = IStream_Write(This->stream, pv, cb, &uBytesWritten);
585 SetPosition.QuadPart = OldPosition.QuadPart;
586 IStream_Seek(This->stream, SetPosition, STREAM_SEEK_SET, NULL);
587 }
588 if (SUCCEEDED(hr))
589 This->pos.QuadPart += uBytesWritten;
591
592 if (SUCCEEDED(hr) && pcbWritten) *pcbWritten = uBytesWritten;
593
594 return hr;
595}

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( wincodecs  )

Variable Documentation

◆ StreamOnFileHandle_Vtbl

const IStreamVtbl StreamOnFileHandle_Vtbl
static
Initial value:
=
{
}
static HRESULT WINAPI StreamOnFileHandle_Revert(IStream *iface)
Definition: stream.c:381
static HRESULT WINAPI StreamOnFileHandle_Clone(IStream *iface, IStream **ppstm)
Definition: stream.c:412
static HRESULT WINAPI StreamOnFileHandle_Read(IStream *iface, void *pv, ULONG cb, ULONG *pcbRead)
Definition: stream.c:335
static HRESULT WINAPI StreamOnFileHandle_Write(IStream *iface, void const *pv, ULONG cb, ULONG *pcbWritten)
Definition: stream.c:344
static HRESULT WINAPI StreamOnFileHandle_Seek(IStream *iface, LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
Definition: stream.c:351
static ULONG WINAPI StreamOnFileHandle_Release(IStream *iface)
Definition: stream.c:319
static HRESULT WINAPI StreamOnFileHandle_SetSize(IStream *iface, ULARGE_INTEGER libNewSize)
Definition: stream.c:360
static HRESULT WINAPI StreamOnFileHandle_Commit(IStream *iface, DWORD grfCommitFlags)
Definition: stream.c:374
static HRESULT WINAPI StreamOnFileHandle_Stat(IStream *iface, STATSTG *pstatstg, DWORD grfStatFlag)
Definition: stream.c:403
static HRESULT WINAPI StreamOnFileHandle_LockRegion(IStream *iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
Definition: stream.c:387
static HRESULT WINAPI StreamOnFileHandle_UnlockRegion(IStream *iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
Definition: stream.c:395
static HRESULT WINAPI StreamOnFileHandle_QueryInterface(IStream *iface, REFIID iid, void **ppv)
Definition: stream.c:288
static ULONG WINAPI StreamOnFileHandle_AddRef(IStream *iface)
Definition: stream.c:309
static HRESULT WINAPI StreamOnFileHandle_CopyTo(IStream *iface, IStream *pstm, ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten)
Definition: stream.c:367

Definition at line 419 of file stream.c.

Referenced by stream_initialize_from_filehandle().

◆ StreamOnMemory_Vtbl

const IStreamVtbl StreamOnMemory_Vtbl
static
Initial value:
=
{
}
static HRESULT WINAPI StreamOnMemory_Write(IStream *iface, void const *pv, ULONG cb, ULONG *pcbWritten)
Definition: stream.c:120
static HRESULT WINAPI StreamOnMemory_UnlockRegion(IStream *iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
Definition: stream.c:217
static HRESULT WINAPI StreamOnMemory_CopyTo(IStream *iface, IStream *pstm, ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten)
Definition: stream.c:185
static HRESULT WINAPI StreamOnMemory_SetSize(IStream *iface, ULARGE_INTEGER libNewSize)
Definition: stream.c:177
static HRESULT WINAPI StreamOnMemory_QueryInterface(IStream *iface, REFIID iid, void **ppv)
Definition: stream.c:53
static HRESULT WINAPI StreamOnMemory_Clone(IStream *iface, IStream **ppstm)
Definition: stream.c:241
static HRESULT WINAPI StreamOnMemory_Stat(IStream *iface, STATSTG *pstatstg, DWORD grfStatFlag)
Definition: stream.c:225
static HRESULT WINAPI StreamOnMemory_Read(IStream *iface, void *pv, ULONG cb, ULONG *pcbRead)
Definition: stream.c:99
static HRESULT WINAPI StreamOnMemory_Seek(IStream *iface, LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
Definition: stream.c:145
static HRESULT WINAPI StreamOnMemory_Revert(IStream *iface)
Definition: stream.c:201
static ULONG WINAPI StreamOnMemory_Release(IStream *iface)
Definition: stream.c:84
static HRESULT WINAPI StreamOnMemory_Commit(IStream *iface, DWORD grfCommitFlags)
Definition: stream.c:193
static HRESULT WINAPI StreamOnMemory_LockRegion(IStream *iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
Definition: stream.c:208
static ULONG WINAPI StreamOnMemory_AddRef(IStream *iface)
Definition: stream.c:74

Definition at line 249 of file stream.c.

Referenced by IWICStreamImpl_InitializeFromMemory().

◆ StreamOnStreamRange_Vtbl

const IStreamVtbl StreamOnStreamRange_Vtbl
static
Initial value:
=
{
}
static HRESULT WINAPI StreamOnStreamRange_SetSize(IStream *iface, ULARGE_INTEGER libNewSize)
Definition: stream.c:638
static HRESULT WINAPI StreamOnStreamRange_Seek(IStream *iface, LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
Definition: stream.c:597
static HRESULT WINAPI StreamOnStreamRange_Write(IStream *iface, void const *pv, ULONG cb, ULONG *pcbWritten)
Definition: stream.c:554
static ULONG WINAPI StreamOnStreamRange_AddRef(IStream *iface)
Definition: stream.c:484
static HRESULT WINAPI StreamOnStreamRange_Commit(IStream *iface, DWORD grfCommitFlags)
Definition: stream.c:655
static HRESULT WINAPI StreamOnStreamRange_Revert(IStream *iface)
Definition: stream.c:663
static HRESULT WINAPI StreamOnStreamRange_UnlockRegion(IStream *iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
Definition: stream.c:679
static HRESULT WINAPI StreamOnStreamRange_Read(IStream *iface, void *pv, ULONG cb, ULONG *pcbRead)
Definition: stream.c:510
static HRESULT WINAPI StreamOnStreamRange_LockRegion(IStream *iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
Definition: stream.c:670
static HRESULT WINAPI StreamOnStreamRange_Clone(IStream *iface, IStream **ppstm)
Definition: stream.c:711
static HRESULT WINAPI StreamOnStreamRange_QueryInterface(IStream *iface, REFIID iid, void **ppv)
Definition: stream.c:463
static ULONG WINAPI StreamOnStreamRange_Release(IStream *iface)
Definition: stream.c:494
static HRESULT WINAPI StreamOnStreamRange_Stat(IStream *iface, STATSTG *pstatstg, DWORD grfStatFlag)
Definition: stream.c:687
static HRESULT WINAPI StreamOnStreamRange_CopyTo(IStream *iface, IStream *pstm, ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten)
Definition: stream.c:646

Definition at line 718 of file stream.c.

Referenced by IWICStreamImpl_InitializeFromIStreamRegion().

◆ WICStream_Vtbl

const IWICStreamVtbl WICStream_Vtbl
static
Initial value:
=
{
}
static HRESULT WINAPI IWICStreamImpl_Revert(IWICStream *iface)
Definition: stream.c:864
static ULONG WINAPI IWICStreamImpl_Release(IWICStream *iface)
Definition: stream.c:789
static HRESULT WINAPI IWICStreamImpl_InitializeFromIStreamRegion(IWICStream *iface, IStream *pIStream, ULARGE_INTEGER ulOffset, ULARGE_INTEGER ulMaxSize)
Definition: stream.c:1088
static ULONG WINAPI IWICStreamImpl_AddRef(IWICStream *iface)
Definition: stream.c:779
static HRESULT WINAPI IWICStreamImpl_Seek(IWICStream *iface, LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
Definition: stream.c:823
static HRESULT WINAPI IWICStreamImpl_InitializeFromFilename(IWICStream *iface, LPCWSTR wzFileName, DWORD dwDesiredAccess)
Definition: stream.c:937
static HRESULT WINAPI IWICStreamImpl_Stat(IWICStream *iface, STATSTG *pstatstg, DWORD grfStatFlag)
Definition: stream.c:895
static HRESULT WINAPI IWICStreamImpl_Write(IWICStream *iface, void const *pv, ULONG cb, ULONG *pcbWritten)
Definition: stream.c:813
static HRESULT WINAPI IWICStreamImpl_SetSize(IWICStream *iface, ULARGE_INTEGER libNewSize)
Definition: stream.c:834
static HRESULT WINAPI IWICStreamImpl_Commit(IWICStream *iface, DWORD grfCommitFlags)
Definition: stream.c:854
static HRESULT WINAPI IWICStreamImpl_CopyTo(IWICStream *iface, IStream *pstm, ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten)
Definition: stream.c:844
static HRESULT WINAPI IWICStreamImpl_Clone(IWICStream *iface, IStream **ppstm)
Definition: stream.c:905
static HRESULT WINAPI IWICStreamImpl_Read(IWICStream *iface, void *pv, ULONG cb, ULONG *pcbRead)
Definition: stream.c:803
static HRESULT WINAPI IWICStreamImpl_QueryInterface(IWICStream *iface, REFIID iid, void **ppv)
Definition: stream.c:757
static HRESULT WINAPI IWICStreamImpl_InitializeFromIStream(IWICStream *iface, IStream *stream)
Definition: stream.c:915
static HRESULT WINAPI IWICStreamImpl_LockRegion(IWICStream *iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
Definition: stream.c:873
static HRESULT WINAPI IWICStreamImpl_UnlockRegion(IWICStream *iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
Definition: stream.c:884

Definition at line 1124 of file stream.c.

Referenced by StreamImpl_Create().