/************************************************************************* * SHCreateStreamWrapper [SHLWAPI.@] * * Create an IStream object on a block of memory. * * PARAMS * lpbData [I] Memory block to create the IStream object on * dwDataLen [I] Length of data block * dwReserved [I] Reserved, Must be 0. * lppStream [O] Destination for IStream object * * RETURNS * Success: S_OK. lppStream contains the new IStream object. * Failure: E_INVALIDARG, if any parameters are invalid, * E_OUTOFMEMORY if memory allocation fails. * * NOTES * The stream assumes ownership of the memory passed to it. */ HRESULT WINAPI SHCreateStreamWrapper(LPBYTE lpbData, DWORD dwDataLen, DWORD dwReserved, IStream **lppStream) { ISHRegStream *strm; if (lppStream) *lppStream = NULL; if(dwReserved || !lppStream) return E_INVALIDARG; strm = IStream_Create(NULL, lpbData, dwDataLen); if(!strm) return E_OUTOFMEMORY; IStream_QueryInterface(&strm->IStream_iface, &IID_IStream, (void**)lppStream); IStream_Release(&strm->IStream_iface); return S_OK; }
void test_InProcess() { LARGE_INTEGER move; ULARGE_INTEGER size; HRESULT res; ULONG i; RTL_MEMORY_STREAM stream; RTL_MEMORY_STREAM previous; IStream * istream; UCHAR buffer[80]; UCHAR buffer2[180]; ULONG bytesRead; STATSTG stat; finalReleaseCallCount = 0; for (i = 0; i < sizeof(buffer2); i++) { buffer2[i] = i % UCHAR_MAX; } memset(&stream, 0x90, sizeof(stream)); memset(&previous, 0x00, sizeof(previous)); StartSeh() RtlInitMemoryStream(NULL); EndSeh(STATUS_ACCESS_VIOLATION); StartSeh() RtlInitMemoryStream(&stream); EndSeh(STATUS_SUCCESS); CompareStructsAndSaveForLater(&previous, &stream, "After init"); ok(stream.RefCount == 0, "RefCount has a wrong value: %d (expected %d).\n", stream.RefCount, 0); stream.Current = buffer2; stream.Start = buffer2; stream.End = buffer2 + sizeof(buffer2); stream.FinalRelease = CustomFinalReleaseMemoryStream; CompareStructsAndSaveForLater(&previous, &stream, "After assigning"); StartSeh() res = IStream_QueryInterface((struct IStream*)&stream, NULL, NULL); ok(res == E_INVALIDARG, "QueryInterface to IStream returned wrong hResult: 0x%08x.\n", res); ok(stream.RefCount == 0, "RefCount has a wrong value: %d (expected %d).\n", stream.RefCount, 2); EndSeh(STATUS_ACCESS_VIOLATION); StartSeh() res = IStream_QueryInterface((struct IStream*)&stream, &IID_IStream, NULL); ok(res == E_INVALIDARG, "QueryInterface to IStream returned wrong hResult: 0x%08x.\n", res); ok(stream.RefCount == 1, "RefCount has a wrong value: %d (expected %d).\n", stream.RefCount, 2); EndSeh(STATUS_ACCESS_VIOLATION); StartSeh() res = IStream_QueryInterface((struct IStream*)&stream, NULL, (void**)&istream); ok(res == E_INVALIDARG, "QueryInterface to IStream returned wrong hResult: 0x%08x.\n", res); ok(stream.RefCount == 1, "RefCount has a wrong value: %d (expected %d).\n", stream.RefCount, 2); EndSeh(STATUS_ACCESS_VIOLATION); StartSeh() res = IStream_QueryInterface((struct IStream*)&stream, &IID_IStream, (void**)&istream); ok(res == S_OK, "QueryInterface to IStream returned wrong hResult: 0x%08x.\n", res); ok(stream.RefCount == 2, "RefCount has a wrong value: %d (expected %d).\n", stream.RefCount, 2); EndSeh(STATUS_SUCCESS); CompareStructsAndSaveForLater(&previous, &stream, "After QueryInterface"); StartSeh() res = IStream_Stat(istream, NULL, 0); ok(res == STG_E_INVALIDPOINTER, "Stat to IStream returned wrong hResult: 0x%08x.\n", res); EndSeh(STATUS_SUCCESS); StartSeh() res = IStream_Stat(istream, &stat, STATFLAG_NONAME); ok(res == S_OK, "Stat to IStream returned wrong hResult: 0x%08x.\n", res); EndSeh(STATUS_SUCCESS); ok(stream.Current == buffer2, "stream.Current points to the wrong address 0x%p (expected 0x%p)\n", stream.Current, buffer2); ok(stream.Start == buffer2, "stream.Start was changed unexpectedly\n"); ok(stream.End == buffer2 + sizeof(buffer2), "stream.End was changed unexpectedly\n"); ok(stat.cbSize.QuadPart == ((PUCHAR)stream.End - (PUCHAR)stream.Start), "stat.cbSize has the wrong value %lld (expected %d)\n", stat.cbSize.QuadPart, (PUCHAR)stream.End - (PUCHAR)stream.Start); CompareStructsAndSaveForLater(&previous, &stream, "After Stat"); StartSeh() res = IStream_AddRef(istream); ok(res == 3, "AddRef to IStream returned wrong hResult: %d.\n", res); EndSeh(STATUS_SUCCESS); StartSeh() res = IStream_AddRef(istream); ok(res == 4, "AddRef to IStream returned wrong hResult: %d.\n", res); EndSeh(STATUS_SUCCESS); StartSeh() res = IStream_Release(istream); ok(res == 3, "Release to IStream returned wrong hResult: %d.\n", res); EndSeh(STATUS_SUCCESS); StartSeh() res = IStream_AddRef(istream); ok(res == 4, "AddRef to IStream returned wrong hResult: %d.\n", res); EndSeh(STATUS_SUCCESS); StartSeh() res = IStream_Release(istream); ok(res == 3, "Release to IStream returned wrong hResult: %d.\n", res); EndSeh(STATUS_SUCCESS); StartSeh() res = IStream_Release(istream); ok(res == 2, "Release to IStream returned wrong hResult: %d.\n", res); EndSeh(STATUS_SUCCESS); CompareStructsAndSaveForLater(&previous, &stream, "After AddRef"); StartSeh() res = IStream_Read(istream, NULL, 0, &bytesRead); ok(res == S_OK, "Read to IStream returned wrong hResult: 0x%08x.\n", res); EndSeh(STATUS_SUCCESS); StartSeh() res = IStream_Read(istream, buffer, 40, NULL); ok(res == S_OK, "Read to IStream returned wrong hResult: 0x%08x.\n", res); EndSeh(STATUS_ACCESS_VIOLATION); StartSeh() res = IStream_Read(istream, buffer + 40, 39, &bytesRead); ok(res == S_OK, "Read to IStream returned wrong hResult: 0x%08x.\n", res); EndSeh(STATUS_SUCCESS); if (SUCCEEDED(res)) { bytesRead += 40; for (i = 0; i < bytesRead; i++) { ok(buffer[i] == i, "Buffer[%d] contains a wrong number %d (expected %d).\n", i, buffer[i], i); } } ok(stream.Current == buffer2 + 79, "stream.Current points to the wrong address 0x%p (expected 0x%p)\n", stream.Current, buffer2); ok(stream.Start == buffer2, "stream.Start was changed unexpectedly\n"); ok(stream.End == buffer2 + sizeof(buffer2), "stream.End was changed unexpectedly\n"); CompareStructsAndSaveForLater(&previous, &stream, "After Read 1"); size.QuadPart = 0x9090909090909090ull; StartSeh() move.QuadPart = -1; res = IStream_Seek(istream, move, STREAM_SEEK_END, &size); ok(res == STG_E_INVALIDPOINTER, "Seek to IStream returned wrong hResult: 0x%08x.\n", res); ok(size.QuadPart == 0x9090909090909090ull, "Seek modified the new location in an error (0x%08x,0x%08x).\n", size.HighPart, size.LowPart); EndSeh(STATUS_SUCCESS); StartSeh() move.QuadPart = 0; res = IStream_Seek(istream, move, STREAM_SEEK_END, &size); ok(res == S_OK, "Seek to IStream returned wrong hResult: 0x%08x.\n", res); ok(size.QuadPart == (PUCHAR)stream.End - (PUCHAR)stream.Start, "Seek new location unexpected value: 0x%08x.\n", size.LowPart); EndSeh(STATUS_SUCCESS); size.QuadPart = 0x9090909090909090ull; StartSeh() move.QuadPart = 1; res = IStream_Seek(istream, move, STREAM_SEEK_END, &size); ok(res == S_OK, "Seek to IStream returned wrong hResult: 0x%08x.\n", res); ok(size.QuadPart == (PUCHAR)stream.End - (PUCHAR)stream.Start - 1, "Seek new location unexpected value: 0x%08x.\n", size.LowPart); EndSeh(STATUS_SUCCESS); size.QuadPart = 0x9090909090909090ull; StartSeh() move.QuadPart = 2; res = IStream_Seek(istream, move, STREAM_SEEK_END, &size); ok(res == S_OK, "Seek to IStream returned wrong hResult: 0x%08x.\n", res); ok(size.QuadPart == (PUCHAR)stream.End - (PUCHAR)stream.Start - 2, "Seek new location unexpected value: 0x%08x.\n", size.LowPart); EndSeh(STATUS_SUCCESS); size.QuadPart = 0x9090909090909090ull; StartSeh() move.QuadPart = -20; res = IStream_Seek(istream, move, STREAM_SEEK_SET, &size); ok(res == STG_E_INVALIDPOINTER, "Seek to IStream returned wrong hResult: 0x%08x.\n", res); ok(size.QuadPart == 0x9090909090909090ull, "Seek modified the new location in an error.\n"); EndSeh(STATUS_SUCCESS); StartSeh() move.QuadPart = 4000; res = IStream_Seek(istream, move, STREAM_SEEK_SET, &size); ok(res == STG_E_INVALIDPOINTER, "Seek to IStream returned wrong hResult: 0x%08x.\n", res); ok(size.QuadPart == 0x9090909090909090ull, "Seek modified the new location in an error.\n"); EndSeh(STATUS_SUCCESS); StartSeh() move.QuadPart = 0x100000000ull; res = IStream_Seek(istream, move, STREAM_SEEK_SET, &size); #ifdef _WIN64 ok(res == STG_E_INVALIDPOINTER, "Seek to IStream returned wrong hResult: 0x%08x.\n", res); ok(size.QuadPart == 0x9090909090909090ull, "Seek modified the new location in an error (0x%08x,0x%08x).\n", size.HighPart, size.LowPart); #else ok(res == S_OK, "Seek to IStream returned wrong hResult: 0x%08x.\n", res); ok(size.QuadPart == 0, "Seek new location unexpected value: 0x%08x.\n", size.LowPart); #endif EndSeh(STATUS_SUCCESS); #ifdef _WIN64 StartSeh() move.QuadPart = 0; res = IStream_Seek(istream, move, STREAM_SEEK_SET, &size); ok(res == S_OK, "Seek to IStream returned wrong hResult: 0x%08x.\n", res); ok(size.QuadPart == 0, "Seek new location unexpected value: 0x%08x.\n", size.LowPart); EndSeh(STATUS_SUCCESS); #endif size.QuadPart = 0x9090909090909090ull; StartSeh() move.QuadPart = -20; res = IStream_Seek(istream, move, STREAM_SEEK_CUR, &size); ok(res == STG_E_INVALIDPOINTER, "Seek to IStream returned wrong hResult: 0x%08x.\n", res); ok(size.QuadPart == 0x9090909090909090ull, "Seek modified the new location in an error (0x%08x,0x%08x).\n", size.HighPart, size.LowPart); EndSeh(STATUS_SUCCESS); StartSeh() move.QuadPart = 0x100000000ull; res = IStream_Seek(istream, move, STREAM_SEEK_CUR, &size); #ifdef _WIN64 ok(res == STG_E_INVALIDPOINTER, "Seek to IStream returned wrong hResult: 0x%08x.\n", res); ok(size.QuadPart == 0x9090909090909090ull, "Seek modified the new location in an error (0x%08x,0x%08x).\n", size.HighPart, size.LowPart); #else ok(res == S_OK, "Seek to IStream returned wrong hResult: 0x%08x.\n", res); ok(size.QuadPart == 0, "Seek new location unexpected value: 0x%08x.\n", size.LowPart); #endif EndSeh(STATUS_SUCCESS); StartSeh() move.QuadPart = 40; res = IStream_Seek(istream, move, STREAM_SEEK_SET, &size); ok(res == S_OK, "Seek to IStream returned wrong hResult: 0x%08x.\n", res); EndSeh(STATUS_SUCCESS); ok(size.QuadPart == 40, "Seek returned wrong offset %lld (expected %d)\n", size.QuadPart, 40); ok(stream.Current == buffer2 + 40, "stream.Current points to the wrong address 0x%p (expected 0x%p)\n", stream.Current, buffer2); ok(stream.Start == buffer2, "stream.Start was changed unexpectedly\n"); ok(stream.End == buffer2 + sizeof(buffer2), "stream.End was changed unexpectedly\n"); CompareStructsAndSaveForLater(&previous, &stream, "After Seek"); res = IStream_Read(istream, buffer, sizeof(buffer), &bytesRead); ok(res == S_OK, "Read to IStream returned wrong hResult: 0x%08x.\n", res); if (SUCCEEDED(res)) { for (i = 0; i < bytesRead; i++) { ok(buffer[i] == (i + 40), "Buffer[%d] contains a wrong number %d (expected %d).\n", i, buffer[i], i + 40); } } ok(stream.Current == buffer2 + 40 + sizeof(buffer), "stream.Current points to the wrong address 0x%p (expected 0x%p)\n", stream.Current, buffer2); ok(stream.Start == buffer2, "stream.Start was changed unexpectedly\n"); ok(stream.End == buffer2 + sizeof(buffer2), "stream.End was changed unexpectedly\n"); CompareStructsAndSaveForLater(&previous, &stream, "After Read 2"); res = IStream_Release(istream); ok(res == 1, "Release to IStream returned wrong hResult: 0x%08x.\n", res); ok(stream.RefCount == 1, "RefCount has a wrong value: %d (expected %d).\n", stream.RefCount, 1); res = IStream_Release(istream); ok(res == S_OK, "Release to IStream returned wrong hResult: 0x%08x.\n", res); ok(stream.RefCount == 0, "RefCount has a wrong value: %d (expected %d).\n", stream.RefCount, 0); ok(finalReleaseCallCount == 1, "FinalRelease was called %d times instead of 1.\n", finalReleaseCallCount); }
void test_OutOfProcess() { LARGE_INTEGER move; ULARGE_INTEGER size; HRESULT res; HANDLE process; ULONG i; RTL_MEMORY_STREAM stream; RTL_MEMORY_STREAM previous; IStream * istream; UCHAR buffer[80]; UCHAR buffer2[180]; ULONG bytesRead; STATSTG stat; finalReleaseCallCount = 0; for (i = 0; i < sizeof(buffer2); i++) { buffer2[i] = i % UCHAR_MAX; } memset(&stream, 0x90, sizeof(stream)); memset(&previous, 0x00, sizeof(previous)); process = GetCurrentProcess(); RtlInitOutOfProcessMemoryStream(&stream); ok(stream.FinalRelease == RtlFinalReleaseOutOfProcessMemoryStream, "stream.FinalRelease unexpected %p != %p.\n", stream.FinalRelease, RtlFinalReleaseOutOfProcessMemoryStream); ok(stream.RefCount == 0, "RefCount has a wrong value: %d (expected %d).\n", stream.RefCount, 0); CompareStructsAndSaveForLater(&previous, &stream, "After init"); stream.Current = buffer2; stream.Start = buffer2; stream.End = buffer2 + sizeof(buffer2); stream.ProcessHandle = process; stream.FinalRelease = CustomFinalReleaseOutOfProcessMemoryStream; CompareStructsAndSaveForLater(&previous, &stream, "After assigning"); res = IStream_QueryInterface((struct IStream*)&stream, &IID_IStream, (void**)&istream); ok(res == S_OK, "QueryInterface to IStream returned wrong hResult: 0x%08x.\n", res); ok(stream.RefCount == 1, "RefCount has a wrong value: %d (expected %d).\n", stream.RefCount, 1); ok(stream.ProcessHandle == process, "ProcessHandle changed unexpectedly: 0x%08x (expected 0x%p)\n", stream.ProcessHandle, process); CompareStructsAndSaveForLater(&previous, &stream, "After QueryInterface"); res = IStream_Stat(istream, &stat, STATFLAG_NONAME); ok(res == S_OK, "Stat to IStream returned wrong hResult: 0x%08x.\n", res); ok(stream.Current == buffer2, "stream.Current points to the wrong address 0x%p (expected 0x%p)\n", stream.Current, buffer2); ok(stream.Start == buffer2, "stream.Start was changed unexpectedly\n"); ok(stream.End == buffer2 + sizeof(buffer2), "stream.End was changed unexpectedly\n"); ok(stream.ProcessHandle == process, "ProcessHandle changed unexpectedly: 0x%08x (expected 0x%p)\n", stream.ProcessHandle, process); ok(stat.cbSize.QuadPart == ((PUCHAR)stream.End - (PUCHAR)stream.Start), "stat.cbSize has the wrong value %lld (expected %d)\n", stat.cbSize.QuadPart, (PUCHAR)stream.End - (PUCHAR)stream.Start); CompareStructsAndSaveForLater(&previous, &stream, "After Stat"); res = IStream_Read(istream, buffer, sizeof(buffer), &bytesRead); ok(res == S_OK, "Read to IStream returned wrong hResult: 0x%08x.\n", res); if (SUCCEEDED(res)) { for (i = 0; i < bytesRead; i++) { ok(buffer[i] == i, "Buffer[%d] contains a wrong number %d (expected %d).\n", i, buffer[i], i); } } ok(stream.Current == buffer2 + sizeof(buffer), "stream.Current points to the wrong address 0x%p (expected 0x%p)\n", stream.Current, buffer2); ok(stream.Start == buffer2, "stream.Start was changed unexpectedly\n"); ok(stream.End == buffer2 + sizeof(buffer2), "stream.End was changed unexpectedly\n"); ok(stream.ProcessHandle == process, "ProcessHandle changed unexpectedly: 0x%08x (expected 0x%p)\n", stream.ProcessHandle, process); CompareStructsAndSaveForLater(&previous, &stream, "After Read 1"); move.QuadPart = 40; res = IStream_Seek(istream, move, STREAM_SEEK_SET, &size); ok(res == S_OK, "Seek to IStream returned wrong hResult: 0x%08x.\n", res); ok(size.QuadPart == 40, "Seek returned wrong offset %lld (expected %d)\n", size.QuadPart, 40); ok(stream.Current == buffer2 + 40, "stream.Current points to the wrong address 0x%p (expected 0x%p)\n", stream.Current, buffer2); ok(stream.Start == buffer2, "stream.Start was changed unexpectedly\n"); ok(stream.End == buffer2 + sizeof(buffer2), "stream.End was changed unexpectedly\n"); ok(stream.ProcessHandle == process, "ProcessHandle changed unexpectedly: 0x%08x (expected 0x%p)\n", stream.ProcessHandle, process); CompareStructsAndSaveForLater(&previous, &stream, "After Seek"); res = IStream_Read(istream, buffer, sizeof(buffer), &bytesRead); ok(res == S_OK, "Read to IStream returned wrong hResult: 0x%08x.\n", res); if (SUCCEEDED(res)) { for (i = 0; i < bytesRead; i++) { ok(buffer[i] == (i + 40), "Buffer[%d] contains a wrong number %d (expected %d).\n", i, buffer[i], i + 40); } } ok(stream.Current == buffer2 + 40 + sizeof(buffer), "stream.Current points to the wrong address 0x%p (expected 0x%p)\n", stream.Current, buffer2); ok(stream.Start == buffer2, "stream.Start was changed unexpectedly\n"); ok(stream.End == buffer2 + sizeof(buffer2), "stream.End was changed unexpectedly\n"); ok(stream.ProcessHandle == process, "ProcessHandle changed unexpectedly: 0x%08x (expected 0x%p)\n", stream.ProcessHandle, process); CompareStructsAndSaveForLater(&previous, &stream, "After Read 2"); res = IStream_Release(istream); ok(res == S_OK, "Release to IStream returned wrong hResult: 0x%08x.\n", res); ok(stream.RefCount == 0, "RefCount has a wrong value: %d (expected %d).\n", stream.RefCount, 0); ok(finalReleaseCallCount == 1, "FinalRelease was called %d times instead of 1.\n", finalReleaseCallCount); }
static HRESULT WINAPI IDirectMusicScriptImpl_IPersistStream_Load (LPPERSISTSTREAM iface, IStream* pStm) { ICOM_THIS_MULTI(IDirectMusicScriptImpl, PersistStreamVtbl, iface); DMUS_PRIVATE_CHUNK Chunk; DWORD StreamSize, StreamCount, ListSize[3], ListCount[3]; LARGE_INTEGER liMove; /* used when skipping chunks */ LPDIRECTMUSICGETLOADER pGetLoader = NULL; LPDIRECTMUSICLOADER pLoader = NULL; FIXME("(%p, %p): Loading not implemented yet\n", This, pStm); IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL); TRACE_(dmfile)(": %s chunk (size = %d)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize); switch (Chunk.fccID) { case FOURCC_RIFF: { IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL); TRACE_(dmfile)(": RIFF chunk of type %s", debugstr_fourcc(Chunk.fccID)); StreamSize = Chunk.dwSize - sizeof(FOURCC); StreamCount = 0; switch (Chunk.fccID) { case DMUS_FOURCC_SCRIPT_FORM: { TRACE_(dmfile)(": script form\n"); do { IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL); StreamCount += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize; TRACE_(dmfile)(": %s chunk (size = %d)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize); switch (Chunk.fccID) { case DMUS_FOURCC_SCRIPT_CHUNK: { TRACE_(dmfile)(": script header chunk\n"); This->pHeader = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, Chunk.dwSize); IStream_Read (pStm, This->pHeader, Chunk.dwSize, NULL); break; } case DMUS_FOURCC_SCRIPTVERSION_CHUNK: { TRACE_(dmfile)(": script version chunk\n"); This->pVersion = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, Chunk.dwSize); IStream_Read (pStm, This->pVersion, Chunk.dwSize, NULL); TRACE_(dmfile)("version: 0x%08x.0x%08x\n", This->pVersion->dwVersionMS, This->pVersion->dwVersionLS); break; } case DMUS_FOURCC_SCRIPTLANGUAGE_CHUNK: { TRACE_(dmfile)(": script language chunk\n"); This->pwzLanguage = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, Chunk.dwSize); IStream_Read (pStm, This->pwzLanguage, Chunk.dwSize, NULL); TRACE_(dmfile)("using language: %s\n", debugstr_w(This->pwzLanguage)); break; } case DMUS_FOURCC_SCRIPTSOURCE_CHUNK: { TRACE_(dmfile)(": script source chunk\n"); This->pwzSource = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, Chunk.dwSize); IStream_Read (pStm, This->pwzSource, Chunk.dwSize, NULL); if (TRACE_ON(dmscript)) { int count = WideCharToMultiByte(CP_ACP, 0, This->pwzSource, -1, NULL, 0, NULL, NULL); LPSTR str = HeapAlloc(GetProcessHeap (), 0, count); WideCharToMultiByte(CP_ACP, 0, This->pwzSource, -1, str, count, NULL, NULL); str[count-1] = '\n'; TRACE("source:\n"); write( 2, str, count ); HeapFree(GetProcessHeap(), 0, str); } break; } case DMUS_FOURCC_GUID_CHUNK: { TRACE_(dmfile)(": GUID chunk\n"); This->pDesc->dwValidData |= DMUS_OBJ_OBJECT; IStream_Read (pStm, &This->pDesc->guidObject, Chunk.dwSize, NULL); break; } case DMUS_FOURCC_VERSION_CHUNK: { TRACE_(dmfile)(": version chunk\n"); This->pDesc->dwValidData |= DMUS_OBJ_VERSION; IStream_Read (pStm, &This->pDesc->vVersion, Chunk.dwSize, NULL); break; } case DMUS_FOURCC_CATEGORY_CHUNK: { TRACE_(dmfile)(": category chunk\n"); This->pDesc->dwValidData |= DMUS_OBJ_CATEGORY; IStream_Read (pStm, This->pDesc->wszCategory, Chunk.dwSize, NULL); break; } case FOURCC_RIFF: { IDirectMusicObject* pObject = NULL; DMUS_OBJECTDESC desc; ZeroMemory (&desc, sizeof(DMUS_OBJECTDESC)); desc.dwSize = sizeof(DMUS_OBJECTDESC); desc.dwValidData = DMUS_OBJ_STREAM | DMUS_OBJ_CLASS; desc.guidClass = CLSID_DirectMusicContainer; desc.pStream = NULL; IStream_Clone (pStm, &desc.pStream); liMove.QuadPart = 0; liMove.QuadPart -= (sizeof(FOURCC) + sizeof(DWORD)); IStream_Seek (desc.pStream, liMove, STREAM_SEEK_CUR, NULL); IStream_QueryInterface (pStm, &IID_IDirectMusicGetLoader, (LPVOID*)&pGetLoader); IDirectMusicGetLoader_GetLoader (pGetLoader, &pLoader); IDirectMusicGetLoader_Release (pGetLoader); if (SUCCEEDED(IDirectMusicLoader_GetObject (pLoader, &desc, &IID_IDirectMusicObject, (LPVOID*) &pObject))) { IDirectMusicObject_Release (pObject); } else { ERR_(dmfile)("Error on GetObject while trying to load Scrip SubContainer\n"); } IDirectMusicLoader_Release (pLoader); pLoader = NULL; /* release loader */ IStream_Release(desc.pStream); desc.pStream = NULL; /* release cloned stream */ liMove.QuadPart = Chunk.dwSize; IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL); TRACE_(dmfile)(": RIFF chunk of type %s", debugstr_fourcc(Chunk.fccID)); ListSize[0] = Chunk.dwSize - sizeof(FOURCC); ListCount[0] = 0; switch (Chunk.fccID) { default: { TRACE_(dmfile)(": unknown (skipping)\n"); liMove.QuadPart = Chunk.dwSize - sizeof(FOURCC); IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); break; } } */ break; } case FOURCC_LIST: { IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL); TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(Chunk.fccID)); ListSize[0] = Chunk.dwSize - sizeof(FOURCC); ListCount[0] = 0; switch (Chunk.fccID) { case DMUS_FOURCC_UNFO_LIST: { TRACE_(dmfile)(": UNFO list\n"); do { IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL); ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize; TRACE_(dmfile)(": %s chunk (size = %d)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize); switch (Chunk.fccID) { /* don't ask me why, but M$ puts INFO elements in UNFO list sometimes (though strings seem to be valid unicode) */ case mmioFOURCC('I','N','A','M'): case DMUS_FOURCC_UNAM_CHUNK: { TRACE_(dmfile)(": name chunk\n"); This->pDesc->dwValidData |= DMUS_OBJ_NAME; IStream_Read (pStm, This->pDesc->wszName, Chunk.dwSize, NULL); break; } case mmioFOURCC('I','A','R','T'): case DMUS_FOURCC_UART_CHUNK: { TRACE_(dmfile)(": artist chunk (ignored)\n"); liMove.QuadPart = Chunk.dwSize; IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); break; } case mmioFOURCC('I','C','O','P'): case DMUS_FOURCC_UCOP_CHUNK: { TRACE_(dmfile)(": copyright chunk (ignored)\n"); liMove.QuadPart = Chunk.dwSize; IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); break; } case mmioFOURCC('I','S','B','J'): case DMUS_FOURCC_USBJ_CHUNK: { TRACE_(dmfile)(": subject chunk (ignored)\n"); liMove.QuadPart = Chunk.dwSize; IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); break; } case mmioFOURCC('I','C','M','T'): case DMUS_FOURCC_UCMT_CHUNK: { TRACE_(dmfile)(": comment chunk (ignored)\n"); liMove.QuadPart = Chunk.dwSize; IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); break; } default: { TRACE_(dmfile)(": unknown sub-chunk (irrelevant & skipping)\n"); liMove.QuadPart = Chunk.dwSize; IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); break; } } TRACE_(dmfile)(": ListCount[0] = %d < ListSize[0] = %d\n", ListCount[0], ListSize[0]); } while (ListCount[0] < ListSize[0]); break; } default: { TRACE_(dmfile)(": unknown (skipping)\n"); liMove.QuadPart = Chunk.dwSize - sizeof(FOURCC); IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); break; } } break; } default: { TRACE_(dmfile)(": unknown chunk (irrelevant & skipping)\n"); liMove.QuadPart = Chunk.dwSize; IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); break; } } TRACE_(dmfile)(": StreamCount[0] = %d < StreamSize[0] = %d\n", StreamCount, StreamSize); } while (StreamCount < StreamSize); break; } default: { TRACE_(dmfile)(": unexpected chunk; loading failed)\n"); liMove.QuadPart = StreamSize; IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */ return E_FAIL; } } TRACE_(dmfile)(": reading finished\n"); break; } default: { TRACE_(dmfile)(": unexpected chunk; loading failed)\n"); liMove.QuadPart = Chunk.dwSize; IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */ return E_FAIL; } } return S_OK; }