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

Re: How to modify the soundcard buffer? by Tim

Tim
Tue Apr 24 01:08:59 CDT 2007

"Hieu Le Trung" <hieult@cybersoft-vn.com> wrote:
>
>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?

Unless you're working on Vista, this is approximately the right approach.
What did you hear? All you did here is cut the volume in half.

Where did you attach? Upper filter to sysaudio.sys or lower?
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.