ReactOS  0.4.14-dev-998-g623dd26
istream.c File Reference
#include <stdarg.h>
#include <string.h>
#include "windef.h"
#include "winbase.h"
#include "winerror.h"
#include "winnls.h"
#include "shlwapi.h"
#include "wine/debug.h"
Include dependency graph for istream.c:

Go to the source code of this file.

Classes

struct  ISHFileStream
 

Macros

#define COBJMACROS
 
#define NONAMELESSUNION
 
#define NO_SHLWAPI_REG
 
#define NO_SHLWAPI_PATH
 
#define STGM_ACCESS_MODE(stgm)   ((stgm)&0x0000f)
 
#define STGM_SHARE_MODE(stgm)   ((stgm)&0x000f0)
 
#define STGM_CREATE_MODE(stgm)   ((stgm)&0x0f000)
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (shell)
 
static ISHFileStreamimpl_from_IStream (IStream *iface)
 
static HRESULT WINAPI IStream_fnCommit (IStream *, DWORD)
 
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 *pNewPos)
 
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_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 *lpStat, DWORD grfStatFlag)
 
static HRESULT WINAPI IStream_fnClone (IStream *iface, IStream **ppstm)
 
static IStreamIStream_Create (LPCWSTR lpszPath, HANDLE hFile, DWORD dwMode)
 
HRESULT WINAPI SHCreateStreamOnFileEx (LPCWSTR lpszPath, DWORD dwMode, DWORD dwAttributes, BOOL bCreate, IStream *lpTemplate, IStream **lppStream)
 
HRESULT WINAPI SHCreateStreamOnFileW (LPCWSTR lpszPath, DWORD dwMode, IStream **lppStream)
 
HRESULT WINAPI SHCreateStreamOnFileA (LPCSTR lpszPath, DWORD dwMode, IStream **lppStream)
 
HRESULT WINAPI SHIStream_Read (IStream *lpStream, LPVOID lpvDest, ULONG ulSize)
 
BOOL WINAPI SHIsEmptyStream (IStream *lpStream)
 
HRESULT WINAPI SHIStream_Write (IStream *lpStream, LPCVOID lpvSrc, ULONG ulSize)
 
HRESULT WINAPI IStream_Reset (IStream *lpStream)
 
HRESULT WINAPI IStream_Size (IStream *lpStream, ULARGE_INTEGER *lpulSize)
 

Variables

static const IStreamVtbl SHLWAPI_fsVTable
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 23 of file istream.c.

◆ NO_SHLWAPI_PATH

#define NO_SHLWAPI_PATH

Definition at line 31 of file istream.c.

◆ NO_SHLWAPI_REG

#define NO_SHLWAPI_REG

Definition at line 30 of file istream.c.

◆ NONAMELESSUNION

#define NONAMELESSUNION

Definition at line 24 of file istream.c.

◆ STGM_ACCESS_MODE

#define STGM_ACCESS_MODE (   stgm)    ((stgm)&0x0000f)

Definition at line 37 of file istream.c.

◆ STGM_CREATE_MODE

#define STGM_CREATE_MODE (   stgm)    ((stgm)&0x0f000)

Definition at line 39 of file istream.c.

◆ STGM_SHARE_MODE

#define STGM_SHARE_MODE (   stgm)    ((stgm)&0x000f0)

Definition at line 38 of file istream.c.

Function Documentation

◆ impl_from_IStream()

static ISHFileStream* impl_from_IStream ( IStream iface)
inlinestatic

Definition at line 53 of file istream.c.

54 {
56 }
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
IStream IStream_iface
Definition: clist.c:56

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

◆ IStream_Create()

static IStream* IStream_Create ( LPCWSTR  lpszPath,
HANDLE  hFile,
DWORD  dwMode 
)
static

Definition at line 362 of file istream.c.

363 {
364  ISHFileStream *fileStream;
365 
366  fileStream = HeapAlloc(GetProcessHeap(), 0, sizeof(ISHFileStream));
367  if (!fileStream) return NULL;
368 
369  fileStream->IStream_iface.lpVtbl = &SHLWAPI_fsVTable;
370  fileStream->ref = 1;
371  fileStream->hFile = hFile;
372  fileStream->dwMode = dwMode;
373  fileStream->lpszPath = StrDupW(lpszPath);
374  fileStream->type = 0; /* FIXME */
375  fileStream->grfStateBits = 0; /* FIXME */
376 
377  TRACE ("Returning %p\n", fileStream);
378  return &fileStream->IStream_iface;
379 }
LPOLESTR lpszPath
Definition: istream.c:48
IStream IStream_iface
Definition: istream.c:44
LPWSTR WINAPI StrDupW(LPCWSTR lpszStr)
Definition: string.c:1089
LONG ref
Definition: istream.c:45
DWORD type
Definition: istream.c:49
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
_In_ HANDLE hFile
Definition: mswsock.h:90
DWORD dwMode
Definition: istream.c:47
DWORD grfStateBits
Definition: istream.c:50
static const IStreamVtbl SHLWAPI_fsVTable
Definition: istream.c:339
HANDLE hFile
Definition: istream.c:46

Referenced by SHCreateStreamOnFileEx().

◆ IStream_fnAddRef()

static ULONG WINAPI IStream_fnAddRef ( IStream iface)
static

Definition at line 85 of file istream.c.

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

◆ IStream_fnClone()

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

Definition at line 329 of file istream.c.

330 {
332 
333  TRACE("(%p)\n",This);
334  if (ppstm)
335  *ppstm = NULL;
336  return E_NOTIMPL;
337 }
static ISHFileStream * impl_from_IStream(IStream *iface)
Definition: istream.c:53
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ IStream_fnCommit()

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

Definition at line 259 of file istream.c.

260 {
262 
263  TRACE("(%p,%d)\n", This, grfCommitFlags);
264  /* Currently unbuffered: This function is not needed */
265  return S_OK;
266 }
static ISHFileStream * impl_from_IStream(IStream *iface)
Definition: istream.c:53
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59

Referenced by IStream_fnCopyTo(), IStream_fnRelease(), IStream_fnSeek(), and IStream_fnSetSize().

◆ IStream_fnCopyTo()

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

Definition at line 209 of file istream.c.

211 {
213  char copyBuff[1024];
214  ULONGLONG ulSize;
215  HRESULT hRet = S_OK;
216 
217  TRACE("(%p,%p,%d,%p,%p)\n", This, pstm, cb.u.LowPart, pcbRead, pcbWritten);
218 
219  if (pcbRead)
220  pcbRead->QuadPart = 0;
221  if (pcbWritten)
222  pcbWritten->QuadPart = 0;
223 
224  if (!pstm)
225  return S_OK;
226 
227  IStream_fnCommit(iface, 0); /* If ever buffered, this will be needed */
228 
229  /* Copy data */
230  ulSize = cb.QuadPart;
231  while (ulSize)
232  {
233  ULONG ulLeft, ulRead, ulWritten;
234 
235  ulLeft = ulSize > sizeof(copyBuff) ? sizeof(copyBuff) : ulSize;
236 
237  /* Read */
238  hRet = IStream_fnRead(iface, copyBuff, ulLeft, &ulRead);
239  if (FAILED(hRet) || ulRead == 0)
240  break;
241  if (pcbRead)
242  pcbRead->QuadPart += ulRead;
243 
244  /* Write */
245  hRet = IStream_fnWrite(pstm, copyBuff, ulRead, &ulWritten);
246  if (pcbWritten)
247  pcbWritten->QuadPart += ulWritten;
248  if (FAILED(hRet) || ulWritten != ulLeft)
249  break;
250 
251  ulSize -= ulLeft;
252  }
253  return hRet;
254 }
static ISHFileStream * impl_from_IStream(IStream *iface)
Definition: istream.c:53
static HRESULT WINAPI IStream_fnRead(IStream *iface, void *pv, ULONG cb, ULONG *pcbRead)
Definition: istream.c:119
static HRESULT WINAPI IStream_fnWrite(IStream *iface, const void *pv, ULONG cb, ULONG *pcbWritten)
Definition: istream.c:139
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:78
static HRESULT WINAPI IStream_fnCommit(IStream *, DWORD)
Definition: istream.c:259
uint64_t ULONGLONG
Definition: typedefs.h:66
#define S_OK
Definition: intsafe.h:59
static HMODULE MODULEINFO DWORD cb
Definition: module.c:32
unsigned int ULONG
Definition: retypes.h:1

◆ IStream_fnLockUnlockRegion()

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

Definition at line 282 of file istream.c.

284 {
286  TRACE("(%p,%d,%d,%d)\n", This, libOffset.u.LowPart, cb.u.LowPart, dwLockType);
287  return E_NOTIMPL;
288 }
struct _ULARGE_INTEGER::@3765 u
static ISHFileStream * impl_from_IStream(IStream *iface)
Definition: istream.c:53
#define TRACE(s)
Definition: solgame.cpp:4
#define E_NOTIMPL
Definition: ddrawi.h:99
static HMODULE MODULEINFO DWORD cb
Definition: module.c:32

◆ IStream_fnQueryInterface()

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

Definition at line 64 of file istream.c.

65 {
67 
68  TRACE("(%p,%s,%p)\n", This, debugstr_guid(riid), ppvObj);
69 
70  *ppvObj = NULL;
71 
73  IsEqualIID(riid, &IID_IStream))
74  {
75  IStream_AddRef(iface);
76  *ppvObj = iface;
77  return S_OK;
78  }
79  return E_NOINTERFACE;
80 }
#define E_NOINTERFACE
Definition: winerror.h:2364
static ISHFileStream * impl_from_IStream(IStream *iface)
Definition: istream.c:53
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
#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 119 of file istream.c.

120 {
122  DWORD dwRead = 0;
123 
124  TRACE("(%p,%p,0x%08x,%p)\n", This, pv, cb, pcbRead);
125 
126  if (!ReadFile(This->hFile, pv, cb, &dwRead, NULL))
127  {
128  WARN("error %d reading file\n", GetLastError());
129  return S_FALSE;
130  }
131  if (pcbRead)
132  *pcbRead = dwRead;
133  return dwRead == cb ? S_OK : S_FALSE;
134 }
static ISHFileStream * impl_from_IStream(IStream *iface)
Definition: istream.c:53
#define WARN(fmt,...)
Definition: debug.h:111
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define S_FALSE
Definition: winerror.h:2357
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
#define S_OK
Definition: intsafe.h:59
static HMODULE MODULEINFO DWORD cb
Definition: module.c:32
BOOL WINAPI ReadFile(IN HANDLE hFile, IN LPVOID lpBuffer, IN DWORD nNumberOfBytesToRead, OUT LPDWORD lpNumberOfBytesRead OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:123

Referenced by IStream_fnCopyTo().

◆ IStream_fnRelease()

static ULONG WINAPI IStream_fnRelease ( IStream iface)
static

Definition at line 98 of file istream.c.

99 {
101  ULONG refCount = InterlockedDecrement(&This->ref);
102 
103  TRACE("(%p)->(ref before=%u)\n",This, refCount + 1);
104 
105  if (!refCount)
106  {
107  IStream_fnCommit(iface, 0); /* If ever buffered, this will be needed */
108  LocalFree(This->lpszPath);
109  CloseHandle(This->hFile);
111  }
112 
113  return refCount;
114 }
#define CloseHandle
Definition: compat.h:406
static ISHFileStream * impl_from_IStream(IStream *iface)
Definition: istream.c:53
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:403
static HRESULT WINAPI IStream_fnCommit(IStream *, DWORD)
Definition: istream.c:259
#define InterlockedDecrement
Definition: armddk.h:52
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
unsigned int ULONG
Definition: retypes.h:1
#define HeapFree(x, y, z)
Definition: compat.h:402

◆ IStream_fnRevert()

static HRESULT WINAPI IStream_fnRevert ( IStream iface)
static

Definition at line 271 of file istream.c.

272 {
274 
275  TRACE("(%p)\n", This);
276  return E_NOTIMPL;
277 }
static ISHFileStream * impl_from_IStream(IStream *iface)
Definition: istream.c:53
#define TRACE(s)
Definition: solgame.cpp:4
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ IStream_fnSeek()

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

Definition at line 166 of file istream.c.

168 {
170  DWORD dwPos;
171 
172  TRACE("(%p,%d,%d,%p)\n", This, dlibMove.u.LowPart, dwOrigin, pNewPos);
173 
174  IStream_fnCommit(iface, 0); /* If ever buffered, this will be needed */
175  dwPos = SetFilePointer(This->hFile, dlibMove.u.LowPart, NULL, dwOrigin);
176  if( dwPos == INVALID_SET_FILE_POINTER )
178 
179  if (pNewPos)
180  {
181  pNewPos->u.HighPart = 0;
182  pNewPos->u.LowPart = dwPos;
183  }
184  return S_OK;
185 }
#define INVALID_SET_FILE_POINTER
Definition: winbase.h:115
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
struct _ULARGE_INTEGER::@3765 u
static ISHFileStream * impl_from_IStream(IStream *iface)
Definition: istream.c:53
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
DWORD WINAPI DECLSPEC_HOTPATCH SetFilePointer(HANDLE hFile, LONG lDistanceToMove, PLONG lpDistanceToMoveHigh, DWORD dwMoveMethod)
Definition: fileinfo.c:204
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
static HRESULT WINAPI IStream_fnCommit(IStream *, DWORD)
Definition: istream.c:259
struct _LARGE_INTEGER::@2216 u
unsigned long DWORD
Definition: ntddk_ex.h:95
#define S_OK
Definition: intsafe.h:59

◆ IStream_fnSetSize()

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

Definition at line 190 of file istream.c.

191 {
193 
194  TRACE("(%p,%d)\n", This, libNewSize.u.LowPart);
195 
196  IStream_fnCommit(iface, 0); /* If ever buffered, this will be needed */
197  if( ! SetFilePointer( This->hFile, libNewSize.QuadPart, NULL, FILE_BEGIN ) )
198  return E_FAIL;
199 
200  if( ! SetEndOfFile( This->hFile ) )
201  return E_FAIL;
202 
203  return S_OK;
204 }
struct _ULARGE_INTEGER::@3765 u
static ISHFileStream * impl_from_IStream(IStream *iface)
Definition: istream.c:53
BOOL WINAPI SetEndOfFile(HANDLE hFile)
Definition: fileinfo.c:1154
#define E_FAIL
Definition: ddrawi.h:102
DWORD WINAPI DECLSPEC_HOTPATCH SetFilePointer(HANDLE hFile, LONG lDistanceToMove, PLONG lpDistanceToMoveHigh, DWORD dwMoveMethod)
Definition: fileinfo.c:204
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
static HRESULT WINAPI IStream_fnCommit(IStream *, DWORD)
Definition: istream.c:259
#define S_OK
Definition: intsafe.h:59
#define FILE_BEGIN
Definition: winbase.h:112

◆ IStream_fnStat()

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

Definition at line 293 of file istream.c.

295 {
298 
299  TRACE("(%p,%p,%d)\n", This, lpStat, grfStatFlag);
300 
301  if (!lpStat)
302  return STG_E_INVALIDPOINTER;
303 
304  memset(&fi, 0, sizeof(fi));
305  GetFileInformationByHandle(This->hFile, &fi);
306 
307  if (grfStatFlag & STATFLAG_NONAME)
308  lpStat->pwcsName = NULL;
309  else
310  lpStat->pwcsName = StrDupW(This->lpszPath);
311  lpStat->type = This->type;
312  lpStat->cbSize.u.LowPart = fi.nFileSizeLow;
313  lpStat->cbSize.u.HighPart = fi.nFileSizeHigh;
314  lpStat->mtime = fi.ftLastWriteTime;
315  lpStat->ctime = fi.ftCreationTime;
316  lpStat->atime = fi.ftLastAccessTime;
317  lpStat->grfMode = This->dwMode;
318  lpStat->grfLocksSupported = 0;
319  memcpy(&lpStat->clsid, &IID_IStream, sizeof(CLSID));
320  lpStat->grfStateBits = This->grfStateBits;
321  lpStat->reserved = 0;
322 
323  return S_OK;
324 }
#define STG_E_INVALIDPOINTER
Definition: winerror.h:2571
static ISHFileStream * impl_from_IStream(IStream *iface)
Definition: istream.c:53
LPWSTR WINAPI StrDupW(LPCWSTR lpszStr)
Definition: string.c:1089
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
BOOL WINAPI GetFileInformationByHandle(HANDLE hFile, LPBY_HANDLE_FILE_INFORMATION lpFileInformation)
Definition: fileinfo.c:608
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define S_OK
Definition: intsafe.h:59
#define memset(x, y, z)
Definition: compat.h:39

◆ IStream_fnWrite()

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

Definition at line 139 of file istream.c.

140 {
142  DWORD dwWritten = 0;
143 
144  TRACE("(%p,%p,0x%08x,%p)\n", This, pv, cb, pcbWritten);
145 
146  switch (STGM_ACCESS_MODE(This->dwMode))
147  {
148  case STGM_WRITE:
149  case STGM_READWRITE:
150  break;
151  default:
152  return STG_E_ACCESSDENIED;
153  }
154 
155  if (!WriteFile(This->hFile, pv, cb, &dwWritten, NULL))
157 
158  if (pcbWritten)
159  *pcbWritten = dwWritten;
160  return S_OK;
161 }
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
static ISHFileStream * impl_from_IStream(IStream *iface)
Definition: istream.c:53
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define STG_E_ACCESSDENIED
Definition: winerror.h:2568
smooth NULL
Definition: ftsmooth.c:416
#define STGM_WRITE
Definition: objbase.h:917
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
#define STGM_READWRITE
Definition: objbase.h:918
#define S_OK
Definition: intsafe.h:59
#define STGM_ACCESS_MODE(stgm)
Definition: istream.c:37
static HMODULE MODULEINFO DWORD cb
Definition: module.c:32

Referenced by IStream_fnCopyTo().

◆ IStream_Reset()

HRESULT WINAPI IStream_Reset ( IStream lpStream)

Definition at line 640 of file istream.c.

641 {
643  TRACE("(%p)\n", lpStream);
644  zero.QuadPart = 0;
645  return IStream_Seek(lpStream, zero, 0, NULL);
646 }
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
static double zero
Definition: j0_y0.c:96

◆ IStream_Size()

HRESULT WINAPI IStream_Size ( IStream lpStream,
ULARGE_INTEGER lpulSize 
)

Definition at line 661 of file istream.c.

662 {
663  STATSTG statstg;
664  HRESULT hRet;
665 
666  TRACE("(%p,%p)\n", lpStream, lpulSize);
667 
668  memset(&statstg, 0, sizeof(statstg));
669 
670  hRet = IStream_Stat(lpStream, &statstg, 1);
671 
672  if (SUCCEEDED(hRet) && lpulSize)
673  *lpulSize = statstg.cbSize;
674  return hRet;
675 }
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:78
#define memset(x, y, z)
Definition: compat.h:39
#define SUCCEEDED(hr)
Definition: intsafe.h:57

◆ SHCreateStreamOnFileA()

HRESULT WINAPI SHCreateStreamOnFileA ( LPCSTR  lpszPath,
DWORD  dwMode,
IStream **  lppStream 
)

Definition at line 512 of file istream.c.

514 {
516 
517  TRACE("(%s,%d,%p)\n", debugstr_a(lpszPath), dwMode, lppStream);
518 
519  if (!lpszPath)
521 
522  MultiByteToWideChar(CP_ACP, 0, lpszPath, -1, szPath, MAX_PATH);
523  return SHCreateStreamOnFileW(szPath, dwMode, lppStream);
524 }
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
#define CP_ACP
Definition: compat.h:99
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define debugstr_a
Definition: kernel32.h:31
#define MAX_PATH
Definition: compat.h:26
LPCWSTR szPath
Definition: env.c:35
#define MultiByteToWideChar
Definition: compat.h:100
HRESULT WINAPI SHCreateStreamOnFileW(LPCWSTR lpszPath, DWORD dwMode, IStream **lppStream)
Definition: istream.c:484
#define ERROR_PATH_NOT_FOUND
Definition: winerror.h:106

Referenced by test_SHCreateStreamOnFileA().

◆ SHCreateStreamOnFileEx()

HRESULT WINAPI SHCreateStreamOnFileEx ( LPCWSTR  lpszPath,
DWORD  dwMode,
DWORD  dwAttributes,
BOOL  bCreate,
IStream lpTemplate,
IStream **  lppStream 
)

Definition at line 401 of file istream.c.

404 {
405  DWORD dwAccess, dwShare, dwCreate;
406  HANDLE hFile;
407 
408  TRACE("(%s,%d,0x%08X,%d,%p,%p)\n", debugstr_w(lpszPath), dwMode,
409  dwAttributes, bCreate, lpTemplate, lppStream);
410 
411  if (!lpszPath || !lppStream || lpTemplate)
412  return E_INVALIDARG;
413 
414  *lppStream = NULL;
415 
416  /* Access */
417  switch (STGM_ACCESS_MODE(dwMode))
418  {
419  case STGM_WRITE:
420  case STGM_READWRITE:
421  dwAccess = GENERIC_READ|GENERIC_WRITE;
422  break;
423  case STGM_READ:
424  dwAccess = GENERIC_READ;
425  break;
426  default:
427  return E_INVALIDARG;
428  }
429 
430  /* Sharing */
431  switch (STGM_SHARE_MODE(dwMode))
432  {
433  case 0:
436  break;
438  dwShare = FILE_SHARE_WRITE;
439  break;
441  dwShare = FILE_SHARE_READ;
442  break;
444  dwShare = 0;
445  break;
446  default:
447  return E_INVALIDARG;
448  }
449 
450  switch(STGM_CREATE_MODE(dwMode))
451  {
452  case STGM_FAILIFTHERE:
453  dwCreate = bCreate ? CREATE_NEW : OPEN_EXISTING;
454  break;
455  case STGM_CREATE:
456  dwCreate = CREATE_ALWAYS;
457  break;
458  default:
459  return E_INVALIDARG;
460  }
461 
462  /* Open HANDLE to file */
463  hFile = CreateFileW(lpszPath, dwAccess, dwShare, NULL, dwCreate,
464  dwAttributes, 0);
465 
468 
469  *lppStream = IStream_Create(lpszPath, hFile, dwMode);
470 
471  if(!*lppStream)
472  {
474  return E_OUTOFMEMORY;
475  }
476  return S_OK;
477 }
#define STGM_SHARE_DENY_NONE
Definition: objbase.h:919
#define CloseHandle
Definition: compat.h:406
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
#define STGM_SHARE_EXCLUSIVE
Definition: objbase.h:922
#define STGM_FAILIFTHERE
Definition: objbase.h:927
#define STGM_CREATE
Definition: objbase.h:925
static IStream * IStream_Create(LPCWSTR lpszPath, HANDLE hFile, DWORD dwMode)
Definition: istream.c:362
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
DWORD dwAttributes
Definition: vdmdbg.h:34
#define FILE_SHARE_READ
Definition: compat.h:125
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define GENERIC_WRITE
Definition: nt_native.h:90
#define debugstr_w
Definition: kernel32.h:32
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
#define STGM_WRITE
Definition: objbase.h:917
#define OPEN_EXISTING
Definition: compat.h:434
#define STGM_READ
Definition: objbase.h:916
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
#define STGM_CREATE_MODE(stgm)
Definition: istream.c:39
#define GENERIC_READ
Definition: compat.h:124
_In_ HANDLE hFile
Definition: mswsock.h:90
#define STGM_READWRITE
Definition: objbase.h:918
#define S_OK
Definition: intsafe.h:59
#define CREATE_ALWAYS
Definition: disk.h:72
#define STGM_SHARE_MODE(stgm)
Definition: istream.c:38
_In_ int _In_ BOOL bCreate
Definition: shlobj.h:1443
#define STGM_ACCESS_MODE(stgm)
Definition: istream.c:37
#define CreateFileW
Definition: compat.h:408
#define CREATE_NEW
Definition: disk.h:69
#define STGM_SHARE_DENY_WRITE
Definition: objbase.h:921
#define STGM_SHARE_DENY_READ
Definition: objbase.h:920

Referenced by DoLoadPicture(), OpenStreamOnFile(), SHCreateStreamOnFileW(), test_SHCreateStreamOnFileEx(), and test_SHCreateStreamOnFileEx_CopyTo().

◆ SHCreateStreamOnFileW()

HRESULT WINAPI SHCreateStreamOnFileW ( LPCWSTR  lpszPath,
DWORD  dwMode,
IStream **  lppStream 
)

Definition at line 484 of file istream.c.

486 {
487  TRACE("(%s,%d,%p)\n", debugstr_w(lpszPath), dwMode, lppStream);
488 
489  if (!lpszPath || !lppStream)
490  return E_INVALIDARG;
491 
492  if ((dwMode & (STGM_CONVERT|STGM_DELETEONRELEASE|STGM_TRANSACTED)) != 0)
493  return E_INVALIDARG;
494 
495  return SHCreateStreamOnFileEx(lpszPath, dwMode, 0, FALSE, NULL, lppStream);
496 }
#define debugstr_w
Definition: kernel32.h:32
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
#define STGM_DELETEONRELEASE
Definition: objbase.h:924
#define STGM_CONVERT
Definition: objbase.h:926
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT WINAPI SHCreateStreamOnFileEx(LPCWSTR lpszPath, DWORD dwMode, DWORD dwAttributes, BOOL bCreate, IStream *lpTemplate, IStream **lppStream)
Definition: istream.c:401
#define STGM_TRANSACTED
Definition: objbase.h:914

Referenced by GdipCreateStreamOnFile(), IWICStreamImpl_InitializeFromFilename(), CShellLink::Load(), msi_dump_stream_to_file(), parse_config_file(), CShellLink::Save(), SHCreateStreamOnFileA(), and test_SHCreateStreamOnFileW().

◆ SHIsEmptyStream()

BOOL WINAPI SHIsEmptyStream ( IStream lpStream)

Definition at line 567 of file istream.c.

568 {
569  STATSTG statstg;
570  BOOL bRet = TRUE;
571 
572  TRACE("(%p)\n", lpStream);
573 
574  memset(&statstg, 0, sizeof(statstg));
575 
576  if(SUCCEEDED(IStream_Stat(lpStream, &statstg, 1)))
577  {
578  if(statstg.cbSize.QuadPart)
579  bRet = FALSE; /* Non-Zero */
580  }
581  else
582  {
583  DWORD dwDummy;
584 
585  /* Try to read from the stream */
586  if(SUCCEEDED(SHIStream_Read(lpStream, &dwDummy, sizeof(dwDummy))))
587  {
589  zero.QuadPart = 0;
590 
591  IStream_Seek(lpStream, zero, 0, NULL);
592  bRet = FALSE; /* Non-Zero */
593  }
594  }
595  return bRet;
596 }
#define TRUE
Definition: types.h:120
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
static double zero
Definition: j0_y0.c:96
#define memset(x, y, z)
Definition: compat.h:39
HRESULT WINAPI SHIStream_Read(IStream *lpStream, LPVOID lpvDest, ULONG ulSize)
Definition: istream.c:541
#define SUCCEEDED(hr)
Definition: intsafe.h:57

◆ SHIStream_Read()

HRESULT WINAPI SHIStream_Read ( IStream lpStream,
LPVOID  lpvDest,
ULONG  ulSize 
)

Definition at line 541 of file istream.c.

542 {
543  ULONG ulRead;
544  HRESULT hRet;
545 
546  TRACE("(%p,%p,%d)\n", lpStream, lpvDest, ulSize);
547 
548  hRet = IStream_Read(lpStream, lpvDest, ulSize, &ulRead);
549 
550  if (SUCCEEDED(hRet) && ulRead != ulSize)
551  hRet = E_FAIL;
552  return hRet;
553 }
#define E_FAIL
Definition: ddrawi.h:102
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:78
unsigned int ULONG
Definition: retypes.h:1
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by SHIsEmptyStream().

◆ SHIStream_Write()

HRESULT WINAPI SHIStream_Write ( IStream lpStream,
LPCVOID  lpvSrc,
ULONG  ulSize 
)

Definition at line 613 of file istream.c.

614 {
615  ULONG ulWritten;
616  HRESULT hRet;
617 
618  TRACE("(%p,%p,%d)\n", lpStream, lpvSrc, ulSize);
619 
620  hRet = IStream_Write(lpStream, lpvSrc, ulSize, &ulWritten);
621 
622  if (SUCCEEDED(hRet) && ulWritten != ulSize)
623  hRet = E_FAIL;
624 
625  return hRet;
626 }
#define E_FAIL
Definition: ddrawi.h:102
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:78
unsigned int ULONG
Definition: retypes.h:1
#define SUCCEEDED(hr)
Definition: intsafe.h:57

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( shell  )

Variable Documentation

◆ SHLWAPI_fsVTable

const IStreamVtbl SHLWAPI_fsVTable
static
Initial value:
=
{
}
static HRESULT WINAPI IStream_fnCopyTo(IStream *iface, IStream *pstm, ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten)
Definition: istream.c:209
static HRESULT WINAPI IStream_fnRead(IStream *iface, void *pv, ULONG cb, ULONG *pcbRead)
Definition: istream.c:119
static HRESULT WINAPI IStream_fnWrite(IStream *iface, const void *pv, ULONG cb, ULONG *pcbWritten)
Definition: istream.c:139
static HRESULT WINAPI IStream_fnRevert(IStream *iface)
Definition: istream.c:271
static ULONG WINAPI IStream_fnAddRef(IStream *iface)
Definition: istream.c:85
static HRESULT WINAPI IStream_fnClone(IStream *iface, IStream **ppstm)
Definition: istream.c:329
static HRESULT WINAPI IStream_fnSeek(IStream *iface, LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *pNewPos)
Definition: istream.c:166
static HRESULT WINAPI IStream_fnSetSize(IStream *iface, ULARGE_INTEGER libNewSize)
Definition: istream.c:190
static HRESULT WINAPI IStream_fnQueryInterface(IStream *iface, REFIID riid, LPVOID *ppvObj)
Definition: istream.c:64
static HRESULT WINAPI IStream_fnStat(IStream *iface, STATSTG *lpStat, DWORD grfStatFlag)
Definition: istream.c:293
static HRESULT WINAPI IStream_fnCommit(IStream *, DWORD)
Definition: istream.c:259
static HRESULT WINAPI IStream_fnLockUnlockRegion(IStream *iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
Definition: istream.c:282
static ULONG WINAPI IStream_fnRelease(IStream *iface)
Definition: istream.c:98

Definition at line 339 of file istream.c.

Referenced by IStream_Create().