Best way to handle unwanted control code in IOCTLs ?

Dear all,
I have a driver for my USB device.
My driver reads, writes data in IOCTL depending on the control code.
My problem is , what is the best way to handle unwanted control code ?.

Simply returning STATUS_INVALID_DEVICE_REQUEST is enough ?
Should I do NumberOfBytesTransferd=0 ?
Should I complete IRP with IoCompleteRequest() ?

or the above three statements compulsory ?

Regards,
S

STATUS_INVALID_DEVICE_REQUEST or STATUS_NOT_SUPPORTED are common codes
to complete the request with for an unsupported IRP, but any NTSTATUS
that evaluates to !NT_SUCCESS will do. Simply returning the value is
not enough. *ALL* PIRPs must be completed. So you must

  1. set the Irp->IoStatus.Status to the error code
  2. optionally set Irp->IoStatus.Information to 0x0
  3. call IoCompleteRequest(Irp, IO_NO_INCREMENT)
  4. return the *SAME* error code that you set in step 1)

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of S
Sent: Sunday, April 17, 2005 11:03 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Best way to handle unwanted control code in IOCTLs ?

Dear all,
I have a driver for my USB device.
My driver reads, writes data in IOCTL depending on the control code.
My problem is , what is the best way to handle unwanted control code ?.

Simply returning STATUS_INVALID_DEVICE_REQUEST is enough ?
Should I do NumberOfBytesTransferd=0 ?
Should I complete IRP with IoCompleteRequest() ?

or the above three statements compulsory ?

Regards,
S


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument:
‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

Dear Doron,

If I set status as NT_SUCCESS and return the same status.
Irp->IoStatus.Information = 0x0 and IoCompleteRequest(),
causes error ? (in my HCT)

Regards,
S
On 4/18/05, Doron Holan wrote:
> STATUS_INVALID_DEVICE_REQUEST or STATUS_NOT_SUPPORTED are common codes
> to complete the request with for an unsupported IRP, but any NTSTATUS
> that evaluates to !NT_SUCCESS will do. Simply returning the value is
> not enough. ALL PIRPs must be completed. So you must
> 1) set the Irp->IoStatus.Status to the error code
> 2) optionally set Irp->IoStatus.Information to 0x0
> 3) call IoCompleteRequest(Irp, IO_NO_INCREMENT)
> 4) return the SAME error code that you set in step 1)
>
> d
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of S
> Sent: Sunday, April 17, 2005 11:03 PM
> To: Windows System Software Devs Interest List
> Subject: [ntdev] Best way to handle unwanted control code in IOCTLs ?
>
> Dear all,
> I have a driver for my USB device.
> My driver reads, writes data in IOCTL depending on the control code.
> My problem is , what is the best way to handle unwanted control code ?.
>
> Simply returning STATUS_INVALID_DEVICE_REQUEST is enough ?
> Should I do NumberOfBytesTransferd=0 ?
> Should I complete IRP with IoCompleteRequest() ?
>
> or the above three statements compulsory ?
>
> Regards,
> S
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: unknown lmsubst tag argument:
> ‘’
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
> —
> Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>

It was unclear to me from your posts if these are IOCTLs which your driver
simply doesn’t understand or handle, or if these are standard IOCTLs that
are in fact supposed to be handled by your device that you choose (either
sometimes or all the time) to not handle.

I happen to think that if you are not a PDO driver, that is if your are not
at the bottom of the stack, then your default ‘unhandled’ IOCTL processing
should be to forward the IOCTL down the stack and let drivers below you
handle it. There is the alternate theory that a function driver’s default
IOCTL processing should be to reject these IOCTLs with an error. However,
your third approach, a default handler that returns STATUS_SUCCESS with zero
data, is unusual. This approach might be useful in some specific cases
(where for example the caller can handle zero data but cannot handle IOCTL
failure) but as a general approach it seems wrong. The fact that the HCT
test is rejecting it would seem to confirm that this is the wrong approach.

It would be helpful if you provided details about what type of device this
is, which HCT test is failing, and exactly which IOCTL or IOCTLs you are
processing in this way.

=====================
Mark Roddy

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of S
Sent: Monday, April 18, 2005 4:54 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] Best way to handle unwanted control code in IOCTLs ?

Dear Doron,

If I set status as NT_SUCCESS and return the same status.
Irp->IoStatus.Information = 0x0 and IoCompleteRequest(),
causes error ? (in my HCT)

Regards,
S
On 4/18/05, Doron Holan wrote:
> STATUS_INVALID_DEVICE_REQUEST or STATUS_NOT_SUPPORTED are common codes
> to complete the request with for an unsupported IRP, but any NTSTATUS
> that evaluates to !NT_SUCCESS will do. Simply returning the value is
> not enough. ALL PIRPs must be completed. So you must
> 1) set the Irp->IoStatus.Status to the error code
> 2) optionally set Irp->IoStatus.Information to 0x0
> 3) call IoCompleteRequest(Irp, IO_NO_INCREMENT)
> 4) return the SAME error code that you set in step 1)
>
> d
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of S
> Sent: Sunday, April 17, 2005 11:03 PM
> To: Windows System Software Devs Interest List
> Subject: [ntdev] Best way to handle unwanted control code in IOCTLs ?
>
> Dear all,
> I have a driver for my USB device.
> My driver reads, writes data in IOCTL depending on the control code.
> My problem is , what is the best way to handle unwanted control code ?.
>
> Simply returning STATUS_INVALID_DEVICE_REQUEST is enough ?
> Should I do NumberOfBytesTransferd=0 ?
> Should I complete IRP with IoCompleteRequest() ?
>
> or the above three statements compulsory ?
>
> Regards,
> S
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: unknown lmsubst tag argument:
> ‘’
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
> —
> Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com