changeset 7386:174e2a58b4cd

avifile sync - 95% cosmetics 5% bug
author arpi
date Fri, 13 Sep 2002 19:43:17 +0000
parents e2fcdd7608b1
children 072a85aa31c6
files loader/afl.c loader/com.h loader/driver.c loader/driver.h loader/dshow/DS_Filter.c loader/dshow/allocator.c loader/dshow/allocator.h loader/dshow/cmediasample.c loader/dshow/guids.c loader/dshow/guids.h loader/dshow/inputpin.c loader/dshow/inputpin.h loader/dshow/interfaces.h loader/dshow/iunk.h loader/dshow/outputpin.c loader/dshow/outputpin.h loader/elfdll.c loader/ext.c loader/ext.h loader/ldt_keeper.c loader/ldt_keeper.h loader/loader.h loader/module.c loader/module.h loader/pe_image.c loader/pe_resource.c loader/registry.c loader/resource.c loader/win32.c loader/win32.h loader/wine/avifmt.h loader/wine/mmreg.h loader/wine/module.h loader/wine/msacm.h loader/wine/pe_image.h loader/wine/vfw.h loader/wineacm.h
diffstat 37 files changed, 757 insertions(+), 962 deletions(-) [+]
line wrap: on
line diff
--- a/loader/afl.c	Fri Sep 13 19:42:33 2002 +0000
+++ b/loader/afl.c	Fri Sep 13 19:43:17 2002 +0000
@@ -21,12 +21,6 @@
 ***************************************************************************/
 #include "config.h"
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "win32.h"
-
 #include "wine/winbase.h"
 #include "wine/windef.h"
 #include "wine/winuser.h"
@@ -38,15 +32,16 @@
 #include "wine/msacmdrv.h"
 #include "wineacm.h"
 #include "ext.h"
-
 #include "driver.h"
 
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#pragma pack(1)
 #define OpenDriverA DrvOpen
 #define CloseDriver DrvClose
 
-#pragma pack(1)
-
-static PWINE_ACMSTREAM	ACM_GetStream(HACMSTREAM has)
+static inline PWINE_ACMSTREAM ACM_GetStream(HACMSTREAM has)
 {
     return (PWINE_ACMSTREAM)has;
 }
@@ -75,7 +70,7 @@
      * LoadDriver on it, to be sure we can call SendDriverMessage on the
      * hDrvr handle.
      */
-    *phadid = (HACMDRIVERID) MSACM_RegisterDriver(NULL, NULL, hinstModule);
+    *phadid = (HACMDRIVERID) MSACM_RegisterDriver(NULL, 0, hinstModule);
     
     /* FIXME: lParam, dwPriority and fdwAdd ignored */
     
@@ -195,7 +190,6 @@
     HDRVR		hdrv;
 
 
-
     TRACE("(%p, %x, %08lu)\n", phad, hadid, fdwOpen);
 
     if (!phad)
@@ -208,8 +202,9 @@
     if (fdwOpen)
 	return MMSYSERR_INVALFLAG;
     
-    pad = HeapAlloc(MSACM_hHeap, 0, sizeof(WINE_ACMDRIVER));
-    if (!pad) return MMSYSERR_NOMEM;
+    pad = (PWINE_ACMDRIVER) HeapAlloc(MSACM_hHeap, 0, sizeof(WINE_ACMDRIVER));
+    if (!pad)
+	return MMSYSERR_NOMEM;
 
     pad->obj.pACMDriverID = padid;
     icopen.fccType		= mmioFOURCC('a', 'u', 'd', 'c');
@@ -217,7 +212,8 @@
     icopen.dwSize		= sizeof(ICOPEN);
     icopen.dwFlags		= 0;
 
-   if (!padid->hInstModule)
+    icopen.pV1Reserved = padid->pszFileName;
+    if (!padid->hInstModule)
 	pad->hDrvr = OpenDriverA((long)&icopen);
     else
 	pad->hDrvr = padid->hInstModule;
@@ -226,7 +222,7 @@
 	HeapFree(MSACM_hHeap, 0, pad);
 	return MMSYSERR_ERROR;
     }
-    
+
     pad->pfnDriverProc = GetProcAddress(pad->hDrvr, "DriverProc");
 
     /* insert new pad at beg of list */
@@ -235,7 +231,7 @@
 
     /* FIXME: Create a WINE_ACMDRIVER32 */
     *phad = (HACMDRIVER)pad;
-    
+
     return MMSYSERR_NOERROR;
 }
 
@@ -269,22 +265,19 @@
 /***********************************************************************
  *           MSACM_RegisterDriver32() 
  */
-PWINE_ACMDRIVERID MSACM_RegisterDriver(LPSTR pszDriverAlias, LPSTR pszFileName,
+PWINE_ACMDRIVERID MSACM_RegisterDriver(const char* pszFileName,
+				       WORD wFormatTag,
 				       HINSTANCE hinstModule)
-//
-// File names are stored in driver.c. I reuse this variable to store driver ID
-// in it. If it's <0x10000, it is primary codec for corresponding format.
-//				       
-{ 
+{
     PWINE_ACMDRIVERID padid;
 
-    TRACE("('%s', '%x', 0x%08x)\n", pszDriverAlias, pszFileName, hinstModule);
+    TRACE("('%s', '%x', 0x%08x)\n", pszFileName, wFormatTag, hinstModule);
 
     padid = (PWINE_ACMDRIVERID) HeapAlloc(MSACM_hHeap, 0, sizeof(WINE_ACMDRIVERID));
-    padid->pszDriverAlias = (char*)malloc(strlen(pszDriverAlias)+1);
-    strcpy(padid->pszDriverAlias, pszDriverAlias);
+    padid->pszFileName = (char*)malloc(strlen(pszFileName)+1);
+    strcpy(padid->pszFileName, pszFileName);
 //    1~strdup(pszDriverAlias);
-    padid->pszFileName = pszFileName;
+    padid->wFormatTag = wFormatTag;
     padid->hInstModule = hinstModule;
     padid->bEnabled = TRUE;
     padid->pACMDriverList = NULL;
@@ -299,23 +292,6 @@
     return padid;
 }
 
-/***********************************************************************
- *           MSACM_RegisterAllDrivers32() 
- */
-void MSACM_RegisterAllDrivers(void)
-{
-    LPSTR pszBuffer;
-    DWORD dwBufferLength;
-    
-    if (MSACM_pFirstACMDriverID)
-	return;
-    
-    MSACM_RegisterDriver("divxa32", (LPSTR)0x161, 0);  // DivX/WMA     [07]
-    MSACM_RegisterDriver("msadp32", (LPSTR)0x2, 0);    // MS ADPCM     [08]
-    MSACM_RegisterDriver("l3codeca", (LPSTR)0x55, 0);  // MPEG Layer-3 [12]
-//    MSACM_RegisterDriver("imaadp32", (LPSTR)0x11, 0);  // IMA ADPCM    [13]
-//    MSACM_RegisterDriver("msgsm32", (LPSTR)0x32, 0);   // MS GSM 6.10  [14]
-}
 
 /***********************************************************************
  *           MSACM_UnregisterDriver32()
@@ -327,10 +303,8 @@
     while (p->pACMDriverList)
 	acmDriverClose((HACMDRIVER) p->pACMDriverList, 0);
     
-    if (p->pszDriverAlias)
-	HeapFree(MSACM_hHeap, 0, p->pszDriverAlias);
-//    if (p->pszFileName)
-//	HeapFree(MSACM_hHeap, 0, p->pszFileName);
+    if (p->pszFileName)
+	free(p->pszFileName);
     
     if (p == MSACM_pFirstACMDriverID)
 	MSACM_pFirstACMDriverID = p->pNextACMDriverID;
@@ -400,8 +374,6 @@
     int			wfxSrcSize;
     int			wfxDstSize;
     
-    //printf("gcc-3.0 bug, pwfxSrc=%p, pwfxSrc->cbSize=%d\n", pwfxSrc, pwfxSrc->cbSize);
-
     TRACE("(%p, 0x%08x, %p, %p, %p, %ld, %ld, %ld)\n",
 	  phas, had, pwfxSrc, pwfxDst, pwfltr, dwCallback, dwInstance, fdwOpen);
 
@@ -418,13 +390,15 @@
     wfxDstSize = SIZEOF_WFX(pwfxDst);
 #undef SIZEOF_WFX
 
-    was = HeapAlloc(MSACM_hHeap, 0, sizeof(*was) + wfxSrcSize + wfxDstSize + ((pwfltr) ? sizeof(WAVEFILTER) : 0));
+    was = (PWINE_ACMSTREAM) HeapAlloc(MSACM_hHeap, 0, sizeof(*was) + wfxSrcSize + wfxDstSize + ((pwfltr) ? sizeof(WAVEFILTER) : 0));
     if (was == NULL)
 	return MMSYSERR_NOMEM;
-    
     was->drvInst.cbStruct = sizeof(was->drvInst);
     was->drvInst.pwfxSrc = (PWAVEFORMATEX)((LPSTR)was + sizeof(*was));
     memcpy(was->drvInst.pwfxSrc, pwfxSrc, wfxSrcSize);
+    // LHACM is checking for 0x1
+    // but if this will not help
+    // was->drvInst.pwfxSrc->wFormatTag = 1;
     was->drvInst.pwfxDst = (PWAVEFORMATEX)((LPSTR)was + sizeof(*was) + wfxSrcSize);
     memcpy(was->drvInst.pwfxDst, pwfxDst, wfxDstSize);
     if (pwfltr) {
@@ -481,10 +455,14 @@
 		    }
 		}
 		acmDriverClose(had, 0L);*/
-	if(MSACM_pFirstACMDriverID==NULL)
-	    MSACM_RegisterAllDrivers();	
+	//if(MSACM_pFirstACMDriverID==NULL)
+	//    MSACM_RegisterAllDrivers();
 	
-	for (wadi = MSACM_pFirstACMDriverID; wadi; wadi = wadi->pNextACMDriverID) {
+	for (wadi = MSACM_pFirstACMDriverID; wadi; wadi = wadi->pNextACMDriverID)
+	{
+	    /* Check Format */
+	    if ((int)wadi->wFormatTag != (int)pwfxSrc->wFormatTag) continue;
+
 	    ret = acmDriverOpen(&had, (HACMDRIVERID)wadi, 0L);
 	    if (ret == MMSYSERR_NOERROR) {
 		if ((wad = MSACM_GetDriver(had)) != 0) {
@@ -493,6 +471,8 @@
 		    was->hAcmDriver = had;
 		    
 		    ret = SendDriverMessage(wad->hDrvr, ACMDM_STREAM_OPEN, (DWORD)&was->drvInst, 0L);
+		    //lhacm - crash printf("RETOPEN %d\n", ret);
+                    //ret = 0;
 		    if (ret == MMSYSERR_NOERROR) {
 			if (fdwOpen & ACM_STREAMOPENF_QUERY) {
 			    acmDriverClose(had, 0L);
@@ -514,6 +494,7 @@
 	if (phas)
 	    *phas = (HACMSTREAM)was;
 	TRACE("=> (%d)\n", ret);
+        CodecAlloc();
 	return ret;
     }
 errCleanUp:		
@@ -540,6 +521,7 @@
 	if (was->hAcmDriver)
 	    acmDriverClose(was->hAcmDriver, 0L);	
 	HeapFree(MSACM_hHeap, 0, was);
+        CodecRelease();
     }
     TRACE("=> (%d)\n", ret);
     return ret;
@@ -556,7 +538,7 @@
     PACMDRVSTREAMHEADER	padsh;
 
     TRACE("(0x%08x, %p, %ld)\n", has, pash, fdwConvert);
-    
+
     if ((was = ACM_GetStream(has)) == NULL)
 	return MMSYSERR_INVALHANDLE;
     if (!pash || pash->cbStruct < sizeof(ACMSTREAMHEADER))
--- a/loader/com.h	Fri Sep 13 19:42:33 2002 +0000
+++ b/loader/com.h	Fri Sep 13 19:43:17 2002 +0000
@@ -1,7 +1,14 @@
 #ifndef AVIFILE_COM_H
 #define AVIFILE_COM_H
 
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#else
 #include <inttypes.h>
+#endif
 
 /**
  * Internal functions and structures for COM emulation code.
@@ -27,12 +34,12 @@
 } GUID;
 #endif
 
-extern GUID IID_IUnknown;
-extern GUID IID_IClassFactory;
+extern const GUID IID_IUnknown;
+extern const GUID IID_IClassFactory;
 
-typedef long (*GETCLASSOBJECT) (GUID* clsid, GUID* iid, void** ppv);
-int RegisterComClass(GUID* clsid, GETCLASSOBJECT gcs);
-int UnregisterComClass(GUID* clsid, GETCLASSOBJECT gcs);
+typedef long (*GETCLASSOBJECT) (GUID* clsid, const GUID* iid, void** ppv);
+int RegisterComClass(const GUID* clsid, GETCLASSOBJECT gcs);
+int UnregisterComClass(const GUID* clsid, GETCLASSOBJECT gcs);
 
 #ifndef STDCALL
 #define STDCALL __attribute__((__stdcall__))
@@ -42,7 +49,7 @@
 struct IClassFactory;
 struct IUnknown_vt
 {
-    long STDCALL (*QueryInterface)(struct IUnknown* _this, GUID* iid, void** ppv);
+    long STDCALL (*QueryInterface)(struct IUnknown* _this, const GUID* iid, void** ppv);
     long STDCALL (*AddRef)(struct IUnknown* _this) ;
     long STDCALL (*Release)(struct IUnknown* _this) ;
 } ;
@@ -54,10 +61,10 @@
 
 struct IClassFactory_vt
 {
-    long STDCALL (*QueryInterface)(struct IUnknown* _this, GUID* iid, void** ppv);
+    long STDCALL (*QueryInterface)(struct IUnknown* _this, const GUID* iid, void** ppv);
     long STDCALL (*AddRef)(struct IUnknown* _this) ;
     long STDCALL (*Release)(struct IUnknown* _this) ;
-    long STDCALL (*CreateInstance)(struct IClassFactory* _this, struct IUnknown* pUnkOuter, GUID* riid, void** ppvObject);
+    long STDCALL (*CreateInstance)(struct IClassFactory* _this, struct IUnknown* pUnkOuter, const GUID* riid, void** ppvObject);
 };
 
 struct IClassFactory
@@ -66,7 +73,7 @@
 };
 
 long CoCreateInstance(GUID* rclsid, struct IUnknown* pUnkOuter,
-		      long dwClsContext, GUID* riid, void** ppv);
+		      long dwClsContext, const GUID* riid, void** ppv);
 
 #ifdef __cplusplus
 };
--- a/loader/driver.c	Fri Sep 13 19:42:33 2002 +0000
+++ b/loader/driver.c	Fri Sep 13 19:43:17 2002 +0000
@@ -1,4 +1,5 @@
-#include <config.h>
+#include "config.h"
+
 #include <stdio.h>
 #ifdef HAVE_MALLOC_H
 #include <malloc.h>
@@ -17,22 +18,26 @@
 #include "ldt_keeper.h"
 #include "driver.h"
 
+extern char* def_path;
 
 #if 1
+
 /*
  * STORE_ALL/REST_ALL seems like an attempt to workaround problems due to
  * WINAPI/no-WINAPI bustage.
  *
- * There should be no need for the STORE_ALL/REST_ALL hack once all 
+ * There should be no need for the STORE_ALL/REST_ALL hack once all
  * function definitions agree with their prototypes (WINAPI-wise) and
  * we make sure, that we do not call these functions without a proper
  * prototype in scope.
  */
-#define	STORE_ALL	/**/
-#define	REST_ALL	/**/
+
+#define STORE_ALL
+#define REST_ALL
 #else
+// this asm code is no longer needed
 #define STORE_ALL \
-    __asm__( \
+    __asm__ __volatile__ ( \
     "push %%ebx\n\t" \
     "push %%ecx\n\t" \
     "push %%edx\n\t" \
@@ -40,7 +45,7 @@
     "push %%edi\n\t"::)
 
 #define REST_ALL \
-    __asm__( \
+    __asm__ __volatile__ ( \
     "pop %%edi\n\t" \
     "pop %%esi\n\t" \
     "pop %%edx\n\t" \
@@ -48,180 +53,125 @@
     "pop %%ebx\n\t"::)
 #endif
 
-
+static int needs_free=0;
+void SetCodecPath(const char* path)
+{
+    if(needs_free)free(def_path);
+    if(path==0)
+    {
+	def_path=WIN32_PATH;
+	needs_free=0;
+	return;
+    }
+    def_path = (char*) malloc(strlen(path)+1);
+    strcpy(def_path, path);
+    needs_free=1;
+}
 
-    
 static DWORD dwDrvID = 0;
 
-
-LRESULT WINAPI SendDriverMessage( HDRVR hDriver, UINT message,
-                                    LPARAM lParam1, LPARAM lParam2 )
+LRESULT WINAPI SendDriverMessage(HDRVR hDriver, UINT message,
+				 LPARAM lParam1, LPARAM lParam2)
 {
     DRVR* module=(DRVR*)hDriver;
     int result;
-#ifdef DETAILED_OUT    
+#ifndef __svr4__
+    char qw[300];
+#endif
+#ifdef DETAILED_OUT
     printf("SendDriverMessage: driver %X, message %X, arg1 %X, arg2 %X\n", hDriver, message, lParam1, lParam2);
 #endif
-    if(module==0)return -1;
-    if(module->hDriverModule==0)return -1;
-    if(module->DriverProc==0)return -1;
-    STORE_ALL;
-    result=module->DriverProc(module->dwDriverID,1,message,lParam1,lParam2);
-    REST_ALL;
-#ifdef DETAILED_OUT    
-    printf("\t\tResult: %X\n", result);
-#endif    
-    return result;
-}				    
+    if (!module || !module->hDriverModule || !module->DriverProc) return -1;
+#ifndef __svr4__
+    __asm__ __volatile__ ("fsave (%0)\n\t": :"r"(&qw));
+#endif
+
+    Setup_FS_Segment();
 
-static NPDRVR DrvAlloc(HDRVR*lpDriver, LPUINT lpDrvResult)
-{
-    NPDRVR npDriver;
-    /* allocate and lock handle */
-    if (lpDriver)
-    {
-      if ( (*lpDriver = (HDRVR) malloc(sizeof(DRVR))) )
-        {
-            if ((npDriver = (NPDRVR) *lpDriver))
-            {
-                    *lpDrvResult = MMSYSERR_NOERROR;
-                    return (npDriver);
-            }
-            free((NPDRVR)*lpDriver);
-        }
-        return (*lpDrvResult = MMSYSERR_NOMEM, (NPDRVR) 0);
-    }
-    return (*lpDrvResult = MMSYSERR_INVALPARAM, (NPDRVR) 0);
+    STORE_ALL;
+    result=module->DriverProc(module->dwDriverID, hDriver, message, lParam1, lParam2);
+    REST_ALL;
+
+#ifndef __svr4__
+    __asm__ __volatile__ ("frstor (%0)\n\t": :"r"(&qw));
+#endif
+
+#ifdef DETAILED_OUT
+    printf("\t\tResult: %X\n", result);
+#endif
+    return result;
 }
 
-                                                                                                                    
-static void DrvFree(HDRVR hDriver)
+void DrvClose(HDRVR hDriver)
 {
-    int i;
-    Setup_FS_Segment();
-    if(hDriver)
-    	if(((DRVR*)hDriver)->hDriverModule)
-    	if(((DRVR*)hDriver)->DriverProc)
-	(((DRVR*)hDriver)->DriverProc)(((DRVR*)hDriver)->dwDriverID, hDriver, DRV_CLOSE, 0, 0);
-    if(hDriver)	{
-            if(((DRVR*)hDriver)->hDriverModule)
-    		if(((DRVR*)hDriver)->DriverProc)
-			(((DRVR*)hDriver)->DriverProc)(0, hDriver, DRV_FREE, 0, 0);
-		FreeLibrary(((DRVR*)hDriver)->hDriverModule);
-        	free((NPDRVR)hDriver);
-		return;	
+    if (hDriver)
+    {
+	DRVR* d = (DRVR*)hDriver;
+	if (d->hDriverModule)
+	{
+	    Setup_FS_Segment();
+	    if (d->DriverProc)
+	    {
+		SendDriverMessage(hDriver, DRV_CLOSE, 0, 0);
+		d->dwDriverID = 0;
+		SendDriverMessage(hDriver, DRV_FREE, 0, 0);
+	    }
+	    FreeLibrary(d->hDriverModule);
+	}
+	free(d);
     }
+    CodecRelease();
 }
 
-void DrvClose(HDRVR hdrvr)
-{
-    DrvFree(hdrvr);
-}
-
-
-char* win32_codec_name=NULL;  // must be set before calling DrvOpen() !!!
-
-HDRVR VFWAPI
-DrvOpen(LPARAM lParam2)
+//DrvOpen(LPCSTR lpszDriverName, LPCSTR lpszSectionName, LPARAM lParam2)
+HDRVR DrvOpen(LPARAM lParam2)
 {
-    ICOPEN *icopen=(ICOPEN *) lParam2;
-    UINT uDrvResult;
-    HDRVR hDriver;
-    NPDRVR npDriver;
-    char unknown[0x24];
-//    char* codec_name=icopen->fccHandler;
+    NPDRVR hDriver;
+    int i;
+    char unknown[0x124];
+    const char* filename = (const char*) ((ICOPEN*) lParam2)->pV1Reserved;
 
+#ifdef MPLAYER
     Setup_LDT_Keeper();
+    printf("Loading codec DLL: '%s'\n",filename);
+#endif
 
-    if (!(npDriver = DrvAlloc(&hDriver, &uDrvResult)))
+    hDriver = (NPDRVR) malloc(sizeof(DRVR));
+    if (!hDriver)
 	return ((HDRVR) 0);
+    memset((void*)hDriver, 0, sizeof(DRVR));
 
-    if (!(npDriver->hDriverModule = LoadLibraryA(win32_codec_name))) {
-     	printf("Can't open library %s\n", win32_codec_name);
-        DrvFree(hDriver);
-        return ((HDRVR) 0);
+    CodecAlloc();
+    Setup_FS_Segment();
+
+    hDriver->hDriverModule = LoadLibraryA(filename);
+    if (!hDriver->hDriverModule)
+    {
+	printf("Can't open library %s\n", filename);
+	DrvClose((HDRVR)hDriver);
+	return ((HDRVR) 0);
     }
 
-#if 0
+    hDriver->DriverProc = (DRIVERPROC) GetProcAddress(hDriver->hDriverModule,
+						      "DriverProc");
+    if (!hDriver->DriverProc)
     {
-        unsigned char *p=((char*)npDriver->hDriverModule);
-        double *dp;
-        int i;
-        p+=0x14c0;
-        for(i=0;i<16;i++)printf(" %02X",p[i]); printf("\n");
-        dp=(double*)p;
-        printf("divx bitrate = %f\n",(float)(*dp));
-//    	*(double*)((char*)npDriver->hDriverModule+0x14c0)=bitrate;
-    }
-#endif
-   
-    if (!(npDriver->DriverProc = (DRIVERPROC)
-             GetProcAddress(npDriver->hDriverModule, "DriverProc"))) {
-#if 1
-         printf("Library %s is not a VfW/ACM valid codec\n", win32_codec_name);
-#else
-        // Try DirectShow...
-         GETCLASS func=(GETCLASS)GetProcAddress(npDriver->hDriverModule,"DllGetClassObject");
-         if(!func)
-           printf("Library %s is not a valid VfW/ACM/DShow codec\n", win32_codec_name);
-         else {
-            HRESULT result;
-            struct IClassFactory* factory=0;
-	    struct IUnknown* object=0;
-            GUID CLSID_Voxware={0x73f7a062, 0x8829, 0x11d1,
-                {0xb5, 0x50, 0x00, 0x60, 0x97, 0x24, 0x2d, 0x8d}};
-            GUID* id=&CLSID_Voxware;
-            
-            result=func(id, &IID_IClassFactory, (void**)&factory);
-            if(result || (!factory)) printf("No such class object (wrong/missing GUID?)\n");
-
-            printf("Calling factory->vt->CreateInstance()\n");
-            printf("addr = %X\n",(unsigned int)factory->vt->CreateInstance);
-            result=factory->vt->CreateInstance(factory, 0, &IID_IUnknown, (void**)&object);
-            printf("Calling factory->vt->Release()\n");
-            factory->vt->Release((struct IUnknown*)factory);
-            if(result || (!object)) printf("Class factory failure\n");
-
-            printf("DirectShow codecs not yet supported...\n");
-         }
-#endif
-
-         FreeLibrary(npDriver->hDriverModule);
-         DrvFree(hDriver);
-         return ((HDRVR) 0);
-
+	printf("Library %s is not a valid VfW/ACM codec\n", filename);
+	DrvClose((HDRVR)hDriver);
+	return ((HDRVR) 0);
     }
 
-    //TRACE("DriverProc == %X\n", npDriver->DriverProc);
-     npDriver->dwDriverID = ++dwDrvID;
-
-     Setup_FS_Segment();
-
-	STORE_ALL;
-        (npDriver->DriverProc)(0, hDriver, DRV_LOAD, 0, 0);
-	REST_ALL;
-	//TRACE("DRV_LOAD Ok!\n");
-	STORE_ALL;
-	(npDriver->DriverProc)(0, hDriver, DRV_ENABLE, 0, 0);
-	REST_ALL;
-	//TRACE("DRV_ENABLE Ok!\n");
+    TRACE("DriverProc == %X\n", hDriver->DriverProc);
+    SendDriverMessage((HDRVR)hDriver, DRV_LOAD, 0, 0);
+    TRACE("DRV_LOAD Ok!\n");
+    SendDriverMessage((HDRVR)hDriver, DRV_ENABLE, 0, 0);
+    TRACE("DRV_ENABLE Ok!\n");
+    hDriver->dwDriverID = ++dwDrvID; // generate new id
 
-     // open driver 
-    STORE_ALL;
-     npDriver->dwDriverID=(npDriver->DriverProc)(npDriver->dwDriverID, hDriver, DRV_OPEN,
-         (LPARAM) (LPSTR) unknown, lParam2);
-    REST_ALL;
-
-    //TRACE("DRV_OPEN Ok!(%X)\n", npDriver->dwDriverID);
+    // open driver and remmeber proper DriverID
+    hDriver->dwDriverID = SendDriverMessage((HDRVR)hDriver, DRV_OPEN, (LPARAM) unknown, lParam2);
+    TRACE("DRV_OPEN Ok!(%X)\n", hDriver->dwDriverID);
 
-    if (uDrvResult)
-    {
-         DrvFree(hDriver);
-         hDriver = (HDRVR) 0;
-     }
-     
-//     printf("Successfully loaded codec %s\n",win32_codec_name);
-     
-     return (hDriver);
+    printf("Loaded DLL driver %s\n", filename);
+    return (HDRVR)hDriver;
 }
-  
--- a/loader/driver.h	Fri Sep 13 19:42:33 2002 +0000
+++ b/loader/driver.h	Fri Sep 13 19:43:17 2002 +0000
@@ -1,11 +1,22 @@
-
 #ifndef loader_driver_h
 #define	loader_driver_h
 
-//#include "wine/windef.h"
-//#include "wine/vfw.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "wine/windef.h"
+#include "wine/driver.h"
 
-extern HDRVR VFWAPI DrvOpen(LPARAM lParam2);
-extern void DrvClose(HDRVR hdrvr);
+void SetCodecPath(const char* path);
+void CodecAlloc(void);
+void CodecRelease(void);
+
+HDRVR DrvOpen(LPARAM lParam2);
+void DrvClose(HDRVR hdrvr);
+
+#ifdef __cplusplus
+}
+#endif
 
 #endif
--- a/loader/dshow/DS_Filter.c	Fri Sep 13 19:42:33 2002 +0000
+++ b/loader/dshow/DS_Filter.c	Fri Sep 13 19:43:17 2002 +0000
@@ -1,9 +1,10 @@
 #include "DS_Filter.h"
 #include "driver.h"
 #include "com.h"
-#include "module.h"
 #include <stdio.h>
 #include <string.h>
+#include <stdlib.h>
+#include "win32.h" // printf macro
 
 typedef long STDCALL (*GETCLASS) (const GUID*, const GUID*, void**);
 
@@ -145,7 +146,7 @@
 	object->vt->Release((IUnknown*)object);
 	if (result || !This->m_pFilter)
 	{
-	    em = "object does not have IBaseFilter interface";
+	    em = "object does not provide IBaseFilter interface";
             break;
 	}
 	// enumerate pins
@@ -228,7 +229,6 @@
             break;
 	}
 
-	printf("Using DirectShow codec: %s\n", dllname);
 	init++;
         break;
     }
--- a/loader/dshow/allocator.c	Fri Sep 13 19:42:33 2002 +0000
+++ b/loader/dshow/allocator.c	Fri Sep 13 19:43:17 2002 +0000
@@ -2,9 +2,17 @@
 #include "com.h"
 #include "wine/winerror.h"
 #include <stdio.h>
+#include <stdlib.h>
 
 static int AllocatorKeeper = 0;
 
+struct _avm_list_t
+{
+    struct _avm_list_t* next;
+    struct _avm_list_t* prev;
+    void* member;
+};
+
 static inline int avm_list_size(avm_list_t* head)
 {
     avm_list_t* it = head;
@@ -100,7 +108,7 @@
     return NULL;
 }
 
-static long MemAllocator_CreateAllocator(GUID* clsid, GUID* iid, void** ppv)
+static long MemAllocator_CreateAllocator(GUID* clsid, const GUID* iid, void** ppv)
 {
     IMemAllocator* p;
     int result;
--- a/loader/dshow/allocator.h	Fri Sep 13 19:42:33 2002 +0000
+++ b/loader/dshow/allocator.h	Fri Sep 13 19:43:17 2002 +0000
@@ -4,14 +4,9 @@
 #include "interfaces.h"
 #include "cmediasample.h"
 
-typedef struct avm_list_t
-{
-    struct avm_list_t* next;
-    struct avm_list_t* prev;
-    void* member;
-} avm_list_t;
+typedef struct _avm_list_t avm_list_t;
+typedef struct _MemAllocator MemAllocator;
 
-typedef struct _MemAllocator MemAllocator;
 struct _MemAllocator
 {
     IMemAllocator_vt* vt;
--- a/loader/dshow/cmediasample.c	Fri Sep 13 19:42:33 2002 +0000
+++ b/loader/dshow/cmediasample.c	Fri Sep 13 19:43:17 2002 +0000
@@ -2,9 +2,10 @@
 #include "wine/winerror.h"
 #include <stdio.h>
 #include <string.h>
+#include <stdlib.h>
 
 static long STDCALL CMediaSample_QueryInterface(IUnknown* This,
-						/* [in] */ IID* iid,
+						/* [in] */ const GUID* iid,
 						/* [iid_is][out] */ void **ppv)
 {
     Debug printf("CMediaSample_QueryInterface(%p) called\n", This);
--- a/loader/dshow/guids.c	Fri Sep 13 19:42:33 2002 +0000
+++ b/loader/dshow/guids.c	Fri Sep 13 19:43:17 2002 +0000
@@ -1,68 +1,67 @@
 #include "guids.h"
 int DSHOW_DEBUG = 0;
 
-GUID CLSID_DivxDecompressorCF={0x82CCd3E0, 0xF71A, 0x11D0,
+const GUID CLSID_DivxDecompressorCF={0x82CCd3E0, 0xF71A, 0x11D0,
     { 0x9f, 0xe5, 0x00, 0x60, 0x97, 0x78, 0xaa, 0xaa}};
-GUID IID_IDivxFilterInterface={0xd132ee97, 0x3e38, 0x4030,
+const GUID IID_IDivxFilterInterface={0xd132ee97, 0x3e38, 0x4030,
     {0x8b, 0x17, 0x59, 0x16, 0x3b, 0x30, 0xa1, 0xf5}};
 
-GUID CLSID_IV50_Decoder={0x30355649, 0x0000, 0x0010,
+const GUID CLSID_IV50_Decoder={0x30355649, 0x0000, 0x0010,
     {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
-GUID IID_IBaseFilter={0x56a86895, 0x0ad4, 0x11ce,
+const GUID IID_IBaseFilter={0x56a86895, 0x0ad4, 0x11ce,
     {0xb0, 0x3a, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
-GUID IID_IEnumPins={0x56a86892, 0x0ad4, 0x11ce,
+const GUID IID_IEnumPins={0x56a86892, 0x0ad4, 0x11ce,
     {0xb0, 0x3a, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
-GUID IID_IEnumMediaTypes={0x89c31040, 0x846b, 0x11ce,
+const GUID IID_IEnumMediaTypes={0x89c31040, 0x846b, 0x11ce,
     {0x97, 0xd3, 0x00, 0xaa, 0x00, 0x55, 0x59, 0x5a}};
-GUID IID_IMemInputPin={0x56a8689d, 0x0ad4, 0x11ce,
+const GUID IID_IMemInputPin={0x56a8689d, 0x0ad4, 0x11ce,
     {0xb0, 0x3a, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
-GUID IID_IMemAllocator={0x56a8689c, 0x0ad4, 0x11ce,
+const GUID IID_IMemAllocator={0x56a8689c, 0x0ad4, 0x11ce,
     {0xb0, 0x3a, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
-GUID IID_IMediaSample={0x56a8689a, 0x0ad4, 0x11ce,
+const GUID IID_IMediaSample={0x56a8689a, 0x0ad4, 0x11ce,
     {0xb0, 0x3a, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
 
-GUID MEDIATYPE_Video={0x73646976, 0x0000, 0x0010,
+const GUID MEDIATYPE_Video={0x73646976, 0x0000, 0x0010,
     {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
-GUID GUID_NULL={0x0, 0x0, 0x0,
+const GUID GUID_NULL={0x0, 0x0, 0x0,
     {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}};
-GUID FORMAT_VideoInfo={0x05589f80, 0xc356, 0x11ce,
+const GUID FORMAT_VideoInfo={0x05589f80, 0xc356, 0x11ce,
     {0xbf, 0x01, 0x00, 0xaa, 0x00, 0x55, 0x59, 0x5a}};
-GUID MEDIASUBTYPE_RGB565={0xe436eb7b, 0x524f, 0x11ce,
+const GUID MEDIASUBTYPE_RGB565={0xe436eb7b, 0x524f, 0x11ce,
     {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
-GUID MEDIASUBTYPE_RGB555={0xe436eb7c, 0x524f, 0x11ce,
+const GUID MEDIASUBTYPE_RGB555={0xe436eb7c, 0x524f, 0x11ce,
     {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
-GUID MEDIASUBTYPE_RGB24={0xe436eb7d, 0x524f, 0x11ce,
+const GUID MEDIASUBTYPE_RGB24={0xe436eb7d, 0x524f, 0x11ce,
     {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
-GUID MEDIASUBTYPE_RGB32={0xe436eb7e, 0x524f, 0x11ce,
+const GUID MEDIASUBTYPE_RGB32={0xe436eb7e, 0x524f, 0x11ce,
     {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
-GUID MEDIASUBTYPE_YUYV={0x56595559, 0x0000, 0x0010,
+const GUID MEDIASUBTYPE_YUYV={0x56595559, 0x0000, 0x0010,
     {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
-GUID MEDIASUBTYPE_IYUV={0x56555949, 0x0000, 0x0010,
+const GUID MEDIASUBTYPE_IYUV={0x56555949, 0x0000, 0x0010,
     {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
-GUID MEDIASUBTYPE_YVU9={0x39555659, 0x0000, 0x0010,
+const GUID MEDIASUBTYPE_YVU9={0x39555659, 0x0000, 0x0010,
     {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
-GUID MEDIASUBTYPE_Y411={0x31313459, 0x0000, 0x0010,
+const GUID MEDIASUBTYPE_Y411={0x31313459, 0x0000, 0x0010,
     {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
-GUID MEDIASUBTYPE_Y41P={0x50313459, 0x0000, 0x0010,
+const GUID MEDIASUBTYPE_Y41P={0x50313459, 0x0000, 0x0010,
     {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
-GUID MEDIASUBTYPE_YUY2={0x32595559, 0x0000, 0x0010,
-    {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
-GUID MEDIASUBTYPE_YVYU={0x55595659, 0x0000, 0x0010,
+const GUID MEDIASUBTYPE_YUY2={0x32595559, 0x0000, 0x0010,
     {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
-GUID MEDIASUBTYPE_UYVY={0x59565955, 0x0000, 0x0010,
+const GUID MEDIASUBTYPE_YVYU={0x55595659, 0x0000, 0x0010,
     {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
-GUID MEDIASUBTYPE_Y211={0x31313259, 0x0000, 0x0010,
+const GUID MEDIASUBTYPE_UYVY={0x59565955, 0x0000, 0x0010,
     {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
-GUID MEDIASUBTYPE_YV12={0x32315659, 0x0000, 0x0010,
+const GUID MEDIASUBTYPE_Y211={0x31313259, 0x0000, 0x0010,
     {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
-GUID MEDIASUBTYPE_I420={0x30323449, 0x0000, 0x0010,
+const GUID MEDIASUBTYPE_YV12={0x32315659, 0x0000, 0x0010,
+    {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
+const GUID MEDIASUBTYPE_I420={0x30323449, 0x0000, 0x0010,
     {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
-GUID MEDIASUBTYPE_IF09={0x39304649, 0x0000, 0x0010,
+const GUID MEDIASUBTYPE_IF09={0x39304649, 0x0000, 0x0010,
     {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
-GUID CLSID_MemoryAllocator={0x1e651cc0, 0xb199, 0x11d0,
+const GUID CLSID_MemoryAllocator={0x1e651cc0, 0xb199, 0x11d0,
     {0x82, 0x12, 0x00, 0xc0, 0x4f, 0xc3, 0x2c, 0x45}};
-GUID IID_DivxHidden={0x598eba01, 0xb49a, 0x11d2,
+const GUID IID_DivxHidden={0x598eba01, 0xb49a, 0x11d2,
     {0xa1, 0xc1, 0x00, 0x60, 0x97, 0x78, 0xaa, 0xaa}};
-GUID IID_Iv50Hidden={0x665a4442, 0xd905, 0x11d0,
+const GUID IID_Iv50Hidden={0x665a4442, 0xd905, 0x11d0,
     {0xa3, 0x0e, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}};
-
--- a/loader/dshow/guids.h	Fri Sep 13 19:42:33 2002 +0000
+++ b/loader/dshow/guids.h	Fri Sep 13 19:43:17 2002 +0000
@@ -1,5 +1,5 @@
-#ifndef GUIDS_H
-#define GUIDS_H
+#ifndef DS_GUIDS_H
+#define DS_GUIDS_H
 
 #include "com.h"
 #include "wine/module.h"
@@ -22,12 +22,6 @@
     char*	pbFormat;		//0x44
 } AM_MEDIA_TYPE;
 
-typedef enum
-{
-    PINDIR_INPUT = 0,
-    PINDIR_OUTPUT
-} PIN_DIRECTION;
-
 typedef long long REFERENCE_TIME;
 
 typedef struct __attribute__((__packed__)) RECT32
@@ -35,8 +29,8 @@
     int left, top, right, bottom;
 } RECT32;
 
-typedef struct __attribute__((__packed__)) tagVIDEOINFOHEADER {
-
+typedef struct __attribute__((__packed__)) tagVIDEOINFOHEADER
+{
     RECT32            rcSource;          // The bit we really want to use
     RECT32            rcTarget;          // Where the video should go
     unsigned long     dwBitRate;         // Approximate bit data rate
@@ -46,52 +40,39 @@
     //int               reserved[3];
 } VIDEOINFOHEADER;
 
-typedef struct _AllocatorProperties
-{
-    long cBuffers;
-    long cbBuffer;
-    long cbAlign;
-    long cbPrefix;
-} ALLOCATOR_PROPERTIES;
-
-typedef struct _IBaseFilter IBaseFilter;
-typedef struct _PinInfo
-{
-    IBaseFilter* pFilter;
-    PIN_DIRECTION dir;
-    unsigned short achName[128];
-} PIN_INFO;
-
+typedef GUID CLSID;
+typedef GUID IID;
 
-extern GUID IID_IBaseFilter;
-extern GUID IID_IEnumPins;
-extern GUID IID_IEnumMediaTypes;
-extern GUID IID_IMemInputPin;
-extern GUID IID_IMemAllocator;
-extern GUID IID_IMediaSample;
-extern GUID IID_DivxHidden;
-extern GUID IID_Iv50Hidden;
-extern GUID CLSID_DivxDecompressorCF;
-extern GUID IID_IDivxFilterInterface;
-extern GUID CLSID_IV50_Decoder;
-extern GUID CLSID_MemoryAllocator;
-extern GUID MEDIATYPE_Video;
-extern GUID GUID_NULL;
-extern GUID FORMAT_VideoInfo;
-extern GUID MEDIASUBTYPE_RGB565;
-extern GUID MEDIASUBTYPE_RGB555;
-extern GUID MEDIASUBTYPE_RGB24;
-extern GUID MEDIASUBTYPE_RGB32;
-extern GUID MEDIASUBTYPE_YUYV;
-extern GUID MEDIASUBTYPE_IYUV;
-extern GUID MEDIASUBTYPE_YVU9;
-extern GUID MEDIASUBTYPE_Y411;
-extern GUID MEDIASUBTYPE_Y41P;
-extern GUID MEDIASUBTYPE_YUY2;
-extern GUID MEDIASUBTYPE_YVYU;
-extern GUID MEDIASUBTYPE_UYVY;
-extern GUID MEDIASUBTYPE_Y211;
-extern GUID MEDIASUBTYPE_YV12;
-extern GUID MEDIASUBTYPE_I420;
+extern const GUID IID_IBaseFilter;
+extern const GUID IID_IEnumPins;
+extern const GUID IID_IEnumMediaTypes;
+extern const GUID IID_IMemInputPin;
+extern const GUID IID_IMemAllocator;
+extern const GUID IID_IMediaSample;
+extern const GUID IID_DivxHidden;
+extern const GUID IID_Iv50Hidden;
+extern const GUID CLSID_DivxDecompressorCF;
+extern const GUID IID_IDivxFilterInterface;
+extern const GUID CLSID_IV50_Decoder;
+extern const GUID CLSID_MemoryAllocator;
+extern const GUID MEDIATYPE_Video;
+extern const GUID GUID_NULL;
+extern const GUID FORMAT_VideoInfo;
+extern const GUID MEDIASUBTYPE_RGB565;
+extern const GUID MEDIASUBTYPE_RGB555;
+extern const GUID MEDIASUBTYPE_RGB24;
+extern const GUID MEDIASUBTYPE_RGB32;
+extern const GUID MEDIASUBTYPE_YUYV;
+extern const GUID MEDIASUBTYPE_IYUV;
+extern const GUID MEDIASUBTYPE_YVU9;
+extern const GUID MEDIASUBTYPE_Y411;
+extern const GUID MEDIASUBTYPE_Y41P;
+extern const GUID MEDIASUBTYPE_YUY2;
+extern const GUID MEDIASUBTYPE_YVYU;
+extern const GUID MEDIASUBTYPE_UYVY;
+extern const GUID MEDIASUBTYPE_Y211;
+extern const GUID MEDIASUBTYPE_YV12;
+extern const GUID MEDIASUBTYPE_I420;
+extern const GUID MEDIASUBTYPE_IF09;
 
-#endif
+#endif /* DS_GUIDS_H */
--- a/loader/dshow/inputpin.c	Fri Sep 13 19:42:33 2002 +0000
+++ b/loader/dshow/inputpin.c	Fri Sep 13 19:43:17 2002 +0000
@@ -4,7 +4,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-static int unimplemented(const char* s, void* p)
+static inline int unimplemented(const char* s, void* p)
 {
     Debug printf("%s(%p) called (UNIMPLEMENTED)", s, p);
     return E_NOTIMPL;
--- a/loader/dshow/inputpin.h	Fri Sep 13 19:42:33 2002 +0000
+++ b/loader/dshow/inputpin.h	Fri Sep 13 19:43:17 2002 +0000
@@ -33,20 +33,19 @@
 CBaseFilter* CBaseFilterCreate(const AM_MEDIA_TYPE* vhdr, CBaseFilter2* parent);
 
 
-typedef struct _CInputPin CInputPin;
-struct _CInputPin
+typedef struct
 {
     IPin_vt* vt;
     DECLARE_IUNKNOWN();
     CBaseFilter* parent;
     AM_MEDIA_TYPE type;
     GUID interfaces[1];
-};
+} CInputPin;
 
 CInputPin* CInputPinCreate(CBaseFilter* parent, const AM_MEDIA_TYPE* vhdr);
 
 
-typedef struct CRemotePin
+typedef struct
 {
     IPin_vt* vt;
     DECLARE_IUNKNOWN();
@@ -58,7 +57,7 @@
 CRemotePin* CRemotePinCreate(CBaseFilter* pt, IPin* rpin);
 
 
-typedef struct CRemotePin2
+typedef struct
 {
     IPin_vt* vt;
     DECLARE_IUNKNOWN();
--- a/loader/dshow/interfaces.h	Fri Sep 13 19:42:33 2002 +0000
+++ b/loader/dshow/interfaces.h	Fri Sep 13 19:43:17 2002 +0000
@@ -2,26 +2,41 @@
 #define DS_INTERFACES_H
 
 /*
-
-Definition of important DirectShow interfaces.
-Created using freely-available DirectX 8.0 SDK
-( http://msdn.microsoft.com )
-
-*/
+ * Definition of important DirectShow interfaces.
+ * Created using freely-available DirectX 8.0 SDK
+ * ( http://msdn.microsoft.com )
+ */
 
 #include "iunk.h"
 #include "com.h"
 
-//typedef GUID& REFIID;
-typedef GUID CLSID;
-typedef GUID IID;
-
 /*    Sh*t. MSVC++ and g++ use different methods of storing vtables.    */
 
 typedef struct _IReferenceClock IReferenceClock;
 typedef struct _IFilterGraph IFilterGraph;
 
-enum PIN_DIRECTION;
+typedef struct _IBaseFilter IBaseFilter;
+
+typedef enum
+{
+    PINDIR_INPUT = 0,
+    PINDIR_OUTPUT
+} PIN_DIRECTION;
+
+typedef struct _PinInfo
+{
+    IBaseFilter* pFilter;
+    PIN_DIRECTION dir;
+    unsigned short achName[128];
+} PIN_INFO;
+
+typedef struct _AllocatorProperties
+{
+    long cBuffers;
+    long cbBuffer;
+    long cbAlign;
+    long cbPrefix;
+} ALLOCATOR_PROPERTIES;
 
 typedef struct _IEnumMediaTypes IEnumMediaTypes;
 typedef struct IEnumMediaTypes_vt
--- a/loader/dshow/iunk.h	Fri Sep 13 19:42:33 2002 +0000
+++ b/loader/dshow/iunk.h	Fri Sep 13 19:43:17 2002 +0000
@@ -2,10 +2,9 @@
 #define DS_IUNK_H
 
 #include "guids.h"
-#include <stdlib.h>
 
 #define INHERIT_IUNKNOWN() \
-    long STDCALL ( *QueryInterface )(IUnknown * This, GUID* riid, void **ppvObject); \
+    long STDCALL ( *QueryInterface )(IUnknown * This, const GUID* riid, void **ppvObject); \
     long STDCALL ( *AddRef )(IUnknown * This); \
     long STDCALL ( *Release )(IUnknown * This);
 
@@ -14,7 +13,7 @@
 
 #define IMPLEMENT_IUNKNOWN(CLASSNAME) 		\
 static long STDCALL CLASSNAME ## _QueryInterface(IUnknown * This, \
-					  GUID* riid, void **ppvObject) \
+					  const GUID* riid, void **ppvObject) \
 { \
     CLASSNAME * me = (CLASSNAME *)This;		\
     GUID* r; unsigned int i = 0;		\
--- a/loader/dshow/outputpin.c	Fri Sep 13 19:42:33 2002 +0000
+++ b/loader/dshow/outputpin.c	Fri Sep 13 19:43:17 2002 +0000
@@ -4,13 +4,14 @@
 #include "outputpin.h"
 #include <stdio.h>
 #include <string.h>
+#include <stdlib.h>
 
 /*
     An object beyond interface IEnumMediaTypes.
     Returned by COutputPin through call IPin::EnumMediaTypes().
 */
 
-static int unimplemented(const char* s, void* p)
+static inline int output_unimplemented(const char* s, void* p)
 {
     Debug printf("%s(%p) called (UNIMPLEMENTED)", s, p);
     return E_NOTIMPL;
@@ -24,6 +25,15 @@
     GUID interfaces[2];
 } CEnumMediaTypes;
 
+struct _COutputMemPin
+{
+    IMemInputPin_vt* vt;
+    DECLARE_IUNKNOWN();
+    char** frame_pointer;
+    long* frame_size_pointer;
+    MemAllocator* pAllocator;
+    COutputPin* parent;
+};
 
 static HRESULT STDCALL CEnumMediaTypes_Next(IEnumMediaTypes * This,
 					    /* [in] */ ULONG cMediaTypes,
@@ -58,8 +68,7 @@
 static HRESULT STDCALL CEnumMediaTypes_Skip(IEnumMediaTypes * This,
 					    /* [in] */ ULONG cMediaTypes)
 {
-    Debug unimplemented("CEnumMediaTypes::Skip", This);
-    return E_NOTIMPL;
+    return output_unimplemented("CEnumMediaTypes::Skip", This);
 }
 
 static HRESULT STDCALL CEnumMediaTypes_Reset(IEnumMediaTypes * This)
@@ -121,7 +130,7 @@
  *************/
 
 
-static HRESULT STDCALL COutputPin_QueryInterface(IUnknown* This, GUID* iid, void** ppv)
+static HRESULT STDCALL COutputPin_QueryInterface(IUnknown* This, const GUID* iid, void** ppv)
 {
     COutputPin* p = (COutputPin*) This;
 
@@ -214,8 +223,7 @@
 static HRESULT STDCALL COutputPin_QueryPinInfo(IPin * This,
 					       /* [out] */ PIN_INFO *pInfo)
 {
-    Debug unimplemented("COutputPin_QueryPinInfo", This);
-    return E_NOTIMPL;
+    return output_unimplemented("COutputPin_QueryPinInfo", This);
 }
 
 static HRESULT STDCALL COutputPin_QueryDirection(IPin * This,
@@ -231,15 +239,13 @@
 static HRESULT STDCALL COutputPin_QueryId(IPin * This,
 					  /* [out] */ LPWSTR *Id)
 {
-    Debug unimplemented("COutputPin_QueryId", This);
-    return E_NOTIMPL;
+    return output_unimplemented("COutputPin_QueryId", This);
 }
 
 static HRESULT STDCALL COutputPin_QueryAccept(IPin * This,
 					      /* [in] */ const AM_MEDIA_TYPE *pmt)
 {
-    Debug unimplemented("COutputPin_QueryAccept", This);
-    return E_NOTIMPL;
+    return output_unimplemented("COutputPin_QueryAccept", This);
 }
 
 static HRESULT STDCALL COutputPin_EnumMediaTypes(IPin * This,
@@ -256,26 +262,22 @@
 						     /* [out] */ IPin **apPin,
 						     /* [out][in] */ ULONG *nPin)
 {
-    Debug unimplemented("COutputPin_QueryInternalConnections", This);
-    return E_NOTIMPL;
+    return output_unimplemented("COutputPin_QueryInternalConnections", This);
 }
 
 static HRESULT STDCALL COutputPin_EndOfStream(IPin * This)
 {
-    Debug unimplemented("COutputPin_EndOfStream", This);
-    return E_NOTIMPL;
+    return output_unimplemented("COutputPin_EndOfStream", This);
 }
 
 static HRESULT STDCALL COutputPin_BeginFlush(IPin * This)
 {
-    Debug unimplemented("COutputPin_BeginFlush", This);
-    return E_NOTIMPL;
+    return output_unimplemented("COutputPin_BeginFlush", This);
 }
 
 static HRESULT STDCALL COutputPin_EndFlush(IPin * This)
 {
-    Debug unimplemented("COutputPin_EndFlush", This);
-    return E_NOTIMPL;
+    return output_unimplemented("COutputPin_EndFlush", This);
 }
 
 static HRESULT STDCALL COutputPin_NewSegment(IPin * This,
@@ -292,7 +294,7 @@
 
 // IMemInputPin->IUnknown methods
 
-static HRESULT STDCALL COutputPin_M_QueryInterface(IUnknown* This, GUID* iid, void** ppv)
+static HRESULT STDCALL COutputPin_M_QueryInterface(IUnknown* This, const GUID* iid, void** ppv)
 {
     COutputPin* p = (COutputPin*)This;
 
@@ -351,8 +353,7 @@
 static HRESULT STDCALL COutputPin_GetAllocatorRequirements(IMemInputPin* This,
 							   /* [out] */ ALLOCATOR_PROPERTIES* pProps)
 {
-    Debug unimplemented("COutputPin_GetAllocatorRequirements", This);
-    return E_NOTIMPL;
+    return output_unimplemented("COutputPin_GetAllocatorRequirements", This);
 }
 
 static HRESULT STDCALL COutputPin_Receive(IMemInputPin* This,
@@ -395,14 +396,12 @@
 					    /* [in] */ long nSamples,
 					    /* [out] */ long *nSamplesProcessed)
 {
-    Debug unimplemented("COutputPin_ReceiveMultiple", This);
-    return E_NOTIMPL;
+    return output_unimplemented("COutputPin_ReceiveMultiple", This);
 }
 
 static HRESULT STDCALL COutputPin_ReceiveCanBlock(IMemInputPin * This)
 {
-    Debug unimplemented("COutputPin_ReceiveCanBlock", This);
-    return E_NOTIMPL;
+    return output_unimplemented("COutputPin_ReceiveCanBlock", This);
 }
 
 static void COutputPin_SetFramePointer(COutputPin* This, char** z)
--- a/loader/dshow/outputpin.h	Fri Sep 13 19:42:33 2002 +0000
+++ b/loader/dshow/outputpin.h	Fri Sep 13 19:43:17 2002 +0000
@@ -5,19 +5,9 @@
 
 #include "allocator.h"
 
+typedef struct _COutputMemPin COutputMemPin;
 typedef struct _COutputPin COutputPin;
 
-typedef struct _COutputMemPin COutputMemPin;
-struct _COutputMemPin
-{
-    IMemInputPin_vt* vt;
-    DECLARE_IUNKNOWN();
-    char** frame_pointer;
-    long* frame_size_pointer;
-    MemAllocator* pAllocator;
-    COutputPin* parent;
-};
-
 struct _COutputPin
 {
     IPin_vt* vt;
--- a/loader/elfdll.c	Fri Sep 13 19:42:33 2002 +0000
+++ b/loader/elfdll.c	Fri Sep 13 19:43:17 2002 +0000
@@ -3,16 +3,16 @@
  *
  * Copyright 1999 Bertho A. Stultiens
  */
-#include <config.h>
+#include "config.h"
 
 #ifdef HAVE_LIBDL
 
-#include <wine/windef.h>
-#include <wine/module.h>
-#include <wine/heap.h>
-#include <wine/elfdll.h>
-#include <wine/debugtools.h>
-#include <wine/winerror.h>
+#include "wine/windef.h"
+#include "wine/module.h"
+#include "wine/heap.h"
+#include "wine/elfdll.h"
+#include "wine/debugtools.h"
+#include "wine/winerror.h"
 
 //DEFAULT_DEBUG_CHANNEL(elfdll)
 
@@ -22,16 +22,6 @@
 #include <ctype.h>
 #include <dlfcn.h>
 
-struct modref_list_t;
-
-typedef struct modref_list_t
-{
-    WINE_MODREF* wm;
-    struct modref_list_t *next;
-    struct modref_list_t *prev;    
-}
-modref_list;
-
 
 //WINE_MODREF *local_wm=NULL;
 extern modref_list* local_wm;
@@ -202,7 +192,7 @@
 //		wm->binfmt.pe.pe_resource = (PIMAGE_RESOURCE_DIRECTORY)RVA(hModule, dir->VirtualAddress);
 
 
-	wm->filename = malloc(strlen(path)+1);
+	wm->filename = (char*) malloc(strlen(path)+1);
 	strcpy(wm->filename, path);
 	wm->modname = strrchr( wm->filename, '\\' );
 	if (!wm->modname) wm->modname = wm->filename;
@@ -221,7 +211,7 @@
 	
 	if(local_wm)
         {
-    	    local_wm->next=malloc(sizeof(modref_list));
+    	    local_wm->next = (modref_list*) malloc(sizeof(modref_list));
     	    local_wm->next->prev=local_wm;
     	    local_wm->next->next=NULL;
             local_wm->next->wm=wm;
@@ -229,7 +219,7 @@
 	}
 	else
         {
-	    local_wm=malloc(sizeof(modref_list));
+	    local_wm = (modref_list*) malloc(sizeof(modref_list));
 	    local_wm->next=local_wm->prev=NULL;
     	    local_wm->wm=wm;
 	}	
--- a/loader/ext.c	Fri Sep 13 19:42:33 2002 +0000
+++ b/loader/ext.c	Fri Sep 13 19:43:17 2002 +0000
@@ -18,10 +18,11 @@
 #include <string.h>
 #include <stdarg.h>
 #include <ctype.h>
-#include <wine/windef.h>
-#include <wine/winbase.h>
-#include <wine/debugtools.h>
-#include <wine/heap.h>
+
+#include "wine/windef.h"
+#include "wine/winbase.h"
+#include "wine/debugtools.h"
+#include "wine/heap.h"
 #include "ext.h"
 
 #if 0
@@ -188,18 +189,18 @@
 LPSTR HEAP_strdupA(HANDLE heap, DWORD flags, LPCSTR string)
 {
 //    return strdup(string);
-    char* answ=malloc(strlen(string)+1);
+    char* answ = (char*) malloc(strlen(string) + 1);
     strcpy(answ, string);
     return answ;
 }
 LPWSTR HEAP_strdupAtoW(HANDLE heap, DWORD flags, LPCSTR string)
 {
     int size, i;
-    short* answer;
+    WCHAR* answer;
     if(string==0)
 	return 0;
     size=strlen(string);
-    answer=malloc(2 * (size + 1));
+    answer = (WCHAR*) malloc(sizeof(WCHAR) * (size + 1));
     for(i=0; i<=size; i++)
 	answer[i]=(short)string[i];
     return answer;
@@ -213,7 +214,7 @@
     size=0;
     while(string[size])
        size++;
-    answer=malloc(size+2);
+    answer = (char*) malloc(size + 2);
     for(i=0; i<=size; i++)
 	answer[i]=(char)string[i];
     return answer;
@@ -390,12 +391,12 @@
     {
 	if(fm==0)
 	{
-	    fm=malloc(sizeof(file_mapping));
+	    fm = (file_mapping*) malloc(sizeof(file_mapping));
 	    fm->prev=NULL;
 	}
 	else
 	{
-	    fm->next=malloc(sizeof(file_mapping));
+	    fm->next = (file_mapping*) malloc(sizeof(file_mapping));
 	    fm->next->prev=fm;
 	    fm=fm->next;
 	}
@@ -403,7 +404,7 @@
 	fm->handle=answer;
 	if(name)
 	{
-	    fm->name=malloc(strlen(name)+1);
+	    fm->name = (char*) malloc(strlen(name)+1);
 	    strcpy(fm->name, name);
 	}
 	else
@@ -509,9 +510,9 @@
     }
     else
     {
-	virt_alloc *new_vm=malloc(sizeof(virt_alloc));
+	virt_alloc *new_vm = (virt_alloc*) malloc(sizeof(virt_alloc));
 	new_vm->mapping_size=size;
-	new_vm->address=answer;
+	new_vm->address=(char*)answer;
         new_vm->prev=vm;
 	if(type == MEM_RESERVE)
 	    new_vm->state=0;
--- a/loader/ext.h	Fri Sep 13 19:42:33 2002 +0000
+++ b/loader/ext.h	Fri Sep 13 19:43:17 2002 +0000
@@ -1,7 +1,7 @@
 #ifndef loader_ext_h
 #define loader_ext_h
 
-#include <wine/windef.h>
+#include "wine/windef.h"
 
 extern LPVOID FILE_dommap( int unix_handle, LPVOID start,
 			   DWORD size_high, DWORD size_low,
--- a/loader/ldt_keeper.c	Fri Sep 13 19:42:33 2002 +0000
+++ b/loader/ldt_keeper.c	Fri Sep 13 19:43:17 2002 +0000
@@ -4,8 +4,13 @@
  * be modified before program creates first thread
  * - avifile includes this file from C++ code
  * and initializes it at the start of player!
+ * it might sound like a hack and it really is - but
+ * as aviplay is deconding video with more than just one
+ * thread currently it's necessary to do it this way
+ * this might change in the future
  */
 
+/* applied some modification to make make our xine friend more happy */
 #include "ldt_keeper.h"
 
 #include <string.h>
@@ -19,6 +24,14 @@
 #ifdef __linux__
 #include <asm/unistd.h>
 #include <asm/ldt.h>
+/* prototype it here, so we won't depend on kernel headers */
+#ifdef  __cplusplus
+extern "C" {
+#endif
+int modify_ldt(int func, void *ptr, unsigned long bytecount);
+#ifdef  __cplusplus
+}
+#endif
 #else
 #if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__)
 #include <machine/segments.h>
@@ -33,7 +46,7 @@
 #ifdef  __cplusplus
 extern "C" {
 #endif
-extern int sysi86(int, void*);
+int sysi86(int, void*);
 #ifdef  __cplusplus
 }
 #endif
@@ -69,21 +82,14 @@
 /* user level (privilege level: 3) ldt (1<<2) segment selector */
 #define       LDT_SEL(idx) ((idx) << 3 | 1 << 2 | 3)
 
+/* i got this value from wine sources, it's the first free LDT entry */
 #ifndef       TEB_SEL_IDX
-#define       TEB_SEL_IDX     1
+#define       TEB_SEL_IDX     17
 #endif
+
 #define       TEB_SEL LDT_SEL(TEB_SEL_IDX)
 
 /**
- *
- *  This should be performed before we create first thread. See remarks
- *  for write_ldt(), linux/kernel/ldt.c.
- *
- */
-
-void* fs_seg = NULL;
-static char* prev_struct = NULL;
-/**
  * here is a small logical problem with Restore for multithreaded programs -
  * in C++ we use static class for this...
  */
@@ -98,6 +104,8 @@
     );
 }
 
+/* we don't need this - use modify_ldt instead */
+#if 0
 #ifdef __linux__
 /* XXX: why is this routine from libc redefined here? */
 /* NOTE: the redefined version ignores the count param, count is hardcoded as 16 */
@@ -130,6 +138,7 @@
     return -1;
 }
 #endif
+#endif
 
 #if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__)
 static void LDT_EntryToBytes( unsigned long *buffer, const struct modify_ldt_ldt_s *content )
@@ -147,31 +156,34 @@
 }
 #endif
 
-void Setup_LDT_Keeper(void)
+//void* fs_seg=0;
+
+ldt_fs_t* Setup_LDT_Keeper(void)
 {
     struct modify_ldt_ldt_s array;
-    int fd;
     int ret;
+    ldt_fs_t* ldt_fs = (ldt_fs_t*) malloc(sizeof(ldt_fs_t));
 
-    if (fs_seg)
-        return;
+    if (!ldt_fs)
+	return NULL;
 
-    prev_struct = 0;
-    fd = open("/dev/zero", O_RDWR);
-    if(fd<0){
-        perror( "Cannot open /dev/zero for READ+WRITE. Check permissions! error: " );
-	return;
+    ldt_fs->fd = open("/dev/zero", O_RDWR);
+    if(ldt_fs->fd<0){
+        perror( "Cannot open /dev/zero for READ+WRITE. Check permissions! error: ");
+	return NULL;
     }
-    fs_seg = mmap(NULL, getpagesize(), PROT_READ | PROT_WRITE, MAP_PRIVATE,
-		  fd, 0);
-    if(fs_seg==(void*)-1)
+//    fs_seg=
+    ldt_fs->fs_seg = mmap(NULL, getpagesize(), PROT_READ | PROT_WRITE, MAP_PRIVATE,
+			  ldt_fs->fd, 0);
+    if (ldt_fs->fs_seg == (void*)-1)
     {
 	perror("ERROR: Couldn't allocate memory for fs segment");
-	return;
+        close(ldt_fs->fd);
+        free(ldt_fs);
+	return NULL;
     }
-//    printf("fs seg %p\n", fs_seg);
-    *(void**)((char*)fs_seg+0x18) = fs_seg;
-    array.base_addr=(int)fs_seg;
+    *(void**)((char*)ldt_fs->fs_seg+0x18) = ldt_fs->fs_seg;
+    array.base_addr=(int)ldt_fs->fs_seg;
     array.entry_number=TEB_SEL_IDX;
     array.limit=array.base_addr+getpagesize()-1;
     array.seg_32bit=1;
@@ -180,7 +192,8 @@
     array.contents=MODIFY_LDT_CONTENTS_DATA;
     array.limit_in_pages=0;
 #ifdef __linux__
-    ret=LDT_Modify(0x1, &array, sizeof(struct modify_ldt_ldt_s));
+    //ret=LDT_Modify(0x1, &array, sizeof(struct modify_ldt_ldt_s));
+    ret=modify_ldt(0x1, &array, sizeof(struct modify_ldt_ldt_s));
     if(ret<0)
     {
 	perror("install_fs");
@@ -200,7 +213,6 @@
 	    printf("Couldn't install fs segment, expect segfault\n");
             printf("Did you reconfigure the kernel with \"options USER_LDT\"?\n");
         }
-	printf("Set_LDT\n");
     }
 #endif  /* __NetBSD__ || __FreeBSD__ || __OpenBSD__ */
 
@@ -223,17 +235,20 @@
 
     Setup_FS_Segment();
 
-    prev_struct = (char*)malloc(sizeof(char) * 8);
-    *(void**)array.base_addr = prev_struct;
-    close(fd);
+    ldt_fs->prev_struct = (char*)malloc(sizeof(char) * 8);
+    *(void**)array.base_addr = ldt_fs->prev_struct;
+
+    return ldt_fs;
 }
 
-void Restore_LDT_Keeper(void)
+void Restore_LDT_Keeper(ldt_fs_t* ldt_fs)
 {
-    if (fs_seg == 0)
+    if (ldt_fs == NULL || ldt_fs->fs_seg == 0)
 	return;
-    if (prev_struct)
-	free(prev_struct);
-    munmap((char*)fs_seg, getpagesize());
-    fs_seg = 0;
+    if (ldt_fs->prev_struct)
+	free(ldt_fs->prev_struct);
+    munmap((char*)ldt_fs->fs_seg, getpagesize());
+    ldt_fs->fs_seg = 0;
+    close(ldt_fs->fd);
+    free(ldt_fs);
 }
--- a/loader/ldt_keeper.h	Fri Sep 13 19:42:33 2002 +0000
+++ b/loader/ldt_keeper.h	Fri Sep 13 19:43:17 2002 +0000
@@ -5,9 +5,16 @@
 extern "C"
 {
 #endif
+
+typedef struct {
+  void* fs_seg;
+  char* prev_struct;
+  int fd;
+} ldt_fs_t;
+
 void Setup_FS_Segment(void);
-void Setup_LDT_Keeper(void);
-void Restore_LDT_Keeper(void);
+ldt_fs_t* Setup_LDT_Keeper(void);
+void Restore_LDT_Keeper(ldt_fs_t* ldt_fs);
 #ifdef __cplusplus
 }
 #endif
--- a/loader/loader.h	Fri Sep 13 19:42:33 2002 +0000
+++ b/loader/loader.h	Fri Sep 13 19:43:17 2002 +0000
@@ -8,16 +8,16 @@
 
 #ifndef _LOADER_H
 #define _LOADER_H
-#include <wine/windef.h>
-#include <wine/driver.h>
-#include <wine/mmreg.h>
-#include <wine/vfw.h>
-#include <wine/msacm.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-extern char* win32_codec_name;  // must be set before calling DrvOpen() !!!
+#include "wine/windef.h"
+#include "wine/driver.h"
+#include "wine/mmreg.h"
+#include "wine/vfw.h"
+#include "wine/msacm.h"
 
 unsigned int _GetPrivateProfileIntA(const char* appname, const char* keyname, int default_value, const char* filename);
 int _GetPrivateProfileStringA(const char* appname, const char* keyname,
@@ -25,261 +25,6 @@
 int _WritePrivateProfileStringA(const char* appname, const char* keyname,
 	const char* string, const char* filename);
 
-
-/**********************************************
-
-    MS VFW ( Video For Windows ) interface
-	    
-**********************************************/	    
-
-long VFWAPIV ICCompress(
-	HIC hic,long dwFlags,LPBITMAPINFOHEADER lpbiOutput,void* lpData,
-	LPBITMAPINFOHEADER lpbiInput,void* lpBits,long* lpckid,
-	long* lpdwFlags,long lFrameNum,long dwFrameSize,long dwQuality,
-	LPBITMAPINFOHEADER lpbiPrev,void* lpPrev
-);
-
-long VFWAPIV ICDecompress(HIC hic,long dwFlags,LPBITMAPINFOHEADER lpbiFormat,void* lpData,LPBITMAPINFOHEADER lpbi,void* lpBits);
-
-WIN_BOOL	VFWAPI	ICInfo(long fccType, long fccHandler, ICINFO * lpicinfo);
-LRESULT	VFWAPI	ICGetInfo(HIC hic,ICINFO *picinfo, long cb);
-HIC	VFWAPI	ICOpen(long fccType, long fccHandler, UINT wMode);
-HIC	VFWAPI	ICOpenFunction(long fccType, long fccHandler, unsigned int wMode, void* lpfnHandler);
-
-LRESULT VFWAPI ICClose(HIC hic);
-LRESULT	VFWAPI ICSendMessage(HIC hic, unsigned int msg, long dw1, long dw2);
-HIC	VFWAPI ICLocate(long fccType, long fccHandler, LPBITMAPINFOHEADER lpbiIn, LPBITMAPINFOHEADER lpbiOut, short wFlags);
-
-int VFWAPI ICDoSomething();
-
-#define ICCompressGetFormat(hic, lpbiInput, lpbiOutput) 		\
-	ICSendMessage(							\
-	    hic,ICM_COMPRESS_GET_FORMAT,(long)(void*)(lpbiInput),	\
-	    (long)(void*)(lpbiOutput)					\
-	)
-
-#define ICCompressGetFormatSize(hic,lpbi) ICCompressGetFormat(hic,lpbi,NULL)
-
-#define ICGetDefaultKeyFrameRate(hic,lpint) 		\
-	ICSendMessage(					\
-	    hic, ICM_GETDEFAULTKEYFRAMERATE,		\
-	    (long)(void*)(lpint), 			\
-	    0	)		
-
-#define ICGetDefaultQuality(hic,lpint) 			\
-	ICSendMessage(					\
-	    hic, ICM_GETDEFAULTQUALITY,			\
-	    (long)(void*)(lpint), 			\
-	    0	)		
-	    	
-
-#define ICCompressBegin(hic, lpbiInput, lpbiOutput) 			\
-    ICSendMessage(							\
-    	hic, ICM_COMPRESS_BEGIN, (long)(void*)(lpbiInput),		\
-	(long)(void*)(lpbiOutput)					\
-    )
-
-#define ICCompressGetSize(hic, lpbiInput, lpbiOutput) 		\
-    ICSendMessage(							\
-    	hic, ICM_COMPRESS_GET_SIZE, (long)(void*)(lpbiInput), 	\
-	(long)(void*)(lpbiOutput)					\
-    )
-
-#define ICCompressQuery(hic, lpbiInput, lpbiOutput)		\
-    ICSendMessage(						\
-    	hic, ICM_COMPRESS_QUERY, (long)(void*)(lpbiInput),	\
-	(long)(void*)(lpbiOutput)				\
-    )
-
-
-#define ICCompressEnd(hic) ICSendMessage(hic, ICM_COMPRESS_END, 0, 0)
-
-
-
-#define ICDecompressBegin(hic, lpbiInput, lpbiOutput) 	\
-    ICSendMessage(						\
-    	hic, ICM_DECOMPRESS_BEGIN, (long)(void*)(lpbiInput),	\
-	(long)(void*)(lpbiOutput)				\
-    )
-
-#define ICDecompressQuery(hic, lpbiInput, lpbiOutput) 	\
-    ICSendMessage(						\
-    	hic,ICM_DECOMPRESS_QUERY, (long)(void*)(lpbiInput),	\
-	(long) (void*)(lpbiOutput)				\
-    )
-
-#define ICDecompressGetFormat(hic, lpbiInput, lpbiOutput)		\
-    ((long)ICSendMessage(						\
-    	hic,ICM_DECOMPRESS_GET_FORMAT, (long)(void*)(lpbiInput),	\
-	(long)(void*)(lpbiOutput)					\
-    ))
-
-#define ICDecompressGetFormatSize(hic, lpbi) 				\
-	ICDecompressGetFormat(hic, lpbi, NULL)
-
-#define ICDecompressGetPalette(hic, lpbiInput, lpbiOutput)		\
-    ICSendMessage(							\
-    	hic, ICM_DECOMPRESS_GET_PALETTE, (long)(void*)(lpbiInput), 	\
-	(long)(void*)(lpbiOutput)					\
-    )
-
-#define ICDecompressSetPalette(hic,lpbiPalette)	\
-        ICSendMessage(				\
-		hic,ICM_DECOMPRESS_SET_PALETTE,		\
-		(long)(void*)(lpbiPalette),0		\
-	)
-
-#define ICDecompressEnd(hic) ICSendMessage(hic, ICM_DECOMPRESS_END, 0, 0)
-
-
-/*****************************************************
-
-    MS ACM ( Audio Compression Manager ) interface
-	    
-******************************************************/	    
-
-
-MMRESULT WINAPI acmDriverAddA(
-  PHACMDRIVERID phadid, HINSTANCE hinstModule,
-  LPARAM lParam, DWORD dwPriority, DWORD fdwAdd
-);
-MMRESULT WINAPI acmDriverAddW(
-  PHACMDRIVERID phadid, HINSTANCE hinstModule,
-  LPARAM lParam, DWORD dwPriority, DWORD fdwAdd
-);
-MMRESULT WINAPI acmDriverClose(
-  HACMDRIVER had, DWORD fdwClose
-);
-MMRESULT WINAPI acmDriverDetailsA(
-  HACMDRIVERID hadid, PACMDRIVERDETAILSA padd, DWORD fdwDetails
-);
-MMRESULT WINAPI acmDriverDetailsW(
-  HACMDRIVERID hadid, PACMDRIVERDETAILSW padd, DWORD fdwDetails
-);
-MMRESULT WINAPI acmDriverEnum(
-  ACMDRIVERENUMCB fnCallback, DWORD dwInstance, DWORD fdwEnum
-);
-MMRESULT WINAPI acmDriverID(
-  HACMOBJ hao, PHACMDRIVERID phadid, DWORD fdwDriverID
-);
-LRESULT WINAPI acmDriverMessage(
-  HACMDRIVER had, UINT uMsg, LPARAM lParam1, LPARAM lParam2
-);
-MMRESULT WINAPI acmDriverOpen(
-  PHACMDRIVER phad, HACMDRIVERID hadid, DWORD fdwOpen
-);
-MMRESULT WINAPI acmDriverPriority(
-  HACMDRIVERID hadid, DWORD dwPriority, DWORD fdwPriority
-);
-MMRESULT WINAPI acmDriverRemove(
-  HACMDRIVERID hadid, DWORD fdwRemove
-);
-MMRESULT WINAPI acmFilterChooseA(
-  PACMFILTERCHOOSEA pafltrc
-);
-MMRESULT WINAPI acmFilterChooseW(
-  PACMFILTERCHOOSEW pafltrc
-);
-MMRESULT WINAPI acmFilterDetailsA(
-  HACMDRIVER had, PACMFILTERDETAILSA pafd, DWORD fdwDetails
-);
-MMRESULT WINAPI acmFilterDetailsW(
-  HACMDRIVER had, PACMFILTERDETAILSW pafd, DWORD fdwDetails
-);
-MMRESULT WINAPI acmFilterEnumA(
-  HACMDRIVER had, PACMFILTERDETAILSA pafd, 
-  ACMFILTERENUMCBA fnCallback, DWORD dwInstance, DWORD fdwEnum
-);
-MMRESULT WINAPI acmFilterEnumW(
-  HACMDRIVER had, PACMFILTERDETAILSW pafd, 
-  ACMFILTERENUMCBW fnCallback, DWORD dwInstance, DWORD fdwEnum
-);
-MMRESULT WINAPI acmFilterTagDetailsA(
-  HACMDRIVER had, PACMFILTERTAGDETAILSA paftd, DWORD fdwDetails
-);
-MMRESULT WINAPI acmFilterTagDetailsW(
-  HACMDRIVER had, PACMFILTERTAGDETAILSW paftd, DWORD fdwDetails
-);
-MMRESULT WINAPI acmFilterTagEnumA(
-  HACMDRIVER had, PACMFILTERTAGDETAILSA paftd,
-  ACMFILTERTAGENUMCBA fnCallback, DWORD dwInstance, DWORD fdwEnum
-);
-MMRESULT WINAPI acmFilterTagEnumW(
-  HACMDRIVER had, PACMFILTERTAGDETAILSW paftd,
-  ACMFILTERTAGENUMCBW fnCallback, DWORD dwInstance, DWORD fdwEnum
-);
-MMRESULT WINAPI acmFormatChooseA(
-  PACMFORMATCHOOSEA pafmtc
-);
-MMRESULT WINAPI acmFormatChooseW(
-  PACMFORMATCHOOSEW pafmtc
-);
-MMRESULT WINAPI acmFormatDetailsA(
-  HACMDRIVER had, PACMFORMATDETAILSA pafd, DWORD fdwDetails
-);
-MMRESULT WINAPI acmFormatDetailsW(
-  HACMDRIVER had, PACMFORMATDETAILSW pafd, DWORD fdwDetails
-);
-MMRESULT WINAPI acmFormatEnumA(
-  HACMDRIVER had, PACMFORMATDETAILSA pafd,
-  ACMFORMATENUMCBA fnCallback, DWORD dwInstance, DWORD fdwEnum
-);
-MMRESULT WINAPI acmFormatEnumW(
-  HACMDRIVER had, PACMFORMATDETAILSW pafd,
-  ACMFORMATENUMCBW fnCallback, DWORD dwInstance,  DWORD fdwEnum
-);
-MMRESULT WINAPI acmFormatSuggest(
-  HACMDRIVER had, PWAVEFORMATEX pwfxSrc, PWAVEFORMATEX pwfxDst,
-  DWORD cbwfxDst, DWORD fdwSuggest
-);
-MMRESULT WINAPI acmFormatTagDetailsA(
-  HACMDRIVER had, PACMFORMATTAGDETAILSA paftd, DWORD fdwDetails
-);
-MMRESULT WINAPI acmFormatTagDetailsW(
-  HACMDRIVER had, PACMFORMATTAGDETAILSW paftd, DWORD fdwDetails
-);
-MMRESULT WINAPI acmFormatTagEnumA(
-  HACMDRIVER had, PACMFORMATTAGDETAILSA paftd,
-  ACMFORMATTAGENUMCBA fnCallback, DWORD dwInstance, DWORD fdwEnum
-);
-MMRESULT WINAPI acmFormatTagEnumW(
-  HACMDRIVER had, PACMFORMATTAGDETAILSW paftd,
-  ACMFORMATTAGENUMCBW fnCallback, DWORD dwInstance, DWORD fdwEnum
-);
-DWORD WINAPI acmGetVersion(
-);
-MMRESULT WINAPI acmMetrics(
-  HACMOBJ hao, UINT  uMetric, LPVOID  pMetric
-);
-MMRESULT WINAPI acmStreamClose(
-  HACMSTREAM has, DWORD fdwClose
-);
-MMRESULT WINAPI acmStreamConvert(
-  HACMSTREAM has, PACMSTREAMHEADER pash, DWORD fdwConvert
-);
-MMRESULT WINAPI acmStreamMessage(
-  HACMSTREAM has, UINT uMsg, LPARAM lParam1, LPARAM lParam2
-);
-MMRESULT WINAPI acmStreamOpen(
-  PHACMSTREAM phas, HACMDRIVER had, PWAVEFORMATEX pwfxSrc,
-  PWAVEFORMATEX pwfxDst, PWAVEFILTER pwfltr, DWORD dwCallback,
-  DWORD dwInstance, DWORD fdwOpen
-);
-MMRESULT WINAPI acmStreamPrepareHeader(
-  HACMSTREAM has, PACMSTREAMHEADER pash, DWORD fdwPrepare
-);
-MMRESULT WINAPI acmStreamReset(
-  HACMSTREAM has, DWORD fdwReset
-);
-MMRESULT WINAPI acmStreamSize(
-  HACMSTREAM has, DWORD cbInput, 
-  LPDWORD pdwOutputBytes, DWORD fdwSize
-);
-MMRESULT WINAPI acmStreamUnprepareHeader(
-  HACMSTREAM has, PACMSTREAMHEADER pash, DWORD fdwUnprepare
-);
-void MSACM_RegisterAllDrivers(void);
-
 INT WINAPI LoadStringA( HINSTANCE instance, UINT resource_id,
                             LPSTR buffer, INT buflen );
 
--- a/loader/module.c	Fri Sep 13 19:42:33 2002 +0000
+++ b/loader/module.c	Fri Sep 13 19:43:17 2002 +0000
@@ -16,32 +16,22 @@
 #include <sys/types.h>
 
 
-#include <wine/windef.h>
-#include <wine/winerror.h>
-#include <wine/heap.h>
-#include <wine/module.h>
-#include <wine/pe_image.h>
-#include <wine/debugtools.h>
+#include "wine/windef.h"
+#include "wine/winerror.h"
+#include "wine/heap.h"
+#include "wine/module.h"
+#include "wine/pe_image.h"
+#include "wine/debugtools.h"
 #ifdef HAVE_LIBDL
 #include <dlfcn.h>
-#include <wine/elfdll.h>
+#include "wine/elfdll.h"
 #endif
 #include "win32.h"
-#include "module.h"
-//#include "driver.h"
+#include "driver.h"
 
 //#undef TRACE
 //#define TRACE printf
 
-struct modref_list_t;
-
-typedef struct modref_list_t
-{
-    WINE_MODREF* wm;
-    struct modref_list_t *next;
-    struct modref_list_t *prev;
-} modref_list;
-
 //WINE_MODREF *local_wm=NULL;
 modref_list* local_wm=NULL;
 
@@ -217,7 +207,7 @@
     //local_wm=wm;
     if(local_wm)
     {
-        local_wm->next=malloc(sizeof(modref_list));
+	local_wm->next = (modref_list*) malloc(sizeof(modref_list));
         local_wm->next->prev=local_wm;
         local_wm->next->next=NULL;
         local_wm->next->wm=wm;
@@ -225,7 +215,7 @@
     }
     else
     {
-	local_wm=malloc(sizeof(modref_list));
+	local_wm = (modref_list*)malloc(sizeof(modref_list));
 	local_wm->next=local_wm->prev=NULL;
 	local_wm->wm=wm;
     }
@@ -354,7 +344,6 @@
 		SetLastError(ERROR_INVALID_PARAMETER);
 		return 0;
 	}
-	printf("Loading DLL: '%s'\n", libname);
 //	if(fs_installed==0)
 //	    install_fs();
 
@@ -406,14 +395,7 @@
 
 	if (!wm)
 	    printf("Win32 LoadLibrary failed to load: %s\n", checked);
-	else
-	{
-	    extern char *win32_codec_name;
-//	    printf("Loaded %s to address %p\n", libname, wm->module);
-	    /* XXX: FIXME, _VERY_ UGLY HACK */
-	    if (!strcmp(libname, "m3jpegdec.ax"))
-		win32_codec_name = strdup("m3jpeg32.dll");
-	}
+
 
 	return wm ? wm->module : 0;
 }
--- a/loader/module.h	Fri Sep 13 19:42:33 2002 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-#ifndef LOADER_MODULE_H
-#define LOADER_MODULE_H
-void CodecRelease(void);
-void CodecAlloc(void);
-
-#endif // LOADER_MODULE_H
--- a/loader/pe_image.c	Fri Sep 13 19:42:33 2002 +0000
+++ b/loader/pe_image.c	Fri Sep 13 19:43:17 2002 +0000
@@ -34,7 +34,6 @@
  *   to 4096 byte boundaries on disk.
  */
 #include "config.h"
-//#include <wine/config.h>
 
 #include <errno.h>
 #include <assert.h>
@@ -48,13 +47,13 @@
 #ifdef HAVE_SYS_MMAN_H
 #include <sys/mman.h>
 #endif
-#include <wine/windef.h>
-#include <wine/winbase.h>
-#include <wine/winerror.h>
-#include <wine/heap.h>
-#include <wine/pe_image.h>
-#include <wine/module.h>
-#include <wine/debugtools.h>
+#include "wine/windef.h"
+#include "wine/winbase.h"
+#include "wine/winerror.h"
+#include "wine/heap.h"
+#include "wine/pe_image.h"
+#include "wine/module.h"
+#include "wine/debugtools.h"
 #include "ext.h"
 #include "win32.h"
 
@@ -68,7 +67,7 @@
 static void dump_exports( HMODULE hModule )
 { 
   char		*Module;
-  int		i, j;
+  unsigned int i, j;
   u_short	*ordinal;
   u_long	*function,*functions;
   u_char	**name;
@@ -125,7 +124,8 @@
 {
 	u_short				* ordinals;
 	u_long				* function;
-	u_char				** name, *ename = NULL;
+	u_char				** name;
+	const char *ename = NULL;
 	int				i, ordinal;
 	PE_MODREF			*pem = &(wm->binfmt.pe);
 	IMAGE_EXPORT_DIRECTORY 		*exports = pem->pe_export;
@@ -161,8 +161,8 @@
             while (min <= max)
             {
                 int res, pos = (min + max) / 2;
-                ename = RVA(name[pos]);
-                if (!(res = strcmp( ename, funcName )))
+		ename = (const char*) RVA(name[pos]);
+		if (!(res = strcmp( ename, funcName )))
                 {
                     ordinal = ordinals[pos];
                     goto found;
@@ -171,9 +171,9 @@
                 else min = pos + 1;
             }
             
-            for (i = 0; i < exports->NumberOfNames; i++)
+	    for (i = 0; i < exports->NumberOfNames; i++)
             {
-                ename = RVA(name[i]);
+		ename = (const char*) RVA(name[i]);
                 if (!strcmp( ename, funcName ))
                 {
 		    ERR( "%s.%s required a linear search\n", wm->modname, funcName );
--- a/loader/pe_resource.c	Fri Sep 13 19:42:33 2002 +0000
+++ b/loader/pe_resource.c	Fri Sep 13 19:43:17 2002 +0000
@@ -9,20 +9,20 @@
  * Copyright 1995 Alexandre Julliard
  * Copyright 1997 Marcus Meissner
  */
-#include <config.h>
+#include "config.h"
 
 #include <stdlib.h>
 #include <sys/types.h>
-#include <wine/winestring.h>
-#include <wine/windef.h>
-#include <wine/pe_image.h>
-#include <wine/module.h>
-#include <wine/heap.h>
+#include "wine/winestring.h"
+#include "wine/windef.h"
+#include "wine/pe_image.h"
+#include "wine/module.h"
+#include "wine/heap.h"
 //#include "task.h"
 //#include "process.h"
 //#include "stackframe.h"
-#include <wine/debugtools.h>
-#include <ext.h>
+#include "wine/debugtools.h"
+#include "ext.h"
 
 /**********************************************************************
  *  HMODULE32toPE_MODREF 
--- a/loader/registry.c	Fri Sep 13 19:42:33 2002 +0000
+++ b/loader/registry.c	Fri Sep 13 19:43:17 2002 +0000
@@ -7,10 +7,10 @@
 #include <pwd.h>
 #include <sys/types.h>
 
-#include <wine/winbase.h>
-#include <wine/winreg.h>
-#include <wine/winnt.h>
-#include <wine/winerror.h>
+#include "wine/winbase.h"
+#include "wine/winreg.h"
+#include "wine/winnt.h"
+#include "wine/winerror.h"
 
 #include "ext.h"
 #include "registry.h"
@@ -210,7 +210,7 @@
 }
 static int generate_handle()
 {
-	static int zz=249;
+	static unsigned int zz=249;
 	zz++;
 	while((zz==HKEY_LOCAL_MACHINE) || (zz==HKEY_CURRENT_USER))
 		zz++;
@@ -281,6 +281,7 @@
 	    free(v->value);
 	    free(v->name);
 	}
+	TRACE("RegInsert '%s'  %p  v:%d  len:%d\n", name, value, *(int*)value, len);
 	v->type=type;
 	v->len=len;
 	v->value=(char*)malloc(len);
@@ -381,10 +382,10 @@
 }
 long RegCloseKey(long key)
 {
-        reg_handle_t *handle;
-    if(key==HKEY_LOCAL_MACHINE)
+    reg_handle_t *handle;
+    if(key==(long)HKEY_LOCAL_MACHINE)
 	return 0;
-    if(key==HKEY_CURRENT_USER)
+    if(key==(long)HKEY_CURRENT_USER)
 	return 0;
     handle=find_handle(key);
     if(handle==0)
@@ -403,65 +404,65 @@
 
 long RegQueryValueExA(long key, const char* value, int* reserved, int* type, int* data, int* count)
 {
-	struct reg_value* t;
-	char* c;
-	TRACE("Querying value %s\n", value);
-	if(!regs)
-	    init_registry();
+    struct reg_value* t;
+    char* c;
+    TRACE("Querying value %s\n", value);
+    if(!regs)
+	init_registry();
 
-	c=build_keyname(key, value);
-	if(c==NULL)
-	    	return 1;
-        t=find_value_by_name(c);
-	free(c);
-	if(t==0)
-		return 2;
-	if(type)
-		*type=t->type;
-	if(data)
-	{
-		memcpy(data, t->value, (t->len<*count)?t->len:*count);
-		TRACE("returning %d bytes: %d\n", t->len, *(int*)data);
-	}
-		if(*count<t->len)
-		{
-			*count=t->len;
-			return ERROR_MORE_DATA;
+    c=build_keyname(key, value);
+    if (!c)
+	return 1;
+    t=find_value_by_name(c);
+    free(c);
+    if (t==0)
+	return 2;
+    if (type)
+	*type=t->type;
+    if (data)
+    {
+	memcpy(data, t->value, (t->len<*count)?t->len:*count);
+	TRACE("returning %d bytes: %d\n", t->len, *(int*)data);
+    }
+    if(*count<t->len)
+    {
+	*count=t->len;
+	return ERROR_MORE_DATA;
     }
     else
     {
-        *count=t->len;
-	}
+	*count=t->len;
+    }
     return 0;
 }
 long RegCreateKeyExA(long key, const char* name, long reserved,
 		     void* classs, long options, long security,
 		     void* sec_attr, int* newkey, int* status)
 {
-	reg_handle_t* t;
-	char* fullname;
-	struct reg_value* v;
-//        TRACE("Creating/Opening key %s\n", name);
-        TRACE("Creating/Opening key %s\n", name);
-	if(!regs)
-	    init_registry();
+    reg_handle_t* t;
+    char* fullname;
+    struct reg_value* v;
+    //        TRACE("Creating/Opening key %s\n", name);
+    if(!regs)
+	init_registry();
 
-	fullname=build_keyname(key, name);
-	if(fullname==NULL)
-		return 1;
-	v=find_value_by_name(fullname);
-	if(v==0)
-	{
-		int qw=45708;
-		v=insert_reg_value(key, name, DIR, &qw, 4);
-		if (status) *status=REG_CREATED_NEW_KEY;
-//		return 0;
-	}
+    fullname=build_keyname(key, name);
+    if (!fullname)
+	return 1;
+    TRACE("Creating/Opening key %s\n", fullname);
+    v=find_value_by_name(fullname);
+    if(v==0)
+    {
+	int qw=45708;
+	v=insert_reg_value(key, name, DIR, &qw, 4);
+	if (status) *status=REG_CREATED_NEW_KEY;
+	//		return 0;
+    }
 
-	t=insert_handle(generate_handle(), fullname);
-	*newkey=t->handle;
-	free(fullname);
-	return 0;
+    t=insert_handle(generate_handle(), fullname);
+    *newkey=t->handle;
+    free(fullname);
+    return 0;
 }
 
 /*
@@ -505,7 +506,7 @@
 {
     struct reg_value* t;
     char* c;
-    TRACE("Request to set value %s\n", name);
+    TRACE("Request to set value %s %d\n", name, *(const int*)data);
     if(!regs)
 	init_registry();
 
--- a/loader/resource.c	Fri Sep 13 19:42:33 2002 +0000
+++ b/loader/resource.c	Fri Sep 13 19:43:17 2002 +0000
@@ -4,7 +4,7 @@
  * Copyright 1993 Robert J. Amstadt
  * Copyright 1995 Alexandre Julliard
  */
-#include <config.h>
+#include "config.h"
 
 #include <assert.h>
 #include <stdio.h>
@@ -14,14 +14,15 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <unistd.h>
-#include <wine/winbase.h>
-#include <wine/windef.h>
-#include <wine/winuser.h>
-#include <wine/heap.h>
-#include <wine/module.h>
-#include <wine/debugtools.h>
-#include <wine/winerror.h>
-#include <loader.h>
+
+#include "wine/winbase.h"
+#include "wine/windef.h"
+#include "wine/winuser.h"
+#include "wine/heap.h"
+#include "wine/module.h"
+#include "wine/debugtools.h"
+#include "wine/winerror.h"
+#include "loader.h"
 
 #define CP_ACP					0
 
@@ -281,7 +282,7 @@
     wbuflen ++;
 
     retval = 0;
-    wbuf = HeapAlloc( GetProcessHeap(), 0, wbuflen * sizeof(WCHAR) );
+    wbuf = (LPWSTR) HeapAlloc( GetProcessHeap(), 0, wbuflen * sizeof(WCHAR) );
     wbuflen = LoadStringW(instance,resource_id,wbuf,wbuflen);
     if ( wbuflen > 0 )
     {
@@ -292,7 +293,7 @@
 		retval = abuflen;
 	    else
 	    {
-		abuf = HeapAlloc( GetProcessHeap(), 0, abuflen * sizeof(CHAR) );
+		abuf = (LPSTR) HeapAlloc( GetProcessHeap(), 0, abuflen * sizeof(CHAR) );
 		abuflen = WideCharToMultiByte(CP_ACP,0,wbuf,wbuflen,abuf,abuflen,NULL,NULL);
 		if ( abuflen > 0 )
 		{
@@ -335,7 +336,7 @@
     hmem = LoadResource( instance, hrsrc );
     if (!hmem) return 0;
     
-    p = LockResource(hmem);
+    p = (WCHAR*) LockResource(hmem);
     string_num = resource_id & 0x000f;
     for (i = 0; i < string_num; i++)
 	p += *p + 1;
--- a/loader/win32.c	Fri Sep 13 19:42:33 2002 +0000
+++ b/loader/win32.c	Fri Sep 13 19:43:17 2002 +0000
@@ -187,7 +187,7 @@
 	va_end(va);
     }
 #endif
-#undef MPLAYER
+//#undef MPLAYER
 #ifdef MPLAYER
     #include "../mp_msg.h"
     if (verbose > 2)
@@ -251,7 +251,7 @@
 
 #ifdef MEMORY_DEBUG
 
-void* my_mreq(int size, int to_zero)
+static void* my_mreq(int size, int to_zero)
 {
     static int test=0;
     test++;
@@ -284,7 +284,7 @@
     heap_counter+=size;
     return heap+heap_counter-size;
 }
-int my_release(char* memory)
+static int my_release(char* memory)
 {
     //    test_heap();
     if(memory==NULL)
@@ -342,7 +342,7 @@
 void* mreq_private(int size, int to_zero, int type)
 {
     int nsize = size + sizeof(alloc_header);
-    alloc_header* header = malloc(nsize);
+    alloc_header* header = (alloc_header* ) malloc(nsize);
     if (!header)
         return 0;
     if (to_zero)
@@ -373,7 +373,7 @@
     return header + 1;
 }
 
-int my_release(void* memory)
+static int my_release(void* memory)
 {
     alloc_header* header = (alloc_header*) memory - 1;
 #ifdef GARBAGE
@@ -383,7 +383,7 @@
     if (memory == 0)
 	return 0;
 
-    if (header->deadbeef != 0xdeadbeef)
+    if (header->deadbeef != (long) 0xdeadbeef)
     {
 	printf("FATAL releasing corrupted memory! %p  0x%lx  (%d)\n", header, header->deadbeef, alccnt);
 	return 0;
@@ -440,12 +440,12 @@
 }
 #endif
 
-inline void* my_mreq(int size, int to_zero)
+static inline void* my_mreq(int size, int to_zero)
 {
     return mreq_private(size, to_zero, AREATYPE_CLIENT);
 }
 
-static /*inline*/ int my_size(void* memory)
+static int my_size(void* memory)
 {
     if(!memory) return 0;
     return ((alloc_header*)memory)[-1].size;
@@ -540,7 +540,7 @@
 {
     pthread_t *pth;
     //    printf("CreateThread:");
-    pth=my_mreq(sizeof(pthread_t), 0);
+    pth = (pthread_t*) my_mreq(sizeof(pthread_t), 0);
     pthread_create(pth, NULL, (void*(*)(void*))lpStartAddress, lpParameter);
     if(dwFlags)
 	printf( "WARNING: CreateThread flags not supported\n");
@@ -788,22 +788,6 @@
 static int pf_set = 0;
 static BYTE PF[64] = {0,};
 
-static void WINAPI expGetSystemInfo(SYSTEM_INFO* si); /* forward declaration */
-
-static WIN_BOOL WINAPI expIsProcessorFeaturePresent(DWORD v)
-{
-    WIN_BOOL result;
-    if(v>63)result=0;
-    if (!pf_set)
-    {
-	SYSTEM_INFO si;
-	expGetSystemInfo(&si);
-    }
-    else result=PF[v];
-    dbgprintf("IsProcessorFeaturePresent(0x%x) => 0x%x\n", v, result);
-    return result;
-}
-
 static void DumpSystemInfo(const SYSTEM_INFO* si)
 {
     dbgprintf("  Processor architecture %d\n", si->u.s.wProcessorArchitecture);
@@ -1006,7 +990,7 @@
 	    }
 	    if (!lstrncmpiA(line,"processor",strlen("processor"))) {
 		/* processor number counts up...*/
-		int	x;
+		unsigned int x;
 
 		if (sscanf(value,"%d",&x))
 		    if (x+1>cachedsi.dwNumberOfProcessors)
@@ -1054,6 +1038,21 @@
     DumpSystemInfo(si);
 }
 
+// avoid undefined expGetSystemInfo
+static WIN_BOOL WINAPI expIsProcessorFeaturePresent(DWORD v)
+{
+    WIN_BOOL result = 0;
+    if (!pf_set)
+    {
+	SYSTEM_INFO si;
+	expGetSystemInfo(&si);
+    }
+    if(v<64) result=PF[v];
+    dbgprintf("IsProcessorFeaturePresent(0x%x) => 0x%x\n", v, result);
+    return result;
+}
+
+
 static long WINAPI expGetVersion()
 {
     dbgprintf("GetVersion() => 0xC0000004\n");
@@ -1106,7 +1105,11 @@
 static long WINAPI expHeapFree(HANDLE heap, DWORD dwFlags, LPVOID lpMem)
 {
     dbgprintf("HeapFree(0x%x, 0x%x, pointer 0x%x) => 1\n", heap, dwFlags, lpMem);
-    if (heapfreehack != lpMem && lpMem != (void*)0xffffffff)
+    if (heapfreehack != lpMem && lpMem != (void*)0xffffffff
+	&& lpMem != (void*)0xbdbdbdbd)
+	// 0xbdbdbdbd is for i263_drv.drv && libefence
+	// it seems to be reading from relased memory
+        // EF_PROTECT_FREE doens't show any probleme
 	my_release(lpMem);
     else
     {
@@ -1336,12 +1339,12 @@
     return getpid();
 }
 
-extern void* fs_seg;
-
-#if 1
+#if 0
 // this version is required for Quicktime codecs (.qtx/.qts) to work.
 // (they assume some pointers at FS: segment)
 
+extern void* fs_seg;
+
 //static int tls_count;
 static int tls_use_map[64];
 static int WINAPI expTlsAlloc()
@@ -1396,7 +1399,7 @@
 
 static void* WINAPI expTlsAlloc()
 {
-    if(g_tls==NULL)
+    if (g_tls == NULL)
     {
 	g_tls=my_mreq(sizeof(tls_t), 0);
 	g_tls->next=g_tls->prev=NULL;
@@ -1451,6 +1454,8 @@
 	    index->next->prev=index->prev;
 	if(index->prev)
 	    index->prev->next=index->next;
+	if (g_tls == index)
+            g_tls = index->prev;
 	my_release((void*)index);
 	result=1;
     }
@@ -2696,6 +2701,21 @@
     return 0;
 }
 
+#define SECS_1601_TO_1970  ((369 * 365 + 89) * 86400ULL)
+static void WINAPI expGetSystemTimeAsFileTime(FILETIME* systime)
+{
+    struct tm *local_tm;
+    struct timeval tv;
+    unsigned long long secs;
+
+    dbgprintf("GetSystemTime(0x%x)\n", systime);
+    gettimeofday(&tv, NULL);
+    secs = (tv.tv_sec + SECS_1601_TO_1970) * 10000000;
+    secs += tv.tv_usec * 10;
+    systime->dwLowDateTime = secs & 0xffffffff;
+    systime->dwHighDateTime = (secs >> 32);
+}
+
 static int WINAPI expGetEnvironmentVariableA(const char* name, char* field, int size)
 {
     char *p;
@@ -2741,12 +2761,12 @@
 struct COM_OBJECT_INFO
 {
     GUID clsid;
-    long (*GetClassObject) (GUID* clsid, GUID* iid, void** ppv);
+    long (*GetClassObject) (GUID* clsid, const GUID* iid, void** ppv);
 };
 
 static struct COM_OBJECT_INFO* com_object_table=0;
 static int com_object_size=0;
-int RegisterComClass(GUID* clsid, GETCLASSOBJECT gcs)
+int RegisterComClass(const GUID* clsid, GETCLASSOBJECT gcs)
 {
     if(!clsid || !gcs)
 	return -1;
@@ -2756,7 +2776,7 @@
     return 0;
 }
 
-int UnregisterComClass(GUID* clsid, GETCLASSOBJECT gcs)
+int UnregisterComClass(const GUID* clsid, GETCLASSOBJECT gcs)
 {
     int found = 0;
     int i = 0;
@@ -2793,19 +2813,19 @@
 }
 
 
-GUID IID_IUnknown =
+const GUID IID_IUnknown =
 {
     0x00000000, 0x0000, 0x0000,
     {0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}
 };
-GUID IID_IClassFactory =
+const GUID IID_IClassFactory =
 {
     0x00000001, 0x0000, 0x0000,
     {0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}
 };
 
 static long WINAPI expCoCreateInstance(GUID* rclsid, struct IUnknown* pUnkOuter,
-				       long dwClsContext, GUID* riid, void** ppv)
+				       long dwClsContext, const GUID* riid, void** ppv)
 {
     int i;
     struct COM_OBJECT_INFO* ci=0;
@@ -2819,7 +2839,7 @@
 }
 
 long CoCreateInstance(GUID* rclsid, struct IUnknown* pUnkOuter,
-		      long dwClsContext, GUID* riid, void** ppv)
+		      long dwClsContext, const GUID* riid, void** ppv)
 {
     return expCoCreateInstance(rclsid, pUnkOuter, dwClsContext, riid, ppv);
 }
@@ -2829,7 +2849,7 @@
     int r = 0;
 //    int r = (!lprc || (lprc->right == lprc->left) || (lprc->top == lprc->bottom));
     int w,h;
-    
+
     if (lprc)
     {
 	w = lprc->right - lprc->left;
@@ -2988,7 +3008,7 @@
     }
 
 #if 0
-    /* we need this for some virtualdub filters */  
+    /* we need this for some virtualdub filters */
     {
 	int r;
 	int flg = 0;
@@ -3001,7 +3021,7 @@
 	}
 	r=open(cs1, flg);
 	return r;
-    }    
+    }
 #endif
 
     return atoi(cs1+2);
@@ -3049,7 +3069,7 @@
     strcpy(shortpath,longpath);
     return strlen(shortpath);
 }
-			
+
 static WIN_BOOL WINAPI expReadFile(HANDLE h,LPVOID pv,DWORD size,LPDWORD rd,LPOVERLAPPED unused)
 {
     int result;
@@ -3274,7 +3294,7 @@
     my_release(memory);
     return 0;
 }
-#if 1
+#if 0
 static int exp_initterm(int v1, int v2)
 {
     dbgprintf("_initterm(0x%x, 0x%x) => 0\n", v1, v2);
@@ -3282,25 +3302,49 @@
 }
 #else
 /* merged from wine - 2002.04.21 */
-typedef void (*_INITTERMFUNC)(void);
+typedef void (*_INITTERMFUNC)();
 static int exp_initterm(_INITTERMFUNC *start, _INITTERMFUNC *end)
 {
-    _INITTERMFUNC *current = start;
-
-    dbgprintf("_initterm(0x%x, 0x%x)\n", start, end);
-    while (current < end)
+    dbgprintf("_initterm(0x%x, 0x%x) %p\n", start, end, *start);
+    while (start < end)
     {
-	if (*current)
+	if (*start)
 	{
-	    printf("call init func: %p\n", *current);
-	    (**current)();
+	    //printf("call _initfunc: from: %p %d\n", *start);
+	    // ok this trick with push/pop is necessary as otherwice
+	    // edi/esi registers are being trashed
+	    void* p = *start;
+	    __asm__ __volatile__
+		(
+		 "pushl %%ebx		\n\t"
+		 "pushl %%ecx		\n\t"
+		 "pushl %%edx		\n\t"
+		 "pushl %%edi		\n\t"
+		 "pushl %%esi		\n\t"
+		 "call  *%%eax		\n\t"
+		 "popl  %%esi		\n\t"
+		 "popl  %%edi		\n\t"
+		 "popl  %%edx		\n\t"
+		 "popl  %%ecx		\n\t"
+		 "popl  %%ebx		\n\t"
+		 :
+		 : "a"(p)
+		 : "memory"
+		);
+            //printf("done  %p  %d:%d\n", end);
 	}
-	current++;
+	start++;
     }
     return 0;
 }
 #endif
 
+static void* exp__dllonexit()
+{
+    // FIXME extract from WINE
+    return NULL;
+}
+
 static int expwsprintfA(char* string, char* format, ...)
 {
     va_list va;
@@ -3429,7 +3473,7 @@
 static char* exp_strdup(const char* str1)
 {
     int l = strlen(str1);
-    char* result = my_mreq(l + 1,0);
+    char* result = (char*) my_mreq(l + 1,0);
     if (result)
 	strcpy(result, str1);
     dbgprintf("_strdup(0x%x='%s') => %p\n", str1, str1, result);
@@ -3610,6 +3654,7 @@
 	 "movl $0, 36(%%edx)	\n\t"
 	 : // output
 	 : "d"(jmpbuf) // input
+	 : "eax"
 	);
 #if 1
     __asm__ __volatile__
@@ -3622,6 +3667,7 @@
 	 "l1:                   \n\t"
 	 :
 	 :
+	 : "eax"
 	);
 #endif
 
@@ -3791,6 +3837,11 @@
 //    dbgprintf("ntohl(%x) => %x\n", netlong, ntohl(netlong));
     return ntohl(netlong);
 }
+static void WINAPI expVariantInit(void* p)
+{
+    printf("InitCommonControls called!\n");
+    return;
+}
 
 int expRegisterClassA(const void/*WNDCLASSA*/ *wc)
 {
@@ -3912,6 +3963,7 @@
     FF(OutputDebugStringA, -1)
     FF(GetLocalTime, -1)
     FF(GetSystemTime, -1)
+    FF(GetSystemTimeAsFileTime, -1)
     FF(GetEnvironmentVariableA, -1)
     FF(SetEnvironmentVariableA, -1)
     FF(RtlZeroMemory,-1)
@@ -3960,6 +4012,7 @@
 struct exports exp_msvcrt[]={
     FF(malloc, -1)
     FF(_initterm, -1)
+    FF(__dllonexit, -1)
     FF(free, -1)
     {"??3@YAXPAX@Z", -1, expdelete},
     {"??2@YAPAXI@Z", -1, expnew},
@@ -4075,6 +4128,17 @@
 };
 struct exports exp_msdmo[]={
     FF(memcpy, -1) // just test
+/*
+    FF(MoCopyMediaType)
+    FF(MoCreateMediaType)
+    FF(MoDeleteMediaType)
+    FF(MoDuplicateMediaType)
+    FF(MoFreeMediaType)
+    FF(MoInitMediaType)
+*/
+};
+struct exports exp_oleaut32[]={
+    FF(VariantInit, 8)
 };
 
 /*  realplayer8:
@@ -4092,6 +4156,7 @@
 	2300e	   85  __CxxFrameHandler
 	23022	  411  _purecall
 */
+#ifdef MPLAYER
 struct exports exp_pncrt[]={
     FF(malloc, -1) // just test
     FF(free, -1) // just test
@@ -4100,14 +4165,7 @@
     FF(_ftol,-1)
     FF(_initterm, -1)
 };
-
-/* needed for Morgand MJPEG */
-struct exports exp_msvfw32[]={
-    {"ICOpen", -1, (void *)&ICOpen},
-    {"ICClose", -1, (void *)&ICClose},
-    {"ICDecompress", -1, (void *)&ICDecompress},
-    {"ICSendMessage", -1, (void *)&ICSendMessage}
-};
+#endif
 
 #define LL(X) \
     {#X".dll", sizeof(exp_##X)/sizeof(struct exports), exp_##X},
@@ -4121,44 +4179,70 @@
     LL(gdi32)
     LL(version)
     LL(ole32)
+    LL(oleaut32)
     LL(crtdll)
     LL(comctl32)
     LL(wsock32)
     LL(msdmo)
-    LL(msvfw32)
+#ifdef MPLAYER
     LL(pncrt)
+#endif
 };
-#include "mangle.h"
-static char* called_unk = "Called unk_%s\n";
+
 static void ext_stubs(void)
 {
     // expects:
     //  ax  position index
     //  cx  address of printf function
+#if 1
     __asm__ __volatile__
 	(
-         "push %edx             \n\t"
-	 "movl $0, %eax		\n\t"
-	 "movl $0, %edx		\n\t"
-	 "shl $5,%eax		\n\t"			// ax * 32
-	 "addl $"MANGLE(export_names)",%eax \n\t"
-	 "pushl %eax		\n\t"
-	 "pushl "MANGLE(called_unk)"	\n\t"
-	 "call *%edx		\n\t"                   // printf (via dx)
-	 "addl $8,%esp		\n\t"
-	 "xorl %eax,%eax	\n\t"
-         "pop %edx             \n\t"
+         "push %%edx		\n\t"
+	 "movl $0xdeadbeef, %%eax \n\t"
+	 "movl $0xdeadbeef, %%edx \n\t"
+	 "shl $5, %%eax		\n\t"			// ax * 32
+	 "addl $0xdeadbeef, %%eax \n\t"			// overwrite export_names
+	 "pushl %%eax		\n\t"
+	 "pushl $0xdeadbeef   	\n\t"                   // overwrite called_unk
+	 "call *%%edx		\n\t"                   // printf (via dx)
+	 "addl $8, %%esp	\n\t"
+	 "xorl %%eax, %%eax	\n\t"
+	 "pop %%edx             \n\t"
+	 :
+	 :
+	 : "eax"
 	);
+#else
+    __asm__ __volatile__
+	(
+         "push %%edx		\n\t"
+	 "movl $0, %%eax	\n\t"
+	 "movl $0, %%edx	\n\t"
+	 "shl $5, %%eax		\n\t"			// ax * 32
+	 "addl %0, %%eax	\n\t"
+	 "pushl %%eax		\n\t"
+	 "pushl %1		\n\t"
+	 "call *%%edx		\n\t"                   // printf (via dx)
+	 "addl $8, %%esp	\n\t"
+	 "xorl %%eax, %%eax	\n\t"
+	 "pop %%edx		\n\t"
+	 ::"m"(*export_names), "m"(*called_unk)
+	: "memory", "edx", "eax"
+	);
+#endif
+
 }
 
 //static void add_stub(int pos)
 
 extern int unk_exp1;
+static int pos=0;
 static char extcode[20000];// place for 200 unresolved exports
-static int pos=0;
+static const char* called_unk = "Called unk_%s\n";
 
 static void* add_stub()
 {
+    // generated code in runtime!
     char* answ = (char*)extcode+pos*0x30;
 #if 0
     memcpy(answ, &unk_exp1, 0x64);
@@ -4166,10 +4250,14 @@
     *(int*)(answ+47)-=((int)answ-(int)&unk_exp1);
 #endif
     memcpy(answ, ext_stubs, 0x2f); // 0x2c is current size
-    //answ[0] = 0xb8; // movl $0, eax  (0xb8 0x00000000)
+    //answ[4] = 0xb8; // movl $0, eax  (0xb8 0x00000000)
     *((int*) (answ + 5)) = pos;
-    //answ[5] = 0xb9; // movl $0, edx  (0xb9 0x00000000)
-    *((int*) (answ + 10)) = (int) printf;
+    //answ[9] = 0xba; // movl $0, edx  (0xba 0x00000000)
+    *((long*) (answ + 10)) = (long)printf;
+    //answ[17] = 0x05; // addl $0, eax  (0x05 0x00000000)
+    *((long*) (answ + 18)) = (long)export_names;
+    //answ[23] = 0x68; // pushl $0  (0x68 0x00000000)
+    *((long*) (answ + 24)) = (long)called_unk;
     pos++;
     return (void*)answ;
 }
@@ -4201,7 +4289,7 @@
 
     /* ok, this is a hack, and a big memory leak. should be fixed. - alex */
     {
-	HMODULE hand;
+	int hand;
 	WINE_MODREF *wm;
 	void *func;
 
@@ -4214,23 +4302,23 @@
 	    FreeLibrary(hand);
 	    goto no_dll;
 	}
-	func = PE_FindExportedFunction(wm, ordinal, 0);
+	func = PE_FindExportedFunction(wm, (LPCSTR) ordinal, 0);
 	if (!func)
 	{
 	    printf("No such ordinal in external dll\n");
-	    FreeLibrary(hand);
+	    FreeLibrary((int)hand);
 	    goto no_dll;
 	}
 
-	printf("External dll loaded (offset: %p, func: %p)\n",
-	    hand, func);
+	printf("External dll loaded (offset: 0x%x, func: %p)\n",
+	       hand, func);
 	return func;
     }
 
 no_dll:
     if(pos>150)return 0;
     sprintf(export_names[pos], "%s:%d", library, ordinal);
-    return add_stub(pos);
+    return add_stub();
 }
 
 void* LookupExternalByName(const char* library, const char* name)
@@ -4263,7 +4351,7 @@
     }
     if(pos>150)return 0;// to many symbols
     strcpy(export_names[pos], name);
-    return add_stub(pos);
+    return add_stub();
 }
 
 void my_garbagecollection(void)
@@ -4271,15 +4359,19 @@
 #ifdef GARBAGE
     int unfree = 0, unfreecnt = 0;
 
+    int max_fatal = 8;
     free_registry();
     while (last_alloc)
     {
 	alloc_header* mem = last_alloc + 1;
 	unfree += my_size(mem);
 	unfreecnt++;
-	my_release(mem);
+	if (my_release(mem) != 0)
+	    // avoid endless loop when memory is trashed
+	    if (--max_fatal < 0)
+		break;
     }
-    dbgprintf("Total Unfree %d bytes cnt %d [%p,%d]\n",unfree, unfreecnt, last_alloc, alccnt);
+    printf("Total Unfree %d bytes cnt %d [%p,%d]\n",unfree, unfreecnt, last_alloc, alccnt);
 #endif
     g_tls = NULL;
     list = NULL;
--- a/loader/win32.h	Fri Sep 13 19:42:33 2002 +0000
+++ b/loader/win32.h	Fri Sep 13 19:43:17 2002 +0000
@@ -3,9 +3,18 @@
 
 #include <time.h>
 
-#include <wine/windef.h>
-#include <wine/winbase.h>
-#include <com.h>
+#include "wine/windef.h"
+#include "wine/winbase.h"
+#include "com.h"
+
+#ifdef AVIFILE
+#ifdef __GNUC__
+#include "avm_output.h"
+#ifndef __cplusplus
+#define printf(a, ...)  avm_printf("Win32 plugin", a, ## __VA_ARGS__)
+#endif
+#endif
+#endif
 
 extern void my_garbagecollection(void);
 
@@ -25,9 +34,7 @@
 
 extern void* LookupExternal(const char* library, int ordinal);
 extern void* LookupExternalByName(const char* library, const char* name);
-
-extern void* my_mreq(int size, int to_zero);
-extern int my_release(void* memory);
-
+extern int expRegisterClassA(const void/*WNDCLASSA*/ *wc);
+extern int expUnregisterClassA(const char *className, HINSTANCE hInstance);
 
 #endif
--- a/loader/wine/avifmt.h	Fri Sep 13 19:42:33 2002 +0000
+++ b/loader/wine/avifmt.h	Fri Sep 13 19:43:17 2002 +0000
@@ -11,7 +11,7 @@
  
 
 #ifndef  __WINE_WINDEF_H
-#include <wine/windef.h>
+#include "wine/windef.h"
 #endif
 
 #ifndef __WINE_MMSYSTEM_H
--- a/loader/wine/mmreg.h	Fri Sep 13 19:42:33 2002 +0000
+++ b/loader/wine/mmreg.h	Fri Sep 13 19:43:17 2002 +0000
@@ -17,7 +17,7 @@
 #define WAVE_FILTER_UNKNOWN     0x0000
 #define WAVE_FILTER_DEVELOPMENT 0xFFFF
 
-typedef struct _WAVEFILTER {
+typedef struct __attribute__((__packed__)) _WAVEFILTER {
   DWORD   cbStruct;
   DWORD   dwFilterTag;
   DWORD   fdwFilter;
@@ -28,7 +28,7 @@
 #ifndef WAVE_FILTER_VOLUME
 #define WAVE_FILTER_VOLUME      0x0001
 
-typedef struct _WAVEFILTER_VOLUME {
+typedef struct __attribute__((__packed__)) _WAVEFILTER_VOLUME {
    WAVEFILTER      wfltr;
    DWORD           dwVolume;
 } VOLUMEWAVEFILTER, *PVOLUMEWAVEFILTER, *NPVOLUMEWAVEFILTER, *LPVOLUMEWAVEFILTER;
@@ -37,7 +37,7 @@
 #ifndef WAVE_FILTER_ECHO
 #define WAVE_FILTER_ECHO        0x0002
 
-typedef struct WAVEFILTER_ECHO {
+typedef struct __attribute__((__packed__)) WAVEFILTER_ECHO {
    WAVEFILTER      wfltr;
    DWORD           dwVolume;
    DWORD           dwDelay;
@@ -46,7 +46,7 @@
     
 #ifndef _WAVEFORMATEX_
 #define _WAVEFORMATEX_
-typedef struct _WAVEFORMATEX {
+typedef struct __attribute__((__packed__)) _WAVEFORMATEX {
   WORD   wFormatTag;
   WORD   nChannels;
   DWORD  nSamplesPerSec;
--- a/loader/wine/module.h	Fri Sep 13 19:42:33 2002 +0000
+++ b/loader/wine/module.h	Fri Sep 13 19:43:17 2002 +0000
@@ -128,6 +128,16 @@
 #define NE_MODULE_NAME(pModule) \
     (((OFSTRUCT *)((char*)(pModule) + (pModule)->fileinfo))->szPathName)
 
+struct modref_list_t;
+
+typedef struct modref_list_t
+{
+    WINE_MODREF* wm;
+    struct modref_list_t *next;
+    struct modref_list_t *prev;
+} modref_list;
+
+
 /* module.c */
 extern FARPROC MODULE_GetProcAddress( HMODULE hModule, LPCSTR function, WIN_BOOL snoop );
 extern WINE_MODREF *MODULE32_LookupHMODULE( HMODULE hModule );
--- a/loader/wine/msacm.h	Fri Sep 13 19:42:33 2002 +0000
+++ b/loader/wine/msacm.h	Fri Sep 13 19:43:17 2002 +0000
@@ -25,7 +25,9 @@
 
 
 
+#if !defined(WAVE_FORMAT_PCM)
 #define WAVE_FORMAT_PCM     1
+#endif
 
 /***********************************************************************
  * Defines/Enums
@@ -931,7 +933,6 @@
 MMRESULT WINAPI acmStreamUnprepareHeader(
   HACMSTREAM has, PACMSTREAMHEADER pash, DWORD fdwUnprepare
 );
-void MSACM_RegisterAllDrivers(void);
 
 #ifdef __cplusplus
 } /* extern "C" */
--- a/loader/wine/pe_image.h	Fri Sep 13 19:42:33 2002 +0000
+++ b/loader/wine/pe_image.h	Fri Sep 13 19:43:17 2002 +0000
@@ -1,7 +1,7 @@
 #ifndef __WINE_PE_IMAGE_H
 #define __WINE_PE_IMAGE_H
 
-#include "windef.h"
+#include "winnt.h"
 #include "winbase.h"
 
 #define PE_HEADER(module) \
--- a/loader/wine/vfw.h	Fri Sep 13 19:42:33 2002 +0000
+++ b/loader/wine/vfw.h	Fri Sep 13 19:43:17 2002 +0000
@@ -69,11 +69,7 @@
 	long		type;		/* 08: */
 	long		handler;	/* 0C: */
 	HDRVR		hdrv;		/* 10: */
-#ifndef __cplusplus
-	long		private;	/* 14:(handled by SendDriverMessage)*/
-#else	
-	long		_private;	/* 14:(handled by SendDriverMessage)*/
-#endif	
+	long		driverid;	/* 14:(handled by SendDriverMessage)*/
 	DRIVERPROC	driverproc;	/* 18:(handled by SendDriverMessage)*/
 	long		x1;		/* 1c: name? */
 	short		x2;		/* 20: */
@@ -200,7 +196,7 @@
     LPBITMAPINFOHEADER	lpbiOutput;
     void*		lpOutput;
     LPBITMAPINFOHEADER	lpbiInput;
-    void*		lpInput;
+    const void*		lpInput;
     long*		lpckid;
     long*		lpdwFlags;
     long		lFrameNum;
@@ -211,10 +207,10 @@
 } ICCOMPRESS;
 
 long VFWAPIV ICCompress(
-	HIC hic,long dwFlags,LPBITMAPINFOHEADER lpbiOutput,void* lpOutputBuf,
-	LPBITMAPINFOHEADER lpbiInput,void* lpImage,long* lpckid,
+	HIC hic,long dwFlags,LPBITMAPINFOHEADER lpbiOutput,void* lpData,
+	LPBITMAPINFOHEADER lpbiInput,void* lpBits,long* lpckid,
 	long* lpdwFlags,long lFrameNum,long dwFrameSize,long dwQuality,
-	LPBITMAPINFOHEADER lpbiInputPrev,void* lpImagePrev
+	LPBITMAPINFOHEADER lpbiPrev,void* lpPrev
 );
 
 
@@ -350,7 +346,7 @@
 typedef struct {
     long		dwFlags;	/* flags (from AVI index...) */
     LPBITMAPINFOHEADER	lpbiInput;	/* BITMAPINFO of compressed data */
-    void*		lpInput;	/* compressed data */
+    const void*		lpInput;	/* compressed data */
     LPBITMAPINFOHEADER	lpbiOutput;	/* DIB to decompress to */
     void*		lpOutput;
     long		ckid;		/* ckid from AVI file */
@@ -358,8 +354,8 @@
 
 typedef struct {
     long		dwFlags;
-    LPBITMAPINFOHEADER	lpbiSrc;
-    void*		lpSrc;
+    LPBITMAPINFOHEADER lpbiSrc;
+    const void*		lpSrc;
     LPBITMAPINFOHEADER	lpbiDst;
     void*		lpDst;
 
@@ -437,11 +433,11 @@
 WIN_BOOL	VFWAPI	ICInfo(long fccType, long fccHandler, ICINFO * lpicinfo);
 LRESULT	VFWAPI	ICGetInfo(HIC hic,ICINFO *picinfo, long cb);
 HIC	VFWAPI	ICOpen(long fccType, long fccHandler, UINT wMode);
-HIC	VFWAPI	ICOpenFunction(long fccType, long fccHandler, unsigned int wMode, void* lpfnHandler);
+//HIC	VFWAPI	ICOpenFunction(long fccType, long fccHandler, unsigned int wMode, void* lpfnHandler);
 
 LRESULT VFWAPI ICClose(HIC hic);
 LRESULT	VFWAPI ICSendMessage(HIC hic, unsigned int msg, long dw1, long dw2);
-HIC	VFWAPI ICLocate(long fccType, long fccHandler, LPBITMAPINFOHEADER lpbiIn, LPBITMAPINFOHEADER lpbiOut, short wFlags);
+//HIC	VFWAPI ICLocate(long fccType, long fccHandler, LPBITMAPINFOHEADER lpbiIn, LPBITMAPINFOHEADER lpbiOut, short wFlags);
 
 int VFWAPI ICDoSomething(void);
 
--- a/loader/wineacm.h	Fri Sep 13 19:42:33 2002 +0000
+++ b/loader/wineacm.h	Fri Sep 13 19:43:17 2002 +0000
@@ -1,8 +1,19 @@
+#ifndef WINEACM_H
+#define WINEACM_H
 /* -*- tab-width: 8; c-basic-offset: 4 -*- */
 
 /***********************************************************************
  * Wine specific - Win32
  */
+
+
+#include "wine/msacmdrv.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* defined(__cplusplus) */
+
+
 typedef struct _WINE_ACMDRIVERID *PWINE_ACMDRIVERID;
 typedef struct _WINE_ACMDRIVER   *PWINE_ACMDRIVER;
 
@@ -17,6 +28,7 @@
     HDRVR      		hDrvr;
     DRIVERPROC		pfnDriverProc;
     PWINE_ACMDRIVER	pNextACMDriver;
+    int                 iUsage;
 } WINE_ACMDRIVER;
 
 typedef struct _WINE_ACMSTREAM
@@ -29,8 +41,8 @@
 
 typedef struct _WINE_ACMDRIVERID
 {
-    LPSTR               pszDriverAlias;
     LPSTR               pszFileName;
+    WORD		wFormatTag;
     HINSTANCE		hInstModule;          /* NULL if global */
     DWORD		dwProcessID;	      /* ID of process which installed a local driver */
     WIN_BOOL                bEnabled;
@@ -43,13 +55,18 @@
 extern HANDLE MSACM_hHeap;
 extern PWINE_ACMDRIVERID MSACM_pFirstACMDriverID;
 extern PWINE_ACMDRIVERID MSACM_pLastACMDriverID;
-PWINE_ACMDRIVERID MSACM_RegisterDriver(LPSTR pszDriverAlias,
-				       LPSTR pszFileName,
+
+PWINE_ACMDRIVERID MSACM_RegisterDriver(const char* pszFileName,
+				       WORD wFormatTag,
 				       HINSTANCE hinstModule);
-void MSACM_RegisterAllDrivers(void);
 PWINE_ACMDRIVERID MSACM_UnregisterDriver(PWINE_ACMDRIVERID p);
 void MSACM_UnregisterAllDrivers(void);
 PWINE_ACMDRIVERID MSACM_GetDriverID(HACMDRIVERID hDriverID);
 PWINE_ACMDRIVER MSACM_GetDriver(HACMDRIVER hDriver);
 PWINE_ACMOBJ MSACM_GetObj(HACMOBJ hObj);
 
+#ifdef __cplusplus
+} /* extern "C" */
+#endif /* defined(__cplusplus) */
+
+#endif /* WINEACM_H */