ReactOS 0.4.15-dev-8135-g1bc6c90
driver.c File Reference
#include "winemm.h"
Include dependency graph for driver.c:

Go to the source code of this file.

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (driver)
 
static void DRIVER_Dump (const char *comment)
 
static unsigned DRIVER_GetNumberOfModuleRefs (HMODULE hModule, WINE_DRIVER **found)
 
LPWINE_DRIVER DRIVER_FindFromHDrvr (HDRVR hDrvr)
 
static LRESULT DRIVER_SendMessage (LPWINE_DRIVER lpDrv, UINT msg, LPARAM lParam1, LPARAM lParam2)
 
LRESULT WINAPI SendDriverMessage (HDRVR hDriver, UINT msg, LPARAM lParam1, LPARAM lParam2)
 
static BOOL DRIVER_RemoveFromList (LPWINE_DRIVER lpDrv)
 
static BOOL DRIVER_AddToList (LPWINE_DRIVER lpNewDrv, LPARAM lParam1, LPARAM lParam2)
 
BOOL DRIVER_GetLibName (LPCWSTR keyName, LPCWSTR sectName, LPWSTR buf, int sz)
 
LPWINE_DRIVER DRIVER_TryOpenDriver32 (LPCWSTR fn, LPARAM lParam2)
 
HDRVR WINAPI OpenDriverA (LPCSTR lpDriverName, LPCSTR lpSectionName, LPARAM lParam)
 
HDRVR WINAPI OpenDriver (LPCWSTR lpDriverName, LPCWSTR lpSectionName, LPARAM lParam)
 
LRESULT WINAPI CloseDriver (HDRVR hDrvr, LPARAM lParam1, LPARAM lParam2)
 
DWORD WINAPI GetDriverFlags (HDRVR hDrvr)
 
HMODULE WINAPI GetDriverModuleHandle (HDRVR hDrvr)
 
LRESULT WINAPI DefDriverProc (DWORD_PTR dwDriverIdentifier, HDRVR hDrv, UINT Msg, LPARAM lParam1, LPARAM lParam2)
 
static const charDRIVER_getCallback (DWORD uFlags)
 
BOOL WINAPI DriverCallback (DWORD_PTR dwCallBack, DWORD uFlags, HDRVR hDev, DWORD wMsg, DWORD_PTR dwUser, DWORD_PTR dwParam1, DWORD_PTR dwParam2)
 
void DRIVER_UnloadAll (void)
 

Variables

static CRITICAL_SECTION mmdriver_lock = { &mmdriver_lock_debug, -1, 0, 0, 0, 0 }
 
static CRITICAL_SECTION_DEBUG mmdriver_lock_debug
 
static LPWINE_DRIVER lpDrvItemList
 
static const WCHAR HKLM_BASE []
 

Function Documentation

◆ CloseDriver()

LRESULT WINAPI CloseDriver ( HDRVR  hDrvr,
LPARAM  lParam1,
LPARAM  lParam2 
)

Definition at line 462 of file driver.c.

463{
464 BOOL ret;
465 LPWINE_DRIVER lpDrv;
466
467 TRACE("(%p, %08lX, %08lX);\n", hDrvr, lParam1, lParam2);
468
469 DRIVER_Dump("BEFORE:");
470
471 if ((lpDrv = DRIVER_FindFromHDrvr(hDrvr)) != NULL)
472 {
473 LPWINE_DRIVER lpDrv0;
474
475 DRIVER_SendMessage(lpDrv, DRV_CLOSE, lParam1, lParam2);
476
478
479 if (lpDrv->dwFlags & WINE_GDF_SESSION)
480 FIXME("WINE_GDF_SESSION: Shouldn't happen (%p)\n", lpDrv);
481 /* if driver has an opened session instance, we have to close it too */
482 if (DRIVER_GetNumberOfModuleRefs(lpDrv->hModule, &lpDrv0) == 1 &&
483 (lpDrv0->dwFlags & WINE_GDF_SESSION))
484 {
485 DRIVER_SendMessage(lpDrv0, DRV_CLOSE, 0, 0);
486 DRIVER_RemoveFromList(lpDrv0);
487 FreeLibrary(lpDrv0->hModule);
488 HeapFree(GetProcessHeap(), 0, lpDrv0);
489 }
490 FreeLibrary(lpDrv->hModule);
491
492 HeapFree(GetProcessHeap(), 0, lpDrv);
493 ret = TRUE;
494 }
495 else
496 {
497 WARN("Failed to close driver\n");
498 ret = FALSE;
499 }
500
501 DRIVER_Dump("AFTER:");
502
503 return ret;
504}
#define FIXME(fmt,...)
Definition: debug.h:114
#define WARN(fmt,...)
Definition: debug.h:115
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define GetProcessHeap()
Definition: compat.h:736
#define FreeLibrary(x)
Definition: compat.h:748
#define HeapFree(x, y, z)
Definition: compat.h:735
LPWINE_DRIVER DRIVER_FindFromHDrvr(HDRVR hDrvr)
Definition: driver.c:89
static BOOL DRIVER_RemoveFromList(LPWINE_DRIVER lpDrv)
Definition: driver.c:155
static unsigned DRIVER_GetNumberOfModuleRefs(HMODULE hModule, WINE_DRIVER **found)
Definition: driver.c:63
static LRESULT DRIVER_SendMessage(LPWINE_DRIVER lpDrv, UINT msg, LPARAM lParam1, LPARAM lParam2)
Definition: driver.c:113
static void DRIVER_Dump(const char *comment)
Definition: driver.c:40
unsigned int BOOL
Definition: ntddk_ex.h:94
#define DRV_CLOSE
Definition: mmsystem.h:122
#define TRACE(s)
Definition: solgame.cpp:4
HMODULE hModule
Definition: winemm.h:58
DWORD dwFlags
Definition: winemm.h:57
int ret
#define WINE_GDF_SESSION
Definition: winemm.h:193

Referenced by acmDriverClose(), DRIVER_TryOpenDriver32(), DRIVER_UnloadAll(), ICClose(), ICOpen(), MCI_UnLoadMciDriver(), MCIWndProc(), MMDRV_Exit(), and MMDRV_Install().

◆ DefDriverProc()

LRESULT WINAPI DefDriverProc ( DWORD_PTR  dwDriverIdentifier,
HDRVR  hDrv,
UINT  Msg,
LPARAM  lParam1,
LPARAM  lParam2 
)

Definition at line 554 of file driver.c.

556{
557 switch (Msg) {
558 case DRV_LOAD:
559 case DRV_FREE:
560 case DRV_ENABLE:
561 case DRV_DISABLE:
562 return 1;
563 case DRV_INSTALL:
564 case DRV_REMOVE:
565 return DRV_SUCCESS;
566 default:
567 return 0;
568 }
569}
struct @1637 Msg[]
#define DRV_LOAD(x)
#define DRV_SUCCESS
Definition: mmsystem.h:18
#define DRV_REMOVE
Definition: mmsystem.h:128
#define DRV_ENABLE
Definition: mmsystem.h:120
#define DRV_INSTALL
Definition: mmsystem.h:127
#define DRV_FREE
Definition: mmsystem.h:124
#define DRV_DISABLE
Definition: mmsystem.h:123

Referenced by acm_driver_func(), ADPCM_DriverProc(), DriverProc(), G711_DriverProc(), GSM_DriverProc(), MCIAVI_DriverProc(), MCICDA_DriverProc(), MCIMIDI_DriverProc(), MCIQTZ_DriverProc(), MCIWAVE_DriverProc(), MIDIMAP_DriverProc(), MPEG3_DriverProc(), MSRLE32_DriverProc(), PCM_DriverProc(), and WAVEMAP_DriverProc().

◆ DRIVER_AddToList()

static BOOL DRIVER_AddToList ( LPWINE_DRIVER  lpNewDrv,
LPARAM  lParam1,
LPARAM  lParam2 
)
static

Definition at line 187 of file driver.c.

188{
189 lpNewDrv->dwMagic = WINE_DI_MAGIC;
190 /* First driver to be loaded for this module, need to load correctly the module */
191 /* first of this driver in list ? */
192 if (DRIVER_GetNumberOfModuleRefs(lpNewDrv->hModule, NULL) == 0) {
193 if (DRIVER_SendMessage(lpNewDrv, DRV_LOAD, 0L, 0L) != DRV_SUCCESS) {
194 TRACE("DRV_LOAD failed on driver %p\n", lpNewDrv);
195 return FALSE;
196 }
197 /* returned value is not checked */
198 DRIVER_SendMessage(lpNewDrv, DRV_ENABLE, 0L, 0L);
199 }
200
201 /* Now just open a new instance of a driver on this module */
202 lpNewDrv->dwDriverID = DRIVER_SendMessage(lpNewDrv, DRV_OPEN, lParam1, lParam2);
203
204 if (lpNewDrv->dwDriverID == 0)
205 {
206 TRACE("DRV_OPEN failed on driver %p\n", lpNewDrv);
207 return FALSE;
208 }
209
211
212 lpNewDrv->lpNextItem = NULL;
213 if (lpDrvItemList == NULL) {
214 lpDrvItemList = lpNewDrv;
215 lpNewDrv->lpPrevItem = NULL;
216 } else {
217 LPWINE_DRIVER lpDrv = lpDrvItemList; /* find end of list */
218 while (lpDrv->lpNextItem != NULL)
219 lpDrv = lpDrv->lpNextItem;
220
221 lpDrv->lpNextItem = lpNewDrv;
222 lpNewDrv->lpPrevItem = lpDrv;
223 }
224
226 return TRUE;
227}
static LPWINE_DRIVER lpDrvItemList
Definition: driver.c:36
static CRITICAL_SECTION mmdriver_lock
Definition: driver.c:27
#define DRV_OPEN
Definition: mmsystem.h:121
#define L(x)
Definition: ntvdm.h:50
DWORD dwMagic
Definition: winemm.h:55
struct tagWINE_DRIVER * lpPrevItem
Definition: winemm.h:61
DWORD_PTR dwDriverID
Definition: winemm.h:60
struct tagWINE_DRIVER * lpNextItem
Definition: winemm.h:62
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
#define WINE_DI_MAGIC
Definition: winemm.h:51

Referenced by DRIVER_TryOpenDriver32(), and OpenDriver().

◆ DRIVER_Dump()

static void DRIVER_Dump ( const char comment)
static

Definition at line 40 of file driver.c.

41{
42#if 0
43 LPWINE_DRIVER lpDrv;
44
45 TRACE("%s\n", comment);
46
48
49 for (lpDrv = lpDrvItemList; lpDrv != NULL; lpDrv = lpDrv->lpNextItem)
50 {
51 TRACE("%p, magic %04lx, id %p, next %p\n", lpDrv, lpDrv->dwMagic, lpDrv->d.d32.dwDriverID, lpDrv->lpNextItem);
52 }
53
55#endif
56}
#define comment(fmt, arg1)
Definition: rebar.c:820

Referenced by CloseDriver().

◆ DRIVER_FindFromHDrvr()

LPWINE_DRIVER DRIVER_FindFromHDrvr ( HDRVR  hDrvr)

Definition at line 89 of file driver.c.

90{
92
93 __TRY
94 {
95 d = (LPWINE_DRIVER)hDrvr;
96 if (d && d->dwMagic != WINE_DI_MAGIC) d = NULL;
97 }
99 {
100 return NULL;
101 }
102 __ENDTRY;
103
104 if (d) TRACE("%p -> %p, %p\n", hDrvr, d->lpDrvProc, (void *)d->dwDriverID);
105 else TRACE("%p -> NULL\n", hDrvr);
106
107 return d;
108}
#define __TRY
Definition: compat.h:80
#define __ENDTRY
Definition: compat.h:82
#define __EXCEPT_PAGE_FAULT
Definition: compat.h:81
#define d
Definition: ke_i.h:81
struct tagWINE_DRIVER * LPWINE_DRIVER

Referenced by CloseDriver(), GetDriverFlags(), GetDriverModuleHandle(), MMDRV_Install(), and SendDriverMessage().

◆ DRIVER_getCallback()

static const char * DRIVER_getCallback ( DWORD  uFlags)
static

Definition at line 574 of file driver.c.

575{
576 switch(uFlags & DCB_TYPEMASK) {
577 case DCB_NULL: return "null";
578 case DCB_WINDOW: return "window";
579 case DCB_TASK: return "task";
580 case DCB_EVENT: return "event";
581 case DCB_FUNCTION: return "32bit function";
582 default: return "UNKNOWN";
583 }
584}
UINT uFlags
Definition: api.c:59
#define DCB_EVENT
Definition: mmddk.h:457
#define DCB_TYPEMASK
Definition: mmddk.h:458
#define DCB_FUNCTION
Definition: mmddk.h:456
#define DCB_TASK
Definition: mmddk.h:455
#define DCB_WINDOW
Definition: mmddk.h:454
#define DCB_NULL
Definition: mmddk.h:453

Referenced by DriverCallback().

◆ DRIVER_GetLibName()

BOOL DRIVER_GetLibName ( LPCWSTR  keyName,
LPCWSTR  sectName,
LPWSTR  buf,
int  sz 
)

Definition at line 233 of file driver.c.

234{
235 HKEY hKey, hSecKey;
236 DWORD bufLen, lRet;
237 static const WCHAR wszSystemIni[] = {'S','Y','S','T','E','M','.','I','N','I',0};
238 WCHAR wsznull = '\0';
239
240 /* This takes us as far as Windows NT\CurrentVersion */
242
243 if (lRet == ERROR_SUCCESS)
244 {
245 /* Now we descend into the section name that we were given */
246 lRet = RegOpenKeyExW(hKey, sectName, 0, KEY_QUERY_VALUE, &hSecKey);
247
248 if (lRet == ERROR_SUCCESS)
249 {
250 /* Retrieve the desired value - this is the filename of the lib */
251 bufLen = sz;
252 lRet = RegQueryValueExW(hSecKey, keyName, 0, 0, (void*)buf, &bufLen);
253 RegCloseKey( hSecKey );
254 }
255
256 RegCloseKey( hKey );
257 }
258
259 /* Finish up if we've got what we want from the registry */
260 if (lRet == ERROR_SUCCESS)
261 return TRUE;
262
263 /* default to system.ini if we can't find it in the registry,
264 * to support native installations where system.ini is still used */
265 return GetPrivateProfileStringW(sectName, keyName, &wsznull, buf, sz / sizeof(WCHAR), wszSystemIni);
266}
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
INT WINAPI GetPrivateProfileStringW(LPCWSTR section, LPCWSTR entry, LPCWSTR def_val, LPWSTR buffer, UINT len, LPCWSTR filename)
Definition: profile.c:1142
static const WCHAR HKLM_BASE[]
Definition: driver.c:37
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by MCI_OpenMciDriver(), mciSendStringW(), and OpenDriver().

◆ DRIVER_GetNumberOfModuleRefs()

static unsigned DRIVER_GetNumberOfModuleRefs ( HMODULE  hModule,
WINE_DRIVER **  found 
)
static

Definition at line 63 of file driver.c.

64{
65 LPWINE_DRIVER lpDrv;
66 unsigned count = 0;
67
69
70 if (found) *found = NULL;
71 for (lpDrv = lpDrvItemList; lpDrv; lpDrv = lpDrv->lpNextItem)
72 {
73 if (lpDrv->hModule == hModule)
74 {
75 if (found && !*found) *found = lpDrv;
76 count++;
77 }
78 }
79
81 return count;
82}
HMODULE hModule
Definition: animate.c:44
GLuint GLuint GLsizei count
Definition: gl.h:1545

Referenced by CloseDriver(), DRIVER_AddToList(), DRIVER_RemoveFromList(), and DRIVER_TryOpenDriver32().

◆ DRIVER_RemoveFromList()

static BOOL DRIVER_RemoveFromList ( LPWINE_DRIVER  lpDrv)
static

Definition at line 155 of file driver.c.

156{
157 /* last of this driver in list ? */
158 if (DRIVER_GetNumberOfModuleRefs(lpDrv->hModule, NULL) == 1) {
159 DRIVER_SendMessage(lpDrv, DRV_DISABLE, 0L, 0L);
160 DRIVER_SendMessage(lpDrv, DRV_FREE, 0L, 0L);
161 }
162
164
165 if (lpDrv->lpPrevItem)
166 lpDrv->lpPrevItem->lpNextItem = lpDrv->lpNextItem;
167 else
168 lpDrvItemList = lpDrv->lpNextItem;
169 if (lpDrv->lpNextItem)
170 lpDrv->lpNextItem->lpPrevItem = lpDrv->lpPrevItem;
171 /* trash magic number */
172 lpDrv->dwMagic ^= 0xa5a5a5a5;
173 lpDrv->lpDrvProc = NULL;
174 lpDrv->dwDriverID = 0;
175
177
178 return TRUE;
179}
DRIVERPROC lpDrvProc
Definition: winemm.h:59

Referenced by CloseDriver().

◆ DRIVER_SendMessage()

static LRESULT DRIVER_SendMessage ( LPWINE_DRIVER  lpDrv,
UINT  msg,
LPARAM  lParam1,
LPARAM  lParam2 
)
inlinestatic

Definition at line 113 of file driver.c.

115{
116 LRESULT ret = 0;
117
118 TRACE("Before call32 proc=%p drvrID=%08lx hDrv=%p wMsg=%04x p1=%08lx p2=%08lx\n",
119 lpDrv->lpDrvProc, lpDrv->dwDriverID, lpDrv, msg, lParam1, lParam2);
120 ret = lpDrv->lpDrvProc(lpDrv->dwDriverID, (HDRVR)lpDrv, msg, lParam1, lParam2);
121 TRACE("After call32 proc=%p drvrID=%08lx hDrv=%p wMsg=%04x p1=%08lx p2=%08lx => %08lx\n",
122 lpDrv->lpDrvProc, lpDrv->dwDriverID, lpDrv, msg, lParam1, lParam2, ret);
123
124 return ret;
125}
#define msg(x)
Definition: auth_time.c:54
LONG_PTR LRESULT
Definition: windef.h:209

Referenced by CloseDriver(), DRIVER_AddToList(), DRIVER_RemoveFromList(), and SendDriverMessage().

◆ DRIVER_TryOpenDriver32()

LPWINE_DRIVER DRIVER_TryOpenDriver32 ( LPCWSTR  fn,
LPARAM  lParam2 
)

Definition at line 273 of file driver.c.

274{
275 LPWINE_DRIVER lpDrv = NULL;
276 HMODULE hModule = 0;
277 LPWSTR ptr;
278 LPCSTR cause = 0;
279
280 TRACE("(%s, %08lX);\n", debugstr_w(fn), lParam2);
281
282 if ((ptr = strchrW(fn, ' ')) != NULL)
283 {
284 *ptr++ = '\0';
285
286 while (*ptr == ' ')
287 ptr++;
288
289 if (*ptr == '\0')
290 ptr = NULL;
291 }
292
293 lpDrv = HeapAlloc(GetProcessHeap(), 0, sizeof(WINE_DRIVER));
294
295 if (lpDrv == NULL)
296 {
297 cause = "OOM";
298 goto exit;
299 }
300
301 if ((hModule = LoadLibraryW(fn)) == 0)
302 {
303 cause = "Not a 32 bit lib";
304 goto exit;
305 }
306
307 lpDrv->lpDrvProc = (DRIVERPROC)GetProcAddress(hModule, "DriverProc");
308
309 if (lpDrv->lpDrvProc == NULL)
310 {
311 cause = "no DriverProc";
312 goto exit;
313 }
314
315 lpDrv->dwFlags = 0;
316 lpDrv->hModule = hModule;
317 lpDrv->dwDriverID = 0;
318
319 /* Win32 installable drivers must support a two phase opening scheme:
320 * + first open with NULL as lParam2 (session instance),
321 * + then do a second open with the real non null lParam2)
322 */
323 if (DRIVER_GetNumberOfModuleRefs(lpDrv->hModule, NULL) == 0 && lParam2)
324 {
326
327 if (!DRIVER_AddToList(lpDrv, (LPARAM)ptr, 0L))
328 {
329 cause = "load0 failed";
330 goto exit;
331 }
332 ret = DRIVER_TryOpenDriver32(fn, lParam2);
333 if (!ret)
334 {
335 CloseDriver((HDRVR)lpDrv, 0L, 0L);
336 cause = "load1 failed";
337 goto exit;
338 }
339 return ret;
340 }
341
342 if (!DRIVER_AddToList(lpDrv, (LPARAM)ptr, lParam2))
343 {
344 cause = "load failed";
345 goto exit;
346 }
347
348 TRACE("=> %p\n", lpDrv);
349 return lpDrv;
350
351 exit:
353 HeapFree(GetProcessHeap(), 0, lpDrv);
354 TRACE("Unable to load 32 bit module %s: %s\n", debugstr_w(fn), cause);
355 return NULL;
356}
#define GetProcAddress(x, y)
Definition: compat.h:753
#define HeapAlloc
Definition: compat.h:733
#define LoadLibraryW(x)
Definition: compat.h:747
static BOOL DRIVER_AddToList(LPWINE_DRIVER lpNewDrv, LPARAM lParam1, LPARAM lParam2)
Definition: driver.c:187
LPWINE_DRIVER DRIVER_TryOpenDriver32(LPCWSTR fn, LPARAM lParam2)
Definition: driver.c:273
LRESULT WINAPI CloseDriver(HDRVR hDrvr, LPARAM lParam1, LPARAM lParam2)
Definition: driver.c:462
#define debugstr_w
Definition: kernel32.h:32
LRESULT(CALLBACK * DRIVERPROC)(DWORD_PTR, HDRVR, UINT, LPARAM, LPARAM)
Definition: mmsystem.h:1001
static PVOID ptr
Definition: dispmode.c:27
#define strchrW(s, c)
Definition: unicode.h:40
#define exit(n)
Definition: config.h:202
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159
LONG_PTR LPARAM
Definition: windef.h:208
const char * LPCSTR
Definition: xmlstorage.h:183
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by DRIVER_TryOpenDriver32(), MCI_OpenMciDriver(), and OpenDriver().

◆ DRIVER_UnloadAll()

void DRIVER_UnloadAll ( void  )

Definition at line 658 of file driver.c.

659{
660 LPWINE_DRIVER lpDrv;
661 LPWINE_DRIVER lpNextDrv = NULL;
662 unsigned count = 0;
663
664restart:
666
667 for (lpDrv = lpDrvItemList; lpDrv != NULL; lpDrv = lpNextDrv)
668 {
669 lpNextDrv = lpDrv->lpNextItem;
670
671 /* session instances will be unloaded automatically */
672 if (!(lpDrv->dwFlags & WINE_GDF_SESSION))
673 {
675 CloseDriver((HDRVR)lpDrv, 0, 0);
676 count++;
677 /* restart from the beginning of the list */
678 goto restart;
679 }
680 }
681
683
684 TRACE("Unloaded %u drivers\n", count);
685}
void restart(int argc, const char *argv[])
Definition: cmds.c:2115

Referenced by DllMain().

◆ DriverCallback()

BOOL WINAPI DriverCallback ( DWORD_PTR  dwCallBack,
DWORD  uFlags,
HDRVR  hDev,
DWORD  wMsg,
DWORD_PTR  dwUser,
DWORD_PTR  dwParam1,
DWORD_PTR  dwParam2 
)

Definition at line 589 of file driver.c.

592{
593 BOOL ret = FALSE;
594 TRACE("(%08lX, %s %04X, %p, %04X, %08lX, %08lX, %08lX)\n",
595 dwCallBack, DRIVER_getCallback(uFlags), uFlags, hDev, wMsg, dwUser, dwParam1, dwParam2);
596 if (!dwCallBack)
597 return ret;
598
599 switch (uFlags & DCB_TYPEMASK) {
600 case DCB_NULL:
601 /* Native returns FALSE = no notification, not TRUE */
602 return ret;
603 case DCB_WINDOW:
604 ret = PostMessageA((HWND)dwCallBack, wMsg, (WPARAM)hDev, dwParam1);
605 break;
606 case DCB_TASK: /* aka DCB_THREAD */
607 ret = PostThreadMessageA(dwCallBack, wMsg, (WPARAM)hDev, dwParam1);
608 break;
609 case DCB_FUNCTION:
610 ((LPDRVCALLBACK)dwCallBack)(hDev, wMsg, dwUser, dwParam1, dwParam2);
611 ret = TRUE;
612 break;
613 case DCB_EVENT:
614 ret = SetEvent((HANDLE)dwCallBack);
615 break;
616#if 0
617 /* FIXME: for now only usable in mmsystem.dll16
618 * If needed, should be enabled back
619 */
620 case 6: /* I would dub it DCB_MMTHREADSIGNAL */
621 /* this is an undocumented DCB_ value used for mmThreads
622 * loword of dwCallBack contains the handle of the lpMMThd block
623 * which dwSignalCount has to be incremented
624 */
625 if (pFnGetMMThread16)
626 {
627 WINE_MMTHREAD* lpMMThd = pFnGetMMThread16(LOWORD(dwCallBack));
628
629 TRACE("mmThread (%04x, %p) !\n", LOWORD(dwCallBack), lpMMThd);
630 /* same as mmThreadSignal16 */
631 InterlockedIncrement(&lpMMThd->dwSignalCount);
632 SetEvent(lpMMThd->hEvent);
633 /* some other stuff on lpMMThd->hVxD */
634 }
635 break;
636#endif
637#if 0
638 case 4:
639 /* this is an undocumented DCB_ value for... I don't know */
640 break;
641#endif
642 default:
643 WARN("Unknown callback type %d\n", uFlags & DCB_TYPEMASK);
644 return FALSE;
645 }
646 if (ret)
647 TRACE("Done\n");
648 else
649 WARN("Notification failure\n");
650 return ret;
651}
#define InterlockedIncrement
Definition: armddk.h:53
static const char * DRIVER_getCallback(DWORD uFlags)
Definition: driver.c:574
DRVCALLBACK * LPDRVCALLBACK
Definition: mmsystem.h:1003
#define LOWORD(l)
Definition: pedump.c:82
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
UINT_PTR WPARAM
Definition: windef.h:207
BOOL WINAPI PostThreadMessageA(_In_ DWORD, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI PostMessageA(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

◆ GetDriverFlags()

DWORD WINAPI GetDriverFlags ( HDRVR  hDrvr)

Definition at line 519 of file driver.c.

520{
521 LPWINE_DRIVER lpDrv;
522 DWORD ret = 0;
523
524 TRACE("(%p)\n", hDrvr);
525
526 if ((lpDrv = DRIVER_FindFromHDrvr(hDrvr)) != NULL) {
528 }
529 return ret;
530}
#define WINE_GDF_EXIST
Definition: winemm.h:191
#define WINE_GDF_EXTERNAL_MASK
Definition: winemm.h:192

◆ GetDriverModuleHandle()

HMODULE WINAPI GetDriverModuleHandle ( HDRVR  hDrvr)

Definition at line 536 of file driver.c.

537{
538 LPWINE_DRIVER lpDrv;
539 HMODULE hModule = 0;
540
541 TRACE("(%p);\n", hDrvr);
542
543 if ((lpDrv = DRIVER_FindFromHDrvr(hDrvr)) != NULL) {
544 hModule = lpDrv->hModule;
545 }
546 TRACE("=> %p\n", hModule);
547 return hModule;
548}

Referenced by MCI_HandleReturnValues().

◆ OpenDriver()

HDRVR WINAPI OpenDriver ( LPCWSTR  lpDriverName,
LPCWSTR  lpSectionName,
LPARAM  lParam 
)

Definition at line 400 of file driver.c.

401{
402 LPWINE_DRIVER lpDrv = NULL;
403 WCHAR libName[128];
404 LPCWSTR lsn = lpSectionName;
405
406 TRACE("(%s, %s, 0x%08lx);\n",
407 debugstr_w(lpDriverName), debugstr_w(lpSectionName), lParam);
408
409 /* If no section name is specified, either the caller is intending on
410 opening a driver by filename, or wants to open a user-installable
411 driver that has an entry in the Drivers32 key in the registry */
412 if (lsn == NULL)
413 {
414 /* Default registry key */
415 static const WCHAR wszDrivers32[] = {'D','r','i','v','e','r','s','3','2',0};
416
417 lstrcpynW(libName, lpDriverName, sizeof(libName) / sizeof(WCHAR));
418
419 /* Try and open the driver by filename */
420 if ( (lpDrv = DRIVER_TryOpenDriver32(libName, lParam)) )
421 goto the_end;
422
423 /* If we got here, the file wasn't found. So we assume the caller
424 wanted a driver specified under the Drivers32 registry key */
425 lsn = wszDrivers32;
426 }
427
428 /* Attempt to locate the driver filename in the registry */
429 if ( DRIVER_GetLibName(lpDriverName, lsn, libName, sizeof(libName)) )
430 {
431 /* Now we have the filename, we can try and load it */
432 if ( (lpDrv = DRIVER_TryOpenDriver32(libName, lParam)) )
433 goto the_end;
434 }
435
436 /* now we will try a 16 bit driver (and add all the glue to make it work... which
437 * is located in our mmsystem implementation)
438 * so ensure, we can load our mmsystem, otherwise just fail
439 */
441#if 0
442 if (pFnOpenDriver16 &&
443 (lpDrv = pFnOpenDriver16(lpDriverName, lpSectionName, lParam)))
444 {
445 if (DRIVER_AddToList(lpDrv, 0, lParam)) goto the_end;
446 HeapFree(GetProcessHeap(), 0, lpDrv);
447 }
448 TRACE("Failed to open driver %s from system.ini file, section %s\n",
449 debugstr_w(lpDriverName), debugstr_w(lpSectionName));
450#endif
451 return 0;
452
453 the_end:
454 if (lpDrv) TRACE("=> %p\n", lpDrv);
455 return (HDRVR)lpDrv;
456}
LPARAM lParam
Definition: combotst.c:139
#define lstrcpynW
Definition: compat.h:738
BOOL DRIVER_GetLibName(LPCWSTR keyName, LPCWSTR sectName, LPWSTR buf, int sz)
Definition: driver.c:233
BOOL WINMM_CheckForMMSystem(void)
Definition: winmm.c:86
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by acmDriverOpen(), ICOpen(), MCIWndProc(), MSACM_FormatEnumHelper(), and OpenDriverA().

◆ OpenDriverA()

HDRVR WINAPI OpenDriverA ( LPCSTR  lpDriverName,
LPCSTR  lpSectionName,
LPARAM  lParam 
)

Definition at line 365 of file driver.c.

366{
367 INT len;
368 LPWSTR dn = NULL;
369 LPWSTR sn = NULL;
370 HDRVR ret = 0;
371
372 if (lpDriverName)
373 {
374 len = MultiByteToWideChar( CP_ACP, 0, lpDriverName, -1, NULL, 0 );
375 dn = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
376 if (!dn) goto done;
377 MultiByteToWideChar( CP_ACP, 0, lpDriverName, -1, dn, len );
378 }
379
380 if (lpSectionName)
381 {
382 len = MultiByteToWideChar( CP_ACP, 0, lpSectionName, -1, NULL, 0 );
383 sn = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
384 if (!sn) goto done;
385 MultiByteToWideChar( CP_ACP, 0, lpSectionName, -1, sn, len );
386 }
387
388 ret = OpenDriver(dn, sn, lParam);
389
390done:
391 HeapFree(GetProcessHeap(), 0, dn);
392 HeapFree(GetProcessHeap(), 0, sn);
393 return ret;
394}
#define CP_ACP
Definition: compat.h:109
#define MultiByteToWideChar
Definition: compat.h:110
HDRVR WINAPI OpenDriver(LPCWSTR lpDriverName, LPCWSTR lpSectionName, LPARAM lParam)
Definition: driver.c:400
GLenum GLsizei len
Definition: glext.h:6722
int32_t INT
Definition: typedefs.h:58

Referenced by JOY_LoadDriver(), and MMDRV_Install().

◆ SendDriverMessage()

LRESULT WINAPI SendDriverMessage ( HDRVR  hDriver,
UINT  msg,
LPARAM  lParam1,
LPARAM  lParam2 
)

Definition at line 131 of file driver.c.

133{
134 LPWINE_DRIVER lpDrv;
135 LRESULT retval = 0;
136
137 TRACE("(%p, %04X, %08lX, %08lX)\n", hDriver, msg, lParam1, lParam2);
138
139 if ((lpDrv = DRIVER_FindFromHDrvr(hDriver)) != NULL) {
140 retval = DRIVER_SendMessage(lpDrv, msg, lParam1, lParam2);
141 } else {
142 WARN("Bad driver handle %p\n", hDriver);
143 }
144 TRACE("retval = %ld\n", retval);
145
146 return retval;
147}
_In_ LPWSTR _In_ ULONG _In_ ULONG _In_ ULONG _Out_ DEVINFO _In_ HDEV _In_ LPWSTR _In_ HANDLE hDriver
Definition: winddi.h:3557

Referenced by joyGetDevCapsW(), joyGetNumDevs(), joyGetPos(), joyGetPosEx(), MCI_SendCommandFrom32(), MCIWndProc(), MSACM_FormatEnumHelper(), MSACM_Message(), and MSVIDEO_SendMessage().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( driver  )

Variable Documentation

◆ HKLM_BASE

const WCHAR HKLM_BASE[]
static
Initial value:
= {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
'W','i','n','d','o','w','s',' ','N','T','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n',0}

Definition at line 37 of file driver.c.

Referenced by DRIVER_GetLibName().

◆ lpDrvItemList

◆ mmdriver_lock

static CRITICAL_SECTION mmdriver_lock = { &mmdriver_lock_debug, -1, 0, 0, 0, 0 }
static

◆ mmdriver_lock_debug

CRITICAL_SECTION_DEBUG mmdriver_lock_debug
static
Initial value:
=
{
0, 0, &mmdriver_lock,
0, 0, { (DWORD_PTR)(__FILE__ ": mmdriver_lock") }
}
static CRITICAL_SECTION_DEBUG mmdriver_lock_debug
Definition: driver.c:28
LIST_ENTRY ProcessLocksList
Definition: winbase.h:883
#define DWORD_PTR
Definition: treelist.c:76

Definition at line 28 of file driver.c.