ReactOS 0.4.15-dev-7674-gc0b4db1
deviface.c File Reference
#include "wdmaud.h"
#include <debug.h>
Include dependency graph for deviface.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

NTSTATUS WdmAudOpenSysAudioDevice (IN LPWSTR DeviceName, OUT PHANDLE Handle)
 
NTSTATUS NTAPI DeviceInterfaceChangeCallback (IN PVOID NotificationStructure, IN PVOID Context)
 
NTSTATUS WdmAudOpenSysAudioDeviceInterfaces (IN PWDMAUD_DEVICE_EXTENSION DeviceExtension, IN LPWSTR SymbolicLinkList)
 
NTSTATUS WdmAudOpenSysAudioDevices (IN PDEVICE_OBJECT DeviceObject, IN PWDMAUD_DEVICE_EXTENSION DeviceExtension)
 
NTSTATUS WdmAudRegisterDeviceInterface (IN PDEVICE_OBJECT PhysicalDeviceObject, IN PWDMAUD_DEVICE_EXTENSION DeviceExtension)
 
NTSTATUS WdmAudOpenSysaudio (IN PDEVICE_OBJECT DeviceObject, IN PWDMAUD_CLIENT *pClient)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file deviface.c.

Function Documentation

◆ DeviceInterfaceChangeCallback()

NTSTATUS NTAPI DeviceInterfaceChangeCallback ( IN PVOID  NotificationStructure,
IN PVOID  Context 
)

Definition at line 48 of file deviface.c.

51{
53
54 DPRINT1("DeviceInterfaceChangeCallback called %p\n", Event);
56 return STATUS_SUCCESS;
57}
#define DPRINT1
Definition: precomp.h:8
NTSYSAPI void WINAPI DbgBreakPoint(void)
#define STATUS_SUCCESS
Definition: shellext.h:65
_In_ PVOID NotificationStructure
Definition: iofuncs.h:1206

Referenced by SysAudioRegisterNotifications(), and WdmAudOpenSysAudioDevices().

◆ WdmAudOpenSysaudio()

NTSTATUS WdmAudOpenSysaudio ( IN PDEVICE_OBJECT  DeviceObject,
IN PWDMAUD_CLIENT pClient 
)

Definition at line 206 of file deviface.c.

209{
211 PWDMAUD_DEVICE_EXTENSION DeviceExtension;
212
213 /* get device extension */
214 DeviceExtension = (PWDMAUD_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
215
216 if (!DeviceExtension->NumSysAudioDevices)
217 {
218 /* wdmaud failed to open sysaudio */
219 return STATUS_UNSUCCESSFUL;
220 }
221
222 /* sanity check */
223 ASSERT(!IsListEmpty(&DeviceExtension->SysAudioDeviceList));
224
225 /* allocate client context struct */
227
228 /* check for allocation failure */
229 if (!Client)
230 {
231 /* not enough memory */
233 }
234
235 /* zero client context struct */
237
238 /* initialize mixer event list */
239 InitializeListHead(&Client->MixerEventList);
240
241 /* store result */
242 *pClient = Client;
243
244 /* insert client into list */
245 ExInterlockedInsertTailList(&DeviceExtension->WdmAudClientList, &Client->Entry, &DeviceExtension->Lock);
246
247 /* done */
248 return STATUS_SUCCESS;
249}
struct WDMAUD_DEVICE_EXTENSION * PWDMAUD_DEVICE_EXTENSION
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
#define NonPagedPool
Definition: env_spec_w32.h:307
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
PLIST_ENTRY NTAPI ExInterlockedInsertTailList(IN OUT PLIST_ENTRY ListHead, IN OUT PLIST_ENTRY ListEntry, IN OUT PKSPIN_LOCK Lock)
Definition: interlocked.c:140
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:29
if(dx< 0)
Definition: linetemp.h:194
#define ASSERT(a)
Definition: mode.c:44
Definition: client.c:28
LIST_ENTRY SysAudioDeviceList
Definition: wdmaud.h:60
LIST_ENTRY WdmAudClientList
Definition: wdmaud.h:63
KSPIN_LOCK Lock
Definition: wdmaud.h:58
ULONG NumSysAudioDevices
Definition: wdmaud.h:59
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055

Referenced by WdmAudCreate().

◆ WdmAudOpenSysAudioDevice()

NTSTATUS WdmAudOpenSysAudioDevice ( IN LPWSTR  DeviceName,
OUT PHANDLE  Handle 
)

Definition at line 16 of file deviface.c.

19{
24
27
32 NULL,
33 0,
34 0,
37 NULL,
38 0,
40 NULL,
42
43 return Status;
44}
LONG NTSTATUS
Definition: precomp.h:26
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define NULL
Definition: types.h:112
#define GENERIC_READ
Definition: compat.h:135
static const WCHAR SymbolicLink[]
Definition: interface.c:31
#define FILE_OPEN
Definition: from_kernel.h:54
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
ULONG Handle
Definition: gdb_input.c:15
Status
Definition: gdiplustypes.h:25
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define OBJ_OPENIF
Definition: winternl.h:229
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define SYNCHRONIZE
Definition: nt_native.h:61
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define GENERIC_WRITE
Definition: nt_native.h:90
NTSTATUS NTAPI IoCreateFile(OUT PHANDLE FileHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK IoStatusBlock, IN PLARGE_INTEGER AllocationSize OPTIONAL, IN ULONG FileAttributes, IN ULONG ShareAccess, IN ULONG Disposition, IN ULONG CreateOptions, IN PVOID EaBuffer OPTIONAL, IN ULONG EaLength, IN CREATE_FILE_TYPE CreateFileType, IN PVOID ExtraCreateParameters OPTIONAL, IN ULONG Options)
Definition: file.c:3010
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3275
#define IO_FORCE_ACCESS_CHECK
Definition: iotypes.h:540
#define IO_NO_PARAMETER_CHECKING
Definition: iotypes.h:541
@ CreateFileTypeNone
Definition: iotypes.h:535

Referenced by Open(), OpenDevice(), and WdmAudOpenSysAudioDevices().

◆ WdmAudOpenSysAudioDeviceInterfaces()

NTSTATUS WdmAudOpenSysAudioDeviceInterfaces ( IN PWDMAUD_DEVICE_EXTENSION  DeviceExtension,
IN LPWSTR  SymbolicLinkList 
)

Definition at line 60 of file deviface.c.

63{
66
67 DPRINT1("WdmAudOpenSysAudioDeviceInterfaces called\n");
68
69 while(*SymbolicLinkList)
70 {
73 if (!Entry)
74 {
76 }
77
78 Entry->SymbolicLink.Length = Length * sizeof(WCHAR);
79 Entry->SymbolicLink.MaximumLength = Length * sizeof(WCHAR);
80 Entry->SymbolicLink.Buffer = (LPWSTR) (Entry + 1);
81 wcscpy(Entry->SymbolicLink.Buffer, SymbolicLinkList);
82
83 InsertTailList(&DeviceExtension->SysAudioDeviceList, &Entry->Entry);
84
85 DeviceExtension->NumSysAudioDevices++;
87 }
88 return STATUS_SUCCESS;
89}
#define InsertTailList(ListHead, Entry)
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
base of all file and directory entries
Definition: entries.h:83
Entry(ENTRY_TYPE etype)
Definition: entries.cpp:35
Definition: wdmaud.h:46
uint32_t ULONG
Definition: typedefs.h:59
_In_opt_ PDEVICE_OBJECT _In_ ULONG _Outptr_result_nullonfailure_ _At_ * SymbolicLinkList(return==0, __drv_allocatesMem(Mem))) PZZWSTR *SymbolicLinkList
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by WdmAudOpenSysAudioDevices().

◆ WdmAudOpenSysAudioDevices()

NTSTATUS WdmAudOpenSysAudioDevices ( IN PDEVICE_OBJECT  DeviceObject,
IN PWDMAUD_DEVICE_EXTENSION  DeviceExtension 
)

Definition at line 93 of file deviface.c.

96{
101 HANDLE hSysAudio;
103 UNICODE_STRING DeviceName = RTL_CONSTANT_STRING(L"\\Device\\sysaudio\\GLOBAL");
104
105 if (DeviceExtension->DeviceInterfaceSupport)
106 {
108 NULL,
109 0,
111
112 if (NT_SUCCESS(Status))
113 {
116 }
117
118
122 DeviceObject->DriverObject,
124 (PVOID)DeviceExtension,
125 &DeviceExtension->SysAudioNotification);
126 }
127 else
128 {
130 if (!Entry)
131 {
133 }
134
135
136 Length = wcslen(DeviceName.Buffer) + 1;
137 Entry->SymbolicLink.Length = 0;
138 Entry->SymbolicLink.MaximumLength = Length * sizeof(WCHAR);
139 Entry->SymbolicLink.Buffer = AllocateItem(NonPagedPool, Entry->SymbolicLink.MaximumLength);
140
141 if (!Entry->SymbolicLink.Buffer)
142 {
145 }
146
148
149 if (!NT_SUCCESS(Status))
150 {
151 FreeItem(Entry->SymbolicLink.Buffer);
153 return Status;
154 }
155
156 DPRINT("Opening device %S\n", Entry->SymbolicLink.Buffer);
157 Status = WdmAudOpenSysAudioDevice(Entry->SymbolicLink.Buffer, &hSysAudio);
158 if (!NT_SUCCESS(Status))
159 {
160 DPRINT1("Failed to open sysaudio %x\n", Status);
161 FreeItem(Entry->SymbolicLink.Buffer);
163 return Status;
164 }
165
166 InsertTailList(&DeviceExtension->SysAudioDeviceList, &Entry->Entry);
167 DeviceExtension->NumSysAudioDevices++;
168
169 /* get the file object */
171 if (!NT_SUCCESS(Status))
172 {
173 DPRINT1("Failed to reference FileObject %x\n", Status);
174 ZwClose(hSysAudio);
175 return Status;
176 }
177 DeviceExtension = (PWDMAUD_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
178 DeviceExtension->hSysAudio = hSysAudio;
179 DeviceExtension->FileObject = FileObject;
180 }
181
182 return Status;
183}
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS WdmAudOpenSysAudioDeviceInterfaces(IN PWDMAUD_DEVICE_EXTENSION DeviceExtension, IN LPWSTR SymbolicLinkList)
Definition: deviface.c:60
NTSTATUS NTAPI DeviceInterfaceChangeCallback(IN PVOID NotificationStructure, IN PVOID Context)
Definition: deviface.c:48
NTSTATUS WdmAudOpenSysAudioDevice(IN LPWSTR DeviceName, OUT PHANDLE Handle)
Definition: deviface.c:16
POBJECT_TYPE IoFileObjectType
Definition: iomgr.c:36
VOID FreeItem(IN PVOID Item)
Definition: misc.c:37
#define KSCATEGORY_SYSAUDIO
Definition: ksmedia.h:217
#define KernelMode
Definition: asm.h:34
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
#define FILE_WRITE_DATA
Definition: nt_native.h:631
#define FILE_READ_DATA
Definition: nt_native.h:628
NTSYSAPI NTSTATUS NTAPI RtlAppendUnicodeStringToString(PUNICODE_STRING Destination, PUNICODE_STRING Source)
NTSTATUS NTAPI IoGetDeviceInterfaces(IN CONST GUID *InterfaceClassGuid, IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL, IN ULONG Flags, OUT PWSTR *SymbolicLinkList)
Definition: deviface.c:454
#define L(x)
Definition: ntvdm.h:50
NTSTATUS NTAPI ObReferenceObjectByHandle(IN HANDLE Handle, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, OUT PVOID *Object, OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL)
Definition: obref.c:494
NTSTATUS NTAPI IoRegisterPlugPlayNotification(_In_ IO_NOTIFICATION_EVENT_CATEGORY EventCategory, _In_ ULONG EventCategoryFlags, _In_opt_ PVOID EventCategoryData, _In_ PDRIVER_OBJECT DriverObject, _In_ PDRIVER_NOTIFICATION_CALLBACK_ROUTINE CallbackRoutine, _Inout_opt_ PVOID Context, _Out_ PVOID *NotificationEntry)
Definition: pnpnotify.c:345
#define DPRINT
Definition: sndvol32.h:71
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550
@ EventCategoryDeviceInterfaceChange
Definition: iotypes.h:1226
* PFILE_OBJECT
Definition: iotypes.h:1998
#define PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES
Definition: iotypes.h:1239

Referenced by WdmAudInitWorkerRoutine().

◆ WdmAudRegisterDeviceInterface()

NTSTATUS WdmAudRegisterDeviceInterface ( IN PDEVICE_OBJECT  PhysicalDeviceObject,
IN PWDMAUD_DEVICE_EXTENSION  DeviceExtension 
)

Definition at line 186 of file deviface.c.

189{
192
194 if (NT_SUCCESS(Status))
195 {
198 //DeviceExtension->DeviceInterfaceSupport = TRUE;
199 return Status;
200 }
201
202 return Status;
203}
PDEVICE_OBJECT PhysicalDeviceObject
Definition: btrfs_drv.h:1157
#define TRUE
Definition: types.h:120
#define KSCATEGORY_WDMAUD
Definition: ksmedia.h:222
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
NTSTATUS NTAPI IoRegisterDeviceInterface(IN PDEVICE_OBJECT PhysicalDeviceObject, IN CONST GUID *InterfaceClassGuid, IN PUNICODE_STRING ReferenceString OPTIONAL, OUT PUNICODE_STRING SymbolicLinkName)
Definition: deviface.c:955
NTSTATUS NTAPI IoSetDeviceInterfaceState(IN PUNICODE_STRING SymbolicLinkName, IN BOOLEAN Enable)
Definition: deviface.c:1311
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING SymbolicLinkName
Definition: wdfdevice.h:3739

Referenced by WdmaudAddDevice().