1999-03-27 17:15:22 +01:00
|
|
|
/*
|
2002-07-19 05:13:58 +02:00
|
|
|
* SHLWAPI Registry Stream functions
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* Copyright 1999 Juergen Schmied
|
2002-07-19 05:13:58 +02:00
|
|
|
* Copyright 2002 Jon Griffiths
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* 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
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
1999-03-27 17:15:22 +01:00
|
|
|
*/
|
2002-03-10 00:29:33 +01:00
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
1999-03-27 17:15:22 +01:00
|
|
|
#include <string.h>
|
|
|
|
|
2004-10-07 05:06:48 +02:00
|
|
|
#define COBJMACROS
|
|
|
|
|
1999-03-27 17:15:22 +01:00
|
|
|
#include "winerror.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "windef.h"
|
2000-09-26 02:00:55 +02:00
|
|
|
#include "winbase.h"
|
2002-12-05 21:33:07 +01:00
|
|
|
#include "objbase.h"
|
1999-03-27 17:15:22 +01:00
|
|
|
#include "winreg.h"
|
2005-12-09 11:51:17 +01:00
|
|
|
#include "shlwapi.h"
|
1999-03-27 17:15:22 +01:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
1999-03-27 17:15:22 +01:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(shell);
|
1999-04-19 16:56:29 +02:00
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
typedef struct
|
2005-06-06 21:50:35 +02:00
|
|
|
{
|
2010-11-30 00:05:03 +01:00
|
|
|
IStream IStream_iface;
|
2005-07-29 16:15:31 +02:00
|
|
|
LONG ref;
|
2002-07-19 05:13:58 +02:00
|
|
|
LPBYTE pbBuffer;
|
|
|
|
DWORD dwLength;
|
|
|
|
DWORD dwPos;
|
2009-09-28 22:24:13 +02:00
|
|
|
DWORD dwMode;
|
1999-03-27 17:15:22 +01:00
|
|
|
} ISHRegStream;
|
|
|
|
|
2010-11-30 00:05:03 +01:00
|
|
|
static inline ISHRegStream *impl_from_IStream(IStream *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, ISHRegStream, IStream_iface);
|
|
|
|
}
|
|
|
|
|
1999-03-27 17:15:22 +01:00
|
|
|
/**************************************************************************
|
|
|
|
* IStream_fnQueryInterface
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI IStream_fnQueryInterface(IStream *iface, REFIID riid, LPVOID *ppvObj)
|
|
|
|
{
|
2010-11-30 00:05:03 +01:00
|
|
|
ISHRegStream *This = impl_from_IStream(iface);
|
1999-03-27 17:15:22 +01:00
|
|
|
|
2000-01-18 06:09:49 +01:00
|
|
|
TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj);
|
1999-03-27 17:15:22 +01:00
|
|
|
|
|
|
|
*ppvObj = NULL;
|
|
|
|
|
2017-01-25 12:19:46 +01:00
|
|
|
if(IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IStream))
|
|
|
|
*ppvObj = &This->IStream_iface;
|
1999-03-27 17:15:22 +01:00
|
|
|
|
|
|
|
if(*ppvObj)
|
2002-06-01 01:06:46 +02:00
|
|
|
{
|
|
|
|
IStream_AddRef((IStream*)*ppvObj);
|
1999-06-12 17:45:58 +02:00
|
|
|
TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
|
1999-03-27 17:15:22 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
1999-06-12 17:45:58 +02:00
|
|
|
TRACE("-- Interface: E_NOINTERFACE\n");
|
1999-03-27 17:15:22 +01:00
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* IStream_fnAddRef
|
|
|
|
*/
|
|
|
|
static ULONG WINAPI IStream_fnAddRef(IStream *iface)
|
|
|
|
{
|
2010-11-30 00:05:03 +01:00
|
|
|
ISHRegStream *This = impl_from_IStream(iface);
|
2005-01-12 20:29:43 +01:00
|
|
|
ULONG refCount = InterlockedIncrement(&This->ref);
|
|
|
|
|
2006-10-06 12:43:28 +02:00
|
|
|
TRACE("(%p)->(ref before=%u)\n",This, refCount - 1);
|
1999-03-27 17:15:22 +01:00
|
|
|
|
2005-01-12 20:29:43 +01:00
|
|
|
return refCount;
|
1999-03-27 17:15:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* IStream_fnRelease
|
|
|
|
*/
|
|
|
|
static ULONG WINAPI IStream_fnRelease(IStream *iface)
|
|
|
|
{
|
2010-11-30 00:05:03 +01:00
|
|
|
ISHRegStream *This = impl_from_IStream(iface);
|
2005-01-12 20:29:43 +01:00
|
|
|
ULONG refCount = InterlockedDecrement(&This->ref);
|
1999-03-27 17:15:22 +01:00
|
|
|
|
2006-10-06 12:43:28 +02:00
|
|
|
TRACE("(%p)->(ref before=%u)\n",This, refCount + 1);
|
1999-03-27 17:15:22 +01:00
|
|
|
|
2005-01-12 20:29:43 +01:00
|
|
|
if (!refCount)
|
2002-07-19 05:13:58 +02:00
|
|
|
{
|
2009-09-28 22:24:13 +02:00
|
|
|
HeapFree(GetProcessHeap(),0,This->pbBuffer);
|
1999-03-27 17:15:22 +01:00
|
|
|
HeapFree(GetProcessHeap(),0,This);
|
|
|
|
return 0;
|
|
|
|
}
|
2005-01-12 20:29:43 +01:00
|
|
|
|
|
|
|
return refCount;
|
1999-03-27 17:15:22 +01:00
|
|
|
}
|
|
|
|
|
2002-07-19 05:13:58 +02:00
|
|
|
/**************************************************************************
|
|
|
|
* IStream_fnRead
|
|
|
|
*/
|
2000-07-26 19:51:32 +02:00
|
|
|
static HRESULT WINAPI IStream_fnRead (IStream * iface, void* pv, ULONG cb, ULONG* pcbRead)
|
1999-03-27 17:15:22 +01:00
|
|
|
{
|
2010-11-30 00:05:03 +01:00
|
|
|
ISHRegStream *This = impl_from_IStream(iface);
|
2009-09-28 22:24:07 +02:00
|
|
|
DWORD dwBytesToRead;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2006-10-06 12:43:28 +02:00
|
|
|
TRACE("(%p)->(%p,0x%08x,%p)\n",This, pv, cb, pcbRead);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2009-09-28 22:24:07 +02:00
|
|
|
if (This->dwPos >= This->dwLength)
|
|
|
|
dwBytesToRead = 0;
|
|
|
|
else
|
|
|
|
dwBytesToRead = This->dwLength - This->dwPos;
|
1999-03-27 17:15:22 +01:00
|
|
|
|
2009-09-28 22:24:07 +02:00
|
|
|
dwBytesToRead = (cb > dwBytesToRead) ? dwBytesToRead : cb;
|
|
|
|
if (dwBytesToRead != 0) /* not at end of buffer and we want to read something */
|
|
|
|
{
|
|
|
|
memmove(pv, This->pbBuffer + This->dwPos, dwBytesToRead);
|
|
|
|
This->dwPos += dwBytesToRead; /* adjust pointer */
|
|
|
|
}
|
1999-03-27 17:15:22 +01:00
|
|
|
|
|
|
|
if (pcbRead)
|
|
|
|
*pcbRead = dwBytesToRead;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
2002-07-19 05:13:58 +02:00
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* IStream_fnWrite
|
|
|
|
*/
|
2000-07-26 19:51:32 +02:00
|
|
|
static HRESULT WINAPI IStream_fnWrite (IStream * iface, const void* pv, ULONG cb, ULONG* pcbWritten)
|
1999-03-27 17:15:22 +01:00
|
|
|
{
|
2010-11-30 00:05:03 +01:00
|
|
|
ISHRegStream *This = impl_from_IStream(iface);
|
2009-09-28 22:24:08 +02:00
|
|
|
DWORD newLen = This->dwPos + cb;
|
1999-03-27 17:15:22 +01:00
|
|
|
|
2009-09-28 22:24:08 +02:00
|
|
|
TRACE("(%p, %p, %d, %p)\n",This, pv, cb, pcbWritten);
|
|
|
|
|
|
|
|
if (newLen < This->dwPos) /* overflow */
|
|
|
|
return STG_E_INSUFFICIENTMEMORY;
|
|
|
|
|
|
|
|
if (newLen > This->dwLength)
|
|
|
|
{
|
|
|
|
LPBYTE newBuf = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, This->pbBuffer, newLen);
|
|
|
|
if (!newBuf)
|
|
|
|
return STG_E_INSUFFICIENTMEMORY;
|
|
|
|
|
|
|
|
This->dwLength = newLen;
|
|
|
|
This->pbBuffer = newBuf;
|
|
|
|
}
|
|
|
|
memmove(This->pbBuffer + This->dwPos, pv, cb);
|
|
|
|
This->dwPos += cb; /* adjust pointer */
|
1999-03-27 17:15:22 +01:00
|
|
|
|
2002-07-19 05:13:58 +02:00
|
|
|
if (pcbWritten)
|
2009-09-28 22:24:08 +02:00
|
|
|
*pcbWritten = cb;
|
2002-07-19 05:13:58 +02:00
|
|
|
|
2009-09-28 22:24:08 +02:00
|
|
|
return S_OK;
|
1999-03-27 17:15:22 +01:00
|
|
|
}
|
2002-07-19 05:13:58 +02:00
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* IStream_fnSeek
|
|
|
|
*/
|
2000-07-26 19:51:32 +02:00
|
|
|
static HRESULT WINAPI IStream_fnSeek (IStream * iface, LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER* plibNewPosition)
|
1999-03-27 17:15:22 +01:00
|
|
|
{
|
2010-11-30 00:05:03 +01:00
|
|
|
ISHRegStream *This = impl_from_IStream(iface);
|
2009-09-28 22:24:08 +02:00
|
|
|
LARGE_INTEGER tmp;
|
|
|
|
TRACE("(%p, %s, %d %p)\n", This,
|
|
|
|
wine_dbgstr_longlong(dlibMove.QuadPart), dwOrigin, plibNewPosition);
|
|
|
|
|
|
|
|
if (dwOrigin == STREAM_SEEK_SET)
|
|
|
|
tmp = dlibMove;
|
|
|
|
else if (dwOrigin == STREAM_SEEK_CUR)
|
|
|
|
tmp.QuadPart = This->dwPos + dlibMove.QuadPart;
|
|
|
|
else if (dwOrigin == STREAM_SEEK_END)
|
|
|
|
tmp.QuadPart = This->dwLength + dlibMove.QuadPart;
|
|
|
|
else
|
|
|
|
return STG_E_INVALIDPARAMETER;
|
1999-03-27 17:15:22 +01:00
|
|
|
|
2009-09-28 22:24:08 +02:00
|
|
|
if (tmp.QuadPart < 0)
|
|
|
|
return STG_E_INVALIDFUNCTION;
|
|
|
|
|
|
|
|
/* we cut off the high part here */
|
2009-10-17 20:29:10 +02:00
|
|
|
This->dwPos = tmp.u.LowPart;
|
1999-03-27 17:15:22 +01:00
|
|
|
|
2002-07-19 05:13:58 +02:00
|
|
|
if (plibNewPosition)
|
2009-09-28 22:24:08 +02:00
|
|
|
plibNewPosition->QuadPart = This->dwPos;
|
|
|
|
return S_OK;
|
1999-03-27 17:15:22 +01:00
|
|
|
}
|
2002-07-19 05:13:58 +02:00
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* IStream_fnSetSize
|
|
|
|
*/
|
2000-07-26 19:51:32 +02:00
|
|
|
static HRESULT WINAPI IStream_fnSetSize (IStream * iface, ULARGE_INTEGER libNewSize)
|
1999-03-27 17:15:22 +01:00
|
|
|
{
|
2010-11-30 00:05:03 +01:00
|
|
|
ISHRegStream *This = impl_from_IStream(iface);
|
2009-09-28 22:24:08 +02:00
|
|
|
DWORD newLen;
|
|
|
|
LPBYTE newBuf;
|
|
|
|
|
|
|
|
TRACE("(%p, %s)\n", This, wine_dbgstr_longlong(libNewSize.QuadPart));
|
1999-03-27 17:15:22 +01:00
|
|
|
|
2009-09-28 22:24:08 +02:00
|
|
|
/* we cut off the high part here */
|
2009-10-17 20:29:10 +02:00
|
|
|
newLen = libNewSize.u.LowPart;
|
2009-09-28 22:24:08 +02:00
|
|
|
newBuf = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, This->pbBuffer, newLen);
|
|
|
|
if (!newBuf)
|
|
|
|
return STG_E_INSUFFICIENTMEMORY;
|
|
|
|
|
|
|
|
This->pbBuffer = newBuf;
|
|
|
|
This->dwLength = newLen;
|
|
|
|
|
|
|
|
return S_OK;
|
1999-03-27 17:15:22 +01:00
|
|
|
}
|
2002-07-19 05:13:58 +02:00
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* IStream_fnCopyTo
|
|
|
|
*/
|
2000-07-26 19:51:32 +02:00
|
|
|
static HRESULT WINAPI IStream_fnCopyTo (IStream * iface, IStream* pstm, ULARGE_INTEGER cb, ULARGE_INTEGER* pcbRead, ULARGE_INTEGER* pcbWritten)
|
1999-03-27 17:15:22 +01:00
|
|
|
{
|
2010-11-30 00:05:03 +01:00
|
|
|
ISHRegStream *This = impl_from_IStream(iface);
|
1999-03-27 17:15:22 +01:00
|
|
|
|
1999-06-12 17:45:58 +02:00
|
|
|
TRACE("(%p)\n",This);
|
2002-07-19 05:13:58 +02:00
|
|
|
if (pcbRead)
|
|
|
|
pcbRead->QuadPart = 0;
|
|
|
|
if (pcbWritten)
|
|
|
|
pcbWritten->QuadPart = 0;
|
2009-09-28 22:24:10 +02:00
|
|
|
|
|
|
|
/* TODO implement */
|
1999-03-27 17:15:22 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
2002-07-19 05:13:58 +02:00
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* IStream_fnCommit
|
|
|
|
*/
|
2000-07-26 19:51:32 +02:00
|
|
|
static HRESULT WINAPI IStream_fnCommit (IStream * iface, DWORD grfCommitFlags)
|
1999-03-27 17:15:22 +01:00
|
|
|
{
|
2010-11-30 00:05:03 +01:00
|
|
|
ISHRegStream *This = impl_from_IStream(iface);
|
1999-03-27 17:15:22 +01:00
|
|
|
|
1999-06-12 17:45:58 +02:00
|
|
|
TRACE("(%p)\n",This);
|
1999-03-27 17:15:22 +01:00
|
|
|
|
2009-09-28 22:24:10 +02:00
|
|
|
/* commit not supported by this stream */
|
1999-03-27 17:15:22 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
2002-07-19 05:13:58 +02:00
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* IStream_fnRevert
|
|
|
|
*/
|
2000-07-26 19:51:32 +02:00
|
|
|
static HRESULT WINAPI IStream_fnRevert (IStream * iface)
|
1999-03-27 17:15:22 +01:00
|
|
|
{
|
2010-11-30 00:05:03 +01:00
|
|
|
ISHRegStream *This = impl_from_IStream(iface);
|
1999-03-27 17:15:22 +01:00
|
|
|
|
1999-06-12 17:45:58 +02:00
|
|
|
TRACE("(%p)\n",This);
|
1999-03-27 17:15:22 +01:00
|
|
|
|
2009-09-28 22:24:10 +02:00
|
|
|
/* revert not supported by this stream */
|
1999-03-27 17:15:22 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2002-07-19 05:13:58 +02:00
|
|
|
/**************************************************************************
|
|
|
|
* IStream_fnLockUnlockRegion
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI IStream_fnLockUnlockRegion (IStream * iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
|
1999-03-27 17:15:22 +01:00
|
|
|
{
|
2010-11-30 00:05:03 +01:00
|
|
|
ISHRegStream *This = impl_from_IStream(iface);
|
1999-03-27 17:15:22 +01:00
|
|
|
|
1999-06-12 17:45:58 +02:00
|
|
|
TRACE("(%p)\n",This);
|
1999-03-27 17:15:22 +01:00
|
|
|
|
2009-09-28 22:24:10 +02:00
|
|
|
/* lock/unlock not supported by this stream */
|
1999-03-27 17:15:22 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
2002-07-19 05:13:58 +02:00
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* IStream_fnStat
|
|
|
|
*/
|
2009-09-28 22:24:00 +02:00
|
|
|
static HRESULT WINAPI IStream_fnStat (IStream * iface, STATSTG* pstatstg, DWORD grfStatFlag)
|
1999-03-27 17:15:22 +01:00
|
|
|
{
|
2010-11-30 00:05:03 +01:00
|
|
|
ISHRegStream *This = impl_from_IStream(iface);
|
1999-03-27 17:15:22 +01:00
|
|
|
|
2009-09-28 22:24:00 +02:00
|
|
|
TRACE("(%p, %p, %d)\n",This,pstatstg,grfStatFlag);
|
|
|
|
|
|
|
|
pstatstg->pwcsName = NULL;
|
|
|
|
pstatstg->type = STGTY_STREAM;
|
|
|
|
pstatstg->cbSize.QuadPart = This->dwLength;
|
|
|
|
pstatstg->mtime.dwHighDateTime = 0;
|
|
|
|
pstatstg->mtime.dwLowDateTime = 0;
|
|
|
|
pstatstg->ctime.dwHighDateTime = 0;
|
|
|
|
pstatstg->ctime.dwLowDateTime = 0;
|
|
|
|
pstatstg->atime.dwHighDateTime = 0;
|
|
|
|
pstatstg->atime.dwLowDateTime = 0;
|
2009-09-28 22:24:13 +02:00
|
|
|
pstatstg->grfMode = This->dwMode;
|
2009-09-28 22:24:00 +02:00
|
|
|
pstatstg->grfLocksSupported = 0;
|
|
|
|
pstatstg->clsid = CLSID_NULL;
|
|
|
|
pstatstg->grfStateBits = 0;
|
|
|
|
pstatstg->reserved = 0;
|
1999-03-27 17:15:22 +01:00
|
|
|
|
2009-09-28 22:24:00 +02:00
|
|
|
return S_OK;
|
1999-03-27 17:15:22 +01:00
|
|
|
}
|
2002-07-19 05:13:58 +02:00
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* IStream_fnClone
|
|
|
|
*/
|
2000-07-26 19:51:32 +02:00
|
|
|
static HRESULT WINAPI IStream_fnClone (IStream * iface, IStream** ppstm)
|
1999-03-27 17:15:22 +01:00
|
|
|
{
|
2010-11-30 00:05:03 +01:00
|
|
|
ISHRegStream *This = impl_from_IStream(iface);
|
1999-03-27 17:15:22 +01:00
|
|
|
|
1999-06-12 17:45:58 +02:00
|
|
|
TRACE("(%p)\n",This);
|
2009-09-28 22:24:10 +02:00
|
|
|
*ppstm = NULL;
|
|
|
|
|
|
|
|
/* clone not supported by this stream */
|
1999-03-27 17:15:22 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2005-06-06 21:50:35 +02:00
|
|
|
static const IStreamVtbl rstvt =
|
2002-06-01 01:06:46 +02:00
|
|
|
{
|
1999-03-27 17:15:22 +01:00
|
|
|
IStream_fnQueryInterface,
|
|
|
|
IStream_fnAddRef,
|
|
|
|
IStream_fnRelease,
|
|
|
|
IStream_fnRead,
|
|
|
|
IStream_fnWrite,
|
|
|
|
IStream_fnSeek,
|
|
|
|
IStream_fnSetSize,
|
|
|
|
IStream_fnCopyTo,
|
|
|
|
IStream_fnCommit,
|
|
|
|
IStream_fnRevert,
|
2002-07-19 05:13:58 +02:00
|
|
|
IStream_fnLockUnlockRegion,
|
|
|
|
IStream_fnLockUnlockRegion,
|
1999-03-27 17:15:22 +01:00
|
|
|
IStream_fnStat,
|
|
|
|
IStream_fnClone
|
2002-07-19 05:13:58 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* IStream_Create
|
|
|
|
*
|
|
|
|
* Internal helper: Create and initialise a new registry stream object.
|
|
|
|
*/
|
2009-09-28 22:24:13 +02:00
|
|
|
static ISHRegStream *IStream_Create(HKEY hKey, LPBYTE pbBuffer, DWORD dwLength)
|
2002-07-19 05:13:58 +02:00
|
|
|
{
|
|
|
|
ISHRegStream* regStream;
|
|
|
|
|
2005-03-24 22:01:35 +01:00
|
|
|
regStream = HeapAlloc(GetProcessHeap(), 0, sizeof(ISHRegStream));
|
2002-07-19 05:13:58 +02:00
|
|
|
|
|
|
|
if (regStream)
|
|
|
|
{
|
2010-11-30 00:05:03 +01:00
|
|
|
regStream->IStream_iface.lpVtbl = &rstvt;
|
2002-07-19 05:13:58 +02:00
|
|
|
regStream->ref = 1;
|
|
|
|
regStream->pbBuffer = pbBuffer;
|
|
|
|
regStream->dwLength = dwLength;
|
|
|
|
regStream->dwPos = 0;
|
2009-09-28 22:24:13 +02:00
|
|
|
regStream->dwMode = STGM_READWRITE;
|
2002-07-19 05:13:58 +02:00
|
|
|
}
|
|
|
|
TRACE ("Returning %p\n", regStream);
|
2009-09-28 22:24:13 +02:00
|
|
|
return regStream;
|
2002-07-19 05:13:58 +02:00
|
|
|
}
|
|
|
|
|
2002-09-20 21:41:08 +02:00
|
|
|
/*************************************************************************
|
|
|
|
* SHCreateStreamWrapper [SHLWAPI.@]
|
|
|
|
*
|
2003-03-18 19:35:48 +01:00
|
|
|
* Create an IStream object on a block of memory.
|
2002-09-20 21:41:08 +02:00
|
|
|
*
|
|
|
|
* PARAMS
|
2003-03-18 19:35:48 +01:00
|
|
|
* lpbData [I] Memory block to create the IStream object on
|
2002-09-20 21:41:08 +02:00
|
|
|
* dwDataLen [I] Length of data block
|
|
|
|
* dwReserved [I] Reserved, Must be 0.
|
2003-03-18 19:35:48 +01:00
|
|
|
* lppStream [O] Destination for IStream object
|
2002-09-20 21:41:08 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
2003-03-18 19:35:48 +01:00
|
|
|
* Success: S_OK. lppStream contains the new IStream object.
|
2002-09-20 21:41:08 +02:00
|
|
|
* Failure: E_INVALIDARG, if any parameters are invalid,
|
|
|
|
* E_OUTOFMEMORY if memory allocation fails.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* The stream assumes ownership of the memory passed to it.
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI SHCreateStreamWrapper(LPBYTE lpbData, DWORD dwDataLen,
|
|
|
|
DWORD dwReserved, IStream **lppStream)
|
|
|
|
{
|
2010-11-30 00:05:03 +01:00
|
|
|
ISHRegStream *strm;
|
2002-09-20 21:41:08 +02:00
|
|
|
|
|
|
|
if (lppStream)
|
|
|
|
*lppStream = NULL;
|
|
|
|
|
|
|
|
if(dwReserved || !lppStream)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2010-11-30 00:05:03 +01:00
|
|
|
strm = IStream_Create(NULL, lpbData, dwDataLen);
|
2002-09-20 21:41:08 +02:00
|
|
|
|
2010-11-30 00:05:03 +01:00
|
|
|
if(!strm)
|
2002-09-20 21:41:08 +02:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2010-11-30 00:05:03 +01:00
|
|
|
IStream_QueryInterface(&strm->IStream_iface, &IID_IStream, (void**)lppStream);
|
|
|
|
IStream_Release(&strm->IStream_iface);
|
2002-09-20 21:41:08 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|