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.

Re: how to accessed paged memory at DISPATCH_LEVEL by Don

Don
Wed Jul 23 06:35:12 CDT 2008

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@yahoo.com> wrote in message
news:%23ITk5XL7IHA.3736@TK2MSFTNGP06.phx.gbl...
> 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.
>



Re: how to accessed paged memory at DISPATCH_LEVEL by David

David
Wed Jul 23 06:56:47 CDT 2008

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@stopspam.windrvr.com> wrote in message
news:OwyNtgL7IHA.4532@TK2MSFTNGP05.phx.gbl...
> 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@yahoo.com> wrote in message
> news:%23ITk5XL7IHA.3736@TK2MSFTNGP06.phx.gbl...
>> 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.
>>
>
>



Re: how to accessed paged memory at DISPATCH_LEVEL by Don

Don
Wed Jul 23 07:53:43 CDT 2008

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@yahoo.com> wrote in message
news:uYM0wsL7IHA.4468@TK2MSFTNGP02.phx.gbl...
> 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@stopspam.windrvr.com> wrote in message
> news:OwyNtgL7IHA.4532@TK2MSFTNGP05.phx.gbl...
>> 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@yahoo.com> wrote in message
>> news:%23ITk5XL7IHA.3736@TK2MSFTNGP06.phx.gbl...
>>> 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.
>>>
>>
>>
>
>



Re: how to accessed paged memory at DISPATCH_LEVEL by David

David
Wed Jul 23 08:17:49 CDT 2008

Thank you for reply,

but i do not know address buffer untill the SFDDeviceIoCompletion function
called.

"Don Burn" <burn@stopspam.windrvr.com> wrote in message
news:OMoglMM7IHA.2332@TK2MSFTNGP03.phx.gbl...
> 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@yahoo.com> wrote in message
> news:uYM0wsL7IHA.4468@TK2MSFTNGP02.phx.gbl...
>> 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@stopspam.windrvr.com> wrote in message
>> news:OwyNtgL7IHA.4532@TK2MSFTNGP05.phx.gbl...
>>> 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@yahoo.com> wrote in message
>>> news:%23ITk5XL7IHA.3736@TK2MSFTNGP06.phx.gbl...
>>>> 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.
>>>>
>>>
>>>
>>
>>
>
>



Re: how to accessed paged memory at DISPATCH_LEVEL by Don

Don
Wed Jul 23 08:42:24 CDT 2008

I may not be the right guy here because when someone mentions "kernel
screaming" (oops kernel streaming) I run from the room. But if you cannot
access the buffer address in the dispatch routine, you are going to have to
request a worker thread with the context pointing to the IRP in the
completion routine and return STATUS_MORE_PROCESSING required from
completion. Then complete the IRP in the worker thread which runs at
passive, after copying the buffer.


--
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@yahoo.com> wrote in message
news:eDEDDaM7IHA.4108@TK2MSFTNGP04.phx.gbl...
> Thank you for reply,
>
> but i do not know address buffer untill the SFDDeviceIoCompletion
> function called.
>
> "Don Burn" <burn@stopspam.windrvr.com> wrote in message
> news:OMoglMM7IHA.2332@TK2MSFTNGP03.phx.gbl...
>> 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@yahoo.com> wrote in message
>> news:uYM0wsL7IHA.4468@TK2MSFTNGP02.phx.gbl...
>>> 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@stopspam.windrvr.com> wrote in message
>>> news:OwyNtgL7IHA.4532@TK2MSFTNGP05.phx.gbl...
>>>> 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@yahoo.com> wrote in message
>>>> news:%23ITk5XL7IHA.3736@TK2MSFTNGP06.phx.gbl...
>>>>> 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.
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>



Re: how to accessed paged memory at DISPATCH_LEVEL by Alexander

Alexander
Wed Jul 23 09:54:57 CDT 2008

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@yahoo.com> wrote in message
news:eDEDDaM7IHA.4108@TK2MSFTNGP04.phx.gbl...
> Thank you for reply,
>
> but i do not know address buffer untill the SFDDeviceIoCompletion
> function called.
>
> "Don Burn" <burn@stopspam.windrvr.com> wrote in message
> news:OMoglMM7IHA.2332@TK2MSFTNGP03.phx.gbl...
>> 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@yahoo.com> wrote in message
>> news:uYM0wsL7IHA.4468@TK2MSFTNGP02.phx.gbl...
>>> 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@stopspam.windrvr.com> wrote in message
>>> news:OwyNtgL7IHA.4532@TK2MSFTNGP05.phx.gbl...
>>>> 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@yahoo.com> wrote in message
>>>> news:%23ITk5XL7IHA.3736@TK2MSFTNGP06.phx.gbl...
>>>>> 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.
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>



Re: how to accessed paged memory at DISPATCH_LEVEL by Tim

Tim
Thu Jul 24 23:54:16 CDT 2008

"David" <thuong101277@yahoo.com> wrote:
>
>Thank you for reply,
>
>but i do not know address buffer untill the SFDDeviceIoCompletion function
>called.

That's wrong. It's the same buffer going in as it is coming out. The same
method you use in the completion will work in the ioctl handler.
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

Re: how to accessed paged memory at DISPATCH_LEVEL by Maxim

Maxim
Fri Jul 25 09:36:04 CDT 2008

> but my filter driver need to accessed paged memory at DISPATCH_LEVEL,

Offload the work to a work item OR review the design or make this memory
nonpaged.

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com


Re: how to accessed paged memory at DISPATCH_LEVEL by David

David
Sun Jul 27 21:14:37 CDT 2008

Thank you for reply.

this buffer allow at lower driver, can you explain more clearly? Thank you
again.

"Don Burn" <burn@stopspam.windrvr.com> wrote in message
news:Oo6cynM7IHA.2224@TK2MSFTNGP05.phx.gbl...
>I may not be the right guy here because when someone mentions "kernel
>screaming" (oops kernel streaming) I run from the room. But if you cannot
>access the buffer address in the dispatch routine, you are going to have to
>request a worker thread with the context pointing to the IRP in the
>completion routine and return STATUS_MORE_PROCESSING required from
>completion. Then complete the IRP in the worker thread which runs at
>passive, after copying the buffer.
>
>
> --
> 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@yahoo.com> wrote in message
> news:eDEDDaM7IHA.4108@TK2MSFTNGP04.phx.gbl...
>> Thank you for reply,
>>
>> but i do not know address buffer untill the SFDDeviceIoCompletion
>> function called.
>>
>> "Don Burn" <burn@stopspam.windrvr.com> wrote in message
>> news:OMoglMM7IHA.2332@TK2MSFTNGP03.phx.gbl...
>>> 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@yahoo.com> wrote in message
>>> news:uYM0wsL7IHA.4468@TK2MSFTNGP02.phx.gbl...
>>>> 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@stopspam.windrvr.com> wrote in message
>>>> news:OwyNtgL7IHA.4532@TK2MSFTNGP05.phx.gbl...
>>>>> 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@yahoo.com> wrote in message
>>>>> news:%23ITk5XL7IHA.3736@TK2MSFTNGP06.phx.gbl...
>>>>>> 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.
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>



Re: how to accessed paged memory at DISPATCH_LEVEL by David

David
Sun Jul 27 21:17:18 CDT 2008

Thank you for reply.

this buffer allow at lower driver, can you explain more clearly? Thank you
again.

"Alexander Grigoriev" <alegr@earthlink.net> wrote in message
news:eWFWTQN7IHA.2348@TK2MSFTNGP06.phx.gbl...
> 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@yahoo.com> wrote in message
> news:eDEDDaM7IHA.4108@TK2MSFTNGP04.phx.gbl...
>> Thank you for reply,
>>
>> but i do not know address buffer untill the SFDDeviceIoCompletion
>> function called.
>>
>> "Don Burn" <burn@stopspam.windrvr.com> wrote in message
>> news:OMoglMM7IHA.2332@TK2MSFTNGP03.phx.gbl...
>>> 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@yahoo.com> wrote in message
>>> news:uYM0wsL7IHA.4468@TK2MSFTNGP02.phx.gbl...
>>>> 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@stopspam.windrvr.com> wrote in message
>>>> news:OwyNtgL7IHA.4532@TK2MSFTNGP05.phx.gbl...
>>>>> 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@yahoo.com> wrote in message
>>>>> news:%23ITk5XL7IHA.3736@TK2MSFTNGP06.phx.gbl...
>>>>>> 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.
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>



Re: how to accessed paged memory at DISPATCH_LEVEL by David

David
Sun Jul 27 21:20:06 CDT 2008

Thank you for reply.

This buffer allocated at lower driver, can you explain more clearly? Thank
you
again.

"Don Burn" <burn@stopspam.windrvr.com> wrote in message
news:Oo6cynM7IHA.2224@TK2MSFTNGP05.phx.gbl...
>I may not be the right guy here because when someone mentions "kernel
>screaming" (oops kernel streaming) I run from the room. But if you cannot
>access the buffer address in the dispatch routine, you are going to have to
>request a worker thread with the context pointing to the IRP in the
>completion routine and return STATUS_MORE_PROCESSING required from
>completion. Then complete the IRP in the worker thread which runs at
>passive, after copying the buffer.
>
>
> --
> 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@yahoo.com> wrote in message
> news:eDEDDaM7IHA.4108@TK2MSFTNGP04.phx.gbl...
>> Thank you for reply,
>>
>> but i do not know address buffer untill the SFDDeviceIoCompletion
>> function called.
>>
>> "Don Burn" <burn@stopspam.windrvr.com> wrote in message
>> news:OMoglMM7IHA.2332@TK2MSFTNGP03.phx.gbl...
>>> 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@yahoo.com> wrote in message
>>> news:uYM0wsL7IHA.4468@TK2MSFTNGP02.phx.gbl...
>>>> 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@stopspam.windrvr.com> wrote in message
>>>> news:OwyNtgL7IHA.4532@TK2MSFTNGP05.phx.gbl...
>>>>> 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@yahoo.com> wrote in message
>>>>> news:%23ITk5XL7IHA.3736@TK2MSFTNGP06.phx.gbl...
>>>>>> 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.
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>



Re: how to accessed paged memory at DISPATCH_LEVEL by David

David
Sun Jul 27 21:20:34 CDT 2008

Thank you for reply.

This buffer allocated at lower driver, can you explain more clearly? Thank
you
again.

"Alexander Grigoriev" <alegr@earthlink.net> wrote in message
news:eWFWTQN7IHA.2348@TK2MSFTNGP06.phx.gbl...
> 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@yahoo.com> wrote in message
> news:eDEDDaM7IHA.4108@TK2MSFTNGP04.phx.gbl...
>> Thank you for reply,
>>
>> but i do not know address buffer untill the SFDDeviceIoCompletion
>> function called.
>>
>> "Don Burn" <burn@stopspam.windrvr.com> wrote in message
>> news:OMoglMM7IHA.2332@TK2MSFTNGP03.phx.gbl...
>>> 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@yahoo.com> wrote in message
>>> news:uYM0wsL7IHA.4468@TK2MSFTNGP02.phx.gbl...
>>>> 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 stat