Author: janderwald
Date: Fri Jun 19 14:50:19 2009
New Revision: 41467
URL:
http://svn.reactos.org/svn/reactos?rev=41467&view=rev
Log:
- Improve user mode buffer probing
Modified:
trunk/reactos/drivers/wdm/audio/legacy/wdmaud/control.c
trunk/reactos/drivers/wdm/audio/legacy/wdmaud/entry.c
Modified: trunk/reactos/drivers/wdm/audio/legacy/wdmaud/control.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/legacy/w…
==============================================================================
--- trunk/reactos/drivers/wdm/audio/legacy/wdmaud/control.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/legacy/wdmaud/control.c [iso-8859-1] Fri Jun 19
14:50:19 2009
@@ -679,6 +679,8 @@
PCONTEXT_WRITE Packet;
PFILE_OBJECT FileObject;
IO_STATUS_BLOCK IoStatusBlock;
+ PMDL Mdl;
+ PVOID SystemBuffer;
IoStack = IoGetCurrentIrpStackLocation(Irp);
@@ -746,10 +748,19 @@
}
Packet->Header.Data = Buffer;
+ Mdl = IoAllocateMdl(DeviceInfo->Buffer, DeviceInfo->BufferSize, FALSE, FALSE,
FALSE);
+ if (!Mdl)
+ {
+ /* no memory */
+ ExFreePool(Packet);
+ ObDereferenceObject(FileObject);
+ ExFreePool(Buffer);
+ return SetIrpIoStatus(Irp, STATUS_NO_MEMORY, 0);
+ }
+
_SEH2_TRY
{
- ProbeForRead(DeviceInfo->Buffer, DeviceInfo->BufferSize,
TYPE_ALIGNMENT(char));
- RtlMoveMemory(Buffer, DeviceInfo->Buffer, DeviceInfo->BufferSize);
+ MmProbeAndLockPages(Mdl, UserMode, IoReadAccess);
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
@@ -763,9 +774,25 @@
DPRINT1("Invalid buffer supplied\n");
ExFreePool(Buffer);
ExFreePool(Packet);
+ IoFreeMdl(Mdl);
ObDereferenceObject(FileObject);
return SetIrpIoStatus(Irp, Status, 0);
}
+
+ SystemBuffer = MmGetSystemAddressForMdlSafe(Mdl, NormalPagePriority );
+ if (!SystemBuffer)
+ {
+ DPRINT1("Invalid buffer supplied\n");
+ ExFreePool(Buffer);
+ ExFreePool(Packet);
+ IoFreeMdl(Mdl);
+ ObDereferenceObject(FileObject);
+ return SetIrpIoStatus(Irp, Status, 0);
+ }
+
+ RtlMoveMemory(Buffer, SystemBuffer, DeviceInfo->BufferSize);
+ MmUnlockPages(Mdl);
+ IoFreeMdl(Mdl);
KsStreamIo(FileObject, NULL, NULL, NULL, NULL, 0, &IoStatusBlock, Packet,
sizeof(CONTEXT_WRITE), KSSTREAM_WRITE, KernelMode);
ObDereferenceObject(FileObject);
Modified: trunk/reactos/drivers/wdm/audio/legacy/wdmaud/entry.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/legacy/w…
==============================================================================
--- trunk/reactos/drivers/wdm/audio/legacy/wdmaud/entry.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/legacy/wdmaud/entry.c [iso-8859-1] Fri Jun 19 14:50:19
2009
@@ -204,6 +204,7 @@
{
for (Index = 0; Index < pClient->NumPins; Index++)
{
+ DPRINT("Index %u Pin %p Type %x\n", Index,
pClient->hPins[Index].Handle, pClient->hPins[Index].Type);
if (pClient->hPins[Index].Handle && pClient->hPins[Index].Type
!= MIXER_DEVICE_TYPE)
{
ZwClose(pClient->hPins[Index].Handle);