- Correct the ulAssemblyRosterIndex member of ACTCTX_SECTION_KEYED_DATA -- it is...
[reactos.git] / reactos / dll / win32 / winmm / registry.c
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 <windows.h>
20 #include "winemm.h"
21 #include "wine/debug.h"
22
23 WINE_DEFAULT_DEBUG_CHANNEL(winmm);
24
25 BOOL LoadRegistryMMEDrivers(char* key)
26 {
27 INT driver_count = 0;
28 INT driver_index = 0;
29 HKEY drivers_key;
30
31 DWORD value_name_length = 256;
32 char value_name[value_name_length];
33
34 DWORD value_data_length = 256;
35 char value_data[value_data_length];
36
37 DWORD value_type;
38
39 if ( RegOpenKeyA(HKEY_LOCAL_MACHINE, key, &drivers_key) != ERROR_SUCCESS )
40 {
41 TRACE("ERROR: Could not open: HKEY_LOCAL_MACHINE\\%s\n", key);
42 return 0;
43 }
44
45 while ( RegEnumValue(drivers_key,
46 driver_index,
47 value_name,
48 &value_name_length,
49 NULL,
50 &value_type,
51 (LPBYTE)value_data,
52 &value_data_length) == ERROR_SUCCESS )
53 {
54 BOOL valid_driver = FALSE;
55 BOOL is_mapper = FALSE;
56
57 if ( value_type == REG_SZ )
58 {
59 /* We look for mappers first so they don't match
60 something else later on! */
61
62 if ( ! stricmp("wavemapper", value_name) )
63 {
64 TRACE("Found a Wave-mapper: %s\n", value_data);
65 valid_driver = TRUE;
66 is_mapper = TRUE;
67 driver_count ++;
68 }
69 else if ( ! stricmp("midimapper", value_name) )
70 {
71 TRACE("Found a MIDI-mapper: %s\n", value_data);
72 valid_driver = TRUE;
73 is_mapper = TRUE;
74 driver_count ++;
75 }
76 else if ( ! _strnicmp("wave", value_name, 4) )
77 {
78 TRACE("Found a Wave driver: %s\n", value_data);
79 valid_driver = TRUE;
80 driver_count ++;
81 }
82 else if ( ! _strnicmp("midi", value_name, 4) )
83 {
84 TRACE("Found a MIDI driver: %s\n", value_data);
85 valid_driver = TRUE;
86 driver_count ++;
87 }
88 else if ( ! _strnicmp("mixer", value_name, 5) )
89 {
90 TRACE("Found a mixer driver: %s\n", value_data);
91 valid_driver = TRUE;
92 driver_count ++;
93 }
94 else if ( ! _strnicmp("aux", value_name, 4) )
95 {
96 TRACE("Found an aux driver: %s\n", value_data);
97 valid_driver = TRUE;
98 driver_count ++;
99 }
100 else
101 {
102 TRACE("Not supported: %s\n", value_data);
103 }
104
105 /* If we have a valid driver now, we get it "installed" in
106 winmm itself so it can be used */
107
108 if ( valid_driver )
109 {
110 if ( ! MMDRV_Install(value_name, value_data, is_mapper) )
111 {
112 TRACE("FAILED when initializing %s\n", value_data);
113 }
114 }
115 }
116 else
117 {
118 TRACE("Invalid data format\n");
119 }
120
121 /* Reinitialize */
122 value_name_length = 256;
123 value_data_length = 256;
124 memset(value_name, 0, value_name_length);
125 memset(value_data, 0, value_data_length);
126
127 driver_index ++;
128 }
129
130 TRACE("Found a total of %d drivers\n", driver_count);
131
132 return driver_count;
133 }