Web lists-archives.com

[MPlayer-dev-eng] how to add lookup / add functions in loader/win32.c ?




trying to get G729DecoderDmo.dll to work in linux.
http://samples.ffmpeg.org/drivers32/new/G729DecoderDMO.dll
https://trac.ffmpeg.org/attachment/ticket/4553/g729stereo.wav
(use ffmpeg -i g729stereo.wav -acodec copy out.wav to get proper wav header)

a@lappy:~/Desktop/trunk$ ./mplayer out.wav -v -v -v
MPlayer SVN-r37401-4.7 (C) 2000-2015 MPlayer Team

...

Opening audio decoder: [dmo] Win32/DMO decoders
Called unk__initterm_e
Called unk__initterm
Called unk_memset
DisableThreadLibraryCalls(0x60e50000) => 0
Called unk_ATL90.DLL:15


MPlayer interrupted by signal 11 in module: init_audio_codec

i added a struct for msvcr90 with initterm and memset and some others....
now i get this:

Opening audio decoder: [dmo] Win32/DMO decoders
External func ATL90.DLL:32
External func ATL90.DLL:61
External func ATL90.DLL:49
External func ATL90.DLL:15
External func ATL90.DLL:64
External func ATL90.DLL:23
Called unk_ATL90.DLL:15

MPlayer interrupted by signal 11 in module: init_audio_codec


ok , got creative. copied over winxp version of ATL90.DLL
ffmpeg.org/~compn/ATL90.DLL
then i enabled #define LOADLIB_TRY_NATIVE in win32.c

now the codec loads AND works AND no crash, and i get this in output:

External dll loaded (offset: 0x78e20000, func: 0x78e25d87)
External func ATL90.DLL:61
External dll loaded (offset: 0x78e20000, func: 0x78e28712)
External func ATL90.DLL:49
External dll loaded (offset: 0x78e20000, func: 0x78e2a430)
External func ATL90.DLL:15
External dll loaded (offset: 0x78e20000, func: 0x78e2a974)
External func ATL90.DLL:64
External dll loaded (offset: 0x78e20000, func: 0x78e26032)
External func ATL90.DLL:23
External dll loaded (offset: 0x78e20000, func: 0x78e2873e)





any loader devs still around want to clean up and finish this? :)

maybe write a howto add codecs this time! :P

not terribly important, just bored. 
hey i was able to copy paste my way around the loader, yay.

patch to make it work on linux with latest SVN mplayer attached.

-compn
Index: win32.c
===================================================================
--- win32.c	(revision 37401)
+++ win32.c	(working copy)
@@ -22,7 +22,7 @@
 #include "mangle.h"
 
 #define REALPLAYER
-//#define LOADLIB_TRY_NATIVE
+#define LOADLIB_TRY_NATIVE
 
 /* Hack to make sure the correct function declaration in com.h is used when
  * this file is built for the test applications with WIN32_LOADER disabled. */
@@ -552,6 +552,8 @@
 #define	MODULE_HANDLE_ole32	((HMODULE)0x127)
 #define	MODULE_HANDLE_winmm	((HMODULE)0x128)
 #define	MODULE_HANDLE_psapi	((HMODULE)0x129)
+#define	MODULE_HANDLE_atl90	((HMODULE)0x130)
+#define	MODULE_HANDLE_msvcr90	((HMODULE)0x131)
 
 // Fake PE header, since some software (and the Microsoft CRT v8 and newer)
 // assume GetModuleHandle(NULL) returns a pointer to a PE header.
@@ -2559,7 +2561,12 @@
 	return MODULE_HANDLE_winmm;
     if (strcasecmp(name, "psapi.dll") == 0 || strcasecmp(name, "psapi") == 0)
 	return MODULE_HANDLE_psapi;
+    if (strcasecmp(name, "atl90.dll") == 0 || strcasecmp(name, "atl90") == 0)
+	return MODULE_HANDLE_atl90;
+    if (strcasecmp(name, "msvcr90.dll") == 0 || strcasecmp(name, "msvcr90") == 0)
+	return MODULE_HANDLE_msvcr90;
 
+
     result=LoadLibraryA(name);
     dbgprintf("Returned LoadLibraryA(0x%x='%s'), codec_path=%s => 0x%x\n",
               name, name, codec_path, result);
@@ -2604,6 +2611,10 @@
 	result=LookupExternalByName("winmm.dll", name); break;
     case MODULE_HANDLE_psapi:
 	result=LookupExternalByName("psapi.dll", name); break;
+    case MODULE_HANDLE_atl90:
+	result=LookupExternalByName("atl90.dll", name); break;
+    case MODULE_HANDLE_msvcr90:
+	result=LookupExternalByName("msvcr90.dll", name); break;
     default:
 	result=GetProcAddress(mod, name);
     }
@@ -5113,6 +5124,27 @@
     return 0;
 }
 
+static int exp_encode_pointer(void *ptr)
+{
+    dbgprintf("_encode_pointer (0x%08x)\n", ptr);
+    return 0;
+}
+
+static int exp_lock(void *ptr)
+{
+    dbgprintf("_lock (0x%08x)\n", ptr);
+    return 0;
+}
+
+static int exp_unlock(void *ptr)
+{
+    dbgprintf("_unlock (0x%08x)\n", ptr);
+    return 0;
+}
+
+
+
+
 /* Fake implementation of sdt::_Lockit::_Lockit(void) from msvcp60.dll
    Needed by SCLS.DLL */
 static int exp_0Lockit_dummy(void)
@@ -5139,6 +5171,7 @@
     return p;
 }
 
+
 static DWORD WINAPI expGetThreadLocale(void)
 {
     return 0;
@@ -5556,6 +5589,13 @@
 #endif
 };
 
+static const struct exports exp_atl90[]={
+    FF(_initterm_e, -1)
+    FF(_initterm, -1)
+    FF(memset,-1)
+};
+
+
 /*  realplayer8:
 	DLL Name: PNCRT.dll
 	vma:  Hint/Ord Member-Name
@@ -5635,6 +5675,80 @@
     {"??3@YAXPAX@Z", -1, expdelete}
 };
 
+static const struct exports exp_msvcr90[]={
+    FF(_lock, -1)
+    FF(_unlock, -1)
+    FF(malloc, -1)
+    FF(_initterm, -1)
+    FF(_initterm_e, -1)
+    FF(_encode_pointer, -1)
+    FF(_decode_pointer, -1)
+    FF(__dllonexit, -1)
+    FF(_snprintf,-1)
+    FF(free, -1)
+    {"??3@YAXPAX@Z", -1, expdelete},
+    {"??2@YAPAXI@Z", -1, expnew},
+    {"??_U@YAPAXI@Z", -1, expnew},
+    
+
+{"_adjust_fdiv", -1, (void*)&_adjust_fdiv},
+    {"_winver",-1,(void*)&_winver},
+    FF(strrchr, -1)
+    FF(strchr, -1)
+    FF(strlen, -1)
+    FF(strcpy, -1)
+    FF(strncpy, -1)
+    FF(wcscpy, -1)
+    FF(strcmp, -1)
+    FF(strncmp, -1)
+    FF(strcat, -1)
+    FF(_stricmp,-1)
+    FF(_strdup,-1)
+    FF(_setjmp3,-1)
+    FF(isalnum, -1)
+    FF(isspace, -1)
+    FF(isalpha, -1)
+    FF(isdigit, -1)
+    FF(memmove, -1)
+    FF(memcmp, -1)
+    FF(memset, -1)
+    FF(memcpy, -1)
+    FF(time, -1)
+    FF(rand, -1)
+    FF(srand, -1)
+    FF(log10, -1)
+    FF(pow, -1)
+    FF(cos, -1)
+    FF(_ftol,-1)
+    FF(_CIpow,-1)
+    FF(_CIcos,-1)
+    FF(_CIsin,-1)
+    FF(_CIsqrt,-1)
+    FF(ldexp,-1)
+    FF(frexp,-1)
+    FF(sprintf,-1)
+    FF(sscanf,-1)
+    FF(fopen,-1)
+    FF(fprintf,-1)
+    FF(printf,-1)
+    FF(getenv,-1)
+    FF(floor,-1)
+/* needed by frapsvid.dll */
+    {"strstr",-1,(char *)&strstr},
+    {"qsort",-1,(void *)&qsort},
+    FF(_EH_prolog,-1)
+    FF(calloc,-1)
+    {"ceil",-1,(void*)&ceil},
+/* needed by imagepower mjpeg2k */
+    {"clock",-1,(void*)&clock},
+    {"memchr",-1,(void*)&memchr},
+    {"vfprintf",-1,(void*)&vfprintf},
+//    {"realloc",-1,(void*)&realloc},
+    FF(realloc,-1)
+    {"puts",-1,(void*)&puts}
+};
+
+
 static const struct exports exp_msvcp60[]={
     {"??0_Lockit@std@@QAE@XZ", -1, exp_0Lockit_dummy},
     {"??1_Lockit@std@@QAE@XZ", -1, exp_1Lockit_dummy}
@@ -5678,6 +5792,8 @@
     LL(msvcr80)
     LL(msvcp60)
     LL(msvcr100)
+    LL(atl90)
+    LL(msvcr90)
 };
 
 static WIN_BOOL WINAPI ext_stubs(void)
@@ -5757,7 +5873,7 @@
 
 #ifndef LOADLIB_TRY_NATIVE
   /* hack for truespeech and vssh264*/
-  if (!strcmp(library, "tsd32.dll") || !strcmp(library,"vssh264dec.dll") || !strcmp(library,"LCMW2.dll") || !strcmp(library,"VDODEC32.dll"))
+  if (!strcmp(library, "tsd32.dll") || !strcmp(library,"vssh264dec.dll") || !strcmp(library,"LCMW2.dll") || !strcmp(library,"VDODEC32.dll") || !strcmp(library,"G729DecoderDMO.dll"))
 #endif
     /* ok, this is a hack, and a big memory leak. should be fixed. - alex */
     {
_______________________________________________
MPlayer-dev-eng mailing list
MPlayer-dev-eng@xxxxxxxxxxxx
https://lists.mplayerhq.hu/mailman/listinfo/mplayer-dev-eng