WINMM/MMSYSTEM split

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

 



this is the third attempt for splitting 16 bit MMIO out of WINMM
A+
Name:          mm1632_3
ChangeLog:     keep on moving 16 bit code out of winmm
now only using linear addresses for buffers
License:       X11
GenDate:       2002/10/20 09:33:40 UTC
ModifiedFiles: dlls/winmm/mmio.c dlls/winmm/mmsystem.c dlls/winmm/winemm.h
AddedFiles:    
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/dlls/winmm/mmio.c,v
retrieving revision 1.34
diff -u -u -r1.34 mmio.c
--- dlls/winmm/mmio.c	9 Aug 2002 19:51:01 -0000	1.34
+++ dlls/winmm/mmio.c	20 Oct 2002 08:42:36 -0000
@@ -4,7 +4,7 @@
  *
  * Copyright 1998 Andrew Taylor
  * Copyright 1998 Ove Kåven
- * Copyright 2000 Eric Pouech
+ * Copyright 2000,2002 Eric Pouech
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -22,15 +22,13 @@
  */
 
 /* Still to be done:
- * 	+ correct handling of global/local IOProcs
+ * 	+ correct handling of global/local IOProcs (and temporary IOProcs)
  *	+ mode of mmio objects is not used (read vs write vs readwrite)
- *	+ optimization of internal buffers (seg / lin)
- *	+ even in 32 bit only, a seg ptr IO buffer is allocated (after this is
- *	  fixed, we'll have a proper 32/16 separation)
  *	+ thread safeness
- *	+ rename operation is broken
+ *      + 32 A <=> W message mapping
  */
 
+
 #include <ctype.h>
 #include <stdlib.h>
 #include <string.h>
@@ -39,9 +37,6 @@
 
 #include "mmsystem.h"
 #include "windef.h"
-
-#include "wine/mmsystem16.h"
-#include "wine/winbase16.h"
 #include "heap.h"
 #include "winemm.h"
 
@@ -64,11 +59,10 @@
 	{
 	    /* Parameters:
 	     * lParam1 = szFileName parameter from mmioOpen
-	     * lParam2 = reserved (we use it for 16-bitness)
+	     * lParam2 = reserved
 	     * Returns: zero on success, error code on error
 	     * NOTE: lDiskOffset automatically set to zero
 	     */
-	    OFSTRUCT    ofs;
 	    LPCSTR      szFileName = (LPCSTR)lParam1;
 
 	    if (lpmmioinfo->dwFlags & MMIO_GETTEMP) {
@@ -78,11 +72,11 @@
 
 	    /* if filename NULL, assume open file handle in adwInfo[0] */
 	    if (!szFileName) {
-		if (lParam2)
-		    lpmmioinfo->adwInfo[0] = DosFileHandleToWin32Handle(lpmmioinfo->adwInfo[0]);
-		break;
-	    }
-	    lpmmioinfo->adwInfo[0] = (DWORD)OpenFile(szFileName, &ofs, lpmmioinfo->dwFlags & 0xFFFF);
+                lpmmioinfo->adwInfo[0] = DosFileHandleToWin32Handle(lpmmioinfo->adwInfo[0]);
+	    } else {
+                OFSTRUCT    ofs;
+                lpmmioinfo->adwInfo[0] = (DWORD)OpenFile(szFileName, &ofs, lpmmioinfo->dwFlags & 0xFFFF);
+            }
 	    if (lpmmioinfo->adwInfo[0] == (DWORD)HFILE_ERROR)
 		ret = MMIOERR_CANNOTOPEN;
 	}
@@ -168,7 +162,7 @@
     case MMIOM_OPEN:
 	/* Parameters:
 	 * lParam1 = filename (must be NULL)
-	 * lParam2 = reserved (we use it for 16-bitness)
+	 * lParam2 = reserved
 	 * Returns: zero on success, error code on error
 	 * NOTE: lDiskOffset automatically set to zero
 	 */
@@ -229,19 +223,9 @@
     return 0;
 }
 
-
-enum mmioProcType {MMIO_PROC_16,MMIO_PROC_32A,MMIO_PROC_32W};
-
-struct IOProcList
-{
-    struct IOProcList*pNext;       /* Next item in linked list */
-    FOURCC            fourCC;      /* four-character code identifying IOProc */
-    LPMMIOPROC	      pIOProc;     /* pointer to IProc */
-    enum mmioProcType type;        /* 16, 32A or 32W */
-    int		      count;	   /* number of objects linked to it */
-};
-
-/* This array will be the entire list for most apps */
+/* This array will be the entire list for most apps 
+ * Note that temporary ioProcs will be stored with a 0 fourCC code
+ */
 
 static struct IOProcList defaultProcs[] = {
     {&defaultProcs[1], FOURCC_DOS, (LPMMIOPROC)mmioDosIOProc, MMIO_PROC_32A, 0},
@@ -270,8 +254,8 @@
 /****************************************************************
  *       	MMIO_InstallIOProc 			[INTERNAL]
  */
-static LPMMIOPROC MMIO_InstallIOProc(FOURCC fccIOProc, LPMMIOPROC pIOProc,
-				     DWORD dwFlags, enum mmioProcType type)
+LPMMIOPROC MMIO_InstallIOProc(FOURCC fccIOProc, LPMMIOPROC pIOProc,
+                              DWORD dwFlags, enum mmioProcType type)
 {
     LPMMIOPROC	        lpProc = NULL;
     struct IOProcList*  pListNode;
@@ -305,13 +289,18 @@
 
     case MMIO_REMOVEPROC:
 	/*
-	 * Search for the node that we're trying to remove - note
-	 * that this method won't find the first item on the list, but
+	 * Search for the node that we're trying to remove
+         * We search for a matching fourCC code if it's non null, or the proc
+         * address otherwise
+         * note that this method won't find the first item on the list, but
 	 * since the first two items on this list are ones we won't
 	 * let the user delete anyway, that's okay
 	 */
 	ppListNode = &pIOProcListAnchor;
-	while ((*ppListNode) && (*ppListNode)->fourCC != fccIOProc)
+	while ((*ppListNode) && 
+               ((fccIOProc != 0) ? 
+                (*ppListNode)->fourCC != fccIOProc : 
+                (*ppListNode)->pIOProc != pIOProc))
 	    ppListNode = &((*ppListNode)->pNext);
 
 	if (*ppListNode) { /* found it */
@@ -347,125 +336,59 @@
 }
 
 /****************************************************************
- *       		MMIO_Map32To16			[INTERNAL]
- */
-static LRESULT	MMIO_Map32To16(DWORD wMsg, LPARAM* lp1, LPARAM* lp2)
-{
-    switch (wMsg) {
-    case MMIOM_CLOSE:
-    case MMIOM_SEEK:
-	/* nothing to do */
-	break;
-    case MMIOM_OPEN:
-    case MMIOM_READ:
-    case MMIOM_WRITE:
-    case MMIOM_WRITEFLUSH:
-        *lp1 = MapLS( (void *)*lp1 );
-	break;
-    default:
-	TRACE("Not a mappable message (%ld)\n", wMsg);
-    }
-    return MMSYSERR_NOERROR;
-}
-
-/****************************************************************
- *       	MMIO_UnMap32To16 			[INTERNAL]
+ *       	send_message    			[INTERNAL]
  */
-static LRESULT	MMIO_UnMap32To16(DWORD wMsg, LPARAM lParam1, LPARAM lParam2,
-				 LPARAM lp1, LPARAM lp2)
+static LRESULT	send_message(struct IOProcList* ioProc, LPMMIOINFO mmioinfo,
+                             DWORD wMsg, LPARAM lParam1,
+                             LPARAM lParam2, enum mmioProcType type)
 {
-    switch (wMsg) {
-    case MMIOM_CLOSE:
-    case MMIOM_SEEK:
-	/* nothing to do */
-	break;
-    case MMIOM_OPEN:
-    case MMIOM_READ:
-    case MMIOM_WRITE:
-    case MMIOM_WRITEFLUSH:
-        UnMapLS( lp1 );
-	break;
-    default:
-	TRACE("Not a mappable message (%ld)\n", wMsg);
-    }
-    return MMSYSERR_NOERROR;
-}
-
-/****************************************************************
- *       	MMIO_SendMessage			[INTERNAL]
- */
-static LRESULT	MMIO_SendMessage(LPWINE_MMIO wm, DWORD wMsg, LPARAM lParam1,
-				 LPARAM lParam2, enum mmioProcType type)
-{
-    MMIOINFO16 mmioInfo16;
-    LRESULT 		result;
-    SEGPTR		segmmioInfo16;
+    LRESULT 		result = MMSYSERR_ERROR;
     LPARAM		lp1 = lParam1, lp2 = lParam2;
 
-    if (!wm->ioProc || !wm->info.pIOProc) {
+    if (!ioProc) {
 	ERR("brrr\n");
 	result = MMSYSERR_INVALPARAM;
     }
 
-    switch (wm->ioProc->type) {
+    switch (ioProc->type) {
     case MMIO_PROC_16:
-        memset( &mmioInfo16, 0, sizeof(MMIOINFO16));
-        mmioInfo16.lDiskOffset = wm->info.lDiskOffset;
-        mmioInfo16.adwInfo[0]  = wm->info.adwInfo[0];
-        mmioInfo16.adwInfo[1]  = wm->info.adwInfo[1];
-        mmioInfo16.adwInfo[2]  = wm->info.adwInfo[2];
-        mmioInfo16.adwInfo[3]  = wm->info.adwInfo[3];
-	if (wm->ioProc->type != type) {
-	    /* map (lParam1, lParam2) into (lp1, lp2) 32=>16 */
-	    if ((result = MMIO_Map32To16(wMsg, &lp1, &lp2)) != MMSYSERR_NOERROR)
-		return result;
-	}
-	/* FIXME: is wm->info.pIOProc a segmented or a linear address ?
-	 * sounds to me it's a segmented one, should use a thunk somewhere
-	 */
-        segmmioInfo16 = MapLS( &mmioInfo16 );
-        result = ((LPMMIOPROC16)wm->info.pIOProc)((LPSTR)segmmioInfo16, wMsg, lp1, lp2);
-        UnMapLS( segmmioInfo16 );
-	if (wm->ioProc->type != type) {
-	    MMIO_UnMap32To16(wMsg, lParam1, lParam2, lp1, lp2);
-	}
-        wm->info.lDiskOffset = mmioInfo16.lDiskOffset;
-        wm->info.adwInfo[0]  = mmioInfo16.adwInfo[0];
-        wm->info.adwInfo[1]  = mmioInfo16.adwInfo[1];
-        wm->info.adwInfo[2]  = mmioInfo16.adwInfo[2];
-        wm->info.adwInfo[3]  = mmioInfo16.adwInfo[3];
-	break;
+        {
+            LPWINE_MM_IDATA iData = MULTIMEDIA_GetIData();
+            if (iData && iData->pFnMmioCallback16)
+                result = iData->pFnMmioCallback16((SEGPTR)ioProc->pIOProc,
+                                                  mmioinfo, wMsg, lp1, lp2);
+        }
+        break;
     case MMIO_PROC_32A:
     case MMIO_PROC_32W:
-	if (wm->ioProc->type != type) {
-	    /* map (lParam1, lParam2) into (lp1, lp2) 16=>32 */
-	    WARN("NIY\n");
+	if (ioProc->type != type) {
+	    /* map (lParam1, lParam2) into (lp1, lp2) 32 A<=>W */
+	    FIXME("NIY 32 A<=>W mapping\n");
 	}
-	result = (wm->info.pIOProc)((LPSTR)&wm->info, wMsg, lp1, lp2);
+	result = (ioProc->pIOProc)((LPSTR)mmioinfo, wMsg, lp1, lp2);
 
 #if 0
-	if (wm->ioProc->type != type) {
-	    /* unmap (lParam1, lParam2) into (lp1, lp2) 16=>32 */
+	if (ioProc->type != type) {
+	    /* unmap (lParam1, lParam2) into (lp1, lp2) 32 A<=>W */
 	}
 #endif
 	break;
     default:
 	FIXME("Internal error\n");
-	result = MMSYSERR_ERROR;
     }
 
     return result;
 }
 
 /**************************************************************************
- *      			MMIO_ParseExt 		        [internal]
+ *      			MMIO_ParseExtA 		        [internal]
  *
  * Parses a filename for the extension.
  *
  * RETURNS
  *  The FOURCC code for the extension if found, else 0.
  */
-static FOURCC MMIO_ParseExt(LPCSTR szFileName)
+static FOURCC MMIO_ParseExtA(LPCSTR szFileName)
 {
     /* Filenames are of the form file.ext+ABC
        FIXME: What if a '+' is part of the file name?
@@ -476,7 +399,7 @@
     /* Note that ext{Start,End} point to the . and + respectively */
     LPSTR extEnd;
 
-    TRACE("(%s)\n",debugstr_a(szFileName));
+    TRACE("(%s)\n", debugstr_a(szFileName));
 
     if (!szFileName)
 	return ret;
@@ -497,7 +420,7 @@
 
 	    if (extEnd - extStart - 1 > 4)
 		WARN("Extension length > 4\n");
-	    lstrcpynA(ext,extStart + 1,min(extEnd-extStart,5));
+	    lstrcpynA(ext, extStart + 1, min(extEnd-extStart,5));
 	    TRACE("Got extension: %s\n", debugstr_a(ext));
 	    /* FOURCC codes identifying file-extensions must be uppercase */
 	    ret = mmioStringToFOURCCA(ext, MMIO_TOUPPER);
@@ -511,7 +434,7 @@
  *
  * Retrieves the mmio object from current process
  */
-static	LPWINE_MMIO	MMIO_Get(LPWINE_MM_IDATA iData, HMMIO h)
+LPWINE_MMIO	MMIO_Get(LPWINE_MM_IDATA iData, HMMIO h)
 {
     LPWINE_MMIO		wm = NULL;
 
@@ -540,7 +463,8 @@
     wm = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WINE_MMIO));
     if (wm) {
 	EnterCriticalSection(&iData->cs);
-	while (MMIO_Get(iData, HMMIO_32(++MMIO_counter)));
+        /* lookup next unallocated WORD handle, with a non NULL value */
+	while (++MMIO_counter == 0 || MMIO_Get(iData, HMMIO_32(MMIO_counter)));
 	wm->info.hmmio = HMMIO_32(MMIO_counter);
 	wm->lpNext = iData->lpMMIO;
 	iData->lpMMIO = wm;
@@ -582,10 +506,11 @@
 	/* not quite sure what to do here, but I'll guess */
 	if (wm->info.dwFlags & MMIO_DIRTY) {
             /* FIXME: error handling */
-	    MMIO_SendMessage(wm, MMIOM_SEEK, wm->info.lBufOffset,
-			     SEEK_SET, MMIO_PROC_32A);
-	    MMIO_SendMessage(wm, MMIOM_WRITE, (LPARAM)wm->info.pchBuffer,
-			     wm->info.pchNext - wm->info.pchBuffer, MMIO_PROC_32A);
+	    send_message(wm->ioProc, &wm->info, MMIOM_SEEK, 
+                         wm->info.lBufOffset, SEEK_SET, MMIO_PROC_32A);
+	    send_message(wm->ioProc, &wm->info, MMIOM_WRITE, 
+                         (LPARAM)wm->info.pchBuffer,
+                         wm->info.pchNext - wm->info.pchBuffer, MMIO_PROC_32A);
 	}
 	if (uFlags & MMIO_EMPTYBUF)
 	    wm->info.pchNext = wm->info.pchEndRead = wm->info.pchBuffer;
@@ -604,7 +529,7 @@
 
     TRACE("bo=%lx do=%lx of=%lx\n",
 	  wm->info.lBufOffset, wm->info.lDiskOffset,
-	  MMIO_SendMessage(wm, MMIOM_SEEK, 0, SEEK_CUR, MMIO_PROC_32A));
+	  send_message(wm->ioProc, &wm->info, MMIOM_SEEK, 0, SEEK_CUR, MMIO_PROC_32A));
 
     wm->info.lBufOffset = wm->info.lDiskOffset;
     wm->info.pchNext = wm->info.pchBuffer;
@@ -612,8 +537,8 @@
     wm->info.pchEndWrite = wm->info.pchBuffer + wm->info.cchBuffer;
 
     if (for_read) {
-	size = MMIO_SendMessage(wm, MMIOM_READ, (LPARAM)wm->info.pchBuffer,
-				size, MMIO_PROC_32A);
+	size = send_message(wm->ioProc, &wm->info, MMIOM_READ, 
+                            (LPARAM)wm->info.pchBuffer, size, MMIO_PROC_32A);
 	if (size > 0)
 	    wm->info.pchEndRead += size;
     }
@@ -626,9 +551,9 @@
  *       		MMIO_SetBuffer 				[INTERNAL]
  */
 static MMRESULT MMIO_SetBuffer(WINE_MMIO* wm, void* pchBuffer, LONG cchBuffer,
-			       UINT uFlags, BOOL bFrom32)
+			       UINT uFlags)
 {
-    TRACE("(%p %p %ld %u %d)\n", wm, pchBuffer, cchBuffer, uFlags, bFrom32);
+    TRACE("(%p %p %ld %u)\n", wm, pchBuffer, cchBuffer, uFlags);
 
     if (uFlags)			return MMSYSERR_INVALPARAM;
     if (cchBuffer > 0xFFFF)
@@ -637,36 +562,32 @@
     if (MMIO_Flush(wm, 0) != MMSYSERR_NOERROR)
 	return MMIOERR_CANNOTWRITE;
 
-    if (wm->hMem && (wm->info.dwFlags & MMIO_ALLOCBUF)) {
-	GlobalUnlock16(wm->hMem);
-	GlobalFree16(wm->hMem);
-	wm->hMem = 0;
+    /* free previous buffer if allocated */
+    if (wm->info.dwFlags & MMIO_ALLOCBUF) {
+        HeapFree(GetProcessHeap(), 0, wm->info.pchBuffer);
+        wm->info.pchBuffer = NULL;
 	wm->info.dwFlags &= ~MMIO_ALLOCBUF;
     }
 
+    /* free segmented ptr mapping, if any */
+    if (wm->info.dwReserved1 != 0L)
+    {
+        UnMapLS(wm->info.dwReserved1);
+        wm->info.dwReserved1 = 0L;
+    }
+
     if (pchBuffer) {
-	if (bFrom32) {
-	    wm->info.pchBuffer = pchBuffer;
-	    wm->buffer16 = 0;
-	} else {
-	    wm->info.pchBuffer = MapSL((SEGPTR)pchBuffer);
-	    wm->buffer16 = (SEGPTR)pchBuffer;
-	}
-	wm->hMem = 0;
+        wm->info.pchBuffer = pchBuffer;
     } else if (cchBuffer) {
-	if (!(wm->hMem = GlobalAlloc16(GMEM_MOVEABLE, cchBuffer)))
+	if (!(wm->info.pchBuffer = HeapAlloc(GetProcessHeap(), 0, cchBuffer)))
 	    return MMIOERR_OUTOFMEMORY;
 	wm->info.dwFlags |= MMIO_ALLOCBUF;
     } else {
 	wm->info.pchBuffer = NULL;
-	wm->hMem = 0;
-	wm->buffer16 = 0;
     }
 
-    if (wm->hMem) {
-	wm->buffer16 = K32WOWGlobalLock16(wm->hMem);
-	wm->info.pchBuffer = MapSL(wm->buffer16);
-    }
+    if (wm->ioProc->type == MMIO_PROC_16)
+        wm->info.dwReserved1 = MapLS(wm->info.pchBuffer);
 
     wm->info.cchBuffer = cchBuffer;
     wm->info.pchNext = wm->info.pchBuffer;
@@ -679,15 +600,26 @@
 }
 
 /**************************************************************************
- * 			MMIO_Open      				[internal]
+ * 			MMIO_Open       			[internal]
  */
-static HMMIO MMIO_Open(LPSTR szFileName, MMIOINFO* refmminfo,
-		       DWORD dwOpenFlags, enum mmioProcType type)
+HMMIO MMIO_Open(LPSTR szFileName, MMIOINFO* refmminfo, DWORD dwOpenFlags, 
+                enum mmioProcType type)
 {
     LPWINE_MMIO		wm;
+    MMIOINFO    	mmioinfo;
 
     TRACE("('%s', %p, %08lX, %d);\n", szFileName, refmminfo, dwOpenFlags, type);
 
+    if (!refmminfo) {
+        refmminfo = &mmioinfo;
+
+	mmioinfo.fccIOProc = 0;
+	mmioinfo.pIOProc = NULL;
+	mmioinfo.pchBuffer = NULL;
+	mmioinfo.cchBuffer = 0;
+        type = MMIO_PROC_32A;
+    }
+
     if (dwOpenFlags & (MMIO_PARSE|MMIO_EXIST)) {
 	char	buffer[MAX_PATH];
 
@@ -704,30 +636,26 @@
 
     /* If both params are NULL, then parse the file name if available */
     if (refmminfo->fccIOProc == 0 && refmminfo->pIOProc == NULL) {
-	wm->info.fccIOProc = MMIO_ParseExt(szFileName);
+	wm->info.fccIOProc = MMIO_ParseExtA(szFileName);
 	/* Handle any unhandled/error case. Assume DOS file */
 	if (wm->info.fccIOProc == 0)
 	    wm->info.fccIOProc = FOURCC_DOS;
 	if (!(wm->ioProc = MMIO_FindProcNode(wm->info.fccIOProc))) goto error2;
-	wm->info.pIOProc = wm->ioProc->pIOProc;
 	wm->bTmpIOProc = FALSE;
     }
     /* if just the four character code is present, look up IO proc */
     else if (refmminfo->pIOProc == NULL) {
 	wm->info.fccIOProc = refmminfo->fccIOProc;
 	if (!(wm->ioProc = MMIO_FindProcNode(wm->info.fccIOProc))) goto error2;
-	wm->info.pIOProc = wm->ioProc->pIOProc;
 	wm->bTmpIOProc = FALSE;
     }
     /* if IO proc specified, use it and specified four character code */
     else {
 	wm->info.fccIOProc = refmminfo->fccIOProc;
-	wm->info.pIOProc = refmminfo->pIOProc;
-	MMIO_InstallIOProc(wm->info.fccIOProc, wm->info.pIOProc,
-			   MMIO_INSTALLPROC, type);
+	MMIO_InstallIOProc(wm->info.fccIOProc, refmminfo->pIOProc,
+                           MMIO_INSTALLPROC, type);
 	if (!(wm->ioProc = MMIO_FindProcNode(wm->info.fccIOProc))) goto error2;
 	assert(wm->ioProc->pIOProc == refmminfo->pIOProc);
-	wm->info.pIOProc = wm->ioProc->pIOProc;
 	wm->bTmpIOProc = TRUE;
     }
 
@@ -735,13 +663,10 @@
     wm->ioProc->count++;
 
     if (dwOpenFlags & MMIO_ALLOCBUF) {
-	if ((refmminfo->wErrorRet = MMIO_SetBuffer(wm, NULL, MMIO_DEFAULTBUFFER, 0,
-                                                   type != MMIO_PROC_16)))
+	if ((refmminfo->wErrorRet = MMIO_SetBuffer(wm, NULL, MMIO_DEFAULTBUFFER, 0)))
 	    goto error1;
     } else if (wm->info.fccIOProc == FOURCC_MEM) {
-	refmminfo->wErrorRet = MMIO_SetBuffer(wm, refmminfo->pchBuffer,
-					      refmminfo->cchBuffer, 0,
-					      type != MMIO_PROC_16);
+        refmminfo->wErrorRet = MMIO_SetBuffer(wm, refmminfo->pchBuffer, refmminfo->cchBuffer, 0);
 	if (refmminfo->wErrorRet != MMSYSERR_NOERROR)
 	    goto error1;
 	wm->bBufferLoaded = TRUE;
@@ -752,8 +677,8 @@
     wm->info.dwFlags = dwOpenFlags;
 
     /* call IO proc to actually open file */
-    refmminfo->wErrorRet = MMIO_SendMessage(wm, MMIOM_OPEN, (LPARAM)szFileName,
-                                            type == MMIO_PROC_16, MMIO_PROC_32A);
+    refmminfo->wErrorRet = send_message(wm->ioProc, &wm->info, MMIOM_OPEN, 
+                                        (LPARAM)szFileName, 0, MMIO_PROC_32A);
 
     /* grab file size, when possible */
     wm->dwFileSize = GetFileSize(wm->info.adwInfo[0], NULL);
@@ -776,18 +701,7 @@
     HMMIO 	ret;
     LPSTR	szFn = HEAP_strdupWtoA(GetProcessHeap(), 0, szFileName);
 
-    if (lpmmioinfo) {
-	ret = MMIO_Open(szFn, lpmmioinfo, dwOpenFlags, MMIO_PROC_32W);
-    } else {
-	MMIOINFO	mmioinfo;
-
-	mmioinfo.fccIOProc = 0;
-	mmioinfo.pIOProc = NULL;
-	mmioinfo.pchBuffer = NULL;
-	mmioinfo.cchBuffer = 0;
-
-	ret = MMIO_Open(szFn, &mmioinfo, dwOpenFlags, MMIO_PROC_32W);
-    }
+    ret = MMIO_Open(szFn, lpmmioinfo, dwOpenFlags, MMIO_PROC_32W);
 
     HeapFree(GetProcessHeap(), 0, szFn);
     return ret;
@@ -799,63 +713,10 @@
 HMMIO WINAPI mmioOpenA(LPSTR szFileName, MMIOINFO* lpmmioinfo,
 		       DWORD dwOpenFlags)
 {
-    HMMIO 	ret;
-
-    if (lpmmioinfo) {
-	ret = MMIO_Open(szFileName, lpmmioinfo, dwOpenFlags, MMIO_PROC_32A);
-    } else {
-	MMIOINFO	mmioinfo;
-
-	mmioinfo.fccIOProc = 0;
-	mmioinfo.pIOProc = NULL;
-	mmioinfo.pchBuffer = NULL;
-	mmioinfo.cchBuffer = 0;
-
-	ret = MMIO_Open(szFileName, &mmioinfo, dwOpenFlags, MMIO_PROC_32A);
-    }
-    return ret;
+    return  MMIO_Open(szFileName, lpmmioinfo, dwOpenFlags, MMIO_PROC_32A);
 }
 
 /**************************************************************************
- * 				mmioOpen       		[MMSYSTEM.1210]
- */
-HMMIO16 WINAPI mmioOpen16(LPSTR szFileName, MMIOINFO16* lpmmioinfo16,
-			  DWORD dwOpenFlags)
-{
-    HMMIO 	ret;
-    MMIOINFO	mmio;
-
-    if (lpmmioinfo16) {
-	MMIOINFO	mmioinfo;
-
-	memset(&mmioinfo, 0, sizeof(mmioinfo));
-
-	mmioinfo.dwFlags     = lpmmioinfo16->dwFlags;
-	mmioinfo.fccIOProc   = lpmmioinfo16->fccIOProc;
-	mmioinfo.pIOProc     = (LPMMIOPROC)lpmmioinfo16->pIOProc;
-	mmioinfo.cchBuffer   = lpmmioinfo16->cchBuffer;
-	mmioinfo.pchBuffer   = lpmmioinfo16->pchBuffer;
-	mmioinfo.adwInfo[0]  = lpmmioinfo16->adwInfo[0];
-	mmioinfo.adwInfo[1]  = lpmmioinfo16->adwInfo[1];
-	mmioinfo.adwInfo[2]  = lpmmioinfo16->adwInfo[2];
-	mmioinfo.adwInfo[3]  = lpmmioinfo16->adwInfo[3];
-
-	ret = MMIO_Open(szFileName, &mmioinfo, dwOpenFlags, MMIO_PROC_16);
-
-	mmioGetInfo16(HMMIO_16(mmioinfo.hmmio), lpmmioinfo16, 0);
-	lpmmioinfo16->wErrorRet = HMMIO_16(ret);
-    } else {
-	mmio.fccIOProc = 0;
-	mmio.pIOProc = NULL;
-	mmio.pchBuffer = NULL;
-	mmio.cchBuffer = 0;
-	ret = MMIO_Open(szFileName, &mmio, dwOpenFlags, FALSE);
-    }
-    return HMMIO_16(ret);
-}
-
-
-/**************************************************************************
  * 				mmioClose      		[WINMM.@]
  */
 MMRESULT WINAPI mmioClose(HMMIO hmmio, UINT uFlags)
@@ -871,15 +732,16 @@
     if ((result = MMIO_Flush(wm, 0)) != MMSYSERR_NOERROR)
 	return result;
 
-    result = MMIO_SendMessage(wm, MMIOM_CLOSE, uFlags, 0, MMIO_PROC_32A);
+    result = send_message(wm->ioProc, &wm->info, MMIOM_CLOSE, 
+                          uFlags, 0, MMIO_PROC_32A);
 
-    MMIO_SetBuffer(wm, NULL, 0, 0, TRUE);
+    MMIO_SetBuffer(wm, NULL, 0, 0);
 
     wm->ioProc->count--;
 
     if (wm->bTmpIOProc)
-	MMIO_InstallIOProc(wm->info.fccIOProc, NULL,
-			   MMIO_REMOVEPROC, wm->ioProc->type);
+	MMIO_InstallIOProc(wm->info.fccIOProc, wm->ioProc->pIOProc,
+                           MMIO_REMOVEPROC, wm->ioProc->type);
 
     MMIO_Destroy(wm);
 
@@ -887,14 +749,6 @@
 }
 
 /**************************************************************************
- * 				mmioClose      		[MMSYSTEM.1211]
- */
-MMRESULT16 WINAPI mmioClose16(HMMIO16 hmmio, UINT16 uFlags)
-{
-    return mmioClose(HMMIO_32(hmmio), uFlags);
-}
-
-/**************************************************************************
  * 				mmioRead	       	[WINMM.@]
  */
 LONG WINAPI mmioRead(HMMIO hmmio, HPSTR pch, LONG cch)
@@ -909,7 +763,8 @@
 
     /* unbuffered case first */
     if (!wm->info.pchBuffer)
-	return MMIO_SendMessage(wm, MMIOM_READ, (LPARAM)pch, cch, MMIO_PROC_32A);
+	return send_message(wm->ioProc, &wm->info, MMIOM_READ, 
+                            (LPARAM)pch, cch, MMIO_PROC_32A);
 
     /* first try from current buffer */
     if (wm->info.pchNext != wm->info.pchEndRead) {
@@ -944,14 +799,6 @@
 }
 
 /**************************************************************************
- * 				mmioRead	       	[MMSYSTEM.1212]
- */
-LONG WINAPI mmioRead16(HMMIO16 hmmio, HPSTR pch, LONG cch)
-{
-    return mmioRead(HMMIO_32(hmmio), pch, cch);
-}
-
-/**************************************************************************
  * 				mmioWrite      		[WINMM.@]
  */
 LONG WINAPI mmioWrite(HMMIO hmmio, HPCSTR pch, LONG cch)
@@ -997,7 +844,8 @@
         }
 	count = bytesW;
     } else {
-	count = MMIO_SendMessage(wm, MMIOM_WRITE, (LPARAM)pch, cch, MMIO_PROC_32A);
+	count = send_message(wm->ioProc, &wm->info, MMIOM_WRITE, 
+                             (LPARAM)pch, cch, MMIO_PROC_32A);
 	wm->info.lBufOffset = wm->info.lDiskOffset;
     }
 
@@ -1006,14 +854,6 @@
 }
 
 /**************************************************************************
- * 				mmioWrite      		[MMSYSTEM.1213]
- */
-LONG WINAPI mmioWrite16(HMMIO16 hmmio, HPCSTR pch, LONG cch)
-{
-    return mmioWrite(HMMIO_32(hmmio),pch,cch);
-}
-
-/**************************************************************************
  * 				mmioSeek		[WINMM.@]
  */
 LONG WINAPI mmioSeek(HMMIO hmmio, LONG lOffset, INT iOrigin)
@@ -1028,7 +868,8 @@
 
     /* not buffered, direct seek on file */
     if (!wm->info.pchBuffer)
-	return MMIO_SendMessage(wm, MMIOM_SEEK, lOffset, iOrigin, MMIO_PROC_32A);
+	return send_message(wm->ioProc, &wm->info, MMIOM_SEEK, 
+                            lOffset, iOrigin, MMIO_PROC_32A);
 
     switch (iOrigin) {
     case SEEK_SET:
@@ -1065,9 +906,9 @@
 	if ((wm->info.fccIOProc == FOURCC_MEM) ||
 	    MMIO_Flush(wm, 0) != MMSYSERR_NOERROR ||
 	    /* this also sets the wm->info.lDiskOffset field */
-	    MMIO_SendMessage(wm, MMIOM_SEEK,
-			     (offset / wm->info.cchBuffer) * wm->info.cchBuffer,
-			     SEEK_SET, MMIO_PROC_32A) == -1)
+	    send_message(wm->ioProc, &wm->info, MMIOM_SEEK,
+                         (offset / wm->info.cchBuffer) * wm->info.cchBuffer,
+                         SEEK_SET, MMIO_PROC_32A) == -1)
 	    return -1;
 	MMIO_GrabNextBuffer(wm, TRUE);
     }
@@ -1079,52 +920,6 @@
 }
 
 /**************************************************************************
- * 				mmioSeek       		[MMSYSTEM.1214]
- */
-LONG WINAPI mmioSeek16(HMMIO16 hmmio, LONG lOffset, INT16 iOrigin)
-{
-    return mmioSeek(HMMIO_32(hmmio), lOffset, iOrigin);
-}
-
-/**************************************************************************
- * 				mmioGetInfo	       	[MMSYSTEM.1215]
- */
-MMRESULT16 WINAPI mmioGetInfo16(HMMIO16 hmmio, MMIOINFO16* lpmmioinfo, UINT16 uFlags)
-{
-    LPWINE_MMIO	wm;
-
-    TRACE("(0x%04x,%p,0x%08x)\n",hmmio,lpmmioinfo,uFlags);
-
-    if ((wm = MMIO_Get(NULL, HMMIO_32(hmmio))) == NULL)
-	return MMSYSERR_INVALHANDLE;
-
-    if (!wm->buffer16)
-	return MMSYSERR_ERROR;
-
-    lpmmioinfo->dwFlags     = wm->info.dwFlags;
-    lpmmioinfo->fccIOProc   = wm->info.fccIOProc;
-    lpmmioinfo->pIOProc     = (LPMMIOPROC16)wm->info.pIOProc;
-    lpmmioinfo->wErrorRet   = wm->info.wErrorRet;
-    lpmmioinfo->hTask       = wm->info.hTask;
-    lpmmioinfo->cchBuffer   = wm->info.cchBuffer;
-    lpmmioinfo->pchBuffer   = (void*)wm->buffer16;
-    lpmmioinfo->pchNext     = (void*)(wm->buffer16 + (wm->info.pchNext - wm->info.pchBuffer));
-    lpmmioinfo->pchEndRead  = (void*)(wm->buffer16 + (wm->info.pchEndRead - wm->info.pchBuffer));
-    lpmmioinfo->pchEndWrite = (void*)(wm->buffer16 + (wm->info.pchEndWrite - wm->info.pchBuffer));
-    lpmmioinfo->lBufOffset  = wm->info.lBufOffset;
-    lpmmioinfo->lDiskOffset = wm->info.lDiskOffset;
-    lpmmioinfo->adwInfo[0]  = wm->info.adwInfo[0];
-    lpmmioinfo->adwInfo[1]  = wm->info.adwInfo[1];
-    lpmmioinfo->adwInfo[2]  = wm->info.adwInfo[2];
-    lpmmioinfo->adwInfo[3]  = wm->info.adwInfo[3];
-    lpmmioinfo->dwReserved1 = 0;
-    lpmmioinfo->dwReserved2 = 0;
-    lpmmioinfo->hmmio = HMMIO_16(wm->info.hmmio);
-
-    return MMSYSERR_NOERROR;
-}
-
-/**************************************************************************
  * 				mmioGetInfo	       	[WINMM.@]
  */
 MMRESULT WINAPI mmioGetInfo(HMMIO hmmio, MMIOINFO* lpmmioinfo, UINT uFlags)
@@ -1137,39 +932,9 @@
 	return MMSYSERR_INVALHANDLE;
 
     memcpy(lpmmioinfo, &wm->info, sizeof(MMIOINFO));
-
-    return MMSYSERR_NOERROR;
-}
-
-/**************************************************************************
- * 				mmioSetInfo  		[MMSYSTEM.1216]
- */
-MMRESULT16 WINAPI mmioSetInfo16(HMMIO16 hmmio, const MMIOINFO16* lpmmioinfo, UINT16 uFlags)
-{
-    LPWINE_MMIO		wm;
-
-    TRACE("(0x%04x,%p,0x%08x)\n",hmmio,lpmmioinfo,uFlags);
-
-    if ((wm = MMIO_Get(NULL, HMMIO_32(hmmio))) == NULL)
-	return MMSYSERR_INVALHANDLE;
-
-    /* check if seg and lin buffers are the same */
-    if (wm->info.cchBuffer != lpmmioinfo->cchBuffer ||
-	wm->info.pchBuffer != MapSL(wm->buffer16))
-	return MMSYSERR_INVALPARAM;
-
-    /* check pointers coherence */
-    if (lpmmioinfo->pchNext < lpmmioinfo->pchBuffer ||
-	lpmmioinfo->pchNext > lpmmioinfo->pchBuffer + lpmmioinfo->cchBuffer ||
-	lpmmioinfo->pchEndRead < lpmmioinfo->pchBuffer ||
-	lpmmioinfo->pchEndRead > lpmmioinfo->pchBuffer + lpmmioinfo->cchBuffer ||
-	lpmmioinfo->pchEndWrite < lpmmioinfo->pchBuffer ||
-	lpmmioinfo->pchEndWrite > lpmmioinfo->pchBuffer + lpmmioinfo->cchBuffer)
-	return MMSYSERR_INVALPARAM;
-
-    wm->info.pchNext     = wm->info.pchBuffer + (lpmmioinfo->pchNext     - lpmmioinfo->pchBuffer);
-    wm->info.pchEndRead  = wm->info.pchBuffer + (lpmmioinfo->pchEndRead  - lpmmioinfo->pchBuffer);
-    wm->info.pchEndWrite = wm->info.pchBuffer + (lpmmioinfo->pchEndWrite - lpmmioinfo->pchBuffer);
+    /* don't expose 16 bit ioproc:s */
+    if (wm->ioProc->type != MMIO_PROC_16)
+        lpmmioinfo->pIOProc = wm->ioProc->pIOProc;
 
     return MMSYSERR_NOERROR;
 }
@@ -1214,24 +979,7 @@
     if ((wm = MMIO_Get(NULL, hmmio)) == NULL)
 	return MMSYSERR_INVALHANDLE;
 
-    return MMIO_SetBuffer(wm, pchBuffer, cchBuffer, uFlags, TRUE);
-}
-
-/**************************************************************************
- * 				mmioSetBuffer		[MMSYSTEM.1217]
- */
-MMRESULT16 WINAPI mmioSetBuffer16(HMMIO16 hmmio, LPSTR segpchBuffer,
-                                  LONG cchBuffer, UINT16 uFlags)
-{
-    LPWINE_MMIO		wm;
-
-    TRACE("(hmmio=%04x, segpchBuf=%p, cchBuf=%ld, uFlags=%#08x)\n",
-	  hmmio, segpchBuffer, cchBuffer, uFlags);
-
-    if ((wm = MMIO_Get(NULL, HMMIO_32(hmmio))) == NULL)
-	return MMSYSERR_INVALHANDLE;
-
-    return MMIO_SetBuffer(wm, segpchBuffer, cchBuffer, uFlags, FALSE);
+    return MMIO_SetBuffer(wm, pchBuffer, cchBuffer, uFlags);
 }
 
 /**************************************************************************
@@ -1250,14 +998,6 @@
 }
 
 /**************************************************************************
- * 				mmioFlush      		[MMSYSTEM.1218]
- */
-MMRESULT16 WINAPI mmioFlush16(HMMIO16 hmmio, UINT16 uFlags)
-{
-    return mmioFlush(HMMIO_32(hmmio), uFlags);
-}
-
-/**************************************************************************
  * 				mmioAdvance      	[WINMM.@]
  */
 MMRESULT WINAPI mmioAdvance(HMMIO hmmio, MMIOINFO* lpmmioinfo, UINT uFlags)
@@ -1266,6 +1006,9 @@
 
     TRACE("hmmio=%04X, lpmmioinfo=%p, uFlags=%04X\n", hmmio, lpmmioinfo, uFlags);
 
+    /* NOTE: mmioAdvance16 heavily relies on parameters from lpmmioinfo we're using
+     * here. be sure if you change something here to check mmioAdvance16 as well
+     */
     if ((wm = MMIO_Get(NULL, hmmio)) == NULL)
 	return MMSYSERR_INVALHANDLE;
 
@@ -1277,16 +1020,19 @@
 
     if (uFlags == MMIO_WRITE && (lpmmioinfo->dwFlags & MMIO_DIRTY))
     {
-        MMIO_SendMessage(wm, MMIOM_SEEK, lpmmioinfo->lBufOffset, SEEK_SET, MMIO_PROC_32A);
-        MMIO_SendMessage(wm, MMIOM_WRITE, (LPARAM)lpmmioinfo->pchBuffer,
-                         lpmmioinfo->pchNext - lpmmioinfo->pchBuffer, MMIO_PROC_32A);
+        send_message(wm->ioProc, &wm->info, MMIOM_SEEK, 
+                     lpmmioinfo->lBufOffset, SEEK_SET, MMIO_PROC_32A);
+        send_message(wm->ioProc, &wm->info, MMIOM_WRITE, 
+                     (LPARAM)lpmmioinfo->pchBuffer,
+                     lpmmioinfo->pchNext - lpmmioinfo->pchBuffer, MMIO_PROC_32A);
         lpmmioinfo->dwFlags &= ~MMIO_DIRTY;
     }
     if (MMIO_Flush(wm, 0) != MMSYSERR_NOERROR)
 	return MMIOERR_CANNOTWRITE;
 
     if (lpmmioinfo) {
-	wm->dwFileSize = max(wm->dwFileSize, lpmmioinfo->lBufOffset + (lpmmioinfo->pchNext - lpmmioinfo->pchBuffer));
+	wm->dwFileSize = max(wm->dwFileSize, lpmmioinfo->lBufOffset + 
+                             (lpmmioinfo->pchNext - lpmmioinfo->pchBuffer));
     }
     MMIO_GrabNextBuffer(wm, uFlags == MMIO_READ);
 
@@ -1302,40 +1048,6 @@
     return MMSYSERR_NOERROR;
 }
 
-/***********************************************************************
- * 				mmioAdvance    		[MMSYSTEM.1219]
- */
-MMRESULT16 WINAPI mmioAdvance16(HMMIO16 hmmio, MMIOINFO16* lpmmioinfo, UINT16 uFlags)
-{
-    LPWINE_MMIO		wm;
-
-    TRACE("hmmio=%04X, lpmmioinfo=%p, uFlags=%04X\n", hmmio, lpmmioinfo, uFlags);
-
-    if ((wm = MMIO_Get(NULL, HMMIO_32(hmmio))) == NULL)
-	return MMSYSERR_INVALHANDLE;
-
-    if (!wm->info.cchBuffer)
-	return MMIOERR_UNBUFFERED;
-
-    if (uFlags != MMIO_READ && uFlags != MMIO_WRITE)
-	return MMSYSERR_INVALPARAM;
-
-    if (MMIO_Flush(wm, 0) != MMSYSERR_NOERROR)
-	return MMIOERR_CANNOTWRITE;
-
-    MMIO_GrabNextBuffer(wm, uFlags == MMIO_READ);
-
-    lpmmioinfo->pchNext = lpmmioinfo->pchBuffer;
-    lpmmioinfo->pchEndRead  = lpmmioinfo->pchBuffer +
-	(wm->info.pchEndRead - wm->info.pchBuffer);
-    lpmmioinfo->pchEndWrite = lpmmioinfo->pchBuffer +
-	(wm->info.pchEndWrite - wm->info.pchBuffer);
-    lpmmioinfo->lDiskOffset = wm->info.lDiskOffset;
-    lpmmioinfo->lBufOffset = wm->info.lBufOffset;
-
-    return MMSYSERR_NOERROR;
-}
-
 /**************************************************************************
  * 				mmioStringToFOURCCA	[WINMM.@]
  */
@@ -1372,24 +1084,6 @@
 }
 
 /**************************************************************************
- * 				mmioStringToFOURCC	[MMSYSTEM.1220]
- */
-FOURCC WINAPI mmioStringToFOURCC16(LPCSTR sz, UINT16 uFlags)
-{
-    return mmioStringToFOURCCA(sz, uFlags);
-}
-
-/**************************************************************************
- *              mmioInstallIOProc    [MMSYSTEM.1221]
- */
-LPMMIOPROC16 WINAPI mmioInstallIOProc16(FOURCC fccIOProc, LPMMIOPROC16 pIOProc,
-                                        DWORD dwFlags)
-{
-    return (LPMMIOPROC16)MMIO_InstallIOProc(fccIOProc, (LPMMIOPROC)pIOProc,
-					    dwFlags, MMIO_PROC_16);
-}
-
-/**************************************************************************
  * 				mmioInstallIOProcA	   [WINMM.@]
  */
 LPMMIOPROC WINAPI mmioInstallIOProcA(FOURCC fccIOProc,
@@ -1407,23 +1101,25 @@
     return MMIO_InstallIOProc(fccIOProc, pIOProc, dwFlags, MMIO_PROC_32W);
 }
 
-/**************************************************************************
- * 				mmioSendMessage	[MMSYSTEM.1222]
+/******************************************************************
+ *		MMIO_SendMessage
+ *
+ *
  */
-LRESULT WINAPI mmioSendMessage16(HMMIO16 hmmio, UINT16 uMessage,
-				 LPARAM lParam1, LPARAM lParam2)
+LRESULT         MMIO_SendMessage(HMMIO hmmio, UINT uMessage, LPARAM lParam1, 
+                                 LPARAM lParam2, enum mmioProcType type)
 {
     LPWINE_MMIO		wm;
 
-    TRACE("(%04X, %u, %ld, %ld)\n", hmmio, uMessage, lParam1, lParam2);
+    TRACE("(%04X, %u, %ld, %ld, %d)\n", hmmio, uMessage, lParam1, lParam2, type);
 
     if (uMessage < MMIOM_USER)
 	return MMSYSERR_INVALPARAM;
 
-    if ((wm = MMIO_Get(NULL, HMMIO_32(hmmio))) == NULL)
+    if ((wm = MMIO_Get(NULL, hmmio)) == NULL)
 	return MMSYSERR_INVALHANDLE;
 
-    return MMIO_SendMessage(wm, uMessage, lParam1, lParam2, MMIO_PROC_16);
+    return send_message(wm->ioProc, &wm->info, uMessage, lParam1, lParam2, type);
 }
 
 /**************************************************************************
@@ -1432,17 +1128,7 @@
 LRESULT WINAPI mmioSendMessage(HMMIO hmmio, UINT uMessage,
 			       LPARAM lParam1, LPARAM lParam2)
 {
-    LPWINE_MMIO		wm;
-
-    TRACE("(%04X, %u, %ld, %ld)\n", hmmio, uMessage, lParam1, lParam2);
-
-    if (uMessage < MMIOM_USER)
-	return MMSYSERR_INVALPARAM;
-
-    if ((wm = MMIO_Get(NULL, hmmio)) == NULL)
-	return MMSYSERR_INVALHANDLE;
-
-    return MMIO_SendMessage(wm, uMessage, lParam1, lParam2, MMIO_PROC_32A);
+    return MMIO_SendMessage(hmmio, uMessage, lParam1, lParam2, MMIO_PROC_32A);
 }
 
 /**************************************************************************
@@ -1550,15 +1236,6 @@
 }
 
 /**************************************************************************
- * 				mmioDescend	       	[MMSYSTEM.1223]
- */
-MMRESULT16 WINAPI mmioDescend16(HMMIO16 hmmio, LPMMCKINFO lpck,
-                                const MMCKINFO* lpckParent, UINT16 uFlags)
-{
-    return mmioDescend(HMMIO_32(hmmio), lpck, lpckParent, uFlags);
-}
-
-/**************************************************************************
  * 				mmioAscend     		[WINMM.@]
  */
 MMRESULT WINAPI mmioAscend(HMMIO hmmio, LPMMCKINFO lpck, UINT uFlags)
@@ -1593,14 +1270,6 @@
 }
 
 /**************************************************************************
- * 				mmioAscend     		[MMSYSTEM.1224]
- */
-MMRESULT16 WINAPI mmioAscend16(HMMIO16 hmmio, MMCKINFO* lpck, UINT16 uFlags)
-{
-    return mmioAscend(HMMIO_32(hmmio),lpck,uFlags);
-}
-
-/**************************************************************************
  * 			mmioCreateChunk				[WINMM.@]
  */
 MMRESULT WINAPI mmioCreateChunk(HMMIO hmmio, MMCKINFO* lpck, UINT uFlags)
@@ -1640,93 +1309,52 @@
 }
 
 /**************************************************************************
- * 				mmioCreateChunk		[MMSYSTEM.1225]
- */
-MMRESULT16 WINAPI mmioCreateChunk16(HMMIO16 hmmio, MMCKINFO* lpck, UINT16 uFlags)
-{
-    return mmioCreateChunk(HMMIO_32(hmmio), lpck, uFlags);
-}
-
-/**************************************************************************
- * 				mmioRename     		[MMSYSTEM.1226]
- */
-MMRESULT16 WINAPI mmioRename16(LPCSTR szFileName, LPCSTR szNewFileName,
-                               MMIOINFO16* lpmmioinfo, DWORD dwRenameFlags)
-{
-    UINT16 		result = MMSYSERR_ERROR;
-    LPMMIOPROC16	ioProc;
-
-    TRACE("('%s', '%s', %p, %08lX);\n",
-	  szFileName, szNewFileName, lpmmioinfo, dwRenameFlags);
-
-    /* If both params are NULL, then parse the file name */
-    if (lpmmioinfo && lpmmioinfo->fccIOProc == 0 && lpmmioinfo->pIOProc == NULL)
-	lpmmioinfo->fccIOProc = MMIO_ParseExt(szFileName);
-
-    /* Handle any unhandled/error case from above. Assume DOS file */
-    if (!lpmmioinfo || (lpmmioinfo->fccIOProc == 0 && lpmmioinfo->pIOProc == NULL))
-	ioProc = (LPMMIOPROC16)mmioDosIOProc;
-    /* if just the four character code is present, look up IO proc */
-    else if (lpmmioinfo->pIOProc == NULL)
-	ioProc = mmioInstallIOProc16(lpmmioinfo->fccIOProc, NULL, MMIO_FINDPROC);
-    else
- 	ioProc = lpmmioinfo->pIOProc;
-
-    /* FIXME: ioProc is likely a segmented address, thus needing a
-     * thunk somewhere. The main issue is that Wine's current thunking
-     * 32 to 16 only supports pascal calling convention
-     */
-    if (ioProc)
-	result = (ioProc)(0, MMIOM_RENAME,
-			  (LPARAM)szFileName, (LPARAM)szNewFileName);
-
-    return result;
-}
-
-/**************************************************************************
  * 				mmioRenameA    			[WINMM.@]
  */
 MMRESULT WINAPI mmioRenameA(LPCSTR szFileName, LPCSTR szNewFileName,
-                            MMIOINFO* lpmmioinfo, DWORD dwRenameFlags)
+                            MMIOINFO* lpmmioinfo, DWORD dwFlags)
 {
-    UINT	result = MMSYSERR_ERROR;
-    LPMMIOPROC	ioProc;
+    struct IOProcList*  ioProc = NULL;
+    struct IOProcList   tmp;
 
     TRACE("('%s', '%s', %p, %08lX);\n",
-	  szFileName, szNewFileName, lpmmioinfo, dwRenameFlags);
+	  debugstr_a(szFileName), debugstr_a(szNewFileName), lpmmioinfo, dwFlags);
 
     /* If both params are NULL, then parse the file name */
     if (lpmmioinfo && lpmmioinfo->fccIOProc == 0 && lpmmioinfo->pIOProc == NULL)
-	lpmmioinfo->fccIOProc = MMIO_ParseExt(szFileName);
+	lpmmioinfo->fccIOProc = MMIO_ParseExtA(szFileName);
 
     /* Handle any unhandled/error case from above. Assume DOS file */
     if (!lpmmioinfo || (lpmmioinfo->fccIOProc == 0 && lpmmioinfo->pIOProc == NULL))
-	ioProc = (LPMMIOPROC)mmioDosIOProc;
+	ioProc = MMIO_FindProcNode(FOURCC_DOS);
     /* if just the four character code is present, look up IO proc */
     else if (lpmmioinfo->pIOProc == NULL)
-	ioProc = MMIO_InstallIOProc(lpmmioinfo->fccIOProc, NULL,
-				    MMIO_FINDPROC, MMIO_PROC_32A);
+        ioProc = MMIO_FindProcNode(lpmmioinfo->fccIOProc);
     else /* use relevant ioProc */
- 	ioProc = lpmmioinfo->pIOProc;
-
-    if (ioProc)
-	result = (ioProc)(0, MMIOM_RENAME,
-			  (LPARAM)szFileName, (LPARAM)szNewFileName);
+    {
+        ioProc = &tmp;
+        tmp.fourCC = lpmmioinfo->fccIOProc;
+        tmp.pIOProc = lpmmioinfo->pIOProc;
+        tmp.type = MMIO_PROC_32A;
+        tmp.count = 1;
+    }
 
-    return result;
+    return send_message(ioProc, lpmmioinfo, MMIOM_RENAME,
+                        (LPARAM)szFileName, (LPARAM)szNewFileName, MMIO_PROC_32A);
 }
 
 /**************************************************************************
  * 				mmioRenameW    			[WINMM.@]
  */
 MMRESULT WINAPI mmioRenameW(LPCWSTR szFileName, LPCWSTR szNewFileName,
-                            MMIOINFO* lpmmioinfo, DWORD dwRenameFlags)
+                            MMIOINFO* lpmmioinfo, DWORD dwFlags)
 {
     LPSTR	szFn = HEAP_strdupWtoA(GetProcessHeap(), 0, szFileName);
     LPSTR	sznFn = HEAP_strdupWtoA(GetProcessHeap(), 0, szNewFileName);
-    UINT	ret = mmioRenameA(szFn, sznFn, lpmmioinfo, dwRenameFlags);
+    UINT	ret = mmioRenameA(szFn, sznFn, lpmmioinfo, dwFlags);
 
     HeapFree(GetProcessHeap(),0,szFn);
     HeapFree(GetProcessHeap(),0,sznFn);
     return ret;
 }
+
Index: dlls/winmm/mmsystem.c
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/dlls/winmm/mmsystem.c,v
retrieving revision 1.72
diff -u -u -r1.72 mmsystem.c
--- dlls/winmm/mmsystem.c	10 Oct 2002 23:28:22 -0000	1.72
+++ dlls/winmm/mmsystem.c	20 Oct 2002 09:30:53 -0000
@@ -44,6 +44,20 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(mmsys);
 
+/* ### start build ### */
+extern LONG CALLBACK MMSYSTEM_CallTo16_long_l    (FARPROC16,LONG);
+extern LONG CALLBACK MMSYSTEM_CallTo16_long_lwll (LPMMIOPROC16,LONG,WORD,LONG,LONG);
+/* ### stop build ### */
+
+static LRESULT CALLBACK mmioCallback16(SEGPTR cb16,
+                                       LPMMIOINFO lpmmioinfo, UINT uMessage,
+                                       LPARAM lParam1, LPARAM lParam2);
+
+/* ###################################################
+ * #                  LIBRARY                        #
+ * ###################################################
+ */
+
 /**************************************************************************
  * 			DllEntryPoint (MMSYSTEM.2046)
  *
@@ -73,6 +87,7 @@
 	iData = MULTIMEDIA_GetIData();
 	iData->hWinMM16Instance = hinstDLL;
 	iData->h16Module32 = hndl;
+        iData->pFnMmioCallback16 = mmioCallback16;
 	break;
     case DLL_PROCESS_DETACH:
 	iData = MULTIMEDIA_GetIData();
@@ -95,6 +110,11 @@
     return TRUE;
 }
 
+/* ###################################################
+ * #                  PlaySound                      #
+ * ###################################################
+ */
+
 /**************************************************************************
  * 				PlaySound		[MMSYSTEM.3]
  */
@@ -125,6 +145,11 @@
     return retv;
 }
 
+/* ###################################################
+ * #                    MISC                         #
+ * ###################################################
+ */
+
 /**************************************************************************
  * 				mmsystemGetVersion	[MMSYSTEM.5]
  *
@@ -145,6 +170,20 @@
 }
 
 /**************************************************************************
+ * 			OutputDebugStr	 	[MMSYSTEM.30]
+ */
+void WINAPI OutputDebugStr16(LPCSTR str)
+{
+    OutputDebugStringA( str );
+}
+
+
+/* ###################################################
+ * #                    MIXER                        #
+ * ###################################################
+ */
+
+/**************************************************************************
  * 	Mixer devices. New to Win95
  */
 
@@ -386,6 +425,11 @@
     return MMDRV_GetNum(MMDRV_AUX);
 }
 
+/* ###################################################
+ * #                     AUX                         #
+ * ###################################################
+ */
+
 /**************************************************************************
  * 				auxGetDevCaps		[MMSYSTEM.351]
  */
@@ -457,6 +501,11 @@
     return MMDRV_Message(wmld, uMessage, dw1, dw2, TRUE);
 }
 
+/* ###################################################
+ * #                     MCI                         #
+ * ###################################################
+ */
+
 /**************************************************************************
  * 				mciGetErrorString		[MMSYSTEM.706]
  */
@@ -604,6 +653,11 @@
     return ret;
 }
 
+/* ###################################################
+ * #                     MIDI                        #
+ * ###################################################
+ */
+
 /**************************************************************************
  * 				midiOutGetNumDevs	[MMSYSTEM.201]
  */
@@ -1103,6 +1157,11 @@
     return midiStreamStop(HMIDISTRM_32(hMidiStrm));
 }
 
+/* ###################################################
+ * #                     WAVE                        #
+ * ###################################################
+ */
+
 /**************************************************************************
  * 				waveOutGetNumDevs		[MMSYSTEM.401]
  */
@@ -1635,6 +1694,11 @@
     return MMDRV_Message(wmld, uMessage, dwParam1, dwParam2, TRUE);
 }
 
+/* ###################################################
+ * #                     TASK                        #
+ * ###################################################
+ */
+
 /*#define USE_MM_TSK_WINE*/
 
 /**************************************************************************
@@ -2013,10 +2077,6 @@
     return ret;
 }
 
-/* ### start build ### */
-extern LONG CALLBACK MMSYSTEM_CallTo16_long_l    (FARPROC16,LONG);
-/* ### stop build ### */
-
 /**************************************************************************
  * 				__wine_mmThreadEntryPoint (MMSYSTEM.2047)
  */
@@ -2107,17 +2167,13 @@
  */
 void WINAPI WMMMidiRunOnce16(void)
 {
-	FIXME("(), stub!\n");
+    FIXME("(), stub!\n");
 }
 
-/**************************************************************************
- * 			OutputDebugStr	 	[MMSYSTEM.30]
+/* ###################################################
+ * #                    DRIVER                       #
+ * ###################################################
  */
-void WINAPI OutputDebugStr16(
-    LPCSTR str) /* [in] The message to be logged and given to the debugger. */
-{
-    OutputDebugStringA( str );
-}
 
 /**************************************************************************
  * 				DrvOpen	       		[MMSYSTEM.1100]
@@ -2173,6 +2229,11 @@
     return DrvDefDriverProc16(dwDevID, hDrv, wMsg, dwParam1, dwParam2);
 }
 
+/* ###################################################
+ * #                     TIME                        #
+ * ###################################################
+ */
+
 /**************************************************************************
  * 				timeGetSystemTime	[MMSYSTEM.601]
  */
@@ -2276,3 +2337,406 @@
 
     return mciFreeCommandResource(uTable);
 }
+
+/* ###################################################
+ * #                     MMIO                        #
+ * ###################################################
+ */
+
+/****************************************************************
+ *       		MMIO_Map32To16			[INTERNAL]
+ */
+static LRESULT	MMIO_Map32To16(DWORD wMsg, LPARAM* lp1, LPARAM* lp2)
+{
+    switch (wMsg) {
+    case MMIOM_CLOSE:
+    case MMIOM_SEEK:
+	/* nothing to do */
+	break;
+    case MMIOM_OPEN:
+    case MMIOM_READ:
+    case MMIOM_WRITE:
+    case MMIOM_WRITEFLUSH:
+        *lp1 = MapLS( (void *)*lp1 );
+	break;
+    case MMIOM_RENAME:
+        *lp1 = MapLS( (void *)*lp1 );
+        *lp2 = MapLS( (void *)*lp2 );
+        break;
+    default:
+        if (wMsg < MMIOM_USER)
+            TRACE("Not a mappable message (%ld)\n", wMsg);
+    }
+    return MMSYSERR_NOERROR;
+}
+
+/****************************************************************
+ *       	MMIO_UnMap32To16 			[INTERNAL]
+ */
+static LRESULT	MMIO_UnMap32To16(DWORD wMsg, LPARAM lParam1, LPARAM lParam2,
+				 LPARAM lp1, LPARAM lp2)
+{
+    switch (wMsg) {
+    case MMIOM_CLOSE:
+    case MMIOM_SEEK:
+	/* nothing to do */
+	break;
+    case MMIOM_OPEN:
+    case MMIOM_READ:
+    case MMIOM_WRITE:
+    case MMIOM_WRITEFLUSH:
+        UnMapLS( lp1 );
+	break;
+    case MMIOM_RENAME:
+        UnMapLS( lp1 );
+        UnMapLS( lp2 );
+	break;
+    default:
+        if (wMsg < MMIOM_USER)
+            TRACE("Not a mappable message (%ld)\n", wMsg);
+    }
+    return MMSYSERR_NOERROR;
+}
+
+/******************************************************************
+ *		mmioCallback16
+ *
+ *
+ */
+static LRESULT CALLBACK mmioCallback16(SEGPTR cb16,
+                                       LPMMIOINFO lpmmioinfo, UINT uMessage,
+                                       LPARAM lParam1, LPARAM lParam2)
+{
+    LRESULT 		result;
+    MMIOINFO16          mmioInfo16;
+    SEGPTR		segmmioInfo16;
+    LPARAM		lp1 = lParam1, lp2 = lParam2;
+
+    memset(&mmioInfo16, 0, sizeof(MMIOINFO16));
+    mmioInfo16.lDiskOffset = lpmmioinfo->lDiskOffset;
+    mmioInfo16.adwInfo[0]  = lpmmioinfo->adwInfo[0];
+    mmioInfo16.adwInfo[1]  = lpmmioinfo->adwInfo[1];
+    mmioInfo16.adwInfo[2]  = lpmmioinfo->adwInfo[2];
+    mmioInfo16.adwInfo[3]  = lpmmioinfo->adwInfo[3];
+    /* map (lParam1, lParam2) into (lp1, lp2) 32=>16 */
+    if ((result = MMIO_Map32To16(uMessage, &lp1, &lp2)) != MMSYSERR_NOERROR)
+        return result;
+    
+    segmmioInfo16 = MapLS(&mmioInfo16);
+    
+    result = MMSYSTEM_CallTo16_long_lwll((LPMMIOPROC16)cb16, segmmioInfo16, uMessage, lp1, lp2);
+    UnMapLS(segmmioInfo16);
+    MMIO_UnMap32To16(uMessage, lParam1, lParam2, lp1, lp2);
+
+    lpmmioinfo->lDiskOffset = mmioInfo16.lDiskOffset;
+    lpmmioinfo->adwInfo[0]  = mmioInfo16.adwInfo[0];
+    lpmmioinfo->adwInfo[1]  = mmioInfo16.adwInfo[1];
+    lpmmioinfo->adwInfo[2]  = mmioInfo16.adwInfo[2];
+    lpmmioinfo->adwInfo[3]  = mmioInfo16.adwInfo[3];
+
+    return result;
+}
+
+/******************************************************************
+ *             MMIO_ResetSegmentedData
+ *
+ * 
+ * 
+ */
+static LRESULT     MMIO_SetSegmentedBuffer(HMMIO hmmio, SEGPTR ptr)
+{
+    LPWINE_MMIO		wm;
+
+    if ((wm = MMIO_Get(NULL, hmmio)) == NULL)
+	return MMSYSERR_INVALHANDLE;
+    wm->segBuffer16 = ptr;
+    return MMSYSERR_NOERROR;
+}
+
+/**************************************************************************
+ * 				mmioOpen       		[MMSYSTEM.1210]
+ */
+HMMIO16 WINAPI mmioOpen16(LPSTR szFileName, MMIOINFO16* lpmmioinfo16,
+			  DWORD dwOpenFlags)
+{
+    HMMIO 	ret;
+
+    if (lpmmioinfo16) {
+	MMIOINFO	mmioinfo;
+
+	memset(&mmioinfo, 0, sizeof(mmioinfo));
+
+	mmioinfo.dwFlags     = lpmmioinfo16->dwFlags;
+	mmioinfo.fccIOProc   = lpmmioinfo16->fccIOProc;
+	mmioinfo.pIOProc     = (LPMMIOPROC)lpmmioinfo16->pIOProc;
+	mmioinfo.cchBuffer   = lpmmioinfo16->cchBuffer;
+	mmioinfo.pchBuffer   = MapSL((DWORD)lpmmioinfo16->pchBuffer);
+	mmioinfo.adwInfo[0]  = lpmmioinfo16->adwInfo[0];
+	mmioinfo.adwInfo[1]  = lpmmioinfo16->adwInfo[1];
+	mmioinfo.adwInfo[2]  = lpmmioinfo16->adwInfo[2];
+	mmioinfo.adwInfo[3]  = lpmmioinfo16->adwInfo[3];
+
+	ret = MMIO_Open(szFileName, &mmioinfo, dwOpenFlags, MMIO_PROC_16);
+        MMIO_SetSegmentedBuffer(mmioinfo.hmmio, (SEGPTR)lpmmioinfo16->pchBuffer);
+
+	lpmmioinfo16->wErrorRet = mmioinfo.wErrorRet;
+        lpmmioinfo16->hmmio     = HMMIO_16(mmioinfo.hmmio);
+    } else {
+	ret = MMIO_Open(szFileName, NULL, dwOpenFlags, MMIO_PROC_32A);
+    }
+    return HMMIO_16(ret);
+}
+
+/**************************************************************************
+ * 				mmioClose      		[MMSYSTEM.1211]
+ */
+MMRESULT16 WINAPI mmioClose16(HMMIO16 hmmio, UINT16 uFlags)
+{
+    return mmioClose(HMMIO_32(hmmio), uFlags);
+}
+
+/**************************************************************************
+ * 				mmioRead	       	[MMSYSTEM.1212]
+ */
+LONG WINAPI mmioRead16(HMMIO16 hmmio, HPSTR pch, LONG cch)
+{
+    return mmioRead(HMMIO_32(hmmio), pch, cch);
+}
+
+/**************************************************************************
+ * 				mmioWrite      		[MMSYSTEM.1213]
+ */
+LONG WINAPI mmioWrite16(HMMIO16 hmmio, HPCSTR pch, LONG cch)
+{
+    return mmioWrite(HMMIO_32(hmmio),pch,cch);
+}
+
+/**************************************************************************
+ * 				mmioSeek       		[MMSYSTEM.1214]
+ */
+LONG WINAPI mmioSeek16(HMMIO16 hmmio, LONG lOffset, INT16 iOrigin)
+{
+    return mmioSeek(HMMIO_32(hmmio), lOffset, iOrigin);
+}
+
+/**************************************************************************
+ * 				mmioGetInfo	       	[MMSYSTEM.1215]
+ */
+MMRESULT16 WINAPI mmioGetInfo16(HMMIO16 hmmio, MMIOINFO16* lpmmioinfo, UINT16 uFlags)
+{
+    MMIOINFO            mmioinfo;
+    MMRESULT            ret;
+    LPWINE_MMIO		wm;
+
+    TRACE("(0x%04x,%p,0x%08x)\n", hmmio, lpmmioinfo, uFlags);
+
+    if ((wm = MMIO_Get(NULL, hmmio)) == NULL)
+	return MMSYSERR_INVALHANDLE;
+
+    ret = mmioGetInfo(HMMIO_32(hmmio), &mmioinfo, uFlags);
+    if (ret != MMSYSERR_NOERROR) return ret;
+
+    lpmmioinfo->dwFlags     = mmioinfo.dwFlags;
+    lpmmioinfo->fccIOProc   = mmioinfo.fccIOProc;
+    lpmmioinfo->pIOProc     = (wm->ioProc->type == MMIO_PROC_16) ?
+        (LPMMIOPROC16)wm->ioProc->pIOProc : NULL;
+    lpmmioinfo->wErrorRet   = mmioinfo.wErrorRet;
+    lpmmioinfo->hTask       = mmioinfo.hTask;
+    lpmmioinfo->cchBuffer   = mmioinfo.cchBuffer;
+    lpmmioinfo->pchBuffer   = (void*)wm->segBuffer16;
+    lpmmioinfo->pchNext     = (void*)(wm->segBuffer16 + (mmioinfo.pchNext - mmioinfo.pchBuffer));
+    lpmmioinfo->pchEndRead  = (void*)(wm->segBuffer16 + (mmioinfo.pchEndRead - mmioinfo.pchBuffer));
+    lpmmioinfo->pchEndWrite = (void*)(wm->segBuffer16 + (mmioinfo.pchEndWrite - mmioinfo.pchBuffer));
+    lpmmioinfo->lBufOffset  = mmioinfo.lBufOffset;
+    lpmmioinfo->lDiskOffset = mmioinfo.lDiskOffset;
+    lpmmioinfo->adwInfo[0]  = mmioinfo.adwInfo[0];
+    lpmmioinfo->adwInfo[1]  = mmioinfo.adwInfo[1];
+    lpmmioinfo->adwInfo[2]  = mmioinfo.adwInfo[2];
+    lpmmioinfo->adwInfo[3]  = mmioinfo.adwInfo[3];
+    lpmmioinfo->dwReserved1 = 0;
+    lpmmioinfo->dwReserved2 = 0;
+    lpmmioinfo->hmmio = HMMIO_16(mmioinfo.hmmio);
+
+    return MMSYSERR_NOERROR;
+}
+
+/**************************************************************************
+ * 				mmioSetInfo  		[MMSYSTEM.1216]
+ */
+MMRESULT16 WINAPI mmioSetInfo16(HMMIO16 hmmio, const MMIOINFO16* lpmmioinfo, UINT16 uFlags)
+{
+    MMIOINFO            mmioinfo;
+    MMRESULT            ret;
+
+    TRACE("(0x%04x,%p,0x%08x)\n",hmmio,lpmmioinfo,uFlags);
+
+    ret = mmioGetInfo(HMMIO_32(hmmio), &mmioinfo, 0);
+    if (ret != MMSYSERR_NOERROR) return ret;
+
+    /* check if seg and lin buffers are the same */
+    if (mmioinfo.cchBuffer != lpmmioinfo->cchBuffer  ||
+        mmioinfo.pchBuffer != MapSL((DWORD)lpmmioinfo->pchBuffer)) 
+	return MMSYSERR_INVALPARAM;
+
+    /* check pointers coherence */
+    if (lpmmioinfo->pchNext < lpmmioinfo->pchBuffer ||
+	lpmmioinfo->pchNext > lpmmioinfo->pchBuffer + lpmmioinfo->cchBuffer ||
+	lpmmioinfo->pchEndRead < lpmmioinfo->pchBuffer ||
+	lpmmioinfo->pchEndRead > lpmmioinfo->pchBuffer + lpmmioinfo->cchBuffer ||
+	lpmmioinfo->pchEndWrite < lpmmioinfo->pchBuffer ||
+	lpmmioinfo->pchEndWrite > lpmmioinfo->pchBuffer + lpmmioinfo->cchBuffer)
+	return MMSYSERR_INVALPARAM;
+
+    mmioinfo.pchNext     = mmioinfo.pchBuffer + (lpmmioinfo->pchNext     - lpmmioinfo->pchBuffer);
+    mmioinfo.pchEndRead  = mmioinfo.pchBuffer + (lpmmioinfo->pchEndRead  - lpmmioinfo->pchBuffer);
+    mmioinfo.pchEndWrite = mmioinfo.pchBuffer + (lpmmioinfo->pchEndWrite - lpmmioinfo->pchBuffer);
+
+    return mmioSetInfo(HMMIO_32(hmmio), &mmioinfo, uFlags);
+}
+
+/**************************************************************************
+ * 				mmioSetBuffer		[MMSYSTEM.1217]
+ */
+MMRESULT16 WINAPI mmioSetBuffer16(HMMIO16 hmmio, LPSTR pchBuffer,
+                                  LONG cchBuffer, UINT16 uFlags)
+{
+    MMRESULT    ret = mmioSetBuffer(HMMIO_32(hmmio), MapSL((DWORD)pchBuffer), 
+                                    cchBuffer, uFlags);
+
+    if (ret == MMSYSERR_NOERROR)
+        MMIO_SetSegmentedBuffer(HMMIO_32(hmmio), (DWORD)pchBuffer);
+    return ret;
+}
+
+/**************************************************************************
+ * 				mmioFlush      		[MMSYSTEM.1218]
+ */
+MMRESULT16 WINAPI mmioFlush16(HMMIO16 hmmio, UINT16 uFlags)
+{
+    return mmioFlush(HMMIO_32(hmmio), uFlags);
+}
+
+/***********************************************************************
+ * 				mmioAdvance    		[MMSYSTEM.1219]
+ */
+MMRESULT16 WINAPI mmioAdvance16(HMMIO16 hmmio, MMIOINFO16* lpmmioinfo, UINT16 uFlags)
+{
+    MMIOINFO    mmioinfo;
+    LRESULT     ret;
+
+    /* WARNING: this heavily relies on mmioAdvance implementation (for choosing which
+     * fields to init
+     */
+    if (lpmmioinfo)
+    {
+        mmioinfo.pchBuffer = MapSL((DWORD)lpmmioinfo->pchBuffer);
+        mmioinfo.pchNext = MapSL((DWORD)lpmmioinfo->pchNext);
+        mmioinfo.dwFlags = lpmmioinfo->dwFlags;
+        mmioinfo.lBufOffset = lpmmioinfo->lBufOffset;
+        ret = mmioAdvance(HMMIO_32(hmmio), &mmioinfo, uFlags);
+    }
+    else
+        ret = mmioAdvance(HMMIO_32(hmmio), NULL, uFlags);
+        
+    if (ret != MMSYSERR_NOERROR) return ret;
+
+    if (lpmmioinfo)
+    {
+        lpmmioinfo->dwFlags = mmioinfo.dwFlags;
+        lpmmioinfo->pchNext     = (void*)(lpmmioinfo->pchBuffer + (mmioinfo.pchNext - mmioinfo.pchBuffer));
+        lpmmioinfo->pchEndRead  = (void*)(lpmmioinfo->pchBuffer + (mmioinfo.pchEndRead - mmioinfo.pchBuffer));
+        lpmmioinfo->pchEndWrite = (void*)(lpmmioinfo->pchBuffer + (mmioinfo.pchEndWrite - mmioinfo.pchBuffer));
+        lpmmioinfo->lBufOffset  = mmioinfo.lBufOffset;
+        lpmmioinfo->lDiskOffset = mmioinfo.lDiskOffset;
+    }
+
+    return MMSYSERR_NOERROR;
+}
+
+/**************************************************************************
+ * 				mmioStringToFOURCC	[MMSYSTEM.1220]
+ */
+FOURCC WINAPI mmioStringToFOURCC16(LPCSTR sz, UINT16 uFlags)
+{
+    return mmioStringToFOURCCA(sz, uFlags);
+}
+
+/**************************************************************************
+ *              mmioInstallIOProc    [MMSYSTEM.1221]
+ */
+LPMMIOPROC16 WINAPI mmioInstallIOProc16(FOURCC fccIOProc, LPMMIOPROC16 pIOProc,
+                                        DWORD dwFlags)
+{
+    return (LPMMIOPROC16)MMIO_InstallIOProc(fccIOProc, (LPMMIOPROC)pIOProc,
+                                            dwFlags, MMIO_PROC_16);
+}
+
+/**************************************************************************
+ * 				mmioSendMessage	[MMSYSTEM.1222]
+ */
+LRESULT WINAPI mmioSendMessage16(HMMIO16 hmmio, UINT16 uMessage,
+				 LPARAM lParam1, LPARAM lParam2)
+{
+    return MMIO_SendMessage(HMMIO_32(hmmio), uMessage, 
+                            lParam1, lParam2, MMIO_PROC_16);
+}
+
+/**************************************************************************
+ * 				mmioDescend	       	[MMSYSTEM.1223]
+ */
+MMRESULT16 WINAPI mmioDescend16(HMMIO16 hmmio, LPMMCKINFO lpck,
+                                const MMCKINFO* lpckParent, UINT16 uFlags)
+{
+    return mmioDescend(HMMIO_32(hmmio), lpck, lpckParent, uFlags);
+}
+
+/**************************************************************************
+ * 				mmioAscend     		[MMSYSTEM.1224]
+ */
+MMRESULT16 WINAPI mmioAscend16(HMMIO16 hmmio, MMCKINFO* lpck, UINT16 uFlags)
+{
+    return mmioAscend(HMMIO_32(hmmio),lpck,uFlags);
+}
+
+/**************************************************************************
+ * 				mmioCreateChunk		[MMSYSTEM.1225]
+ */
+MMRESULT16 WINAPI mmioCreateChunk16(HMMIO16 hmmio, MMCKINFO* lpck, UINT16 uFlags)
+{
+    return mmioCreateChunk(HMMIO_32(hmmio), lpck, uFlags);
+}
+
+/**************************************************************************
+ * 				mmioRename     		[MMSYSTEM.1226]
+ */
+MMRESULT16 WINAPI mmioRename16(LPCSTR szFileName, LPCSTR szNewFileName,
+                               MMIOINFO16* lpmmioinfo, DWORD dwRenameFlags)
+{
+    BOOL        inst = FALSE;
+    MMRESULT    ret;
+    MMIOINFO    mmioinfo;
+
+    if (lpmmioinfo != NULL && lpmmioinfo->pIOProc != NULL && 
+        lpmmioinfo->fccIOProc == 0) {
+        FIXME("Can't handle this case yet\n");
+        return MMSYSERR_ERROR;
+    }
+     
+    /* this is a bit hacky, but it'll work if we get a fourCC code or nothing.
+     * but a non installed ioproc without a fourcc won't do
+     */
+    if (lpmmioinfo && lpmmioinfo->fccIOProc && lpmmioinfo->pIOProc) {
+        MMIO_InstallIOProc(lpmmioinfo->fccIOProc, (LPMMIOPROC)lpmmioinfo->pIOProc,
+                           MMIO_INSTALLPROC, MMIO_PROC_16);
+        inst = TRUE;
+    }
+    memset(&mmioinfo, 0, sizeof(mmioinfo));
+    mmioinfo.fccIOProc = lpmmioinfo->fccIOProc;
+    ret = mmioRenameA(szFileName, szNewFileName, &mmioinfo, dwRenameFlags);
+    if (inst) {
+        MMIO_InstallIOProc(lpmmioinfo->fccIOProc, NULL,
+                           MMIO_REMOVEPROC, MMIO_PROC_16);
+    }
+    return ret;
+}
+
Index: dlls/winmm/winemm.h
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/dlls/winmm/winemm.h,v
retrieving revision 1.25
diff -u -u -r1.25 winemm.h
--- dlls/winmm/winemm.h	17 Oct 2002 16:43:43 -0000	1.25
+++ dlls/winmm/winemm.h	17 Oct 2002 20:08:40 -0000
@@ -146,14 +146,24 @@
     struct tagWINE_TIMERENTRY*	lpNext;
 } WINE_TIMERENTRY, *LPWINE_TIMERENTRY;
 
+enum mmioProcType {MMIO_PROC_16,MMIO_PROC_32A,MMIO_PROC_32W};
+
+struct IOProcList
+{
+    struct IOProcList*pNext;       /* Next item in linked list */
+    FOURCC            fourCC;      /* four-character code identifying IOProc */
+    LPMMIOPROC	      pIOProc;     /* pointer to IProc */
+    enum mmioProcType type;        /* 16, 32A or 32W */
+    int		      count;	   /* number of objects linked to it */
+};
+
 typedef struct tagWINE_MMIO {
     MMIOINFO			info;
-    struct IOProcList*		ioProc;
-    BOOL			bTmpIOProc;
-    HANDLE			hMem;
-    SEGPTR			buffer16;
     struct tagWINE_MMIO*	lpNext;
-    BOOL			bBufferLoaded;
+    struct IOProcList*		ioProc;
+    BOOL			bTmpIOProc : 1,
+                                bBufferLoaded : 1;
+    SEGPTR                      segBuffer16;
     DWORD                       dwFileSize;
 } WINE_MMIO, *LPWINE_MMIO;
 
@@ -186,6 +196,7 @@
     /* LPWINE_MIXER		lpMixer; */
     /* mmio part */
     LPWINE_MMIO			lpMMIO;
+    LRESULT (CALLBACK*          pFnMmioCallback16)(SEGPTR,LPMMIOINFO,UINT,LPARAM,LPARAM);
     /* playsound and sndPlaySound */
     WINE_PLAYSOUND*             lpPlaySound;
     HANDLE                      psLastEvent;
@@ -233,6 +244,13 @@
                                                   DWORD dwInstance, DWORD dwFlags, BOOL bFrom32);
 WORD	                        timeSetEventInternal(UINT wDelay, UINT wResol,
                                                      FARPROC16 lpFunc, DWORD dwUser, UINT wFlags);
+HMMIO                           MMIO_Open(LPSTR szFileName, MMIOINFO* refmminfo,
+                                          DWORD dwOpenFlags, enum mmioProcType type);
+LPMMIOPROC                      MMIO_InstallIOProc(FOURCC fccIOProc, LPMMIOPROC pIOProc,
+                                                   DWORD dwFlags, enum mmioProcType type);
+LRESULT                         MMIO_SendMessage(HMMIO hmmio, UINT uMessage, LPARAM lParam1, 
+                                                 LPARAM lParam2, enum mmioProcType type);
+LPWINE_MMIO	                MMIO_Get(LPWINE_MM_IDATA iData, HMMIO h);
 
 BOOL				MULTIMEDIA_MciInit(void);
 LPWINE_MM_IDATA			MULTIMEDIA_GetIData(void);

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

  Powered by Linux