[Mplayer-cvslog] CVS: main/loader Makefile,1.3,1.4 afl.c,1.2,1.3 driver.h,1.1,1.2 elfdll.c,1.2,1.3 ext.c,1.3,1.4 ldt_keeper.c,1.1,1.2 module.c,1.3,1.4 pe_image.c,1.4,1.5 registry.h,1.1.1.1,1.2 vfl.c,1.6,1.7 win32.c,1.19,1.20 win32.h,1.2,1.3 wineacm.h,1.1.1.1,1.2

Arpi of Ize arpi at mplayer.dev.hu
Thu Oct 4 04:21:50 CEST 2001


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

Modified Files:
	Makefile afl.c driver.h elfdll.c ext.c ldt_keeper.c module.c 
	pe_image.c registry.h vfl.c win32.c win32.h wineacm.h 
Log Message:
sync with avifile

Index: Makefile
===================================================================
RCS file: /cvsroot/mplayer/main/loader/Makefile,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Makefile	12 Jul 2001 15:27:47 -0000	1.3
+++ Makefile	4 Oct 2001 02:21:34 -0000	1.4
@@ -4,7 +4,7 @@
 DEFINES=$(WIN32_PATH) -D__WINE__ -Ddbg_printf=__vprintf \
 	-DTRACE=__vprintf # -DDETAILED_OUT
 
-LIB_OBJECTS= setup_FS.o pe_image.o module.o \
+LIB_OBJECTS= ldt_keeper.o pe_image.o module.o \
 ext.o win32.o driver.o pe_resource.o \
 resource.o registry.o elfdll.o afl.o vfl.o
 

Index: afl.c
===================================================================
RCS file: /cvsroot/mplayer/main/loader/afl.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- afl.c	12 Jul 2001 15:27:47 -0000	1.2
+++ afl.c	4 Oct 2001 02:21:34 -0000	1.3
@@ -19,7 +19,7 @@
 
   
 ***************************************************************************/
-#include <config.h>
+#include "config.h"
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -27,17 +27,18 @@
 
 #include "win32.h"
 
-#include <wine/winbase.h>
-#include <wine/windef.h>
-#include <wine/winuser.h>
-#include <wine/vfw.h>
-#include <wine/winestring.h>
-#include <wine/driver.h>
-#include <wine/winerror.h>
-#include <wine/msacm.h>
-#include <wine/msacmdrv.h>
+#include "wine/winbase.h"
+#include "wine/windef.h"
+#include "wine/winuser.h"
+#include "wine/vfw.h"
+#include "wine/winestring.h"
+#include "wine/driver.h"
+#include "wine/winerror.h"
+#include "wine/msacm.h"
+#include "wine/msacmdrv.h"
 #include "wineacm.h"
 #include "ext.h"
+
 #include "driver.h"
 
 #define OpenDriverA DrvOpen

Index: driver.h
===================================================================
RCS file: /cvsroot/mplayer/main/loader/driver.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- driver.h	12 Jul 2001 15:27:47 -0000	1.1
+++ driver.h	4 Oct 2001 02:21:34 -0000	1.2
@@ -2,8 +2,8 @@
 #ifndef loader_driver_h
 #define	loader_driver_h
 
-#include <wine/windef.h>
-#include <wine/vfw.h>
+//#include "wine/windef.h"
+//#include "wine/vfw.h"
 
 extern HDRVR VFWAPI DrvOpen(LPARAM lParam2);
 extern void DrvClose(HDRVR hdrvr);

Index: elfdll.c
===================================================================
RCS file: /cvsroot/mplayer/main/loader/elfdll.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- elfdll.c	12 Jul 2001 15:27:47 -0000	1.2
+++ elfdll.c	4 Oct 2001 02:21:34 -0000	1.3
@@ -7,10 +7,10 @@
 
 #ifdef HAVE_LIBDL
 
-#include <string.h>
-#include <ctype.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
 
 #include <wine/windef.h>
 //#include <wine/global.h>

Index: ext.c
===================================================================
RCS file: /cvsroot/mplayer/main/loader/ext.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ext.c	12 Jul 2001 15:27:47 -0000	1.3
+++ ext.c	4 Oct 2001 02:21:34 -0000	1.4
@@ -67,7 +67,7 @@
 	return malloc(size);
 }
 
-WIN_BOOL WINAPI HeapFree(HANDLE heap, DWORD flags,LPVOID mem)
+WIN_BOOL WINAPI HeapFree(HANDLE heap, DWORD flags, LPVOID mem)
 {
     if (mem) free(mem);
     return 1;
@@ -82,15 +82,15 @@
 
 VOID WINAPI SetLastError(DWORD error)
 { 
-    last_error = error;
+    last_error=error;
 }    
 
-WIN_BOOL WINAPI ReadFile(HANDLE handle,LPVOID mem, DWORD size, LPDWORD result, LPOVERLAPPED flags)
+WIN_BOOL WINAPI ReadFile(HANDLE handle, LPVOID mem, DWORD size, LPDWORD result, LPOVERLAPPED flags)
 {
     *result=read(handle, mem, size);
     return *result;
 }    
-int WINAPI lstrcmpiA(const char* c1, const char* c2)
+INT WINAPI lstrcmpiA(LPCSTR c1, LPCSTR c2)
 {
     return strcasecmp(c1,c2);
 }
@@ -98,7 +98,7 @@
 {
     return strncpy(dest,src,num);
 }
-int WINAPI lstrlenA(const char* s)
+INT WINAPI lstrlenA(LPCSTR s)
 {
     return strlen(s);
 }   
@@ -114,7 +114,7 @@
 }
 LPSTR WINAPI lstrcpynWtoA(LPSTR dest, LPCWSTR src, INT count)
 {
-    LPSTR rval = dest;
+    LPSTR result = dest;
     int moved=0;
     if((dest==0) || (src==0))
 	return 0;
@@ -127,14 +127,16 @@
 	src++;
 	dest++;
     }
-    return rval;
+    return result;
 }
 int wcsnicmp(const unsigned short* s1, const unsigned short* s2, int n)
 {
+    /*
     if(s1==0)
 	return;
     if(s2==0)
         return;
+    */
     while(n>0)
     {
 	if(*s1<*s2)
@@ -309,7 +311,7 @@
 {
     int mapping_size;
     char* name;
-    HANDLE handle;
+    LPVOID handle;
     struct file_mapping_s* next;
     struct file_mapping_s* prev;
 }file_mapping;
@@ -335,7 +337,7 @@
 {
     int hFile = (int)handle;
     unsigned int len;
-    HANDLE answer;
+    LPVOID answer;
     int anon=0;
     int mmap_access=0;
     if(hFile<0)
@@ -357,10 +359,10 @@
     else
 	mmap_access |=PROT_READ|PROT_WRITE;
 	
-    answer=(HANDLE)mmap(NULL, len, mmap_access, MAP_PRIVATE, hFile, 0);    
+    answer=mmap(NULL, len, mmap_access, MAP_PRIVATE, hFile, 0);    
     if(anon)
         close(hFile);
-    if(answer!=(HANDLE)-1)
+    if(answer!=(LPVOID)-1)
     {
 	if(fm==0)
 	{
@@ -386,7 +388,7 @@
 	
 	if(anon)
 	    close(hFile);
-	return answer;
+	return (HANDLE)answer;
     }
     return (HANDLE)0;
 }        
@@ -395,10 +397,10 @@
     file_mapping* p;
     int result;
     if(fm==0)
-	return (HANDLE)0;
+	return 0;
     for(p=fm; p; p=p->next)
     {
-	if(p->handle==(HANDLE)handle)
+	if(p->handle==handle)
 	{
 	    result=munmap((void*)handle, p->mapping_size);
 	    if(p->next)p->next->prev=p->prev;
@@ -427,7 +429,7 @@
 #define MEM_COMMIT              0x00001000
 #define MEM_RESERVE             0x00002000
 
-void* WINAPI VirtualAlloc(void* address, DWORD size, DWORD type,  DWORD protection)
+LPVOID WINAPI VirtualAlloc(LPVOID address, DWORD size, DWORD type,  DWORD protection)
 {
     void* answer;
     int fd=open("/dev/zero", O_RDWR);
@@ -474,7 +476,7 @@
     if(answer==(void*)-1)
     {
 	printf("Error no %d\n", errno);
-	printf("VirtualAlloc(0x%08X, %d) failed\n", address, size);
+	printf("VirtualAlloc(0x%p, %ld) failed\n", address, size);
 	return NULL;
     }
     else
@@ -497,7 +499,7 @@
         return answer;
     }	
 }    	
-WIN_BOOL WINAPI VirtualFree(LPVOID address, DWORD t1, DWORD t2)//not sure
+WIN_BOOL WINAPI VirtualFree(LPVOID  address, DWORD t1, DWORD t2)//not sure
 {
     virt_alloc* str=vm;
     int answer;
@@ -518,14 +520,13 @@
     return -1;
 }
 
-INT WINAPI WideCharToMultiByte(UINT codepage, DWORD flags, 
-			       LPCWSTR src, INT srclen,
-			       LPSTR dest, INT destlen,
-			       LPCSTR defch, WIN_BOOL*used_defch)
+INT WINAPI WideCharToMultiByte(UINT codepage, DWORD flags, LPCWSTR src,
+     INT srclen,LPSTR dest, INT destlen, LPCSTR defch, WIN_BOOL* used_defch)
 {
     int i;
     if(src==0)
 	return 0;
+    if ((srclen==-1)&&(dest==0)) return 0;
     if(srclen==-1){srclen=0; while(src[srclen++]);}
 //    for(i=0; i<srclen; i++)
 //	printf("%c", src[i]);
@@ -552,9 +553,8 @@
     }	    
     return min(srclen, destlen);
 }
-INT WINAPI MultiByteToWideChar(UINT codepage, DWORD flags,
-			       LPCSTR src, INT srclen,
-			       LPWSTR dest, INT destlen)
+INT WINAPI MultiByteToWideChar(UINT codepage,DWORD flags, LPCSTR src, INT srclen,
+    LPWSTR dest, INT destlen)
 {
     return 0;
 }
@@ -570,7 +570,7 @@
 	if(p->name==0)
 	    continue;
 	if(strcmp(p->name, name)==0)
-	    return p->handle;
+	    return (HANDLE)p->handle;
     }
     return 0;	
 }

Index: ldt_keeper.c
===================================================================
RCS file: /cvsroot/mplayer/main/loader/ldt_keeper.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ldt_keeper.c	4 Oct 2001 00:06:10 -0000	1.1
+++ ldt_keeper.c	4 Oct 2001 02:21:34 -0000	1.2
@@ -72,6 +72,8 @@
 #endif
 #define       TEB_SEL LDT_SEL(TEB_SEL_IDX)
 
+#include "ldt_keeper.h"
+
 /**
  *
  *  This should be performed before we create first thread. See remarks

Index: module.c
===================================================================
RCS file: /cvsroot/mplayer/main/loader/module.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- module.c	12 Jul 2001 15:27:47 -0000	1.3
+++ module.c	4 Oct 2001 02:21:34 -0000	1.4
@@ -12,14 +12,8 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
-
 #include <sys/mman.h>
 #include <sys/types.h>
-#ifdef HAVE_LIBDL
-#include <wine/elfdll.h>
-#include <dlfcn.h>
-#endif
-
 /*
 #ifdef __linux__
 #include <asm/unistd.h>
@@ -53,6 +47,10 @@
 #include <wine/module.h>
 #include <wine/pe_image.h>
 #include <wine/debugtools.h>
+#ifdef HAVE_LIBDL
+#include <dlfcn.h>
+#include <wine/elfdll.h>
+#endif
 #include "win32.h"
 
 struct modref_list_t;
@@ -61,13 +59,15 @@
 {
     WINE_MODREF* wm;
     struct modref_list_t *next;
-    struct modref_list_t *prev;    
+    struct modref_list_t *prev;
 }
 modref_list;
 
 //WINE_MODREF *local_wm=NULL;
 modref_list* local_wm=NULL;
 
+//HANDLE SegptrHeap;  // unused?
+
 WINE_MODREF *MODULE_FindModule(LPCSTR m)
 {
     modref_list* list=local_wm;
@@ -80,10 +80,10 @@
 	list=list->prev;
 	if(list==NULL)
 	    return NULL;
-    }	
+    }
     TRACE("Resolved to %s\n", list->wm->filename);
     return list->wm;
-}    
+}
 
 static void MODULE_RemoveFromList(WINE_MODREF *mod)
 {
@@ -113,8 +113,8 @@
 	    return;
 	}
     }
-}    		    	
-		
+}
+
 WINE_MODREF *MODULE32_LookupHMODULE(HMODULE m)
 {
     modref_list* list=local_wm;
@@ -128,10 +128,10 @@
 	list=list->prev;
 	if(list==NULL)
 	    return NULL;
-    }	
-    TRACE("LookupHMODULE hit %X\n", list->wm);
+    }
+    TRACE("LookupHMODULE hit %p\n", list->wm);
     return list->wm;
-}    
+}
 
 /*************************************************************************
  *		MODULE_InitDll
@@ -140,7 +140,7 @@
 {
     WIN_BOOL retv = TRUE;
 
-    static LPCSTR typeName[] = { "PROCESS_DETACH", "PROCESS_ATTACH", 
+    static LPCSTR typeName[] = { "PROCESS_DETACH", "PROCESS_ATTACH",
                                  "THREAD_ATTACH", "THREAD_DETACH" };
     assert( wm );
 
@@ -181,14 +181,14 @@
 
 /*************************************************************************
  *		MODULE_DllProcessAttach
- * 
+ *
  * Send the process attach notification to all DLLs the given module
  * depends on (recursively). This is somewhat complicated due to the fact that
  *
  * - we have to respect the module dependencies, i.e. modules implicitly
  *   referenced by another module have to be initialized before the module
  *   itself can be initialized
- * 
+ *
  * - the initialization routine of a DLL can itself call LoadLibrary,
  *   thereby introducing a whole new set of dependencies (even involving
  *   the 'old' modules) at any time during the whole process
@@ -199,7 +199,7 @@
  *
  * Furthermore, we need to rearrange the main WINE_MODREF list to allow
  * the process *detach* notifications to be sent in the correct order.
- * This must not only take into account module dependencies, but also 
+ * This must not only take into account module dependencies, but also
  * 'hidden' dependencies created by modules calling LoadLibrary in their
  * attach notification routine.
  *
@@ -248,10 +248,10 @@
 	local_wm=malloc(sizeof(modref_list));
 	local_wm->next=local_wm->prev=NULL;
 	local_wm->wm=wm;
-    }		
+    }
     /* Remove recursion flag */
     wm->flags &= ~WINE_MODREF_MARKER;
-    
+
     if ( retv )
     {
         retv = MODULE_InitDll( wm, DLL_PROCESS_ATTACH, lpReserved );
@@ -267,8 +267,8 @@
 
 /*************************************************************************
  *		MODULE_DllProcessDetach
- * 
- * Send DLL process detach notifications.  See the comment about calling 
+ *
+ * Send DLL process detach notifications.  See the comment about calling
  * sequence at MODULE_DllProcessAttach.  Unless the bForceDetach flag
  * is set, only DLLs with zero refcount are notified.
  */
@@ -285,18 +285,59 @@
  */
 HMODULE WINAPI LoadLibraryExA(LPCSTR libname, HANDLE hfile, DWORD flags)
 {
-	WINE_MODREF *wm;
+	WINE_MODREF *wm = 0;
+	char* listpath[] = { "", "", "/usr/lib/win32", "/usr/local/lib/win32", 0 };
+	extern char* def_path;
+	char path[512];
+	char checked[2000];
+        int i = -1;
 
+        checked[0] = 0;
 	if(!libname)
 	{
 		SetLastError(ERROR_INVALID_PARAMETER);
 		return 0;
 	}
+
+	printf("Loading DLL: '%s'\n", libname);
+	
 //	if(fs_installed==0)
 //	    install_fs();
-	    
 
-	wm = MODULE_LoadLibraryExA( libname, hfile, flags );
+	while (wm == 0 && listpath[++i])
+	{
+	    if (i < 2)
+	    {
+		if (i == 0)
+		    /* check just original file name */
+		    strncpy(path, libname, 511); 
+                else
+		    /* check default user path */
+		    strncpy(path, def_path, 300);
+	    }
+	    else if (strcmp(def_path, listpath[i]))
+                /* path from the list */
+		strncpy(path, listpath[i], 300);
+	    else
+		continue;
+
+	    if (i > 0)
+	    {
+		strcat(path, "/");
+		strncat(path, libname, 100);
+	    }
+	    path[511] = 0;
+	    wm = MODULE_LoadLibraryExA( path, hfile, flags );
+
+	    if (!wm)
+	    {
+		if (checked[0])
+		    strcat(checked, ", ");
+		strcat(checked, path);
+                checked[1500] = 0;
+
+	    }
+	}
 	if ( wm )
 	{
 		if ( !MODULE_DllProcessAttach( wm, NULL ) )
@@ -309,6 +350,10 @@
 		}
 	}
 
+	if (!wm)
+	    printf("Win32 LoadLibrary failed to load: %s\n", checked);
+
+
 	return wm ? wm->module : 0;
 }
 
@@ -331,7 +376,6 @@
 	int i;
 //	module_loadorder_t *plo;
 
-
         SetLastError( ERROR_FILE_NOT_FOUND );
 	TRACE("Trying native dll '%s'\n", libname);
 	pwm = PE_LoadLibraryExA(libname, flags);
@@ -340,8 +384,8 @@
 	{
     	    TRACE("Trying ELF dll '%s'\n", libname);
 	    pwm=(WINE_MODREF*)ELFDLL_LoadLibraryExA(libname, flags);
-	}	
-#endif	
+	}
+#endif
 //		printf("0x%08x\n", pwm);
 //		break;
 	if(pwm)
@@ -356,7 +400,7 @@
 		return pwm;
 	}
 
-	
+
 	WARN("Failed to load module '%s'; error=0x%08lx, \n", libname, GetLastError());
 	return NULL;
 }
@@ -384,10 +428,10 @@
     {
         SetLastError( ERROR_INVALID_HANDLE );
 	return 0;
-    }	
+    }
     else
         retv = MODULE_FreeLibrary( wm );
-    
+
     MODULE_RemoveFromList(wm);
 
     /* garbage... */
@@ -459,13 +503,13 @@
 /***********************************************************************
  *           MODULE_GetProcAddress   		(internal)
  */
-FARPROC MODULE_GetProcAddress( 
+FARPROC MODULE_GetProcAddress(
 	HMODULE hModule, 	/* [in] current module handle */
 	LPCSTR function,	/* [in] function to be looked up */
 	WIN_BOOL snoop )
 {
     WINE_MODREF	*wm = MODULE32_LookupHMODULE( hModule );
-//    WINE_MODREF *wm=local_wm;    
+//    WINE_MODREF *wm=local_wm;
     FARPROC	retproc;
 
     if (HIWORD(function))
@@ -482,9 +526,9 @@
      	retproc = PE_FindExportedFunction( wm, function, snoop );
 	if (!retproc) SetLastError(ERROR_PROC_NOT_FOUND);
 	return retproc;
-#ifdef HAVE_LIBDL	
+#ifdef HAVE_LIBDL
     case MODULE32_ELF:
-	retproc = (FARPROC) dlsym( (void*)wm->module, function);
+	retproc = (FARPROC) dlsym( (void*) wm->module, function);
 	if (!retproc) SetLastError(ERROR_PROC_NOT_FOUND);
 	return retproc;
 #endif

Index: pe_image.c
===================================================================
RCS file: /cvsroot/mplayer/main/loader/pe_image.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- pe_image.c	29 Jul 2001 10:17:53 -0000	1.4
+++ pe_image.c	4 Oct 2001 02:21:34 -0000	1.5
@@ -33,7 +33,8 @@
  *   newer pe binaries produced by MSVC 5 and later, since they are also aligned
  *   to 4096 byte boundaries on disk.
  */
-#include <config.h>
+#include "config.h"
+//#include <wine/config.h>
 
 #include <errno.h>
 #include <assert.h>
@@ -44,9 +45,6 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
-#ifdef HAVE_ALLOCA_H
-#include <alloca.h>
-#endif
 #ifdef HAVE_SYS_MMAN_H
 #include <sys/mman.h>
 #endif
@@ -57,8 +55,7 @@
 #include <wine/pe_image.h>
 #include <wine/module.h>
 #include <wine/debugtools.h>
-#include <ext.h>
-
+#include "ext.h"
 #include "win32.h"
 
 #define RVA(x) ((void *)((char *)load_addr+(unsigned int)(x)))
@@ -179,7 +176,7 @@
                 ename = RVA(name[i]);
                 if (!strcmp( ename, funcName ))
                 {
-                    ERR( "%s.%s required a linear search\n", wm->modname, funcName );
+		    ERR( "%s.%s required a linear search\n", wm->modname, funcName );
                     ordinal = ordinals[i];
                     goto found;
                 }
@@ -565,6 +562,7 @@
         }
     }
 
+
     
     load_addr = nt->OptionalHeader.ImageBase;
     vma_size = calc_vma_size( hModule );
@@ -884,6 +882,7 @@
  * due to the PROCESS_Create stuff.
  */
 
+
 /*
  * This is a dirty hack.
  * The win32 DLLs contain an alloca routine, that first probes the soon
@@ -898,10 +897,11 @@
  */
 static void extend_stack_for_dll_alloca(void)
 {
+#ifndef __FreeBSD__
     void* mem=alloca(0x20000);
     *(int*)mem=0x1234;
+#endif
 }
-
 
 /* Called if the library is loaded or freed.
  * NOTE: if a thread attaches a DLL, the current thread will only do

Index: registry.h
===================================================================
RCS file: /cvsroot/mplayer/main/loader/registry.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- registry.h	24 Feb 2001 20:30:26 -0000	1.1.1.1
+++ registry.h	4 Oct 2001 02:21:34 -0000	1.2
@@ -1,24 +1,33 @@
-/********************************************************
-
-	Declaration of registry access functions
-	Copyright 2000 Eugene Smith (divx at euro.ru)
-
-*********************************************************/
+#ifndef AVIFILE_REGISTRY_H
+#define AVIFILE_REGISTRY_H
 
+/********************************************************
+ *
+ *       Declaration of registry access functions
+ *       Copyright 2000 Eugene Kuznetsov  (divx at euro.ru)
+ *
+ ********************************************************/
 
-#ifndef REGISTRY_H
-#define REGISTRY_H
 #ifdef __cplusplus
 extern "C" {
 #endif
-long RegOpenKeyExA(long key, const char* subkey, long reserved, long access, int* newkey);
+
+long RegOpenKeyExA(long key, const char* subkey, long reserved,
+		   long access, int* newkey);
 long RegCloseKey(long key);
-long RegQueryValueExA(long key, const char* value, int* reserved, int* type, int* data, int* count);
+long RegQueryValueExA(long key, const char* value, int* reserved,
+		      int* type, int* data, int* count);
 long RegCreateKeyExA(long key, const char* name, long reserved,
-							   void* classs, long options, long security,
-							   void* sec_attr, int* newkey, int* status);
-long RegSetValueExA(long key, const char* name, long v1, long v2, const void* data, long size);
+		     void* classs, long options, long security,
+		     void* sec_attr, int* newkey, int* status);
+long RegSetValueExA(long key, const char* name, long v1, long v2,
+		    const void* data, long size);
+#ifdef __WINE_WINERROR_H
+long RegEnumValueA(HKEY hkey, DWORD index, LPSTR value, LPDWORD val_count,
+		   LPDWORD reserved, LPDWORD type, LPBYTE data, LPDWORD count);
+#endif
 #ifdef __cplusplus
 };
 #endif
-#endif
+
+#endif // AVIFILE_REGISTRY_H

Index: vfl.c
===================================================================
RCS file: /cvsroot/mplayer/main/loader/vfl.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- vfl.c	13 Jul 2001 08:51:50 -0000	1.6
+++ vfl.c	4 Oct 2001 02:21:34 -0000	1.7
@@ -351,6 +351,8 @@
 	WINE_HIC	*whic = (WINE_HIC*)hic;
 	char qw[200];
 
+//    printf("ICSendMessage.whic=%p\n",whic);
+
 #if 0
     __asm__ __volatile__ ("fsave (%0)\n\t": :"r"(&qw));    
 #endif

Index: win32.c
===================================================================
RCS file: /cvsroot/mplayer/main/loader/win32.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- win32.c	20 Sep 2001 09:12:29 -0000	1.19
+++ win32.c	4 Oct 2001 02:21:34 -0000	1.20
@@ -11,14 +11,21 @@
 
 ************************************************************/
 
-#include <config.h>
+#include "config.h"
 
+#include "wine/winbase.h"
+#include "wine/winreg.h"
+#include "wine/winnt.h"
+#include "wine/winerror.h"
+#include "wine/debugtools.h"
+#include "wine/module.h"
 #include "win32.h"
+
 #include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
 #include <pthread.h>
 #include <errno.h>
-#include <ctype.h>
-#include <stdlib.h>
 #ifdef HAVE_MALLOC_H
 #include <malloc.h>
 #endif
@@ -28,38 +35,29 @@
 #include <sys/types.h>
 #include <sys/time.h>
 #include <sys/timeb.h>
-#if HAVE_LIBKSTAT
+#ifdef	HAVE_KSTAT
 #include <kstat.h>
 #endif
 
-#include <wine/winbase.h>
-#include <wine/winreg.h>
-#include <wine/winnt.h>
-#include <wine/winerror.h>
-#include <wine/debugtools.h>
-#include <wine/module.h>
-
-#include <registry.h>
-#include <loader.h>
-#include <com.h>
-
-long RegEnumValueA(HKEY hkey, DWORD index, LPSTR value, LPDWORD val_count,
-		   LPDWORD reserved, LPDWORD type, LPBYTE data, LPDWORD count);
+#include "registry.h"
+#include "loader.h"
+#include "com.h"
 
 char* def_path=WIN32_PATH;
 
 static void do_cpuid(unsigned int ax, unsigned int *regs)
 {
-    __asm__ __volatile__(
-	"pushl %%ebx; pushl %%ecx; pushl %%edx; "
-        ".byte  0x0f, 0xa2;"
-        "movl   %%eax, (%2);"
-        "movl   %%ebx, 4(%2);"
-        "movl   %%ecx, 8(%2);"
-        "movl   %%edx, 12(%2);"
-	"popl %%edx; popl %%ecx; popl %%ebx; "
-        : "=a" (ax)
-    :  "0" (ax), "S" (regs));
+	__asm__ __volatile__(
+	"pushl %%ebx; pushl %%ecx; pushl %%edx;"
+	".byte  0x0f, 0xa2;"
+	"movl   %%eax, (%2);"
+	"movl   %%ebx, 4(%2);"
+	"movl   %%ecx, 8(%2);"
+	"movl   %%edx, 12(%2);"
+	"popl %%edx; popl %%ecx; popl %%ebx;"
+	: "=a" (ax)
+	:  "0" (ax), "S" (regs)
+	);
 }
 static unsigned int c_localcount_tsc()
 {
@@ -102,9 +100,8 @@
     result+=limit*tv.tv_usec;
     *z=result;
 }
-
 static unsigned int localcount_stub(void);
-static void longcount_stub(long long* z);
+static void longcount_stub(long long*);
 static unsigned int (*localcount)()=localcount_stub;
 static void (*longcount)(long long*)=longcount_stub;
 
@@ -141,7 +138,7 @@
     longcount(z);
 }
 
-int LOADER_DEBUG=1;
+int LOADER_DEBUG=1; // active only if compiled with -DDETAILED_OUT
 static inline void dbgprintf(char* fmt, ...)
 {
 #ifdef DETAILED_OUT
@@ -171,7 +168,7 @@
 
 static unsigned char* heap=NULL; 
 static int heap_counter=0;
-static void test_heap()
+static void test_heap(void)
 {
     int offset=0;	
     if(heap==0)
@@ -224,11 +221,11 @@
     if(to_zero)
     	memset(heap+heap_counter, 0, size);	    
     else
-      memset(heap+heap_counter, 0xcc, size);
+	memset(heap+heap_counter, 0xcc, size);  // make crash reprocable
     heap_counter+=size;
     return heap+heap_counter-size;	
 }
-int my_release(void* memory)
+int my_release(char* memory)
 {
 //    test_heap();
     if(memory==NULL)
@@ -299,7 +296,7 @@
 	}
 	else {
 		for(;pp;pp=pp->prev) {
-			if (pp->addr == memory-4) {
+			if (pp->addr == (char*)memory-4) {
 				if (pp->prev)
 					pp->prev->next=pp->next;
 				if (pp->next)
@@ -312,26 +309,48 @@
 			}
 		}
         	if (pp == NULL) {
-			printf("Not Found %p %d\n",memory-4,alccnt);
+			printf("Not Found %p %d\n",(char*)memory-4,alccnt);
 			return 0;
 		}
 	}
     }
 #endif
-    free(memory-4);
+    free((char*)memory-4);
     return 0;
 }
 #endif
-int my_size(char* memory)
+int my_size(void* memory)
 {
-    return *(int*)(memory-4);
+    return *(int*)((char*)memory-4);
 }    
+void* my_realloc(void* memory,int size)
+{
+  void *ans;
+#ifdef GARBAGE
+  alc_list* pp;
+  if(memory == NULL)return 0;
+  pp=alclist;
+  if(pp == NULL) return 0;
+  ans=NULL;
+  for(;pp;pp=pp->prev) {
+    if (pp->addr == (char*)memory-4) {
+      ans = realloc(memory-4,size+4);
+      if (ans == 0) return 0;
+      pp->size = size;
+      pp->addr = ans;
+    }
+  }
+#else
+  ans = realloc(memory-4,size+4);
+#endif
+  return ans;
+}
 
 extern int unk_exp1;
 char extcode[20000];// place for 200 unresolved exports
 int pos=0;
 
-int WINAPI ext_unknown(void)
+int WINAPI ext_unknown()
 {
     printf("Unknown func called\n");
     return 0;
@@ -408,21 +427,23 @@
     return 0;
 }    
 
-void* WINAPI expGetDriverModuleHandle(DRVR* pdrv)
+HMODULE WINAPI expGetDriverModuleHandle(DRVR* pdrv)
 {
-    void* result;
-    if (pdrv==NULL)
-	result=NULL;
+    HMODULE result;
+    if (pdrv==NULL) 
+	result=0;
     else
-	result=(void*) pdrv->hDriverModule;
-    dbgprintf("GetDriverModuleHandle(0x%x) => 0x%x\n", pdrv, result);
+        result=pdrv->hDriverModule;
+    dbgprintf("GetDriverModuleHandle(%p) => %p\n", pdrv, result);
     return result;
 }
 
-void* WINAPI expGetModuleHandleA(const char* name)
+#define	MODULE_HANDLE_kernel32	((HMODULE)0x120)
+
+HMODULE WINAPI expGetModuleHandleA(const char* name)
 {
 	WINE_MODREF* wm;
-	void* result;
+	HMODULE result;
 	if(!name)
 	    result=0;
 	else
@@ -430,12 +451,12 @@
     	    wm=MODULE_FindModule(name);
 		if(wm==0)result=0;
 	    else
-    		result=(void*)(wm->module);
+    		result=(HMODULE)(wm->module);
 	}
 	if(!result)
 	{
 	    if(strcasecmp(name, "kernel32")==0)
-		result=(void *) 0x120;
+		result=MODULE_HANDLE_kernel32;
 	}	
          dbgprintf("GetModuleHandleA('%s') => 0x%x\n", name, result);
 	return result;
@@ -515,7 +536,7 @@
 		    pSecAttr, bManualReset, bInitialState, name, name, pp->pm);
 		return pp->pm;
 	    }
-	}while((pp=pp->prev));
+	}while((pp=pp->prev) != NULL);
     }	
     pm=my_mreq(sizeof(pthread_mutex_t), 0);
     pthread_mutex_init(pm, NULL);
@@ -584,18 +605,20 @@
 void* WINAPI expWaitForSingleObject(void* object, int duration)
 {
     mutex_list *ml = (mutex_list *)object;
-    int ret=WAIT_FAILED; // fixed by Zdenek Kabelac
+    // FIXME FIXME FIXME - this value is sometime unititialize !!!
+    int ret = WAIT_FAILED;
     mutex_list* pp=mlist;
-//    dbgprintf("WaitForSingleObject(0x%x, duration %d) =>\n",object, duration);
+    dbgprintf("WaitForSingleObject(0x%x, duration %d) =>\n",object, duration);
+
     // loop below was slightly fixed - its used just for checking if
     // this object really exists in our list
     if (!ml)
         return (void*) ret;
     while (pp && (pp->pm != ml->pm))
-        pp = pp->prev;
+	pp = pp->prev;
     if (!pp) {
-        //dbgprintf("WaitForSingleObject: NotFound\n");
-        return (void*)ret;
+	dbgprintf("WaitForSingleObject: NotFound\n");
+	return (void*)ret;
     }
 
     pthread_mutex_lock(ml->pm);
@@ -679,8 +702,7 @@
 	static int cache = 0;
 	static SYSTEM_INFO cachedsi;
 	unsigned int regs[4];
-	HKEY	xhkey=0,hkey;
-        dbgprintf("GetSystemInfo(0x%d) =>\n");
+        dbgprintf("GetSystemInfo(%p) =>\n", si);
 
 	if (cache) {
 		memcpy(si,&cachedsi,sizeof(*si));
@@ -735,7 +757,6 @@
 
 	if (!f)
 		return;
-        xhkey = 0;
 	while (fgets(line,200,f)!=NULL) {
 		char	*s,*value;
 
@@ -771,7 +792,7 @@
 				}
 			}
 			/* set the CPU type of the current processor */
-			snprintf(buf,20,"CPU %ld",cachedsi.dwProcessorType);
+			sprintf(buf,"CPU %ld",cachedsi.dwProcessorType);
 			continue;
 		}
 		/* old 2.0 method */
@@ -798,7 +819,7 @@
 				}
 			}
 			/* set the CPU type of the current processor */
-			snprintf(buf,20,"CPU %ld",cachedsi.dwProcessorType);
+			sprintf(buf,"CPU %ld",cachedsi.dwProcessorType);
 			continue;
 		}
 		if (!lstrncmpiA(line,"fdiv_bug",strlen("fdiv_bug"))) {
@@ -824,7 +845,7 @@
 			/* Create a new processor subkey on a multiprocessor
 			 * system
 			 */
-			snprintf(buf,20,"%d",x);
+			sprintf(buf,"%d",x);
 		}
 		if (!lstrncmpiA(line,"stepping",strlen("stepping"))) {
 			int	x;
@@ -853,6 +874,7 @@
         cachedsi.dwNumberOfProcessors=1;
 	}
 #endif /* __FreeBSD__ */
+	cache = 1;
 	memcpy(si,&cachedsi,sizeof(*si));
 	DumpSystemInfo(si);
 }
@@ -908,6 +930,19 @@
     dbgprintf("HeapSize(heap 0x%x, flags 0x%x, pointer 0x%x) => %d\n", heap, flags, pointer, result);
     return result;
 } 
+void* WINAPI expHeapReAlloc(HANDLE heap,int flags,void *lpMem,int size)
+{
+  long orgsize;
+  void *newp;
+  orgsize = my_size(lpMem);
+  dbgprintf("HeapReAlloc() Size %ld org %d\n",orgsize,size);
+  if (size < orgsize) 
+    return lpMem;
+  newp=my_mreq(size, flags & 8);
+  memcpy(newp, lpMem, orgsize);
+  my_release(lpMem);
+  return newp;
+}
 long WINAPI expGetProcessHeap(void)
 {
     dbgprintf("GetProcessHeap() => 1\n");
@@ -934,6 +969,7 @@
     pthread_mutex_t mutex;
     int locked;
 };
+
 void WINAPI expInitializeCriticalSection(CRITICAL_SECTION* c)
 {
     struct CRITSECT cs;
@@ -955,6 +991,12 @@
 {
     struct CRITSECT* cs=*(struct CRITSECT**)c;
     dbgprintf("EnterCriticalSection(0x%x)\n",c);
+    if (!cs)
+    {
+	expInitializeCriticalSection(c);
+	cs=*(struct CRITSECT**)c;
+	printf("Win32 Warning: Accessed uninitialized Critical Section (%p)!\n", c);
+    }
 //    cs.id=pthread_self();
     if(cs->locked)
 	if(cs->id==pthread_self())
@@ -969,6 +1011,11 @@
     struct CRITSECT* cs=*(struct CRITSECT**)c;
 //    struct CRITSECT* cs=(struct CRITSECT*)c;
     dbgprintf("LeaveCriticalSection(0x%x)\n",c);
+    if (!cs)
+    {
+	printf("Win32 Warning: Leaving noninitialized Critical Section %p!!\n", c);
+	return;
+    }
     cs->locked=0;
     pthread_mutex_unlock(&(cs->mutex));
     return;
@@ -993,13 +1040,13 @@
     return getpid();
 }                  
 
-struct tls_s
-{
+struct tls_s {
     void* value;
     int used;
     struct tls_s* prev;
     struct tls_s* next;
 };
+
 tls_t* g_tls=NULL;    
     
 void* WINAPI expTlsAlloc()
@@ -1017,6 +1064,7 @@
 	g_tls=g_tls->next;
     }
     dbgprintf("TlsAlloc() => 0x%x\n", g_tls);
+    g_tls->value=0; /* XXX For Divx.dll */
     return g_tls;    
 }
 
@@ -1072,6 +1120,30 @@
     dbgprintf("LocalAlloc(%d, flags 0x%x) => 0x%x\n", size, flags, z);
     return z;
 }	
+
+void* WINAPI expLocalReAlloc(int handle,int size, int flags)
+{
+   void *newpointer;
+   int oldsize;
+
+   newpointer=NULL;
+   if (flags & LMEM_MODIFY) {
+        dbgprintf("LocalReAlloc MODIFY\n");
+       return (void *)handle;
+   }
+   oldsize = my_size((void *)handle);
+   if (size >  oldsize) {
+     newpointer=my_realloc((void *)handle,size);
+   }
+   else {
+     newpointer=(void *)handle;
+   }
+   dbgprintf("LocalReAlloc(%x %d(old %d), flags 0x%x) => 0x%x\n", handle,size,oldsize, flags,newpointer);
+
+  return newpointer;
+
+}
+
 void* WINAPI expLocalLock(void* z)
 {
     dbgprintf("LocalLock(0x%x) => 0x%x\n", z, z);
@@ -1130,12 +1202,12 @@
     result=i;
     }
     if(s1)
-    dbgprintf("MultiByteToWideChar(codepage %d, flags 0x%x, string 0x%x='%s', "
-	"size %d, dest buffer 0x%x, dest size %d) => %d\n",
+    dbgprintf("MultiByteToWideChar(codepage %d, flags 0x%x, string 0x%x='%s',
+	size %d, dest buffer 0x%x, dest size %d) => %d\n",
 	    v1, v2, s1, s1, siz1, s2, siz2, result);
     else
-    dbgprintf("MultiByteToWideChar(codepage %d, flags 0x%x, string NULL, "
-	"size %d, dest buffer 0x%x, dest size %d) =>\n",
+    dbgprintf("MultiByteToWideChar(codepage %d, flags 0x%x, string NULL,
+	size %d, dest buffer 0x%x, dest size %d) =>\n",
 	    v1, v2, siz1, s2, siz2, result);
     return result;
 }
@@ -1152,7 +1224,7 @@
 	"dest 0x%x, dest size %d, defch 0x%x, used_defch 0x%x)", v1, v2, s1, siz1, s2, siz2, c3, siz3);
     result=WideCharToMultiByte(v1, v2, s1, siz1, s2, siz2, c3, siz3);
     dbgprintf("=> %d\n", result);
-    if(s1)wch_print(s1);
+    //if(s1)wch_print(s1);
     if(s2)dbgprintf("  dest: %s\n", s2);
     return result;
 }
@@ -1163,10 +1235,16 @@
     c->dwMajorVersion=4;
     c->dwMinorVersion=0;
     c->dwBuildNumber=0x4000457;
+#if 0
+    // leave it here for testing win9x-only codecs
     c->dwPlatformId=VER_PLATFORM_WIN32_WINDOWS;
     strcpy(c->szCSDVersion, " B");
+#else
+    c->dwPlatformId=VER_PLATFORM_WIN32_NT; // let's not make DLL assume that it can read CR* registers
+    strcpy(c->szCSDVersion, "Service Pack 3");
+#endif
     dbgprintf("  Major version: 4\n  Minor version: 0\n  Build number: 0x4000457\n"
-    "  Platform Id: VER_PLATFORM_WIN32_WINDOWS\n Version string: ' B'\n");
+    "  Platform Id: VER_PLATFORM_WIN32_NT\n Version string: 'Service Pack 3'\n");
     return 1;
 }        
 HANDLE WINAPI expCreateSemaphoreA(char* v1, long init_count, long max_count, char* name)
@@ -1185,7 +1263,7 @@
 		    v1, init_count, max_count, name, name, mlist);
 		return (HANDLE)mlist;
 	    }
-	}while((pp=pp->prev));
+	}while((pp=pp->prev) != NULL);
     }	
     pm=my_mreq(sizeof(pthread_mutex_t), 0);
     pthread_mutex_init(pm, NULL);
@@ -1297,6 +1375,13 @@
     return result;
 }
 
+DWORD WINAPI expRegEnumValueA(HKEY hkey, DWORD index, LPSTR value, LPDWORD val_count,
+			       LPDWORD reserved, LPDWORD type, LPBYTE data, LPDWORD count)
+{
+    return RegEnumValueA(hkey, index, value, val_count,
+			 reserved, type, data, count);
+}
+
 long WINAPI expQueryPerformanceCounter(long long* z)
 {
     longcount(z);
@@ -1641,17 +1726,18 @@
     dbgprintf("SetUnhandledExceptionFilter(0x%x) => 1\n", filter);
     return 1;//unsupported and probably won't ever be supported
 }    
-extern char* def_path;
+
 int WINAPI expLoadLibraryA(char* name)
 {
-    char qq[256];
-    int result;
+    int result = 0;
     char* lastbc;
+    int i;
     if (!name)
 	return -1;
     // we skip to the last backslash
     // this is effectively eliminating weird characters in
     // the text output windows
+
     lastbc = strrchr(name, '\\');
     if (lastbc)
     {
@@ -1664,52 +1750,43 @@
 		break;
 	}
     }
-//    printf("LoadLibrary wants: %s/%s\n", def_path, name);
-
-    if(strncmp(name, "c:\\windows\\", 11)==0)name+=11;
+    if(strncmp(name, "c:\\windows\\", 11)==0) name += 11;
     if(strncmp(name, ".\\", 2)==0) name += 2;
-    if(name[0]!='/')
-    {
-	strcpy(qq, def_path);
-	strcat(qq, "/");
-	strcat(qq, name);
-    }
-    printf("Loading DLL: %s", qq);fflush(stdout);
-//    printf("Entering LoadLibraryA(%s)\n", name);
-    result=LoadLibraryA(qq);
-    if(!result) printf("  FAILED!\n"); else printf("  OK\n");
-//    printf("Returned LoadLibraryA(0x%x='%s'), def_path=%s => 0x%x\n", name, name, def_path, result);
+
+    dbgprintf("Entering LoadLibraryA(%s)\n", name);
+    result=LoadLibraryA(name);
+    dbgprintf("Returned LoadLibraryA(0x%x='%s'), def_path=%s => 0x%x\n", name, name, def_path, result);
+
     return result;
-}      
+}
 int WINAPI expFreeLibrary(int module)
 {
     int result=FreeLibrary(module);
     dbgprintf("FreeLibrary(0x%x) => %d\n", module, result);
     return result;
 }   
-void* LookupExternalByName(const char* library, const char* name);
 void* WINAPI expGetProcAddress(HMODULE mod, char* name)
 {
-    void *result;
-    if(mod!=0x120)
+    void* result;
+    if(mod!=MODULE_HANDLE_kernel32)
 	result=GetProcAddress(mod, name);
     else
 	result=LookupExternalByName("kernel32.dll", name);
     dbgprintf("GetProcAddress(0x%x, '%s') => 0x%x\n", mod, name, result);
     return result;
-}    
+}
 
 long WINAPI expCreateFileMappingA(int hFile, void* lpAttr,
     long flProtect, long dwMaxHigh, long dwMaxLow, const char* name)
 {
     long result=CreateFileMappingA(hFile, lpAttr, flProtect, dwMaxHigh, dwMaxLow, name);
     if(!name)
-    dbgprintf("CreateFileMappingA(file 0x%x, lpAttr 0x%x, "
-	"flProtect 0x%x, dwMaxHigh 0x%x, dwMaxLow 0x%x, name 0) => %d\n",
+    dbgprintf("CreateFileMappingA(file 0x%x, lpAttr 0x%x, 
+	flProtect 0x%x, dwMaxHigh 0x%x, dwMaxLow 0x%x, name 0) => %d\n",
 	    hFile, lpAttr, flProtect, dwMaxHigh, dwMaxLow, result);
     else
-    dbgprintf("CreateFileMappingA(file 0x%x, lpAttr 0x%x, "
-	"flProtect 0x%x, dwMaxHigh 0x%x, dwMaxLow 0x%x, name 0x%x='%s') => %d\n",
+    dbgprintf("CreateFileMappingA(file 0x%x, lpAttr 0x%x, 
+	flProtect 0x%x, dwMaxHigh 0x%x, dwMaxLow 0x%x, name 0x%x='%s') => %d\n",
 	    hFile, lpAttr, flProtect, dwMaxHigh, dwMaxLow, name, name, result);    
     return result;
 }    
@@ -1741,7 +1818,9 @@
 
 void* WINAPI expSleep(int time)
 {
+//    extern int avm_usleep(int);
     dbgprintf("Sleep(%d) => 0\n", time);
+//    avm_usleep(time);
     usleep(time);
     return 0;
 }
@@ -1986,10 +2065,12 @@
 
 int WINAPI expStringFromGUID2(GUID* guid, char* str, int cbMax)
 {
-    int result=snprintf(str, cbMax, "%.8lx-%.4x-%.4x-%.2x%.2x%.2x%.2x%.2x%.2x%.2x%.2x",
-     guid->f1, guid->f2, guid->f3,
-     (unsigned char)guid->f4[0], (unsigned char)guid->f4[1], (unsigned char)guid->f4[2], (unsigned char)guid->f4[3], 
-     (unsigned char)guid->f4[4], (unsigned char)guid->f4[5], (unsigned char)guid->f4[6], (unsigned char)guid->f4[7]);
+    int result=snprintf(str, cbMax, "%.8x-%.4x-%.4x-%.2x%.2x%.2x%.2x%.2x%.2x%.2x%.2x",
+			guid->f1, guid->f2, guid->f3,
+			(unsigned char)guid->f4[0], (unsigned char)guid->f4[1],
+			(unsigned char)guid->f4[2], (unsigned char)guid->f4[3],
+			(unsigned char)guid->f4[4], (unsigned char)guid->f4[5],
+			(unsigned char)guid->f4[6], (unsigned char)guid->f4[7]);
     dbgprintf("StringFromGUID2(0x%x, 0x%x='%s', %d) => %d\n", guid, str, str, cbMax, result);
     return result;
 }
@@ -2009,16 +2090,6 @@
     if(string)wch_print(string);
     return result;
 }    
-
-int WINAPI expIsBadStringPtrA(const char* string, int nchars)
-{
-    int result=0;
-//    if(string==0)result=1; else result=0;
-//    dbgprintf("IsBadStringPtrW(0x%x, %d) => %d", string, nchars, result);
-//    if(string)wch_print(string);
-    return result;
-}    
-
 extern long WINAPI InterlockedExchangeAdd( long* dest, long incr )
 {
     long ret;
@@ -2075,6 +2146,54 @@
     dbgprintf("SetCursor(0x%x) => 0x%x\n", cursor, cursor);
     return (int)cursor;
 }
+int WINAPI expGetCursorPos(void *cursor)
+{
+    dbgprintf("GetCursorPos(0x%x) => 0x%x\n", cursor, cursor);
+    return 1;
+}
+int WINAPI expRegisterWindowMessageA(char *message)
+{
+    dbgprintf("RegisterWindowMessageA(%s)\n", message);
+    return 1;
+}
+int WINAPI expGetProcessVersion(int pid)
+{
+    dbgprintf("GetProcessVersion(%d)\n", pid);
+    return 1;
+}
+int WINAPI expGetCurrentThread(void)
+{
+    dbgprintf("GetCurrentThread()\n");
+    return 1;
+}
+int WINAPI expGetOEMCP(void)
+{
+    dbgprintf("GetOEMCP()\n");
+    return 1;
+}
+int WINAPI expGetCPInfo(int cp,void *info)
+{
+    dbgprintf("GetCPInfo()\n");
+    return 0;
+}
+int WINAPI expGetSystemMetrics(int index)
+{
+    dbgprintf("GetSystemMetrics(%d)\n", index);
+    return 1;
+}
+int WINAPI expGetSysColor(int index)
+{
+    dbgprintf("GetSysColor(%d)\n", index);
+    return 1;
+}
+int WINAPI expGetSysColorBrush(int index)
+{
+    dbgprintf("GetSysColorBrush(%d)\n", index);
+    return 1;
+}
+
+
+
 int WINAPI expGetSystemPaletteEntries(int hdc, int iStartIndex, int nEntries, void* lppe)
 {
     dbgprintf("GetSystemPaletteEntries(0x%x, 0x%x, 0x%x, 0x%x) => 0\n",
@@ -2166,6 +2285,7 @@
     "  Milliseconds: %d\n",
     systime->wYear, systime->wMonth, systime->wDayOfWeek, systime->wDay,
     systime->wHour, systime->wMinute, systime->wSecond, systime->wMilliseconds);
+    return 0;
 }
 
 int WINAPI expGetEnvironmentVariableA(const char* name, char* field, int size)
@@ -2205,14 +2325,51 @@
 static int com_object_size=0;
 int RegisterComClass(GUID* clsid, GETCLASSOBJECT gcs)
 {
-    if(!clsid)return -1;
-    if(!gcs)return -1;
+    if(!clsid || !gcs)
+	return -1;
     com_object_table=realloc(com_object_table, sizeof(struct COM_OBJECT_INFO)*(++com_object_size));
     com_object_table[com_object_size-1].clsid=*clsid;        
     com_object_table[com_object_size-1].GetClassObject=gcs;
     return 0;        
 }
 
+int UnregisterComClass(GUID* clsid, GETCLASSOBJECT gcs)
+{
+    int found = 0;
+    int i = 0;
+    if(!clsid || !gcs)
+	return -1;
+
+    if (com_object_table == 0)
+	printf("Warning: UnregisterComClass() called without any registered class\n");
+    while (i < com_object_size)
+    {
+	if (found && i > 0)
+	{
+	    memcpy(&com_object_table[i - 1].clsid,
+		   &com_object_table[i].clsid, sizeof(GUID));
+	    com_object_table[i - 1].GetClassObject =
+		com_object_table[i].GetClassObject;
+	}
+	else if (memcmp(&com_object_table[i].clsid, clsid, sizeof(GUID)) == 0
+		 && com_object_table[i].GetClassObject == gcs)
+	{
+            found++;
+	}
+	i++;
+    }
+    if (found)
+    {
+	if (--com_object_size == 0)
+	{
+	    free(com_object_table);
+            com_object_table = 0;
+	}
+    }
+    return 0;
+}
+
+
 GUID IID_IUnknown={0x00000000, 0x0000, 0x0000,
     {0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}};
 GUID IID_IClassFactory={0x00000001, 0x0000, 0x0000,
@@ -2438,31 +2595,6 @@
     return 1;
 }
 
-
-/******************************************************************************
- *           RegEnumValueA   [ADVAPI32.@]
- */
- DWORD WINAPI expRegEnumValueA( HKEY hkey, DWORD index, LPSTR value, LPDWORD val_count,
-                             LPDWORD reserved, LPDWORD type, LPBYTE data, LPDWORD count )
-{
- 
-// printf("RegEnumValueA(%x,%ld,%p,%p,%p,%p,%p,%p)\n",
-//   hkey, index, value, val_count, reserved, type, data, count );
-// return -1;
-
- return RegEnumValueA(hkey, index, value, val_count,
-			 reserved, type, data, count);
-
-}
- 
-
-#if 0
-INT WINAPI expMulDiv(int nNumber,int nNumerator,int nDenominator)
-{
-	return ((long long)nNumber * (long long)nNumerator) / nDenominator;
-}
-#endif
-
 int WINAPI expMulDiv(int nNumber, int nNumerator, int nDenominator)
 {
     static const long long max_int=0x7FFFFFFFLL;
@@ -2495,6 +2627,23 @@
     dbgprintf("strcpy(0x%x, 0x%x='%s') => %d\n", str1, str2, str2, result);
     return result;
 }
+LONG WINAPI explstrcpynA(char* str1, const char* str2,int len)
+{
+    int result;
+    if (strlen(str2)>len)
+      result =  (int) strncpy(str1, str2,len);
+    else
+      result =  (int) strcpy(str1,str2);
+    dbgprintf("strncpy(0x%x, 0x%x='%s' len %d strlen %d) => %x\n", str1, str2, str2,len, strlen(str2),result);
+    return result;
+}
+LONG WINAPI explstrcatA(char* str1, const char* str2)
+{
+    int result= (int) strcat(str1, str2);
+    dbgprintf("strcat(0x%x, 0x%x='%s') => %d\n", str1, str2, str2, result);
+    return result;
+}
+
 
 LONG WINAPI expInterlockedExchange(long *dest, long l)
 {
@@ -2504,57 +2653,12 @@
 	return retval;
 }
 
-int WINAPI expUnknownMFC42_1176() /* exact number of arguments unknown */
+void WINAPI expInitCommonControls()
 {
-    dbgprintf("MFC42:1176\n");
-    return 0;
-}
-
-int WINAPI expUnknownMFC42_1243() /* exact number of arguments unknown */
-{
-    dbgprintf("MFC42:1243\n");
-    return 0;
-}
-
-int UnregisterComClass(GUID* clsid, GETCLASSOBJECT gcs)
-{
-    int found = 0;
-    int i = 0;
-    if(!clsid || !gcs)
-	return -1;
-
-    if (com_object_table == 0)
-	printf("Warning: UnregisterComClass() called without any registered class\n");
-    while (i < com_object_size)
-    {
-	if (found && i > 0)
-	{
-	    memcpy(&com_object_table[i - 1].clsid,
-		   &com_object_table[i].clsid, sizeof(GUID));
-	    com_object_table[i - 1].GetClassObject =
-		com_object_table[i].GetClassObject;
-	}
-	else if (memcmp(&com_object_table[i].clsid, clsid, sizeof(GUID)) == 0
-		 && com_object_table[i].GetClassObject == gcs)
-	{
-            found++;
-	}
-	i++;
-    }
-    if (found)
-    {
-	if (--com_object_size == 0)
-	{
-	    free(com_object_table);
-            com_object_table = 0;
-	}
-    }
-    return 0;
+    printf("InitCommonControls called!\n");
+    return;
 }
 
-
-
-
 struct exports
 {
     char name[64];
@@ -2575,7 +2679,6 @@
 FF(IsBadWritePtr, 357)
 FF(IsBadReadPtr, 354)
 FF(IsBadStringPtrW, -1)
-FF(IsBadStringPtrA, -1)
 FF(DisableThreadLibraryCalls, -1)
 FF(CreateThread, -1)
 FF(CreateEventA, -1)
@@ -2589,6 +2692,7 @@
 FF(HeapDestroy, -1)
 FF(HeapFree, -1)
 FF(HeapSize, -1)
+FF(HeapReAlloc,-1)
 FF(GetProcessHeap, -1)
 FF(VirtualAlloc, -1)
 FF(VirtualFree, -1)
@@ -2603,6 +2707,7 @@
 FF(GetCurrentThreadId, -1)
 FF(GetCurrentProcess, -1)
 FF(LocalAlloc, -1) 
+FF(LocalReAlloc,-1)
 FF(LocalLock, -1)
 FF(GlobalAlloc, -1)
 FF(GlobalReAlloc, -1)
@@ -2684,6 +2789,12 @@
 FF(lstrcmpiA, -1)
 FF(lstrlenA, -1)
 FF(lstrcpyA, -1)
+FF(lstrcatA, -1)
+FF(GetProcessVersion,-1)
+FF(GetCurrentThread,-1)
+FF(GetOEMCP,-1)
+FF(GetCPInfo,-1)
+FF(lstrcpynA,-1)
 };
 
 struct exports exp_msvcrt[]={
@@ -2720,6 +2831,12 @@
 FF(IsRectEmpty, -1)
 FF(LoadCursorA,-1)
 FF(SetCursor,-1)
+FF(GetCursorPos,-1)
+FF(GetCursorPos,-1)
+FF(RegisterWindowMessageA,-1)
+FF(GetSystemMetrics,-1)
+FF(GetSysColor,-1)
+FF(GetSysColorBrush,-1)
 };
 struct exports exp_advapi32[]={
 FF(RegOpenKeyA, -1)
@@ -2728,7 +2845,7 @@
 FF(RegQueryValueExA, -1)
 FF(RegSetValueExA, -1)
 FF(RegCloseKey, -1)
-//FF(RegEnumValueA, -1)
+FF(RegEnumValueA, -1)
 };
 struct exports exp_gdi32[]={
 FF(CreateCompatibleDC, -1)
@@ -2745,13 +2862,13 @@
 FF(CoCreateInstance, -1)
 FF(StringFromGUID2, -1)
 };
-struct exports exp_mfc42[]={
-FF(UnknownMFC42_1176, 1176)
-FF(UnknownMFC42_1243, 1243)
-};
 struct exports exp_crtdll[]={
 FF(memcpy, -1)
 };
+struct exports exp_comctl32[]={
+FF(StringFromGUID2, -1)
+FF(InitCommonControls, 17)
+};
 
 #define LL(X) \
 {#X".dll", sizeof(exp_##X)/sizeof(struct exports), exp_##X},
@@ -2765,10 +2882,11 @@
 LL(gdi32)
 LL(version)
 LL(ole32)
-LL(mfc42)
 LL(crtdll)
+LL(comctl32)
 };
 
+
 void* LookupExternal(const char* library, int ordinal)
 {
     char* answ;
@@ -2789,7 +2907,7 @@
 	{
 	    if(ordinal!=libraries[i].exps[j].id)
 		continue;
-	    printf("Hit: 0x%08X\n", libraries[i].exps[j].func);
+	    printf("Hit: 0x%p\n", libraries[i].exps[j].func);
 	    return libraries[i].exps[j].func;
 	}
     }
@@ -2847,7 +2965,7 @@
 //    return (void*)ext_unknown;
 }
 
-int my_garbagecollection(void)
+void my_garbagecollection(void)
 {
 #ifdef GARBAGE
     alc_list* pp,*ppsv;
@@ -2873,7 +2991,7 @@
       }
     }
  
-    if (alclist==NULL) return 0;
+    if (alclist==NULL) return;
 
     pp=alclist;
     unfree=unfreecnt=0;

Index: win32.h
===================================================================
RCS file: /cvsroot/mplayer/main/loader/win32.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- win32.h	12 Jul 2001 15:27:47 -0000	1.2
+++ win32.h	4 Oct 2001 02:21:34 -0000	1.3
@@ -9,8 +9,9 @@
 
 extern void* my_mreq(int size, int to_zero);
 extern int my_release(void* memory);
-extern int my_size(char* memory);
-extern int my_garbagecollection(void);
+extern int my_size(void* memory);
+extern void* my_realloc(void *memory,int size);
+extern void my_garbagecollection(void);
 
 
 typedef struct {
@@ -31,8 +32,8 @@
 extern int WINAPI expIsBadWritePtr(void* ptr, unsigned int count);
 extern int WINAPI expIsBadReadPtr(void* ptr, unsigned int count);
 extern int WINAPI expDisableThreadLibraryCalls(int module);
-extern void* WINAPI expGetDriverModuleHandle(DRVR* pdrv);
-extern void* WINAPI expGetModuleHandleA(const char* name);
+extern HMODULE WINAPI expGetDriverModuleHandle(DRVR* pdrv);
+extern HMODULE WINAPI expGetModuleHandleA(const char* name);
 extern void* WINAPI expCreateThread(void* pSecAttr, long dwStackSize, void* lpStartAddress,
 				    void* lpParameter, long dwFlags, long* dwThreadId);
 extern void* WINAPI expCreateEventA(void* pSecAttr, char bManualReset,
@@ -48,6 +49,7 @@
 extern void* WINAPI expHeapAlloc(HANDLE heap, int flags, int size);
 extern long WINAPI expHeapDestroy(void* heap);
 extern long WINAPI expHeapFree(int arg1, int arg2, void* ptr);
+extern void* WINAPI expHeapReAlloc(HANDLE heap,int flags,void* lpMem,int size);
 extern long WINAPI expHeapSize(int heap, int flags, void* pointer);
 extern long WINAPI expGetProcessHeap(void);
 extern void* WINAPI expVirtualAlloc(void* v1, long v2, long v3, long v4);
@@ -63,6 +65,7 @@
 extern void* WINAPI expTlsGetValue(tls_t* index);
 extern int WINAPI expTlsFree(tls_t* index);
 extern void* WINAPI expLocalAlloc(int flags, int size);
+extern void* WINAPI expLocalReAlloc(int handle,int size,int flags);
 extern void* WINAPI expLocalLock(void* z);
 extern void* WINAPI expGlobalAlloc(int flags, int size);
 extern void* WINAPI expGlobalLock(void* z);
@@ -147,6 +150,15 @@
 extern int WINAPI expReleaseDC(int hwnd, int hdc);
 extern int WINAPI expLoadCursorA(int handle,LPCSTR name);
 extern int WINAPI expSetCursor(void *cursor);
+extern int WINAPI expGetCursorPos(void *cursor);
+extern int WINAPI expRegisterWindowMessageA(char *message);
+extern int WINAPI expGetProcessVersion(int pid);
+extern int WINAPI expGetCurrentThread(void);
+extern int WINAPI expGetOEMCP(void);
+extern int WINAPI expGetCPInfo(int cp,void *info);
+extern int WINAPI expGetSysColor(int pid);
+extern int WINAPI expGetSysColorBrush(int pid);
+extern int WINAPI expGetSystemMetrics(int index);
 extern int WINAPI expGetSystemPaletteEntries(int hdc, int iStartIndex, int nEntries, void* lppe);
 extern int WINAPI expGetTimeZoneInformation(LPTIME_ZONE_INFORMATION lpTimeZoneInformation);
 extern void WINAPI expGetLocalTime(SYSTEMTIME* systime);
@@ -185,6 +197,8 @@
 extern LONG WINAPI explstrcmpiA(const char* str1, const char* str2);
 extern LONG WINAPI explstrlenA(const char* str1);
 extern LONG WINAPI explstrcpyA(char* str1, const char* str2);
+extern LONG WINAPI explstrcpynA(char* str1, const char* str2,int len);
+extern LONG WINAPI explstrcatA(char* str1, const char* str2);
 extern LONG WINAPI expInterlockedExchange(long *dest, long l);
 
 extern void* CDECL expmalloc(int size);
@@ -206,5 +220,6 @@
 extern void *expmemcpy(void* dest, void* src, int n) ;
 extern time_t exptime(time_t* t);
 extern void* LookupExternal(const char* library, int ordinal);
+extern void* LookupExternalByName(const char* library, const char* name);
 
 #endif

Index: wineacm.h
===================================================================
RCS file: /cvsroot/mplayer/main/loader/wineacm.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- wineacm.h	24 Feb 2001 20:30:26 -0000	1.1.1.1
+++ wineacm.h	4 Oct 2001 02:21:34 -0000	1.2
@@ -43,9 +43,9 @@
 extern HANDLE MSACM_hHeap;
 extern PWINE_ACMDRIVERID MSACM_pFirstACMDriverID;
 extern PWINE_ACMDRIVERID MSACM_pLastACMDriverID;
-PWINE_ACMDRIVERID MSACM_RegisterDriver(
-  LPSTR pszDriverAlias, LPSTR pszFileName,
-  HINSTANCE hinstModule);
+PWINE_ACMDRIVERID MSACM_RegisterDriver(LPSTR pszDriverAlias,
+				       LPSTR pszFileName,
+				       HINSTANCE hinstModule);
 void MSACM_RegisterAllDrivers(void);
 PWINE_ACMDRIVERID MSACM_UnregisterDriver(PWINE_ACMDRIVERID p);
 void MSACM_UnregisterAllDrivers(void);




More information about the MPlayer-cvslog mailing list