Re: how to accessed paged memory at DISPATCH_LEVEL

Tech-Archive recommends: Fix windows errors by optimizing your registry



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.











.



Relevant Pages

  • Re: how to accessed paged memory at DISPATCH_LEVEL
    ... passive, after copying the buffer. ... Don Burn (MVP, Windows DDK) ... Windows 2k/XP/2k3 Filesystem and Driver Consulting ... accessed paged memory: KsStreamHeader->Data, i have not way or ideas to ...
    (microsoft.public.development.device.drivers)
  • Re: how to accessed paged memory at DISPATCH_LEVEL
    ... access the buffer address in the dispatch routine, you are going to have to ... Don Burn (MVP, Windows DDK) ... Windows 2k/XP/2k3 Filesystem and Driver Consulting ... accessed paged memory: KsStreamHeader->Data, i have not way or ideas to ...
    (microsoft.public.development.device.drivers)
  • Re: how to accessed paged memory at DISPATCH_LEVEL
    ... This buffer allocated at lower driver, ... Don Burn (MVP, Windows DDK) ... Windows 2k/XP/2k3 Filesystem and Driver Consulting ... accessed paged memory: KsStreamHeader->Data, i have not way or ideas to ...
    (microsoft.public.development.device.drivers)
  • Re: Real World Significant Sources of (what we usually call) Latency
    ... CPU is twice as fast, you can reduce your buffer size to half." ... the buffer adjustment for the driver or DAW program would go down to zero. ... nothing that can distract it from processing audio. ...
    (rec.audio.pro)
  • Re: Difference between synchronous and asynchronous operation/calls (NDISPROT)
    ... The main problem with synchronous operation/calls seems to be the lack of buffers for the driver to store data into. ... Each "read call" supplies the driver with a buffer and optionally a completion routine so that the driver can inform the application when the requested operation is/was done. ... However it seems the current windows/driver design does some copies as well? ...
    (microsoft.public.development.device.drivers)