- Pass pointer to debugprint function to the kernel in LoaderBlock->u.I386.CommonDataArea
[reactos.git] / reactos / dll / win32 / winmm / driver.c
1 /*
2 * WINE Drivers functions
3 *
4 * Copyright 1994 Martin Ayotte
5 * Copyright 1998 Marcus Meissner
6 * Copyright 1999 Eric Pouech
7 *
8 * Reformatting and additional comments added by Andrew Greenwood.
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 <stdarg.h>
27 #include "windef.h"
28 #include "winbase.h"
29 #include "wingdi.h"
30 #include "winuser.h"
31 #include "winnls.h"
32 #include "winreg.h"
33 #include "mmddk.h"
34 #include "winemm.h"
35 #include "wine/debug.h"
36 #include "wine/unicode.h"
37
38 WINE_DEFAULT_DEBUG_CHANNEL(driver);
39
40 static LPWINE_DRIVER lpDrvItemList /* = NULL */;
41 static const WCHAR HKLM_BASE[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
42 'W','i','n','d','o','w','s',' ','N','T','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n',0};
43
44 WINE_MMTHREAD* (*pFnGetMMThread16)(UINT16 h) /* = NULL */;
45 LPWINE_DRIVER (*pFnOpenDriver16)(LPCWSTR,LPCWSTR,LPARAM) /* = NULL */;
46 LRESULT (*pFnCloseDriver16)(UINT16,LPARAM,LPARAM) /* = NULL */;
47 LRESULT (*pFnSendMessage16)(UINT16,UINT,LPARAM,LPARAM) /* = NULL */;
48
49 /**************************************************************************
50 * DRIVER_GetNumberOfModuleRefs [internal]
51 *
52 * Returns the number of open drivers which share the same module.
53 */
54 static unsigned DRIVER_GetNumberOfModuleRefs(HMODULE hModule, WINE_DRIVER** found)
55 {
56 LPWINE_DRIVER lpDrv;
57 unsigned count = 0;
58
59 if (found) *found = NULL;
60 for (lpDrv = lpDrvItemList; lpDrv; lpDrv = lpDrv->lpNextItem)
61 {
62 if (!(lpDrv->dwFlags & WINE_GDF_16BIT) && lpDrv->d.d32.hModule == hModule)
63 {
64 if (found && !*found) *found = lpDrv;
65 count++;
66 }
67 }
68 return count;
69 }
70
71 /**************************************************************************
72 * DRIVER_FindFromHDrvr [internal]
73 *
74 * From a hDrvr being 32 bits, returns the WINE internal structure.
75 */
76 LPWINE_DRIVER DRIVER_FindFromHDrvr(HDRVR hDrvr)
77 {
78 LPWINE_DRIVER d = (LPWINE_DRIVER)hDrvr;
79
80 if (hDrvr && HeapValidate(GetProcessHeap(), 0, d) && d->dwMagic == WINE_DI_MAGIC) {
81 return d;
82 }
83 return NULL;
84 }
85
86 /**************************************************************************
87 * DRIVER_SendMessage [internal]
88 */
89 static LRESULT inline DRIVER_SendMessage(LPWINE_DRIVER lpDrv, UINT msg,
90 LPARAM lParam1, LPARAM lParam2)
91 {
92 LRESULT ret = 0;
93
94 if (lpDrv->dwFlags & WINE_GDF_16BIT) {
95 /* no need to check mmsystem presence: the driver must have been opened as a 16 bit one,
96 */
97 if (pFnSendMessage16)
98 ret = pFnSendMessage16(lpDrv->d.d16.hDriver16, msg, lParam1, lParam2);
99 } else {
100 TRACE("Before call32 proc=%p drvrID=%08lx hDrv=%p wMsg=%04x p1=%08lx p2=%08lx\n",
101 lpDrv->d.d32.lpDrvProc, lpDrv->d.d32.dwDriverID, (HDRVR)lpDrv, msg, lParam1, lParam2);
102 ret = lpDrv->d.d32.lpDrvProc(lpDrv->d.d32.dwDriverID, (HDRVR)lpDrv, msg, lParam1, lParam2);
103 TRACE("After call32 proc=%p drvrID=%08lx hDrv=%p wMsg=%04x p1=%08lx p2=%08lx => %08lx\n",
104 lpDrv->d.d32.lpDrvProc, lpDrv->d.d32.dwDriverID, (HDRVR)lpDrv, msg, lParam1, lParam2, ret);
105 }
106 return ret;
107 }
108
109 /**************************************************************************
110 * SendDriverMessage [WINMM.@]
111 * DrvSendMessage [WINMM.@]
112 */
113 LRESULT WINAPI SendDriverMessage(HDRVR hDriver, UINT msg, LONG lParam1,
114 LONG lParam2)
115 {
116 LPWINE_DRIVER lpDrv;
117 LRESULT retval = 0;
118
119 TRACE("(%p, %04X, %08lX, %08lX)\n", hDriver, msg, lParam1, lParam2);
120
121 if ((lpDrv = DRIVER_FindFromHDrvr(hDriver)) != NULL) {
122 retval = DRIVER_SendMessage(lpDrv, msg, lParam1, lParam2);
123 } else {
124 WARN("Bad driver handle %p\n", hDriver);
125 }
126 TRACE("retval = %ld\n", retval);
127
128 return retval;
129 }
130
131 /**************************************************************************
132 * DRIVER_RemoveFromList [internal]
133 *
134 * Generates all the logic to handle driver closure / deletion
135 * Removes a driver struct to the list of open drivers.
136 */
137 static BOOL DRIVER_RemoveFromList(LPWINE_DRIVER lpDrv)
138 {
139 if (!(lpDrv->dwFlags & WINE_GDF_16BIT)) {
140 /* last of this driver in list ? */
141 if (DRIVER_GetNumberOfModuleRefs(lpDrv->d.d32.hModule, NULL) == 1) {
142 DRIVER_SendMessage(lpDrv, DRV_DISABLE, 0L, 0L);
143 DRIVER_SendMessage(lpDrv, DRV_FREE, 0L, 0L);
144 }
145 }
146
147 if (lpDrv->lpPrevItem)
148 lpDrv->lpPrevItem->lpNextItem = lpDrv->lpNextItem;
149 else
150 lpDrvItemList = lpDrv->lpNextItem;
151 if (lpDrv->lpNextItem)
152 lpDrv->lpNextItem->lpPrevItem = lpDrv->lpPrevItem;
153 /* trash magic number */
154 lpDrv->dwMagic ^= 0xa5a5a5a5;
155
156 return TRUE;
157 }
158
159 /**************************************************************************
160 * DRIVER_AddToList [internal]
161 *
162 * Adds a driver struct to the list of open drivers.
163 * Generates all the logic to handle driver creation / open.
164 */
165 static BOOL DRIVER_AddToList(LPWINE_DRIVER lpNewDrv, LPARAM lParam1, LPARAM lParam2)
166 {
167 lpNewDrv->dwMagic = WINE_DI_MAGIC;
168 /* First driver to be loaded for this module, need to load correctly the module */
169 if (!(lpNewDrv->dwFlags & WINE_GDF_16BIT)) {
170 /* first of this driver in list ? */
171 if (DRIVER_GetNumberOfModuleRefs(lpNewDrv->d.d32.hModule, NULL) == 0) {
172 if (DRIVER_SendMessage(lpNewDrv, DRV_LOAD, 0L, 0L) != DRV_SUCCESS) {
173 TRACE("DRV_LOAD failed on driver %p\n", lpNewDrv);
174 return FALSE;
175 }
176 /* returned value is not checked */
177 DRIVER_SendMessage(lpNewDrv, DRV_ENABLE, 0L, 0L);
178 }
179 }
180
181 lpNewDrv->lpNextItem = NULL;
182 if (lpDrvItemList == NULL) {
183 lpDrvItemList = lpNewDrv;
184 lpNewDrv->lpPrevItem = NULL;
185 } else {
186 LPWINE_DRIVER lpDrv = lpDrvItemList; /* find end of list */
187 while (lpDrv->lpNextItem != NULL)
188 lpDrv = lpDrv->lpNextItem;
189
190 lpDrv->lpNextItem = lpNewDrv;
191 lpNewDrv->lpPrevItem = lpDrv;
192 }
193
194 if (!(lpNewDrv->dwFlags & WINE_GDF_16BIT)) {
195 /* Now just open a new instance of a driver on this module */
196 lpNewDrv->d.d32.dwDriverID = DRIVER_SendMessage(lpNewDrv, DRV_OPEN, lParam1, lParam2);
197
198 if (lpNewDrv->d.d32.dwDriverID == 0) {
199 TRACE("DRV_OPEN failed on driver %p\n", lpNewDrv);
200 DRIVER_RemoveFromList(lpNewDrv);
201 return FALSE;
202 }
203 }
204 return TRUE;
205 }
206
207 /**************************************************************************
208 * DRIVER_GetLibName [internal]
209 *
210 */
211 BOOL DRIVER_GetLibName(LPCWSTR keyName, LPCWSTR sectName, LPWSTR buf, int sz)
212 {
213 HKEY hKey, hSecKey;
214 DWORD bufLen, lRet;
215 static const WCHAR wszSystemIni[] = {'S','Y','S','T','E','M','.','I','N','I',0};
216 WCHAR wsznull = '\0';
217
218 /* This takes us as far as Windows NT\CurrentVersion */
219 lRet = RegOpenKeyExW(HKEY_LOCAL_MACHINE, HKLM_BASE, 0, KEY_QUERY_VALUE, &hKey);
220
221 if (lRet == ERROR_SUCCESS)
222 {
223 /* Now we descend into the section name that we were given */
224 lRet = RegOpenKeyExW(hKey, sectName, 0, KEY_QUERY_VALUE, &hSecKey);
225
226 if (lRet == ERROR_SUCCESS)
227 {
228 /* Retrieve the desired value - this is the filename of the lib */
229 bufLen = sz;
230 lRet = RegQueryValueExW(hSecKey, keyName, 0, 0, (void*)buf, &bufLen);
231 RegCloseKey( hSecKey );
232 }
233
234 RegCloseKey( hKey );
235 }
236
237 /* Finish up if we've got what we want from the registry */
238 if (lRet == ERROR_SUCCESS)
239 return TRUE;
240
241 /* default to system.ini if we can't find it in the registry,
242 * to support native installations where system.ini is still used */
243 return GetPrivateProfileStringW(sectName, keyName, &wsznull, buf, sz / sizeof(WCHAR), wszSystemIni);
244 }
245
246 /**************************************************************************
247 * DRIVER_TryOpenDriver32 [internal]
248 *
249 * Tries to load a 32 bit driver whose DLL's (module) name is fn
250 */
251 LPWINE_DRIVER DRIVER_TryOpenDriver32(LPCWSTR fn, LPARAM lParam2)
252 {
253 LPWINE_DRIVER lpDrv = NULL;
254 HMODULE hModule = 0;
255 LPWSTR ptr;
256 LPCSTR cause = 0;
257
258 TRACE("(%s, %08lX);\n", debugstr_w(fn), lParam2);
259
260 if ((ptr = strchrW(fn, ' ')) != NULL)
261 {
262 *ptr++ = '\0';
263
264 while (*ptr == ' ')
265 ptr++;
266
267 if (*ptr == '\0')
268 ptr = NULL;
269 }
270
271 lpDrv = HeapAlloc(GetProcessHeap(), 0, sizeof(WINE_DRIVER));
272
273 if (lpDrv == NULL)
274 {
275 cause = "OOM";
276 goto exit;
277 }
278
279 if ((hModule = LoadLibraryW(fn)) == 0)
280 {
281 cause = "Not a 32 bit lib";
282 goto exit;
283 }
284
285 lpDrv->d.d32.lpDrvProc = (DRIVERPROC)GetProcAddress(hModule, "DriverProc");
286
287 if (lpDrv->d.d32.lpDrvProc == NULL)
288 {
289 cause = "no DriverProc";
290 goto exit;
291 }
292
293 lpDrv->dwFlags = 0;
294 lpDrv->d.d32.hModule = hModule;
295 lpDrv->d.d32.dwDriverID = 0;
296
297 /* Win32 installable drivers must support a two phase opening scheme:
298 * + first open with NULL as lParam2 (session instance),
299 * + then do a second open with the real non null lParam2)
300 */
301 if (DRIVER_GetNumberOfModuleRefs(lpDrv->d.d32.hModule, NULL) == 0 && lParam2)
302 {
303 LPWINE_DRIVER ret;
304
305 if (!DRIVER_AddToList(lpDrv, (LPARAM)ptr, 0L))
306 {
307 cause = "load0 failed";
308 goto exit;
309 }
310 ret = DRIVER_TryOpenDriver32(fn, lParam2);
311 if (!ret)
312 {
313 CloseDriver((HDRVR)lpDrv, 0L, 0L);
314 cause = "load1 failed";
315 goto exit;
316 }
317 return ret;
318 }
319
320 if (!DRIVER_AddToList(lpDrv, (LPARAM)ptr, lParam2))
321 {
322 cause = "load failed";
323 goto exit;
324 }
325
326 TRACE("=> %p\n", lpDrv);
327 return lpDrv;
328
329 exit:
330 FreeLibrary(hModule);
331 HeapFree(GetProcessHeap(), 0, lpDrv);
332 TRACE("Unable to load 32 bit module %s: %s\n", debugstr_w(fn), cause);
333 return NULL;
334 }
335
336 /**************************************************************************
337 * OpenDriverA [WINMM.@]
338 * DrvOpenA [WINMM.@]
339 * (0,1,DRV_LOAD ,0 ,0)
340 * (0,1,DRV_ENABLE,0 ,0)
341 * (0,1,DRV_OPEN ,buf[256],0)
342 */
343 HDRVR WINAPI OpenDriverA(LPCSTR lpDriverName, LPCSTR lpSectionName, LPARAM lParam)
344 {
345 INT len;
346 LPWSTR dn = NULL;
347 LPWSTR sn = NULL;
348 HDRVR ret = 0;
349
350 if (lpDriverName)
351 {
352 len = MultiByteToWideChar( CP_ACP, 0, lpDriverName, -1, NULL, 0 );
353 dn = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
354 if (!dn) goto done;
355 MultiByteToWideChar( CP_ACP, 0, lpDriverName, -1, dn, len );
356 }
357
358 if (lpSectionName)
359 {
360 len = MultiByteToWideChar( CP_ACP, 0, lpSectionName, -1, NULL, 0 );
361 sn = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
362 if (!sn) goto done;
363 MultiByteToWideChar( CP_ACP, 0, lpSectionName, -1, sn, len );
364 }
365
366 ret = OpenDriver(dn, sn, lParam);
367
368 done:
369 HeapFree(GetProcessHeap(), 0, dn);
370 HeapFree(GetProcessHeap(), 0, sn);
371 return ret;
372 }
373
374 /**************************************************************************
375 * OpenDriver [WINMM.@]
376 * DrvOpen [WINMM.@]
377 */
378 HDRVR WINAPI OpenDriver(LPCWSTR lpDriverName, LPCWSTR lpSectionName, LONG lParam)
379 {
380 LPWINE_DRIVER lpDrv = NULL;
381 WCHAR libName[128];
382 LPCWSTR lsn = lpSectionName;
383
384 TRACE("(%s, %s, 0x%08lx);\n",
385 debugstr_w(lpDriverName), debugstr_w(lpSectionName), lParam);
386
387 /* If no section name is specified, either the caller is intending on
388 opening a driver by filename, or wants to open a user-installable
389 driver that has an entry in the Drivers32 key in the registry */
390 if (lsn == NULL)
391 {
392 /* Default registry key */
393 static const WCHAR wszDrivers32[] = {'D','r','i','v','e','r','s','3','2',0};
394
395 lstrcpynW(libName, lpDriverName, sizeof(libName) / sizeof(WCHAR));
396
397 /* Try and open the driver by filename */
398 if ( (lpDrv = DRIVER_TryOpenDriver32(libName, lParam)) )
399 goto the_end;
400
401 /* If we got here, the file wasn't found. So we assume the caller
402 wanted a driver specified under the Drivers32 registry key */
403 lsn = wszDrivers32;
404 }
405
406 /* Attempt to locate the driver filename in the registry */
407 if ( DRIVER_GetLibName(lpDriverName, lsn, libName, sizeof(libName)) )
408 {
409 /* Now we have the filename, we can try and load it */
410 if ( (lpDrv = DRIVER_TryOpenDriver32(libName, lParam)) )
411 goto the_end;
412 }
413
414 /* now we will try a 16 bit driver (and add all the glue to make it work... which
415 * is located in our mmsystem implementation)
416 * so ensure, we can load our mmsystem, otherwise just fail
417 */
418 WINMM_CheckForMMSystem();
419 if (pFnOpenDriver16 &&
420 (lpDrv = pFnOpenDriver16(lpDriverName, lpSectionName, lParam)))
421 {
422 if (DRIVER_AddToList(lpDrv, 0, lParam)) goto the_end;
423 HeapFree(GetProcessHeap(), 0, lpDrv);
424 }
425 TRACE("Failed to open driver %s from system.ini file, section %s\n",
426 debugstr_w(lpDriverName), debugstr_w(lpSectionName));
427 return 0;
428
429 the_end:
430 if (lpDrv) TRACE("=> %p\n", lpDrv);
431 return (HDRVR)lpDrv;
432 }
433
434 /**************************************************************************
435 * CloseDriver [WINMM.@]
436 * DrvClose [WINMM.@]
437 */
438 LRESULT WINAPI CloseDriver(HDRVR hDrvr, LONG lParam1, LONG lParam2)
439 {
440 LPWINE_DRIVER lpDrv;
441
442 TRACE("(%p, %08lX, %08lX);\n", hDrvr, lParam1, lParam2);
443
444 if ((lpDrv = DRIVER_FindFromHDrvr(hDrvr)) != NULL)
445 {
446 if (lpDrv->dwFlags & WINE_GDF_16BIT)
447 {
448 if (pFnCloseDriver16)
449 pFnCloseDriver16(lpDrv->d.d16.hDriver16, lParam1, lParam2);
450 }
451 else
452 {
453 DRIVER_SendMessage(lpDrv, DRV_CLOSE, lParam1, lParam2);
454 lpDrv->d.d32.dwDriverID = 0;
455 }
456 if (DRIVER_RemoveFromList(lpDrv)) {
457 if (!(lpDrv->dwFlags & WINE_GDF_16BIT))
458 {
459 LPWINE_DRIVER lpDrv0;
460
461 /* if driver has an opened session instance, we have to close it too */
462 if (DRIVER_GetNumberOfModuleRefs(lpDrv->d.d32.hModule, &lpDrv0) == 1)
463 {
464 DRIVER_SendMessage(lpDrv0, DRV_CLOSE, 0L, 0L);
465 lpDrv0->d.d32.dwDriverID = 0;
466 DRIVER_RemoveFromList(lpDrv0);
467 FreeLibrary(lpDrv0->d.d32.hModule);
468 HeapFree(GetProcessHeap(), 0, lpDrv0);
469 }
470 FreeLibrary(lpDrv->d.d32.hModule);
471 }
472 HeapFree(GetProcessHeap(), 0, lpDrv);
473 return TRUE;
474 }
475 }
476 WARN("Failed to close driver\n");
477 return FALSE;
478 }
479
480 /**************************************************************************
481 * GetDriverFlags [WINMM.@]
482 * [in] hDrvr handle to the driver
483 *
484 * Returns:
485 * 0x00000000 if hDrvr is an invalid handle
486 * 0x80000000 if hDrvr is a valid 32 bit driver
487 * 0x90000000 if hDrvr is a valid 16 bit driver
488 *
489 * native WINMM doesn't return those flags
490 * 0x80000000 for a valid 32 bit driver and that's it
491 * (I may have mixed up the two flags :-(
492 */
493 DWORD WINAPI GetDriverFlags(HDRVR hDrvr)
494 {
495 LPWINE_DRIVER lpDrv;
496 DWORD ret = 0;
497
498 TRACE("(%p)\n", hDrvr);
499
500 if ((lpDrv = DRIVER_FindFromHDrvr(hDrvr)) != NULL) {
501 ret = WINE_GDF_EXIST | lpDrv->dwFlags;
502 }
503 return ret;
504 }
505
506 /**************************************************************************
507 * GetDriverModuleHandle [WINMM.@]
508 * DrvGetModuleHandle [WINMM.@]
509 */
510 HMODULE WINAPI GetDriverModuleHandle(HDRVR hDrvr)
511 {
512 LPWINE_DRIVER lpDrv;
513 HMODULE hModule = 0;
514
515 TRACE("(%p);\n", hDrvr);
516
517 if ((lpDrv = DRIVER_FindFromHDrvr(hDrvr)) != NULL) {
518 if (!(lpDrv->dwFlags & WINE_GDF_16BIT))
519 hModule = lpDrv->d.d32.hModule;
520 }
521 TRACE("=> %p\n", hModule);
522 return hModule;
523 }
524
525 /**************************************************************************
526 * DefDriverProc [WINMM.@]
527 * DrvDefDriverProc [WINMM.@]
528 */
529 LONG WINAPI DefDriverProc(DWORD dwDriverIdentifier, HDRVR hDrv,
530 UINT Msg, LONG lParam1, LONG lParam2)
531 {
532 switch (Msg) {
533 case DRV_LOAD:
534 case DRV_FREE:
535 case DRV_ENABLE:
536 case DRV_DISABLE:
537 return 1;
538 case DRV_INSTALL:
539 case DRV_REMOVE:
540 return DRV_SUCCESS;
541 default:
542 return 0;
543 }
544 }
545
546 /**************************************************************************
547 * DriverCallback [WINMM.@]
548 */
549 BOOL WINAPI DriverCallback(DWORD dwCallBack, UINT uFlags, HDRVR hDev,
550 UINT wMsg, DWORD dwUser, DWORD dwParam1,
551 DWORD dwParam2)
552 {
553 TRACE("(%08lX, %04X, %p, %04X, %08lX, %08lX, %08lX); !\n",
554 dwCallBack, uFlags, hDev, wMsg, dwUser, dwParam1, dwParam2);
555
556 switch (uFlags & DCB_TYPEMASK) {
557 case DCB_NULL:
558 TRACE("Null !\n");
559 if (dwCallBack)
560 WARN("uFlags=%04X has null DCB value, but dwCallBack=%08lX is not null !\n", uFlags, dwCallBack);
561 break;
562 case DCB_WINDOW:
563 TRACE("Window(%04lX) handle=%p!\n", dwCallBack, hDev);
564 PostMessageA((HWND)dwCallBack, wMsg, (WPARAM)hDev, dwParam1);
565 break;
566 case DCB_TASK: /* aka DCB_THREAD */
567 TRACE("Task(%04lx) !\n", dwCallBack);
568 PostThreadMessageA(dwCallBack, wMsg, (WPARAM)hDev, dwParam1);
569 break;
570 case DCB_FUNCTION:
571 TRACE("Function (32 bit) !\n");
572 ((LPDRVCALLBACK)dwCallBack)(hDev, wMsg, dwUser, dwParam1, dwParam2);
573 break;
574 case DCB_EVENT:
575 TRACE("Event(%08lx) !\n", dwCallBack);
576 SetEvent((HANDLE)dwCallBack);
577 break;
578 case 6: /* I would dub it DCB_MMTHREADSIGNAL */
579 /* this is an undocumented DCB_ value used for mmThreads
580 * loword of dwCallBack contains the handle of the lpMMThd block
581 * which dwSignalCount has to be incremented
582 */
583 if (pFnGetMMThread16)
584 {
585 WINE_MMTHREAD* lpMMThd = pFnGetMMThread16(LOWORD(dwCallBack));
586
587 TRACE("mmThread (%04x, %p) !\n", LOWORD(dwCallBack), lpMMThd);
588 /* same as mmThreadSignal16 */
589 InterlockedIncrement((PLONG)&lpMMThd->dwSignalCount);
590 SetEvent(lpMMThd->hEvent);
591 /* some other stuff on lpMMThd->hVxD */
592 }
593 break;
594 #if 0
595 case 4:
596 /* this is an undocumented DCB_ value for... I don't know */
597 break;
598 #endif
599 default:
600 WARN("Unknown callback type %d\n", uFlags & DCB_TYPEMASK);
601 return FALSE;
602 }
603 TRACE("Done\n");
604 return TRUE;
605 }
606
607 /******************************************************************
608 * DRIVER_UnloadAll
609 *
610 *
611 */
612 void DRIVER_UnloadAll(void)
613 {
614 LPWINE_DRIVER lpDrv;
615 LPWINE_DRIVER lpNextDrv = NULL;
616 unsigned count = 0;
617
618 for (lpDrv = lpDrvItemList; lpDrv != NULL; lpDrv = lpNextDrv)
619 {
620 lpNextDrv = lpDrv->lpNextItem;
621 CloseDriver((HDRVR)lpDrv, 0, 0);
622 count++;
623 }
624 TRACE("Unloaded %u drivers\n", count);
625 }