[Mplayer-cvslog] CVS: main/loader afl.c,1.3,1.4 com.h,1.4,1.5 driver.c,1.8,1.9 driver.h,1.2,1.3 elfdll.c,1.4,1.5 ext.c,1.8,1.9 ext.h,1.2,1.3 ldt_keeper.c,1.8,1.9 ldt_keeper.h,1.1,1.2 loader.h,1.4,1.5 module.c,1.9,1.10 pe_image.c,1.6,1.7 pe_resource.c,1.2,1.3 registry.c,1.12,1.13 resource.c,1.2,1.3 win32.c,1.61,1.62 win32.h,1.9,1.10 wineacm.h,1.2,1.3 module.h,1.1,NONE

Arpi of Ize arpi at mplayerhq.hu
Fri Sep 13 21:43:47 CEST 2002


Update of /cvsroot/mplayer/main/loader
In directory mail:/var/tmp.root/cvs-serv768

Modified Files:
	afl.c com.h driver.c driver.h elfdll.c ext.c ext.h 
	ldt_keeper.c ldt_keeper.h loader.h module.c pe_image.c 
	pe_resource.c registry.c resource.c win32.c win32.h wineacm.h 
Removed Files:
	module.h 
Log Message:
avifile sync - 95% cosmetics 5% bug


Index: afl.c
===================================================================
RCS file: /cvsroot/mplayer/main/loader/afl.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- afl.c	4 Oct 2001 02:21:34 -0000	1.3
+++ afl.c	13 Sep 2002 19:43:13 -0000	1.4
@@ -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))

Index: com.h
===================================================================
RCS file: /cvsroot/mplayer/main/loader/com.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- com.h	26 Nov 2001 00:47:58 -0000	1.4
+++ com.h	13 Sep 2002 19:43:13 -0000	1.5
@@ -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
 };

Index: driver.c
===================================================================
RCS file: /cvsroot/mplayer/main/loader/driver.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- driver.c	11 Dec 2001 22:58:13 -0000	1.8
+++ driver.c	13 Sep 2002 19:43:13 -0000	1.9
@@ -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;
+    if (!module || !module->hDriverModule || !module->DriverProc) return -1;
+#ifndef __svr4__
+    __asm__ __volatile__ ("fsave (%0)\n\t": :"r"(&qw));
+#endif
+
+    Setup_FS_Segment();
+
     STORE_ALL;
-    result=module->DriverProc(module->dwDriverID,1,message,lParam1,lParam2);
+    result=module->DriverProc(module->dwDriverID, hDriver, message, lParam1, lParam2);
     REST_ALL;
-#ifdef DETAILED_OUT    
+
+#ifndef __svr4__
+    __asm__ __volatile__ ("frstor (%0)\n\t": :"r"(&qw));
+#endif
+
+#ifdef DETAILED_OUT
     printf("\t\tResult: %X\n", result);
-#endif    
+#endif
     return result;
-}				    
+}
 
-static NPDRVR DrvAlloc(HDRVR*lpDriver, LPUINT lpDrvResult)
+void DrvClose(HDRVR hDriver)
 {
-    NPDRVR npDriver;
-    /* allocate and lock handle */
-    if (lpDriver)
+    if (hDriver)
     {
-      if ( (*lpDriver = (HDRVR) malloc(sizeof(DRVR))) )
-        {
-            if ((npDriver = (NPDRVR) *lpDriver))
-            {
-                    *lpDrvResult = MMSYSERR_NOERROR;
-                    return (npDriver);
-            }
-            free((NPDRVR)*lpDriver);
-        }
-        return (*lpDrvResult = MMSYSERR_NOMEM, (NPDRVR) 0);
+	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);
     }
-    return (*lpDrvResult = MMSYSERR_INVALPARAM, (NPDRVR) 0);
+    CodecRelease();
 }
 
-                                                                                                                    
-static void DrvFree(HDRVR hDriver)
+//DrvOpen(LPCSTR lpszDriverName, LPCSTR lpszSectionName, LPARAM lParam2)
+HDRVR DrvOpen(LPARAM lParam2)
 {
+    NPDRVR 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;	
-    }
-}
-
-void DrvClose(HDRVR hdrvr)
-{
-    DrvFree(hdrvr);
-}
-
-
-char* win32_codec_name=NULL;  // must be set before calling DrvOpen() !!!
-
-HDRVR VFWAPI
-DrvOpen(LPARAM lParam2)
-{
-    ICOPEN *icopen=(ICOPEN *) lParam2;
-    UINT uDrvResult;
-    HDRVR hDriver;
-    NPDRVR npDriver;
-    char unknown[0x24];
-//    char* codec_name=icopen->fccHandler;
+    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();
 
-#if 0
+    hDriver->hDriverModule = LoadLibraryA(filename);
+    if (!hDriver->hDriverModule)
     {
-        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;
+	printf("Can't open library %s\n", filename);
+	DrvClose((HDRVR)hDriver);
+	return ((HDRVR) 0);
     }
-#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);
 
+    hDriver->DriverProc = (DRIVERPROC) GetProcAddress(hDriver->hDriverModule,
+						      "DriverProc");
+    if (!hDriver->DriverProc)
+    {
+	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 and remmeber proper DriverID
+    hDriver->dwDriverID = SendDriverMessage((HDRVR)hDriver, DRV_OPEN, (LPARAM) unknown, lParam2);
+    TRACE("DRV_OPEN Ok!(%X)\n", hDriver->dwDriverID);
 
-     // 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);
-
-    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;
 }
-  

Index: driver.h
===================================================================
RCS file: /cvsroot/mplayer/main/loader/driver.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- driver.h	4 Oct 2001 02:21:34 -0000	1.2
+++ driver.h	13 Sep 2002 19:43:13 -0000	1.3
@@ -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"
+
+void SetCodecPath(const char* path);
+void CodecAlloc(void);
+void CodecRelease(void);
+
+HDRVR DrvOpen(LPARAM lParam2);
+void DrvClose(HDRVR hdrvr);
 
-extern HDRVR VFWAPI DrvOpen(LPARAM lParam2);
-extern void DrvClose(HDRVR hdrvr);
+#ifdef __cplusplus
+}
+#endif
 
 #endif

Index: elfdll.c
===================================================================
RCS file: /cvsroot/mplayer/main/loader/elfdll.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- elfdll.c	8 Oct 2001 22:26:13 -0000	1.4
+++ elfdll.c	13 Sep 2002 19:43:13 -0000	1.5
@@ -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;
 	}	

Index: ext.c
===================================================================
RCS file: /cvsroot/mplayer/main/loader/ext.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- ext.c	26 Dec 2001 22:33:15 -0000	1.8
+++ ext.c	13 Sep 2002 19:43:13 -0000	1.9
@@ -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;

Index: ext.h
===================================================================
RCS file: /cvsroot/mplayer/main/loader/ext.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ext.h	8 Oct 2001 22:26:13 -0000	1.2
+++ ext.h	13 Sep 2002 19:43:13 -0000	1.3
@@ -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,

Index: ldt_keeper.c
===================================================================
RCS file: /cvsroot/mplayer/main/loader/ldt_keeper.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- ldt_keeper.c	27 Apr 2002 22:42:26 -0000	1.8
+++ ldt_keeper.c	13 Sep 2002 19:43:13 -0000	1.9
@@ -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,20 +82,13 @@
 /* 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.
- *
- */
+#define       TEB_SEL LDT_SEL(TEB_SEL_IDX)
 
-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);
 }

Index: ldt_keeper.h
===================================================================
RCS file: /cvsroot/mplayer/main/loader/ldt_keeper.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ldt_keeper.h	4 Oct 2001 00:06:10 -0000	1.1
+++ ldt_keeper.h	13 Sep 2002 19:43:13 -0000	1.2
@@ -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

Index: loader.h
===================================================================
RCS file: /cvsroot/mplayer/main/loader/loader.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- loader.h	12 Aug 2001 13:18:07 -0000	1.4
+++ loader.h	13 Sep 2002 19:43:13 -0000	1.5
@@ -8,277 +8,22 @@
 
 #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,
 	const char* def_val, char* dest, unsigned int len, const char* filename);
 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 );

Index: module.c
===================================================================
RCS file: /cvsroot/mplayer/main/loader/module.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- module.c	23 Jul 2002 12:02:52 -0000	1.9
+++ module.c	13 Sep 2002 19:43:13 -0000	1.10
@@ -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;
 }

Index: pe_image.c
===================================================================
RCS file: /cvsroot/mplayer/main/loader/pe_image.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- pe_image.c	3 Nov 2001 19:40:38 -0000	1.6
+++ pe_image.c	13 Sep 2002 19:43:13 -0000	1.7
@@ -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 );

Index: pe_resource.c
===================================================================
RCS file: /cvsroot/mplayer/main/loader/pe_resource.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- pe_resource.c	12 Jul 2001 15:27:47 -0000	1.2
+++ pe_resource.c	13 Sep 2002 19:43:13 -0000	1.3
@@ -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 

Index: registry.c
===================================================================
RCS file: /cvsroot/mplayer/main/loader/registry.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- registry.c	27 Jan 2002 17:17:58 -0000	1.12
+++ registry.c	13 Sep 2002 19:43:13 -0000	1.13
@@ -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();
-
-	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;
+    struct reg_value* t;
+    char* c;
+    TRACE("Querying value %s\n", value);
+    if(!regs)
+	init_registry();
+
+    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();
-
-	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;
-	}
-
-	t=insert_handle(generate_handle(), fullname);
-	*newkey=t->handle;
-	free(fullname);
-	return 0;
+    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)
+	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;
 }
 
 /*
@@ -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();
 

Index: resource.c
===================================================================
RCS file: /cvsroot/mplayer/main/loader/resource.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- resource.c	12 Jul 2001 15:27:47 -0000	1.2
+++ resource.c	13 Sep 2002 19:43:13 -0000	1.3
@@ -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;

Index: win32.c
===================================================================
RCS file: /cvsroot/mplayer/main/loader/win32.c,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -r1.61 -r1.62
--- win32.c	28 Aug 2002 22:45:47 -0000	1.61
+++ win32.c	13 Sep 2002 19:43:13 -0000	1.62
@@ -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 at YAXPAX@Z", -1, expdelete},
     {"??2 at 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 $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 $"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 $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 char extcode[20000];// place for 200 unresolved exports
 static int pos=0;
+static char extcode[20000];// place for 200 unresolved exports
+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;

Index: win32.h
===================================================================
RCS file: /cvsroot/mplayer/main/loader/win32.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- win32.h	11 Dec 2001 22:58:13 -0000	1.9
+++ win32.h	13 Sep 2002 19:43:13 -0000	1.10
@@ -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

Index: wineacm.h
===================================================================
RCS file: /cvsroot/mplayer/main/loader/wineacm.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- wineacm.h	4 Oct 2001 02:21:34 -0000	1.2
+++ wineacm.h	13 Sep 2002 19:43:13 -0000	1.3
@@ -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 */

--- module.h DELETED ---




More information about the MPlayer-cvslog mailing list