2009-08-18 17:48:49 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2009 Tony Wasserka
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winreg.h"
|
|
|
|
#include "objbase.h"
|
2010-04-27 17:20:42 +02:00
|
|
|
#include "shlwapi.h"
|
2009-08-18 17:48:49 +02:00
|
|
|
#include "wincodecs_private.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(wincodecs);
|
|
|
|
|
2009-08-21 12:02:10 +02:00
|
|
|
/******************************************
|
|
|
|
* StreamOnMemory implementation
|
|
|
|
*
|
|
|
|
* Used by IWICStream_InitializeFromMemory
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
typedef struct StreamOnMemory {
|
2011-01-11 00:47:30 +01:00
|
|
|
IStream IStream_iface;
|
2009-08-21 12:02:10 +02:00
|
|
|
LONG ref;
|
2009-08-21 11:07:37 +02:00
|
|
|
|
|
|
|
BYTE *pbMemory;
|
|
|
|
DWORD dwMemsize;
|
|
|
|
DWORD dwCurPos;
|
2010-04-09 17:53:24 +02:00
|
|
|
|
|
|
|
CRITICAL_SECTION lock; /* must be held when pbMemory or dwCurPos is accessed */
|
2009-08-21 12:02:10 +02:00
|
|
|
} StreamOnMemory;
|
|
|
|
|
2011-01-11 00:47:30 +01:00
|
|
|
static inline StreamOnMemory *StreamOnMemory_from_IStream(IStream *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, StreamOnMemory, IStream_iface);
|
|
|
|
}
|
|
|
|
|
2009-08-21 12:02:10 +02:00
|
|
|
static HRESULT WINAPI StreamOnMemory_QueryInterface(IStream *iface,
|
|
|
|
REFIID iid, void **ppv)
|
|
|
|
{
|
|
|
|
TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
|
|
|
|
|
|
|
|
if (!ppv) return E_INVALIDARG;
|
|
|
|
|
|
|
|
if (IsEqualIID(&IID_IUnknown, iid) || IsEqualIID(&IID_IStream, iid) ||
|
|
|
|
IsEqualIID(&IID_ISequentialStream, iid))
|
|
|
|
{
|
|
|
|
*ppv = iface;
|
|
|
|
IUnknown_AddRef((IUnknown*)*ppv);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*ppv = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI StreamOnMemory_AddRef(IStream *iface)
|
|
|
|
{
|
2011-01-11 00:47:30 +01:00
|
|
|
StreamOnMemory *This = StreamOnMemory_from_IStream(iface);
|
2009-08-21 12:02:10 +02:00
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) refcount=%u\n", iface, ref);
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI StreamOnMemory_Release(IStream *iface)
|
|
|
|
{
|
2011-01-11 00:47:30 +01:00
|
|
|
StreamOnMemory *This = StreamOnMemory_from_IStream(iface);
|
2009-08-21 12:02:10 +02:00
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) refcount=%u\n", iface, ref);
|
|
|
|
|
|
|
|
if (ref == 0) {
|
2010-04-09 17:53:24 +02:00
|
|
|
This->lock.DebugInfo->Spare[0] = 0;
|
|
|
|
DeleteCriticalSection(&This->lock);
|
2009-08-21 12:02:10 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
}
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI StreamOnMemory_Read(IStream *iface,
|
|
|
|
void *pv, ULONG cb, ULONG *pcbRead)
|
|
|
|
{
|
2011-01-11 00:47:30 +01:00
|
|
|
StreamOnMemory *This = StreamOnMemory_from_IStream(iface);
|
2009-08-21 11:07:37 +02:00
|
|
|
ULONG uBytesRead;
|
2018-11-29 10:36:44 +01:00
|
|
|
|
|
|
|
TRACE("(%p, %p, %u, %p)\n", This, pv, cb, pcbRead);
|
2009-08-21 11:07:37 +02:00
|
|
|
|
|
|
|
if (!pv) return E_INVALIDARG;
|
|
|
|
|
2010-04-09 17:53:24 +02:00
|
|
|
EnterCriticalSection(&This->lock);
|
2009-08-21 11:07:37 +02:00
|
|
|
uBytesRead = min(cb, This->dwMemsize - This->dwCurPos);
|
2011-01-21 12:03:19 +01:00
|
|
|
memmove(pv, This->pbMemory + This->dwCurPos, uBytesRead);
|
2009-08-21 11:07:37 +02:00
|
|
|
This->dwCurPos += uBytesRead;
|
2010-04-09 17:53:24 +02:00
|
|
|
LeaveCriticalSection(&This->lock);
|
|
|
|
|
2009-08-21 11:07:37 +02:00
|
|
|
if (pcbRead) *pcbRead = uBytesRead;
|
|
|
|
|
|
|
|
return S_OK;
|
2009-08-21 12:02:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI StreamOnMemory_Write(IStream *iface,
|
|
|
|
void const *pv, ULONG cb, ULONG *pcbWritten)
|
|
|
|
{
|
2011-01-11 00:47:30 +01:00
|
|
|
StreamOnMemory *This = StreamOnMemory_from_IStream(iface);
|
2010-04-09 17:53:24 +02:00
|
|
|
HRESULT hr;
|
2018-11-29 10:36:44 +01:00
|
|
|
|
|
|
|
TRACE("(%p, %p, %u, %p)\n", This, pv, cb, pcbWritten);
|
2009-08-21 11:08:10 +02:00
|
|
|
|
|
|
|
if (!pv) return E_INVALIDARG;
|
|
|
|
|
2010-04-09 17:53:24 +02:00
|
|
|
EnterCriticalSection(&This->lock);
|
|
|
|
if (cb > This->dwMemsize - This->dwCurPos) {
|
|
|
|
hr = STG_E_MEDIUMFULL;
|
|
|
|
}
|
|
|
|
else {
|
2011-01-21 12:03:19 +01:00
|
|
|
memmove(This->pbMemory + This->dwCurPos, pv, cb);
|
2010-04-14 19:26:12 +02:00
|
|
|
This->dwCurPos += cb;
|
|
|
|
hr = S_OK;
|
2010-04-09 17:53:24 +02:00
|
|
|
if (pcbWritten) *pcbWritten = cb;
|
2009-08-21 11:08:10 +02:00
|
|
|
}
|
2010-04-09 17:53:24 +02:00
|
|
|
LeaveCriticalSection(&This->lock);
|
2009-08-21 11:08:10 +02:00
|
|
|
|
2010-04-09 17:53:24 +02:00
|
|
|
return hr;
|
2009-08-21 12:02:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI StreamOnMemory_Seek(IStream *iface,
|
|
|
|
LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
|
|
|
|
{
|
2011-01-11 00:47:30 +01:00
|
|
|
StreamOnMemory *This = StreamOnMemory_from_IStream(iface);
|
2009-08-21 11:11:39 +02:00
|
|
|
LARGE_INTEGER NewPosition;
|
2010-04-09 17:53:24 +02:00
|
|
|
HRESULT hr=S_OK;
|
2018-11-29 10:36:44 +01:00
|
|
|
|
|
|
|
TRACE("(%p, %s, %d, %p)\n", This, wine_dbgstr_longlong(dlibMove.QuadPart), dwOrigin, plibNewPosition);
|
2009-08-21 11:11:39 +02:00
|
|
|
|
2010-04-09 17:53:24 +02:00
|
|
|
EnterCriticalSection(&This->lock);
|
2009-08-21 11:11:39 +02:00
|
|
|
if (dwOrigin == STREAM_SEEK_SET) NewPosition.QuadPart = dlibMove.QuadPart;
|
|
|
|
else if (dwOrigin == STREAM_SEEK_CUR) NewPosition.QuadPart = This->dwCurPos + dlibMove.QuadPart;
|
|
|
|
else if (dwOrigin == STREAM_SEEK_END) NewPosition.QuadPart = This->dwMemsize + dlibMove.QuadPart;
|
2010-04-09 17:53:24 +02:00
|
|
|
else hr = E_INVALIDARG;
|
2009-08-21 11:11:39 +02:00
|
|
|
|
2010-04-09 17:53:24 +02:00
|
|
|
if (SUCCEEDED(hr)) {
|
|
|
|
if (NewPosition.u.HighPart) hr = HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW);
|
|
|
|
else if (NewPosition.QuadPart > This->dwMemsize) hr = E_INVALIDARG;
|
|
|
|
else if (NewPosition.QuadPart < 0) hr = E_INVALIDARG;
|
|
|
|
}
|
2009-08-21 11:11:39 +02:00
|
|
|
|
2010-04-09 17:53:24 +02:00
|
|
|
if (SUCCEEDED(hr)) {
|
|
|
|
This->dwCurPos = NewPosition.u.LowPart;
|
|
|
|
|
|
|
|
if(plibNewPosition) plibNewPosition->QuadPart = This->dwCurPos;
|
|
|
|
}
|
|
|
|
LeaveCriticalSection(&This->lock);
|
|
|
|
|
|
|
|
return hr;
|
2009-08-21 12:02:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* SetSize isn't implemented in the native windowscodecs DLL either */
|
|
|
|
static HRESULT WINAPI StreamOnMemory_SetSize(IStream *iface,
|
|
|
|
ULARGE_INTEGER libNewSize)
|
|
|
|
{
|
2018-11-29 10:36:44 +01:00
|
|
|
TRACE("(%p, %s)\n", iface, wine_dbgstr_longlong(libNewSize.QuadPart));
|
2009-08-21 12:02:10 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* CopyTo isn't implemented in the native windowscodecs DLL either */
|
|
|
|
static HRESULT WINAPI StreamOnMemory_CopyTo(IStream *iface,
|
|
|
|
IStream *pstm, ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten)
|
|
|
|
{
|
2018-11-29 10:36:44 +01:00
|
|
|
TRACE("(%p, %p, %s, %p, %p)\n", iface, pstm, wine_dbgstr_longlong(cb.QuadPart), pcbRead, pcbWritten);
|
2009-08-21 12:02:10 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI StreamOnMemory_Commit(IStream *iface,
|
|
|
|
DWORD grfCommitFlags)
|
|
|
|
{
|
2018-11-29 10:36:44 +01:00
|
|
|
TRACE("(%p, %#x)\n", iface, grfCommitFlags);
|
2019-10-21 20:43:50 +02:00
|
|
|
return S_OK;
|
2009-08-21 12:02:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Revert isn't implemented in the native windowscodecs DLL either */
|
|
|
|
static HRESULT WINAPI StreamOnMemory_Revert(IStream *iface)
|
|
|
|
{
|
|
|
|
TRACE("(%p)\n", iface);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* LockRegion isn't implemented in the native windowscodecs DLL either */
|
|
|
|
static HRESULT WINAPI StreamOnMemory_LockRegion(IStream *iface,
|
|
|
|
ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
|
|
|
|
{
|
2018-11-29 10:36:44 +01:00
|
|
|
TRACE("(%p, %s, %s, %d)\n", iface, wine_dbgstr_longlong(libOffset.QuadPart),
|
|
|
|
wine_dbgstr_longlong(cb.QuadPart), dwLockType);
|
2009-08-21 12:02:10 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* UnlockRegion isn't implemented in the native windowscodecs DLL either */
|
|
|
|
static HRESULT WINAPI StreamOnMemory_UnlockRegion(IStream *iface,
|
|
|
|
ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
|
|
|
|
{
|
2018-11-29 10:36:44 +01:00
|
|
|
TRACE("(%p, %s, %s, %d)\n", iface, wine_dbgstr_longlong(libOffset.QuadPart),
|
|
|
|
wine_dbgstr_longlong(cb.QuadPart), dwLockType);
|
2009-08-21 12:02:10 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI StreamOnMemory_Stat(IStream *iface,
|
|
|
|
STATSTG *pstatstg, DWORD grfStatFlag)
|
|
|
|
{
|
2011-01-11 00:47:30 +01:00
|
|
|
StreamOnMemory *This = StreamOnMemory_from_IStream(iface);
|
2018-11-29 10:36:44 +01:00
|
|
|
TRACE("(%p, %p, %#x)\n", This, pstatstg, grfStatFlag);
|
2009-08-21 11:12:03 +02:00
|
|
|
|
|
|
|
if (!pstatstg) return E_INVALIDARG;
|
|
|
|
|
|
|
|
ZeroMemory(pstatstg, sizeof(STATSTG));
|
|
|
|
pstatstg->type = STGTY_STREAM;
|
|
|
|
pstatstg->cbSize.QuadPart = This->dwMemsize;
|
|
|
|
|
|
|
|
return S_OK;
|
2009-08-21 12:02:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Clone isn't implemented in the native windowscodecs DLL either */
|
|
|
|
static HRESULT WINAPI StreamOnMemory_Clone(IStream *iface,
|
|
|
|
IStream **ppstm)
|
|
|
|
{
|
2018-11-29 10:36:44 +01:00
|
|
|
TRACE("(%p, %p)\n", iface, ppstm);
|
2009-08-21 12:02:10 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-05-28 10:49:31 +02:00
|
|
|
static const IStreamVtbl StreamOnMemory_Vtbl =
|
2009-08-21 12:02:10 +02:00
|
|
|
{
|
|
|
|
/*** IUnknown methods ***/
|
|
|
|
StreamOnMemory_QueryInterface,
|
|
|
|
StreamOnMemory_AddRef,
|
|
|
|
StreamOnMemory_Release,
|
|
|
|
/*** ISequentialStream methods ***/
|
|
|
|
StreamOnMemory_Read,
|
|
|
|
StreamOnMemory_Write,
|
|
|
|
/*** IStream methods ***/
|
|
|
|
StreamOnMemory_Seek,
|
|
|
|
StreamOnMemory_SetSize,
|
|
|
|
StreamOnMemory_CopyTo,
|
|
|
|
StreamOnMemory_Commit,
|
|
|
|
StreamOnMemory_Revert,
|
|
|
|
StreamOnMemory_LockRegion,
|
|
|
|
StreamOnMemory_UnlockRegion,
|
|
|
|
StreamOnMemory_Stat,
|
|
|
|
StreamOnMemory_Clone,
|
|
|
|
};
|
|
|
|
|
2013-02-06 13:53:21 +01:00
|
|
|
/******************************************
|
|
|
|
* StreamOnFileHandle implementation (internal)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
typedef struct StreamOnFileHandle {
|
|
|
|
IStream IStream_iface;
|
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
HANDLE map;
|
|
|
|
void *mem;
|
|
|
|
IWICStream *stream;
|
|
|
|
} StreamOnFileHandle;
|
|
|
|
|
|
|
|
static inline StreamOnFileHandle *StreamOnFileHandle_from_IStream(IStream *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, StreamOnFileHandle, IStream_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI StreamOnFileHandle_QueryInterface(IStream *iface,
|
|
|
|
REFIID iid, void **ppv)
|
|
|
|
{
|
|
|
|
TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
|
|
|
|
|
|
|
|
if (!ppv) return E_INVALIDARG;
|
|
|
|
|
|
|
|
if (IsEqualIID(&IID_IUnknown, iid) || IsEqualIID(&IID_IStream, iid) ||
|
|
|
|
IsEqualIID(&IID_ISequentialStream, iid))
|
|
|
|
{
|
|
|
|
*ppv = iface;
|
|
|
|
IUnknown_AddRef((IUnknown*)*ppv);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*ppv = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI StreamOnFileHandle_AddRef(IStream *iface)
|
|
|
|
{
|
|
|
|
StreamOnFileHandle *This = StreamOnFileHandle_from_IStream(iface);
|
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) refcount=%u\n", iface, ref);
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI StreamOnFileHandle_Release(IStream *iface)
|
|
|
|
{
|
|
|
|
StreamOnFileHandle *This = StreamOnFileHandle_from_IStream(iface);
|
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) refcount=%u\n", iface, ref);
|
|
|
|
|
|
|
|
if (ref == 0) {
|
|
|
|
IWICStream_Release(This->stream);
|
|
|
|
UnmapViewOfFile(This->mem);
|
|
|
|
CloseHandle(This->map);
|
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
}
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI StreamOnFileHandle_Read(IStream *iface,
|
|
|
|
void *pv, ULONG cb, ULONG *pcbRead)
|
|
|
|
{
|
|
|
|
StreamOnFileHandle *This = StreamOnFileHandle_from_IStream(iface);
|
2018-11-29 10:36:44 +01:00
|
|
|
TRACE("(%p, %p, %u, %p)\n", This, pv, cb, pcbRead);
|
2013-02-06 13:53:21 +01:00
|
|
|
|
|
|
|
return IWICStream_Read(This->stream, pv, cb, pcbRead);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI StreamOnFileHandle_Write(IStream *iface,
|
|
|
|
void const *pv, ULONG cb, ULONG *pcbWritten)
|
|
|
|
{
|
2018-11-29 10:36:44 +01:00
|
|
|
ERR("(%p, %p, %u, %p)\n", iface, pv, cb, pcbWritten);
|
2013-02-06 13:53:21 +01:00
|
|
|
return HRESULT_FROM_WIN32(ERROR_ACCESS_DENIED);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI StreamOnFileHandle_Seek(IStream *iface,
|
|
|
|
LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
|
|
|
|
{
|
|
|
|
StreamOnFileHandle *This = StreamOnFileHandle_from_IStream(iface);
|
2018-11-29 10:36:44 +01:00
|
|
|
TRACE("(%p, %s, %d, %p)\n", This, wine_dbgstr_longlong(dlibMove.QuadPart), dwOrigin, plibNewPosition);
|
2013-02-06 13:53:21 +01:00
|
|
|
|
|
|
|
return IWICStream_Seek(This->stream, dlibMove, dwOrigin, plibNewPosition);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI StreamOnFileHandle_SetSize(IStream *iface,
|
|
|
|
ULARGE_INTEGER libNewSize)
|
|
|
|
{
|
2018-11-29 10:36:44 +01:00
|
|
|
TRACE("(%p, %s)\n", iface, wine_dbgstr_longlong(libNewSize.QuadPart));
|
2013-02-06 13:53:21 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI StreamOnFileHandle_CopyTo(IStream *iface,
|
|
|
|
IStream *pstm, ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten)
|
|
|
|
{
|
2018-11-29 10:36:44 +01:00
|
|
|
TRACE("(%p, %p, %s, %p, %p)\n", iface, pstm, wine_dbgstr_longlong(cb.QuadPart), pcbRead, pcbWritten);
|
2013-02-06 13:53:21 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI StreamOnFileHandle_Commit(IStream *iface,
|
|
|
|
DWORD grfCommitFlags)
|
|
|
|
{
|
2018-11-29 10:36:44 +01:00
|
|
|
TRACE("(%p, %#x)\n", iface, grfCommitFlags);
|
2019-10-21 20:43:50 +02:00
|
|
|
return S_OK;
|
2013-02-06 13:53:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI StreamOnFileHandle_Revert(IStream *iface)
|
|
|
|
{
|
|
|
|
TRACE("(%p)\n", iface);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI StreamOnFileHandle_LockRegion(IStream *iface,
|
|
|
|
ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
|
|
|
|
{
|
2018-11-29 10:36:44 +01:00
|
|
|
TRACE("(%p, %s, %s, %d)\n", iface, wine_dbgstr_longlong(libOffset.QuadPart),
|
|
|
|
wine_dbgstr_longlong(cb.QuadPart), dwLockType);
|
2013-02-06 13:53:21 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI StreamOnFileHandle_UnlockRegion(IStream *iface,
|
|
|
|
ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
|
|
|
|
{
|
2018-11-29 10:36:44 +01:00
|
|
|
TRACE("(%p, %s, %s, %d)\n", iface, wine_dbgstr_longlong(libOffset.QuadPart),
|
|
|
|
wine_dbgstr_longlong(cb.QuadPart), dwLockType);
|
2013-02-06 13:53:21 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI StreamOnFileHandle_Stat(IStream *iface,
|
|
|
|
STATSTG *pstatstg, DWORD grfStatFlag)
|
|
|
|
{
|
|
|
|
StreamOnFileHandle *This = StreamOnFileHandle_from_IStream(iface);
|
2018-11-29 10:36:44 +01:00
|
|
|
TRACE("(%p, %p, %#x)\n", This, pstatstg, grfStatFlag);
|
2013-02-06 13:53:21 +01:00
|
|
|
|
|
|
|
return IWICStream_Stat(This->stream, pstatstg, grfStatFlag);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI StreamOnFileHandle_Clone(IStream *iface,
|
|
|
|
IStream **ppstm)
|
|
|
|
{
|
2018-11-29 10:36:44 +01:00
|
|
|
TRACE("(%p, %p)\n", iface, ppstm);
|
2013-02-06 13:53:21 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IStreamVtbl StreamOnFileHandle_Vtbl =
|
|
|
|
{
|
|
|
|
/*** IUnknown methods ***/
|
|
|
|
StreamOnFileHandle_QueryInterface,
|
|
|
|
StreamOnFileHandle_AddRef,
|
|
|
|
StreamOnFileHandle_Release,
|
|
|
|
/*** ISequentialStream methods ***/
|
|
|
|
StreamOnFileHandle_Read,
|
|
|
|
StreamOnFileHandle_Write,
|
|
|
|
/*** IStream methods ***/
|
|
|
|
StreamOnFileHandle_Seek,
|
|
|
|
StreamOnFileHandle_SetSize,
|
|
|
|
StreamOnFileHandle_CopyTo,
|
|
|
|
StreamOnFileHandle_Commit,
|
|
|
|
StreamOnFileHandle_Revert,
|
|
|
|
StreamOnFileHandle_LockRegion,
|
|
|
|
StreamOnFileHandle_UnlockRegion,
|
|
|
|
StreamOnFileHandle_Stat,
|
|
|
|
StreamOnFileHandle_Clone,
|
|
|
|
};
|
|
|
|
|
2010-08-28 01:24:29 +02:00
|
|
|
/******************************************
|
|
|
|
* StreamOnStreamRange implementation
|
|
|
|
*
|
|
|
|
* Used by IWICStream_InitializeFromIStreamRegion
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
typedef struct StreamOnStreamRange {
|
2011-01-11 00:47:30 +01:00
|
|
|
IStream IStream_iface;
|
2010-08-28 01:24:29 +02:00
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
IStream *stream;
|
|
|
|
ULARGE_INTEGER pos;
|
|
|
|
ULARGE_INTEGER offset;
|
|
|
|
ULARGE_INTEGER max_size;
|
|
|
|
|
|
|
|
CRITICAL_SECTION lock;
|
|
|
|
} StreamOnStreamRange;
|
|
|
|
|
2011-01-11 00:47:30 +01:00
|
|
|
static inline StreamOnStreamRange *StreamOnStreamRange_from_IStream(IStream *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, StreamOnStreamRange, IStream_iface);
|
|
|
|
}
|
|
|
|
|
2010-08-28 01:24:29 +02:00
|
|
|
static HRESULT WINAPI StreamOnStreamRange_QueryInterface(IStream *iface,
|
|
|
|
REFIID iid, void **ppv)
|
|
|
|
{
|
|
|
|
TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
|
|
|
|
|
|
|
|
if (!ppv) return E_INVALIDARG;
|
|
|
|
|
|
|
|
if (IsEqualIID(&IID_IUnknown, iid) || IsEqualIID(&IID_IStream, iid) ||
|
|
|
|
IsEqualIID(&IID_ISequentialStream, iid))
|
|
|
|
{
|
|
|
|
*ppv = iface;
|
|
|
|
IUnknown_AddRef((IUnknown*)*ppv);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*ppv = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI StreamOnStreamRange_AddRef(IStream *iface)
|
|
|
|
{
|
2011-01-11 00:47:30 +01:00
|
|
|
StreamOnStreamRange *This = StreamOnStreamRange_from_IStream(iface);
|
2010-08-28 01:24:29 +02:00
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) refcount=%u\n", iface, ref);
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI StreamOnStreamRange_Release(IStream *iface)
|
|
|
|
{
|
2011-01-11 00:47:30 +01:00
|
|
|
StreamOnStreamRange *This = StreamOnStreamRange_from_IStream(iface);
|
2010-08-28 01:24:29 +02:00
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) refcount=%u\n", iface, ref);
|
|
|
|
|
|
|
|
if (ref == 0) {
|
|
|
|
This->lock.DebugInfo->Spare[0] = 0;
|
|
|
|
DeleteCriticalSection(&This->lock);
|
|
|
|
IStream_Release(This->stream);
|
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
}
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI StreamOnStreamRange_Read(IStream *iface,
|
|
|
|
void *pv, ULONG cb, ULONG *pcbRead)
|
|
|
|
{
|
2011-01-11 00:47:30 +01:00
|
|
|
StreamOnStreamRange *This = StreamOnStreamRange_from_IStream(iface);
|
2010-08-28 01:24:29 +02:00
|
|
|
ULONG uBytesRead=0;
|
|
|
|
HRESULT hr;
|
|
|
|
ULARGE_INTEGER OldPosition;
|
|
|
|
LARGE_INTEGER SetPosition;
|
2018-11-29 10:36:44 +01:00
|
|
|
|
|
|
|
TRACE("(%p, %p, %u, %p)\n", This, pv, cb, pcbRead);
|
2010-08-28 01:24:29 +02:00
|
|
|
|
|
|
|
if (!pv) return E_INVALIDARG;
|
|
|
|
|
|
|
|
EnterCriticalSection(&This->lock);
|
|
|
|
SetPosition.QuadPart = 0;
|
|
|
|
hr = IStream_Seek(This->stream, SetPosition, STREAM_SEEK_CUR, &OldPosition);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
SetPosition.QuadPart = This->pos.QuadPart + This->offset.QuadPart;
|
2010-09-12 02:19:34 +02:00
|
|
|
hr = IStream_Seek(This->stream, SetPosition, STREAM_SEEK_SET, NULL);
|
2010-08-28 01:24:29 +02:00
|
|
|
}
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
if (This->pos.QuadPart + cb > This->max_size.QuadPart)
|
|
|
|
{
|
|
|
|
/* This would read past the end of the stream. */
|
|
|
|
if (This->pos.QuadPart > This->max_size.QuadPart)
|
|
|
|
cb = 0;
|
|
|
|
else
|
|
|
|
cb = This->max_size.QuadPart - This->pos.QuadPart;
|
|
|
|
}
|
|
|
|
hr = IStream_Read(This->stream, pv, cb, &uBytesRead);
|
|
|
|
SetPosition.QuadPart = OldPosition.QuadPart;
|
|
|
|
IStream_Seek(This->stream, SetPosition, STREAM_SEEK_SET, NULL);
|
|
|
|
}
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
This->pos.QuadPart += uBytesRead;
|
|
|
|
LeaveCriticalSection(&This->lock);
|
|
|
|
|
2011-01-21 12:03:07 +01:00
|
|
|
if (SUCCEEDED(hr) && pcbRead) *pcbRead = uBytesRead;
|
2010-08-28 01:24:29 +02:00
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI StreamOnStreamRange_Write(IStream *iface,
|
|
|
|
void const *pv, ULONG cb, ULONG *pcbWritten)
|
|
|
|
{
|
2011-01-11 00:47:30 +01:00
|
|
|
StreamOnStreamRange *This = StreamOnStreamRange_from_IStream(iface);
|
2010-08-28 01:24:29 +02:00
|
|
|
HRESULT hr;
|
|
|
|
ULARGE_INTEGER OldPosition;
|
|
|
|
LARGE_INTEGER SetPosition;
|
|
|
|
ULONG uBytesWritten=0;
|
2018-11-29 10:36:44 +01:00
|
|
|
TRACE("(%p, %p, %u, %p)\n", This, pv, cb, pcbWritten);
|
2010-08-28 01:24:29 +02:00
|
|
|
|
|
|
|
if (!pv) return E_INVALIDARG;
|
|
|
|
|
|
|
|
EnterCriticalSection(&This->lock);
|
|
|
|
SetPosition.QuadPart = 0;
|
|
|
|
hr = IStream_Seek(This->stream, SetPosition, STREAM_SEEK_CUR, &OldPosition);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
SetPosition.QuadPart = This->pos.QuadPart + This->offset.QuadPart;
|
2010-09-12 02:19:34 +02:00
|
|
|
hr = IStream_Seek(This->stream, SetPosition, STREAM_SEEK_SET, NULL);
|
2010-08-28 01:24:29 +02:00
|
|
|
}
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
if (This->pos.QuadPart + cb > This->max_size.QuadPart)
|
|
|
|
{
|
|
|
|
/* This would read past the end of the stream. */
|
|
|
|
if (This->pos.QuadPart > This->max_size.QuadPart)
|
|
|
|
cb = 0;
|
|
|
|
else
|
|
|
|
cb = This->max_size.QuadPart - This->pos.QuadPart;
|
|
|
|
}
|
|
|
|
hr = IStream_Write(This->stream, pv, cb, &uBytesWritten);
|
|
|
|
SetPosition.QuadPart = OldPosition.QuadPart;
|
|
|
|
IStream_Seek(This->stream, SetPosition, STREAM_SEEK_SET, NULL);
|
|
|
|
}
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
This->pos.QuadPart += uBytesWritten;
|
|
|
|
LeaveCriticalSection(&This->lock);
|
|
|
|
|
2011-01-21 12:03:07 +01:00
|
|
|
if (SUCCEEDED(hr) && pcbWritten) *pcbWritten = uBytesWritten;
|
2010-08-28 01:24:29 +02:00
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI StreamOnStreamRange_Seek(IStream *iface,
|
|
|
|
LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
|
|
|
|
{
|
2011-01-11 00:47:30 +01:00
|
|
|
StreamOnStreamRange *This = StreamOnStreamRange_from_IStream(iface);
|
2010-08-28 01:24:29 +02:00
|
|
|
ULARGE_INTEGER NewPosition, actual_size;
|
|
|
|
HRESULT hr=S_OK;
|
|
|
|
STATSTG statstg;
|
2018-11-29 10:36:44 +01:00
|
|
|
TRACE("(%p, %s, %d, %p)\n", This, wine_dbgstr_longlong(dlibMove.QuadPart), dwOrigin, plibNewPosition);
|
2010-08-28 01:24:29 +02:00
|
|
|
|
|
|
|
EnterCriticalSection(&This->lock);
|
|
|
|
actual_size = This->max_size;
|
|
|
|
if (dwOrigin == STREAM_SEEK_SET)
|
|
|
|
NewPosition.QuadPart = dlibMove.QuadPart;
|
|
|
|
else if (dwOrigin == STREAM_SEEK_CUR)
|
|
|
|
NewPosition.QuadPart = This->pos.QuadPart + dlibMove.QuadPart;
|
|
|
|
else if (dwOrigin == STREAM_SEEK_END)
|
|
|
|
{
|
|
|
|
hr = IStream_Stat(This->stream, &statstg, STATFLAG_NONAME);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
if (This->max_size.QuadPart + This->offset.QuadPart > statstg.cbSize.QuadPart)
|
|
|
|
actual_size.QuadPart = statstg.cbSize.QuadPart - This->offset.QuadPart;
|
|
|
|
NewPosition.QuadPart = dlibMove.QuadPart + actual_size.QuadPart;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else hr = E_INVALIDARG;
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr) && (NewPosition.u.HighPart != 0 || NewPosition.QuadPart > actual_size.QuadPart))
|
|
|
|
hr = WINCODEC_ERR_VALUEOUTOFRANGE;
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr)) {
|
|
|
|
This->pos.QuadPart = NewPosition.QuadPart;
|
|
|
|
|
|
|
|
if(plibNewPosition) plibNewPosition->QuadPart = This->pos.QuadPart;
|
|
|
|
}
|
|
|
|
LeaveCriticalSection(&This->lock);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* SetSize isn't implemented in the native windowscodecs DLL either */
|
|
|
|
static HRESULT WINAPI StreamOnStreamRange_SetSize(IStream *iface,
|
|
|
|
ULARGE_INTEGER libNewSize)
|
|
|
|
{
|
2018-11-29 10:36:44 +01:00
|
|
|
TRACE("(%p, %s)\n", iface, wine_dbgstr_longlong(libNewSize.QuadPart));
|
2010-08-28 01:24:29 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* CopyTo isn't implemented in the native windowscodecs DLL either */
|
|
|
|
static HRESULT WINAPI StreamOnStreamRange_CopyTo(IStream *iface,
|
|
|
|
IStream *pstm, ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten)
|
|
|
|
{
|
2018-11-29 10:36:44 +01:00
|
|
|
TRACE("(%p, %p, %s, %p, %p)\n", iface, pstm, wine_dbgstr_longlong(cb.QuadPart),
|
|
|
|
pcbRead, pcbWritten);
|
2010-08-28 01:24:29 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Commit isn't implemented in the native windowscodecs DLL either */
|
|
|
|
static HRESULT WINAPI StreamOnStreamRange_Commit(IStream *iface,
|
|
|
|
DWORD grfCommitFlags)
|
|
|
|
{
|
2019-10-21 20:43:50 +02:00
|
|
|
StreamOnStreamRange *This = StreamOnStreamRange_from_IStream(iface);
|
|
|
|
TRACE("(%p, %#x)\n", This, grfCommitFlags);
|
|
|
|
return IStream_Commit(This->stream, grfCommitFlags);
|
2010-08-28 01:24:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Revert isn't implemented in the native windowscodecs DLL either */
|
|
|
|
static HRESULT WINAPI StreamOnStreamRange_Revert(IStream *iface)
|
|
|
|
{
|
|
|
|
TRACE("(%p)\n", iface);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* LockRegion isn't implemented in the native windowscodecs DLL either */
|
|
|
|
static HRESULT WINAPI StreamOnStreamRange_LockRegion(IStream *iface,
|
|
|
|
ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
|
|
|
|
{
|
2018-11-29 10:36:44 +01:00
|
|
|
TRACE("(%p, %s, %s, %d)\n", iface, wine_dbgstr_longlong(libOffset.QuadPart),
|
|
|
|
wine_dbgstr_longlong(cb.QuadPart), dwLockType);
|
2010-08-28 01:24:29 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* UnlockRegion isn't implemented in the native windowscodecs DLL either */
|
|
|
|
static HRESULT WINAPI StreamOnStreamRange_UnlockRegion(IStream *iface,
|
|
|
|
ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
|
|
|
|
{
|
2018-11-29 10:36:44 +01:00
|
|
|
TRACE("(%p, %s, %s, %d)\n", iface, wine_dbgstr_longlong(libOffset.QuadPart),
|
|
|
|
wine_dbgstr_longlong(cb.QuadPart), dwLockType);
|
2010-08-28 01:24:29 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI StreamOnStreamRange_Stat(IStream *iface,
|
|
|
|
STATSTG *pstatstg, DWORD grfStatFlag)
|
|
|
|
{
|
2011-01-11 00:47:30 +01:00
|
|
|
StreamOnStreamRange *This = StreamOnStreamRange_from_IStream(iface);
|
2010-08-28 01:24:29 +02:00
|
|
|
HRESULT hr;
|
2018-11-29 10:36:44 +01:00
|
|
|
TRACE("(%p, %p, %#x)\n", This, pstatstg, grfStatFlag);
|
2010-08-28 01:24:29 +02:00
|
|
|
|
|
|
|
if (!pstatstg) return E_INVALIDARG;
|
|
|
|
|
|
|
|
EnterCriticalSection(&This->lock);
|
|
|
|
hr = IStream_Stat(This->stream, pstatstg, grfStatFlag);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
pstatstg->cbSize.QuadPart -= This->offset.QuadPart;
|
|
|
|
if (This->max_size.QuadPart < pstatstg->cbSize.QuadPart)
|
|
|
|
pstatstg->cbSize.QuadPart = This->max_size.QuadPart;
|
|
|
|
}
|
|
|
|
|
|
|
|
LeaveCriticalSection(&This->lock);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Clone isn't implemented in the native windowscodecs DLL either */
|
|
|
|
static HRESULT WINAPI StreamOnStreamRange_Clone(IStream *iface,
|
|
|
|
IStream **ppstm)
|
|
|
|
{
|
2018-11-29 10:36:44 +01:00
|
|
|
TRACE("(%p, %p)\n", iface, ppstm);
|
2010-08-28 01:24:29 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2011-05-28 10:49:31 +02:00
|
|
|
static const IStreamVtbl StreamOnStreamRange_Vtbl =
|
2010-08-28 01:24:29 +02:00
|
|
|
{
|
|
|
|
/*** IUnknown methods ***/
|
|
|
|
StreamOnStreamRange_QueryInterface,
|
|
|
|
StreamOnStreamRange_AddRef,
|
|
|
|
StreamOnStreamRange_Release,
|
|
|
|
/*** ISequentialStream methods ***/
|
|
|
|
StreamOnStreamRange_Read,
|
|
|
|
StreamOnStreamRange_Write,
|
|
|
|
/*** IStream methods ***/
|
|
|
|
StreamOnStreamRange_Seek,
|
|
|
|
StreamOnStreamRange_SetSize,
|
|
|
|
StreamOnStreamRange_CopyTo,
|
|
|
|
StreamOnStreamRange_Commit,
|
|
|
|
StreamOnStreamRange_Revert,
|
|
|
|
StreamOnStreamRange_LockRegion,
|
|
|
|
StreamOnStreamRange_UnlockRegion,
|
|
|
|
StreamOnStreamRange_Stat,
|
|
|
|
StreamOnStreamRange_Clone,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-08-18 17:48:49 +02:00
|
|
|
/******************************************
|
|
|
|
* IWICStream implementation
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
typedef struct IWICStreamImpl
|
|
|
|
{
|
2011-01-11 00:47:30 +01:00
|
|
|
IWICStream IWICStream_iface;
|
2009-08-18 17:48:49 +02:00
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
IStream *pStream;
|
|
|
|
} IWICStreamImpl;
|
|
|
|
|
2011-01-11 00:47:30 +01:00
|
|
|
static inline IWICStreamImpl *impl_from_IWICStream(IWICStream *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, IWICStreamImpl, IWICStream_iface);
|
|
|
|
}
|
|
|
|
|
2009-08-18 17:48:49 +02:00
|
|
|
static HRESULT WINAPI IWICStreamImpl_QueryInterface(IWICStream *iface,
|
|
|
|
REFIID iid, void **ppv)
|
|
|
|
{
|
2011-01-11 00:47:30 +01:00
|
|
|
IWICStreamImpl *This = impl_from_IWICStream(iface);
|
2009-08-18 17:48:49 +02:00
|
|
|
TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
|
|
|
|
|
|
|
|
if (!ppv) return E_INVALIDARG;
|
|
|
|
|
|
|
|
if (IsEqualIID(&IID_IUnknown, iid) || IsEqualIID(&IID_IStream, iid) ||
|
|
|
|
IsEqualIID(&IID_ISequentialStream, iid) || IsEqualIID(&IID_IWICStream, iid))
|
|
|
|
{
|
2015-06-26 05:52:08 +02:00
|
|
|
*ppv = &This->IWICStream_iface;
|
2009-08-18 17:48:49 +02:00
|
|
|
IUnknown_AddRef((IUnknown*)*ppv);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*ppv = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI IWICStreamImpl_AddRef(IWICStream *iface)
|
|
|
|
{
|
2011-01-11 00:47:30 +01:00
|
|
|
IWICStreamImpl *This = impl_from_IWICStream(iface);
|
2009-08-18 17:48:49 +02:00
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) refcount=%u\n", iface, ref);
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI IWICStreamImpl_Release(IWICStream *iface)
|
|
|
|
{
|
2011-01-11 00:47:30 +01:00
|
|
|
IWICStreamImpl *This = impl_from_IWICStream(iface);
|
2009-08-18 17:48:49 +02:00
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) refcount=%u\n", iface, ref);
|
|
|
|
|
|
|
|
if (ref == 0) {
|
|
|
|
if (This->pStream) IStream_Release(This->pStream);
|
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
}
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IWICStreamImpl_Read(IWICStream *iface,
|
|
|
|
void *pv, ULONG cb, ULONG *pcbRead)
|
|
|
|
{
|
2011-01-11 00:47:30 +01:00
|
|
|
IWICStreamImpl *This = impl_from_IWICStream(iface);
|
2018-11-29 10:36:44 +01:00
|
|
|
TRACE("(%p, %p, %u, %p)\n", This, pv, cb, pcbRead);
|
2009-08-18 17:48:49 +02:00
|
|
|
|
|
|
|
if (!This->pStream) return WINCODEC_ERR_NOTINITIALIZED;
|
|
|
|
return IStream_Read(This->pStream, pv, cb, pcbRead);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IWICStreamImpl_Write(IWICStream *iface,
|
|
|
|
void const *pv, ULONG cb, ULONG *pcbWritten)
|
|
|
|
{
|
2011-01-11 00:47:30 +01:00
|
|
|
IWICStreamImpl *This = impl_from_IWICStream(iface);
|
2018-11-29 10:36:44 +01:00
|
|
|
TRACE("(%p, %p, %u, %p)\n", This, pv, cb, pcbWritten);
|
2009-08-18 17:48:49 +02:00
|
|
|
|
|
|
|
if (!This->pStream) return WINCODEC_ERR_NOTINITIALIZED;
|
|
|
|
return IStream_Write(This->pStream, pv, cb, pcbWritten);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IWICStreamImpl_Seek(IWICStream *iface,
|
|
|
|
LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
|
|
|
|
{
|
2011-01-11 00:47:30 +01:00
|
|
|
IWICStreamImpl *This = impl_from_IWICStream(iface);
|
2018-11-29 10:36:44 +01:00
|
|
|
TRACE("(%p, %s, %d, %p)\n", This, wine_dbgstr_longlong(dlibMove.QuadPart),
|
|
|
|
dwOrigin, plibNewPosition);
|
2009-08-18 17:48:49 +02:00
|
|
|
|
|
|
|
if (!This->pStream) return WINCODEC_ERR_NOTINITIALIZED;
|
|
|
|
return IStream_Seek(This->pStream, dlibMove, dwOrigin, plibNewPosition);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IWICStreamImpl_SetSize(IWICStream *iface,
|
|
|
|
ULARGE_INTEGER libNewSize)
|
|
|
|
{
|
2011-01-11 00:47:30 +01:00
|
|
|
IWICStreamImpl *This = impl_from_IWICStream(iface);
|
2018-11-29 10:36:44 +01:00
|
|
|
TRACE("(%p, %s)\n", This, wine_dbgstr_longlong(libNewSize.QuadPart));
|
2009-08-18 17:48:49 +02:00
|
|
|
|
|
|
|
if (!This->pStream) return WINCODEC_ERR_NOTINITIALIZED;
|
|
|
|
return IStream_SetSize(This->pStream, libNewSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IWICStreamImpl_CopyTo(IWICStream *iface,
|
|
|
|
IStream *pstm, ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten)
|
|
|
|
{
|
2011-01-11 00:47:30 +01:00
|
|
|
IWICStreamImpl *This = impl_from_IWICStream(iface);
|
2018-11-29 10:36:44 +01:00
|
|
|
TRACE("(%p, %p, %s, %p, %p)\n", This, pstm, wine_dbgstr_longlong(cb.QuadPart), pcbRead, pcbWritten);
|
2009-08-18 17:48:49 +02:00
|
|
|
|
|
|
|
if (!This->pStream) return WINCODEC_ERR_NOTINITIALIZED;
|
|
|
|
return IStream_CopyTo(This->pStream, pstm, cb, pcbRead, pcbWritten);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IWICStreamImpl_Commit(IWICStream *iface,
|
|
|
|
DWORD grfCommitFlags)
|
|
|
|
{
|
2011-01-11 00:47:30 +01:00
|
|
|
IWICStreamImpl *This = impl_from_IWICStream(iface);
|
2018-11-29 10:36:44 +01:00
|
|
|
TRACE("(%p, %#x)\n", This, grfCommitFlags);
|
2009-08-18 17:48:49 +02:00
|
|
|
|
|
|
|
if (!This->pStream) return WINCODEC_ERR_NOTINITIALIZED;
|
|
|
|
return IStream_Commit(This->pStream, grfCommitFlags);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IWICStreamImpl_Revert(IWICStream *iface)
|
|
|
|
{
|
2011-01-11 00:47:30 +01:00
|
|
|
IWICStreamImpl *This = impl_from_IWICStream(iface);
|
2018-11-29 10:36:44 +01:00
|
|
|
TRACE("(%p)\n", This);
|
2009-08-18 17:48:49 +02:00
|
|
|
|
|
|
|
if (!This->pStream) return WINCODEC_ERR_NOTINITIALIZED;
|
|
|
|
return IStream_Revert(This->pStream);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IWICStreamImpl_LockRegion(IWICStream *iface,
|
|
|
|
ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
|
|
|
|
{
|
2011-01-11 00:47:30 +01:00
|
|
|
IWICStreamImpl *This = impl_from_IWICStream(iface);
|
2018-11-29 10:36:44 +01:00
|
|
|
TRACE("(%p, %s, %s, %d)\n", This, wine_dbgstr_longlong(libOffset.QuadPart),
|
|
|
|
wine_dbgstr_longlong(cb.QuadPart), dwLockType);
|
2009-08-18 17:48:49 +02:00
|
|
|
|
|
|
|
if (!This->pStream) return WINCODEC_ERR_NOTINITIALIZED;
|
|
|
|
return IStream_LockRegion(This->pStream, libOffset, cb, dwLockType);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IWICStreamImpl_UnlockRegion(IWICStream *iface,
|
|
|
|
ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
|
|
|
|
{
|
2011-01-11 00:47:30 +01:00
|
|
|
IWICStreamImpl *This = impl_from_IWICStream(iface);
|
2018-11-29 10:36:44 +01:00
|
|
|
TRACE("(%p, %s, %s, %d)\n", This, wine_dbgstr_longlong(libOffset.QuadPart),
|
|
|
|
wine_dbgstr_longlong(cb.QuadPart), dwLockType);
|
2009-08-18 17:48:49 +02:00
|
|
|
|
|
|
|
if (!This->pStream) return WINCODEC_ERR_NOTINITIALIZED;
|
|
|
|
return IStream_UnlockRegion(This->pStream, libOffset, cb, dwLockType);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IWICStreamImpl_Stat(IWICStream *iface,
|
|
|
|
STATSTG *pstatstg, DWORD grfStatFlag)
|
|
|
|
{
|
2011-01-11 00:47:30 +01:00
|
|
|
IWICStreamImpl *This = impl_from_IWICStream(iface);
|
2018-11-29 10:36:44 +01:00
|
|
|
TRACE("(%p, %p, %#x)\n", This, pstatstg, grfStatFlag);
|
2009-08-18 17:48:49 +02:00
|
|
|
|
|
|
|
if (!This->pStream) return WINCODEC_ERR_NOTINITIALIZED;
|
|
|
|
return IStream_Stat(This->pStream, pstatstg, grfStatFlag);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IWICStreamImpl_Clone(IWICStream *iface,
|
|
|
|
IStream **ppstm)
|
|
|
|
{
|
2011-01-11 00:47:30 +01:00
|
|
|
IWICStreamImpl *This = impl_from_IWICStream(iface);
|
2018-11-29 10:36:44 +01:00
|
|
|
TRACE("(%p, %p)\n", This, ppstm);
|
2009-08-18 17:48:49 +02:00
|
|
|
|
|
|
|
if (!This->pStream) return WINCODEC_ERR_NOTINITIALIZED;
|
|
|
|
return IStream_Clone(This->pStream, ppstm);
|
|
|
|
}
|
|
|
|
|
2018-11-29 10:36:45 +01:00
|
|
|
static HRESULT WINAPI IWICStreamImpl_InitializeFromIStream(IWICStream *iface, IStream *stream)
|
2009-08-18 17:48:49 +02:00
|
|
|
{
|
2018-11-29 10:36:45 +01:00
|
|
|
IWICStreamImpl *This = impl_from_IWICStream(iface);
|
|
|
|
HRESULT hr = S_OK;
|
|
|
|
|
|
|
|
TRACE("(%p, %p)\n", iface, stream);
|
|
|
|
|
|
|
|
if (!stream) return E_INVALIDARG;
|
|
|
|
if (This->pStream) return WINCODEC_ERR_WRONGSTATE;
|
|
|
|
|
|
|
|
IStream_AddRef(stream);
|
2012-05-29 11:29:21 +02:00
|
|
|
|
2018-11-29 10:36:45 +01:00
|
|
|
if (InterlockedCompareExchangePointer((void **)&This->pStream, stream, NULL))
|
|
|
|
{
|
|
|
|
/* Some other thread set the stream first. */
|
|
|
|
IStream_Release(stream);
|
|
|
|
hr = WINCODEC_ERR_WRONGSTATE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
2009-08-18 17:48:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IWICStreamImpl_InitializeFromFilename(IWICStream *iface,
|
|
|
|
LPCWSTR wzFileName, DWORD dwDesiredAccess)
|
|
|
|
{
|
2011-01-11 00:47:30 +01:00
|
|
|
IWICStreamImpl *This = impl_from_IWICStream(iface);
|
2010-04-27 17:20:42 +02:00
|
|
|
HRESULT hr;
|
|
|
|
DWORD dwMode;
|
|
|
|
IStream *stream;
|
|
|
|
|
|
|
|
TRACE("(%p, %s, %u)\n", iface, debugstr_w(wzFileName), dwDesiredAccess);
|
|
|
|
|
|
|
|
if (This->pStream) return WINCODEC_ERR_WRONGSTATE;
|
|
|
|
|
|
|
|
if(dwDesiredAccess & GENERIC_WRITE)
|
|
|
|
dwMode = STGM_SHARE_DENY_WRITE | STGM_WRITE | STGM_CREATE;
|
|
|
|
else if(dwDesiredAccess & GENERIC_READ)
|
|
|
|
dwMode = STGM_SHARE_DENY_WRITE | STGM_READ | STGM_FAILIFTHERE;
|
|
|
|
else
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
hr = SHCreateStreamOnFileW(wzFileName, dwMode, &stream);
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
if (InterlockedCompareExchangePointer((void**)&This->pStream, stream, NULL))
|
|
|
|
{
|
|
|
|
/* Some other thread set the stream first. */
|
|
|
|
IStream_Release(stream);
|
|
|
|
hr = WINCODEC_ERR_WRONGSTATE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
2009-08-18 17:48:49 +02:00
|
|
|
}
|
|
|
|
|
2009-08-21 12:02:10 +02:00
|
|
|
/******************************************
|
|
|
|
* IWICStream_InitializeFromMemory
|
|
|
|
*
|
|
|
|
* Initializes the internal IStream object to retrieve its data from a memory chunk.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* pbBuffer [I] pointer to the memory chunk
|
|
|
|
* cbBufferSize [I] number of bytes to use from the memory chunk
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* SUCCESS: S_OK
|
|
|
|
* FAILURE: E_INVALIDARG, if pbBuffer is NULL
|
|
|
|
* E_OUTOFMEMORY, if we run out of memory
|
|
|
|
* WINCODEC_ERR_WRONGSTATE, if the IStream object has already been initialized before
|
|
|
|
*
|
|
|
|
*/
|
2009-08-18 17:48:49 +02:00
|
|
|
static HRESULT WINAPI IWICStreamImpl_InitializeFromMemory(IWICStream *iface,
|
|
|
|
BYTE *pbBuffer, DWORD cbBufferSize)
|
|
|
|
{
|
2011-01-11 00:47:30 +01:00
|
|
|
IWICStreamImpl *This = impl_from_IWICStream(iface);
|
2009-08-21 12:02:10 +02:00
|
|
|
StreamOnMemory *pObject;
|
2018-11-29 10:36:44 +01:00
|
|
|
TRACE("(%p, %p, %u)\n", iface, pbBuffer, cbBufferSize);
|
2009-08-21 12:02:10 +02:00
|
|
|
|
|
|
|
if (!pbBuffer) return E_INVALIDARG;
|
|
|
|
if (This->pStream) return WINCODEC_ERR_WRONGSTATE;
|
|
|
|
|
|
|
|
pObject = HeapAlloc(GetProcessHeap(), 0, sizeof(StreamOnMemory));
|
|
|
|
if (!pObject) return E_OUTOFMEMORY;
|
|
|
|
|
2011-01-11 00:47:30 +01:00
|
|
|
pObject->IStream_iface.lpVtbl = &StreamOnMemory_Vtbl;
|
2009-08-21 12:02:10 +02:00
|
|
|
pObject->ref = 1;
|
2009-08-21 11:07:37 +02:00
|
|
|
pObject->pbMemory = pbBuffer;
|
|
|
|
pObject->dwMemsize = cbBufferSize;
|
|
|
|
pObject->dwCurPos = 0;
|
2010-04-09 17:53:24 +02:00
|
|
|
InitializeCriticalSection(&pObject->lock);
|
|
|
|
pObject->lock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": StreamOnMemory.lock");
|
2009-08-21 12:02:10 +02:00
|
|
|
|
2010-04-09 18:04:00 +02:00
|
|
|
if (InterlockedCompareExchangePointer((void**)&This->pStream, pObject, NULL))
|
|
|
|
{
|
|
|
|
/* Some other thread set the stream first. */
|
2011-01-11 00:47:30 +01:00
|
|
|
IStream_Release(&pObject->IStream_iface);
|
2010-04-09 18:04:00 +02:00
|
|
|
return WINCODEC_ERR_WRONGSTATE;
|
|
|
|
}
|
|
|
|
|
2009-08-21 12:02:10 +02:00
|
|
|
return S_OK;
|
2009-08-18 17:48:49 +02:00
|
|
|
}
|
|
|
|
|
2013-02-06 13:53:21 +01:00
|
|
|
static HRESULT map_file(HANDLE file, HANDLE *map, void **mem, LARGE_INTEGER *size)
|
|
|
|
{
|
|
|
|
*map = NULL;
|
|
|
|
if (!GetFileSizeEx(file, size)) return HRESULT_FROM_WIN32(GetLastError());
|
|
|
|
if (size->u.HighPart)
|
|
|
|
{
|
|
|
|
WARN("file too large\n");
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
if (!(*map = CreateFileMappingW(file, NULL, PAGE_READONLY, 0, size->u.LowPart, NULL)))
|
|
|
|
{
|
|
|
|
return HRESULT_FROM_WIN32(GetLastError());
|
|
|
|
}
|
|
|
|
if (!(*mem = MapViewOfFile(*map, FILE_MAP_READ, 0, 0, size->u.LowPart)))
|
|
|
|
{
|
|
|
|
CloseHandle(*map);
|
|
|
|
return HRESULT_FROM_WIN32(GetLastError());
|
|
|
|
}
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT stream_initialize_from_filehandle(IWICStream *iface, HANDLE file)
|
|
|
|
{
|
|
|
|
IWICStreamImpl *This = impl_from_IWICStream(iface);
|
|
|
|
StreamOnFileHandle *pObject;
|
|
|
|
IWICStream *stream = NULL;
|
|
|
|
HANDLE map;
|
|
|
|
void *mem;
|
|
|
|
LARGE_INTEGER size;
|
|
|
|
HRESULT hr;
|
|
|
|
TRACE("(%p,%p)\n", iface, file);
|
|
|
|
|
|
|
|
if (This->pStream) return WINCODEC_ERR_WRONGSTATE;
|
|
|
|
|
|
|
|
hr = map_file(file, &map, &mem, &size);
|
|
|
|
if (FAILED(hr)) return hr;
|
|
|
|
|
|
|
|
hr = StreamImpl_Create(&stream);
|
|
|
|
if (FAILED(hr)) goto error;
|
|
|
|
|
|
|
|
hr = IWICStreamImpl_InitializeFromMemory(stream, mem, size.u.LowPart);
|
|
|
|
if (FAILED(hr)) goto error;
|
|
|
|
|
|
|
|
pObject = HeapAlloc(GetProcessHeap(), 0, sizeof(StreamOnFileHandle));
|
|
|
|
if (!pObject)
|
|
|
|
{
|
|
|
|
hr = E_OUTOFMEMORY;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
pObject->IStream_iface.lpVtbl = &StreamOnFileHandle_Vtbl;
|
|
|
|
pObject->ref = 1;
|
|
|
|
pObject->map = map;
|
|
|
|
pObject->mem = mem;
|
|
|
|
pObject->stream = stream;
|
|
|
|
|
|
|
|
if (InterlockedCompareExchangePointer((void**)&This->pStream, pObject, NULL))
|
|
|
|
{
|
|
|
|
/* Some other thread set the stream first. */
|
|
|
|
IStream_Release(&pObject->IStream_iface);
|
|
|
|
return WINCODEC_ERR_WRONGSTATE;
|
|
|
|
}
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
error:
|
|
|
|
if (stream) IWICStream_Release(stream);
|
|
|
|
UnmapViewOfFile(mem);
|
|
|
|
CloseHandle(map);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2009-08-18 17:48:49 +02:00
|
|
|
static HRESULT WINAPI IWICStreamImpl_InitializeFromIStreamRegion(IWICStream *iface,
|
|
|
|
IStream *pIStream, ULARGE_INTEGER ulOffset, ULARGE_INTEGER ulMaxSize)
|
|
|
|
{
|
2011-01-11 00:47:30 +01:00
|
|
|
IWICStreamImpl *This = impl_from_IWICStream(iface);
|
2010-08-28 01:24:29 +02:00
|
|
|
StreamOnStreamRange *pObject;
|
2018-11-29 10:36:44 +01:00
|
|
|
|
|
|
|
TRACE("(%p,%p,%s,%s)\n", iface, pIStream, wine_dbgstr_longlong(ulOffset.QuadPart),
|
|
|
|
wine_dbgstr_longlong(ulMaxSize.QuadPart));
|
2010-08-28 01:24:29 +02:00
|
|
|
|
|
|
|
if (!pIStream) return E_INVALIDARG;
|
|
|
|
if (This->pStream) return WINCODEC_ERR_WRONGSTATE;
|
|
|
|
|
|
|
|
pObject = HeapAlloc(GetProcessHeap(), 0, sizeof(StreamOnStreamRange));
|
|
|
|
if (!pObject) return E_OUTOFMEMORY;
|
|
|
|
|
2011-01-11 00:47:30 +01:00
|
|
|
pObject->IStream_iface.lpVtbl = &StreamOnStreamRange_Vtbl;
|
2010-08-28 01:24:29 +02:00
|
|
|
pObject->ref = 1;
|
|
|
|
IStream_AddRef(pIStream);
|
|
|
|
pObject->stream = pIStream;
|
|
|
|
pObject->pos.QuadPart = 0;
|
|
|
|
pObject->offset = ulOffset;
|
|
|
|
pObject->max_size = ulMaxSize;
|
|
|
|
InitializeCriticalSection(&pObject->lock);
|
|
|
|
pObject->lock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": StreamOnStreamRange.lock");
|
|
|
|
|
|
|
|
if (InterlockedCompareExchangePointer((void**)&This->pStream, pObject, NULL))
|
|
|
|
{
|
|
|
|
/* Some other thread set the stream first. */
|
2011-01-11 00:47:30 +01:00
|
|
|
IStream_Release(&pObject->IStream_iface);
|
2010-08-28 01:24:29 +02:00
|
|
|
return WINCODEC_ERR_WRONGSTATE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
2009-08-18 17:48:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-05-28 10:49:31 +02:00
|
|
|
static const IWICStreamVtbl WICStream_Vtbl =
|
2009-08-18 17:48:49 +02:00
|
|
|
{
|
|
|
|
/*** IUnknown methods ***/
|
|
|
|
IWICStreamImpl_QueryInterface,
|
|
|
|
IWICStreamImpl_AddRef,
|
|
|
|
IWICStreamImpl_Release,
|
|
|
|
/*** ISequentialStream methods ***/
|
|
|
|
IWICStreamImpl_Read,
|
|
|
|
IWICStreamImpl_Write,
|
|
|
|
/*** IStream methods ***/
|
|
|
|
IWICStreamImpl_Seek,
|
|
|
|
IWICStreamImpl_SetSize,
|
|
|
|
IWICStreamImpl_CopyTo,
|
|
|
|
IWICStreamImpl_Commit,
|
|
|
|
IWICStreamImpl_Revert,
|
|
|
|
IWICStreamImpl_LockRegion,
|
|
|
|
IWICStreamImpl_UnlockRegion,
|
|
|
|
IWICStreamImpl_Stat,
|
|
|
|
IWICStreamImpl_Clone,
|
|
|
|
/*** IWICStream methods ***/
|
|
|
|
IWICStreamImpl_InitializeFromIStream,
|
|
|
|
IWICStreamImpl_InitializeFromFilename,
|
|
|
|
IWICStreamImpl_InitializeFromMemory,
|
|
|
|
IWICStreamImpl_InitializeFromIStreamRegion,
|
|
|
|
};
|
|
|
|
|
|
|
|
HRESULT StreamImpl_Create(IWICStream **stream)
|
|
|
|
{
|
|
|
|
IWICStreamImpl *pObject;
|
|
|
|
|
|
|
|
if( !stream ) return E_INVALIDARG;
|
|
|
|
|
|
|
|
pObject = HeapAlloc(GetProcessHeap(), 0, sizeof(IWICStreamImpl));
|
|
|
|
if( !pObject ) {
|
|
|
|
*stream = NULL;
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
2011-01-11 00:47:30 +01:00
|
|
|
pObject->IWICStream_iface.lpVtbl = &WICStream_Vtbl;
|
2009-08-18 17:48:49 +02:00
|
|
|
pObject->ref = 1;
|
|
|
|
pObject->pStream = NULL;
|
|
|
|
|
2011-01-11 00:47:30 +01:00
|
|
|
*stream = &pObject->IWICStream_iface;
|
2009-08-18 17:48:49 +02:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|