Author: janderwald
Date: Fri Dec 18 11:42:29 2009
New Revision: 44647
URL:
http://svn.reactos.org/svn/reactos?rev=44647&view=rev
Log:
[WDMAUD.DRV]
- Add support for Opening/Querying/Closing registry keys within the mmixer library
Modified:
trunk/reactos/dll/win32/wdmaud.drv/mmixer.c
Modified: trunk/reactos/dll/win32/wdmaud.drv/mmixer.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/wdmaud.drv/mmixe…
==============================================================================
--- trunk/reactos/dll/win32/wdmaud.drv/mmixer.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/wdmaud.drv/mmixer.c [iso-8859-1] Fri Dec 18 11:42:29 2009
@@ -16,7 +16,10 @@
VOID Copy(PVOID Src, PVOID Dst, ULONG NumBytes);
MIXER_STATUS Open(IN LPWSTR DevicePath, OUT PHANDLE hDevice);
MIXER_STATUS Control(IN HANDLE hMixer, IN ULONG dwIoControlCode, IN PVOID lpInBuffer, IN
ULONG nInBufferSize, OUT PVOID lpOutBuffer, ULONG nOutBufferSize, PULONG
lpBytesReturned);
-MIXER_STATUS Enum(IN PVOID EnumContext, IN ULONG DeviceIndex, OUT LPWSTR * DeviceName,
OUT PHANDLE OutHandle);
+MIXER_STATUS Enum(IN PVOID EnumContext, IN ULONG DeviceIndex, OUT LPWSTR * DeviceName,
OUT PHANDLE OutHandle, OUT PHANDLE OutKey);
+MIXER_STATUS OpenKey(IN HANDLE hKey, IN LPWSTR SubKey, IN ULONG DesiredAccess, OUT
PHANDLE OutKey);
+MIXER_STATUS CloseKey(IN HANDLE hKey);
+MIXER_STATUS QueryKeyValue(IN HANDLE hKey, IN LPWSTR KeyName, OUT PVOID * ResultBuffer,
OUT PULONG ResultLength, OUT PULONG KeyType);
MIXER_CONTEXT MixerContext =
{
@@ -27,10 +30,58 @@
Free,
Open,
Close,
- Copy
+ Copy,
+ OpenKey,
+ QueryKeyValue,
+ CloseKey
};
GUID CategoryGuid = {STATIC_KSCATEGORY_AUDIO};
+
+MIXER_STATUS
+QueryKeyValue(
+ IN HANDLE hKey,
+ IN LPWSTR KeyName,
+ OUT PVOID * ResultBuffer,
+ OUT PULONG ResultLength,
+ OUT PULONG KeyType)
+{
+ if (RegQueryValueExW((HKEY)hKey, KeyName, NULL, KeyType, NULL, ResultLength) ==
ERROR_FILE_NOT_FOUND)
+ return MM_STATUS_UNSUCCESSFUL;
+
+ *ResultBuffer = HeapAlloc(GetProcessHeap(), 0, *ResultLength);
+ if (*ResultBuffer == NULL)
+ return MM_STATUS_NO_MEMORY;
+
+ if (RegQueryValueExW((HKEY)hKey, KeyName, NULL, KeyType, *ResultBuffer, ResultLength)
!= ERROR_SUCCESS)
+ {
+ HeapFree(GetProcessHeap(), 0, *ResultBuffer);
+ return MM_STATUS_UNSUCCESSFUL;
+ }
+ return MM_STATUS_SUCCESS;
+}
+
+MIXER_STATUS
+OpenKey(
+ IN HANDLE hKey,
+ IN LPWSTR SubKey,
+ IN ULONG DesiredAccess,
+ OUT PHANDLE OutKey)
+{
+ if (RegOpenKeyExW((HKEY)hKey, SubKey, 0, DesiredAccess, (PHKEY)OutKey) ==
ERROR_SUCCESS)
+ return MM_STATUS_SUCCESS;
+
+ return MM_STATUS_UNSUCCESSFUL;
+}
+
+MIXER_STATUS
+CloseKey(
+ IN HANDLE hKey)
+{
+ RegCloseKey((HKEY)hKey);
+ return MM_STATUS_SUCCESS;
+}
+
PVOID Alloc(ULONG NumBytes)
{
@@ -151,13 +202,15 @@
IN PVOID EnumContext,
IN ULONG DeviceIndex,
OUT LPWSTR * DeviceName,
- OUT PHANDLE OutHandle)
+ OUT PHANDLE OutHandle,
+ OUT PHANDLE OutKey)
{
SP_DEVICE_INTERFACE_DATA InterfaceData;
SP_DEVINFO_DATA DeviceData;
PSP_DEVICE_INTERFACE_DETAIL_DATA_W DetailData;
BOOL Result;
DWORD Length;
+ MIXER_STATUS Status;
//printf("Enum EnumContext %p DeviceIndex %lu OutHandle %p\n", EnumContext,
DeviceIndex, OutHandle);
@@ -196,12 +249,40 @@
if (!Result)
{
- return MM_STATUS_UNSUCCESSFUL;
- }
-
- // copy path
- *DeviceName = (LPWSTR)&DetailData->DevicePath[0];
- return Open(DetailData->DevicePath, OutHandle);
+ DPRINT("SetupDiGetDeviceInterfaceDetailW failed with %lu\n",
GetLastError());
+ return MM_STATUS_UNSUCCESSFUL;
+ }
+
+
+ *OutKey = SetupDiOpenDeviceInterfaceRegKey(EnumContext, &InterfaceData, 0,
KEY_READ);
+ if ((HKEY)*OutKey == INVALID_HANDLE_VALUE)
+ {
+ HeapFree(GetProcessHeap(), 0, DetailData);
+ return MM_STATUS_UNSUCCESSFUL;
+ }
+
+ Status = Open(DetailData->DevicePath, OutHandle);
+
+ if (Status != MM_STATUS_SUCCESS)
+ {
+ RegCloseKey((HKEY)*OutKey);
+ HeapFree(GetProcessHeap(), 0, DetailData);
+ return Status;
+ }
+
+ *DeviceName = (LPWSTR)HeapAlloc(GetProcessHeap(), 0,
(wcslen(DetailData->DevicePath)+1) * sizeof(WCHAR));
+ if (*DeviceName == NULL)
+ {
+ CloseHandle(*OutHandle);
+ RegCloseKey((HKEY)*OutKey);
+ HeapFree(GetProcessHeap(), 0, DetailData);
+ return MM_STATUS_NO_MEMORY;
+ }
+
+ wcscpy(*DeviceName, DetailData->DevicePath);
+ HeapFree(GetProcessHeap(), 0, DetailData);
+
+ return Status;
}
BOOL