I write a storage filter driver;
and I want to implement this
function: Give sector5 when get sector0

I use this method:

when(Parameters.Read.ByteOffset==0)
Parameters.Read.ByteOffset=512*5

but I got that winxp auto reboot after
a blue screen


this is my code below:

/////////////////////////////////////////////////////////////////////////
FilterRead(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp
)
{

PIO_STACK_LOCATION currentIrpStack = IoGetCurrentIrpStackLocation(Irp);
PIO_STACK_LOCATION nextIrpStack = IoGetNextIrpStackLocation(Irp);

...

// Copy current stack to next stack.
*nextIrpStack = *currentIrpStack;

if(currentIrpStack->Parameters.Read.ByteOffset.QuadPart == 0)
{
// It's not matter to deleting this line
currentIrpStack->Parameters.Read.ByteOffset.QuadPart = 512*5;

// if add this line,
// blue screen appear and auto reboot when winxp is booting
nextIrpStack->Parameters.Read.ByteOffset.QuadPart = 512*5;
}

IoSetCompletionRoutine(Irp, RmFilterIoCompletion,
DeviceObject, TRUE, TRUE, TRUE);
return IoCallDriver(deviceExtension->TargetDeviceObject, Irp);
}

Re: storage filter, error when sector read redirect by David

David
Tue Aug 02 01:27:48 CDT 2005

Read the newsgroups and a good book on writing drivers. Far too many errors
and bad assumptions for a commercial quality driver. 512? Stack location
copying? If these mistakes extend to the rest of the code, it will take a
while to fix it.

"Funfound" <funfound@hotmail.com> wrote in message
news:uJ0eTPylFHA.3584@TK2MSFTNGP10.phx.gbl...
>I write a storage filter driver;
> and I want to implement this
> function: Give sector5 when get sector0
>
> I use this method:
>
> when(Parameters.Read.ByteOffset==0)
> Parameters.Read.ByteOffset=512*5
>
> but I got that winxp auto reboot after
> a blue screen
>
>
> this is my code below:
>
> /////////////////////////////////////////////////////////////////////////
> FilterRead(
> IN PDEVICE_OBJECT DeviceObject,
> IN PIRP Irp
> )
> {
>
> PIO_STACK_LOCATION currentIrpStack = IoGetCurrentIrpStackLocation(Irp);
> PIO_STACK_LOCATION nextIrpStack = IoGetNextIrpStackLocation(Irp);
>
> ...
>
> // Copy current stack to next stack.
> *nextIrpStack = *currentIrpStack;
>
> if(currentIrpStack->Parameters.Read.ByteOffset.QuadPart == 0)
> {
> // It's not matter to deleting this line
> currentIrpStack->Parameters.Read.ByteOffset.QuadPart = 512*5;
>
> // if add this line,
> // blue screen appear and auto reboot when winxp is booting
> nextIrpStack->Parameters.Read.ByteOffset.QuadPart = 512*5;
> }
>
> IoSetCompletionRoutine(Irp, RmFilterIoCompletion,
> DeviceObject, TRUE, TRUE, TRUE);
> return IoCallDriver(deviceExtension->TargetDeviceObject, Irp);
> }
>
>
>