mirror of
https://github.com/reactos/reactos.git
synced 2025-04-26 16:40:27 +00:00
- Improve user mode buffer probing
svn path=/trunk/; revision=41467
This commit is contained in:
parent
97aea8189d
commit
f791b1fa91
2 changed files with 30 additions and 2 deletions
|
@ -679,6 +679,8 @@ WdmAudWrite(
|
|||
PCONTEXT_WRITE Packet;
|
||||
PFILE_OBJECT FileObject;
|
||||
IO_STATUS_BLOCK IoStatusBlock;
|
||||
PMDL Mdl;
|
||||
PVOID SystemBuffer;
|
||||
|
||||
IoStack = IoGetCurrentIrpStackLocation(Irp);
|
||||
|
||||
|
@ -746,10 +748,19 @@ WdmAudWrite(
|
|||
}
|
||||
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,10 +774,26 @@ WdmAudWrite(
|
|||
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);
|
||||
return IoStatusBlock.Status;
|
||||
|
|
|
@ -204,6 +204,7 @@ WdmAudCleanup(
|
|||
{
|
||||
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);
|
||||
|
|
Loading…
Reference in a new issue