| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
#include "config.h" |
|---|
| 31 |
|
|---|
| 32 |
#include <stdio.h> |
|---|
| 33 |
#ifdef HAVE_MALLOC_H |
|---|
| 34 |
#include <malloc.h> |
|---|
| 35 |
#endif |
|---|
| 36 |
#include <stdlib.h> |
|---|
| 37 |
#ifdef __FreeBSD__ |
|---|
| 38 |
#include <sys/time.h> |
|---|
| 39 |
#endif |
|---|
| 40 |
|
|---|
| 41 |
#include "win32.h" |
|---|
| 42 |
#include "wine/driver.h" |
|---|
| 43 |
#include "wine/pe_image.h" |
|---|
| 44 |
#include "wine/winreg.h" |
|---|
| 45 |
#include "wine/vfw.h" |
|---|
| 46 |
#include "registry.h" |
|---|
| 47 |
#ifdef WIN32_LOADER |
|---|
| 48 |
#include "ldt_keeper.h" |
|---|
| 49 |
#endif |
|---|
| 50 |
#include "driver.h" |
|---|
| 51 |
#ifndef __MINGW32__ |
|---|
| 52 |
#include "ext.h" |
|---|
| 53 |
#endif |
|---|
| 54 |
|
|---|
| 55 |
#ifndef WIN32_LOADER |
|---|
| 56 |
char* def_path=WIN32_PATH; |
|---|
| 57 |
#else |
|---|
| 58 |
extern char* def_path; |
|---|
| 59 |
#endif |
|---|
| 60 |
|
|---|
| 61 |
#if 1 |
|---|
| 62 |
|
|---|
| 63 |
|
|---|
| 64 |
|
|---|
| 65 |
|
|---|
| 66 |
|
|---|
| 67 |
|
|---|
| 68 |
|
|---|
| 69 |
|
|---|
| 70 |
|
|---|
| 71 |
|
|---|
| 72 |
|
|---|
| 73 |
#define STORE_ALL |
|---|
| 74 |
#define REST_ALL |
|---|
| 75 |
#else |
|---|
| 76 |
|
|---|
| 77 |
#define STORE_ALL \ |
|---|
| 78 |
__asm__ __volatile__ ( \ |
|---|
| 79 |
"push %%ebx\n\t" \ |
|---|
| 80 |
"push %%ecx\n\t" \ |
|---|
| 81 |
"push %%edx\n\t" \ |
|---|
| 82 |
"push %%esi\n\t" \ |
|---|
| 83 |
"push %%edi\n\t"::) |
|---|
| 84 |
|
|---|
| 85 |
#define REST_ALL \ |
|---|
| 86 |
__asm__ __volatile__ ( \ |
|---|
| 87 |
"pop %%edi\n\t" \ |
|---|
| 88 |
"pop %%esi\n\t" \ |
|---|
| 89 |
"pop %%edx\n\t" \ |
|---|
| 90 |
"pop %%ecx\n\t" \ |
|---|
| 91 |
"pop %%ebx\n\t"::) |
|---|
| 92 |
#endif |
|---|
| 93 |
|
|---|
| 94 |
static int needs_free=0; |
|---|
| 95 |
void SetCodecPath(const char* path) |
|---|
| 96 |
{ |
|---|
| 97 |
if(needs_free)free(def_path); |
|---|
| 98 |
if(path==0) |
|---|
| 99 |
{ |
|---|
| 100 |
def_path=WIN32_PATH; |
|---|
| 101 |
needs_free=0; |
|---|
| 102 |
return; |
|---|
| 103 |
} |
|---|
| 104 |
def_path = (char*) malloc(strlen(path)+1); |
|---|
| 105 |
strcpy(def_path, path); |
|---|
| 106 |
needs_free=1; |
|---|
| 107 |
} |
|---|
| 108 |
|
|---|
| 109 |
static DWORD dwDrvID = 0; |
|---|
| 110 |
|
|---|
| 111 |
LRESULT WINAPI SendDriverMessage(HDRVR hDriver, UINT message, |
|---|
| 112 |
LPARAM lParam1, LPARAM lParam2) |
|---|
| 113 |
{ |
|---|
| 114 |
DRVR* module=(DRVR*)hDriver; |
|---|
| 115 |
int result; |
|---|
| 116 |
#ifndef __svr4__ |
|---|
| 117 |
char qw[300]; |
|---|
| 118 |
#endif |
|---|
| 119 |
#ifdef DETAILED_OUT |
|---|
| 120 |
printf("SendDriverMessage: driver %X, message %X, arg1 %X, arg2 %X\n", hDriver, message, lParam1, lParam2); |
|---|
| 121 |
#endif |
|---|
| 122 |
if (!module || !module->hDriverModule || !module->DriverProc) return -1; |
|---|
| 123 |
#ifndef __svr4__ |
|---|
| 124 |
__asm__ __volatile__ ("fsave (%0)\n\t": :"r"(&qw)); |
|---|
| 125 |
#endif |
|---|
| 126 |
|
|---|
| 127 |
#ifdef WIN32_LOADER |
|---|
| 128 |
Setup_FS_Segment(); |
|---|
| 129 |
#endif |
|---|
| 130 |
|
|---|
| 131 |
STORE_ALL; |
|---|
| 132 |
result=module->DriverProc(module->dwDriverID, hDriver, message, lParam1, lParam2); |
|---|
| 133 |
REST_ALL; |
|---|
| 134 |
|
|---|
| 135 |
#ifndef __svr4__ |
|---|
| 136 |
__asm__ __volatile__ ("frstor (%0)\n\t": :"r"(&qw)); |
|---|
| 137 |
#endif |
|---|
| 138 |
|
|---|
| 139 |
#ifdef DETAILED_OUT |
|---|
| 140 |
printf("\t\tResult: %X\n", result); |
|---|
| 141 |
#endif |
|---|
| 142 |
return result; |
|---|
| 143 |
} |
|---|
| 144 |
|
|---|
| 145 |
void DrvClose(HDRVR hDriver) |
|---|
| 146 |
{ |
|---|
| 147 |
if (hDriver) |
|---|
| 148 |
{ |
|---|
| 149 |
DRVR* d = (DRVR*)hDriver; |
|---|
| 150 |
if (d->hDriverModule) |
|---|
| 151 |
{ |
|---|
| 152 |
#ifdef WIN32_LOADER |
|---|
| 153 |
Setup_FS_Segment(); |
|---|
| 154 |
#endif |
|---|
| 155 |
if (d->DriverProc) |
|---|
| 156 |
{ |
|---|
| 157 |
SendDriverMessage(hDriver, DRV_CLOSE, 0, 0); |
|---|
| 158 |
d->dwDriverID = 0; |
|---|
| 159 |
SendDriverMessage(hDriver, DRV_FREE, 0, 0); |
|---|
| 160 |
} |
|---|
| 161 |
FreeLibrary(d->hDriverModule); |
|---|
| 162 |
} |
|---|
| 163 |
free(d); |
|---|
| 164 |
} |
|---|
| 165 |
#ifdef WIN32_LOADER |
|---|
| 166 |
CodecRelease(); |
|---|
| 167 |
#endif |
|---|
| 168 |
} |
|---|
| 169 |
|
|---|
| 170 |
|
|---|
| 171 |
HDRVR DrvOpen(LPARAM lParam2) |
|---|
| 172 |
{ |
|---|
| 173 |
NPDRVR hDriver; |
|---|
| 174 |
int i; |
|---|
| 175 |
char unknown[0x124]; |
|---|
| 176 |
const char* filename = (const char*) ((ICOPEN*) lParam2)->pV1Reserved; |
|---|
| 177 |
|
|---|
| 178 |
#ifdef MPLAYER |
|---|
| 179 |
#ifdef WIN32_LOADER |
|---|
| 180 |
Setup_LDT_Keeper(); |
|---|
| 181 |
#endif |
|---|
| 182 |
printf("Loading codec DLL: '%s'\n",filename); |
|---|
| 183 |
#endif |
|---|
| 184 |
|
|---|
| 185 |
hDriver = (NPDRVR) malloc(sizeof(DRVR)); |
|---|
| 186 |
if (!hDriver) |
|---|
| 187 |
return ((HDRVR) 0); |
|---|
| 188 |
memset((void*)hDriver, 0, sizeof(DRVR)); |
|---|
| 189 |
|
|---|
| 190 |
#ifdef WIN32_LOADER |
|---|
| 191 |
CodecAlloc(); |
|---|
| 192 |
Setup_FS_Segment(); |
|---|
| 193 |
#endif |
|---|
| 194 |
|
|---|
| 195 |
hDriver->hDriverModule = LoadLibraryA(filename); |
|---|
| 196 |
if (!hDriver->hDriverModule) |
|---|
| 197 |
{ |
|---|
| 198 |
printf("Can't open library %s\n", filename); |
|---|
| 199 |
DrvClose((HDRVR)hDriver); |
|---|
| 200 |
return ((HDRVR) 0); |
|---|
| 201 |
} |
|---|
| 202 |
|
|---|
| 203 |
hDriver->DriverProc = (DRIVERPROC) GetProcAddress(hDriver->hDriverModule, |
|---|
| 204 |
"DriverProc"); |
|---|
| 205 |
if (!hDriver->DriverProc) |
|---|
| 206 |
{ |
|---|
| 207 |
printf("Library %s is not a valid VfW/ACM codec\n", filename); |
|---|
| 208 |
DrvClose((HDRVR)hDriver); |
|---|
| 209 |
return ((HDRVR) 0); |
|---|
| 210 |
} |
|---|
| 211 |
|
|---|
| 212 |
TRACE("DriverProc == %X\n", hDriver->DriverProc); |
|---|
| 213 |
SendDriverMessage((HDRVR)hDriver, DRV_LOAD, 0, 0); |
|---|
| 214 |
TRACE("DRV_LOAD Ok!\n"); |
|---|
| 215 |
SendDriverMessage((HDRVR)hDriver, DRV_ENABLE, 0, 0); |
|---|
| 216 |
TRACE("DRV_ENABLE Ok!\n"); |
|---|
| 217 |
hDriver->dwDriverID = ++dwDrvID; |
|---|
| 218 |
|
|---|
| 219 |
|
|---|
| 220 |
hDriver->dwDriverID = SendDriverMessage((HDRVR)hDriver, DRV_OPEN, (LPARAM) unknown, lParam2); |
|---|
| 221 |
TRACE("DRV_OPEN Ok!(%X)\n", hDriver->dwDriverID); |
|---|
| 222 |
|
|---|
| 223 |
printf("Loaded DLL driver %s at %x\n", filename, hDriver->hDriverModule); |
|---|
| 224 |
return (HDRVR)hDriver; |
|---|
| 225 |
} |
|---|