- Use ZwCreateFile to get the file handle

- Ignore failure of device interface registration. Atm registering device interface fails due the device node has zero length. Needs more investigation
- Fix resource file constants

svn path=/trunk/; revision=39547
This commit is contained in:
Johannes Anderwald
2009-02-11 09:54:47 +00:00
parent 335a11923d
commit 0491d4e284
3 changed files with 54 additions and 29 deletions

View File

@@ -43,11 +43,10 @@ SysAudio_Pnp(
UNICODE_STRING SymlinkName = RTL_CONSTANT_STRING(L"\\DosDevices\\sysaudio");
SYSAUDIODEVEXT *DeviceExtension;
DPRINT1("SysAudio_Pnp called\n");
IrpStack = IoGetCurrentIrpStackLocation(Irp);
DPRINT1("SysAudio_Pnp called for func %x\n", IrpStack->MinorFunction);
DeviceExtension = (SYSAUDIODEVEXT*)DeviceObject->DeviceExtension;
if (IrpStack->MinorFunction == IRP_MN_REMOVE_DEVICE)
@@ -86,9 +85,11 @@ DeviceInterfaceChangeCallback(
/* a new device has arrived */
PFILE_OBJECT FileObject = NULL;
PDEVICE_OBJECT DeviceObject = NULL;
UNICODE_STRING DeviceName;
PKSAUDIO_DEVICE_ENTRY DeviceEntry;
HANDLE NodeHandle;
IO_STATUS_BLOCK IoStatusBlock;
OBJECT_ATTRIBUTES ObjectAttributes;
DeviceEntry = ExAllocatePool(NonPagedPool, sizeof(KSAUDIO_DEVICE_ENTRY));
if (!DeviceEntry)
@@ -106,24 +107,44 @@ DeviceInterfaceChangeCallback(
RtlInitUnicodeString(&DeviceName, Event->SymbolicLinkName->Buffer);
#endif
Status = IoGetDeviceObjectPointer(&DeviceName,
FILE_READ_DATA | FILE_WRITE_DATA,
&FileObject,
&DeviceObject);
InitializeObjectAttributes(&ObjectAttributes, &DeviceName, OBJ_KERNEL_HANDLE | OBJ_CASE_INSENSITIVE, NULL, NULL);
Status = ZwCreateFile(&NodeHandle,
GENERIC_READ | GENERIC_WRITE,
&ObjectAttributes,
&IoStatusBlock,
NULL,
0,
0,
FILE_OPEN,
FILE_SYNCHRONOUS_IO_NONALERT,
NULL,
0);
if (!NT_SUCCESS(Status))
{
DPRINT1("ZwCreateFile failed with %x\n", Status);
ExFreePool(DeviceEntry);
return Status;
}
DeviceEntry->DeviceObject = DeviceObject;
Status = ObReferenceObjectByHandle(NodeHandle, GENERIC_READ | GENERIC_WRITE, IoFileObjectType, KernelMode, (PVOID*)&FileObject, NULL);
if (!NT_SUCCESS(Status))
{
ZwClose(NodeHandle);
ExFreePool(DeviceEntry);
DPRINT1("ObReferenceObjectByHandle failed with %x\n", Status);
return Status;
}
DeviceEntry->Handle = NodeHandle;
DeviceEntry->FileObject = FileObject;
InsertTailList(&DeviceExtension->KsAudioDeviceList, &DeviceEntry->Entry);
DeviceExtension->NumberOfKsAudioDevices++;
DPRINT1("Successfully opened audio device\n");
DPRINT1("Successfully opened audio device handle %p file object %p device object %p\n", NodeHandle, FileObject, FileObject->DeviceObject);
return Status;
}
else if (IsEqualGUIDAligned(&Event->Event,
@@ -256,28 +277,34 @@ SysAudio_AddDevice(
#endif
Status = IoRegisterDeviceInterface(PhysicalDeviceObject, &KSCATEGORY_PREFERRED_MIDIOUT_DEVICE, NULL, &SymbolicLink);
if (!NT_SUCCESS(Status))
if (NT_SUCCESS(Status))
{
DPRINT1("Failed to register KSCATEGORY_PREFERRED_MIDIOUT_DEVICE interface\n");
return Status;
RtlFreeUnicodeString(&SymbolicLink);
}
else
{
DPRINT1("Failed to register KSCATEGORY_PREFERRED_MIDIOUT_DEVICE interface Status %x\n", Status);
}
RtlFreeUnicodeString(&SymbolicLink);
Status = IoRegisterDeviceInterface(PhysicalDeviceObject, &KSCATEGORY_PREFERRED_WAVEIN_DEVICE, NULL, &SymbolicLink);
if (!NT_SUCCESS(Status))
if (NT_SUCCESS(Status))
{
DPRINT1("Failed to register KSCATEGORY_PREFERRED_WAVEIN_DEVICE interface\n");
return Status;
RtlFreeUnicodeString(&SymbolicLink);
}
else
{
DPRINT1("Failed to register KSCATEGORY_PREFERRED_WAVEIN_DEVICE interface Status %x\n", Status);
}
RtlFreeUnicodeString(&SymbolicLink);
Status = IoRegisterDeviceInterface(PhysicalDeviceObject, &KSCATEGORY_PREFERRED_WAVEOUT_DEVICE, NULL, &SymbolicLink);
if (!NT_SUCCESS(Status))
if (NT_SUCCESS(Status))
{
DPRINT1("Failed to register KSCATEGORY_PREFERRED_WAVEOUT_DEVICE interface\n");
return Status;
RtlFreeUnicodeString(&SymbolicLink);
}
else
{
DPRINT1("Failed to register KSCATEGORY_PREFERRED_WAVEOUT_DEVICE interface Status %x\n", Status);
}
RtlFreeUnicodeString(&SymbolicLink);
/* set io flags */
DeviceObject->Flags |= DO_DIRECT_IO | DO_POWER_PAGABLE;
@@ -286,11 +313,9 @@ SysAudio_AddDevice(
}
}
DPRINT("Device SysAudio_AddDevice result %x\n", Status);
return Status;
return STATUS_SUCCESS;
}
NTSTATUS

View File

@@ -4,7 +4,7 @@
typedef struct
{
LIST_ENTRY Entry;
PDEVICE_OBJECT DeviceObject;
HANDLE Handle;
PFILE_OBJECT FileObject;
UNICODE_STRING DeviceName;

View File

@@ -1,5 +1,5 @@
#define REACTOS_VERSION_DLL
#define REACTOS_STR_FILE_DESCRIPTION "System audio graph builder\0"
#define REACTOS_STR_INTERNAL_NAME "portcls\0"
#define REACTOS_STR_ORIGINAL_FILENAME "portcls.sys\0"
#define REACTOS_STR_FILE_DESCRIPTION "System Audio Graph Builder\0"
#define REACTOS_STR_INTERNAL_NAME "sysaudio\0"
#define REACTOS_STR_ORIGINAL_FILENAME "sysaudio.sys\0"
#include <reactos/version.rc>