From 77e66ee012c4811996ac1a6170dfd3802adfbba6 Mon Sep 17 00:00:00 2001 From: reimar Date: Tue, 9 Feb 2010 19:43:02 +0000 Subject: Add stubs for several functions, needed for CineForm codec. Patch by Steinar H. Gunderson [sgunderson bigfoot com] with some modifications by me. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@30531 b3059339-0415-0410-9bf9-f77b7e298cf2 --- loader/win32.c | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) (limited to 'loader/win32.c') diff --git a/loader/win32.c b/loader/win32.c index 3b0dd5bb3e..552032464e 100644 --- a/loader/win32.c +++ b/loader/win32.c @@ -72,6 +72,7 @@ for DLL to know too much about its environment. #include "osdep/mmap.h" #endif #include "osdep/mmap_anon.h" +#include "libavutil/avstring.h" char* def_path = WIN32_PATH; @@ -562,6 +563,7 @@ static HMODULE WINAPI expGetDriverModuleHandle(DRVR* pdrv) #define MODULE_HANDLE_msvcrt ((HMODULE)0x126) #define MODULE_HANDLE_ole32 ((HMODULE)0x127) #define MODULE_HANDLE_winmm ((HMODULE)0x128) +#define MODULE_HANDLE_psapi ((HMODULE)0x129) static HMODULE WINAPI expGetModuleHandleA(const char* name) { @@ -1133,6 +1135,10 @@ static WIN_BOOL WINAPI expIsProcessorFeaturePresent(DWORD v) return result; } +static WIN_BOOL WINAPI expIsDebuggerPresent(void) +{ + return 0; +} static long WINAPI expGetVersion(void) { @@ -2269,6 +2275,21 @@ static int WINAPI expGetModuleFileNameA(int module, char* s, int len) return result; } +static int WINAPI expGetModuleBaseNameA(int process, int module, char* s, int len) +{ + int result = 0; + + if (s && len) { + av_strlcpy(s, "aviplay.dll", len); + result = strlen(s); + } + + dbgprintf("GetModuleBaseNameA(0x%x, 0x%x, 0x%x, %d) => %d\n", + process, module, s, len, result); + + return result; +} + static int WINAPI expSetUnhandledExceptionFilter(void* filter) { dbgprintf("SetUnhandledExceptionFilter(0x%x) => 1\n", filter); @@ -2329,6 +2350,8 @@ static int WINAPI expLoadLibraryA(char* name) return MODULE_HANDLE_ole32; if (strcasecmp(name, "winmm.dll") == 0 || strcasecmp(name, "winmm") == 0) return MODULE_HANDLE_winmm; + if (strcasecmp(name, "psapi.dll") == 0 || strcasecmp(name, "psapi") == 0) + return MODULE_HANDLE_psapi; result=LoadLibraryA(name); dbgprintf("Returned LoadLibraryA(0x%x='%s'), def_path=%s => 0x%x\n", name, name, def_path, result); @@ -2371,6 +2394,8 @@ static void* WINAPI expGetProcAddress(HMODULE mod, char* name) result=LookupExternalByName("ole32.dll", name); break; case MODULE_HANDLE_winmm: result=LookupExternalByName("winmm.dll", name); break; + case MODULE_HANDLE_psapi: + result=LookupExternalByName("psapi.dll", name); break; default: result=GetProcAddress(mod, name); } @@ -4543,6 +4568,12 @@ static WIN_BOOL WINAPI expSetThreadPriority( return TRUE; } +static void WINAPI expTerminateProcess( DWORD process, DWORD status ) +{ + printf("EXIT - process %ld code %ld\n", process, status); + exit(status); +} + static void WINAPI expExitProcess( DWORD status ) { printf("EXIT - code %ld\n",status); @@ -4592,6 +4623,28 @@ static WINAPI inline unsigned long int expntohl(unsigned long int netlong) // dbgprintf("ntohl(%x) => %x\n", netlong, ntohl(netlong)); return ntohl(netlong); } + +static char* WINAPI expSysAllocStringLen(char *pch, unsigned cch) +{ + char *str; + dbgprintf("SysAllocStringLen('%s', %d)\n", pch, cch); + str = malloc(cch * 2 + sizeof(unsigned) + 2); + *(unsigned *)str = cch; + str += sizeof(unsigned); + if (pch) + memcpy(str, pch, cch * 2); + str[cch * 2] = 0; + str[cch * 2 + 1] = 0; + return str; +} + +static void WINAPI expSysFreeString(char *str) +{ + if (str) { + free(str - sizeof(unsigned)); + } +} + static void WINAPI expVariantInit(void* p) { printf("InitCommonControls called!\n"); @@ -4846,6 +4899,25 @@ static void * WINAPI expDecodePointer(void *p) return p; } +static DWORD WINAPI expGetThreadLocale(void) +{ + return 0; +} + +/** + * Very incomplete implementation, return an error for almost all cases. + */ +static DWORD WINAPI expGetLocaleInfoA(DWORD locale, DWORD lctype, char* lpLCData, int cchData) +{ + if (lctype == 0x1004) { // LOCALE_IDEFAULTANSICODEPAGE + if (cchData < 4) + return cchData == 0 ? 4 : 0; + strcpy(lpLCData, "437"); + return 4; + } + return 0; +} + struct exports { char name[64]; @@ -4997,6 +5069,7 @@ struct exports exp_kernel32[]= FF(GetFullPathNameA,-1) FF(SetErrorMode, -1) FF(IsProcessorFeaturePresent, -1) + FF(IsDebuggerPresent, -1) FF(GetProcessAffinityMask, -1) FF(InterlockedExchange, -1) FF(InterlockedCompareExchange, -1) @@ -5017,12 +5090,15 @@ struct exports exp_kernel32[]= FF(GlobalMemoryStatus,-1) FF(GetThreadPriority,-1) FF(SetThreadPriority,-1) + FF(TerminateProcess,-1) FF(ExitProcess,-1) {"LoadLibraryExA", -1, (void*)&LoadLibraryExA}, FF(SetThreadIdealProcessor,-1) FF(SetProcessAffinityMask, -1) FF(EncodePointer, -1) FF(DecodePointer, -1) + FF(GetThreadLocale, -1) + FF(GetLocaleInfoA, -1) UNDEFF(FlsAlloc, -1) UNDEFF(FlsGetValue, -1) UNDEFF(FlsSetValue, -1) @@ -5106,6 +5182,9 @@ struct exports exp_winmm[]={ FF(waveOutGetNumDevs, -1) #endif }; +struct exports exp_psapi[]={ + FF(GetModuleBaseNameA, -1) +}; struct exports exp_user32[]={ FF(LoadIconA,-1) FF(LoadStringA, -1) @@ -5220,6 +5299,8 @@ struct exports exp_msdmo[]={ FF(MoInitMediaType, -1) }; struct exports exp_oleaut32[]={ + FF(SysAllocStringLen, 4) + FF(SysFreeString, 6) FF(VariantInit, 8) #ifdef QTX FF(SysStringByteLen, 149) @@ -5302,6 +5383,7 @@ struct libs libraries[]={ LL(kernel32) LL(msvcrt) LL(winmm) + LL(psapi) LL(user32) LL(advapi32) LL(gdi32) -- cgit v1.2.3 From c53143fffb60edba9897a33e6f9dc397626c26ac Mon Sep 17 00:00:00 2001 From: diego Date: Fri, 12 Feb 2010 13:45:19 +0000 Subject: Fix linking of loader test programs when loader is disabled. Dependencies were only set correctly if the loader code was enabled. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@30542 b3059339-0415-0410-9bf9-f77b7e298cf2 --- loader/win32.c | 1 + 1 file changed, 1 insertion(+) (limited to 'loader/win32.c') diff --git a/loader/win32.c b/loader/win32.c index 552032464e..10c8278ea3 100644 --- a/loader/win32.c +++ b/loader/win32.c @@ -24,6 +24,7 @@ for DLL to know too much about its environment. #endif #define REALPLAYER //#define LOADLIB_TRY_NATIVE +#define WIN32_LOADER #ifdef QTX #define PSEUDO_SCREEN_WIDTH /*640*/800 -- cgit v1.2.3 From 5b01485ea39ffb69d63fc53bc1420b8a87cc0c4e Mon Sep 17 00:00:00 2001 From: diego Date: Fri, 12 Feb 2010 14:10:21 +0000 Subject: Get rid of pointless CONFIG_QTX_CODECS --> QTX preprocessor indirection. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@30544 b3059339-0415-0410-9bf9-f77b7e298cf2 --- loader/win32.c | 81 ++++++++++++++++++++++++++++------------------------------ 1 file changed, 39 insertions(+), 42 deletions(-) (limited to 'loader/win32.c') diff --git a/loader/win32.c b/loader/win32.c index 10c8278ea3..b09cb5a716 100644 --- a/loader/win32.c +++ b/loader/win32.c @@ -19,14 +19,11 @@ for DLL to know too much about its environment. #include "config.h" #include "mangle.h" -#ifdef CONFIG_QTX_CODECS -#define QTX -#endif #define REALPLAYER //#define LOADLIB_TRY_NATIVE #define WIN32_LOADER -#ifdef QTX +#ifdef CONFIG_QTX_CODECS #define PSEUDO_SCREEN_WIDTH /*640*/800 #define PSEUDO_SCREEN_HEIGHT /*480*/600 #endif @@ -555,7 +552,7 @@ static HMODULE WINAPI expGetDriverModuleHandle(DRVR* pdrv) #define MODULE_HANDLE_kernel32 ((HMODULE)0x120) #define MODULE_HANDLE_user32 ((HMODULE)0x121) -#ifdef QTX +#ifdef CONFIG_QTX_CODECS #define MODULE_HANDLE_wininet ((HMODULE)0x122) #define MODULE_HANDLE_ddraw ((HMODULE)0x123) #define MODULE_HANDLE_advapi32 ((HMODULE)0x124) @@ -571,7 +568,7 @@ static HMODULE WINAPI expGetModuleHandleA(const char* name) WINE_MODREF* wm; HMODULE result; if(!name) -#ifdef QTX +#ifdef CONFIG_QTX_CODECS result=1; #else result=0; @@ -587,7 +584,7 @@ static HMODULE WINAPI expGetModuleHandleA(const char* name) { if(name && (strcasecmp(name, "kernel32")==0 || !strcasecmp(name, "kernel32.dll"))) result=MODULE_HANDLE_kernel32; -#ifdef QTX +#ifdef CONFIG_QTX_CODECS if(name && strcasecmp(name, "user32")==0) result=MODULE_HANDLE_user32; #endif @@ -847,7 +844,7 @@ static void* WINAPI expWaitForSingleObject(void* object, int duration) return (void *)ret; } -#ifdef QTX +#ifdef CONFIG_QTX_CODECS static void* WINAPI expWaitForMultipleObjects(int count, const void** objects, int WaitAll, int duration) { @@ -887,7 +884,7 @@ static HANDLE WINAPI expCreateMutexA(void *pSecAttr, else dbgprintf("CreateMutexA(0x%x, %d, NULL) => 0x%x\n", pSecAttr, bInitialOwner, mlist); -#ifndef QTX +#ifndef CONFIG_QTX_CODECS /* 10l to QTX, if CreateMutex returns a real mutex, WaitForSingleObject waits for ever, else it works ;) */ return mlist; @@ -1444,7 +1441,7 @@ static int WINAPI expGetCurrentProcess(void) return getpid(); } -#ifdef QTX +#ifdef CONFIG_QTX_CODECS // this version is required for Quicktime codecs (.qtx/.qts) to work. // (they assume some pointers at FS: segment) @@ -2208,7 +2205,7 @@ static int WINAPI expGetStdHandle(int z) return z+0x1234; } -#ifdef QTX +#ifdef CONFIG_QTX_CODECS #define FILE_HANDLE_quicktimeqts ((HANDLE)0x444) #define FILE_HANDLE_quicktimeqtx ((HANDLE)0x445) #endif @@ -2218,7 +2215,7 @@ static int WINAPI expGetFileType(int handle) dbgprintf("GetFileType(0x%x) => 0x3 = pipe\n", handle); return 0x3; } -#ifdef QTX +#ifdef CONFIG_QTX_CODECS static int WINAPI expGetFileAttributesA(char *filename) { dbgprintf("GetFileAttributesA(%s) => FILE_ATTR_NORMAL\n", filename); @@ -2334,7 +2331,7 @@ static int WINAPI expLoadLibraryA(char* name) // return MODULE_HANDLE_kernel32; return MODULE_HANDLE_user32; -#ifdef QTX +#ifdef CONFIG_QTX_CODECS if (strcasecmp(name, "wininet.dll") == 0 || strcasecmp(name, "wininet") == 0) return MODULE_HANDLE_wininet; if (strcasecmp(name, "ddraw.dll") == 0 || strcasecmp(name, "ddraw") == 0) @@ -2362,7 +2359,7 @@ static int WINAPI expLoadLibraryA(char* name) static int WINAPI expFreeLibrary(int module) { -#ifdef QTX +#ifdef CONFIG_QTX_CODECS int result=0; /* FIXME:XXX: qtx svq3 frees up qt.qts */ #else int result=FreeLibrary(module); @@ -2379,7 +2376,7 @@ 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 +#ifdef CONFIG_QTX_CODECS case MODULE_HANDLE_wininet: result=LookupExternalByName("wininet.dll", name); break; case MODULE_HANDLE_ddraw: @@ -2476,7 +2473,7 @@ static int WINAPI expCreateCompatibleDC(int hdc) static int WINAPI expGetDeviceCaps(int hdc, int unk) { dbgprintf("GetDeviceCaps(0x%x, %d) => 0\n", hdc, unk); -#ifdef QTX +#ifdef CONFIG_QTX_CODECS #define BITSPIXEL 12 #define PLANES 14 if (unk == BITSPIXEL) @@ -2509,7 +2506,7 @@ static void* WINAPI expGetWindowDC(int hdc) return 0; } -#ifdef QTX +#ifdef CONFIG_QTX_CODECS static int WINAPI expGetWindowRect(HWND win, RECT *r) { dbgprintf("GetWindowRect(0x%x, 0x%x) => 1\n", win, r); @@ -2963,7 +2960,7 @@ static int WINAPI expGetCursorPos(void *cursor) dbgprintf("GetCursorPos(0x%x) => 0x%x\n", cursor, cursor); return 1; } -#ifdef QTX +#ifdef CONFIG_QTX_CODECS static int show_cursor = 0; static int WINAPI expShowCursor(int show) { @@ -3001,7 +2998,7 @@ static int WINAPI expGetCPInfo(int cp,void *info) dbgprintf("GetCPInfo()\n"); return 0; } -#ifdef QTX +#ifdef CONFIG_QTX_CODECS #define SM_CXSCREEN 0 #define SM_CYSCREEN 1 #define SM_XVIRTUALSCREEN 76 @@ -3013,7 +3010,7 @@ static int WINAPI expGetCPInfo(int cp,void *info) static int WINAPI expGetSystemMetrics(int index) { dbgprintf("GetSystemMetrics(%d)\n", index); -#ifdef QTX +#ifdef CONFIG_QTX_CODECS switch(index) { case SM_XVIRTUALSCREEN: @@ -3340,7 +3337,7 @@ static DIR* qtx_dir=NULL; static WIN_BOOL WINAPI expFindNextFileA(HANDLE h,LPWIN32_FIND_DATAA lpfd) { -#ifdef QTX +#ifdef CONFIG_QTX_CODECS dbgprintf("FindNextFileA(0x%x, 0x%x) => 0\n", h, lpfd); if(h==FILE_HANDLE_quicktimeqtx){ struct dirent* d; @@ -3366,7 +3363,7 @@ static HANDLE WINAPI expFindFirstFileA(LPCSTR s, LPWIN32_FIND_DATAA lpfd) { dbgprintf("FindFirstFileA(0x%x='%s', 0x%x) => 0\n", s, s, lpfd); // printf("\n### FindFirstFileA('%s')...\n",s); -#ifdef QTX +#ifdef CONFIG_QTX_CODECS if(strstr(s, "quicktime\\*.QTX")){ dbgprintf("FindFirstFileA(0x%x='%s', 0x%x) => QTX\n", s, s, lpfd); dbgprintf("\n### Searching for QuickTime plugins (*.qtx) at %s...\n",def_path); @@ -3402,7 +3399,7 @@ static HANDLE WINAPI expFindFirstFileA(LPCSTR s, LPWIN32_FIND_DATAA lpfd) static WIN_BOOL WINAPI expFindClose(HANDLE h) { dbgprintf("FindClose(0x%x) => 0\n", h); -#ifdef QTX +#ifdef CONFIG_QTX_CODECS // if(h==FILE_HANDLE_quicktimeqtx && qtx_dir){ // closedir(qtx_dir); // qtx_dir=NULL; @@ -3424,7 +3421,7 @@ static UINT WINAPI expGetWindowsDirectoryA(LPSTR s,UINT c) dbgprintf("GetWindowsDirectoryA(0x%x, %d) => %d\n", s, c, result); return result; } -#ifdef QTX +#ifdef CONFIG_QTX_CODECS static UINT WINAPI expGetCurrentDirectoryA(UINT c, LPSTR s) { char curdir[]="c:\\"; @@ -3508,7 +3505,7 @@ static HANDLE WINAPI expCreateFileA(LPCSTR cs1,DWORD i1,DWORD i2, i2, p1, i3, i4, i5); if((!cs1) || (strlen(cs1)<2))return -1; -#ifdef QTX +#ifdef CONFIG_QTX_CODECS if(strstr(cs1, "QuickTime.qts")) { int result; @@ -3624,7 +3621,7 @@ static DWORD WINAPI expGetFullPathNameA dbgprintf("GetFullPathNameA('%s',%d,%p,%p)\n",lpFileName,nBufferLength, lpBuffer, lpFilePart); #if 0 -#ifdef QTX +#ifdef CONFIG_QTX_CODECS strcpy(lpFilePart, "Quick123.qts"); #else strcpy(lpFilePart, lpFileName); @@ -3688,7 +3685,7 @@ static DWORD WINAPI expSetFilePointer(HANDLE h, LONG val, LPLONG ext, DWORD whe default: return -1; } -#ifdef QTX +#ifdef CONFIG_QTX_CODECS if (val == 0 && ext != 0) val = val&(*ext); #endif @@ -3794,7 +3791,7 @@ static void WINAPI expInitCommonControls(void) return; } -#ifdef QTX +#ifdef CONFIG_QTX_CODECS /* needed by QuickTime.qts */ static HWND WINAPI expCreateUpDownControl (DWORD style, INT x, INT y, INT cx, INT cy, HWND parent, INT id, HINSTANCE inst, @@ -4453,7 +4450,7 @@ static MMRESULT WINAPI exptimeBeginPeriod(UINT wPeriod) return 0; } -#ifdef QTX +#ifdef CONFIG_QTX_CODECS static MMRESULT WINAPI exptimeEndPeriod(UINT wPeriod) { dbgprintf("timeEndPeriod(%u) !\n", wPeriod); @@ -4583,7 +4580,7 @@ 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); -#ifdef QTX +#ifdef CONFIG_QTX_CODECS if (type == MB_ICONHAND && !strlen(text) && !strlen(title)) return IDIGNORE; #endif @@ -4664,7 +4661,7 @@ static int WINAPI expUnregisterClassA(const char *className, HINSTANCE hInstance return 0; } -#ifdef QTX +#ifdef CONFIG_QTX_CODECS /* should be fixed bcs it's not fully strlen equivalent */ static int expSysStringByteLen(void *str) { @@ -4953,7 +4950,7 @@ struct exports exp_kernel32[]= FF(SetEvent, -1) FF(ResetEvent, -1) FF(WaitForSingleObject, -1) -#ifdef QTX +#ifdef CONFIG_QTX_CODECS FF(WaitForMultipleObjects, -1) FF(ExitThread, -1) FF(CreateMutexA,-1) @@ -5014,7 +5011,7 @@ struct exports exp_kernel32[]= FF(GetStartupInfoA, -1) FF(GetStdHandle, -1) FF(GetFileType, -1) -#ifdef QTX +#ifdef CONFIG_QTX_CODECS FF(GetFileAttributesA, -1) #endif FF(SetHandleCount, -1) @@ -5061,7 +5058,7 @@ struct exports exp_kernel32[]= FF(CreateFileA,-1) FF(GetSystemDirectoryA,-1) FF(GetWindowsDirectoryA,-1) -#ifdef QTX +#ifdef CONFIG_QTX_CODECS FF(GetCurrentDirectoryA,-1) FF(SetCurrentDirectoryA,-1) FF(CreateDirectoryA,-1) @@ -5178,7 +5175,7 @@ struct exports exp_winmm[]={ FF(OpenDriver, -1) FF(timeGetDevCaps, -1) FF(timeBeginPeriod, -1) -#ifdef QTX +#ifdef CONFIG_QTX_CODECS FF(timeEndPeriod, -1) FF(waveOutGetNumDevs, -1) #endif @@ -5197,7 +5194,7 @@ struct exports exp_user32[]={ FF(LoadCursorA,-1) FF(SetCursor,-1) FF(GetCursorPos,-1) -#ifdef QTX +#ifdef CONFIG_QTX_CODECS FF(ShowCursor,-1) #endif FF(RegisterWindowMessageA,-1) @@ -5209,7 +5206,7 @@ struct exports exp_user32[]={ FF(MessageBoxA, -1) FF(RegisterClassA, -1) FF(UnregisterClassA, -1) -#ifdef QTX +#ifdef CONFIG_QTX_CODECS FF(GetWindowRect, -1) FF(MonitorFromWindow, -1) FF(MonitorFromRect, -1) @@ -5253,7 +5250,7 @@ struct exports exp_gdi32[]={ FF(DeleteObject, -1) FF(GetDeviceCaps, -1) FF(GetSystemPaletteEntries, -1) -#ifdef QTX +#ifdef CONFIG_QTX_CODECS FF(CreatePalette, -1) FF(GetObjectA, -1) FF(CreateRectRgn, -1) @@ -5282,7 +5279,7 @@ struct exports exp_crtdll[]={ struct exports exp_comctl32[]={ FF(StringFromGUID2, -1) FF(InitCommonControls, 17) -#ifdef QTX +#ifdef CONFIG_QTX_CODECS FF(CreateUpDownControl, 16) #endif }; @@ -5303,7 +5300,7 @@ struct exports exp_oleaut32[]={ FF(SysAllocStringLen, 4) FF(SysFreeString, 6) FF(VariantInit, 8) -#ifdef QTX +#ifdef CONFIG_QTX_CODECS FF(SysStringByteLen, 149) #endif }; @@ -5343,7 +5340,7 @@ struct exports exp_pncrt[]={ }; #endif -#ifdef QTX +#ifdef CONFIG_QTX_CODECS struct exports exp_ddraw[]={ FF(DirectDrawCreate, -1) }; @@ -5398,7 +5395,7 @@ struct libs libraries[]={ #ifdef REALPLAYER LL(pncrt) #endif -#ifdef QTX +#ifdef CONFIG_QTX_CODECS LL(ddraw) #endif LL(comdlg32) -- cgit v1.2.3 From f34f239ccef8f7f74c389490c7dd5a1078a3e9d4 Mon Sep 17 00:00:00 2001 From: diego Date: Fri, 12 Feb 2010 14:25:25 +0000 Subject: Explain WIN32_LOADER definition hack. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@30545 b3059339-0415-0410-9bf9-f77b7e298cf2 --- loader/win32.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'loader/win32.c') diff --git a/loader/win32.c b/loader/win32.c index b09cb5a716..812815e699 100644 --- a/loader/win32.c +++ b/loader/win32.c @@ -21,6 +21,9 @@ for DLL to know too much about its environment. #define REALPLAYER //#define LOADLIB_TRY_NATIVE + +/* Hack to make sure the correct function declaration in com.h is used when + * this file is built for the test applications with WIN32_LOADER disabled. */ #define WIN32_LOADER #ifdef CONFIG_QTX_CODECS -- cgit v1.2.3