2002-09-13 19:43:17 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#ifdef HAVE_MALLOC_H
|
|
|
|
#include <malloc.h>
|
2001-07-12 15:27:48 +00:00
|
|
|
#endif
|
2001-02-24 20:28:24 +00:00
|
|
|
#include <stdlib.h>
|
2001-07-12 15:27:48 +00:00
|
|
|
#ifdef __FreeBSD__
|
|
|
|
#include <sys/time.h>
|
2001-02-24 20:28:24 +00:00
|
|
|
#endif
|
|
|
|
|
2001-10-04 00:24:05 +00:00
|
|
|
#include "win32.h"
|
|
|
|
#include "wine/driver.h"
|
|
|
|
#include "wine/pe_image.h"
|
|
|
|
#include "wine/winreg.h"
|
|
|
|
#include "wine/vfw.h"
|
|
|
|
#include "registry.h"
|
|
|
|
#include "ldt_keeper.h"
|
2001-07-12 15:27:48 +00:00
|
|
|
#include "driver.h"
|
2002-12-14 17:56:35 +00:00
|
|
|
#include "ext.h"
|
2001-07-12 15:27:48 +00:00
|
|
|
|
2002-09-13 19:43:17 +00:00
|
|
|
extern char* def_path;
|
2001-07-12 15:27:48 +00:00
|
|
|
|
|
|
|
#if 1
|
2002-09-13 19:43:17 +00:00
|
|
|
|
2001-07-12 15:27:48 +00:00
|
|
|
/*
|
|
|
|
* STORE_ALL/REST_ALL seems like an attempt to workaround problems due to
|
|
|
|
* WINAPI/no-WINAPI bustage.
|
|
|
|
*
|
2002-09-13 19:43:17 +00:00
|
|
|
* There should be no need for the STORE_ALL/REST_ALL hack once all
|
2001-07-12 15:27:48 +00:00
|
|
|
* 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.
|
|
|
|
*/
|
2002-09-13 19:43:17 +00:00
|
|
|
|
|
|
|
#define STORE_ALL
|
|
|
|
#define REST_ALL
|
2001-07-12 15:27:48 +00:00
|
|
|
#else
|
2002-09-13 19:43:17 +00:00
|
|
|
// this asm code is no longer needed
|
2001-02-24 20:28:24 +00:00
|
|
|
#define STORE_ALL \
|
2002-09-13 19:43:17 +00:00
|
|
|
__asm__ __volatile__ ( \
|
2001-02-24 20:28:24 +00:00
|
|
|
"push %%ebx\n\t" \
|
|
|
|
"push %%ecx\n\t" \
|
|
|
|
"push %%edx\n\t" \
|
|
|
|
"push %%esi\n\t" \
|
|
|
|
"push %%edi\n\t"::)
|
|
|
|
|
|
|
|
#define REST_ALL \
|
2002-09-13 19:43:17 +00:00
|
|
|
__asm__ __volatile__ ( \
|
2001-02-24 20:28:24 +00:00
|
|
|
"pop %%edi\n\t" \
|
|
|
|
"pop %%esi\n\t" \
|
|
|
|
"pop %%edx\n\t" \
|
|
|
|
"pop %%ecx\n\t" \
|
|
|
|
"pop %%ebx\n\t"::)
|
2001-07-12 15:27:48 +00:00
|
|
|
#endif
|
2001-02-24 20:28:24 +00:00
|
|
|
|
2002-09-13 19:43:17 +00:00
|
|
|
static int needs_free=0;
|
|
|
|
void SetCodecPath(const char* path)
|
|
|
|
{
|
|
|
|
if(needs_free)free(def_path);
|
|
|
|
if(path==0)
|
|
|
|
{
|
|
|
|
def_path=WIN32_PATH;
|
|
|
|
needs_free=0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
def_path = (char*) malloc(strlen(path)+1);
|
|
|
|
strcpy(def_path, path);
|
|
|
|
needs_free=1;
|
|
|
|
}
|
2001-02-24 20:28:24 +00:00
|
|
|
|
|
|
|
static DWORD dwDrvID = 0;
|
|
|
|
|
2002-09-13 19:43:17 +00:00
|
|
|
LRESULT WINAPI SendDriverMessage(HDRVR hDriver, UINT message,
|
|
|
|
LPARAM lParam1, LPARAM lParam2)
|
2001-02-24 20:28:24 +00:00
|
|
|
{
|
|
|
|
DRVR* module=(DRVR*)hDriver;
|
|
|
|
int result;
|
2002-09-13 19:43:17 +00:00
|
|
|
#ifndef __svr4__
|
|
|
|
char qw[300];
|
|
|
|
#endif
|
|
|
|
#ifdef DETAILED_OUT
|
2001-02-24 20:28:24 +00:00
|
|
|
printf("SendDriverMessage: driver %X, message %X, arg1 %X, arg2 %X\n", hDriver, message, lParam1, lParam2);
|
|
|
|
#endif
|
2002-09-13 19:43:17 +00:00
|
|
|
if (!module || !module->hDriverModule || !module->DriverProc) return -1;
|
|
|
|
#ifndef __svr4__
|
|
|
|
__asm__ __volatile__ ("fsave (%0)\n\t": :"r"(&qw));
|
|
|
|
#endif
|
|
|
|
|
|
|
|
Setup_FS_Segment();
|
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
STORE_ALL;
|
2002-09-13 19:43:17 +00:00
|
|
|
result=module->DriverProc(module->dwDriverID, hDriver, message, lParam1, lParam2);
|
2001-02-24 20:28:24 +00:00
|
|
|
REST_ALL;
|
2002-09-13 19:43:17 +00:00
|
|
|
|
|
|
|
#ifndef __svr4__
|
|
|
|
__asm__ __volatile__ ("frstor (%0)\n\t": :"r"(&qw));
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef DETAILED_OUT
|
2001-02-24 20:28:24 +00:00
|
|
|
printf("\t\tResult: %X\n", result);
|
2002-09-13 19:43:17 +00:00
|
|
|
#endif
|
2001-02-24 20:28:24 +00:00
|
|
|
return result;
|
2002-09-13 19:43:17 +00:00
|
|
|
}
|
2001-02-24 20:28:24 +00:00
|
|
|
|
2002-09-13 19:43:17 +00:00
|
|
|
void DrvClose(HDRVR hDriver)
|
2001-02-24 20:28:24 +00:00
|
|
|
{
|
2002-09-13 19:43:17 +00:00
|
|
|
if (hDriver)
|
2001-02-24 20:28:24 +00:00
|
|
|
{
|
2002-09-13 19:43:17 +00:00
|
|
|
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);
|
2001-02-24 20:28:24 +00:00
|
|
|
}
|
2002-09-13 19:43:17 +00:00
|
|
|
CodecRelease();
|
2001-02-24 20:28:24 +00:00
|
|
|
}
|
|
|
|
|
2002-09-13 19:43:17 +00:00
|
|
|
//DrvOpen(LPCSTR lpszDriverName, LPCSTR lpszSectionName, LPARAM lParam2)
|
|
|
|
HDRVR DrvOpen(LPARAM lParam2)
|
2001-02-24 20:28:24 +00:00
|
|
|
{
|
2002-09-13 19:43:17 +00:00
|
|
|
NPDRVR hDriver;
|
2001-02-24 20:28:24 +00:00
|
|
|
int i;
|
2002-09-13 19:43:17 +00:00
|
|
|
char unknown[0x124];
|
|
|
|
const char* filename = (const char*) ((ICOPEN*) lParam2)->pV1Reserved;
|
2001-02-24 20:28:24 +00:00
|
|
|
|
2002-09-13 19:43:17 +00:00
|
|
|
#ifdef MPLAYER
|
2001-03-28 21:44:26 +00:00
|
|
|
Setup_LDT_Keeper();
|
2002-09-13 19:43:17 +00:00
|
|
|
printf("Loading codec DLL: '%s'\n",filename);
|
|
|
|
#endif
|
2001-03-28 21:44:26 +00:00
|
|
|
|
2002-09-13 19:43:17 +00:00
|
|
|
hDriver = (NPDRVR) malloc(sizeof(DRVR));
|
|
|
|
if (!hDriver)
|
2001-02-24 20:28:24 +00:00
|
|
|
return ((HDRVR) 0);
|
2002-09-13 19:43:17 +00:00
|
|
|
memset((void*)hDriver, 0, sizeof(DRVR));
|
2001-02-24 20:28:24 +00:00
|
|
|
|
2002-09-13 19:43:17 +00:00
|
|
|
CodecAlloc();
|
|
|
|
Setup_FS_Segment();
|
2001-02-24 20:28:24 +00:00
|
|
|
|
2002-09-13 19:43:17 +00:00
|
|
|
hDriver->hDriverModule = LoadLibraryA(filename);
|
|
|
|
if (!hDriver->hDriverModule)
|
2001-02-24 20:28:24 +00:00
|
|
|
{
|
2002-09-13 19:43:17 +00:00
|
|
|
printf("Can't open library %s\n", filename);
|
|
|
|
DrvClose((HDRVR)hDriver);
|
|
|
|
return ((HDRVR) 0);
|
2001-02-24 20:28:24 +00:00
|
|
|
}
|
|
|
|
|
2002-09-13 19:43:17 +00:00
|
|
|
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);
|
2001-02-24 20:28:24 +00:00
|
|
|
}
|
|
|
|
|
2002-09-13 19:43:17 +00:00
|
|
|
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
|
2001-03-28 21:44:26 +00:00
|
|
|
|
2002-09-13 19:43:17 +00:00
|
|
|
// open driver and remmeber proper DriverID
|
|
|
|
hDriver->dwDriverID = SendDriverMessage((HDRVR)hDriver, DRV_OPEN, (LPARAM) unknown, lParam2);
|
|
|
|
TRACE("DRV_OPEN Ok!(%X)\n", hDriver->dwDriverID);
|
2001-02-24 20:28:24 +00:00
|
|
|
|
2002-09-13 19:43:17 +00:00
|
|
|
printf("Loaded DLL driver %s\n", filename);
|
|
|
|
return (HDRVR)hDriver;
|
2001-02-24 20:28:24 +00:00
|
|
|
}
|