diff -ru MPlayer-1.0pre8 2/loader/ext.c MPlayer-1.0pre8/loader/ext.c
--- MPlayer-1.0pre8 2/loader/ext.c	2006-06-11 12:35:46.000000000 -0600
+++ MPlayer-1.0pre8/loader/ext.c	2006-07-24 14:22:15.000000000 -0600
@@ -233,7 +233,6 @@
 
 //#define MAP_PRIVATE
 //#define MAP_SHARED
-#undef MAP_ANON
 LPVOID FILE_dommap( int unix_handle, LPVOID start,
                     DWORD size_high, DWORD size_low,
                     DWORD offset_high, DWORD offset_low,
@@ -248,9 +247,10 @@
 
     if (unix_handle == -1)
     {
-#ifdef MAP_ANON
+#ifdef CONFIG_DARWIN
 //	printf("Anonymous\n");
         flags |= MAP_ANON;
+	fd = -1;
 #else
         static int fdzero = -1;
 
@@ -263,7 +263,7 @@
             }
         }
         fd = fdzero;
-#endif  /* MAP_ANON */
+#endif  /* CONFIG_DARWIN */
 	/* Linux EINVAL's on us if we don't pass MAP_PRIVATE to an anon mmap */
 #ifdef MAP_SHARED
 	flags &= ~MAP_SHARED;
@@ -276,8 +276,12 @@
 //    printf("fd %x, start %x, size %x, pos %x, prot %x\n",fd,start,size_low, offset_low, prot);
 //    if ((ret = mmap( start, size_low, prot,
 //                     flags, fd, offset_low )) != (LPVOID)-1)
+#ifndef CONFIG_DARWIN
     if ((ret = mmap( start, size_low, prot,
                      MAP_PRIVATE | MAP_FIXED, fd, offset_low )) != (LPVOID)-1)
+#else
+    if ((ret = mmap( start, size_low, prot, MAP_PRIVATE | MAP_FIXED | MAP_ANON, fd, offset_low )) != (LPVOID)-1)
+#endif /* CONFIG_DARWIN */
     {
 //	    printf("address %08x\n", *(int*)ret);
 //	printf("%x\n", ret);
@@ -471,11 +475,13 @@
 
     if ((type&(MEM_RESERVE|MEM_COMMIT)) == 0) return NULL;
 
+#ifndef CONFIG_DARWIN
     fd=open("/dev/zero", O_RDWR);
     if(fd<0){
         perror( "Cannot open /dev/zero for READ+WRITE. Check permissions! error: " );
 	return NULL;
     }
+#endif /* CONFIG_DARWIN */
 
     if (type&MEM_RESERVE && (unsigned)address&0xffff) {
 	size += (unsigned)address&0xffff;
@@ -513,7 +519,9 @@
 		   && ((unsigned)address+size<=(unsigned)str->address+str->mapping_size)
 		   && (type & MEM_COMMIT))
 		{
+#ifndef CONFIG_DARWIN
 		    close(fd);
+#endif /* !CONFIG_DARWIN */
 		    return address; //returning previously reserved memory
 		}
 		//printf(" VirtualAlloc(...) does not commit or not entirely within reserved, and\n");
@@ -525,11 +533,18 @@
 	}
     }
 
+#ifndef CONFIG_DARWIN
     answer=mmap(address, size, PROT_READ | PROT_WRITE | PROT_EXEC,
 		MAP_PRIVATE, fd, 0);
+#else
+    /* mmap feeding from fd from /dev/zero doesn't work on darwin ! */
+    answer=mmap(address, size, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANON, -1, 0);
+#endif /* CONFIG_DARWIN */
 //    answer=FILE_dommap(-1, address, 0, size, 0, 0,
 //	PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE);
+#ifndef CONFIG_DARWIN
     close(fd);
+#endif /* !CONFIG_DARWIN */
     if (answer != (void *)-1 && address && answer != address) {
 	/* It is dangerous to try mmap() with MAP_FIXED since it does not
 	   always detect conflicts or non-allocation and chaos ensues after
diff -ru MPlayer-1.0pre8 2/loader/ldt_keeper.c MPlayer-1.0pre8/loader/ldt_keeper.c
--- MPlayer-1.0pre8 2/loader/ldt_keeper.c	2006-06-11 12:35:46.000000000 -0600
+++ MPlayer-1.0pre8/loader/ldt_keeper.c	2006-07-24 14:22:15.000000000 -0600
@@ -102,7 +102,7 @@
 #define       LDT_SEL(idx) ((idx) << 3 | 1 << 2 | 3)
 
 /* i got this value from wine sources, it's the first free LDT entry */
-#if defined(__FreeBSD__) && defined(LDT_AUTO_ALLOC)
+#if (defined(__FreeBSD__) || defined(CONFIG_DARWIN)) && defined(LDT_AUTO_ALLOC)
 #define       TEB_SEL_IDX     LDT_AUTO_ALLOC
 #endif
 
@@ -167,7 +167,7 @@
 #endif
 #endif
 
-#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
+#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(CONFIG_DARWIN) || defined(__OpenBSD__) || defined(__DragonFly__)
 static void LDT_EntryToBytes( unsigned long *buffer, const struct modify_ldt_ldt_s *content )
 {
     *buffer++ = ((content->base_addr & 0x0000ffff) << 16) |
@@ -193,7 +193,7 @@
 
     if (!ldt_fs)
 	return NULL;
-
+#ifndef CONFIG_DARWIN
     ldt_fs->fd = open("/dev/zero", O_RDWR);
     if(ldt_fs->fd<0){
         perror( "Cannot open /dev/zero for READ+WRITE. Check permissions! error: ");
@@ -202,6 +202,10 @@
     fs_seg=
     ldt_fs->fs_seg = mmap(NULL, getpagesize(), PROT_READ | PROT_WRITE, MAP_PRIVATE,
 			  ldt_fs->fd, 0);
+#else
+    fs_seg=
+    ldt_fs->fs_seg = mmap(NULL, getpagesize(), PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
+#endif /* CONFIG_DARWIN */
     if (ldt_fs->fs_seg == (void*)-1)
     {
 	perror("ERROR: Couldn't allocate memory for fs segment");
@@ -229,12 +233,12 @@
     }
 #endif /*linux*/
 
-#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
+#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(CONFIG_DARWIN) || defined(__OpenBSD__) || defined(__DragonFly__)
     {
         unsigned long d[2];
 
         LDT_EntryToBytes( d, &array );
-#if defined(__FreeBSD__) && defined(LDT_AUTO_ALLOC)
+#if (defined(__FreeBSD__) || defined(CONFIG_DARWIN)) && defined(LDT_AUTO_ALLOC)
         ret = i386_set_ldt(LDT_AUTO_ALLOC, (union descriptor *)d, 1);
         array.entry_number = ret;
         fs_ldt = ret;
diff -ru MPlayer-1.0pre8 2/loader/registry.c MPlayer-1.0pre8/loader/registry.c
--- MPlayer-1.0pre8 2/loader/registry.c	2006-06-11 12:35:46.000000000 -0600
+++ MPlayer-1.0pre8/loader/registry.c	2006-07-24 17:21:34.000000000 -0600
@@ -24,6 +24,26 @@
 //#undef TRACE
 //#define TRACE printf
 
+/*
+ * Modified by DarkSoul (darksoul@darkbsd.org)
+ *
+ * Added prefixes and suffixes to every non-WINAPI
+ * function. This is for use with ia32/Darwin, in
+ * order to ensure a clean %esp register.
+ */
+
+#ifdef CONFIG_DARWIN
+# define STACK_CLEANER_PREFIX	__asm__(	"pushl	%ebp		\n\t" \
+						"movl	%esp, %ebp	\n\t" \
+						"andl	$-16, %esp	\n\t" \
+						"subl	$16, %esp	\n\t" )
+# define STACK_CLEANER_SUFFIX	__asm__(	"leave			\n\t" )
+#else
+/* No need for stack cleaner unless for Darwin, is there ? */
+# define STACK_CLEANER_PREFIX
+# define STACK_CLEANER_SUFFIX
+#endif
+
 extern char *get_path ( char * );
 
 // ...can be set before init_registry() call
@@ -58,6 +78,51 @@
 static void save_registry(void);
 static void init_registry(void);
 
+/*
+ * Modified by DarkSoul (darksoul@darkbsd.org)
+ *
+ * Added my own strcat/strcpy/strlen implementations
+ * so on Darwin system it doesn't have to resort to
+ * loading it from a dynamic lib, which can crash
+ * MPlayer if %esp register is in a wrong state.
+ */
+
+static int    my_strlen(char *str)
+{
+  int   i;
+
+  if (str)
+    {
+      i = 0;
+      while ((*str++) != '\0') i++;
+      return i;
+    }
+  else
+    return 0;
+}
+
+static char    *my_strcat(char *str1, const char *str2)
+{
+  int   len1, len2, i;
+
+  len1 = my_strlen(str1);
+  len2 = my_strlen(str2);
+  for (i = 0; i < len2; i++)
+    str1[i + len1] = str2[i];
+  str1[len1 + len2] = '\0';
+  return str1;
+}
+
+static char    *my_strcpy(char *str1, const char *str2)
+{
+  int   len, i;
+
+  len = my_strlen(str2);
+  for (i = 0; i < len; i++)
+    str1[i] = str2[i];
+  str1[len] = '\0';
+  return str1;
+}
 
 static void create_registry(void){
     if(regs)
@@ -69,9 +134,9 @@
     regs=(struct reg_value*)malloc(3*sizeof(struct reg_value));
     regs[0].type=regs[1].type=DIR;
     regs[0].name=(char*)malloc(5);
-    strcpy(regs[0].name, "HKLM");
+    my_strcpy(regs[0].name, "HKLM");
     regs[1].name=(char*)malloc(5);
-    strcpy(regs[1].name, "HKCU");
+    my_strcpy(regs[1].name, "HKCU");
     regs[0].value=regs[1].value=NULL;
     regs[0].len=regs[1].len=0;
     reg_size=2;
@@ -142,7 +207,7 @@
 	write(fd, &reg_size, 4);
 	for(i=0; i<reg_size; i++)
 	{
-	        unsigned len=strlen(regs[i].name);
+	        unsigned len=my_strlen(regs[i].name);
 		write(fd, &regs[i].type, 4);
 		write(fd, &len, 4);
 		write(fd, regs[i].name, len);
@@ -237,8 +302,8 @@
 		t->prev=head;
 	}
 	t->next=0;
-	t->name=(char*)malloc(strlen(name)+1);
-	strcpy(t->name, name);
+	t->name=(char*)malloc(my_strlen(name)+1);
+	my_strcpy(t->name, name);
 	t->handle=handle;
 	head=t;
 	return t;
@@ -254,10 +319,10 @@
 	}
 	if(subkey==NULL)
 		subkey="<default>";
-	full_name=(char*)malloc(strlen(t->name)+strlen(subkey)+10);
-	strcpy(full_name, t->name);
-	strcat(full_name, "\\");
-	strcat(full_name, subkey);
+	full_name=(char*)malloc(my_strlen(t->name)+my_strlen(subkey)+10);
+	my_strcpy(full_name, t->name);
+	my_strcat(full_name, "\\");
+	my_strcat(full_name, subkey);
 	return full_name;
 }
 static struct reg_value* insert_reg_value(int handle, const char* name, int type, const void* value, int len)
@@ -292,8 +357,8 @@
 	v->len=len;
 	v->value=(char*)malloc(len);
 	memcpy(v->value, value, len);
-	v->name=(char*)malloc(strlen(fullname)+1);
-	strcpy(v->name, fullname);
+	v->name=(char*)malloc(my_strlen(fullname)+1);
+	my_strcpy(v->name, fullname);
         free(fullname);
 	save_registry();
 	return v;
@@ -325,9 +390,9 @@
                 pthn = pwent->pw_dir;
 	    }
 
-	    localregpathname = (char*)malloc(strlen(pthn)+20);
-	    strcpy(localregpathname, pthn);
-	    strcat(localregpathname, "/.registry");
+	    localregpathname = (char*)malloc(my_strlen(pthn)+20);
+	    my_strcpy(localregpathname, pthn);
+	    my_strcat(localregpathname, "/.registry");
 	}
 #endif
 
@@ -347,10 +412,10 @@
 	}
 	if(subkey==NULL)
 		return t;
-	full_name=(char*)malloc(strlen(t->name)+strlen(subkey)+10);
-	strcpy(full_name, t->name);
-	strcat(full_name, "\\");
-	strcat(full_name, subkey);
+	full_name=(char*)malloc(my_strlen(t->name)+strlen(subkey)+10);
+	my_strcpy(full_name, t->name);
+	my_strcat(full_name, "\\");
+	my_strcat(full_name, subkey);
 	t=find_handle_by_name(full_name);
 	free(full_name);
 	return t;
@@ -363,10 +428,16 @@
     struct reg_value* v;
     TRACE("Opening key %s\n", subkey);
 
-    if(!regs)
-        init_registry()
-;
-/*	t=find_handle_2(key, subkey);
+/*********************MODIFICATION BY WORLDMULTICAST*************************************/
+	if(!regs) /* Stack clean prefix/suffix here to prevent stack curruption with DLLs */
+	{
+		STACK_CLEANER_PREFIX;
+        init_registry();
+		STACK_CLEANER_SUFFIX;
+	}
+/*********************END OF MODIFICATION************************************************/
+	
+	/*	t=find_handle_2(key, subkey);
 
 	if(t==0)
 		return -1;
@@ -413,16 +484,27 @@
     struct reg_value* t;
     char* c;
     TRACE("Querying value %s\n", value);
-    if(!regs)
-	init_registry();
+
+	STACK_CLEANER_PREFIX;
+
+	if(!regs) /* Stack clean prefix/suffix here to prevent stack curruption with DLLs */
+        init_registry();
 
     c=build_keyname(key, value);
     if (!c)
-	return 1;
+	{
+		STACK_CLEANER_SUFFIX;
+		return 1;
+	}
+	
     t=find_value_by_name(c);
     free(c);
     if (t==0)
-	return 2;
+	{
+		STACK_CLEANER_SUFFIX;
+		return 2;
+	}
+	
     if (type)
 	*type=t->type;
     if (data)
@@ -439,7 +521,9 @@
     {
 	*count=t->len;
     }
-    return 0;
+    
+	STACK_CLEANER_SUFFIX;
+	return 0;
 }
 long __stdcall RegCreateKeyExA(long key, const char* name, long reserved,
 		     void* classs, long options, long security,
@@ -449,12 +533,19 @@
     char* fullname;
     struct reg_value* v;
     //        TRACE("Creating/Opening key %s\n", name);
-    if(!regs)
-	init_registry();
+
+	STACK_CLEANER_PREFIX;
+
+	if(!regs) /* Stack clean prefix/suffix here to prevent stack curruption with DLLs */
+        init_registry();
 
     fullname=build_keyname(key, name);
     if (!fullname)
-	return 1;
+	{
+		STACK_CLEANER_SUFFIX;
+		return 1;
+	}
+	
     TRACE("Creating/Opening key %s\n", fullname);
     v=find_value_by_name(fullname);
     if(v==0)
@@ -468,6 +559,9 @@
     t=insert_handle(generate_handle(), fullname);
     *newkey=t->handle;
     free(fullname);
+
+	STACK_CLEANER_SUFFIX;
+
     return 0;
 }
 
@@ -512,15 +606,21 @@
 {
     struct reg_value* t;
     char* c;
-    TRACE("Request to set value %s %d\n", name, *(const int*)data);
-    if(!regs)
-	init_registry();
+//    TRACE("Request to set value %s %d\n", name, *(const int*)data);
+		
+	STACK_CLEANER_PREFIX;
+
+	if(!regs) /* Stack clean prefix/suffix here to prevent stack curruption with DLLs */
+        init_registry();
 
     c=build_keyname(key, name);
     if(c==NULL)
 	return 1;
-    insert_reg_value(key, name, v2, data, size);
+	    
+	insert_reg_value(key, name, v2, data, size);
     free(c);
+
+	STACK_CLEANER_SUFFIX;
     return 0;
 }
 
diff -ru MPlayer-1.0pre8 2/loader/stubs.s MPlayer-1.0pre8/loader/stubs.s
--- MPlayer-1.0pre8 2/loader/stubs.s	2006-06-11 12:35:46.000000000 -0600
+++ MPlayer-1.0pre8/loader/stubs.s	2006-07-24 14:22:15.000000000 -0600
@@ -1,6 +1,6 @@
 	.data
-.LC0:	.string	"Called unk_%s\n"
-       .balign 4
+.LC0:	.asciz	"Called unk_%s\n"
+       .p2align 2
 .globl unk_exp1
 unk_exp1:
 	pushl %ebp
@@ -14,16 +14,16 @@
 	subl %eax,%edx
 	leal 0(,%edx,2),%eax
 	movl %eax,%edx
-	addl $export_names,%edx
+	addl $_export_names,%edx
 	pushl %edx
 	pushl $.LC0
-	call printf
+	call _printf
 	addl $8,%esp
 	xorl %eax,%eax
 	leave
 	ret
-.globl exp_EH_prolog
-exp_EH_prolog:
+.globl _exp_EH_prolog
+_exp_EH_prolog:
 	pushl $0xff
 	pushl %eax
 	pushl %fs:0
diff -ru MPlayer-1.0pre8 2/loader/win32.c MPlayer-1.0pre8/loader/win32.c
--- MPlayer-1.0pre8 2/loader/win32.c	2006-06-11 12:35:46.000000000 -0600
+++ MPlayer-1.0pre8/loader/win32.c	2006-07-24 14:22:16.000000000 -0600
@@ -19,6 +19,27 @@
 
 #include "config.h"
 
+
+/*
+ * Modified by DarkSoul (darksoul@darkbsd.org)
+ *
+ * Added prefixes and suffixes to every non-WINAPI
+ * function. This is for use with ia32/Darwin, in
+ * order to ensure a clean %esp register.
+ */
+
+#ifdef CONFIG_DARWIN
+# define STACK_CLEANER_PREFIX	__asm__(	"pushl	%ebp		\n\t" \
+						"movl	%esp, %ebp	\n\t" \
+						"andl	$-16, %esp	\n\t" \
+						"subl	$16, %esp	\n\t" )
+# define STACK_CLEANER_SUFFIX	__asm__(	"leave			\n\t" )
+#else
+/* No need for stack cleaner unless for Darwin, is there ? */
+# define STACK_CLEANER_PREFIX
+# define STACK_CLEANER_SUFFIX
+#endif
+
 #ifdef MPLAYER
 #ifdef USE_QTX_CODECS
 #define QTX
@@ -193,11 +214,13 @@
 #endif
 int LOADER_DEBUG=1; // active only if compiled with -DDETAILED_OUT
 //#define DETAILED_OUT
-static inline void dbgprintf(char* fmt, ...)
+static void dbgprintf(char* fmt, ...)
 {
+#ifndef CONFIG_DARWIN
 #ifdef DETAILED_OUT
     if(LOADER_DEBUG)
     {
+STACK_CLEANER_PREFIX;
 	FILE* f;
 	va_list va;
 	va_start(va, fmt);
@@ -211,6 +234,7 @@
 	    fclose(f);
 	}
 	va_end(va);
+STACK_CLEANER_SUFFIX;
     }
 #endif
 #ifdef MPLAYER
@@ -223,7 +247,10 @@
 //	mp_dbg(MSGT_WIN32, MSGL_DBG3, fmt, va);
 	va_end(va);
     }
+STACK_CLEANER_PREFIX;
   fflush(stdout);
+STACK_CLEANER_SUFFIX;
+#endif
 #endif
 }
 
@@ -404,6 +431,7 @@
 #ifdef GARBAGE
     alloc_header* prevmem;
     alloc_header* nextmem;
+    void*	  darwin_mem_temp = memory; // Used to store the memory argument
 
     if (memory == 0)
 	return 0;
@@ -416,24 +444,26 @@
 
     pthread_mutex_lock(&memmut);
 
+    STACK_CLEANER_PREFIX;
     switch(header->type)
     {
     case AREATYPE_EVENT:
-	destroy_event(memory);
+	destroy_event(darwin_mem_temp);
 	break;
     case AREATYPE_COND:
-	pthread_cond_destroy((pthread_cond_t*)memory);
+	pthread_cond_destroy((pthread_cond_t*)darwin_mem_temp);
 	break;
     case AREATYPE_MUTEX:
-	pthread_mutex_destroy((pthread_mutex_t*)memory);
+	pthread_mutex_destroy((pthread_mutex_t*)darwin_mem_temp);
 	break;
     case AREATYPE_CRITSECT:
-	pthread_mutex_destroy(&((struct CRITSECT*)memory)->mutex);
+	pthread_mutex_destroy(&((struct CRITSECT*)darwin_mem_temp)->mutex);
 	break;
     default:
-	//memset(memory, 0xcc, header->size);
+	//memset(darwin_mem_temp, 0xcc, header->size);
 	;
     }
+    STACK_CLEANER_SUFFIX;
 
     header->deadbeef = 0;
     prevmem = header->prev;
@@ -465,10 +495,12 @@
 }
 #endif
 
+#ifndef MEMORY_DEBUG
 static inline void* my_mreq(int size, int to_zero)
 {
     return mreq_private(size, to_zero, AREATYPE_CLIENT);
 }
+#endif
 
 static int my_size(void* memory)
 {
@@ -2479,6 +2511,7 @@
 
 static void* WINAPI expSleep(int time)
 {
+STACK_CLEANER_PREFIX;
 #if HAVE_NANOSLEEP
     /* solaris doesn't have thread safe usleep */
     struct timespec tsp;
@@ -2489,6 +2522,7 @@
     usleep(time);
 #endif
     dbgprintf("Sleep(%d) => 0\n", time);
+STACK_CLEANER_SUFFIX;
     return 0;
 }
 
@@ -3170,16 +3204,22 @@
 #define SECS_1601_TO_1970  ((369 * 365 + 89) * 86400ULL)
 static void WINAPI expGetSystemTimeAsFileTime(FILETIME* systime)
 {
+    STACK_CLEANER_PREFIX;
     struct tm *local_tm;
     struct timeval tv;
     unsigned long long secs;
 
+//#ifndef CONFIG_DARWIN
+    // This calls fflush(), which is not really liked on Darwin() in a DLL-code context
+    // which maims %esp register.
     dbgprintf("GetSystemTime(0x%x)\n", systime);
+//#endif /* !CONFIG_DARWIN */
     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);
+    STACK_CLEANER_SUFFIX;
 }
 
 static int WINAPI expGetEnvironmentVariableA(const char* name, char* field, int size)
@@ -3886,31 +3926,38 @@
  */
 static void* expmalloc(int size)
 {
+    STACK_CLEANER_PREFIX;
     //printf("malloc");
     //    return malloc(size);
     void* result=my_mreq(size,0);
     dbgprintf("malloc(0x%x) => 0x%x\n", size,result);
     if(result==0)
-	printf("WARNING: malloc() failed\n");
+	printf("WARNING: malloc(%d) failed\n", size);
+    STACK_CLEANER_SUFFIX;
     return result;
 }
 static void expfree(void* mem)
 {
+    STACK_CLEANER_PREFIX;
     //    return free(mem);
     dbgprintf("free(%p)\n", mem);
     my_release(mem);
+    STACK_CLEANER_SUFFIX;
 }
 /* needed by atrac3.acm */
 static void *expcalloc(int num, int size)
 {
+    STACK_CLEANER_PREFIX;
     void* result=my_mreq(num*size,1);
     dbgprintf("calloc(%d,%d) => %p\n", num,size,result);
     if(result==0)
 	printf("WARNING: calloc() failed\n");
+    STACK_CLEANER_SUFFIX;
     return result;
 }
 static void* expnew(int size)
 {
+    STACK_CLEANER_PREFIX;
     //    printf("NEW:: Call from address %08x\n STACK DUMP:\n", *(-1+(int*)&size));
     //    printf("%08x %08x %08x %08x\n",
     //    size, *(1+(int*)&size),
@@ -3922,13 +3969,16 @@
     dbgprintf("new(%d) => %p\n", size, result);
     if (result==0)
 	printf("WARNING: new() failed\n");
+    STACK_CLEANER_SUFFIX;
     return result;
 
 }
 static int expdelete(void* memory)
 {
+    STACK_CLEANER_PREFIX;
     dbgprintf("delete(%p)\n", memory);
     my_release(memory);
+    STACK_CLEANER_SUFFIX;
     return 0;
 }
 
@@ -4018,8 +4068,10 @@
 #if 0
 static int exp_initterm(int v1, int v2)
 {
+    STACK_CLEANER_PREFIX;
     dbgprintf("_initterm(0x%x, 0x%x) => 0\n", v1, v2);
     return 0;
+    STACK_CLEANER_SUFFIX;
 }
 #else
 /* merged from wine - 2002.04.21 */
@@ -4037,6 +4089,12 @@
 	    void* p = *start;
 	    __asm__ __volatile__
 		(
+		 "pushl  %ebp           \n\t"
+		 "movl   %esp, %ebp     \n\t"
+		 "andl   $-16, %esp     \n\t"
+		 "subl   $16, %esp      \n\t" );
+	    __asm__ __volatile__
+		(
 		 "pushl %%ebx		\n\t"
 		 "pushl %%ecx		\n\t"
 		 "pushl %%edx		\n\t"
@@ -4048,6 +4106,7 @@
 		 "popl  %%edx		\n\t"
 		 "popl  %%ecx		\n\t"
 		 "popl  %%ebx		\n\t"
+		 "leave			\n\t"
 		 :
 		 : "a"(p)
 		 : "memory"
@@ -4068,33 +4127,39 @@
 
 static int expwsprintfA(char* string, const char* format, ...)
 {
+    STACK_CLEANER_PREFIX;
     va_list va;
     int result;
     va_start(va, format);
     result = vsprintf(string, format, va);
     dbgprintf("wsprintfA(0x%x, '%s', ...) => %d\n", string, format, result);
     va_end(va);
+    STACK_CLEANER_SUFFIX;
     return result;
 }
 
 static int expsprintf(char* str, const char* format, ...)
 {
+    STACK_CLEANER_PREFIX;
     va_list args;
     int r;
     dbgprintf("sprintf(0x%x, %s)\n", str, format);
     va_start(args, format);
     r = vsprintf(str, format, args);
     va_end(args);
+    STACK_CLEANER_SUFFIX;
     return r;
 }
 static int expsscanf(const char* str, const char* format, ...)
 {
+    STACK_CLEANER_PREFIX;
     va_list args;
     int r;
     dbgprintf("sscanf(%s, %s)\n", str, format);
     va_start(args, format);
     r = vsscanf(str, format, args);
     va_end(args);
+    STACK_CLEANER_SUFFIX;
     return r;
 }
 static void* expfopen(const char* path, const char* mode)
@@ -4105,6 +4170,7 @@
 }
 static int expfprintf(void* stream, const char* format, ...)
 {
+    STACK_CLEANER_PREFIX;
     va_list args;
     int r = 0;
     dbgprintf("fprintf(%p, %s, ...)\n", stream, format);
@@ -4113,24 +4179,29 @@
     r = vfprintf((FILE*) stream, format, args);
     va_end(args);
 #endif
+    STACK_CLEANER_SUFFIX;
     return r;
 }
 
 static int expprintf(const char* format, ...)
 {
+    STACK_CLEANER_PREFIX;
     va_list args;
     int r;
     dbgprintf("printf(%s, ...)\n", format);
     va_start(args, format);
     r = vprintf(format, args);
     va_end(args);
+    STACK_CLEANER_SUFFIX;
     return r;
 }
 
 static char* expgetenv(const char* varname)
 {
+    STACK_CLEANER_PREFIX;
     char* v = getenv(varname);
     dbgprintf("getenv(%s) => %s\n", varname, v);
+    STACK_CLEANER_SUFFIX;
     return v;
 }
 
diff -ru MPlayer-1.0pre8 2/loader/wine/poppack.h MPlayer-1.0pre8/loader/wine/poppack.h
--- MPlayer-1.0pre8 2/loader/wine/poppack.h	2006-06-11 12:35:46.000000000 -0600
+++ MPlayer-1.0pre8/loader/wine/poppack.h	2006-07-24 14:22:16.000000000 -0600
@@ -1,15 +1,263 @@
-#ifdef __WINE_PSHPACK_H
-#undef __WINE_PSHPACK_H
+/*
+ * Copyright (C) 1999 Patrik Stridvall
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
 
-#if defined(__GNUC__) || defined(__SUNPRO_C)
-#pragma pack()
-#elif defined(__SUNPRO_CC)
-#warning "Assumes default alignment is 4"
-#pragma pack(4)
-#elif !defined(RC_INVOKED)
-#error "Restoration of the previous alignment isn't supported by the compiler"
-#endif /* defined(__GNUC__) || defined(__SUNPRO_C) ; !defined(RC_INVOKED) */
+#if defined(__WINE_PSHPACK_H15)
+#  ifndef __WINE_INTERNAL_POPPACK
+#    undef __WINE_PSHPACK_H15
+#  endif
+/* Depth == 15 */
+
+#  if __WINE_PSHPACK_H14 == 1
+#    pragma pack(1)
+#  elif __WINE_PSHPACK_H14 == 2
+#    pragma pack(2)
+#  elif __WINE_PSHPACK_H14 == 8
+#    pragma pack(8)
+#  else
+#    pragma pack(4)
+#  endif
+
+#elif defined(__WINE_PSHPACK_H14)
+#  ifndef __WINE_INTERNAL_POPPACK
+#    undef __WINE_PSHPACK_H14
+#  endif
+/* Depth == 14 */
+
+#  if __WINE_PSHPACK_H13 == 1
+#    pragma pack(1)
+#  elif __WINE_PSHPACK_H13 == 2
+#    pragma pack(2)
+#  elif __WINE_PSHPACK_H13 == 8
+#    pragma pack(8)
+#  else
+#    pragma pack(4)
+#  endif
+
+#elif defined(__WINE_PSHPACK_H13)
+#  ifndef __WINE_INTERNAL_POPPACK
+#    undef __WINE_PSHPACK_H13
+#  endif
+/* Depth == 13 */
+
+#  if __WINE_PSHPACK_H12 == 1
+#    pragma pack(1)
+#  elif __WINE_PSHPACK_H12 == 2
+#    pragma pack(2)
+#  elif __WINE_PSHPACK_H12 == 8
+#    pragma pack(8)
+#  else
+#    pragma pack(4)
+#  endif
+
+#elif defined(__WINE_PSHPACK_H12)
+#  ifndef __WINE_INTERNAL_POPPACK
+#    undef __WINE_PSHPACK_H12
+#  endif
+/* Depth == 12 */
+
+#  if __WINE_PSHPACK_H11 == 1
+#    pragma pack(1)
+#  elif __WINE_PSHPACK_H11 == 2
+#    pragma pack(2)
+#  elif __WINE_PSHPACK_H11 == 8
+#    pragma pack(8)
+#  else
+#    pragma pack(4)
+#  endif
+
+#elif defined(__WINE_PSHPACK_H11)
+#  ifndef __WINE_INTERNAL_POPPACK
+#    undef __WINE_PSHPACK_H11
+#  endif
+/* Depth == 11 */
+
+#  if __WINE_PSHPACK_H10 == 1
+#    pragma pack(1)
+#  elif __WINE_PSHPACK_H10 == 2
+#    pragma pack(2)
+#  elif __WINE_PSHPACK_H10 == 8
+#    pragma pack(8)
+#  else
+#    pragma pack(4)
+#  endif
+
+#elif defined(__WINE_PSHPACK_H10)
+#  ifndef __WINE_INTERNAL_POPPACK
+#    undef __WINE_PSHPACK_H10
+#  endif
+/* Depth == 10 */
+
+#  if __WINE_PSHPACK_H9 == 1
+#    pragma pack(1)
+#  elif __WINE_PSHPACK_H9 == 2
+#    pragma pack(2)
+#  elif __WINE_PSHPACK_H9 == 8
+#    pragma pack(8)
+#  else
+#    pragma pack(4)
+#  endif
+
+#elif defined(__WINE_PSHPACK_H9)
+#  ifndef __WINE_INTERNAL_POPPACK
+#    undef __WINE_PSHPACK_H9
+#  endif
+/* Depth == 9 */
+
+#  if __WINE_PSHPACK_H8 == 1
+#    pragma pack(1)
+#  elif __WINE_PSHPACK_H8 == 2
+#    pragma pack(2)
+#  elif __WINE_PSHPACK_H8 == 8
+#    pragma pack(8)
+#  else
+#    pragma pack(4)
+#  endif
+
+#elif defined(__WINE_PSHPACK_H8)
+#  ifndef __WINE_INTERNAL_POPPACK
+#    undef __WINE_PSHPACK_H8
+#  endif
+/* Depth == 8 */
+
+#  if __WINE_PSHPACK_H7 == 1
+#    pragma pack(1)
+#  elif __WINE_PSHPACK_H7 == 2
+#    pragma pack(2)
+#  elif __WINE_PSHPACK_H7 == 8
+#    pragma pack(8)
+#  else
+#    pragma pack(4)
+#  endif
+
+#elif defined(__WINE_PSHPACK_H7)
+#  ifndef __WINE_INTERNAL_POPPACK
+#    undef __WINE_PSHPACK_H7
+#  endif
+/* Depth == 7 */
+
+#  if __WINE_PSHPACK_H6 == 1
+#    pragma pack(1)
+#  elif __WINE_PSHPACK_H6 == 2
+#    pragma pack(2)
+#  elif __WINE_PSHPACK_H6 == 8
+#    pragma pack(8)
+#  else
+#    pragma pack(4)
+#  endif
+
+#elif defined(__WINE_PSHPACK_H6)
+#  ifndef __WINE_INTERNAL_POPPACK
+#    undef __WINE_PSHPACK_H6
+#  endif
+/* Depth == 6 */
+
+#  if __WINE_PSHPACK_H5 == 1
+#    pragma pack(1)
+#  elif __WINE_PSHPACK_H5 == 2
+#    pragma pack(2)
+#  elif __WINE_PSHPACK_H5 == 8
+#    pragma pack(8)
+#  else
+#    pragma pack(4)
+#  endif
+
+#elif defined(__WINE_PSHPACK_H5)
+#  ifndef __WINE_INTERNAL_POPPACK
+#    undef __WINE_PSHPACK_H5
+#  endif
+/* Depth == 5 */
+
+#  if __WINE_PSHPACK_H4 == 1
+#    pragma pack(1)
+#  elif __WINE_PSHPACK_H4 == 2
+#    pragma pack(2)
+#  elif __WINE_PSHPACK_H4 == 8
+#    pragma pack(8)
+#  else
+#    pragma pack(4)
+#  endif
+
+#elif defined(__WINE_PSHPACK_H4)
+#  ifndef __WINE_INTERNAL_POPPACK
+#    undef __WINE_PSHPACK_H4
+#  endif
+/* Depth == 4 */
+
+#  if __WINE_PSHPACK_H3 == 1
+#    pragma pack(1)
+#  elif __WINE_PSHPACK_H3 == 2
+#    pragma pack(2)
+#  elif __WINE_PSHPACK_H3 == 8
+#    pragma pack(8)
+#  else
+#    pragma pack(4)
+#  endif
+
+#elif defined(__WINE_PSHPACK_H3)
+#  ifndef __WINE_INTERNAL_POPPACK
+#    undef __WINE_PSHPACK_H3
+#  endif
+/* Depth == 3 */
+
+#  if __WINE_PSHPACK_H2 == 1
+#    pragma pack(1)
+#  elif __WINE_PSHPACK_H2 == 2
+#    pragma pack(2)
+#  elif __WINE_PSHPACK_H2 == 8
+#    pragma pack(8)
+#  else
+#    pragma pack(4)
+#  endif
+
+#elif defined(__WINE_PSHPACK_H2)
+#  ifndef __WINE_INTERNAL_POPPACK
+#    undef __WINE_PSHPACK_H2
+#  endif
+/* Depth == 2 */
+
+#  if __WINE_PSHPACK_H == 1
+#    pragma pack(1)
+#  elif __WINE_PSHPACK_H == 2
+#    pragma pack(2)
+#  elif __WINE_PSHPACK_H == 8
+#    pragma pack(8)
+#  else
+#    pragma pack(4)
+#  endif
+
+#elif defined(__WINE_PSHPACK_H)
+#  ifndef __WINE_INTERNAL_POPPACK
+#    undef __WINE_PSHPACK_H
+#  endif
+/* Depth == 1 */
+
+#  if defined(__SUNPRO_CC)
+#    warning "Assuming a default alignment of 4"
+#    pragma pack(4)
+#  else
+#    pragma pack()
+#  endif
+
+#else
+/* Depth == 0 ! */
 
-#else /* defined(__WINE_PSHPACK_H) */
 #error "Popping alignment isn't possible since no alignment has been pushed"
-#endif /* defined(__WINE_PSHPACK_H) */
+
+#endif
+
+#undef __WINE_INTERNAL_POPPACK
diff -ru MPlayer-1.0pre8 2/loader/wine/pshpack1.h MPlayer-1.0pre8/loader/wine/pshpack1.h
--- MPlayer-1.0pre8 2/loader/wine/pshpack1.h	2006-06-11 12:35:46.000000000 -0600
+++ MPlayer-1.0pre8/loader/wine/pshpack1.h	2006-07-24 14:22:16.000000000 -0600
@@ -1,13 +1,107 @@
-#ifndef __WINE_PSHPACK_H
-#define __WINE_PSHPACK_H 1
+/*
+ * Copyright (C) 1999 Patrik Stridvall
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
 
-#if defined(__GNUC__) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
-//#pragma pack(1)
-#elif !defined(RC_INVOKED)
-#error "1 as alignment isn't supported by the compiler"
-#endif /* defined(__GNUC__) || defined(__SUNPRO_C) || defined(__SUNPRO_CC) ; !defined(RC_INVOKED) */
-
-#else /* !defined(__WINE_PSHPACK_H) */
-#error "Nested pushing of alignment isn't supported by the compiler"
-#endif /* !defined(__WINE_PSHPACK_H) */
+#if defined(__WINE_PSHPACK_H15)
 
+   /* Depth > 15 */
+#  error "Alignment nesting > 15 is not supported"
+
+#else
+
+#  if !defined(__WINE_PSHPACK_H)
+#    define __WINE_PSHPACK_H  1
+     /* Depth == 1 */
+#  elif !defined(__WINE_PSHPACK_H2)
+#    define __WINE_PSHPACK_H2 1
+     /* Depth == 2 */
+#    define __WINE_INTERNAL_POPPACK
+#    include <poppack.h>
+#  elif !defined(__WINE_PSHPACK_H3)
+#    define __WINE_PSHPACK_H3 1
+     /* Depth == 3 */
+#    define __WINE_INTERNAL_POPPACK
+#    include <poppack.h>
+#  elif !defined(__WINE_PSHPACK_H4)
+#    define __WINE_PSHPACK_H4 1
+     /* Depth == 4 */
+#    define __WINE_INTERNAL_POPPACK
+#    include <poppack.h>
+#  elif !defined(__WINE_PSHPACK_H5)
+#    define __WINE_PSHPACK_H5 1
+     /* Depth == 5 */
+#    define __WINE_INTERNAL_POPPACK
+#    include <poppack.h>
+#  elif !defined(__WINE_PSHPACK_H6)
+#    define __WINE_PSHPACK_H6 1
+     /* Depth == 6 */
+#    define __WINE_INTERNAL_POPPACK
+#    include <poppack.h>
+#  elif !defined(__WINE_PSHPACK_H7)
+#    define __WINE_PSHPACK_H7 1
+     /* Depth == 7 */
+#    define __WINE_INTERNAL_POPPACK
+#    include <poppack.h>
+#  elif !defined(__WINE_PSHPACK_H8)
+#    define __WINE_PSHPACK_H8 1
+     /* Depth == 8 */
+#    define __WINE_INTERNAL_POPPACK
+#    include <poppack.h>
+#  elif !defined(__WINE_PSHPACK_H9)
+#    define __WINE_PSHPACK_H9 1
+     /* Depth == 9 */
+#    define __WINE_INTERNAL_POPPACK
+#    include <poppack.h>
+#  elif !defined(__WINE_PSHPACK_H10)
+#    define __WINE_PSHPACK_H10 1
+     /* Depth == 10 */
+#    define __WINE_INTERNAL_POPPACK
+#    include <poppack.h>
+#  elif !defined(__WINE_PSHPACK_H11)
+#    define __WINE_PSHPACK_H11 1
+     /* Depth == 11 */
+#    define __WINE_INTERNAL_POPPACK
+#    include <poppack.h>
+#  elif !defined(__WINE_PSHPACK_H12)
+#    define __WINE_PSHPACK_H12 1
+     /* Depth == 12 */
+#    define __WINE_INTERNAL_POPPACK
+#    include <poppack.h>
+#  elif !defined(__WINE_PSHPACK_H13)
+#    define __WINE_PSHPACK_H13 1
+     /* Depth == 13 */
+#    define __WINE_INTERNAL_POPPACK
+#    include <poppack.h>
+#  elif !defined(__WINE_PSHPACK_H14)
+#    define __WINE_PSHPACK_H14 1
+     /* Depth == 14 */
+#    define __WINE_INTERNAL_POPPACK
+#    include <poppack.h>
+#  elif !defined(__WINE_PSHPACK_H15)
+#    define __WINE_PSHPACK_H15 1
+     /* Depth == 15 */
+#    define __WINE_INTERNAL_POPPACK
+#    include <poppack.h>
+#  endif
+
+#  if defined(_MSC_VER) && (_MSC_VER >= 800)
+#   pragma warning(disable:4103)
+#  endif
+
+#  pragma pack(1)
+
+#endif
diff -ru MPlayer-1.0pre8 2/loader/wine/pshpack2.h MPlayer-1.0pre8/loader/wine/pshpack2.h
--- MPlayer-1.0pre8 2/loader/wine/pshpack2.h	2006-06-11 12:35:46.000000000 -0600
+++ MPlayer-1.0pre8/loader/wine/pshpack2.h	2006-07-24 14:22:16.000000000 -0600
@@ -1,12 +1,107 @@
-#ifndef __WINE_PSHPACK_H
-#define __WINE_PSHPACK_H 2
+/*
+ * Copyright (C) 1999 Patrik Stridvall
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
 
-#if defined(__GNUC__) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
-//#pragma pack(2)
-#elif !defined(RC_INVOKED)
-#error "2 as alignment isn't supported by the compiler"
-#endif /* defined(__GNUC__) || defined(__SUNPRO_CC) ; !defined(RC_INVOKED) */
-
-#else /* !defined(__WINE_PSHPACK_H) */
-#error "Nested pushing of alignment isn't supported by the compiler"
-#endif /* !defined(__WINE_PSHPACK_H) */
+#if defined(__WINE_PSHPACK_H15)
+
+   /* Depth > 15 */
+#  error "Alignment nesting > 15 is not supported"
+
+#else
+
+#  if !defined(__WINE_PSHPACK_H)
+#    define __WINE_PSHPACK_H  2
+     /* Depth == 1 */
+#  elif !defined(__WINE_PSHPACK_H2)
+#    define __WINE_PSHPACK_H2 2
+     /* Depth == 2 */
+#    define __WINE_INTERNAL_POPPACK
+#    include <poppack.h>
+#  elif !defined(__WINE_PSHPACK_H3)
+#    define __WINE_PSHPACK_H3 2
+     /* Depth == 3 */
+#    define __WINE_INTERNAL_POPPACK
+#    include <poppack.h>
+#  elif !defined(__WINE_PSHPACK_H4)
+#    define __WINE_PSHPACK_H4 2
+     /* Depth == 4 */
+#    define __WINE_INTERNAL_POPPACK
+#    include <poppack.h>
+#  elif !defined(__WINE_PSHPACK_H5)
+#    define __WINE_PSHPACK_H5 2
+     /* Depth == 5 */
+#    define __WINE_INTERNAL_POPPACK
+#    include <poppack.h>
+#  elif !defined(__WINE_PSHPACK_H6)
+#    define __WINE_PSHPACK_H6 2
+     /* Depth == 6 */
+#    define __WINE_INTERNAL_POPPACK
+#    include <poppack.h>
+#  elif !defined(__WINE_PSHPACK_H7)
+#    define __WINE_PSHPACK_H7 2
+     /* Depth == 7 */
+#    define __WINE_INTERNAL_POPPACK
+#    include <poppack.h>
+#  elif !defined(__WINE_PSHPACK_H8)
+#    define __WINE_PSHPACK_H8 2
+     /* Depth == 8 */
+#    define __WINE_INTERNAL_POPPACK
+#    include <poppack.h>
+#  elif !defined(__WINE_PSHPACK_H9)
+#    define __WINE_PSHPACK_H9 2
+     /* Depth == 9 */
+#    define __WINE_INTERNAL_POPPACK
+#    include <poppack.h>
+#  elif !defined(__WINE_PSHPACK_H10)
+#    define __WINE_PSHPACK_H10 2
+     /* Depth == 10 */
+#    define __WINE_INTERNAL_POPPACK
+#    include <poppack.h>
+#  elif !defined(__WINE_PSHPACK_H11)
+#    define __WINE_PSHPACK_H11 2
+     /* Depth == 11 */
+#    define __WINE_INTERNAL_POPPACK
+#    include <poppack.h>
+#  elif !defined(__WINE_PSHPACK_H12)
+#    define __WINE_PSHPACK_H12 2
+     /* Depth == 12 */
+#    define __WINE_INTERNAL_POPPACK
+#    include <poppack.h>
+#  elif !defined(__WINE_PSHPACK_H13)
+#    define __WINE_PSHPACK_H13 2
+     /* Depth == 13 */
+#    define __WINE_INTERNAL_POPPACK
+#    include <poppack.h>
+#  elif !defined(__WINE_PSHPACK_H14)
+#    define __WINE_PSHPACK_H14 2
+     /* Depth == 14 */
+#    define __WINE_INTERNAL_POPPACK
+#    include <poppack.h>
+#  elif !defined(__WINE_PSHPACK_H15)
+#    define __WINE_PSHPACK_H15 2
+     /* Depth == 15 */
+#    define __WINE_INTERNAL_POPPACK
+#    include <poppack.h>
+#  endif
+
+#  if defined(_MSC_VER) && (_MSC_VER >= 800)
+#   pragma warning(disable:4103)
+#  endif
+
+#  pragma pack(2)
+
+#endif
diff -ru MPlayer-1.0pre8 2/loader/wine/pshpack4.h MPlayer-1.0pre8/loader/wine/pshpack4.h
--- MPlayer-1.0pre8 2/loader/wine/pshpack4.h	2006-06-11 12:35:46.000000000 -0600
+++ MPlayer-1.0pre8/loader/wine/pshpack4.h	2006-07-24 14:22:17.000000000 -0600
@@ -1,15 +1,107 @@
-#ifndef __WINE_PSHPACK_H
-#define __WINE_PSHPACK_H 4
+/*
+ * Copyright (C) 1999 Patrik Stridvall
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
 
-#if defined(__GNUC__) || defined(__SUNPRO_CC)
-//#pragma pack(4)
-#elif defined(__SUNPRO_C)
-//#pragma pack()
-#elif !defined(RC_INVOKED)
-#error "4 as alignment isn't supported by the compiler"
-#endif /* defined(__GNUC__) || defined(__SUNPRO_CC) ; !defined(RC_INVOKED) */
-
-#else /* !defined(__WINE_PSHPACK_H) */
-#error "Nested pushing of alignment isn't supported by the compiler"
-#endif /* !defined(__WINE_PSHPACK_H) */
+#if defined(__WINE_PSHPACK_H15)
 
+   /* Depth > 15 */
+#  error "Alignment nesting > 15 is not supported"
+
+#else
+
+#  if !defined(__WINE_PSHPACK_H)
+#    define __WINE_PSHPACK_H  4
+     /* Depth == 1 */
+#  elif !defined(__WINE_PSHPACK_H2)
+#    define __WINE_PSHPACK_H2 4
+     /* Depth == 2 */
+#    define __WINE_INTERNAL_POPPACK
+#    include <poppack.h>
+#  elif !defined(__WINE_PSHPACK_H3)
+#    define __WINE_PSHPACK_H3 4
+     /* Depth == 3 */
+#    define __WINE_INTERNAL_POPPACK
+#    include <poppack.h>
+#  elif !defined(__WINE_PSHPACK_H4)
+#    define __WINE_PSHPACK_H4 4
+     /* Depth == 4 */
+#    define __WINE_INTERNAL_POPPACK
+#    include <poppack.h>
+#  elif !defined(__WINE_PSHPACK_H5)
+#    define __WINE_PSHPACK_H5 4
+     /* Depth == 5 */
+#    define __WINE_INTERNAL_POPPACK
+#    include <poppack.h>
+#  elif !defined(__WINE_PSHPACK_H6)
+#    define __WINE_PSHPACK_H6 4
+     /* Depth == 6 */
+#    define __WINE_INTERNAL_POPPACK
+#    include <poppack.h>
+#  elif !defined(__WINE_PSHPACK_H7)
+#    define __WINE_PSHPACK_H7 4
+     /* Depth == 7 */
+#    define __WINE_INTERNAL_POPPACK
+#    include <poppack.h>
+#  elif !defined(__WINE_PSHPACK_H8)
+#    define __WINE_PSHPACK_H8 4
+     /* Depth == 8 */
+#    define __WINE_INTERNAL_POPPACK
+#    include <poppack.h>
+#  elif !defined(__WINE_PSHPACK_H9)
+#    define __WINE_PSHPACK_H9 4
+     /* Depth == 9 */
+#    define __WINE_INTERNAL_POPPACK
+#    include <poppack.h>
+#  elif !defined(__WINE_PSHPACK_H10)
+#    define __WINE_PSHPACK_H10 4
+     /* Depth == 10 */
+#    define __WINE_INTERNAL_POPPACK
+#    include <poppack.h>
+#  elif !defined(__WINE_PSHPACK_H11)
+#    define __WINE_PSHPACK_H11 4
+     /* Depth == 11 */
+#    define __WINE_INTERNAL_POPPACK
+#    include <poppack.h>
+#  elif !defined(__WINE_PSHPACK_H12)
+#    define __WINE_PSHPACK_H12 4
+     /* Depth == 12 */
+#    define __WINE_INTERNAL_POPPACK
+#    include <poppack.h>
+#  elif !defined(__WINE_PSHPACK_H13)
+#    define __WINE_PSHPACK_H13 4
+     /* Depth == 13 */
+#    define __WINE_INTERNAL_POPPACK
+#    include <poppack.h>
+#  elif !defined(__WINE_PSHPACK_H14)
+#    define __WINE_PSHPACK_H14 4
+     /* Depth == 14 */
+#    define __WINE_INTERNAL_POPPACK
+#    include <poppack.h>
+#  elif !defined(__WINE_PSHPACK_H15)
+#    define __WINE_PSHPACK_H15 4
+     /* Depth == 15 */
+#    define __WINE_INTERNAL_POPPACK
+#    include <poppack.h>
+#  endif
+
+#  if defined(_MSC_VER) && (_MSC_VER >= 800)
+#   pragma warning(disable:4103)
+#  endif
+
+#  pragma pack(4)
+
+#endif
diff -ru MPlayer-1.0pre8 2/loader/wine/pshpack8.h MPlayer-1.0pre8/loader/wine/pshpack8.h
--- MPlayer-1.0pre8 2/loader/wine/pshpack8.h	2006-06-11 12:35:46.000000000 -0600
+++ MPlayer-1.0pre8/loader/wine/pshpack8.h	2006-07-24 14:22:17.000000000 -0600
@@ -1,12 +1,107 @@
-#ifndef __WINE_PSHPACK_H
-#define __WINE_PSHPACK_H 8
+/*
+ * Copyright (C) 1999 Patrik Stridvall
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
 
-#if 0
-//#pragma pack(8)
-#elif !defined(RC_INVOKED)
-#error "8 as alignment is not supported"
-#endif /* 0 ; !defined(RC_INVOKED) */
-
-#else /* !defined(__WINE_PSHPACK_H) */
-#error "Nested pushing of alignment isn't supported by the compiler"
-#endif /* !defined(__WINE_PSHPACK_H) */
+#if defined(__WINE_PSHPACK_H15)
+
+   /* Depth > 15 */
+#  error "Alignment nesting > 15 is not supported"
+
+#else
+
+#  if !defined(__WINE_PSHPACK_H)
+#    define __WINE_PSHPACK_H  8
+     /* Depth == 1 */
+#  elif !defined(__WINE_PSHPACK_H2)
+#    define __WINE_PSHPACK_H2 8
+     /* Depth == 2 */
+#    define __WINE_INTERNAL_POPPACK
+#    include <poppack.h>
+#  elif !defined(__WINE_PSHPACK_H3)
+#    define __WINE_PSHPACK_H3 8
+     /* Depth == 3 */
+#    define __WINE_INTERNAL_POPPACK
+#    include <poppack.h>
+#  elif !defined(__WINE_PSHPACK_H4)
+#    define __WINE_PSHPACK_H4 8
+     /* Depth == 4 */
+#    define __WINE_INTERNAL_POPPACK
+#    include <poppack.h>
+#  elif !defined(__WINE_PSHPACK_H5)
+#    define __WINE_PSHPACK_H5 8
+     /* Depth == 5 */
+#    define __WINE_INTERNAL_POPPACK
+#    include <poppack.h>
+#  elif !defined(__WINE_PSHPACK_H6)
+#    define __WINE_PSHPACK_H6 8
+     /* Depth == 6 */
+#    define __WINE_INTERNAL_POPPACK
+#    include <poppack.h>
+#  elif !defined(__WINE_PSHPACK_H7)
+#    define __WINE_PSHPACK_H7 8
+     /* Depth == 7 */
+#    define __WINE_INTERNAL_POPPACK
+#    include <poppack.h>
+#  elif !defined(__WINE_PSHPACK_H8)
+#    define __WINE_PSHPACK_H8 8
+     /* Depth == 8 */
+#    define __WINE_INTERNAL_POPPACK
+#    include <poppack.h>
+#  elif !defined(__WINE_PSHPACK_H9)
+#    define __WINE_PSHPACK_H9 8
+     /* Depth == 9 */
+#    define __WINE_INTERNAL_POPPACK
+#    include <poppack.h>
+#  elif !defined(__WINE_PSHPACK_H10)
+#    define __WINE_PSHPACK_H10 8
+     /* Depth == 10 */
+#    define __WINE_INTERNAL_POPPACK
+#    include <poppack.h>
+#  elif !defined(__WINE_PSHPACK_H11)
+#    define __WINE_PSHPACK_H11 8
+     /* Depth == 11 */
+#    define __WINE_INTERNAL_POPPACK
+#    include <poppack.h>
+#  elif !defined(__WINE_PSHPACK_H12)
+#    define __WINE_PSHPACK_H12 8
+     /* Depth == 12 */
+#    define __WINE_INTERNAL_POPPACK
+#    include <poppack.h>
+#  elif !defined(__WINE_PSHPACK_H13)
+#    define __WINE_PSHPACK_H13 8
+     /* Depth == 13 */
+#    define __WINE_INTERNAL_POPPACK
+#    include <poppack.h>
+#  elif !defined(__WINE_PSHPACK_H14)
+#    define __WINE_PSHPACK_H14 8
+     /* Depth == 14 */
+#    define __WINE_INTERNAL_POPPACK
+#    include <poppack.h>
+#  elif !defined(__WINE_PSHPACK_H15)
+#    define __WINE_PSHPACK_H15 8
+     /* Depth == 15 */
+#    define __WINE_INTERNAL_POPPACK
+#    include <poppack.h>
+#  endif
+
+#  if defined(_MSC_VER) && (_MSC_VER >= 800)
+#   pragma warning(disable:4103)
+#  endif
+
+#  pragma pack(8)
+
+#endif
diff -ru MPlayer-1.0pre8 2/loader/wrapper.S MPlayer-1.0pre8/loader/wrapper.S
--- MPlayer-1.0pre8 2/loader/wrapper.S	2006-06-11 12:35:46.000000000 -0600
+++ MPlayer-1.0pre8/loader/wrapper.S	2006-07-24 14:22:17.000000000 -0600
@@ -1,27 +1,27 @@
-.section .data
+.data
 .globl caller_return
 caller_return:
 	.long 0
-.globl report_entry
-report_entry:
+.globl _report_entry
+_report_entry:
 	.long null_call
-.globl report_ret
-report_ret:	
+.globl _report_ret
+_report_ret:	
 	.long null_call
-.global wrapper_target
-wrapper_target:	
+.globl _wrapper_target
+_wrapper_target:	
 	.long null_call
 
-.section .text
+.text
 .globl null_call
-	.type null_call, @function
-	.balign 16,0x90
+#	.type null_call, @function
+	.p2align 4,0x90
 null_call:
 	ret
-.globl wrapper
-	.type wrapper, @function
-	.balign 16,0x90
-wrapper:
+.globl _wrapper
+#	.type wrapper, @function
+	.p2align 4,0x90
+_wrapper:
 	pusha			# store registers (EAX, ECX, EDX, EBX, ESP, EBP, ESI, EDI) 
 	pushf			# store flags
 	
@@ -39,7 +39,7 @@
 	push %eax
 	push %edx
 	
-	call *report_entry	# report entry
+	call *_report_entry	# report entry
 	
 	test %eax, %eax
 	jnz .Ldone
@@ -51,9 +51,9 @@
 	popl caller_return	# switch return addresses
 	pushl $.Lwrapper_return 
 	
-	jmp *wrapper_target	# wrapper_target should return at .Lwrapper_return
+	jmp *_wrapper_target	# wrapper_target should return at .Lwrapper_return
 
-	.balign 16, 0x90
+	.p2align 4, 0x90
 .Lwrapper_return:	
 	pushl caller_return	# restore the original return address
 	pusha			# more for reference sake here
@@ -73,7 +73,7 @@
 	push %eax
 	push %edx
 
-	call *report_ret	# report the return information (same args)
+	call *_report_ret	# report the return information (same args)
 .Ldone:	
 
 	leave
