- Better handling when settimeofday is not available.
[wine] / dlls / winmm / driver.c
1 /* -*- tab-width: 8; c-basic-offset: 4 -*- */
2
3 /*
4  * WINE Drivers functions
5  *
6  * Copyright 1994 Martin Ayotte
7  * Copyright 1998 Marcus Meissner
8  * Copyright 1999 Eric Pouech
9  *
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 2.1 of the License, or (at your option) any later version.
14  *
15  * This library is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with this library; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23  */
24
25 #include <string.h>
26 #include "heap.h"
27 #include "windef.h"
28 #include "mmddk.h"
29 #include "winemm.h"
30 #include "wine/winbase16.h"
31 #include "wine/debug.h"
32
33 WINE_DEFAULT_DEBUG_CHANNEL(driver);
34
35 static LPWINE_DRIVER    lpDrvItemList = NULL;
36
37 /* TODO list :
38  *      - LoadModule count and clean up is not handled correctly (it's not a 
39  *        problem as long as FreeLibrary is not working correctly)
40  */
41
42 /**************************************************************************
43  *                      DRIVER_GetNumberOfModuleRefs            [internal]
44  *
45  * Returns the number of open drivers which share the same module.
46  */
47 static  WORD    DRIVER_GetNumberOfModuleRefs(LPWINE_DRIVER lpNewDrv)
48 {
49     LPWINE_DRIVER       lpDrv;
50     WORD                count = 0;
51
52     if (lpNewDrv->dwFlags & WINE_GDF_16BIT) ERR("OOOch\n");
53     for (lpDrv = lpDrvItemList; lpDrv; lpDrv = lpDrv->lpNextItem) {
54         if (!(lpDrv->dwFlags & WINE_GDF_16BIT) &&
55             lpDrv->d.d32.hModule == lpNewDrv->d.d32.hModule) {
56             count++;
57         }
58     }
59     return count;
60 }
61
62 /**************************************************************************
63  *                              DRIVER_FindFromHDrvr            [internal]
64  * 
65  * From a hDrvr being 32 bits, returns the WINE internal structure.
66  */
67 LPWINE_DRIVER   DRIVER_FindFromHDrvr(HDRVR hDrvr)
68 {    
69     LPWINE_DRIVER       d = (LPWINE_DRIVER)hDrvr;
70
71     if (hDrvr && HeapValidate(GetProcessHeap(), 0, d) && d->dwMagic == WINE_DI_MAGIC) {
72         return d;
73     }
74     return NULL;
75 }
76
77 /**************************************************************************
78  *                              DRIVER_MapMsg32To16             [internal]
79  *
80  * Map a 32 bit driver message to a 16 bit driver message.
81  *  1 : ok, some memory allocated, need to call DRIVER_UnMapMsg32To16
82  *  0 : ok, no memory allocated
83  * -1 : ko, unknown message
84  * -2 : ko, memory problem
85  */
86 static int DRIVER_MapMsg32To16(WORD wMsg, DWORD* lParam1, DWORD* lParam2)
87 {
88     int ret = -1;
89     
90     switch (wMsg) {
91     case DRV_LOAD:
92     case DRV_ENABLE:
93     case DRV_DISABLE:
94     case DRV_FREE:
95     case DRV_QUERYCONFIGURE:
96     case DRV_REMOVE:
97     case DRV_EXITSESSION:
98     case DRV_EXITAPPLICATION:   
99     case DRV_POWER:
100     case DRV_CLOSE:     /* should be 0/0 */
101     case DRV_OPEN:      /* pass through */
102         /* lParam1 and lParam2 are not used */
103         ret = 0;
104         break;
105         break;
106     case DRV_CONFIGURE:
107     case DRV_INSTALL:
108         /* lParam1 is a handle to a window (conf) or to a driver (inst) or not used, 
109          * lParam2 is a pointer to DRVCONFIGINFO 
110          */
111         if (*lParam2) {
112             LPDRVCONFIGINFO16 dci16 = HeapAlloc( GetProcessHeap(), 0, sizeof(*dci16) );
113             LPDRVCONFIGINFO     dci32 = (LPDRVCONFIGINFO)(*lParam2);
114             
115             if (dci16) {
116                 LPSTR str1;
117                 
118                 dci16->dwDCISize = sizeof(DRVCONFIGINFO16);
119                 
120                 if ((str1 = HEAP_strdupWtoA(GetProcessHeap(), 0, dci32->lpszDCISectionName)) != NULL)
121                 {
122                     dci16->lpszDCISectionName = MapLS( str1 );
123                 } else {
124                     return -2;
125                 }
126                 if ((str1 = HEAP_strdupWtoA(GetProcessHeap(), 0, dci32->lpszDCIAliasName)) != NULL)
127                 {
128                     dci16->lpszDCIAliasName = MapLS( str1 );
129                 } else {
130                     return -2;
131                 }
132             } else {
133                 return -2;
134             }
135             *lParam2 = MapLS( dci16 );
136             ret = 1;
137         } else {
138             ret = 0;
139         }
140         break;
141     default:
142         if (!((wMsg >= 0x800 && wMsg < 0x900) || (wMsg >= 0x4000 && wMsg < 0x4100))) {
143            FIXME("Unknown message 0x%04x\n", wMsg);
144         }
145         ret = 0;
146     }
147     return ret;
148 }
149
150 /**************************************************************************
151  *                              DRIVER_UnMapMsg32To16           [internal]
152  *
153  * UnMap a 32 bit driver message to a 16 bit driver message.
154  *  0 : ok
155  * -1 : ko
156  * -2 : ko, memory problem
157  */
158 static int DRIVER_UnMapMsg32To16(WORD wMsg, DWORD lParam1, DWORD lParam2)
159 {
160     int ret = -1;
161     
162     switch (wMsg) {
163     case DRV_LOAD:
164     case DRV_ENABLE:
165     case DRV_DISABLE:
166     case DRV_FREE:
167     case DRV_QUERYCONFIGURE:
168     case DRV_REMOVE:
169     case DRV_EXITSESSION:
170     case DRV_EXITAPPLICATION:
171     case DRV_POWER:
172     case DRV_OPEN:
173     case DRV_CLOSE:
174         /* lParam1 and lParam2 are not used */
175         break;
176     case DRV_CONFIGURE: 
177     case DRV_INSTALL:
178         /* lParam1 is a handle to a window (or not used), lParam2 is a pointer to DRVCONFIGINFO, lParam2 */
179         if (lParam2) {
180             LPDRVCONFIGINFO16   dci16 = MapSL(lParam2);
181             HeapFree( GetProcessHeap(), 0, MapSL(dci16->lpszDCISectionName) );
182             HeapFree( GetProcessHeap(), 0, MapSL(dci16->lpszDCIAliasName) );
183             UnMapLS( lParam2 );
184             UnMapLS( dci16->lpszDCISectionName );
185             UnMapLS( dci16->lpszDCIAliasName );
186             HeapFree( GetProcessHeap(), 0, dci16 );
187         }
188         ret = 0;
189         break;
190     default:
191         if (!((wMsg >= 0x800 && wMsg < 0x900) || (wMsg >= 0x4000 && wMsg < 0x4100))) {
192             FIXME("Unknown message 0x%04x\n", wMsg);
193         }
194         ret = 0;
195     }
196     return ret;
197 }
198
199 /**************************************************************************
200  *                              DRIVER_SendMessage              [internal]
201  */
202 static LRESULT inline DRIVER_SendMessage(LPWINE_DRIVER lpDrv, UINT msg, 
203                                         LPARAM lParam1, LPARAM lParam2)
204 {
205     if (lpDrv->dwFlags & WINE_GDF_16BIT) {
206         LRESULT         ret;
207         int             map = 0;
208         TRACE("Before sdm16 call hDrv=%04x wMsg=%04x p1=%08lx p2=%08lx\n", 
209               lpDrv->d.d16.hDriver16, msg, lParam1, lParam2);
210
211         if ((map = DRIVER_MapMsg32To16(msg, &lParam1, &lParam2)) >= 0) {
212             ret = SendDriverMessage16(lpDrv->d.d16.hDriver16, msg, lParam1, lParam2);
213             if (map == 1)
214                 DRIVER_UnMapMsg32To16(msg, lParam1, lParam2);
215         } else {
216             ret = 0;
217         }
218         return ret;
219     }
220     TRACE("Before func32 call proc=%p driverID=%08lx hDrv=%08x wMsg=%04x p1=%08lx p2=%08lx\n", 
221           lpDrv->d.d32.lpDrvProc, lpDrv->d.d32.dwDriverID, (HDRVR)lpDrv, msg, lParam1, lParam2);
222     return lpDrv->d.d32.lpDrvProc(lpDrv->d.d32.dwDriverID, (HDRVR)lpDrv, msg, lParam1, lParam2);
223 }
224
225 /**************************************************************************
226  *                              SendDriverMessage               [WINMM.@]
227  *                              DrvSendMessage                  [WINMM.@]
228  */
229 LRESULT WINAPI SendDriverMessage(HDRVR hDriver, UINT msg, LPARAM lParam1,
230                                  LPARAM lParam2)
231 {
232     LPWINE_DRIVER       lpDrv;
233     LRESULT             retval = 0;
234     
235     TRACE("(%04x, %04X, %08lX, %08lX)\n", hDriver, msg, lParam1, lParam2);
236     
237     if ((lpDrv = DRIVER_FindFromHDrvr(hDriver)) != NULL) {
238         retval = DRIVER_SendMessage(lpDrv, msg, lParam1, lParam2);
239     } else {
240         WARN("Bad driver handle %u\n", hDriver);
241     }
242     TRACE("retval = %ld\n", retval);
243     
244     return retval;
245 }
246
247 /**************************************************************************
248  *                              DRIVER_RemoveFromList           [internal]
249  *
250  * Generates all the logic to handle driver closure / deletion
251  * Removes a driver struct to the list of open drivers.
252  */
253 static  BOOL    DRIVER_RemoveFromList(LPWINE_DRIVER lpDrv)
254 {
255     if (!(lpDrv->dwFlags & WINE_GDF_16BIT)) {
256         if (DRIVER_GetNumberOfModuleRefs(lpDrv) == 1) {
257             DRIVER_SendMessage(lpDrv, DRV_DISABLE, 0L, 0L);
258             DRIVER_SendMessage(lpDrv, DRV_FREE,    0L, 0L);
259         }
260     }
261     
262     if (lpDrv->lpPrevItem)
263         lpDrv->lpPrevItem->lpNextItem = lpDrv->lpNextItem;
264     else
265         lpDrvItemList = lpDrv->lpNextItem;
266     if (lpDrv->lpNextItem)
267         lpDrv->lpNextItem->lpPrevItem = lpDrv->lpPrevItem;
268
269     return TRUE;
270 }
271
272 /**************************************************************************
273  *                              DRIVER_AddToList                [internal]
274  *
275  * Adds a driver struct to the list of open drivers.
276  * Generates all the logic to handle driver creation / open.
277  */
278 static  BOOL    DRIVER_AddToList(LPWINE_DRIVER lpNewDrv, LPARAM lParam1, LPARAM lParam2)
279 {
280     lpNewDrv->dwMagic = WINE_DI_MAGIC;
281     /* First driver to be loaded for this module, need to load correctly the module */
282     if (!(lpNewDrv->dwFlags & WINE_GDF_16BIT)) {
283         if (DRIVER_GetNumberOfModuleRefs(lpNewDrv) == 0) {
284             if (DRIVER_SendMessage(lpNewDrv, DRV_LOAD, 0L, 0L) != DRV_SUCCESS) {
285                 TRACE("DRV_LOAD failed on driver 0x%08lx\n", (DWORD)lpNewDrv);
286                 return FALSE;
287             }
288             /* returned value is not checked */
289             DRIVER_SendMessage(lpNewDrv, DRV_ENABLE, 0L, 0L);
290         }
291     }
292
293     lpNewDrv->lpNextItem = NULL;
294     if (lpDrvItemList == NULL) {
295         lpDrvItemList = lpNewDrv;
296         lpNewDrv->lpPrevItem = NULL;
297     } else {
298         LPWINE_DRIVER   lpDrv = lpDrvItemList;  /* find end of list */
299         while (lpDrv->lpNextItem != NULL)
300             lpDrv = lpDrv->lpNextItem;
301         
302         lpDrv->lpNextItem = lpNewDrv;
303         lpNewDrv->lpPrevItem = lpDrv;
304     }
305
306     if (!(lpNewDrv->dwFlags & WINE_GDF_16BIT)) {
307         /* Now just open a new instance of a driver on this module */
308         lpNewDrv->d.d32.dwDriverID = DRIVER_SendMessage(lpNewDrv, DRV_OPEN, lParam1, lParam2);
309
310         if (lpNewDrv->d.d32.dwDriverID == 0) {
311             TRACE("DRV_OPEN failed on driver 0x%08lx\n", (DWORD)lpNewDrv);
312             DRIVER_RemoveFromList(lpNewDrv);
313             return FALSE;
314         }
315     }
316     return TRUE;
317 }
318
319 /**************************************************************************
320  *                              DRIVER_GetLibName               [internal]
321  *
322  */
323 BOOL    DRIVER_GetLibName(LPCSTR keyName, LPCSTR sectName, LPSTR buf, int sz)
324 {
325     /* should also do some registry diving */
326     return GetPrivateProfileStringA(sectName, keyName, "", buf, sz, "SYSTEM.INI");
327 }
328
329 /**************************************************************************
330  *                              DRIVER_TryOpenDriver32          [internal]
331  *
332  * Tries to load a 32 bit driver whose DLL's (module) name is fn
333  */
334 LPWINE_DRIVER   DRIVER_TryOpenDriver32(LPCSTR fn, LPARAM lParam2)
335 {
336     LPWINE_DRIVER       lpDrv = NULL;
337     HMODULE             hModule = 0;
338     LPSTR               ptr;
339     LPCSTR              cause = 0;
340
341     TRACE("(%s, %08lX);\n", debugstr_a(fn), lParam2);
342     
343     if ((ptr = strchr(fn, ' ')) != NULL) {
344         *ptr++ = '\0';
345         while (*ptr == ' ') ptr++;
346         if (*ptr == '\0') ptr = NULL;
347     }
348
349     lpDrv = HeapAlloc(GetProcessHeap(), 0, sizeof(WINE_DRIVER));
350     if (lpDrv == NULL) {cause = "OOM"; goto exit;}
351
352     if ((hModule = LoadLibraryA(fn)) == 0) {cause = "Not a 32 bit lib"; goto exit;}
353
354     lpDrv->d.d32.lpDrvProc = (DRIVERPROC)GetProcAddress(hModule, "DriverProc");
355     if (lpDrv->d.d32.lpDrvProc == NULL) {cause = "no DriverProc"; goto exit;}
356
357     lpDrv->dwFlags          = 0;
358     lpDrv->d.d32.hModule    = hModule;
359     lpDrv->d.d32.dwDriverID = 0;
360
361     if (!DRIVER_AddToList(lpDrv, (LPARAM)ptr, lParam2)) {cause = "load failed"; goto exit;}
362
363     TRACE("=> %p\n", lpDrv);
364     return lpDrv;
365  exit:
366     FreeLibrary(hModule);
367     HeapFree(GetProcessHeap(), 0, lpDrv);
368     TRACE("Unable to load 32 bit module %s: %s\n", debugstr_a(fn), cause);
369     return NULL;
370 }
371
372 /**************************************************************************
373  *                              DRIVER_TryOpenDriver16          [internal]
374  *
375  * Tries to load a 16 bit driver whose DLL's (module) name is lpFileName.
376  */
377 static  LPWINE_DRIVER   DRIVER_TryOpenDriver16(LPCSTR fn, LPCSTR sn, LPARAM lParam2)
378 {
379     LPWINE_DRIVER       lpDrv = NULL;
380     LPCSTR              cause = 0;
381
382     TRACE("(%s, %08lX);\n", debugstr_a(sn), lParam2);
383     
384     lpDrv = HeapAlloc(GetProcessHeap(), 0, sizeof(WINE_DRIVER));
385     if (lpDrv == NULL) {cause = "OOM"; goto exit;}
386
387     /* FIXME: shall we do some black magic here on sn ?
388      *  drivers32 => drivers
389      *  mci32 => mci
390      * ...
391      */
392     lpDrv->d.d16.hDriver16 = OpenDriver16(fn, sn, lParam2);
393     if (lpDrv->d.d16.hDriver16 == 0) {cause = "Not a 16 bit driver"; goto exit;}
394     lpDrv->dwFlags = WINE_GDF_16BIT;
395
396     if (!DRIVER_AddToList(lpDrv, 0, lParam2)) {cause = "load failed"; goto exit;}
397
398     TRACE("=> %p\n", lpDrv);
399     return lpDrv;
400  exit:
401     HeapFree(GetProcessHeap(), 0, lpDrv);
402     TRACE("Unable to load 32 bit module %s: %s\n", debugstr_a(fn), cause);
403     return NULL;
404 }
405
406 /**************************************************************************
407  *                              OpenDriverA                     [WINMM.@]
408  *                              DrvOpenA                        [WINMM.@]
409  * (0,1,DRV_LOAD  ,0       ,0)
410  * (0,1,DRV_ENABLE,0       ,0)
411  * (0,1,DRV_OPEN  ,buf[256],0)
412  */
413 HDRVR WINAPI OpenDriverA(LPCSTR lpDriverName, LPCSTR lpSectionName, LPARAM lParam2) 
414 {
415     LPWINE_DRIVER       lpDrv = NULL;
416     char                libName[128];
417     LPCSTR              lsn = lpSectionName;
418
419     TRACE("(%s, %s, 0x%08lx);\n", debugstr_a(lpDriverName), debugstr_a(lpSectionName), lParam2);
420     
421     if (lsn == NULL) {
422         lstrcpynA(libName, lpDriverName, sizeof(libName));
423
424         if ((lpDrv = DRIVER_TryOpenDriver32(libName, lParam2)))
425             goto the_end;
426         lsn = "Drivers32";
427     }
428     if (DRIVER_GetLibName(lpDriverName, lsn, libName, sizeof(libName)) &&
429         (lpDrv = DRIVER_TryOpenDriver32(libName, lParam2)))
430         goto the_end;
431
432     if (!(lpDrv = DRIVER_TryOpenDriver16(lpDriverName, lpSectionName, lParam2)))
433         TRACE("Failed to open driver %s from system.ini file, section %s\n", debugstr_a(lpDriverName), debugstr_a(lpSectionName));
434  the_end:
435     if (lpDrv)  TRACE("=> %08lx\n", (DWORD)lpDrv);
436     return (DWORD)lpDrv;
437 }
438
439 /**************************************************************************
440  *                              OpenDriver                      [WINMM.@]
441  *                              DrvOpen                         [WINMM.@]
442  */
443 HDRVR WINAPI OpenDriverW(LPCWSTR lpDriverName, LPCWSTR lpSectionName, LPARAM lParam)
444 {
445     LPSTR               dn = HEAP_strdupWtoA(GetProcessHeap(), 0, lpDriverName);
446     LPSTR               sn = HEAP_strdupWtoA(GetProcessHeap(), 0, lpSectionName);
447     HDRVR               ret = OpenDriverA(dn, sn, lParam);
448     
449     if (dn) HeapFree(GetProcessHeap(), 0, dn);
450     if (sn) HeapFree(GetProcessHeap(), 0, sn);
451     return ret;
452 }
453
454 /**************************************************************************
455  *                      CloseDriver                             [WINMM.@]
456  *                      DrvClose                                [WINMM.@]
457  */
458 LRESULT WINAPI CloseDriver(HDRVR hDrvr, LPARAM lParam1, LPARAM lParam2)
459 {
460     LPWINE_DRIVER       lpDrv;
461
462     TRACE("(%04x, %08lX, %08lX);\n", hDrvr, lParam1, lParam2);
463     
464     if ((lpDrv = DRIVER_FindFromHDrvr(hDrvr)) != NULL) {
465         if (lpDrv->dwFlags & WINE_GDF_16BIT)
466             CloseDriver16(lpDrv->d.d16.hDriver16, lParam1, lParam2);
467         else
468             DRIVER_SendMessage(lpDrv, DRV_CLOSE, lParam1, lParam2);
469         if (DRIVER_RemoveFromList(lpDrv)) {
470             HeapFree(GetProcessHeap(), 0, lpDrv);
471             return TRUE;
472         }
473     }
474     WARN("Failed to close driver\n");
475     return FALSE;
476 }
477
478 /**************************************************************************
479  *                              GetDriverFlags          [WINMM.@]
480  * [in] hDrvr handle to the driver
481  *
482  * Returns:
483  *      0x00000000 if hDrvr is an invalid handle
484  *      0x80000000 if hDrvr is a valid 32 bit driver
485  *      0x90000000 if hDrvr is a valid 16 bit driver
486  *
487  * native WINMM doesn't return those flags
488  *      0x80000000 for a valid 32 bit driver and that's it
489  *      (I may have mixed up the two flags :-(
490  */
491 DWORD   WINAPI GetDriverFlags(HDRVR hDrvr)
492 {
493     LPWINE_DRIVER       lpDrv;
494     DWORD               ret = 0;
495
496     TRACE("(%04x)\n", hDrvr);
497
498     if ((lpDrv = DRIVER_FindFromHDrvr(hDrvr)) != NULL) {
499         ret = WINE_GDF_EXIST | lpDrv->dwFlags;
500     }
501     return ret;
502 }
503
504 /**************************************************************************
505  *                              GetDriverModuleHandle   [WINMM.@]
506  *                              DrvGetModuleHandle      [WINMM.@]
507  */
508 HMODULE WINAPI GetDriverModuleHandle(HDRVR hDrvr)
509 {
510     LPWINE_DRIVER       lpDrv;
511     HMODULE             hModule = 0;
512     
513     TRACE("(%04x);\n", hDrvr);
514     
515     if ((lpDrv = DRIVER_FindFromHDrvr(hDrvr)) != NULL) {
516         if (!(lpDrv->dwFlags & WINE_GDF_16BIT))
517             hModule = lpDrv->d.d32.hModule;
518     }
519     TRACE("=> %04x\n", hModule);
520     return hModule;
521 }
522
523 /**************************************************************************
524  *                              DrvOpen                 [MMSYSTEM.1100]
525  */
526 HDRVR16 WINAPI DrvOpen16(LPSTR lpDriverName, LPSTR lpSectionName, LPARAM lParam)
527 {
528     return OpenDriver16(lpDriverName, lpSectionName, lParam);
529 }
530
531 /**************************************************************************
532  *                              DrvClose                [MMSYSTEM.1101]
533  */
534 LRESULT WINAPI DrvClose16(HDRVR16 hDrv, LPARAM lParam1, LPARAM lParam2)
535 {
536     return CloseDriver16(hDrv, lParam1, lParam2);
537 }
538
539 /**************************************************************************
540  *                              DrvSendMessage          [MMSYSTEM.1102]
541  */
542 LRESULT WINAPI DrvSendMessage16(HDRVR16 hDrv, WORD msg, LPARAM lParam1,
543                                 LPARAM lParam2)
544 {
545     return SendDriverMessage16(hDrv, msg, lParam1, lParam2);
546 }
547
548 /**************************************************************************
549  *                              DrvGetModuleHandle      [MMSYSTEM.1103]
550  */
551 HANDLE16 WINAPI DrvGetModuleHandle16(HDRVR16 hDrv)
552 {
553     return GetDriverModuleHandle16(hDrv);
554 }
555
556 /**************************************************************************
557  *                              DrvDefDriverProc        [MMSYSTEM.1104]
558  */
559 LRESULT WINAPI DrvDefDriverProc16(DWORD dwDriverID, HDRVR16 hDrv, WORD wMsg, 
560                                   DWORD dwParam1, DWORD dwParam2)
561 {
562     return DefDriverProc16(dwDriverID, hDrv, wMsg, dwParam1, dwParam2);
563 }
564
565 /**************************************************************************
566  *                              DefDriverProc                     [WINMM.@]
567  *                              DrvDefDriverProc                  [WINMM.@]
568  */
569 LRESULT WINAPI DefDriverProc(DWORD dwDriverIdentifier, HDRVR hDrv,
570                              UINT Msg, LPARAM lParam1, LPARAM lParam2)
571 {
572     switch (Msg) {
573     case DRV_LOAD:
574     case DRV_FREE:
575     case DRV_ENABLE:
576     case DRV_DISABLE:
577         return 1;
578     case DRV_INSTALL:
579     case DRV_REMOVE:
580         return DRV_SUCCESS;
581     default:
582         return 0;
583     }
584 }
585
586 /**************************************************************************
587  *                              DriverProc                      [MMSYSTEM.6]
588  */
589 LRESULT WINAPI DriverProc16(DWORD dwDevID, HDRVR16 hDrv, WORD wMsg, 
590                             DWORD dwParam1, DWORD dwParam2)
591 {
592     TRACE("dwDevID=%08lx hDrv=%04x wMsg=%04x dwParam1=%08lx dwParam2=%08lx\n",
593           dwDevID, hDrv, wMsg, dwParam1, dwParam2);
594
595     return DrvDefDriverProc16(dwDevID, hDrv, wMsg, dwParam1, dwParam2);
596 }
597