summaryrefslogtreecommitdiff
path: root/src/libw32dll/wine
diff options
context:
space:
mode:
authorGuenter Bartsch <guenter@users.sourceforge.net>2002-12-18 04:00:45 +0000
committerGuenter Bartsch <guenter@users.sourceforge.net>2002-12-18 04:00:45 +0000
commit85632e5177760e08d3d40dcfe9456bef54fcdc2d (patch)
tree23fe16c5ebbc032f620ac5d97706a539982426a2 /src/libw32dll/wine
parent54e7d3ecdb73fbbe09025c7f8b3bdbbe8ea87690 (diff)
downloadxine-lib-85632e5177760e08d3d40dcfe9456bef54fcdc2d.tar.gz
xine-lib-85632e5177760e08d3d40dcfe9456bef54fcdc2d.tar.bz2
first draft of quicktime binary-only codec support
CVS patchset: 3580 CVS date: 2002/12/18 04:00:45
Diffstat (limited to 'src/libw32dll/wine')
-rw-r--r--src/libw32dll/wine/Makefile.am10
-rw-r--r--src/libw32dll/wine/afl.c65
-rw-r--r--src/libw32dll/wine/com.h18
-rw-r--r--src/libw32dll/wine/driver.c246
-rw-r--r--src/libw32dll/wine/elfdll.c10
-rw-r--r--src/libw32dll/wine/ldt_keeper.c9
-rw-r--r--src/libw32dll/wine/module.c480
-rw-r--r--src/libw32dll/wine/module.h10
-rw-r--r--src/libw32dll/wine/registry.c98
-rw-r--r--src/libw32dll/wine/vfl.c190
-rw-r--r--src/libw32dll/wine/vfw.h23
-rw-r--r--src/libw32dll/wine/win32.c1138
-rw-r--r--src/libw32dll/wine/win32.h6
-rw-r--r--src/libw32dll/wine/wineacm.h25
-rw-r--r--src/libw32dll/wine/wrapper.S83
-rw-r--r--src/libw32dll/wine/wrapper.h20
16 files changed, 1812 insertions, 619 deletions
diff --git a/src/libw32dll/wine/Makefile.am b/src/libw32dll/wine/Makefile.am
index ecae2cdaa..48b3cee8f 100644
--- a/src/libw32dll/wine/Makefile.am
+++ b/src/libw32dll/wine/Makefile.am
@@ -1,4 +1,4 @@
-EXTRA_DIST = stubs.s
+EXTRA_DIST = stubs.s wrapper.S
noinst_LTLIBRARIES = $(wine_lib)
@@ -33,7 +33,7 @@ libwine_la_SOURCES = \
vfl.c \
win32.c
-libwine_la_LIBADD = stubs.lo
+libwine_la_LIBADD = stubs.lo wrapper.lo
noinst_HEADERS = \
avifmt.h \
@@ -70,11 +70,15 @@ noinst_HEADERS = \
winestring.h \
winnt.h \
winreg.h \
- winuser.h
+ winuser.h \
+ wrapper.h
stubs.lo: stubs.s
$(CC) -c $(srcdir)/stubs.s -o stubs.lo
+wrapper.lo: wrapper.S
+ $(CC) -c $(srcdir)/wrapper.S -o wrapper.lo
+
debug:
@$(MAKE) CFLAGS="$(DEBUG_CFLAGS)"
diff --git a/src/libw32dll/wine/afl.c b/src/libw32dll/wine/afl.c
index a887ead80..6f3fb0eb6 100644
--- a/src/libw32dll/wine/afl.c
+++ b/src/libw32dll/wine/afl.c
@@ -39,6 +39,10 @@
#include "driver.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#pragma pack(1)
#define OpenDriverA DrvOpen
#define CloseDriver DrvClose
@@ -215,7 +219,8 @@ MMRESULT WINAPI acmDriverOpen(PHACMDRIVER phad, HACMDRIVERID hadid, DWORD fdwOpe
icopen.dwSize = sizeof(ICOPEN);
icopen.dwFlags = 0;
- if (!padid->hInstModule)
+ icopen.pV1Reserved = padid->pszFileName;
+ if (!padid->hInstModule)
pad->hDrvr = OpenDriverA((long)&icopen);
else
pad->hDrvr = padid->hInstModule;
@@ -267,22 +272,19 @@ PWINE_ACMDRIVERID MSACM_pLastACMDriverID = NULL;
/***********************************************************************
* MSACM_RegisterDriver32()
*/
-PWINE_ACMDRIVERID MSACM_RegisterDriver(LPSTR pszDriverAlias, LPSTR pszFileName,
+PWINE_ACMDRIVERID MSACM_RegisterDriver(const char* pszFileName,
+ WORD wFormatTag,
HINSTANCE hinstModule)
-//
-// File names are stored in driver.c. I reuse this variable to store driver ID
-// in it. If it's <0x10000, it is primary codec for corresponding format.
-//
{
PWINE_ACMDRIVERID padid;
- TRACE("('%s', '%x', 0x%08x)\n", pszDriverAlias, pszFileName, hinstModule);
+ TRACE("('%s', '%x', 0x%08x)\n", pszFileName, wFormatTag, hinstModule);
padid = (PWINE_ACMDRIVERID) HeapAlloc(MSACM_hHeap, 0, sizeof(WINE_ACMDRIVERID));
- padid->pszDriverAlias = (char*)malloc(strlen(pszDriverAlias)+1);
- strcpy(padid->pszDriverAlias, pszDriverAlias);
+ padid->pszFileName = (char*)malloc(strlen(pszFileName)+1);
+ strcpy(padid->pszFileName, pszFileName);
// 1~strdup(pszDriverAlias);
- padid->pszFileName = pszFileName;
+ padid->wFormatTag = wFormatTag;
padid->hInstModule = hinstModule;
padid->bEnabled = TRUE;
padid->pACMDriverList = NULL;
@@ -297,23 +299,6 @@ PWINE_ACMDRIVERID MSACM_RegisterDriver(LPSTR pszDriverAlias, LPSTR pszFileName,
return padid;
}
-/***********************************************************************
- * MSACM_RegisterAllDrivers32()
- */
-void MSACM_RegisterAllDrivers(void)
-{
- /*LPSTR pszBuffer;
- DWORD dwBufferLength; -- not used */
-
- if (MSACM_pFirstACMDriverID)
- return;
-
- MSACM_RegisterDriver("divxa32", (LPSTR)0x161, 0); // DivX/WMA [07]
- MSACM_RegisterDriver("msadp32", (LPSTR)0x2, 0); // MS ADPCM [08]
- MSACM_RegisterDriver("l3codeca", (LPSTR)0x55, 0); // MPEG Layer-3 [12]
-// MSACM_RegisterDriver("imaadp32", (LPSTR)0x11, 0); // IMA ADPCM [13]
-// MSACM_RegisterDriver("msgsm32", (LPSTR)0x32, 0); // MS GSM 6.10 [14]
-}
/***********************************************************************
* MSACM_UnregisterDriver32()
@@ -325,10 +310,8 @@ PWINE_ACMDRIVERID MSACM_UnregisterDriver(PWINE_ACMDRIVERID p)
while (p->pACMDriverList)
acmDriverClose((HACMDRIVER) p->pACMDriverList, 0);
- if (p->pszDriverAlias)
- HeapFree(MSACM_hHeap, 0, p->pszDriverAlias);
-// if (p->pszFileName)
-// HeapFree(MSACM_hHeap, 0, p->pszFileName);
+ if (p->pszFileName)
+ free(p->pszFileName);
if (p == MSACM_pFirstACMDriverID)
MSACM_pFirstACMDriverID = p->pNextACMDriverID;
@@ -398,8 +381,6 @@ MMRESULT WINAPI acmStreamOpen(PHACMSTREAM phas, HACMDRIVER had, PWAVEFORMATEX pw
int wfxSrcSize;
int wfxDstSize;
- //printf("gcc-3.0 bug, pwfxSrc=%p, pwfxSrc->cbSize=%d\n", pwfxSrc, pwfxSrc->cbSize);
-
TRACE("(%p, 0x%08x, %p, %p, %p, %ld, %ld, %ld)\n",
phas, had, pwfxSrc, pwfxDst, pwfltr, dwCallback, dwInstance, fdwOpen);
@@ -416,13 +397,15 @@ MMRESULT WINAPI acmStreamOpen(PHACMSTREAM phas, HACMDRIVER had, PWAVEFORMATEX pw
wfxDstSize = SIZEOF_WFX(pwfxDst);
#undef SIZEOF_WFX
- was = HeapAlloc(MSACM_hHeap, 0, sizeof(*was) + wfxSrcSize + wfxDstSize + ((pwfltr) ? sizeof(WAVEFILTER) : 0));
+ 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) {
@@ -479,10 +462,14 @@ MMRESULT WINAPI acmStreamOpen(PHACMSTREAM phas, HACMDRIVER had, PWAVEFORMATEX pw
}
}
acmDriverClose(had, 0L);*/
- if(MSACM_pFirstACMDriverID==NULL)
- MSACM_RegisterAllDrivers();
+ //if(MSACM_pFirstACMDriverID==NULL)
+ // MSACM_RegisterAllDrivers();
- for (wadi = MSACM_pFirstACMDriverID; wadi; wadi = wadi->pNextACMDriverID) {
+ 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)) != 0) {
@@ -491,6 +478,8 @@ MMRESULT WINAPI acmStreamOpen(PHACMSTREAM phas, HACMDRIVER had, PWAVEFORMATEX pw
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);
diff --git a/src/libw32dll/wine/com.h b/src/libw32dll/wine/com.h
index 84a667f0f..50d47a7f2 100644
--- a/src/libw32dll/wine/com.h
+++ b/src/libw32dll/wine/com.h
@@ -27,12 +27,12 @@ typedef struct
} GUID;
#endif
-extern GUID IID_IUnknown;
-extern GUID IID_IClassFactory;
+extern const GUID IID_IUnknown;
+extern const GUID IID_IClassFactory;
-typedef long (*GETCLASSOBJECT) (GUID* clsid, GUID* iid, void** ppv);
-int RegisterComClass(GUID* clsid, GETCLASSOBJECT gcs);
-int UnregisterComClass(GUID* clsid, GETCLASSOBJECT gcs);
+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__))
@@ -42,7 +42,7 @@ struct IUnknown;
struct IClassFactory;
struct IUnknown_vt
{
- long STDCALL (*QueryInterface)(struct IUnknown* _this, GUID* iid, void** ppv);
+ long STDCALL (*QueryInterface)(struct IUnknown* _this, const GUID* iid, void** ppv);
long STDCALL (*AddRef)(struct IUnknown* _this) ;
long STDCALL (*Release)(struct IUnknown* _this) ;
} ;
@@ -54,10 +54,10 @@ typedef struct IUnknown
struct IClassFactory_vt
{
- long STDCALL (*QueryInterface)(struct IUnknown* _this, GUID* iid, void** ppv);
+ 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, GUID* riid, void** ppvObject);
+ long STDCALL (*CreateInstance)(struct IClassFactory* _this, struct IUnknown* pUnkOuter, const GUID* riid, void** ppvObject);
};
struct IClassFactory
@@ -66,7 +66,7 @@ struct IClassFactory
};
long CoCreateInstance(GUID* rclsid, struct IUnknown* pUnkOuter,
- long dwClsContext, GUID* riid, void** ppv);
+ long dwClsContext, const GUID* riid, void** ppv);
#ifdef __cplusplus
};
diff --git a/src/libw32dll/wine/driver.c b/src/libw32dll/wine/driver.c
index 822d0167f..8dea4b85f 100644
--- a/src/libw32dll/wine/driver.c
+++ b/src/libw32dll/wine/driver.c
@@ -9,29 +9,34 @@
#endif
#include "win32.h"
+#include "driver.h"
#include "pe_image.h"
#include "winreg.h"
#include "vfw.h"
#include "registry.h"
#include "ldt_keeper.h"
-#include "driver.h"
+
+extern char* win32_def_path;
#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
+ * 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 /**/
+
+#define STORE_ALL
+#define REST_ALL
#else
+// this asm code is no longer needed
#define STORE_ALL \
- __asm__( \
+ __asm__ __volatile__ ( \
"push %%ebx\n\t" \
"push %%ecx\n\t" \
"push %%edx\n\t" \
@@ -39,7 +44,7 @@
"push %%edi\n\t"::)
#define REST_ALL \
- __asm__( \
+ __asm__ __volatile__ ( \
"pop %%edi\n\t" \
"pop %%esi\n\t" \
"pop %%edx\n\t" \
@@ -47,182 +52,123 @@
"pop %%ebx\n\t"::)
#endif
+static int needs_free=0;
+void SetCodecPath(const char* path)
+{
+ if(needs_free)free(win32_def_path);
+ if(path==0)
+ {
+ win32_def_path=WIN32_PATH;
+ needs_free=0;
+ return;
+ }
+ win32_def_path = (char*) malloc(strlen(path)+1);
+ strcpy(win32_def_path, path);
+ needs_free=1;
+}
-
-
static DWORD dwDrvID = 0;
-
-LRESULT WINAPI SendDriverMessage( HDRVR hDriver, UINT message,
- LPARAM lParam1, LPARAM lParam2 )
+LRESULT WINAPI SendDriverMessage(HDRVR hDriver, UINT message,
+ LPARAM lParam1, LPARAM lParam2)
{
DRVR* module=(DRVR*)hDriver;
int result;
-#ifdef DETAILED_OUT
+#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==0)return -1;
- if(module->hDriverModule==0)return -1;
- if(module->DriverProc==0)return -1;
+ if (!module || !module->hDriverModule || !module->DriverProc) return -1;
+#ifndef __svr4__
+ __asm__ __volatile__ ("fsave (%0)\n\t": :"r"(&qw));
+#endif
+
+ Setup_FS_Segment();
+
STORE_ALL;
- result=module->DriverProc(module->dwDriverID,1,message,lParam1,lParam2);
+ result=module->DriverProc(module->dwDriverID, hDriver, message, lParam1, lParam2);
REST_ALL;
-#ifdef DETAILED_OUT
+
+#ifndef __svr4__
+ __asm__ __volatile__ ("frstor (%0)\n\t": :"r"(&qw));
+#endif
+
+#ifdef DETAILED_OUT
printf("\t\tResult: %X\n", result);
#endif
return result;
}
-static NPDRVR DrvAlloc(HDRVR*lpDriver, LPUINT lpDrvResult)
+void DrvClose(HDRVR hDriver)
{
- NPDRVR npDriver;
- /* allocate and lock handle */
- if (lpDriver)
+ if (hDriver)
{
- if ( (*lpDriver = (HDRVR) malloc(sizeof(DRVR))) )
- {
- if ((npDriver = (NPDRVR) *lpDriver))
- {
- *lpDrvResult = MMSYSERR_NOERROR;
- return (npDriver);
- }
- free((NPDRVR)*lpDriver);
- }
- return (*lpDrvResult = MMSYSERR_NOMEM, (NPDRVR) 0);
- }
- return (*lpDrvResult = MMSYSERR_INVALPARAM, (NPDRVR) 0);
-}
-
-
-static void DrvFree(HDRVR hDriver)
-{
- /* int i; -- unused */
- Setup_FS_Segment();
- if(hDriver)
- if(((DRVR*)hDriver)->hDriverModule)
- if(((DRVR*)hDriver)->DriverProc)
- (((DRVR*)hDriver)->DriverProc)(((DRVR*)hDriver)->dwDriverID, hDriver, DRV_CLOSE, 0, 0);
- if(hDriver) {
- if(((DRVR*)hDriver)->hDriverModule)
- if(((DRVR*)hDriver)->DriverProc)
- (((DRVR*)hDriver)->DriverProc)(0, hDriver, DRV_FREE, 0, 0);
- FreeLibrary(((DRVR*)hDriver)->hDriverModule);
- free((NPDRVR)hDriver);
- return;
+ DRVR* d = (DRVR*)hDriver;
+ if (d->hDriverModule)
+ {
+ Setup_FS_Segment();
+ if (d->DriverProc)
+ {
+ SendDriverMessage(hDriver, DRV_CLOSE, 0, 0);
+ d->dwDriverID = 0;
+ SendDriverMessage(hDriver, DRV_FREE, 0, 0);
+ }
+ FreeLibrary(d->hDriverModule);
+ }
+ free(d);
}
-}
-
-void DrvClose(HDRVR hdrvr)
-{
- DrvFree(hdrvr);
CodecRelease();
}
-
-char* win32_codec_name=NULL; // must be set before calling DrvOpen() !!!
-
-HDRVR VFWAPI
-DrvOpen(LPARAM lParam2)
+//DrvOpen(LPCSTR lpszDriverName, LPCSTR lpszSectionName, LPARAM lParam2)
+HDRVR DrvOpen(LPARAM lParam2)
{
- /* ICOPEN *icopen=(ICOPEN *) lParam2; -- unused */
- UINT uDrvResult;
- HDRVR hDriver;
- NPDRVR npDriver;
- char unknown[0x24];
-// char* codec_name=icopen->fccHandler;
+ NPDRVR hDriver;
+ int i;
+ char unknown[0x124];
+ const char* filename = (const char*) ((ICOPEN*) lParam2)->pV1Reserved;
- Setup_FS_Segment();
+ Setup_LDT_Keeper();
+ printf("Loading codec DLL: '%s'\n",filename);
- if (!(npDriver = DrvAlloc(&hDriver, &uDrvResult)))
+ hDriver = (NPDRVR) malloc(sizeof(DRVR));
+ if (!hDriver)
return ((HDRVR) 0);
+ memset((void*)hDriver, 0, sizeof(DRVR));
- if (!(npDriver->hDriverModule = LoadLibraryA(win32_codec_name))) {
- printf("Can't open library %s\n", win32_codec_name);
- DrvFree(hDriver);
- return ((HDRVR) 0);
- }
+ CodecAlloc();
+ Setup_FS_Segment();
-#if 0
+ hDriver->hDriverModule = LoadLibraryA(filename);
+ if (!hDriver->hDriverModule)
{
- unsigned char *p=((char*)npDriver->hDriverModule);
- double *dp;
- int i;
- p+=0x14c0;
- for(i=0;i<16;i++)printf(" %02X",p[i]); printf("\n");
- dp=(double*)p;
- printf("divx bitrate = %f\n",(float)(*dp));
-// *(double*)((char*)npDriver->hDriverModule+0x14c0)=bitrate;
+ printf("Can't open library %s\n", filename);
+ DrvClose((HDRVR)hDriver);
+ return ((HDRVR) 0);
}
-#endif
-
- if (!(npDriver->DriverProc = (DRIVERPROC)
- GetProcAddress(npDriver->hDriverModule, "DriverProc"))) {
-#if 1
- printf("Library %s is not a VfW/ACM valid codec\n", win32_codec_name);
-#else
- // Try DirectShow...
- GETCLASS func=(GETCLASS)GetProcAddress(npDriver->hDriverModule,"DllGetClassObject");
- if(!func)
- printf("Library %s is not a valid VfW/ACM/DShow codec\n", win32_codec_name);
- else {
- HRESULT result;
- struct IClassFactory* factory=0;
- struct IUnknown* object=0;
- GUID CLSID_Voxware={0x73f7a062, 0x8829, 0x11d1,
- {0xb5, 0x50, 0x00, 0x60, 0x97, 0x24, 0x2d, 0x8d}};
- GUID* id=&CLSID_Voxware;
-
- result=func(id, &IID_IClassFactory, (void**)&factory);
- if(result || (!factory)) printf("No such class object (wrong/missing GUID?)\n");
-
- printf("Calling factory->vt->CreateInstance()\n");
- printf("addr = %X\n",(unsigned int)factory->vt->CreateInstance);
- result=factory->vt->CreateInstance(factory, 0, &IID_IUnknown, (void**)&object);
- printf("Calling factory->vt->Release()\n");
- factory->vt->Release((struct IUnknown*)factory);
- if(result || (!object)) printf("Class factory failure\n");
-
- printf("DirectShow codecs not yet supported...\n");
- }
-#endif
-
- FreeLibrary(npDriver->hDriverModule);
- DrvFree(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", npDriver->DriverProc);
- npDriver->dwDriverID = ++dwDrvID;
-
- Setup_FS_Segment();
+ 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
- STORE_ALL;
- (npDriver->DriverProc)(0, hDriver, DRV_LOAD, 0, 0);
- REST_ALL;
- //TRACE("DRV_LOAD Ok!\n");
- STORE_ALL;
- (npDriver->DriverProc)(0, hDriver, DRV_ENABLE, 0, 0);
- REST_ALL;
- //TRACE("DRV_ENABLE Ok!\n");
+ // open driver and remmeber proper DriverID
+ hDriver->dwDriverID = SendDriverMessage((HDRVR)hDriver, DRV_OPEN, (LPARAM) unknown, lParam2);
+ TRACE("DRV_OPEN Ok!(%X)\n", hDriver->dwDriverID);
- // open driver
- STORE_ALL;
- npDriver->dwDriverID=(npDriver->DriverProc)(npDriver->dwDriverID, hDriver, DRV_OPEN,
- (LPARAM) (LPSTR) unknown, lParam2);
- REST_ALL;
-
- //TRACE("DRV_OPEN Ok!(%X)\n", npDriver->dwDriverID);
-
- if (uDrvResult)
- {
- DrvFree(hDriver);
- hDriver = (HDRVR) 0;
- }
-
-// printf("Successfully loaded codec %s\n",win32_codec_name);
-
- CodecAlloc();
- return (hDriver);
+ printf("Loaded DLL driver %s\n", filename);
+ return (HDRVR)hDriver;
}
-
diff --git a/src/libw32dll/wine/elfdll.c b/src/libw32dll/wine/elfdll.c
index fd4712fcd..ecee7a28c 100644
--- a/src/libw32dll/wine/elfdll.c
+++ b/src/libw32dll/wine/elfdll.c
@@ -22,16 +22,6 @@
#include <ctype.h>
#include <dlfcn.h>
-struct modref_list_t;
-
-typedef struct modref_list_t
-{
- WINE_MODREF* wm;
- struct modref_list_t *next;
- struct modref_list_t *prev;
-}
-modref_list;
-
//WINE_MODREF *local_wm=NULL;
extern modref_list* local_wm;
diff --git a/src/libw32dll/wine/ldt_keeper.c b/src/libw32dll/wine/ldt_keeper.c
index b7c611ddc..fef86c6bd 100644
--- a/src/libw32dll/wine/ldt_keeper.c
+++ b/src/libw32dll/wine/ldt_keeper.c
@@ -1,7 +1,7 @@
/*
- * Copyright (C) 2000-2001 the xine project
+ * Copyright (C) 2000-2002 the xine project
*
- * This file is part of xine, a unix video player.
+ * This file is part of xine, a free video player.
*
* xine is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: ldt_keeper.c,v 1.4 2002/06/21 01:44:17 miguelfreitas Exp $
+ * $Id: ldt_keeper.c,v 1.5 2002/12/18 04:00:53 guenter Exp $
*
*
* contents:
@@ -202,6 +202,8 @@ static void LDT_EntryToBytes( unsigned long *buffer, const struct modify_ldt_ldt
}
#endif
+void* fs_seg=0;
+
ldt_fs_t* Setup_LDT_Keeper(void)
{
struct modify_ldt_ldt_s array;
@@ -216,6 +218,7 @@ ldt_fs_t* Setup_LDT_Keeper(void)
perror( "Cannot open /dev/zero for READ+WRITE. Check permissions! error: ");
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)
diff --git a/src/libw32dll/wine/module.c b/src/libw32dll/wine/module.c
index f7bee81d6..8e88fb5e6 100644
--- a/src/libw32dll/wine/module.c
+++ b/src/libw32dll/wine/module.c
@@ -3,6 +3,13 @@
*
* Copyright 1995 Alexandre Julliard
*/
+
+// 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>
@@ -29,18 +36,15 @@
#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, u_int32_t *flags);
+static int report_func_ret(void *stack_base, int stack_size, reg386_t *reg, u_int32_t *flags);
+#endif
+
//#undef TRACE
//#define TRACE printf
-struct modref_list_t;
-
-typedef struct modref_list_t
-{
- WINE_MODREF* wm;
- struct modref_list_t *next;
- struct modref_list_t *prev;
-} modref_list;
-
//WINE_MODREF *local_wm=NULL;
modref_list* local_wm=NULL;
@@ -49,10 +53,11 @@ HANDLE SegptrHeap;
WINE_MODREF* MODULE_FindModule(LPCSTR m)
{
modref_list* list=local_wm;
- TRACE("Module %s request\n", m);
+ TRACE("FindModule: Module %s request\n", m);
if(list==NULL)
return NULL;
- while(strcmp(m, list->wm->filename))
+// 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;
@@ -97,16 +102,22 @@ static void MODULE_RemoveFromList(WINE_MODREF *mod)
WINE_MODREF *MODULE32_LookupHMODULE(HMODULE m)
{
modref_list* list=local_wm;
- TRACE("Module %X request\n", m);
+ 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;
@@ -216,7 +227,7 @@ static WIN_BOOL MODULE_DllProcessAttach( WINE_MODREF *wm, LPVOID lpReserved )
//local_wm=wm;
if(local_wm)
{
- local_wm->next=malloc(sizeof(modref_list));
+ 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;
@@ -224,7 +235,7 @@ static WIN_BOOL MODULE_DllProcessAttach( WINE_MODREF *wm, LPVOID lpReserved )
}
else
{
- local_wm=malloc(sizeof(modref_list));
+ local_wm = (modref_list*)malloc(sizeof(modref_list));
local_wm->next=local_wm->prev=NULL;
local_wm->wm=wm;
}
@@ -353,7 +364,10 @@ HMODULE WINAPI LoadLibraryExA(LPCSTR libname, HANDLE hfile, DWORD flags)
SetLastError(ERROR_INVALID_PARAMETER);
return 0;
}
- printf("Loading DLL: '%s'\n", libname);
+
+ wm=MODULE_FindModule(libname);
+ if(wm) return wm->module;
+
// if(fs_installed==0)
// install_fs();
@@ -404,8 +418,69 @@ HMODULE WINAPI LoadLibraryExA(LPCSTR libname, HANDLE hfile, DWORD flags)
}
if (!wm)
- printf("Win32 LoadLibrary failed to load: %s\n", checked);
+ printf("wine/module: Win32 LoadLibrary failed to load: %s\n", checked);
+
+ 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 == 0x62924c30)
+ {
+ printf ("wine/module: QuickTime5 DLLs found\n");
+ ptr = 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 == 0x6693b330)
+ {
+ printf ("wine/module: QuickTime6 DLLs found\n");
+ ptr = 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
+ {
+ printf ("wine/module: Unsupported QuickTime version (0x%x)\n",
+ dispatch_addr);
+ return NULL;
+ }
+
+ printf ("wine/module: 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;
}
@@ -482,6 +557,337 @@ FARPROC WINAPI GetProcAddress( HMODULE hModule, LPCSTR function )
return MODULE_GetProcAddress( hModule, function, TRUE );
}
+#ifdef DEBUG_QTX_API
+
+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){
+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";
+}
+return "???";
+}
+
+static char* component_func_type(int type,int what){
+if(type==1) switch(what){
+case 0: return "kImageCodecGetCodecInfoSelect";
+case 1: return "kImageCodecGetCompressionTimeSelect";
+case 5: return "kImageCodecPreDecompressSelect";
+case 6: return "kImageCodecBandDecompressSelect";
+case 0x12: return "kImageCodecDisposeMemorySelect";
+case 0x10: return "kImageCodecIsImageDescriptionEquivalentSelect";
+case 0x14: return "kImageCodecNewImageBufferMemorySelect";
+case 0x28: return "kImageCodecRequestGammaLevelSelect";
+}
+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;
+
+ if(params->what<0)
+ fprintf(stderr,"%*sComponentCall: %s flags=0x%X size=%d what=%d %s\n",3*c_level,"",name,params->flags, params->paramSize, params->what, component_func(params->what));
+ else
+ 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_type(type,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 u_int32_t ret_array[4096];
+static int ret_i=0;
+
+static int report_func(void *stack_base, int stack_size, reg386_t *reg, u_int32_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",((u_int32_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=((u_int32_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=malloc(((u_int32_t *)stack_base)[1]);
+ memset(reg->eax,0,((u_int32_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=malloc(((u_int32_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(((u_int32_t *)stack_base)[1]>=0x60000000)
+ printf("WARNING! Invalid Ptr handle!\n");
+ else
+ free(((u_int32_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",((u_int32_t *)stack_base)[1],((u_int32_t *)stack_base)[4]);
+// break;
+ case 0x00010003:
+ printf("FUNC: CountComponents(&desc=%p)\n",((u_int32_t *)stack_base)[1]);
+ break;
+ case 0x00010004:
+ printf("FUNC: FindNextComponent(prev=%p,&desc=%p)\n",((u_int32_t *)stack_base)[1],((u_int32_t *)stack_base)[2]);
+ break;
+ case 0x00010007:
+ printf("FUNC: OpenComponent(prev=%p)\n",((u_int32_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",
+ ((u_int32_t *)stack_base)[1],
+ &(((u_int32_t *)stack_base)[2]),
+ ((u_int32_t *)stack_base)[3],
+ ((u_int32_t *)stack_base)[4],
+ ((u_int32_t *)stack_base)[5],
+ ((u_int32_t *)stack_base)[6],
+ ((u_int32_t *)stack_base)[7],
+ ((u_int32_t *)stack_base)[8]);
+ break;
+ case 0x001c0018:
+ printf("FUNC: GetGWorldPixMap(gworld=%p)\n",((u_int32_t *)stack_base)[1]);
+ break;
+ case 0x00110001:
+ printf("FUNC: Gestalt(fourcc=%.4s, &ret=%p)\n",&(((u_int32_t *)stack_base)[1]),((u_int32_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]=((u_int32_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 ", ((u_int32_t *)stack_base)[i]);
+ }
+ printf("}\n\n");
+#endif
+
+// // mess with function parameters
+// ((u_int32_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, u_int32_t *flags)
+{
+ int i;
+ short err;
+
+ // restore ret addr:
+ --ret_i;
+ ((u_int32_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 ", ((u_int32_t *)stack_base)[i]);
+ }
+ printf("}\n\n");
+#endif
+
+#endif
+
+// // mess with function parameters
+// ((u_int32_t *)stack_base)[1] = 0x66554433;
+
+// // mess with return address...
+// reg->eax = 0x11223344;
+ return 0;
+}
+
+#endif
+
/***********************************************************************
* MODULE_GetProcAddress (internal)
*/
@@ -494,10 +900,17 @@ FARPROC MODULE_GetProcAddress(
// WINE_MODREF *wm=local_wm;
FARPROC retproc;
+#ifdef DEBUG_QTX_API
if (HIWORD(function))
- TRACE_(win32)("(%08lx,%s)\n",(DWORD)hModule,function);
+ fprintf(stderr,"XXX GetProcAddress(%08lx,%s)\n",(DWORD)hModule,function);
else
- TRACE_(win32)("(%08lx,%p)\n",(DWORD)hModule,function);
+ 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;
@@ -507,7 +920,7 @@ FARPROC MODULE_GetProcAddress(
case MODULE32_PE:
retproc = PE_FindExportedFunction( wm, function, snoop );
if (!retproc) SetLastError(ERROR_PROC_NOT_FOUND);
- return retproc;
+ break;
#ifdef HAVE_LIBDL
case MODULE32_ELF:
retproc = (FARPROC) dlsym( (void*) wm->module, function);
@@ -519,6 +932,35 @@ FARPROC MODULE_GetProcAddress(
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=retproc;
+ retproc=wrapper;
+ }
+
+ }
+#endif
+
+ return retproc;
}
static int acounter = 0;
diff --git a/src/libw32dll/wine/module.h b/src/libw32dll/wine/module.h
index 91e94b122..6f6b31a0a 100644
--- a/src/libw32dll/wine/module.h
+++ b/src/libw32dll/wine/module.h
@@ -128,6 +128,16 @@ typedef struct resource_nameinfo_s NE_NAMEINFO;
#define NE_MODULE_NAME(pModule) \
(((OFSTRUCT *)((char*)(pModule) + (pModule)->fileinfo))->szPathName)
+struct modref_list_t;
+
+typedef struct modref_list_t
+{
+ WINE_MODREF* wm;
+ struct modref_list_t *next;
+ struct modref_list_t *prev;
+} modref_list;
+
+
/* module.c */
extern FARPROC MODULE_GetProcAddress( HMODULE hModule, LPCSTR function, WIN_BOOL snoop );
extern WINE_MODREF *MODULE32_LookupHMODULE( HMODULE hModule );
diff --git a/src/libw32dll/wine/registry.c b/src/libw32dll/wine/registry.c
index c8495d453..ed7f5e74d 100644
--- a/src/libw32dll/wine/registry.c
+++ b/src/libw32dll/wine/registry.c
@@ -406,65 +406,65 @@ long RegCloseKey(long key)
long 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==NULL)
- return 1;
- t=find_value_by_name(c);
- free(c);
- if(t==0)
- 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;
+ 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==0)
+ 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;
- }
+ *count=t->len;
+ }
return 0;
}
long 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);
- TRACE("Creating/Opening key %s\n", name);
- if(!regs)
- init_registry();
-
- fullname=build_keyname(key, name);
- if(fullname==NULL)
- return 1;
- v=find_value_by_name(fullname);
- if(v==0)
- {
- int qw=45708;
- v=insert_reg_value(key, name, DIR, &qw, 4);
- if (status) *status=REG_CREATED_NEW_KEY;
-// return 0;
- }
+ reg_handle_t* t;
+ char* fullname;
+ struct reg_value* v;
+ // TRACE("Creating/Opening key %s\n", name);
+ if(!regs)
+ init_registry();
- t=insert_handle(generate_handle(), fullname);
- *newkey=t->handle;
- free(fullname);
- return 0;
+ fullname=build_keyname(key, name);
+ if (!fullname)
+ return 1;
+ TRACE("Creating/Opening key %s\n", fullname);
+ v=find_value_by_name(fullname);
+ if(v==0)
+ {
+ 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;
}
/*
diff --git a/src/libw32dll/wine/vfl.c b/src/libw32dll/wine/vfl.c
index b86b702e1..e8eb7969f 100644
--- a/src/libw32dll/wine/vfl.c
+++ b/src/libw32dll/wine/vfl.c
@@ -26,46 +26,12 @@
#define OpenDriverA DrvOpen
#define CloseDriver DrvClose
-long VFWAPI VideoForWindowsVersion(void);
-
-
-#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
-#define STORE_ALL \
- __asm__ ( \
- "push %%ebx\n\t" \
- "push %%ecx\n\t" \
- "push %%edx\n\t" \
- "push %%esi\n\t" \
- "push %%edi\n\t"::)
-
-#define REST_ALL \
- __asm__ ( \
- "pop %%edi\n\t" \
- "pop %%esi\n\t" \
- "pop %%edx\n\t" \
- "pop %%ecx\n\t" \
- "pop %%ebx\n\t"::)
-#endif
-
-
/***********************************************************************
* VideoForWindowsVersion [MSVFW.2][MSVIDEO.2]
* Returns the version in major.minor form.
* In Windows95 this returns 0x040003b6 (4.950)
*/
-long VideoForWindowsVersion(void) {
+long VFWAPI VideoForWindowsVersion(void) {
return 0x040003B6; /* 4.950 */
}
@@ -82,28 +48,10 @@ ICInfo(
long fccHandler, /* [in] <n>th compressor */
ICINFO *lpicinfo /* [out] information about compressor */
) {
- char type[5];
-
- memcpy(type,&fccType,4);type[4]=0;
-
/* does OpenDriver/CloseDriver */
lpicinfo->dwSize = sizeof(ICINFO);
lpicinfo->fccType = fccType;
lpicinfo->dwFlags = 0;
-/*
- if (GetPrivateProfileStringA("drivers32",NULL,NULL,buf,2000,"system.ini")) {
- char *s = buf;
- while (*s) {
- if (!lstrncmpiA(type,s,4)) {
- if(!fccHandler--) {
- lpicinfo->fccHandler = mmioStringToFOURCCA(s+5,0);
- return TRUE;
- }
- }
- s=s+lstrlenA(s)+1;
- }
- }
-*/
return TRUE;
}
@@ -112,69 +60,32 @@ ICInfo(
* Opens an installable compressor. Return special handle.
*/
HIC VFWAPI
-ICOpen(long fccType,long fccHandler,unsigned int wMode) {
- char type[5],handler[5],codecname[20];
+//ICOpen(long fccType,long fccHandler,unsigned int wMode) {
+ICOpen(long filename,long fccHandler,unsigned int wMode) {
ICOPEN icopen;
HDRVR hdrv;
WINE_HIC *whic;
- memcpy(type,&fccType,4);type[4]=0;
- memcpy(handler,&fccHandler,4);handler[4]=0;
-
- snprintf(codecname,20,"%s.%s",type,handler);
-
/* Well, lParam2 is in fact a LPVIDEO_OPEN_PARMS, but it has the
* same layout as ICOPEN
*/
- icopen.fccType = fccType;
+ 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(codecname,"drivers32",(long)&icopen);
hdrv=OpenDriverA((long)&icopen);
-/*
- if (!hdrv) {
- if (!strcasecmp(type,"vids")) {
- snprintf(codecname,20,"vidc.%s",handler);
- fccType = mmioFOURCC('v','i','d','c');
- }
-// hdrv=OpenDriverA(codecname,"drivers32",(long)&icopen);
- hdrv=OpenDriverA((long)&icopen);
-*/
- if (!hdrv)
- return 0;
-// }
- whic = (WINE_HIC*)my_mreq(sizeof(WINE_HIC), 0);
+ 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->private = ((DRVR*)hdrv)->dwDriverID;
+ whic->driverid = ((DRVR*)hdrv)->dwDriverID;
return (HIC)whic;
}
/***********************************************************************
- * ICOpenFunction [MSVFW.38]
- */
-HIC VFWAPI ICOpenFunction(long fccType, long fccHandler, unsigned int wMode,
-void* lpfnHandler) {
- char type[5],handler[5];
- HIC hic;
- WINE_HIC *whic;
-
- memcpy(type,&fccType,4);type[4]=0;
- memcpy(handler,&fccHandler,4);handler[4]=0;
- FIXME("(%s,%s,%d,%p), stub!\n",type,handler,wMode,lpfnHandler);
- hic = ICOpen(fccType,fccHandler,wMode);
- if (!hic)
- return hic;
- whic = (WINE_HIC*)hic;
- whic->driverproc = (DRIVERPROC)lpfnHandler;
- return hic;
-}
-
-
-/***********************************************************************
* ICGetInfo [MSVFW.30]
*/
LRESULT VFWAPI
@@ -187,53 +98,6 @@ ICGetInfo(HIC hic,ICINFO *picinfo,long cb) {
}
/***********************************************************************
- * ICLocate [MSVFW.35]
- */
-HIC VFWAPI
-ICLocate(
- long fccType, long fccHandler, LPBITMAPINFOHEADER lpbiIn,
- LPBITMAPINFOHEADER lpbiOut, short wMode
-) {
- char type[5],handler[5];
- HIC hic;
- long querymsg;
-
- switch (wMode) {
- case ICMODE_FASTCOMPRESS:
- case ICMODE_COMPRESS:
- querymsg = ICM_COMPRESS_QUERY;
- break;
- case ICMODE_DECOMPRESS:
- case ICMODE_FASTDECOMPRESS:
- querymsg = ICM_DECOMPRESS_QUERY;
- break;
- case ICMODE_DRAW:
- querymsg = ICM_DRAW_QUERY;
- break;
- default:
- FIXME("Unknown mode (%d)\n",wMode);
- return 0;
- }
-
- /* Easy case: handler/type match, we just fire a query and return */
- hic = ICOpen(fccType,fccHandler,wMode);
- if (hic) {
- if (!ICSendMessage(hic,querymsg,(long)lpbiIn,(long)lpbiOut))
- return hic;
- ICClose(hic);
- }
- type[4]='\0';memcpy(type,&fccType,4);
- handler[4]='\0';memcpy(handler,&fccHandler,4);
- if (fccType==streamtypeVIDEO) {
- hic = ICLocate(ICTYPE_VIDEO,fccHandler,lpbiIn,lpbiOut,wMode);
- if (hic)
- return hic;
- }
- FIXME("(%s,%s,%p,%p,0x%04x),unhandled!\n",type,handler,lpbiIn,lpbiOut,wMode);
- return 0;
-}
-
-/***********************************************************************
* ICCompress [MSVFW.23]
*/
long VFWAPIV
@@ -276,9 +140,7 @@ ICDecompress(HIC hic,long dwFlags,LPBITMAPINFOHEADER lpbiFormat,void* lpData,LPB
icd.lpbiOutput = lpbi;
icd.lpOutput = lpBits;
icd.ckid = 0;
- STORE_ALL;
result=ICSendMessage(hic,ICM_DECOMPRESS,(long)&icd,sizeof(icd));
- REST_ALL;
return result;
}
@@ -307,9 +169,7 @@ ICDecompressEx(HIC hic,long dwFlags,LPBITMAPINFOHEADER lpbiFormat,void* lpData,L
icd.dyDst=abs(lpbi->biHeight);
//icd.ckid = 0;
- STORE_ALL;
result=ICSendMessage(hic,ICM_DECOMPRESSEX,(long)&icd,sizeof(icd));
- REST_ALL;
return result;
}
@@ -335,9 +195,7 @@ ICUniversalEx(HIC hic,int command,LPBITMAPINFOHEADER lpbiFormat,LPBITMAPINFOHEAD
icd.dyDst=abs(lpbi->biHeight);
//icd.ckid = 0;
- STORE_ALL;
result=ICSendMessage(hic,command,(long)&icd,sizeof(icd));
- REST_ALL;
return result;
}
@@ -347,33 +205,8 @@ ICUniversalEx(HIC hic,int command,LPBITMAPINFOHEADER lpbiFormat,LPBITMAPINFOHEAD
*/
LRESULT VFWAPI
ICSendMessage(HIC hic,unsigned int msg,long lParam1,long lParam2) {
- LRESULT ret;
- WINE_HIC *whic = (WINE_HIC*)hic;
- /* char qw[200]; -- unused*/
-
-// printf("ICSendMessage.whic=%p\n",whic);
-
-#if 0
- __asm__ __volatile__ ("fsave (%0)\n\t": :"r"(&qw));
-#endif
- STORE_ALL;
- /*__asm__
- (
- "pushl %eax\n\t"
- "movl $0xf,%eax\n\t"
- "movw %ax, %fs\n\t"
- "popl %eax\n\t"
- );*/
- ret = whic->driverproc(whic->private,1,msg,lParam1,lParam2);
- REST_ALL;
-#if 0
- __asm__ __volatile__ ("frstor (%0)\n\t": :"r"(&qw));
-#endif
-// } else
-
-// ret = SendDriverMessage(whic->hdrv,msg,lParam1,lParam2);
-// TRACE(" -> 0x%08lx\n",ret);
- return ret;
+ WINE_HIC *whic = (WINE_HIC*)hic;
+ return SendDriverMessage(whic->hdrv, msg, lParam1,lParam2);
}
@@ -386,9 +219,10 @@ LRESULT VFWAPI ICClose(HIC hic) {
// CloseDriver(whic->hdrv,0,0);
DrvClose(whic->hdrv);
//#warning FIXME: DrvClose
- my_release(whic);
+ free(whic);
return 0;
}
+
int VFWAPI ICDoSomething()
{
return 0;
diff --git a/src/libw32dll/wine/vfw.h b/src/libw32dll/wine/vfw.h
index bc32aff5e..d2917601e 100644
--- a/src/libw32dll/wine/vfw.h
+++ b/src/libw32dll/wine/vfw.h
@@ -69,11 +69,7 @@ typedef struct tagWINE_HIC {
long type; /* 08: */
long handler; /* 0C: */
HDRVR hdrv; /* 10: */
-#ifndef __cplusplus
- long private; /* 14:(handled by SendDriverMessage)*/
-#else
- long _private; /* 14:(handled by SendDriverMessage)*/
-#endif
+ long driverid; /* 14:(handled by SendDriverMessage)*/
DRIVERPROC driverproc; /* 18:(handled by SendDriverMessage)*/
long x1; /* 1c: name? */
short x2; /* 20: */
@@ -200,7 +196,7 @@ typedef struct {
LPBITMAPINFOHEADER lpbiOutput;
void* lpOutput;
LPBITMAPINFOHEADER lpbiInput;
- void* lpInput;
+ const void* lpInput;
long* lpckid;
long* lpdwFlags;
long lFrameNum;
@@ -211,10 +207,10 @@ typedef struct {
} ICCOMPRESS;
long VFWAPIV ICCompress(
- HIC hic,long dwFlags,LPBITMAPINFOHEADER lpbiOutput,void* lpOutputBuf,
- LPBITMAPINFOHEADER lpbiInput,void* lpImage,long* lpckid,
+ HIC hic,long dwFlags,LPBITMAPINFOHEADER lpbiOutput,void* lpData,
+ LPBITMAPINFOHEADER lpbiInput,void* lpBits,long* lpckid,
long* lpdwFlags,long lFrameNum,long dwFrameSize,long dwQuality,
- LPBITMAPINFOHEADER lpbiInputPrev,void* lpImagePrev
+ LPBITMAPINFOHEADER lpbiPrev,void* lpPrev
);
@@ -350,7 +346,7 @@ typedef struct {
typedef struct {
long dwFlags; /* flags (from AVI index...) */
LPBITMAPINFOHEADER lpbiInput; /* BITMAPINFO of compressed data */
- void* lpInput; /* compressed data */
+ const void* lpInput; /* compressed data */
LPBITMAPINFOHEADER lpbiOutput; /* DIB to decompress to */
void* lpOutput;
long ckid; /* ckid from AVI file */
@@ -359,7 +355,7 @@ typedef struct {
typedef struct {
long dwFlags;
LPBITMAPINFOHEADER lpbiSrc;
- void* lpSrc;
+ const void* lpSrc;
LPBITMAPINFOHEADER lpbiDst;
void* lpDst;
@@ -427,6 +423,7 @@ long VFWAPIV ICUniversalEx(HIC hic,int command,LPBITMAPINFOHEADER lpbiFormat,LPB
)
#define ICDecompressEnd(hic) ICSendMessage(hic, ICM_DECOMPRESS_END, 0, 0)
+#define ICDecompressEndEx(hic) ICSendMessage(hic,ICM_DECOMPRESSEX_END, 0, 0)
#define ICDRAW_QUERY 0x00000001L /* test for support */
@@ -437,11 +434,11 @@ long VFWAPIV ICUniversalEx(HIC hic,int command,LPBITMAPINFOHEADER lpbiFormat,LPB
WIN_BOOL VFWAPI ICInfo(long fccType, long fccHandler, ICINFO * lpicinfo);
LRESULT VFWAPI ICGetInfo(HIC hic,ICINFO *picinfo, long cb);
HIC VFWAPI ICOpen(long fccType, long fccHandler, UINT wMode);
-HIC VFWAPI ICOpenFunction(long fccType, long fccHandler, unsigned int wMode, void* lpfnHandler);
+//HIC VFWAPI ICOpenFunction(long fccType, long fccHandler, unsigned int wMode, void* lpfnHandler);
LRESULT VFWAPI ICClose(HIC hic);
LRESULT VFWAPI ICSendMessage(HIC hic, unsigned int msg, long dw1, long dw2);
-HIC VFWAPI ICLocate(long fccType, long fccHandler, LPBITMAPINFOHEADER lpbiIn, LPBITMAPINFOHEADER lpbiOut, short wFlags);
+//HIC VFWAPI ICLocate(long fccType, long fccHandler, LPBITMAPINFOHEADER lpbiIn, LPBITMAPINFOHEADER lpbiOut, short wFlags);
int VFWAPI ICDoSomething(void);
diff --git a/src/libw32dll/wine/win32.c b/src/libw32dll/wine/win32.c
index 144c1ade8..00fcabb4f 100644
--- a/src/libw32dll/wine/win32.c
+++ b/src/libw32dll/wine/win32.c
@@ -13,12 +13,21 @@ for DLL to know too much about its environment.
#include "config.h"
+#define QTX
+
+#ifdef QTX
+#define PSEUDO_SCREEN_WIDTH /*640*/800
+#define PSEUDO_SCREEN_HEIGHT /*480*/600
+#endif
+
+
#include "winbase.h"
#include "winreg.h"
#include "winnt.h"
#include "winerror.h"
#include "debugtools.h"
#include "module.h"
+#include "winuser.h"
#include <stdio.h>
#include "win32.h"
@@ -41,6 +50,7 @@ for DLL to know too much about its environment.
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
+#include <dirent.h>
#include <sys/time.h>
#include <sys/timeb.h>
#ifdef HAVE_KSTAT
@@ -257,7 +267,7 @@ static void test_heap(void)
#ifdef MEMORY_DEBUG
-void* my_mreq(int size, int to_zero)
+static void* my_mreq(int size, int to_zero)
{
static int test=0;
test++;
@@ -290,7 +300,7 @@ void* my_mreq(int size, int to_zero)
heap_counter+=size;
return heap+heap_counter-size;
}
-int my_release(char* memory)
+static int my_release(char* memory)
{
// test_heap();
if(memory==NULL)
@@ -348,7 +358,7 @@ 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 = malloc(nsize);
+ alloc_header* header = (alloc_header* ) malloc(nsize);
if (!header)
return 0;
if (to_zero)
@@ -379,7 +389,7 @@ void* mreq_private(int size, int to_zero, int type)
return header + 1;
}
-int my_release(void* memory)
+static int my_release(void* memory)
{
alloc_header* header = (alloc_header*) memory - 1;
#ifdef GARBAGE
@@ -389,7 +399,7 @@ int my_release(void* memory)
if (memory == 0)
return 0;
- if (header->deadbeef != 0xdeadbeef)
+ if (header->deadbeef != (long) 0xdeadbeef)
{
printf("FATAL releasing corrupted memory! %p 0x%lx (%d)\n", header, header->deadbeef, alccnt);
return 0;
@@ -446,12 +456,12 @@ int my_release(void* memory)
}
#endif
-inline void* my_mreq(int size, int to_zero)
+static inline void* my_mreq(int size, int to_zero)
{
return mreq_private(size, to_zero, AREATYPE_CLIENT);
}
-static /*inline*/ int my_size(void* memory)
+static int my_size(void* memory)
{
if(!memory) return 0;
return ((alloc_header*)memory)[-1].size;
@@ -516,13 +526,22 @@ static HMODULE WINAPI expGetDriverModuleHandle(DRVR* pdrv)
#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
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);
@@ -532,21 +551,24 @@ static HMODULE WINAPI expGetModuleHandleA(const char* name)
}
if(!result)
{
- if(name && strcasecmp(name, "kernel32")==0)
+ 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=my_mreq(sizeof(pthread_t), 0);
+ 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");
@@ -791,25 +813,64 @@ static void* WINAPI expWaitForSingleObject(void* object, int duration)
return (void *)ret;
}
-static int pf_set = 0;
-static BYTE PF[64] = {0,};
-
-static void WINAPI expGetSystemInfo(SYSTEM_INFO* si); /* forward declaration */
-
-static WIN_BOOL WINAPI expIsProcessorFeaturePresent(DWORD v)
+#ifdef QTX
+static void* WINAPI expWaitForMultipleObjects(int count, const void** objects,
+ int WaitAll, int duration)
{
- WIN_BOOL result;
- if(v>63)result=0;
- if (!pf_set)
+ int i;
+ void *object;
+ int ret;
+
+ dbgprintf("WaitForMultipleObjects(%d, 0x%x, %d, duration %d) =>\n",
+ count, objects, WaitAll, duration);
+
+ for (i = 0; i < count; i++)
{
- SYSTEM_INFO si;
- expGetSystemInfo(&si);
+ object = (void *) objects[i];
+ ret = expWaitForSingleObject(object, duration);
+ if (WaitAll)
+ dbgprintf("WaitAll flag not yet supported...\n");
+ else
+ return ret;
}
- else result=PF[v];
- dbgprintf("IsProcessorFeaturePresent(0x%x) => 0x%x\n", v, result);
- return result;
+ 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 = 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);
@@ -1012,7 +1073,7 @@ static void WINAPI expGetSystemInfo(SYSTEM_INFO* si)
}
if (!lstrncmpiA(line,"processor",strlen("processor"))) {
/* processor number counts up...*/
- int x;
+ unsigned int x;
if (sscanf(value,"%d",&x))
if (x+1>cachedsi.dwNumberOfProcessors)
@@ -1060,6 +1121,21 @@ static void WINAPI expGetSystemInfo(SYSTEM_INFO* 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");
@@ -1112,7 +1188,11 @@ static long WINAPI expHeapDestroy(void* heap)
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)
+ 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
{
@@ -1162,12 +1242,14 @@ struct critsecs_list_t
struct CRITSECT *cs_unix;
};
-/* 'NEWTYPE' is working with VIVO and 3ivX dll (no more segfaults) -- alex */
+/* 'NEWTYPE' is working with VIVO, 3ivX and QTX dll (no more segfaults) -- alex */
#undef CRITSECS_NEWTYPE
//#define CRITSECS_NEWTYPE 1
#ifdef CRITSECS_NEWTYPE
-#define CRITSECS_LIST_MAX 20
+/* 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)
@@ -1190,9 +1272,6 @@ static int critsecs_get_unused(void)
return(-1);
}
-#if 0
-#define critsecs_get_unix(cs_win) (critsecs_list[critsecs_get_pos(cs_win)].cs_win)
-#else
struct CRITSECT *critsecs_get_unix(CRITICAL_SECTION *cs_win)
{
int i;
@@ -1203,7 +1282,6 @@ struct CRITSECT *critsecs_get_unix(CRITICAL_SECTION *cs_win)
return(NULL);
}
#endif
-#endif
static void WINAPI expInitializeCriticalSection(CRITICAL_SECTION* c)
{
@@ -1246,7 +1324,7 @@ static void WINAPI expInitializeCriticalSection(CRITICAL_SECTION* c)
pthread_mutex_init(&cs->mutex, NULL);
cs->locked=0;
cs->deadbeef = 0xdeadbeef;
- *(void**)c = cs + 1;
+ *(void**)c = cs;
}
#endif
return;
@@ -1257,10 +1335,9 @@ static void WINAPI expEnterCriticalSection(CRITICAL_SECTION* c)
#ifdef CRITSECS_NEWTYPE
struct CRITSECT* cs = critsecs_get_unix(c);
#else
- struct CRITSECT* cs = (*(struct CRITSECT**)c) - 1;
-
+ struct CRITSECT* cs = (*(struct CRITSECT**)c);
#endif
- dbgprintf("EnterCriticalSection(0x%x) %p maso:0x%x\n",c, cs, cs->deadbeef);
+ dbgprintf("EnterCriticalSection(0x%x) %p\n",c, cs);
if (!cs)
{
dbgprintf("entered uninitialized critisec!\n");
@@ -1268,9 +1345,9 @@ static void WINAPI expEnterCriticalSection(CRITICAL_SECTION* c)
#ifdef CRITSECS_NEWTYPE
cs=critsecs_get_unix(c);
#else
- cs = (*(struct CRITSECT**)c) - 1;
+ cs = (*(struct CRITSECT**)c);
#endif
- printf("Win32 Warning: Accessed uninitialized Critical Section (%p)!\n", c);
+ printf("wine/win32: Win32 Warning: Accessed uninitialized Critical Section (%p)!\n", c);
}
if(cs->locked)
if(cs->id==pthread_self())
@@ -1285,10 +1362,10 @@ static void WINAPI expLeaveCriticalSection(CRITICAL_SECTION* c)
#ifdef CRITSECS_NEWTYPE
struct CRITSECT* cs = critsecs_get_unix(c);
#else
- struct CRITSECT* cs = (*(struct CRITSECT**)c) - 1;
+ struct CRITSECT* cs = (*(struct CRITSECT**)c);
#endif
// struct CRITSECT* cs=(struct CRITSECT*)c;
- dbgprintf("LeaveCriticalSection(0x%x) 0x%x\n",c, cs->deadbeef);
+ dbgprintf("LeaveCriticalSection(0x%x) 0x%x\n",c, cs);
if (!cs)
{
printf("Win32 Warning: Leaving uninitialized Critical Section %p!!\n", c);
@@ -1303,7 +1380,7 @@ static void WINAPI expDeleteCriticalSection(CRITICAL_SECTION *c)
#ifdef CRITSECS_NEWTYPE
struct CRITSECT* cs = critsecs_get_unix(c);
#else
- struct CRITSECT* cs= (*(struct CRITSECT**)c) - 1;
+ struct CRITSECT* cs= (*(struct CRITSECT**)c);
#endif
// struct CRITSECT* cs=(struct CRITSECT*)c;
dbgprintf("DeleteCriticalSection(0x%x)\n",c);
@@ -1333,8 +1410,8 @@ static void WINAPI expDeleteCriticalSection(CRITICAL_SECTION *c)
}
static int WINAPI expGetCurrentThreadId()
{
- dbgprintf("GetCurrentThreadId() => %d\n", getpid());
- return getpid();
+ dbgprintf("GetCurrentThreadId() => %d\n", pthread_self());
+ return pthread_self();
}
static int WINAPI expGetCurrentProcess()
{
@@ -1342,12 +1419,12 @@ static int WINAPI expGetCurrentProcess()
return getpid();
}
-extern void* fs_seg;
-
-#if 0
+#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()
@@ -1364,9 +1441,10 @@ static int WINAPI expTlsAlloc()
return -1;
}
-static int WINAPI expTlsSetValue(DWORD index, void* value)
+//static int WINAPI expTlsSetValue(DWORD index, void* value)
+static int WINAPI expTlsSetValue(int index, void* value)
{
- dbgprintf("TlsSetValue(%d,%p)\n",index,value);
+ dbgprintf("TlsSetValue(%d,0x%x) => 1\n",index,value);
// if((index<0) || (index>64))
if((index>=64))
return 0;
@@ -1402,7 +1480,7 @@ struct tls_s {
static void* WINAPI expTlsAlloc()
{
- if(g_tls==NULL)
+ if (g_tls == NULL)
{
g_tls=my_mreq(sizeof(tls_t), 0);
g_tls->next=g_tls->prev=NULL;
@@ -1457,6 +1535,8 @@ static int WINAPI expTlsFree(void* idx)
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;
}
@@ -2077,17 +2157,32 @@ 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()
+static int WINAPI expGetACP(void)
{
dbgprintf("GetACP() => 0\n");
return 0;
@@ -2097,8 +2192,15 @@ static int WINAPI expGetModuleFileNameA(int module, char* s, int len)
{
WINE_MODREF *mr;
int result;
- // printf("File name of module %X requested\n", module);
- if(s==0)
+ //printf("File name of module %X (%s) requested\n", module, s);
+
+ if (module == 0 && len >= 12)
+ {
+ /* return caller program name */
+ strcpy(s, "aviplay.dll");
+ result=1;
+ }
+ else if(s==0)
result=0;
else
if(len<35)
@@ -2169,17 +2271,32 @@ static int WINAPI expLoadLibraryA(char* name)
// return MODULE_HANDLE_kernel32;
return MODULE_HANDLE_user32;
+#ifdef QTX
+ if (strcasecmp(name, "wininet.dll") == 0 || strcasecmp(name, "wininet") == 0)
+ return MODULE_HANDLE_wininet;
+ if (strcasecmp(name, "ddraw.dll") == 0 || strcasecmp(name, "ddraw") == 0)
+ return MODULE_HANDLE_ddraw;
+ if (strcasecmp(name, "advapi32.dll") == 0 || strcasecmp(name, "advapi32") == 0)
+ return MODULE_HANDLE_advapi32;
+#endif
+
result=LoadLibraryA(name);
dbgprintf("Returned LoadLibraryA(0x%x='%s'), def_path=%s => 0x%x\n", name, name, win32_def_path, result);
return result;
}
+
static int WINAPI expFreeLibrary(int module)
{
+#ifdef QTX
+ int result=0; /* FIXME:XXX: qtx svq3 frees up qt.qts */
+#else
int result=FreeLibrary(module);
+#endif
dbgprintf("FreeLibrary(0x%x) => %d\n", module, result);
return result;
}
+
static void* WINAPI expGetProcAddress(HMODULE mod, char* name)
{
void* result;
@@ -2188,6 +2305,14 @@ static void* WINAPI expGetProcAddress(HMODULE mod, char* name)
result=LookupExternalByName("kernel32.dll", name); break;
case MODULE_HANDLE_user32:
result=LookupExternalByName("user32.dll", name); break;
+#ifdef QTX
+ case MODULE_HANDLE_wininet:
+ result=LookupExternalByName("wininet.dll", name); break;
+ case MODULE_HANDLE_ddraw:
+ result=LookupExternalByName("ddraw.dll", name); break;
+ case MODULE_HANDLE_advapi32:
+ result=LookupExternalByName("advapi32.dll", name); break;
+#endif
default:
result=GetProcAddress(mod, name);
}
@@ -2264,7 +2389,15 @@ static int WINAPI expCreateCompatibleDC(int hdc)
static int WINAPI expGetDeviceCaps(int hdc, int unk)
{
dbgprintf("GetDeviceCaps(0x%x, %d) => 0\n", hdc, unk);
- return 0;
+#ifdef QTX
+ #define BITSPIXEL 12
+ #define PLANES 14
+ if (unk == BITSPIXEL)
+ return 24;
+ if (unk == PLANES)
+ return 1;
+#endif
+ return 1;
}
static WIN_BOOL WINAPI expDeleteDC(int hdc)
@@ -2289,6 +2422,178 @@ static void* WINAPI expGetWindowDC(int hdc)
return 0;
}
+#ifdef QTX
+static int WINAPI expGetWindowRect(HWND win, RECT *r)
+{
+ dbgprintf("GetWindowRect(0x%x, 0x%x) => 1\n", win, r);
+ /* (win == 0) => desktop */
+ r->right = PSEUDO_SCREEN_WIDTH;
+ r->left = 0;
+ r->bottom = PSEUDO_SCREEN_HEIGHT;
+ r->top = 0;
+ return 1;
+}
+
+static int WINAPI expMonitorFromWindow(HWND win, int flags)
+{
+ dbgprintf("MonitorFromWindow(0x%x, 0x%x) => 0\n", win, flags);
+ return 0;
+}
+
+static int WINAPI expMonitorFromRect(RECT *r, int flags)
+{
+ dbgprintf("MonitorFromRect(0x%x, 0x%x) => 0\n", r, flags);
+ return 0;
+}
+
+static int WINAPI expMonitorFromPoint(void *p, int flags)
+{
+ dbgprintf("MonitorFromPoint(0x%x, 0x%x) => 0\n", p, flags);
+ return 0;
+}
+
+static int WINAPI expEnumDisplayMonitors(void *dc, RECT *r,
+ int WINAPI (*callback_proc)(), void *callback_param)
+{
+ dbgprintf("EnumDisplayMonitors(0x%x, 0x%x, 0x%x, 0x%x) => ?\n",
+ dc, r, callback_proc, callback_param);
+ return callback_proc(0, dc, r, callback_param);
+}
+
+#if 0
+typedef struct tagMONITORINFO {
+ DWORD cbSize;
+ RECT rcMonitor;
+ RECT rcWork;
+ DWORD dwFlags;
+} MONITORINFO, *LPMONITORINFO;
+#endif
+
+#define CCHDEVICENAME 8
+typedef struct tagMONITORINFOEX {
+ DWORD cbSize;
+ RECT rcMonitor;
+ RECT rcWork;
+ DWORD dwFlags;
+ TCHAR szDevice[CCHDEVICENAME];
+} MONITORINFOEX, *LPMONITORINFOEX;
+
+static int WINAPI expGetMonitorInfoA(void *mon, LPMONITORINFO lpmi)
+{
+ dbgprintf("GetMonitorInfoA(0x%x, 0x%x) => 1\n", mon, lpmi);
+
+ lpmi->rcMonitor.right = lpmi->rcWork.right = PSEUDO_SCREEN_WIDTH;
+ lpmi->rcMonitor.left = lpmi->rcWork.left = 0;
+ lpmi->rcMonitor.bottom = lpmi->rcWork.bottom = PSEUDO_SCREEN_HEIGHT;
+ lpmi->rcMonitor.top = lpmi->rcWork.top = 0;
+
+ lpmi->dwFlags = 1; /* primary monitor */
+
+ if (lpmi->cbSize == sizeof(MONITORINFOEX))
+ {
+ LPMONITORINFOEX lpmiex = lpmi;
+ dbgprintf("MONITORINFOEX!\n");
+ strncpy(lpmiex->szDevice, "Monitor1", CCHDEVICENAME);
+ }
+
+ return 1;
+}
+
+static int WINAPI expEnumDisplayDevicesA(const char *device, int devnum,
+ void *dispdev, int flags)
+{
+ dbgprintf("EnumDisplayDevicesA(0x%x = %s, %d, 0x%x, %x) => 1\n",
+ device, device, devnum, dispdev, flags);
+ return 1;
+}
+
+static int WINAPI expIsWindowVisible(HWND win)
+{
+ dbgprintf("IsWindowVisible(0x%x) => 1\n", win);
+ return 1;
+}
+
+static HWND WINAPI expGetActiveWindow(void)
+{
+ dbgprintf("GetActiveWindow() => 0\n");
+ return (HWND)0;
+}
+
+static int WINAPI expGetClassNameA(HWND win, LPTSTR classname, int maxcount)
+{
+ strncat(classname, "QuickTime", maxcount);
+ dbgprintf("GetClassNameA(0x%x, 0x%x, %d) => %d\n",
+ win, classname, maxcount, strlen(classname));
+ return strlen(classname);
+}
+
+#define LPWNDCLASS void *
+static int WINAPI expGetClassInfoA(HINSTANCE inst, LPCSTR classname, LPWNDCLASS wndclass)
+{
+ dbgprintf("GetClassInfoA(0x%x, 0x%x = %s, 0x%x) => 1\n", inst,
+ classname, classname, wndclass);
+ return 1;
+}
+
+static int WINAPI expGetWindowLongA(HWND win, int index)
+{
+ dbgprintf("GetWindowLongA(0x%x, %d) => 0\n", win, index);
+ return 1;
+}
+
+static int WINAPI expGetObjectA(HGDIOBJ hobj, int objsize, LPVOID obj)
+{
+ dbgprintf("GetObjectA(0x%x, %d, 0x%x) => %d\n", hobj, objsize, obj, objsize);
+ return objsize;
+}
+
+static int WINAPI expCreateRectRgn(int x, int y, int width, int height)
+{
+ dbgprintf("CreateRectRgn(%d, %d, %d, %d) => 0\n", x, y, width, height);
+ return 0;
+}
+
+static int WINAPI expEnumWindows(int (*callback_func)(), void *callback_param)
+{
+ int i, i2;
+ dbgprintf("EnumWindows(0x%x, 0x%x) => 1\n", callback_func, callback_param);
+ i = callback_func(0, callback_param);
+ i2 = callback_func(1, callback_param);
+ return i && i2;
+}
+
+static int WINAPI expGetWindowThreadProcessId(HWND win, int *pid_data)
+{
+ int tid = pthread_self();
+ dbgprintf("GetWindowThreadProcessId(0x%x, 0x%x) => %d\n",
+ win, pid_data, tid);
+ if (pid_data)
+ (int)*pid_data = tid;
+ return tid;
+}
+
+//HWND WINAPI CreateWindowExA(DWORD,LPCSTR,LPCSTR,DWORD,INT,INT,
+// INT,INT,HWND,HMENU,HINSTANCE,LPVOID);
+
+static HWND WINAPI expCreateWindowExA(int exstyle, const char *classname,
+ const char *winname, int style, int x, int y, int w, int h,
+ HWND parent, HMENU menu, HINSTANCE inst, LPVOID param)
+{
+ printf("CreateWindowEx() called\n");
+ dbgprintf("CreateWindowEx(%d, 0x%x = %s, 0x%x = %s, %d, %d, %d, %d, %d, 0x%x, 0x%x, 0x%x, 0x%x) => 1\n",
+ exstyle, classname, classname, winname, winname, style, x, y, w, h,
+ parent, menu, inst, param);
+ printf("CreateWindowEx() called okey\n");
+ return 1;
+}
+
+static int WINAPI expwaveOutGetNumDevs(void)
+{
+ dbgprintf("waveOutGetNumDevs() => 0\n");
+ return 0;
+}
+#endif
+
/*
* Returns the number of milliseconds, modulo 2^32, since the start
* of the wineserver.
@@ -2510,6 +2815,14 @@ static long WINAPI expInterlockedExchangeAdd( long* dest, long incr )
return ret;
}
+static long WINAPI expInterlockedCompareExchange( unsigned long* dest, unsigned long exchange, unsigned long comperand)
+{
+ unsigned long retval = *dest;
+ if(*dest == comperand)
+ *dest = exchange;
+ return retval;
+}
+
static long WINAPI expInterlockedIncrement( long* dest )
{
long result=expInterlockedExchangeAdd( dest, 1 ) + 1;
@@ -2531,14 +2844,14 @@ static void WINAPI expOutputDebugStringA( const char* string )
static int WINAPI expGetDC(int hwnd)
{
- dbgprintf("GetDC(0x%x) => 0\n", hwnd);
- return 0;
+ dbgprintf("GetDC(0x%x) => 1\n", hwnd);
+ return 1;
}
static int WINAPI expReleaseDC(int hwnd, int hdc)
{
- dbgprintf("ReleaseDC(0x%x, 0x%x) => 0\n", hwnd, hdc);
- return 0;
+ dbgprintf("ReleaseDC(0x%x, 0x%x) => 1\n", hwnd, hdc);
+ return 1;
}
static int WINAPI expGetDesktopWindow()
@@ -2564,6 +2877,18 @@ static int WINAPI expGetCursorPos(void *cursor)
dbgprintf("GetCursorPos(0x%x) => 0x%x\n", cursor, cursor);
return 1;
}
+#ifdef QTX
+static int show_cursor = 0;
+static int WINAPI expShowCursor(int show)
+{
+ dbgprintf("ShowCursor(%d) => %d\n", show, show);
+ if (show)
+ show_cursor++;
+ else
+ show_cursor--;
+ return show_cursor;
+}
+#endif
static int WINAPI expRegisterWindowMessageA(char *message)
{
dbgprintf("RegisterWindowMessageA(%s)\n", message);
@@ -2590,14 +2915,39 @@ static int WINAPI expGetCPInfo(int cp,void *info)
dbgprintf("GetCPInfo()\n");
return 0;
}
+#ifdef QTX
+#define SM_CXSCREEN 0
+#define SM_CYSCREEN 1
+#define SM_XVIRTUALSCREEN 76
+#define SM_YVIRTUALSCREEN 77
+#define SM_CXVIRTUALSCREEN 78
+#define SM_CYVIRTUALSCREEN 79
+#define SM_CMONITORS 80
+#endif
static int WINAPI expGetSystemMetrics(int index)
{
dbgprintf("GetSystemMetrics(%d)\n", index);
+#ifdef QTX
+ switch(index)
+ {
+ case SM_XVIRTUALSCREEN:
+ case SM_YVIRTUALSCREEN:
+ return 0;
+ case SM_CXSCREEN:
+ case SM_CXVIRTUALSCREEN:
+ return PSEUDO_SCREEN_WIDTH;
+ case SM_CYSCREEN:
+ case SM_CYVIRTUALSCREEN:
+ return PSEUDO_SCREEN_HEIGHT;
+ case SM_CMONITORS:
+ return 1;
+ }
+#endif
return 1;
}
static int WINAPI expGetSysColor(int index)
{
- dbgprintf("GetSysColor(%d)\n", index);
+ dbgprintf("GetSysColor(%d) => 1\n", index);
return 1;
}
static int WINAPI expGetSysColorBrush(int index)
@@ -2702,6 +3052,21 @@ static int WINAPI expGetSystemTime(SYSTEMTIME* systime)
return 0;
}
+#define SECS_1601_TO_1970 ((369 * 365 + 89) * 86400ULL)
+static void WINAPI expGetSystemTimeAsFileTime(FILETIME* systime)
+{
+ /* struct tm *local_tm; -- unused */
+ struct timeval tv;
+ unsigned long long secs;
+
+ dbgprintf("GetSystemTime(0x%x)\n", systime);
+ gettimeofday(&tv, NULL);
+ secs = (tv.tv_sec + SECS_1601_TO_1970) * 10000000;
+ secs += tv.tv_usec * 10;
+ systime->dwLowDateTime = secs & 0xffffffff;
+ systime->dwHighDateTime = (secs >> 32);
+}
+
static int WINAPI expGetEnvironmentVariableA(const char* name, char* field, int size)
{
/* char *p; */
@@ -2747,12 +3112,12 @@ void CoTaskMemFree(void* cb)
struct COM_OBJECT_INFO
{
GUID clsid;
- long (*GetClassObject) (GUID* clsid, GUID* iid, void** ppv);
+ long (*GetClassObject) (GUID* clsid, const GUID* iid, void** ppv);
};
static struct COM_OBJECT_INFO* com_object_table=0;
static int com_object_size=0;
-int RegisterComClass(GUID* clsid, GETCLASSOBJECT gcs)
+int RegisterComClass(const GUID* clsid, GETCLASSOBJECT gcs)
{
if(!clsid || !gcs)
return -1;
@@ -2762,7 +3127,7 @@ int RegisterComClass(GUID* clsid, GETCLASSOBJECT gcs)
return 0;
}
-int UnregisterComClass(GUID* clsid, GETCLASSOBJECT gcs)
+int UnregisterComClass(const GUID* clsid, GETCLASSOBJECT gcs)
{
int found = 0;
int i = 0;
@@ -2799,19 +3164,19 @@ int UnregisterComClass(GUID* clsid, GETCLASSOBJECT gcs)
}
-GUID IID_IUnknown =
+const GUID IID_IUnknown =
{
0x00000000, 0x0000, 0x0000,
{0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}
};
-GUID IID_IClassFactory =
+const GUID IID_IClassFactory =
{
0x00000001, 0x0000, 0x0000,
{0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}
};
-static long WINAPI expCoCreateInstance(GUID* rclsid, struct IUnknown* pUnkOuter,
- long dwClsContext, GUID* riid, void** ppv)
+static long WINAPI expCoCreateInstance(GUID* rclsid, struct IUnknown* pUnkOuter,
+ long dwClsContext, const GUID* riid, void** ppv)
{
int i;
struct COM_OBJECT_INFO* ci=0;
@@ -2825,7 +3190,7 @@ static long WINAPI expCoCreateInstance(GUID* rclsid, struct IUnknown* pUnkOuter,
}
long CoCreateInstance(GUID* rclsid, struct IUnknown* pUnkOuter,
- long dwClsContext, GUID* riid, void** ppv)
+ long dwClsContext, const GUID* riid, void** ppv)
{
return expCoCreateInstance(rclsid, pUnkOuter, dwClsContext, riid, ppv);
}
@@ -2833,9 +3198,8 @@ long CoCreateInstance(GUID* rclsid, struct IUnknown* pUnkOuter,
static int WINAPI expIsRectEmpty(CONST RECT *lprc)
{
int r = 0;
-// int r = (!lprc || (lprc->right == lprc->left) || (lprc->top == lprc->bottom));
int w,h;
-
+//trapbug();
if (lprc)
{
w = lprc->right - lprc->left;
@@ -2847,9 +3211,9 @@ static int WINAPI expIsRectEmpty(CONST RECT *lprc)
r = 1;
dbgprintf("IsRectEmpty(%p) => %s\n", lprc, (r) ? "TRUE" : "FALSE");
-// printf("Rect: left: %d, top: %d, right: %d, bottom: %d\n",
-// lprc->left, lprc->top, lprc->right, lprc->bottom);
- return r;
+ //printf("Rect: left: %d, top: %d, right: %d, bottom: %d\n", lprc->left, lprc->top, lprc->right, lprc->bottom);
+// return 0; // wmv9?
+ return r; // TM20
}
static int _adjust_fdiv=0; //what's this? - used to adjust division
@@ -2886,21 +3250,69 @@ static unsigned int WINAPI expGetTempPathA(unsigned int len, char* path)
} WIN32_FIND_DATAA, *LPWIN32_FIND_DATAA;
*/
+static DIR* qtx_dir=NULL;
+
+static WIN_BOOL WINAPI expFindNextFileA(HANDLE h,LPWIN32_FIND_DATAA lpfd)
+{
+#ifdef QTX
+ dbgprintf("FindNextFileA(0x%x, 0x%x) => 0\n", h, lpfd);
+ if(h==FILE_HANDLE_quicktimeqtx){
+ struct dirent* d;
+ if(!qtx_dir) return 0;
+ while((d=readdir(qtx_dir))){
+ char* x=strrchr(d->d_name,'.');
+ if(!x) continue;
+ if(strcmp(x,".qtx")) continue;
+ strcpy(lpfd->cFileName,d->d_name);
+// sprintf(lpfd->cAlternateFileName,"%-8s.qtx",d->d_name);
+ strcpy(lpfd->cAlternateFileName,"foobar.qtx");
+ printf("### FindNext: %s\n",lpfd->cFileName);
+ return 1;
+ }
+ closedir(qtx_dir); qtx_dir=NULL;
+ return 0;
+ }
+#endif
+ return 0;
+}
+
static HANDLE WINAPI expFindFirstFileA(LPCSTR s, LPWIN32_FIND_DATAA lpfd)
{
+#ifdef QTX
+ if(strstr(s, "*.QTX")){
+ dbgprintf("FindFirstFileA(0x%x='%s', 0x%x) => QTX\n", s, s, lpfd);
+ qtx_dir=opendir(win32_def_path);
+ if(!qtx_dir) return (HANDLE)-1;
+ memset(lpfd,0,sizeof(*lpfd));
+ if(expFindNextFileA(FILE_HANDLE_quicktimeqtx,lpfd))
+ return FILE_HANDLE_quicktimeqtx;
+ printf("loader: Couldn't find the QuickTime plugins (.qtx files) at %s\n",win32_def_path);
+ return (HANDLE)-1;
+ }
+ if(strstr(s, "QuickTime.qts")){
+ dbgprintf("FindFirstFileA(0x%x='%s', 0x%x) => QTS\n", s, s, lpfd);
+// if(!strcmp(s,"C:\\windows\\QuickTime.qts\\QuickTime.qts\\*.QTX"))
+// return (HANDLE)-1;
+ strcpy(lpfd->cFileName, "QuickTime.qts");
+ strcpy(lpfd->cAlternateFileName, "QuickT~1.qts");
+ return FILE_HANDLE_quicktimeqts;
+ }
+#endif
dbgprintf("FindFirstFileA(0x%x='%s', 0x%x) => 0\n", s, s, lpfd);
strcpy(lpfd->cFileName, "msms001.vwp");
strcpy(lpfd->cAlternateFileName, "msms001.vwp");
- return (HANDLE)0;
-}
-static WIN_BOOL WINAPI expFindNextFileA(HANDLE h,LPWIN32_FIND_DATAA p)
-{
- dbgprintf("FindNextFileA(0x%x, 0x%x) => 0\n", h, p);
- return 0;
+ return (HANDLE)-1;
}
+
static WIN_BOOL WINAPI expFindClose(HANDLE h)
{
dbgprintf("FindClose(0x%x) => 0\n", h);
+#ifdef QTX
+// if(h==FILE_HANDLE_quicktimeqtx && qtx_dir){
+// closedir(qtx_dir);
+// qtx_dir=NULL;
+// }
+#endif
return 0;
}
static UINT WINAPI expSetErrorMode(UINT i)
@@ -2917,7 +3329,52 @@ static UINT WINAPI expGetWindowsDirectoryA(LPSTR s,UINT c)
dbgprintf("GetWindowsDirectoryA(0x%x, %d) => %d\n", s, c, result);
return result;
}
+#ifdef QTX
+static UINT WINAPI expGetCurrentDirectoryA(UINT c, LPSTR s)
+{
+ char curdir[]="c:\\";
+ int result;
+ strncpy(s, curdir, c);
+ result=1+((c<strlen(curdir))?c:strlen(curdir));
+ dbgprintf("GetCurrentDirectoryA(0x%x, %d) => %d\n", s, c, result);
+ return result;
+}
+
+static int WINAPI expSetCurrentDirectoryA(const char *pathname)
+{
+ dbgprintf("SetCurrentDirectoryA(0x%x = %s) => 1\n", pathname, pathname);
+#if 0
+ if (strrchr(pathname, '\\'))
+ chdir(strcat(strrchr(pathname, '\\')+1, '/'));
+ else
+ chdir(pathname);
+#endif
+ return 1;
+}
+static int WINAPI expCreateDirectoryA(const char *pathname, void *sa)
+{
+ dbgprintf("CreateDirectory(0x%x = %s, 0x%x) => 1\n",
+ pathname, pathname, sa);
+#if 0
+ p = strrchr(pathname, '\\')+1;
+ strcpy(&buf[0], p); /* should be strncpy */
+ if (!strlen(p))
+ {
+ buf[0] = '.';
+ buf[1] = 0;
+ }
+#if 0
+ if (strrchr(pathname, '\\'))
+ mkdir(strcat(strrchr(pathname, '\\')+1, '/'), 666);
+ else
+ mkdir(pathname, 666);
+#endif
+ mkdir(&buf);
+#endif
+ return 1;
+}
+#endif
static WIN_BOOL WINAPI expDeleteFileA(LPCSTR s)
{
dbgprintf("DeleteFileA(0x%x='%s') => 0\n", s, s);
@@ -2956,6 +3413,31 @@ static HANDLE WINAPI expCreateFileA(LPCSTR cs1,DWORD i1,DWORD i2,
i2, p1, i3, i4, i5);
if((!cs1) || (strlen(cs1)<2))return -1;
+#ifdef QTX
+ if(strstr(cs1, "QuickTime.qts"))
+ {
+ int result;
+ char* tmp=(char*)malloc(strlen(win32_def_path)+50);
+ strcpy(tmp, win32_def_path);
+ strcat(tmp, "/");
+ strcat(tmp, "QuickTime.qts");
+ result=open(tmp, O_RDONLY);
+ free(tmp);
+ return result;
+ }
+ if(strstr(cs1, ".qtx"))
+ {
+ int result;
+ char* tmp=(char*)malloc(strlen(win32_def_path)+250);
+ char* x=strrchr(cs1,'\\');
+ sprintf(tmp,"%s/%s",win32_def_path,x?(x+1):cs1);
+// printf("### Open: %s -> %s\n",cs1,tmp);
+ result=open(tmp, O_RDONLY);
+ free(tmp);
+ return result;
+ }
+#endif
+
if(strncmp(cs1, "AP", 2) == 0)
{
int result;
@@ -2994,7 +3476,7 @@ static HANDLE WINAPI expCreateFileA(LPCSTR cs1,DWORD i1,DWORD i2,
}
#if 0
- /* we need this for some virtualdub filters */
+ /* we need this for some virtualdub filters */
{
int r;
int flg = 0;
@@ -3007,7 +3489,7 @@ static HANDLE WINAPI expCreateFileA(LPCSTR cs1,DWORD i1,DWORD i2,
}
r=open(cs1, flg);
return r;
- }
+ }
#endif
return atoi(cs1+2);
@@ -3038,7 +3520,18 @@ static DWORD WINAPI expGetFullPathNameA
if(!lpFileName) return 0;
dbgprintf("GetFullPathNameA('%s',%d,%p,%p)\n",lpFileName,nBufferLength,
lpBuffer, lpFilePart);
+#if 0
+#ifdef QTX
+ strcpy(lpFilePart, "Quick123.qts");
+#else
strcpy(lpFilePart, lpFileName);
+#endif
+#else
+ if (strrchr(lpFileName, '\\'))
+ *lpFilePart = strrchr(lpFileName, '\\');
+ else
+ *lpFilePart = lpFileName;
+#endif
strcpy(lpBuffer, lpFileName);
// strncpy(lpBuffer, lpFileName, rindex(lpFileName, '\\')-lpFileName);
return strlen(lpBuffer);
@@ -3055,7 +3548,7 @@ static DWORD WINAPI expGetShortPathNameA
strcpy(shortpath,longpath);
return strlen(shortpath);
}
-
+
static WIN_BOOL WINAPI expReadFile(HANDLE h,LPVOID pv,DWORD size,LPDWORD rd,LPOVERLAPPED unused)
{
int result;
@@ -3079,7 +3572,7 @@ static WIN_BOOL WINAPI expWriteFile(HANDLE h,LPCVOID pv,DWORD size,LPDWORD wr,LP
static DWORD WINAPI expSetFilePointer(HANDLE h, LONG val, LPLONG ext, DWORD whence)
{
int wh;
- dbgprintf("SetFilePointer(%d, %d, 0x%x, %d)\n", h, val, ext, whence);
+ dbgprintf("SetFilePointer(%d, 0x%x, 0x%x = %d, %d)\n", h, val, ext, *ext, whence);
//why would DLL want temporary file with >2Gb size?
switch(whence)
{
@@ -3092,6 +3585,10 @@ static DWORD WINAPI expSetFilePointer(HANDLE h, LONG val, LPLONG ext, DWORD whe
default:
return -1;
}
+#ifdef QTX
+ if (val == 0 && ext != 0)
+ val = val&(*ext);
+#endif
return lseek(h, val, wh);
}
@@ -3180,14 +3677,25 @@ static LONG WINAPI expInterlockedExchange(long *dest, long l)
static void WINAPI expInitCommonControls(void)
{
- printf("InitCommonControls called!\n");
+ dbgprintf("InitCommonControls called!\n");
return;
}
+#ifdef QTX
+/* needed by QuickTime.qts */
+static HWND WINAPI expCreateUpDownControl (DWORD style, INT x, INT y, INT cx, INT cy,
+ HWND parent, INT id, HINSTANCE inst,
+ HWND buddy, INT maxVal, INT minVal, INT curVal)
+{
+ dbgprintf("CreateUpDownControl(...)\n");
+ return 0;
+}
+#endif
+
/* alex: implement this call! needed for 3ivx */
static HRESULT WINAPI expCoCreateFreeThreadedMarshaler(void *pUnkOuter, void **ppUnkInner)
{
- printf("CoCreateFreeThreadedMarshaler(%p, %p) called!\n",
+ dbgprintf("CoCreateFreeThreadedMarshaler(%p, %p) called!\n",
pUnkOuter, ppUnkInner);
// return 0;
return ERROR_CALL_NOT_IMPLEMENTED;
@@ -3280,7 +3788,81 @@ static int expdelete(void* memory)
my_release(memory);
return 0;
}
-#if 1
+
+/*
+ * local definition - we need only the last two members at this point
+ * otherwice we would have to introduce here GUIDs and some more types..
+ */
+typedef struct __attribute__((__packed__))
+{
+ char hay[0x40];
+ unsigned long cbFormat; //0x40
+ char* pbFormat; //0x44
+} MY_MEDIA_TYPE;
+static HRESULT WINAPI expMoCopyMediaType(MY_MEDIA_TYPE* dest, const MY_MEDIA_TYPE* src)
+{
+ if (!dest || !src)
+ return E_POINTER;
+ memcpy(dest, src, sizeof(MY_MEDIA_TYPE));
+ if (dest->cbFormat)
+ {
+ dest->pbFormat = (char*) my_mreq(dest->cbFormat, 0);
+ if (!dest->pbFormat)
+ return E_OUTOFMEMORY;
+ memcpy(dest->pbFormat, src->pbFormat, dest->cbFormat);
+ }
+ return S_OK;
+}
+static HRESULT WINAPI expMoInitMediaType(MY_MEDIA_TYPE* dest, DWORD cbFormat)
+{
+ if (!dest)
+ return E_POINTER;
+ memset(dest, 0, sizeof(MY_MEDIA_TYPE));
+ if (cbFormat)
+ {
+ dest->pbFormat = (char*) my_mreq(cbFormat, 0);
+ if (!dest->pbFormat)
+ return E_OUTOFMEMORY;
+ }
+ return S_OK;
+}
+static HRESULT WINAPI expMoCreateMediaType(MY_MEDIA_TYPE** dest, DWORD cbFormat)
+{
+ if (!dest)
+ return E_POINTER;
+ *dest = my_mreq(sizeof(MY_MEDIA_TYPE), 0);
+ return expMoInitMediaType(*dest, cbFormat);
+}
+static HRESULT WINAPI expMoDuplicateMediaType(MY_MEDIA_TYPE** dest, const void* src)
+{
+ if (!dest)
+ return E_POINTER;
+ *dest = my_mreq(sizeof(MY_MEDIA_TYPE), 0);
+ return expMoCopyMediaType(*dest, src);
+}
+static HRESULT WINAPI expMoFreeMediaType(MY_MEDIA_TYPE* dest)
+{
+ if (!dest)
+ return E_POINTER;
+ if (dest->pbFormat)
+ {
+ my_release(dest->pbFormat);
+ dest->pbFormat = 0;
+ dest->cbFormat = 0;
+ }
+ return S_OK;
+}
+static HRESULT WINAPI expMoDeleteMediaType(MY_MEDIA_TYPE* dest)
+{
+ if (!dest)
+ return E_POINTER;
+ expMoFreeMediaType(dest);
+ my_release(dest);
+ return S_OK;
+}
+
+
+#if 0
static int exp_initterm(int v1, int v2)
{
dbgprintf("_initterm(0x%x, 0x%x) => 0\n", v1, v2);
@@ -3288,25 +3870,49 @@ static int exp_initterm(int v1, int v2)
}
#else
/* merged from wine - 2002.04.21 */
-typedef void (*_INITTERMFUNC)(void);
+typedef void (*_INITTERMFUNC)();
static int exp_initterm(_INITTERMFUNC *start, _INITTERMFUNC *end)
{
- _INITTERMFUNC *current = start;
-
- dbgprintf("_initterm(0x%x, 0x%x)\n", start, end);
- while (current < end)
+ dbgprintf("_initterm(0x%x, 0x%x) %p\n", start, end, *start);
+ while (start < end)
{
- if (*current)
+ if (*start)
{
- printf("call init func: %p\n", *current);
- (**current)();
+ //printf("call _initfunc: from: %p %d\n", *start);
+ // ok this trick with push/pop is necessary as otherwice
+ // edi/esi registers are being trashed
+ void* p = *start;
+ __asm__ __volatile__
+ (
+ "pushl %%ebx \n\t"
+ "pushl %%ecx \n\t"
+ "pushl %%edx \n\t"
+ "pushl %%edi \n\t"
+ "pushl %%esi \n\t"
+ "call *%%eax \n\t"
+ "popl %%esi \n\t"
+ "popl %%edi \n\t"
+ "popl %%edx \n\t"
+ "popl %%ecx \n\t"
+ "popl %%ebx \n\t"
+ :
+ : "a"(p)
+ : "memory"
+ );
+ //printf("done %p %d:%d\n", end);
}
- current++;
+ start++;
}
return 0;
}
#endif
+static void* exp__dllonexit()
+{
+ // FIXME extract from WINE
+ return NULL;
+}
+
static int expwsprintfA(char* string, char* format, ...)
{
va_list va;
@@ -3435,7 +4041,7 @@ static char* expstrcat(char* str1, const char* str2)
static char* exp_strdup(const char* str1)
{
int l = strlen(str1);
- char* result = my_mreq(l + 1,0);
+ char* result = (char*) my_mreq(l + 1,0);
if (result)
strcpy(result, str1);
dbgprintf("_strdup(0x%x='%s') => %p\n", str1, str1, result);
@@ -3578,12 +4184,31 @@ static void exp_ftol(void)
);
}
+/* #warning check for _CIpow */
+static double exp_CIpow(double x, double y)
+{
+ /*printf("Pow %f %f 0x%Lx 0x%Lx => %f\n", x, y, *((int64_t*)&x), *((int64_t*)&y), pow(x, y));*/
+ return pow(x, y);
+}
+
static double exppow(double x, double y)
{
/*printf("Pow %f %f 0x%Lx 0x%Lx => %f\n", x, y, *((int64_t*)&x), *((int64_t*)&y), pow(x, y));*/
return pow(x, y);
}
+static double expldexp(double x, int expo)
+{
+ /*printf("Cos %f => %f 0x%Lx\n", x, cos(x), *((int64_t*)&x));*/
+ return ldexp(x, expo);
+}
+
+static double expfrexp(double x, int* expo)
+{
+ /*printf("Cos %f => %f 0x%Lx\n", x, cos(x), *((int64_t*)&x));*/
+ return frexp(x, expo);
+}
+
static int exp_stricmp(const char* s1, const char* s2)
@@ -3616,6 +4241,7 @@ static int exp_setjmp3(void* jmpbuf, int x)
"movl $0, 36(%%edx) \n\t"
: // output
: "d"(jmpbuf) // input
+ : "eax"
);
#if 1
__asm__ __volatile__
@@ -3628,6 +4254,7 @@ static int exp_setjmp3(void* jmpbuf, int x)
"l1: \n\t"
:
:
+ : "eax"
);
#endif
@@ -3636,16 +4263,10 @@ static int exp_setjmp3(void* jmpbuf, int x)
static DWORD WINAPI expGetCurrentProcessId(void)
{
+ dbgprintf("GetCurrentProcessId(void) => %d\n", getpid());
return getpid(); //(DWORD)NtCurrentTeb()->pid;
}
-static HANDLE WINAPI
-expCreateMutexA( SECURITY_ATTRIBUTES *sa, WIN_BOOL owner, LPCSTR name ){
- static int x=0xcfcf9898;
- //++x;
- dbgprintf("CreateMutexA(%p,%d,'%s') => %d\n",sa,owner,name,x);
- return x;
-}
typedef struct {
UINT wPeriodMin;
@@ -3669,6 +4290,16 @@ static MMRESULT WINAPI exptimeBeginPeriod(UINT wPeriod)
return 0;
}
+#ifdef QTX
+static MMRESULT WINAPI exptimeEndPeriod(UINT wPeriod)
+{
+ dbgprintf("timeEndPeriod(%u) !\n", wPeriod);
+
+ if (wPeriod < 1 || wPeriod > 65535) return 96+1; //TIMERR_NOCANDO;
+ return 0;
+}
+#endif
+
static void WINAPI expGlobalMemoryStatus(
LPMEMORYSTATUS lpmem
) {
@@ -3777,7 +4408,11 @@ static void WINAPI expExitProcess( DWORD status )
static INT WINAPI expMessageBoxA(HWND hWnd, LPCSTR text, LPCSTR title, UINT type){
printf("MSGBOX '%s' '%s' (%d)\n",text,title,type);
- return 1;
+#ifdef QTX
+ if (type == MB_ICONHAND && !strlen(text) && !strlen(title))
+ return IDIGNORE;
+#endif
+ return IDOK;
}
/* these are needed for mss1 */
@@ -3797,6 +4432,11 @@ static WINAPI inline unsigned long int expntohl(unsigned long int netlong)
// dbgprintf("ntohl(%x) => %x\n", netlong, ntohl(netlong));
return ntohl(netlong);
}
+static void WINAPI expVariantInit(void* p)
+{
+ printf("InitCommonControls called!\n");
+ return;
+}
int expRegisterClassA(const void/*WNDCLASSA*/ *wc)
{
@@ -3810,6 +4450,113 @@ int expUnregisterClassA(const char *className, HINSTANCE hInstance)
return 0;
}
+#ifdef QTX
+/* should be fixed bcs it's not fully strlen equivalent */
+static int expSysStringByteLen(void *str)
+{
+ dbgprintf("SysStringByteLen(%p) => %d\n", str, strlen(str));
+ return strlen(str);
+}
+
+static int expDirectDrawCreate(void)
+{
+ dbgprintf("DirectDrawCreate(...) => NULL\n");
+ return NULL;
+}
+
+#if 1
+typedef struct tagPALETTEENTRY {
+ BYTE peRed;
+ BYTE peGreen;
+ BYTE peBlue;
+ BYTE peFlags;
+} PALETTEENTRY;
+
+/* reversed the first 2 entries */
+typedef struct tagLOGPALETTE {
+ WORD palNumEntries;
+ WORD palVersion;
+ PALETTEENTRY palPalEntry[1];
+} LOGPALETTE;
+
+static HPALETTE WINAPI expCreatePalette(CONST LOGPALETTE *lpgpl)
+{
+ HPALETTE test;
+ int i;
+
+ dbgprintf("CreatePalette(%x) => NULL\n", lpgpl);
+
+ i = sizeof(LOGPALETTE)+((lpgpl->palNumEntries-1)*sizeof(PALETTEENTRY));
+ test = malloc(i);
+ memcpy(test, lpgpl, i);
+
+ return test;
+}
+#else
+static int expCreatePalette(void)
+{
+ dbgprintf("CreatePalette(...) => NULL\n");
+ return NULL;
+}
+#endif
+
+static int WINAPI expGetClientRect(HWND win, RECT *r)
+{
+ dbgprintf("GetClientRect(0x%x, 0x%x) => 1\n", win, r);
+ r->right = PSEUDO_SCREEN_WIDTH;
+ r->left = 0;
+ r->bottom = PSEUDO_SCREEN_HEIGHT;
+ r->top = 0;
+ return 1;
+}
+
+#if 0
+typedef struct tagPOINT {
+ LONG x;
+ LONG y;
+} POINT, *PPOINT;
+#endif
+
+static int WINAPI expClientToScreen(HWND win, POINT *p)
+{
+ dbgprintf("ClientToScreen(0x%x, 0x%x = %d,%d) => 1\n", win, p, p->x, p->y);
+ p->x = 0;
+ p->y = 0;
+ return 1;
+}
+#endif
+
+/* for m3jpeg */
+static int WINAPI expSetThreadIdealProcessor(HANDLE thread, int proc)
+{
+ dbgprintf("SetThreadIdealProcessor(0x%x, %x) => 0\n", thread, proc);
+ return 0;
+}
+
+static int WINAPI expMessageBeep(int type)
+{
+ dbgprintf("MessageBeep(%d) => 1\n", type);
+ return 1;
+}
+
+static int WINAPI expDialogBoxParamA(void *inst, const char *name,
+ HWND parent, void *dialog_func, void *init_param)
+{
+ dbgprintf("DialogBoxParamA(0x%x, 0x%x = %s, 0x%x, 0x%x, 0x%x) => 0x42424242\n",
+ inst, name, name, parent, dialog_func, init_param);
+ return 0x42424242;
+}
+
+/* needed by imagepower mjpeg2k */
+static void *exprealloc(void *ptr, size_t size)
+{
+ dbgprintf("realloc(0x%x, %x)\n", ptr, size);
+ if (!ptr)
+ return my_mreq(size,0);
+ else
+ return my_realloc(ptr, size);
+}
+
struct exports
{
char name[64];
@@ -3838,6 +4585,12 @@ struct exports exp_kernel32[]=
FF(SetEvent, -1)
FF(ResetEvent, -1)
FF(WaitForSingleObject, -1)
+#ifdef QTX
+ FF(WaitForMultipleObjects, -1)
+ FF(ExitThread, -1)
+ FF(CreateMutexA,-1)
+ FF(ReleaseMutex,-1)
+#endif
FF(GetSystemInfo, -1)
FF(GetVersion, 332)
FF(HeapCreate, 461)
@@ -3893,6 +4646,9 @@ struct exports exp_kernel32[]=
FF(GetStartupInfoA, -1)
FF(GetStdHandle, -1)
FF(GetFileType, -1)
+#ifdef QTX
+ FF(GetFileAttributesA, -1)
+#endif
FF(SetHandleCount, -1)
FF(GetACP, -1)
FF(GetModuleFileNameA, -1)
@@ -3918,6 +4674,7 @@ struct exports exp_kernel32[]=
FF(OutputDebugStringA, -1)
FF(GetLocalTime, -1)
FF(GetSystemTime, -1)
+ FF(GetSystemTimeAsFileTime, -1)
FF(GetEnvironmentVariableA, -1)
FF(SetEnvironmentVariableA, -1)
FF(RtlZeroMemory,-1)
@@ -3936,12 +4693,18 @@ struct exports exp_kernel32[]=
FF(CreateFileA,-1)
FF(GetSystemDirectoryA,-1)
FF(GetWindowsDirectoryA,-1)
+#ifdef QTX
+ FF(GetCurrentDirectoryA,-1)
+ FF(SetCurrentDirectoryA,-1)
+ FF(CreateDirectoryA,-1)
+#endif
FF(GetShortPathNameA,-1)
FF(GetFullPathNameA,-1)
FF(SetErrorMode, -1)
FF(IsProcessorFeaturePresent, -1)
FF(GetProcessAffinityMask, -1)
FF(InterlockedExchange, -1)
+ FF(InterlockedCompareExchange, -1)
FF(MulDiv, -1)
FF(lstrcmpiA, -1)
FF(lstrlenA, -1)
@@ -3956,16 +4719,17 @@ struct exports exp_kernel32[]=
FF(GetTickCount, -1)
FF(SetThreadAffinityMask,-1)
FF(GetCurrentProcessId,-1)
- FF(CreateMutexA,-1)
FF(GlobalMemoryStatus,-1)
FF(SetThreadPriority,-1)
FF(ExitProcess,-1)
{"LoadLibraryExA", -1, (void*)&LoadLibraryExA},
+ FF(SetThreadIdealProcessor,-1)
};
struct exports exp_msvcrt[]={
FF(malloc, -1)
FF(_initterm, -1)
+ FF(__dllonexit, -1)
FF(free, -1)
{"??3@YAXPAX@Z", -1, expdelete},
{"??2@YAPAXI@Z", -1, expnew},
@@ -3996,6 +4760,9 @@ struct exports exp_msvcrt[]={
FF(pow, -1)
FF(cos, -1)
FF(_ftol,-1)
+ FF(_CIpow,-1)
+ FF(ldexp,-1)
+ FF(frexp,-1)
FF(sprintf,-1)
FF(sscanf,-1)
FF(fopen,-1)
@@ -4004,7 +4771,14 @@ struct exports exp_msvcrt[]={
FF(getenv,-1)
FF(_EH_prolog,-1)
FF(calloc,-1)
- {"ceil",-1,(void*)&ceil}
+ {"ceil",-1,(void*)&ceil},
+/* needed by imagepower mjpeg2k */
+ {"clock",-1,(void*)&clock},
+ {"memchr",-1,(void*)&memchr},
+ {"vfprintf",-1,(void*)&vfprintf},
+// {"realloc",-1,(void*)&realloc},
+ FF(realloc,-1)
+ {"puts",-1,(void*)&puts}
};
struct exports exp_winmm[]={
FF(GetDriverModuleHandle, -1)
@@ -4014,6 +4788,10 @@ struct exports exp_winmm[]={
FF(OpenDriver, -1)
FF(timeGetDevCaps, -1)
FF(timeBeginPeriod, -1)
+#ifdef QTX
+ FF(timeEndPeriod, -1)
+ FF(waveOutGetNumDevs, -1)
+#endif
};
struct exports exp_user32[]={
FF(LoadStringA, -1)
@@ -4025,7 +4803,9 @@ struct exports exp_user32[]={
FF(LoadCursorA,-1)
FF(SetCursor,-1)
FF(GetCursorPos,-1)
- FF(GetCursorPos,-1)
+#ifdef QTX
+ FF(ShowCursor,-1)
+#endif
FF(RegisterWindowMessageA,-1)
FF(GetSystemMetrics,-1)
FF(GetSysColor,-1)
@@ -4035,6 +4815,27 @@ struct exports exp_user32[]={
FF(MessageBoxA, -1)
FF(RegisterClassA, -1)
FF(UnregisterClassA, -1)
+#ifdef QTX
+ FF(GetWindowRect, -1)
+ FF(MonitorFromWindow, -1)
+ FF(MonitorFromRect, -1)
+ FF(MonitorFromPoint, -1)
+ FF(EnumDisplayMonitors, -1)
+ FF(GetMonitorInfoA, -1)
+ FF(EnumDisplayDevicesA, -1)
+ FF(GetClientRect, -1)
+ FF(ClientToScreen, -1)
+ FF(IsWindowVisible, -1)
+ FF(GetActiveWindow, -1)
+ FF(GetClassNameA, -1)
+ FF(GetClassInfoA, -1)
+ FF(GetWindowLongA, -1)
+ FF(EnumWindows, -1)
+ FF(GetWindowThreadProcessId, -1)
+ FF(CreateWindowExA, -1)
+#endif
+ FF(MessageBeep, -1)
+ FF(DialogBoxParamA, -1)
};
struct exports exp_advapi32[]={
FF(RegCloseKey, -1)
@@ -4053,6 +4854,11 @@ struct exports exp_gdi32[]={
FF(DeleteObject, -1)
FF(GetDeviceCaps, -1)
FF(GetSystemPaletteEntries, -1)
+#ifdef QTX
+ FF(CreatePalette, -1)
+ FF(GetObjectA, -1)
+ FF(CreateRectRgn, -1)
+#endif
};
struct exports exp_version[]={
FF(GetFileVersionInfoSizeA, -1)
@@ -4074,6 +4880,9 @@ struct exports exp_crtdll[]={
struct exports exp_comctl32[]={
FF(StringFromGUID2, -1)
FF(InitCommonControls, 17)
+#ifdef QTX
+ FF(CreateUpDownControl, 16)
+#endif
};
struct exports exp_wsock32[]={
FF(htonl,8)
@@ -4081,6 +4890,18 @@ struct exports exp_wsock32[]={
};
struct exports exp_msdmo[]={
FF(memcpy, -1) // just test
+ FF(MoCopyMediaType, -1)
+ FF(MoCreateMediaType, -1)
+ FF(MoDeleteMediaType, -1)
+ FF(MoDuplicateMediaType, -1)
+ FF(MoFreeMediaType, -1)
+ FF(MoInitMediaType, -1)
+};
+struct exports exp_oleaut32[]={
+ FF(VariantInit, 8)
+#ifdef QTX
+ FF(SysStringByteLen, 149)
+#endif
};
/* realplayer8:
@@ -4098,6 +4919,7 @@ struct exports exp_msdmo[]={
2300e 85 __CxxFrameHandler
23022 411 _purecall
*/
+#ifdef REALPLAYER
struct exports exp_pncrt[]={
FF(malloc, -1) // just test
FF(free, -1) // just test
@@ -4106,14 +4928,13 @@ struct exports exp_pncrt[]={
FF(_ftol,-1)
FF(_initterm, -1)
};
+#endif
-/* needed for Morgand MJPEG */
-struct exports exp_msvfw32[]={
- {"ICOpen", -1, (void *)&ICOpen},
- {"ICClose", -1, (void *)&ICClose},
- {"ICDecompress", -1, (void *)&ICDecompress},
- {"ICSendMessage", -1, (void *)&ICSendMessage}
+#ifdef QTX
+struct exports exp_ddraw[]={
+ FF(DirectDrawCreate, -1)
};
+#endif
#define LL(X) \
{#X".dll", sizeof(exp_##X)/sizeof(struct exports), exp_##X},
@@ -4127,48 +4948,77 @@ struct libs libraries[]={
LL(gdi32)
LL(version)
LL(ole32)
+ LL(oleaut32)
LL(crtdll)
LL(comctl32)
LL(wsock32)
LL(msdmo)
- LL(msvfw32)
+#ifdef REALPLAYER
LL(pncrt)
+#endif
+#ifdef QTX
+ LL(ddraw)
+#endif
};
#if defined(__CYGWIN__) || defined(__OS2__) || defined (__OpenBSD__)
#define MANGLE(a) "_" #a
#else
#define MANGLE(a) #a
#endif
-static char* called_unk = "Called unk_%s\n";
static void ext_stubs(void)
{
// expects:
// ax position index
// cx address of printf function
+#if 1
+ __asm__ __volatile__
+ (
+ "push %%edx \n\t"
+ "movl $0xdeadbeef, %%eax \n\t"
+ "movl $0xdeadbeef, %%edx \n\t"
+ "shl $5, %%eax \n\t" // ax * 32
+ "addl $0xdeadbeef, %%eax \n\t" // overwrite export_names
+ "pushl %%eax \n\t"
+ "pushl $0xdeadbeef \n\t" // overwrite called_unk
+ "call *%%edx \n\t" // printf (via dx)
+ "addl $8, %%esp \n\t"
+ "xorl %%eax, %%eax \n\t"
+ "pop %%edx \n\t"
+ :
+ :
+ : "eax"
+ );
+#else
__asm__ __volatile__
(
- "push %edx \n\t"
- "movl $0, %eax \n\t"
- "movl $0, %edx \n\t"
- "shl $5,%eax \n\t" // ax * 32
- "addl $"MANGLE(export_names)",%eax \n\t"
- "pushl %eax \n\t"
- "pushl "MANGLE(called_unk)" \n\t"
- "call *%edx \n\t" // printf (via dx)
- "addl $8,%esp \n\t"
- "xorl %eax,%eax \n\t"
- "pop %edx \n\t"
+ "push %%edx \n\t"
+ "movl $0, %%eax \n\t"
+ "movl $0, %%edx \n\t"
+ "shl $5, %%eax \n\t" // ax * 32
+ "addl %0, %%eax \n\t"
+ "pushl %%eax \n\t"
+ "pushl %1 \n\t"
+ "call *%%edx \n\t" // printf (via dx)
+ "addl $8, %%esp \n\t"
+ "xorl %%eax, %%eax \n\t"
+ "pop %%edx \n\t"
+ ::"m"(*export_names), "m"(*called_unk)
+ : "memory", "edx", "eax"
);
+#endif
+
}
//static void add_stub(int pos)
extern int unk_exp1;
-static char extcode[20000];// place for 200 unresolved exports
static int pos=0;
+static char extcode[20000];// place for 200 unresolved exports
+static const char* called_unk = "Called unk_%s\n";
-static void* add_stub()
+static void* add_stub(void)
{
+ // generated code in runtime!
char* answ = (char*)extcode+pos*0x30;
#if 0
memcpy(answ, &unk_exp1, 0x64);
@@ -4176,10 +5026,14 @@ static void* add_stub()
*(int*)(answ+47)-=((int)answ-(int)&unk_exp1);
#endif
memcpy(answ, ext_stubs, 0x2f); // 0x2c is current size
- //answ[0] = 0xb8; // movl $0, eax (0xb8 0x00000000)
+ //answ[4] = 0xb8; // movl $0, eax (0xb8 0x00000000)
*((int*) (answ + 5)) = pos;
- //answ[5] = 0xb9; // movl $0, edx (0xb9 0x00000000)
- *((int*) (answ + 10)) = (int) printf;
+ //answ[9] = 0xba; // movl $0, edx (0xba 0x00000000)
+ *((long*) (answ + 10)) = (long)printf;
+ //answ[17] = 0x05; // addl $0, eax (0x05 0x00000000)
+ *((long*) (answ + 18)) = (long)export_names;
+ //answ[23] = 0x68; // pushl $0 (0x68 0x00000000)
+ *((long*) (answ + 24)) = (long)called_unk;
pos++;
return (void*)answ;
}
@@ -4209,9 +5063,10 @@ void* LookupExternal(const char* library, int ordinal)
}
}
+#ifdef LOADLIB_TRY_NATIVE
/* ok, this is a hack, and a big memory leak. should be fixed. - alex */
{
- HMODULE *hand;
+ int hand;
WINE_MODREF *wm;
void *func;
@@ -4224,23 +5079,24 @@ void* LookupExternal(const char* library, int ordinal)
FreeLibrary(hand);
goto no_dll;
}
- func = PE_FindExportedFunction(wm, ordinal, 0);
+ func = PE_FindExportedFunction(wm, (LPCSTR) ordinal, 0);
if (!func)
{
printf("No such ordinal in external dll\n");
- FreeLibrary(hand);
+ FreeLibrary((int)hand);
goto no_dll;
}
- printf("External dll loaded (offset: %p, func: %p)\n",
- hand, func);
+ printf("External dll loaded (offset: 0x%x, func: %p)\n",
+ hand, func);
return func;
}
+#endif
no_dll:
if(pos>150)return 0;
sprintf(export_names[pos], "%s:%d", library, ordinal);
- return add_stub(pos);
+ return add_stub();
}
void* LookupExternalByName(const char* library, const char* name)
@@ -4258,7 +5114,7 @@ void* LookupExternalByName(const char* library, const char* name)
printf("ERROR: name=0\n");
return (void*)ext_unknown;
}
- //printf("External func %s:%s\n", library, name);
+ dbgprintf("External func %s:%s\n", library, name);
for(i=0; i<sizeof(libraries)/sizeof(struct libs); i++)
{
if(strcasecmp(library, libraries[i].name))
@@ -4273,7 +5129,7 @@ void* LookupExternalByName(const char* library, const char* name)
}
if(pos>150)return 0;// to many symbols
strcpy(export_names[pos], name);
- return add_stub(pos);
+ return add_stub();
}
void my_garbagecollection(void)
@@ -4281,15 +5137,19 @@ void my_garbagecollection(void)
#ifdef GARBAGE
int unfree = 0, unfreecnt = 0;
+ int max_fatal = 8;
free_registry();
while (last_alloc)
{
alloc_header* mem = last_alloc + 1;
unfree += my_size(mem);
unfreecnt++;
- my_release(mem);
+ if (my_release(mem) != 0)
+ // avoid endless loop when memory is trashed
+ if (--max_fatal < 0)
+ break;
}
- dbgprintf("Total Unfree %d bytes cnt %d [%p,%d]\n",unfree, unfreecnt, last_alloc, alccnt);
+ printf("Total Unfree %d bytes cnt %d [%p,%d]\n",unfree, unfreecnt, last_alloc, alccnt);
#endif
g_tls = NULL;
list = NULL;
diff --git a/src/libw32dll/wine/win32.h b/src/libw32dll/wine/win32.h
index 89321eb7a..79d6877e3 100644
--- a/src/libw32dll/wine/win32.h
+++ b/src/libw32dll/wine/win32.h
@@ -25,9 +25,7 @@ typedef struct tls_s tls_t;
extern void* LookupExternal(const char* library, int ordinal);
extern void* LookupExternalByName(const char* library, const char* name);
-
-extern void* my_mreq(int size, int to_zero);
-extern int my_release(void* memory);
-
+extern int expRegisterClassA(const void/*WNDCLASSA*/ *wc);
+extern int expUnregisterClassA(const char *className, HINSTANCE hInstance);
#endif
diff --git a/src/libw32dll/wine/wineacm.h b/src/libw32dll/wine/wineacm.h
index 5984a68c5..e7604dc64 100644
--- a/src/libw32dll/wine/wineacm.h
+++ b/src/libw32dll/wine/wineacm.h
@@ -1,8 +1,19 @@
+#ifndef WINEACM_H
+#define WINEACM_H
/* -*- tab-width: 8; c-basic-offset: 4 -*- */
/***********************************************************************
* Wine specific - Win32
*/
+
+
+#include "msacmdrv.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* defined(__cplusplus) */
+
+
typedef struct _WINE_ACMDRIVERID *PWINE_ACMDRIVERID;
typedef struct _WINE_ACMDRIVER *PWINE_ACMDRIVER;
@@ -17,6 +28,7 @@ typedef struct _WINE_ACMDRIVER
HDRVR hDrvr;
DRIVERPROC pfnDriverProc;
PWINE_ACMDRIVER pNextACMDriver;
+ int iUsage;
} WINE_ACMDRIVER;
typedef struct _WINE_ACMSTREAM
@@ -29,8 +41,8 @@ typedef struct _WINE_ACMSTREAM
typedef struct _WINE_ACMDRIVERID
{
- LPSTR pszDriverAlias;
LPSTR pszFileName;
+ WORD wFormatTag;
HINSTANCE hInstModule; /* NULL if global */
DWORD dwProcessID; /* ID of process which installed a local driver */
WIN_BOOL bEnabled;
@@ -43,13 +55,18 @@ typedef struct _WINE_ACMDRIVERID
extern HANDLE MSACM_hHeap;
extern PWINE_ACMDRIVERID MSACM_pFirstACMDriverID;
extern PWINE_ACMDRIVERID MSACM_pLastACMDriverID;
-PWINE_ACMDRIVERID MSACM_RegisterDriver(LPSTR pszDriverAlias,
- LPSTR pszFileName,
+
+PWINE_ACMDRIVERID MSACM_RegisterDriver(const char* pszFileName,
+ WORD wFormatTag,
HINSTANCE hinstModule);
-void MSACM_RegisterAllDrivers(void);
PWINE_ACMDRIVERID MSACM_UnregisterDriver(PWINE_ACMDRIVERID p);
void MSACM_UnregisterAllDrivers(void);
PWINE_ACMDRIVERID MSACM_GetDriverID(HACMDRIVERID hDriverID);
PWINE_ACMDRIVER MSACM_GetDriver(HACMDRIVER hDriver);
PWINE_ACMOBJ MSACM_GetObj(HACMOBJ hObj);
+#ifdef __cplusplus
+} /* extern "C" */
+#endif /* defined(__cplusplus) */
+
+#endif /* WINEACM_H */
diff --git a/src/libw32dll/wine/wrapper.S b/src/libw32dll/wine/wrapper.S
new file mode 100644
index 000000000..fe2d85619
--- /dev/null
+++ b/src/libw32dll/wine/wrapper.S
@@ -0,0 +1,83 @@
+.section .data
+.globl caller_return
+caller_return:
+ .long 0
+.globl report_entry
+report_entry:
+ .long null_call
+.globl report_ret
+report_ret:
+ .long null_call
+.global wrapper_target
+wrapper_target:
+ .long null_call
+
+.section .text
+.globl null_call
+ .type null_call, @function
+ .balign 16,0x90
+null_call:
+ ret
+.globl wrapper
+ .type wrapper, @function
+ .balign 16,0x90
+wrapper:
+ pusha # store registers (EAX, ECX, EDX, EBX, ESP, EBP, ESI, EDI)
+ pushf # store flags
+
+ push %ebp # set up a stack frame
+ movl %esp, %ebp
+
+ leal 4(%ebp), %eax # push flags addr
+ push %eax
+ leal 8(%ebp), %eax # push registers addr
+ push %eax
+
+ leal 40(%ebp), %edx
+ movl (%ebp), %eax
+ subl %edx, %eax
+ push %eax
+ push %edx
+
+ call *report_entry # report entry
+
+ test %eax, %eax
+ jnz .Ldone
+
+ leave # restore %esp, %ebp
+ popf # restore flags
+ popa # restore registers
+
+ popl caller_return # switch return addresses
+ pushl $.Lwrapper_return
+
+ jmp *wrapper_target # wrapper_target should return at .Lwrapper_return
+
+ .balign 16, 0x90
+.Lwrapper_return:
+ pushl caller_return # restore the original return address
+ pusha # more for reference sake here
+ pushf
+
+ push %ebp # set up a stack frame
+ movl %esp, %ebp
+
+ leal 4(%ebp), %eax # push flags addr
+ push %eax
+ leal 8(%ebp), %eax # push registers addr
+ push %eax
+
+ leal 40(%ebp), %edx # push stack top address (relative to our entry)
+ movl (%ebp), %eax
+ subl %edx, %eax # calculate difference between entry and previous frame
+ push %eax
+ push %edx
+
+ call *report_ret # report the return information (same args)
+.Ldone:
+
+ leave
+ popf
+ popa
+ ret
+
diff --git a/src/libw32dll/wine/wrapper.h b/src/libw32dll/wine/wrapper.h
new file mode 100644
index 000000000..e307c0e65
--- /dev/null
+++ b/src/libw32dll/wine/wrapper.h
@@ -0,0 +1,20 @@
+#ifndef _WRAPPER_H
+#define _WRAPPER_H
+
+#include <sys/types.h>
+
+typedef struct {
+ u_int32_t edi, esi, ebp, esp, ebx, edx, ecx, eax;
+} reg386_t;
+
+typedef int (*wrapper_func_t)(void *stack_base, int stack_size, reg386_t *reg, u_int32_t *flags);
+
+extern wrapper_func_t report_entry, report_ret;
+
+extern void (*wrapper_target)(void);
+
+extern int wrapper(void);
+extern int null_call(void);
+
+#endif /* _WRAPPER_H */
+