From: unclepauly on
hello,

i am making an upper filter for the disk class. i am using the toaster
sample from WDK v7600 found here:

C:\WinDDK\7600.16385.1\src\general\toaster\wdm\filter\clasupper


i am using a windows 7 checked build environment. i built the toaster sample
and put the driver on a windows 7 laptop. i added the service in the
registry, and set the UpperFilters reg key on the DiskDrive class. i rebooted
and everything was fine.

then, i added the IRP_MJ_READ to the sample and rebuilt - and now it
bluescreens on startup.

to explain exactly what i have done:

1) in filter.h, where all the declarations for __drv_dispatchType are, i
added:

__drv_dispatchType(IRP_MJ_READ)

2) then in DriverEntry i just added the IRP_MJ_READ bit:

DriverObject->MajorFunction[IRP_MJ_READ] =
DriverObject->MajorFunction[IRP_MJ_CREATE] =
DriverObject->MajorFunction[IRP_MJ_CLOSE] =
DriverObject->MajorFunction[IRP_MJ_CLEANUP] =
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = FilterDispatchIo;


thats all ive done. FilterDispatchIo is already in the sample, it does this
check:

if (commonData->Type == DEVICE_TYPE_FIDO)
{
return FilterPass(DeviceObject, Irp);
}
else
{
ASSERT(commonData->Type == DEVICE_TYPE_CDO);
//.....do the control object stuff here.....//
}

where FilterPass just does:

IoSkipCurrentIrpStackLocation (Irp);
status = IoCallDriver (deviceExtension->NextLowerDriver, Irp);


the above change works fine on xp, its just windows 7 that bluescreens
(haven't tried vista). but im sure this is some novice mistake. can anyone
tell me what ive done wrong please ?

thank you.
From: unclepauly on
well i found the problem, purely by luck. i was looking at the diskperf
sample and noticed that the read/write handler was not in the "alloc_text"
section. so i thought it might be something to do with paging...

i was sending IRP_MJ_READ and IRP_MJ_WRITE through FilterDispatchIo, but
FilterDispatchIo has the PAGE_CODE macro at the top. so i wrote another
handler that was the same as FilterDispatchIo (i called it FilterReadWrite)
but did not have this macro. and now it works. so it looks like READ and
WRITE handlers cannot have the PAGED_CODE macro...maybe this will help some
other beginner in the furture...


"unclepauly" wrote:

> hello,
>
> i am making an upper filter for the disk class. i am using the toaster
> sample from WDK v7600 found here:
>
> C:\WinDDK\7600.16385.1\src\general\toaster\wdm\filter\clasupper
>
>
> i am using a windows 7 checked build environment. i built the toaster sample
> and put the driver on a windows 7 laptop. i added the service in the
> registry, and set the UpperFilters reg key on the DiskDrive class. i rebooted
> and everything was fine.
>
> then, i added the IRP_MJ_READ to the sample and rebuilt - and now it
> bluescreens on startup.
>
> to explain exactly what i have done:
>
> 1) in filter.h, where all the declarations for __drv_dispatchType are, i
> added:
>
> __drv_dispatchType(IRP_MJ_READ)
>
> 2) then in DriverEntry i just added the IRP_MJ_READ bit:
>
> DriverObject->MajorFunction[IRP_MJ_READ] =
> DriverObject->MajorFunction[IRP_MJ_CREATE] =
> DriverObject->MajorFunction[IRP_MJ_CLOSE] =
> DriverObject->MajorFunction[IRP_MJ_CLEANUP] =
> DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = FilterDispatchIo;
>
>
> thats all ive done. FilterDispatchIo is already in the sample, it does this
> check:
>
> if (commonData->Type == DEVICE_TYPE_FIDO)
> {
> return FilterPass(DeviceObject, Irp);
> }
> else
> {
> ASSERT(commonData->Type == DEVICE_TYPE_CDO);
> //.....do the control object stuff here.....//
> }
>
> where FilterPass just does:
>
> IoSkipCurrentIrpStackLocation (Irp);
> status = IoCallDriver (deviceExtension->NextLowerDriver, Irp);
>
>
> the above change works fine on xp, its just windows 7 that bluescreens
> (haven't tried vista). but im sure this is some novice mistake. can anyone
> tell me what ive done wrong please ?
>
> thank you.
From: Doron Holan [MSFT] on
read/write in the storage stack can come in at dispatch_level, but that is
not a general statement across all driver stacks.

d

"unclepauly" wrote in message
news:7DEF0CE6-FFD2-4E31-967C-36EC2891ED1C(a)microsoft.com...

well i found the problem, purely by luck. i was looking at the diskperf
sample and noticed that the read/write handler was not in the "alloc_text"
section. so i thought it might be something to do with paging...

i was sending IRP_MJ_READ and IRP_MJ_WRITE through FilterDispatchIo, but
FilterDispatchIo has the PAGE_CODE macro at the top. so i wrote another
handler that was the same as FilterDispatchIo (i called it FilterReadWrite)
but did not have this macro. and now it works. so it looks like READ and
WRITE handlers cannot have the PAGED_CODE macro...maybe this will help some
other beginner in the furture...


"unclepauly" wrote:

> hello,
>
> i am making an upper filter for the disk class. i am using the toaster
> sample from WDK v7600 found here:
>
> C:\WinDDK\7600.16385.1\src\general\toaster\wdm\filter\clasupper
>
>
> i am using a windows 7 checked build environment. i built the toaster
> sample
> and put the driver on a windows 7 laptop. i added the service in the
> registry, and set the UpperFilters reg key on the DiskDrive class. i
> rebooted
> and everything was fine.
>
> then, i added the IRP_MJ_READ to the sample and rebuilt - and now it
> bluescreens on startup.
>
> to explain exactly what i have done:
>
> 1) in filter.h, where all the declarations for __drv_dispatchType are, i
> added:
>
> __drv_dispatchType(IRP_MJ_READ)
>
> 2) then in DriverEntry i just added the IRP_MJ_READ bit:
>
> DriverObject->MajorFunction[IRP_MJ_READ] =
> DriverObject->MajorFunction[IRP_MJ_CREATE] =
> DriverObject->MajorFunction[IRP_MJ_CLOSE] =
> DriverObject->MajorFunction[IRP_MJ_CLEANUP] =
> DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = FilterDispatchIo;
>
>
> thats all ive done. FilterDispatchIo is already in the sample, it does
> this
> check:
>
> if (commonData->Type == DEVICE_TYPE_FIDO)
> {
> return FilterPass(DeviceObject, Irp);
> }
> else
> {
> ASSERT(commonData->Type == DEVICE_TYPE_CDO);
> //.....do the control object stuff here.....//
> }
>
> where FilterPass just does:
>
> IoSkipCurrentIrpStackLocation (Irp);
> status = IoCallDriver (deviceExtension->NextLowerDriver, Irp);
>
>
> the above change works fine on xp, its just windows 7 that bluescreens
> (haven't tried vista). but im sure this is some novice mistake. can anyone
> tell me what ive done wrong please ?
>
> thank you.