Re: how to accessed paged memory at DISPATCH_LEVEL
- From: "Alexander Grigoriev" <alegr@xxxxxxxxxxxxx>
- Date: Wed, 23 Jul 2008 07:54:57 -0700
The question is "whose buffer is that".
If the buffer is allocated by the lower driver, it's OK to touch it.
If the buffer came from user mode, you cannot touch it in your completion
routine ever. NEVER. You cannot touch neither header, nor data. Not even on
PASSIVE_LEVEL.
And, by the way, Irp argument in the completion routine can never be NULL.
Stack location is also NEVER NULL.
"David" <thuong101277@xxxxxxxxx> wrote in message
news:eDEDDaM7IHA.4108@xxxxxxxxxxxxxxxxxxxxxxx
Thank you for reply,
but i do not know address buffer untill the SFDDeviceIoCompletion
function called.
"Don Burn" <burn@xxxxxxxxxxxxxxxxxxxx> wrote in message
news:OMoglMM7IHA.2332@xxxxxxxxxxxxxxxxxxxxxxx
You need to lock the buffer in the SFDDispatchDeviceIoControl function,
then unlock the buffer after the copy in the completion routine.
--
Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
Remove StopSpam to reply
"David" <thuong101277@xxxxxxxxx> wrote in message
news:uYM0wsL7IHA.4468@xxxxxxxxxxxxxxxxxxxxxxx
Thank you for reply,
my problem is i have call function complete:
NTSTATUS SFDDispatchDeviceIoControl(__in PDEVICE_OBJECT fido, __in PIRP
Irp)
{
PDEVICE_EXTENSION pdx;
NTSTATUS status;
pdx = (PDEVICE_EXTENSION) fido->DeviceExtension;
IoCopyCurrentIrpStackLocationToNext(Irp);
IoSetCompletionRoutine(Irp, SFDDeviceIoCompletion, NULL, TRUE, TRUE,
TRUE );
status = IoCallDriver(pdx->NextLowerDriver,Irp);
return status;
}
NTSTATUS SFDDeviceIoCompletion(__in PDEVICE_OBJECT fido, __in PIRP Irp,
__in PVOID Context)
{
NTSTATUS status = STATUS_UNSUCCESSFUL;
PIO_STACK_LOCATION stack = NULL;
ULONG IoControlCode = 0;
ULONG cbin, cbout;
ULONG info;
PKSSTREAM_HEADER KsStreamHeader;
PKSDATAFORMAT KsDataFormat;
PVOID sysBuffer;
LPBYTE buffer;
KIRQL oldirql;
BOOL isRaise = FALSE;
if(!Irp)
return status;
if(Irp->PendingReturned)
IoMarkIrpPending(Irp);
stack = IoGetCurrentIrpStackLocation(Irp);
if(!stack)
return status;
IoControlCode = stack->Parameters.DeviceIoControl.IoControlCode;
cbin = stack->Parameters.DeviceIoControl.InputBufferLength;
cbout = stack->Parameters.DeviceIoControl.OutputBufferLength;
switch(IoControlCode)
{
case IOCTL_KS_READ_STREAM:
{
info = Irp->IoStatus.Information;
sysBuffer = Irp->AssociatedIrp.SystemBuffer;
KsStreamHeader = (PKSSTREAM_HEADER)sysBuffer;
KsDataFormat = (KSDATAFORMAT*)((LPBYTE)sysBuffer +
sizeof(KSSTREAM_HEADER));
if(KsStreamHeader->Data && (KsStreamHeader->DataUsed > 0))
{
buffer = ExAllocatePool(NonPagedPool, KsStreamHeader->DataUsed);
if(buffer)
{
RtlCopyMemory(buffer, KsStreamHeader->Data,
KsStreamHeader->DataUsed);
ExFreePool(buffer);
}
}
}
break;
case IOCTL_KS_WRITE_STREAM:
DebugPrint(("IOCTL_KS_WRITE_STREAM\n"));
break;
case IOCTL_KS_PROPERTY:
DebugPrint(("IOCTL_KS_WRITE_STREAM\n"));
break;
default:
break;
}
return STATUS_CONTINUE_COMPLETION;
}
When i open webcam it always at case IOCTL_KS_READ_STREAM, but i debug
try to get CurrentIrql by use function:
KeGetCurrentIrql() then it is : DISPATH_LEVEL, in while i want to
accessed paged memory: KsStreamHeader->Data, i have not way or ideas to
access this memory.
"Don Burn" <burn@xxxxxxxxxxxxxxxxxxxx> wrote in message
news:OwyNtgL7IHA.4532@xxxxxxxxxxxxxxxxxxxxxxx
The only way to access paged memory at DISPATCH is to lock it down so
it is not paged before you run the code at DISPATCH. Take a look at
MmProbeAndLockPages.
--
Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
Remove StopSpam to reply
"David" <thuong101277@xxxxxxxxx> wrote in message
news:%23ITk5XL7IHA.3736@xxxxxxxxxxxxxxxxxxxxxxx
hi all,
such as document then we can not accessed paged memory at
DISPATCH_LEVEL, but my filter driver need to accessed paged memory at
DISPATCH_LEVEL, anybody pls help me, i can able to access or not. have
any ways to solve this problem.
Thank very much.
.
- Follow-Ups:
- Re: how to accessed paged memory at DISPATCH_LEVEL
- From: David
- Re: how to accessed paged memory at DISPATCH_LEVEL
- From: David
- Re: how to accessed paged memory at DISPATCH_LEVEL
- References:
- how to accessed paged memory at DISPATCH_LEVEL
- From: David
- Re: how to accessed paged memory at DISPATCH_LEVEL
- From: Don Burn
- Re: how to accessed paged memory at DISPATCH_LEVEL
- From: David
- Re: how to accessed paged memory at DISPATCH_LEVEL
- From: Don Burn
- Re: how to accessed paged memory at DISPATCH_LEVEL
- From: David
- how to accessed paged memory at DISPATCH_LEVEL
- Prev by Date: USB Remote Wake
- Next by Date: Kernel debug Lenovo X300
- Previous by thread: Re: how to accessed paged memory at DISPATCH_LEVEL
- Next by thread: Re: how to accessed paged memory at DISPATCH_LEVEL
- Index(es):
Relevant Pages
|