ReactOS  0.4.14-dev-1034-g1e60116
registry.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS Sound System "MME Buddy" NT4 Library
3  * LICENSE: GPL - See COPYING in the top level directory
4  * FILE: lib/drivers/sound/mment4/registry.c
5  *
6  * PURPOSE: Registry operation helper for audio device drivers.
7  *
8  * PROGRAMMERS: Andrew Greenwood (silverblade@reactos.org)
9 */
10 
11 #include "precomp.h"
12 
13 #include <mmebuddy_debug.h>
14 
15 /*
16  Open the parameters key of a sound driver.
17  NT4 only.
18 */
23 {
24  SIZE_T KeyLength;
25  PWCHAR ParametersKeyName;
26 
29 
30  /* Work out how long the string will be */
31  KeyLength = wcslen(REG_SERVICES_KEY_NAME_U) + 1
32  + wcslen(ServiceName) + 1
34 
35  /* Allocate memory for the string */
36  ParametersKeyName = AllocateWideString(KeyLength);
37 
38  if ( ! ParametersKeyName )
39  return MMSYSERR_NOMEM;
40 
41  /* Construct the registry path */
42  wsprintf(ParametersKeyName,
43  L"%s\\%s\\%s",
47 
48  SND_TRACE(L"Opening reg key: %wS\n", ParametersKeyName);
49 
50  /* Perform the open */
52  ParametersKeyName,
53  0,
54  KEY_READ,
56  {
57  /* Couldn't open the key */
58  SND_ERR(L"Failed to open reg key: %wS\n", ParametersKeyName);
59  FreeMemory(ParametersKeyName);
60  return MMSYSERR_ERROR;
61  }
62 
63  FreeMemory(ParametersKeyName);
64 
65  return MMSYSERR_NOERROR;
66 }
67 
68 /*
69  Open one of the Device sub-keys belonging to the sound driver.
70  NT4 only.
71 */
75  IN DWORD DeviceIndex,
77 {
79  PWCHAR RegPath;
80 
83 
84  /*
85  Work out the space required to hold the path:
86 
87  HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\
88  sndblst\
89  Parameters\
90  Device123\
91  */
93  + wcslen(ServiceName) + 1
96  + GetDigitCount(DeviceIndex);
97 
98  /* Allocate storage for the string */
99  RegPath = AllocateWideString(PathLength);
100 
101  if ( ! RegPath )
102  {
103  return MMSYSERR_NOMEM;
104  }
105 
106  /* Write the path */
107  wsprintf(RegPath,
108  L"%ls\\%ls\\%ls\\%ls%d",
110  ServiceName,
113  DeviceIndex);
114 
115  SND_TRACE(L"Opening reg key: %wS\n", RegPath);
116 
117  /* Perform the open */
119  RegPath,
120  0,
121  KEY_READ,
123  {
124  /* Couldn't open the key */
125  SND_ERR(L"Failed to open reg key: %wS\n", RegPath);
126  FreeMemory(RegPath);
127  return MMSYSERR_ERROR;
128  }
129 
130  FreeMemory(RegPath);
131 
132  return MMSYSERR_NOERROR;
133 }
#define IN
Definition: typedefs.h:39
static VOID FreeMemory(PCREATE_DATA Data)
Definition: create.c:134
#define ERROR_SUCCESS
Definition: deptool.c:10
#define REG_PARAMETERS_KEY_NAME_U
Definition: sndnames.h:76
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4711
UINT GetDigitCount(IN UINT Number)
Definition: utility.c:68
#define KEY_READ
Definition: nt_native.h:1023
UINT MMRESULT
Definition: mmsystem.h:962
uint16_t * PWCHAR
Definition: typedefs.h:55
static USHORT PathLength
#define VALIDATE_MMSYS_PARAMETER(parameter_condition)
Definition: mmebuddy.h:71
MMRESULT OpenSoundDriverParametersRegKey(IN LPWSTR ServiceName, OUT PHKEY KeyHandle)
Definition: registry.c:20
#define MMSYSERR_NOMEM
Definition: mmsystem.h:103
#define AllocateWideString(string_length)
Definition: mmebuddy.h:33
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
MMRESULT OpenSoundDeviceRegKey(IN LPWSTR ServiceName, IN DWORD DeviceIndex, OUT PHKEY KeyHandle)
Definition: registry.c:73
LPTSTR ServiceName
Definition: ServiceMain.c:15
#define MMSYSERR_ERROR
Definition: mmsystem.h:97
#define SND_ERR(...)
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
#define REG_SERVICES_KEY_NAME_U
Definition: sndnames.h:75
ULONG_PTR SIZE_T
Definition: typedefs.h:79
#define RegOpenKeyEx
Definition: winreg.h:520
#define OUT
Definition: typedefs.h:40
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define wsprintf
Definition: winuser.h:5840
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define REG_DEVICE_KEY_NAME_U
Definition: sndnames.h:77
#define SND_TRACE(...)
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12