ReactOS 0.4.15-dev-7918-g2a2556c
sndblst.c File Reference
#include <ntddk.h>
#include <windef.h>
#include <mmsystem.h>
#include <debug.h>
Include dependency graph for sndblst.c:

Go to the source code of this file.

Classes

struct  _SOUND_BLASTER_DEVICE
 

Macros

#define CompleteIrpAndReturn(irp, status)
 

Typedefs

typedef NTSTATUS(* SOUNDDEVICEENUMERATIONCALLBACK) (IN PUNICODE_STRING DeviceRegistryPath)
 
typedef struct _SOUND_BLASTER_DEVICE SOUND_BLASTER_DEVICE
 

Functions

static VOID NTAPI UnloadSoundBlaster (PDRIVER_OBJECT DriverObject)
 
NTSTATUS EnumerateSoundDevices (IN PUNICODE_STRING RegistryPath, IN PWSTR RegistrySubKey, IN SOUNDDEVICEENUMERATIONCALLBACK Callback)
 
NTSTATUS PublishWaveOutDevice (IN DWORD HardwareDeviceIndex, IN PWSTR BaseDeviceName, IN DWORD DeviceIndex, IN LPWAVEOUTCAPS Capabilities)
 
NTSTATUS AllocateSoundBlasterStructure (OUT SOUND_BLASTER_DEVICE *SoundBlasterDevice)
 
NTSTATUS ConfigureSoundBlasterDevice (IN PUNICODE_STRING DeviceRegistryPath)
 
static NTSTATUS NTAPI CreateSoundBlaster (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
static NTSTATUS NTAPI CloseSoundBlaster (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
static NTSTATUS NTAPI CleanupSoundBlaster (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
static NTSTATUS NTAPI ControlSoundBlaster (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
static NTSTATUS NTAPI WriteToSoundBlaster (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI DriverEntry (IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath)
 
static VOID NTAPI UnloadSoundBlaster (IN PDRIVER_OBJECT DriverObject)
 

Macro Definition Documentation

◆ CompleteIrpAndReturn

#define CompleteIrpAndReturn (   irp,
  status 
)
Value:
irp->IoStatus.Status = status; \
irp->IoStatus.Information = 0; \
IoCompleteRequest(Irp, IO_NO_INCREMENT); \
return status;
_In_ PIRP Irp
Definition: csq.h:116
FxIrp * irp
Definition: ps.c:97
#define IO_NO_INCREMENT
Definition: iotypes.h:598

Definition at line 20 of file sndblst.c.

Typedef Documentation

◆ SOUND_BLASTER_DEVICE

◆ SOUNDDEVICEENUMERATIONCALLBACK

typedef NTSTATUS(* SOUNDDEVICEENUMERATIONCALLBACK) (IN PUNICODE_STRING DeviceRegistryPath)

Definition at line 36 of file sndblst.c.

Function Documentation

◆ AllocateSoundBlasterStructure()

NTSTATUS AllocateSoundBlasterStructure ( OUT SOUND_BLASTER_DEVICE SoundBlasterDevice)

Definition at line 235 of file sndblst.c.

236{
238}
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239

◆ CleanupSoundBlaster()

static NTSTATUS NTAPI CleanupSoundBlaster ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)
static

Definition at line 317 of file sndblst.c.

320{
321 DPRINT("Sound Blaster driver received IRP_MJ_CLEANUP\n");
322
324}
#define CompleteIrpAndReturn(irp, status)
Definition: sndblst.c:20
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71

Referenced by DriverEntry().

◆ CloseSoundBlaster()

static NTSTATUS NTAPI CloseSoundBlaster ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)
static

Definition at line 307 of file sndblst.c.

310{
311 DPRINT("Sound Blaster driver received IRP_MJ_CLOSE\n");
312
314}

Referenced by DriverEntry().

◆ ConfigureSoundBlasterDevice()

NTSTATUS ConfigureSoundBlasterDevice ( IN PUNICODE_STRING  DeviceRegistryPath)

Definition at line 257 of file sndblst.c.

258{
259 OBJECT_ATTRIBUTES RegAttributes;
261 HKEY ConfigKeyHandle;
262
263 DPRINT("Configuring Sound Blaster (config at %S)\n", DeviceRegistryPath->Buffer);
264
265 if ( ! DeviceRegistryPath )
266 {
268 }
269
270 /* Open the registry key */
271 InitializeObjectAttributes(&RegAttributes,
272 DeviceRegistryPath,
274 NULL,
276
277 Status = ZwOpenKey(&ConfigKeyHandle, KEY_READ, &RegAttributes);
278
279 if ( ! NT_SUCCESS(Status) )
280 {
281 DPRINT("Failed to open config registry key\n");
282 return Status;
283 }
284
285 /* Read configuration */
286 DPRINT("Reading configuration\n");
287
288 //Status = ZwQueryValueKey(ConfigKeyHandle,
289
290 return Status;
291}
LONG NTSTATUS
Definition: precomp.h:26
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Status
Definition: gdiplustypes.h:25
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define KEY_READ
Definition: nt_native.h:1023
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135

Referenced by DriverEntry().

◆ ControlSoundBlaster()

static NTSTATUS NTAPI ControlSoundBlaster ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)
static

Definition at line 327 of file sndblst.c.

330{
331 DPRINT("Sound Blaster driver received IRP_MJ_CONTROL\n");
332
334}

Referenced by DriverEntry().

◆ CreateSoundBlaster()

static NTSTATUS NTAPI CreateSoundBlaster ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)
static

Definition at line 297 of file sndblst.c.

300{
301 DPRINT("Sound Blaster driver received IRP_MJ_CREATE\n");
302
304}

Referenced by DriverEntry().

◆ DriverEntry()

NTSTATUS NTAPI DriverEntry ( IN PDRIVER_OBJECT  DriverObject,
IN PUNICODE_STRING  RegistryPath 
)

Definition at line 350 of file sndblst.c.

353{
355
356 DPRINT("Sound Blaster driver by silverblade\n");
357
358 DriverObject->Flags = 0;
364 DriverObject->DriverUnload = UnloadSoundBlaster;
365
367
368 return Status;
369}
NTSTATUS EnumerateSoundDevices(IN PUNICODE_STRING RegistryPath, IN PWSTR RegistrySubKey, IN SOUNDDEVICEENUMERATIONCALLBACK Callback)
Definition: sndblst.c:40
static VOID NTAPI UnloadSoundBlaster(PDRIVER_OBJECT DriverObject)
Definition: main.c:117
static NTSTATUS NTAPI WriteToSoundBlaster(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: sndblst.c:337
static NTSTATUS NTAPI ControlSoundBlaster(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: sndblst.c:327
static NTSTATUS NTAPI CreateSoundBlaster(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: sndblst.c:297
NTSTATUS ConfigureSoundBlasterDevice(IN PUNICODE_STRING DeviceRegistryPath)
Definition: sndblst.c:257
static NTSTATUS NTAPI CleanupSoundBlaster(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: sndblst.c:317
static NTSTATUS NTAPI CloseSoundBlaster(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: sndblst.c:307
#define L(x)
Definition: ntvdm.h:50
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52
#define IRP_MJ_WRITE
Definition: rdpdr.c:47
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:215
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
#define IRP_MJ_CLEANUP

◆ EnumerateSoundDevices()

NTSTATUS EnumerateSoundDevices ( IN PUNICODE_STRING  RegistryPath,
IN PWSTR  RegistrySubKey,
IN SOUNDDEVICEENUMERATIONCALLBACK  Callback 
)

Definition at line 40 of file sndblst.c.

44{
46 OBJECT_ATTRIBUTES RegAttributes;
47 HKEY MainKeyHandle, ChildKeyHandle;
48 UNICODE_STRING UnicodeSubkeyName, DeviceKeyName;
49 KEY_BASIC_INFORMATION KeyInfo, *FinalKeyInfo;
50 ULONG i = 0, NeededDataLength = 0, FinalDataLength = 0, NameLength = 0;
51
52 /* Turn the subkey name into a Unicode string */
53 RtlInitUnicodeString(&UnicodeSubkeyName, RegistrySubKey);
54
55 /* Open the registry key for the service */
56 InitializeObjectAttributes(&RegAttributes,
59 NULL,
61
62 Status = ZwOpenKey(&MainKeyHandle, KEY_READ, &RegAttributes);
63
64 if ( ! NT_SUCCESS(Status) )
65 {
66 DPRINT("Failed to open registry key\n");
67 return Status;
68 }
69
70 /* Open the subkey usually named "Parameters" */
71 InitializeObjectAttributes(&RegAttributes,
72 &UnicodeSubkeyName,
74 MainKeyHandle,
76
77 Status = ZwOpenKey(&ChildKeyHandle, KEY_ENUMERATE_SUB_KEYS, &RegAttributes);
78
79 /* We're done with the main key now */
80 ZwClose(MainKeyHandle);
81
82 if ( ! NT_SUCCESS(Status) )
83 {
84 DPRINT("Failed to open registry subkeys for enumeration\n");
85 return Status;
86 }
87
88 /* Enumerate through the device keys */
89 while ( ( Status = ZwEnumerateKey(ChildKeyHandle,
90 i,
92 &KeyInfo,
94 &NeededDataLength) ) != STATUS_NO_MORE_ENTRIES )
95 {
96 PWSTR EnumeratedKeyName, StartOfEnumeratedKeyName;
97
98 DPRINT("Found subkey %d\n", i);
99
100 FinalDataLength = NeededDataLength + FIELD_OFFSET(KEY_BASIC_INFORMATION, Name[0]);
101 DPRINT("Allocating %d bytes\n", FinalDataLength);
102
103 FinalKeyInfo = (PKEY_BASIC_INFORMATION) ExAllocatePool(PagedPool, FinalDataLength);
104
105 if ( ! FinalKeyInfo )
106 {
108 break;
109 }
110
111 /* This time we get the real info */
112 Status = ZwEnumerateKey(ChildKeyHandle,
113 i,
115 FinalKeyInfo,
116 FinalDataLength,
117 &NeededDataLength);
118
119 if ( ! NT_SUCCESS(Status) )
120 {
121 DPRINT("FAILED to enumerate key!\n");
122 }
123 else
124 {
125 NameLength = RegistryPath->Length + sizeof(WCHAR) +
126 UnicodeSubkeyName.Length + sizeof(WCHAR) +
127 FinalKeyInfo->NameLength + sizeof(UNICODE_NULL);
128
129 DPRINT("Allocating memory for name (%d bytes)\n", NameLength);
130
131 EnumeratedKeyName = (PWSTR) ExAllocatePool(PagedPool, NameLength);
132
133 if ( ! EnumeratedKeyName )
134 {
135 ExFreePool((PVOID)FinalKeyInfo);
137 break;
138 }
139
140 StartOfEnumeratedKeyName = EnumeratedKeyName;
141
142 /* Start building the registry path using the service key */
143 RtlCopyMemory(EnumeratedKeyName,
144 RegistryPath->Buffer,
145 RegistryPath->Length);
146
147 EnumeratedKeyName += RegistryPath->Length / sizeof(WCHAR);
148 EnumeratedKeyName[0] = '\\';
149 ++ EnumeratedKeyName;
150
151 /* Append the parameters subkey */
152 RtlCopyMemory(EnumeratedKeyName,
153 RegistrySubKey,
154 UnicodeSubkeyName.Length);
155
156 EnumeratedKeyName += UnicodeSubkeyName.Length / sizeof(WCHAR);
157 EnumeratedKeyName[0] = '\\';
158 ++ EnumeratedKeyName;
159
160 /* And finally append the enumerated key name */
161 RtlCopyMemory(EnumeratedKeyName,
162 FinalKeyInfo->Name,
163 FinalKeyInfo->NameLength);
164
165 EnumeratedKeyName += FinalKeyInfo->NameLength / sizeof(WCHAR);
166 EnumeratedKeyName[0] = UNICODE_NULL;
167
168 /* Reset pointer */
169 EnumeratedKeyName = StartOfEnumeratedKeyName;
170
171 /* Convert into a Unicode string for the callback */
172 RtlInitUnicodeString(&DeviceKeyName, EnumeratedKeyName);
173
174 Callback(&DeviceKeyName);
175
176 /* No longer need the key name */
177 ExFreePool((PVOID)EnumeratedKeyName);
178 EnumeratedKeyName = NULL;
179 }
180
181 /* No longer need the key info */
182 ExFreePool((PVOID)FinalKeyInfo);
183 FinalKeyInfo = NULL;
184
185 ++ i;
186 }
187
188 /* We're done with enumeration so close this */
189 ZwClose(ChildKeyHandle);
190
191 /* This isn't an error */
193 {
195 }
196
197 /* No devices configured? */
198 if ( i == 0 && Status == STATUS_NO_MORE_ENTRIES )
199 {
201 }
202
203 return Status;
204}
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define PagedPool
Definition: env_spec_w32.h:308
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
@ KeyBasicInformation
Definition: nt_native.h:1131
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
struct _KEY_BASIC_INFORMATION * PKEY_BASIC_INFORMATION
#define KEY_ENUMERATE_SUB_KEYS
Definition: nt_native.h:1019
#define UNICODE_NULL
#define STATUS_NO_MORE_ENTRIES
Definition: ntstatus.h:205
#define STATUS_DEVICE_CONFIGURATION_ERROR
Definition: ntstatus.h:619
uint16_t * PWSTR
Definition: typedefs.h:56
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ WDFINTERRUPT _In_ PFN_WDF_INTERRUPT_SYNCHRONIZE Callback
Definition: wdfinterrupt.h:458
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by DriverEntry().

◆ PublishWaveOutDevice()

NTSTATUS PublishWaveOutDevice ( IN DWORD  HardwareDeviceIndex,
IN PWSTR  BaseDeviceName,
IN DWORD  DeviceIndex,
IN LPWAVEOUTCAPS  Capabilities 
)

Definition at line 207 of file sndblst.c.

212{
213 return STATUS_SUCCESS;
214}

◆ UnloadSoundBlaster() [1/2]

static VOID NTAPI UnloadSoundBlaster ( IN PDRIVER_OBJECT  DriverObject)
static

Definition at line 372 of file sndblst.c.

373{
374 DPRINT("Sound Blaster driver is being unloaded\n");
375}

◆ UnloadSoundBlaster() [2/2]

static VOID NTAPI UnloadSoundBlaster ( PDRIVER_OBJECT  DriverObject)
static

Definition at line 117 of file main.c.

119{
120 DPRINT("Sound Blaster driver unload\n");
121}

Referenced by DriverEntry().

◆ WriteToSoundBlaster()

static NTSTATUS NTAPI WriteToSoundBlaster ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)
static

Definition at line 337 of file sndblst.c.

340{
341 DPRINT("Sound Blaster driver received IRP_MJ_WRITE\n");
342
344}

Referenced by DriverEntry().