Author: silverblade
Date: Wed Sep 12 04:29:07 2007
New Revision: 29011
URL:
http://svn.reactos.org/svn/reactos?rev=29011&view=rev
Log:
Modified WINE's winmm.dll to support loading of user-installable drivers
from the registry 'Drivers' and 'Drivers32' keys, as Windows does. Also
silenced the beep-MIDI driver (which is supported by winmm! - but
doesn't seem to do much, at least under vmware.)
Added some Drivers32 entries to be loaded by default, to the hivesft.inf
file.
Added:
trunk/reactos/dll/win32/winmm/registry.c
Modified:
trunk/reactos/boot/bootdata/hivesft.inf
trunk/reactos/boot/bootdata/packages/reactos.dff
trunk/reactos/dll/win32/beepmidi/beepmidi.c
trunk/reactos/dll/win32/winmm/lolvldrv.c
trunk/reactos/dll/win32/winmm/winemm.h
trunk/reactos/dll/win32/winmm/winmm.rbuild
Modified: trunk/reactos/boot/bootdata/hivesft.inf
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/bootdata/hivesft.inf?…
==============================================================================
--- trunk/reactos/boot/bootdata/hivesft.inf (original)
+++ trunk/reactos/boot/bootdata/hivesft.inf Wed Sep 12 04:29:07 2007
@@ -24,6 +24,12 @@
;HKLM,"Software\Microsoft\Windows NT\CurrentVersion\Image File Execution
Options\loaddll.exe","GlobalFlag",0x00000000,"0x00000002"
;HKLM,"Software\Microsoft\Windows NT\CurrentVersion\Image File Execution
Options\soffice.exe","GlobalFlag",0x00000000,"0x00000002"
;HKLM,"Software\Microsoft\Windows NT\CurrentVersion\Image File Execution
Options\tlstest.exe","GlobalFlag",0x00000000,"0x00000002"
+
+; MME - TODO: Should not require full paths!
+HKLM,"SOFTWARE\Microsoft\Windows
NT\CurrentVersion\Drivers32","midimapper",0x00000000,"c:\reactos\system32\midimap.dll"
+HKLM,"SOFTWARE\Microsoft\Windows
NT\CurrentVersion\Drivers32","wavemapper",0x00000000,"c:\reactos\system32\msacm32.dll"
+;HKLM,"SOFTWARE\Microsoft\Windows
NT\CurrentVersion\Drivers32","wave",0x00000000,"sndblst.dll"
+HKLM,"SOFTWARE\Microsoft\Windows
NT\CurrentVersion\Drivers32","midi",0x00000000,"c:\reactos\system32\beepmidi.dll"
; Mesa OpenGL Driver
HKLM,"SOFTWARE\Microsoft\Windows
NT\CurrentVersion\OpenGLDrivers","DefaultDriver",0x00000000,"Mesa"
Modified: trunk/reactos/boot/bootdata/packages/reactos.dff
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/bootdata/packages/rea…
==============================================================================
--- trunk/reactos/boot/bootdata/packages/reactos.dff (original)
+++ trunk/reactos/boot/bootdata/packages/reactos.dff Wed Sep 12 04:29:07 2007
@@ -251,6 +251,7 @@
dll\win32\wshirda\wshirda.dll 1
dll\win32\wsock32\wsock32.dll 1
dll\win32\wtsapi32\wtsapi32.dll 1
+dll\win32\beepmidi\beepmidi.dll 1
; Drivers
Modified: trunk/reactos/dll/win32/beepmidi/beepmidi.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/beepmidi/beepmid…
==============================================================================
--- trunk/reactos/dll/win32/beepmidi/beepmidi.c (original)
+++ trunk/reactos/dll/win32/beepmidi/beepmidi.c Wed Sep 12 04:29:07 2007
@@ -51,8 +51,8 @@
#include <mmddk.h>
#include <mmsystem.h>
-#define DPRINT printf
-//#define DPRINT //
+/*#define DPRINT printf*/
+#define DPRINT FakePrintf
/* A few MIDI command categories */
#define MIDI_NOTE_OFF 0x80
Modified: trunk/reactos/dll/win32/winmm/lolvldrv.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/winmm/lolvldrv.c…
==============================================================================
--- trunk/reactos/dll/win32/winmm/lolvldrv.c (original)
+++ trunk/reactos/dll/win32/winmm/lolvldrv.c Wed Sep 12 04:29:07 2007
@@ -620,7 +620,7 @@
/**************************************************************************
* MMDRV_Install [internal]
*/
-static BOOL MMDRV_Install(LPCSTR drvRegName, LPCSTR drvFileName, BOOL bIsMapper)
+BOOL MMDRV_Install(LPCSTR drvRegName, LPCSTR drvFileName, BOOL bIsMapper)
{
int i, count = 0;
LPWINE_MM_DRIVER lpDrv = &MMDrvs[MMDrvsHi];
@@ -723,6 +723,8 @@
*/
BOOL MMDRV_Init(void)
{
+/* Redundant code, keeping this for reference only (for now) */
+#if 0
HKEY hKey;
char driver_buffer[256];
char mapper_buffer[256];
@@ -743,13 +745,21 @@
strcpy(driver_buffer, WINE_DEFAULT_WINMM_DRIVER);
}
- // AG: TESTING:
- ret |= MMDRV_Install("mmdrv.dll", "mmdrv.dll", FALSE);
+ ret |= MMDRV_Install("beepmidi.dll", "beepmidi.dll", FALSE);
ret |= MMDRV_Install("wavemapper", WINE_DEFAULT_WINMM_MAPPER, TRUE);
ret |= MMDRV_Install("midimapper", WINE_DEFAULT_WINMM_MIDI, TRUE);
return ret;
-
+#else
+ INT driver_count = 0;
+
+ driver_count += LoadRegistryMMEDrivers(NT_MME_DRIVERS_KEY);
+ driver_count += LoadRegistryMMEDrivers(NT_MME_DRIVERS32_KEY);
+
+ /* Explorer doesn't like us failing */
+ return TRUE;
+// return ( driver_count > 0 );
+#endif
}
/******************************************************************
Added: trunk/reactos/dll/win32/winmm/registry.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/winmm/registry.c…
==============================================================================
--- trunk/reactos/dll/win32/winmm/registry.c (added)
+++ trunk/reactos/dll/win32/winmm/registry.c Wed Sep 12 04:29:07 2007
@@ -1,0 +1,134 @@
+/*
+ MME User-Mode Driver Support
+ (c) Andrew Greenwood, 2007.
+
+ This is intended for use with WINE's winmm.dll to allow it to find
+ and load appropriate drivers from the correct (Windows) registry keys.
+
+ By default, WINE's winmm.dll will look in:
+ HKEY_CURRENT_USER\Software\Wine\Drivers
+
+ Here it determines the driver to load based on a value called "Audio".
+
+ Windows NT stores a list of drivers in:
+ HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Drivers32
+
+ TODO: Handle system.ini
+*/
+
+#include <windows.h>
+#include "winemm.h"
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(winmm);
+
+BOOL LoadRegistryMMEDrivers(char* key)
+{
+ INT driver_count = 0;
+ INT driver_index = 0;
+ HKEY drivers_key;
+ BOOL ret;
+
+ DWORD value_name_length = 256;
+ char value_name[value_name_length];
+
+ DWORD value_data_length = 256;
+ char value_data[value_data_length];
+
+ DWORD value_type;
+
+ if ( RegOpenKeyA(HKEY_LOCAL_MACHINE, key, &drivers_key) != ERROR_SUCCESS )
+ {
+ TRACE("ERROR: Could not open: HKEY_LOCAL_MACHINE\\%s\n", key);
+ return 0;
+ }
+
+ while ( RegEnumValue(drivers_key,
+ driver_index,
+ value_name,
+ &value_name_length,
+ NULL,
+ &value_type,
+ value_data,
+ &value_data_length) == ERROR_SUCCESS )
+ {
+ BOOL valid_driver = FALSE;
+ BOOL is_mapper = FALSE;
+
+ if ( value_type == REG_SZ )
+ {
+ /* We look for mappers first so they don't match
+ something else later on! */
+
+ if ( ! stricmp("wavemapper", value_name) )
+ {
+ TRACE("Found a Wave-mapper: %s\n", value_data);
+ valid_driver = TRUE;
+ is_mapper = TRUE;
+ driver_count ++;
+ }
+ else if ( ! stricmp("midimapper", value_name) )
+ {
+ TRACE("Found a MIDI-mapper: %s\n", value_data);
+ valid_driver = TRUE;
+ is_mapper = TRUE;
+ driver_count ++;
+ }
+ else if ( ! strnicmp("wave", value_name, 4) )
+ {
+ TRACE("Found a Wave driver: %s\n", value_data);
+ valid_driver = TRUE;
+ driver_count ++;
+ }
+ else if ( ! strnicmp("midi", value_name, 4) )
+ {
+ TRACE("Found a MIDI driver: %s\n", value_data);
+ valid_driver = TRUE;
+ driver_count ++;
+ }
+ else if ( ! strnicmp("mixer", value_name, 5) )
+ {
+ TRACE("Found a mixer driver: %s\n", value_data);
+ valid_driver = TRUE;
+ driver_count ++;
+ }
+ else if ( ! strnicmp("aux", value_name, 4) )
+ {
+ TRACE("Found an aux driver: %s\n", value_data);
+ valid_driver = TRUE;
+ driver_count ++;
+ }
+ else
+ {
+ TRACE("Not supported: %s\n", value_data);
+ }
+
+ /* If we have a valid driver now, we get it "installed" in
+ winmm itself so it can be used */
+
+ if ( valid_driver )
+ {
+ if ( ! MMDRV_Install(value_name, value_data, is_mapper) )
+ {
+ TRACE("FAILED when initializing %s\n", value_data);
+ }
+ }
+ }
+ else
+ {
+ TRACE("Invalid data format\n");
+ }
+
+ /* Reinitialize */
+ value_name_length = 256;
+ value_data_length = 256;
+ memset(value_name, 0, value_name_length);
+ memset(value_data, 0, value_data_length);
+
+ driver_index ++;
+ }
+
+ TRACE("Found a total of %d drivers\n", driver_count);
+
+ return driver_count;
+}
Modified: trunk/reactos/dll/win32/winmm/winemm.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/winmm/winemm.h?r…
==============================================================================
--- trunk/reactos/dll/win32/winmm/winemm.h (original)
+++ trunk/reactos/dll/win32/winmm/winemm.h Wed Sep 12 04:29:07 2007
@@ -315,3 +315,14 @@
*/
#define WINE_GDF_EXIST 0x80000000
#define WINE_GDF_16BIT 0x10000000
+
+/* Modification to take into account Windows NT's registry format */
+
+#define NT_MME_DRIVERS32_KEY \
+ "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Drivers32"
+
+#define NT_MME_DRIVERS_KEY \
+ "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Drivers"
+
+INT LoadRegistryMMEDrivers(char* key);
+BOOL MMDRV_Install(LPCSTR drvRegName, LPCSTR drvFileName, BOOL bIsMapper);
Modified: trunk/reactos/dll/win32/winmm/winmm.rbuild
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/winmm/winmm.rbui…
==============================================================================
--- trunk/reactos/dll/win32/winmm/winmm.rbuild (original)
+++ trunk/reactos/dll/win32/winmm/winmm.rbuild Wed Sep 12 04:29:07 2007
@@ -27,7 +27,8 @@
<file>playsound.c</file>
<file>time.c</file>
<file>winmm.c</file>
+ <file>registry.c</file>
<file>winmm_res.rc</file>
<file>winmm.spec</file>
</module>
-</group>
+</group>