Move libs/loader to modules/codec/loader
authorRémi Denis-Courmont <remi@remlab.net>
Tue, 30 Aug 2011 16:55:18 +0000 (19:55 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Tue, 30 Aug 2011 18:36:06 +0000 (21:36 +0300)
95 files changed:
Makefile.am
configure.ac
libs/loader/Makefile.am [deleted file]
libs/loader/afl.c [deleted file]
libs/loader/com.h [deleted file]
libs/loader/driver.c [deleted file]
libs/loader/driver.h [deleted file]
libs/loader/ext.c [deleted file]
libs/loader/ext.h [deleted file]
libs/loader/kludge.c [deleted file]
libs/loader/ldt_keeper.c [deleted file]
libs/loader/ldt_keeper.h [deleted file]
libs/loader/loader.h [deleted file]
libs/loader/module.c [deleted file]
libs/loader/pe_image.c [deleted file]
libs/loader/pe_resource.c [deleted file]
libs/loader/qtx/qtxsdk/components.h [deleted file]
libs/loader/registry.c [deleted file]
libs/loader/registry.h [deleted file]
libs/loader/resource.c [deleted file]
libs/loader/stubs.s [deleted file]
libs/loader/vfl.c [deleted file]
libs/loader/win32.c [deleted file]
libs/loader/win32.h [deleted file]
libs/loader/wine/avifmt.h [deleted file]
libs/loader/wine/basetsd.h [deleted file]
libs/loader/wine/debugtools.h [deleted file]
libs/loader/wine/driver.h [deleted file]
libs/loader/wine/heap.h [deleted file]
libs/loader/wine/mmreg.h [deleted file]
libs/loader/wine/module.h [deleted file]
libs/loader/wine/msacm.h [deleted file]
libs/loader/wine/msacmdrv.h [deleted file]
libs/loader/wine/pe_image.h [deleted file]
libs/loader/wine/poppack.h [deleted file]
libs/loader/wine/pshpack1.h [deleted file]
libs/loader/wine/pshpack2.h [deleted file]
libs/loader/wine/vfw.h [deleted file]
libs/loader/wine/winbase.h [deleted file]
libs/loader/wine/windef.h [deleted file]
libs/loader/wine/winerror.h [deleted file]
libs/loader/wine/winestring.h [deleted file]
libs/loader/wine/winnt.h [deleted file]
libs/loader/wine/winreg.h [deleted file]
libs/loader/wine/winuser.h [deleted file]
libs/loader/wineacm.h [deleted file]
libs/loader/wrapper.S [deleted file]
libs/loader/wrapper.h [deleted file]
modules/codec/Modules.am
modules/codec/loader/Makefile.am [new file with mode: 0644]
modules/codec/loader/afl.c [new file with mode: 0644]
modules/codec/loader/com.h [new file with mode: 0644]
modules/codec/loader/driver.c [new file with mode: 0644]
modules/codec/loader/driver.h [new file with mode: 0644]
modules/codec/loader/ext.c [new file with mode: 0644]
modules/codec/loader/ext.h [new file with mode: 0644]
modules/codec/loader/kludge.c [new file with mode: 0644]
modules/codec/loader/ldt_keeper.c [new file with mode: 0644]
modules/codec/loader/ldt_keeper.h [new file with mode: 0644]
modules/codec/loader/loader.h [new file with mode: 0644]
modules/codec/loader/module.c [new file with mode: 0644]
modules/codec/loader/pe_image.c [new file with mode: 0644]
modules/codec/loader/pe_resource.c [new file with mode: 0644]
modules/codec/loader/qtx/qtxsdk/components.h [new file with mode: 0644]
modules/codec/loader/registry.c [new file with mode: 0644]
modules/codec/loader/registry.h [new file with mode: 0644]
modules/codec/loader/resource.c [new file with mode: 0644]
modules/codec/loader/stubs.s [new file with mode: 0644]
modules/codec/loader/vfl.c [new file with mode: 0644]
modules/codec/loader/win32.c [new file with mode: 0644]
modules/codec/loader/win32.h [new file with mode: 0644]
modules/codec/loader/wine/avifmt.h [new file with mode: 0644]
modules/codec/loader/wine/basetsd.h [new file with mode: 0644]
modules/codec/loader/wine/debugtools.h [new file with mode: 0644]
modules/codec/loader/wine/driver.h [new file with mode: 0644]
modules/codec/loader/wine/heap.h [new file with mode: 0644]
modules/codec/loader/wine/mmreg.h [new file with mode: 0644]
modules/codec/loader/wine/module.h [new file with mode: 0644]
modules/codec/loader/wine/msacm.h [new file with mode: 0644]
modules/codec/loader/wine/msacmdrv.h [new file with mode: 0644]
modules/codec/loader/wine/pe_image.h [new file with mode: 0644]
modules/codec/loader/wine/poppack.h [new file with mode: 0644]
modules/codec/loader/wine/pshpack1.h [new file with mode: 0644]
modules/codec/loader/wine/pshpack2.h [new file with mode: 0644]
modules/codec/loader/wine/vfw.h [new file with mode: 0644]
modules/codec/loader/wine/winbase.h [new file with mode: 0644]
modules/codec/loader/wine/windef.h [new file with mode: 0644]
modules/codec/loader/wine/winerror.h [new file with mode: 0644]
modules/codec/loader/wine/winestring.h [new file with mode: 0644]
modules/codec/loader/wine/winnt.h [new file with mode: 0644]
modules/codec/loader/wine/winreg.h [new file with mode: 0644]
modules/codec/loader/wine/winuser.h [new file with mode: 0644]
modules/codec/loader/wineacm.h [new file with mode: 0644]
modules/codec/loader/wrapper.S [new file with mode: 0644]
modules/codec/loader/wrapper.h [new file with mode: 0644]

index d22eb8c..2598ba4 100644 (file)
@@ -9,13 +9,10 @@
 #  - libs/* are needed by modules
 BASE_SUBDIRS = po compat src bin modules share doc test
 EXTRA_SUBDIRS = m4 \
-       libs/loader libs/srtp
+       libs/srtp
 DIST_SUBDIRS = $(BASE_SUBDIRS) $(EXTRA_SUBDIRS)
 
 SUBDIRS = po compat src
-if LOADER
-SUBDIRS += libs/loader
-endif
 if HAVE_GCRYPT
 SUBDIRS += libs/srtp
 endif
index fad2e09..277e6e5 100644 (file)
@@ -4175,8 +4175,8 @@ AC_ARG_ENABLE(loader,
 AM_CONDITIONAL(LOADER, [test "${enable_loader}" = "yes"])
 AS_IF([test "${enable_loader}" = "yes"],
   [ VLC_ADD_PLUGIN([dmo])
-    VLC_ADD_CPPFLAGS([dmo quicktime realvideo],[-I\\\${top_srcdir}/libs/loader])
-    VLC_ADD_LIBS([dmo quicktime realvideo],[\\\${top_builddir}/libs/loader/libloader.la])
+    VLC_ADD_CPPFLAGS([dmo quicktime realvideo],[-I\\\${top_srcdir}/modules/codec/loader])
+    VLC_ADD_LIBS([dmo quicktime realvideo],[\\\${top_builddir}/modules/codec/loader/libloader.la])
     VLC_ADD_CPPFLAGS([realvideo], [-DLOADER])
     VLC_ADD_LIBS([dmo quicktime], [-lpthread])
   ])
@@ -4259,7 +4259,6 @@ AC_SUBST(FILE_LIBVLC_DLL)
 AC_CONFIG_FILES([
   Makefile
   doc/Makefile
-  libs/loader/Makefile
   libs/srtp/Makefile
   modules/Makefile
   m4/Makefile
@@ -4288,6 +4287,7 @@ AC_CONFIG_FILES([
   modules/codec/Makefile
   modules/codec/avcodec/Makefile
   modules/codec/dmo/Makefile
+  modules/codec/loader/Makefile
   modules/codec/omxil/Makefile
   modules/codec/shine/Makefile
   modules/codec/spudec/Makefile
diff --git a/libs/loader/Makefile.am b/libs/loader/Makefile.am
deleted file mode 100644 (file)
index 23ce88d..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-
-# Makefile to build MPlayer's DLL loader
-# from VLC trunk
-#
-# by Rémi Denis-Courmont <rem # videolan.org>
-# $Id$
-#
-# All other files in this directory (and subdirectories) are copyrighted
-# by their respective owner(s).
-#
-
-noinst_LTLIBRARIES = libloader.la
-
-# TODO: real check for vsscanf() and <sys/mmap.h>
-AM_CPPFLAGS = -D__WINE__ -DHAVE_SYS_MMAN_H=1 -DHAVE_VSSCANF=1 \
-       -DWIN32_PATH=\"\" -DTRACE\(...\)=\(void\)0
-AM_CFLAGS = -fno-PIC -U_FILE_OFFSET_BITS \
-       -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer
-
-noinst_HEADERS = com.h driver.h ext.h ldt_keeper.h loader.h registry.h \
-       win32.h wineacm.h wrapper.h qtx/qtxsdk/components.h \
-       wine/avifmt.h wine/basetsd.h wine/debugtools.h wine/driver.h \
-       wine/heap.h wine/mmreg.h wine/module.h wine/msacmdrv.h wine/msacm.h \
-       wine/pe_image.h wine/poppack.h wine/pshpack1.h wine/pshpack2.h \
-       wine/vfw.h wine/winbase.h wine/windef.h wine/winerror.h \
-       wine/winestring.h wine/winnt.h wine/winreg.h wine/winuser.h
-
-libloader_la_SOURCES = ldt_keeper.c pe_image.c module.c ext.c win32.c \
-       driver.c pe_resource.c resource.c registry.c afl.c vfl.c \
-       wrapper.S stubs.s kludge.c
-libloader_la_LIBADD = -lpthread
-
diff --git a/libs/loader/afl.c b/libs/loader/afl.c
deleted file mode 100644 (file)
index 7cb0eb8..0000000
+++ /dev/null
@@ -1,791 +0,0 @@
-/*
- * $Id$
- *
- * Copyright (C) 1998 Patrick Stridvall
- * Copyright (C) 1999 Eric Pouech
- *
- * Originally distributed under LPGL 2.1 (or later) by the Wine project.
- *
- * Modified for use with MPlayer, detailed CVS changelog at
- * http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
- *
- * File now distributed as part of VLC media player with no modifications.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
- */
-
-/**************************************************************************
-
-
-  This file will contain an interface to ACM drivers.
-  Its content will be based mainly on wine/dlls/msacm32
-  actually, for audio decompression only the following functions
-  are needed:
-  
-  acmStreamOpen ( takes formats of src and dest, returns stream handle )
-  acmStreamPrepareHeader ( takes stream handler and info on data )
-  acmStreamConvert ( the same as PrepareHeader )
-  acmStreamUnprepareHeader
-  acmStreamClose
-  acmStreamSize
-  maybe acmStreamReset
-  
-  In future I'll also add functions for format enumeration, 
-  but not right now.
-
-  Modified for use with MPlayer, detailed CVS changelog at
-  http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
-  
-***************************************************************************/
-#include "config.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"
-#ifndef __MINGW32__
-#include "ext.h"
-#endif
-#include "driver.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#pragma pack(1)
-#define OpenDriverA DrvOpen
-#define CloseDriver DrvClose
-
-static inline PWINE_ACMSTREAM ACM_GetStream(HACMSTREAM has)
-{
-    return (PWINE_ACMSTREAM)has;
-}
-
-/***********************************************************************
- *           acmDriverAddA (MSACM32.2)
- */
-MMRESULT WINAPI acmDriverAddA(PHACMDRIVERID phadid, HINSTANCE hinstModule,
-                             LPARAM lParam, DWORD dwPriority, DWORD fdwAdd)
-{
-    if (!phadid)
-       return MMSYSERR_INVALPARAM;
-    
-    /* Check if any unknown flags */
-    if (fdwAdd & 
-       ~(ACM_DRIVERADDF_FUNCTION|ACM_DRIVERADDF_NOTIFYHWND|
-         ACM_DRIVERADDF_GLOBAL))
-       return MMSYSERR_INVALFLAG;
-    
-    /* Check if any incompatible flags */
-    if ((fdwAdd & ACM_DRIVERADDF_FUNCTION) && 
-       (fdwAdd & ACM_DRIVERADDF_NOTIFYHWND))
-       return MMSYSERR_INVALFLAG;
-    
-    /* FIXME: in fact, should GetModuleFileName(hinstModule) and do a 
-     * LoadDriver on it, to be sure we can call SendDriverMessage on the
-     * hDrvr handle.
-     */
-    *phadid = (HACMDRIVERID) MSACM_RegisterDriver(NULL, 0, hinstModule);
-    
-    /* FIXME: lParam, dwPriority and fdwAdd ignored */
-    
-    return MMSYSERR_NOERROR;
-}
-
-/***********************************************************************
- *           acmDriverClose (MSACM32.4)
- */
-MMRESULT WINAPI acmDriverClose(HACMDRIVER had, DWORD fdwClose)
-{
-    PWINE_ACMDRIVER  p;
-    PWINE_ACMDRIVER* tp;
-    
-    if (fdwClose)
-       return MMSYSERR_INVALFLAG;
-    
-    p = MSACM_GetDriver(had);
-    if (!p)
-       return MMSYSERR_INVALHANDLE;
-
-    for (tp = &(p->obj.pACMDriverID->pACMDriverList); *tp; *tp = (*tp)->pNextACMDriver) {
-       if (*tp == p) {
-           *tp = (*tp)->pNextACMDriver;
-           break;
-       }
-    }
-    
-    if (p->hDrvr && !p->obj.pACMDriverID->pACMDriverList)
-       CloseDriver(p->hDrvr);
-    
-    HeapFree(MSACM_hHeap, 0, p);
-    
-    return MMSYSERR_NOERROR;
-}
-
-/***********************************************************************
- *           acmDriverEnum (MSACM32.7)
- */
-MMRESULT WINAPI acmDriverEnum(ACMDRIVERENUMCB fnCallback, DWORD dwInstance, DWORD fdwEnum)
-{
-    PWINE_ACMDRIVERID  p;
-    DWORD              fdwSupport;
-
-    if (!fnCallback) {
-       return MMSYSERR_INVALPARAM;
-    }
-    
-    if (fdwEnum && ~(ACM_DRIVERENUMF_NOLOCAL|ACM_DRIVERENUMF_DISABLED)) {
-       return MMSYSERR_INVALFLAG;
-    }
-    
-    for (p = MSACM_pFirstACMDriverID; p; p = p->pNextACMDriverID) {
-       fdwSupport = ACMDRIVERDETAILS_SUPPORTF_CODEC;
-       if (!p->bEnabled) {
-           if (fdwEnum & ACM_DRIVERENUMF_DISABLED)
-               fdwSupport |= ACMDRIVERDETAILS_SUPPORTF_DISABLED;
-           else
-               continue;
-       }
-       (*fnCallback)((HACMDRIVERID) p, dwInstance, fdwSupport);
-    }
-    
-    return MMSYSERR_NOERROR;
-}
-
-/***********************************************************************
- *           acmDriverID (MSACM32.8)
- */
-MMRESULT WINAPI acmDriverID(HACMOBJ hao, PHACMDRIVERID phadid, DWORD fdwDriverID)
-{
-    PWINE_ACMOBJ pao;
-    
-    pao = MSACM_GetObj(hao);
-    if (!pao)
-       return MMSYSERR_INVALHANDLE;
-    
-    if (!phadid)
-       return MMSYSERR_INVALPARAM;
-    
-    if (fdwDriverID)
-       return MMSYSERR_INVALFLAG;
-    
-    *phadid = (HACMDRIVERID) pao->pACMDriverID;
-    
-    return MMSYSERR_NOERROR;
-}
-
-/***********************************************************************
- *           acmDriverMessage (MSACM32.9)
- * FIXME
- *   Not implemented
- */
-LRESULT WINAPI acmDriverMessage(HACMDRIVER had, UINT uMsg, LPARAM lParam1, LPARAM lParam2)
-{
-    PWINE_ACMDRIVER pad = MSACM_GetDriver(had);
-    if (!pad)
-       return MMSYSERR_INVALPARAM;
-    
-    /* FIXME: Check if uMsg legal */
-    
-    if (!SendDriverMessage(pad->hDrvr, uMsg, lParam1, lParam2))
-       return MMSYSERR_NOTSUPPORTED;
-    
-    return MMSYSERR_NOERROR;
-}
-
-
-/***********************************************************************
- *           acmDriverOpen (MSACM32.10)
- */
-MMRESULT WINAPI acmDriverOpen(PHACMDRIVER phad, HACMDRIVERID hadid, DWORD fdwOpen)
-{
-    PWINE_ACMDRIVERID  padid;
-    PWINE_ACMDRIVER    pad;
-    ICOPEN             icopen;
-    HDRVR              hdrv;
-
-
-    TRACE("(%p, %x, %08lu)\n", phad, hadid, fdwOpen);
-
-    if (!phad)
-       return MMSYSERR_INVALPARAM;
-    
-    padid = MSACM_GetDriverID(hadid); 
-    if (!padid)
-       return MMSYSERR_INVALHANDLE;
-    
-    if (fdwOpen)
-       return MMSYSERR_INVALFLAG;
-    
-    pad = (PWINE_ACMDRIVER) HeapAlloc(MSACM_hHeap, 0, sizeof(WINE_ACMDRIVER));
-    if (!pad)
-       return MMSYSERR_NOMEM;
-
-    pad->obj.pACMDriverID = padid;
-    icopen.fccType             = mmioFOURCC('a', 'u', 'd', 'c');
-    icopen.fccHandler          = (long)padid->pszFileName;
-    icopen.dwSize              = sizeof(ICOPEN);
-    icopen.dwFlags             = 0;
-
-    icopen.pV1Reserved = padid->pszFileName;
-    if (!padid->hInstModule)
-       pad->hDrvr = OpenDriverA((long)&icopen);
-    else
-       pad->hDrvr = padid->hInstModule;
-    
-    if (!pad->hDrvr) {
-       HeapFree(MSACM_hHeap, 0, pad);
-       return MMSYSERR_ERROR;
-    }
-
-    pad->pfnDriverProc = GetProcAddress(pad->hDrvr, "DriverProc");
-
-    /* insert new pad at beg of list */
-    pad->pNextACMDriver = padid->pACMDriverList;
-    padid->pACMDriverList = pad;
-
-    /* FIXME: Create a WINE_ACMDRIVER32 */
-    *phad = (HACMDRIVER)pad;
-
-    return MMSYSERR_NOERROR;
-}
-
-/***********************************************************************
- *           acmDriverRemove (MSACM32.12)
- */
-MMRESULT WINAPI acmDriverRemove(HACMDRIVERID hadid, DWORD fdwRemove)
-{
-    PWINE_ACMDRIVERID padid;
-    
-    padid = MSACM_GetDriverID(hadid);
-    if (!padid)
-       return MMSYSERR_INVALHANDLE;
-    
-    if (fdwRemove)
-       return MMSYSERR_INVALFLAG;
-    
-    MSACM_UnregisterDriver(padid);
-    
-    return MMSYSERR_NOERROR;
-}
-
-
-
-/**********************************************************************/
-
-HANDLE MSACM_hHeap = (HANDLE) NULL;
-PWINE_ACMDRIVERID MSACM_pFirstACMDriverID = NULL;
-PWINE_ACMDRIVERID MSACM_pLastACMDriverID = NULL;
-
-/***********************************************************************
- *           MSACM_RegisterDriver32() 
- */
-PWINE_ACMDRIVERID MSACM_RegisterDriver(const char* pszFileName,
-                                      WORD wFormatTag,
-                                      HINSTANCE hinstModule)
-{
-    PWINE_ACMDRIVERID padid;
-
-    TRACE("('%s', '%x', 0x%08x)\n", pszFileName, wFormatTag, hinstModule);
-
-#ifndef WIN32_LOADER
-       MSACM_hHeap = GetProcessHeap();
-#endif
-    padid = (PWINE_ACMDRIVERID) HeapAlloc(MSACM_hHeap, 0, sizeof(WINE_ACMDRIVERID));
-    padid->pszFileName = (char*)malloc(strlen(pszFileName)+1);
-    strcpy(padid->pszFileName, pszFileName);
-//    1~strdup(pszDriverAlias);
-    padid->wFormatTag = wFormatTag;
-    padid->hInstModule = hinstModule;
-    padid->bEnabled = TRUE;
-    padid->pACMDriverList = NULL;
-    padid->pNextACMDriverID = NULL;
-    padid->pPrevACMDriverID = MSACM_pLastACMDriverID;
-    if (MSACM_pLastACMDriverID)
-       MSACM_pLastACMDriverID->pNextACMDriverID = padid;
-    MSACM_pLastACMDriverID = padid;
-    if (!MSACM_pFirstACMDriverID)
-       MSACM_pFirstACMDriverID = padid;
-    
-    return padid;
-}
-
-
-/***********************************************************************
- *           MSACM_UnregisterDriver32()
- */
-PWINE_ACMDRIVERID MSACM_UnregisterDriver(PWINE_ACMDRIVERID p)
-{
-    PWINE_ACMDRIVERID pNextACMDriverID;
-    
-    while (p->pACMDriverList)
-       acmDriverClose((HACMDRIVER) p->pACMDriverList, 0);
-    
-    free( p->pszFileName );
-    
-    if (p == MSACM_pFirstACMDriverID)
-       MSACM_pFirstACMDriverID = p->pNextACMDriverID;
-    if (p == MSACM_pLastACMDriverID)
-       MSACM_pLastACMDriverID = p->pPrevACMDriverID;
-
-    if (p->pPrevACMDriverID)
-       p->pPrevACMDriverID->pNextACMDriverID = p->pNextACMDriverID;
-    if (p->pNextACMDriverID)
-       p->pNextACMDriverID->pPrevACMDriverID = p->pPrevACMDriverID;
-    
-    pNextACMDriverID = p->pNextACMDriverID;
-    
-    HeapFree(MSACM_hHeap, 0, p);
-    
-    return pNextACMDriverID;
-}
-
-/***********************************************************************
- *           MSACM_UnregisterAllDrivers32()
- * FIXME
- *   Where should this function be called?
- */
-void MSACM_UnregisterAllDrivers(void)
-{
-    PWINE_ACMDRIVERID p;
-
-    for (p = MSACM_pFirstACMDriverID; p; p = MSACM_UnregisterDriver(p));
-}
-
-/***********************************************************************
- *           MSACM_GetDriverID32() 
- */
-PWINE_ACMDRIVERID MSACM_GetDriverID(HACMDRIVERID hDriverID)
-{
-    return (PWINE_ACMDRIVERID)hDriverID;
-}
-
-/***********************************************************************
- *           MSACM_GetDriver32()
- */
-PWINE_ACMDRIVER MSACM_GetDriver(HACMDRIVER hDriver)
-{
-    return (PWINE_ACMDRIVER)hDriver;
-}
-
-/***********************************************************************
- *           MSACM_GetObj32()
- */
-PWINE_ACMOBJ MSACM_GetObj(HACMOBJ hObj)
-{
-    return (PWINE_ACMOBJ)hObj;
-}
-
-
-
-/***********************************************************************
- *           acmStreamOpen (MSACM32.40)
- */
-MMRESULT WINAPI acmStreamOpen(PHACMSTREAM phas, HACMDRIVER had, PWAVEFORMATEX pwfxSrc,
-                             PWAVEFORMATEX pwfxDst, PWAVEFILTER pwfltr, DWORD dwCallback,
-                             DWORD dwInstance, DWORD fdwOpen)
-{
-    PWINE_ACMSTREAM    was;
-    PWINE_ACMDRIVER    wad;
-    MMRESULT           ret;
-    int                        wfxSrcSize;
-    int                        wfxDstSize;
-    
-    TRACE("(%p, 0x%08x, %p, %p, %p, %ld, %ld, %ld)\n",
-         phas, had, pwfxSrc, pwfxDst, pwfltr, dwCallback, dwInstance, fdwOpen);
-
-    TRACE("src [wFormatTag=%u, nChannels=%u, nSamplesPerSec=%lu, nAvgBytesPerSec=%lu, nBlockAlign=%u, wBitsPerSample=%u, cbSize=%u]\n", 
-         pwfxSrc->wFormatTag, pwfxSrc->nChannels, pwfxSrc->nSamplesPerSec, pwfxSrc->nAvgBytesPerSec, 
-         pwfxSrc->nBlockAlign, pwfxSrc->wBitsPerSample, pwfxSrc->cbSize);
-
-    TRACE("dst [wFormatTag=%u, nChannels=%u, nSamplesPerSec=%lu, nAvgBytesPerSec=%lu, nBlockAlign=%u, wBitsPerSample=%u, cbSize=%u]\n", 
-         pwfxDst->wFormatTag, pwfxDst->nChannels, pwfxDst->nSamplesPerSec, pwfxDst->nAvgBytesPerSec, 
-         pwfxDst->nBlockAlign, pwfxDst->wBitsPerSample, pwfxDst->cbSize);
-
-#define SIZEOF_WFX(wfx) (sizeof(WAVEFORMATEX) + ((wfx->wFormatTag == WAVE_FORMAT_PCM) ? 0 : wfx->cbSize))
-    wfxSrcSize = SIZEOF_WFX(pwfxSrc);
-    wfxDstSize = SIZEOF_WFX(pwfxDst);
-#undef SIZEOF_WFX
-
-    was = (PWINE_ACMSTREAM) HeapAlloc(MSACM_hHeap, 0, sizeof(*was) + wfxSrcSize + wfxDstSize + ((pwfltr) ? sizeof(WAVEFILTER) : 0));
-    if (was == NULL)
-       return MMSYSERR_NOMEM;
-    was->drvInst.cbStruct = sizeof(was->drvInst);
-    was->drvInst.pwfxSrc = (PWAVEFORMATEX)((LPSTR)was + sizeof(*was));
-    memcpy(was->drvInst.pwfxSrc, pwfxSrc, wfxSrcSize);
-    // LHACM is checking for 0x1
-    // but if this will not help
-    // was->drvInst.pwfxSrc->wFormatTag = 1;
-    was->drvInst.pwfxDst = (PWAVEFORMATEX)((LPSTR)was + sizeof(*was) + wfxSrcSize);
-    memcpy(was->drvInst.pwfxDst, pwfxDst, wfxDstSize);
-    if (pwfltr) {
-       was->drvInst.pwfltr = (PWAVEFILTER)((LPSTR)was + sizeof(*was) + wfxSrcSize + wfxDstSize);
-       memcpy(was->drvInst.pwfltr, pwfltr, sizeof(WAVEFILTER));
-    } else {
-       was->drvInst.pwfltr = NULL;
-    }
-    was->drvInst.dwCallback = dwCallback;    
-    was->drvInst.dwInstance = dwInstance;
-    was->drvInst.fdwOpen = fdwOpen;
-    was->drvInst.fdwDriver = 0L;  
-    was->drvInst.dwDriver = 0L;     
-    was->drvInst.has = (HACMSTREAM)was;
-    
-    if (had) {
-       if (!(wad = MSACM_GetDriver(had))) {
-           ret = MMSYSERR_INVALPARAM;
-           goto errCleanUp;
-       }
-       
-       was->obj.pACMDriverID = wad->obj.pACMDriverID;
-       was->pDrv = wad;
-       was->hAcmDriver = 0; /* not to close it in acmStreamClose */
-
-       ret = SendDriverMessage(wad->hDrvr, ACMDM_STREAM_OPEN, (DWORD)&was->drvInst, 0L);
-       if (ret != MMSYSERR_NOERROR)
-           goto errCleanUp;
-    } else {
-       PWINE_ACMDRIVERID wadi;
-       short drv_tag;
-       ret = ACMERR_NOTPOSSIBLE;
-/*     if(pwfxSrc->wFormatTag==1)//compression
-           drv_tag=pwfxDst->wFormatTag;
-           else
-           if(pwfxDst->wFormatTag==1)//decompression
-               drv_tag=pwfxSrc->wFormatTag;
-               else
-               goto errCleanUp;
-
-           ret=acmDriverOpen2(drv_tag); 
-           if (ret == MMSYSERR_NOERROR) {
-               if ((wad = MSACM_GetDriver(had)) != 0) {
-                   was->obj.pACMDriverID = wad->obj.pACMDriverID;
-                   was->pDrv = wad;
-                   was->hAcmDriver = had;
-                   
-                   ret = SendDriverMessage(wad->hDrvr, ACMDM_STREAM_OPEN, (DWORD)&was->drvInst, 0L);
-                   if (ret == MMSYSERR_NOERROR) {
-                       if (fdwOpen & ACM_STREAMOPENF_QUERY) {
-                           acmDriverClose(had, 0L);
-                       }
-                       break;
-                   }
-               }
-               acmDriverClose(had, 0L);*/
-       //if(MSACM_pFirstACMDriverID==NULL)
-       //    MSACM_RegisterAllDrivers();
-       
-       for (wadi = MSACM_pFirstACMDriverID; wadi; wadi = wadi->pNextACMDriverID)
-       {
-           /* Check Format */
-           if ((int)wadi->wFormatTag != (int)pwfxSrc->wFormatTag) continue;
-
-           ret = acmDriverOpen(&had, (HACMDRIVERID)wadi, 0L);
-           if (ret == MMSYSERR_NOERROR) {
-               if ((wad = MSACM_GetDriver(had)) != NULL) {
-                   was->obj.pACMDriverID = wad->obj.pACMDriverID;
-                   was->pDrv = wad;
-                   was->hAcmDriver = had;
-                   
-                   ret = SendDriverMessage(wad->hDrvr, ACMDM_STREAM_OPEN, (DWORD)&was->drvInst, 0L);
-                   //lhacm - crash printf("RETOPEN %d\n", ret);
-                    //ret = 0;
-                   if (ret == MMSYSERR_NOERROR) {
-                       if (fdwOpen & ACM_STREAMOPENF_QUERY) {
-                           acmDriverClose(had, 0L);
-                       }
-                       break;
-                   }
-               }
-               // no match, close this acm driver and try next one 
-               acmDriverClose(had, 0L);
-           }
-       }
-       if (ret != MMSYSERR_NOERROR) {
-           ret = ACMERR_NOTPOSSIBLE;
-           goto errCleanUp;
-       }
-    }
-    ret = MMSYSERR_NOERROR;
-    if (!(fdwOpen & ACM_STREAMOPENF_QUERY)) {
-       if (phas)
-           *phas = (HACMSTREAM)was;
-       TRACE("=> (%d)\n", ret);
-#ifdef WIN32_LOADER
-        CodecAlloc();
-#endif
-       return ret;
-    }
-errCleanUp:            
-    if (phas)
-       *phas = (HACMSTREAM)0;
-    HeapFree(MSACM_hHeap, 0, was);
-    TRACE("=> (%d)\n", ret);
-    return ret;
-}
-
-
-MMRESULT WINAPI acmStreamClose(HACMSTREAM has, DWORD fdwClose)
-{
-    PWINE_ACMSTREAM    was;
-    MMRESULT           ret;
-               
-    TRACE("(0x%08x, %ld)\n", has, fdwClose);
-    
-    if ((was = ACM_GetStream(has)) == NULL) {
-       return MMSYSERR_INVALHANDLE;
-    }
-    ret = SendDriverMessage(was->pDrv->hDrvr, ACMDM_STREAM_CLOSE, (DWORD)&was->drvInst, 0);
-    if (ret == MMSYSERR_NOERROR) {
-       if (was->hAcmDriver)
-           acmDriverClose(was->hAcmDriver, 0L);        
-       HeapFree(MSACM_hHeap, 0, was);
-#ifdef WIN32_LOADER
-        CodecRelease();
-#endif
-    }
-    TRACE("=> (%d)\n", ret);
-    return ret;
-}
-
-/***********************************************************************
- *           acmStreamConvert (MSACM32.38)
- */
-MMRESULT WINAPI acmStreamConvert(HACMSTREAM has, PACMSTREAMHEADER pash, 
-                                DWORD fdwConvert)
-{
-    PWINE_ACMSTREAM    was;
-    MMRESULT           ret = MMSYSERR_NOERROR;
-    PACMDRVSTREAMHEADER        padsh;
-
-    TRACE("(0x%08x, %p, %ld)\n", has, pash, fdwConvert);
-
-    if ((was = ACM_GetStream(has)) == NULL)
-       return MMSYSERR_INVALHANDLE;
-    if (!pash || pash->cbStruct < sizeof(ACMSTREAMHEADER))
-       return MMSYSERR_INVALPARAM;
-
-    if (!(pash->fdwStatus & ACMSTREAMHEADER_STATUSF_PREPARED))
-       return ACMERR_UNPREPARED;
-
-    /* Note: the ACMSTREAMHEADER and ACMDRVSTREAMHEADER structs are of same
-     * size. some fields are private to msacm internals, and are exposed
-     * in ACMSTREAMHEADER in the dwReservedDriver array
-     */
-    padsh = (PACMDRVSTREAMHEADER)pash;
-
-    /* check that pointers have not been modified */
-    if (padsh->pbPreparedSrc != padsh->pbSrc ||
-       padsh->cbPreparedSrcLength < padsh->cbSrcLength ||
-       padsh->pbPreparedDst != padsh->pbDst ||
-       padsh->cbPreparedDstLength < padsh->cbDstLength) {
-       return MMSYSERR_INVALPARAM;
-    }  
-
-    padsh->fdwConvert = fdwConvert;
-
-    ret = SendDriverMessage(was->pDrv->hDrvr, ACMDM_STREAM_CONVERT, (DWORD)&was->drvInst, (DWORD)padsh);
-    if (ret == MMSYSERR_NOERROR) {
-       padsh->fdwStatus |= ACMSTREAMHEADER_STATUSF_DONE;
-    }
-    TRACE("=> (%d)\n", ret);
-    return ret;
-}
-
-
-/***********************************************************************
- *           acmStreamPrepareHeader (MSACM32.41)
- */
-MMRESULT WINAPI acmStreamPrepareHeader(HACMSTREAM has, PACMSTREAMHEADER pash, 
-                                      DWORD fdwPrepare)
-{
-    PWINE_ACMSTREAM    was;
-    MMRESULT           ret = MMSYSERR_NOERROR;
-    PACMDRVSTREAMHEADER        padsh;
-
-    TRACE("(0x%08x, %p, %ld)\n", has, pash, fdwPrepare);
-    
-    if ((was = ACM_GetStream(has)) == NULL)
-       return MMSYSERR_INVALHANDLE;
-    if (!pash || pash->cbStruct < sizeof(ACMSTREAMHEADER))
-       return MMSYSERR_INVALPARAM;
-    if (fdwPrepare)
-       ret = MMSYSERR_INVALFLAG;
-
-    if (pash->fdwStatus & ACMSTREAMHEADER_STATUSF_DONE)
-       return MMSYSERR_NOERROR;
-
-    /* Note: the ACMSTREAMHEADER and ACMDRVSTREAMHEADER structs are of same
-     * size. some fields are private to msacm internals, and are exposed
-     * in ACMSTREAMHEADER in the dwReservedDriver array
-     */
-    padsh = (PACMDRVSTREAMHEADER)pash;
-
-    padsh->fdwConvert = fdwPrepare;
-    padsh->padshNext = NULL;
-    padsh->fdwDriver = padsh->dwDriver = 0L;
-
-    padsh->fdwPrepared = 0;
-    padsh->dwPrepared = 0;
-    padsh->pbPreparedSrc = 0;
-    padsh->cbPreparedSrcLength = 0;
-    padsh->pbPreparedDst = 0;
-    padsh->cbPreparedDstLength = 0;
-
-    ret = SendDriverMessage(was->pDrv->hDrvr, ACMDM_STREAM_PREPARE, (DWORD)&was->drvInst, (DWORD)padsh);
-    if (ret == MMSYSERR_NOERROR || ret == MMSYSERR_NOTSUPPORTED) {
-       ret = MMSYSERR_NOERROR;
-       padsh->fdwStatus &= ~(ACMSTREAMHEADER_STATUSF_DONE|ACMSTREAMHEADER_STATUSF_INQUEUE);
-       padsh->fdwStatus |= ACMSTREAMHEADER_STATUSF_PREPARED;
-       padsh->fdwPrepared = padsh->fdwStatus;
-       padsh->dwPrepared = 0;
-       padsh->pbPreparedSrc = padsh->pbSrc;
-       padsh->cbPreparedSrcLength = padsh->cbSrcLength;
-       padsh->pbPreparedDst = padsh->pbDst;
-       padsh->cbPreparedDstLength = padsh->cbDstLength;
-    } else {
-       padsh->fdwPrepared = 0;
-       padsh->dwPrepared = 0;
-       padsh->pbPreparedSrc = 0;
-       padsh->cbPreparedSrcLength = 0;
-       padsh->pbPreparedDst = 0;
-       padsh->cbPreparedDstLength = 0;
-    }
-    TRACE("=> (%d)\n", ret);
-    return ret;
-}
-
-/***********************************************************************
- *           acmStreamReset (MSACM32.42)
- */
-MMRESULT WINAPI acmStreamReset(HACMSTREAM has, DWORD fdwReset)
-{
-    PWINE_ACMSTREAM    was;
-    MMRESULT           ret = MMSYSERR_NOERROR;
-
-    TRACE("(0x%08x, %ld)\n", has, fdwReset);
-
-    if (fdwReset) {
-       ret = MMSYSERR_INVALFLAG;
-    } else if ((was = ACM_GetStream(has)) == NULL) {
-       return MMSYSERR_INVALHANDLE;
-    } else if (was->drvInst.fdwOpen & ACM_STREAMOPENF_ASYNC) {
-       ret = SendDriverMessage(was->pDrv->hDrvr, ACMDM_STREAM_RESET, (DWORD)&was->drvInst, 0);
-    }
-    TRACE("=> (%d)\n", ret);
-    return ret;
-}
-
-/***********************************************************************
- *           acmStreamSize (MSACM32.43)
- */
-MMRESULT WINAPI acmStreamSize(HACMSTREAM has, DWORD cbInput, 
-                             LPDWORD pdwOutputBytes, DWORD fdwSize)
-{
-    PWINE_ACMSTREAM    was;
-    ACMDRVSTREAMSIZE   adss;
-    MMRESULT           ret;
-    
-    TRACE("(0x%08x, %ld, %p, %ld)\n", has, cbInput, pdwOutputBytes, fdwSize);
-    
-    if ((was = ACM_GetStream(has)) == NULL) {
-       return MMSYSERR_INVALHANDLE;
-    }
-    if ((fdwSize & ~ACM_STREAMSIZEF_QUERYMASK) != 0) {
-       return MMSYSERR_INVALFLAG;
-    }
-
-    *pdwOutputBytes = 0L;
-    
-    switch (fdwSize & ACM_STREAMSIZEF_QUERYMASK) {
-    case ACM_STREAMSIZEF_DESTINATION:
-       adss.cbDstLength = cbInput;
-       adss.cbSrcLength = 0;
-       break;
-    case ACM_STREAMSIZEF_SOURCE:
-       adss.cbSrcLength = cbInput;
-       adss.cbDstLength = 0;
-       break;
-    default:   
-       return MMSYSERR_INVALFLAG;
-    }
-    
-    adss.cbStruct = sizeof(adss);
-    adss.fdwSize = fdwSize;
-    ret = SendDriverMessage(was->pDrv->hDrvr, ACMDM_STREAM_SIZE, 
-                           (DWORD)&was->drvInst, (DWORD)&adss);
-    if (ret == MMSYSERR_NOERROR) {
-       switch (fdwSize & ACM_STREAMSIZEF_QUERYMASK) {
-       case ACM_STREAMSIZEF_DESTINATION:
-           *pdwOutputBytes = adss.cbSrcLength;
-           break;
-       case ACM_STREAMSIZEF_SOURCE:
-           *pdwOutputBytes = adss.cbDstLength;
-           break;
-       }
-    }
-    TRACE("=> (%d) [%lu]\n", ret, *pdwOutputBytes);
-    return ret;
-}
-
-/***********************************************************************
- *           acmStreamUnprepareHeader (MSACM32.44)
- */
-MMRESULT WINAPI acmStreamUnprepareHeader(HACMSTREAM has, PACMSTREAMHEADER pash, 
-                                        DWORD fdwUnprepare)
-{
-    PWINE_ACMSTREAM    was;
-    MMRESULT           ret = MMSYSERR_NOERROR;
-    PACMDRVSTREAMHEADER        padsh;
-
-    TRACE("(0x%08x, %p, %ld)\n", has, pash, fdwUnprepare);
-    
-    if ((was = ACM_GetStream(has)) == NULL)
-       return MMSYSERR_INVALHANDLE;
-    if (!pash || pash->cbStruct < sizeof(ACMSTREAMHEADER))
-       return MMSYSERR_INVALPARAM;
-
-    if (!(pash->fdwStatus & ACMSTREAMHEADER_STATUSF_PREPARED))
-       return ACMERR_UNPREPARED;
-
-    /* Note: the ACMSTREAMHEADER and ACMDRVSTREAMHEADER structs are of same
-     * size. some fields are private to msacm internals, and are exposed
-     * in ACMSTREAMHEADER in the dwReservedDriver array
-     */
-    padsh = (PACMDRVSTREAMHEADER)pash;
-
-    /* check that pointers have not been modified */
-    if (padsh->pbPreparedSrc != padsh->pbSrc ||
-       padsh->cbPreparedSrcLength < padsh->cbSrcLength ||
-       padsh->pbPreparedDst != padsh->pbDst ||
-       padsh->cbPreparedDstLength < padsh->cbDstLength) {
-       return MMSYSERR_INVALPARAM;
-    }  
-
-    padsh->fdwConvert = fdwUnprepare;
-
-    ret = SendDriverMessage(was->pDrv->hDrvr, ACMDM_STREAM_UNPREPARE, (DWORD)&was->drvInst, (DWORD)padsh);
-    if (ret == MMSYSERR_NOERROR || ret == MMSYSERR_NOTSUPPORTED) {
-       ret = MMSYSERR_NOERROR;
-       padsh->fdwStatus &= ~(ACMSTREAMHEADER_STATUSF_DONE|ACMSTREAMHEADER_STATUSF_INQUEUE|ACMSTREAMHEADER_STATUSF_PREPARED);
-    }
-    TRACE("=> (%d)\n", ret);
-    return ret;
-}
diff --git a/libs/loader/com.h b/libs/loader/com.h
deleted file mode 100644 (file)
index a647235..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Modified for use with MPlayer, detailed CVS changelog at
- * http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
- * $Id$
- */
-
-#ifndef AVIFILE_COM_H
-#define AVIFILE_COM_H
-
-#include "config.h"
-
-#ifdef HAVE_STDINT_H
-#include <stdint.h>
-#else
-#include <inttypes.h>
-#endif
-
-/**
- * Internal functions and structures for COM emulation code.
- */
-
-#if !defined(WIN32) || defined(__CYGWIN__) || defined(__MINGW32__)
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void* CoTaskMemAlloc(unsigned long cb);
-void CoTaskMemFree(void* cb);
-
-#ifndef GUID_TYPE
-#define GUID_TYPE
-typedef struct
-{
-    uint32_t f1;
-    uint16_t f2;
-    uint16_t f3;
-    uint8_t  f4[8];
-} GUID;
-#endif
-
-extern const GUID IID_IUnknown;
-extern const GUID IID_IClassFactory;
-
-typedef long (*GETCLASSOBJECT) (GUID* clsid, const GUID* iid, void** ppv);
-int RegisterComClass(const GUID* clsid, GETCLASSOBJECT gcs);
-int UnregisterComClass(const GUID* clsid, GETCLASSOBJECT gcs);
-
-#ifndef STDCALL
-#define STDCALL __attribute__((__stdcall__))
-#endif
-
-struct IUnknown;
-struct IClassFactory;
-struct IUnknown_vt
-{
-    long STDCALL (*QueryInterface)(struct IUnknown* _this, const GUID* iid, void** ppv);
-    long STDCALL (*AddRef)(struct IUnknown* _this) ;
-    long STDCALL (*Release)(struct IUnknown* _this) ;
-} ;
-
-typedef struct IUnknown
-{
-    struct IUnknown_vt* vt;
-} IUnknown;
-
-struct IClassFactory_vt
-{
-    long STDCALL (*QueryInterface)(struct IUnknown* _this, const GUID* iid, void** ppv);
-    long STDCALL (*AddRef)(struct IUnknown* _this) ;
-    long STDCALL (*Release)(struct IUnknown* _this) ;
-    long STDCALL (*CreateInstance)(struct IClassFactory* _this, struct IUnknown* pUnkOuter, const GUID* riid, void** ppvObject);
-};
-
-struct IClassFactory
-{
-    struct IClassFactory_vt* vt;
-};
-
-long CoCreateInstance(GUID* rclsid, struct IUnknown* pUnkOuter,
-                     long dwClsContext, const GUID* riid, void** ppv);
-
-#ifdef __cplusplus
-};
-#endif /* __cplusplus */
-
-#endif /* WIN32 */
-
-#endif /* AVIFILE_COM_H */
diff --git a/libs/loader/driver.c b/libs/loader/driver.c
deleted file mode 100644 (file)
index dde6a1d..0000000
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- * $Id$
- *
- * Copyright 1993, 1994 Martin Ayotte
- * Copyright 1998 Marcus Meissner
- * Copyright 1999 Eric Pouech
- *
- * Originally distributed under LPGL 2.1 (or later) by the Wine project.
- *
- * Modified for use with MPlayer, detailed CVS changelog at
- * http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
- *
- * File now distributed as part of VLC media player with no modifications.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
- */
-
-#include "config.h"
-
-#include <stdio.h>
-#ifdef HAVE_MALLOC_H
-#include <malloc.h>
-#endif
-#include <stdlib.h>
-#ifdef __FreeBSD__
-#include <sys/time.h>
-#endif
-
-#include "win32.h"
-#include "wine/driver.h"
-#include "wine/pe_image.h"
-#include "wine/winreg.h"
-#include "wine/vfw.h"
-#include "registry.h"
-#ifdef WIN32_LOADER
-#include "ldt_keeper.h"
-#endif
-#include "driver.h"
-#ifndef __MINGW32__
-#include "ext.h"
-#endif
-
-#ifndef WIN32_LOADER
-char* def_path=WIN32_PATH;
-#else
-extern char* def_path;
-#endif
-
-#if 1
-
-/*
- * STORE_ALL/REST_ALL seems like an attempt to workaround problems due to
- * WINAPI/no-WINAPI bustage.
- *
- * There should be no need for the STORE_ALL/REST_ALL hack once all
- * function definitions agree with their prototypes (WINAPI-wise) and
- * we make sure, that we do not call these functions without a proper
- * prototype in scope.
- */
-
-#define STORE_ALL
-#define REST_ALL
-#else
-// this asm code is no longer needed
-#define STORE_ALL \
-    __asm__ __volatile__ ( \
-    "push %%ebx\n\t" \
-    "push %%ecx\n\t" \
-    "push %%edx\n\t" \
-    "push %%esi\n\t" \
-    "push %%edi\n\t"::)
-
-#define REST_ALL \
-    __asm__ __volatile__ ( \
-    "pop %%edi\n\t" \
-    "pop %%esi\n\t" \
-    "pop %%edx\n\t" \
-    "pop %%ecx\n\t" \
-    "pop %%ebx\n\t"::)
-#endif
-
-static int needs_free=0;
-void SetCodecPath(const char* path)
-{
-    if(needs_free)free(def_path);
-    if(path==NULL)
-    {
-       def_path=WIN32_PATH;
-       needs_free=0;
-       return;
-    }
-    def_path = (char*) malloc(strlen(path)+1);
-    strcpy(def_path, path);
-    needs_free=1;
-}
-
-static DWORD dwDrvID = 0;
-
-LRESULT WINAPI SendDriverMessage(HDRVR hDriver, UINT message,
-                                LPARAM lParam1, LPARAM lParam2)
-{
-    DRVR* module=(DRVR*)hDriver;
-    int result;
-#ifndef __svr4__
-    char qw[300];
-#endif
-#ifdef DETAILED_OUT
-    printf("SendDriverMessage: driver %X, message %X, arg1 %X, arg2 %X\n", hDriver, message, lParam1, lParam2);
-#endif
-    if (!module || !module->hDriverModule || !module->DriverProc) return -1;
-#ifndef __svr4__
-    __asm__ __volatile__ ("fsave (%0)\n\t": :"r"(&qw));
-#endif
-
-#ifdef WIN32_LOADER
-    Setup_FS_Segment();
-#endif
-
-    STORE_ALL;
-    result=module->DriverProc(module->dwDriverID, hDriver, message, lParam1, lParam2);
-    REST_ALL;
-
-#ifndef __svr4__
-    __asm__ __volatile__ ("frstor (%0)\n\t": :"r"(&qw));
-#endif
-
-#ifdef DETAILED_OUT
-    printf("\t\tResult: %X\n", result);
-#endif
-    return result;
-}
-
-void DrvClose(HDRVR hDriver)
-{
-    if (hDriver)
-    {
-       DRVR* d = (DRVR*)hDriver;
-       if (d->hDriverModule)
-       {
-#ifdef WIN32_LOADER
-           Setup_FS_Segment();
-#endif
-           if (d->DriverProc)
-           {
-               SendDriverMessage(hDriver, DRV_CLOSE, 0, 0);
-               d->dwDriverID = 0;
-               SendDriverMessage(hDriver, DRV_FREE, 0, 0);
-           }
-           FreeLibrary(d->hDriverModule);
-       }
-       free(d);
-    }
-#ifdef WIN32_LOADER
-    CodecRelease();
-#endif
-}
-
-//DrvOpen(LPCSTR lpszDriverName, LPCSTR lpszSectionName, LPARAM lParam2)
-HDRVR DrvOpen(LPARAM lParam2)
-{
-    NPDRVR hDriver;
-    int i;
-    char unknown[0x124];
-    const char* filename = (const char*) ((ICOPEN*) lParam2)->pV1Reserved;
-
-#ifdef MPLAYER
-#ifdef WIN32_LOADER
-    Setup_LDT_Keeper();
-#endif
-    printf("Loading codec DLL: '%s'\n",filename);
-#endif
-
-    hDriver = (NPDRVR) malloc(sizeof(DRVR));
-    if (!hDriver)
-       return ((HDRVR) 0);
-    memset((void*)hDriver, 0, sizeof(DRVR));
-
-#ifdef WIN32_LOADER
-    CodecAlloc();
-    Setup_FS_Segment();
-#endif
-
-    hDriver->hDriverModule = LoadLibraryA(filename);
-    if (!hDriver->hDriverModule)
-    {
-       printf("Can't open library %s\n", filename);
-       DrvClose((HDRVR)hDriver);
-       return ((HDRVR) 0);
-    }
-
-    hDriver->DriverProc = (DRIVERPROC) GetProcAddress(hDriver->hDriverModule,
-                                                     "DriverProc");
-    if (!hDriver->DriverProc)
-    {
-       printf("Library %s is not a valid VfW/ACM codec\n", filename);
-       DrvClose((HDRVR)hDriver);
-       return ((HDRVR) 0);
-    }
-
-    TRACE("DriverProc == %X\n", hDriver->DriverProc);
-    SendDriverMessage((HDRVR)hDriver, DRV_LOAD, 0, 0);
-    TRACE("DRV_LOAD Ok!\n");
-    SendDriverMessage((HDRVR)hDriver, DRV_ENABLE, 0, 0);
-    TRACE("DRV_ENABLE Ok!\n");
-    hDriver->dwDriverID = ++dwDrvID; // generate new id
-
-    // open driver and remmeber proper DriverID
-    hDriver->dwDriverID = SendDriverMessage((HDRVR)hDriver, DRV_OPEN, (LPARAM) unknown, lParam2);
-    TRACE("DRV_OPEN Ok!(%X)\n", hDriver->dwDriverID);
-
-    printf("Loaded DLL driver %s at %x\n", filename, hDriver->hDriverModule);
-    return (HDRVR)hDriver;
-}
diff --git a/libs/loader/driver.h b/libs/loader/driver.h
deleted file mode 100644 (file)
index f7e369d..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Modified for use with MPlayer, detailed CVS changelog at
- * http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
- * $Id$
- */
-
-#ifndef loader_driver_h
-#define        loader_driver_h
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "wine/windef.h"
-#include "wine/driver.h"
-
-void SetCodecPath(const char* path);
-void CodecAlloc(void);
-void CodecRelease(void);
-
-HDRVR DrvOpen(LPARAM lParam2);
-void DrvClose(HDRVR hdrvr);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/libs/loader/ext.c b/libs/loader/ext.c
deleted file mode 100644 (file)
index 3d6b9a7..0000000
+++ /dev/null
@@ -1,645 +0,0 @@
-/********************************************************
- *
- *
- *      Stub functions for Wine module
- *
- *
- ********************************************************/
-
-/*
- * Modified for use with MPlayer, detailed CVS changelog at
- * http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
- * $Id$
- */
-
-#include "config.h"
-#include <stdio.h>
-#include <stdlib.h>
-#ifdef HAVE_MALLOC_H
-#include <malloc.h>
-#endif
-#include <unistd.h>
-#include <sys/mman.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <string.h>
-#include <stdarg.h>
-#include <ctype.h>
-
-#include "wine/windef.h"
-#include "wine/winbase.h"
-#include "wine/debugtools.h"
-#include "wine/heap.h"
-#include "ext.h"
-
-#if 0
-//REMOVE SIMPLIFY
-static void* mymalloc(unsigned int size)
-{
-    printf("malloc %d\n", size);
-    return malloc(size);
-}
-
-#undef malloc
-#define malloc mymalloc
-#endif
-
-int dbg_header_err( const char *dbg_channel, const char *func )
-{
-    return 0;
-}
-int dbg_header_warn( const char *dbg_channel, const char *func )
-{
-    return 0;
-}
-int dbg_header_fixme( const char *dbg_channel, const char *func )
-{
-    return 0;
-}
-int dbg_header_trace( const char *dbg_channel, const char *func )
-{
-    return 0;
-}
-int dbg_vprintf( const char *format, va_list args )
-{
-    return 0;
-}
-int __vprintf( const char *format, ... )
-{
-#ifdef DETAILED_OUT
-    va_list va;
-    va_start(va, format);
-    vprintf(format, va);
-    va_end(va);
-#endif
-    return 0;
-}
-
-HANDLE WINAPI GetProcessHeap(void)
-{
-    return 1;
-}
-
-LPVOID WINAPI HeapAlloc(HANDLE heap, DWORD flags, DWORD size)
-{
-    static int i = 5;
-    void* m = (flags & 0x8) ? calloc(size, 1) : malloc(size);
-    //printf("HeapAlloc %p  %d  (%d)\n", m, size, flags);
-    //if (--i == 0)
-    //    abort();
-    return m;
-}
-
-WIN_BOOL WINAPI HeapFree(HANDLE heap, DWORD flags, LPVOID mem)
-{
-    free( mem );
-    //printf("HeapFree  %p\n", mem);
-    //if (!mem)
-    //    abort();
-    return 1;
-}
-
-static int last_error;
-
-DWORD WINAPI GetLastError(void)
-{
-    return last_error;
-}
-
-VOID WINAPI SetLastError(DWORD error)
-{
-    last_error=error;
-}
-
-WIN_BOOL WINAPI ReadFile(HANDLE handle, LPVOID mem, DWORD size, LPDWORD result, LPOVERLAPPED flags)
-{
-    *result=read(handle, mem, size);
-    return *result;
-}
-INT WINAPI lstrcmpiA(LPCSTR c1, LPCSTR c2)
-{
-    return strcasecmp(c1,c2);
-}
-LPSTR WINAPI lstrcpynA(LPSTR dest, LPCSTR src, INT num)
-{
-    return strncpy(dest,src,num);
-}
-INT WINAPI lstrlenA(LPCSTR s)
-{
-    return strlen(s);
-}
-INT WINAPI lstrlenW(LPCWSTR s)
-{
-    int l;
-    if(!s)
-       return 0;
-    l=0;
-    while(s[l])
-       l++;
-     return l;
-}
-LPSTR WINAPI lstrcpynWtoA(LPSTR dest, LPCWSTR src, INT count)
-{
-    LPSTR result = dest;
-    int moved=0;
-    if((dest==NULL) || (src==NULL))
-       return 0;
-    while(moved<count)
-    {
-        *dest=*src;
-       moved++;
-       if(*src==0)
-           break;
-       src++;
-       dest++;
-    }
-    return result;
-}
-/* i stands here for ignore case! */
-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) & 0xff00) || toupper((char)*s1) != toupper((char)*s2))
-       {
-
-           if(*s1<*s2)
-               return -1;
-           else
-               if(*s1>*s2)
-                   return 1;
-               else
-                   if(*s1==0)
-                       return 0;
-       }
-       s1++;
-       s2++;
-       n--;
-    }
-    return 0;
-}
-
-WIN_BOOL WINAPI IsBadReadPtr(LPCVOID data, UINT size)
-{
-    if(size==0)
-       return 0;
-    if(data==NULL)
-        return 1;
-    return 0;
-}
-LPSTR HEAP_strdupA(HANDLE heap, DWORD flags, LPCSTR string)
-{
-//    return strdup(string);
-    char* answ = (char*) malloc(strlen(string) + 1);
-    strcpy(answ, string);
-    return answ;
-}
-LPWSTR HEAP_strdupAtoW(HANDLE heap, DWORD flags, LPCSTR string)
-{
-    int size, i;
-    WCHAR* answer;
-    if(string==NULL)
-       return 0;
-    size=strlen(string);
-    answer = (WCHAR*) malloc(sizeof(WCHAR) * (size + 1));
-    for(i=0; i<=size; i++)
-       answer[i]=(short)string[i];
-    return answer;
-}
-LPSTR HEAP_strdupWtoA(HANDLE heap, DWORD flags, LPCWSTR string)
-{
-    int size, i;
-    char* answer;
-    if(string==NULL)
-       return 0;
-    size=0;
-    while(string[size])
-       size++;
-    answer = (char*) malloc(size + 2);
-    for(i=0; i<=size; i++)
-       answer[i]=(char)string[i];
-    return answer;
-}
-
-/***********************************************************************
- *           FILE_dommap
- */
-
-//#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,
-                    int prot, int flags )
-{
-    int fd = -1;
-    int pos;
-    LPVOID ret;
-
-    if (size_high || offset_high)
-        printf("offsets larger than 4Gb not supported\n");
-
-    if (unix_handle == -1)
-    {
-#ifdef MAP_ANON
-//     printf("Anonymous\n");
-        flags |= MAP_ANON;
-#else
-        static int fdzero = -1;
-
-        if (fdzero == -1)
-        {
-            if ((fdzero = open( "/dev/zero", O_RDONLY )) == -1)
-            {
-               perror( "Cannot open /dev/zero for READ. Check permissions! error: " );
-                exit(1);
-            }
-        }
-        fd = fdzero;
-#endif  /* MAP_ANON */
-       /* Linux EINVAL's on us if we don't pass MAP_PRIVATE to an anon mmap */
-#ifdef MAP_SHARED
-       flags &= ~MAP_SHARED;
-#endif
-#ifdef MAP_PRIVATE
-       flags |= MAP_PRIVATE;
-#endif
-    }
-    else fd = unix_handle;
-//    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)
-    if ((ret = mmap( start, size_low, prot,
-                     MAP_PRIVATE | MAP_FIXED, fd, offset_low )) != (LPVOID)-1)
-    {
-//         printf("address %08x\n", *(int*)ret);
-//     printf("%x\n", ret);
-           return ret;
-    }
-
-//    printf("mmap %d\n", errno);
-
-    /* mmap() failed; if this is because the file offset is not    */
-    /* page-aligned (EINVAL), or because the underlying filesystem */
-    /* does not support mmap() (ENOEXEC), we do it by hand.        */
-
-    if (unix_handle == -1) return ret;
-    if ((errno != ENOEXEC) && (errno != EINVAL)) return ret;
-    if (prot & PROT_WRITE)
-    {
-        /* We cannot fake shared write mappings */
-#ifdef MAP_SHARED
-       if (flags & MAP_SHARED) return ret;
-#endif
-#ifdef MAP_PRIVATE
-       if (!(flags & MAP_PRIVATE)) return ret;
-#endif
-    }
-/*    printf( "FILE_mmap: mmap failed (%d), faking it\n", errno );*/
-    /* Reserve the memory with an anonymous mmap */
-    ret = FILE_dommap( -1, start, size_high, size_low, 0, 0,
-                       PROT_READ | PROT_WRITE, flags );
-    if (ret == (LPVOID)-1)
-//    {
-//     perror(
-        return ret;
-    /* Now read in the file */
-    if ((pos = lseek( fd, offset_low, SEEK_SET )) == -1)
-    {
-        FILE_munmap( ret, size_high, size_low );
-//     printf("lseek\n");
-        return (LPVOID)-1;
-    }
-    read( fd, ret, size_low );
-    lseek( fd, pos, SEEK_SET );  /* Restore the file pointer */
-    mprotect( ret, size_low, prot );  /* Set the right protection */
-//    printf("address %08x\n", *(int*)ret);
-    return ret;
-}
-
-
-/***********************************************************************
- *           FILE_munmap
- */
-int FILE_munmap( LPVOID start, DWORD size_high, DWORD size_low )
-{
-    if (size_high)
-      printf("offsets larger than 4Gb not supported\n");
-    return munmap( start, size_low );
-}
-static int mapping_size=0;
-
-struct file_mapping_s;
-typedef struct file_mapping_s
-{
-    int mapping_size;
-    char* name;
-    LPVOID handle;
-    struct file_mapping_s* next;
-    struct file_mapping_s* prev;
-}file_mapping;
-static file_mapping* fm=0;
-
-
-
-#define        PAGE_NOACCESS           0x01
-#define        PAGE_READONLY           0x02
-#define        PAGE_READWRITE          0x04
-#define        PAGE_WRITECOPY          0x08
-#define        PAGE_EXECUTE            0x10
-#define        PAGE_EXECUTE_READ       0x20
-#define        PAGE_EXECUTE_READWRITE  0x40
-#define        PAGE_EXECUTE_WRITECOPY  0x80
-#define        PAGE_GUARD              0x100
-#define        PAGE_NOCACHE            0x200
-
-HANDLE WINAPI CreateFileMappingA(HANDLE handle, LPSECURITY_ATTRIBUTES lpAttr,
-                                DWORD flProtect,
-                                DWORD dwMaxHigh, DWORD dwMaxLow,
-                                LPCSTR name)
-{
-    int hFile = (int)handle;
-    unsigned int len;
-    LPVOID answer;
-    int anon=0;
-    int mmap_access=0;
-    if(hFile<0)
-    {
-       anon=1;
-       hFile=open("/dev/zero", O_RDWR);
-       if(hFile<0){
-           perror( "Cannot open /dev/zero for READ+WRITE. Check permissions! error: " );
-           return 0;
-       }
-    }
-    if(!anon)
-    {
-        len=lseek(hFile, 0, SEEK_END);
-       lseek(hFile, 0, SEEK_SET);
-    }
-    else len=dwMaxLow;
-
-    if(flProtect & PAGE_READONLY)
-       mmap_access |=PROT_READ;
-    else
-       mmap_access |=PROT_READ|PROT_WRITE;
-
-    answer=mmap(NULL, len, mmap_access, MAP_PRIVATE, hFile, 0);
-    if(anon)
-        close(hFile);
-    if(answer!=(LPVOID)-1)
-    {
-       if(fm==NULL)
-       {
-           fm = (file_mapping*) malloc(sizeof(file_mapping));
-           fm->prev=NULL;
-       }
-       else
-       {
-           fm->next = (file_mapping*) malloc(sizeof(file_mapping));
-           fm->next->prev=fm;
-           fm=fm->next;
-       }
-       fm->next=NULL;
-       fm->handle=answer;
-       if(name)
-       {
-           fm->name = (char*) malloc(strlen(name)+1);
-           strcpy(fm->name, name);
-       }
-       else
-           fm->name=NULL;
-       fm->mapping_size=len;
-
-       if(anon)
-           close(hFile);
-       return (HANDLE)answer;
-    }
-    return (HANDLE)0;
-}
-WIN_BOOL WINAPI UnmapViewOfFile(LPVOID handle)
-{
-    file_mapping* p;
-    int result;
-    if(fm==NULL)
-       return 0;
-    for(p=fm; p; p=p->next)
-    {
-       if(p->handle==handle)
-       {
-           result=munmap((void*)handle, p->mapping_size);
-           if(p->next)p->next->prev=p->prev;
-           if(p->prev)p->prev->next=p->next;
-            free(p->name);
-           if(p==fm)
-               fm=p->prev;
-           free(p);
-           return result;
-       }
-    }
-    return 0;
-}
-//static int va_size=0;
-struct virt_alloc_s;
-typedef struct virt_alloc_s
-{
-    int mapping_size;
-    char* address;
-    struct virt_alloc_s* next;
-    struct virt_alloc_s* prev;
-    int state;
-}virt_alloc;
-static virt_alloc* vm=0;
-#define MEM_COMMIT              0x00001000
-#define MEM_RESERVE             0x00002000
-
-LPVOID WINAPI VirtualAlloc(LPVOID address, DWORD size, DWORD type,  DWORD protection)
-{
-    void* answer;
-    int fd;
-    long pgsz;
-
-    //printf("VirtualAlloc(0x%08X, %u, 0x%08X, 0x%08X)\n", (unsigned)address, size, type, protection);
-
-    if ((type&(MEM_RESERVE|MEM_COMMIT)) == 0) return NULL;
-
-    fd=open("/dev/zero", O_RDWR);
-    if(fd<0){
-        perror( "Cannot open /dev/zero for READ+WRITE. Check permissions! error: " );
-       return NULL;
-    }
-
-    if (type&MEM_RESERVE && (unsigned)address&0xffff) {
-       size += (unsigned)address&0xffff;
-       address = (unsigned)address&~0xffff;
-    }
-    pgsz = sysconf(_SC_PAGESIZE);
-    if (type&MEM_COMMIT && (unsigned)address%pgsz) {
-       size += (unsigned)address%pgsz;
-       address -= (unsigned)address%pgsz;
-    }
-
-    if (type&MEM_RESERVE && size<0x10000) size = 0x10000;
-    if (size%pgsz) size += pgsz - size%pgsz;
-
-    if(address!=NULL)
-    {
-    //check whether we can allow to allocate this
-        virt_alloc* str=vm;
-        while(str)
-        {
-           if((unsigned)address>=(unsigned)str->address+str->mapping_size)
-           {
-               str=str->prev;
-               continue;
-           }
-           if((unsigned)address+size<=(unsigned)str->address)
-           {
-               str=str->prev;
-               continue;
-           }
-           if(str->state==0)
-           {
-#warning FIXME
-               if(   ((unsigned)address >= (unsigned)str->address)
-                  && ((unsigned)address+size<=(unsigned)str->address+str->mapping_size)
-                  && (type & MEM_COMMIT))
-               {
-                   close(fd);
-                   return address; //returning previously reserved memory
-               }
-               //printf(" VirtualAlloc(...) does not commit or not entirely within reserved, and\n");
-           }
-           /*printf(" VirtualAlloc(...) (0x%08X, %u) overlaps with (0x%08X, %u, state=%d)\n",
-                  (unsigned)address, size, (unsigned)str->address, str->mapping_size, str->state);*/
-           close(fd);
-           return NULL;
-       }
-    }
-
-    answer=mmap(address, size, PROT_READ | PROT_WRITE | PROT_EXEC,
-               MAP_PRIVATE, fd, 0);
-//    answer=FILE_dommap(-1, address, 0, size, 0, 0,
-//     PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE);
-    close(fd);
-    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
-          a successful call but an overlapping or non-allocated region.  */
-       munmap(answer, size);
-       answer = (void *) -1;
-       errno = EINVAL;
-       //printf(" VirtualAlloc(...) cannot satisfy requested address but address=NULL would work.\n");
-    }
-    if(answer==(void*)-1)
-    {
-       /*printf(" VirtualAlloc(...) mmap(0x%08X, %u, ...) failed with errno=%d (\"%s\")\n",
-              (unsigned)address, size, errno, strerror(errno));*/
-       return NULL;
-    }
-    else
-    {
-       virt_alloc *new_vm = (virt_alloc*) malloc(sizeof(virt_alloc));
-       new_vm->mapping_size=size;
-       new_vm->address=(char*)answer;
-        new_vm->prev=vm;
-       if(type == MEM_RESERVE)
-           new_vm->state=0;
-       else
-           new_vm->state=1;
-       if(vm)
-           vm->next=new_vm;
-       vm=new_vm;
-       vm->next=0;
-       //if(va_size!=0)
-       //    printf("Multiple VirtualAlloc!\n");
-       //printf(" VirtualAlloc(...) provides (0x%08X, %u)\n", (unsigned)answer, size);
-        return answer;
-    }
-}
-
-WIN_BOOL WINAPI VirtualFree(LPVOID  address, SIZE_T dwSize, DWORD dwFreeType)//not sure
-{
-    virt_alloc* str=vm;
-    int answer;
-
-    //printf("VirtualFree(0x%08X, %d, 0x%08X)\n", (unsigned)address, dwSize, dwFreeType);
-    while(str)
-    {
-       if(address!=str->address)
-       {
-           str=str->prev;
-           continue;
-       }
-       //printf(" VirtualFree(...) munmap(0x%08X, %d)\n", (unsigned)str->address, str->mapping_size);
-       answer=munmap(str->address, str->mapping_size);
-       if(str->next)str->next->prev=str->prev;
-       if(str->prev)str->prev->next=str->next;
-       if(vm==str)vm=str->prev;
-       free(str);
-       return 0;
-    }
-    return -1;
-}
-
-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==NULL)
-       return 0;
-    if ((srclen==-1)&&(dest==NULL)) return 0;
-    if(srclen==-1){srclen=0; while(src[srclen++]);}
-//    for(i=0; i<srclen; i++)
-//     printf("%c", src[i]);
-//    printf("\n");
-    if(dest==NULL)
-    {
-    for(i=0; i<srclen; i++)
-    {
-       src++;
-       if(*src==0)
-           return i+1;
-    }
-       return srclen+1;
-    }
-    if(used_defch)
-       *used_defch=0;
-    for(i=0; i<min(srclen, destlen); i++)
-    {
-       *dest=(char)*src;
-       dest++;
-       src++;
-       if(*src==0)
-           return i+1;
-    }
-    return min(srclen, destlen);
-}
-INT WINAPI MultiByteToWideChar(UINT codepage,DWORD flags, LPCSTR src, INT srclen,
-    LPWSTR dest, INT destlen)
-{
-    return 0;
-}
-HANDLE WINAPI OpenFileMappingA(DWORD access, WIN_BOOL prot, LPCSTR name)
-{
-    file_mapping* p;
-    if(fm==NULL)
-       return (HANDLE)0;
-    if(name==NULL)
-       return (HANDLE)0;
-    for(p=fm; p; p=p->prev)
-    {
-       if(p->name==NULL)
-           continue;
-       if(strcmp(p->name, name)==0)
-           return (HANDLE)p->handle;
-    }
-    return 0;
-}
diff --git a/libs/loader/ext.h b/libs/loader/ext.h
deleted file mode 100644 (file)
index 668219f..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Modified for use with MPlayer, detailed CVS changelog at
- * http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
- * $Id$
- */
-
-#ifndef loader_ext_h
-#define loader_ext_h
-
-#include "wine/windef.h"
-
-extern LPVOID FILE_dommap( int unix_handle, LPVOID start,
-                          DWORD size_high, DWORD size_low,
-                          DWORD offset_high, DWORD offset_low,
-                          int prot, int flags );
-extern int FILE_munmap( LPVOID start, DWORD size_high, DWORD size_low );
-extern int wcsnicmp(const unsigned short* s1, const unsigned short* s2, int n);
-extern int __vprintf( const char *format, ... );
-
-#endif
diff --git a/libs/loader/kludge.c b/libs/loader/kludge.c
deleted file mode 100644 (file)
index a22af0a..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*****************************************************************************
- * kludge.c
- *****************************************************************************
- * Copyright (C) 2005 Rémi Denis-Courmont
- * $Id$
- *
- * Authors: Rémi Denis-Courmont <rem # videolan.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
- *****************************************************************************/
-
-int dbg_printf(const char *format, ...)
-{
-       return 0;
-}
diff --git a/libs/loader/ldt_keeper.c b/libs/loader/ldt_keeper.c
deleted file mode 100644 (file)
index 4bf5d04..0000000
+++ /dev/null
@@ -1,308 +0,0 @@
-/*
- * $Id$
- *
- * Copyright 1993 Robert J. Amstadt
- * Copyright 1995 Alexandre Julliard
- *
- * Originally distributed under LPGL 2.1 (or later) by the Wine project.
- *
- * Modified for use with MPlayer, detailed CVS changelog at
- * http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
- *
- * File now distributed as part of VLC media player with no modifications.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
- */
-
-/**
- * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- * This file MUST be in main library because LDT must
- * be modified before program creates first thread
- * - avifile includes this file from C++ code
- * and initializes it at the start of player!
- * it might sound like a hack and it really is - but
- * as aviplay is deconding video with more than just one
- * thread currently it's necessary to do it this way
- * this might change in the future
- */
-
-/* applied some modification to make make our xine friend more happy */
-
-#include "ldt_keeper.h"
-
-#include <string.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <sys/mman.h>
-#include <sys/types.h>
-#include <stdio.h>
-#include <unistd.h>
-#ifdef __linux__
-#include <asm/unistd.h>
-#include <asm/ldt.h>
-// 2.5.xx+ calls this user_desc:
-#include <linux/version.h>
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,47)
-#define modify_ldt_ldt_s user_desc
-#endif
-/* prototype it here, so we won't depend on kernel headers */
-#ifdef  __cplusplus
-extern "C" {
-#endif
-/// declare modify_ldt with the _syscall3 macro for older glibcs
-#if defined(__GLIBC__) &&  (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ == 0))
-_syscall3( int, modify_ldt, int, func, void *, ptr, unsigned long, bytecount );
-#else
-int modify_ldt(int func, void *ptr, unsigned long bytecount);
-#endif
-#ifdef  __cplusplus
-}
-#endif
-#else
-#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
-#include <machine/segments.h>
-#include <machine/sysarch.h>
-#endif
-
-#ifdef __svr4__
-#include <sys/segment.h>
-#include <sys/sysi86.h>
-
-/* solaris x86: add missing prototype for sysi86() */
-#ifdef  __cplusplus
-extern "C" {
-#endif
-int sysi86(int, void*);
-#ifdef  __cplusplus
-}
-#endif
-
-#ifndef NUMSYSLDTS             /* SunOS 2.5.1 does not define NUMSYSLDTS */
-#define NUMSYSLDTS     6       /* Let's hope the SunOS 5.8 value is OK */
-#endif
-
-#define       TEB_SEL_IDX     NUMSYSLDTS
-#endif
-
-#define LDT_ENTRIES     8192
-#define LDT_ENTRY_SIZE  8
-#pragma pack(4)
-struct modify_ldt_ldt_s {
-        unsigned int  entry_number;
-        unsigned long base_addr;
-        unsigned int  limit;
-        unsigned int  seg_32bit:1;
-        unsigned int  contents:2;
-        unsigned int  read_exec_only:1;
-        unsigned int  limit_in_pages:1;
-        unsigned int  seg_not_present:1;
-        unsigned int  useable:1;
-};
-
-#define MODIFY_LDT_CONTENTS_DATA        0
-#define MODIFY_LDT_CONTENTS_STACK       1
-#define MODIFY_LDT_CONTENTS_CODE        2
-#endif
-
-
-/* user level (privilege level: 3) ldt (1<<2) segment selector */
-#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)
-#define       TEB_SEL_IDX     LDT_AUTO_ALLOC
-#endif
-
-#ifndef       TEB_SEL_IDX
-#define       TEB_SEL_IDX     17
-#endif
-
-static unsigned int fs_ldt = TEB_SEL_IDX;
-
-
-/**
- * here is a small logical problem with Restore for multithreaded programs -
- * in C++ we use static class for this...
- */
-
-#ifdef __cplusplus
-extern "C"
-#endif
-void Setup_FS_Segment(void)
-{
-    unsigned int ldt_desc = LDT_SEL(fs_ldt);
-
-    __asm__ __volatile__(
-       "movl %0,%%eax; movw %%ax, %%fs" : : "r" (ldt_desc)
-       :"eax"
-    );
-}
-
-/* we don't need this - use modify_ldt instead */
-#if 0
-#ifdef __linux__
-/* XXX: why is this routine from libc redefined here? */
-/* NOTE: the redefined version ignores the count param, count is hardcoded as 16 */
-static int LDT_Modify( 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"(16)//sizeof(*ptr) from kernel point of view
-                         :"esi"     );
-#else
-    __asm__ __volatile__("int $0x80"
-                        : "=a" (res)
-                        : "0" (__NR_modify_ldt),
-                        "b" (func),
-                        "c" (ptr),
-                        "d"(16)
-                        :"esi");
-#endif  /* __PIC__ */
-    if (res >= 0) return res;
-    errno = -res;
-    return -1;
-}
-#endif
-#endif
-
-#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
-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;
-}
-#endif
-
-void* fs_seg=0;
-
-ldt_fs_t* Setup_LDT_Keeper(void)
-{
-    struct modify_ldt_ldt_s array;
-    int ret;
-    ldt_fs_t* ldt_fs = (ldt_fs_t*) malloc(sizeof(ldt_fs_t));
-
-    if (!ldt_fs)
-       return NULL;
-
-    ldt_fs->fd = open("/dev/zero", O_RDWR);
-    if(ldt_fs->fd<0){
-        perror( "Cannot open /dev/zero for READ+WRITE. Check permissions! error: ");
-        free(ldt_fs);
-       return NULL;
-    }
-    fs_seg=
-    ldt_fs->fs_seg = mmap(NULL, getpagesize(), PROT_READ | PROT_WRITE, MAP_PRIVATE,
-                         ldt_fs->fd, 0);
-    if (ldt_fs->fs_seg == (void*)-1)
-    {
-       perror("ERROR: Couldn't allocate memory for fs segment");
-        close(ldt_fs->fd);
-        free(ldt_fs);
-       return NULL;
-    }
-    *(void**)((char*)ldt_fs->fs_seg+0x18) = ldt_fs->fs_seg;
-    memset(&array, 0, sizeof(array));
-    array.base_addr=(int)ldt_fs->fs_seg;
-    array.entry_number=TEB_SEL_IDX;
-    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=LDT_Modify(0x1, &array, sizeof(struct modify_ldt_ldt_s));
-    ret=modify_ldt(0x1, &array, sizeof(struct modify_ldt_ldt_s));
-    if(ret<0)
-    {
-       perror("install_fs");
-       printf("Couldn't install fs segment, expect segfault\n");
-    }
-#endif /*linux*/
-
-#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
-    {
-        unsigned long d[2];
-
-        LDT_EntryToBytes( d, &array );
-#if defined(__FreeBSD__) && defined(LDT_AUTO_ALLOC)
-        ret = i386_set_ldt(LDT_AUTO_ALLOC, (union descriptor *)d, 1);
-        array.entry_number = ret;
-        fs_ldt = ret;
-#else
-        ret = i386_set_ldt(array.entry_number, (union descriptor *)d, 1);
-#endif
-        if (ret < 0)
-        {
-            perror("install_fs");
-           printf("Couldn't install fs segment, expect segfault\n");
-            printf("Did you reconfigure the kernel with \"options USER_LDT\"?\n");
-        }
-    }
-#endif  /* __NetBSD__ || __FreeBSD__ || __OpenBSD__ || __DragonFly__ */
-
-#if defined(__svr4__)
-    {
-       struct ssd ssd;
-       ssd.sel = LDT_SEL(TEB_SEL_IDX);
-       ssd.bo = array.base_addr;
-       ssd.ls = array.limit - array.base_addr;
-       ssd.acc1 = ((array.read_exec_only == 0) << 1) |
-           (array.contents << 2) |
-           0xf0;   /* P(resent) | DPL3 | S */
-       ssd.acc2 = 0x4;   /* byte limit, 32-bit segment */
-       if (sysi86(SI86DSCR, &ssd) < 0) {
-           perror("sysi86(SI86DSCR)");
-           printf("Couldn't install fs segment, expect segfault\n");
-       }
-    }
-#endif
-
-    Setup_FS_Segment();
-
-    ldt_fs->prev_struct = (char*)malloc(sizeof(char) * 8);
-    *(void**)array.base_addr = ldt_fs->prev_struct;
-
-    return ldt_fs;
-}
-
-void Restore_LDT_Keeper(ldt_fs_t* ldt_fs)
-{
-    if (ldt_fs == NULL || ldt_fs->fs_seg == NULL)
-       return;
-    free(ldt_fs->prev_struct);
-    munmap((char*)ldt_fs->fs_seg, getpagesize());
-    ldt_fs->fs_seg = 0;
-    close(ldt_fs->fd);
-    free(ldt_fs);
-}
diff --git a/libs/loader/ldt_keeper.h b/libs/loader/ldt_keeper.h
deleted file mode 100644 (file)
index d36ebb8..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-#ifndef LDT_KEEPER_H
-#define LDT_KEEPER_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-typedef struct {
-  void* fs_seg;
-  char* prev_struct;
-  int fd;
-} ldt_fs_t;
-
-void Setup_FS_Segment(void);
-ldt_fs_t* Setup_LDT_Keeper(void);
-void Restore_LDT_Keeper(ldt_fs_t* ldt_fs);
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* LDT_KEEPER_H */
diff --git a/libs/loader/loader.h b/libs/loader/loader.h
deleted file mode 100644 (file)
index ec29983..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Win32 binary loader interface
- * $Id$
- *
- * Copyright 2000 Eugene Kuznetsov (divx@euro.ru)
- * Copyright (C) the Wine project
- *
- * Originally distributed under LPGL 2.1 (or later) by the Wine project.
- *
- * Modified for use with MPlayer, detailed CVS changelog at
- * http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
- *
- * File now distributed as part of VLC media player with no modifications.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
- */
-
-#ifndef _LOADER_H
-#define _LOADER_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "wine/windef.h"
-#include "wine/driver.h"
-#include "wine/mmreg.h"
-#include "wine/vfw.h"
-#include "wine/msacm.h"
-
-unsigned int _GetPrivateProfileIntA(const char* appname, const char* keyname, int default_value, const char* filename);
-int _GetPrivateProfileStringA(const char* appname, const char* keyname,
-       const char* def_val, char* dest, unsigned int len, const char* filename);
-int _WritePrivateProfileStringA(const char* appname, const char* keyname,
-       const char* string, const char* filename);
-
-INT WINAPI LoadStringA( HINSTANCE instance, UINT resource_id,
-                            LPSTR buffer, INT buflen );
-
-#ifdef __cplusplus
-}
-#endif
-#endif /* __LOADER_H */
-
diff --git a/libs/loader/module.c b/libs/loader/module.c
deleted file mode 100644 (file)
index 635f4b5..0000000
+++ /dev/null
@@ -1,1106 +0,0 @@
-/*
- * Modules
- *
- * $Id$
- *
- * Copyright 1995 Alexandre Julliard
- *
- * Originally distributed under LPGL 2.1 (or later) by the Wine project.
- *
- * Modified for use with MPlayer, detailed CVS changelog at
- * http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
- *
- * File now distributed as part of VLC media player with no modifications.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
- */
-
-// define for quicktime calls debugging and/or MacOS-level emulation:
-#define EMU_QTX_API
-
-// define for quicktime debugging (verbose logging):
-//#define DEBUG_QTX_API
-
-#include "config.h"
-
-#include <assert.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/mman.h>
-#include <inttypes.h>
-
-#include "wine/windef.h"
-#include "wine/winerror.h"
-#include "wine/heap.h"
-#include "wine/module.h"
-#include "wine/pe_image.h"
-#include "wine/debugtools.h"
-
-#undef HAVE_LIBDL
-
-#ifdef HAVE_LIBDL
-#include <dlfcn.h>
-#include "wine/elfdll.h"
-#endif
-#include "win32.h"
-#include "driver.h"
-
-#ifdef EMU_QTX_API
-#include "wrapper.h"
-static int report_func(void *stack_base, int stack_size, reg386_t *reg, uint32_t *flags);
-static int report_func_ret(void *stack_base, int stack_size, reg386_t *reg, uint32_t *flags);
-#endif
-
-//#undef TRACE
-//#define TRACE printf
-
-//WINE_MODREF *local_wm=NULL;
-modref_list* local_wm=NULL;
-
-HANDLE SegptrHeap;
-
-WINE_MODREF* MODULE_FindModule(LPCSTR m)
-{
-    modref_list* list=local_wm;
-    TRACE("FindModule: Module %s request\n", m);
-    if(list==NULL)
-       return NULL;
-//    while(strcmp(m, list->wm->filename))
-    while(!strstr(list->wm->filename, m))
-    {
-       TRACE("%s: %x\n", list->wm->filename, list->wm->module);
-       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)
-{
-    modref_list* list=local_wm;
-    if(list==NULL)
-       return;
-    if(mod==NULL)
-       return;
-    if((list->prev==NULL)&&(list->next==NULL))
-    {
-       free(list);
-       local_wm=NULL;
-//     uninstall_fs();
-       return;
-    }
-    for(;list;list=list->prev)
-    {
-       if(list->wm==mod)
-       {
-           if(list->prev)
-               list->prev->next=list->next;
-           if(list->next)
-               list->next->prev=list->prev;
-           if(list==local_wm)
-               local_wm=list->prev;
-           free(list);
-           return;
-       }
-    }
-
-}
-
-WINE_MODREF *MODULE32_LookupHMODULE(HMODULE m)
-{
-    modref_list* list=local_wm;
-    TRACE("LookupHMODULE: Module %X request\n", m);
-    if(list==NULL)
-    {
-       TRACE("LookupHMODULE failed\n");
-       return NULL;
-    }
-    while(m!=list->wm->module)
-    {
-//      printf("Checking list %X wm %X module %X\n",
-//     list, list->wm, list->wm->module);
-       list=list->prev;
-       if(list==NULL)
-       {
-           TRACE("LookupHMODULE failed\n");
-           return NULL;
-       }
-    }
-    TRACE("LookupHMODULE hit %p\n", list->wm);
-    return list->wm;
-}
-
-/*************************************************************************
- *             MODULE_InitDll
- */
-static WIN_BOOL MODULE_InitDll( WINE_MODREF *wm, DWORD type, LPVOID lpReserved )
-{
-    WIN_BOOL retv = TRUE;
-
-    static LPCSTR typeName[] = { "PROCESS_DETACH", "PROCESS_ATTACH",
-                                 "THREAD_ATTACH", "THREAD_DETACH" };
-    assert( wm );
-
-
-    /* Skip calls for modules loaded with special load flags */
-
-    if (    ( wm->flags & WINE_MODREF_DONT_RESOLVE_REFS )
-         || ( wm->flags & WINE_MODREF_LOAD_AS_DATAFILE ) )
-        return TRUE;
-
-
-    TRACE("(%s,%s,%p) - CALL\n", wm->modname, typeName[type], lpReserved );
-
-    /* Call the initialization routine */
-    switch ( wm->type )
-    {
-    case MODULE32_PE:
-        retv = PE_InitDLL( wm, type, lpReserved );
-        break;
-
-    case MODULE32_ELF:
-        /* no need to do that, dlopen() already does */
-        break;
-
-    default:
-        ERR("wine_modref type %d not handled.\n", wm->type );
-        retv = FALSE;
-        break;
-    }
-
-    /* The state of the module list may have changed due to the call
-       to PE_InitDLL. We cannot assume that this module has not been
-       deleted.  */
-    TRACE("(%p,%s,%p) - RETURN %d\n", wm, typeName[type], lpReserved, retv );
-
-    return retv;
-}
-
-/*************************************************************************
- *             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
- *
- * (Note that this routine can be recursively entered not only directly
- *  from itself, but also via LoadLibrary from one of the called initialization
- *  routines.)
- *
- * 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
- * 'hidden' dependencies created by modules calling LoadLibrary in their
- * attach notification routine.
- *
- * The strategy is rather simple: we move a WINE_MODREF to the head of the
- * list after the attach notification has returned.  This implies that the
- * detach notifications are called in the reverse of the sequence the attach
- * notifications *returned*.
- *
- * NOTE: Assumes that the process critical section is held!
- *
- */
-static WIN_BOOL MODULE_DllProcessAttach( WINE_MODREF *wm, LPVOID lpReserved )
-{
-    WIN_BOOL retv = TRUE;
-    int i;
-    assert( wm );
-
-    /* prevent infinite recursion in case of cyclical dependencies */
-    if (    ( wm->flags & WINE_MODREF_MARKER )
-         || ( wm->flags & WINE_MODREF_PROCESS_ATTACHED ) )
-        return retv;
-
-    TRACE("(%s,%p) - START\n", wm->modname, lpReserved );
-
-    /* Tag current MODREF to prevent recursive loop */
-    wm->flags |= WINE_MODREF_MARKER;
-
-    /* Recursively attach all DLLs this one depends on */
-/*    for ( i = 0; retv && i < wm->nDeps; i++ )
-        if ( wm->deps[i] )
-            retv = MODULE_DllProcessAttach( wm->deps[i], lpReserved );
-*/
-    /* Call DLL entry point */
-
-    //local_wm=wm;
-    if(local_wm)
-    {
-       local_wm->next = (modref_list*) 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 = (modref_list*)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 );
-        if ( retv )
-            wm->flags |= WINE_MODREF_PROCESS_ATTACHED;
-    }
-
-
-    TRACE("(%s,%p) - END\n", wm->modname, lpReserved );
-
-    return retv;
-}
-
-/*************************************************************************
- *             MODULE_DllProcessDetach
- *
- * 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.
- */
-static void MODULE_DllProcessDetach( WINE_MODREF* wm, WIN_BOOL bForceDetach, LPVOID lpReserved )
-{
-    //    WINE_MODREF *wm=local_wm;
-    modref_list* l = local_wm;
-    wm->flags &= ~WINE_MODREF_PROCESS_ATTACHED;
-    MODULE_InitDll( wm, DLL_PROCESS_DETACH, lpReserved );
-/*    while (l)
-    {
-       modref_list* f = l;
-       l = l->next;
-       free(f);
-    }
-    local_wm = 0;*/
-}
-
-/***********************************************************************
- *     MODULE_LoadLibraryExA   (internal)
- *
- * Load a PE style module according to the load order.
- *
- * The HFILE parameter is not used and marked reserved in the SDK. I can
- * only guess that it should force a file to be mapped, but I rather
- * ignore the parameter because it would be extremely difficult to
- * integrate this with different types of module represenations.
- *
- */
-static WINE_MODREF *MODULE_LoadLibraryExA( LPCSTR libname, HFILE hfile, DWORD flags )
-{
-       DWORD err = GetLastError();
-       WINE_MODREF *pwm;
-       int i;
-//     module_loadorder_t *plo;
-
-        SetLastError( ERROR_FILE_NOT_FOUND );
-       TRACE("Trying native dll '%s'\n", libname);
-       pwm = PE_LoadLibraryExA(libname, flags);
-#ifdef HAVE_LIBDL
-       if(!pwm)
-       {
-           TRACE("Trying ELF dll '%s'\n", libname);
-           pwm=(WINE_MODREF*)ELFDLL_LoadLibraryExA(libname, flags);
-       }
-#endif
-//             printf("0x%08x\n", pwm);
-//             break;
-       if(pwm)
-       {
-               /* Initialize DLL just loaded */
-               TRACE("Loaded module '%s' at 0x%08x, \n", libname, pwm->module);
-               /* Set the refCount here so that an attach failure will */
-               /* decrement the dependencies through the MODULE_FreeLibrary call. */
-               pwm->refCount++;
-
-                SetLastError( err );  /* restore last error */
-               return pwm;
-       }
-
-
-       WARN("Failed to load module '%s'; error=0x%08lx, \n", libname, GetLastError());
-       return NULL;
-}
-
-/***********************************************************************
- *           MODULE_FreeLibrary
- *
- * NOTE: Assumes that the process critical section is held!
- */
-static WIN_BOOL MODULE_FreeLibrary( WINE_MODREF *wm )
-{
-    TRACE("(%s) - START\n", wm->modname );
-
-    /* Recursively decrement reference counts */
-    //MODULE_DecRefCount( wm );
-
-    /* Call process detach notifications */
-    MODULE_DllProcessDetach( wm, FALSE, NULL );
-
-    PE_UnloadLibrary(wm);
-
-    TRACE("END\n");
-
-    return TRUE;
-}
-
-/***********************************************************************
- *           LoadLibraryExA   (KERNEL32)
- */
-HMODULE WINAPI LoadLibraryExA(LPCSTR libname, HANDLE hfile, DWORD flags)
-{
-       WINE_MODREF *wm = 0;
-       char* listpath[] = { "", "", "/usr/lib/win32", "/usr/local/lib/win32", "/usr/lib/codecs", "/usr/local/lib/codecs", 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;
-       }
-
-       wm=MODULE_FindModule(libname);
-       if(wm) return wm->module;
-
-//     if(fs_installed==0)
-//         install_fs();
-
-       while (wm == NULL && 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 ) )
-               {
-                       WARN_(module)("Attach failed for module '%s', \n", libname);
-                       MODULE_FreeLibrary(wm);
-                       SetLastError(ERROR_DLL_INIT_FAILED);
-                       MODULE_RemoveFromList(wm);
-                       wm = NULL;
-               }
-       }
-
-       if (!wm)
-           printf("Win32 LoadLibrary failed to load: %s\n", checked);
-
-       if (strstr(libname,"vp31vfw.dll") && wm)
-       {
-           int i;
-
-         // sse hack moved from patch dll into runtime patching
-          if (PE_FindExportedFunction(wm, "DriverProc", TRUE)==(void*)0x10001000) {
-           fprintf(stderr, "VP3 DLL found\n");
-           for (i=0;i<18;i++) ((char*)0x10004bd6)[i]=0x90;
-         }
-       }
-
-        // remove a few divs in the VP codecs that make trouble
-        if (strstr(libname,"vp5vfw.dll") && wm)
-        {
-          int i;
-          if (PE_FindExportedFunction(wm, "DriverProc", TRUE)==(void*)0x10003930) {
-            for (i=0;i<3;i++) ((char*)0x10004e86)[i]=0x90;
-            for (i=0;i<3;i++) ((char*)0x10005a23)[i]=0x90;
-            for (i=0;i<3;i++) ((char*)0x10005bff)[i]=0x90;
-          } else {
-            fprintf(stderr, "Unsupported VP5 version\n");
-            return 0;
-          }
-        }
-
-        if (strstr(libname,"vp6vfw.dll") && wm)
-        {
-          int i;
-          if (PE_FindExportedFunction(wm, "DriverProc", TRUE)==(void*)0x10003ef0) {
-            // looks like VP 6.1.0.2
-            for (i=0;i<6;i++) ((char*)0x10007268)[i]=0x90;
-            for (i=0;i<6;i++) ((char*)0x10007e83)[i]=0x90;
-            for (i=0;i<6;i++) ((char*)0x1000806a)[i]=0x90;
-          } else if (PE_FindExportedFunction(wm, "DriverProc", TRUE)==(void*)0x10004120) {
-            // looks like VP 6.2.0.10
-            for (i=0;i<6;i++) ((char*)0x10007688)[i]=0x90;
-            for (i=0;i<6;i++) ((char*)0x100082c3)[i]=0x90;
-            for (i=0;i<6;i++) ((char*)0x100084aa)[i]=0x90;
-          } else if (PE_FindExportedFunction(wm, "DriverProc", TRUE)==(void*)0x10003e70) {
-            // looks like VP 6.0.7.3
-            for (i=0;i<6;i++) ((char*)0x10007559)[i]=0x90;
-            for (i=0;i<6;i++) ((char*)0x100081c3)[i]=0x90;
-            for (i=0;i<6;i++) ((char*)0x1000839e)[i]=0x90;
-          } else {
-            fprintf(stderr, "Unsupported VP6 version\n");
-            return 0;
-          }
-        }
-
-        // Windows Media Video 9 Advanced
-        if (strstr(libname,"wmvadvd.dll") && wm)
-        {
-          // The codec calls IsRectEmpty with coords 0,0,0,0 => result is 0
-          // but it really wants the rectangle to be not empty
-          if (PE_FindExportedFunction(wm, "CreateInstance", TRUE)==(void*)0x08c4b812) {
-            // Dll version is 10.0.0.3645
-            *((char*)0x08c48b0f)=0xeb; // Jump always, ignoring IsRectEmpty result
-          } else {
-            fprintf(stderr, "Unsupported WMVA version\n");
-            return 0;
-          }
-        }
-
-       if (strstr(libname,"QuickTime.qts") && wm)
-       {
-           void** ptr;
-           void *dispatch_addr;
-           int i;
-
-//         dispatch_addr = GetProcAddress(wm->module, "theQuickTimeDispatcher", TRUE);
-           dispatch_addr = PE_FindExportedFunction(wm, "theQuickTimeDispatcher", TRUE);
-           if (dispatch_addr == (void *)0x62924c30)
-           {
-               fprintf(stderr, "QuickTime5 DLLs found\n");
-               ptr = (void **)0x62b75ca4; // dispatch_ptr
-               for (i=0;i<5;i++)  ((char*)0x6299e842)[i]=0x90; // make_new_region ?
-               for (i=0;i<28;i++) ((char*)0x6299e86d)[i]=0x90; // call__call_CreateCompatibleDC ?
-               for (i=0;i<5;i++)  ((char*)0x6299e898)[i]=0x90; // jmp_to_call_loadbitmap ?
-               for (i=0;i<9;i++)  ((char*)0x6299e8ac)[i]=0x90; // call__calls_OLE_shit ?
-               for (i=0;i<106;i++) ((char*)0x62a61b10)[i]=0x90; // disable threads
-#if 0
-               /* CreateThread callers */
-               for (i=0;i<5;i++) ((char*)0x629487c5)[i]=0x90;
-               for (i=0;i<5;i++) ((char*)0x6294b275)[i]=0x90;
-               for (i=0;i<5;i++) ((char*)0x629a24b1)[i]=0x90;
-               for (i=0;i<5;i++) ((char*)0x629afc5a)[i]=0x90;
-               for (i=0;i<5;i++) ((char*)0x62af799c)[i]=0x90;
-               for (i=0;i<5;i++) ((char*)0x62af7efe)[i]=0x90;
-               for (i=0;i<5;i++) ((char*)0x62afa33e)[i]=0x90;
-#endif
-
-#if 0
-               /* TerminateQTML fix */
-               for (i=0;i<47;i++) ((char*)0x62afa3b8)[i]=0x90; // terminate thread
-               for (i=0;i<47;i++) ((char*)0x62af7f78)[i]=0x90; // terminate thread
-               for (i=0;i<77;i++) ((char*)0x629a13d5)[i]=0x90;
-               ((char *)0x6288e0ae)[0] = 0xc3; // font/dc remover
-               for (i=0;i<24;i++) ((char*)0x6287a1ad)[i]=0x90; // destroy window
-#endif
-           } else if (dispatch_addr == (void *)0x6693b330)
-           {
-               fprintf(stderr, "QuickTime6 DLLs found\n");
-               ptr = (void **)0x66bb9524; // dispatcher_ptr
-               for (i=0;i<5;i++)  ((char *)0x66a730cc)[i]=0x90; // make_new_region
-               for (i=0;i<28;i++) ((char *)0x66a730f7)[i]=0x90; // call__call_CreateCompatibleDC
-               for (i=0;i<5;i++)  ((char *)0x66a73122)[i]=0x90; // jmp_to_call_loadbitmap
-               for (i=0;i<9;i++)  ((char *)0x66a73131)[i]=0x90; // call__calls_OLE_shit
-               for (i=0;i<96;i++) ((char *)0x66aac852)[i]=0x90; // disable threads
-           } else if (dispatch_addr == (void *)0x6693c3e0)
-           {
-               fprintf(stderr, "QuickTime6.3 DLLs found\n");
-               ptr = (void **)0x66bca01c; // dispatcher_ptr
-               for (i=0;i<5;i++)  ((char *)0x66a68f6c)[i]=0x90; // make_new_region
-               for (i=0;i<28;i++) ((char *)0x66a68f97)[i]=0x90; // call__call_CreateCompatibleDC
-               for (i=0;i<5;i++)  ((char *)0x66a68fc2)[i]=0x90; // jmp_to_call_loadbitmap
-               for (i=0;i<9;i++)  ((char *)0x66a68fd1)[i]=0x90; // call__calls_OLE_shit
-               for (i=0;i<96;i++) ((char *)0x66ab4722)[i]=0x90; // disable threads
-           } else
-           {
-               fprintf(stderr, "Unsupported QuickTime version (%p)\n",
-                   dispatch_addr);
-               return 0;
-           }
-
-           fprintf(stderr,"QuickTime.qts patched!!! old entry=%p\n",ptr[0]);
-
-#ifdef EMU_QTX_API
-           report_entry = report_func;
-           report_ret   = report_func_ret;
-           wrapper_target=ptr[0];
-           ptr[0]=wrapper;
-#endif
-       }
-
-       return wm ? wm->module : 0;
-}
-
-
-/***********************************************************************
- *           LoadLibraryA         (KERNEL32)
- */
-HMODULE WINAPI LoadLibraryA(LPCSTR libname) {
-       return LoadLibraryExA(libname,0,0);
-}
-
-/***********************************************************************
- *           FreeLibrary
- */
-WIN_BOOL WINAPI FreeLibrary(HINSTANCE hLibModule)
-{
-    WIN_BOOL retv = FALSE;
-    WINE_MODREF *wm;
-
-    wm=MODULE32_LookupHMODULE(hLibModule);
-
-    if ( !wm || !hLibModule )
-    {
-        SetLastError( ERROR_INVALID_HANDLE );
-       return 0;
-    }
-    else
-        retv = MODULE_FreeLibrary( wm );
-
-    MODULE_RemoveFromList(wm);
-
-    /* garbage... */
-    if (local_wm == NULL) my_garbagecollection();
-
-    return retv;
-}
-
-/***********************************************************************
- *           MODULE_DecRefCount
- *
- * NOTE: Assumes that the process critical section is held!
- */
-static void MODULE_DecRefCount( WINE_MODREF *wm )
-{
-    int i;
-
-    if ( wm->flags & WINE_MODREF_MARKER )
-        return;
-
-    if ( wm->refCount <= 0 )
-        return;
-
-    --wm->refCount;
-    TRACE("(%s) refCount: %d\n", wm->modname, wm->refCount );
-
-    if ( wm->refCount == 0 )
-    {
-        wm->flags |= WINE_MODREF_MARKER;
-
-        for ( i = 0; i < wm->nDeps; i++ )
-            if ( wm->deps[i] )
-                MODULE_DecRefCount( wm->deps[i] );
-
-        wm->flags &= ~WINE_MODREF_MARKER;
-    }
-}
-
-/***********************************************************************
- *           GetProcAddress            (KERNEL32.257)
- */
-FARPROC WINAPI GetProcAddress( HMODULE hModule, LPCSTR function )
-{
-    return MODULE_GetProcAddress( hModule, function, TRUE );
-}
-
-#ifdef DEBUG_QTX_API
-
-/* 
-http://lists.apple.com/archives/quicktime-api/2003/Jan/msg00278.html
-*/
-
-struct ComponentParameters {
-    unsigned char                   flags;                      /* call modifiers: sync/async, deferred, immed, etc */
-    unsigned char                   paramSize;                  /* size in bytes of actual parameters passed to this call */
-    short                           what;                       /* routine selector, negative for Component management calls */
-    long                            params[1];                  /* actual parameters for the indicated routine */
-};
-typedef struct ComponentParameters      ComponentParameters;
-
-static char* component_func(int what){
-if (what < 0) // Range 0: Standard Component Calls
-switch(what){
-case -1: return "kComponentOpenSelect";
-case -2: return "kComponentCloseSelect";
-case -3: return "kComponentCanDoSelect";
-case -4: return "kComponentVersionSelect";
-case -5: return "kComponentRegisterSelect";
-case -6: return "kComponentTargetSelect";
-case -7: return "kComponentUnregisterSelect";
-}
-
-if (what >= 0 && what <= 0xff) // Range 1: Generic codecs
-switch(what & 0xff){
-case 0: return "kImageCodecGetCodecInfoSelect";
-case 1: return "kImageCodecGetCompressionTimeSelect";
-case 2: return "kImageCodecGetMaxCompressionSizeSelect";
-case 3: return "kImageCodecPreCompressSelect";
-case 4: return "kImageCodecBandCompressSelect";
-case 5: return "kImageCodecPreDecompressSelect";
-case 6: return "kImageCodecBandDecompressSelect";
-case 7: return "kImageCodecBusySelect";
-// finish this list from the above URL
-case 0x10: return "kImageCodecIsImageDescriptionEquivalentSelect";
-case 0x12: return "kImageCodecDisposeMemorySelect";
-case 0x14: return "kImageCodecNewImageBufferMemorySelect";
-case 0x28: return "kImageCodecRequestGammaLevelSelect";
-}
-
-//if (what >= 0x100 && what <= 0x1ff) // Range 2: Specific to QT Photo JPEG codecs
-
-if (what >= 0x200 && what <= 0x2ff) // Range 3: Base Decompressor
-switch(what & 0xff){
-case 0: return "Preflight";
-case 1: return "Initialize";
-case 2: return "BeginBand";
-case 3: return "DrawBand";
-case 4: return "EndBand";
-case 5: return "QueueStarting";
-case 6: return "QueueStopping";
-}
-
-return "???";
-}
-
-static int c_level=0;
-
-static int dump_component(char* name,int type,void* _orig, ComponentParameters *params,void** glob){
-    int ( *orig)(ComponentParameters *params, void** glob) = _orig;
-    int ret,i;
-
-    fprintf(stderr,"%*sComponentCall: %s  flags=0x%X  size=%d  what=0x%X %s\n",3*c_level,"",name,params->flags, params->paramSize, params->what, component_func(params->what));
-
-    for(i=0;i<params->paramSize/4;i++)
-       fprintf(stderr,"%*s param[%d] = 0x%X\n",3*c_level,"",i,params->params[i]);
-
-    ++c_level;
-    ret=orig(params,glob);
-    --c_level;
-    
-    if(ret>=0x1000)
-       fprintf(stderr,"%*s return=0x%X\n",3*c_level,"",ret);
-    else
-       fprintf(stderr,"%*s return=%d\n",3*c_level,"",ret);
-    return ret;
-}
-
-#define DECL_COMPONENT(sname,name,type) \
-    static void* real_ ## sname = NULL; \
-    static int fake_ ## sname(ComponentParameters *params,void** glob){ \
-       return dump_component(name,type,real_ ## sname, params, glob); \
-    }
-
-#include "qt_comp.h"
-
-#undef DECL_COMPONENT
-
-#include "qt_fv.h"
-
-#endif
-
-#ifdef EMU_QTX_API
-
-static uint32_t ret_array[4096];
-static int ret_i=0;
-
-static int report_func(void *stack_base, int stack_size, reg386_t *reg, uint32_t *flags)
-{
-#ifdef DEBUG_QTX_API
-  int i;
-  int* dptr;
-  void* pwrapper=NULL;
-  void* pptr=NULL;
-  char* pname=NULL;
-  int plen=-1;
-  // find the code:
-  
-  dptr=0x62b67ae0;dptr+=2*((reg->eax>>16)&255);
-//  printf("FUNC: flag=%d ptr=%p\n",dptr[0],dptr[1]);
-  if(dptr[0]&255){
-      dptr=dptr[1];dptr+=4*(reg->eax&65535);
-//      printf("FUNC: ptr2=%p  eax=%p  edx=%p\n",dptr[1],dptr[0],dptr[2]);
-      pwrapper=dptr[1]; pptr=dptr[0]; plen=dptr[2]; 
-  } else {
-      pwrapper=0x62924910;
-      switch(dptr[1]){
-      case 0x629248d0:
-          dptr=0x62b672c0;dptr+=2*(reg->eax&65535);
-//          printf("FUNC: ptr2=%p  eax=%p  edx=%p\n",0x62924910,dptr[0],dptr[1]);
-          pptr=dptr[0]; plen=dptr[1]; 
-         break;
-      case 0x62924e40:
-          dptr=0x62b67c70;dptr+=2*(reg->eax&65535);
-//          printf("FUNC: ptr2=%p  eax=%p  edx=%p\n",0x62924910,dptr[0],dptr[1]);
-          pptr=dptr[0]; plen=dptr[1]; 
-         break;
-      case 0x62924e60:
-          dptr=0x62b68108;if(reg->eax&0x8000) dptr+=2*(reg->eax|0xffff0000); else dptr+=2*(reg->eax&65535);
-//          printf("FUNC: ptr2=%p  eax=%p  edx=%p\n",0x62924910,dptr[0],dptr[1]);
-          pptr=dptr[0]; plen=dptr[1]; 
-         break;
-      case 0x62924e80:
-          dptr=0x62b68108;if(reg->eax&0x8000) dptr+=2*(reg->eax|0xffff0000); else dptr+=2*(reg->eax&65535);
-//          printf("FUNC: ptr2=%p  eax=%p  edx=%p\n",0x62924910,dptr[0],dptr[1]);
-          pptr=dptr[0]; plen=dptr[1]; 
-         break;
-      default:
-          printf("FUNC: unknown ptr & psize!\n");
-         pwrapper=dptr[1];
-      }
-  }
-
-  for(i=0;qt_fv_list[i].name;i++){
-          if(qt_fv_list[i].id==reg->eax){
-             pname=qt_fv_list[i].name;
-             break;
-         }
-  }
-
-  printf("FUNC[%X/%s]: wrapper=%p  func=%p  len=%d\n",reg->eax,
-      pname?pname:"???",pwrapper,pptr,plen);
-
-  printf("FUNC: caller=%p  ebx=%p\n",((uint32_t *)stack_base)[0],reg->ebx);
-
-  if(pname)
-      printf("%*sENTER(%d): %s(",ret_i*2,"",ret_i,pname);
-  else
-      printf("%*sENTER(%d): %X(",ret_i*2,"",ret_i,reg->eax);
-  for (i=0;i<plen/4;i++){
-    unsigned int val=((uint32_t *)stack_base)[1+i];
-    unsigned char* fcc=&val;
-    printf("%s0x%X", i?", ":"",val);
-    if(fcc[0]>=0x20 && fcc[0]<128 &&
-       fcc[1]>=0x20 && fcc[1]<128 &&
-       fcc[2]>=0x20 && fcc[2]<128 &&
-       fcc[3]>=0x20 && fcc[3]<128) printf("='%c%c%c%c'",fcc[3],fcc[2],fcc[1],fcc[0]);
-    else if(val>=8 && val<65536) printf("=%d",val);
-  }
-  printf(")\n");
-  fflush(stdout);
-
-#endif
-  
-#if 1
-  // emulate some functions:
-  switch(reg->eax){
-  // memory management:
-  case 0x150011: //NewPtrClear
-  case 0x150012: //NewPtrSysClear
-      reg->eax=(uint32_t)malloc(((uint32_t *)stack_base)[1]);
-      memset((void *)reg->eax,0,((uint32_t *)stack_base)[1]);
-#ifdef DEBUG_QTX_API
-      printf("%*sLEAVE(%d): EMULATED! 0x%X\n",ret_i*2,"",ret_i, reg->eax);
-#endif
-      return 1;
-  case 0x15000F: //NewPtr
-  case 0x150010: //NewPtrSys
-      reg->eax=(uint32_t)malloc(((uint32_t *)stack_base)[1]);
-#ifdef DEBUG_QTX_API
-      printf("%*sLEAVE(%d): EMULATED! 0x%X\n",ret_i*2,"",ret_i, reg->eax);
-#endif
-      return 1;
-  case 0x15002f: //DisposePtr
-      if(((uint32_t *)stack_base)[1]>=0x60000000)
-          printf("WARNING! Invalid Ptr handle!\n");
-      else
-          free((void *)((uint32_t *)stack_base)[1]);
-      reg->eax=0;
-#ifdef DEBUG_QTX_API
-      printf("%*sLEAVE(%d): EMULATED! 0x%X\n",ret_i*2,"",ret_i, reg->eax);
-#endif
-      return 1;
-  // mutexes:
-  case 0x1d0033: //QTMLCreateMutex
-      reg->eax=0xdeadbabe;
-#ifdef DEBUG_QTX_API
-      printf("%*sLEAVE(%d): EMULATED! 0x%X\n",ret_i*2,"",ret_i, reg->eax);
-#endif
-      return 1;
-  case 0x1d0034: //QTMLDestroyMutex
-  case 0x1d0035: //QTMLGrabMutex
-  case 0x1d0036: //QTMLReturnMutex
-  case 0x1d003d: //QTMLTryGrabMutex
-      reg->eax=0;
-#ifdef DEBUG_QTX_API
-      printf("%*sLEAVE(%d): EMULATED! 0x%X\n",ret_i*2,"",ret_i, reg->eax);
-#endif
-      return 1;
-  }
-#endif
-
-#if 0
-  switch(reg->eax){
-//  case 0x00010000:
-//      printf("FUNC: ImageCodecInitialize/ImageCodecGetCodecInfo(ci=%p,&icap=%p)\n",((uint32_t *)stack_base)[1],((uint32_t *)stack_base)[4]);
-//      break;
-  case 0x00010003:
-      printf("FUNC: CountComponents(&desc=%p)\n",((uint32_t *)stack_base)[1]);
-      break;
-  case 0x00010004:
-      printf("FUNC: FindNextComponent(prev=%p,&desc=%p)\n",((uint32_t *)stack_base)[1],((uint32_t *)stack_base)[2]);
-      break;
-  case 0x00010007:
-      printf("FUNC: OpenComponent(prev=%p)\n",((uint32_t *)stack_base)[1]);
-      break;
-  case 0x0003008b:
-      printf("FUNC: QTNewGWorldFromPtr(&pts=%p,fourcc=%.4s,&rect=%p,x1=%p,x2=%p,x3=%p,plane=%p,stride=%d)\n",
-          ((uint32_t *)stack_base)[1],
-          &(((uint32_t *)stack_base)[2]),
-          ((uint32_t *)stack_base)[3],
-          ((uint32_t *)stack_base)[4],
-          ((uint32_t *)stack_base)[5],
-          ((uint32_t *)stack_base)[6],
-          ((uint32_t *)stack_base)[7],
-          ((uint32_t *)stack_base)[8]);
-      break;
-  case 0x001c0018:
-      printf("FUNC: GetGWorldPixMap(gworld=%p)\n",((uint32_t *)stack_base)[1]);
-      break;
-  case 0x00110001:
-      printf("FUNC: Gestalt(fourcc=%.4s, &ret=%p)\n",&(((uint32_t *)stack_base)[1]),((uint32_t *)stack_base)[2]);
-      break;
-  default: {
-      int i;
-      for(i=0;qt_fv_list[i].name;i++){
-          if(qt_fv_list[i].id==reg->eax){
-             printf("FUNC: %s\n",qt_fv_list[i].name);
-             break;
-         }
-      }
-      }
-  }
-
-  // print stack/reg information 
-  printf("ENTER(%d) stack = %d bytes @ %p\n"
-        "eax = 0x%08x edx = 0x%08x ebx = 0x%08x ecx = 0x%08x\n"
-        "esp = 0x%08x ebp = 0x%08x esi = 0x%08x edi = 0x%08x\n"
-        "flags = 0x%08x\n", ret_i,
-        stack_size, stack_base,
-        reg->eax, reg->edx, reg->ebx, reg->ecx,
-        reg->esp, reg->ebp, reg->esi, reg->edi,
-        *flags);
-#endif
-
-  // save ret addr:
-  ret_array[ret_i]=((uint32_t *)stack_base)[0];
-  ++ret_i;
-
-#if 0
-  // print first 7 longs in the stack (return address, arg[1], arg[2] ... ) 
-  printf("stack[] = { ");
-  for (i=0;i<7;i++) {
-    printf("%08x ", ((uint32_t *)stack_base)[i]);
-  }
-  printf("}\n\n");
-#endif
-  
-//  // mess with function parameters 
-//  ((uint32_t *)stack_base)[1] = 0x66554433;
-
-//  // mess with return address...
-//  reg->eax = 0x11223344;
-    return 0;
-}
-
-static int report_func_ret(void *stack_base, int stack_size, reg386_t *reg, uint32_t *flags)
-{
-  int i;
-  short err;
-
-  // restore ret addr:
-  --ret_i;
-  ((uint32_t *)stack_base)[0]=ret_array[ret_i];
-
-#ifdef DEBUG_QTX_API
-
-#if 1
-  printf("%*sLEAVE(%d): 0x%X",ret_i*2,"",ret_i, reg->eax);
-  err=reg->eax;
-  if(err && (reg->eax>>16)==0) printf(" = %d",err);
-  printf("\n");
-  fflush(stdout);
-#else
-  // print stack/reg information 
-  printf("LEAVE(%d) stack = %d bytes @ %p\n"
-        "eax = 0x%08x edx = 0x%08x ebx = 0x%08x ecx = 0x%08x\n"
-        "esp = 0x%08x ebp = 0x%08x esi = 0x%08x edi = 0x%08x\n"
-        "flags = 0x%08x\n", ret_i,
-        stack_size, stack_base,
-        reg->eax, reg->edx, reg->ebx, reg->ecx,
-        reg->esp, reg->ebp, reg->esi, reg->edi,
-        *flags);
-#endif
-
-#if 0
-  // print first 7 longs in the stack (return address, arg[1], arg[2] ... ) 
-  printf("stack[] = { ");
-  for (i=0;i<7;i++) {
-    printf("%08x ", ((uint32_t *)stack_base)[i]);
-  }
-  printf("}\n\n");
-#endif
-
-#endif
-  
-//  // mess with function parameters 
-//  ((uint32_t *)stack_base)[1] = 0x66554433;
-
-//  // mess with return address...
-//  reg->eax = 0x11223344;
-    return 0;
-}
-
-#endif
-
-/***********************************************************************
- *           MODULE_GetProcAddress             (internal)
- */
-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;
-    FARPROC    retproc;
-
-#ifdef DEBUG_QTX_API
-    if (HIWORD(function))
-       fprintf(stderr,"XXX GetProcAddress(%08lx,%s)\n",(DWORD)hModule,function);
-    else
-       fprintf(stderr,"XXX GetProcAddress(%08lx,%p)\n",(DWORD)hModule,function);
-#endif
-
-//     TRACE_(win32)("(%08lx,%s)\n",(DWORD)hModule,function);
-//    else
-//     TRACE_(win32)("(%08lx,%p)\n",(DWORD)hModule,function);
-
-    if (!wm) {
-       SetLastError(ERROR_INVALID_HANDLE);
-        return (FARPROC)0;
-    }
-    switch (wm->type)
-    {
-    case MODULE32_PE:
-       retproc = PE_FindExportedFunction( wm, function, snoop );
-       if (!retproc) SetLastError(ERROR_PROC_NOT_FOUND);
-       break;
-#ifdef HAVE_LIBDL
-    case MODULE32_ELF:
-       retproc = (FARPROC) dlsym( (void*) wm->module, function);
-       if (!retproc) SetLastError(ERROR_PROC_NOT_FOUND);
-       return retproc;
-#endif
-    default:
-       ERR("wine_modref type %d not handled.\n",wm->type);
-       SetLastError(ERROR_INVALID_HANDLE);
-       return (FARPROC)0;
-    }
-
-#ifdef EMU_QTX_API
-    if (HIWORD(function) && retproc){
-
-#ifdef DEBUG_QTX_API
-#define DECL_COMPONENT(sname,name,type) \
-    if(!strcmp(function,name)){ \
-       fprintf(stderr,name "dispatcher catched -> %p\n",retproc); \
-       real_ ## sname = retproc; retproc = fake_ ## sname; \
-    }
-#include "qt_comp.h"
-#undef DECL_COMPONENT
-#endif
-
-    if(!strcmp(function,"theQuickTimeDispatcher")
-//      || !strcmp(function,"_CallComponentFunctionWithStorage")
-//      || !strcmp(function,"_CallComponent")
-      ){
-       fprintf(stderr,"theQuickTimeDispatcher catched -> %p\n",retproc);
-      report_entry = report_func;
-      report_ret   = report_func_ret;
-      wrapper_target=(void(*)(void))retproc;
-      retproc=(FARPROC)wrapper;
-    }
-
-    }
-#endif
-
-    return retproc;
-}
-
-static int acounter = 0;
-void CodecAlloc(void)
-{
-    acounter++;
-    //printf("**************CODEC ALLOC %d\n", acounter);
-}
-
-void CodecRelease(void)
-{
-    acounter--;
-    //printf("**************CODEC RELEASE %d\n", acounter);
-    if (acounter == 0)
-    {
-       for (;;)
-       {
-           modref_list* list = local_wm;
-           if (!local_wm)
-               break;
-           //printf("CODECRELEASE %p\n", list);
-            MODULE_FreeLibrary(list->wm);
-           MODULE_RemoveFromList(list->wm);
-            if (local_wm == NULL)
-               my_garbagecollection();
-       }
-    }
-}
diff --git a/libs/loader/pe_image.c b/libs/loader/pe_image.c
deleted file mode 100644 (file)
index 8c6f542..0000000
+++ /dev/null
@@ -1,980 +0,0 @@
-/*
- * $Id$
- *
- *  Copyright  1994    Eric Youndale & Erik Bos
- *  Copyright  1995    Martin von Löwis
- *  Copyright   1996-98 Marcus Meissner
- *
- *     based on Eric Youndale's pe-test and:
- *
- *     ftp.microsoft.com:/pub/developer/MSDN/CD8/PEFILE.ZIP
- * make that:
- *     ftp.microsoft.com:/developr/MSDN/OctCD/PEFILE.ZIP
- *
- * Modified for use with MPlayer, detailed CVS changelog at
- * http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
- *
- * File now distributed as part of VLC media player with no modifications.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
- */
-/* Notes:
- * Before you start changing something in this file be aware of the following:
- *
- * - There are several functions called recursively. In a very subtle and 
- *   obscure way. DLLs can reference each other recursively etc.
- * - If you want to enhance, speed up or clean up something in here, think
- *   twice WHY it is implemented in that strange way. There is usually a reason.
- *   Though sometimes it might just be lazyness ;)
- * - In PE_MapImage, right before fixup_imports() all external and internal 
- *   state MUST be correct since this function can be called with the SAME image
- *   AGAIN. (Thats recursion for you.) That means MODREF.module and
- *   NE_MODULE.module32.
- * - Sometimes, we can't use Linux mmap() to mmap() the images directly.
- *
- *   The problem is, that there is not direct 1:1 mapping from a diskimage and
- *   a memoryimage. The headers at the start are mapped linear, but the sections
- *   are not. Older x86 pe binaries are 512 byte aligned in file and 4096 byte
- *   aligned in memory. Linux likes them 4096 byte aligned in memory (due to
- *   x86 pagesize, this cannot be fixed without a rather large kernel rewrite)
- *   and 'blocksize' file-aligned (offsets). Since we have 512/1024/2048 (CDROM)
- *   and other byte blocksizes, we can't always do this.  We *can* do this for
- *   newer pe binaries produced by MSVC 5 and later, since they are also aligned
- *   to 4096 byte boundaries on disk.
- */
-#include "config.h"
-
-#include <errno.h>
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#ifdef HAVE_SYS_MMAN_H
-#include <sys/mman.h>
-#endif
-#include "wine/windef.h"
-#include "wine/winbase.h"
-#include "wine/winerror.h"
-#include "wine/heap.h"
-#include "wine/pe_image.h"
-#include "wine/module.h"
-#include "wine/debugtools.h"
-#include "ext.h"
-#include "win32.h"
-
-#define RVA(x) ((void *)((char *)load_addr+(unsigned int)(x)))
-
-#define AdjustPtr(ptr,delta) ((char *)(ptr) + (delta))
-
-extern void* LookupExternal(const char* library, int ordinal);
-extern void* LookupExternalByName(const char* library, const char* name);
-
-static void dump_exports( HMODULE hModule )
-{ 
-  char         *Module;
-  unsigned int i, j;
-  u_short      *ordinal;
-  u_long       *function,*functions;
-  u_char       **name;
-  unsigned int load_addr = hModule;
-
-  DWORD rva_start = PE_HEADER(hModule)->OptionalHeader
-                   .DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress;
-  DWORD rva_end = rva_start + PE_HEADER(hModule)->OptionalHeader
-                   .DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].Size;
-  IMAGE_EXPORT_DIRECTORY *pe_exports = (IMAGE_EXPORT_DIRECTORY*)RVA(rva_start);
-
-  Module = (char*)RVA(pe_exports->Name);
-  TRACE("*******EXPORT DATA*******\n");
-  TRACE("Module name is %s, %ld functions, %ld names\n", 
-        Module, pe_exports->NumberOfFunctions, pe_exports->NumberOfNames);
-
-  ordinal=(u_short*) RVA(pe_exports->AddressOfNameOrdinals);
-  functions=function=(u_long*) RVA(pe_exports->AddressOfFunctions);
-  name=(u_char**) RVA(pe_exports->AddressOfNames);
-
-  TRACE(" Ord    RVA     Addr   Name\n" );
-  for (i=0;i<pe_exports->NumberOfFunctions;i++, function++)
-  {
-      if (!*function) continue;  
-      if (TRACE_ON(win32))
-      {
-       DPRINTF( "%4ld %08lx %p", i + pe_exports->Base, *function, RVA(*function) );
-       
-       for (j = 0; j < pe_exports->NumberOfNames; j++)
-          if (ordinal[j] == i)
-          {
-              DPRINTF( "  %s", (char*)RVA(name[j]) );
-              break;
-          }
-       if ((*function >= rva_start) && (*function <= rva_end))
-         DPRINTF(" (forwarded -> %s)", (char *)RVA(*function));
-       DPRINTF("\n");
-      }
-  }
-}
-
-/* Look up the specified function or ordinal in the exportlist:
- * If it is a string:
- *     - look up the name in the Name list. 
- *     - look up the ordinal with that index.
- *     - use the ordinal as offset into the functionlist
- * If it is a ordinal:
- *     - use ordinal-pe_export->Base as offset into the functionlist
- */
-FARPROC PE_FindExportedFunction( 
-       WINE_MODREF *wm,        
-       LPCSTR funcName,        
-        WIN_BOOL snoop )
-{
-       u_short                         * ordinals;
-       u_long                          * function;
-       u_char                          ** name;
-       const char *ename = NULL;
-       int                             i, ordinal;
-       PE_MODREF                       *pem = &(wm->binfmt.pe);
-       IMAGE_EXPORT_DIRECTORY          *exports = pem->pe_export;
-       unsigned int                    load_addr = wm->module;
-       u_long                          rva_start, rva_end, addr;
-       char                            * forward;
-
-       if (HIWORD(funcName))
-               TRACE("(%s)\n",funcName);
-       else
-               TRACE("(%d)\n",(int)funcName);
-       if (!exports) {
-               /* Not a fatal problem, some apps do
-                * GetProcAddress(0,"RegisterPenApp") which triggers this
-                * case.
-                */
-               WARN("Module %08x(%s)/MODREF %p doesn't have a exports table.\n",wm->module,wm->modname,pem);
-               return NULL;
-       }
-       ordinals= (u_short*)  RVA(exports->AddressOfNameOrdinals);
-       function= (u_long*)   RVA(exports->AddressOfFunctions);
-       name    = (u_char **) RVA(exports->AddressOfNames);
-       forward = NULL;
-       rva_start = PE_HEADER(wm->module)->OptionalHeader
-               .DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress;
-       rva_end = rva_start + PE_HEADER(wm->module)->OptionalHeader
-               .DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].Size;
-
-       if (HIWORD(funcName))
-        {
-            
-            int min = 0, max = exports->NumberOfNames - 1;
-            while (min <= max)
-            {
-                int res, pos = (min + max) / 2;
-               ename = (const char*) RVA(name[pos]);
-               if (!(res = strcmp( ename, funcName )))
-                {
-                    ordinal = ordinals[pos];
-                    goto found;
-                }
-                if (res > 0) max = pos - 1;
-                else min = pos + 1;
-            }
-            
-           for (i = 0; i < exports->NumberOfNames; i++)
-            {
-               ename = (const char*) RVA(name[i]);
-                if (!strcmp( ename, funcName ))
-                {
-                   ERR( "%s.%s required a linear search\n", wm->modname, funcName );
-                    ordinal = ordinals[i];
-                    goto found;
-                }
-            }
-            return NULL;
-       }
-        else  
-        {
-            ordinal = LOWORD(funcName) - exports->Base;
-            if (snoop && name)  
-            {
-                for (i = 0; i < exports->NumberOfNames; i++)
-                    if (ordinals[i] == ordinal)
-                    {
-                        ename = RVA(name[i]);
-                        break;
-                    }
-            }
-       }
-
- found:
-        if (ordinal >= exports->NumberOfFunctions)
-        {
-            TRACE("    ordinal %ld out of range!\n", ordinal + exports->Base );
-            return NULL;
-        }
-        addr = function[ordinal];
-        if (!addr) return NULL;
-        if ((addr < rva_start) || (addr >= rva_end))
-        {
-            FARPROC proc = RVA(addr);
-            if (snoop)
-            {
-                if (!ename) ename = "@";
-//                proc = SNOOP_GetProcAddress(wm->module,ename,ordinal,proc);
-               TRACE("SNOOP_GetProcAddress n/a\n");
-               
-            }
-            return proc;
-        }
-        else  
-        {
-                WINE_MODREF *wm;
-                char *forward = RVA(addr);
-               char module[256];
-               char *end = strchr(forward, '.');
-
-               if (!end) return NULL;
-                if (end - forward >= sizeof(module)) return NULL;
-                memcpy( module, forward, end - forward );
-               module[end-forward] = 0;
-                if (!(wm = MODULE_FindModule( module )))
-                {
-                    ERR("module not found for forward '%s'\n", forward );
-                    return NULL;
-                }
-               return MODULE_GetProcAddress( wm->module, end + 1, snoop );
-       }
-}
-
-static DWORD fixup_imports( WINE_MODREF *wm )
-{
-    IMAGE_IMPORT_DESCRIPTOR    *pe_imp;
-    PE_MODREF                  *pem;
-    unsigned int load_addr     = wm->module;
-    int                                i,characteristics_detection=1;
-    char                       *modname;
-    
-    assert(wm->type==MODULE32_PE);
-    pem = &(wm->binfmt.pe);
-    if (pem->pe_export)
-       modname = (char*) RVA(pem->pe_export->Name);
-    else
-        modname = "<unknown>";
-
-    
-    TRACE("Dumping imports list\n");
-
-    
-    pe_imp = pem->pe_import;
-    if (!pe_imp) return 0;
-
-    /* We assume that we have at least one import with !0 characteristics and
-     * detect broken imports with all characteristsics 0 (notably Borland) and
-     * switch the detection off for them.
-     */
-    for (i = 0; pe_imp->Name ; pe_imp++) {
-       if (!i && !pe_imp->u.Characteristics)
-               characteristics_detection = 0;
-       if (characteristics_detection && !pe_imp->u.Characteristics)
-               break;
-       i++;
-    }
-    if (!i) return 0;  
-
-    
-    wm->nDeps = i;
-    wm->deps  = HeapAlloc( GetProcessHeap(), 0, i*sizeof(WINE_MODREF *) );
-
-    /* load the imported modules. They are automatically 
-     * added to the modref list of the process.
-     */
-    for (i = 0, pe_imp = pem->pe_import; pe_imp->Name ; pe_imp++) {
-       IMAGE_IMPORT_BY_NAME    *pe_name;
-       PIMAGE_THUNK_DATA       import_list,thunk_list;
-       char                    *name = (char *) RVA(pe_imp->Name);
-
-       if (characteristics_detection && !pe_imp->u.Characteristics)
-               break;
-
-//#warning FIXME: here we should fill imports
-        TRACE("Loading imports for %s.dll\n", name);
-    
-       if (pe_imp->u.OriginalFirstThunk != 0) { 
-           TRACE("Microsoft style imports used\n");
-           import_list =(PIMAGE_THUNK_DATA) RVA(pe_imp->u.OriginalFirstThunk);
-           thunk_list = (PIMAGE_THUNK_DATA) RVA(pe_imp->FirstThunk);
-
-           while (import_list->u1.Ordinal) {
-               if (IMAGE_SNAP_BY_ORDINAL(import_list->u1.Ordinal)) {
-                   int ordinal = IMAGE_ORDINAL(import_list->u1.Ordinal);
-
-//                 TRACE("--- Ordinal %s,%d\n", name, ordinal);
-                   
-                   thunk_list->u1.Function=LookupExternal(name, ordinal);
-               } else {                
-                   pe_name = (PIMAGE_IMPORT_BY_NAME)RVA(import_list->u1.AddressOfData);
-//                 TRACE("--- %s %s.%d\n", pe_name->Name, name, pe_name->Hint);
-                   thunk_list->u1.Function=LookupExternalByName(name, pe_name->Name);
-               }
-               import_list++;
-               thunk_list++;
-           }
-       } else {        
-           TRACE("Borland style imports used\n");
-           thunk_list = (PIMAGE_THUNK_DATA) RVA(pe_imp->FirstThunk);
-           while (thunk_list->u1.Ordinal) {
-               if (IMAGE_SNAP_BY_ORDINAL(thunk_list->u1.Ordinal)) {
-                   
-                   int ordinal = IMAGE_ORDINAL(thunk_list->u1.Ordinal);
-
-                   TRACE("--- Ordinal %s.%d\n",name,ordinal);
-                   thunk_list->u1.Function=LookupExternal(
-                     name, ordinal);
-               } else {
-                   pe_name=(PIMAGE_IMPORT_BY_NAME) RVA(thunk_list->u1.AddressOfData);
-                   TRACE("--- %s %s.%d\n",
-                                 pe_name->Name,name,pe_name->Hint);
-                   thunk_list->u1.Function=LookupExternalByName(
-                     name, pe_name->Name);
-               }
-               thunk_list++;
-           }
-       }
-    }
-    return 0;
-}
-
-static int calc_vma_size( HMODULE hModule )
-{
-    int i,vma_size = 0;
-    IMAGE_SECTION_HEADER *pe_seg = PE_SECTIONS(hModule);
-
-    TRACE("Dump of segment table\n");
-    TRACE("   Name    VSz  Vaddr     SzRaw   Fileadr  *Reloc *Lineum #Reloc #Linum Char\n");
-    for (i = 0; i< PE_HEADER(hModule)->FileHeader.NumberOfSections; i++)
-    {
-        TRACE("%8s: %4.4lx %8.8lx %8.8lx %8.8lx %8.8lx %8.8lx %4.4x %4.4x %8.8lx\n", 
-                      pe_seg->Name, 
-                      pe_seg->Misc.VirtualSize,
-                      pe_seg->VirtualAddress,
-                      pe_seg->SizeOfRawData,
-                      pe_seg->PointerToRawData,
-                      pe_seg->PointerToRelocations,
-                      pe_seg->PointerToLinenumbers,
-                      pe_seg->NumberOfRelocations,
-                      pe_seg->NumberOfLinenumbers,
-                      pe_seg->Characteristics);
-        vma_size=max(vma_size, pe_seg->VirtualAddress+pe_seg->SizeOfRawData);
-        vma_size=max(vma_size, pe_seg->VirtualAddress+pe_seg->Misc.VirtualSize);
-        pe_seg++;
-    }
-    return vma_size;
-}
-
-static void do_relocations( unsigned int load_addr, IMAGE_BASE_RELOCATION *r )
-{
-    int delta = load_addr - PE_HEADER(load_addr)->OptionalHeader.ImageBase;
-    int        hdelta = (delta >> 16) & 0xFFFF;
-    int        ldelta = delta & 0xFFFF;
-
-       if(delta == 0)
-               
-               return;
-       while(r->VirtualAddress)
-       {
-               char *page = (char*) RVA(r->VirtualAddress);
-               int count = (r->SizeOfBlock - 8)/2;
-               int i;
-               TRACE_(fixup)("%x relocations for page %lx\n",
-                       count, r->VirtualAddress);
-               
-               for(i=0;i<count;i++)
-               {
-                       int offset = r->TypeOffset[i] & 0xFFF;
-                       int type = r->TypeOffset[i] >> 12;
-//                     TRACE_(fixup)("patching %x type %x\n", offset, type);
-                       switch(type)
-                       {
-                       case IMAGE_REL_BASED_ABSOLUTE: break;
-                       case IMAGE_REL_BASED_HIGH:
-                               *(short*)(page+offset) += hdelta;
-                               break;
-                       case IMAGE_REL_BASED_LOW:
-                               *(short*)(page+offset) += ldelta;
-                               break;
-                       case IMAGE_REL_BASED_HIGHLOW:
-                               *(int*)(page+offset) += delta;
-                               
-                               break;
-                       case IMAGE_REL_BASED_HIGHADJ:
-                               FIXME("Don't know what to do with IMAGE_REL_BASED_HIGHADJ\n");
-                               break;
-                       case IMAGE_REL_BASED_MIPS_JMPADDR:
-                               FIXME("Is this a MIPS machine ???\n");
-                               break;
-                       default:
-                               FIXME("Unknown fixup type\n");
-                               break;
-                       }
-               }
-               r = (IMAGE_BASE_RELOCATION*)((char*)r + r->SizeOfBlock);
-       }
-}
-               
-
-       
-       
-
-/**********************************************************************
- *                     PE_LoadImage
- * Load one PE format DLL/EXE into memory
- * 
- * Unluckily we can't just mmap the sections where we want them, for 
- * (at least) Linux does only support offsets which are page-aligned.
- *
- * BUT we have to map the whole image anyway, for Win32 programs sometimes
- * want to access them. (HMODULE32 point to the start of it)
- */
-HMODULE PE_LoadImage( int handle, LPCSTR filename, WORD *version )
-{
-    (void)filename;
-    HMODULE    hModule;
-    HANDLE     mapping;
-
-    IMAGE_NT_HEADERS *nt;
-    IMAGE_SECTION_HEADER *pe_sec;
-    IMAGE_DATA_DIRECTORY *dir;
-    int        i, rawsize, lowest_va, vma_size, file_size = 0;
-    DWORD load_addr = 0, aoep, reloc = 0;
-//    struct get_read_fd_request *req = get_req_buffer();
-    int unix_handle = handle;
-    int page_size = getpagesize();
-
-    
-//    if ( GetFileInformationByHandle( hFile, &bhfi ) ) 
-//     file_size = bhfi.nFileSizeLow; 
-    file_size=lseek(handle, 0, SEEK_END);
-    lseek(handle, 0, SEEK_SET);
-
-//#warning fix CreateFileMappingA
-    mapping = CreateFileMappingA( handle, NULL, PAGE_READONLY | SEC_COMMIT,
-                                    0, 0, NULL );
-    if (!mapping)
-    {
-        WARN("CreateFileMapping error %ld\n", GetLastError() );
-        return 0;
-    }
-//    hModule = (HMODULE)MapViewOfFile( mapping, FILE_MAP_READ, 0, 0, 0 );
-    hModule=(HMODULE)mapping;
-//    CloseHandle( mapping );
-    if (!hModule)
-    {
-        WARN("MapViewOfFile error %ld\n", GetLastError() );
-        return 0;
-    }
-    if ( *(WORD*)hModule !=IMAGE_DOS_SIGNATURE)
-    {
-        WARN("%s image doesn't have DOS signature, but 0x%04x\n", filename,*(WORD*)hModule);
-        goto error;
-    }
-
-    nt = PE_HEADER( hModule );
-
-    
-    if ( nt->Signature != IMAGE_NT_SIGNATURE )
-    {
-        WARN("%s image doesn't have PE signature, but 0x%08lx\n", filename, nt->Signature );
-        goto error;
-    }
-
-    
-    if ( nt->FileHeader.Machine != IMAGE_FILE_MACHINE_I386 )
-    {
-        MESSAGE("Trying to load PE image for unsupported architecture (");
-        switch (nt->FileHeader.Machine)
-        {
-        case IMAGE_FILE_MACHINE_UNKNOWN: MESSAGE("Unknown"); break;
-        case IMAGE_FILE_MACHINE_I860:    MESSAGE("I860"); break;
-        case IMAGE_FILE_MACHINE_R3000:   MESSAGE("R3000"); break;
-        case IMAGE_FILE_MACHINE_R4000:   MESSAGE("R4000"); break;
-        case IMAGE_FILE_MACHINE_R10000:  MESSAGE("R10000"); break;
-        case IMAGE_FILE_MACHINE_ALPHA:   MESSAGE("Alpha"); break;
-        case IMAGE_FILE_MACHINE_POWERPC: MESSAGE("PowerPC"); break;
-        default: MESSAGE("Unknown-%04x", nt->FileHeader.Machine); break;
-        }
-        MESSAGE(")\n");
-        goto error;
-    }
-
-    
-    pe_sec = PE_SECTIONS( hModule );
-    rawsize = 0; lowest_va = 0x10000;
-    for (i = 0; i < nt->FileHeader.NumberOfSections; i++) 
-    {
-        if (lowest_va > pe_sec[i].VirtualAddress)
-           lowest_va = pe_sec[i].VirtualAddress;
-       if (pe_sec[i].Characteristics & IMAGE_SCN_CNT_UNINITIALIZED_DATA)
-           continue;
-       if (pe_sec[i].PointerToRawData+pe_sec[i].SizeOfRawData > rawsize)
-           rawsize = pe_sec[i].PointerToRawData+pe_sec[i].SizeOfRawData;
-    }
-    
-    if ( file_size && file_size < rawsize )
-    {
-        ERR("PE module is too small (header: %d, filesize: %d), "
-                    "probably truncated download?\n", 
-                    rawsize, file_size );
-        goto error;
-    }
-
-    
-    aoep = nt->OptionalHeader.AddressOfEntryPoint;
-    if (aoep && (aoep < lowest_va))
-        FIXME("VIRUS WARNING: '%s' has an invalid entrypoint (0x%08lx) "
-                      "below the first virtual address (0x%08x) "
-                      "(possibly infected by Tchernobyl/SpaceFiller virus)!\n",
-                       filename, aoep, lowest_va );
-
-
-    /* FIXME:  Hack!  While we don't really support shared sections yet,
-     *         this checks for those special cases where the whole DLL
-     *         consists only of shared sections and is mapped into the
-     *         shared address space > 2GB.  In this case, we assume that
-     *         the module got mapped at its base address. Thus we simply
-     *         check whether the module has actually been mapped there
-     *         and use it, if so.  This is needed to get Win95 USER32.DLL
-     *         to work (until we support shared sections properly).
-     */
-
-    if ( nt->OptionalHeader.ImageBase & 0x80000000 )
-    {
-        HMODULE sharedMod = (HMODULE)nt->OptionalHeader.ImageBase; 
-        IMAGE_NT_HEADERS *sharedNt = (PIMAGE_NT_HEADERS)
-               ( (LPBYTE)sharedMod + ((LPBYTE)nt - (LPBYTE)hModule) );
-
-        /* Well, this check is not really comprehensive, 
-           but should be good enough for now ... */
-        if (    !IsBadReadPtr( (LPBYTE)sharedMod, sizeof(IMAGE_DOS_HEADER) )
-             && memcmp( (LPBYTE)sharedMod, (LPBYTE)hModule, sizeof(IMAGE_DOS_HEADER) ) == 0
-             && !IsBadReadPtr( sharedNt, sizeof(IMAGE_NT_HEADERS) )
-             && memcmp( sharedNt, nt, sizeof(IMAGE_NT_HEADERS) ) == 0 )
-        {
-            UnmapViewOfFile( (LPVOID)hModule );
-            return sharedMod;
-        }
-    }
-
-
-    
-    load_addr = nt->OptionalHeader.ImageBase;
-    vma_size = calc_vma_size( hModule );
-
-    load_addr = (DWORD)VirtualAlloc( (void*)load_addr, vma_size,
-                                     MEM_RESERVE | MEM_COMMIT,
-                                     PAGE_EXECUTE_READWRITE );
-    if (load_addr == 0) 
-    {
-        
-        FIXME("We need to perform base relocations for %s\n", filename);
-       dir = nt->OptionalHeader.DataDirectory+IMAGE_DIRECTORY_ENTRY_BASERELOC;
-        if (dir->Size)
-            reloc = dir->VirtualAddress;
-        else 
-        {
-            FIXME( "FATAL: Need to relocate %s, but no relocation records present (%s). Try to run that file directly !\n",
-                   filename,
-                   (nt->FileHeader.Characteristics&IMAGE_FILE_RELOCS_STRIPPED)?
-                   "stripped during link" : "unknown reason" );
-            goto error;
-        }
-
-        /* FIXME: If we need to relocate a system DLL (base > 2GB) we should
-         *        really make sure that the *new* base address is also > 2GB.
-         *        Some DLLs really check the MSB of the module handle :-/
-         */
-        if ( nt->OptionalHeader.ImageBase & 0x80000000 )
-            ERR( "Forced to relocate system DLL (base > 2GB). This is not good.\n" );
-
-        load_addr = (DWORD)VirtualAlloc( NULL, vma_size,
-                                        MEM_RESERVE | MEM_COMMIT,
-                                        PAGE_EXECUTE_READWRITE );
-       if (!load_addr) {
-            FIXME_(win32)(
-                   "FATAL: Couldn't load module %s (out of memory, %d needed)!\n", filename, vma_size);
-            goto error;
-       }
-    }
-
-    TRACE("Load addr is %lx (base %lx), range %x\n",
-          load_addr, nt->OptionalHeader.ImageBase, vma_size );
-    TRACE_(segment)("Loading %s at %lx, range %x\n",
-                    filename, load_addr, vma_size );
-
-#if 0
-    
-    *(PIMAGE_DOS_HEADER)load_addr = *(PIMAGE_DOS_HEADER)hModule;
-    *PE_HEADER( load_addr ) = *nt;
-    memcpy( PE_SECTIONS(load_addr), PE_SECTIONS(hModule),
-            sizeof(IMAGE_SECTION_HEADER) * nt->FileHeader.NumberOfSections );
-
-    
-    memcpy( load_addr, hModule, lowest_fa );
-#endif
-
-    if ((void*)FILE_dommap( handle, (void *)load_addr, 0, nt->OptionalHeader.SizeOfHeaders,
-                     0, 0, PROT_EXEC | PROT_WRITE | PROT_READ,
-                     MAP_PRIVATE | MAP_FIXED ) != (void*)load_addr)
-    {
-        ERR_(win32)( "Critical Error: failed to map PE header to necessary address.\n");       
-        goto error;
-    }
-
-    
-    pe_sec = PE_SECTIONS( hModule );
-    for (i = 0; i < nt->FileHeader.NumberOfSections; i++, pe_sec++)
-    {
-        if (!pe_sec->SizeOfRawData || !pe_sec->PointerToRawData) continue;
-        TRACE("%s: mmaping section %s at %p off %lx size %lx/%lx\n",
-              filename, pe_sec->Name, (void*)RVA(pe_sec->VirtualAddress),
-              pe_sec->PointerToRawData, pe_sec->SizeOfRawData, pe_sec->Misc.VirtualSize );
-        if ((void*)FILE_dommap( unix_handle, (void*)RVA(pe_sec->VirtualAddress),
-                         0, pe_sec->SizeOfRawData, 0, pe_sec->PointerToRawData,
-                         PROT_EXEC | PROT_WRITE | PROT_READ,
-                         MAP_PRIVATE | MAP_FIXED ) != (void*)RVA(pe_sec->VirtualAddress))
-        {
-            
-            ERR_(win32)( "Critical Error: failed to map PE section to necessary address.\n");
-            goto error;
-        }
-        if ((pe_sec->SizeOfRawData < pe_sec->Misc.VirtualSize) &&
-            (pe_sec->SizeOfRawData & (page_size-1)))
-        {
-            DWORD end = (pe_sec->SizeOfRawData & ~(page_size-1)) + page_size;
-            if (end > pe_sec->Misc.VirtualSize) end = pe_sec->Misc.VirtualSize;
-            TRACE("clearing %p - %p\n",
-                  RVA(pe_sec->VirtualAddress) + pe_sec->SizeOfRawData,
-                  RVA(pe_sec->VirtualAddress) + end );
-            memset( (char*)RVA(pe_sec->VirtualAddress) + pe_sec->SizeOfRawData, 0,
-                    end - pe_sec->SizeOfRawData );
-        }
-    }
-
-    
-    if ( reloc )
-        do_relocations( load_addr, (IMAGE_BASE_RELOCATION *)RVA(reloc) );
-
-    
-    *version =   ( (nt->OptionalHeader.MajorSubsystemVersion & 0xff) << 8 )
-               |   (nt->OptionalHeader.MinorSubsystemVersion & 0xff);
-
-    
-    UnmapViewOfFile( (LPVOID)hModule );
-    return (HMODULE)load_addr;
-
-error:
-    if (unix_handle != -1) close( unix_handle );
-    if (load_addr) 
-    VirtualFree( (LPVOID)load_addr, 0, MEM_RELEASE );
-    UnmapViewOfFile( (LPVOID)hModule );
-    return 0;
-}
-
-/**********************************************************************
- *                 PE_CreateModule
- *
- * Create WINE_MODREF structure for loaded HMODULE32, link it into
- * process modref_list, and fixup all imports.
- *
- * Note: hModule must point to a correctly allocated PE image,
- *       with base relocations applied; the 16-bit dummy module
- *       associated to hModule must already exist.
- *
- * Note: This routine must always be called in the context of the
- *       process that is to own the module to be created.
- */
-WINE_MODREF *PE_CreateModule( HMODULE hModule, 
-                              LPCSTR filename, DWORD flags, WIN_BOOL builtin )
-{
-    DWORD load_addr = (DWORD)hModule;  
-    IMAGE_NT_HEADERS *nt = PE_HEADER(hModule);
-    IMAGE_DATA_DIRECTORY *dir;
-    IMAGE_IMPORT_DESCRIPTOR *pe_import = NULL;
-    IMAGE_EXPORT_DIRECTORY *pe_export = NULL;
-    IMAGE_RESOURCE_DIRECTORY *pe_resource = NULL;
-    WINE_MODREF *wm;
-
-    dir = nt->OptionalHeader.DataDirectory+IMAGE_DIRECTORY_ENTRY_EXPORT;
-    if (dir->Size)
-        pe_export = (PIMAGE_EXPORT_DIRECTORY)RVA(dir->VirtualAddress);
-
-    dir = nt->OptionalHeader.DataDirectory+IMAGE_DIRECTORY_ENTRY_IMPORT;
-    if (dir->Size)
-        pe_import = (PIMAGE_IMPORT_DESCRIPTOR)RVA(dir->VirtualAddress);
-
-    dir = nt->OptionalHeader.DataDirectory+IMAGE_DIRECTORY_ENTRY_RESOURCE;
-    if (dir->Size)
-        pe_resource = (PIMAGE_RESOURCE_DIRECTORY)RVA(dir->VirtualAddress);
-
-    dir = nt->OptionalHeader.DataDirectory+IMAGE_DIRECTORY_ENTRY_EXCEPTION;
-    if (dir->Size) FIXME("Exception directory ignored\n" );
-
-    dir = nt->OptionalHeader.DataDirectory+IMAGE_DIRECTORY_ENTRY_SECURITY;
-    if (dir->Size) FIXME("Security directory ignored\n" );
-
-    
-    
-
-    dir = nt->OptionalHeader.DataDirectory+IMAGE_DIRECTORY_ENTRY_DEBUG;
-    if (dir->Size) TRACE("Debug directory ignored\n" );
-
-    dir = nt->OptionalHeader.DataDirectory+IMAGE_DIRECTORY_ENTRY_COPYRIGHT;
-    if (dir->Size) FIXME("Copyright string ignored\n" );
-
-    dir = nt->OptionalHeader.DataDirectory+IMAGE_DIRECTORY_ENTRY_GLOBALPTR;
-    if (dir->Size) FIXME("Global Pointer (MIPS) ignored\n" );
-
-    
-
-    dir = nt->OptionalHeader.DataDirectory+IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG;
-    if (dir->Size) FIXME("Load Configuration directory ignored\n" );
-
-    dir = nt->OptionalHeader.DataDirectory+IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT;
-    if (dir->Size) TRACE("Bound Import directory ignored\n" );
-
-    dir = nt->OptionalHeader.DataDirectory+IMAGE_DIRECTORY_ENTRY_IAT;
-    if (dir->Size) TRACE("Import Address Table directory ignored\n" );
-
-    dir = nt->OptionalHeader.DataDirectory+IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT;
-    if (dir->Size)
-    {
-               TRACE("Delayed import, stub calls LoadLibrary\n" );
-               /*
-                * Nothing to do here.
-                */
-
-#ifdef ImgDelayDescr
-               /*
-                * This code is useful to observe what the heck is going on.
-                */
-               {
-               ImgDelayDescr *pe_delay = NULL;
-        pe_delay = (PImgDelayDescr)RVA(dir->VirtualAddress);
-        TRACE_(delayhlp)("pe_delay->grAttrs = %08x\n", pe_delay->grAttrs);
-        TRACE_(delayhlp)("pe_delay->szName = %s\n", pe_delay->szName);
-        TRACE_(delayhlp)("pe_delay->phmod = %08x\n", pe_delay->phmod);
-        TRACE_(delayhlp)("pe_delay->pIAT = %08x\n", pe_delay->pIAT);
-        TRACE_(delayhlp)("pe_delay->pINT = %08x\n", pe_delay->pINT);
-        TRACE_(delayhlp)("pe_delay->pBoundIAT = %08x\n", pe_delay->pBoundIAT);
-        TRACE_(delayhlp)("pe_delay->pUnloadIAT = %08x\n", pe_delay->pUnloadIAT);
-        TRACE_(delayhlp)("pe_delay->dwTimeStamp = %08x\n", pe_delay->dwTimeStamp);
-        }
-#endif 
-       }
-
-    dir = nt->OptionalHeader.DataDirectory+IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR;
-    if (dir->Size) FIXME("Unknown directory 14 ignored\n" );
-
-    dir = nt->OptionalHeader.DataDirectory+15;
-    if (dir->Size) FIXME("Unknown directory 15 ignored\n" );
-
-
-    
-
-    wm = (WINE_MODREF *)HeapAlloc( GetProcessHeap(), 
-                                   HEAP_ZERO_MEMORY, sizeof(*wm) );
-    wm->module = hModule;
-
-    if ( builtin ) 
-        wm->flags |= WINE_MODREF_INTERNAL;
-    if ( flags & DONT_RESOLVE_DLL_REFERENCES )
-        wm->flags |= WINE_MODREF_DONT_RESOLVE_REFS;
-    if ( flags & LOAD_LIBRARY_AS_DATAFILE )
-        wm->flags |= WINE_MODREF_LOAD_AS_DATAFILE;
-
-    wm->type = MODULE32_PE;
-    wm->binfmt.pe.pe_export = pe_export;
-    wm->binfmt.pe.pe_import = pe_import;
-    wm->binfmt.pe.pe_resource = pe_resource;
-    wm->binfmt.pe.tlsindex = -1;
-
-    wm->filename = malloc(strlen(filename)+1);
-    strcpy(wm->filename, filename );
-    wm->modname = strrchr( wm->filename, '\\' );
-    if (!wm->modname) wm->modname = wm->filename;
-    else wm->modname++;
-
-    if ( pe_export )
-        dump_exports( hModule );
-
-    /* Fixup Imports */
-
-    if (    pe_import
-         && !( wm->flags & WINE_MODREF_LOAD_AS_DATAFILE )
-         && !( wm->flags & WINE_MODREF_DONT_RESOLVE_REFS ) 
-         && fixup_imports( wm ) ) 
-    {
-        /* remove entry from modref chain */
-         return NULL;
-    }
-
-    return wm;
-
-    return wm;
-}
-
-/******************************************************************************
- * The PE Library Loader frontend. 
- * FIXME: handle the flags.
- */
-WINE_MODREF *PE_LoadLibraryExA (LPCSTR name, DWORD flags)
-{
-       HMODULE         hModule32;
-       WINE_MODREF     *wm;
-       char            filename[256];
-       int hFile;
-       WORD            version = 0;
-
-       
-       strncpy(filename, name, sizeof(filename));      
-       hFile=open(filename, O_RDONLY);
-       if(hFile==-1)
-           return NULL;
-       
-       
-       hModule32 = PE_LoadImage( hFile, filename, &version );
-       if (!hModule32)
-       {
-               SetLastError( ERROR_OUTOFMEMORY );      
-               return NULL;
-       }
-
-       if ( !(wm = PE_CreateModule( hModule32, filename, flags, FALSE )) )
-       {
-               ERR( "can't load %s\n", filename );
-               SetLastError( ERROR_OUTOFMEMORY );
-               return NULL;
-       }
-       close(hFile);
-       //printf("^^^^^^^^^^^^^^^^Alloc VM1  %p\n", wm);
-       return wm;
-}
-
-
-/*****************************************************************************
- *     PE_UnloadLibrary
- *
- * Unload the library unmapping the image and freeing the modref structure.
- */
-void PE_UnloadLibrary(WINE_MODREF *wm)
-{
-    TRACE(" unloading %s\n", wm->filename);
-
-    free(wm->filename);
-    free(wm->short_filename);
-    HeapFree( GetProcessHeap(), 0, wm->deps );
-    VirtualFree( (LPVOID)wm->module, 0, MEM_RELEASE );
-    HeapFree( GetProcessHeap(), 0, wm );
-    //printf("^^^^^^^^^^^^^^^^Free VM1  %p\n", wm);
-}
-
-/*****************************************************************************
- * Load the PE main .EXE. All other loading is done by PE_LoadLibraryExA
- * FIXME: this function should use PE_LoadLibraryExA, but currently can't
- * due to the PROCESS_Create stuff.
- */
-
-
-/*
- * This is a dirty hack.
- * The win32 DLLs contain an alloca routine, that first probes the soon
- * to be allocated new memory *below* the current stack pointer in 4KByte
- * increments.  After the mem probing below the current %esp,  the stack
- * pointer is finally decremented to make room for the "alloca"ed memory.
- * Maybe the probing code is intended to extend the stack on a windows box.
- * Anyway, the linux kernel does *not* extend the stack by simply accessing
- * memory below %esp;  it segfaults.
- * The extend_stack_for_dll_alloca() routine just preallocates a big chunk
- * of memory on the stack, for use by the DLLs alloca routine.
- * Added the noinline attribute as e.g. gcc 3.2.2 inlines this function
- * in a way that breaks it.
- */
-static void __attribute__((noinline)) extend_stack_for_dll_alloca(void)
-{
-#if !defined(__FreeBSD__) && !defined(__DragonFly__)
-    volatile int* mem=alloca(0x20000);
-    *mem=0x1234;
-#endif
-}
-
-/* Called if the library is loaded or freed.
- * NOTE: if a thread attaches a DLL, the current thread will only do
- * DLL_PROCESS_ATTACH. Only new created threads do DLL_THREAD_ATTACH
- * (SDK)
- */
-WIN_BOOL PE_InitDLL( WINE_MODREF *wm, DWORD type, LPVOID lpReserved )
-{
-    WIN_BOOL retv = TRUE;
-    assert( wm->type == MODULE32_PE );
-
-    
-    if ((PE_HEADER(wm->module)->FileHeader.Characteristics & IMAGE_FILE_DLL) &&
-        (PE_HEADER(wm->module)->OptionalHeader.AddressOfEntryPoint)
-    ) {
-       DLLENTRYPROC entry ;
-       entry = (void*)PE_FindExportedFunction(wm, "DllMain", 0);
-       if(entry==NULL)
-           entry = (void*)RVA_PTR( wm->module,OptionalHeader.AddressOfEntryPoint );
-        
-       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);
-       extend_stack_for_dll_alloca();
-        retv = entry( wm->module, type, lpReserved );
-    }
-
-    return retv;
-}
-
-static LPVOID
-_fixup_address(PIMAGE_OPTIONAL_HEADER opt,int delta,LPVOID addr) {
-       if (    ((DWORD)addr>opt->ImageBase) &&
-               ((DWORD)addr<opt->ImageBase+opt->SizeOfImage)
-       )
-               
-               return (LPVOID)(((DWORD)addr)+delta);
-       else
-               
-               return addr;
-}
diff --git a/libs/loader/pe_resource.c b/libs/loader/pe_resource.c
deleted file mode 100644 (file)
index 5e54e5e..0000000
+++ /dev/null
@@ -1,412 +0,0 @@
-/*
- * PE (Portable Execute) File Resources
- * $Id$
- *
- * Copyright 1995 Thomas Sandford
- * Copyright 1996 Martin von Loewis
- *
- * Based on the Win16 resource handling code in loader/resource.c
- * Copyright 1993 Robert J. Amstadt
- * Copyright 1995 Alexandre Julliard
- * Copyright 1997 Marcus Meissner
- *
- * Modified for use with MPlayer, detailed CVS changelog at
- * http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
- *
- * File now distributed as part of VLC media player with no modifications.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
- */
-#include "config.h"
-
-#include <stdlib.h>
-#include <sys/types.h>
-#include "wine/winestring.h"
-#include "wine/windef.h"
-#include "wine/pe_image.h"
-#include "wine/module.h"
-#include "wine/heap.h"
-//#include "task.h"
-//#include "process.h"
-//#include "stackframe.h"
-#include "wine/debugtools.h"
-#include "ext.h"
-
-/**********************************************************************
- *  HMODULE32toPE_MODREF 
- *
- * small helper function to get a PE_MODREF from a passed HMODULE32
- */
-static PE_MODREF*
-HMODULE32toPE_MODREF(HMODULE hmod) {
-       WINE_MODREF     *wm;
-
-       wm = MODULE32_LookupHMODULE( hmod );
-       if (!wm || wm->type!=MODULE32_PE)
-               return NULL;
-       return &(wm->binfmt.pe);
-}
-
-/**********************************************************************
- *         GetResDirEntryW
- *
- *     Helper function - goes down one level of PE resource tree
- *
- */
-PIMAGE_RESOURCE_DIRECTORY GetResDirEntryW(PIMAGE_RESOURCE_DIRECTORY resdirptr,
-                                          LPCWSTR name,DWORD root,
-                                          WIN_BOOL allowdefault)
-{
-    int entrynum;
-    PIMAGE_RESOURCE_DIRECTORY_ENTRY entryTable;
-    int namelen;
-
-    if (HIWORD(name)) {
-       if (name[0]=='#') {
-               char    buf[10];
-
-               lstrcpynWtoA(buf,name+1,10);
-               return GetResDirEntryW(resdirptr,(LPCWSTR)atoi(buf),root,allowdefault);
-       }
-       entryTable = (PIMAGE_RESOURCE_DIRECTORY_ENTRY) (
-                       (BYTE *) resdirptr + 
-                        sizeof(IMAGE_RESOURCE_DIRECTORY));
-       namelen = lstrlenW(name);
-       for (entrynum = 0; entrynum < resdirptr->NumberOfNamedEntries; entrynum++)
-       {
-               PIMAGE_RESOURCE_DIR_STRING_U str =
-               (PIMAGE_RESOURCE_DIR_STRING_U) (root + 
-                       entryTable[entrynum].u1.s.NameOffset);
-               if(namelen != str->Length)
-                       continue;
-               if(wcsnicmp(name,str->NameString,str->Length)==0)
-                       return (PIMAGE_RESOURCE_DIRECTORY) (
-                               root +
-                               entryTable[entrynum].u2.s.OffsetToDirectory);
-       }
-       return NULL;
-    } else {
-       entryTable = (PIMAGE_RESOURCE_DIRECTORY_ENTRY) (
-                       (BYTE *) resdirptr + 
-                        sizeof(IMAGE_RESOURCE_DIRECTORY) +
-                       resdirptr->NumberOfNamedEntries * sizeof(IMAGE_RESOURCE_DIRECTORY_ENTRY));
-       for (entrynum = 0; entrynum < resdirptr->NumberOfIdEntries; entrynum++)
-           if ((DWORD)entryTable[entrynum].u1.Name == (DWORD)name)
-               return (PIMAGE_RESOURCE_DIRECTORY) (
-                       root +
-                       entryTable[entrynum].u2.s.OffsetToDirectory);
-       /* just use first entry if no default can be found */
-       if (allowdefault && !name && resdirptr->NumberOfIdEntries)
-               return (PIMAGE_RESOURCE_DIRECTORY) (
-                       root +
-                       entryTable[0].u2.s.OffsetToDirectory);
-       return NULL;
-    }
-}
-
-/**********************************************************************
- *         GetResDirEntryA
- */
-PIMAGE_RESOURCE_DIRECTORY GetResDirEntryA( PIMAGE_RESOURCE_DIRECTORY resdirptr,
-                                          LPCSTR name, DWORD root,
-                                          WIN_BOOL allowdefault )
-{
-    PIMAGE_RESOURCE_DIRECTORY retv;
-    LPWSTR nameW = HIWORD(name)? HEAP_strdupAtoW( GetProcessHeap(), 0, name ) 
-                               : (LPWSTR)name;
-
-    retv = GetResDirEntryW( resdirptr, nameW, root, allowdefault );
-
-    if ( HIWORD(name) ) HeapFree( GetProcessHeap(), 0, nameW );
-
-    return retv;
-}
-
-/**********************************************************************
- *         PE_FindResourceEx32W
- */
-HANDLE PE_FindResourceExW(
-       WINE_MODREF *wm,LPCWSTR name,LPCWSTR type,WORD lang
-) {
-    PIMAGE_RESOURCE_DIRECTORY resdirptr;
-    DWORD root;
-    HANDLE result;
-    PE_MODREF  *pem = &(wm->binfmt.pe);
-
-    if (!pem || !pem->pe_resource)
-       return 0;
-
-    resdirptr = pem->pe_resource;
-    root = (DWORD) resdirptr;
-    if ((resdirptr = GetResDirEntryW(resdirptr, type, root, FALSE)) == NULL)
-       return 0;
-    if ((resdirptr = GetResDirEntryW(resdirptr, name, root, FALSE)) == NULL)
-       return 0;
-    result = (HANDLE)GetResDirEntryW(resdirptr, (LPCWSTR)(UINT)lang, root, FALSE);
-       /* Try LANG_NEUTRAL, too */
-    if(!result)
-        return (HANDLE)GetResDirEntryW(resdirptr, (LPCWSTR)0, root, TRUE);
-    return result;
-}
-
-
-/**********************************************************************
- *         PE_LoadResource32
- */
-HANDLE PE_LoadResource( WINE_MODREF *wm, HANDLE hRsrc )
-{
-    if (!hRsrc || !wm || wm->type!=MODULE32_PE)
-       return 0;
-    return (HANDLE) (wm->module + ((PIMAGE_RESOURCE_DATA_ENTRY)hRsrc)->OffsetToData);
-}
-
-
-/**********************************************************************
- *         PE_SizeofResource32
- */
-DWORD PE_SizeofResource( HINSTANCE hModule, HANDLE hRsrc )
-{
-    /* we don't need hModule */
-    if (!hRsrc)
-        return 0;
-    return ((PIMAGE_RESOURCE_DATA_ENTRY)hRsrc)->Size;
-}
-
-/**********************************************************************
- *         PE_EnumResourceTypes32A
- */
-WIN_BOOL
-PE_EnumResourceTypesA(HMODULE hmod,ENUMRESTYPEPROCA lpfun,LONG lparam) {
-    PE_MODREF  *pem = HMODULE32toPE_MODREF(hmod);
-    int                i;
-    PIMAGE_RESOURCE_DIRECTORY          resdir;
-    PIMAGE_RESOURCE_DIRECTORY_ENTRY    et;
-    WIN_BOOL   ret;
-    HANDLE     heap = GetProcessHeap();        
-
-    if (!pem || !pem->pe_resource)
-       return FALSE;
-
-    resdir = (PIMAGE_RESOURCE_DIRECTORY)pem->pe_resource;
-    et =(PIMAGE_RESOURCE_DIRECTORY_ENTRY)((LPBYTE)resdir+sizeof(IMAGE_RESOURCE_DIRECTORY));
-    ret = FALSE;
-    for (i=0;i<resdir->NumberOfNamedEntries+resdir->NumberOfIdEntries;i++) {
-       LPSTR   name;
-
-       if (et[i].u1.s.NameIsString)
-               name = HEAP_strdupWtoA(heap,0,(LPWSTR)((LPBYTE)pem->pe_resource+et[i].u1.s.NameOffset));
-       else
-               name = (LPSTR)(int)et[i].u1.Id;
-       ret = lpfun(hmod,name,lparam);
-       if (HIWORD(name))
-               HeapFree(heap,0,name);
-       if (!ret)
-               break;
-    }
-    return ret;
-}
-
-/**********************************************************************
- *         PE_EnumResourceTypes32W
- */
-WIN_BOOL
-PE_EnumResourceTypesW(HMODULE hmod,ENUMRESTYPEPROCW lpfun,LONG lparam) {
-    PE_MODREF  *pem = HMODULE32toPE_MODREF(hmod);
-    int                i;
-    PIMAGE_RESOURCE_DIRECTORY          resdir;
-    PIMAGE_RESOURCE_DIRECTORY_ENTRY    et;
-    WIN_BOOL   ret;
-
-    if (!pem || !pem->pe_resource)
-       return FALSE;
-
-    resdir = (PIMAGE_RESOURCE_DIRECTORY)pem->pe_resource;
-    et =(PIMAGE_RESOURCE_DIRECTORY_ENTRY)((LPBYTE)resdir+sizeof(IMAGE_RESOURCE_DIRECTORY));
-    ret = FALSE;
-    for (i=0;i<resdir->NumberOfNamedEntries+resdir->NumberOfIdEntries;i++) {
-       LPWSTR  type;
-       if (et[i].u1.s.NameIsString)
-               type = (LPWSTR)((LPBYTE)pem->pe_resource+et[i].u1.s.NameOffset);
-       else
-               type = (LPWSTR)(int)et[i].u1.Id;
-
-       ret = lpfun(hmod,type,lparam);
-       if (!ret)
-               break;
-    }
-    return ret;
-}
-
-/**********************************************************************
- *         PE_EnumResourceNames32A
- */
-WIN_BOOL
-PE_EnumResourceNamesA(
-       HMODULE hmod,LPCSTR type,ENUMRESNAMEPROCA lpfun,LONG lparam
-) {
-    PE_MODREF  *pem = HMODULE32toPE_MODREF(hmod);
-    int                i;
-    PIMAGE_RESOURCE_DIRECTORY          resdir;
-    PIMAGE_RESOURCE_DIRECTORY_ENTRY    et;
-    WIN_BOOL   ret;
-    HANDLE     heap = GetProcessHeap();        
-    LPWSTR     typeW;
-
-    if (!pem || !pem->pe_resource)
-       return FALSE;
-    resdir = (PIMAGE_RESOURCE_DIRECTORY)pem->pe_resource;
-    if (HIWORD(type))
-       typeW = HEAP_strdupAtoW(heap,0,type);
-    else
-       typeW = (LPWSTR)type;
-    resdir = GetResDirEntryW(resdir,typeW,(DWORD)pem->pe_resource,FALSE);
-    if (HIWORD(typeW))
-       HeapFree(heap,0,typeW);
-    if (!resdir)
-       return FALSE;
-    et =(PIMAGE_RESOURCE_DIRECTORY_ENTRY)((LPBYTE)resdir+sizeof(IMAGE_RESOURCE_DIRECTORY));
-    ret = FALSE;
-    for (i=0;i<resdir->NumberOfNamedEntries+resdir->NumberOfIdEntries;i++) {
-       LPSTR   name;
-
-       if (et[i].u1.s.NameIsString)
-           name = HEAP_strdupWtoA(heap,0,(LPWSTR)((LPBYTE)pem->pe_resource+et[i].u1.s.NameOffset));
-       else
-           name = (LPSTR)(int)et[i].u1.Id;
-       ret = lpfun(hmod,type,name,lparam);
-       if (HIWORD(name)) HeapFree(heap,0,name);
-       if (!ret)
-               break;
-    }
-    return ret;
-}
-
-/**********************************************************************
- *         PE_EnumResourceNames32W
- */
-WIN_BOOL
-PE_EnumResourceNamesW(
-       HMODULE hmod,LPCWSTR type,ENUMRESNAMEPROCW lpfun,LONG lparam
-) {
-    PE_MODREF  *pem = HMODULE32toPE_MODREF(hmod);
-    int                i;
-    PIMAGE_RESOURCE_DIRECTORY          resdir;
-    PIMAGE_RESOURCE_DIRECTORY_ENTRY    et;
-    WIN_BOOL   ret;
-
-    if (!pem || !pem->pe_resource)
-       return FALSE;
-
-    resdir = (PIMAGE_RESOURCE_DIRECTORY)pem->pe_resource;
-    resdir = GetResDirEntryW(resdir,type,(DWORD)pem->pe_resource,FALSE);
-    if (!resdir)
-       return FALSE;
-    et =(PIMAGE_RESOURCE_DIRECTORY_ENTRY)((LPBYTE)resdir+sizeof(IMAGE_RESOURCE_DIRECTORY));
-    ret = FALSE;
-    for (i=0;i<resdir->NumberOfNamedEntries+resdir->NumberOfIdEntries;i++) {
-       LPWSTR  name;
-       if (et[i].u1.s.NameIsString)
-               name = (LPWSTR)((LPBYTE)pem->pe_resource+et[i].u1.s.NameOffset);
-       else
-               name = (LPWSTR)(int)et[i].u1.Id;
-       ret = lpfun(hmod,type,name,lparam);
-       if (!ret)
-               break;
-    }
-    return ret;
-}
-
-/**********************************************************************
- *         PE_EnumResourceNames32A
- */
-WIN_BOOL
-PE_EnumResourceLanguagesA(
-       HMODULE hmod,LPCSTR name,LPCSTR type,ENUMRESLANGPROCA lpfun,
-       LONG lparam
-) {
-    PE_MODREF  *pem = HMODULE32toPE_MODREF(hmod);
-    int                i;
-    PIMAGE_RESOURCE_DIRECTORY          resdir;
-    PIMAGE_RESOURCE_DIRECTORY_ENTRY    et;
-    WIN_BOOL   ret;
-    HANDLE     heap = GetProcessHeap();        
-    LPWSTR     nameW,typeW;
-
-    if (!pem || !pem->pe_resource)
-       return FALSE;
-
-    resdir = (PIMAGE_RESOURCE_DIRECTORY)pem->pe_resource;
-    if (HIWORD(name))
-       nameW = HEAP_strdupAtoW(heap,0,name);
-    else
-       nameW = (LPWSTR)name;
-    resdir = GetResDirEntryW(resdir,nameW,(DWORD)pem->pe_resource,FALSE);
-    if (HIWORD(nameW))
-       HeapFree(heap,0,nameW);
-    if (!resdir)
-       return FALSE;
-    if (HIWORD(type))
-       typeW = HEAP_strdupAtoW(heap,0,type);
-    else
-       typeW = (LPWSTR)type;
-    resdir = GetResDirEntryW(resdir,typeW,(DWORD)pem->pe_resource,FALSE);
-    if (HIWORD(typeW))
-       HeapFree(heap,0,typeW);
-    if (!resdir)
-       return FALSE;
-    et =(PIMAGE_RESOURCE_DIRECTORY_ENTRY)((LPBYTE)resdir+sizeof(IMAGE_RESOURCE_DIRECTORY));
-    ret = FALSE;
-    for (i=0;i<resdir->NumberOfNamedEntries+resdir->NumberOfIdEntries;i++) {
-       /* languages are just ids... I hopem */
-       ret = lpfun(hmod,name,type,et[i].u1.Id,lparam);
-       if (!ret)
-               break;
-    }
-    return ret;
-}
-
-/**********************************************************************
- *         PE_EnumResourceLanguages32W
- */
-WIN_BOOL
-PE_EnumResourceLanguagesW(
-       HMODULE hmod,LPCWSTR name,LPCWSTR type,ENUMRESLANGPROCW lpfun,
-       LONG lparam
-) {
-    PE_MODREF  *pem = HMODULE32toPE_MODREF(hmod);
-    int                i;
-    PIMAGE_RESOURCE_DIRECTORY          resdir;
-    PIMAGE_RESOURCE_DIRECTORY_ENTRY    et;
-    WIN_BOOL   ret;
-
-    if (!pem || !pem->pe_resource)
-       return FALSE;
-
-    resdir = (PIMAGE_RESOURCE_DIRECTORY)pem->pe_resource;
-    resdir = GetResDirEntryW(resdir,name,(DWORD)pem->pe_resource,FALSE);
-    if (!resdir)
-       return FALSE;
-    resdir = GetResDirEntryW(resdir,type,(DWORD)pem->pe_resource,FALSE);
-    if (!resdir)
-       return FALSE;
-    et =(PIMAGE_RESOURCE_DIRECTORY_ENTRY)((LPBYTE)resdir+sizeof(IMAGE_RESOURCE_DIRECTORY));
-    ret = FALSE;
-    for (i=0;i<resdir->NumberOfNamedEntries+resdir->NumberOfIdEntries;i++) {
-       ret = lpfun(hmod,name,type,et[i].u1.Id,lparam);
-       if (!ret)
-               break;
-    }
-    return ret;
-}
diff --git a/libs/loader/qtx/qtxsdk/components.h b/libs/loader/qtx/qtxsdk/components.h
deleted file mode 100644 (file)
index 4609124..0000000
+++ /dev/null
@@ -1,741 +0,0 @@
-// Basic types:
-
-typedef char *                          Ptr;
-typedef Ptr *                           Handle;
-typedef int32_t                         Size;
-typedef unsigned char                   Boolean;
-typedef unsigned char                   Str31[32];
-typedef int32_t                         Fixed;
-
-typedef int32_t OSErr;
-typedef int OSType;
-
-typedef int32_t ComponentResult;
-typedef unsigned char                   UInt8;
-typedef signed char                     SInt8;
-typedef unsigned short                  UInt16;
-typedef signed short                    SInt16;
-typedef uint32_t                        UInt32;
-typedef int32_t                         SInt32;
-
-#define FOUR_CHAR_CODE(a,b,c,d)       ((uint32_t)(a)<<24 | (uint32_t)(b)<<16 | (uint32_t)(c)<<8 | (uint32_t)(d)) /* otherwise compiler will complain about values with high bit set */
-
-// codec private shit:
-typedef void *GlobalsPtr;
-typedef void **Globals;
-
-//==================== COMPONENTS ===========================
-
-struct __attribute__((__packed__)) ComponentParameters {
-    UInt8                           flags;                      /* call modifiers: sync/async, deferred, immed, etc */
-    UInt8                           paramSize;                  /* size in bytes of actual parameters passed to this call */
-    short                           what;                       /* routine selector, negative for Component management calls */
-    int32_t                         params[1];                  /* actual parameters for the indicated routine */
-};
-typedef struct ComponentParameters      ComponentParameters;
-
-
-struct __attribute__((__packed__)) ComponentDescription {
-    OSType                          componentType;              /* A unique 4-byte code indentifying the command set */
-    OSType                          componentSubType;           /* Particular flavor of this instance */
-    OSType                          componentManufacturer;      /* Vendor indentification */
-    uint32_t                        componentFlags;             /* 8 each for Component,Type,SubType,Manuf/revision */
-    uint32_t                        componentFlagsMask;         /* Mask for specifying which flags to consider in search, zero during registration */
-};
-typedef struct ComponentDescription     ComponentDescription;
-
-
-struct __attribute__((__packed__)) ResourceSpec {
-    OSType                          resType;                    /* 4-byte code    */
-    short                           resID;                      /*         */
-};
-typedef struct ResourceSpec             ResourceSpec;
-
-
-struct __attribute__((__packed__)) ComponentResource {
-    ComponentDescription            cd;                         /* Registration parameters */
-    ResourceSpec                    component;                  /* resource where Component code is found */
-    ResourceSpec                    componentName;              /* name string resource */
-    ResourceSpec                    componentInfo;              /* info string resource */
-    ResourceSpec                    componentIcon;              /* icon resource */
-};
-typedef struct ComponentResource        ComponentResource;
-typedef ComponentResource *             ComponentResourcePtr;
-typedef ComponentResourcePtr *          ComponentResourceHandle;
-
-
-struct __attribute__((__packed__)) ComponentRecord {
-    int32_t                            data[1];
-};
-typedef struct ComponentRecord          ComponentRecord;
-typedef ComponentRecord *               Component;
-
-
-struct __attribute__((__packed__)) ComponentInstanceRecord {
-    int32_t                            data[1];
-};
-typedef struct ComponentInstanceRecord  ComponentInstanceRecord;
-
-typedef ComponentInstanceRecord *       ComponentInstance;
-
-// ========================= QUICKDRAW =========================
-
-struct __attribute__((__packed__)) Rect {
-    short                           top;
-    short                           left;
-    short                           bottom;
-    short                           right;
-};
-typedef struct Rect                     Rect;
-typedef Rect *                          RectPtr;
-
-struct __attribute__((__packed__)) RGBColor {
-    unsigned short                  red;                        /*magnitude of red component*/
-    unsigned short                  green;                      /*magnitude of green component*/
-    unsigned short                  blue;                       /*magnitude of blue component*/
-};
-typedef struct RGBColor                 RGBColor;
-typedef RGBColor *                      RGBColorPtr;
-typedef RGBColorPtr *                   RGBColorHdl;
-
-struct __attribute__((__packed__)) ColorSpec {
-    short                           value;                      /*index or other value*/
-    RGBColor                        rgb;                        /*true color*/
-};
-typedef struct ColorSpec                ColorSpec;
-typedef ColorSpec *                     ColorSpecPtr;
-typedef ColorSpec                       CSpecArray[1];
-
-struct __attribute__((__packed__)) ColorTable {
-    int32_t                         ctSeed;                     /*unique identifier for table*/
-    short                           ctFlags;                    /*high bit: 0 = PixMap; 1 = device*/
-    short                           ctSize;                     /*number of entries in CTTable*/
-    CSpecArray                      ctTable;                    /*array [0..0] of ColorSpec*/
-};
-typedef struct ColorTable               ColorTable;
-typedef ColorTable *                    CTabPtr;
-typedef CTabPtr *                       CTabHandle;
-
-struct __attribute__((__packed__)) MatrixRecord {
-    Fixed                           matrix[3][3];
-};
-typedef struct MatrixRecord             MatrixRecord;
-typedef MatrixRecord *                  MatrixRecordPtr;
-
-typedef int32_t                         ImageSequence;
-typedef OSType                          CodecType;
-typedef unsigned short                  CodecFlags;
-typedef uint32_t                        CodecQ;
-
-struct __attribute__((__packed__)) ImageDescription {
-    int32_t                         idSize;                     /* total size of ImageDescription including extra data ( CLUTs and other per sequence data ) */
-    CodecType                       cType;                      /* what kind of codec compressed this data */
-    int32_t                         resvd1;                     /* reserved for Apple use */
-    short                           resvd2;                     /* reserved for Apple use */
-    short                           dataRefIndex;               /* set to zero  */
-    short                           version;                    /* which version is this data */
-    short                           revisionLevel;              /* what version of that codec did this */
-    int32_t                         vendor;                     /* whose  codec compressed this data */
-    CodecQ                          temporalQuality;            /* what was the temporal quality factor  */
-    CodecQ                          spatialQuality;             /* what was the spatial quality factor */
-    short                           width;                      /* how many pixels wide is this data */
-    short                           height;                     /* how many pixels high is this data */
-    Fixed                           hRes;                       /* horizontal resolution */
-    Fixed                           vRes;                       /* vertical resolution */
-    int32_t                         dataSize;                   /* if known, the size of data for this image descriptor */
-    short                           frameCount;                 /* number of frames this description applies to */
-    Str31                           name;                       /* name of codec ( in case not installed )  */
-    short                           depth;                      /* what depth is this data (1-32) or ( 33-40 grayscale ) */
-    short                           clutID;                     /* clut id or if 0 clut follows  or -1 if no clut */
-};
-typedef struct ImageDescription         ImageDescription;
-typedef ImageDescription *              ImageDescriptionPtr;
-typedef ImageDescriptionPtr *           ImageDescriptionHandle;
-
-/* values for PixMap.pixelFormat*/
-enum {
-    k16LE555PixelFormat         = FOUR_CHAR_CODE('L','5','5','5'),       /* 16 bit LE rgb 555 (PC)*/
-    k16LE5551PixelFormat        = FOUR_CHAR_CODE('5','5','5','1'),       /* 16 bit LE rgb 5551*/
-    k16BE565PixelFormat         = FOUR_CHAR_CODE('B','5','6','5'),       /* 16 bit BE rgb 565*/
-    k16LE565PixelFormat         = FOUR_CHAR_CODE('L','5','6','5'),       /* 16 bit LE rgb 565*/
-    k24BGRPixelFormat           = FOUR_CHAR_CODE('2','4','B','G'),       /* 24 bit bgr */
-    k32BGRAPixelFormat          = FOUR_CHAR_CODE('B','G','R','A'),       /* 32 bit bgra    (Matrox)*/
-    k32ABGRPixelFormat          = FOUR_CHAR_CODE('A','B','G','R'),       /* 32 bit abgr    */
-    k32RGBAPixelFormat          = FOUR_CHAR_CODE('R','G','B','A'),       /* 32 bit rgba    */
-    kYUVSPixelFormat            = FOUR_CHAR_CODE('y','u','v','s'),       /* YUV 4:2:2 byte ordering 16-unsigned = 'YUY2'*/
-    kYUVUPixelFormat            = FOUR_CHAR_CODE('y','u','v','u'),       /* YUV 4:2:2 byte ordering 16-signed*/
-    kYVU9PixelFormat            = FOUR_CHAR_CODE('Y','V','U','9'),       /* YVU9 Planar    9*/
-    kYUV411PixelFormat          = FOUR_CHAR_CODE('Y','4','1','1'),       /* YUV 4:1:1 Interleaved  16*/
-    kYVYU422PixelFormat         = FOUR_CHAR_CODE('Y','V','Y','U'),       /* YVYU 4:2:2 byte ordering   16*/
-    kUYVY422PixelFormat         = FOUR_CHAR_CODE('U','Y','V','Y'),       /* UYVY 4:2:2 byte ordering   16*/
-    kYUV211PixelFormat          = FOUR_CHAR_CODE('Y','2','1','1'),       /* YUV 2:1:1 Packed   8*/
-    k2vuyPixelFormat            = FOUR_CHAR_CODE('2','v','u','y')        /* UYVY 4:2:2 byte ordering   16*/
-};
-
-struct __attribute__((__packed__)) PixMapExtension {
-    int32_t                         extSize;                    /*size of struct, duh!*/
-    uint32_t                        pmBits;                     /*pixmap attributes bitfield*/
-    void *                          pmGD;                       /*this is a GDHandle*/
-    int32_t                         pmSeed;
-    Fixed                           gammaLevel;                 /*pixmap gammalevel*/
-    Fixed                           requestedGammaLevel;
-    uint32_t                        reserved2;
-    int32_t                         longRowBytes;               /*used when rowBytes > 16382*/
-    uint32_t                        signature;
-    Handle                          baseAddrHandle;
-};
-typedef struct PixMapExtension          PixMapExtension;
-
-typedef PixMapExtension *               PixMapExtPtr;
-typedef PixMapExtPtr *                  PixMapExtHandle;
-
-
-struct __attribute__((__packed__)) PixMap {
-    Ptr                             baseAddr;                   /*pointer to pixels*/
-    short                           rowBytes;                   /*offset to next line*/
-    Rect                            bounds;                     /*encloses bitmap*/
-    short                           pmVersion;                  /*pixMap version number*/
-    short                           packType;                   /*defines packing format*/
-    int32_t                         packSize;                   /*length of pixel data*/
-    Fixed                           hRes;                       /*horiz. resolution (ppi)*/
-    Fixed                           vRes;                       /*vert. resolution (ppi)*/
-    short                           pixelType;                  /*defines pixel type*/
-    short                           pixelSize;                  /*# bits in pixel*/
-    short                           cmpCount;                   /*# components in pixel*/
-    short                           cmpSize;                    /*# bits per component*/
-    OSType                          pixelFormat;                /*fourCharCode representation*/
-    CTabHandle                      pmTable;                    /*color map for this pixMap*/
-    PixMapExtHandle                 pmExt;                      /*Handle to pixMap extension*/
-};
-typedef struct PixMap                   PixMap;
-typedef PixMap *                        PixMapPtr;
-typedef PixMapPtr *                     PixMapHandle;
-
-
-struct __attribute__((__packed__)) BitMap {
-    Ptr                             baseAddr;
-    short                           rowBytes;
-    Rect                            bounds;
-};
-typedef struct BitMap                   BitMap;
-typedef BitMap *                        BitMapPtr;
-typedef BitMapPtr *                     BitMapHandle;
-typedef struct OpaqueRgnHandle*         RgnHandle;
-
-struct Pattern {
-    UInt8                           pat[8];
-};
-typedef struct Pattern                  Pattern;
-typedef unsigned char                   Style;
-typedef Style                           StyleField;
-struct __attribute__((__packed__)) Point {
-    short                           v;
-    short                           h;
-};
-typedef struct Point                    Point;
-struct __attribute__((__packed__)) GrafPort {
-    short                           device;
-    BitMap                          portBits;
-    Rect                            portRect;
-    RgnHandle                       visRgn;
-    RgnHandle                       clipRgn;
-    Pattern                         bkPat;
-    Pattern                         fillPat;
-    Point                           pnLoc;
-    Point                           pnSize;
-    short                           pnMode;
-    Pattern                         pnPat;
-    short                           pnVis;
-    short                           txFont;
-    StyleField                      txFace;                     /*StyleField occupies 16-bits, but only first 8-bits are used*/
-    UInt8                           txFlags;                    /* QuickTime uses second 8 bits of StyleField for txFlags */
-    short                           txMode;
-    short                           txSize;
-    Fixed                           spExtra;
-    int32_t                         fgColor;
-    int32_t                         bkColor;
-    short                           colrBit;
-    short                           patStretch;
-    Handle                          picSave;
-    Handle                          rgnSave;
-    Handle                          polySave;
-    /*QDProcsPtr*/void*                      grafProcs;
-};
-typedef struct GrafPort                 GrafPort;
-typedef GrafPort *GWorldPtr;
-typedef GWorldPtr *GWorldHandle;
-#define anyCodec                ((CodecComponent)0)
-enum {
-                                                                /* transfer modes */
-    srcCopy                     = 0,                            /*the 16 transfer modes*/
-    srcOr                       = 1,
-    srcXor                      = 2,
-    srcBic                      = 3,
-    notSrcCopy                  = 4,
-    notSrcOr                    = 5,
-    notSrcXor                   = 6,
-    notSrcBic                   = 7,
-    patCopy                     = 8,
-    patOr                       = 9,
-    patXor                      = 10,
-    patBic                      = 11,
-    notPatCopy                  = 12,
-    notPatOr                    = 13,
-    notPatXor                   = 14,
-    notPatBic                   = 15,                           /* Special Text Transfer Mode */
-    grayishTextOr               = 49,
-    hilitetransfermode          = 50,
-    hilite                      = 50,                           /* Arithmetic transfer modes */
-    blend                       = 32,
-    addPin                      = 33,
-    addOver                     = 34,
-    subPin                      = 35,
-    addMax                      = 37,
-    adMax                       = 37,
-    subOver                     = 38,
-    adMin                       = 39,
-    ditherCopy                  = 64,                           /* Transparent mode constant */
-    transparent                 = 36
-};
-
-typedef uint32_t                   GWorldFlags;
-
-
-
-// ============================== CODECS ===========================
-
-typedef Component                       CompressorComponent;
-typedef Component                       DecompressorComponent;
-typedef Component                       CodecComponent;
-
-enum {
-    codecLosslessQuality        = 0x00000400,
-    codecMaxQuality             = 0x000003FF,
-    codecMinQuality             = 0x00000000,
-    codecLowQuality             = 0x00000100,
-    codecNormalQuality          = 0x00000200,
-    codecHighQuality            = 0x00000300
-};
-
-
-
-// callbacks:
-typedef void* ImageCodecDrawBandCompleteUPP;
-typedef int64_t ICMProgressProcRecord;
-typedef int64_t ICMCompletionProcRecord;
-typedef ICMCompletionProcRecord* ICMCompletionProcRecordPtr;
-typedef int64_t ICMDataProcRecord;
-typedef void* ICMFrameTimePtr;
-typedef void* CDSequenceDataSourcePtr;
-typedef void* ICMFrameTimeInfoPtr;
-
-// graphics port
-typedef struct OpaqueGrafPtr*           GrafPtr;
-typedef GrafPtr                         CGrafPtr;
-
-
-/*  codec capabilities flags    */
-enum {
-    codecCanScale               = 1L << 0,     // 1
-    codecCanMask                = 1L << 1,     // 2
-    codecCanMatte               = 1L << 2,     // 4
-    codecCanTransform           = 1L << 3,     // 8
-    codecCanTransferMode        = 1L << 4,     // 10
-    codecCanCopyPrev            = 1L << 5,     // 20
-    codecCanSpool               = 1L << 6,     // 40
-    codecCanClipVertical        = 1L << 7,     // 80
-    codecCanClipRectangular     = 1L << 8,     // 100
-    codecCanRemapColor          = 1L << 9,     // 200
-    codecCanFastDither          = 1L << 10,    // 400
-    codecCanSrcExtract          = 1L << 11,    // 800
-    codecCanCopyPrevComp        = 1L << 12,    // 1000
-    codecCanAsync               = 1L << 13,    // 2000
-    codecCanMakeMask            = 1L << 14,    // 4000
-    codecCanShift               = 1L << 15,    // 8000
-    codecCanAsyncWhen           = 1L << 16,    // 10000
-    codecCanShieldCursor        = 1L << 17,    // 20000
-    codecCanManagePrevBuffer    = 1L << 18,    // 40000
-    codecHasVolatileBuffer      = 1L << 19,     // 80000                /* codec requires redraw after window movement */
-    codecWantsRegionMask        = 1L << 20,    // 100000
-    codecImageBufferIsOnScreen  = 1L << 21,     // 200000                /* old def of codec using overlay surface, = ( codecIsDirectToScreenOnly | codecUsesOverlaySurface | codecImageBufferIsOverlaySurface | codecSrcMustBeImageBuffer ) */
-    codecWantsDestinationPixels = 1L << 22,     // 400000
-    codecWantsSpecialScaling    = 1L << 23,     // 800000
-    codecHandlesInputs          = 1L << 24,    // 1000000
-    codecCanDoIndirectSurface   = 1L << 25,                     /* codec can handle indirect surface (GDI) */
-    codecIsSequenceSensitive    = 1L << 26,
-    codecRequiresOffscreen      = 1L << 27,
-    codecRequiresMaskBits       = 1L << 28,
-    codecCanRemapResolution     = 1L << 29,
-    codecIsDirectToScreenOnly   = 1L << 30,                     /* codec can only decompress data to the screen */
-    codecCanLockSurface         = 1L << 31                      /* codec can lock destination surface, icm doesn't lock for you */
-};
-
-/*  codec capabilities flags2   */
-enum {
-    codecUsesOverlaySurface     = 1L << 0,                      /* codec uses overlay surface */
-    codecImageBufferIsOverlaySurface = 1L << 1,                 /* codec image buffer is overlay surface, the bits in the buffer are on the screen */
-    codecSrcMustBeImageBuffer   = 1L << 2,                      /* codec can only source data from an image buffer */
-    codecImageBufferIsInAGPMemory = 1L << 4,                    /* codec image buffer is in AGP space, byte writes are OK */
-    codecImageBufferIsInPCIMemory = 1L << 5                     /* codec image buffer is across a PCI bus; byte writes are bad */
-};
-
-/*  codec condition flags   */
-// FFD =  13 = 8+4+1
-enum {
-    codecConditionFirstBand     = 1L << 0,     // 1
-    codecConditionLastBand      = 1L << 1,     // 2
-    codecConditionFirstFrame    = 1L << 2,     // 4
-    codecConditionNewDepth      = 1L << 3,     // 8
-    codecConditionNewTransform  = 1L << 4,     // 10
-    codecConditionNewSrcRect    = 1L << 5,     // 20
-    codecConditionNewMask       = 1L << 6,     // 40
-    codecConditionNewMatte      = 1L << 7,     // 80
-    codecConditionNewTransferMode = 1L << 8,   // 100
-    codecConditionNewClut       = 1L << 9,     // 200
-    codecConditionNewAccuracy   = 1L << 10,    // 400
-    codecConditionNewDestination = 1L << 11,   // 800
-    codecConditionFirstScreen   = 1L << 12,    // 1000
-    codecConditionDoCursor      = 1L << 13,    // 2000
-    codecConditionCatchUpDiff   = 1L << 14,    // 4000
-    codecConditionMaskMayBeChanged = 1L << 15, // 8000
-    codecConditionToBuffer      = 1L << 16,    // 10000
-    codecConditionCodecChangedMask = 1L << 31  // 20000
-};
-
-
-
-struct __attribute__((__packed__)) CodecCapabilities {
-    int32_t                         flags;
-    short                           wantedPixelSize;
-    short                           extendWidth;
-    short                           extendHeight;
-    short                           bandMin;
-    short                           bandInc;
-    short                           pad;
-    uint32_t                        time;
-    int32_t                         flags2;                     /* field new in QuickTime 4.0 */
-};
-typedef struct CodecCapabilities        CodecCapabilities;
-
-struct __attribute__((__packed__)) CodecDecompressParams {
-    ImageSequence                   sequenceID;                 /* predecompress,banddecompress */
-    ImageDescriptionHandle          imageDescription;           /* predecompress,banddecompress */
-    Ptr                             data;
-    int32_t                         bufferSize;
-
-    int32_t                         frameNumber;
-    int32_t                         startLine;
-    int32_t                         stopLine;
-    int32_t                         conditionFlags;
-
-    CodecFlags                      callerFlags; // short
-    CodecCapabilities *             capabilities;               /* predecompress,banddecompress */
-    ICMProgressProcRecord           progressProcRecord;
-    ICMCompletionProcRecord         completionProcRecord;
-
-    ICMDataProcRecord               dataProcRecord;
-    CGrafPtr                        port;                       /* predecompress,banddecompress */
-    PixMap                          dstPixMap;                  /* predecompress,banddecompress */
-    BitMapPtr                       maskBits;
-    PixMapPtr                       mattePixMap;
-    Rect                            srcRect;                    /* predecompress,banddecompress */
-    MatrixRecord *                  matrix;                     /* predecompress,banddecompress */
-    CodecQ                          accuracy;                   /* predecompress,banddecompress */
-    short                           transferMode;               /* predecompress,banddecompress */
-    ICMFrameTimePtr                 frameTime;                  /* banddecompress */
-    int32_t                         reserved[1];
-
-                                                                /* The following fields only exist for QuickTime 2.0 and greater */
-    SInt8                           matrixFlags;                /* high bit set if 2x resize */
-    SInt8                           matrixType;
-    Rect                            dstRect;                    /* only valid for simple transforms */
-
-                                                                /* The following fields only exist for QuickTime 2.1 and greater */
-    UInt16                          majorSourceChangeSeed;
-    UInt16                          minorSourceChangeSeed;
-    CDSequenceDataSourcePtr         sourceData;
-
-    RgnHandle                       maskRegion;
-
-                                                                /* The following fields only exist for QuickTime 2.5 and greater */
-    OSType **                       wantedDestinationPixelTypes; /* Handle to 0-terminated list of OSTypes */
-
-    int32_t                         screenFloodMethod;
-    int32_t                         screenFloodValue;
-    short                           preferredOffscreenPixelSize;
-
-                                                                /* The following fields only exist for QuickTime 3.0 and greater */
-    ICMFrameTimeInfoPtr             syncFrameTime;              /* banddecompress */
-    Boolean                         needUpdateOnTimeChange;     /* banddecompress */
-    Boolean                         enableBlackLining;
-    Boolean                         needUpdateOnSourceChange;   /* band decompress */
-    Boolean                         pad;
-
-    int32_t                         unused;
-
-    CGrafPtr                        finalDestinationPort;
-
-    int32_t                         requestedBufferWidth;       /* must set codecWantsSpecialScaling to indicate this field is valid*/
-    int32_t                         requestedBufferHeight;      /* must set codecWantsSpecialScaling to indicate this field is valid*/
-
-                                                                /* The following fields only exist for QuickTime 4.0 and greater */
-    Rect                            displayableAreaOfRequestedBuffer; /* set in predecompress*/
-    Boolean                         requestedSingleField;
-    Boolean                         needUpdateOnNextIdle;
-    Boolean                         pad2[2];
-    Fixed                           bufferGammaLevel;
-
-                                                                /* The following fields only exist for QuickTime 5.0 and greater */
-    UInt32                          taskWeight;                 /* preferred weight for MP tasks implementing this operation*/
-    OSType                          taskName;                   /* preferred name (type) for MP tasks implementing this operation*/
-};
-typedef struct CodecDecompressParams    CodecDecompressParams;
-
-
-
-struct __attribute__((__packed__)) ImageSubCodecDecompressCapabilities {
-    int32_t                         recordSize;                 /* sizeof(ImageSubCodecDecompressCapabilities)*/
-    int32_t                         decompressRecordSize;       /* size of your codec's decompress record*/
-    Boolean                         canAsync;                   /* default true*/
-    UInt8                           pad0;
-
-                                                                /* The following fields only exist for QuickTime 4.0 and greater */
-    UInt16                          suggestedQueueSize;
-    Boolean                         canProvideTrigger;
-
-                                                                /* The following fields only exist for QuickTime 5.0 and greater */
-    Boolean                         subCodecFlushesScreen;      /* only used on Mac OS X*/
-    Boolean                         subCodecCallsDrawBandComplete;
-    UInt8                           pad2[1];
-
-                                                                /* The following fields only exist for QuickTime 5.1 and greater */
-    Boolean                         isChildCodec;               /* set by base codec before calling Initialize*/
-    UInt8                           pad3[3];
-};
-typedef struct ImageSubCodecDecompressCapabilities ImageSubCodecDecompressCapabilities;
-
-
-struct __attribute__((__packed__)) ImageSubCodecDecompressRecord {
-    Ptr                             baseAddr;
-    int32_t                         rowBytes;
-    Ptr                             codecData;
-    ICMProgressProcRecord           progressProcRecord;
-    ICMDataProcRecord               dataProcRecord;
-    void *                          userDecompressRecord;       /* pointer to codec-specific per-band data*/
-    UInt8                           frameType;
-    Boolean                         inhibitMP;                  /* set this in BeginBand to tell the base decompressor not to call DrawBand from an MP task for this frame.  (Only has any effect for MP-capable subcodecs.  New in QuickTime 5.0.)*/
-    UInt8                           pad[2];
-    int32_t                         priv[2];
-
-                                                                /* The following fields only exist for QuickTime 5.0 and greater */
-    ImageCodecDrawBandCompleteUPP   drawBandCompleteUPP;        /* only used if subcodec set subCodecCallsDrawBandComplete; if drawBandCompleteUPP is non-nil, codec must call it when a frame is finished, but may return from DrawBand before the frame is finished. */
-    void *                          drawBandCompleteRefCon;     /* Note: do not call drawBandCompleteUPP directly from a hardware interrupt; instead, use DTInstall to run a function at deferred task time, and call drawBandCompleteUPP from that. */
-};
-typedef struct ImageSubCodecDecompressRecord ImageSubCodecDecompressRecord;
-
-
-/* These are the bits that are set in the Component flags, and also in the codecInfo struct. */
-enum {
-    codecInfoDoes1              = (1L << 0),                    /* codec can work with 1-bit pixels */
-    codecInfoDoes2              = (1L << 1),                    /* codec can work with 2-bit pixels */
-    codecInfoDoes4              = (1L << 2),                    /* codec can work with 4-bit pixels */
-    codecInfoDoes8              = (1L << 3),                    /* codec can work with 8-bit pixels */
-    codecInfoDoes16             = (1L << 4),                    /* codec can work with 16-bit pixels */
-    codecInfoDoes32             = (1L << 5),                    /* codec can work with 32-bit pixels */
-    codecInfoDoesDither         = (1L << 6),                    /* codec can do ditherMode */
-    codecInfoDoesStretch        = (1L << 7),                    /* codec can stretch to arbitrary sizes */
-    codecInfoDoesShrink         = (1L << 8),                    /* codec can shrink to arbitrary sizes */
-    codecInfoDoesMask           = (1L << 9),                    /* codec can mask to clipping regions */
-    codecInfoDoesTemporal       = (1L << 10),                   /* codec can handle temporal redundancy */
-    codecInfoDoesDouble         = (1L << 11),                   /* codec can stretch to double size exactly */
-    codecInfoDoesQuad           = (1L << 12),                   /* codec can stretch to quadruple size exactly */
-    codecInfoDoesHalf           = (1L << 13),                   /* codec can shrink to half size */
-    codecInfoDoesQuarter        = (1L << 14),                   /* codec can shrink to quarter size */
-    codecInfoDoesRotate         = (1L << 15),                   /* codec can rotate on decompress */
-    codecInfoDoesHorizFlip      = (1L << 16),                   /* codec can flip horizontally on decompress */
-    codecInfoDoesVertFlip       = (1L << 17),                   /* codec can flip vertically on decompress */
-    codecInfoHasEffectParameterList = (1L << 18),               /* codec implements get effects parameter list call, once was codecInfoDoesSkew */
-    codecInfoDoesBlend          = (1L << 19),                   /* codec can blend on decompress */
-    codecInfoDoesWarp           = (1L << 20),                   /* codec can warp arbitrarily on decompress */
-    codecInfoDoesRecompress     = (1L << 21),                   /* codec can recompress image without accumulating errors */
-    codecInfoDoesSpool          = (1L << 22),                   /* codec can spool image data */
-    codecInfoDoesRateConstrain  = (1L << 23)                    /* codec can data rate constrain */
-};
-
-
-enum {
-    codecInfoDepth1             = (1L << 0),                    /* compressed data at 1 bpp depth available */
-    codecInfoDepth2             = (1L << 1),                    /* compressed data at 2 bpp depth available */
-    codecInfoDepth4             = (1L << 2),                    /* compressed data at 4 bpp depth available */
-    codecInfoDepth8             = (1L << 3),                    /* compressed data at 8 bpp depth available */
-    codecInfoDepth16            = (1L << 4),                    /* compressed data at 16 bpp depth available */
-    codecInfoDepth32            = (1L << 5),                    /* compressed data at 32 bpp depth available */
-    codecInfoDepth24            = (1L << 6),                    /* compressed data at 24 bpp depth available */
-    codecInfoDepth33            = (1L << 7),                    /* compressed data at 1 bpp monochrome depth  available */
-    codecInfoDepth34            = (1L << 8),                    /* compressed data at 2 bpp grayscale depth available */
-    codecInfoDepth36            = (1L << 9),                    /* compressed data at 4 bpp grayscale depth available */
-    codecInfoDepth40            = (1L << 10),                   /* compressed data at 8 bpp grayscale depth available */
-    codecInfoStoresClut         = (1L << 11),                   /* compressed data can have custom cluts */
-    codecInfoDoesLossless       = (1L << 12),                   /* compressed data can be stored in lossless format */
-    codecInfoSequenceSensitive  = (1L << 13)                    /* compressed data is sensitive to out of sequence decoding */
-};
-
-struct __attribute__((__packed__)) CodecInfo {
-    Str31                           typeName;                   /* name of the codec type i.e.: 'Apple Image Compression' */
-    short                           version;                    /* version of the codec data that this codec knows about */
-    short                           revisionLevel;              /* revision level of this codec i.e: 0x00010001 (1.0.1) */
-    int32_t                         vendor;                     /* Maker of this codec i.e: 'appl' */
-    int32_t                         decompressFlags;            /* codecInfo flags for decompression capabilities */
-    int32_t                         compressFlags;              /* codecInfo flags for compression capabilities */
-    int32_t                         formatFlags;                /* codecInfo flags for compression format details */
-    UInt8                           compressionAccuracy;        /* measure (1-255) of accuracy of this codec for compress (0 if unknown) */
-    UInt8                           decompressionAccuracy;      /* measure (1-255) of accuracy of this codec for decompress (0 if unknown) */
-    unsigned short                  compressionSpeed;           /* ( millisecs for compressing 320x240 on base mac II) (0 if unknown)  */
-    unsigned short                  decompressionSpeed;         /* ( millisecs for decompressing 320x240 on mac II)(0 if unknown)  */
-    UInt8                           compressionLevel;           /* measure (1-255) of compression level of this codec (0 if unknown)  */
-    UInt8                           resvd;                      /* pad */
-    short                           minimumHeight;              /* minimum height of image (block size) */
-    short                           minimumWidth;               /* minimum width of image (block size) */
-    short                           decompressPipelineLatency;  /* in milliseconds ( for asynchronous codecs ) */
-    short                           compressPipelineLatency;    /* in milliseconds ( for asynchronous codecs ) */
-    int32_t                         privateData;
-};
-typedef struct CodecInfo                CodecInfo;
-
-enum {
-    codecFlagUseImageBuffer     = (1L << 0),                    /* decompress*/
-    codecFlagUseScreenBuffer    = (1L << 1),                    /* decompress*/
-    codecFlagUpdatePrevious     = (1L << 2),                    /* compress*/
-    codecFlagNoScreenUpdate     = (1L << 3),                    /* decompress*/
-    codecFlagWasCompressed      = (1L << 4),                    /* compress*/
-    codecFlagDontOffscreen      = (1L << 5),                    /* decompress*/
-    codecFlagUpdatePreviousComp = (1L << 6),                    /* compress*/
-    codecFlagForceKeyFrame      = (1L << 7),                    /* compress*/
-    codecFlagOnlyScreenUpdate   = (1L << 8),                    /* decompress*/
-    codecFlagLiveGrab           = (1L << 9),                    /* compress*/
-    codecFlagDiffFrame          = (1L << 9),                    /* decompress*/
-    codecFlagDontUseNewImageBuffer = (1L << 10),                /* decompress*/
-    codecFlagInterlaceUpdate    = (1L << 11),                   /* decompress*/
-    codecFlagCatchUpDiff        = (1L << 12),                   /* decompress*/
-    codecFlagSupportDisable     = (1L << 13),                   /* decompress*/
-    codecFlagReenable           = (1L << 14)                    /* decompress*/
-};
-
-static inline void dump_ImageDescription(void* xxx){
-    ImageDescription* id=(ImageDescription*)xxx;
-    unsigned char* x;
-    int i;
-
-    for(i=0;i<id->idSize;i++){
-       printf(" %02X",((unsigned char*)id)[i]);
-       if((i%16)==15) printf("\n");
-    }
-    printf("\n");
-
-
-    printf("=============== ImageDescription at %p ==================\n",xxx);
-    printf("idSize=0x%X  fourcc=0x%08X\n",id->idSize,id->cType);
-    printf("ver=%d rev=%d vendor=0x%08X\n",id->version,id->revisionLevel,id->vendor);
-    printf("tempQ=%d spatQ=%d  dim: %d x %d  dpi: %d x %d  depth: %d\n",
-       id->temporalQuality,id->spatialQuality,
-       id->width, id->height,
-       id->hRes, id->vRes,
-       id->depth);
-    printf("dataSize=%d frameCount=%d clutID=%d\n",id->dataSize, id->frameCount, id->clutID);
-    printf("name='%.*s'\n",((char*)(&id->name))[0],((char*)(&id->name))+1);
-    x=((char*)(&id->clutID))+2;
-    if(id->idSize>sizeof(ImageDescription)){
-       printf("%02X %02X %02X %02X | %02X %02X %02X %02X | %02X %02X %02X %02X | %02X %02X %02X %02X\n",
-       x[0],x[1],x[2],x[3],x[4],x[5],x[6],x[7],x[8],x[9],x[10],x[11],x[12],x[13],x[14],x[15]);
-    }
-    printf("=========================================================\n");
-}
-
-static inline void dump_Rect(char* title,Rect *r){
-    printf("%s: %d;%d - %d;%d\n",title,
-        (int)r->top,(int)r->left,(int)r->bottom,(int)r->right);
-}
-
-static inline void dump_MatrixRecord(char* title, MatrixRecord *m){
-    printf("%s: [%d %d %d][%d %d %d][%d %d %d]\n",title,
-       m->matrix[0][0],m->matrix[0][1],m->matrix[0][2],
-       m->matrix[1][0],m->matrix[1][1],m->matrix[1][2],
-       m->matrix[2][0],m->matrix[2][1],m->matrix[2][2]);
-}
-
-static inline void dump_PixMap(void* xxx){
-    PixMap *p=xxx;
-    printf("=============== PixMap at %p ==================\n",xxx);
-    printf("base=%p  stride=%d\n",p->baseAddr, p->rowBytes);
-    dump_Rect("bounds",&p->bounds);
-    printf("pmVersion=0x%X packType=0x%X\n packSize=0x%X\n",
-       p->pmVersion,p->packType, p->packSize);
-    printf("hRes=0x%X vRes=0x%X pixelType=0x%X pixelSize=0x%X\n",
-       p->hRes,p->vRes,p->pixelType,p->pixelSize);
-    printf("cmpCount=0x%X cmpSize=0x%X pixelFormat=0x%X\n",
-       p->cmpCount,p->cmpSize,p->pixelFormat);
-    printf("pmTable=%p pmExt=%p\n",p->pmTable,p->pmExt);
-    printf("=========================================================\n");
-}
-
-static inline void dump_CodecCapabilities(void* xxx){
-    CodecCapabilities* cc=xxx;
-    if(!xxx) return;
-    printf("=============== CodecCapabilities at %p =================\n",xxx);
-    printf("flags=0x%X  flags2=0x%X\n",cc->flags,cc->flags2);
-    printf("wantedPixelSize=%d extendWidth=%d extendHeight=%d band=%d+%d\n",
-       cc->wantedPixelSize,cc->extendWidth,cc->extendHeight,
-       cc->bandMin,cc->bandInc);
-    printf("pad=0x%X  time=0x%X\n",cc->pad,cc->time);
-    printf("=========================================================\n");
-}
-
-static inline void dump_CodecDecompressParams(void* xxx){
-    CodecDecompressParams* cd=xxx;
-    ImageDescription **idh;
-    int i;
-    if(!xxx) return;
-    printf("=============== CodecDecompressParams at %p ==================\n",xxx);
-    printf("sequenceID=%d\n",cd->sequenceID);
-    idh=cd->imageDescription;
-    if(idh && idh[0]) dump_ImageDescription(idh[0]);
-    
-    for(i=0;i<sizeof(CodecDecompressParams);i++){
-       printf(" %02X",((unsigned char*)cd)[i]);
-       if((i%16)==15) printf("\n");
-    }
-    printf("\n");
-    
-    printf("data=%p  size=%d\n",cd->data,cd->bufferSize);
-    printf("frameno=%d  lines: %d .. %d   condflags=0x%X  callerflags=0x%X\n",
-       cd->frameNumber, cd->startLine, cd->stopLine, cd->conditionFlags,cd->callerFlags);
-//    printf("maskBits=%p mattePixMap=%p\n",
-//     cd->maskBits,cd->mattePixMap);
-    dump_PixMap(&cd->dstPixMap);
-//    if(cd->mattePixMap) dump_PixMap(cd->mattePixMap);
-    if(cd->matrix) dump_MatrixRecord("matrix",cd->matrix);
-    if(cd->capabilities) dump_CodecCapabilities(cd->capabilities);
-    printf("accuracy=%d  transferMode=%d  matrixFlags=0x%X matrixType=%d\n",
-       (int)cd->accuracy, (int)cd->transferMode, (int)cd->matrixFlags, (int)cd->matrixType);
-    printf("srcrect: %d;%d - %d;%d\n",cd->srcRect.top,cd->srcRect.left,cd->srcRect.bottom,cd->srcRect.right);
-    printf("dstrect: %d;%d - %d;%d\n",cd->dstRect.top,cd->dstRect.left,cd->dstRect.bottom,cd->dstRect.right);
-    printf("wantedDestinationPixelTypes=%p\n",cd->wantedDestinationPixelTypes);
-    if(cd->wantedDestinationPixelTypes){
-       unsigned int* p=cd->wantedDestinationPixelTypes;
-       while(p[0]){
-           printf("  0x%08X %.4s\n",p[0],&p[0]);
-           ++p;
-       }
-    }
-    printf("screenFloodMethod=%d value=%d  preferredOffscreenPixelSize=%d\n",
-       cd->screenFloodMethod, cd->screenFloodValue, cd->preferredOffscreenPixelSize);
-    printf("callbacks: progress=%p compl=%p data=%p ftime=%p srcdata=%p sync=%p\n",
-     cd->progressProcRecord, cd->completionProcRecord,
-     cd->dataProcRecord, cd->frameTime, cd->sourceData, cd->syncFrameTime);
-//    printf("\n");
-
-    printf("=========================================================\n");
-
-
-}
-
diff --git a/libs/loader/registry.c b/libs/loader/registry.c
deleted file mode 100644 (file)
index 5bc802f..0000000
+++ /dev/null
@@ -1,551 +0,0 @@
-/*
- * $Id$
- *
- * Copyright (C) 1999 Alexandre Julliard
- *
- * Originally distributed under LPGL 2.1 (or later) by the Wine project.
- *
- * Modified for use with MPlayer, detailed CVS changelog at
- * http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
- *
- * File now distributed as part of VLC media player with no modifications.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
- */
-
-#include "config.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <pwd.h>
-#include <sys/types.h>
-
-#include "wine/winbase.h"
-#include "wine/winreg.h"
-#include "wine/winnt.h"
-#include "wine/winerror.h"
-
-#include "ext.h"
-#include "registry.h"
-
-//#undef TRACE
-//#define TRACE printf
-
-extern char *get_path ( char * );
-
-// ...can be set before init_registry() call
-char* regpathname = NULL;
-
-static char* localregpathname = NULL;
-
-typedef struct reg_handle_s
-{
-       int handle;
-       char* name;
-       struct reg_handle_s* next;
-       struct reg_handle_s* prev;
-} reg_handle_t;
-
-struct reg_value
-{
-       int type;
-       char* name;
-       int len;
-       char* value;
-};
-
-static struct reg_value* regs = NULL;
-static int reg_size;
-static reg_handle_t* head = NULL;
-
-#define DIR -25
-
-static void create_registry(void);
-static void open_registry(void);
-static void save_registry(void);
-static void init_registry(void);
-
-
-static void create_registry(void){
-    if(regs)
-    {
-       printf("Logic error: create_registry() called with existing registry\n");
-       save_registry();
-       return;
-    }
-    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");
-    regs[1].name=(char*)malloc(5);
-    strcpy(regs[1].name, "HKCU");
-    regs[0].value=regs[1].value=NULL;
-    regs[0].len=regs[1].len=0;
-    reg_size=2;
-    head = 0;
-    save_registry();
-}
-
-static void open_registry(void)
-{
-       int fd;
-       int i;
-       unsigned int len;
-       if(regs)
-       {
-               printf("Multiple open_registry(>\n");
-               return;
-       }
-       fd = open(localregpathname, O_RDONLY);
-       if (fd == -1)
-       {
-           printf("Creating new registry\n");
-           create_registry();
-           return;
-       }
-       read(fd, &reg_size, 4);
-       regs=(struct reg_value*)malloc(reg_size*sizeof(struct reg_value));
-       head = 0;
-       for(i=0; i<reg_size; i++)
-       {
-               read(fd,&regs[i].type,4);
-               read(fd,&len,4);
-               regs[i].name=(char*)malloc(len+1);
-               if(regs[i].name==NULL)
-               {
-                       reg_size=i+1;
-                       goto error;
-               }
-               read(fd, regs[i].name, len);
-               regs[i].name[len]=0;
-               read(fd,&regs[i].len,4);
-               regs[i].value=(char*)malloc(regs[i].len+1);
-               if(regs[i].value==NULL)
-               {
-                       free(regs[i].name);
-                       reg_size=i+1;
-                       goto error;
-               }
-               read(fd, regs[i].value, regs[i].len);
-               regs[i].value[regs[i].len]=0;
-       }
-error:
-       close(fd);
-       return;
-}
-
-static void save_registry(void)
-{
-       int fd, i;
-       if (!regs)
-               init_registry();
-       fd = open(localregpathname, O_WRONLY | O_CREAT, 00666);
-       if (fd == -1)
-       {
-           printf("Failed to open registry file '%s' for writing.\n",
-                  localregpathname);
-           return;
-       }
-       write(fd, &reg_size, 4);
-       for(i=0; i<reg_size; i++)
-       {
-               unsigned len=strlen(regs[i].name);
-               write(fd, &regs[i].type, 4);
-               write(fd, &len, 4);
-               write(fd, regs[i].name, len);
-               write(fd, &regs[i].len, 4);
-               write(fd, regs[i].value, regs[i].len);
-       }
-       close(fd);
-}
-
-void free_registry(void)
-{
-    reg_handle_t* t = head;
-    while (t)
-    {
-       reg_handle_t* f = t;
-       free(t->name);
-       t=t->prev;
-        free(f);
-    }
-    head = 0;
-    if (regs)
-    {
-        int i;
-       for(i=0; i<reg_size; i++)
-       {
-           free(regs[i].name);
-           free(regs[i].value);
-       }
-       free(regs);
-       regs = 0;
-    }
-
-    if (localregpathname != regpathname)
-       free(localregpathname);
-    localregpathname = 0;
-}
-
-
-static reg_handle_t* find_handle_by_name(const char* name)
-{
-       reg_handle_t* t;
-       for(t=head; t; t=t->prev)
-       {
-               if(!strcmp(t->name, name))
-               {
-                       return t;
-               }
-       }
-       return 0;
-}
-static struct reg_value* find_value_by_name(const char* name)
-{
-       int i;
-       for(i=0; i<reg_size; i++)
-               if(!strcmp(regs[i].name, name))
-                       return regs+i;
-       return 0;
-}
-static reg_handle_t* find_handle(int handle)
-{
-       reg_handle_t* t;
-       for(t=head; t; t=t->prev)
-       {
-               if(t->handle==handle)
-               {
-                       return t;
-               }
-       }
-       return 0;
-}
-static int generate_handle()
-{
-       static unsigned int zz=249;
-       zz++;
-       while((zz==HKEY_LOCAL_MACHINE) || (zz==HKEY_CURRENT_USER))
-               zz++;
-       return zz;
-}
-
-static reg_handle_t* insert_handle(long handle, const char* name)
-{
-       reg_handle_t* t;
-       t=(reg_handle_t*)malloc(sizeof(reg_handle_t));
-       if(head==NULL)
-       {
-               t->prev=0;
-       }
-       else
-       {
-               head->next=t;
-               t->prev=head;
-       }
-       t->next=0;
-       t->name=(char*)malloc(strlen(name)+1);
-       strcpy(t->name, name);
-       t->handle=handle;
-       head=t;
-       return t;
-}
-static char* build_keyname(long key, const char* subkey)
-{
-       char* full_name;
-       reg_handle_t* t;
-        if((t=find_handle(key))==NULL)
-       {
-               TRACE("Invalid key\n");
-               return NULL;
-       }
-       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);
-       return full_name;
-}
-static struct reg_value* insert_reg_value(int handle, const char* name, int type, const void* value, int len)
-{
-       reg_handle_t* t;
-       struct reg_value* v;
-       char* fullname;
-       if((fullname=build_keyname(handle, name))==NULL)
-       {
-               TRACE("Invalid handle\n");
-               return NULL;
-       }
-
-       if((v=find_value_by_name(fullname))==NULL)
-       //creating new value in registry
-       {
-               if(regs==NULL)
-                   create_registry();
-               regs=(struct reg_value*)realloc(regs, sizeof(struct reg_value)*(reg_size+1));
-               //regs=(struct reg_value*)my_realloc(regs, sizeof(struct reg_value)*(reg_size+1));
-               v=regs+reg_size;
-               reg_size++;
-       }
-       else
-       //replacing old one
-       {
-           free(v->value);
-           free(v->name);
-       }
-       TRACE("RegInsert '%s'  %p  v:%d  len:%d\n", name, value, *(int*)value, len);
-       v->type=type;
-       v->len=len;
-       v->value=(char*)malloc(len);
-       memcpy(v->value, value, len);
-       v->name=(char*)malloc(strlen(fullname)+1);
-       strcpy(v->name, fullname);
-        free(fullname);
-       save_registry();
-       return v;
-}
-
-static void init_registry(void)
-{
-       TRACE("Initializing registry\n");
-       // can't be free-ed - it's static and probably thread
-       // unsafe structure which is stored in glibc
-
-#ifdef MPLAYER
-       regpathname = get_path("registry");
-       localregpathname = regpathname;
-#else
-       // regpathname is an external pointer
-        //
-       // registry.c is holding its own internal pointer
-       // localregpathname  - which is being allocate/deallocated
-
-       if (localregpathname == NULL)
-       {
-            const char* pthn = regpathname;
-           if (!regpathname)
-           {
-               // avifile - for now reading data from user's home
-               struct passwd* pwent;
-               pwent = getpwuid(geteuid());
-                pthn = pwent->pw_dir;
-           }
-
-           localregpathname = (char*)malloc(strlen(pthn)+20);
-           strcpy(localregpathname, pthn);
-           strcat(localregpathname, "/.registry");
-       }
-#endif
-
-       open_registry();
-       insert_handle(HKEY_LOCAL_MACHINE, "HKLM");
-       insert_handle(HKEY_CURRENT_USER, "HKCU");
-}
-
-static reg_handle_t* find_handle_2(long key, const char* subkey)
-{
-       char* full_name;
-       reg_handle_t* t;
-        if((t=find_handle(key))==NULL)
-       {
-               TRACE("Invalid key\n");
-               return (reg_handle_t*)-1;
-       }
-       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);
-       t=find_handle_by_name(full_name);
-       free(full_name);
-       return t;
-}
-
-long __stdcall RegOpenKeyExA(long key, const char* subkey, long reserved, long access, int* newkey)
-{
-    char* full_name;
-    reg_handle_t* t;
-    struct reg_value* v;
-    TRACE("Opening key %s\n", subkey);
-
-    if(!regs)
-        init_registry()
-;
-/*     t=find_handle_2(key, subkey);
-
-       if(t==0)
-               return -1;
-
-       if(t==(reg_handle_t*)-1)
-               return -1;
-*/
-    full_name=build_keyname(key, subkey);
-    if(!full_name)
-        return -1;
-    TRACE("Opening key Fullname %s\n", full_name);
-    v=find_value_by_name(full_name);
-
-    t=insert_handle(generate_handle(), full_name);
-    *newkey=t->handle;
-    free(full_name);
-
-    return 0;
-}
-long __stdcall RegCloseKey(long key)
-{
-    reg_handle_t *handle;
-    if(key==(long)HKEY_LOCAL_MACHINE)
-       return 0;
-    if(key==(long)HKEY_CURRENT_USER)
-       return 0;
-    handle=find_handle(key);
-    if(handle==NULL)
-       return 0;
-    if(handle->prev)
-       handle->prev->next=handle->next;
-    if(handle->next)
-       handle->next->prev=handle->prev;
-    free(handle->name);
-    if(handle==head)
-       head=head->prev;
-    free(handle);
-    return 1;
-}
-
-long __stdcall RegQueryValueExA(long key, const char* value, int* reserved, int* type, int* data, int* count)
-{
-    struct reg_value* t;
-    char* c;
-    TRACE("Querying value %s\n", value);
-    if(!regs)
-       init_registry();
-
-    c=build_keyname(key, value);
-    if (!c)
-       return 1;
-    t=find_value_by_name(c);
-    free(c);
-    if (t==NULL)
-       return 2;
-    if (type)
-       *type=t->type;
-    if (data)
-    {
-       memcpy(data, t->value, (t->len<*count)?t->len:*count);
-       TRACE("returning %d bytes: %d\n", t->len, *(int*)data);
-    }
-    if(*count<t->len)
-    {
-       *count=t->len;
-       return ERROR_MORE_DATA;
-    }
-    else
-    {
-       *count=t->len;
-    }
-    return 0;
-}
-long __stdcall RegCreateKeyExA(long key, const char* name, long reserved,
-                    void* classs, long options, long security,
-                    void* sec_attr, int* newkey, int* status)
-{
-    reg_handle_t* t;
-    char* fullname;
-    struct reg_value* v;
-    //        TRACE("Creating/Opening key %s\n", name);
-    if(!regs)
-       init_registry();
-
-    fullname=build_keyname(key, name);
-    if (!fullname)
-       return 1;
-    TRACE("Creating/Opening key %s\n", fullname);
-    v=find_value_by_name(fullname);
-    if(v==NULL)
-    {
-       int qw=45708;
-       v=insert_reg_value(key, name, DIR, &qw, 4);
-       if (status) *status=REG_CREATED_NEW_KEY;
-       //              return 0;
-    }
-
-    t=insert_handle(generate_handle(), fullname);
-    *newkey=t->handle;
-    free(fullname);
-    return 0;
-}
-
-/*
-LONG RegEnumValue(
-  HKEY hKey,              // handle to key to query
-  DWORD dwIndex,          // index of value to query
-  LPTSTR lpValueName,     // address of buffer for value string
-  LPDWORD lpcbValueName,  // address for size of value buffer
-  LPDWORD lpReserved,     // reserved
-  LPDWORD lpType,         // address of buffer for type code
-  LPBYTE lpData,          // address of buffer for value data
-  LPDWORD lpcbData        // address for size of data buffer
-);
-*/
-
-long __stdcall RegEnumValueA(HKEY hkey, DWORD index, LPSTR value, LPDWORD val_count,
-                  LPDWORD reserved, LPDWORD type, LPBYTE data, LPDWORD count)
-{
-    // currenly just made to support MSZH & ZLIB
-    //printf("Reg Enum 0x%x %d  %s %d   data: %p %d  %d >%s<\n", hkey, index,
-    //       value, *val_count, data, *count, reg_size, data);
-    reg_handle_t* t = find_handle(hkey);
-    if (t && index < 10)
-    {
-       struct reg_value* v=find_value_by_name(t->name);
-       if (v)
-       {
-           memcpy(data, v->value, (v->len < *count) ? v->len : *count);
-           if(*count < v->len)
-               *count = v->len;
-           if (type)
-               *type = v->type;
-           //printf("Found handle  %s\n", v->name);
-           return 0;
-       }
-    }
-    return ERROR_NO_MORE_ITEMS;
-}
-
-long __stdcall RegSetValueExA(long key, const char* name, long v1, long v2, const void* data, long size)
-{
-    struct reg_value* t;
-    char* c;
-    TRACE("Request to set value %s %d\n", name, *(const int*)data);
-    if(!regs)
-       init_registry();
-
-    c=build_keyname(key, name);
-    if(c==NULL)
-       return 1;
-    insert_reg_value(key, name, v2, data, size);
-    free(c);
-    return 0;
-}
-
-long __stdcall RegEnumKeyExA(HKEY hKey, DWORD dwIndex, LPSTR lpName, LPDWORD lpcbName,
-                  LPDWORD lpReserved, LPSTR lpClass, LPDWORD lpcbClass,
-                  LPFILETIME lpftLastWriteTime)
-{
-    return ERROR_NO_MORE_ITEMS;
-}
diff --git a/libs/loader/registry.h b/libs/loader/registry.h
deleted file mode 100644 (file)
index fd27576..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-#ifndef AVIFILE_REGISTRY_H
-#define AVIFILE_REGISTRY_H
-
-/********************************************************
- *
- *       Declaration of registry access functions
- *       Copyright 2000 Eugene Kuznetsov  (divx@euro.ru)
- *
- ********************************************************/
-
-/*
- * Modified for use with MPlayer, detailed CVS changelog at
- * http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
- * $Id$
- */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void free_registry(void);
-
-long __stdcall RegOpenKeyExA(long key, const char* subkey, long reserved,
-                  long access, int* newkey);
-long __stdcall RegCloseKey(long key);
-long __stdcall RegQueryValueExA(long key, const char* value, int* reserved,
-                     int* type, int* data, int* count);
-long __stdcall RegCreateKeyExA(long key, const char* name, long reserved,
-                    void* classs, long options, long security,
-                    void* sec_attr, int* newkey, int* status);
-long __stdcall RegSetValueExA(long key, const char* name, long v1, long v2,
-                   const void* data, long size);
-
-#ifdef __WINE_WINERROR_H
-
-long __stdcall RegEnumKeyExA(HKEY hKey, DWORD dwIndex, LPSTR lpName, LPDWORD lpcbName,
-                  LPDWORD lpReserved, LPSTR lpClass, LPDWORD lpcbClass,
-                  LPFILETIME lpftLastWriteTime);
-long __stdcall RegEnumValueA(HKEY hkey, DWORD index, LPSTR value, LPDWORD val_count,
-                  LPDWORD reserved, LPDWORD type, LPBYTE data, LPDWORD count);
-#endif
-#ifdef __cplusplus
-};
-#endif
-
-#endif // AVIFILE_REGISTRY_H
diff --git a/libs/loader/resource.c b/libs/loader/resource.c
deleted file mode 100644 (file)
index 3560dd0..0000000
+++ /dev/null
@@ -1,504 +0,0 @@
-/*
- * Resources
- * $Id$
- *
- * Copyright 1993 Robert J. Amstadt
- * Copyright 1995 Alexandre Julliard
- *
- * Originally distributed under LPGL 2.1 (or later) by the Wine project.
- *
- * Modified for use with MPlayer, detailed CVS changelog at
- * http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
- *
- * File now distributed as part of VLC media player with no modifications.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
- */
-#include "config.h"
-
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-
-#include "wine/winbase.h"
-#include "wine/windef.h"
-#include "wine/winuser.h"
-#include "wine/heap.h"
-#include "wine/module.h"
-#include "wine/debugtools.h"
-#include "wine/winerror.h"
-#include "loader.h"
-
-#define CP_ACP                                 0
-
-WORD WINE_LanguageId=0x409;//english
-
-#define HRSRC_MAP_BLOCKSIZE 16
-
-typedef struct _HRSRC_ELEM
-{
-    HANDLE hRsrc;
-    WORD     type;
-} HRSRC_ELEM;
-
-typedef struct _HRSRC_MAP
-{
-    int nAlloc;
-    int nUsed;
-    HRSRC_ELEM *elem;
-} HRSRC_MAP;
-
-static HRSRC RES_FindResource2( HMODULE hModule, LPCSTR type,
-                               LPCSTR name, WORD lang, int unicode)
-{
-    HRSRC hRsrc = 0;
-    LPWSTR typeStr, nameStr;    
-    WINE_MODREF *wm = MODULE32_LookupHMODULE( hModule );
-
-    if(!wm)
-       return 0;    
-    /* 32-bit PE module */
-
-    
-    if ( HIWORD( type ) && (!unicode))
-       typeStr = HEAP_strdupAtoW( GetProcessHeap(), 0, type );
-    else
-       typeStr = (LPWSTR)type;
-    if ( HIWORD( name ) && (!unicode))
-       nameStr = HEAP_strdupAtoW( GetProcessHeap(), 0, name );
-    else
-       nameStr = (LPWSTR)name;
-    
-    hRsrc = PE_FindResourceExW( wm, nameStr, typeStr, lang );
-    
-    if ( HIWORD( type ) && (!unicode)) 
-       HeapFree( GetProcessHeap(), 0, typeStr );
-    if ( HIWORD( name ) && (!unicode)) 
-       HeapFree( GetProcessHeap(), 0, nameStr );
-
-    return hRsrc;
-}
-
-/**********************************************************************
- *          RES_FindResource
- */
-
-static HRSRC RES_FindResource( HMODULE hModule, LPCSTR type,
-                               LPCSTR name, WORD lang, int unicode )
-{
-    HRSRC hRsrc;
-//    __TRY
-//    {
-       hRsrc = RES_FindResource2(hModule, type, name, lang, unicode);
-//    }
-//    __EXCEPT(page_fault)
-//    {
-//     WARN("page fault\n");
-//     SetLastError(ERROR_INVALID_PARAMETER);
-//     return 0;
-//    }
-//    __ENDTRY
-    return hRsrc;
-}
-
-/**********************************************************************
- *          RES_SizeofResource
- */
-static DWORD RES_SizeofResource( HMODULE hModule, HRSRC hRsrc)
-{
-    DWORD size = 0;
-    HRSRC hRsrc32;
-
-//    HMODULE16 hMod16   = MapHModuleLS( hModule );
-//    NE_MODULE *pModule = NE_GetPtr( hMod16 );
-//    WINE_MODREF *wm    = pModule && pModule->module32? 
-//                         MODULE32_LookupHMODULE( pModule->module32 ) : NULL;
-    WINE_MODREF *wm = MODULE32_LookupHMODULE( hModule );
-
-    if ( !hModule || !hRsrc ) return 0;
-
-    /* 32-bit PE module */
-    /* If we got a 16-bit hRsrc, convert it */
-//    hRsrc32  = HIWORD(hRsrc)? hRsrc : MapHRsrc16To32( pModule, hRsrc );
-    if(!HIWORD(hRsrc))
-    {
-       printf("16-bit hRsrcs not supported\n");
-       return 0;
-    }  
-    size = PE_SizeofResource( hModule, hRsrc );
-    return size;
-}
-
-/**********************************************************************
- *          RES_AccessResource
- */
-static HFILE RES_AccessResource( HMODULE hModule, HRSRC hRsrc )
-{
-    HFILE hFile = HFILE_ERROR;
-
-    WINE_MODREF *wm = MODULE32_LookupHMODULE( hModule );
-
-    if ( !hModule || !hRsrc ) return HFILE_ERROR;
-
-    /* 32-bit PE module */
-    FIXME("32-bit modules not yet supported.\n" );
-    hFile = HFILE_ERROR;
-
-    return hFile;
-}
-
-/**********************************************************************
- *          RES_LoadResource
- */
-static HGLOBAL RES_LoadResource( HMODULE hModule, HRSRC hRsrc)
-{
-    HGLOBAL hMem = 0;
-    HRSRC hRsrc32;
-    WINE_MODREF *wm = MODULE32_LookupHMODULE( hModule );
-
-
-    if ( !hModule || !hRsrc ) return 0;
-
-    /* 32-bit PE module */
-
-    /* If we got a 16-bit hRsrc, convert it */
-//    hRsrc32 = HIWORD(hRsrc)? hRsrc : MapHRsrc16To32( pModule, hRsrc );
-    if(!HIWORD(hRsrc))
-    {
-       printf("16-bit hRsrcs not supported\n");
-       return 0;
-    }
-    hMem = PE_LoadResource( wm, hRsrc );
-
-    return hMem;
-}
-
-/**********************************************************************
- *          RES_LockResource
- */
-static LPVOID RES_LockResource( HGLOBAL handle )
-{
-    LPVOID bits = NULL;
-
-    TRACE("(%08x, %s)\n", handle, "PE" );
-
-    bits = (LPVOID)handle;
-
-    return bits;
-}
-
-/**********************************************************************
- *          RES_FreeResource
- */
-static WIN_BOOL RES_FreeResource( HGLOBAL handle )
-{
-    HGLOBAL retv = handle;
-    return (WIN_BOOL)retv;
-}
-
-/**********************************************************************
- *         FindResourceA    (KERNEL32.128)
- */
-HANDLE WINAPI FindResourceA( HMODULE hModule, LPCSTR name, LPCSTR type )
-{
-    return RES_FindResource( hModule, type, name, 
-                             WINE_LanguageId, 0);
-}
-HANDLE WINAPI FindResourceW( HMODULE hModule, LPCWSTR name, LPCWSTR type )
-{
-    return RES_FindResource( hModule, (LPCSTR)type, (LPCSTR)name, 
-                             WINE_LanguageId, 1);
-}
-
-/**********************************************************************
- *         FindResourceExA  (KERNEL32.129)
- */
-HANDLE WINAPI FindResourceExA( HMODULE hModule, 
-                               LPCSTR type, LPCSTR name, WORD lang )
-{
-    return RES_FindResource( hModule, type, name, 
-                             lang, 0 );
-}
-
-HANDLE WINAPI FindResourceExW( HMODULE hModule, 
-                               LPCWSTR type, LPCWSTR name, WORD lang )
-{
-    return RES_FindResource( hModule, (LPCSTR)type, (LPCSTR)name, 
-                             lang, 1 );
-}
-
-
-
-/**********************************************************************
- *         LockResource     (KERNEL32.384)
- */
-LPVOID WINAPI LockResource( HGLOBAL handle )
-{
-    return RES_LockResource( handle );
-}
-
-
-/**********************************************************************
- *         FreeResource     (KERNEL32.145)
- */
-WIN_BOOL WINAPI FreeResource( HGLOBAL handle )
-{
-    return RES_FreeResource( handle );
-}
-
-
-/**********************************************************************
- *         AccessResource   (KERNEL32.64)
- */
-INT WINAPI AccessResource( HMODULE hModule, HRSRC hRsrc )
-{
-    return RES_AccessResource( hModule, hRsrc );
-}
-/**********************************************************************
- *         SizeofResource   (KERNEL32.522)
- */
-DWORD WINAPI SizeofResource( HINSTANCE hModule, HRSRC hRsrc )
-{
-    return RES_SizeofResource( hModule, hRsrc );
-}
-
-
-INT WINAPI LoadStringW( HINSTANCE instance, UINT resource_id,
-                            LPWSTR buffer, INT buflen );
-
-/**********************************************************************
- *     LoadStringA     (USER32.375)
- */
-INT WINAPI LoadStringA( HINSTANCE instance, UINT resource_id,
-                            LPSTR buffer, INT buflen )
-{
-    INT    retval;
-    INT    wbuflen;
-    INT    abuflen;
-    LPWSTR wbuf = NULL;
-    LPSTR  abuf = NULL;
-
-    if ( buffer != NULL && buflen > 0 )
-       *buffer = 0;
-
-    wbuflen = LoadStringW(instance,resource_id,NULL,0);
-    if ( !wbuflen )
-       return 0;
-    wbuflen ++;
-
-    retval = 0;
-    wbuf = (LPWSTR) HeapAlloc( GetProcessHeap(), 0, wbuflen * sizeof(WCHAR) );
-    wbuflen = LoadStringW(instance,resource_id,wbuf,wbuflen);
-    if ( wbuflen > 0 )
-    {
-       abuflen = WideCharToMultiByte(CP_ACP,0,wbuf,wbuflen,NULL,0,NULL,NULL);
-       if ( abuflen > 0 )
-       {
-           if ( buffer == NULL || buflen == 0 )
-               retval = abuflen;
-           else
-           {
-               abuf = (LPSTR) HeapAlloc( GetProcessHeap(), 0, abuflen * sizeof(CHAR) );
-               abuflen = WideCharToMultiByte(CP_ACP,0,wbuf,wbuflen,abuf,abuflen,NULL,NULL);
-               if ( abuflen > 0 )
-               {
-                   abuflen = min(abuflen,buflen - 1);
-                   memcpy( buffer, abuf, abuflen );
-                   buffer[abuflen] = 0;
-                   retval = abuflen;
-               }
-               HeapFree( GetProcessHeap(), 0, abuf );
-           }
-       }
-    }
-    HeapFree( GetProcessHeap(), 0, wbuf );
-
-    return retval;
-}
-
-/**********************************************************************
- *     LoadStringW             (USER32.376)
- */
-INT WINAPI LoadStringW( HINSTANCE instance, UINT resource_id,
-                            LPWSTR buffer, INT buflen )
-{
-    HGLOBAL hmem;
-    HRSRC hrsrc;
-    WCHAR *p;
-    int string_num;
-    int i;
-
-    if (HIWORD(resource_id)==0xFFFF) /* netscape 3 passes this */
-       resource_id = (UINT)(-((INT)resource_id));
-    TRACE("instance = %04x, id = %04x, buffer = %08x, "
-          "length = %d\n", instance, (int)resource_id, (int) buffer, buflen);
-
-    /* Use bits 4 - 19 (incremented by 1) as resourceid, mask out 
-     * 20 - 31. */
-    hrsrc = FindResourceW( instance, (LPCWSTR)(((resource_id>>4)&0xffff)+1),
-                             RT_STRINGW );
-    if (!hrsrc) return 0;
-    hmem = LoadResource( instance, hrsrc );
-    if (!hmem) return 0;
-    
-    p = (WCHAR*) LockResource(hmem);
-    string_num = resource_id & 0x000f;
-    for (i = 0; i < string_num; i++)
-       p += *p + 1;
-    
-    TRACE("strlen = %d\n", (int)*p );
-    
-    if (buffer == NULL) return *p;
-    i = min(buflen - 1, *p);
-    if (i > 0) {
-       memcpy(buffer, p + 1, i * sizeof (WCHAR));
-       buffer[i] = (WCHAR) 0;
-    } else {
-       if (buflen > 1) {
-           buffer[0] = (WCHAR) 0;
-           return 0;
-       }
-#if 0
-       WARN("Don't know why caller give buflen=%d *p=%d trying to obtain string '%s'\n", buflen, *p, p + 1);
-#endif
-    }
-
-    TRACE("String loaded !\n");
-    return i;
-}
-
-/* Messages...used by FormatMessage32* (KERNEL32.something)
- * 
- * They can be specified either directly or using a message ID and
- * loading them from the resource.
- * 
- * The resourcedata has following format:
- * start:
- * 0: DWORD nrofentries
- * nrofentries * subentry:
- *     0: DWORD firstentry
- *     4: DWORD lastentry
- *      8: DWORD offset from start to the stringentries
- *
- * (lastentry-firstentry) * stringentry:
- * 0: WORD len (0 marks end)
- * 2: WORD flags
- * 4: CHAR[len-4]
- *     (stringentry i of a subentry refers to the ID 'firstentry+i')
- *
- * Yes, ANSI strings in win32 resources. Go figure.
- */
-
-/**********************************************************************
- *     LoadMessageA            (internal)
- */
-INT WINAPI LoadMessageA( HMODULE instance, UINT id, WORD lang,
-                      LPSTR buffer, INT buflen )
-{
-    HGLOBAL    hmem;
-    HRSRC      hrsrc;
-    PMESSAGE_RESOURCE_DATA     mrd;
-    PMESSAGE_RESOURCE_BLOCK    mrb;
-    PMESSAGE_RESOURCE_ENTRY    mre;
-    int                i,slen;
-
-    TRACE("instance = %08lx, id = %08lx, buffer = %p, length = %ld\n", (DWORD)instance, (DWORD)id, buffer, (DWORD)buflen);
-
-    /*FIXME: I am not sure about the '1' ... But I've only seen those entries*/
-    hrsrc = FindResourceExW(instance,RT_MESSAGELISTW,(LPWSTR)1,lang);
-    if (!hrsrc) return 0;
-    hmem = LoadResource( instance, hrsrc );
-    if (!hmem) return 0;
-    
-    mrd = (PMESSAGE_RESOURCE_DATA)LockResource(hmem);
-    mre = NULL;
-    mrb = &(mrd->Blocks[0]);
-    for (i=mrd->NumberOfBlocks;i--;) {
-       if ((id>=mrb->LowId) && (id<=mrb->HighId)) {
-           mre = (PMESSAGE_RESOURCE_ENTRY)(((char*)mrd)+mrb->OffsetToEntries);
-           id  -= mrb->LowId;
-           break;
-       }
-       mrb++;
-    }
-    if (!mre)
-       return 0;
-    for (i=id;i--;) {
-       if (!mre->Length)
-               return 0;
-       mre = (PMESSAGE_RESOURCE_ENTRY)(((char*)mre)+(mre->Length));
-    }
-    slen=mre->Length;
-    TRACE("    - strlen=%d\n",slen);
-    i = min(buflen - 1, slen);
-    if (buffer == NULL)
-       return slen;
-    if (i>0) {
-       lstrcpynA(buffer,(char*)mre->Text,i);
-       buffer[i]=0;
-    } else {
-       if (buflen>1) {
-           buffer[0]=0;
-           return 0;
-       }
-    }
-    if (buffer)
-           TRACE("'%s' copied !\n", buffer);
-    return i;
-}
-
-
-
-/**********************************************************************
- *     EnumResourceTypesA      (KERNEL32.90)
- */
-WIN_BOOL WINAPI EnumResourceTypesA( HMODULE hmodule,ENUMRESTYPEPROCA lpfun,
-                                    LONG lParam)
-{
-       /* FIXME: move WINE_MODREF stuff here */
-    return PE_EnumResourceTypesA(hmodule,lpfun,lParam);
-}
-
-/**********************************************************************
- *     EnumResourceNamesA      (KERNEL32.88)
- */
-WIN_BOOL WINAPI EnumResourceNamesA( HMODULE hmodule, LPCSTR type,
-                                    ENUMRESNAMEPROCA lpfun, LONG lParam )
-{
-       /* FIXME: move WINE_MODREF stuff here */
-    return PE_EnumResourceNamesA(hmodule,type,lpfun,lParam);
-}
-/**********************************************************************
- *     EnumResourceLanguagesA  (KERNEL32.86)
- */
-WIN_BOOL WINAPI EnumResourceLanguagesA( HMODULE hmodule, LPCSTR type,
-                                        LPCSTR name, ENUMRESLANGPROCA lpfun,
-                                        LONG lParam)
-{
-       /* FIXME: move WINE_MODREF stuff here */
-    return PE_EnumResourceLanguagesA(hmodule,type,name,lpfun,lParam);
-}
-/**********************************************************************
- *         LoadResource     (KERNEL32.370)
- */
-HGLOBAL WINAPI LoadResource( HINSTANCE hModule, HRSRC hRsrc )
-{
-    return RES_LoadResource( hModule, hRsrc);
-}
diff --git a/libs/loader/stubs.s b/libs/loader/stubs.s
deleted file mode 100644 (file)
index 24d99aa..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-       .data
-.LC0:  .string "Called unk_%s\n"
-       .balign 4
-.globl unk_exp1
-unk_exp1:
-       pushl %ebp
-       movl %esp,%ebp
-       subl $4,%esp
-       movl $1,-4(%ebp)
-       movl -4(%ebp),%eax
-       movl %eax,%ecx
-       movl %ecx,%edx
-       sall $4,%edx
-       subl %eax,%edx
-       leal 0(,%edx,2),%eax
-       movl %eax,%edx
-       addl $export_names,%edx
-       pushl %edx
-       pushl $.LC0
-       call printf
-       addl $8,%esp
-       xorl %eax,%eax
-       leave
-       ret
-.globl exp_EH_prolog
-exp_EH_prolog:
-       pushl $0xff
-       pushl %eax
-       pushl %fs:0
-       movl  %esp, %fs:0
-       movl  12(%esp), %eax
-       movl  %ebp, 12(%esp)
-       leal  12(%esp), %ebp
-       pushl %eax
-       ret
diff --git a/libs/loader/vfl.c b/libs/loader/vfl.c
deleted file mode 100644 (file)
index cc3b866..0000000
+++ /dev/null
@@ -1,247 +0,0 @@
-/*
- * $Id$
- *
- * Copyright 1998 Marcus Meissner
- *
- * Modified for use with MPlayer, detailed CVS changelog at
- * http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
- *
- * File now distributed as part of VLC media player with no modifications.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
- */
-#include <config.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "win32.h"
-#include "loader.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/avifmt.h"
-#include "driver.h"
-
-#define OpenDriverA DrvOpen
-#define CloseDriver DrvClose
-
-/***********************************************************************
- *             VideoForWindowsVersion          [MSVFW.2][MSVIDEO.2]
- * Returns the version in major.minor form.
- * In Windows95 this returns 0x040003b6 (4.950)
- */
-long VFWAPI VideoForWindowsVersion(void) {
-       return 0x040003B6; /* 4.950 */
-}
-
-/* system.ini: [drivers] */
-
-/***********************************************************************
- *             ICInfo                          [MSVFW.33]
- * Get information about an installable compressor. Return TRUE if there
- * is one.
- */
-int VFWAPI
-ICInfo(
-       long fccType,           /* [in] type of compressor ('vidc') */
-       long fccHandler,        /* [in] <n>th compressor */
-       ICINFO *lpicinfo        /* [out] information about compressor */
-) {
-       /* does OpenDriver/CloseDriver */
-       lpicinfo->dwSize = sizeof(ICINFO);
-       lpicinfo->fccType = fccType;
-       lpicinfo->dwFlags = 0;
-       return TRUE;
-}
-
-/***********************************************************************
- *             ICOpen                          [MSVFW.37]
- * Opens an installable compressor. Return special handle.
- */
-HIC VFWAPI
-//ICOpen(long fccType,long fccHandler,unsigned int wMode) {
-ICOpen(long filename,long fccHandler,unsigned int wMode) {
-       ICOPEN          icopen;
-       HDRVR           hdrv;
-       WINE_HIC        *whic;
-
-       /* Well, lParam2 is in fact a LPVIDEO_OPEN_PARMS, but it has the 
-        * same layout as ICOPEN
-        */
-       icopen.fccType          = 0x63646976; // "vidc" //fccType;
-       icopen.fccHandler       = fccHandler;
-       icopen.dwSize           = sizeof(ICOPEN);
-       icopen.dwFlags          = wMode;
-       icopen.pV1Reserved      = (void*)filename;
-       /* FIXME: do we need to fill out the rest too? */
-       hdrv=OpenDriverA((long)&icopen);
-       if (!hdrv) return 0;
-       whic = (WINE_HIC*)malloc(sizeof(WINE_HIC));
-       whic->hdrv      = hdrv;
-       whic->driverproc= ((DRVR*)hdrv)->DriverProc;
-//     whic->private   = ICSendMessage((HIC)whic,DRV_OPEN,0,(long)&icopen);
-       whic->driverid  = ((DRVR*)hdrv)->dwDriverID;
-       return (HIC)whic;
-}
-
-/***********************************************************************
- *             ICGetInfo                       [MSVFW.30]
- */
-LRESULT VFWAPI
-ICGetInfo(HIC hic,ICINFO *picinfo,long cb) {
-       LRESULT         ret;
-
-       ret = ICSendMessage(hic,ICM_GETINFO,(long)picinfo,cb);
-       
-       return ret;
-}
-
-/***********************************************************************
- *             ICCompress                      [MSVFW.23]
- */
-long VFWAPIV
-ICCompress(
-       HIC hic,long dwFlags,LPBITMAPINFOHEADER lpbiOutput,void* lpData,
-       LPBITMAPINFOHEADER lpbiInput,void* lpBits,long* lpckid,
-       long* lpdwFlags,long lFrameNum,long dwFrameSize,long dwQuality,
-       LPBITMAPINFOHEADER lpbiPrev,void* lpPrev
-) {
-       ICCOMPRESS      iccmp;
-
-       iccmp.dwFlags           = dwFlags;
-
-       iccmp.lpbiOutput        = lpbiOutput;
-       iccmp.lpOutput          = lpData;
-       iccmp.lpbiInput         = lpbiInput;
-       iccmp.lpInput           = lpBits;
-
-       iccmp.lpckid            = lpckid;
-       iccmp.lpdwFlags         = lpdwFlags;
-       iccmp.lFrameNum         = lFrameNum;
-       iccmp.dwFrameSize       = dwFrameSize;
-       iccmp.dwQuality         = dwQuality;
-       iccmp.lpbiPrev          = lpbiPrev;
-       iccmp.lpPrev            = lpPrev;
-       return ICSendMessage(hic,ICM_COMPRESS,(long)&iccmp,sizeof(iccmp));
-}
-
-/***********************************************************************
- *             ICDecompress                    [MSVFW.26]
- */
-long VFWAPIV 
-ICDecompress(HIC hic,long dwFlags,LPBITMAPINFOHEADER lpbiFormat,void* lpData,LPBITMAPINFOHEADER  lpbi,void* lpBits) {
-       ICDECOMPRESS    icd;
-       int result;
-       icd.dwFlags     = dwFlags;
-       icd.lpbiInput   = lpbiFormat;
-       icd.lpInput     = lpData;
-
-       icd.lpbiOutput  = lpbi;
-       icd.lpOutput    = lpBits;
-       icd.ckid        = 0;
-       result=ICSendMessage(hic,ICM_DECOMPRESS,(long)&icd,sizeof(icd));
-       return result;
-}
-
-/***********************************************************************
- *             ICDecompressEx                  [MSVFW.26]
- */
-long VFWAPIV 
-ICDecompressEx(HIC hic,long dwFlags,LPBITMAPINFOHEADER lpbiFormat,void* lpData,LPBITMAPINFOHEADER  lpbi,void* lpBits) {
-       ICDECOMPRESSEX  icd;
-       int result;
-       
-       icd.dwFlags     = dwFlags;
-
-       icd.lpbiSrc     = lpbiFormat;
-       icd.lpSrc       = lpData;
-
-       icd.lpbiDst     = lpbi;
-       icd.lpDst       = lpBits;
-       
-       icd.xSrc=icd.ySrc=0;
-       icd.dxSrc=lpbiFormat->biWidth;
-       icd.dySrc=abs(lpbiFormat->biHeight);
-
-       icd.xDst=icd.yDst=0;
-       icd.dxDst=lpbi->biWidth;
-       icd.dyDst=abs(lpbi->biHeight);
-       
-       //icd.ckid      = 0;
-       result=ICSendMessage(hic,ICM_DECOMPRESSEX,(long)&icd,sizeof(icd));
-       return result;
-}
-
-long VFWAPIV 
-ICUniversalEx(HIC hic,int command,LPBITMAPINFOHEADER lpbiFormat,LPBITMAPINFOHEADER lpbi) {
-       ICDECOMPRESSEX  icd;
-       int result;
-       
-       icd.dwFlags     = 0;
-
-       icd.lpbiSrc     = lpbiFormat;
-       icd.lpSrc       = 0;
-
-       icd.lpbiDst     = lpbi;
-       icd.lpDst       = 0;
-       
-       icd.xSrc=icd.ySrc=0;
-       icd.dxSrc=lpbiFormat->biWidth;
-       icd.dySrc=abs(lpbiFormat->biHeight);
-
-       icd.xDst=icd.yDst=0;
-       icd.dxDst=lpbi->biWidth;
-       icd.dyDst=abs(lpbi->biHeight);
-       
-       //icd.ckid      = 0;
-       result=ICSendMessage(hic,command,(long)&icd,sizeof(icd));
-       return result;
-}
-
-
-/***********************************************************************
- *             ICSendMessage                   [MSVFW.40]
- */
-LRESULT VFWAPI
-ICSendMessage(HIC hic,unsigned int msg,long lParam1,long lParam2) {
-    WINE_HIC   *whic = (WINE_HIC*)hic;
-    return SendDriverMessage(whic->hdrv, msg, lParam1,lParam2);
-}
-
-
-/***********************************************************************
- *             ICClose                 [MSVFW.22]
- */
-LRESULT VFWAPI ICClose(HIC hic) {
-       WINE_HIC        *whic = (WINE_HIC*)hic;
-       /* FIXME: correct? */
-//     CloseDriver(whic->hdrv,0,0);
-        DrvClose(whic->hdrv);
-//#warning FIXME: DrvClose
-       free(whic);
-       return 0;
-}
-
-int VFWAPI ICDoSomething()
-{
-  return 0;
-}
-
diff --git a/libs/loader/win32.c b/libs/loader/win32.c
deleted file mode 100644 (file)
index 7f4acf1..0000000
+++ /dev/null
@@ -1,5416 +0,0 @@
-/*
- * $Id$
- *
- * Originally distributed under LPGL 2.1 (or later) by the Wine project.
- *
- * Modified for use with MPlayer, detailed CVS changelog at
- * http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
- *
- * File now distributed as part of VLC media player with no modifications.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
- */
-
-/***********************************************************
-
-Win32 emulation code. Functions that emulate
-responses from corresponding Win32 API calls.
-Since we are not going to be able to load
-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.
-
-************************************************************/
-
-#include "config.h"
-
-#ifdef MPLAYER
-#ifdef USE_QTX_CODECS
-#define QTX
-#endif
-#define REALPLAYER
-//#define LOADLIB_TRY_NATIVE
-#endif
-
-#ifdef QTX
-#define PSEUDO_SCREEN_WIDTH    /*640*/800
-#define PSEUDO_SCREEN_HEIGHT   /*480*/600
-#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 "wine/winuser.h"
-
-#include <stdio.h>
-#include "win32.h"
-
-#include "registry.h"
-#include "loader.h"
-#include "com.h"
-#include "ext.h"
-
-#include <stdlib.h>
-#include <assert.h>
-#include <stdarg.h>
-#include <ctype.h>
-#include <pthread.h>
-#include <errno.h>
-#ifdef HAVE_MALLOC_H
-#include <malloc.h>
-#endif
-#include <time.h>
-#include <math.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <dirent.h>
-#include <sys/time.h>
-#include <sys/timeb.h>
-#ifdef HAVE_KSTAT
-#include <kstat.h>
-#endif
-
-#if HAVE_VSSCANF
-int vsscanf( const char *str, const char *format, va_list ap);
-#else
-/* system has no vsscanf.  try to provide one */
-static int vsscanf( const char *str, const char *format, va_list ap)
-{
-    long p1 = va_arg(ap, long);
-    long p2 = va_arg(ap, long);
-    long p3 = va_arg(ap, long);
-    long p4 = va_arg(ap, long);
-    long p5 = va_arg(ap, long);
-    return sscanf(str, format, p1, p2, p3, p4, p5);
-}
-#endif
-
-static 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)
-       );
-}
-static unsigned int c_localcount_tsc()
-{
-    int a;
-    __asm__ __volatile__
-       (
-        "rdtsc\n\t"
-        :"=a"(a)
-        :
-        :"edx"
-       );
-    return a;
-}
-static void c_longcount_tsc(long long* z)
-{
-    __asm__ __volatile__
-       (
-        "pushl %%ebx\n\t"
-        "movl %%eax, %%ebx\n\t"
-        "rdtsc\n\t"
-        "movl %%eax, 0(%%ebx)\n\t"
-        "movl %%edx, 4(%%ebx)\n\t"
-        "popl %%ebx\n\t"
-        ::"a"(z)
-        :"edx"
-       );
-}
-static unsigned int c_localcount_notsc()
-{
-    struct timeval tv;
-    unsigned limit=~0;
-    limit/=1000000;
-    gettimeofday(&tv, 0);
-    return limit*tv.tv_usec;
-}
-static void c_longcount_notsc(long long* z)
-{
-    struct timeval tv;
-    unsigned long long result;
-    unsigned limit=~0;
-    if(!z)return;
-    limit/=1000000;
-    gettimeofday(&tv, 0);
-    result=tv.tv_sec;
-    result<<=32;
-    result+=limit*tv.tv_usec;
-    *z=result;
-}
-static unsigned int localcount_stub(void);
-static void longcount_stub(long long*);
-static unsigned int (*localcount)()=localcount_stub;
-static void (*longcount)(long long*)=longcount_stub;
-
-static pthread_mutex_t memmut;
-
-static unsigned int localcount_stub(void)
-{
-    unsigned int regs[4];
-    do_cpuid(1, regs);
-    if ((regs[3] & 0x00000010) != 0)
-    {
-       localcount=c_localcount_tsc;
-       longcount=c_longcount_tsc;
-    }
-    else
-    {
-       localcount=c_localcount_notsc;
-       longcount=c_longcount_notsc;
-    }
-    return localcount();
-}
-static void longcount_stub(long long* z)
-{
-    unsigned int regs[4];
-    do_cpuid(1, regs);
-    if ((regs[3] & 0x00000010) != 0)
-    {
-       localcount=c_localcount_tsc;
-       longcount=c_longcount_tsc;
-    }
-    else
-    {
-       localcount=c_localcount_notsc;
-       longcount=c_longcount_notsc;
-    }
-    longcount(z);
-}
-
-#ifdef MPLAYER
-#include "../mp_msg.h"
-#endif
-int LOADER_DEBUG=1; // active only if compiled with -DDETAILED_OUT
-//#define DETAILED_OUT
-static inline void dbgprintf(const char* fmt, ...)
-{
-#ifdef DETAILED_OUT
-    if(LOADER_DEBUG)
-    {
-       FILE* f;
-       va_list va;
-       va_start(va, fmt);
-       f=fopen("./log", "a");
-       vprintf(fmt, va);
-       fflush(stdout);
-       if(f)
-       {
-           vfprintf(f, fmt, va);
-           fsync(fileno(f));
-           fclose(f);
-       }
-       va_end(va);
-    }
-#endif
-#ifdef MPLAYER
-    if (verbose > 2)
-    {
-       va_list va;
-       
-       va_start(va, fmt);
-       vprintf(fmt, va);
-//     mp_dbg(MSGT_WIN32, MSGL_DBG3, fmt, va);
-       va_end(va);
-    }
-  fflush(stdout);
-#endif
-}
-
-
-char export_names[300][32]={
-    "name1",
-    //"name2",
-    //"name3"
-};
-//#define min(x,y) ((x)<(y)?(x):(y))
-
-void destroy_event(void* event);
-
-struct th_list_t;
-typedef struct th_list_t{
-    int id;
-    void* thread;
-    struct th_list_t* next;
-    struct th_list_t* prev;
-} th_list;
-
-
-// have to be cleared by GARBAGE COLLECTOR
-static unsigned char* heap=NULL;
-static int heap_counter=0;
-static tls_t* g_tls=NULL;
-static th_list* list=NULL;
-
-static void test_heap(void)
-{
-    int offset=0;
-    if(heap==0)
-       return;
-    while(offset<heap_counter)
-    {
-       if(*(int*)(heap+offset)!=0x433476)
-       {
-           printf("Heap corruption at address %d\n", offset);
-           return;
-       }
-       offset+=8+*(int*)(heap+offset+4);
-    }
-    for(;offset<min(offset+1000, 20000000); offset++)
-       if(heap[offset]!=0xCC)
-       {
-           printf("Free heap corruption at address %d\n", offset);
-       }
-}
-#undef MEMORY_DEBUG
-
-#ifdef MEMORY_DEBUG
-
-static void* my_mreq(int size, int to_zero)
-{
-    static int test=0;
-    test++;
-    if(test%10==0)printf("Memory: %d bytes allocated\n", heap_counter);
-    //    test_heap();
-    if(heap==NULL)
-    {
-       heap=malloc(20000000);
-       memset(heap, 0xCC,20000000);
-    }
-    if(heap==0)
-    {
-       printf("No enough memory\n");
-       return 0;
-    }
-    if(heap_counter+size>20000000)
-    {
-       printf("No enough memory\n");
-       return 0;
-    }
-    *(int*)(heap+heap_counter)=0x433476;
-    heap_counter+=4;
-    *(int*)(heap+heap_counter)=size;
-    heap_counter+=4;
-    printf("Allocated %d bytes of memory: sys %d, user %d-%d\n", size, heap_counter-8, heap_counter, heap_counter+size);
-    if(to_zero)
-       memset(heap+heap_counter, 0, size);
-    else
-       memset(heap+heap_counter, 0xcc, size);  // make crash reproducable
-    heap_counter+=size;
-    return heap+heap_counter-size;
-}
-static int my_release(char* memory)
-{
-    //    test_heap();
-    if(memory==NULL)
-    {
-       printf("ERROR: free(0)\n");
-       return 0;
-    }
-    if(*(int*)(memory-8)!=0x433476)
-    {
-       printf("MEMORY CORRUPTION !!!!!!!!!!!!!!!!!!!\n");
-       return 0;
-    }
-    printf("Freed %d bytes of memory\n", *(int*)(memory-4));
-    //    memset(memory-8, *(int*)(memory-4), 0xCC);
-    return 0;
-}
-
-#else
-#define GARBAGE
-typedef struct alloc_header_t alloc_header;
-struct alloc_header_t
-{
-    // let's keep allocated data 16 byte aligned
-    alloc_header* prev;
-    alloc_header* next;
-    long deadbeef;
-    long size;
-    long type;
-    long reserved1;
-    long reserved2;
-    long reserved3;
-};
-
-#ifdef GARBAGE
-static alloc_header* last_alloc = NULL;
-static int alccnt = 0;
-#endif
-
-#define AREATYPE_CLIENT 0
-#define AREATYPE_EVENT 1
-#define AREATYPE_MUTEX 2
-#define AREATYPE_COND 3
-#define AREATYPE_CRITSECT 4
-
-/* -- critical sections -- */
-struct CRITSECT
-{
-    pthread_t id;
-    pthread_mutex_t mutex;
-    int locked;
-    long deadbeef;
-};
-
-void* mreq_private(int size, int to_zero, int type);
-void* mreq_private(int size, int to_zero, int type)
-{
-    int nsize = size + sizeof(alloc_header);
-    alloc_header* header = (alloc_header* ) malloc(nsize);
-    if (!header)
-        return 0;
-    if (to_zero)
-       memset(header, 0, nsize);
-#ifdef GARBAGE
-    if (!last_alloc)
-    {
-       pthread_mutex_init(&memmut, NULL);
-       pthread_mutex_lock(&memmut);
-    }
-    else
-    {
-       pthread_mutex_lock(&memmut);
-       last_alloc->next = header;  /* set next */
-    }
-
-    header->prev = last_alloc;
-    header->next = 0;
-    last_alloc = header;
-    alccnt++;
-    pthread_mutex_unlock(&memmut);
-#endif
-    header->deadbeef = 0xdeadbeef;
-    header->size = size;
-    header->type = type;
-
-    //if (alccnt < 40000) printf("MY_REQ: %p\t%d   t:%d  (cnt:%d)\n",  header, size, type, alccnt);
-    return header + 1;
-}
-
-static int my_release(void* memory)
-{
-    alloc_header* header = (alloc_header*) memory - 1;
-#ifdef GARBAGE
-    alloc_header* prevmem;
-    alloc_header* nextmem;
-
-    if (memory == 0)
-       return 0;
-
-    if (header->deadbeef != (long) 0xdeadbeef)
-    {
-       dbgprintf("FATAL releasing corrupted memory! %p  0x%lx  (%d)\n", header, header->deadbeef, alccnt);
-       return 0;
-    }
-
-    pthread_mutex_lock(&memmut);
-
-    switch(header->type)
-    {
-    case AREATYPE_EVENT:
-       destroy_event(memory);
-       break;
-    case AREATYPE_COND:
-       pthread_cond_destroy((pthread_cond_t*)memory);
-       break;
-    case AREATYPE_MUTEX:
-       pthread_mutex_destroy((pthread_mutex_t*)memory);
-       break;
-    case AREATYPE_CRITSECT:
-       pthread_mutex_destroy(&((struct CRITSECT*)memory)->mutex);
-       break;
-    default:
-       //memset(memory, 0xcc, header->size);
-       ;
-    }
-
-    header->deadbeef = 0;
-    prevmem = header->prev;
-    nextmem = header->next;
-
-    if (prevmem)
-       prevmem->next = nextmem;
-    if (nextmem)
-       nextmem->prev = prevmem;
-
-    if (header == last_alloc)
-       last_alloc = prevmem;
-
-    alccnt--;
-
-    if (last_alloc)
-       pthread_mutex_unlock(&memmut);
-    else
-       pthread_mutex_destroy(&memmut);
-
-    //if (alccnt < 40000) printf("MY_RELEASE: %p\t%ld    (%d)\n", header, header->size, alccnt);
-#else
-    if (memory == 0)
-       return 0;
-#endif
-    //memset(header + 1, 0xcc, header->size);
-    free(header);
-    return 0;
-}
-#endif
-
-static inline void* my_mreq(int size, int to_zero)
-{
-    return mreq_private(size, to_zero, AREATYPE_CLIENT);
-}
-
-static int my_size(void* memory)
-{
-    if(!memory) return 0;
-    return ((alloc_header*)memory)[-1].size;
-}
-
-static void* my_realloc(void* memory, int size)
-{
-    void *ans = memory;
-    int osize;
-    if (memory == NULL)
-       return my_mreq(size, 0);
-    osize = my_size(memory);
-    if (osize < size)
-    {
-       ans = my_mreq(size, 0);
-       memcpy(ans, memory, osize);
-       my_release(memory);
-    }
-    return ans;
-}
-
-/*
- *
- *  WINE  API  - native implementation for several win32 libraries
- *
- */
-
-static int WINAPI ext_unknown()
-{
-    printf("Unknown func called\n");
-    return 0;
-}
-
-static int  WINAPI expGetVolumeInformationA( const char *root, char *label,
-                                       unsigned int label_len, unsigned int *serial,
-                                       unsigned int *filename_len,unsigned int *flags,
-                                       char *fsname, unsigned int fsname_len )
-{
-dbgprintf("GetVolumeInformationA( %s, 0x%x, %ld, 0x%x, 0x%x, 0x%x, 0x%x, %ld) => 1\n",
-                     root,label,label_len,serial,filename_len,flags,fsname,fsname_len);
-//hack Do not return any real data - do nothing
-return 1;
-}
-
-static unsigned int WINAPI expGetDriveTypeA( const char *root )
-{
- dbgprintf("GetDriveTypeA( %s ) => %d\n",root,DRIVE_FIXED);
- // hack return as Fixed Drive Type
- return DRIVE_FIXED;
-}
-
-static unsigned int WINAPI expGetLogicalDriveStringsA( unsigned int len, char *buffer )
-{
- dbgprintf("GetLogicalDriveStringsA(%d, 0x%x) => 4\n",len,buffer);
- // hack only have one drive c:\ in this hack
-  *buffer++='c';
-  *buffer++=':';
-  *buffer++='\\';
-  *buffer++='\0';
-  *buffer= '\0';
-return 4; // 1 drive * 4 bytes (includes null)
-}
-
-
-static int WINAPI expIsBadWritePtr(void* ptr, unsigned int count)
-{
-    int result = (count == 0 || ptr != 0) ? 0 : 1;
-    dbgprintf("IsBadWritePtr(0x%x, 0x%x) => %d\n", ptr, count, result);
-    return result;
-}
-static int WINAPI expIsBadReadPtr(void* ptr, unsigned int count)
-{
-    int result = (count == 0 || ptr != 0) ? 0 : 1;
-    dbgprintf("IsBadReadPtr(0x%x, 0x%x) => %d\n", ptr, count, result);
-    return result;
-}
-static int WINAPI expDisableThreadLibraryCalls(int module)
-{
-    dbgprintf("DisableThreadLibraryCalls(0x%x) => 0\n", module);
-    return 0;
-}
-
-static HMODULE WINAPI expGetDriverModuleHandle(DRVR* pdrv)
-{
-    HMODULE result;
-    if (pdrv==NULL)
-       result=0;
-    else
-       result=pdrv->hDriverModule;
-    dbgprintf("GetDriverModuleHandle(%p) => %p\n", pdrv, result);
-    return result;
-}
-
-#define        MODULE_HANDLE_kernel32  ((HMODULE)0x120)
-#define        MODULE_HANDLE_user32    ((HMODULE)0x121)
-#ifdef QTX
-#define        MODULE_HANDLE_wininet   ((HMODULE)0x122)
-#define        MODULE_HANDLE_ddraw     ((HMODULE)0x123)
-#define        MODULE_HANDLE_advapi32  ((HMODULE)0x124)
-#endif
-#define        MODULE_HANDLE_comdlg32  ((HMODULE)0x125)
-#define        MODULE_HANDLE_msvcrt    ((HMODULE)0x126)
-#define        MODULE_HANDLE_ole32     ((HMODULE)0x127)
-#define        MODULE_HANDLE_winmm     ((HMODULE)0x128)
-
-static HMODULE WINAPI expGetModuleHandleA(const char* name)
-{
-    WINE_MODREF* wm;
-    HMODULE result;
-    if(!name)
-#ifdef QTX
-       result=1;
-#else
-       result=0;
-#endif
-    else
-    {
-       wm=MODULE_FindModule(name);
-       if(wm==0)result=0;
-       else
-           result=(HMODULE)(wm->module);
-    }
-    if(!result)
-    {
-       if(name && (strcasecmp(name, "kernel32")==0 || !strcasecmp(name, "kernel32.dll")))
-           result=MODULE_HANDLE_kernel32;
-#ifdef QTX
-       if(name && strcasecmp(name, "user32")==0)
-           result=MODULE_HANDLE_user32;
-#endif
-    }
-    dbgprintf("GetModuleHandleA('%s') => 0x%x\n", name, result);
-    return result;
-}
-
-static void* WINAPI expCreateThread(void* pSecAttr, long dwStackSize,
-                                   void* lpStartAddress, void* lpParameter,
-                                   long dwFlags, long* dwThreadId)
-{
-    pthread_t *pth;
-    //    printf("CreateThread:");
-    pth = (pthread_t*) my_mreq(sizeof(pthread_t), 0);
-    pthread_create(pth, NULL, (void*(*)(void*))lpStartAddress, lpParameter);
-    if(dwFlags)
-       printf( "WARNING: CreateThread flags not supported\n");
-    if(dwThreadId)
-       *dwThreadId=(long)pth;
-    if(list==NULL)
-    {
-       list=my_mreq(sizeof(th_list), 1);
-       list->next=list->prev=NULL;
-    }
-    else
-    {
-       list->next=my_mreq(sizeof(th_list), 0);
-       list->next->prev=list;
-       list->next->next=NULL;
-       list=list->next;
-    }
-    list->thread=pth;
-    dbgprintf("CreateThread(0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x) => 0x%x\n",
-             pSecAttr, dwStackSize, lpStartAddress, lpParameter, dwFlags, dwThreadId, pth);
-    return pth;
-}
-
-struct mutex_list_t;
-
-struct mutex_list_t
-{
-    char type;
-    pthread_mutex_t *pm;
-    pthread_cond_t  *pc;
-    char state;
-    char reset;
-    char name[128];
-    int  semaphore;
-    struct mutex_list_t* next;
-    struct mutex_list_t* prev;
-};
-typedef struct mutex_list_t mutex_list;
-static mutex_list* mlist=NULL;
-
-void destroy_event(void* event)
-{
-    mutex_list* pp=mlist;
-    //    printf("garbage collector: destroy_event(%x)\n", event);
-    while(pp)
-    {
-       if(pp==(mutex_list*)event)
-       {
-           if(pp->next)
-               pp->next->prev=pp->prev;
-           if(pp->prev)
-               pp->prev->next=pp->next;
-           if(mlist==(mutex_list*)event)
-               mlist=mlist->prev;
-           /*
-            pp=mlist;
-            while(pp)
-            {
-            printf("%x => ", pp);
-            pp=pp->prev;
-            }
-            printf("0\n");
-            */
-           return;
-       }
-       pp=pp->prev;
-    }
-}
-
-static void* WINAPI expCreateEventA(void* pSecAttr, char bManualReset,
-                                   char bInitialState, const char* name)
-{
-    pthread_mutex_t *pm;
-    pthread_cond_t  *pc;
-    /*
-     mutex_list* pp;
-     pp=mlist;
-     while(pp)
-     {
-     printf("%x => ", pp);
-     pp=pp->prev;
-     }
-     printf("0\n");
-     */
-    if(mlist!=NULL)
-    {
-       mutex_list* pp=mlist;
-       if(name!=NULL)
-           do
-       {
-           if((strcmp(pp->name, name)==0) && (pp->type==0))
-           {
-               dbgprintf("CreateEventA(0x%x, 0x%x, 0x%x, 0x%x='%s') => 0x%x\n",
-                         pSecAttr, bManualReset, bInitialState, name, name, pp->pm);
-               return pp->pm;
-           }
-       }while((pp=pp->prev) != NULL);
-    }
-    pm=mreq_private(sizeof(pthread_mutex_t), 0, AREATYPE_MUTEX);
-    pthread_mutex_init(pm, NULL);
-    pc=mreq_private(sizeof(pthread_cond_t), 0, AREATYPE_COND);
-    pthread_cond_init(pc, NULL);
-    if(mlist==NULL)
-    {
-       mlist=mreq_private(sizeof(mutex_list), 00, AREATYPE_EVENT);
-       mlist->next=mlist->prev=NULL;
-    }
-    else
-    {
-       mlist->next=mreq_private(sizeof(mutex_list), 00, AREATYPE_EVENT);
-       mlist->next->prev=mlist;
-       mlist->next->next=NULL;
-       mlist=mlist->next;
-    }
-    mlist->type=0; /* Type Event */
-    mlist->pm=pm;
-    mlist->pc=pc;
-    mlist->state=bInitialState;
-    mlist->reset=bManualReset;
-    if(name)
-       strncpy(mlist->name, name, 127);
-    else
-       mlist->name[0]=0;
-    if(pm==NULL)
-       dbgprintf("ERROR::: CreateEventA failure\n");
-    /*
-     if(bInitialState)
-     pthread_mutex_lock(pm);
-     */
-    if(name)
-       dbgprintf("CreateEventA(0x%x, 0x%x, 0x%x, 0x%x='%s') => 0x%x\n",
-                 pSecAttr, bManualReset, bInitialState, name, name, mlist);
-    else
-       dbgprintf("CreateEventA(0x%x, 0x%x, 0x%x, NULL) => 0x%x\n",
-                 pSecAttr, bManualReset, bInitialState, mlist);
-    return mlist;
-}
-
-static void* WINAPI expSetEvent(void* event)
-{
-    mutex_list *ml = (mutex_list *)event;
-    dbgprintf("SetEvent(%x) => 0x1\n", event);
-    pthread_mutex_lock(ml->pm);
-    if (ml->state == 0) {
-       ml->state = 1;
-       pthread_cond_signal(ml->pc);
-    }
-    pthread_mutex_unlock(ml->pm);
-
-    return (void *)1;
-}
-static void* WINAPI expResetEvent(void* event)
-{
-    mutex_list *ml = (mutex_list *)event;
-    dbgprintf("ResetEvent(0x%x) => 0x1\n", event);
-    pthread_mutex_lock(ml->pm);
-    ml->state = 0;
-    pthread_mutex_unlock(ml->pm);
-
-    return (void *)1;
-}
-
-static void* WINAPI expWaitForSingleObject(void* object, int duration)
-{
-    mutex_list *ml = (mutex_list *)object;
-    // FIXME FIXME FIXME - this value is sometime unititialize !!!
-    int ret = WAIT_FAILED;
-    mutex_list* pp=mlist;
-    if(object == (void*)0xcfcf9898)
-    {
-       /**
-        From GetCurrentThread() documentation:
-        A pseudo handle is a special constant that is interpreted as the current thread handle. The calling thread can use this handle to specify itself whenever a thread handle is required. Pseudo handles are not inherited by child processes.
-
-        This handle has the maximum possible access to the thread object. For systems that support security descriptors, this is the maximum access allowed by the security descriptor for the calling process. For systems that do not support security descriptors, this is THREAD_ALL_ACCESS.
-
-        The function cannot be used by one thread to create a handle that can be used by other threads to refer to the first thread. The handle is always interpreted as referring to the thread that is using it. A thread can create a "real" handle to itself that can be used by other threads, or inherited by other processes, by specifying the pseudo handle as the source handle in a call to the DuplicateHandle function.
-        **/
-       dbgprintf("WaitForSingleObject(thread_handle) called\n");
-       return (void*)WAIT_FAILED;
-    }
-    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;
-    if (!pp) {
-       dbgprintf("WaitForSingleObject: NotFound\n");
-       return (void*)ret;
-    }
-
-    pthread_mutex_lock(ml->pm);
-
-    switch(ml->type) {
-    case 0: /* Event */
-       if (duration == 0) { /* Check Only */
-           if (ml->state == 1) ret = WAIT_FAILED;
-           else                   ret = WAIT_OBJECT_0;
-       }
-       if (duration == -1) { /* INFINITE */
-           if (ml->state == 0)
-               pthread_cond_wait(ml->pc,ml->pm);
-           if (ml->reset)
-               ml->state = 0;
-           ret = WAIT_OBJECT_0;
-       }
-       if (duration > 0) {  /* Timed Wait */
-           struct timespec abstime;
-           struct timeval now;
-           gettimeofday(&now, 0);
-           abstime.tv_sec = now.tv_sec + (now.tv_usec+duration)/1000000;
-           abstime.tv_nsec = ((now.tv_usec+duration)%1000000)*1000;
-           if (ml->state == 0)
-               ret=pthread_cond_timedwait(ml->pc,ml->pm,&abstime);
-           if (ret == ETIMEDOUT) ret = WAIT_TIMEOUT;
-           else                  ret = WAIT_OBJECT_0;
-           if (ml->reset)
-               ml->state = 0;
-       }
-       break;
-    case 1:  /* Semaphore */
-       if (duration == 0) {
-           if(ml->semaphore==0) ret = WAIT_FAILED;
-           else {
-               ml->semaphore++;
-               ret = WAIT_OBJECT_0;
-           }
-       }
-       if (duration == -1) {
-           if (ml->semaphore==0)
-               pthread_cond_wait(ml->pc,ml->pm);
-           ml->semaphore--;
-       }
-       break;
-    }
-    pthread_mutex_unlock(ml->pm);
-
-    dbgprintf("WaitForSingleObject(0x%x, %d): 0x%x => 0x%x \n",object,duration,ml,ret);
-    return (void *)ret;
-}
-
-#ifdef QTX
-static void* WINAPI expWaitForMultipleObjects(int count, const void** objects,
-                   int WaitAll, int duration)
-{
-    int i;
-    void *object;
-    void *ret;
-
-    dbgprintf("WaitForMultipleObjects(%d, 0x%x, %d, duration %d) =>\n",
-       count, objects, WaitAll, duration);
-    
-    for (i = 0; i < count; i++)
-    {
-       object = (void *)objects[i];
-       ret = expWaitForSingleObject(object, duration);
-       if (WaitAll)
-           dbgprintf("WaitAll flag not yet supported...\n");
-       else
-           return ret;
-    }
-    return NULL;
-}
-
-static void WINAPI expExitThread(int retcode)
-{
-    dbgprintf("ExitThread(%d)\n", retcode);
-    pthread_exit(&retcode);
-}
-
-static HANDLE WINAPI expCreateMutexA(void *pSecAttr,
-                   char bInitialOwner, const char *name)
-{
-    HANDLE mlist = (HANDLE)expCreateEventA(pSecAttr, 0, 0, name);
-    
-    if (name)
-       dbgprintf("CreateMutexA(0x%x, %d, '%s') => 0x%x\n",
-           pSecAttr, bInitialOwner, name, mlist);
-    else
-       dbgprintf("CreateMutexA(0x%x, %d, NULL) => 0x%x\n",
-           pSecAttr, bInitialOwner, mlist);
-#ifndef QTX
-    /* 10l to QTX, if CreateMutex returns a real mutex, WaitForSingleObject
-       waits for ever, else it works ;) */
-    return mlist;
-#endif
-}
-
-static int WINAPI expReleaseMutex(HANDLE hMutex)
-{
-    dbgprintf("ReleaseMutex(%x) => 1\n", hMutex);
-    /* FIXME:XXX !! not yet implemented */
-    return 1;
-}
-#endif
-
-static int pf_set = 0;
-static BYTE PF[64] = {0,};
-
-static void DumpSystemInfo(const SYSTEM_INFO* si)
-{
-    dbgprintf("  Processor architecture %d\n", si->u.s.wProcessorArchitecture);
-    dbgprintf("  Page size: %d\n", si->dwPageSize);
-    dbgprintf("  Minimum app address: %d\n", si->lpMinimumApplicationAddress);
-    dbgprintf("  Maximum app address: %d\n", si->lpMaximumApplicationAddress);
-    dbgprintf("  Active processor mask: 0x%x\n", si->dwActiveProcessorMask);
-    dbgprintf("  Number of processors: %d\n", si->dwNumberOfProcessors);
-    dbgprintf("  Processor type: 0x%x\n", si->dwProcessorType);
-    dbgprintf("  Allocation granularity: 0x%x\n", si->dwAllocationGranularity);
-    dbgprintf("  Processor level: 0x%x\n", si->wProcessorLevel);
-    dbgprintf("  Processor revision: 0x%x\n", si->wProcessorRevision);
-}
-
-static void WINAPI expGetSystemInfo(SYSTEM_INFO* si)
-{
-    /* FIXME: better values for the two entries below... */
-    static int cache = 0;
-    static SYSTEM_INFO cachedsi;
-    unsigned int regs[4];
-    dbgprintf("GetSystemInfo(%p) =>\n", si);
-
-    if (cache) {
-       memcpy(si,&cachedsi,sizeof(*si));
-       DumpSystemInfo(si);
-       return;
-    }
-    memset(PF,0,sizeof(PF));
-    pf_set = 1;
-
-    cachedsi.u.s.wProcessorArchitecture     = PROCESSOR_ARCHITECTURE_INTEL;
-    cachedsi.dwPageSize                        = getpagesize();
-
-    /* FIXME: better values for the two entries below... */
-    cachedsi.lpMinimumApplicationAddress       = (void *)0x00000000;
-    cachedsi.lpMaximumApplicationAddress       = (void *)0x7FFFFFFF;
-    cachedsi.dwActiveProcessorMask             = 1;
-    cachedsi.dwNumberOfProcessors              = 1;
-    cachedsi.dwProcessorType           = PROCESSOR_INTEL_386;
-    cachedsi.dwAllocationGranularity   = 0x10000;
-    cachedsi.wProcessorLevel           = 5; /* pentium */
-    cachedsi.wProcessorRevision                = 0x0101;
-
-#ifdef MPLAYER
-    /* mplayer's way to detect PF's */
-    {
-#include "../cpudetect.h"
-       extern CpuCaps gCpuCaps;
-
-       if (gCpuCaps.hasMMX)
-           PF[PF_MMX_INSTRUCTIONS_AVAILABLE] = TRUE;
-       if (gCpuCaps.hasSSE)
-           PF[PF_XMMI_INSTRUCTIONS_AVAILABLE] = TRUE;
-       if (gCpuCaps.has3DNow)
-           PF[PF_AMD3D_INSTRUCTIONS_AVAILABLE] = TRUE;
-
-           if (gCpuCaps.cpuType == 4)
-           {
-               cachedsi.dwProcessorType = PROCESSOR_INTEL_486;
-               cachedsi.wProcessorLevel = 4;
-           }
-           else if (gCpuCaps.cpuType >= 5)
-           {
-               cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
-               cachedsi.wProcessorLevel = 5;
-           }
-           else
-           {
-               cachedsi.dwProcessorType = PROCESSOR_INTEL_386;
-               cachedsi.wProcessorLevel = 3;
-           }
-           cachedsi.wProcessorRevision = gCpuCaps.cpuStepping;
-           cachedsi.dwNumberOfProcessors = 1;  /* hardcoded */
-    }
-#endif
-
-/* disable cpuid based detection (mplayer's cpudetect.c does this - see above) */
-#ifndef MPLAYER
-#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__svr4__) || defined(__DragonFly__)
-    do_cpuid(1, regs);
-    switch ((regs[0] >> 8) & 0xf) {                    // cpu family
-    case 3: cachedsi.dwProcessorType = PROCESSOR_INTEL_386;
-    cachedsi.wProcessorLevel= 3;
-    break;
-    case 4: cachedsi.dwProcessorType = PROCESSOR_INTEL_486;
-    cachedsi.wProcessorLevel= 4;
-    break;
-    case 5: cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
-    cachedsi.wProcessorLevel= 5;
-    break;
-    case 6: cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
-    cachedsi.wProcessorLevel= 5;
-    break;
-    default:cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
-    cachedsi.wProcessorLevel= 5;
-    break;
-    }
-    cachedsi.wProcessorRevision = regs[0] & 0xf;       // stepping
-    if (regs[3] & (1 <<  8))
-       PF[PF_COMPARE_EXCHANGE_DOUBLE] = TRUE;
-    if (regs[3] & (1 << 23))
-       PF[PF_MMX_INSTRUCTIONS_AVAILABLE] = TRUE;
-    if (regs[3] & (1 << 25))
-       PF[PF_XMMI_INSTRUCTIONS_AVAILABLE] = TRUE;
-    if (regs[3] & (1 << 31))
-       PF[PF_AMD3D_INSTRUCTIONS_AVAILABLE] = TRUE;
-    cachedsi.dwNumberOfProcessors=1;
-#endif
-#endif /* MPLAYER */
-
-/* MPlayer: linux detection enabled (based on proc/cpuinfo) for checking
-   fdiv_bug and fpu emulation flags -- alex/MPlayer */
-#ifdef __linux__
-    {
-       char buf[20];
-       char line[200];
-       FILE *f = fopen ("/proc/cpuinfo", "r");
-
-       if (!f)
-           return;
-       while (fgets(line,200,f)!=NULL) {
-           char        *s,*value;
-
-           /* NOTE: the ':' is the only character we can rely on */
-           if (!(value = strchr(line,':')))
-               continue;
-           /* terminate the valuename */
-           *value++ = '\0';
-           /* skip any leading spaces */
-           while (*value==' ') value++;
-           if ((s=strchr(value,'\n')))
-               *s='\0';
-
-           /* 2.1 method */
-           if (!lstrncmpiA(line, "cpu family",strlen("cpu family"))) {
-               if (isdigit (value[0])) {
-                   switch (value[0] - '0') {
-                   case 3: cachedsi.dwProcessorType = PROCESSOR_INTEL_386;
-                   cachedsi.wProcessorLevel= 3;
-                   break;
-                   case 4: cachedsi.dwProcessorType = PROCESSOR_INTEL_486;
-                   cachedsi.wProcessorLevel= 4;
-                   break;
-                   case 5: cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
-                   cachedsi.wProcessorLevel= 5;
-                   break;
-                   case 6: cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
-                   cachedsi.wProcessorLevel= 5;
-                   break;
-                   default:cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
-                   cachedsi.wProcessorLevel= 5;
-                   break;
-                   }
-               }
-               /* set the CPU type of the current processor */
-               sprintf(buf,"CPU %ld",cachedsi.dwProcessorType);
-               continue;
-           }
-           /* old 2.0 method */
-           if (!lstrncmpiA(line, "cpu",strlen("cpu"))) {
-               if (    isdigit (value[0]) && value[1] == '8' &&
-                       value[2] == '6' && value[3] == 0
-                  ) {
-                   switch (value[0] - '0') {
-                   case 3: cachedsi.dwProcessorType = PROCESSOR_INTEL_386;
-                   cachedsi.wProcessorLevel= 3;
-                   break;
-                   case 4: cachedsi.dwProcessorType = PROCESSOR_INTEL_486;
-                   cachedsi.wProcessorLevel= 4;
-                   break;
-                   case 5: cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
-                   cachedsi.wProcessorLevel= 5;
-                   break;
-                   case 6: cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
-                   cachedsi.wProcessorLevel= 5;
-                   break;
-                   default:cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
-                   cachedsi.wProcessorLevel= 5;
-                   break;
-                   }
-               }
-               /* set the CPU type of the current processor */
-               sprintf(buf,"CPU %ld",cachedsi.dwProcessorType);
-               continue;
-           }
-           if (!lstrncmpiA(line,"fdiv_bug",strlen("fdiv_bug"))) {
-               if (!lstrncmpiA(value,"yes",3))
-                   PF[PF_FLOATING_POINT_PRECISION_ERRATA] = TRUE;
-
-               continue;
-           }
-           if (!lstrncmpiA(line,"fpu",strlen("fpu"))) {
-               if (!lstrncmpiA(value,"no",2))
-                   PF[PF_FLOATING_POINT_EMULATED] = TRUE;
-
-               continue;
-           }
-           if (!lstrncmpiA(line,"processor",strlen("processor"))) {
-               /* processor number counts up...*/
-               unsigned int x;
-
-               if (sscanf(value,"%d",&x))
-                   if (x+1>cachedsi.dwNumberOfProcessors)
-                       cachedsi.dwNumberOfProcessors=x+1;
-
-               /* Create a new processor subkey on a multiprocessor
-                * system
-                */
-               sprintf(buf,"%d",x);
-           }
-           if (!lstrncmpiA(line,"stepping",strlen("stepping"))) {
-               int     x;
-
-               if (sscanf(value,"%d",&x))
-                   cachedsi.wProcessorRevision = x;
-           }
-           if
-               ( (!lstrncmpiA(line,"flags",strlen("flags")))
-                 || (!lstrncmpiA(line,"features",strlen("features"))) )
-           {
-               if (strstr(value,"cx8"))
-                   PF[PF_COMPARE_EXCHANGE_DOUBLE] = TRUE;
-               if (strstr(value,"mmx"))
-                   PF[PF_MMX_INSTRUCTIONS_AVAILABLE] = TRUE;
-               if (strstr(value,"tsc"))
-                   PF[PF_RDTSC_INSTRUCTION_AVAILABLE] = TRUE;
-               if (strstr(value,"xmm"))
-                   PF[PF_XMMI_INSTRUCTIONS_AVAILABLE] = TRUE;
-               if (strstr(value,"3dnow"))
-                   PF[PF_AMD3D_INSTRUCTIONS_AVAILABLE] = TRUE;
-           }
-       }
-       fclose (f);
-       /*
-        *      ad hoc fix for smp machines.
-        *      some problems on WaitForSingleObject,CreateEvent,SetEvent
-        *                      CreateThread ...etc..
-        *
-        */
-       cachedsi.dwNumberOfProcessors=1;
-    }
-#endif /* __linux__ */
-    cache = 1;
-    memcpy(si,&cachedsi,sizeof(*si));
-    DumpSystemInfo(si);
-}
-
-// avoid undefined expGetSystemInfo
-static WIN_BOOL WINAPI expIsProcessorFeaturePresent(DWORD v)
-{
-    WIN_BOOL result = 0;
-    if (!pf_set)
-    {
-       SYSTEM_INFO si;
-       expGetSystemInfo(&si);
-    }
-    if(v<64) result=PF[v];
-    dbgprintf("IsProcessorFeaturePresent(0x%x) => 0x%x\n", v, result);
-    return result;
-}
-
-
-static long WINAPI expGetVersion()
-{
-    dbgprintf("GetVersion() => 0xC0000004\n");
-    return 0xC0000004;//Windows 95
-}
-
-static HANDLE WINAPI expHeapCreate(long flags, long init_size, long max_size)
-{
-    //    printf("HeapCreate:");
-    HANDLE result;
-    if(init_size==0)
-       result=(HANDLE)my_mreq(0x110000, 0);
-    else
-       result=(HANDLE)my_mreq((init_size + 0xfff) & 0x7ffff000 , 0);
-    dbgprintf("HeapCreate(flags 0x%x, initial size %d, maximum size %d) => 0x%x\n", flags, init_size, max_size, result);
-    return result;
-}
-
-// this is another dirty hack
-// VP31 is releasing one allocated Heap chunk twice
-// we will silently ignore this second call...
-static void* heapfreehack = 0;
-static int heapfreehackshown = 0;
-//extern void trapbug(void);
-static void* WINAPI expHeapAlloc(HANDLE heap, int flags, int size)
-{
-    void* z;
-    /**
-     Morgan's m3jpeg32.dll v. 2.0 encoder expects that request for
-     HeapAlloc returns area larger than size argument :-/
-
-     actually according to M$ Doc  HeapCreate size should be rounded
-     to page boundaries thus we should simulate this
-     **/
-    //if (size == 22276) trapbug();
-    z=my_mreq((size + 0xfff) & 0x7ffff000, (flags & HEAP_ZERO_MEMORY));
-    if(z==0)
-       printf("HeapAlloc failure\n");
-    dbgprintf("HeapAlloc(heap 0x%x, flags 0x%x, size %d) => 0x%x\n", heap, flags, size, z);
-    heapfreehack = 0; // reset
-    return z;
-}
-static long WINAPI expHeapDestroy(void* heap)
-{
-    dbgprintf("HeapDestroy(heap 0x%x) => 1\n", heap);
-    my_release(heap);
-    return 1;
-}
-
-static long WINAPI expHeapFree(HANDLE heap, DWORD dwFlags, LPVOID lpMem)
-{
-    dbgprintf("HeapFree(0x%x, 0x%x, pointer 0x%x) => 1\n", heap, dwFlags, lpMem);
-    if (heapfreehack != lpMem && lpMem != (void*)0xffffffff
-       && lpMem != (void*)0xbdbdbdbd)
-       // 0xbdbdbdbd is for i263_drv.drv && libefence
-       // it seems to be reading from relased memory
-        // EF_PROTECT_FREE doens't show any probleme
-       my_release(lpMem);
-    else
-    {
-       if (!heapfreehackshown++)
-           printf("Info: HeapFree deallocating same memory twice! (%p)\n", lpMem);
-    }
-    heapfreehack = lpMem;
-    return 1;
-}
-static long WINAPI expHeapSize(int heap, int flags, void* pointer)
-{
-    long result=my_size(pointer);
-    dbgprintf("HeapSize(heap 0x%x, flags 0x%x, pointer 0x%x) => %d\n", heap, flags, pointer, result);
-    return result;
-}
-static void* WINAPI expHeapReAlloc(HANDLE heap,int flags,void *lpMem,int size)
-{
-    long orgsize = my_size(lpMem);
-    dbgprintf("HeapReAlloc() Size %ld org %d\n",orgsize,size);
-    return my_realloc(lpMem, size);
-}
-static long WINAPI expGetProcessHeap(void)
-{
-    dbgprintf("GetProcessHeap() => 1\n");
-    return 1;
-}
-static void* WINAPI expVirtualAlloc(void* v1, long v2, long v3, long v4)
-{
-    void* z = VirtualAlloc(v1, v2, v3, v4);
-    if(z==0)
-       printf("VirtualAlloc failure\n");
-    dbgprintf("VirtualAlloc(0x%x, %d, %d, %d) => 0x%x \n",v1,v2,v3,v4, z);
-    return z;
-}
-static int WINAPI expVirtualFree(void* v1, int v2, int v3)
-{
-    int result = VirtualFree(v1,v2,v3);
-    dbgprintf("VirtualFree(0x%x, %d, %d) => %d\n",v1,v2,v3, result);
-    return result;
-}
-
-/* we're building a table of critical sections. cs_win pointer uses the DLL
- cs_unix is the real structure, we're using cs_win only to identifying cs_unix */
-struct critsecs_list_t
-{
-    CRITICAL_SECTION *cs_win;
-    struct CRITSECT *cs_unix;
-};
-
-/* 'NEWTYPE' is working with VIVO, 3ivX and QTX dll (no more segfaults) -- alex */
-#undef CRITSECS_NEWTYPE
-//#define CRITSECS_NEWTYPE 1
-
-#ifdef CRITSECS_NEWTYPE
-/* increased due to ucod needs more than 32 entries */
-/* and 64 should be enough for everything */
-#define CRITSECS_LIST_MAX 64
-static struct critsecs_list_t critsecs_list[CRITSECS_LIST_MAX];
-
-static int critsecs_get_pos(CRITICAL_SECTION *cs_win)
-{
-    int i;
-
-    for (i=0; i < CRITSECS_LIST_MAX; i++)
-       if (critsecs_list[i].cs_win == cs_win)
-           return(i);
-    return(-1);
-}
-
-static int critsecs_get_unused(void)
-{
-    int i;
-
-    for (i=0; i < CRITSECS_LIST_MAX; i++)
-       if (critsecs_list[i].cs_win == NULL)
-           return(i);
-    return(-1);
-}
-
-struct CRITSECT *critsecs_get_unix(CRITICAL_SECTION *cs_win)
-{
-    int i;
-
-    for (i=0; i < CRITSECS_LIST_MAX; i++)
-       if (critsecs_list[i].cs_win == cs_win && critsecs_list[i].cs_unix)
-           return(critsecs_list[i].cs_unix);
-    return(NULL);
-}
-#endif
-
-static void WINAPI expInitializeCriticalSection(CRITICAL_SECTION* c)
-{
-    dbgprintf("InitializeCriticalSection(0x%x)\n", c);
-    /*    if(sizeof(pthread_mutex_t)>sizeof(CRITICAL_SECTION))
-     {
-     printf(" ERROR:::: sizeof(pthread_mutex_t) is %d, expected <=%d!\n",
-     sizeof(pthread_mutex_t), sizeof(CRITICAL_SECTION));
-     return;
-     }*/
-    /*    pthread_mutex_init((pthread_mutex_t*)c, NULL);   */
-#ifdef CRITSECS_NEWTYPE
-    {
-       struct CRITSECT *cs;
-       int i = critsecs_get_unused();
-
-       if (i < 0)
-       {
-           printf("InitializeCriticalSection(%p) - no more space in list\n", c);
-           return;
-       }
-       dbgprintf("got unused space at %d\n", i);
-       cs = malloc(sizeof(struct CRITSECT));
-       if (!cs)
-       {
-           printf("InitializeCriticalSection(%p) - out of memory\n", c);
-           return;
-       }
-       pthread_mutex_init(&cs->mutex, NULL);
-       cs->locked = 0;
-       critsecs_list[i].cs_win = c;
-       critsecs_list[i].cs_unix = cs;
-       dbgprintf("InitializeCriticalSection -> itemno=%d, cs_win=%p, cs_unix=%p\n",
-                 i, c, cs);
-    }
-#else
-    {
-       struct CRITSECT* cs = mreq_private(sizeof(struct CRITSECT) + sizeof(CRITICAL_SECTION),
-                                          0, AREATYPE_CRITSECT);
-       pthread_mutex_init(&cs->mutex, NULL);
-       cs->locked=0;
-        cs->deadbeef = 0xdeadbeef;
-       *(void**)c = cs;
-    }
-#endif
-    return;
-}
-
-static void WINAPI expEnterCriticalSection(CRITICAL_SECTION* c)
-{
-#ifdef CRITSECS_NEWTYPE
-    struct CRITSECT* cs = critsecs_get_unix(c);
-#else
-    struct CRITSECT* cs = (*(struct CRITSECT**)c);
-#endif
-    dbgprintf("EnterCriticalSection(0x%x) %p\n",c, cs);
-    if (!cs)
-    {
-       dbgprintf("entered uninitialized critisec!\n");
-       expInitializeCriticalSection(c);
-#ifdef CRITSECS_NEWTYPE
-       cs=critsecs_get_unix(c);
-#else
-       cs = (*(struct CRITSECT**)c);
-#endif
-       dbgprintf("Win32 Warning: Accessed uninitialized Critical Section (%p)!\n", c);
-    }
-    if(cs->locked)
-       if(cs->id==pthread_self())
-           return;
-    pthread_mutex_lock(&(cs->mutex));
-    cs->locked=1;
-    cs->id=pthread_self();
-    return;
-}
-static void WINAPI expLeaveCriticalSection(CRITICAL_SECTION* c)
-{
-#ifdef CRITSECS_NEWTYPE
-    struct CRITSECT* cs = critsecs_get_unix(c);
-#else
-    struct CRITSECT* cs = (*(struct CRITSECT**)c);
-#endif
-    //    struct CRITSECT* cs=(struct CRITSECT*)c;
-    dbgprintf("LeaveCriticalSection(0x%x) 0x%x\n",c, cs);
-    if (!cs)
-    {
-       dbgprintf("Win32 Warning: Leaving uninitialized Critical Section %p!!\n", c);
-       return;
-    }
-    if (cs->locked)
-    {
-       cs->locked=0;
-       pthread_mutex_unlock(&(cs->mutex));
-    }
-    else
-       dbgprintf("Win32 Warning: Unlocking unlocked Critical Section %p!!\n", c);
-    return;
-}
-
-static void expfree(void* mem); /* forward declaration */
-
-static void WINAPI expDeleteCriticalSection(CRITICAL_SECTION *c)
-{
-#ifdef CRITSECS_NEWTYPE
-    struct CRITSECT* cs = critsecs_get_unix(c);
-#else
-    struct CRITSECT* cs= (*(struct CRITSECT**)c);
-#endif
-    //    struct CRITSECT* cs=(struct CRITSECT*)c;
-    dbgprintf("DeleteCriticalSection(0x%x)\n",c);
-
-    if (!cs)
-    {
-       dbgprintf("Win32 Warning: Deleting uninitialized Critical Section %p!!\n", c);
-       return;
-    }
-    
-    if (cs->locked)
-    {
-       dbgprintf("Win32 Warning: Deleting unlocked Critical Section %p!!\n", c);
-       pthread_mutex_unlock(&(cs->mutex));
-    }
-
-#ifndef GARBAGE
-    pthread_mutex_destroy(&(cs->mutex));
-    // released by GarbageCollector in my_relase otherwise
-#endif
-    my_release(cs);
-#ifdef CRITSECS_NEWTYPE
-    {
-       int i = critsecs_get_pos(c);
-
-       if (i < 0)
-       {
-           printf("DeleteCriticalSection(%p) error (critsec not found)\n", c);
-           return;
-       }
-
-       critsecs_list[i].cs_win = NULL;
-       expfree(critsecs_list[i].cs_unix);
-       critsecs_list[i].cs_unix = NULL;
-       dbgprintf("DeleteCriticalSection -> itemno=%d\n", i);
-    }
-#endif
-    return;
-}
-static int WINAPI expGetCurrentThreadId()
-{
-    dbgprintf("GetCurrentThreadId() => %d\n", pthread_self());
-    return pthread_self();
-}
-static int WINAPI expGetCurrentProcess()
-{
-    dbgprintf("GetCurrentProcess() => %d\n", getpid());
-    return getpid();
-}
-
-#ifdef QTX
-// this version is required for Quicktime codecs (.qtx/.qts) to work.
-// (they assume some pointers at FS: segment)
-
-extern void* fs_seg;
-
-//static int tls_count;
-static int tls_use_map[64];
-static int WINAPI expTlsAlloc()
-{
-    int i;
-    for(i=0; i<64; i++)
-       if(tls_use_map[i]==0)
-       {
-           tls_use_map[i]=1;
-           dbgprintf("TlsAlloc() => %d\n",i);
-           return i;
-       }
-    dbgprintf("TlsAlloc() => -1 (ERROR)\n");
-    return -1;
-}
-
-//static int WINAPI expTlsSetValue(DWORD index, void* value)
-static int WINAPI expTlsSetValue(int index, void* value)
-{
-    dbgprintf("TlsSetValue(%d,0x%x) => 1\n",index,value);
-//    if((index<0) || (index>64))
-    if((index>=64))
-       return 0;
-    *(void**)((char*)fs_seg+0x88+4*index) = value;
-    return 1;
-}
-
-static void* WINAPI expTlsGetValue(DWORD index)
-{
-    dbgprintf("TlsGetValue(%d)\n",index);
-//    if((index<0) || (index>64))
-    if((index>=64)) return NULL;
-    return *(void**)((char*)fs_seg+0x88+4*index);
-}
-
-static int WINAPI expTlsFree(int idx)
-{
-    int index = (int) idx;
-    dbgprintf("TlsFree(%d)\n",index);
-    if((index<0) || (index>64))
-       return 0;
-    tls_use_map[index]=0;
-    return 1;
-}
-
-#else
-struct tls_s {
-    void* value;
-    int used;
-    struct tls_s* prev;
-    struct tls_s* next;
-};
-
-static void* WINAPI expTlsAlloc()
-{
-    if (g_tls == NULL)
-    {
-       g_tls=my_mreq(sizeof(tls_t), 0);
-       g_tls->next=g_tls->prev=NULL;
-    }
-    else
-    {
-       g_tls->next=my_mreq(sizeof(tls_t), 0);
-       g_tls->next->prev=g_tls;
-       g_tls->next->next=NULL;
-       g_tls=g_tls->next;
-    }
-    dbgprintf("TlsAlloc() => 0x%x\n", g_tls);
-    if (g_tls)
-       g_tls->value=0; /* XXX For Divx.dll */
-    return g_tls;
-}
-
-static int WINAPI expTlsSetValue(void* idx, void* value)
-{
-    tls_t* index = (tls_t*) idx;
-    int result;
-    if(index==0)
-       result=0;
-    else
-    {
-       index->value=value;
-       result=1;
-    }
-    dbgprintf("TlsSetValue(index 0x%x, value 0x%x) => %d \n", index, value, result );
-    return result;
-}
-static void* WINAPI expTlsGetValue(void* idx)
-{
-    tls_t* index = (tls_t*) idx;
-    void* result;
-    if(index==0)
-       result=0;
-    else
-       result=index->value;
-    dbgprintf("TlsGetValue(index 0x%x) => 0x%x\n", index, result);
-    return result;
-}
-static int WINAPI expTlsFree(void* idx)
-{
-    tls_t* index = (tls_t*) idx;
-    int result;
-    if(index==0)
-       result=0;
-    else
-    {
-       if(index->next)
-           index->next->prev=index->prev;
-       if(index->prev)
-           index->prev->next=index->next;
-       if (g_tls == index)
-            g_tls = index->prev;
-       my_release((void*)index);
-       result=1;
-    }
-    dbgprintf("TlsFree(index 0x%x) => %d\n", index, result);
-    return result;
-}
-#endif
-
-static void* WINAPI expLocalAlloc(int flags, int size)
-{
-    void* z = my_mreq(size, (flags & GMEM_ZEROINIT));
-    if (z == 0)
-       printf("LocalAlloc() failed\n");
-    dbgprintf("LocalAlloc(%d, flags 0x%x) => 0x%x\n", size, flags, z);
-    return z;
-}
-
-static 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);
-    newpointer = my_realloc((void *)handle,size);
-    dbgprintf("LocalReAlloc(%x %d(old %d), flags 0x%x) => 0x%x\n", handle,size,oldsize, flags,newpointer);
-
-    return newpointer;
-}
-
-static void* WINAPI expLocalLock(void* z)
-{
-    dbgprintf("LocalLock(0x%x) => 0x%x\n", z, z);
-    return z;
-}
-
-static void* WINAPI expGlobalAlloc(int flags, int size)
-{
-    void* z;
-    dbgprintf("GlobalAlloc(%d, flags 0x%X)\n", size, flags);
-
-    z=my_mreq(size, (flags & GMEM_ZEROINIT));
-    //z=calloc(size, 1);
-    //z=malloc(size);
-    if(z==0)
-       printf("GlobalAlloc() failed\n");
-    dbgprintf("GlobalAlloc(%d, flags 0x%x) => 0x%x\n", size, flags, z);
-    return z;
-}
-static void* WINAPI expGlobalLock(void* z)
-{
-    dbgprintf("GlobalLock(0x%x) => 0x%x\n", z, z);
-    return z;
-}
-// pvmjpg20 - but doesn't work anyway
-static int WINAPI expGlobalSize(void* amem)
-{
-    int size = 100000;
-#ifdef GARBAGE
-    alloc_header* header = last_alloc;
-    alloc_header* mem = (alloc_header*) amem - 1;
-    if (amem == 0)
-       return 0;
-    pthread_mutex_lock(&memmut);
-    while (header)
-    {
-       if (header->deadbeef != 0xdeadbeef)
-       {
-           dbgprintf("FATAL found corrupted memory! %p  0x%lx  (%d)\n", header, header->deadbeef, alccnt);
-           break;
-       }
-
-       if (header == mem)
-       {
-           size = header->size;
-           break;
-       }
-
-       header = header->prev;
-    }
-    pthread_mutex_unlock(&memmut);
-#endif
-
-    dbgprintf("GlobalSize(0x%x)\n", amem);
-    return size;
-}
-
-static int WINAPI expLoadIconA( long hinstance, char *name )
-{
- dbgprintf("LoadIconA( %ld, 0x%x ) => 1\n",hinstance,name);
- return 1;
-}
-
-static int WINAPI expLoadStringA(long instance, long  id, void* buf, long size)
-{
-    int result=LoadStringA(instance, id, buf, size);
-    //    if(buf)
-    dbgprintf("LoadStringA(instance 0x%x, id 0x%x, buffer 0x%x, size %d) => %d ( %s )\n",
-             instance, id, buf, size, result, buf);
-    //    else
-    //    dbgprintf("LoadStringA(instance 0x%x, id 0x%x, buffer 0x%x, size %d) => %d\n",
-    // instance, id, buf, size, result);
-    return result;
-}
-
-static long WINAPI expMultiByteToWideChar(long v1, long v2, char* s1, long siz1, short* s2, int siz2)
-{
-#warning FIXME
-    int i;
-    int result;
-    if(s2==0)
-       result=1;
-    else
-    {
-       if(siz1>siz2/2)siz1=siz2/2;
-       for(i=1; i<=siz1; i++)
-       {
-           *s2=*s1;
-           if(!*s1)break;
-           s2++;
-           s1++;
-       }
-       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",
-                 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",
-                 v1, v2, siz1, s2, siz2, result);
-    return result;
-}
-static void wch_print(const short* str)
-{
-    dbgprintf("  src: ");
-    while(*str)dbgprintf("%c", *str++);
-    dbgprintf("\n");
-}
-static long WINAPI expWideCharToMultiByte(long v1, long v2, short* s1, long siz1,
-                                         char* s2, int siz2, char* c3, int* siz3)
-{
-    int result;
-    dbgprintf("WideCharToMultiByte(codepage %d, flags 0x%x, src 0x%x, src size %d, "
-             "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(s2)dbgprintf("  dest: %s\n", s2);
-    return result;
-}
-static long WINAPI expGetVersionExA(OSVERSIONINFOA* c)
-{
-    dbgprintf("GetVersionExA(0x%x) => 1\n");
-    c->dwOSVersionInfoSize=sizeof(*c);
-    c->dwMajorVersion=4;
-    c->dwMinorVersion=0;
-    c->dwBuildNumber=0x4000457;
-#if 1
-    // 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_NT\n Version string: 'Service Pack 3'\n");
-    return 1;
-}
-static HANDLE WINAPI expCreateSemaphoreA(char* v1, long init_count,
-                                        long max_count, char* name)
-{
-    pthread_mutex_t *pm;
-    pthread_cond_t  *pc;
-    mutex_list* pp;
-    /*
-     printf("CreateSemaphoreA(%p = %s)\n", name, (name ? name : "<null>"));
-     pp=mlist;
-     while(pp)
-     {
-     printf("%p => ", pp);
-     pp=pp->prev;
-     }
-     printf("0\n");
-     */
-    if(mlist!=NULL)
-    {
-       mutex_list* pp=mlist;
-       if(name!=NULL)
-           do
-       {
-           if((strcmp(pp->name, name)==0) && (pp->type==1))
-           {
-               dbgprintf("CreateSemaphoreA(0x%x, init_count %d, max_count %d, name 0x%x='%s') => 0x%x\n",
-                         v1, init_count, max_count, name, name, mlist);
-               return (HANDLE)mlist;
-           }
-       }while((pp=pp->prev) != NULL);
-    }
-    pm=mreq_private(sizeof(pthread_mutex_t), 0, AREATYPE_MUTEX);
-    pthread_mutex_init(pm, NULL);
-    pc=mreq_private(sizeof(pthread_cond_t), 0, AREATYPE_COND);
-    pthread_cond_init(pc, NULL);
-    if(mlist==NULL)
-    {
-       mlist=mreq_private(sizeof(mutex_list), 00, AREATYPE_EVENT);
-       mlist->next=mlist->prev=NULL;
-    }
-    else
-    {
-       mlist->next=mreq_private(sizeof(mutex_list), 00, AREATYPE_EVENT);
-       mlist->next->prev=mlist;
-       mlist->next->next=NULL;
-       mlist=mlist->next;
-       //      printf("new semaphore %p\n", mlist);
-    }
-    mlist->type=1; /* Type Semaphore */
-    mlist->pm=pm;
-    mlist->pc=pc;
-    mlist->state=0;
-    mlist->reset=0;
-    mlist->semaphore=init_count;
-    if(name!=NULL)
-       strncpy(mlist->name, name, 64);
-    else
-       mlist->name[0]=0;
-    if(pm==NULL)
-       dbgprintf("ERROR::: CreateSemaphoreA failure\n");
-    if(name)
-       dbgprintf("CreateSemaphoreA(0x%x, init_count %d, max_count %d, name 0x%x='%s') => 0x%x\n",
-                 v1, init_count, max_count, name, name, mlist);
-    else
-       dbgprintf("CreateSemaphoreA(0x%x, init_count %d, max_count %d, name 0) => 0x%x\n",
-                 v1, init_count, max_count, mlist);
-    return (HANDLE)mlist;
-}
-
-static long WINAPI expReleaseSemaphore(long hsem, long increment, long* prev_count)
-{
-    // The state of a semaphore object is signaled when its count
-    // is greater than zero and nonsignaled when its count is equal to zero
-    // Each time a waiting thread is released because of the semaphore's signaled
-    // state, the count of the semaphore is decreased by one.
-    mutex_list *ml = (mutex_list *)hsem;
-
-    pthread_mutex_lock(ml->pm);
-    if (prev_count != 0) *prev_count = ml->semaphore;
-    if (ml->semaphore == 0) pthread_cond_signal(ml->pc);
-    ml->semaphore += increment;
-    pthread_mutex_unlock(ml->pm);
-    dbgprintf("ReleaseSemaphore(semaphore 0x%x, increment %d, prev_count 0x%x) => 1\n",
-             hsem, increment, prev_count);
-    return 1;
-}
-
-
-static long WINAPI expRegOpenKeyExA(long key, const char* subkey, long reserved, long access, int* newkey)
-{
-    long result=RegOpenKeyExA(key, subkey, reserved, access, newkey);
-    dbgprintf("RegOpenKeyExA(key 0x%x, subkey %s, reserved %d, access 0x%x, pnewkey 0x%x) => %d\n",
-             key, subkey, reserved, access, newkey, result);
-    if(newkey)dbgprintf("  New key: 0x%x\n", *newkey);
-    return result;
-}
-static long WINAPI expRegCloseKey(long key)
-{
-    long result=RegCloseKey(key);
-    dbgprintf("RegCloseKey(0x%x) => %d\n", key, result);
-    return result;
-}
-static long WINAPI expRegQueryValueExA(long key, const char* value, int* reserved, int* type, int* data, int* count)
-{
-    long result=RegQueryValueExA(key, value, reserved, type, data, count);
-    dbgprintf("RegQueryValueExA(key 0x%x, value %s, reserved 0x%x, data 0x%x, count 0x%x)"
-             " => 0x%x\n", key, value, reserved, data, count, result);
-    if(data && count)dbgprintf("  read %d bytes: '%s'\n", *count, data);
-    return result;
-}
-
-//from wine source dlls/advapi32/registry.c
-static long WINAPI expRegCreateKeyA(long hkey, const char* name, int *retkey)
-{
-    dbgprintf("RegCreateKeyA(key 0x%x, name 0x%x='%s',newkey=0x%x)\n",hkey,name,retkey);
-    return RegCreateKeyExA( hkey, name, 0, NULL,REG_OPTION_NON_VOLATILE,
-                            KEY_ALL_ACCESS , NULL, retkey, NULL );
-}
-
-static long WINAPI expRegCreateKeyExA(long key, const char* name, long reserved,
-                                     void* classs, long options, long security,
-                                     void* sec_attr, int* newkey, int* status)
-{
-    long result=RegCreateKeyExA(key, name, reserved, classs, options, security, sec_attr, newkey, status);
-    dbgprintf("RegCreateKeyExA(key 0x%x, name 0x%x='%s', reserved=0x%x,"
-             " 0x%x, 0x%x, 0x%x, newkey=0x%x, status=0x%x) => %d\n",
-             key, name, name, reserved, classs, options, security, sec_attr, newkey, status, result);
-    if(!result && newkey) dbgprintf("  New key: 0x%x\n", *newkey);
-    if(!result && status) dbgprintf("  New key status: 0x%x\n", *status);
-    return result;
-}
-static long WINAPI expRegSetValueExA(long key, const char* name, long v1, long v2, void* data, long size)
-{
-    long result=RegSetValueExA(key, name, v1, v2, data, size);
-    dbgprintf("RegSetValueExA(key 0x%x, name '%s', 0x%x, 0x%x, data 0x%x -> 0x%x '%s', size=%d) => %d",
-             key, name, v1, v2, data, *(int*)data, data, size, result);
-    return result;
-}
-
-static long WINAPI expRegOpenKeyA (long hKey, LPCSTR lpSubKey, int* phkResult)
-{
-    long result=RegOpenKeyExA(hKey, lpSubKey, 0, 0, phkResult);
-    dbgprintf("RegOpenKeyExA(key 0x%x, subkey '%s', 0x%x) => %d\n",
-             hKey, lpSubKey, phkResult, result);
-    if(!result && phkResult) dbgprintf("  New key: 0x%x\n", *phkResult);
-    return result;
-}
-
-static 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);
-}
-
-static DWORD WINAPI expRegEnumKeyExA(HKEY hKey, DWORD dwIndex, LPSTR lpName, LPDWORD lpcbName,
-                                    LPDWORD lpReserved, LPSTR lpClass, LPDWORD lpcbClass,
-                                    LPFILETIME lpftLastWriteTime)
-{
-    return RegEnumKeyExA(hKey, dwIndex, lpName, lpcbName, lpReserved, lpClass,
-                        lpcbClass, lpftLastWriteTime);
-}
-
-static long WINAPI expQueryPerformanceCounter(long long* z)
-{
-    longcount(z);
-    dbgprintf("QueryPerformanceCounter(0x%x) => 1 ( %Ld )\n", z, *z);
-    return 1;
-}
-
-/*
- * dummy function RegQueryInfoKeyA(), required by vss codecs
- */
-static DWORD WINAPI expRegQueryInfoKeyA( HKEY hkey, LPSTR class, LPDWORD class_len, LPDWORD reserved,
-                                         LPDWORD subkeys, LPDWORD max_subkey, LPDWORD max_class,
-                                         LPDWORD values, LPDWORD max_value, LPDWORD max_data,
-                                         LPDWORD security, FILETIME *modif )
-{
-    return ERROR_SUCCESS;
-}
-
-/*
- * return CPU clock (in kHz), using linux's /proc filesystem (/proc/cpuinfo)
- */
-static double linux_cpuinfo_freq()
-{
-    double freq=-1;
-    FILE *f;
-    char line[200];
-    char *s,*value;
-
-    f = fopen ("/proc/cpuinfo", "r");
-    if (f != NULL) {
-       while (fgets(line,sizeof(line),f)!=NULL) {
-           /* NOTE: the ':' is the only character we can rely on */
-           if (!(value = strchr(line,':')))
-               continue;
-           /* terminate the valuename */
-           *value++ = '\0';
-           /* skip any leading spaces */
-           while (*value==' ') value++;
-           if ((s=strchr(value,'\n')))
-               *s='\0';
-
-           if (!strncasecmp(line, "cpu MHz",strlen("cpu MHz"))
-               && sscanf(value, "%lf", &freq) == 1) {
-               freq*=1000;
-               break;
-           }
-       }
-       fclose(f);
-    }
-    return freq;
-}
-
-
-static double solaris_kstat_freq()
-{
-#if    defined(HAVE_LIBKSTAT) && defined(KSTAT_DATA_INT32)
-    /*
-     * try to extract the CPU speed from the solaris kernel's kstat data
-     */
-    kstat_ctl_t   *kc;
-    kstat_t       *ksp;
-    kstat_named_t *kdata;
-    int            mhz = 0;
-
-    kc = kstat_open();
-    if (kc != NULL)
-    {
-       ksp = kstat_lookup(kc, "cpu_info", 0, "cpu_info0");
-
-       /* kstat found and name/value pairs? */
-       if (ksp != NULL && ksp->ks_type == KSTAT_TYPE_NAMED)
-       {
-           /* read the kstat data from the kernel */
-           if (kstat_read(kc, ksp, NULL) != -1)
-           {
-               /*
-                * lookup desired "clock_MHz" entry, check the expected
-                * data type
-                */
-               kdata = (kstat_named_t *)kstat_data_lookup(ksp, "clock_MHz");
-               if (kdata != NULL && kdata->data_type == KSTAT_DATA_INT32)
-                   mhz = kdata->value.i32;
-           }
-       }
-       kstat_close(kc);
-    }
-
-    if (mhz > 0)
-       return mhz * 1000.;
-#endif /* HAVE_LIBKSTAT */
-    return -1;         // kstat stuff is not available, CPU freq is unknown
-}
-
-/*
- * Measure CPU freq using the pentium's time stamp counter register (TSC)
- */
-static double tsc_freq()
-{
-    static double ofreq=0.0;
-    int i;
-    int x,y;
-    i=time(NULL);
-    if (ofreq != 0.0) return ofreq;
-    while(i==time(NULL));
-    x=localcount();
-    i++;
-    while(i==time(NULL));
-    y=localcount();
-    ofreq = (double)(y-x)/1000.;
-    return ofreq;
-}
-
-static double CPU_Freq()
-{
-    double freq;
-
-    if ((freq = linux_cpuinfo_freq()) > 0)
-       return freq;
-
-    if ((freq = solaris_kstat_freq()) > 0)
-       return freq;
-
-    return tsc_freq();
-}
-
-static long WINAPI expQueryPerformanceFrequency(long long* z)
-{
-    *z=(long long)CPU_Freq();
-    dbgprintf("QueryPerformanceFrequency(0x%x) => 1 ( %Ld )\n", z, *z);
-    return 1;
-}
-static long WINAPI exptimeGetTime()
-{
-    struct timeval t;
-    long result;
-    gettimeofday(&t, 0);
-    result=1000*t.tv_sec+t.tv_usec/1000;
-    dbgprintf("timeGetTime() => %d\n", result);
-    return result;
-}
-static void* WINAPI expLocalHandle(void* v)
-{
-    dbgprintf("LocalHandle(0x%x) => 0x%x\n", v, v);
-    return v;
-}
-
-static void* WINAPI expGlobalHandle(void* v)
-{
-    dbgprintf("GlobalHandle(0x%x) => 0x%x\n", v, v);
-    return v;
-}
-static int WINAPI expGlobalUnlock(void* v)
-{
-    dbgprintf("GlobalUnlock(0x%x) => 1\n", v);
-    return 1;
-}
-static void* WINAPI expGlobalFree(void* v)
-{
-    dbgprintf("GlobalFree(0x%x) => 0\n", v);
-    my_release(v);
-    //free(v);
-    return 0;
-}
-
-static void* WINAPI expGlobalReAlloc(void* v, int size, int flags)
-{
-    void* result=my_realloc(v, size);
-    //void* result=realloc(v, size);
-    dbgprintf("GlobalReAlloc(0x%x, size %d, flags 0x%x) => 0x%x\n", v,size,flags,result);
-    return result;
-}
-
-static int WINAPI expLocalUnlock(void* v)
-{
-    dbgprintf("LocalUnlock(0x%x) => 1\n", v);
-    return 1;
-}
-//
-static void* WINAPI expLocalFree(void* v)
-{
-    dbgprintf("LocalFree(0x%x) => 0\n", v);
-    my_release(v);
-    return 0;
-}
-static HRSRC WINAPI expFindResourceA(HMODULE module, char* name, char* type)
-{
-    HRSRC result;
-
-    result=FindResourceA(module, name, type);
-    dbgprintf("FindResourceA(module 0x%x, name 0x%x(%s), type 0x%x(%s)) => 0x%x\n",
-       module, name, HIWORD(name) ? name : "UNICODE", type, HIWORD(type) ? type : "UNICODE", result);
-    return result;
-}
-
-extern HRSRC WINAPI LoadResource(HMODULE, HRSRC);
-static HGLOBAL WINAPI expLoadResource(HMODULE module, HRSRC res)
-{
-    HGLOBAL result=LoadResource(module, res);
-    dbgprintf("LoadResource(module 0x%x, resource 0x%x) => 0x%x\n", module, res, result);
-    return result;
-}
-static void* WINAPI expLockResource(long res)
-{
-    void* result=LockResource(res);
-    dbgprintf("LockResource(0x%x) => 0x%x\n", res, result);
-    return result;
-}
-static int WINAPI expFreeResource(long res)
-{
-    int result=FreeResource(res);
-    dbgprintf("FreeResource(0x%x) => %d\n", res, result);
-    return result;
-}
-//bool fun(HANDLE)
-//!0 on success
-static int WINAPI expCloseHandle(long v1)
-{
-    dbgprintf("CloseHandle(0x%x) => 1\n", v1);
-    /* do not close stdin,stdout and stderr */
-    if (v1 > 2)
-       if (!close(v1))
-           return 0;
-    return 1;
-}
-
-static const char* WINAPI expGetCommandLineA()
-{
-    dbgprintf("GetCommandLineA() => \"c:\\aviplay.exe\"\n");
-    return "c:\\aviplay.exe";
-}
-static short envs[]={'p', 'a', 't', 'h', ' ', 'c', ':', '\\', 0, 0};
-static LPWSTR WINAPI expGetEnvironmentStringsW()
-{
-    dbgprintf("GetEnvironmentStringsW() => 0\n", envs);
-    return 0;
-}
-static void * WINAPI expRtlZeroMemory(void *p, size_t len)
-{
-    void* result=memset(p,0,len);
-    dbgprintf("RtlZeroMemory(0x%x, len %d) => 0x%x\n",p,len,result);
-    return result;
-}
-static void * WINAPI expRtlMoveMemory(void *dst, void *src, size_t len)
-{
-    void* result=memmove(dst,src,len);
-    dbgprintf("RtlMoveMemory (dest 0x%x, src 0x%x, len %d) => 0x%x\n",dst,src,len,result);
-    return result;
-}
-
-static void * WINAPI expRtlFillMemory(void *p, int ch, size_t len)
-{
-    void* result=memset(p,ch,len);
-    dbgprintf("RtlFillMemory(0x%x, char 0x%x, len %d) => 0x%x\n",p,ch,len,result);
-    return result;
-}
-static int WINAPI expFreeEnvironmentStringsW(short* strings)
-{
-    dbgprintf("FreeEnvironmentStringsW(0x%x) => 1\n", strings);
-    return 1;
-}
-static int WINAPI expFreeEnvironmentStringsA(char* strings)
-{
-    dbgprintf("FreeEnvironmentStringsA(0x%x) => 1\n", strings);
-    return 1;
-}
-
-static const char ch_envs[]=
-"__MSVCRT_HEAP_SELECT=__GLOBAL_HEAP_SELECTED,1\r\n"
-"PATH=C:\\;C:\\windows\\;C:\\windows\\system\r\n";
-static LPCSTR WINAPI expGetEnvironmentStrings()
-{
-    dbgprintf("GetEnvironmentStrings() => 0x%x\n", ch_envs);
-    return (LPCSTR)ch_envs;
-    // dbgprintf("GetEnvironmentStrings() => 0\n");
-    // return 0;
-}
-
-static int WINAPI expGetStartupInfoA(STARTUPINFOA *s)
-{
-    int i;
-    dbgprintf("GetStartupInfoA(0x%x) => 1\n");
-    memset(s, 0, sizeof(*s));
-    s->cb=sizeof(*s);
-    // s->lpReserved="Reserved";
-    // s->lpDesktop="Desktop";
-    // s->lpTitle="Title";
-    // s->dwX=s->dwY=0;
-    // s->dwXSize=s->dwYSize=200;
-    s->dwFlags=s->wShowWindow=1;
-    // s->hStdInput=s->hStdOutput=s->hStdError=0x1234;
-    dbgprintf("  cb=%d\n", s->cb);
-    dbgprintf("  lpReserved='%s'\n", s->lpReserved);
-    dbgprintf("  lpDesktop='%s'\n", s->lpDesktop);
-    dbgprintf("  lpTitle='%s'\n", s->lpTitle);
-    dbgprintf("  dwX=%d dwY=%d dwXSize=%d dwYSize=%d\n",
-             s->dwX, s->dwY, s->dwXSize, s->dwYSize);
-    dbgprintf("  dwXCountChars=%d dwYCountChars=%d dwFillAttribute=%d\n",
-             s->dwXCountChars, s->dwYCountChars, s->dwFillAttribute);
-    dbgprintf("  dwFlags=0x%x wShowWindow=0x%x cbReserved2=0x%x\n",
-             s->dwFlags, s->wShowWindow, s->cbReserved2);
-    dbgprintf("  lpReserved2=0x%x hStdInput=0x%x hStdOutput=0x%x hStdError=0x%x\n",
-             s->lpReserved2, s->hStdInput, s->hStdOutput, s->hStdError);
-    return 1;
-}
-
-static int WINAPI expGetStdHandle(int z)
-{
-    dbgprintf("GetStdHandle(0x%x) => 0x%x\n", z+0x1234);
-    return z+0x1234;
-}
-
-#ifdef QTX
-#define FILE_HANDLE_quicktimeqts       ((HANDLE)0x444)
-#define FILE_HANDLE_quicktimeqtx       ((HANDLE)0x445)
-#endif
-
-static int WINAPI expGetFileType(int handle)
-{
-    dbgprintf("GetFileType(0x%x) => 0x3 = pipe\n", handle);
-    return 0x3;
-}
-#ifdef QTX
-static int WINAPI expGetFileAttributesA(char *filename)
-{
-    dbgprintf("GetFileAttributesA(%s) => FILE_ATTR_NORMAL\n", filename);
-    if (strstr(filename, "QuickTime.qts"))
-       return FILE_ATTRIBUTE_SYSTEM;
-    return FILE_ATTRIBUTE_NORMAL;
-}
-#endif
-static int WINAPI expSetHandleCount(int count)
-{
-    dbgprintf("SetHandleCount(0x%x) => 1\n", count);
-    return 1;
-}
-static int WINAPI expGetACP(void)
-{
-    dbgprintf("GetACP() => 0\n");