2 * Modified for use with MPlayer, detailed changelog at
3 * http://svn.mplayerhq.hu/mplayer/trunk/
16 #include "wine/driver.h"
17 #include "wine/pe_image.h"
18 #include "wine/winreg.h"
22 #include "ldt_keeper.h"
33 * STORE_ALL/REST_ALL seems like an attempt to workaround problems due to
34 * WINAPI/no-WINAPI bustage.
36 * There should be no need for the STORE_ALL/REST_ALL hack once all
37 * function definitions agree with their prototypes (WINAPI-wise) and
38 * we make sure, that we do not call these functions without a proper
45 // this asm code is no longer needed
63 static DWORD dwDrvID
= 0;
65 LRESULT WINAPI
SendDriverMessage(HDRVR hDriver
, UINT message
,
66 LPARAM lParam1
, LPARAM lParam2
)
68 DRVR
* module
=(DRVR
*)hDriver
;
74 printf("SendDriverMessage: driver %X, message %X, arg1 %X, arg2 %X\n", hDriver
, message
, lParam1
, lParam2
);
76 if (!module
|| !module
->hDriverModule
|| !module
->DriverProc
) return -1;
78 __asm__
volatile ("fsave (%0)\n\t": :"r"(&qw
));
86 result
=module
->DriverProc(module
->dwDriverID
, hDriver
, message
, lParam1
, lParam2
);
90 __asm__
volatile ("frstor (%0)\n\t": :"r"(&qw
));
94 printf("\t\tResult: %X\n", result
);
99 void DrvClose(HDRVR hDriver
)
103 DRVR
* d
= (DRVR
*)hDriver
;
104 if (d
->hDriverModule
)
111 SendDriverMessage(hDriver
, DRV_CLOSE
, 0, 0);
113 SendDriverMessage(hDriver
, DRV_FREE
, 0, 0);
115 FreeLibrary(d
->hDriverModule
);
124 //DrvOpen(LPCSTR lpszDriverName, LPCSTR lpszSectionName, LPARAM lParam2)
125 HDRVR
DrvOpen(LPARAM lParam2
)
129 const char* filename
= (const char*) ((ICOPEN
*) lParam2
)->pV1Reserved
;
134 printf("Loading codec DLL: '%s'\n",filename
);
136 hDriver
= malloc(sizeof(DRVR
));
139 memset((void*)hDriver
, 0, sizeof(DRVR
));
146 hDriver
->hDriverModule
= LoadLibraryA(filename
);
147 if (!hDriver
->hDriverModule
)
149 printf("Can't open library %s\n", filename
);
150 DrvClose((HDRVR
)hDriver
);
154 hDriver
->DriverProc
= (DRIVERPROC
) GetProcAddress(hDriver
->hDriverModule
,
156 if (!hDriver
->DriverProc
)
158 printf("Library %s is not a valid VfW/ACM codec\n", filename
);
159 DrvClose((HDRVR
)hDriver
);
163 TRACE("DriverProc == %X\n", hDriver
->DriverProc
);
164 SendDriverMessage((HDRVR
)hDriver
, DRV_LOAD
, 0, 0);
165 TRACE("DRV_LOAD Ok!\n");
166 SendDriverMessage((HDRVR
)hDriver
, DRV_ENABLE
, 0, 0);
167 TRACE("DRV_ENABLE Ok!\n");
168 hDriver
->dwDriverID
= ++dwDrvID
; // generate new id
170 // open driver and remmeber proper DriverID
171 hDriver
->dwDriverID
= SendDriverMessage((HDRVR
)hDriver
, DRV_OPEN
, (LPARAM
) unknown
, lParam2
);
172 TRACE("DRV_OPEN Ok!(%X)\n", hDriver
->dwDriverID
);
174 printf("Loaded DLL driver %s at %x\n", filename
, hDriver
->hDriverModule
);
175 return (HDRVR
)hDriver
;