Hello All,
I'm developing a virtual audio driver using the example from this GitHub repository.
I want to get the data from a user application and feed the audio data to the virtual driver for the capturing pipeline. I have created an IOCTL and can send audio data from the user application to the driver, which seems to be working fine as I verified by dumping it into a file.
However, I have two problems now:
- After creating the IOCTL and handling the major IRP create and IRP close, I'm not getting the endpoints. I have attached my major function handling the IRP below.
- How do I send audio data from
adapter.cpp
where I'm receiving the data to theCMiniportWaveRTStream
class? I know I need to pass the data toCMiniportWaveRTStream::WriteBytes
to write data to the mic.
In DriverEntry
, I have created the IOCTL (IoCreateDevice
) and symbolic link (IoCreateSymbolicLink
). Here is my code example:
if (!NT_SUCCESS(IoCreateDevice(DriverObject, 0, &DEVICE_NAME, FILE_DEVICE_UNKNOWN, FILE_DEVICE_SECURE_OPEN, FALSE, &DriverObject->DeviceObject))) {
DPF_ENTER(("Siva : IO Create device failed"));
ntStatus = STATUS_UNSUCCESSFUL;
goto Done;
}
// Routines that will execute once a handle to our device's symbolic link is opened/closed
DriverObject->MajorFunction[IRP_MJ_CREATE] = MajorFunctions;
DriverObject->MajorFunction[IRP_MJ_CLOSE] = MajorFunctions;
// Routine for handling IO requests from userland
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = SimpleAudioSampleDeviceControl;
DPF_ENTER(("Siva Create symbolic link"));
if (NT_SUCCESS(IoCreateSymbolicLink(&DEVICE_SYMBOLIC_NAME, &DEVICE_NAME))) {
DPF_ENTER(("Siva : Symbolic link created"));
} else {
DPF_ENTER(("Siva : Symbolic link failed"));
IoDeleteDevice(DriverObject->DeviceObject);
ntStatus = STATUS_UNSUCCESSFUL;
goto Done;
}
NTSTATUS MajorFunctions(PDEVICE_OBJECT DriverObject, PIRP Irp) {
NTSTATUS ntStatus = STATUS_UNSUCCESSFUL;
UNREFERENCED_PARAMETER(DriverObject);
PAGED_CODE();
PIO_STACK_LOCATION stackLocation = IoGetCurrentIrpStackLocation(Irp);
switch (stackLocation->MajorFunction) {
case IRP_MJ_CREATE:
DbgPrint("siva: IRP_MJ_CREATE File Name: %wZ\n", stackLocation->FileObject->FileName);
break;
case IRP_MJ_CLOSE:
DbgPrint("siva: IRP_MJ_CLOSE File Name: %wZ\n", stackLocation->FileObject->FileName);
break;
default:
DbgPrint("siva: default File Name: %wZ\n", stackLocation->FileObject->FileName);
ntStatus = STATUS_INVALID_DEVICE_REQUEST;
break;
}
ntStatus = PcDispatchIrp(DriverObject, Irp);
if (ntStatus != STATUS_SUCCESS) {
DbgPrint("PcDispatchIrp inside if: \n");
Irp->IoStatus.Information = 0;
Irp->IoStatus.Status = STATUS_SUCCESS;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
}
return STATUS_SUCCESS;
}
Please guide me on how to move forward. Thanks in advance!