[MPlayer-dev-eng] quicktime news - we did it again? :)

Dominik Mierzejewski dominik at rangers.eu.org
Sun Nov 24 23:10:31 CET 2002


On Sunday, 24 November 2002, Arpi wrote:
> Hi,
> 
> > > ok then cvs up -d
> > > and replace loader/win32.c with this file:
> > > http://mplayerhq.hu/~arpi/qtx/win32.c
> > > (this file is not commited, as it needs cleanup and anyway it's Alex's work
> > > so he'll commit it after cleanup)
> > 
> > Good to know ...
> 
> also, edit win32.c, i've hardcoded the svq3 plugin path at line 3401 :)
> 
>    tmp="/root/.wine/fake_windows/Windows/System/QuickTime/QuickTimeEssentials.qtx";
>    result=open(tmp, O_RDONLY);

Here's a patch that does all necessary changes (diff to your win32.c+module.c mods):
 
-- 
MPlayer RPMs maintainer: http://www.piorunek.pl/~dominik/linux/pkgs/mplayer/
"The Universe doesn't give you any points for doing things that are easy."
        -- Sheridan to Garibaldi in Babylon 5:"The Geometry of Shadows"
-------------- next part --------------
--- MPlayer-20021124/loader/win32.c.qtx	Sun Nov 24 23:06:02 2002
+++ MPlayer-20021124/loader/win32.c	Sun Nov 24 23:08:27 2002
@@ -13,12 +13,26 @@
 
 #include "config.h"
 
+#ifdef MPLAYER
+#ifdef USE_QTX_CODECS
+#define QTX
+#endif
+#define REALPLAYER
+//#define LOADLIB_TRY_NATIVE
+#endif
+
+#ifdef QTX
+#define PSEUDO_SCREEN_WIDTH	/*640*/800
+#define PSEUDO_SCREEN_HEIGHT	/*480*/600
+#endif
+
 #include "wine/winbase.h"
 #include "wine/winreg.h"
 #include "wine/winnt.h"
 #include "wine/winerror.h"
 #include "wine/debugtools.h"
 #include "wine/module.h"
+#include "wine/winuser.h"
 
 #include <stdio.h>
 #include "win32.h"
@@ -166,7 +180,9 @@
     longcount(z);
 }
 
-int LOADER_DEBUG=1; // active only if compiled with -DDETAILED_OUT
+    #include "../mp_msg.h"
+
+int LOADER_DEBUG=0; // active only if compiled with -DDETAILED_OUT
 //#define DETAILED_OUT
 static inline void dbgprintf(char* fmt, ...)
 {
@@ -188,18 +204,17 @@
 	va_end(va);
     }
 #endif
-//#undef MPLAYER
 #ifdef MPLAYER
-    #include "../mp_msg.h"
     if (verbose > 2)
     {
 	va_list va;
 	
 	va_start(va, fmt);
-//	vprintf(fmt, va);
-	mp_dbg(MSGT_WIN32, MSGL_DBG3, fmt, va);
+	vprintf(fmt, va);
+//	mp_dbg(MSGT_WIN32, MSGL_DBG3, fmt, va);
 	va_end(va);
     }
+  fflush(stdout);
 #endif
 }
 
@@ -511,13 +526,22 @@
 
 #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);
@@ -527,14 +551,17 @@
     }
     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)
@@ -786,6 +813,65 @@
     return (void *)ret;
 }
 
+#ifdef QTX
+static void* WINAPI expWaitForMultipleObjects(int count, const void** objects,
+		    int WaitAll, int duration)
+{
+    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++)
+    {
+	object = objects[i];
+	ret = expWaitForSingleObject(object, duration);
+	if (WaitAll)
+	    dprintf("suck...\n");
+	else
+	    return ret;
+    }
+    return NULL;
+}
+#endif
+
+#if 0
+static void *mutex;
+static int mutex_size = 0;
+
+static HANDLE WINAPI expCreateMutexA( SECURITY_ATTRIBUTES *sa, WIN_BOOL owner, LPCSTR name)
+{
+#if 0
+    static int x=0xcfcf9898;
+    //++x;
+#else
+    void *x;
+    
+    mutex_size+=4;
+    mutex = realloc(mutex, mutex_size);
+    x = (mutex+mutex_size);
+#endif
+    dbgprintf("CreateMutexA(0x%x, %d, '%s') => %d\n",sa,owner,name,x);
+    return x;
+}
+#else
+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);
+}
+#endif
+
+
 static int pf_set = 0;
 static BYTE PF[64] = {0,};
 
@@ -1259,7 +1345,7 @@
 #else
     struct CRITSECT* cs = (*(struct CRITSECT**)c);
 #endif
-    dbgprintf("EnterCriticalSection(0x%x) %p maso:0x%x\n",c, cs, (cs)?cs->deadbeef:0);
+//    dbgprintf("EnterCriticalSection(0x%x) %p\n",c, cs);
     if (!cs)
     {
 	dbgprintf("entered uninitialized critisec!\n");
@@ -1287,7 +1373,7 @@
     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->deadbeef);
     if (!cs)
     {
 	printf("Win32 Warning: Leaving uninitialized Critical Section %p!!\n", c);
@@ -1335,8 +1421,8 @@
 }
 static int WINAPI expGetCurrentThreadId()
 {
-    dbgprintf("GetCurrentThreadId() => %d\n", getpid());
-    return getpid();
+//    dbgprintf("GetCurrentThreadId() => %d\n", pthread_self());
+    return pthread_self();
 }
 static int WINAPI expGetCurrentProcess()
 {
@@ -1344,7 +1430,7 @@
     return getpid();
 }
 
-#if 0
+#ifdef QTX
 // this version is required for Quicktime codecs (.qtx/.qts) to work.
 // (they assume some pointers at FS: segment)
 
@@ -1366,9 +1452,10 @@
     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;
@@ -2081,17 +2168,32 @@
     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;
@@ -2101,8 +2203,15 @@
 {
     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)
@@ -2173,17 +2282,28 @@
 //	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, def_path, result);
 
     return result;
 }
+
 static int WINAPI expFreeLibrary(int module)
 {
-    int result=FreeLibrary(module);
+    int result=0; //FreeLibrary(module);
     dbgprintf("FreeLibrary(0x%x) => %d\n", module, result);
     return result;
 }
+
 static void* WINAPI expGetProcAddress(HMODULE mod, char* name)
 {
     void* result;
@@ -2192,6 +2312,14 @@
 	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);
     }
@@ -2268,7 +2396,15 @@
 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)
@@ -2293,6 +2429,178 @@
     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.
@@ -2517,13 +2825,13 @@
 static long WINAPI expInterlockedIncrement( long* dest )
 {
     long result=expInterlockedExchangeAdd( dest, 1 ) + 1;
-    dbgprintf("InterlockedIncrement(0x%x => %d) => %d\n", dest, *dest, result);
+//    dbgprintf("InterlockedIncrement(0x%x => %d) => %d\n", dest, *dest, result);
     return result;
 }
 static long WINAPI expInterlockedDecrement( long* dest )
 {
     long result=expInterlockedExchangeAdd( dest, -1 ) - 1;
-    dbgprintf("InterlockedDecrement(0x%x => %d) => %d\n", dest, *dest, result);
+//    dbgprintf("InterlockedDecrement(0x%x => %d) => %d\n", dest, *dest, result);
     return result;
 }
 
@@ -2535,14 +2843,14 @@
 
 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()
@@ -2568,6 +2876,18 @@
     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);
@@ -2594,14 +2914,39 @@
     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)
@@ -2907,14 +3252,38 @@
 
 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);
+	strcpy(lpfd->cFileName, "QuickTimeEssentials.qtx");
+	strcpy(lpfd->cAlternateFileName, "QuickEss.qts");
+	return FILE_HANDLE_quicktimeqtx;
+    }
+    if (strstr(s, "QuickTime.qts") || strstr(s,"c:\\windows\\system") )
+    {
+	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;
+    return (HANDLE)-1;
 }
-static WIN_BOOL WINAPI expFindNextFileA(HANDLE h,LPWIN32_FIND_DATAA p)
+static WIN_BOOL WINAPI expFindNextFileA(HANDLE h,LPWIN32_FIND_DATAA lpfd)
 {
-    dbgprintf("FindNextFileA(0x%x, 0x%x) => 0\n", h, p);
+    dbgprintf("FindNextFileA(0x%x, 0x%x) => 0\n", h, lpfd);
+#if 0
+    if(h==FILE_HANDLE_quicktimeqts && strcmp(lpfd->cFileName,"QuickTimeEssentials.qtx")){
+	strcpy(lpfd->cFileName, "QuickTimeEssentials.qtx");
+	strcpy(lpfd->cAlternateFileName, "QuickT~1.qtx");
+	return FILE_HANDLE_quicktimeess;
+    }
+#endif
     return 0;
 }
 static WIN_BOOL WINAPI expFindClose(HANDLE h)
@@ -2924,7 +3293,7 @@
 }
 static UINT WINAPI expSetErrorMode(UINT i)
 {
-    dbgprintf("SetErrorMode(%d) => 0\n", i);
+//    dbgprintf("SetErrorMode(%d) => 0\n", i);
     return 0;
 }
 static UINT WINAPI expGetWindowsDirectoryA(LPSTR s,UINT c)
@@ -2936,7 +3305,52 @@
     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);
@@ -2975,6 +3389,30 @@
 	      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(def_path)+50);
+	strcpy(tmp, def_path);
+	strcat(tmp, "/");
+	strcat(tmp, "QuickTime.qts");
+	result=open(tmp, O_RDONLY);
+	free(tmp);
+	return result;
+    }
+    if(strstr(cs1, "QuickTimeEssentials.qtx"))
+    {
+	int result;
+	char* tmp=(char*)malloc(strlen(def_path)+50);
+	strcpy(tmp, def_path);
+	strcat(tmp, "/");
+	strcat(tmp,"QuickTimeEssentials.qtx");
+	result=open(tmp, O_RDONLY);
+	return result;
+    }
+#endif
+
     if(strncmp(cs1, "AP", 2) == 0)
     {
 	int result;
@@ -3057,7 +3495,8 @@
     if(!lpFileName) return 0;
     dbgprintf("GetFullPathNameA('%s',%d,%p,%p)\n",lpFileName,nBufferLength,
 	lpBuffer, lpFilePart);
-    strcpy(lpFilePart, lpFileName);
+//    strcpy(lpFilePart, lpFileName);
+    strcpy(lpFilePart, "Quick123.qts");
     strcpy(lpBuffer, lpFileName);
 //    strncpy(lpBuffer, lpFileName, rindex(lpFileName, '\\')-lpFileName);
     return strlen(lpBuffer);
@@ -3098,7 +3537,7 @@
 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)
     {
@@ -3111,6 +3550,10 @@
     default:
 	return -1;
     }
+#ifdef QTX
+    if (val == 0 && ext != 0)
+	val = val&(*ext);
+#endif
     return lseek(h, val, wh);
 }
 
@@ -3199,14 +3642,25 @@
 
 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;
@@ -3682,16 +4136,10 @@
 
 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;
@@ -3823,7 +4271,11 @@
 
 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 */
@@ -3861,6 +4313,115 @@
     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);
+
+    printf("palV: %d palNE: %d\n", lpgpl->palVersion, lpgpl->palNumEntries);
+
+    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];
@@ -3889,6 +4450,9 @@
     FF(SetEvent, -1)
     FF(ResetEvent, -1)
     FF(WaitForSingleObject, -1)
+#ifdef QTX
+    FF(WaitForMultipleObjects, -1)
+#endif
     FF(GetSystemInfo, -1)
     FF(GetVersion, 332)
     FF(HeapCreate, 461)
@@ -3944,6 +4508,9 @@
     FF(GetStartupInfoA, -1)
     FF(GetStdHandle, -1)
     FF(GetFileType, -1)
+#ifdef QTX
+    FF(GetFileAttributesA, -1)
+#endif
     FF(SetHandleCount, -1)
     FF(GetACP, -1)
     FF(GetModuleFileNameA, -1)
@@ -3988,6 +4555,11 @@
     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)
@@ -4013,6 +4585,7 @@
     FF(SetThreadPriority,-1)
     FF(ExitProcess,-1)
     {"LoadLibraryExA", -1, (void*)&LoadLibraryExA},
+    FF(SetThreadIdealProcessor,-1)
 };
 
 struct exports exp_msvcrt[]={
@@ -4057,7 +4630,14 @@
     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)
@@ -4067,6 +4647,9 @@
     FF(OpenDriver, -1)
     FF(timeGetDevCaps, -1)
     FF(timeBeginPeriod, -1)
+#ifdef QTX
+    FF(waveOutGetNumDevs, -1)
+#endif
 };
 struct exports exp_user32[]={
     FF(LoadStringA, -1)
@@ -4078,7 +4661,9 @@
     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)
@@ -4088,6 +4673,27 @@
     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)
@@ -4106,6 +4712,11 @@
     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)
@@ -4127,6 +4738,9 @@
 struct exports exp_comctl32[]={
     FF(StringFromGUID2, -1)
     FF(InitCommonControls, 17)
+#ifdef QTX
+    FF(CreateUpDownControl, 16)
+#endif
 };
 struct exports exp_wsock32[]={
     FF(htonl,8)
@@ -4145,6 +4759,9 @@
 };
 struct exports exp_oleaut32[]={
     FF(VariantInit, 8)
+#ifdef QTX
+    FF(SysStringByteLen, 149)
+#endif
 };
 
 /*  realplayer8:
@@ -4162,7 +4779,7 @@
 	2300e	   85  __CxxFrameHandler
 	23022	  411  _purecall
 */
-#ifdef MPLAYER
+#ifdef REALPLAYER
 struct exports exp_pncrt[]={
     FF(malloc, -1) // just test
     FF(free, -1) // just test
@@ -4173,6 +4790,12 @@
 };
 #endif
 
+#ifdef QTX
+struct exports exp_ddraw[]={
+    FF(DirectDrawCreate, -1)
+};
+#endif
+
 #define LL(X) \
     {#X".dll", sizeof(exp_##X)/sizeof(struct exports), exp_##X},
 
@@ -4190,9 +4813,12 @@
     LL(comctl32)
     LL(wsock32)
     LL(msdmo)
-#ifdef MPLAYER
+#ifdef REALPLAYER
     LL(pncrt)
 #endif
+#ifdef QTX
+    LL(ddraw)
+#endif
 };
 
 static void ext_stubs(void)
@@ -4293,6 +4919,7 @@
 	}
     }
 
+#ifdef LOADLIB_TRY_NATIVE
     /* ok, this is a hack, and a big memory leak. should be fixed. - alex */
     {
 	int hand;
@@ -4320,6 +4947,7 @@
 	       hand, func);
 	return func;
     }
+#endif
 
 no_dll:
     if(pos>150)return 0;
--- MPlayer-20021124/loader/module.c.qtx	Sun Nov 24 23:06:02 2002
+++ MPlayer-20021124/loader/module.c	Sun Nov 24 23:06:02 2002
@@ -5,7 +5,7 @@
  */
 
 // define for quicktime calls debugging and/or MacOS-level emulation:
-//#define EMU_QTX_API
+#define EMU_QTX_API
 
 // define for quicktime debugging (verbose logging):
 //#define DEBUG_QTX_API


More information about the MPlayer-dev-eng mailing list