ReactOS 0.4.17-dev-934-g091855f
loaderstream.c File Reference
#include "dmloader_private.h"
Include dependency graph for loaderstream.c:

Go to the source code of this file.

Classes

struct  loader_stream
 
struct  file_stream
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (dmloader)
 
 WINE_DECLARE_DEBUG_CHANNEL (dmfileraw)
 
static struct loader_stream * impl_from_IStream (IStream *iface)
 
static HRESULT WINAPI loader_stream_QueryInterface (IStream *iface, REFIID riid, void **ret_iface)
 
static ULONG WINAPI loader_stream_AddRef (IStream *iface)
 
static ULONG WINAPI loader_stream_Release (IStream *iface)
 
static HRESULT WINAPI loader_stream_Read (IStream *iface, void *data, ULONG size, ULONG *ret_size)
 
static HRESULT WINAPI loader_stream_Write (IStream *iface, const void *data, ULONG size, ULONG *ret_size)
 
static HRESULT WINAPI loader_stream_Seek (IStream *iface, LARGE_INTEGER offset, DWORD method, ULARGE_INTEGER *ret_offset)
 
static HRESULT WINAPI loader_stream_SetSize (IStream *iface, ULARGE_INTEGER size)
 
static HRESULT WINAPI loader_stream_CopyTo (IStream *iface, IStream *dest, ULARGE_INTEGER size, ULARGE_INTEGER *read_size, ULARGE_INTEGER *write_size)
 
static HRESULT WINAPI loader_stream_Commit (IStream *iface, DWORD flags)
 
static HRESULT WINAPI loader_stream_Revert (IStream *iface)
 
static HRESULT WINAPI loader_stream_LockRegion (IStream *iface, ULARGE_INTEGER offset, ULARGE_INTEGER size, DWORD type)
 
static HRESULT WINAPI loader_stream_UnlockRegion (IStream *iface, ULARGE_INTEGER offset, ULARGE_INTEGER size, DWORD type)
 
static HRESULT WINAPI loader_stream_Stat (IStream *iface, STATSTG *stat, DWORD flags)
 
static HRESULT WINAPI loader_stream_Clone (IStream *iface, IStream **ret_iface)
 
static struct loader_stream * impl_from_IDirectMusicGetLoader (IDirectMusicGetLoader *iface)
 
static HRESULT WINAPI loader_stream_getter_QueryInterface (IDirectMusicGetLoader *iface, REFIID iid, void **out)
 
static ULONG WINAPI loader_stream_getter_AddRef (IDirectMusicGetLoader *iface)
 
static ULONG WINAPI loader_stream_getter_Release (IDirectMusicGetLoader *iface)
 
static HRESULT WINAPI loader_stream_getter_GetLoader (IDirectMusicGetLoader *iface, IDirectMusicLoader **ret_loader)
 
HRESULT loader_stream_create (IDirectMusicLoader *loader, IStream *stream, IStream **ret_iface)
 
static struct file_stream * file_stream_from_IStream (IStream *iface)
 
static HRESULT WINAPI file_stream_QueryInterface (IStream *iface, REFIID riid, void **ret_iface)
 
static ULONG WINAPI file_stream_AddRef (IStream *iface)
 
static ULONG WINAPI file_stream_Release (IStream *iface)
 
static HRESULT WINAPI file_stream_Read (IStream *iface, void *data, ULONG size, ULONG *ret_size)
 
static HRESULT WINAPI file_stream_Write (IStream *iface, const void *data, ULONG size, ULONG *ret_size)
 
static HRESULT WINAPI file_stream_Seek (IStream *iface, LARGE_INTEGER offset, DWORD method, ULARGE_INTEGER *ret_offset)
 
static HRESULT WINAPI file_stream_SetSize (IStream *iface, ULARGE_INTEGER size)
 
static HRESULT WINAPI file_stream_CopyTo (IStream *iface, IStream *dest, ULARGE_INTEGER size, ULARGE_INTEGER *read_size, ULARGE_INTEGER *write_size)
 
static HRESULT WINAPI file_stream_Commit (IStream *iface, DWORD flags)
 
static HRESULT WINAPI file_stream_Revert (IStream *iface)
 
static HRESULT WINAPI file_stream_LockRegion (IStream *iface, ULARGE_INTEGER offset, ULARGE_INTEGER size, DWORD type)
 
static HRESULT WINAPI file_stream_UnlockRegion (IStream *iface, ULARGE_INTEGER offset, ULARGE_INTEGER size, DWORD type)
 
static HRESULT WINAPI file_stream_Stat (IStream *iface, STATSTG *stat, DWORD flags)
 
static HRESULT WINAPI file_stream_Clone (IStream *iface, IStream **ret_iface)
 
HRESULT file_stream_create (const WCHAR *path, IStream **ret_iface)
 
static ULONG WINAPI IDirectMusicLoaderResourceStream_IStream_AddRef (LPSTREAM iface)
 
static void IDirectMusicLoaderResourceStream_Detach (LPSTREAM iface)
 
HRESULT WINAPI IDirectMusicLoaderResourceStream_Attach (LPSTREAM iface, LPBYTE pbMemData, LONGLONG llMemLength, LONGLONG llPos)
 
static HRESULT WINAPI IDirectMusicLoaderResourceStream_IStream_QueryInterface (LPSTREAM iface, REFIID riid, void **ppobj)
 
static ULONG WINAPI IDirectMusicLoaderResourceStream_IStream_Release (LPSTREAM iface)
 
static HRESULT WINAPI IDirectMusicLoaderResourceStream_IStream_Read (LPSTREAM iface, void *pv, ULONG cb, ULONG *pcbRead)
 
static HRESULT WINAPI IDirectMusicLoaderResourceStream_IStream_Seek (LPSTREAM iface, LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
 
static HRESULT WINAPI IDirectMusicLoaderResourceStream_IStream_Clone (LPSTREAM iface, IStream **ppstm)
 
static HRESULT WINAPI IDirectMusicLoaderResourceStream_IStream_Write (LPSTREAM iface, const void *pv, ULONG cb, ULONG *pcbWritten)
 
static HRESULT WINAPI IDirectMusicLoaderResourceStream_IStream_SetSize (LPSTREAM iface, ULARGE_INTEGER libNewSize)
 
static HRESULT WINAPI IDirectMusicLoaderResourceStream_IStream_CopyTo (LPSTREAM iface, IStream *pstm, ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten)
 
static HRESULT WINAPI IDirectMusicLoaderResourceStream_IStream_Commit (LPSTREAM iface, DWORD grfCommitFlags)
 
static HRESULT WINAPI IDirectMusicLoaderResourceStream_IStream_Revert (LPSTREAM iface)
 
static HRESULT WINAPI IDirectMusicLoaderResourceStream_IStream_LockRegion (LPSTREAM iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
 
static HRESULT WINAPI IDirectMusicLoaderResourceStream_IStream_UnlockRegion (LPSTREAM iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
 
static HRESULT WINAPI IDirectMusicLoaderResourceStream_IStream_Stat (LPSTREAM iface, STATSTG *pstatstg, DWORD grfStatFlag)
 
HRESULT DMUSIC_CreateDirectMusicLoaderResourceStream (void **ppobj)
 

Variables

static const IStreamVtbl loader_stream_vtbl
 
static const IDirectMusicGetLoaderVtbl loader_stream_getter_vtbl
 
static const IStreamVtbl file_stream_vtbl
 
static const IStreamVtbl DirectMusicLoaderResourceStream_Stream_Vtbl
 

Function Documentation

◆ DMUSIC_CreateDirectMusicLoaderResourceStream()

HRESULT DMUSIC_CreateDirectMusicLoaderResourceStream ( void **  ppobj)

Definition at line 661 of file loaderstream.c.

661 {
663
664 TRACE("(%p)\n", ppobj);
665
666 *ppobj = NULL;
667 if (!(obj = calloc(1, sizeof(*obj)))) return E_OUTOFMEMORY;
669 obj->dwRef = 0; /* will be inited with QueryInterface */
670
671 return IDirectMusicLoaderResourceStream_IStream_QueryInterface ((LPSTREAM)&obj->StreamVtbl, &IID_IStream, ppobj);
672}
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define NULL
Definition: types.h:112
static HRESULT WINAPI IDirectMusicLoaderResourceStream_IStream_QueryInterface(LPSTREAM iface, REFIID riid, void **ppobj)
Definition: loaderstream.c:490
static const IStreamVtbl DirectMusicLoaderResourceStream_Stream_Vtbl
Definition: loaderstream.c:644
interface IStream * LPSTREAM
Definition: objfwd.h:10
#define calloc
Definition: rosglue.h:14
#define TRACE(s)
Definition: solgame.cpp:4

Referenced by IDirectMusicLoaderResourceStream_IStream_Clone(), loader_GetObject(), and loader_SetObject().

◆ file_stream_AddRef()

static ULONG WINAPI file_stream_AddRef ( IStream *  iface)
static

Definition at line 293 of file loaderstream.c.

294{
297 TRACE("(%p): new ref = %lu\n", This, ref);
298 return ref;
299}
#define InterlockedIncrement
Definition: armddk.h:53
static struct file_stream * file_stream_from_IStream(IStream *iface)
Definition: loaderstream.c:269
Definition: send.c:48
uint32_t ULONG
Definition: typedefs.h:59

◆ file_stream_Clone()

static HRESULT WINAPI file_stream_Clone ( IStream *  iface,
IStream **  ret_iface 
)
static

Definition at line 400 of file loaderstream.c.

401{
403 HRESULT hr;
404
405 TRACE("(%p, %p)\n", This, ret_iface);
406
407 if (SUCCEEDED(hr = file_stream_create(This->path, ret_iface)))
408 {
409 LARGE_INTEGER position = {0};
410 position.LowPart = SetFilePointer(This->file, 0, NULL, FILE_CURRENT);
411 hr = IStream_Seek(*ret_iface, position, STREAM_SEEK_SET, NULL);
412 }
413
414 return hr;
415}
HRESULT hr
Definition: delayimp.cpp:582
#define SetFilePointer
Definition: compat.h:743
#define SUCCEEDED(hr)
Definition: intsafe.h:50
HRESULT file_stream_create(const WCHAR *path, IStream **ret_iface)
Definition: loaderstream.c:435
ULONG LowPart
Definition: typedefs.h:106
#define FILE_CURRENT
Definition: winbase.h:116

◆ file_stream_Commit()

static HRESULT WINAPI file_stream_Commit ( IStream *  iface,
DWORD  flags 
)
static

Definition at line 364 of file loaderstream.c.

365{
367 FIXME("(%p): stub\n", This);
368 return E_NOTIMPL;
369}
#define FIXME(fmt,...)
Definition: precomp.h:53
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ file_stream_CopyTo()

static HRESULT WINAPI file_stream_CopyTo ( IStream *  iface,
IStream *  dest,
ULARGE_INTEGER  size,
ULARGE_INTEGER *  read_size,
ULARGE_INTEGER *  write_size 
)
static

Definition at line 356 of file loaderstream.c.

358{
360 FIXME("(%p): stub\n", This);
361 return E_NOTIMPL;
362}

◆ file_stream_create()

HRESULT file_stream_create ( const WCHAR *  path,
IStream **  ret_iface 
)

Definition at line 435 of file loaderstream.c.

436{
437 struct file_stream *stream;
438
439 *ret_iface = NULL;
440 if (!(stream = calloc(1, sizeof(*stream)))) return E_OUTOFMEMORY;
442 stream->ref = 1;
443
444 wcscpy(stream->path, path);
447 if (stream->file == INVALID_HANDLE_VALUE)
448 {
449 free(stream);
451 }
452
453 *ret_iface = &stream->IStream_iface;
454 return S_OK;
455}
#define free
Definition: debug_ros.c:5
#define OPEN_EXISTING
Definition: compat.h:775
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define GENERIC_READ
Definition: compat.h:135
#define CreateFileW
Definition: compat.h:741
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define FILE_SHARE_READ
Definition: compat.h:136
#define DMUS_E_LOADER_FAILEDOPEN
Definition: dmerror.h:119
#define S_OK
Definition: intsafe.h:52
static const IStreamVtbl file_stream_vtbl
Definition: loaderstream.c:417
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
wcscpy
Definition: parse.h:23
IStream IStream_iface
Definition: request.c:5732

Referenced by file_stream_Clone(), loader_GetObject(), and loader_SetObject().

◆ file_stream_from_IStream()

◆ file_stream_LockRegion()

static HRESULT WINAPI file_stream_LockRegion ( IStream *  iface,
ULARGE_INTEGER  offset,
ULARGE_INTEGER  size,
DWORD  type 
)
static

Definition at line 378 of file loaderstream.c.

379{
381 FIXME("(%p): stub\n", This);
382 return E_NOTIMPL;
383}

◆ file_stream_QueryInterface()

static HRESULT WINAPI file_stream_QueryInterface ( IStream *  iface,
REFIID  riid,
void **  ret_iface 
)
static

Definition at line 274 of file loaderstream.c.

275{
277
278 TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ret_iface);
279
281 || IsEqualGUID(riid, &IID_IStream))
282 {
283 IStream_AddRef(&This->IStream_iface);
284 *ret_iface = &This->IStream_iface;
285 return S_OK;
286 }
287
288 WARN("(%p, %s, %p): not found\n", iface, debugstr_dmguid(riid), ret_iface);
289 *ret_iface = NULL;
290 return E_NOINTERFACE;
291}
#define WARN(fmt,...)
Definition: precomp.h:61
const GUID IID_IUnknown
const char * debugstr_dmguid(const GUID *id)
Definition: dmobject.c:36
REFIID riid
Definition: atlbase.h:39
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define E_NOINTERFACE
Definition: winerror.h:3479

◆ file_stream_Read()

static HRESULT WINAPI file_stream_Read ( IStream *  iface,
void *  data,
ULONG  size,
ULONG *  ret_size 
)
static

Definition at line 317 of file loaderstream.c.

318{
320 DWORD dummy;
321
322 TRACE("(%p, %p, %#lx, %p)\n", This, data, size, ret_size);
323
324 if (!ret_size) ret_size = &dummy;
326 return *ret_size == size ? S_OK : S_FALSE;
327}
#define ReadFile(a, b, c, d, e)
Definition: compat.h:742
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLsizeiptr size
Definition: glext.h:5919
static void ULONG ULONG * ret_size
Definition: time.c:40
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define S_FALSE
Definition: winerror.h:3451
static HRESULT HRESULT_FROM_WIN32(unsigned int x)
Definition: winerror.h:210

◆ file_stream_Release()

static ULONG WINAPI file_stream_Release ( IStream *  iface)
static

Definition at line 301 of file loaderstream.c.

302{
305
306 TRACE("(%p): new ref = %lu\n", This, ref);
307
308 if (!ref)
309 {
310 CloseHandle(This->file);
311 free(This);
312 }
313
314 return ref;
315}
#define InterlockedDecrement
Definition: armddk.h:52
#define CloseHandle
Definition: compat.h:739

◆ file_stream_Revert()

static HRESULT WINAPI file_stream_Revert ( IStream *  iface)
static

Definition at line 371 of file loaderstream.c.

372{
374 FIXME("(%p): stub\n", This);
375 return E_NOTIMPL;
376}

◆ file_stream_Seek()

static HRESULT WINAPI file_stream_Seek ( IStream *  iface,
LARGE_INTEGER  offset,
DWORD  method,
ULARGE_INTEGER *  ret_offset 
)
static

Definition at line 336 of file loaderstream.c.

337{
339 DWORD position;
340
341 TRACE("(%p, %I64d, %#lx, %p)\n", This, offset.QuadPart, method, ret_offset);
342
343 position = SetFilePointer(This->file, offset.u.LowPart, NULL, method);
345 if (ret_offset) ret_offset->QuadPart = position;
346 return S_OK;
347}
#define INVALID_SET_FILE_POINTER
Definition: compat.h:732
method
Definition: dragdrop.c:54
GLintptr offset
Definition: glext.h:5920
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185

◆ file_stream_SetSize()

static HRESULT WINAPI file_stream_SetSize ( IStream *  iface,
ULARGE_INTEGER  size 
)
static

Definition at line 349 of file loaderstream.c.

350{
352 FIXME("(%p): stub\n", This);
353 return E_NOTIMPL;
354}

◆ file_stream_Stat()

static HRESULT WINAPI file_stream_Stat ( IStream *  iface,
STATSTG *  stat,
DWORD  flags 
)
static

Definition at line 393 of file loaderstream.c.

394{
396 FIXME("(%p): stub\n", This);
397 return E_NOTIMPL;
398}

◆ file_stream_UnlockRegion()

static HRESULT WINAPI file_stream_UnlockRegion ( IStream *  iface,
ULARGE_INTEGER  offset,
ULARGE_INTEGER  size,
DWORD  type 
)
static

Definition at line 385 of file loaderstream.c.

387{
389 FIXME("(%p): stub\n", This);
390 return E_NOTIMPL;
391}

◆ file_stream_Write()

static HRESULT WINAPI file_stream_Write ( IStream *  iface,
const void *  data,
ULONG  size,
ULONG *  ret_size 
)
static

Definition at line 329 of file loaderstream.c.

330{
332 FIXME("(%p): stub\n", This);
333 return E_NOTIMPL;
334}

◆ IDirectMusicLoaderResourceStream_Attach()

HRESULT WINAPI IDirectMusicLoaderResourceStream_Attach ( LPSTREAM  iface,
LPBYTE  pbMemData,
LONGLONG  llMemLength,
LONGLONG  llPos 
)

Definition at line 472 of file loaderstream.c.

472 {
474
475 TRACE("(%p, %p, %s, %s)\n", This, pbMemData, wine_dbgstr_longlong(llMemLength), wine_dbgstr_longlong(llPos));
476 if (!pbMemData || !llMemLength) {
477 WARN(": invalid pbMemData or llMemLength\n");
478 return E_FAIL;
479 }
481 This->pbMemData = pbMemData;
482 This->llMemLength = llMemLength;
483 This->llPos = llPos;
484
485 return S_OK;
486}
#define E_FAIL
Definition: ddrawi.h:102
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49
#define ICOM_THIS_MULTI(impl, field, iface)
static void IDirectMusicLoaderResourceStream_Detach(LPSTREAM iface)
Definition: loaderstream.c:464
static const IStreamVtbl StreamVtbl
Definition: mimeole.c:416

Referenced by IDirectMusicLoaderResourceStream_IStream_Clone(), loader_GetObject(), and loader_SetObject().

◆ IDirectMusicLoaderResourceStream_Detach()

static void IDirectMusicLoaderResourceStream_Detach ( LPSTREAM  iface)
static

Definition at line 464 of file loaderstream.c.

464 {
466 TRACE("(%p)\n", This);
467
468 This->pbMemData = NULL;
469 This->llMemLength = 0;
470}

Referenced by IDirectMusicLoaderResourceStream_Attach(), and IDirectMusicLoaderResourceStream_IStream_Release().

◆ IDirectMusicLoaderResourceStream_IStream_AddRef()

static ULONG WINAPI IDirectMusicLoaderResourceStream_IStream_AddRef ( LPSTREAM  iface)
static

Definition at line 505 of file loaderstream.c.

505 {
507 TRACE("(%p): AddRef from %ld\n", This, This->dwRef);
508 return InterlockedIncrement (&This->dwRef);
509}

Referenced by IDirectMusicLoaderResourceStream_IStream_QueryInterface().

◆ IDirectMusicLoaderResourceStream_IStream_Clone()

static HRESULT WINAPI IDirectMusicLoaderResourceStream_IStream_Clone ( LPSTREAM  iface,
IStream **  ppstm 
)
static

Definition at line 588 of file loaderstream.c.

588 {
590 LPSTREAM pOther = NULL;
592
593 TRACE("(%p, %p)\n", iface, ppstm);
595 if (FAILED(result)) return result;
596
597 IDirectMusicLoaderResourceStream_Attach (pOther, This->pbMemData, This->llMemLength, This->llPos);
598
599 TRACE(": succeeded\n");
600 *ppstm = pOther;
601 return S_OK;
602}
GLuint64EXT * result
Definition: glext.h:11304
#define FAILED(hr)
Definition: intsafe.h:51
HRESULT DMUSIC_CreateDirectMusicLoaderResourceStream(void **ppobj)
Definition: loaderstream.c:661
HRESULT WINAPI IDirectMusicLoaderResourceStream_Attach(LPSTREAM iface, LPBYTE pbMemData, LONGLONG llMemLength, LONGLONG llPos)
Definition: loaderstream.c:472

◆ IDirectMusicLoaderResourceStream_IStream_Commit()

static HRESULT WINAPI IDirectMusicLoaderResourceStream_IStream_Commit ( LPSTREAM  iface,
DWORD  grfCommitFlags 
)
static

Definition at line 619 of file loaderstream.c.

619 {
620 ERR(": should not be needed\n");
621 return E_NOTIMPL;
622}
#define ERR(fmt,...)
Definition: precomp.h:57

◆ IDirectMusicLoaderResourceStream_IStream_CopyTo()

static HRESULT WINAPI IDirectMusicLoaderResourceStream_IStream_CopyTo ( LPSTREAM  iface,
IStream *  pstm,
ULARGE_INTEGER  cb,
ULARGE_INTEGER *  pcbRead,
ULARGE_INTEGER *  pcbWritten 
)
static

Definition at line 614 of file loaderstream.c.

614 {
615 ERR(": should not be needed\n");
616 return E_NOTIMPL;
617}

◆ IDirectMusicLoaderResourceStream_IStream_LockRegion()

static HRESULT WINAPI IDirectMusicLoaderResourceStream_IStream_LockRegion ( LPSTREAM  iface,
ULARGE_INTEGER  libOffset,
ULARGE_INTEGER  cb,
DWORD  dwLockType 
)
static

Definition at line 629 of file loaderstream.c.

629 {
630 ERR(": should not be needed\n");
631 return E_NOTIMPL;
632}

◆ IDirectMusicLoaderResourceStream_IStream_QueryInterface()

static HRESULT WINAPI IDirectMusicLoaderResourceStream_IStream_QueryInterface ( LPSTREAM  iface,
REFIID  riid,
void **  ppobj 
)
static

Definition at line 490 of file loaderstream.c.

490 {
492
493 TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ppobj);
494 if (IsEqualIID (riid, &IID_IUnknown) ||
495 IsEqualIID (riid, &IID_IStream)) {
496 *ppobj = &This->StreamVtbl;
498 return S_OK;
499 }
500
501 WARN(": not found\n");
502 return E_NOINTERFACE;
503}
static ULONG WINAPI IDirectMusicLoaderResourceStream_IStream_AddRef(LPSTREAM iface)
Definition: loaderstream.c:505
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95

Referenced by DMUSIC_CreateDirectMusicLoaderResourceStream().

◆ IDirectMusicLoaderResourceStream_IStream_Read()

static HRESULT WINAPI IDirectMusicLoaderResourceStream_IStream_Read ( LPSTREAM  iface,
void *  pv,
ULONG  cb,
ULONG *  pcbRead 
)
static

Definition at line 524 of file loaderstream.c.

524 {
525 LPBYTE pByte;
527
528 TRACE_(dmfileraw)("(%p, %p, %#lx, %p)\n", This, pv, cb, pcbRead);
529 if ((This->llPos + cb) > This->llMemLength) {
530 WARN_(dmfileraw)(": requested size out of range\n");
531 return E_FAIL;
532 }
533
534 pByte = &This->pbMemData[This->llPos];
535 memcpy (pv, pByte, cb);
536 This->llPos += cb; /* move pointer */
537 /* FIXME: error checking would be nice */
538 if (pcbRead) *pcbRead = cb;
539
540 TRACE_(dmfileraw)(": data (size = %#lx): %s\n", cb, debugstr_an(pv, cb));
541 return S_OK;
542}
#define TRACE_(x)
Definition: compat.h:76
static __inline const char * debugstr_an(const char *s, int n)
Definition: compat.h:55
static MonoProfilerRuntimeShutdownBeginCallback cb
Definition: metahost.c:118
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define WARN_(ch,...)
Definition: debug.h:157
unsigned char * LPBYTE
Definition: typedefs.h:53

◆ IDirectMusicLoaderResourceStream_IStream_Release()

static ULONG WINAPI IDirectMusicLoaderResourceStream_IStream_Release ( LPSTREAM  iface)
static

Definition at line 511 of file loaderstream.c.

511 {
513
514 DWORD dwRef = InterlockedDecrement (&This->dwRef);
515 TRACE("(%p): ReleaseRef to %ld\n", This, dwRef);
516 if (dwRef == 0) {
518 free(This);
519 }
520
521 return dwRef;
522}

◆ IDirectMusicLoaderResourceStream_IStream_Revert()

static HRESULT WINAPI IDirectMusicLoaderResourceStream_IStream_Revert ( LPSTREAM  iface)
static

Definition at line 624 of file loaderstream.c.

624 {
625 ERR(": should not be needed\n");
626 return E_NOTIMPL;
627}

◆ IDirectMusicLoaderResourceStream_IStream_Seek()

static HRESULT WINAPI IDirectMusicLoaderResourceStream_IStream_Seek ( LPSTREAM  iface,
LARGE_INTEGER  dlibMove,
DWORD  dwOrigin,
ULARGE_INTEGER *  plibNewPosition 
)
static

Definition at line 544 of file loaderstream.c.

544 {
546 TRACE_(dmfileraw)("(%p, %s, %s, %p)\n", This, wine_dbgstr_longlong(dlibMove.QuadPart), resolve_STREAM_SEEK(dwOrigin), plibNewPosition);
547
548 switch (dwOrigin) {
549 case STREAM_SEEK_CUR: {
550 if ((This->llPos + dlibMove.QuadPart) > This->llMemLength) {
551 WARN_(dmfileraw)(": requested offset out of range\n");
552 return E_FAIL;
553 }
554 break;
555 }
556 case STREAM_SEEK_SET: {
557 if (dlibMove.QuadPart > This->llMemLength) {
558 WARN_(dmfileraw)(": requested offset out of range\n");
559 return E_FAIL;
560 }
561 /* set to the beginning of the stream */
562 This->llPos = 0;
563 break;
564 }
565 case STREAM_SEEK_END: {
566 /* TODO: check if this is true... I do think offset should be negative in this case */
567 if (dlibMove.QuadPart > 0) {
568 WARN_(dmfileraw)(": requested offset out of range\n");
569 return E_FAIL;
570 }
571 /* set to the end of the stream */
572 This->llPos = This->llMemLength;
573 break;
574 }
575 default: {
576 ERR_(dmfileraw)(": invalid dwOrigin\n");
577 return E_FAIL;
578 }
579 }
580 /* now simply add */
581 This->llPos += dlibMove.QuadPart;
582
583 if (plibNewPosition) plibNewPosition->QuadPart = This->llPos;
584
585 return S_OK;
586}
const char * resolve_STREAM_SEEK(DWORD flag)
Definition: debug.c:33
#define ERR_(ch,...)
Definition: debug.h:156
LONGLONG QuadPart
Definition: typedefs.h:114

◆ IDirectMusicLoaderResourceStream_IStream_SetSize()

static HRESULT WINAPI IDirectMusicLoaderResourceStream_IStream_SetSize ( LPSTREAM  iface,
ULARGE_INTEGER  libNewSize 
)
static

Definition at line 609 of file loaderstream.c.

609 {
610 ERR(": should not be needed\n");
611 return E_NOTIMPL;
612}

◆ IDirectMusicLoaderResourceStream_IStream_Stat()

static HRESULT WINAPI IDirectMusicLoaderResourceStream_IStream_Stat ( LPSTREAM  iface,
STATSTG *  pstatstg,
DWORD  grfStatFlag 
)
static

Definition at line 639 of file loaderstream.c.

639 {
640 ERR(": should not be needed\n");
641 return E_NOTIMPL;
642}

◆ IDirectMusicLoaderResourceStream_IStream_UnlockRegion()

static HRESULT WINAPI IDirectMusicLoaderResourceStream_IStream_UnlockRegion ( LPSTREAM  iface,
ULARGE_INTEGER  libOffset,
ULARGE_INTEGER  cb,
DWORD  dwLockType 
)
static

Definition at line 634 of file loaderstream.c.

634 {
635 ERR(": should not be needed\n");
636 return E_NOTIMPL;
637}

◆ IDirectMusicLoaderResourceStream_IStream_Write()

static HRESULT WINAPI IDirectMusicLoaderResourceStream_IStream_Write ( LPSTREAM  iface,
const void *  pv,
ULONG  cb,
ULONG *  pcbWritten 
)
static

Definition at line 604 of file loaderstream.c.

604 {
605 ERR(": should not be needed\n");
606 return E_NOTIMPL;
607}

◆ impl_from_IDirectMusicGetLoader()

static struct loader_stream * impl_from_IDirectMusicGetLoader ( IDirectMusicGetLoader *  iface)
static

Definition at line 198 of file loaderstream.c.

199{
200 return CONTAINING_RECORD(iface, struct loader_stream, IDirectMusicGetLoader_iface);
201}

Referenced by loader_stream_getter_AddRef(), loader_stream_getter_GetLoader(), loader_stream_getter_QueryInterface(), and loader_stream_getter_Release().

◆ impl_from_IStream()

◆ loader_stream_AddRef()

static ULONG WINAPI loader_stream_AddRef ( IStream *  iface)
static

Definition at line 66 of file loaderstream.c.

67{
68 struct loader_stream *This = impl_from_IStream(iface);
70 TRACE("(%p): new ref = %lu\n", This, ref);
71 return ref;
72}
static struct loader_stream * impl_from_IStream(IStream *iface)
Definition: loaderstream.c:35

◆ loader_stream_Clone()

static HRESULT WINAPI loader_stream_Clone ( IStream *  iface,
IStream **  ret_iface 
)
static

Definition at line 163 of file loaderstream.c.

164{
165 struct loader_stream *This = impl_from_IStream(iface);
167 HRESULT hr;
168
169 TRACE("(%p, %p)\n", This, ret_iface);
170
171 if (SUCCEEDED(hr = IStream_Clone(This->stream, &stream)))
172 {
173 hr = loader_stream_create(This->loader, stream, ret_iface);
174 IStream_Release(stream);
175 }
176
177 return hr;
178}
HRESULT loader_stream_create(IDirectMusicLoader *loader, IStream *stream, IStream **ret_iface)
Definition: loaderstream.c:240
IStream * stream
Definition: loaderstream.c:31

◆ loader_stream_Commit()

static HRESULT WINAPI loader_stream_Commit ( IStream *  iface,
DWORD  flags 
)
static

Definition at line 127 of file loaderstream.c.

128{
129 struct loader_stream *This = impl_from_IStream(iface);
130 FIXME("(%p): stub\n", This);
131 return E_NOTIMPL;
132}

◆ loader_stream_CopyTo()

static HRESULT WINAPI loader_stream_CopyTo ( IStream *  iface,
IStream *  dest,
ULARGE_INTEGER  size,
ULARGE_INTEGER *  read_size,
ULARGE_INTEGER *  write_size 
)
static

Definition at line 119 of file loaderstream.c.

121{
122 struct loader_stream *This = impl_from_IStream(iface);
123 FIXME("(%p): stub\n", This);
124 return E_NOTIMPL;
125}

◆ loader_stream_create()

HRESULT loader_stream_create ( IDirectMusicLoader *  loader,
IStream *  stream,
IStream **  ret_iface 
)

Definition at line 240 of file loaderstream.c.

242{
243 struct loader_stream *obj;
244
245 *ret_iface = NULL;
246 if (!(obj = calloc(1, sizeof(*obj)))) return E_OUTOFMEMORY;
247 obj->IStream_iface.lpVtbl = &loader_stream_vtbl;
248 obj->IDirectMusicGetLoader_iface.lpVtbl = &loader_stream_getter_vtbl;
249 obj->ref = 1;
250
251 obj->stream = stream;
252 IStream_AddRef(stream);
253 obj->loader = loader;
255
256 *ret_iface = &obj->IStream_iface;
257 return S_OK;
258}
#define IDirectMusicLoader_AddRef(p)
Definition: dmusici.h:878
static const IDirectMusicGetLoaderVtbl loader_stream_getter_vtbl
Definition: loaderstream.c:232
static const IStreamVtbl loader_stream_vtbl
Definition: loaderstream.c:180
IDirectMusicLoader * loader
Definition: loaderstream.c:32
Definition: loader.c:72

Referenced by loader_GetObject(), loader_SetObject(), and loader_stream_Clone().

◆ loader_stream_getter_AddRef()

static ULONG WINAPI loader_stream_getter_AddRef ( IDirectMusicGetLoader *  iface)
static

Definition at line 209 of file loaderstream.c.

210{
212 return IStream_AddRef(&This->IStream_iface);
213}
static struct loader_stream * impl_from_IDirectMusicGetLoader(IDirectMusicGetLoader *iface)
Definition: loaderstream.c:198

◆ loader_stream_getter_GetLoader()

static HRESULT WINAPI loader_stream_getter_GetLoader ( IDirectMusicGetLoader *  iface,
IDirectMusicLoader **  ret_loader 
)
static

Definition at line 221 of file loaderstream.c.

222{
224
225 TRACE("(%p, %p)\n", This, ret_loader);
226
227 *ret_loader = This->loader;
229 return S_OK;
230}

◆ loader_stream_getter_QueryInterface()

static HRESULT WINAPI loader_stream_getter_QueryInterface ( IDirectMusicGetLoader *  iface,
REFIID  iid,
void **  out 
)
static

Definition at line 203 of file loaderstream.c.

204{
206 return IStream_QueryInterface(&This->IStream_iface, iid, out);
207}
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383

◆ loader_stream_getter_Release()

static ULONG WINAPI loader_stream_getter_Release ( IDirectMusicGetLoader *  iface)
static

Definition at line 215 of file loaderstream.c.

216{
218 return IStream_Release(&This->IStream_iface);
219}

◆ loader_stream_LockRegion()

static HRESULT WINAPI loader_stream_LockRegion ( IStream *  iface,
ULARGE_INTEGER  offset,
ULARGE_INTEGER  size,
DWORD  type 
)
static

Definition at line 141 of file loaderstream.c.

142{
143 struct loader_stream *This = impl_from_IStream(iface);
144 FIXME("(%p): stub\n", This);
145 return E_NOTIMPL;
146}

◆ loader_stream_QueryInterface()

static HRESULT WINAPI loader_stream_QueryInterface ( IStream *  iface,
REFIID  riid,
void **  ret_iface 
)
static

Definition at line 40 of file loaderstream.c.

41{
42 struct loader_stream *This = impl_from_IStream(iface);
43
44 TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ret_iface);
45
47 || IsEqualGUID(riid, &IID_IStream))
48 {
49 IStream_AddRef(&This->IStream_iface);
50 *ret_iface = &This->IStream_iface;
51 return S_OK;
52 }
53
54 if (IsEqualGUID(riid, &IID_IDirectMusicGetLoader))
55 {
56 IDirectMusicGetLoader_AddRef(&This->IDirectMusicGetLoader_iface);
57 *ret_iface = &This->IDirectMusicGetLoader_iface;
58 return S_OK;
59 }
60
61 WARN("(%p, %s, %p): not found\n", iface, debugstr_dmguid(riid), ret_iface);
62 *ret_iface = NULL;
63 return E_NOINTERFACE;
64}
#define IDirectMusicGetLoader_AddRef(p)
Definition: dmusici.h:960

◆ loader_stream_Read()

static HRESULT WINAPI loader_stream_Read ( IStream *  iface,
void *  data,
ULONG  size,
ULONG *  ret_size 
)
static

Definition at line 91 of file loaderstream.c.

92{
93 struct loader_stream *This = impl_from_IStream(iface);
94 TRACE("(%p, %p, %#lx, %p)\n", This, data, size, ret_size);
95 return IStream_Read(This->stream, data, size, ret_size);
96}

◆ loader_stream_Release()

static ULONG WINAPI loader_stream_Release ( IStream *  iface)
static

Definition at line 74 of file loaderstream.c.

75{
76 struct loader_stream *This = impl_from_IStream(iface);
78
79 TRACE("(%p): new ref = %lu\n", This, ref);
80
81 if (!ref)
82 {
84 IStream_Release(This->stream);
85 free(This);
86 }
87
88 return ref;
89}
#define IDirectMusicLoader_Release(p)
Definition: dmusici.h:879

◆ loader_stream_Revert()

static HRESULT WINAPI loader_stream_Revert ( IStream *  iface)
static

Definition at line 134 of file loaderstream.c.

135{
136 struct loader_stream *This = impl_from_IStream(iface);
137 FIXME("(%p): stub\n", This);
138 return E_NOTIMPL;
139}

◆ loader_stream_Seek()

static HRESULT WINAPI loader_stream_Seek ( IStream *  iface,
LARGE_INTEGER  offset,
DWORD  method,
ULARGE_INTEGER *  ret_offset 
)
static

Definition at line 105 of file loaderstream.c.

106{
107 struct loader_stream *This = impl_from_IStream(iface);
108 TRACE("(%p, %I64d, %#lx, %p)\n", This, offset.QuadPart, method, ret_offset);
109 return IStream_Seek(This->stream, offset, method, ret_offset);
110}

◆ loader_stream_SetSize()

static HRESULT WINAPI loader_stream_SetSize ( IStream *  iface,
ULARGE_INTEGER  size 
)
static

Definition at line 112 of file loaderstream.c.

113{
114 struct loader_stream *This = impl_from_IStream(iface);
115 FIXME("(%p): stub\n", This);
116 return E_NOTIMPL;
117}

◆ loader_stream_Stat()

static HRESULT WINAPI loader_stream_Stat ( IStream *  iface,
STATSTG *  stat,
DWORD  flags 
)
static

Definition at line 156 of file loaderstream.c.

157{
158 struct loader_stream *This = impl_from_IStream(iface);
159 FIXME("(%p): stub\n", This);
160 return E_NOTIMPL;
161}

◆ loader_stream_UnlockRegion()

static HRESULT WINAPI loader_stream_UnlockRegion ( IStream *  iface,
ULARGE_INTEGER  offset,
ULARGE_INTEGER  size,
DWORD  type 
)
static

Definition at line 148 of file loaderstream.c.

150{
151 struct loader_stream *This = impl_from_IStream(iface);
152 FIXME("(%p): stub\n", This);
153 return E_NOTIMPL;
154}

◆ loader_stream_Write()

static HRESULT WINAPI loader_stream_Write ( IStream *  iface,
const void *  data,
ULONG  size,
ULONG *  ret_size 
)
static

Definition at line 98 of file loaderstream.c.

99{
100 struct loader_stream *This = impl_from_IStream(iface);
101 FIXME("(%p): stub\n", This);
102 return E_NOTIMPL;
103}

◆ WINE_DECLARE_DEBUG_CHANNEL()

WINE_DECLARE_DEBUG_CHANNEL ( dmfileraw  )

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( dmloader  )

Variable Documentation

◆ DirectMusicLoaderResourceStream_Stream_Vtbl

const IStreamVtbl DirectMusicLoaderResourceStream_Stream_Vtbl
static
Initial value:
= {
}
static HRESULT WINAPI IDirectMusicLoaderResourceStream_IStream_SetSize(LPSTREAM iface, ULARGE_INTEGER libNewSize)
Definition: loaderstream.c:609
static HRESULT WINAPI IDirectMusicLoaderResourceStream_IStream_Read(LPSTREAM iface, void *pv, ULONG cb, ULONG *pcbRead)
Definition: loaderstream.c:524
static HRESULT WINAPI IDirectMusicLoaderResourceStream_IStream_Write(LPSTREAM iface, const void *pv, ULONG cb, ULONG *pcbWritten)
Definition: loaderstream.c:604
static HRESULT WINAPI IDirectMusicLoaderResourceStream_IStream_Revert(LPSTREAM iface)
Definition: loaderstream.c:624
static ULONG WINAPI IDirectMusicLoaderResourceStream_IStream_Release(LPSTREAM iface)
Definition: loaderstream.c:511
static HRESULT WINAPI IDirectMusicLoaderResourceStream_IStream_Seek(LPSTREAM iface, LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
Definition: loaderstream.c:544
static HRESULT WINAPI IDirectMusicLoaderResourceStream_IStream_Clone(LPSTREAM iface, IStream **ppstm)
Definition: loaderstream.c:588
static HRESULT WINAPI IDirectMusicLoaderResourceStream_IStream_Commit(LPSTREAM iface, DWORD grfCommitFlags)
Definition: loaderstream.c:619
static HRESULT WINAPI IDirectMusicLoaderResourceStream_IStream_UnlockRegion(LPSTREAM iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
Definition: loaderstream.c:634
static HRESULT WINAPI IDirectMusicLoaderResourceStream_IStream_Stat(LPSTREAM iface, STATSTG *pstatstg, DWORD grfStatFlag)
Definition: loaderstream.c:639
static HRESULT WINAPI IDirectMusicLoaderResourceStream_IStream_LockRegion(LPSTREAM iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
Definition: loaderstream.c:629
static HRESULT WINAPI IDirectMusicLoaderResourceStream_IStream_CopyTo(LPSTREAM iface, IStream *pstm, ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten)
Definition: loaderstream.c:614

Definition at line 644 of file loaderstream.c.

Referenced by DMUSIC_CreateDirectMusicLoaderResourceStream().

◆ file_stream_vtbl

const IStreamVtbl file_stream_vtbl
static
Initial value:
=
{
}
static HRESULT WINAPI file_stream_UnlockRegion(IStream *iface, ULARGE_INTEGER offset, ULARGE_INTEGER size, DWORD type)
Definition: loaderstream.c:385
static HRESULT WINAPI file_stream_Clone(IStream *iface, IStream **ret_iface)
Definition: loaderstream.c:400
static HRESULT WINAPI file_stream_Seek(IStream *iface, LARGE_INTEGER offset, DWORD method, ULARGE_INTEGER *ret_offset)
Definition: loaderstream.c:336
static HRESULT WINAPI file_stream_LockRegion(IStream *iface, ULARGE_INTEGER offset, ULARGE_INTEGER size, DWORD type)
Definition: loaderstream.c:378
static HRESULT WINAPI file_stream_Commit(IStream *iface, DWORD flags)
Definition: loaderstream.c:364
static HRESULT WINAPI file_stream_QueryInterface(IStream *iface, REFIID riid, void **ret_iface)
Definition: loaderstream.c:274
static HRESULT WINAPI file_stream_Revert(IStream *iface)
Definition: loaderstream.c:371
static HRESULT WINAPI file_stream_Write(IStream *iface, const void *data, ULONG size, ULONG *ret_size)
Definition: loaderstream.c:329
static HRESULT WINAPI file_stream_Read(IStream *iface, void *data, ULONG size, ULONG *ret_size)
Definition: loaderstream.c:317
static HRESULT WINAPI file_stream_SetSize(IStream *iface, ULARGE_INTEGER size)
Definition: loaderstream.c:349
static ULONG WINAPI file_stream_Release(IStream *iface)
Definition: loaderstream.c:301
static ULONG WINAPI file_stream_AddRef(IStream *iface)
Definition: loaderstream.c:293
static HRESULT WINAPI file_stream_CopyTo(IStream *iface, IStream *dest, ULARGE_INTEGER size, ULARGE_INTEGER *read_size, ULARGE_INTEGER *write_size)
Definition: loaderstream.c:356
static HRESULT WINAPI file_stream_Stat(IStream *iface, STATSTG *stat, DWORD flags)
Definition: loaderstream.c:393

Definition at line 417 of file loaderstream.c.

Referenced by file_stream_create().

◆ loader_stream_getter_vtbl

const IDirectMusicGetLoaderVtbl loader_stream_getter_vtbl
static
Initial value:
=
{
}
static HRESULT WINAPI loader_stream_getter_QueryInterface(IDirectMusicGetLoader *iface, REFIID iid, void **out)
Definition: loaderstream.c:203
static ULONG WINAPI loader_stream_getter_Release(IDirectMusicGetLoader *iface)
Definition: loaderstream.c:215
static ULONG WINAPI loader_stream_getter_AddRef(IDirectMusicGetLoader *iface)
Definition: loaderstream.c:209
static HRESULT WINAPI loader_stream_getter_GetLoader(IDirectMusicGetLoader *iface, IDirectMusicLoader **ret_loader)
Definition: loaderstream.c:221

Definition at line 232 of file loaderstream.c.

Referenced by loader_stream_create().

◆ loader_stream_vtbl

const IStreamVtbl loader_stream_vtbl
static
Initial value:
=
{
}
static HRESULT WINAPI loader_stream_Stat(IStream *iface, STATSTG *stat, DWORD flags)
Definition: loaderstream.c:156
static HRESULT WINAPI loader_stream_QueryInterface(IStream *iface, REFIID riid, void **ret_iface)
Definition: loaderstream.c:40
static HRESULT WINAPI loader_stream_SetSize(IStream *iface, ULARGE_INTEGER size)
Definition: loaderstream.c:112
static HRESULT WINAPI loader_stream_Seek(IStream *iface, LARGE_INTEGER offset, DWORD method, ULARGE_INTEGER *ret_offset)
Definition: loaderstream.c:105
static HRESULT WINAPI loader_stream_UnlockRegion(IStream *iface, ULARGE_INTEGER offset, ULARGE_INTEGER size, DWORD type)
Definition: loaderstream.c:148
static HRESULT WINAPI loader_stream_Commit(IStream *iface, DWORD flags)
Definition: loaderstream.c:127
static HRESULT WINAPI loader_stream_Clone(IStream *iface, IStream **ret_iface)
Definition: loaderstream.c:163
static ULONG WINAPI loader_stream_AddRef(IStream *iface)
Definition: loaderstream.c:66
static HRESULT WINAPI loader_stream_Write(IStream *iface, const void *data, ULONG size, ULONG *ret_size)
Definition: loaderstream.c:98
static HRESULT WINAPI loader_stream_Read(IStream *iface, void *data, ULONG size, ULONG *ret_size)
Definition: loaderstream.c:91
static HRESULT WINAPI loader_stream_CopyTo(IStream *iface, IStream *dest, ULARGE_INTEGER size, ULARGE_INTEGER *read_size, ULARGE_INTEGER *write_size)
Definition: loaderstream.c:119
static ULONG WINAPI loader_stream_Release(IStream *iface)
Definition: loaderstream.c:74
static HRESULT WINAPI loader_stream_LockRegion(IStream *iface, ULARGE_INTEGER offset, ULARGE_INTEGER size, DWORD type)
Definition: loaderstream.c:141
static HRESULT WINAPI loader_stream_Revert(IStream *iface)
Definition: loaderstream.c:134

Definition at line 180 of file loaderstream.c.

Referenced by loader_stream_create().