summaryrefslogtreecommitdiffstats
path: root/loader/elfdll.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2012-08-12 15:30:21 +0200
committerwm4 <wm4@nowhere>2012-08-16 17:16:33 +0200
commitaebfbbf2bdda8e18beef90c16da97bd335f7d3b0 (patch)
treea7362bf3ef6f2d80a47b2e539a2ea4efe5e2e079 /loader/elfdll.c
parentc6b03ffef6250096373c4a81a489dae9fbff9087 (diff)
downloadmpv-aebfbbf2bdda8e18beef90c16da97bd335f7d3b0.tar.bz2
mpv-aebfbbf2bdda8e18beef90c16da97bd335f7d3b0.tar.xz
Remove win32/qt/xanim/real binary codecs loading
Remove the win32 loader - the win32 emulation layer, as well as the code for using DirectShow/DMO/VFW codecs. Remove loading of xanim, QuickTime, and RealMedia codecs. The win32 emulation layer is based on a very old version of wine. Apparently, wine code was copied and hacked until it was somehow able to load a limited collection of binary codecs. It poked around in the code segment of some known binary codecs to disable unsupported win32 API calls to make them work. Example from module.c: for (i=0;i<5;i++) RVA(0x19e842)[i]=0x90; // make_new_region ? for (i=0;i<28;i++) RVA(0x19e86d)[i]=0x90; // call__call_CreateCompatibleDC ? for (i=0;i<5;i++) RVA(0x19e898)[i]=0x90; // jmp_to_call_loadbitmap ? for (i=0;i<9;i++) RVA(0x19e8ac)[i]=0x90; // call__calls_OLE_shit ? for (i=0;i<106;i++) RVA(0x261b10)[i]=0x90; // disable threads Just to show how utterly insane this code is. You wouldn't want even your worst enemy to have to maintain this. In fact, it seems nobody made major changes to this code ever since it was committed. Most formats can be decoded by libavcodecs these days, and the loader couldn't be used on 64 bit platforms anyway. The same is (probably) true for the other binary codecs. General note about how support for win32 codecs could be added back: It's not possible to replace the win32 loader code by using wine as library, because modern wine can not be linked with native Linux programs for certain reasons. It would be possible to to move DirectShow video decoding into a separate process linked with wine, like the CoreAVC-for-Linux patches do. There is also the mplayer-ww fork, which uses the dshownative library to use DirectShow codecs on Windows.
Diffstat (limited to 'loader/elfdll.c')
-rw-r--r--loader/elfdll.c292
1 files changed, 0 insertions, 292 deletions
diff --git a/loader/elfdll.c b/loader/elfdll.c
deleted file mode 100644
index 650596ebd1..0000000000
--- a/loader/elfdll.c
+++ /dev/null
@@ -1,292 +0,0 @@
-/*
- * Elf-dll loader functions
- *
- * Copyright 1999 Bertho A. Stultiens
- *
- * Modified for use with MPlayer, detailed changelog at
- * http://svn.mplayerhq.hu/mplayer/trunk/
- *
- */
-#include "config.h"
-
-#ifdef HAVE_LIBDL
-
-#include "wine/windef.h"
-#include "wine/module.h"
-#include "wine/heap.h"
-#include "wine/elfdll.h"
-#include "wine/debugtools.h"
-#include "wine/winerror.h"
-#include "debug.h"
-#include "loader.h"
-#include "path.h"
-
-//DEFAULT_DEBUG_CHANNEL(elfdll)
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-#include <dlfcn.h>
-
-
-/*------------------ HACKS -----------------*/
-DWORD fixup_imports(WINE_MODREF *wm);
-void dump_exports(HMODULE hModule);
-/*---------------- END HACKS ---------------*/
-
-struct elfdll_image
-{
- HMODULE pe_module_start;
- DWORD pe_module_size;
-};
-
-
-/****************************************************************************
- * ELFDLL_dlopen
- *
- * Wrapper for dlopen to search the EXTRA_LD_LIBRARY_PATH from wine.conf
- * manually because libdl.so caches the environment and does not accept our
- * changes.
- */
-void *ELFDLL_dlopen(const char *libname, int flags)
-{
- char buffer[256];
- int namelen;
- void *handle;
- char *ldpath;
-
- /* First try the default path search of dlopen() */
- handle = dlopen(libname, flags);
- if(handle)
- return handle;
-
- /* Now try to construct searches through our extra search-path */
- namelen = strlen(libname);
- ldpath = codec_path;
- while(ldpath && *ldpath)
- {
- int len;
- char *cptr;
- char *from;
-
- from = ldpath;
- cptr = strchr(ldpath, ':');
- if(!cptr)
- {
- len = strlen(ldpath);
- ldpath = NULL;
- }
- else
- {
- len = cptr - ldpath;
- ldpath = cptr + 1;
- }
-
- if(len + namelen + 1 >= sizeof(buffer))
- {
- ERR("Buffer overflow! Check EXTRA_LD_LIBRARY_PATH or increase buffer size.\n");
- return NULL;
- }
-
- strncpy(buffer, from, len);
- if(len)
- {
- buffer[len] = '/';
- strcpy(buffer + len + 1, libname);
- }
- else
- strcpy(buffer + len, libname);
-
- TRACE("Trying dlopen('%s', %d)\n", buffer, flags);
-
- handle = dlopen(buffer, flags);
- if(handle)
- return handle;
- }
- return NULL;
-}
-
-
-/****************************************************************************
- * get_sobasename (internal)
- *
- */
-static LPSTR get_sobasename(LPCSTR path, LPSTR name)
-{
- char *cptr;
-
- /* Strip the path from the library name */
- if((cptr = strrchr(path, '/')))
- {
- char *cp = strrchr(cptr+1, '\\');
- if(cp && cp > cptr)
- cptr = cp;
- }
- else
- cptr = strrchr(path, '\\');
-
- if(!cptr)
- cptr = (char *)path; /* No '/' nor '\\' in path */
- else
- cptr++;
-
- strcpy(name, cptr);
- cptr = strrchr(name, '.');
- if(cptr)
- *cptr = '\0'; /* Strip extension */
-
- /* Convert to lower case.
- * This must be done manually because it is not sure that
- * other modules are accessible.
- */
- for(cptr = name; *cptr; cptr++)
- *cptr = tolower(*cptr);
-
- return name;
-}
-
-
-/****************************************************************************
- * ELFDLL_CreateModref (internal)
- *
- * INPUT
- * hModule - the header from the elf-dll's data-segment
- * path - requested path from original call
- *
- * OUTPUT
- * A WINE_MODREF pointer to the new object
- *
- * BUGS
- * - Does not handle errors due to dependencies correctly
- * - path can be wrong
- */
-#define RVA(base, va) (((DWORD)base) + ((DWORD)va))
-
-static WINE_MODREF *ELFDLL_CreateModref(HMODULE hModule, LPCSTR path)
-{
-// IMAGE_NT_HEADERS *nt = PE_HEADER(hModule);
-// IMAGE_DATA_DIRECTORY *dir;
-// IMAGE_IMPORT_DESCRIPTOR *pe_import = NULL;
- WINE_MODREF *wm;
-// int len;
- HANDLE procheap = GetProcessHeap();
-
- wm = (WINE_MODREF *)HeapAlloc(procheap, HEAP_ZERO_MEMORY, sizeof(*wm));
- if(!wm)
- return NULL;
-
- wm->module = hModule;
- wm->type = MODULE32_ELF; /* FIXME */
-
-// dir = nt->OptionalHeader.DataDirectory+IMAGE_DIRECTORY_ENTRY_EXPORT;
-// if(dir->Size)
-// wm->binfmt.pe.pe_export = (PIMAGE_EXPORT_DIRECTORY)RVA(hModule, dir->VirtualAddress);
-
-// dir = nt->OptionalHeader.DataDirectory+IMAGE_DIRECTORY_ENTRY_IMPORT;
-// if(dir->Size)
-// pe_import = wm->binfmt.pe.pe_import = (PIMAGE_IMPORT_DESCRIPTOR)RVA(hModule, dir->VirtualAddress);
-
-// dir = nt->OptionalHeader.DataDirectory+IMAGE_DIRECTORY_ENTRY_RESOURCE;
-// if(dir->Size)
-// wm->binfmt.pe.pe_resource = (PIMAGE_RESOURCE_DIRECTORY)RVA(hModule, dir->VirtualAddress);
-
-
- wm->filename = malloc(strlen(path)+1);
- strcpy(wm->filename, path);
- wm->modname = strrchr( wm->filename, '\\' );
- if (!wm->modname) wm->modname = wm->filename;
- else wm->modname++;
-/*
- len = GetShortPathNameA( wm->filename, NULL, 0 );
- wm->short_filename = (char *)HeapAlloc( procheap, 0, len+1 );
- GetShortPathNameA( wm->filename, wm->short_filename, len+1 );
- wm->short_modname = strrchr( wm->short_filename, '\\' );
- if (!wm->short_modname) wm->short_modname = wm->short_filename;
- else wm->short_modname++;
-*/
- /* Link MODREF into process list */
-
-// EnterCriticalSection( &PROCESS_Current()->crit_section );
-
- if(local_wm)
- {
- local_wm->next = malloc(sizeof(modref_list));
- local_wm->next->prev=local_wm;
- local_wm->next->next=NULL;
- local_wm->next->wm=wm;
- local_wm=local_wm->next;
- }
- else
- {
- local_wm = malloc(sizeof(modref_list));
- local_wm->next=local_wm->prev=NULL;
- local_wm->wm=wm;
- }
-
-// LeaveCriticalSection( &PROCESS_Current()->crit_section );
- return wm;
-}
-
-/****************************************************************************
- * ELFDLL_LoadLibraryExA (internal)
- *
- * Implementation of elf-dll loading for PE modules
- */
-WINE_MODREF *ELFDLL_LoadLibraryExA(LPCSTR path, DWORD flags)
-{
- LPVOID dlhandle;
-// struct elfdll_image *image;
- char name[129];
- char soname[129];
- WINE_MODREF *wm;
-
- get_sobasename(path, name);
- strcpy(soname, name);
- strcat(soname, ".so");
-
- /* Try to open the elf-dll */
- dlhandle = ELFDLL_dlopen(soname, RTLD_LAZY);
- if(!dlhandle)
- {
- WARN("Could not load %s (%s)\n", soname, dlerror());
- SetLastError( ERROR_FILE_NOT_FOUND );
- return NULL;
- }
-
- /* Get the 'dllname_elfdll_image' variable */
-/* strcpy(soname, name);
- strcat(soname, "_elfdll_image");
- image = (struct elfdll_image *)dlsym(dlhandle, soname);
- if(!image)
- {
- ERR("Could not get elfdll image descriptor %s (%s)\n", soname, dlerror());
- dlclose(dlhandle);
- SetLastError( ERROR_BAD_FORMAT );
- return NULL;
- }
-
-*/
- wm = ELFDLL_CreateModref((int)dlhandle, path);
- if(!wm)
- {
- ERR("Could not create WINE_MODREF for %s\n", path);
- dlclose(dlhandle);
- SetLastError( ERROR_OUTOFMEMORY );
- return NULL;
- }
-
- return wm;
-}
-
-
-/****************************************************************************
- * ELFDLL_UnloadLibrary (internal)
- *
- * Unload an elf-dll completely from memory and deallocate the modref
- */
-void ELFDLL_UnloadLibrary(WINE_MODREF *wm)
-{
-}
-
-#endif /*HAVE_LIBDL*/