ReactOS 0.4.15-dev-8138-g1e75ea8
registry.c
Go to the documentation of this file.
1/*
2 MME User-Mode Driver Support
3 (c) Andrew Greenwood, 2007.
4
5 This is intended for use with WINE's winmm.dll to allow it to find
6 and load appropriate drivers from the correct (Windows) registry keys.
7
8 By default, WINE's winmm.dll will look in:
9 HKEY_CURRENT_USER\Software\Wine\Drivers
10
11 Here it determines the driver to load based on a value called "Audio".
12
13 Windows NT stores a list of drivers in:
14 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Drivers32
15
16 TODO: Handle system.ini
17*/
18
19#include "winemm.h"
20
22
24{
25 INT driver_count = 0;
26 INT driver_index = 0;
28
29 DWORD value_name_length = 256;
30 char value_name[256];
31
32 DWORD value_data_length = 256;
33 char value_data[256];
34
35 char wavemapper[256] = { 0 };
36 char midimapper[256] = { 0 };
37
38 DWORD value_type;
39
41 {
42 TRACE("ERROR: Could not open: HKEY_LOCAL_MACHINE\\%s\n", key);
43 return 0;
44 }
45
47 driver_index,
48 value_name,
49 &value_name_length,
50 NULL,
51 &value_type,
52 (LPBYTE)value_data,
53 &value_data_length) == ERROR_SUCCESS )
54 {
55 BOOL valid_driver = FALSE;
56 BOOL is_mapper = FALSE;
57
58 if ( value_type == REG_SZ )
59 {
60 /* We look for mappers first so they don't match
61 something else later on! */
62
63 if ( ! stricmp("wavemapper", value_name) )
64 {
65 TRACE("Found a Wave-mapper: %s\n", value_data);
66 /* Delay loading Wave mapper driver */
67 strcpy(wavemapper, value_data);
68 is_mapper = TRUE;
69 driver_count ++;
70 }
71 else if ( ! stricmp("midimapper", value_name) )
72 {
73 TRACE("Found a MIDI-mapper: %s\n", value_data);
74 /* Delay loading MIDI mapper driver */
75 strcpy(midimapper, value_data);
76 is_mapper = TRUE;
77 driver_count ++;
78 }
79 else if ( ! _strnicmp("wave", value_name, 4) )
80 {
81 TRACE("Found a Wave driver: %s\n", value_data);
82 valid_driver = TRUE;
83 driver_count ++;
84 }
85 else if ( ! _strnicmp("midi", value_name, 4) )
86 {
87 TRACE("Found a MIDI driver: %s\n", value_data);
88 valid_driver = TRUE;
89 driver_count ++;
90 }
91 else if ( ! _strnicmp("mixer", value_name, 5) )
92 {
93 TRACE("Found a mixer driver: %s\n", value_data);
94 valid_driver = TRUE;
95 driver_count ++;
96 }
97 else if ( ! _strnicmp("aux", value_name, 4) )
98 {
99 TRACE("Found an aux driver: %s\n", value_data);
100 valid_driver = TRUE;
101 driver_count ++;
102 }
103 else
104 {
105 TRACE("Not supported: %s\n", value_data);
106 }
107
108 /* If we have a valid driver now, we get it "installed" in
109 winmm itself so it can be used */
110
111 if ( valid_driver )
112 {
113 if ( ! MMDRV_Install(value_name, value_data, is_mapper) )
114 {
115 TRACE("FAILED when initializing %s\n", value_data);
116 }
117 }
118 }
119 else
120 {
121 TRACE("Invalid data format\n");
122 }
123
124 /* Reinitialize */
125 value_name_length = 256;
126 value_data_length = 256;
127 memset(value_name, 0, value_name_length);
128 memset(value_data, 0, value_data_length);
129
130 driver_index ++;
131 }
132
133 /* Finally load mapper drivers, since they expect device drivers already loaded */
134 if (*wavemapper)
135 {
136 if (!MMDRV_Install("wavemapper", wavemapper, TRUE))
137 {
138 TRACE("FAILED when initializing %s\n", wavemapper);
139 }
140 }
141
142 if (*midimapper)
143 {
144 if (!MMDRV_Install("midimapper", midimapper, TRUE))
145 {
146 TRACE("FAILED when initializing %s\n", midimapper);
147 }
148 }
149
150 TRACE("Found a total of %d drivers\n", driver_count);
151
152 return driver_count;
153}
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
LONG WINAPI RegOpenKeyA(HKEY hKey, LPCSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3234
#define _strnicmp(_String1, _String2, _MaxCount)
Definition: compat.h:23
#define stricmp(_String1, _String2)
Definition: compat.h:24
BOOL LoadRegistryMMEDrivers(char *key)
Definition: registry.c:23
static unsigned driver_count
Definition: ds3d.c:1254
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
#define REG_SZ
Definition: layer.c:22
BOOL MMDRV_Install(LPCSTR drvRegName, LPCSTR drvFileName, BOOL bIsMapper)
Definition: lolvldrv.c:440
#define memset(x, y, z)
Definition: compat.h:39
#define TRACE(s)
Definition: solgame.cpp:4
Definition: copy.c:22
unsigned char * LPBYTE
Definition: typedefs.h:53
int32_t INT
Definition: typedefs.h:58
static const WCHAR drivers_key[]
Definition: odbccp32.c:44
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define RegEnumValue
Definition: winreg.h:511