annotate loader/drv.c @ 29259:c8dda91cf626

libdvdread4 does not use HAVE_CONFIG_H, so drop the -D flag for libdvdread4.
author diego
date Tue, 12 May 2009 08:21:53 +0000
parents 290420c32921
children 9fc9d1e788aa
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
26999
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
1 /*
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
2 * Modified for use with MPlayer, detailed changelog at
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
3 * http://svn.mplayerhq.hu/mplayer/trunk/
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
4 */
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
5
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
6 #include "config.h"
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
7 #include "debug.h"
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
8
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
9 #include <stdio.h>
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
10 #include <stdlib.h>
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
11 #ifdef __FreeBSD__
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
12 #include <sys/time.h>
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
13 #endif
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
14
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
15 #include "win32.h"
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
16 #include "wine/driver.h"
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
17 #include "wine/pe_image.h"
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
18 #include "wine/winreg.h"
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
19 #include "wine/vfw.h"
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
20 #include "registry.h"
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
21 #ifdef WIN32_LOADER
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
22 #include "ldt_keeper.h"
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
23 #endif
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
24 #include "drv.h"
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
25 #ifndef __MINGW32__
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
26 #include "ext.h"
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
27 #endif
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
28
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
29 #ifndef WIN32_LOADER
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
30 char* def_path=WIN32_PATH;
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
31 #else
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
32 extern char* def_path;
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
33 #endif
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
34
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
35 #if 1
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
36
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
37 /*
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
38 * STORE_ALL/REST_ALL seems like an attempt to workaround problems due to
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
39 * WINAPI/no-WINAPI bustage.
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
40 *
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
41 * There should be no need for the STORE_ALL/REST_ALL hack once all
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
42 * function definitions agree with their prototypes (WINAPI-wise) and
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
43 * we make sure, that we do not call these functions without a proper
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
44 * prototype in scope.
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
45 */
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
46
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
47 #define STORE_ALL
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
48 #define REST_ALL
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
49 #else
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
50 // this asm code is no longer needed
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
51 #define STORE_ALL \
27757
b5a46071062a Replace all occurrences of '__volatile__' and '__volatile' by plain 'volatile'.
diego
parents: 26999
diff changeset
52 __asm__ volatile ( \
26999
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
53 "push %%ebx\n\t" \
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
54 "push %%ecx\n\t" \
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
55 "push %%edx\n\t" \
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
56 "push %%esi\n\t" \
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
57 "push %%edi\n\t"::)
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
58
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
59 #define REST_ALL \
27757
b5a46071062a Replace all occurrences of '__volatile__' and '__volatile' by plain 'volatile'.
diego
parents: 26999
diff changeset
60 __asm__ volatile ( \
26999
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
61 "pop %%edi\n\t" \
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
62 "pop %%esi\n\t" \
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
63 "pop %%edx\n\t" \
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
64 "pop %%ecx\n\t" \
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
65 "pop %%ebx\n\t"::)
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
66 #endif
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
67
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
68 static int needs_free=0;
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
69 void SetCodecPath(const char* path)
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
70 {
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
71 if(needs_free)free(def_path);
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
72 if(path==0)
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
73 {
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
74 def_path=WIN32_PATH;
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
75 needs_free=0;
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
76 return;
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
77 }
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
78 def_path = (char*) malloc(strlen(path)+1);
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
79 strcpy(def_path, path);
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
80 needs_free=1;
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
81 }
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
82
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
83 static DWORD dwDrvID = 0;
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
84
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
85 LRESULT WINAPI SendDriverMessage(HDRVR hDriver, UINT message,
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
86 LPARAM lParam1, LPARAM lParam2)
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
87 {
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
88 DRVR* module=(DRVR*)hDriver;
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
89 int result;
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
90 #ifndef __svr4__
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
91 char qw[300];
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
92 #endif
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
93 #ifdef DETAILED_OUT
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
94 printf("SendDriverMessage: driver %X, message %X, arg1 %X, arg2 %X\n", hDriver, message, lParam1, lParam2);
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
95 #endif
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
96 if (!module || !module->hDriverModule || !module->DriverProc) return -1;
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
97 #ifndef __svr4__
27757
b5a46071062a Replace all occurrences of '__volatile__' and '__volatile' by plain 'volatile'.
diego
parents: 26999
diff changeset
98 __asm__ volatile ("fsave (%0)\n\t": :"r"(&qw));
26999
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
99 #endif
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
100
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
101 #ifdef WIN32_LOADER
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
102 Setup_FS_Segment();
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
103 #endif
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
104
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
105 STORE_ALL;
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
106 result=module->DriverProc(module->dwDriverID, hDriver, message, lParam1, lParam2);
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
107 REST_ALL;
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
108
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
109 #ifndef __svr4__
27757
b5a46071062a Replace all occurrences of '__volatile__' and '__volatile' by plain 'volatile'.
diego
parents: 26999
diff changeset
110 __asm__ volatile ("frstor (%0)\n\t": :"r"(&qw));
26999
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
111 #endif
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
112
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
113 #ifdef DETAILED_OUT
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
114 printf("\t\tResult: %X\n", result);
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
115 #endif
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
116 return result;
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
117 }
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
118
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
119 void DrvClose(HDRVR hDriver)
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
120 {
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
121 if (hDriver)
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
122 {
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
123 DRVR* d = (DRVR*)hDriver;
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
124 if (d->hDriverModule)
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
125 {
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
126 #ifdef WIN32_LOADER
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
127 Setup_FS_Segment();
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
128 #endif
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
129 if (d->DriverProc)
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
130 {
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
131 SendDriverMessage(hDriver, DRV_CLOSE, 0, 0);
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
132 d->dwDriverID = 0;
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
133 SendDriverMessage(hDriver, DRV_FREE, 0, 0);
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
134 }
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
135 FreeLibrary(d->hDriverModule);
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
136 }
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
137 free(d);
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
138 }
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
139 #ifdef WIN32_LOADER
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
140 CodecRelease();
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
141 #endif
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
142 }
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
143
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
144 //DrvOpen(LPCSTR lpszDriverName, LPCSTR lpszSectionName, LPARAM lParam2)
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
145 HDRVR DrvOpen(LPARAM lParam2)
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
146 {
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
147 NPDRVR hDriver;
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
148 char unknown[0x124];
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
149 const char* filename = (const char*) ((ICOPEN*) lParam2)->pV1Reserved;
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
150
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
151 #ifdef WIN32_LOADER
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
152 Setup_LDT_Keeper();
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
153 #endif
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
154 printf("Loading codec DLL: '%s'\n",filename);
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
155
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
156 hDriver = (NPDRVR) malloc(sizeof(DRVR));
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
157 if (!hDriver)
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
158 return (HDRVR) 0;
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
159 memset((void*)hDriver, 0, sizeof(DRVR));
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
160
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
161 #ifdef WIN32_LOADER
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
162 CodecAlloc();
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
163 Setup_FS_Segment();
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
164 #endif
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
165
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
166 hDriver->hDriverModule = LoadLibraryA(filename);
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
167 if (!hDriver->hDriverModule)
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
168 {
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
169 printf("Can't open library %s\n", filename);
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
170 DrvClose((HDRVR)hDriver);
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
171 return (HDRVR) 0;
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
172 }
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
173
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
174 hDriver->DriverProc = (DRIVERPROC) GetProcAddress(hDriver->hDriverModule,
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
175 "DriverProc");
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
176 if (!hDriver->DriverProc)
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
177 {
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
178 printf("Library %s is not a valid VfW/ACM codec\n", filename);
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
179 DrvClose((HDRVR)hDriver);
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
180 return (HDRVR) 0;
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
181 }
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
182
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
183 TRACE("DriverProc == %X\n", hDriver->DriverProc);
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
184 SendDriverMessage((HDRVR)hDriver, DRV_LOAD, 0, 0);
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
185 TRACE("DRV_LOAD Ok!\n");
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
186 SendDriverMessage((HDRVR)hDriver, DRV_ENABLE, 0, 0);
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
187 TRACE("DRV_ENABLE Ok!\n");
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
188 hDriver->dwDriverID = ++dwDrvID; // generate new id
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
189
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
190 // open driver and remmeber proper DriverID
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
191 hDriver->dwDriverID = SendDriverMessage((HDRVR)hDriver, DRV_OPEN, (LPARAM) unknown, lParam2);
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
192 TRACE("DRV_OPEN Ok!(%X)\n", hDriver->dwDriverID);
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
193
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
194 printf("Loaded DLL driver %s at %x\n", filename, hDriver->hDriverModule);
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
195 return (HDRVR)hDriver;
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
196 }