Mercurial > mplayer.hg
annotate loader/driver.c @ 22809:09f97d0161ba
Handle X-QT extradata in a slightly more correct way
| author | cehoyos |
|---|---|
| date | Mon, 26 Mar 2007 09:35:03 +0000 |
| parents | a2e02e6b6379 |
| children | c45f009ce3a7 |
| rev | line source |
|---|---|
|
15166
f5537cc95b02
Mark modified imported files as such to comply with GPL ?2a.
diego
parents:
12655
diff
changeset
|
1 /* |
| 18783 | 2 * Modified for use with MPlayer, detailed changelog at |
| 3 * http://svn.mplayerhq.hu/mplayer/trunk/ | |
|
15166
f5537cc95b02
Mark modified imported files as such to comply with GPL ?2a.
diego
parents:
12655
diff
changeset
|
4 * $Id$ |
|
f5537cc95b02
Mark modified imported files as such to comply with GPL ?2a.
diego
parents:
12655
diff
changeset
|
5 */ |
|
f5537cc95b02
Mark modified imported files as such to comply with GPL ?2a.
diego
parents:
12655
diff
changeset
|
6 |
| 7386 | 7 #include "config.h" |
|
21261
a2e02e6b6379
Rename config.h --> debug.h and include config.h explicitly.
diego
parents:
18783
diff
changeset
|
8 #include "debug.h" |
| 7386 | 9 |
| 1 | 10 #include <stdio.h> |
| 11 #ifdef HAVE_MALLOC_H | |
| 12 #include <malloc.h> | |
|
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
340
diff
changeset
|
13 #endif |
| 1 | 14 #include <stdlib.h> |
|
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
340
diff
changeset
|
15 #ifdef __FreeBSD__ |
|
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
340
diff
changeset
|
16 #include <sys/time.h> |
| 1 | 17 #endif |
| 18 | |
|
2068
3189c317dfc1
using ldt_keeper instead of setup_fs, includes changed
arpi
parents:
1307
diff
changeset
|
19 #include "win32.h" |
|
3189c317dfc1
using ldt_keeper instead of setup_fs, includes changed
arpi
parents:
1307
diff
changeset
|
20 #include "wine/driver.h" |
|
3189c317dfc1
using ldt_keeper instead of setup_fs, includes changed
arpi
parents:
1307
diff
changeset
|
21 #include "wine/pe_image.h" |
|
3189c317dfc1
using ldt_keeper instead of setup_fs, includes changed
arpi
parents:
1307
diff
changeset
|
22 #include "wine/winreg.h" |
|
3189c317dfc1
using ldt_keeper instead of setup_fs, includes changed
arpi
parents:
1307
diff
changeset
|
23 #include "wine/vfw.h" |
|
3189c317dfc1
using ldt_keeper instead of setup_fs, includes changed
arpi
parents:
1307
diff
changeset
|
24 #include "registry.h" |
|
9967
b0d1b415320c
cygwin support patch by Sascha Sommer and some fixes by me
alex
parents:
8451
diff
changeset
|
25 #ifdef WIN32_LOADER |
|
2068
3189c317dfc1
using ldt_keeper instead of setup_fs, includes changed
arpi
parents:
1307
diff
changeset
|
26 #include "ldt_keeper.h" |
|
9967
b0d1b415320c
cygwin support patch by Sascha Sommer and some fixes by me
alex
parents:
8451
diff
changeset
|
27 #endif |
|
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
340
diff
changeset
|
28 #include "driver.h" |
| 9978 | 29 #ifndef __MINGW32__ |
| 8451 | 30 #include "ext.h" |
| 9978 | 31 #endif |
| 1 | 32 |
|
9967
b0d1b415320c
cygwin support patch by Sascha Sommer and some fixes by me
alex
parents:
8451
diff
changeset
|
33 #ifndef WIN32_LOADER |
|
b0d1b415320c
cygwin support patch by Sascha Sommer and some fixes by me
alex
parents:
8451
diff
changeset
|
34 char* def_path=WIN32_PATH; |
|
b0d1b415320c
cygwin support patch by Sascha Sommer and some fixes by me
alex
parents:
8451
diff
changeset
|
35 #else |
| 7386 | 36 extern char* def_path; |
|
9967
b0d1b415320c
cygwin support patch by Sascha Sommer and some fixes by me
alex
parents:
8451
diff
changeset
|
37 #endif |
| 1 | 38 |
|
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
340
diff
changeset
|
39 #if 1 |
| 7386 | 40 |
|
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
340
diff
changeset
|
41 /* |
|
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
340
diff
changeset
|
42 * STORE_ALL/REST_ALL seems like an attempt to workaround problems due to |
|
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
340
diff
changeset
|
43 * WINAPI/no-WINAPI bustage. |
|
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
340
diff
changeset
|
44 * |
| 7386 | 45 * There should be no need for the STORE_ALL/REST_ALL hack once all |
|
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
340
diff
changeset
|
46 * function definitions agree with their prototypes (WINAPI-wise) and |
|
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
340
diff
changeset
|
47 * we make sure, that we do not call these functions without a proper |
|
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
340
diff
changeset
|
48 * prototype in scope. |
|
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
340
diff
changeset
|
49 */ |
| 7386 | 50 |
| 51 #define STORE_ALL | |
| 52 #define REST_ALL | |
|
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
340
diff
changeset
|
53 #else |
| 7386 | 54 // this asm code is no longer needed |
| 1 | 55 #define STORE_ALL \ |
| 7386 | 56 __asm__ __volatile__ ( \ |
| 1 | 57 "push %%ebx\n\t" \ |
| 58 "push %%ecx\n\t" \ | |
| 59 "push %%edx\n\t" \ | |
| 60 "push %%esi\n\t" \ | |
| 61 "push %%edi\n\t"::) | |
| 62 | |
| 63 #define REST_ALL \ | |
| 7386 | 64 __asm__ __volatile__ ( \ |
| 1 | 65 "pop %%edi\n\t" \ |
| 66 "pop %%esi\n\t" \ | |
| 67 "pop %%edx\n\t" \ | |
| 68 "pop %%ecx\n\t" \ | |
| 69 "pop %%ebx\n\t"::) | |
|
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
340
diff
changeset
|
70 #endif |
| 1 | 71 |
| 7386 | 72 static int needs_free=0; |
| 73 void SetCodecPath(const char* path) | |
| 74 { | |
| 75 if(needs_free)free(def_path); | |
| 76 if(path==0) | |
| 77 { | |
| 78 def_path=WIN32_PATH; | |
| 79 needs_free=0; | |
| 80 return; | |
| 81 } | |
| 82 def_path = (char*) malloc(strlen(path)+1); | |
| 83 strcpy(def_path, path); | |
| 84 needs_free=1; | |
| 85 } | |
| 1 | 86 |
| 87 static DWORD dwDrvID = 0; | |
| 88 | |
| 7386 | 89 LRESULT WINAPI SendDriverMessage(HDRVR hDriver, UINT message, |
| 90 LPARAM lParam1, LPARAM lParam2) | |
| 1 | 91 { |
| 92 DRVR* module=(DRVR*)hDriver; | |
| 93 int result; | |
| 7386 | 94 #ifndef __svr4__ |
| 95 char qw[300]; | |
| 96 #endif | |
| 97 #ifdef DETAILED_OUT | |
| 1 | 98 printf("SendDriverMessage: driver %X, message %X, arg1 %X, arg2 %X\n", hDriver, message, lParam1, lParam2); |
| 99 #endif | |
| 7386 | 100 if (!module || !module->hDriverModule || !module->DriverProc) return -1; |
| 101 #ifndef __svr4__ | |
| 102 __asm__ __volatile__ ("fsave (%0)\n\t": :"r"(&qw)); | |
| 103 #endif | |
| 104 | |
|
9967
b0d1b415320c
cygwin support patch by Sascha Sommer and some fixes by me
alex
parents:
8451
diff
changeset
|
105 #ifdef WIN32_LOADER |
| 7386 | 106 Setup_FS_Segment(); |
|
9967
b0d1b415320c
cygwin support patch by Sascha Sommer and some fixes by me
alex
parents:
8451
diff
changeset
|
107 #endif |
| 1 | 108 |
| 7386 | 109 STORE_ALL; |
| 110 result=module->DriverProc(module->dwDriverID, hDriver, message, lParam1, lParam2); | |
| 111 REST_ALL; | |
| 112 | |
| 113 #ifndef __svr4__ | |
| 114 __asm__ __volatile__ ("frstor (%0)\n\t": :"r"(&qw)); | |
| 115 #endif | |
| 116 | |
| 117 #ifdef DETAILED_OUT | |
| 118 printf("\t\tResult: %X\n", result); | |
| 119 #endif | |
| 120 return result; | |
| 1 | 121 } |
| 122 | |
| 7386 | 123 void DrvClose(HDRVR hDriver) |
| 1 | 124 { |
| 7386 | 125 if (hDriver) |
| 126 { | |
| 127 DRVR* d = (DRVR*)hDriver; | |
| 128 if (d->hDriverModule) | |
| 129 { | |
|
9967
b0d1b415320c
cygwin support patch by Sascha Sommer and some fixes by me
alex
parents:
8451
diff
changeset
|
130 #ifdef WIN32_LOADER |
| 7386 | 131 Setup_FS_Segment(); |
|
9967
b0d1b415320c
cygwin support patch by Sascha Sommer and some fixes by me
alex
parents:
8451
diff
changeset
|
132 #endif |
| 7386 | 133 if (d->DriverProc) |
| 134 { | |
| 135 SendDriverMessage(hDriver, DRV_CLOSE, 0, 0); | |
| 136 d->dwDriverID = 0; | |
| 137 SendDriverMessage(hDriver, DRV_FREE, 0, 0); | |
| 138 } | |
| 139 FreeLibrary(d->hDriverModule); | |
| 140 } | |
| 141 free(d); | |
| 1 | 142 } |
|
9967
b0d1b415320c
cygwin support patch by Sascha Sommer and some fixes by me
alex
parents:
8451
diff
changeset
|
143 #ifdef WIN32_LOADER |
| 7386 | 144 CodecRelease(); |
|
9967
b0d1b415320c
cygwin support patch by Sascha Sommer and some fixes by me
alex
parents:
8451
diff
changeset
|
145 #endif |
| 1 | 146 } |
| 147 | |
| 7386 | 148 //DrvOpen(LPCSTR lpszDriverName, LPCSTR lpszSectionName, LPARAM lParam2) |
| 149 HDRVR DrvOpen(LPARAM lParam2) | |
| 1 | 150 { |
| 7386 | 151 NPDRVR hDriver; |
| 152 int i; | |
| 153 char unknown[0x124]; | |
| 154 const char* filename = (const char*) ((ICOPEN*) lParam2)->pV1Reserved; | |
| 1 | 155 |
| 7386 | 156 #ifdef MPLAYER |
|
9967
b0d1b415320c
cygwin support patch by Sascha Sommer and some fixes by me
alex
parents:
8451
diff
changeset
|
157 #ifdef WIN32_LOADER |
| 236 | 158 Setup_LDT_Keeper(); |
|
9967
b0d1b415320c
cygwin support patch by Sascha Sommer and some fixes by me
alex
parents:
8451
diff
changeset
|
159 #endif |
| 7386 | 160 printf("Loading codec DLL: '%s'\n",filename); |
| 161 #endif | |
| 236 | 162 |
| 7386 | 163 hDriver = (NPDRVR) malloc(sizeof(DRVR)); |
| 164 if (!hDriver) | |
| 1 | 165 return ((HDRVR) 0); |
| 7386 | 166 memset((void*)hDriver, 0, sizeof(DRVR)); |
| 1 | 167 |
|
9967
b0d1b415320c
cygwin support patch by Sascha Sommer and some fixes by me
alex
parents:
8451
diff
changeset
|
168 #ifdef WIN32_LOADER |
| 7386 | 169 CodecAlloc(); |
| 170 Setup_FS_Segment(); | |
|
9967
b0d1b415320c
cygwin support patch by Sascha Sommer and some fixes by me
alex
parents:
8451
diff
changeset
|
171 #endif |
| 7386 | 172 |
| 173 hDriver->hDriverModule = LoadLibraryA(filename); | |
| 174 if (!hDriver->hDriverModule) | |
| 175 { | |
| 176 printf("Can't open library %s\n", filename); | |
| 177 DrvClose((HDRVR)hDriver); | |
| 178 return ((HDRVR) 0); | |
| 1 | 179 } |
| 180 | |
| 7386 | 181 hDriver->DriverProc = (DRIVERPROC) GetProcAddress(hDriver->hDriverModule, |
| 182 "DriverProc"); | |
| 183 if (!hDriver->DriverProc) | |
| 1 | 184 { |
| 7386 | 185 printf("Library %s is not a valid VfW/ACM codec\n", filename); |
| 186 DrvClose((HDRVR)hDriver); | |
| 187 return ((HDRVR) 0); | |
| 1 | 188 } |
| 189 | |
| 7386 | 190 TRACE("DriverProc == %X\n", hDriver->DriverProc); |
| 191 SendDriverMessage((HDRVR)hDriver, DRV_LOAD, 0, 0); | |
| 192 TRACE("DRV_LOAD Ok!\n"); | |
| 193 SendDriverMessage((HDRVR)hDriver, DRV_ENABLE, 0, 0); | |
| 194 TRACE("DRV_ENABLE Ok!\n"); | |
| 195 hDriver->dwDriverID = ++dwDrvID; // generate new id | |
| 1 | 196 |
| 7386 | 197 // open driver and remmeber proper DriverID |
| 198 hDriver->dwDriverID = SendDriverMessage((HDRVR)hDriver, DRV_OPEN, (LPARAM) unknown, lParam2); | |
| 199 TRACE("DRV_OPEN Ok!(%X)\n", hDriver->dwDriverID); | |
| 1 | 200 |
| 12655 | 201 printf("Loaded DLL driver %s at %x\n", filename, hDriver->hDriverModule); |
| 7386 | 202 return (HDRVR)hDriver; |
| 1 | 203 } |
