[Mplayer-cvslog] CVS: main/loader driver.c,1.1.1.1,1.2 ext.c,1.1.1.1,1.2 loader.h,1.1.1.1,1.2 module.c,1.1.1.1,1.2 pe_image.c,1.1.1.1,1.2 registry.c,1.1.1.1,1.2 win32.c,1.2,1.3

GEREOFFY arpi_esp at users.sourceforge.net
Sun Mar 18 02:01:06 CET 2001


Update of /cvsroot/mplayer/main/loader
In directory usw-pr-cvs1:/tmp/cvs-serv32507

Modified Files:
	driver.c ext.c loader.h module.c pe_image.c registry.c win32.c 
Log Message:
DLL loader updated from avifile-0.60beta4

Index: driver.c
===================================================================
RCS file: /cvsroot/mplayer/main/loader/driver.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** driver.c	2001/02/24 20:30:14	1.1.1.1
--- driver.c	2001/03/18 01:01:02	1.2
***************
*** 14,19 ****
  #include <registry.h>
  
! //#include "com.h"
! //typedef long STDCALL (*GETCLASS) (GUID*, GUID*, void**);
  
  
--- 14,19 ----
  #include <registry.h>
  
! #include "com.h"
! typedef long STDCALL (*GETCLASS) (GUID*, GUID*, void**);
  
  
***************
*** 119,123 ****
  
  
! char* def_path=WIN32_PATH;    // path to codecs
  char* win32_codec_name=NULL;  // must be set before calling DrvOpen() !!!
  
--- 119,123 ----
  
  
! extern char* def_path; //=WIN32_PATH;    // path to codecs
  char* win32_codec_name=NULL;  // must be set before calling DrvOpen() !!!
  
***************
*** 156,160 ****
      if (!(npDriver->DriverProc = (DRIVERPROC)
               GetProcAddress(npDriver->hDriverModule, "DriverProc"))) {
! #if 1
           printf("Library %s is not a VfW/ACM valid codec\n", win32_codec_name);
  #else
--- 156,160 ----
      if (!(npDriver->DriverProc = (DRIVERPROC)
               GetProcAddress(npDriver->hDriverModule, "DriverProc"))) {
! #if 0
           printf("Library %s is not a VfW/ACM valid codec\n", win32_codec_name);
  #else

Index: ext.c
===================================================================
RCS file: /cvsroot/mplayer/main/loader/ext.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** ext.c	2001/02/24 20:30:16	1.1.1.1
--- ext.c	2001/03/18 01:01:02	1.2
***************
*** 12,16 ****
  #include <stdlib.h>
  #endif
- #include <stdio.h>
  #include <unistd.h>
  #include <sys/mman.h>
--- 12,15 ----
***************
*** 48,52 ****
      vprintf(format, va);
      va_end(va);
-     fflush(stdout);
  #endif
      return 0; 
--- 47,50 ----
***************
*** 68,72 ****
  int HeapFree(int heap, int flags, void* mem)
  {
!     free(mem);
      return 1;
  }     	
--- 66,70 ----
  int HeapFree(int heap, int flags, void* mem)
  {
!     if (mem) free(mem);
      return 1;
  }     	
***************
*** 518,524 ****
      if(src==0)
  	return 0;
!     for(i=0; i<srclen; i++)
! 	printf("%c", src[i]);
!     printf("\n");		
      if(dest==0)
      {
--- 516,523 ----
      if(src==0)
  	return 0;
!     if(srclen==-1){srclen=0; while(src[srclen++]);}
! //    for(i=0; i<srclen; i++)
! //	printf("%c", src[i]);
! //    printf("\n");		
      if(dest==0)
      {

Index: loader.h
===================================================================
RCS file: /cvsroot/mplayer/main/loader/loader.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** loader.h	2001/02/24 20:30:26	1.1.1.1
--- loader.h	2001/03/18 01:01:02	1.2
***************
*** 2,6 ****
  
  	Win32 binary loader interface
! 	Copyright 2000 Eugene Smith (divx at euro.ru)
  	Shamelessly stolen from Wine project
  
--- 2,6 ----
  
  	Win32 binary loader interface
! 	Copyright 2000 Eugene Kuznetsov (divx at euro.ru)
  	Shamelessly stolen from Wine project
  
***************
*** 279,282 ****
--- 279,284 ----
  );
  void MSACM_RegisterAllDrivers(void);
+ 
+ int WINAPI LoadStringA(long instance, long  id, void* buf, long size);
  
  #ifdef __cplusplus

Index: module.c
===================================================================
RCS file: /cvsroot/mplayer/main/loader/module.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** module.c	2001/02/24 20:30:17	1.1.1.1
--- module.c	2001/03/18 01:01:02	1.2
***************
*** 60,193 ****
  modref_list;
  
- 
- /***********************************************************************
-  *           LDT_EntryToBytes
-  *
-  * Convert an ldt_entry structure to the raw bytes of the descriptor.
-  */
- /*static void LDT_EntryToBytes( unsigned long *buffer, const struct modify_ldt_ldt_s *content )
- {
-     *buffer++ = ((content->base_addr & 0x0000ffff) << 16) |
-                  (content->limit & 0x0ffff);
-     *buffer = (content->base_addr & 0xff000000) |
-               ((content->base_addr & 0x00ff0000)>>16) |
-               (content->limit & 0xf0000) |
-               (content->contents << 10) |
-               ((content->read_exec_only == 0) << 9) |
-               ((content->seg_32bit != 0) << 22) |
-               ((content->limit_in_pages != 0) << 23) |
-               0xf000;
- }
- */
- 
- //
- // funcs:
- //
- // 0 read LDT
- // 1 write old mode
- // 0x11 write
- //
- /*
- static int modify_ldt( int func, struct modify_ldt_ldt_s *ptr,
-                                   unsigned long count )
- {
-     int res;
- #ifdef __PIC__
-     __asm__ __volatile__( "pushl %%ebx\n\t"
-                           "movl %2,%%ebx\n\t"
-                           "int $0x80\n\t"
-                           "popl %%ebx"
-                           : "=a" (res)
-                           : "0" (__NR_modify_ldt),
-                             "r" (func),
-                             "c" (ptr),
-                             "d" (sizeof(struct modify_ldt_ldt_s)*count) );
- #else
-     __asm__ __volatile__("int $0x80"
-                          : "=a" (res)
-                          : "0" (__NR_modify_ldt),
-                            "b" (func),
-                            "c" (ptr),
-                            "d" (sizeof(struct modify_ldt_ldt_s)*count) );
- #endif  
-     if (res >= 0) return res;
-     errno = -res;
-     return -1;
- }
- static int fs_installed=0;
- static char* fs_seg=0;
- static int install_fs()
- {
-     struct modify_ldt_ldt_s array;
-     int fd;
-     int ret;
-     void* prev_struct;
-     
-     if(fs_installed)
- 	return 0;
- 
-     fd=open("/dev/zero", O_RDWR);
-     fs_seg=mmap((void*)0xbf000000, 0x30000, PROT_READ | PROT_WRITE, MAP_PRIVATE,
- 	fd, 0);
-     if(fs_seg==0)
-     {
- 	printf("ERROR: Couldn't allocate memory for fs segment\n");
- 	return -1;
-     }	
-     array.base_addr=((int)fs_seg+0xffff) & 0xffff0000;
-     array.entry_number=0x1;
-     array.limit=array.base_addr+getpagesize()-1;
-     array.seg_32bit=1;
-     array.read_exec_only=0;
-     array.seg_not_present=0;
-     array.contents=MODIFY_LDT_CONTENTS_DATA;
-     array.limit_in_pages=0;
- #ifdef linux
-     ret=modify_ldt(0x1, &array, 1);
-     if(ret<0)
-     {
- 	perror("install_fs");
- 	MESSAGE("Couldn't install fs segment, expect segfault\n");
-     }	
- #endif 
- 
- #if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__)
-     {
-         long d[2];
- 
-         LDT_EntryToBytes( d, &array );
-         ret = i386_set_ldt(0x1, (union descriptor *)d, 1);
-         if (ret < 0)
-         {
-             perror("install_fs");
-             MESSAGE("Did you reconfigure the kernel with \"options USER_LDT\"?\n");
-         }
-     }
- #endif 
-     __asm__
-     (
-     "movl $0xf,%eax\n\t"
- //    "pushw %ax\n\t"
-     "movw %ax, %fs\n\t"
-     );
-     prev_struct=malloc(8);
-     *(void**)array.base_addr=prev_struct;
-     printf("prev_struct: 0x%X\n", prev_struct);
-     close(fd);
-     
-     fs_installed=1;
-     return 0;
- };    	
- static int uninstall_fs()
- {
-     printf("Uninstalling FS segment\n");
-     if(fs_seg==0)
- 	return -1;
-     munmap(fs_seg, 0x30000);
-     fs_installed=0;
-     return 0;
- }
- 
- */
  //WINE_MODREF *local_wm=NULL;
  modref_list* local_wm=NULL;
--- 60,63 ----
***************
*** 201,205 ****
      while(strcmp(m, list->wm->filename))
      {
! //	printf("%s: %x\n", list->wm->filename, list->wm->module);
  	list=list->prev;
  	if(list==NULL)
--- 71,75 ----
      while(strcmp(m, list->wm->filename))
      {
! 	TRACE("%s: %x\n", list->wm->filename, list->wm->module);
  	list=list->prev;
  	if(list==NULL)
***************
*** 514,517 ****
--- 384,390 ----
      
      MODULE_RemoveFromList(wm);
+ 
+     /* garbage... */
+     if (local_wm == NULL) my_garbagecollection();
  
      return retv;

Index: pe_image.c
===================================================================
RCS file: /cvsroot/mplayer/main/loader/pe_image.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** pe_image.c	2001/02/24 20:30:19	1.1.1.1
--- pe_image.c	2001/03/18 01:01:02	1.2
***************
*** 671,675 ****
  error:
      if (unix_handle != -1) close( unix_handle );
!     if (load_addr) VirtualFree( (LPVOID)load_addr, 0, MEM_RELEASE );
      UnmapViewOfFile( (LPVOID)hModule );
      return 0;
--- 671,676 ----
  error:
      if (unix_handle != -1) close( unix_handle );
!     if (load_addr) 
!     VirtualFree( (LPVOID)load_addr, 0, MEM_RELEASE );
      UnmapViewOfFile( (LPVOID)hModule );
      return 0;
***************
*** 871,874 ****
--- 872,876 ----
      HeapFree( GetProcessHeap(), 0, wm->filename );
      HeapFree( GetProcessHeap(), 0, wm->short_filename );
+     VirtualFree( (LPVOID)wm->module, 0, MEM_RELEASE );
      HeapFree( GetProcessHeap(), 0, wm );
  }
***************
*** 885,888 ****
--- 887,896 ----
   * (SDK)
   */
+ extern void This_Is_Dirty_Hack()
+ {
+     void* mem=alloca(0x20000);
+     *(int*)mem=0x1234;
+ }
+ 
  WIN_BOOL PE_InitDLL( WINE_MODREF *wm, DWORD type, LPVOID lpReserved )
  {
***************
*** 901,921 ****
  	TRACE_(relay)("CallTo32(entryproc=%p,module=%08x,type=%ld,res=%p)\n",
                         entry, wm->module, type, lpReserved );
! 	printf("Entering DllMain(");
  	switch(type)
  	{
  	    case DLL_PROCESS_DETACH:
! 	        printf("DLL_PROCESS_DETACH) ");
  		break;
  	    case DLL_PROCESS_ATTACH:
! 	        printf("DLL_PROCESS_ATTACH) ");
  		break;
  	    case DLL_THREAD_DETACH:
! 	        printf("DLL_THREAD_DETACH) ");
  		break;
  	    case DLL_THREAD_ATTACH:
! 	        printf("DLL_THREAD_ATTACH) ");
  		break;
  	}	
! 	printf("for %s\n", wm->filename);
          retv = entry( wm->module, type, lpReserved );
      }
--- 909,932 ----
  	TRACE_(relay)("CallTo32(entryproc=%p,module=%08x,type=%ld,res=%p)\n",
                         entry, wm->module, type, lpReserved );
! 	
! 	
! 	TRACE("Entering DllMain(");
  	switch(type)
  	{
  	    case DLL_PROCESS_DETACH:
! 	        TRACE("DLL_PROCESS_DETACH) ");
  		break;
  	    case DLL_PROCESS_ATTACH:
! 	        TRACE("DLL_PROCESS_ATTACH) ");
  		break;
  	    case DLL_THREAD_DETACH:
! 	        TRACE("DLL_THREAD_DETACH) ");
  		break;
  	    case DLL_THREAD_ATTACH:
! 	        TRACE("DLL_THREAD_ATTACH) ");
  		break;
  	}	
! 	TRACE("for %s\n", wm->filename);
! 	This_Is_Dirty_Hack();
          retv = entry( wm->module, type, lpReserved );
      }

Index: registry.c
===================================================================
RCS file: /cvsroot/mplayer/main/loader/registry.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** registry.c	2001/02/24 20:30:21	1.1.1.1
--- registry.c	2001/03/18 01:01:02	1.2
***************
*** 12,16 ****
  
  #include <registry.h>
! 
  struct reg_value
  {
--- 12,17 ----
  
  #include <registry.h>
! //#undef TRACE
! //#define TRACE printf
  struct reg_value
  {
***************
*** 148,152 ****
  {
  	reg_handle_t* t;
- //        printf("REGISTRY: find_handle_by_name(%s)\n",name);
  	for(t=head; t; t=t->prev)
  	{
--- 149,152 ----
***************
*** 161,165 ****
  {
  	int i;
- //        printf("REGISTRY: find_value_by_name(%s)\n",name);
  	for(i=0; i<reg_size; i++)
  		if(!strcmp(regs[i].name, name))
--- 161,164 ----
***************
*** 170,174 ****
  {
  	reg_handle_t* t;
- //        printf("REGISTRY: find_handle(%d)\n",handle);
  	for(t=head; t; t=t->prev)
  	{
--- 169,172 ----
***************
*** 264,268 ****
  static void init_registry()
  {
! //	printf("Initializing registry\n");
  	open_registry();
  	insert_handle(HKEY_LOCAL_MACHINE, "HKLM");
--- 262,266 ----
  static void init_registry()
  {
! 	printf("Initializing registry\n");
  	open_registry();
  	insert_handle(HKEY_LOCAL_MACHINE, "HKLM");
***************
*** 394,402 ****
  		int qw=45708;
  		v=insert_reg_value(key, name, DIR, &qw, 4);
! 		*status=REG_CREATED_NEW_KEY;
  //		return 0;
  	}
  	else
! 		*status=REG_OPENED_EXISTING_KEY;
  
  	t=insert_handle(generate_handle(), fullname);
--- 392,400 ----
  		int qw=45708;
  		v=insert_reg_value(key, name, DIR, &qw, 4);
! 		if (status) *status=REG_CREATED_NEW_KEY;
  //		return 0;
  	}
  	else
! 		if (status) *status=REG_OPENED_EXISTING_KEY;
  
  	t=insert_handle(generate_handle(), fullname);

Index: win32.c
===================================================================
RCS file: /cvsroot/mplayer/main/loader/win32.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** win32.c	2001/03/17 22:35:29	1.2
--- win32.c	2001/03/18 01:01:02	1.3
***************
*** 6,9 ****
--- 6,12 ----
         virtually any DLL, we can only implement this
        much, adding needed functions with each new codec.
+       
+       Basic principle of implementation: it's not good
+       for DLL to know too much about its environment.
  
  ************************************************************/
***************
*** 14,17 ****
[...3109 lines suppressed...]
+     pp=alclist;
+     unfree=unfreecnt=0;
+ 	for(;pp;) {
+ 		unfree+=pp->size;
+ 		unfreecnt++;
+ 		if (pp->prev)
+ 			pp->prev->next=pp->next;
+ 		if (pp->next)
+ 			pp->next->prev=pp->prev;
+ 		if (pp == alclist)
+ 			alclist=pp->prev;
+ 		free(pp->addr);
+ 		ppsv = pp;
+ 		pp=pp->prev;
+ 		free(ppsv);
+ 		alccnt--;
+ 	} 
+    printf("Total Unfree %d bytes cnt %d [%x,%d]\n",unfree,unfreecnt,alclist,alccnt);
+ #endif
+ }


_______________________________________________
Mplayer-cvslog mailing list
Mplayer-cvslog at lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/mplayer-cvslog



More information about the MPlayer-cvslog mailing list