ReactOS  0.4.15-dev-489-g75a0787
regstream.c File Reference
#include <stdarg.h>
#include <string.h>
#include "winerror.h"
#include "windef.h"
#include "winbase.h"
#include "objbase.h"
#include "winreg.h"
#include "shlwapi.h"
#include "wine/debug.h"
Include dependency graph for regstream.c:

Go to the source code of this file.

Classes

struct  ISHRegStream
 

Macros

#define COBJMACROS
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (shell)
 
static ISHRegStreamimpl_from_IStream (IStream *iface)
 
static HRESULT WINAPI IStream_fnQueryInterface (IStream *iface, REFIID riid, LPVOID *ppvObj)
 
static ULONG WINAPI IStream_fnAddRef (IStream *iface)
 
static ULONG WINAPI IStream_fnRelease (IStream *iface)
 
static HRESULT WINAPI IStream_fnRead (IStream *iface, void *pv, ULONG cb, ULONG *pcbRead)
 
static HRESULT WINAPI IStream_fnWrite (IStream *iface, const void *pv, ULONG cb, ULONG *pcbWritten)
 
static HRESULT WINAPI IStream_fnSeek (IStream *iface, LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
 
static HRESULT WINAPI IStream_fnSetSize (IStream *iface, ULARGE_INTEGER libNewSize)
 
static HRESULT WINAPI IStream_fnCopyTo (IStream *iface, IStream *pstm, ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten)
 
static HRESULT WINAPI IStream_fnCommit (IStream *iface, DWORD grfCommitFlags)
 
static HRESULT WINAPI IStream_fnRevert (IStream *iface)
 
static HRESULT WINAPI IStream_fnLockUnlockRegion (IStream *iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
 
static HRESULT WINAPI IStream_fnStat (IStream *iface, STATSTG *pstatstg, DWORD grfStatFlag)
 
static HRESULT WINAPI IStream_fnClone (IStream *iface, IStream **ppstm)
 
static ULONG WINAPI IStream_fnAddRefDummy (IStream *iface)
 
static ULONG WINAPI IStream_fnReleaseDummy (IStream *iface)
 
static HRESULT WINAPI IStream_fnReadDummy (IStream *iface, LPVOID pv, ULONG cb, ULONG *pcbRead)
 
static ISHRegStreamIStream_Create (HKEY hKey, LPBYTE pbBuffer, DWORD dwLength)
 
IStream *WINAPI SHOpenRegStream2A (HKEY hKey, LPCSTR pszSubkey, LPCSTR pszValue, DWORD dwMode)
 
IStream *WINAPI SHOpenRegStream2W (HKEY hKey, LPCWSTR pszSubkey, LPCWSTR pszValue, DWORD dwMode)
 
IStream *WINAPI SHOpenRegStreamA (HKEY hkey, LPCSTR pszSubkey, LPCSTR pszValue, DWORD dwMode)
 
IStream *WINAPI SHOpenRegStreamW (HKEY hkey, LPCWSTR pszSubkey, LPCWSTR pszValue, DWORD dwMode)
 
IStream *WINAPI SHCreateMemStream (const BYTE *lpbData, UINT dwDataLen)
 
HRESULT WINAPI SHCreateStreamWrapper (LPBYTE lpbData, DWORD dwDataLen, DWORD dwReserved, IStream **lppStream)
 

Variables

static const IStreamVtbl rstvt
 
static const IStreamVtbl DummyRegStreamVTable
 
static ISHRegStream rsDummyRegStream
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 25 of file regstream.c.

Function Documentation

◆ impl_from_IStream()

static ISHRegStream* impl_from_IStream ( IStream iface)
inlinestatic

Definition at line 54 of file regstream.c.

55 {
56  return CONTAINING_RECORD(iface, ISHRegStream, IStream_iface);
57 }
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560

Referenced by IStream_fnAddRef(), IStream_fnAddRefDummy(), IStream_fnClone(), IStream_fnCommit(), IStream_fnCopyTo(), IStream_fnLockUnlockRegion(), IStream_fnQueryInterface(), IStream_fnRead(), IStream_fnRelease(), IStream_fnReleaseDummy(), IStream_fnRevert(), IStream_fnSeek(), IStream_fnSetSize(), IStream_fnStat(), and IStream_fnWrite().

◆ IStream_Create()

static ISHRegStream* IStream_Create ( HKEY  hKey,
LPBYTE  pbBuffer,
DWORD  dwLength 
)
static

Definition at line 441 of file regstream.c.

442 {
443  ISHRegStream* regStream;
444 
445  regStream = HeapAlloc(GetProcessHeap(), 0, sizeof(ISHRegStream));
446 
447  if (regStream)
448  {
449  regStream->IStream_iface.lpVtbl = &rstvt;
450  regStream->ref = 1;
451  regStream->hKey = hKey;
452  regStream->pbBuffer = pbBuffer;
453  regStream->dwLength = dwLength;
454  regStream->dwPos = 0;
455  regStream->dwMode = STGM_READWRITE;
456  regStream->u.keyNameA = NULL;
457  regStream->bUnicode = FALSE;
458  }
459  TRACE ("Returning %p\n", regStream);
460  return regStream;
461 }
LPSTR keyNameA
Definition: regstream.c:48
DWORD dwLength
Definition: regstream.c:44
smooth NULL
Definition: ftsmooth.c:416
LPBYTE pbBuffer
Definition: regstream.c:43
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:404
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
static DWORD DWORD * dwLength
Definition: fusion.c:85
BOOL bUnicode
Definition: regstream.c:51
IStream IStream_iface
Definition: regstream.c:40
DWORD dwPos
Definition: regstream.c:45
#define STGM_READWRITE
Definition: objbase.h:918
union ISHRegStream::@545 u
DWORD dwMode
Definition: regstream.c:46
static const IStreamVtbl rstvt
Definition: regstream.c:354

Referenced by SHCreateMemStream(), SHCreateStreamWrapper(), SHOpenRegStream2A(), and SHOpenRegStream2W().

◆ IStream_fnAddRef()

static ULONG WINAPI IStream_fnAddRef ( IStream iface)
static

Definition at line 86 of file regstream.c.

87 {
89  ULONG refCount = InterlockedIncrement(&This->ref);
90 
91  TRACE("(%p)->(ref before=%u)\n",This, refCount - 1);
92 
93  return refCount;
94 }
#define TRACE(s)
Definition: solgame.cpp:4
#define InterlockedIncrement
Definition: armddk.h:53
static ISHRegStream * impl_from_IStream(IStream *iface)
Definition: regstream.c:54
unsigned int ULONG
Definition: retypes.h:1

◆ IStream_fnAddRefDummy()

static ULONG WINAPI IStream_fnAddRefDummy ( IStream iface)
static

Definition at line 377 of file regstream.c.

378 {
380  TRACE("(%p)\n", This);
381  return 2;
382 }
#define TRACE(s)
Definition: solgame.cpp:4
static ISHRegStream * impl_from_IStream(IStream *iface)
Definition: regstream.c:54

◆ IStream_fnClone()

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

Definition at line 343 of file regstream.c.

344 {
346 
347  TRACE("(%p)\n",This);
348  *ppstm = NULL;
349 
350  /* clone not supported by this stream */
351  return E_NOTIMPL;
352 }
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
static ISHRegStream * impl_from_IStream(IStream *iface)
Definition: regstream.c:54
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ IStream_fnCommit()

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

Definition at line 277 of file regstream.c.

278 {
280 
281  TRACE("(%p)\n",This);
282 
283  /* commit not supported by this stream */
284  return E_NOTIMPL;
285 }
#define TRACE(s)
Definition: solgame.cpp:4
static ISHRegStream * impl_from_IStream(IStream *iface)
Definition: regstream.c:54
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ IStream_fnCopyTo()

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

Definition at line 260 of file regstream.c.

261 {
263 
264  TRACE("(%p)\n",This);
265  if (pcbRead)
266  pcbRead->QuadPart = 0;
267  if (pcbWritten)
268  pcbWritten->QuadPart = 0;
269 
270  /* TODO implement */
271  return E_NOTIMPL;
272 }
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
#define TRACE(s)
Definition: solgame.cpp:4
static ISHRegStream * impl_from_IStream(IStream *iface)
Definition: regstream.c:54
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ IStream_fnLockUnlockRegion()

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

Definition at line 303 of file regstream.c.

304 {
306 
307  TRACE("(%p)\n",This);
308 
309  /* lock/unlock not supported by this stream */
310  return E_NOTIMPL;
311 }
#define TRACE(s)
Definition: solgame.cpp:4
static ISHRegStream * impl_from_IStream(IStream *iface)
Definition: regstream.c:54
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ IStream_fnQueryInterface()

static HRESULT WINAPI IStream_fnQueryInterface ( IStream iface,
REFIID  riid,
LPVOID ppvObj 
)
static

Definition at line 62 of file regstream.c.

63 {
65 
66  TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj);
67 
68  *ppvObj = NULL;
69 
70  if(IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IStream))
71  *ppvObj = &This->IStream_iface;
72 
73  if(*ppvObj)
74  {
75  IStream_AddRef((IStream*)*ppvObj);
76  TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
77  return S_OK;
78  }
79  TRACE("-- Interface: E_NOINTERFACE\n");
80  return E_NOINTERFACE;
81 }
#define E_NOINTERFACE
Definition: winerror.h:2364
REFIID riid
Definition: precomp.h:44
smooth NULL
Definition: ftsmooth.c:416
#define debugstr_guid
Definition: kernel32.h:35
#define TRACE(s)
Definition: solgame.cpp:4
const GUID IID_IUnknown
#define S_OK
Definition: intsafe.h:59
static ISHRegStream * impl_from_IStream(IStream *iface)
Definition: regstream.c:54
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95

◆ IStream_fnRead()

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

Definition at line 148 of file regstream.c.

149 {
151  DWORD dwBytesToRead;
152 
153  TRACE("(%p)->(%p,0x%08x,%p)\n",This, pv, cb, pcbRead);
154 
155  if (This->dwPos >= This->dwLength)
156  dwBytesToRead = 0;
157  else
158  dwBytesToRead = This->dwLength - This->dwPos;
159 
160  dwBytesToRead = (cb > dwBytesToRead) ? dwBytesToRead : cb;
161  if (dwBytesToRead != 0) /* not at end of buffer and we want to read something */
162  {
163  memmove(pv, This->pbBuffer + This->dwPos, dwBytesToRead);
164  This->dwPos += dwBytesToRead; /* adjust pointer */
165  }
166 
167  if (pcbRead)
168  *pcbRead = dwBytesToRead;
169 
170  return S_OK;
171 }
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
#define S_OK
Definition: intsafe.h:59
static ISHRegStream * impl_from_IStream(IStream *iface)
Definition: regstream.c:54
static HMODULE MODULEINFO DWORD cb
Definition: module.c:32

◆ IStream_fnReadDummy()

static HRESULT WINAPI IStream_fnReadDummy ( IStream iface,
LPVOID  pv,
ULONG  cb,
ULONG pcbRead 
)
static

Definition at line 397 of file regstream.c.

398 {
399  if (pcbRead)
400  *pcbRead = 0;
401  return E_NOTIMPL;
402 }
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ IStream_fnRelease()

static ULONG WINAPI IStream_fnRelease ( IStream iface)
static

Definition at line 99 of file regstream.c.

100 {
102  ULONG refCount = InterlockedDecrement(&This->ref);
103 
104  TRACE("(%p)->(ref before=%u)\n",This, refCount + 1);
105 
106  if (!refCount)
107  {
108  TRACE(" destroying SHReg IStream (%p)\n",This);
109 
110  if (This->hKey)
111  {
112  /* write back data in REG_BINARY */
113  if (This->dwMode == STGM_READWRITE || This->dwMode == STGM_WRITE)
114  {
115  if (This->dwLength)
116  {
117  if (This->bUnicode)
118  RegSetValueExW(This->hKey, This->u.keyNameW, 0, REG_BINARY,
119  (const BYTE *) This->pbBuffer, This->dwLength);
120  else
121  RegSetValueExA(This->hKey, This->u.keyNameA, 0, REG_BINARY,
122  (const BYTE *) This->pbBuffer, This->dwLength);
123  }
124  else
125  {
126  if (This->bUnicode)
127  RegDeleteValueW(This->hKey, This->u.keyNameW);
128  else
129  RegDeleteValueA(This->hKey, This->u.keyNameA);
130  }
131  }
132 
133  RegCloseKey(This->hKey);
134  }
135 
136  HeapFree(GetProcessHeap(),0,This->u.keyNameA);
137  HeapFree(GetProcessHeap(),0,This->pbBuffer);
139  return 0;
140  }
141 
142  return refCount;
143 }
#define REG_BINARY
Definition: nt_native.h:1496
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define STGM_WRITE
Definition: objbase.h:917
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4895
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:404
#define InterlockedDecrement
Definition: armddk.h:52
#define STGM_READWRITE
Definition: objbase.h:918
unsigned char BYTE
Definition: xxhash.c:193
LONG WINAPI RegDeleteValueW(HKEY hKey, LPCWSTR lpValueName)
Definition: reg.c:2355
static ISHRegStream * impl_from_IStream(IStream *iface)
Definition: regstream.c:54
LONG WINAPI RegDeleteValueA(HKEY hKey, LPCSTR lpValueName)
Definition: reg.c:2319
unsigned int ULONG
Definition: retypes.h:1
LONG WINAPI RegSetValueExA(HKEY hKey, LPCSTR lpValueName, DWORD Reserved, DWORD dwType, CONST BYTE *lpData, DWORD cbData)
Definition: reg.c:4812
#define HeapFree(x, y, z)
Definition: compat.h:403

◆ IStream_fnReleaseDummy()

static ULONG WINAPI IStream_fnReleaseDummy ( IStream iface)
static

Definition at line 387 of file regstream.c.

388 {
390  TRACE("(%p)\n", This);
391  return 1;
392 }
#define TRACE(s)
Definition: solgame.cpp:4
static ISHRegStream * impl_from_IStream(IStream *iface)
Definition: regstream.c:54

◆ IStream_fnRevert()

static HRESULT WINAPI IStream_fnRevert ( IStream iface)
static

Definition at line 290 of file regstream.c.

291 {
293 
294  TRACE("(%p)\n",This);
295 
296  /* revert not supported by this stream */
297  return E_NOTIMPL;
298 }
#define TRACE(s)
Definition: solgame.cpp:4
static ISHRegStream * impl_from_IStream(IStream *iface)
Definition: regstream.c:54
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ IStream_fnSeek()

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

Definition at line 207 of file regstream.c.

208 {
210  LARGE_INTEGER tmp;
211  TRACE("(%p, %s, %d %p)\n", This,
212  wine_dbgstr_longlong(dlibMove.QuadPart), dwOrigin, plibNewPosition);
213 
214  if (dwOrigin == STREAM_SEEK_SET)
215  tmp = dlibMove;
216  else if (dwOrigin == STREAM_SEEK_CUR)
217  tmp.QuadPart = This->dwPos + dlibMove.QuadPart;
218  else if (dwOrigin == STREAM_SEEK_END)
219  tmp.QuadPart = This->dwLength + dlibMove.QuadPart;
220  else
221  return STG_E_INVALIDPARAMETER;
222 
223  if (tmp.QuadPart < 0)
224  return STG_E_INVALIDFUNCTION;
225 
226  /* we cut off the high part here */
227  This->dwPos = tmp.u.LowPart;
228 
229  if (plibNewPosition)
230  plibNewPosition->QuadPart = This->dwPos;
231  return S_OK;
232 }
struct _LARGE_INTEGER::@2241 u
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
#define STG_E_INVALIDFUNCTION
Definition: winerror.h:2564
#define TRACE(s)
Definition: solgame.cpp:4
#define STG_E_INVALIDPARAMETER
Definition: winerror.h:2580
#define S_OK
Definition: intsafe.h:59
static ISHRegStream * impl_from_IStream(IStream *iface)
Definition: regstream.c:54
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:41
LONGLONG QuadPart
Definition: typedefs.h:113

◆ IStream_fnSetSize()

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

Definition at line 237 of file regstream.c.

238 {
240  DWORD newLen;
241  LPBYTE newBuf;
242 
243  TRACE("(%p, %s)\n", This, wine_dbgstr_longlong(libNewSize.QuadPart));
244 
245  /* we cut off the high part here */
246  newLen = libNewSize.u.LowPart;
247  newBuf = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, This->pbBuffer, newLen);
248  if (!newBuf)
250 
251  This->pbBuffer = newBuf;
252  This->dwLength = newLen;
253 
254  return S_OK;
255 }
#define STG_E_INSUFFICIENTMEMORY
Definition: winerror.h:2570
unsigned char * LPBYTE
Definition: typedefs.h:53
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:404
unsigned long DWORD
Definition: ntddk_ex.h:95
struct _ULARGE_INTEGER::@3824 u
#define S_OK
Definition: intsafe.h:59
static ISHRegStream * impl_from_IStream(IStream *iface)
Definition: regstream.c:54
#define HeapReAlloc
Definition: compat.h:402
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:41

◆ IStream_fnStat()

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

Definition at line 316 of file regstream.c.

317 {
319 
320  TRACE("(%p, %p, %d)\n",This,pstatstg,grfStatFlag);
321 
322  pstatstg->pwcsName = NULL;
323  pstatstg->type = STGTY_STREAM;
324  pstatstg->cbSize.QuadPart = This->dwLength;
325  pstatstg->mtime.dwHighDateTime = 0;
326  pstatstg->mtime.dwLowDateTime = 0;
327  pstatstg->ctime.dwHighDateTime = 0;
328  pstatstg->ctime.dwLowDateTime = 0;
329  pstatstg->atime.dwHighDateTime = 0;
330  pstatstg->atime.dwLowDateTime = 0;
331  pstatstg->grfMode = This->dwMode;
332  pstatstg->grfLocksSupported = 0;
333  pstatstg->clsid = CLSID_NULL;
334  pstatstg->grfStateBits = 0;
335  pstatstg->reserved = 0;
336 
337  return S_OK;
338 }
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define CLSID_NULL
Definition: guiddef.h:99
#define S_OK
Definition: intsafe.h:59
static ISHRegStream * impl_from_IStream(IStream *iface)
Definition: regstream.c:54

◆ IStream_fnWrite()

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

Definition at line 176 of file regstream.c.

177 {
179  DWORD newLen = This->dwPos + cb;
180 
181  TRACE("(%p, %p, %d, %p)\n",This, pv, cb, pcbWritten);
182 
183  if (newLen < This->dwPos) /* overflow */
185 
186  if (newLen > This->dwLength)
187  {
188  LPBYTE newBuf = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, This->pbBuffer, newLen);
189  if (!newBuf)
191 
192  This->dwLength = newLen;
193  This->pbBuffer = newBuf;
194  }
195  memmove(This->pbBuffer + This->dwPos, pv, cb);
196  This->dwPos += cb; /* adjust pointer */
197 
198  if (pcbWritten)
199  *pcbWritten = cb;
200 
201  return S_OK;
202 }
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
#define STG_E_INSUFFICIENTMEMORY
Definition: winerror.h:2570
unsigned char * LPBYTE
Definition: typedefs.h:53
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:404
unsigned long DWORD
Definition: ntddk_ex.h:95
#define S_OK
Definition: intsafe.h:59
static ISHRegStream * impl_from_IStream(IStream *iface)
Definition: regstream.c:54
#define HeapReAlloc
Definition: compat.h:402
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
static HMODULE MODULEINFO DWORD cb
Definition: module.c:32

◆ SHCreateMemStream()

IStream* WINAPI SHCreateMemStream ( const BYTE lpbData,
UINT  dwDataLen 
)

Definition at line 652 of file regstream.c.

653 {
654  ISHRegStream *strm = NULL;
655  LPBYTE lpbDup;
656 
657  TRACE("(%p,%d)\n", lpbData, dwDataLen);
658 
659  if (!lpbData)
660  dwDataLen = 0;
661 
662  lpbDup = HeapAlloc(GetProcessHeap(), 0, dwDataLen);
663 
664  if (lpbDup)
665  {
666  memcpy(lpbDup, lpbData, dwDataLen);
667  strm = IStream_Create(NULL, lpbDup, dwDataLen);
668 
669  if (!strm)
670  HeapFree(GetProcessHeap(), 0, lpbDup);
671  }
672  return &strm->IStream_iface;
673 }
unsigned char * LPBYTE
Definition: typedefs.h:53
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:404
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
IStream IStream_iface
Definition: regstream.c:40
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static ISHRegStream * IStream_Create(HKEY hKey, LPBYTE pbBuffer, DWORD dwLength)
Definition: regstream.c:441
#define HeapFree(x, y, z)
Definition: compat.h:403

Referenced by create_decoder(), and test_SHCreateMemStream().

◆ SHCreateStreamWrapper()

HRESULT WINAPI SHCreateStreamWrapper ( LPBYTE  lpbData,
DWORD  dwDataLen,
DWORD  dwReserved,
IStream **  lppStream 
)

Definition at line 694 of file regstream.c.

696 {
697  ISHRegStream *strm;
698 
699  if (lppStream)
700  *lppStream = NULL;
701 
702  if(dwReserved || !lppStream)
703  return E_INVALIDARG;
704 
705  strm = IStream_Create(NULL, lpbData, dwDataLen);
706 
707  if(!strm)
708  return E_OUTOFMEMORY;
709 
710  IStream_QueryInterface(&strm->IStream_iface, &IID_IStream, (void**)lppStream);
711  IStream_Release(&strm->IStream_iface);
712  return S_OK;
713 }
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED _In_opt_ LPTRANSMIT_FILE_BUFFERS _In_ DWORD dwReserved
Definition: mswsock.h:90
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
IStream IStream_iface
Definition: regstream.c:40
#define S_OK
Definition: intsafe.h:59
static ISHRegStream * IStream_Create(HKEY hKey, LPBYTE pbBuffer, DWORD dwLength)
Definition: regstream.c:441

◆ SHOpenRegStream2A()

IStream* WINAPI SHOpenRegStream2A ( HKEY  hKey,
LPCSTR  pszSubkey,
LPCSTR  pszValue,
DWORD  dwMode 
)

Definition at line 478 of file regstream.c.

480 {
481  ISHRegStream *tmp;
482  HKEY hStrKey = NULL;
483  LPBYTE lpBuff = NULL;
484  DWORD dwLength = 0;
485  LONG ret;
486 
487  TRACE("(%p,%s,%s,0x%08x)\n", hKey, pszSubkey, pszValue, dwMode);
488 
489  if (dwMode == STGM_READ)
490  ret = RegOpenKeyExA(hKey, pszSubkey, 0, KEY_READ, &hStrKey);
491  else /* in write mode we make sure the subkey exits */
492  ret = RegCreateKeyExA(hKey, pszSubkey, 0, NULL, 0, KEY_READ | KEY_WRITE, NULL, &hStrKey, NULL);
493 
494  if (ret == ERROR_SUCCESS)
495  {
496  if (dwMode == STGM_READ || dwMode == STGM_READWRITE)
497  {
498  /* read initial data */
499  ret = RegQueryValueExA(hStrKey, pszValue, 0, 0, 0, &dwLength);
500  if (ret == ERROR_SUCCESS && dwLength)
501  {
502  lpBuff = HeapAlloc(GetProcessHeap(), 0, dwLength);
503  RegQueryValueExA(hStrKey, pszValue, 0, 0, lpBuff, &dwLength);
504  }
505  }
506 
507  if (!dwLength)
508  lpBuff = HeapAlloc(GetProcessHeap(), 0, dwLength);
509 
510  tmp = IStream_Create(hStrKey, lpBuff, dwLength);
511  if(tmp)
512  {
513  if(pszValue)
514  {
515  int len = lstrlenA(pszValue) + 1;
516  tmp->u.keyNameA = HeapAlloc(GetProcessHeap(), 0, len);
517  memcpy(tmp->u.keyNameA, pszValue, len);
518  }
519 
520  tmp->dwMode = dwMode;
521  tmp->bUnicode = FALSE;
522  return &tmp->IStream_iface;
523  }
524  }
525 
526  HeapFree(GetProcessHeap(), 0, lpBuff);
527  if (hStrKey)
528  RegCloseKey(hStrKey);
529  return NULL;
530 }
LONG WINAPI RegQueryValueExA(_In_ HKEY hkeyorg, _In_ LPCSTR name, _In_ LPDWORD reserved, _Out_opt_ LPDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ LPDWORD count)
Definition: reg.c:4023
LPSTR keyNameA
Definition: regstream.c:48
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
LONG WINAPI RegOpenKeyExA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey, _In_ DWORD ulOptions, _In_ REGSAM samDesired, _Out_ PHKEY phkResult)
Definition: reg.c:3331
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
#define STGM_READ
Definition: objbase.h:916
#define KEY_WRITE
Definition: nt_native.h:1031
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:404
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
static DWORD DWORD * dwLength
Definition: fusion.c:85
BOOL bUnicode
Definition: regstream.c:51
unsigned long DWORD
Definition: ntddk_ex.h:95
IStream IStream_iface
Definition: regstream.c:40
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
#define STGM_READWRITE
Definition: objbase.h:918
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
static ISHRegStream * IStream_Create(HKEY hKey, LPBYTE pbBuffer, DWORD dwLength)
Definition: regstream.c:441
union ISHRegStream::@545 u
DWORD dwMode
Definition: regstream.c:46
LONG WINAPI RegCreateKeyExA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey, _In_ DWORD Reserved, _In_ LPSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_ LPDWORD lpdwDisposition)
Definition: reg.c:1029
#define HeapFree(x, y, z)
Definition: compat.h:403

Referenced by SHOpenRegStreamA().

◆ SHOpenRegStream2W()

IStream* WINAPI SHOpenRegStream2W ( HKEY  hKey,
LPCWSTR  pszSubkey,
LPCWSTR  pszValue,
DWORD  dwMode 
)

Definition at line 537 of file regstream.c.

539 {
540  ISHRegStream *tmp;
541  HKEY hStrKey = NULL;
542  LPBYTE lpBuff = NULL;
543  DWORD dwLength = 0;
544  LONG ret;
545 
546  TRACE("(%p,%s,%s,0x%08x)\n", hKey, debugstr_w(pszSubkey),
547  debugstr_w(pszValue), dwMode);
548 
549  if (dwMode == STGM_READ)
550  ret = RegOpenKeyExW(hKey, pszSubkey, 0, KEY_READ, &hStrKey);
551  else /* in write mode we make sure the subkey exits */
552  ret = RegCreateKeyExW(hKey, pszSubkey, 0, NULL, 0, KEY_READ | KEY_WRITE, NULL, &hStrKey, NULL);
553 
554  if (ret == ERROR_SUCCESS)
555  {
556  if (dwMode == STGM_READ || dwMode == STGM_READWRITE)
557  {
558  /* read initial data */
559  ret = RegQueryValueExW(hStrKey, pszValue, 0, 0, 0, &dwLength);
560  if (ret == ERROR_SUCCESS && dwLength)
561  {
562  lpBuff = HeapAlloc(GetProcessHeap(), 0, dwLength);
563  RegQueryValueExW(hStrKey, pszValue, 0, 0, lpBuff, &dwLength);
564  }
565  }
566 
567  if (!dwLength)
568  lpBuff = HeapAlloc(GetProcessHeap(), 0, dwLength);
569 
570  tmp = IStream_Create(hStrKey, lpBuff, dwLength);
571  if(tmp)
572  {
573  if(pszValue)
574  {
575  int len = lstrlenW(pszValue) + 1;
576  tmp->u.keyNameW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
577  memcpy(tmp->u.keyNameW, pszValue, len * sizeof(WCHAR));
578  }
579 
580  tmp->dwMode = dwMode;
581  tmp->bUnicode = TRUE;
582  return &tmp->IStream_iface;
583  }
584  }
585 
586  HeapFree(GetProcessHeap(), 0, lpBuff);
587  if (hStrKey)
588  RegCloseKey(hStrKey);
589  return NULL;
590 }
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
#define lstrlenW
Definition: compat.h:416
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1091
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
long LONG
Definition: pedump.c:60
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
#define STGM_READ
Definition: objbase.h:916
#define KEY_WRITE
Definition: nt_native.h:1031
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:404
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
__wchar_t WCHAR
Definition: xmlstorage.h:180
static DWORD DWORD * dwLength
Definition: fusion.c:85
BOOL bUnicode
Definition: regstream.c:51
unsigned long DWORD
Definition: ntddk_ex.h:95
IStream IStream_iface
Definition: regstream.c:40
LPWSTR keyNameW
Definition: regstream.c:49
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
#define STGM_READWRITE
Definition: objbase.h:918
static ISHRegStream * IStream_Create(HKEY hKey, LPBYTE pbBuffer, DWORD dwLength)
Definition: regstream.c:441
union ISHRegStream::@545 u
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
DWORD dwMode
Definition: regstream.c:46
#define HeapFree(x, y, z)
Definition: compat.h:403

Referenced by SHOpenRegStreamW().

◆ SHOpenRegStreamA()

IStream* WINAPI SHOpenRegStreamA ( HKEY  hkey,
LPCSTR  pszSubkey,
LPCSTR  pszValue,
DWORD  dwMode 
)

Definition at line 608 of file regstream.c.

610 {
611  IStream *iStream;
612 
613  TRACE("(%p,%s,%s,0x%08x)\n", hkey, pszSubkey, pszValue, dwMode);
614 
615  iStream = SHOpenRegStream2A(hkey, pszSubkey, pszValue, dwMode);
616  return iStream ? iStream : &rsDummyRegStream.IStream_iface;
617 }
IStream *WINAPI SHOpenRegStream2A(HKEY hKey, LPCSTR pszSubkey, LPCSTR pszValue, DWORD dwMode)
Definition: regstream.c:478
static ISHRegStream rsDummyRegStream
Definition: regstream.c:423
#define TRACE(s)
Definition: solgame.cpp:4
IStream IStream_iface
Definition: regstream.c:40

◆ SHOpenRegStreamW()

IStream* WINAPI SHOpenRegStreamW ( HKEY  hkey,
LPCWSTR  pszSubkey,
LPCWSTR  pszValue,
DWORD  dwMode 
)

Definition at line 624 of file regstream.c.

626 {
627  IStream *iStream;
628 
629  TRACE("(%p,%s,%s,0x%08x)\n", hkey, debugstr_w(pszSubkey),
630  debugstr_w(pszValue), dwMode);
631  iStream = SHOpenRegStream2W(hkey, pszSubkey, pszValue, dwMode);
632  return iStream ? iStream : &rsDummyRegStream.IStream_iface;
633 }
static ISHRegStream rsDummyRegStream
Definition: regstream.c:423
IStream *WINAPI SHOpenRegStream2W(HKEY hKey, LPCWSTR pszSubkey, LPCWSTR pszValue, DWORD dwMode)
Definition: regstream.c:537
#define debugstr_w
Definition: kernel32.h:32
#define TRACE(s)
Definition: solgame.cpp:4
IStream IStream_iface
Definition: regstream.c:40

Referenced by CTrayBandSite::GetDefaultBandsStream(), and CTrayBandSite::GetUserBandsStream().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( shell  )

Variable Documentation

◆ DummyRegStreamVTable

const IStreamVtbl DummyRegStreamVTable
static
Initial value:
=
{
}
static HRESULT WINAPI IStream_fnStat(IStream *iface, STATSTG *pstatstg, DWORD grfStatFlag)
Definition: regstream.c:316
static HRESULT WINAPI IStream_fnLockUnlockRegion(IStream *iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
Definition: regstream.c:303
static HRESULT WINAPI IStream_fnQueryInterface(IStream *iface, REFIID riid, LPVOID *ppvObj)
Definition: regstream.c:62
static HRESULT WINAPI IStream_fnCommit(IStream *iface, DWORD grfCommitFlags)
Definition: regstream.c:277
static HRESULT WINAPI IStream_fnClone(IStream *iface, IStream **ppstm)
Definition: regstream.c:343
static HRESULT WINAPI IStream_fnSeek(IStream *iface, LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
Definition: regstream.c:207
static HRESULT WINAPI IStream_fnWrite(IStream *iface, const void *pv, ULONG cb, ULONG *pcbWritten)
Definition: regstream.c:176
static ULONG WINAPI IStream_fnReleaseDummy(IStream *iface)
Definition: regstream.c:387
static HRESULT WINAPI IStream_fnRevert(IStream *iface)
Definition: regstream.c:290
static HRESULT WINAPI IStream_fnReadDummy(IStream *iface, LPVOID pv, ULONG cb, ULONG *pcbRead)
Definition: regstream.c:397
static ULONG WINAPI IStream_fnAddRefDummy(IStream *iface)
Definition: regstream.c:377
static HRESULT WINAPI IStream_fnSetSize(IStream *iface, ULARGE_INTEGER libNewSize)
Definition: regstream.c:237
static HRESULT WINAPI IStream_fnCopyTo(IStream *iface, IStream *pstm, ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten)
Definition: regstream.c:260

Definition at line 404 of file regstream.c.

◆ rsDummyRegStream

ISHRegStream rsDummyRegStream
static
Initial value:
=
{
1,
0,
0,
{NULL},
}
smooth NULL
Definition: ftsmooth.c:416
static const IStreamVtbl DummyRegStreamVTable
Definition: regstream.c:404
#define STGM_READWRITE
Definition: objbase.h:918

Definition at line 423 of file regstream.c.

Referenced by SHOpenRegStreamA(), and SHOpenRegStreamW().

◆ rstvt

const IStreamVtbl rstvt
static
Initial value:
=
{
}
static HRESULT WINAPI IStream_fnStat(IStream *iface, STATSTG *pstatstg, DWORD grfStatFlag)
Definition: regstream.c:316
static HRESULT WINAPI IStream_fnLockUnlockRegion(IStream *iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
Definition: regstream.c:303
static HRESULT WINAPI IStream_fnQueryInterface(IStream *iface, REFIID riid, LPVOID *ppvObj)
Definition: regstream.c:62
static HRESULT WINAPI IStream_fnCommit(IStream *iface, DWORD grfCommitFlags)
Definition: regstream.c:277
static HRESULT WINAPI IStream_fnRead(IStream *iface, void *pv, ULONG cb, ULONG *pcbRead)
Definition: regstream.c:148
static HRESULT WINAPI IStream_fnClone(IStream *iface, IStream **ppstm)
Definition: regstream.c:343
static HRESULT WINAPI IStream_fnSeek(IStream *iface, LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
Definition: regstream.c:207
static HRESULT WINAPI IStream_fnWrite(IStream *iface, const void *pv, ULONG cb, ULONG *pcbWritten)
Definition: regstream.c:176
static HRESULT WINAPI IStream_fnRevert(IStream *iface)
Definition: regstream.c:290
static HRESULT WINAPI IStream_fnSetSize(IStream *iface, ULARGE_INTEGER libNewSize)
Definition: regstream.c:237
static HRESULT WINAPI IStream_fnCopyTo(IStream *iface, IStream *pstm, ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten)
Definition: regstream.c:260
static ULONG WINAPI IStream_fnAddRef(IStream *iface)
Definition: regstream.c:86
static ULONG WINAPI IStream_fnRelease(IStream *iface)
Definition: regstream.c:99

Definition at line 354 of file regstream.c.

Referenced by IStream_Create().