1999-03-27 16:15:22 +00:00
|
|
|
/*
|
2002-07-19 03:13:58 +00:00
|
|
|
* SHLWAPI Registry Stream functions
|
2002-03-09 23:29:33 +00:00
|
|
|
*
|
|
|
|
* Copyright 1999 Juergen Schmied
|
2002-07-19 03:13:58 +00:00
|
|
|
* Copyright 2002 Jon Griffiths
|
2002-03-09 23:29:33 +00: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
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
1999-03-27 16:15:22 +00:00
|
|
|
*/
|
2002-03-09 23:29:33 +00:00
|
|
|
|
2003-09-05 23:08:26 +00:00
|
|
|
#include <stdarg.h>
|
1999-03-27 16:15:22 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
2004-10-07 03:06:48 +00:00
|
|
|
#define COBJMACROS
|
|
|
|
|
1999-03-27 16:15:22 +00:00
|
|
|
#include "winerror.h"
|
2003-09-05 23:08:26 +00:00
|
|
|
#include "windef.h"
|
2000-09-26 00:00:55 +00:00
|
|
|
#include "winbase.h"
|
2002-12-05 20:33:07 +00:00
|
|
|
#include "objbase.h"
|
1999-03-27 16:15:22 +00:00
|
|
|
#include "winreg.h"
|
|
|
|
|
2002-03-09 23:29:33 +00:00
|
|
|
#include "wine/debug.h"
|
1999-03-27 16:15:22 +00:00
|
|
|
|
2002-03-09 23:29:33 +00:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(shell);
|
1999-04-19 14:56:29 +00:00
|
|
|
|
2002-05-31 23:06:46 +00:00
|
|
|
typedef struct
|
2004-08-12 19:52:49 +00:00
|
|
|
{ IStreamVtbl *lpVtbl;
|
2002-07-19 03:13:58 +00:00
|
|
|
DWORD ref;
|
|
|
|
HKEY hKey;
|
|
|
|
LPBYTE pbBuffer;
|
|
|
|
DWORD dwLength;
|
|
|
|
DWORD dwPos;
|
1999-03-27 16:15:22 +00:00
|
|
|
} ISHRegStream;
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* IStream_fnQueryInterface
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI IStream_fnQueryInterface(IStream *iface, REFIID riid, LPVOID *ppvObj)
|
|
|
|
{
|
2004-09-06 20:34:29 +00:00
|
|
|
ISHRegStream *This = (ISHRegStream *)iface;
|
1999-03-27 16:15:22 +00:00
|
|
|
|
2000-01-18 05:09:49 +00:00
|
|
|
TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj);
|
1999-03-27 16:15:22 +00:00
|
|
|
|
|
|
|
*ppvObj = NULL;
|
|
|
|
|
|
|
|
if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
|
2002-07-19 03:13:58 +00:00
|
|
|
*ppvObj = This;
|
1999-03-27 16:15:22 +00:00
|
|
|
else if(IsEqualIID(riid, &IID_IStream)) /*IStream*/
|
2002-07-19 03:13:58 +00:00
|
|
|
*ppvObj = This;
|
1999-03-27 16:15:22 +00:00
|
|
|
|
|
|
|
if(*ppvObj)
|
2002-05-31 23:06:46 +00:00
|
|
|
{
|
|
|
|
IStream_AddRef((IStream*)*ppvObj);
|
1999-06-12 15:45:58 +00:00
|
|
|
TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
|
1999-03-27 16:15:22 +00:00
|
|
|
return S_OK;
|
|
|
|
}
|
1999-06-12 15:45:58 +00:00
|
|
|
TRACE("-- Interface: E_NOINTERFACE\n");
|
1999-03-27 16:15:22 +00:00
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* IStream_fnAddRef
|
|
|
|
*/
|
|
|
|
static ULONG WINAPI IStream_fnAddRef(IStream *iface)
|
|
|
|
{
|
2004-09-06 20:34:29 +00:00
|
|
|
ISHRegStream *This = (ISHRegStream *)iface;
|
2005-01-12 19:29:43 +00:00
|
|
|
ULONG refCount = InterlockedIncrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p)->(ref before=%lu)\n",This, refCount - 1);
|
1999-03-27 16:15:22 +00:00
|
|
|
|
2005-01-12 19:29:43 +00:00
|
|
|
return refCount;
|
1999-03-27 16:15:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* IStream_fnRelease
|
|
|
|
*/
|
|
|
|
static ULONG WINAPI IStream_fnRelease(IStream *iface)
|
|
|
|
{
|
2004-09-06 20:34:29 +00:00
|
|
|
ISHRegStream *This = (ISHRegStream *)iface;
|
2005-01-12 19:29:43 +00:00
|
|
|
ULONG refCount = InterlockedDecrement(&This->ref);
|
1999-03-27 16:15:22 +00:00
|
|
|
|
2005-01-12 19:29:43 +00:00
|
|
|
TRACE("(%p)->(ref before=%lu)\n",This, refCount + 1);
|
1999-03-27 16:15:22 +00:00
|
|
|
|
2005-01-12 19:29:43 +00:00
|
|
|
if (!refCount)
|
2002-07-19 03:13:58 +00:00
|
|
|
{
|
|
|
|
TRACE(" destroying SHReg IStream (%p)\n",This);
|
1999-03-27 16:15:22 +00:00
|
|
|
|
2004-12-23 17:06:43 +00:00
|
|
|
HeapFree(GetProcessHeap(),0,This->pbBuffer);
|
1999-03-27 16:15:22 +00:00
|
|
|
|
|
|
|
if (This->hKey)
|
|
|
|
RegCloseKey(This->hKey);
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(),0,This);
|
|
|
|
return 0;
|
|
|
|
}
|
2005-01-12 19:29:43 +00:00
|
|
|
|
|
|
|
return refCount;
|
1999-03-27 16:15:22 +00:00
|
|
|
}
|
|
|
|
|
2002-07-19 03:13:58 +00:00
|
|
|
/**************************************************************************
|
|
|
|
* IStream_fnRead
|
|
|
|
*/
|
2000-07-26 17:51:32 +00:00
|
|
|
static HRESULT WINAPI IStream_fnRead (IStream * iface, void* pv, ULONG cb, ULONG* pcbRead)
|
1999-03-27 16:15:22 +00:00
|
|
|
{
|
2004-09-06 20:34:29 +00:00
|
|
|
ISHRegStream *This = (ISHRegStream *)iface;
|
1999-03-27 16:15:22 +00:00
|
|
|
|
|
|
|
DWORD dwBytesToRead, dwBytesLeft;
|
2002-05-31 23:06:46 +00:00
|
|
|
|
1999-06-12 15:45:58 +00:00
|
|
|
TRACE("(%p)->(%p,0x%08lx,%p)\n",This, pv, cb, pcbRead);
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2002-07-19 03:13:58 +00:00
|
|
|
if (!pv)
|
1999-03-27 16:15:22 +00:00
|
|
|
return STG_E_INVALIDPOINTER;
|
2002-05-31 23:06:46 +00:00
|
|
|
|
1999-03-27 16:15:22 +00:00
|
|
|
dwBytesLeft = This->dwLength - This->dwPos;
|
|
|
|
|
2002-07-19 03:13:58 +00:00
|
|
|
if ( 0 >= dwBytesLeft ) /* end of buffer */
|
1999-03-27 16:15:22 +00:00
|
|
|
return S_FALSE;
|
2002-05-31 23:06:46 +00:00
|
|
|
|
1999-03-27 16:15:22 +00:00
|
|
|
dwBytesToRead = ( cb > dwBytesLeft) ? dwBytesLeft : cb;
|
|
|
|
|
|
|
|
memmove ( pv, (This->pbBuffer) + (This->dwPos), dwBytesToRead);
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2002-07-19 03:13:58 +00:00
|
|
|
This->dwPos += dwBytesToRead; /* adjust pointer */
|
1999-03-27 16:15:22 +00:00
|
|
|
|
|
|
|
if (pcbRead)
|
|
|
|
*pcbRead = dwBytesToRead;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
2002-07-19 03:13:58 +00:00
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* IStream_fnWrite
|
|
|
|
*/
|
2000-07-26 17:51:32 +00:00
|
|
|
static HRESULT WINAPI IStream_fnWrite (IStream * iface, const void* pv, ULONG cb, ULONG* pcbWritten)
|
1999-03-27 16:15:22 +00:00
|
|
|
{
|
2004-09-06 20:34:29 +00:00
|
|
|
ISHRegStream *This = (ISHRegStream *)iface;
|
1999-03-27 16:15:22 +00:00
|
|
|
|
1999-06-12 15:45:58 +00:00
|
|
|
TRACE("(%p)\n",This);
|
1999-03-27 16:15:22 +00:00
|
|
|
|
2002-07-19 03:13:58 +00:00
|
|
|
if (pcbWritten)
|
|
|
|
*pcbWritten = 0;
|
|
|
|
|
1999-03-27 16:15:22 +00:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
2002-07-19 03:13:58 +00:00
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* IStream_fnSeek
|
|
|
|
*/
|
2000-07-26 17:51:32 +00:00
|
|
|
static HRESULT WINAPI IStream_fnSeek (IStream * iface, LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER* plibNewPosition)
|
1999-03-27 16:15:22 +00:00
|
|
|
{
|
2004-09-06 20:34:29 +00:00
|
|
|
ISHRegStream *This = (ISHRegStream *)iface;
|
1999-03-27 16:15:22 +00:00
|
|
|
|
1999-06-12 15:45:58 +00:00
|
|
|
TRACE("(%p)\n",This);
|
1999-03-27 16:15:22 +00:00
|
|
|
|
2002-07-19 03:13:58 +00:00
|
|
|
if (plibNewPosition)
|
|
|
|
plibNewPosition->QuadPart = 0;
|
1999-03-27 16:15:22 +00:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
2002-07-19 03:13:58 +00:00
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* IStream_fnSetSize
|
|
|
|
*/
|
2000-07-26 17:51:32 +00:00
|
|
|
static HRESULT WINAPI IStream_fnSetSize (IStream * iface, ULARGE_INTEGER libNewSize)
|
1999-03-27 16:15:22 +00:00
|
|
|
{
|
2004-09-06 20:34:29 +00:00
|
|
|
ISHRegStream *This = (ISHRegStream *)iface;
|
1999-03-27 16:15:22 +00:00
|
|
|
|
1999-06-12 15:45:58 +00:00
|
|
|
TRACE("(%p)\n",This);
|
1999-03-27 16:15:22 +00:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
2002-07-19 03:13:58 +00:00
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* IStream_fnCopyTo
|
|
|
|
*/
|
2000-07-26 17:51:32 +00:00
|
|
|
static HRESULT WINAPI IStream_fnCopyTo (IStream * iface, IStream* pstm, ULARGE_INTEGER cb, ULARGE_INTEGER* pcbRead, ULARGE_INTEGER* pcbWritten)
|
1999-03-27 16:15:22 +00:00
|
|
|
{
|
2004-09-06 20:34:29 +00:00
|
|
|
ISHRegStream *This = (ISHRegStream *)iface;
|
1999-03-27 16:15:22 +00:00
|
|
|
|
1999-06-12 15:45:58 +00:00
|
|
|
TRACE("(%p)\n",This);
|
2002-07-19 03:13:58 +00:00
|
|
|
if (pcbRead)
|
|
|
|
pcbRead->QuadPart = 0;
|
|
|
|
if (pcbWritten)
|
|
|
|
pcbWritten->QuadPart = 0;
|
1999-03-27 16:15:22 +00:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
2002-07-19 03:13:58 +00:00
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* IStream_fnCommit
|
|
|
|
*/
|
2000-07-26 17:51:32 +00:00
|
|
|
static HRESULT WINAPI IStream_fnCommit (IStream * iface, DWORD grfCommitFlags)
|
1999-03-27 16:15:22 +00:00
|
|
|
{
|
2004-09-06 20:34:29 +00:00
|
|
|
ISHRegStream *This = (ISHRegStream *)iface;
|
1999-03-27 16:15:22 +00:00
|
|
|
|
1999-06-12 15:45:58 +00:00
|
|
|
TRACE("(%p)\n",This);
|
1999-03-27 16:15:22 +00:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
2002-07-19 03:13:58 +00:00
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* IStream_fnRevert
|
|
|
|
*/
|
2000-07-26 17:51:32 +00:00
|
|
|
static HRESULT WINAPI IStream_fnRevert (IStream * iface)
|
1999-03-27 16:15:22 +00:00
|
|
|
{
|
2004-09-06 20:34:29 +00:00
|
|
|
ISHRegStream *This = (ISHRegStream *)iface;
|
1999-03-27 16:15:22 +00:00
|
|
|
|
1999-06-12 15:45:58 +00:00
|
|
|
TRACE("(%p)\n",This);
|
1999-03-27 16:15:22 +00:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2002-07-19 03:13:58 +00:00
|
|
|
/**************************************************************************
|
|
|
|
* IStream_fnLockUnlockRegion
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI IStream_fnLockUnlockRegion (IStream * iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
|
1999-03-27 16:15:22 +00:00
|
|
|
{
|
2004-09-06 20:34:29 +00:00
|
|
|
ISHRegStream *This = (ISHRegStream *)iface;
|
1999-03-27 16:15:22 +00:00
|
|
|
|
1999-06-12 15:45:58 +00:00
|
|
|
TRACE("(%p)\n",This);
|
1999-03-27 16:15:22 +00:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
2002-07-19 03:13:58 +00:00
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* IStream_fnStat
|
|
|
|
*/
|
2000-07-26 17:51:32 +00:00
|
|
|
static HRESULT WINAPI IStream_fnStat (IStream * iface, STATSTG* pstatstg, DWORD grfStatFlag)
|
1999-03-27 16:15:22 +00:00
|
|
|
{
|
2004-09-06 20:34:29 +00:00
|
|
|
ISHRegStream *This = (ISHRegStream *)iface;
|
1999-03-27 16:15:22 +00:00
|
|
|
|
1999-06-12 15:45:58 +00:00
|
|
|
TRACE("(%p)\n",This);
|
1999-03-27 16:15:22 +00:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
2002-07-19 03:13:58 +00:00
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* IStream_fnClone
|
|
|
|
*/
|
2000-07-26 17:51:32 +00:00
|
|
|
static HRESULT WINAPI IStream_fnClone (IStream * iface, IStream** ppstm)
|
1999-03-27 16:15:22 +00:00
|
|
|
{
|
2004-09-06 20:34:29 +00:00
|
|
|
ISHRegStream *This = (ISHRegStream *)iface;
|
1999-03-27 16:15:22 +00:00
|
|
|
|
1999-06-12 15:45:58 +00:00
|
|
|
TRACE("(%p)\n",This);
|
2002-07-19 03:13:58 +00:00
|
|
|
if (ppstm)
|
|
|
|
*ppstm = NULL;
|
1999-03-27 16:15:22 +00:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2004-08-12 23:00:51 +00:00
|
|
|
static struct IStreamVtbl rstvt =
|
2002-05-31 23:06:46 +00:00
|
|
|
{
|
1999-03-27 16:15:22 +00:00
|
|
|
IStream_fnQueryInterface,
|
|
|
|
IStream_fnAddRef,
|
|
|
|
IStream_fnRelease,
|
|
|
|
IStream_fnRead,
|
|
|
|
IStream_fnWrite,
|
|
|
|
IStream_fnSeek,
|
|
|
|
IStream_fnSetSize,
|
|
|
|
IStream_fnCopyTo,
|
|
|
|
IStream_fnCommit,
|
|
|
|
IStream_fnRevert,
|
2002-07-19 03:13:58 +00:00
|
|
|
IStream_fnLockUnlockRegion,
|
|
|
|
IStream_fnLockUnlockRegion,
|
1999-03-27 16:15:22 +00:00
|
|
|
IStream_fnStat,
|
|
|
|
IStream_fnClone
|
2002-07-19 03:13:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Methods overridden by the dummy stream */
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* IStream_fnAddRefDummy
|
|
|
|
*/
|
|
|
|
static ULONG WINAPI IStream_fnAddRefDummy(IStream *iface)
|
|
|
|
{
|
2004-09-06 20:34:29 +00:00
|
|
|
ISHRegStream *This = (ISHRegStream *)iface;
|
2002-07-19 03:13:58 +00:00
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* IStream_fnReleaseDummy
|
|
|
|
*/
|
|
|
|
static ULONG WINAPI IStream_fnReleaseDummy(IStream *iface)
|
|
|
|
{
|
2004-09-06 20:34:29 +00:00
|
|
|
ISHRegStream *This = (ISHRegStream *)iface;
|
2002-07-19 03:13:58 +00:00
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
return 1;
|
|
|
|
}
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2002-07-19 03:13:58 +00:00
|
|
|
/**************************************************************************
|
|
|
|
* IStream_fnReadDummy
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI IStream_fnReadDummy(IStream *iface, LPVOID pv, ULONG cb, ULONG* pcbRead)
|
|
|
|
{
|
|
|
|
if (pcbRead)
|
|
|
|
*pcbRead = 0;
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2004-08-12 23:00:51 +00:00
|
|
|
static struct IStreamVtbl DummyRegStreamVTable =
|
2002-07-19 03:13:58 +00:00
|
|
|
{
|
|
|
|
IStream_fnQueryInterface,
|
|
|
|
IStream_fnAddRefDummy, /* Overridden */
|
|
|
|
IStream_fnReleaseDummy, /* Overridden */
|
|
|
|
IStream_fnReadDummy, /* Overridden */
|
|
|
|
IStream_fnWrite,
|
|
|
|
IStream_fnSeek,
|
|
|
|
IStream_fnSetSize,
|
|
|
|
IStream_fnCopyTo,
|
|
|
|
IStream_fnCommit,
|
|
|
|
IStream_fnRevert,
|
|
|
|
IStream_fnLockUnlockRegion,
|
|
|
|
IStream_fnLockUnlockRegion,
|
|
|
|
IStream_fnStat,
|
|
|
|
IStream_fnClone
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Dummy registry stream object */
|
|
|
|
static ISHRegStream rsDummyRegStream =
|
|
|
|
{
|
|
|
|
&DummyRegStreamVTable,
|
|
|
|
1,
|
2002-12-02 18:10:57 +00:00
|
|
|
NULL,
|
2002-07-19 03:13:58 +00:00
|
|
|
NULL,
|
|
|
|
0,
|
|
|
|
0
|
1999-03-27 16:15:22 +00:00
|
|
|
};
|
|
|
|
|
2002-07-19 03:13:58 +00:00
|
|
|
/**************************************************************************
|
|
|
|
* IStream_Create
|
|
|
|
*
|
|
|
|
* Internal helper: Create and initialise a new registry stream object.
|
|
|
|
*/
|
|
|
|
static IStream *IStream_Create(HKEY hKey, LPBYTE pbBuffer, DWORD dwLength)
|
|
|
|
{
|
|
|
|
ISHRegStream* regStream;
|
|
|
|
|
|
|
|
regStream = (ISHRegStream*)HeapAlloc(GetProcessHeap(), 0, sizeof(ISHRegStream));
|
|
|
|
|
|
|
|
if (regStream)
|
|
|
|
{
|
2003-04-10 18:17:34 +00:00
|
|
|
regStream->lpVtbl = &rstvt;
|
2002-07-19 03:13:58 +00:00
|
|
|
regStream->ref = 1;
|
|
|
|
regStream->hKey = hKey;
|
|
|
|
regStream->pbBuffer = pbBuffer;
|
|
|
|
regStream->dwLength = dwLength;
|
|
|
|
regStream->dwPos = 0;
|
|
|
|
}
|
|
|
|
TRACE ("Returning %p\n", regStream);
|
|
|
|
return (IStream *)regStream;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* SHOpenRegStream2A [SHLWAPI.@]
|
|
|
|
*
|
|
|
|
* Create a stream to read binary registry data.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* hKey [I] Registry handle
|
|
|
|
* pszSubkey [I] The sub key name
|
|
|
|
* pszValue [I] The value name under the sub key
|
|
|
|
* dwMode [I] Unused
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: An IStream interface referring to the registry data
|
|
|
|
* Failure: NULL, if the registry key could not be opened or is not binary.
|
|
|
|
*/
|
|
|
|
IStream * WINAPI SHOpenRegStream2A(HKEY hKey, LPCSTR pszSubkey,
|
|
|
|
LPCSTR pszValue,DWORD dwMode)
|
|
|
|
{
|
2002-12-02 18:10:57 +00:00
|
|
|
HKEY hStrKey = NULL;
|
2002-07-19 03:13:58 +00:00
|
|
|
LPBYTE lpBuff = NULL;
|
|
|
|
DWORD dwLength, dwType;
|
|
|
|
|
2002-10-25 03:12:32 +00:00
|
|
|
TRACE("(%p,%s,%s,0x%08lx)\n", hKey, pszSubkey, pszValue, dwMode);
|
2002-07-19 03:13:58 +00:00
|
|
|
|
|
|
|
/* Open the key, read in binary data and create stream */
|
|
|
|
if (!RegOpenKeyExA (hKey, pszSubkey, 0, KEY_READ, &hStrKey) &&
|
|
|
|
!RegQueryValueExA (hStrKey, pszValue, 0, 0, 0, &dwLength) &&
|
|
|
|
(lpBuff = HeapAlloc (GetProcessHeap(), 0, dwLength)) &&
|
|
|
|
!RegQueryValueExA (hStrKey, pszValue, 0, &dwType, lpBuff, &dwLength) &&
|
|
|
|
dwType == REG_BINARY)
|
|
|
|
return IStream_Create(hStrKey, lpBuff, dwLength);
|
|
|
|
|
2004-12-23 17:06:43 +00:00
|
|
|
HeapFree (GetProcessHeap(), 0, lpBuff);
|
2002-07-19 03:13:58 +00:00
|
|
|
if (hStrKey)
|
|
|
|
RegCloseKey(hStrKey);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* SHOpenRegStream2W [SHLWAPI.@]
|
|
|
|
*
|
|
|
|
* See SHOpenRegStream2A.
|
|
|
|
*/
|
|
|
|
IStream * WINAPI SHOpenRegStream2W(HKEY hKey, LPCWSTR pszSubkey,
|
|
|
|
LPCWSTR pszValue, DWORD dwMode)
|
|
|
|
{
|
2002-12-02 18:10:57 +00:00
|
|
|
HKEY hStrKey = NULL;
|
2002-07-19 03:13:58 +00:00
|
|
|
LPBYTE lpBuff = NULL;
|
|
|
|
DWORD dwLength, dwType;
|
|
|
|
|
2002-10-25 03:12:32 +00:00
|
|
|
TRACE("(%p,%s,%s,0x%08lx)\n", hKey, debugstr_w(pszSubkey),
|
2002-07-19 03:13:58 +00:00
|
|
|
debugstr_w(pszValue), dwMode);
|
|
|
|
|
|
|
|
/* Open the key, read in binary data and create stream */
|
|
|
|
if (!RegOpenKeyExW (hKey, pszSubkey, 0, KEY_READ, &hStrKey) &&
|
|
|
|
!RegQueryValueExW (hStrKey, pszValue, 0, 0, 0, &dwLength) &&
|
|
|
|
(lpBuff = HeapAlloc (GetProcessHeap(), 0, dwLength)) &&
|
|
|
|
!RegQueryValueExW (hStrKey, pszValue, 0, &dwType, lpBuff, &dwLength) &&
|
|
|
|
dwType == REG_BINARY)
|
|
|
|
return IStream_Create(hStrKey, lpBuff, dwLength);
|
|
|
|
|
2004-12-23 17:06:43 +00:00
|
|
|
HeapFree (GetProcessHeap(), 0, lpBuff);
|
2002-07-19 03:13:58 +00:00
|
|
|
if (hStrKey)
|
|
|
|
RegCloseKey(hStrKey);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
1999-03-27 16:15:22 +00:00
|
|
|
/*************************************************************************
|
2002-07-19 03:13:58 +00:00
|
|
|
* SHOpenRegStreamA [SHLWAPI.@]
|
|
|
|
*
|
|
|
|
* Create a stream to read binary registry data.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* hKey [I] Registry handle
|
|
|
|
* pszSubkey [I] The sub key name
|
|
|
|
* pszValue [I] The value name under the sub key
|
|
|
|
* dwMode [I] STGM mode for opening the file
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: An IStream interface referring to the registry data
|
|
|
|
* Failure: If the registry key could not be opened or is not binary,
|
|
|
|
* A dummy (empty) IStream object is returned.
|
2000-06-01 23:25:44 +00:00
|
|
|
*/
|
2002-07-19 03:13:58 +00:00
|
|
|
IStream * WINAPI SHOpenRegStreamA(HKEY hkey, LPCSTR pszSubkey,
|
|
|
|
LPCSTR pszValue, DWORD dwMode)
|
2000-06-01 23:25:44 +00:00
|
|
|
{
|
2002-07-19 03:13:58 +00:00
|
|
|
IStream *iStream;
|
2000-06-01 23:25:44 +00:00
|
|
|
|
2002-10-25 03:12:32 +00:00
|
|
|
TRACE("(%p,%s,%s,0x%08lx)\n", hkey, pszSubkey, pszValue, dwMode);
|
2002-07-19 03:13:58 +00:00
|
|
|
|
|
|
|
iStream = SHOpenRegStream2A(hkey, pszSubkey, pszValue, dwMode);
|
|
|
|
return iStream ? iStream : (IStream *)&rsDummyRegStream;
|
2000-06-01 23:25:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
2002-07-19 03:13:58 +00:00
|
|
|
* SHOpenRegStreamW [SHLWAPI.@]
|
|
|
|
*
|
|
|
|
* See SHOpenRegStreamA.
|
1999-03-27 16:15:22 +00:00
|
|
|
*/
|
2002-07-19 03:13:58 +00:00
|
|
|
IStream * WINAPI SHOpenRegStreamW(HKEY hkey, LPCWSTR pszSubkey,
|
|
|
|
LPCWSTR pszValue, DWORD dwMode)
|
1999-03-27 16:15:22 +00:00
|
|
|
{
|
2002-07-19 03:13:58 +00:00
|
|
|
IStream *iStream;
|
|
|
|
|
2002-10-25 03:12:32 +00:00
|
|
|
TRACE("(%p,%s,%s,0x%08lx)\n", hkey, debugstr_w(pszSubkey),
|
2002-07-19 03:13:58 +00:00
|
|
|
debugstr_w(pszValue), dwMode);
|
|
|
|
iStream = SHOpenRegStream2W(hkey, pszSubkey, pszValue, dwMode);
|
|
|
|
return iStream ? iStream : (IStream *)&rsDummyRegStream;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* @ [SHLWAPI.12]
|
|
|
|
*
|
2003-03-18 18:35:48 +00:00
|
|
|
* Create an IStream object on a block of memory.
|
2002-07-19 03:13:58 +00:00
|
|
|
*
|
|
|
|
* PARAMS
|
2003-03-18 18:35:48 +00:00
|
|
|
* lpbData [I] Memory block to create the IStream object on
|
2002-07-19 03:13:58 +00:00
|
|
|
* dwDataLen [I] Length of data block
|
|
|
|
*
|
|
|
|
* RETURNS
|
2003-03-18 18:35:48 +00:00
|
|
|
* Success: A pointer to the IStream object.
|
2002-07-19 03:13:58 +00:00
|
|
|
* Failure: NULL, if any parameters are invalid or an error occurs.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* A copy of the memory pointed to by lpbData is made, and is freed
|
|
|
|
* when the stream is released.
|
|
|
|
*/
|
2003-09-11 02:56:15 +00:00
|
|
|
IStream * WINAPI SHCreateMemStream(LPBYTE lpbData, DWORD dwDataLen)
|
2002-07-19 03:13:58 +00:00
|
|
|
{
|
|
|
|
IStream *iStrmRet = NULL;
|
|
|
|
|
|
|
|
TRACE("(%p,%ld)\n", lpbData, dwDataLen);
|
|
|
|
|
|
|
|
if (lpbData)
|
|
|
|
{
|
|
|
|
LPBYTE lpbDup = (LPBYTE)HeapAlloc(GetProcessHeap(), 0, dwDataLen);
|
|
|
|
|
|
|
|
if (lpbDup)
|
|
|
|
{
|
|
|
|
memcpy(lpbDup, lpbData, dwDataLen);
|
2002-12-02 18:10:57 +00:00
|
|
|
iStrmRet = IStream_Create(NULL, lpbDup, dwDataLen);
|
2000-06-01 23:25:44 +00:00
|
|
|
|
2002-07-19 03:13:58 +00:00
|
|
|
if (!iStrmRet)
|
|
|
|
HeapFree(GetProcessHeap(), 0, lpbDup);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return iStrmRet;
|
1999-03-27 16:15:22 +00:00
|
|
|
}
|
2002-09-20 19:41:08 +00:00
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* SHCreateStreamWrapper [SHLWAPI.@]
|
|
|
|
*
|
2003-03-18 18:35:48 +00:00
|
|
|
* Create an IStream object on a block of memory.
|
2002-09-20 19:41:08 +00:00
|
|
|
*
|
|
|
|
* PARAMS
|
2003-03-18 18:35:48 +00:00
|
|
|
* lpbData [I] Memory block to create the IStream object on
|
2002-09-20 19:41:08 +00:00
|
|
|
* dwDataLen [I] Length of data block
|
|
|
|
* dwReserved [I] Reserved, Must be 0.
|
2003-03-18 18:35:48 +00:00
|
|
|
* lppStream [O] Destination for IStream object
|
2002-09-20 19:41:08 +00:00
|
|
|
*
|
|
|
|
* RETURNS
|
2003-03-18 18:35:48 +00:00
|
|
|
* Success: S_OK. lppStream contains the new IStream object.
|
2002-09-20 19:41:08 +00: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)
|
|
|
|
{
|
|
|
|
IStream* lpStream;
|
|
|
|
|
|
|
|
if (lppStream)
|
|
|
|
*lppStream = NULL;
|
|
|
|
|
|
|
|
if(dwReserved || !lppStream)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2002-12-02 18:10:57 +00:00
|
|
|
lpStream = IStream_Create(NULL, lpbData, dwDataLen);
|
2002-09-20 19:41:08 +00:00
|
|
|
|
|
|
|
if(!lpStream)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
IStream_QueryInterface(lpStream, &IID_IStream, (void**)lppStream);
|
|
|
|
IStream_Release(lpStream);
|
|
|
|
return S_OK;
|
|
|
|
}
|