DMUSIC: many loading improvements

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi all,

Now we are much better on Unreal2 dmusic :)

Changelog:
 - Most of this patch is based on a private patch from Rok Mandeljc 
 - fix some dband code
 - implement IDirectMusicContainer Stream loader
 - implement IDirectMusicScript Stream loader
 - fix some GetDescriptor/SetDescriptor behavior (only container and script 
now)
 - fix dmloader code
 - indent

Regards,
Raphael
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQE/pQ1Yp7NA3AmQTU4RAltnAJ9n37tmMeZSrHvnPqzIwnyTM2KBkACfZcov
xipbvXITWEJxG/BHDDWI4Fk=
=Y2eD
-----END PGP SIGNATURE-----
? dlls/d3d8/diff
Index: dlls/dmband/band.c
===================================================================
RCS file: /home/wine/wine/dlls/dmband/band.c,v
retrieving revision 1.4
diff -u -r1.4 band.c
--- dlls/dmband/band.c	28 Oct 2003 21:08:55 -0000	1.4
+++ dlls/dmband/band.c	2 Nov 2003 13:46:02 -0000
@@ -293,363 +293,367 @@
 
 HRESULT WINAPI IDirectMusicBandObjectStream_Load (LPPERSISTSTREAM iface, IStream* pStm)
 {
-	ICOM_THIS(IDirectMusicBandObjectStream,iface);
-	FOURCC chunkID;
-	DWORD chunkSize, StreamSize, StreamCount, ListSize[3], ListCount[3];
-	LARGE_INTEGER liMove; /* used when skipping chunks */
-	DMUS_IO_REFERENCE tempReferenceHeader;
-	DMUS_OBJECTDESC ObjDesc;
-	IDirectMusicBandImpl* pBand = This->pParentObject->pBand; /* that's where we load data to */
-	LPDIRECTMUSICLOADER pLoader;
-	LPDIRECTMUSICGETLOADER pGetLoader;
-	
+  ICOM_THIS(IDirectMusicBandObjectStream,iface);
+  FOURCC chunkID;
+  DWORD chunkSize, StreamSize, StreamCount, ListSize[3], ListCount[3];
+  LARGE_INTEGER liMove; /* used when skipping chunks */
+  DMUS_IO_REFERENCE tempReferenceHeader;
+  DMUS_OBJECTDESC ObjDesc;
+  IDirectMusicBandImpl* pBand = This->pParentObject->pBand; /* that's where we load data to */
+  LPDIRECTMUSICLOADER pLoader;
+  LPDIRECTMUSICGETLOADER pGetLoader;
+  
+  IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
+  IStream_Read (pStm, &chunkSize, sizeof(DWORD), NULL);
+  TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (chunkID), chunkSize);
+  switch (chunkID) {	
+  case FOURCC_RIFF: {
+    IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);				
+    TRACE_(dmfile)(": RIFF chunk of type %s", debugstr_fourcc(chunkID));
+    StreamSize = chunkSize - sizeof(FOURCC);
+    StreamCount = 0;
+    switch (chunkID) {
+    case DMUS_FOURCC_BAND_FORM: {
+      TRACE_(dmfile)(": band  form\n");
+      do {
 	IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
-	IStream_Read (pStm, &chunkSize, sizeof(DWORD), NULL);
+	IStream_Read (pStm, &chunkSize, sizeof(FOURCC), NULL);
+	StreamCount += sizeof(FOURCC) + sizeof(DWORD) + chunkSize;
 	TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (chunkID), chunkSize);
-	switch (chunkID) {	
-		case FOURCC_RIFF: {
-			IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);				
-			TRACE_(dmfile)(": RIFF chunk of type %s", debugstr_fourcc(chunkID));
-			StreamSize = chunkSize - sizeof(FOURCC);
-			StreamCount = 0;
-			switch (chunkID) {
-				case DMUS_FOURCC_BAND_FORM: {
-					TRACE_(dmfile)(": band  form\n");
-					do {
-						IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
-						IStream_Read (pStm, &chunkSize, sizeof(FOURCC), NULL);
-						StreamCount += sizeof(FOURCC) + sizeof(DWORD) + chunkSize;
-						TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (chunkID), chunkSize);
-						switch (chunkID) {
-							case DMUS_FOURCC_GUID_CHUNK: {
-								TRACE_(dmfile)(": GUID chunk\n");
-								IStream_Read (pStm, pBand->guidID, chunkSize, NULL);
-								break;
-							}
-							case DMUS_FOURCC_VERSION_CHUNK: {
-								TRACE_(dmfile)(": version chunk\n");
-								IStream_Read (pStm, pBand->vVersion, chunkSize, NULL);
-								break;
-							}
-							case FOURCC_LIST: {
-								IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);				
-								TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(chunkID));
-								ListSize[0] = chunkSize - sizeof(FOURCC);
-								ListCount[0] = 0;
-								switch (chunkID) {
-									case DMUS_FOURCC_UNFO_LIST: {
-										TRACE_(dmfile)(": UNFO list\n");
-										do {
-											IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
-											IStream_Read (pStm, &chunkSize, sizeof(FOURCC), NULL);
-											ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + chunkSize;
-											TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (chunkID), chunkSize);
-											switch (chunkID) {
-												/* 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");
-													pBand->wzName = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
-													IStream_Read (pStm, pBand->wzName, chunkSize, NULL);
-													break;
-												}
-												case mmioFOURCC('I','A','R','T'):
-												case DMUS_FOURCC_UART_CHUNK: {
-													TRACE_(dmfile)(": artist chunk\n");
-													pBand->wzArtist = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
-													IStream_Read (pStm, pBand->wzArtist, chunkSize, NULL);
-													break;
-												}
-												case mmioFOURCC('I','C','O','P'):
-												case DMUS_FOURCC_UCOP_CHUNK: {
-													TRACE_(dmfile)(": copyright chunk\n");
-													pBand->wzCopyright = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
-													IStream_Read (pStm, pBand->wzCopyright, chunkSize, NULL);
-													break;
-												}
-												case mmioFOURCC('I','S','B','J'):
-												case DMUS_FOURCC_USBJ_CHUNK: {
-													TRACE_(dmfile)(": subject chunk\n");
-													pBand->wzSubject = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
-													IStream_Read (pStm, pBand->wzSubject, chunkSize, NULL);
-													break;
-												}
-												case mmioFOURCC('I','C','M','T'):
-												case DMUS_FOURCC_UCMT_CHUNK: {
-													TRACE_(dmfile)(": comment chunk\n");
-													pBand->wzComment = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
-													IStream_Read (pStm, pBand->wzComment, chunkSize, NULL);
-													break;
-												}
-												default: {
-													TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
-													liMove.QuadPart = chunkSize;
-													IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
-													break;						
-												}
-											}
-											TRACE_(dmfile)(": ListCount[0] = %ld < ListSize[0] = %ld\n", ListCount[0], ListSize[0]);
-										} while (ListCount[0] < ListSize[0]);
-										break;
-									}
-									case DMUS_FOURCC_INSTRUMENTS_LIST: {
-										TRACE_(dmfile)(": instruments list\n");
-										do {
-											IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
-											IStream_Read (pStm, &chunkSize, sizeof(FOURCC), NULL);
-											ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + chunkSize;
-											TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (chunkID), chunkSize);
-											switch (chunkID) {
-												case FOURCC_LIST: {
-													IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);				
-													TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(chunkID));
-													ListSize[1] = chunkSize - sizeof(FOURCC);
-													ListCount[1] = 0;
-													switch (chunkID) {
-														case DMUS_FOURCC_INSTRUMENT_LIST: {
-															/* init new instrument list entry */
-															LPDMUS_PRIVATE_INSTRUMENT pNewInstrument = (LPDMUS_PRIVATE_INSTRUMENT) HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(DMUS_PRIVATE_INSTRUMENT));
-															TRACE_(dmfile)(": instrument list\n");
-															do {
-																IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
-																IStream_Read (pStm, &chunkSize, sizeof(FOURCC), NULL);
-																ListCount[1] += sizeof(FOURCC) + sizeof(DWORD) + chunkSize;
-																TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (chunkID), chunkSize);
-																switch (chunkID) {
-																	case DMUS_FOURCC_INSTRUMENT_CHUNK: {
-																		TRACE_(dmfile)(": band instrument header\n");
-																		IStream_Read (pStm, &pNewInstrument->pInstrument, chunkSize, NULL);
-																		break;
-																	}
-																	case FOURCC_LIST: {
-																		IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);				
-																		TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(chunkID));
-																		ListSize[2] = chunkSize - sizeof(FOURCC);
-																		ListCount[2] = 0;
-																		switch (chunkID) {
-																			case DMUS_FOURCC_REF_LIST: {
-																				TRACE_(dmfile)(": reference list\n");
-																				ZeroMemory ((LPVOID)&ObjDesc, sizeof(DMUS_OBJECTDESC));
-																				do {
-																					IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
-																					IStream_Read (pStm, &chunkSize, sizeof(FOURCC), NULL);
-																					ListCount[2] += sizeof(FOURCC) + sizeof(DWORD) + chunkSize;
-																					TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (chunkID), chunkSize);
-																					switch (chunkID) {
-																						case DMUS_FOURCC_REF_CHUNK: {
-																							TRACE_(dmfile)(": reference header chunk\n");
-																							IStream_Read (pStm, &tempReferenceHeader, chunkSize, NULL);
-																							/* copy retrieved data to DMUS_OBJECTDESC */
-																							ObjDesc.dwSize = sizeof(DMUS_OBJECTDESC);
-																							ObjDesc.guidClass = tempReferenceHeader.guidClassID;
-																							ObjDesc.dwValidData = tempReferenceHeader.dwValidData;
-																							break;																	
-																						}
-																						case DMUS_FOURCC_GUID_CHUNK: {
-																							TRACE_(dmfile)(": guid chunk\n");
-																							IStream_Read (pStm, &ObjDesc.guidObject, chunkSize, NULL);
-																							break;
-																						}
-																						case DMUS_FOURCC_DATE_CHUNK: {
-																							TRACE_(dmfile)(": file date chunk\n");
-																							IStream_Read (pStm, &ObjDesc.ftDate, chunkSize, NULL);
-																							break;
-																						}
-																						case DMUS_FOURCC_NAME_CHUNK: {
-																							TRACE_(dmfile)(": name chunk\n");
-																							IStream_Read (pStm, &ObjDesc.wszName, chunkSize, NULL);
-																							break;
-																						}
-																						case DMUS_FOURCC_FILE_CHUNK: {
-																							TRACE_(dmfile)(": file name chunk\n");
-																							IStream_Read (pStm, &ObjDesc.wszFileName, chunkSize, NULL);
-																							break;
-																						}
-																						case DMUS_FOURCC_CATEGORY_CHUNK: {
-																							TRACE_(dmfile)(": category chunk\n");
-																							IStream_Read (pStm, &ObjDesc.wszCategory, chunkSize, NULL);
-																							break;
-																						}
-																						case DMUS_FOURCC_VERSION_CHUNK: {
-																							TRACE_(dmfile)(": version chunk\n");
-																							IStream_Read (pStm, &ObjDesc.vVersion, chunkSize, NULL);
-																							break;
-																						}
-																						default: {
-																							TRACE_(dmfile)(": unknown chunk (skipping)\n");
-																							liMove.QuadPart = chunkSize;
-																							IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip this chunk */
-																							break;
-																						}
-																					}
-																					TRACE_(dmfile)(": ListCount[2] = %ld < ListSize[2] = %ld\n", ListCount[2], ListSize[2]);
-																				} while (ListCount[2] < ListSize[2]);
-																				/* let's see what we have */
-																				TRACE_(dmfile)(": (READ): reference: dwSize = %ld; dwValidData = %ld; guidObject = %s; guidClass = %s; \
-vVersion = %08lx,%08lx; wszName = %s; wszCategory = %s; wszFileName = %s\n", ObjDesc.dwSize, ObjDesc.dwValidData, debugstr_guid(&ObjDesc.guidObject), debugstr_guid(&ObjDesc.guidClass),
-ObjDesc.vVersion.dwVersionMS, ObjDesc.vVersion.dwVersionLS, debugstr_w(ObjDesc.wszName), debugstr_w(ObjDesc.wszCategory), debugstr_w(ObjDesc.wszFileName));
-																				/* now, let's convience loader to load reference */								
-																				if (IStream_QueryInterface (pStm, &IID_IDirectMusicGetLoader, (LPVOID*)&pGetLoader) == S_OK) {
-																					if (IDirectMusicGetLoader_GetLoader (pGetLoader, &pLoader) == S_OK) {
-																						/* load referenced object */
-																						IDirectMusicObject* pObject;
-																						if(FAILED(IDirectMusicLoader_GetObject (pLoader, &ObjDesc, &IID_IDirectMusicObject, (LPVOID*)&pObject)))
-																						/* acquire collection from loaded referenced object */
-																						if(FAILED(IDirectMusicObject_QueryInterface (pObject, &IID_IDirectMusicCollection, (LPVOID*)&pNewInstrument->ppReferenceCollection)))
-																							IDirectMusicLoader_Release (pLoader);
-																					}
-																					IDirectMusicGetLoader_Release (pGetLoader);											
-																				} else {
-																					ERR("Could not get IDirectMusicGetLoader... reference will not be loaded :(\n");
-																					/* E_FAIL */
-																				}
-																			break;
-																		}
-																		default: {
-																			TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
-																			return E_FAIL;
-																		}
-																	}
-																	break;
-																}
-																	default: {
-																		TRACE_(dmfile)(": unknown chunk (skipping)\n");
-																		liMove.QuadPart = chunkSize;
-																		IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip this chunk */
-																		break;					
-																	}	
-																}
-																TRACE_(dmfile)(": ListCount[1] = %ld < ListSize[1] = %ld\n", ListCount[1], ListSize[1]);
-															} while (ListCount[1] < ListSize[1]);
-															/* hmm... in dxdiag segment's band there aren't any references, but loader still desperatly
-														       loads default collection... does that mean that if there is no reference, use default?
-														    */
-															if (!pNewInstrument->ppReferenceCollection) {
-																TRACE_(dmfile)(": (READ): loading default collection (as no specific reference was made)\n");
-																ZeroMemory ((LPVOID)&ObjDesc, sizeof(DMUS_OBJECTDESC));
-																ObjDesc.dwSize = sizeof(DMUS_OBJECTDESC);
-        														ObjDesc.dwValidData = DMUS_OBJ_CLASS | DMUS_OBJ_OBJECT;
-																ObjDesc.guidObject = GUID_DefaultGMCollection;
-																ObjDesc.guidClass = CLSID_DirectMusicCollection;
-																if (SUCCEEDED(IStream_QueryInterface (pStm, &IID_IDirectMusicGetLoader, (LPVOID*)&pGetLoader))) {
-																	if (SUCCEEDED(IDirectMusicGetLoader_GetLoader (pGetLoader, &pLoader))) {
-																		IDirectMusicObject* pObject;
-																		if (SUCCEEDED(IDirectMusicLoader_GetObject (pLoader, &ObjDesc, &IID_IDirectMusicObject, (LPVOID*)&pObject))) {
-																			IDirectMusicObject_QueryInterface (pObject, &IID_IDirectMusicCollection, (LPVOID*)&pNewInstrument->ppReferenceCollection);
-																			IDirectMusicLoader_Release (pLoader);
-																		}
-																	}
-																	IDirectMusicGetLoader_Release (pGetLoader);											
-																} else {
-																	ERR("Could not get IDirectMusicGetLoader... reference will not be loaded :(\n");
-																	/* E_FAIL */
-																}
-															}
-															list_add_tail (&This->pParentObject->pBand->Instruments, &pNewInstrument->entry);
-															break;
-														}
-														default: {
-															TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
-															return E_FAIL;
-														}
-													}
-													break;
-												}
-												default: {
-													TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
-													liMove.QuadPart = chunkSize;
-													IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
-													break;						
-												}
-											}
-											TRACE_(dmfile)(": ListCount[0] = %ld < ListSize[0] = %ld\n", ListCount[0], ListSize[0]);
-										} while (ListCount[0] < ListSize[0]);
-										break;
-									}
-									default: {
-										TRACE_(dmfile)(": unknown (skipping)\n");
-										liMove.QuadPart = chunkSize - sizeof(FOURCC);
-										IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
-										break;						
-									}
-								}
-								break;
-							}	
-							default: {
-								TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
-								liMove.QuadPart = chunkSize;
-								IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
-								break;						
-							}
-						}
-						TRACE_(dmfile)(": StreamCount[0] = %ld < StreamSize[0] = %ld\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;
-				}
+	switch (chunkID) {
+	case DMUS_FOURCC_GUID_CHUNK: {
+	  TRACE_(dmfile)(": GUID chunk\n");
+	  pBand->guidID = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
+	  IStream_Read (pStm, pBand->guidID, chunkSize, NULL);
+	  break;
+	}
+	case DMUS_FOURCC_VERSION_CHUNK: {
+	  TRACE_(dmfile)(": version chunk\n");
+	  pBand->vVersion = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
+	  IStream_Read (pStm, pBand->vVersion, chunkSize, NULL);
+	  break;
+	}
+	case FOURCC_LIST: {
+	  IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);				
+	  TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(chunkID));
+	  ListSize[0] = chunkSize - sizeof(FOURCC);
+	  ListCount[0] = 0;
+	  switch (chunkID) {
+	  case DMUS_FOURCC_UNFO_LIST: {
+	    TRACE_(dmfile)(": UNFO list\n");
+	    do {
+	      IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
+	      IStream_Read (pStm, &chunkSize, sizeof(FOURCC), NULL);
+	      ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + chunkSize;
+	      TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (chunkID), chunkSize);
+	      switch (chunkID) {
+		/* 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");
+		pBand->wzName = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
+		IStream_Read (pStm, pBand->wzName, chunkSize, NULL);
+		break;
+	      }
+	      case mmioFOURCC('I','A','R','T'):
+	      case DMUS_FOURCC_UART_CHUNK: {
+		TRACE_(dmfile)(": artist chunk\n");
+		pBand->wzArtist = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
+		IStream_Read (pStm, pBand->wzArtist, chunkSize, NULL);
+		break;
+	      }
+	      case mmioFOURCC('I','C','O','P'):
+	      case DMUS_FOURCC_UCOP_CHUNK: {
+		TRACE_(dmfile)(": copyright chunk\n");
+		pBand->wzCopyright = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
+		IStream_Read (pStm, pBand->wzCopyright, chunkSize, NULL);
+		break;
+	      }
+	      case mmioFOURCC('I','S','B','J'):
+	      case DMUS_FOURCC_USBJ_CHUNK: {
+		TRACE_(dmfile)(": subject chunk\n");
+		pBand->wzSubject = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
+		IStream_Read (pStm, pBand->wzSubject, chunkSize, NULL);
+		break;
+	      }
+	      case mmioFOURCC('I','C','M','T'):
+	      case DMUS_FOURCC_UCMT_CHUNK: {
+		TRACE_(dmfile)(": comment chunk\n");
+		pBand->wzComment = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
+		IStream_Read (pStm, pBand->wzComment, chunkSize, NULL);
+		break;
+	      }
+	      default: {
+		TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
+		liMove.QuadPart = chunkSize;
+		IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
+		break;						
+	      }
+	      }
+	      TRACE_(dmfile)(": ListCount[0] = %ld < ListSize[0] = %ld\n", ListCount[0], ListSize[0]);
+	    } while (ListCount[0] < ListSize[0]);
+	    break;
+	  }
+	  case DMUS_FOURCC_INSTRUMENTS_LIST: {
+	    TRACE_(dmfile)(": instruments list\n");
+	    do {
+	      IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
+	      IStream_Read (pStm, &chunkSize, sizeof(FOURCC), NULL);
+	      ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + chunkSize;
+	      TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (chunkID), chunkSize);
+	      switch (chunkID) {
+	      case FOURCC_LIST: {
+		IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);				
+		TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(chunkID));
+		ListSize[1] = chunkSize - sizeof(FOURCC);
+		ListCount[1] = 0;
+		switch (chunkID) {
+		case DMUS_FOURCC_INSTRUMENT_LIST: {
+		  /* init new instrument list entry */
+		  LPDMUS_PRIVATE_INSTRUMENT pNewInstrument = (LPDMUS_PRIVATE_INSTRUMENT) HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(DMUS_PRIVATE_INSTRUMENT));
+		  TRACE_(dmfile)(": instrument list\n");
+		  do {
+		    IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
+		    IStream_Read (pStm, &chunkSize, sizeof(FOURCC), NULL);
+		    ListCount[1] += sizeof(FOURCC) + sizeof(DWORD) + chunkSize;
+		    TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (chunkID), chunkSize);
+		    switch (chunkID) {
+		    case DMUS_FOURCC_INSTRUMENT_CHUNK: {
+		      TRACE_(dmfile)(": band instrument header\n");
+		      IStream_Read (pStm, &pNewInstrument->pInstrument, chunkSize, NULL);
+		      break;
+		    }
+		    case FOURCC_LIST: {
+		      IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);				
+		      TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(chunkID));
+		      ListSize[2] = chunkSize - sizeof(FOURCC);
+		      ListCount[2] = 0;
+		      switch (chunkID) {
+		      case DMUS_FOURCC_REF_LIST: {
+			TRACE_(dmfile)(": reference list\n");
+			ZeroMemory ((LPVOID)&ObjDesc, sizeof(DMUS_OBJECTDESC));
+			do {
+			  IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
+			  IStream_Read (pStm, &chunkSize, sizeof(FOURCC), NULL);
+			  ListCount[2] += sizeof(FOURCC) + sizeof(DWORD) + chunkSize;
+			  TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (chunkID), chunkSize);
+			  switch (chunkID) {
+			  case DMUS_FOURCC_REF_CHUNK: {
+			    TRACE_(dmfile)(": reference header chunk\n");
+			    IStream_Read (pStm, &tempReferenceHeader, chunkSize, NULL);
+			    /* copy retrieved data to DMUS_OBJECTDESC */
+			    ObjDesc.dwSize = sizeof(DMUS_OBJECTDESC);
+			    ObjDesc.guidClass = tempReferenceHeader.guidClassID;
+			    ObjDesc.dwValidData = tempReferenceHeader.dwValidData;
+			    break;																	
+			  }
+			  case DMUS_FOURCC_GUID_CHUNK: {
+			    TRACE_(dmfile)(": guid chunk\n");
+			    IStream_Read (pStm, &ObjDesc.guidObject, chunkSize, NULL);
+			    break;
+			  }
+			  case DMUS_FOURCC_DATE_CHUNK: {
+			    TRACE_(dmfile)(": file date chunk\n");
+			    IStream_Read (pStm, &ObjDesc.ftDate, chunkSize, NULL);
+			    break;
+			  }
+			  case DMUS_FOURCC_NAME_CHUNK: {
+			    TRACE_(dmfile)(": name chunk\n");
+			    IStream_Read (pStm, &ObjDesc.wszName, chunkSize, NULL);
+			    break;
+			  }
+			  case DMUS_FOURCC_FILE_CHUNK: {
+			    TRACE_(dmfile)(": file name chunk\n");
+			    IStream_Read (pStm, &ObjDesc.wszFileName, chunkSize, NULL);
+			    break;
+			  }
+			  case DMUS_FOURCC_CATEGORY_CHUNK: {
+			    TRACE_(dmfile)(": category chunk\n");
+			    IStream_Read (pStm, &ObjDesc.wszCategory, chunkSize, NULL);
+			    break;
+			  }
+			  case DMUS_FOURCC_VERSION_CHUNK: {
+			    TRACE_(dmfile)(": version chunk\n");
+			    IStream_Read (pStm, &ObjDesc.vVersion, chunkSize, NULL);
+			    break;
+			  }
+			  default: {
+			    TRACE_(dmfile)(": unknown chunk (skipping)\n");
+			    liMove.QuadPart = chunkSize;
+			    IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip this chunk */
+			    break;
+			  }
+			  }
+			  TRACE_(dmfile)(": ListCount[2] = %ld < ListSize[2] = %ld\n", ListCount[2], ListSize[2]);
+			} while (ListCount[2] < ListSize[2]);
+			/* let's see what we have */
+			TRACE_(dmfile)(": (READ): reference: dwSize = %ld; dwValidData = %ld; guidObject = %s; guidClass = %s; \
+vVersion = %08lx,%08lx; wszName = %s; wszCategory = %s; wszFileName = %s\n", 
+				       ObjDesc.dwSize, ObjDesc.dwValidData, debugstr_guid(&ObjDesc.guidObject), debugstr_guid(&ObjDesc.guidClass),
+				       ObjDesc.vVersion.dwVersionMS, ObjDesc.vVersion.dwVersionLS, debugstr_w(ObjDesc.wszName), debugstr_w(ObjDesc.wszCategory), debugstr_w(ObjDesc.wszFileName));
+			/* now, let's convience loader to load reference */								
+			if (IStream_QueryInterface (pStm, &IID_IDirectMusicGetLoader, (LPVOID*)&pGetLoader) == S_OK) {
+			  if (IDirectMusicGetLoader_GetLoader (pGetLoader, &pLoader) == S_OK) {
+			    /* load referenced object */
+			    IDirectMusicObject* pObject;
+			    if (FAILED(IDirectMusicLoader_GetObject (pLoader, &ObjDesc, &IID_IDirectMusicObject, (LPVOID*)&pObject)))
+			      /* acquire collection from loaded referenced object */
+			      if (FAILED(IDirectMusicObject_QueryInterface (pObject, &IID_IDirectMusicCollection, (LPVOID*)&pNewInstrument->ppReferenceCollection)))
+				IDirectMusicLoader_Release (pLoader);
+			  }
+			  IDirectMusicGetLoader_Release (pGetLoader);											
+			} else {
+			  ERR("Could not get IDirectMusicGetLoader... reference will not be loaded :(\n");
+			  /* E_FAIL */
 			}
-			TRACE_(dmfile)(": reading finished\n");
 			break;
-		}
-		default: {
+		      }
+		      default: {
 			TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
-			liMove.QuadPart = chunkSize;
-			IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
 			return E_FAIL;
+		      }
+		      }
+		      break;
+		    }
+		    default: {
+		      TRACE_(dmfile)(": unknown chunk (skipping)\n");
+		      liMove.QuadPart = chunkSize;
+		      IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip this chunk */
+		      break;					
+		    }	
+		    }
+		    TRACE_(dmfile)(": ListCount[1] = %ld < ListSize[1] = %ld\n", ListCount[1], ListSize[1]);
+		  } while (ListCount[1] < ListSize[1]);
+		  /* hmm... in dxdiag segment's band there aren't any references, but loader still desperatly
+		     loads default collection... does that mean that if there is no reference, use default?
+		  */
+		  if (!pNewInstrument->ppReferenceCollection) {
+		    TRACE_(dmfile)(": (READ): loading default collection (as no specific reference was made)\n");
+		    ZeroMemory ((LPVOID)&ObjDesc, sizeof(DMUS_OBJECTDESC));
+		    ObjDesc.dwSize = sizeof(DMUS_OBJECTDESC);
+		    ObjDesc.dwValidData = DMUS_OBJ_CLASS | DMUS_OBJ_OBJECT;
+		    ObjDesc.guidObject = GUID_DefaultGMCollection;
+		    ObjDesc.guidClass = CLSID_DirectMusicCollection;
+		    if (SUCCEEDED(IStream_QueryInterface (pStm, &IID_IDirectMusicGetLoader, (LPVOID*)&pGetLoader))) {
+		      if (SUCCEEDED(IDirectMusicGetLoader_GetLoader (pGetLoader, &pLoader))) {
+			IDirectMusicObject* pObject;
+			if (SUCCEEDED(IDirectMusicLoader_GetObject (pLoader, &ObjDesc, &IID_IDirectMusicObject, (LPVOID*)&pObject))) {
+			  IDirectMusicObject_QueryInterface (pObject, &IID_IDirectMusicCollection, (LPVOID*)&pNewInstrument->ppReferenceCollection);
+			  IDirectMusicLoader_Release (pLoader);
+			}
+		      }
+		      IDirectMusicGetLoader_Release (pGetLoader);											
+		    } else {
+		      ERR("Could not get IDirectMusicGetLoader... reference will not be loaded :(\n");
+		      /* E_FAIL */
+		    }
+		  }
+		  list_add_tail (&This->pParentObject->pBand->Instruments, &pNewInstrument->entry);
+		  break;
 		}
-	}
-	
-	/* DEBUG: dumps whole band object tree: */
-	if (TRACE_ON(dmband)) {
-		int r = 0;
-		DMUS_PRIVATE_INSTRUMENT *tmpEntry;
-		struct list *listEntry;
-
-		TRACE("*** IDirectMusicBand (%p) ***\n", pBand);
-		if (pBand->guidID)
-			TRACE(" - GUID = %s\n", debugstr_guid(pBand->guidID));
-		if (pBand->vVersion)
-			TRACE(" - Version = %i,%i,%i,%i\n", (pBand->vVersion->dwVersionMS >> 8) && 0x0000FFFF, pBand->vVersion->dwVersionMS && 0x0000FFFF, \
-				(pBand->vVersion->dwVersionLS >> 8) && 0x0000FFFF, pBand->vVersion->dwVersionLS && 0x0000FFFF);
-		if (pBand->wzName)
-			TRACE(" - Name = %s\n", debugstr_w(pBand->wzName));
-		if (pBand->wzArtist)		
-			TRACE(" - Artist = %s\n", debugstr_w(pBand->wzArtist));
-		if (pBand->wzCopyright)
-			TRACE(" - Copyright = %s\n", debugstr_w(pBand->wzCopyright));
-		if (pBand->wzSubject)
-			TRACE(" - Subject = %s\n", debugstr_w(pBand->wzSubject));
-		if (pBand->wzComment)
-			TRACE(" - Comment = %s\n", debugstr_w(pBand->wzComment));
-		
-		TRACE(" - Instruments:\n");
-		
-		LIST_FOR_EACH (listEntry, &This->pParentObject->pBand->Instruments) {
-			tmpEntry = LIST_ENTRY( listEntry, DMUS_PRIVATE_INSTRUMENT, entry );
-			TRACE("    - Instrument[%i]:\n", r);
-			TRACE("       - Instrument header:\n");
-			TRACE("          - dwPatch = %ld\n", tmpEntry->pInstrument.dwPatch);
-			TRACE("          - dwAssignPatch = %ld\n", tmpEntry->pInstrument.dwAssignPatch);
-			TRACE("          - dwNoteRanges[4] = %ln\n", tmpEntry->pInstrument.dwNoteRanges);
-			TRACE("          - dwPChannel = %ld\n", tmpEntry->pInstrument.dwPChannel);
-			TRACE("          - dwFlags = %ld\n", tmpEntry->pInstrument.dwFlags);
-			TRACE("          - bPan = %i\n", tmpEntry->pInstrument.bPan);
-			TRACE("          - bVolume = %i\n", tmpEntry->pInstrument.bVolume);
-			TRACE("          - nTranspose = %i\n", tmpEntry->pInstrument.nTranspose);
-			TRACE("          - dwChannelPriority = %ld\n", tmpEntry->pInstrument.dwChannelPriority);
-			TRACE("          - nPitchBendRange = %i\n", tmpEntry->pInstrument.nPitchBendRange);
-			TRACE("       - Reference collection: %p\n", tmpEntry->ppReferenceCollection);
-			r++;
+		default: {
+		  TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
+		  return E_FAIL;
 		}
+		}
+		break;
+	      }
+	      default: {
+		TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
+		liMove.QuadPart = chunkSize;
+		IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
+		break;						
+	      }
+	      }
+	      TRACE_(dmfile)(": ListCount[0] = %ld < ListSize[0] = %ld\n", ListCount[0], ListSize[0]);
+	    } while (ListCount[0] < ListSize[0]);
+	    break;
+	  }
+	  default: {
+	    TRACE_(dmfile)(": unknown (skipping)\n");
+	    liMove.QuadPart = chunkSize - sizeof(FOURCC);
+	    IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
+	    break;						
+	  }
+	  }
+	  break;
+	}	
+	default: {
+	  TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
+	  liMove.QuadPart = chunkSize;
+	  IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
+	  break;						
+	}
 	}
-
-	return S_OK;
+	TRACE_(dmfile)(": StreamCount[0] = %ld < StreamSize[0] = %ld\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 = chunkSize;
+    IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
+    return E_FAIL;
+  }
+  }
+  
+  /* DEBUG: dumps whole band object tree: */
+  if (TRACE_ON(dmband)) {
+    int r = 0;
+    DMUS_PRIVATE_INSTRUMENT *tmpEntry;
+    struct list *listEntry;
+    
+    TRACE("*** IDirectMusicBand (%p) ***\n", pBand);
+    if (pBand->guidID)
+      TRACE(" - GUID = %s\n", debugstr_guid(pBand->guidID));
+    if (pBand->vVersion)
+      TRACE(" - Version = %i,%i,%i,%i\n", 
+	    (pBand->vVersion->dwVersionMS >> 8) && 0x0000FFFF, pBand->vVersion->dwVersionMS && 0x0000FFFF, \
+	    (pBand->vVersion->dwVersionLS >> 8) && 0x0000FFFF, pBand->vVersion->dwVersionLS && 0x0000FFFF);
+    if (pBand->wzName)
+      TRACE(" - Name = %s\n", debugstr_w(pBand->wzName));
+    if (pBand->wzArtist)		
+      TRACE(" - Artist = %s\n", debugstr_w(pBand->wzArtist));
+    if (pBand->wzCopyright)
+      TRACE(" - Copyright = %s\n", debugstr_w(pBand->wzCopyright));
+    if (pBand->wzSubject)
+      TRACE(" - Subject = %s\n", debugstr_w(pBand->wzSubject));
+    if (pBand->wzComment)
+      TRACE(" - Comment = %s\n", debugstr_w(pBand->wzComment));
+    
+    TRACE(" - Instruments:\n");
+    
+    LIST_FOR_EACH (listEntry, &pBand->Instruments) {
+      tmpEntry = LIST_ENTRY( listEntry, DMUS_PRIVATE_INSTRUMENT, entry );
+      TRACE("    - Instrument[%i]:\n", r);
+      TRACE("       - Instrument header:\n");
+      TRACE("          - dwPatch = %ld\n", tmpEntry->pInstrument.dwPatch);
+      TRACE("          - dwAssignPatch = %ld\n", tmpEntry->pInstrument.dwAssignPatch);
+      TRACE("          - dwNoteRanges[4] = %ln\n", tmpEntry->pInstrument.dwNoteRanges);
+      TRACE("          - dwPChannel = %ld\n", tmpEntry->pInstrument.dwPChannel);
+      TRACE("          - dwFlags = %ld\n", tmpEntry->pInstrument.dwFlags);
+      TRACE("          - bPan = %i\n", tmpEntry->pInstrument.bPan);
+      TRACE("          - bVolume = %i\n", tmpEntry->pInstrument.bVolume);
+      TRACE("          - nTranspose = %i\n", tmpEntry->pInstrument.nTranspose);
+      TRACE("          - dwChannelPriority = %ld\n", tmpEntry->pInstrument.dwChannelPriority);
+      TRACE("          - nPitchBendRange = %i\n", tmpEntry->pInstrument.nPitchBendRange);
+      TRACE("       - Reference collection: %p\n", tmpEntry->ppReferenceCollection);
+      r++;
+    }
+  }
+  
+  return S_OK;
 }
 
 HRESULT WINAPI IDirectMusicBandObjectStream_Save (LPPERSISTSTREAM iface, IStream* pStm, BOOL fClearDirty)
Index: dlls/dmband/bandtrack.c
===================================================================
RCS file: /home/wine/wine/dlls/dmband/bandtrack.c,v
retrieving revision 1.3
diff -u -r1.3 bandtrack.c
--- dlls/dmband/bandtrack.c	28 Oct 2003 21:08:55 -0000	1.3
+++ dlls/dmband/bandtrack.c	2 Nov 2003 13:46:03 -0000
@@ -423,16 +423,19 @@
 						switch (chunkID) {
 							case DMUS_FOURCC_BANDTRACK_CHUNK: {
 								TRACE_(dmfile)(": band track header chunk\n");
+								pTrack->btkHeader = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
 								IStream_Read (pStm, pTrack->btkHeader, chunkSize, NULL);
 								break;
 							}
 							case DMUS_FOURCC_GUID_CHUNK: {
 								TRACE_(dmfile)(": GUID chunk\n");
+								pTrack->guidID = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
 								IStream_Read (pStm, pTrack->guidID, chunkSize, NULL);
 								break;
 							}
 							case DMUS_FOURCC_VERSION_CHUNK: {
 								TRACE_(dmfile)(": version chunk\n");
+								pTrack->vVersion = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
 								IStream_Read (pStm, pTrack->vVersion, chunkSize, NULL);
 								break;
 							}
Index: dlls/dmloader/container.c
===================================================================
RCS file: /home/wine/wine/dlls/dmloader/container.c,v
retrieving revision 1.4
diff -u -r1.4 container.c
--- dlls/dmloader/container.c	27 Oct 2003 22:08:37 -0000	1.4
+++ dlls/dmloader/container.c	2 Nov 2003 13:46:05 -0000
@@ -24,10 +24,12 @@
 #include "winuser.h"
 #include "wingdi.h"
 #include "wine/debug.h"
+#include "wine/unicode.h"
 
 #include "dmloader_private.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(dmloader);
+WINE_DECLARE_DEBUG_CHANNEL(dmfile);
 
 /* IDirectMusicContainer IUnknown parts follow: */
 HRESULT WINAPI IDirectMusicContainerImpl_QueryInterface (LPDIRECTMUSICCONTAINER iface, REFIID riid, LPVOID *ppobj)
@@ -67,9 +69,24 @@
 {
 	ICOM_THIS(IDirectMusicContainerImpl,iface);
 
-	FIXME("(%p, %s, %ld, %p, %p): stub\n", This, debugstr_guid(rguidClass), dwIndex, pDesc, pwszAlias);
+	TRACE("(%p, %s, %ld, %p, %p)\n", This, debugstr_guid(rguidClass), dwIndex, pDesc, pwszAlias);
 
-	return S_OK;
+	int r = 0;
+	DMUS_PRIVATE_OBJECT *tmpEntry;
+	struct list *listEntry;
+	DMUS_OBJECTDESC ObjDesc;
+	
+	LIST_FOR_EACH (listEntry, &This->Objects) {
+		tmpEntry = LIST_ENTRY( listEntry, DMUS_PRIVATE_OBJECT, entry );
+		if (dwIndex == r) {
+			strcpyW (pwszAlias, tmpEntry->wzAlias);
+			IDirectMusicObject_GetDescriptor (tmpEntry->ppObject, &ObjDesc);	
+			*pDesc = ObjDesc;
+			return S_OK;
+		}
+		r++;
+	}
+	return S_FALSE;	
 }
 
 ICOM_VTABLE(IDirectMusicContainer) DirectMusicContainer_Vtbl =
@@ -94,6 +111,7 @@
 		}
 		dmcon->lpVtbl = &DirectMusicContainer_Vtbl;
 		dmcon->ref = 1;
+		list_init (&dmcon->Objects);
 		*ppDMCon = (LPDIRECTMUSICCONTAINER) dmcon;
 		return S_OK;
 	}
@@ -152,7 +170,7 @@
 	ICOM_THIS(IDirectMusicContainerObject,iface);
 
 	TRACE("(%p, %p)\n", This, pDesc);
-	pDesc = This->pDesc;
+	memcpy(pDesc, &This->desc, sizeof(DMUS_OBJECTDESC));
 	
 	return S_OK;
 }
@@ -162,7 +180,29 @@
 	ICOM_THIS(IDirectMusicContainerObject,iface);
 
 	TRACE("(%p, %p)\n", This, pDesc);
-	This->pDesc = pDesc;
+
+	This->desc.dwValidData = pDesc->dwValidData;
+	/** follow memcpy is temporary while all fields aren't supported */
+	memcpy(&This->desc, pDesc, sizeof(DMUS_OBJECTDESC));
+
+	if (This->pContainer->guidID) {
+	  memcpy (&This->desc.guidObject, This->pContainer->guidID, sizeof (This->desc.guidObject));
+	  This->desc.dwValidData |= DMUS_OBJ_OBJECT;
+	} else {
+	  if (pDesc->dwValidData & DMUS_OBJ_OBJECT)
+	    memcpy (&This->desc.guidObject, &pDesc->guidObject, sizeof (This->desc.guidObject));
+	}
+	if (pDesc->dwValidData & DMUS_OBJ_FILENAME)
+	  strncpyW (This->desc.wszFileName, pDesc->wszFileName, MAX_PATH);
+	if (This->pContainer->wzName) {
+	  strcpyW (This->desc.wszName, This->pContainer->wzName);
+	  This->desc.dwValidData |= DMUS_OBJ_NAME;
+	} else {
+	  if (pDesc->dwValidData & DMUS_OBJ_NAME)
+	    strcpyW (This->desc.wszName, pDesc->wszName);
+	}
+	if (pDesc->dwValidData & DMUS_OBJ_CATEGORY)
+	  strcpyW (This->desc.wszCategory, pDesc->wszCategory);
 
 	return S_OK;
 }
@@ -257,7 +297,8 @@
 /* IDirectMusicContainerObjectStream IPersist part: */
 HRESULT WINAPI IDirectMusicContainerObjectStream_GetClassID (LPPERSISTSTREAM iface, CLSID* pClassID)
 {
-	return E_NOTIMPL;
+        *pClassID = CLSID_DirectMusicContainer;
+	return S_OK;
 }
 
 /* IDirectMusicContainerObjectStream IPersistStream part: */
@@ -268,8 +309,384 @@
 
 HRESULT WINAPI IDirectMusicContainerObjectStream_Load (LPPERSISTSTREAM iface, IStream* pStm)
 {
-	FIXME(": Loading not implemented yet\n");
-	return S_OK;
+  ICOM_THIS(IDirectMusicContainerObjectStream,iface);
+  FOURCC chunkID;
+  DWORD chunkSize, StreamSize, StreamCount, ListSize[3], ListCount[3];
+  LARGE_INTEGER liMove; /* used when skipping chunks */
+  DMUS_IO_REFERENCE tempReferenceHeader;
+  IDirectMusicContainerImpl* pContainer = This->pParentObject->pContainer; /* that's where we load data to */
+  LPDIRECTMUSICLOADER pLoader;
+  LPDIRECTMUSICGETLOADER pGetLoader;
+  
+  IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
+  IStream_Read (pStm, &chunkSize, sizeof(DWORD), NULL);
+  TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (chunkID), chunkSize);
+  switch (chunkID) {	
+  case FOURCC_RIFF: {
+    IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);				
+    TRACE_(dmfile)(": RIFF chunk of type %s", debugstr_fourcc(chunkID));
+    StreamSize = chunkSize - sizeof(FOURCC);
+    StreamCount = 0;
+    switch (chunkID) {
+    case DMUS_FOURCC_CONTAINER_FORM: {
+      TRACE_(dmfile)(": container form\n");
+      do {
+	IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
+	IStream_Read (pStm, &chunkSize, sizeof(FOURCC), NULL);
+	StreamCount += sizeof(FOURCC) + sizeof(DWORD) + chunkSize;
+	TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (chunkID), chunkSize);
+	switch (chunkID) {
+	case DMUS_FOURCC_CONTAINER_CHUNK: {
+	  TRACE_(dmfile)(": container header chunk\n");
+	  pContainer->pHeader = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
+	  IStream_Read (pStm, pContainer->pHeader, chunkSize, NULL);
+	  break;
+	}
+	case DMUS_FOURCC_GUID_CHUNK: {
+	  TRACE_(dmfile)(": GUID chunk\n");
+	  pContainer->guidID = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
+	  IStream_Read (pStm, pContainer->guidID, chunkSize, NULL);
+	  break;
+	}
+	case DMUS_FOURCC_VERSION_CHUNK: {
+	  TRACE_(dmfile)(": version chunk\n");
+	  pContainer->vVersion = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
+	  IStream_Read (pStm, pContainer->vVersion, chunkSize, NULL);
+	  break;
+	}
+	case FOURCC_LIST: {
+	  IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);				
+	  TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(chunkID));
+	  ListSize[0] = chunkSize - sizeof(FOURCC);
+	  ListCount[0] = 0;
+	  switch (chunkID) {
+	  case DMUS_FOURCC_UNFO_LIST: {
+	    TRACE_(dmfile)(": UNFO list\n");
+	    do {
+	      IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
+	      IStream_Read (pStm, &chunkSize, sizeof(FOURCC), NULL);
+	      ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + chunkSize;
+	      TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (chunkID), chunkSize);
+	      switch (chunkID) {
+		/* 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");
+		pContainer->wzName = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
+		IStream_Read (pStm, pContainer->wzName, chunkSize, NULL);
+		break;
+	      }
+	      case mmioFOURCC('I','A','R','T'):
+	      case DMUS_FOURCC_UART_CHUNK: {
+		TRACE_(dmfile)(": artist chunk\n");
+		pContainer->wzArtist = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
+		IStream_Read (pStm, pContainer->wzArtist, chunkSize, NULL);
+		break;
+	      }
+	      case mmioFOURCC('I','C','O','P'):
+	      case DMUS_FOURCC_UCOP_CHUNK: {
+		TRACE_(dmfile)(": copyright chunk\n");
+		pContainer->wzCopyright = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
+		IStream_Read (pStm, pContainer->wzCopyright, chunkSize, NULL);
+		break;
+	      }
+	      case mmioFOURCC('I','S','B','J'):
+	      case DMUS_FOURCC_USBJ_CHUNK: {
+		TRACE_(dmfile)(": subject chunk\n");
+		pContainer->wzSubject = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
+		IStream_Read (pStm, pContainer->wzSubject, chunkSize, NULL);
+		break;
+	      }
+	      case mmioFOURCC('I','C','M','T'):
+	      case DMUS_FOURCC_UCMT_CHUNK: {
+		TRACE_(dmfile)(": comment chunk\n");
+		pContainer->wzComment = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
+		IStream_Read (pStm, pContainer->wzComment, chunkSize, NULL);
+		break;
+	      }
+	      default: {
+		TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
+		liMove.QuadPart = chunkSize;
+		IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
+		break;						
+	      }
+	      }
+	      TRACE_(dmfile)(": ListCount[0] = %ld < ListSize[0] = %ld\n", ListCount[0], ListSize[0]);
+	    } while (ListCount[0] < ListSize[0]);
+	    break;
+	  }
+	  case DMUS_FOURCC_CONTAINED_OBJECTS_LIST: {
+	    TRACE_(dmfile)(": objects list\n");
+	    do {
+	      IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
+	      IStream_Read (pStm, &chunkSize, sizeof(FOURCC), NULL);
+	      ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + chunkSize;
+	      TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (chunkID), chunkSize);
+	      switch (chunkID) {
+	      case FOURCC_LIST: {
+		IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);				
+		TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(chunkID));
+		ListSize[1] = chunkSize - sizeof(FOURCC);
+		ListCount[1] = 0;
+		switch (chunkID) {
+		case DMUS_FOURCC_CONTAINED_OBJECT_LIST: {
+		  /* init new instrument list entry */
+		  LPDMUS_PRIVATE_OBJECT pNewObject = (LPDMUS_PRIVATE_OBJECT) HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(DMUS_PRIVATE_OBJECT));
+		  TRACE_(dmfile)(": ojbect list\n");
+		  do {
+		    IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
+		    IStream_Read (pStm, &chunkSize, sizeof(DWORD), NULL);
+		    ListCount[1] += sizeof(FOURCC) + sizeof(DWORD) + chunkSize;
+		    TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (chunkID), chunkSize);
+		    switch (chunkID) {
+		    case DMUS_FOURCC_CONTAINED_ALIAS_CHUNK: {
+		      TRACE_(dmfile)(": contained object alias chunk\n");
+		      pNewObject->wzAlias = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
+		      IStream_Read (pStm, pNewObject->wzAlias, chunkSize, NULL);
+		      break;
+		    }																	
+		    case DMUS_FOURCC_CONTAINED_OBJECT_CHUNK: {
+		      TRACE_(dmfile)(": contained object header\n");
+		      IStream_Read (pStm, &pNewObject->pHeader, chunkSize, NULL);
+		      break;
+		    }
+		      /* now object can be either in form of reference or embedded RIFF */
+		    case FOURCC_LIST: {
+		      IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);				
+		      TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(chunkID));
+		      ListSize[2] = chunkSize - sizeof(FOURCC);
+		      ListCount[2] = 0;
+		      switch (chunkID) {
+		      case DMUS_FOURCC_REF_LIST: {
+			TRACE_(dmfile)(": reference list\n");
+			DMUS_OBJECTDESC ObjDesc;
+			ZeroMemory ((LPVOID)&ObjDesc, sizeof(DMUS_OBJECTDESC));
+			do {
+			  IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
+			  IStream_Read (pStm, &chunkSize, sizeof(FOURCC), NULL);
+			  ListCount[2] += sizeof(FOURCC) + sizeof(DWORD) + chunkSize;
+			  TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (chunkID), chunkSize);
+			  switch (chunkID) {
+			  case DMUS_FOURCC_REF_CHUNK: {
+			    TRACE_(dmfile)(": reference header chunk\n");
+			    IStream_Read (pStm, &tempReferenceHeader, chunkSize, NULL);
+			    /* copy retrieved data to DMUS_OBJECTDESC */
+			    ObjDesc.dwSize = sizeof(DMUS_OBJECTDESC);
+			    ObjDesc.guidClass = tempReferenceHeader.guidClassID;
+			    ObjDesc.dwValidData = tempReferenceHeader.dwValidData;
+			    break;																	
+			  }
+			  case DMUS_FOURCC_GUID_CHUNK: {
+			    TRACE_(dmfile)(": guid chunk\n");
+			    IStream_Read (pStm, &ObjDesc.guidObject, chunkSize, NULL);
+			    break;
+			  }
+			  case DMUS_FOURCC_DATE_CHUNK: {
+			    TRACE_(dmfile)(": file date chunk\n");
+			    IStream_Read (pStm, &ObjDesc.ftDate, chunkSize, NULL);
+			    break;
+			  }
+			  case DMUS_FOURCC_NAME_CHUNK: {
+			    TRACE_(dmfile)(": name chunk\n");
+			    IStream_Read (pStm, &ObjDesc.wszName, chunkSize, NULL);
+			    break;
+			  }
+			  case DMUS_FOURCC_FILE_CHUNK: {
+			    TRACE_(dmfile)(": file name chunk\n");
+			    IStream_Read (pStm, &ObjDesc.wszFileName, chunkSize, NULL);
+			    break;
+			  }
+			  case DMUS_FOURCC_CATEGORY_CHUNK: {
+			    TRACE_(dmfile)(": category chunk\n");
+			    IStream_Read (pStm, &ObjDesc.wszCategory, chunkSize, NULL);
+			    break;
+			  }
+			  case DMUS_FOURCC_VERSION_CHUNK: {
+			    TRACE_(dmfile)(": version chunk\n");
+			    IStream_Read (pStm, &ObjDesc.vVersion, chunkSize, NULL);
+			    break;
+			  }
+			  default: {
+			    TRACE_(dmfile)(": unknown chunk (skipping)\n");
+			    liMove.QuadPart = chunkSize;
+			    IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip this chunk */
+			    break;
+			  }
+			  }
+			  TRACE_(dmfile)(": ListCount[2] = %ld < ListSize[2] = %ld\n", ListCount[2], ListSize[2]);
+			} while (ListCount[2] < ListSize[2]);
+			/* let's see what we have */
+			TRACE_(dmfile)(": (READ): reference: dwSize = %ld; dwValidData = %ld; guidObject = %s; guidClass = %s; vVersion = %08lx,%08lx; wszName = %s; wszCategory = %s; wszFileName = %s\n", 
+				       ObjDesc.dwSize, ObjDesc.dwValidData, debugstr_guid(&ObjDesc.guidObject), debugstr_guid(&ObjDesc.guidClass),
+				       ObjDesc.vVersion.dwVersionMS, ObjDesc.vVersion.dwVersionLS, debugstr_w(ObjDesc.wszName), debugstr_w(ObjDesc.wszCategory), debugstr_w(ObjDesc.wszFileName));
+			/* now, let's convience loader to load reference */								
+			if (SUCCEEDED(IStream_QueryInterface (pStm, &IID_IDirectMusicGetLoader, (LPVOID*) &pGetLoader))) {
+			  if (SUCCEEDED(IDirectMusicGetLoader_GetLoader (pGetLoader, &pLoader))) {
+			    /* load referenced object into new object entry */
+			    if (FAILED(IDirectMusicLoader_GetObject (pLoader, &ObjDesc, &IID_IDirectMusicObject, (LPVOID*) &pNewObject->ppObject))) {
+			      ERR("Couldn't load reference\n");
+			    }
+			    IDirectMusicLoader_Release (pLoader);
+			  }
+			  IDirectMusicGetLoader_Release (pGetLoader);											
+			} else {
+			  ERR("Could not get IDirectMusicGetLoader... reference will not be loaded :(\n");
+			  /* E_FAIL */
+			}
+			break;
+		      }
+		      default: {
+			TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
+			return E_FAIL;
+		      }
+		      }
+		      break;
+		    }
+		    case FOURCC_RIFF: {
+		      TRACE_(dmfile)(": RIFF chunk");
+		      /* now we load it using loader and then get it's object interface and put it on then
+			 list; sounds too easy to be true (FIXME!)*/
+		      /* move at the beginning of RIFF */
+		      liMove.QuadPart = 0;
+		      liMove.QuadPart -= (sizeof(FOURCC) + sizeof(DWORD));
+		      IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
+		      /* now get the loader */
+		      DMUS_OBJECTDESC ObjDesc2;
+		      ZeroMemory ((LPVOID)&ObjDesc2, sizeof(DMUS_OBJECTDESC));
+		      ObjDesc2.dwSize = sizeof(DMUS_OBJECTDESC);
+		      ObjDesc2.dwValidData = DMUS_OBJ_CLASS | DMUS_OBJ_STREAM;
+		      ObjDesc2.pStream = pStm;
+		      memcpy (&ObjDesc2.guidClass, &pNewObject->pHeader.guidClassID, sizeof(pNewObject->pHeader.guidClassID));
+		      if (SUCCEEDED(IStream_QueryInterface (pStm, &IID_IDirectMusicGetLoader, (LPVOID*) &pGetLoader))) {
+			if (SUCCEEDED(IDirectMusicGetLoader_GetLoader (pGetLoader, &pLoader))) {
+			  /* load contained object into new object entry */
+			  if (FAILED(IDirectMusicLoader_GetObject (pLoader, &ObjDesc2, &IID_IDirectMusicObject, (LPVOID*)&pNewObject->ppObject))) {
+			    ERR("Couldn't load contained object\n");
+			  }
+			  IDirectMusicLoader_Release (pLoader);
+			}
+			IDirectMusicGetLoader_Release (pGetLoader);											
+		      } else {
+			ERR("Could not get IDirectMusicGetLoader... contained object will not be loaded :(\n");
+			/* E_FAIL */
+		      }
+		      break;	
+		    }
+		    default: {
+		      TRACE_(dmfile)(": unknown chunk (skipping)\n");
+		      liMove.QuadPart = chunkSize;
+		      IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip this chunk */
+		      break;					
+		    }	
+		    }
+		    TRACE_(dmfile)(": ListCount[1] = %ld < ListSize[1] = %ld\n", ListCount[1], ListSize[1]);
+		  } while (ListCount[1] < ListSize[1]);
+		  list_add_tail (&pContainer->Objects, &pNewObject->entry);
+		  break;
+		}
+		default: {
+		  TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
+		  return E_FAIL;
+		}
+		}
+		break;
+	      }
+	      default: {
+		TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
+		liMove.QuadPart = chunkSize;
+		IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
+		break;						
+	      }
+	      }
+	      TRACE_(dmfile)(": ListCount[0] = %ld < ListSize[0] = %ld\n", ListCount[0], ListSize[0]);
+	    } while (ListCount[0] < ListSize[0]);
+	    break;
+	  }
+	  default: {
+	    TRACE_(dmfile)(": unknown (skipping)\n");
+	    liMove.QuadPart = chunkSize - sizeof(FOURCC);
+	    IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
+	    break;						
+	  }
+	  }
+	  break;
+	}	
+	default: {
+	  TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
+	  liMove.QuadPart = chunkSize;
+	  IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
+	  break;						
+	}
+	}
+	TRACE_(dmfile)(": StreamCount[0] = %ld < StreamSize[0] = %ld\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 = chunkSize;
+    IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
+    return E_FAIL;
+  }
+  }
+  
+  /* DEBUG: dumps whole container object tree: */
+  if (TRACE_ON(dmfile)) {
+    int r = 0;
+    DMUS_PRIVATE_OBJECT *tmpEntry;
+    struct list *listEntry;
+    
+    TRACE("*** IDirectMusicContainer (%p) ***\n", pContainer);
+    if (pContainer->pHeader) {
+      TRACE(" - Container header:\n");
+      TRACE("    - dwFlags = %ld\n", pContainer->pHeader->dwFlags);
+    }
+    if (pContainer->guidID)
+      TRACE(" - GUID = %s\n", debugstr_guid(pContainer->guidID));
+    if (pContainer->vVersion)
+      TRACE(" - Version = %i,%i,%i,%i\n", (pContainer->vVersion->dwVersionMS >> 8) && 0x0000FFFF, pContainer->vVersion->dwVersionMS && 0x0000FFFF, \
+	    (pContainer->vVersion->dwVersionLS >> 8) && 0x0000FFFF, pContainer->vVersion->dwVersionLS && 0x0000FFFF);
+    if (pContainer->wzName)
+      TRACE(" - Name = %s\n", debugstr_w(pContainer->wzName));
+    if (pContainer->wzArtist)		
+      TRACE(" - Artist = %s\n", debugstr_w(pContainer->wzArtist));
+    if (pContainer->wzCopyright)
+      TRACE(" - Copyright = %s\n", debugstr_w(pContainer->wzCopyright));
+    if (pContainer->wzSubject)
+      TRACE(" - Subject = %s\n", debugstr_w(pContainer->wzSubject));
+    if (pContainer->wzComment)
+      TRACE(" - Comment = %s\n", debugstr_w(pContainer->wzComment));
+    
+    TRACE(" - Objects:\n");
+    
+    LIST_FOR_EACH (listEntry, &pContainer->Objects) {
+      tmpEntry = LIST_ENTRY( listEntry, DMUS_PRIVATE_OBJECT, entry );
+      TRACE("    - Object[%i]:\n", r);
+      TRACE("       - Alias for this object: %s\n", debugstr_w(tmpEntry->wzAlias));
+      TRACE("       - Object header:\n");
+      TRACE("          - guidClassID = %s\n", debugstr_guid(&tmpEntry->pHeader.guidClassID));
+      TRACE("          - dwFlags = %ld\n", tmpEntry->pHeader.dwFlags);
+      TRACE("          - ckid = %s\n", debugstr_fourcc(tmpEntry->pHeader.ckid));
+      TRACE("          - fccType = %s\n", debugstr_fourcc(tmpEntry->pHeader.fccType));
+      TRACE("       - Object pointer: %p\n", tmpEntry->ppObject);
+      r++;
+    }
+  }
+  
+  TRACE("Reading finished\n");
+  
+  return S_OK;
 }
 
 HRESULT WINAPI IDirectMusicContainerObjectStream_Save (LPPERSISTSTREAM iface, IStream* pStm, BOOL fClearDirty)
Index: dlls/dmloader/dmloader_private.h
===================================================================
RCS file: /home/wine/wine/dlls/dmloader/dmloader_private.h,v
retrieving revision 1.5
diff -u -r1.5 dmloader_private.h
--- dlls/dmloader/dmloader_private.h	31 Oct 2003 00:08:02 -0000	1.5
+++ dlls/dmloader/dmloader_private.h	2 Nov 2003 13:46:06 -0000
@@ -42,11 +42,19 @@
 typedef struct _DMUS_PRIVATE_CACHE_ENTRY {
 	struct list entry; /* for listing elements */
 	GUID guidObject;
-	WCHAR wzFileName[MAX_PATH];
-        WCHAR wzName[256];
+	WCHAR wzFileName[DMUS_MAX_FILENAME];
+	WCHAR wzShortFileName[DMUS_MAX_FILENAME];
+	WCHAR wzName[DMUS_MAX_NAME];
+	WCHAR wzCategory[DMUS_MAX_CATEGORY];
     IDirectMusicObject* pObject;
 } DMUS_PRIVATE_CACHE_ENTRY, *LPDMUS_PRIVATE_CACHE_ENTRY;
 
+typedef struct _DMUS_PRIVATE_OBJECT {
+	struct list entry; /* for listing elements */
+	WCHAR* wzAlias;
+	DMUS_IO_CONTAINED_OBJECT_HEADER pHeader;
+	IDirectMusicObject* ppObject;
+} DMUS_PRIVATE_OBJECT, *LPDMUS_PRIVATE_OBJECT;
 
 /*****************************************************************************
  * Interfaces
@@ -134,6 +142,18 @@
 
   /* IDirectMusicContainerImpl fields */
   IDirectMusicContainerObject* pObject;
+  DMUS_IO_CONTAINER_HEADER* pHeader;
+  GUID* guidID; /* unique id */
+  DMUS_IO_VERSION* vVersion; /* version */
+  /* info from UNFO list */
+  WCHAR* wzName;
+  WCHAR* wzArtist;
+  WCHAR* wzCopyright;
+  WCHAR* wzSubject;
+  WCHAR* wzComment;
+
+  /* data */
+  struct list Objects;	
 };
 
 /* IUnknown: */
@@ -154,7 +174,7 @@
   DWORD          ref;
 
   /* IDirectMusicObjectImpl fields */
-  LPDMUS_OBJECTDESC pDesc;
+  DMUS_OBJECTDESC desc;
   IDirectMusicContainerObjectStream* pStream;
   IDirectMusicContainerImpl* pContainer;
 };
@@ -232,5 +252,12 @@
 extern HRESULT WINAPI ILoaderStream_IStream_UnlockRegion (LPSTREAM iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType);
 extern HRESULT WINAPI ILoaderStream_IStream_Stat (LPSTREAM iface, STATSTG* pstatstg, DWORD grfStatFlag);
 extern HRESULT WINAPI ILoaderStream_IStream_Clone (LPSTREAM iface, IStream** ppstm);
+
+static inline const char *debugstr_fourcc (DWORD fourcc) {
+    if (!fourcc) return "'null'";
+    return wine_dbg_sprintf ("\'%c%c%c%c\'",
+		(char)(fourcc), (char)(fourcc >> 8),
+		(char)(fourcc >> 16), (char)(fourcc >> 24));
+}
 
 #endif	/* __WINE_DMLOADER_PRIVATE_H */
Index: dlls/dmloader/loader.c
===================================================================
RCS file: /home/wine/wine/dlls/dmloader/loader.c,v
retrieving revision 1.8
diff -u -r1.8 loader.c
--- dlls/dmloader/loader.c	31 Oct 2003 00:08:02 -0000	1.8
+++ dlls/dmloader/loader.c	2 Nov 2003 13:46:07 -0000
@@ -77,6 +77,7 @@
 	struct list *listEntry;
 	DMUS_PRIVATE_CACHE_ENTRY *cacheEntry;
 	LPDMUS_PRIVATE_CACHE_ENTRY newEntry;
+	DMUS_OBJECTDESC tmpDesc;
 
 	TRACE("(%p, %p(dwValidData:0x%08lx), %s, %p)\n", This, pDesc, pDesc->dwValidData, debugstr_guid(riid), ppv);
 
@@ -84,7 +85,49 @@
 
 	LIST_FOR_EACH (listEntry, &This->CacheList) {
 		cacheEntry = LIST_ENTRY( listEntry, DMUS_PRIVATE_CACHE_ENTRY, entry );
-		
+
+ 		/* according to MSDN, search order is the following */
+ 		if (pDesc->dwValidData & DMUS_OBJ_OBJECT) {
+ 			if (IsEqualGUID (&cacheEntry->guidObject, &pDesc->guidObject)) {
+ 				TRACE(": found it by GUID\n");
+ 				if (cacheEntry->pObject)
+ 					return IDirectMusicObject_QueryInterface ((LPDIRECTMUSICOBJECT) cacheEntry->pObject, riid, ppv);
+ 			}
+ 		}
+ 		else if (pDesc->dwValidData & DMUS_OBJ_MEMORY) {
+ 			FIXME(": DMUS_OBJ_MEMORY not supported yet\n");
+ 		}
+ 		else if (pDesc->dwValidData & DMUS_OBJ_FILENAME && pDesc->dwValidData & DMUS_OBJ_FULLPATH) {
+ 			if (!strncmpW (cacheEntry->wzFileName, pDesc->wszFileName, DMUS_MAX_FILENAME)) {
+ 				TRACE(": found it by fullpath filename\n");
+ 				if (cacheEntry->pObject)
+ 					return IDirectMusicObject_QueryInterface ((LPDIRECTMUSICOBJECT) cacheEntry->pObject, riid, ppv);
+ 			}
+ 		}
+ 		else if (pDesc->dwValidData & DMUS_OBJ_NAME && pDesc->dwValidData & DMUS_OBJ_CATEGORY) {
+ 			if (!strncmpW (cacheEntry->wzName, pDesc->wszName, DMUS_MAX_NAME) && 
+			    !strncmpW (cacheEntry->wzCategory, pDesc->wszCategory, DMUS_MAX_CATEGORY)) {
+ 				TRACE(": found it by name and category\n");
+ 				if (cacheEntry->pObject)
+ 					return IDirectMusicObject_QueryInterface ((LPDIRECTMUSICOBJECT) cacheEntry->pObject, riid, ppv);
+ 			}
+ 		}
+ 		else if (pDesc->dwValidData & DMUS_OBJ_NAME) {
+ 			if (!strncmpW (cacheEntry->wzName, pDesc->wszName, DMUS_MAX_NAME)) {
+ 				TRACE(": found it by name\n");
+ 				if (cacheEntry->pObject)
+ 					return IDirectMusicObject_QueryInterface ((LPDIRECTMUSICOBJECT) cacheEntry->pObject, riid, ppv);
+ 			}
+ 		}
+ 		else if (pDesc->dwValidData & DMUS_OBJ_FILENAME) {
+ 			if (!strncmpW (cacheEntry->wzShortFileName, pDesc->wszFileName, DMUS_MAX_FILENAME)) {
+ 				TRACE(": found it by short filename\n");
+ 				if (cacheEntry->pObject)
+ 					return IDirectMusicObject_QueryInterface ((LPDIRECTMUSICOBJECT) cacheEntry->pObject, riid, ppv);	
+                        }
+		}
+
+/*
 		if ((pDesc->dwValidData & DMUS_OBJ_OBJECT) || (pDesc->dwValidData & DMUS_OBJ_FILENAME)) {
 			if (pDesc->dwValidData & DMUS_OBJ_OBJECT) {
 				if (IsEqualGUID (&cacheEntry->guidObject, &pDesc->guidObject)) {
@@ -100,46 +143,16 @@
 						return IDirectMusicObject_QueryInterface ((LPDIRECTMUSICOBJECT) cacheEntry->pObject, riid, ppv);
 				}
 			}
-		} else if (pDesc->dwValidData & DMUS_OBJ_NAME) {
-		  /**
-		   * Usually search by name (for example main procedure name for scripts) after containers loading
-		   * TODO: container loading code
-		   */
-		  TRACE(" comparing %s with cached %s (file:%s)\n", debugstr_w (pDesc->wszName), debugstr_w (cacheEntry->wzName), debugstr_w(cacheEntry->wzFileName));
-		  if (cacheEntry->wzName && !strncmpW (pDesc->wszName, cacheEntry->wzName, 256)) {
-		    TRACE(": found it by Name\n");
-		    if (NULL != cacheEntry->pObject)
-		      return IDirectMusicObject_QueryInterface ((LPDIRECTMUSICOBJECT) cacheEntry->pObject, riid, ppv);
-		  }
 		}
+*/
 	}
 	
 	/* object doesn't exist in cache... guess we'll have to load it */
 	TRACE(": object does not exist in cache\n");
 	if (pDesc->dwValidData & DMUS_OBJ_LOADED) {
-	  ERR("Wanted a on-memory (cached) entry, but not found. Active Hack (waiting for Load code)\n");
-	  /* ugly hack waiting for Load impl */
-	  result = CoCreateInstance (&pDesc->guidClass, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicObject, (LPVOID*) &pObject);
-	  if (SUCCEEDED(result)) {
-	    /* add object to cache */
-	    result = IDirectMusicObject_QueryInterface (pObject, riid, ppv);
-	    if (SUCCEEDED(result)) {
-	      newEntry = (LPDMUS_PRIVATE_CACHE_ENTRY) HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(DMUS_PRIVATE_CACHE_ENTRY));
-	      if (pDesc->dwValidData & DMUS_OBJ_NAME)
-		strncpyW (newEntry->wzName, pDesc->wszName, 256);
-	      newEntry->pObject = pObject;
-	      list_add_tail (&This->CacheList, &newEntry->entry);
-	      TRACE(": filled in cache entry\n");
-	    } else {
-	      IDirectMusicObject_Release(pObject);
-	    }
-	  }
-	  return result;
-	  /*
-	   * Normal code
+	  ERR("wanted on memory object failed\n");	  
 	  *ppv = NULL;
 	  return E_FAIL;
-	  */
 	}
 	if (!(pDesc->dwValidData & DMUS_OBJ_CLASS)) {
 	  WARN("guidClass not valid but needed. What they want to do ?\n");
@@ -229,15 +242,30 @@
 		return E_FAIL;
 	}
 	/* add object to cache */
+	IDirectMusicObject_SetDescriptor (pObject, pDesc);
+	IDirectMusicObject_GetDescriptor (pObject, &tmpDesc);
 	newEntry = (LPDMUS_PRIVATE_CACHE_ENTRY) HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(DMUS_PRIVATE_CACHE_ENTRY));
-	if (pDesc->dwValidData & DMUS_OBJ_OBJECT)
-		memcpy (&newEntry->guidObject, &pDesc->guidObject, sizeof (pDesc->guidObject));
-	if (pDesc->dwValidData & DMUS_OBJ_FILENAME)
-		strncpyW (newEntry->wzFileName, pDesc->wszFileName, MAX_PATH);
+	if (tmpDesc.dwValidData & DMUS_OBJ_OBJECT)
+	  memcpy (&newEntry->guidObject, &tmpDesc.guidObject, sizeof (tmpDesc.guidObject));
+	if (tmpDesc.dwValidData & DMUS_OBJ_FILENAME)
+	  strncpyW (newEntry->wzFileName, tmpDesc.wszFileName, MAX_PATH);
+	if (tmpDesc.dwValidData & DMUS_OBJ_NAME)
+	  strcpyW (newEntry->wzName, tmpDesc.wszName);
+	if (tmpDesc.dwValidData & DMUS_OBJ_CATEGORY)
+	  strcpyW (newEntry->wzCategory, tmpDesc.wszCategory);
 	if (pObject)
-		newEntry->pObject = pObject;
+	  newEntry->pObject = pObject;
 	list_add_tail (&This->CacheList, &newEntry->entry);
 	TRACE(": filled in cache entry\n");
+
+	if (tmpDesc.dwValidData & DMUS_OBJ_OBJECT)
+	  TRACE(" - GUID = %s\n", debugstr_guid(&newEntry->guidObject));
+	if (tmpDesc.dwValidData & DMUS_OBJ_FILENAME)
+	  TRACE(" - FileName = %s\n", debugstr_w(newEntry->wzFileName));
+	if (tmpDesc.dwValidData & DMUS_OBJ_NAME)
+	  TRACE(" - Name = %s\n", debugstr_w(newEntry->wzName));
+	if (tmpDesc.dwValidData & DMUS_OBJ_CATEGORY)
+	  TRACE(" - Category = %s\n", debugstr_w(newEntry->wzCategory));
 	
 	/* for debug purposes (e.g. to check if all files are cached) */
 #if 0
Index: dlls/dmscript/dmscript_private.h
===================================================================
RCS file: /home/wine/wine/dlls/dmscript/dmscript_private.h,v
retrieving revision 1.3
diff -u -r1.3 dmscript_private.h
--- dlls/dmscript/dmscript_private.h	5 Sep 2003 23:08:39 -0000	1.3
+++ dlls/dmscript/dmscript_private.h	2 Nov 2003 13:46:07 -0000
@@ -79,6 +79,17 @@
 
   /* IDirectMusicScriptImpl fields */
   IDirectMusicScriptObject* pObject;
+  DMUS_IO_SCRIPT_HEADER* pHeader;
+  GUID* guidID; /* unique id */
+  DMUS_IO_VERSION* vVersion; /* version */
+  WCHAR* wzLanguage;
+  WCHAR* wzSource;
+  /* info from UNFO list */
+  WCHAR* wzName;
+  WCHAR* wzArtist;
+  WCHAR* wzCopyright;
+  WCHAR* wzSubject;
+  WCHAR* wzComment;
 };
 
 /* IUnknown: */
@@ -108,7 +119,7 @@
   DWORD          ref;
 
   /* IDirectMusicObjectImpl fields */
-  LPDMUS_OBJECTDESC pDesc;
+  DMUS_OBJECTDESC desc;
   IDirectMusicScriptObjectStream* pStream;
   IDirectMusicScriptImpl* pScript;
 };
@@ -207,5 +218,12 @@
 extern HRESULT WINAPI IDirectMusicScriptTrackStream_Load (LPPERSISTSTREAM iface, IStream* pStm);
 extern HRESULT WINAPI IDirectMusicScriptTrackStream_Save (LPPERSISTSTREAM iface, IStream* pStm, BOOL fClearDirty);
 extern HRESULT WINAPI IDirectMusicScriptTrackStream_GetSizeMax (LPPERSISTSTREAM iface, ULARGE_INTEGER* pcbSize);
+
+static inline const char *debugstr_fourcc (DWORD fourcc) {
+    if (!fourcc) return "'null'";
+    return wine_dbg_sprintf ("\'%c%c%c%c\'",
+		(char)(fourcc), (char)(fourcc >> 8),
+		(char)(fourcc >> 16), (char)(fourcc >> 24));
+}
 
 #endif	/* __WINE_DMSCRIPT_PRIVATE_H */
Index: dlls/dmscript/script.c
===================================================================
RCS file: /home/wine/wine/dlls/dmscript/script.c,v
retrieving revision 1.4
diff -u -r1.4 script.c
--- dlls/dmscript/script.c	31 Oct 2003 00:08:02 -0000	1.4
+++ dlls/dmscript/script.c	2 Nov 2003 13:46:09 -0000
@@ -24,10 +24,12 @@
 #include "winuser.h"
 #include "wingdi.h"
 #include "wine/debug.h"
+#include "wine/unicode.h"
 
 #include "dmscript_private.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(dmscript);
+WINE_DECLARE_DEBUG_CHANNEL(dmfile);
 
 /* IDirectMusicScript IUnknown part: */
 HRESULT WINAPI IDirectMusicScriptImpl_QueryInterface (LPDIRECTMUSICSCRIPT iface, REFIID riid, LPVOID *ppobj)
@@ -244,9 +246,8 @@
 {
 	ICOM_THIS(IDirectMusicScriptObject,iface);
 
-	TRACE("(%p, %p)\n", This, pDesc);
-	pDesc = This->pDesc;
-	
+	TRACE("(%p, %p)\n", This, &This->desc);
+	memcpy(pDesc, &This->desc, sizeof(DMUS_OBJECTDESC));
 	return S_OK;
 }
 
@@ -255,8 +256,29 @@
 	ICOM_THIS(IDirectMusicScriptObject,iface);
 
 	TRACE("(%p, %p)\n", This, pDesc);
-	This->pDesc = pDesc;
-
+	
+	This->desc.dwValidData = pDesc->dwValidData;
+	/** follow memcpy is temporary while all fields aren't supported */
+	memcpy(&This->desc, pDesc, sizeof(DMUS_OBJECTDESC));
+
+	if (This->pScript->guidID) {
+	  memcpy (&This->desc.guidObject, This->pScript->guidID, sizeof (This->desc.guidObject));
+	  This->desc.dwValidData |= DMUS_OBJ_OBJECT;
+	} else {
+	  if (pDesc->dwValidData & DMUS_OBJ_OBJECT)
+	    memcpy (&This->desc.guidObject, &pDesc->guidObject, sizeof (This->desc.guidObject));
+	}
+	if (pDesc->dwValidData & DMUS_OBJ_FILENAME)
+	  strncpyW (This->desc.wszFileName, pDesc->wszFileName, MAX_PATH);
+	if (This->pScript->wzName) {
+	  strcpyW (This->desc.wszName, This->pScript->wzName);
+	  This->desc.dwValidData |= DMUS_OBJ_NAME;
+	} else {
+	  if (pDesc->dwValidData & DMUS_OBJ_NAME)
+	    strcpyW (This->desc.wszName, pDesc->wszName);
+	}
+	if (pDesc->dwValidData & DMUS_OBJ_CATEGORY)
+	  strcpyW (This->desc.wszCategory, pDesc->wszCategory);
 	return S_OK;
 }
 
@@ -362,9 +384,241 @@
 
 HRESULT WINAPI IDirectMusicScriptObjectStream_Load (LPPERSISTSTREAM iface, IStream* pStm)
 {
-	FIXME(": Loading not implemented yet\n");
-	return S_OK;
+  ICOM_THIS(IDirectMusicScriptObjectStream,iface);
+  FOURCC chunkID;
+  DWORD chunkSize, StreamSize, StreamCount, ListSize[3], ListCount[3];
+  LARGE_INTEGER liMove; /* used when skipping chunks */
+  DMUS_IO_REFERENCE tempReferenceHeader;
+  DMUS_OBJECTDESC ObjDesc;
+  IDirectMusicScriptImpl* pScript = This->pParentObject->pScript; /* that's where we load data to */
+  LPDIRECTMUSICLOADER pLoader;
+  LPDIRECTMUSICGETLOADER pGetLoader;
+
+  IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
+  IStream_Read (pStm, &chunkSize, sizeof(DWORD), NULL);
+  TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (chunkID), chunkSize);
+
+  switch (chunkID) {	
+  case FOURCC_RIFF: {
+    IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);				
+    TRACE_(dmfile)(": RIFF chunk of type %s", debugstr_fourcc (chunkID));
+    StreamSize = chunkSize - sizeof(FOURCC);
+    StreamCount = 0;
+    switch (chunkID) {
+    case DMUS_FOURCC_SCRIPT_FORM: {
+      TRACE_(dmfile)(": script form\n"); 
+      do {
+	IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
+	IStream_Read (pStm, &chunkSize, sizeof(FOURCC), NULL);
+	StreamCount += sizeof(FOURCC) + sizeof(DWORD) + chunkSize;
+	TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (chunkID), chunkSize);
+	switch (chunkID) {
+	case DMUS_FOURCC_SCRIPT_CHUNK: {
+	  TRACE_(dmfile)(": script header chunk\n");
+	  pScript->pHeader = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
+	  IStream_Read (pStm, pScript->pHeader, chunkSize, NULL);
+	  break;
+	}
+	case DMUS_FOURCC_GUID_CHUNK: {
+	  TRACE_(dmfile)(": GUID chunk\n");
+	  pScript->guidID = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
+	  IStream_Read (pStm, pScript->guidID, chunkSize, NULL);
+	  break;
+	}
+	case DMUS_FOURCC_VERSION_CHUNK: {
+	  TRACE_(dmfile)(": version chunk\n");
+	  pScript->vVersion = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
+	  IStream_Read (pStm, pScript->vVersion, chunkSize, NULL);
+	  break;
+	}
+	case DMUS_FOURCC_SCRIPTVERSION_CHUNK: {
+	  TRACE_(dmfile)(": script version chunk\n");
+	  pScript->vVersion = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
+	  IStream_Read (pStm, pScript->vVersion, chunkSize, NULL);
+	  break;
+	}
+	case DMUS_FOURCC_SCRIPTLANGUAGE_CHUNK: {
+	  TRACE_(dmfile)(": script language chunk\n");
+	  pScript->wzLanguage = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
+	  IStream_Read (pStm, pScript->wzLanguage, chunkSize, NULL);
+	  break;
+	}
+	case DMUS_FOURCC_SCRIPTSOURCE_CHUNK: {
+	  TRACE_(dmfile)(": script source chunk\n");
+	  pScript->wzSource = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
+	  IStream_Read (pStm, pScript->wzSource, chunkSize, NULL);
+	  break;
+	}
+
+	case FOURCC_RIFF: {
+	  DMUS_OBJECTDESC ObjDesc2;
+	  IDirectMusicObject* pNewObject;
+	  
+	  TRACE_(dmfile)(": RIFF chunk");
+	  /* move at the beginning of RIFF */
+	  liMove.QuadPart = 0;
+	  liMove.QuadPart -= (sizeof(FOURCC) + sizeof(DWORD));
+	  IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
+	  /* now get the loader */
+	  ZeroMemory ((LPVOID)&ObjDesc2, sizeof(DMUS_OBJECTDESC));
+	  ObjDesc2.dwSize = sizeof(DMUS_OBJECTDESC);
+	  ObjDesc2.dwValidData = DMUS_OBJ_CLASS | DMUS_OBJ_STREAM;
+	  ObjDesc2.pStream = pStm;
+	  memcpy (&ObjDesc2.guidClass, &CLSID_DirectMusicContainer, sizeof(ObjDesc2.guidClass));
+	  if (SUCCEEDED(IStream_QueryInterface (pStm, &IID_IDirectMusicGetLoader, (LPVOID*) &pGetLoader))) {
+	    if (SUCCEEDED(IDirectMusicGetLoader_GetLoader (pGetLoader, &pLoader))) {
+	      /* load contained object into new object entry */
+	      if (FAILED(IDirectMusicLoader_GetObject (pLoader, &ObjDesc2, &IID_IDirectMusicObject, (LPVOID*) &pNewObject))) {
+		ERR("Couldn't load contained object\n");
+	      }
+	      IDirectMusicLoader_Release (pLoader);
+	    }
+	    IDirectMusicGetLoader_Release (pGetLoader);											
+	  } else {
+	    ERR("Could not get IDirectMusicGetLoader... contained object will not be loaded :(\n");
+	    /* E_FAIL */
+	  }
+	  break;
+	}
+
+	case FOURCC_LIST: {
+	  IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);				
+	  TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(chunkID));
+	  ListSize[0] = chunkSize - sizeof(FOURCC);
+	  ListCount[0] = 0;
+	  switch (chunkID) {
+	  case DMUS_FOURCC_UNFO_LIST: {
+	    TRACE_(dmfile)(": UNFO list\n");
+	    do {
+	      IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
+	      IStream_Read (pStm, &chunkSize, sizeof(FOURCC), NULL);
+	      ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + chunkSize;
+	      TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (chunkID), chunkSize);
+	      switch (chunkID) {
+	      case mmioFOURCC('I','N','A','M'):
+	      case DMUS_FOURCC_UNAM_CHUNK: {
+		TRACE_(dmfile)(": name chunk\n");
+		pScript->wzName = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
+		IStream_Read (pStm, pScript->wzName, chunkSize, NULL);
+		break;
+	      }
+	      case mmioFOURCC('I','A','R','T'):
+	      case DMUS_FOURCC_UART_CHUNK: {
+		TRACE_(dmfile)(": artist chunk\n");
+		pScript->wzArtist = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
+		IStream_Read (pStm, pScript->wzArtist, chunkSize, NULL);
+		break;
+	      }
+	      case mmioFOURCC('I','C','O','P'):
+	      case DMUS_FOURCC_UCOP_CHUNK: {
+		TRACE_(dmfile)(": copyright chunk\n");
+		pScript->wzCopyright = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
+		IStream_Read (pStm, pScript->wzCopyright, chunkSize, NULL);
+		break;
+	      }
+	      case mmioFOURCC('I','S','B','J'):
+	      case DMUS_FOURCC_USBJ_CHUNK: {
+		TRACE_(dmfile)(": subject chunk\n");
+		pScript->wzSubject = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
+		IStream_Read (pStm, pScript->wzSubject, chunkSize, NULL);
+		break;
+	      }
+	      case mmioFOURCC('I','C','M','T'):
+	      case DMUS_FOURCC_UCMT_CHUNK: {
+		TRACE_(dmfile)(": comment chunk\n");
+		pScript->wzComment = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
+		IStream_Read (pStm, pScript->wzComment, chunkSize, NULL);
+		break;
+	      }
+
+	      case DMUS_FOURCC_SCRIPTTRACK_LIST: {
+		TRACE_(dmfile)(": Script track list\n");
+	      }
+
+	      default: {
+		TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
+		liMove.QuadPart = chunkSize;
+		IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
+		break;						
+	      }
+	      }
+	      TRACE_(dmfile)(": ListCount[0] = %ld < ListSize[0] = %ld\n", ListCount[0], ListSize[0]);
+	    } while (ListCount[0] < ListSize[0]);
+	    break;
+	  }
+
+	  default: {
+	    TRACE_(dmfile)(" DMUS_FOURCC_UNFO_LIST : unknown chunk (irrevelant & skipping)\n");
+	    liMove.QuadPart = chunkSize;
+	    IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
+	    break;						
+	  }
+	  }
+	  break;
+	}
+
+	default: {
+	  TRACE_(dmfile)(" FOURCC_LIST 2 : unknown chunk (irrevelant & skipping)\n");
+	  liMove.QuadPart = chunkSize;
+	  IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
+	  break;						
+	}
+      }
+      } while (StreamCount < StreamSize);
+      break;
+    }
+
+    default: {
+      TRACE_(dmfile)(" DMUS_FOURCC_SCRIPT_FORM : 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;
+    }
+    }
+    break;
+  }
+ 
+  default: {
+    TRACE_(dmfile)(" FOURCC_RIFF 1 : unexpected chunk; loading failed)\n");
+    liMove.QuadPart = chunkSize;
+    IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
+    return E_FAIL;
+  }
+  }
+
+  /* DEBUG: dumps whole script object : */
+  if (TRACE_ON(dmfile)) {
+    int r = 0;
+    
+    TRACE("*** IDirectMusicScript (%p) ***\n", pScript);
+    if (pScript->pHeader) {
+      TRACE(" - Script header:\n");
+      TRACE("    - dwFlags = %ld\n", pScript->pHeader->dwFlags);
+    }
+    if (pScript->guidID)
+      TRACE(" - GUID = %s\n", debugstr_guid(pScript->guidID));
+    if (pScript->vVersion)
+      TRACE(" - Version = %i,%i,%i,%i\n", 
+	    (pScript->vVersion->dwVersionMS >> 8) && 0x0000FFFF, pScript->vVersion->dwVersionMS && 0x0000FFFF, \
+	    (pScript->vVersion->dwVersionLS >> 8) && 0x0000FFFF, pScript->vVersion->dwVersionLS && 0x0000FFFF);
+    if (pScript->wzName)
+      TRACE(" - Name = %s\n", debugstr_w(pScript->wzName));
+    if (pScript->wzArtist)		
+      TRACE(" - Artist = %s\n", debugstr_w(pScript->wzArtist));
+    if (pScript->wzCopyright)
+      TRACE(" - Copyright = %s\n", debugstr_w(pScript->wzCopyright));
+    if (pScript->wzSubject)
+      TRACE(" - Subject = %s\n", debugstr_w(pScript->wzSubject));
+    if (pScript->wzComment)
+      TRACE(" - Comment = %s\n", debugstr_w(pScript->wzComment));
+    if (pScript->wzLanguage)
+      TRACE(" - Language = %s\n", debugstr_w(pScript->wzLanguage));
+    if (pScript->wzSource)
+      TRACE(" - Source = %s\n", debugstr_w(pScript->wzSource));
+  }
+
+  return S_OK;
 }
 
 HRESULT WINAPI IDirectMusicScriptObjectStream_Save (LPPERSISTSTREAM iface, IStream* pStm, BOOL fClearDirty)
Index: include/dmusici.h
===================================================================
RCS file: /home/wine/wine/include/dmusici.h,v
retrieving revision 1.6
diff -u -r1.6 dmusici.h
--- include/dmusici.h	28 Aug 2003 21:43:35 -0000	1.6
+++ include/dmusici.h	2 Nov 2003 13:46:21 -0000
@@ -46,33 +46,33 @@
 DEFINE_GUID(CLSID_DirectMusicPerformance,					0xd2ac2881,0xb39b,0x11d1,0x87,0x4,0x0,0x60,0x8,0x93,0xb1,0xbd);
 DEFINE_GUID(CLSID_DirectMusicSegment,						0xd2ac2882,0xb39b,0x11d1,0x87,0x4,0x0,0x60,0x8,0x93,0xb1,0xbd);
 DEFINE_GUID(CLSID_DirectMusicSegmentState,					0xd2ac2883,0xb39b,0x11d1,0x87,0x4,0x0,0x60,0x8,0x93,0xb1,0xbd);
-DEFINE_GUID(CLSID_DirectMusicGraph,							0xd2ac2884,0xb39b,0x11d1,0x87,0x4,0x0,0x60,0x8,0x93,0xb1,0xbd);
-DEFINE_GUID(CLSID_DirectMusicStyle,							0xd2ac288a,0xb39b,0x11d1,0x87,0x4,0x0,0x60,0x8,0x93,0xb1,0xbd);
+DEFINE_GUID(CLSID_DirectMusicGraph,						0xd2ac2884,0xb39b,0x11d1,0x87,0x4,0x0,0x60,0x8,0x93,0xb1,0xbd);
+DEFINE_GUID(CLSID_DirectMusicStyle,						0xd2ac288a,0xb39b,0x11d1,0x87,0x4,0x0,0x60,0x8,0x93,0xb1,0xbd);
 DEFINE_GUID(CLSID_DirectMusicChordMap,						0xd2ac288f,0xb39b,0x11d1,0x87,0x4,0x0,0x60,0x8,0x93,0xb1,0xbd);
 DEFINE_GUID(CLSID_DirectMusicComposer,						0xd2ac2890,0xb39b,0x11d1,0x87,0x4,0x0,0x60,0x8,0x93,0xb1,0xbd);
 DEFINE_GUID(CLSID_DirectMusicLoader,						0xd2ac2892,0xb39b,0x11d1,0x87,0x4,0x0,0x60,0x8,0x93,0xb1,0xbd);
-DEFINE_GUID(CLSID_DirectMusicBand,							0x79ba9e00,0xb6ee,0x11d1,0x86,0xbe,0x0,0xc0,0x4f,0xbf,0x8f,0xef);
+DEFINE_GUID(CLSID_DirectMusicBand,						0x79ba9e00,0xb6ee,0x11d1,0x86,0xbe,0x0,0xc0,0x4f,0xbf,0x8f,0xef);
 DEFINE_GUID(CLSID_DirectMusicPatternTrack,					0xd2ac2897,0xb39b,0x11d1,0x87,0x4,0x0,0x60,0x8,0x93,0xb1,0xbd);
 DEFINE_GUID(CLSID_DirectMusicScript,						0x810b5013,0xe88d,0x11d2,0x8b,0xc1,0x0,0x60,0x8,0x93,0xb1,0xb6);
 DEFINE_GUID(CLSID_DirectMusicContainer,						0x9301e380,0x1f22,0x11d3,0x82,0x26,0xd2,0xfa,0x76,0x25,0x5d,0x47);
-DEFINE_GUID(CLSID_DirectSoundWave,							0x8a667154,0xf9cb,0x11d2,0xad,0x8a,0x0,0x60,0xb0,0x57,0x5a,0xbc);
-DEFINE_GUID(CLSID_DirectMusicSong,							0xaed5f0a5,0xd972,0x483d,0xa3,0x84,0x64,0x9d,0xfe,0xb9,0xc1,0x81);
-DEFINE_GUID(CLSID_DirectMusicAudioPathConfig,				0xee0b9ca0,0xa81e,0x11d3,0x9b,0xd1,0x0,0x80,0xc7,0x15,0xa,0x74);
+DEFINE_GUID(CLSID_DirectSoundWave,						0x8a667154,0xf9cb,0x11d2,0xad,0x8a,0x0,0x60,0xb0,0x57,0x5a,0xbc);
+DEFINE_GUID(CLSID_DirectMusicSong,						0xaed5f0a5,0xd972,0x483d,0xa3,0x84,0x64,0x9d,0xfe,0xb9,0xc1,0x81);
+DEFINE_GUID(CLSID_DirectMusicAudioPathConfig,				        0xee0b9ca0,0xa81e,0x11d3,0x9b,0xd1,0x0,0x80,0xc7,0x15,0xa,0x74);
 /* these CLSIDs aren't officially declared in any dmusic header, but are used by regsvr implementations*/
 DEFINE_GUID(CLSID_DirectMusicSynthSink,						0xaec17ce3,0xa514,0x11d1,0xaf,0xa6,0x00,0xaa,0x00,0x24,0xd8,0xb6);
 DEFINE_GUID(CLSID_DirectMusicSection,						0x3f037241,0x414e,0x11d1,0xa7,0xce,0x00,0xa0,0xc9,0x13,0xf7,0x3c);
 DEFINE_GUID(CLSID_DirectMusicAuditionTrack,					0xd2ac2897,0xb39b,0x11d1,0x87,0x04,0x00,0x60,0x08,0x93,0xb1,0xbd);
-DEFINE_GUID(CLSID_DirectMusicSegTriggerTrack,				0xbae4d665,0x4ea1,0x11d3,0x8b,0xda,0x00,0x60,0x08,0x93,0xb1,0xb6);
+DEFINE_GUID(CLSID_DirectMusicSegTriggerTrack,				        0xbae4d665,0x4ea1,0x11d3,0x8b,0xda,0x00,0x60,0x08,0x93,0xb1,0xb6);
 DEFINE_GUID(CLSID_DirectMusicAudioPath,						0xee0b9ca0,0xa81e,0x11d3,0x9b,0xd1,0x00,0x80,0xc7,0x15,0x0a,0x74);
 DEFINE_GUID(CLSID_DirectMusicTemplate,						0xd30bcc65,0x60e8,0x11d1,0xa7,0xce,0x00,0xa0,0xc9,0x13,0xf7,0x3c);
-DEFINE_GUID(CLSID_DirectMusicScriptAutoImpSegment,			0x4062c116,0x0270,0x11d3,0x8b,0xcb,0x00,0x60,0x08,0x93,0xb1,0xb6);
-DEFINE_GUID(CLSID_AudioVBScript,							0x4ee17959,0x931e,0x49e4,0xa2,0xc6,0x97,0x7e,0xcf,0x36,0x28,0xf3);
-DEFINE_GUID(CLSID_DirectMusicScriptAutoImpPerformance,		0xa861c6e2,0xfcfc,0x11d2,0x8b,0xc9,0x00,0x60,0x08,0x93,0xb1,0xb6);
-DEFINE_GUID(CLSID_DirectMusicScripSourceCodeLoader,			0xc70eb77f,0xefd4,0x4678,0xa2,0x7b,0xbf,0x16,0x48,0xf3,0x0d,0x04); /* [sic] */
-DEFINE_GUID(CLSID_DirectMusicScriptAutoImpSegmentState,		0xebf2320a,0x2502,0x11d3,0x8b,0xd1,0x00,0x60,0x08,0x93,0xb1,0xb6);
-DEFINE_GUID(CLSID_DirectMusicScriptAutoImpAudioPathConfig,	0x1cebde3e,0x6b91,0x484a,0xaf,0x48,0x5e,0x4f,0x4e,0xd6,0xb1,0xe1);
-DEFINE_GUID(CLSID_DirectMusicScriptAutoImpAudioPath,		0x2c5f9b72,0x7148,0x4d97,0xbf,0xc9,0x68,0xa0,0xe0,0x76,0xbe,0xbd);
-DEFINE_GUID(CLSID_DirectMusicScriptAutoImpSong,				0xa16f1761,0xb6d8,0x42eb,0x8d,0x57,0x4a,0x44,0xfe,0xdd,0x3b,0xd2);
+DEFINE_GUID(CLSID_DirectMusicScriptAutoImpSegment,			        0x4062c116,0x0270,0x11d3,0x8b,0xcb,0x00,0x60,0x08,0x93,0xb1,0xb6);
+DEFINE_GUID(CLSID_AudioVBScript,						0x4ee17959,0x931e,0x49e4,0xa2,0xc6,0x97,0x7e,0xcf,0x36,0x28,0xf3);
+DEFINE_GUID(CLSID_DirectMusicScriptAutoImpPerformance,		                0xa861c6e2,0xfcfc,0x11d2,0x8b,0xc9,0x00,0x60,0x08,0x93,0xb1,0xb6);
+DEFINE_GUID(CLSID_DirectMusicScripSourceCodeLoader,			        0xc70eb77f,0xefd4,0x4678,0xa2,0x7b,0xbf,0x16,0x48,0xf3,0x0d,0x04); /* [sic] */
+DEFINE_GUID(CLSID_DirectMusicScriptAutoImpSegmentState,		                0xebf2320a,0x2502,0x11d3,0x8b,0xd1,0x00,0x60,0x08,0x93,0xb1,0xb6);
+DEFINE_GUID(CLSID_DirectMusicScriptAutoImpAudioPathConfig,	                0x1cebde3e,0x6b91,0x484a,0xaf,0x48,0x5e,0x4f,0x4e,0xd6,0xb1,0xe1);
+DEFINE_GUID(CLSID_DirectMusicScriptAutoImpAudioPath,		                0x2c5f9b72,0x7148,0x4d97,0xbf,0xc9,0x68,0xa0,0xe0,0x76,0xbe,0xbd);
+DEFINE_GUID(CLSID_DirectMusicScriptAutoImpSong,				        0xa16f1761,0xb6d8,0x42eb,0x8d,0x57,0x4a,0x44,0xfe,0xdd,0x3b,0xd2);
 
 /* IIDs */
 DEFINE_GUID(IID_IDirectMusicAudioPath,						0xc87631f5,0x23be,0x4986,0x88,0x36,0x5,0x83,0x2f,0xcc,0x48,0xf9);

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux