Hi all,
I'm writing a Filter Driver which is attached into sysaudio device. I'm able
to catch the IRP_MJ_WRITE and IRP_MJ_READ.
Now how to modify the DMA buffer of the sound and then pass it to the lower
device?
My code snippet
NTSTATUS AudioFilter_Write(PDEVICE_OBJECT DeviceObject, PIRP Irp)
{
NTSTATUS NtStatus = STATUS_BUFFER_TOO_SMALL;
PAUDIO_FILTER_EXTENSION pAudioFilterDeviceContext =
(PAUDIO_FILTER_EXTENSION)DeviceObject->DeviceExtension;
PIO_STACK_LOCATION pIoStackIrp = NULL;
PCHAR pReadDataBuffer;
DbgPrint("AudioFilter_Write Called \r\n");
pIoStackIrp = IoGetCurrentIrpStackLocation(Irp);
pReadDataBuffer = MmGetSystemAddressForMdl(Irp->MdlAddress,
NormalPagePriority);
AudioFilter_ClearBuffer(pReadDataBuffer,
(UINT)MmGetMdlByteCount(Irp->MdlAddress));
IoSkipCurrentIrpStackLocation(Irp);
NtStatus = IoCallDriver(pAudioFilterDeviceContext->pNextDeviceInChain,
Irp);
DbgPrint("AudioFilter_Write Exit 0x%0x \r\n", NtStatus);
return NtStatus;
}
NTSTATUS AudioFilter_ClearBuffer(PUCHAR pString, UINT uiSize)
{
NTSTATUS NtStatus = STATUS_SUCCESS;
UINT uiIndex = 0;
PCHAR data = NULL;
PAGED_CODE();
DbgPrint("AudioFilter_ClearBuffer...\n");
while (uiIndex < (uiSize - 1))
{
if (pString[uiIndex] != 0)
pString[uiIndex] >>= 1;
DbgPrint("%d ", pString[uiIndex]);
uiIndex++;
}
DbgPrint("\n");
return NtStatus;
}
Thanks,
Hieu