ReactOS  0.4.14-dev-376-gaedba84
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);
55  DbgBreakPoint();
56  return STATUS_SUCCESS;
57 }
_In_ PVOID NotificationStructure
Definition: iofuncs.h:1203
void DbgBreakPoint()
Definition: mach.c:553
#define DPRINT1
Definition: precomp.h:8
return STATUS_SUCCESS
Definition: btrfs.c:2938

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 */
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 }
Definition: client.c:29
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
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:30
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
struct WDMAUD_DEVICE_EXTENSION * PWDMAUD_DEVICE_EXTENSION
ULONG NumSysAudioDevices
Definition: wdmaud.h:59
PVOID DeviceExtension
Definition: env_spec_w32.h:418
if(!(yy_init))
Definition: macro.lex.yy.c:714
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
LIST_ENTRY SysAudioDeviceList
Definition: wdmaud.h:60
KSPIN_LOCK Lock
Definition: wdmaud.h:58
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
return STATUS_SUCCESS
Definition: btrfs.c:2938
LIST_ENTRY WdmAudClientList
Definition: wdmaud.h:63

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,
35  FILE_OPEN,
37  NULL,
38  0,
40  NULL,
42 
43  return Status;
44 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define IO_FORCE_ACCESS_CHECK
Definition: iotypes.h:508
LONG NTSTATUS
Definition: precomp.h:26
WCHAR DeviceName[]
Definition: adapter.cpp:21
#define OBJ_OPENIF
Definition: winternl.h:229
#define IO_NO_PARAMETER_CHECKING
Definition: iotypes.h:509
#define GENERIC_WRITE
Definition: nt_native.h:90
smooth NULL
Definition: ftsmooth.c:416
_In_ HANDLE Handle
Definition: extypes.h:390
#define GENERIC_READ
Definition: compat.h:124
#define SYNCHRONIZE
Definition: nt_native.h:61
Status
Definition: gdiplustypes.h:24
#define FILE_OPEN
Definition: from_kernel.h:54
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
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:3009
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
static const WCHAR SymbolicLink[]
Definition: interface.c:31

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 {
65  ULONG Length;
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 STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_opt_ PDEVICE_OBJECT _In_ ULONG _Outptr_result_nullonfailure_ _At_ * SymbolicLinkList(return==0, __drv_allocatesMem(Mem))) PZZWSTR *SymbolicLinkList
struct _Entry Entry
Definition: kefuncs.h:640
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:30
#define InsertTailList(ListHead, Entry)
Entry(ENTRY_TYPE etype)
Definition: entries.cpp:35
Definition: wdmaud.h:45
__wchar_t WCHAR
Definition: xmlstorage.h:180
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
WCHAR * LPWSTR
Definition: xmlstorage.h:184
return STATUS_SUCCESS
Definition: btrfs.c:2938
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
base of all file and directory entries
Definition: entries.h:82

Referenced by WdmAudOpenSysAudioDevices().

◆ WdmAudOpenSysAudioDevices()

NTSTATUS WdmAudOpenSysAudioDevices ( IN PDEVICE_OBJECT  DeviceObject,
IN PWDMAUD_DEVICE_EXTENSION  DeviceExtension 
)

Definition at line 93 of file deviface.c.

96 {
100  ULONG Length;
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  {
143  FreeItem(Entry);
145  }
146 
148 
149  if (!NT_SUCCESS(Status))
150  {
151  FreeItem(Entry->SymbolicLink.Buffer);
152  FreeItem(Entry);
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);
162  FreeItem(Entry);
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  }
178  DeviceExtension->hSysAudio = hSysAudio;
179  DeviceExtension->FileObject = FileObject;
180  }
181 
182  return Status;
183 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_opt_ PDEVICE_OBJECT _In_ ULONG _Outptr_result_nullonfailure_ _At_ * SymbolicLinkList(return==0, __drv_allocatesMem(Mem))) PZZWSTR *SymbolicLinkList
struct _Entry Entry
Definition: kefuncs.h:640
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:30
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI IoGetDeviceInterfaces(IN CONST GUID *InterfaceClassGuid, IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL, IN ULONG Flags, OUT PWSTR *SymbolicLinkList)
Definition: deviface.c:454
#define PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES
Definition: iotypes.h:1196
WCHAR DeviceName[]
Definition: adapter.cpp:21
#define InsertTailList(ListHead, Entry)
VOID FreeItem(IN PVOID Item)
Definition: misc.c:43
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:496
#define FILE_READ_DATA
Definition: nt_native.h:628
Entry(ENTRY_TYPE etype)
Definition: entries.cpp:35
struct WDMAUD_DEVICE_EXTENSION * PWDMAUD_DEVICE_EXTENSION
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
#define FILE_WRITE_DATA
Definition: nt_native.h:631
NTSTATUS NTAPI DeviceInterfaceChangeCallback(IN PVOID NotificationStructure, IN PVOID Context)
Definition: deviface.c:48
#define KSCATEGORY_SYSAUDIO
Definition: ksmedia.h:217
NTSTATUS WdmAudOpenSysAudioDevice(IN LPWSTR DeviceName, OUT PHANDLE Handle)
Definition: deviface.c:16
Definition: wdmaud.h:45
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
* PFILE_OBJECT
Definition: iotypes.h:1955
static const WCHAR L[]
Definition: oid.c:1250
NTSTATUS NTAPI IoRegisterPlugPlayNotification(IN IO_NOTIFICATION_EVENT_CATEGORY EventCategory, IN ULONG EventCategoryFlags, IN PVOID EventCategoryData OPTIONAL, IN PDRIVER_OBJECT DriverObject, IN PDRIVER_NOTIFICATION_CALLBACK_ROUTINE CallbackRoutine, IN PVOID Context, OUT PVOID *NotificationEntry)
Definition: pnpnotify.c:249
POBJECT_TYPE IoFileObjectType
Definition: iomgr.c:36
NTSTATUS WdmAudOpenSysAudioDeviceInterfaces(IN PWDMAUD_DEVICE_EXTENSION DeviceExtension, IN LPWSTR SymbolicLinkList)
Definition: deviface.c:60
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
NTSYSAPI NTSTATUS NTAPI RtlAppendUnicodeStringToString(PUNICODE_STRING Destination, PUNICODE_STRING Source)
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
WCHAR * LPWSTR
Definition: xmlstorage.h:184
return STATUS_SUCCESS
Definition: btrfs.c:2938
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
base of all file and directory entries
Definition: entries.h:82
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14

Referenced by WdmAudInitWorkerRoutine().

◆ WdmAudRegisterDeviceInterface()

NTSTATUS WdmAudRegisterDeviceInterface ( IN PDEVICE_OBJECT  PhysicalDeviceObject,
IN PWDMAUD_DEVICE_EXTENSION  DeviceExtension 
)

Definition at line 186 of file deviface.c.

189 {
191  UNICODE_STRING SymbolicLinkName;
192 
194  if (NT_SUCCESS(Status))
195  {
196  IoSetDeviceInterfaceState(&SymbolicLinkName, TRUE);
197  RtlFreeUnicodeString(&SymbolicLinkName);
198  //DeviceExtension->DeviceInterfaceSupport = TRUE;
199  return Status;
200  }
201 
202  return Status;
203 }
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
PDEVICE_OBJECT PhysicalDeviceObject
Definition: btrfs_drv.h:1122
const GUID KSCATEGORY_WDMAUD
Definition: entry.c:16
smooth NULL
Definition: ftsmooth.c:416
NTSTATUS NTAPI IoSetDeviceInterfaceState(IN PUNICODE_STRING SymbolicLinkName, IN BOOLEAN Enable)
Definition: deviface.c:1311
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
Status
Definition: gdiplustypes.h:24
NTSTATUS NTAPI IoRegisterDeviceInterface(IN PDEVICE_OBJECT PhysicalDeviceObject, IN CONST GUID *InterfaceClassGuid, IN PUNICODE_STRING ReferenceString OPTIONAL, OUT PUNICODE_STRING SymbolicLinkName)
Definition: deviface.c:955

Referenced by WdmaudAddDevice().