ReactOS 0.4.16-dev-197-g92996da
kernel.c File Reference
#include "mmdrv.h"
#include <winuser.h>
#include <debug.h>
Include dependency graph for kernel.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

MMRESULT CobbleDeviceName (DeviceType device_type, UINT device_id, PWCHAR out_device_name)
 
MMRESULT OpenKernelDevice (DeviceType device_type, UINT device_id, DWORD access, HANDLE *handle)
 
void CloseKernelDevice (HANDLE device_handle)
 
MMRESULT SetDeviceData (HANDLE device_handle, DWORD ioctl, PBYTE input_buffer, DWORD buffer_size)
 
MMRESULT GetDeviceData (HANDLE device_handle, DWORD ioctl, PBYTE output_buffer, DWORD buffer_size)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 16 of file kernel.c.

Function Documentation

◆ CloseKernelDevice()

void CloseKernelDevice ( HANDLE  device_handle)

Definition at line 132 of file kernel.c.

133{
134 CloseHandle(device_handle);
135}
#define CloseHandle
Definition: compat.h:739

Referenced by CloseDevice(), and GetDeviceCapabilities().

◆ CobbleDeviceName()

MMRESULT CobbleDeviceName ( DeviceType  device_type,
UINT  device_id,
PWCHAR  out_device_name 
)

Definition at line 28 of file kernel.c.

32{
33 WCHAR base_device_name[MAX_DEVICE_NAME_LENGTH];
34
35 /* Work out the base name from the device type */
36
37 switch ( device_type )
38 {
39 case WaveOutDevice :
40 wsprintf(base_device_name, L"%ls", WAVE_OUT_DEVICE_NAME);
41 break;
42
43 case WaveInDevice :
44 wsprintf(base_device_name, L"%ls", WAVE_IN_DEVICE_NAME);
45 break;
46
47 case MidiOutDevice :
48 wsprintf(base_device_name, L"%ls", MIDI_OUT_DEVICE_NAME);
49 break;
50
51 case MidiInDevice :
52 wsprintf(base_device_name, L"%ls", MIDI_IN_DEVICE_NAME);
53 break;
54
55 case AuxDevice :
56 wsprintf(base_device_name, L"%ls", AUX_DEVICE_NAME);
57 break;
58
59 default :
61 };
62
63 /* Now append the device number, removing the leading \Device */
64
65 wsprintf(out_device_name,
66 L"\\\\.%ls%d",
67 base_device_name + strlen("\\Device"),
68 device_id);
69
70 return MMSYSERR_NOERROR;
71}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
device_type
#define WAVE_OUT_DEVICE_NAME
Definition: mmdef.h:31
#define MIDI_IN_DEVICE_NAME
Definition: mmdef.h:34
#define MIDI_OUT_DEVICE_NAME
Definition: mmdef.h:36
#define WAVE_IN_DEVICE_NAME
Definition: mmdef.h:29
#define AUX_DEVICE_NAME
Definition: mmdef.h:39
#define MAX_DEVICE_NAME_LENGTH
Definition: mmdrv.h:29
@ MidiOutDevice
Definition: mmdrv.h:45
@ MidiInDevice
Definition: mmdrv.h:46
@ WaveInDevice
Definition: mmdrv.h:44
@ AuxDevice
Definition: mmdrv.h:47
@ WaveOutDevice
Definition: mmdrv.h:43
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
#define MMSYSERR_BADDEVICEID
Definition: mmsystem.h:98
#define L(x)
Definition: ntvdm.h:50
#define wsprintf
Definition: winuser.h:5877
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by OpenKernelDevice().

◆ GetDeviceData()

MMRESULT GetDeviceData ( HANDLE  device_handle,
DWORD  ioctl,
PBYTE  output_buffer,
DWORD  buffer_size 
)

Definition at line 152 of file kernel.c.

157{
158 OVERLAPPED overlap;
159 DWORD bytes_returned;
161 DWORD transfer;
162
163 DPRINT("GetDeviceData\n");
164
165 memset(&overlap, 0, sizeof(overlap));
166
167 overlap.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
168
169 if ( ! overlap.hEvent )
170 return MMSYSERR_NOMEM;
171
172 success = DeviceIoControl(device_handle,
173 ioctl,
174 NULL,
175 0,
178 &bytes_returned,
179 &overlap);
180
181 if ( ! success )
182 {
184 {
185 if ( ! GetOverlappedResult(device_handle, &overlap, &transfer, TRUE) )
186 {
187 CloseHandle(overlap.hEvent);
189 }
190 }
191 else
192 {
193 CloseHandle(overlap.hEvent);
195 }
196 }
197
198 while ( TRUE )
199 {
200 SetEvent(overlap.hEvent);
201
203 {
204 break;
205 }
206 }
207
208 CloseHandle(overlap.hEvent);
209
210 return MMSYSERR_NOERROR;
211}
#define ERROR_IO_PENDING
Definition: dderror.h:15
BOOL WINAPI DeviceIoControl(IN HANDLE hDevice, IN DWORD dwIoControlCode, IN LPVOID lpInBuffer OPTIONAL, IN DWORD nInBufferSize OPTIONAL, OUT LPVOID lpOutBuffer OPTIONAL, IN DWORD nOutBufferSize OPTIONAL, OUT LPDWORD lpBytesReturned OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: deviceio.c:136
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
MMRESULT ErrorToMmResult(UINT error_code)
Definition: common.c:22
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL WINAPI GetOverlappedResult(IN HANDLE hFile, IN LPOVERLAPPED lpOverlapped, OUT LPDWORD lpNumberOfBytesTransferred, IN BOOL bWait)
Definition: iocompl.c:221
#define MMSYSERR_NOMEM
Definition: mmsystem.h:103
#define memset(x, y, z)
Definition: compat.h:39
#define DPRINT
Definition: sndvol32.h:73
HANDLE hEvent
Definition: winbase.h:844
static void buffer_size(GLcontext *ctx, GLuint *width, GLuint *height)
Definition: swimpl.c:888
DWORD WINAPI WaitForSingleObjectEx(IN HANDLE hHandle, IN DWORD dwMilliseconds, IN BOOL bAlertable)
Definition: synch.c:94
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
#define success(from, fromstr, to, tostr)
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define WAIT_IO_COMPLETION
Definition: winbase.h:436
#define CreateEvent
Definition: winbase.h:3772
#define ioctl
Definition: wintirpc.h:60

◆ OpenKernelDevice()

MMRESULT OpenKernelDevice ( DeviceType  device_type,
UINT  device_id,
DWORD  access,
HANDLE handle 
)

Definition at line 84 of file kernel.c.

89{
92 DWORD open_flags = 0;
93
95
96 /* Glue the base device name and the ID together */
97
99
100 DPRINT("Opening kernel device %ls\n", device_name);
101
102 if ( result != MMSYSERR_NOERROR )
103 return result;
104
105 /* We want overlapped I/O when writing */
106
107 if ( access != GENERIC_READ )
108 open_flags = FILE_FLAG_OVERLAPPED;
109
110 /* Now try opening... */
111
113 access,
115 NULL,
117 open_flags,
118 NULL);
119
122
123 return MMSYSERR_NOERROR;
124}
#define OPEN_EXISTING
Definition: compat.h:775
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define GENERIC_READ
Definition: compat.h:135
MMRESULT CobbleDeviceName(DeviceType device_type, UINT device_id, PWCHAR out_device_name)
Definition: kernel.c:28
static const WCHAR device_name[]
Definition: btrfs.c:60
GLuint GLint GLboolean GLint GLenum access
Definition: glext.h:7866
GLuint64EXT * result
Definition: glext.h:11304
UINT MMRESULT
Definition: mmsystem.h:962
#define ASSERT(a)
Definition: mode.c:44
#define FILE_FLAG_OVERLAPPED
Definition: disk.h:46
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define CreateFile
Definition: winbase.h:3773

Referenced by GetDeviceCapabilities(), GetDeviceCount(), and OpenDevice().

◆ SetDeviceData()

MMRESULT SetDeviceData ( HANDLE  device_handle,
DWORD  ioctl,
PBYTE  input_buffer,
DWORD  buffer_size 
)

Definition at line 139 of file kernel.c.

144{
145 DPRINT("SetDeviceData\n");
146 /* TODO */
147 return 0;
148}

Referenced by ProcessSessionThreadRequest().