Hi All,

I have a problem formatting and sending an Irp with Urb. I have an usb
upper function filter driver and inside my custom IOCTL handler I call
UsbBuildSelectConfigurationRequest to format an Urb and then I call
SendAwaitUrb to sumbit the Urb. However, IoCallDriver inside
SendAwaitUrb is returning STATUS_INVALID_DEVICE_REQUEST 0xc0000010.

I must be wrong somewere in the code below, because as we all know the
SendWaitUrb and the other code from W.Oney's book is a great source to
learn and practicise.
I have checked the chain Fido->Fdo->Pdo, it's ok, I believe
UsbBuildSelectConfigurationRequest with NULL formats a proper setup
packet... but still I am stuck and could not go ahead.

Please take a look at the code below and let me know what do you think.

Best regards,
Dim

switch (irpStack->MajorFunction) {
case IRP_MJ_CREATE:
DebugPrint(("Create \n"));
break;

case IRP_MJ_CLOSE:
DebugPrint(("Close \n"));
break;

case IRP_MJ_CLEANUP:
DebugPrint(("Cleanup \n"));
break;

case IRP_MJ_DEVICE_CONTROL:
;

switch (irpStack->Parameters.DeviceIoControl.IoControlCode)
{

//Here comes our predefined custom code
case IOCTL_MY_CUSTOM:


// Create the URB
urb = (PURB)ExAllocatePool(NonPagedPool, sizeof(struct
_URB_CONTROL_VENDOR_OR_CLASS_REQUEST));

UsbBuildSelectConfigurationRequest(urb,
sizeof(struct _URB_SELECT_CONFIGURATION),
NULL);


status = SendAwaitUrb(DeviceObject, urb);
if (!NT_SUCCESS(status))
KdPrint((DRIVERNAME " - sending urb failed with status %X\n",
status));
break;
default:
status = STATUS_INVALID_PARAMETER;
break;
}
default:
break;
}

return CompleteRequest(Irp, status, 0);

}

NTSTATUS SendAwaitUrb(PDEVICE_OBJECT fdo, PURB urb)
{
// SendAwaitUrb
PIO_STACK_LOCATION stack;
IO_STATUS_BLOCK iostatus;
KEVENT event;
NTSTATUS status;
PIRP Irp;
PDEVICE_EXTENSION pdx;

PAGED_CODE();

ASSERT(KeGetCurrentIrql() == PASSIVE_LEVEL);

pdx = (PDEVICE_EXTENSION) fdo->DeviceExtension;


if(pdx->NextLowerDriver == NULL)

return STATUS_UNSUCCESSFUL;

KeInitializeEvent(&event, NotificationEvent, FALSE);


Irp = IoBuildDeviceIoControlRequest(IOCTL_INTERNAL_USB_SUBMIT_URB,
pdx->NextLowerDriver, NULL, 0, NULL, 0, TRUE, &event, &iostatus);

if (!Irp)
{

KdPrint((DRIVERNAME " - Unable to allocate IRP for sending URB\n"));
return STATUS_INSUFFICIENT_RESOURCES;
}


stack = IoGetNextIrpStackLocation(Irp);
stack->Parameters.Others.Argument1 = (PVOID) urb;
status = IoCallDriver(pdx->NextLowerDriver, Irp);

if (status == STATUS_PENDING)
{


KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, NULL);
status = iostatus.Status;
}



return status;
}// SendAwaitUrb

Re: IoCallDriver() returns STATUS_INVALID_DEVICE_REQUEST 0xc0000010 by Alexander

Alexander
Fri Feb 03 10:05:13 CST 2006

Look like the actual function driver (below yours) doesn't have a handler
for INTERNAL_DEVICE_CONTROL to pass the IRP down to USBD.

<Dukkov@yahoo.com> wrote in message
news:1138949285.820015.16310@f14g2000cwb.googlegroups.com...
> Hi All,
>
> I have a problem formatting and sending an Irp with Urb. I have an usb
> upper function filter driver and inside my custom IOCTL handler I call
> UsbBuildSelectConfigurationRequest to format an Urb and then I call
> SendAwaitUrb to sumbit the Urb. However, IoCallDriver inside
> SendAwaitUrb is returning STATUS_INVALID_DEVICE_REQUEST 0xc0000010.
>
> I must be wrong somewere in the code below, because as we all know the
> SendWaitUrb and the other code from W.Oney's book is a great source to
> learn and practicise.
> I have checked the chain Fido->Fdo->Pdo, it's ok, I believe
> UsbBuildSelectConfigurationRequest with NULL formats a proper setup
> packet... but still I am stuck and could not go ahead.
>
> Please take a look at the code below and let me know what do you think.
>
> Best regards,
> Dim
>
> switch (irpStack->MajorFunction) {
> case IRP_MJ_CREATE:
> DebugPrint(("Create \n"));
> break;
>
> case IRP_MJ_CLOSE:
> DebugPrint(("Close \n"));
> break;
>
> case IRP_MJ_CLEANUP:
> DebugPrint(("Cleanup \n"));
> break;
>
> case IRP_MJ_DEVICE_CONTROL:
> ;
>
> switch (irpStack->Parameters.DeviceIoControl.IoControlCode)
> {
>
> //Here comes our predefined custom code
> case IOCTL_MY_CUSTOM:
>
>
> // Create the URB
> urb = (PURB)ExAllocatePool(NonPagedPool, sizeof(struct
> _URB_CONTROL_VENDOR_OR_CLASS_REQUEST));
>
> UsbBuildSelectConfigurationRequest(urb,
> sizeof(struct _URB_SELECT_CONFIGURATION),
> NULL);
>
>
> status = SendAwaitUrb(DeviceObject, urb);
> if (!NT_SUCCESS(status))
> KdPrint((DRIVERNAME " - sending urb failed with status %X\n",
> status));
> break;
> default:
> status = STATUS_INVALID_PARAMETER;
> break;
> }
> default:
> break;
> }
>
> return CompleteRequest(Irp, status, 0);
>
> }
>
> NTSTATUS SendAwaitUrb(PDEVICE_OBJECT fdo, PURB urb)
> {
> // SendAwaitUrb
> PIO_STACK_LOCATION stack;
> IO_STATUS_BLOCK iostatus;
> KEVENT event;
> NTSTATUS status;
> PIRP Irp;
> PDEVICE_EXTENSION pdx;
>
> PAGED_CODE();
>
> ASSERT(KeGetCurrentIrql() == PASSIVE_LEVEL);
>
> pdx = (PDEVICE_EXTENSION) fdo->DeviceExtension;
>
>
> if(pdx->NextLowerDriver == NULL)
>
> return STATUS_UNSUCCESSFUL;
>
> KeInitializeEvent(&event, NotificationEvent, FALSE);
>
>
> Irp = IoBuildDeviceIoControlRequest(IOCTL_INTERNAL_USB_SUBMIT_URB,
> pdx->NextLowerDriver, NULL, 0, NULL, 0, TRUE, &event, &iostatus);
>
> if (!Irp)
> {
>
> KdPrint((DRIVERNAME " - Unable to allocate IRP for sending URB\n"));
> return STATUS_INSUFFICIENT_RESOURCES;
> }
>
>
> stack = IoGetNextIrpStackLocation(Irp);
> stack->Parameters.Others.Argument1 = (PVOID) urb;
> status = IoCallDriver(pdx->NextLowerDriver, Irp);
>
> if (status == STATUS_PENDING)
> {
>
>
> KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, NULL);
> status = iostatus.Status;
> }
>
>
>
> return status;
> }// SendAwaitUrb
>



Re: IoCallDriver() returns STATUS_INVALID_DEVICE_REQUEST 0xc0000010 by Walter

Walter
Fri Feb 03 10:07:34 CST 2006

Dukkov@yahoo.com wrote:
> I have an usb
> upper function filter driver

The problem is probably that the function driver does not have an
IRP_MJ_INTERNAL_DEVICE_CONTROL handler. There is a way past this problem
(sending your IRP directly to the PDO), but that's fraught with danger
because the other drivers in the stack must be presumed to be keeping
state information that will become stale. This is ESPECIALLY true with a
SET_CONFIGURATION request, because the drivers below you almost
certainly have pipe handles and a configuration handle that you're going
to be invalidating.

Note that you do not need to allocate a small data structure like a
single URB from the heap. You're lucky in that the size you specified is
bigger than the size you're initializing, but you could just say "URB
urb" and be done with it. That's what the StopDevice function in each of
my USB samples does, for example. The only time I ever allocate a URB
from the heap is when I'm doing something asynchronous. In those cases,
the completion routine will release the memory.

--
Walter Oney, Consulting and Training
http://www.oneysoft.com

Re: IoCallDriver() returns STATUS_INVALID_DEVICE_REQUEST 0xc0000010 by Dukkov

Dukkov
Fri Feb 03 10:30:38 CST 2006

Thanks for the reply Alex!

Now I see one potentional problem--

Upon creation of the device object I put the device type
FILE_DEVICE_UNKNOWN, but what I see on my IRP package sniffer the
actual device type in the outgoing device control IRP is
FILE_DEVICE_VIDEO. How comes? Here is my device create function...
status = IoCreateDevice (DriverObject,
sizeof (DEVICE_EXTENSION),
NULL, // No Name
FILE_DEVICE_UNKNOWN,
FILE_DEVICE_SECURE_OPEN,
FALSE,
&deviceObject);



Alexander Grigoriev wrote:
> Look like the actual function driver (below yours) doesn't have a handler
> for INTERNAL_DEVICE_CONTROL to pass the IRP down to USBD.
>
> <Dukkov@yahoo.com> wrote in message
> news:1138949285.820015.16310@f14g2000cwb.googlegroups.com...
> > Hi All,
> >
> > I have a problem formatting and sending an Irp with Urb. I have an usb
> > upper function filter driver and inside my custom IOCTL handler I call
> > UsbBuildSelectConfigurationRequest to format an Urb and then I call
> > SendAwaitUrb to sumbit the Urb. However, IoCallDriver inside
> > SendAwaitUrb is returning STATUS_INVALID_DEVICE_REQUEST 0xc0000010.
> >
> > I must be wrong somewere in the code below, because as we all know the
> > SendWaitUrb and the other code from W.Oney's book is a great source to
> > learn and practicise.
> > I have checked the chain Fido->Fdo->Pdo, it's ok, I believe
> > UsbBuildSelectConfigurationRequest with NULL formats a proper setup
> > packet... but still I am stuck and could not go ahead.
> >
> > Please take a look at the code below and let me know what do you think.
> >
> > Best regards,
> > Dim
> >
> > switch (irpStack->MajorFunction) {
> > case IRP_MJ_CREATE:
> > DebugPrint(("Create \n"));
> > break;
> >
> > case IRP_MJ_CLOSE:
> > DebugPrint(("Close \n"));
> > break;
> >
> > case IRP_MJ_CLEANUP:
> > DebugPrint(("Cleanup \n"));
> > break;
> >
> > case IRP_MJ_DEVICE_CONTROL:
> > ;
> >
> > switch (irpStack->Parameters.DeviceIoControl.IoControlCode)
> > {
> >
> > //Here comes our predefined custom code
> > case IOCTL_MY_CUSTOM:
> >
> >
> > // Create the URB
> > urb = (PURB)ExAllocatePool(NonPagedPool, sizeof(struct
> > _URB_CONTROL_VENDOR_OR_CLASS_REQUEST));
> >
> > UsbBuildSelectConfigurationRequest(urb,
> > sizeof(struct _URB_SELECT_CONFIGURATION),
> > NULL);
> >
> >
> > status = SendAwaitUrb(DeviceObject, urb);
> > if (!NT_SUCCESS(status))
> > KdPrint((DRIVERNAME " - sending urb failed with status %X\n",
> > status));
> > break;
> > default:
> > status = STATUS_INVALID_PARAMETER;
> > break;
> > }
> > default:
> > break;
> > }
> >
> > return CompleteRequest(Irp, status, 0);
> >
> > }
> >
> > NTSTATUS SendAwaitUrb(PDEVICE_OBJECT fdo, PURB urb)
> > {
> > // SendAwaitUrb
> > PIO_STACK_LOCATION stack;
> > IO_STATUS_BLOCK iostatus;
> > KEVENT event;
> > NTSTATUS status;
> > PIRP Irp;
> > PDEVICE_EXTENSION pdx;
> >
> > PAGED_CODE();
> >
> > ASSERT(KeGetCurrentIrql() == PASSIVE_LEVEL);
> >
> > pdx = (PDEVICE_EXTENSION) fdo->DeviceExtension;
> >
> >
> > if(pdx->NextLowerDriver == NULL)
> >
> > return STATUS_UNSUCCESSFUL;
> >
> > KeInitializeEvent(&event, NotificationEvent, FALSE);
> >
> >
> > Irp = IoBuildDeviceIoControlRequest(IOCTL_INTERNAL_USB_SUBMIT_URB,
> > pdx->NextLowerDriver, NULL, 0, NULL, 0, TRUE, &event, &iostatus);
> >
> > if (!Irp)
> > {
> >
> > KdPrint((DRIVERNAME " - Unable to allocate IRP for sending URB\n"));
> > return STATUS_INSUFFICIENT_RESOURCES;
> > }
> >
> >
> > stack = IoGetNextIrpStackLocation(Irp);
> > stack->Parameters.Others.Argument1 = (PVOID) urb;
> > status = IoCallDriver(pdx->NextLowerDriver, Irp);
> >
> > if (status == STATUS_PENDING)
> > {
> >
> >
> > KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, NULL);
> > status = iostatus.Status;
> > }
> >
> >
> >
> > return status;
> > }// SendAwaitUrb
> >


Re: IoCallDriver() returns STATUS_INVALID_DEVICE_REQUEST 0xc0000010 by Dukkov

Dukkov
Fri Feb 03 10:58:08 CST 2006

Thanks so much, Mr. Oney!

You and Alex are right, I do not provide IRP_MJ_INTERNAL_DEVICE_CONTROL
in my filter code.

Yes, I do send Irp with Urb from my Fido device object to the Pdo
object. I do this in my FilterDispatchIo above.

I have a function driver below my filter and in the Irp sniffer I do
see my function driver's DEVICE_CONTROL Irp going out but I do not see
data.

The strange thing is that upon my filter device object creation
(IoCreateDevice) I put FILE_DEVICE_UNKNOWN device type, but in the
sniffer I see FILE_DEVICE_VIDEO going out.
>From the function driver I see FILE_DEVICE_UNKNOWN going out for this
device control request.

How it is possible? I am going to trace the device type of the device
object right before sending the Irp with Urb.

Also, I am going to provide IRP_MJ_INTERNAL_DEVICE_CONTROL and let you
know.

Thanks once again for your help!

Best regards,
Dim


Re: IoCallDriver() returns STATUS_INVALID_DEVICE_REQUEST 0xc0000010 by Doron

Doron
Fri Feb 03 21:26:22 CST 2006

the issue is not that your driver has no INTERNAL IOCTL handler, the issue
that the driver below you to which you are attached does not have one. You
can only fix this if you own the code to the driver that is below your
filter.

d

--
Please do not send e-mail directly to this alias. this alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.


<Dukkov@yahoo.com> wrote in message
news:1138985888.360769.192920@o13g2000cwo.googlegroups.com...
> Thanks so much, Mr. Oney!
>
> You and Alex are right, I do not provide IRP_MJ_INTERNAL_DEVICE_CONTROL
> in my filter code.
>
> Yes, I do send Irp with Urb from my Fido device object to the Pdo
> object. I do this in my FilterDispatchIo above.
>
> I have a function driver below my filter and in the Irp sniffer I do
> see my function driver's DEVICE_CONTROL Irp going out but I do not see
> data.
>
> The strange thing is that upon my filter device object creation
> (IoCreateDevice) I put FILE_DEVICE_UNKNOWN device type, but in the
> sniffer I see FILE_DEVICE_VIDEO going out.
>>From the function driver I see FILE_DEVICE_UNKNOWN going out for this
> device control request.
>
> How it is possible? I am going to trace the device type of the device
> object right before sending the Irp with Urb.
>
> Also, I am going to provide IRP_MJ_INTERNAL_DEVICE_CONTROL and let you
> know.
>
> Thanks once again for your help!
>
> Best regards,
> Dim
>



Re: IoCallDriver() returns STATUS_INVALID_DEVICE_REQUEST 0xc0000010 by Tim

Tim
Sun Feb 05 01:32:03 CST 2006

Dukkov@yahoo.com wrote:
>
>Thanks for the reply Alex!
>
>Now I see one potentional problem--
>
>Upon creation of the device object I put the device type
>FILE_DEVICE_UNKNOWN, but what I see on my IRP package sniffer the
>actual device type in the outgoing device control IRP is
>FILE_DEVICE_VIDEO. How comes?

Shouldn't be. From usbioctl.h:

#define IOCTL_INTERNAL_USB_SUBMIT_URB CTL_CODE(FILE_DEVICE_USB, \
USB_SUBMIT_URB, \
METHOD_NEITHER, \
FILE_ANY_ACCESS)


#define FILE_DEVICE_USB FILE_DEVICE_UNKNOWN

From ntddk.h:

#define FILE_DEVICE_UNKNOWN 0x00000022
#define FILE_DEVICE_VIDEO 0x00000023

Is your IRP package sniffer cracking the fields properly?
--
- Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

Re: IoCallDriver() returns STATUS_INVALID_DEVICE_REQUEST 0xc0000010 by Dukkov

Dukkov
Sun Feb 05 17:48:17 CST 2006

Thanks a lot for your responses, Doron, Tim!

I found an error in the ioctl handler in my FilterDispatchIo above.
According to the swicth- default-break the filter will handle all
IOCTL_MY_CUSTOM ioctls and will report any other ioctl as
STATUS_INVALID_PARAMETER. Probably the first ioctl to come to my filter
is from the video device (FILE_DEVICE_VIDEO) and because of my error -
it returns with STATUS_INVALID_PARAMETER. I have already fixed this -
for my IOCTL_MY_CUSTOM I generate and submit my Irp with Urb, then call
CompleteRequest.
For any other ioctls I call FilterPass - to pass them down the stack.

Later, I saw the problem with missing IRP_MJ_INTERNAL_DEVICE_CONTROL
handling in the drivers below me (function drivers). Some of the
function drivers had no implementation of
IRP_MJ_INTERNAL_DEVICE_CONTROL at all and I have no the driver's code.
That's why I have to write the filter...

I decided to inject the filter below the function drivers and talk
direcrly to the generic parent. For visibility and access to my filter
I use the approach of shadowing or extra device object described by
Walter Oney and implemented by Eliyas Yakub
http://support.microsoft.com/default.aspx?scid=kb;en-us;Q262305. I
created a symbolic link to call talk directly to this extra device
object, thus bypassing the device stack above me. This guarantee that
my filter will got the ioctl targeted to it.

Now everything seems to work. I see the Urbs being sent from my lower
function filter driver to the generic parent/bus driver (I have a
composite device). I use Compuware Numega wdm sniffer.

I am hoping to be able to construct an 'ideal' Setup packet for my
device - I need to put very specific values there and send them to
control enpoint 0.
For this purpose I am going to use UsbBuildVendorSpecific request and I
hope this function implements the underlaying setup packet for me. I am
going to trace the packets by CATS chief analyzer tomorrow.

UsbBuildVendorSpecific is not very well documented and I am going to
use it, but I wonder if MS puts some wrapping or padding or whatever
that can change the setup packet contents...

I would be glad if someone of you can share his experience about this.

Thanks once again for your help and support!

Dim

Tim Roberts wrote:
> Dukkov@yahoo.com wrote:
> >
> >Thanks for the reply Alex!
> >
> >Now I see one potentional problem--
> >
> >Upon creation of the device object I put the device type
> >FILE_DEVICE_UNKNOWN, but what I see on my IRP package sniffer the
> >actual device type in the outgoing device control IRP is
> >FILE_DEVICE_VIDEO. How comes?
>
> Shouldn't be. From usbioctl.h:
>
> #define IOCTL_INTERNAL_USB_SUBMIT_URB CTL_CODE(FILE_DEVICE_USB, \
> USB_SUBMIT_URB, \
> METHOD_NEITHER, \
> FILE_ANY_ACCESS)
>
>
> #define FILE_DEVICE_USB FILE_DEVICE_UNKNOWN
>
> From ntddk.h:
>
> #define FILE_DEVICE_UNKNOWN 0x00000022
> #define FILE_DEVICE_VIDEO 0x00000023
>
> Is your IRP package sniffer cracking the fields properly?
> --
> - Tim Roberts, timr@probo.com
> Providenza & Boekelheide, Inc.


Re: IoCallDriver() returns STATUS_INVALID_DEVICE_REQUEST 0xc0000010 by Doron

Doron
Sun Feb 05 22:50:25 CST 2006

UsbBuildVendorSpecific just formats the fields of the 8 byte header for the
control endpoint. there is no other padding. just format the values the
way you want and you will be fine.

d

--
Please do not send e-mail directly to this alias. this alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.


<Dukkov@yahoo.com> wrote in message
news:1139183297.180940.122790@g47g2000cwa.googlegroups.com...
> Thanks a lot for your responses, Doron, Tim!
>
> I found an error in the ioctl handler in my FilterDispatchIo above.
> According to the swicth- default-break the filter will handle all
> IOCTL_MY_CUSTOM ioctls and will report any other ioctl as
> STATUS_INVALID_PARAMETER. Probably the first ioctl to come to my filter
> is from the video device (FILE_DEVICE_VIDEO) and because of my error -
> it returns with STATUS_INVALID_PARAMETER. I have already fixed this -
> for my IOCTL_MY_CUSTOM I generate and submit my Irp with Urb, then call
> CompleteRequest.
> For any other ioctls I call FilterPass - to pass them down the stack.
>
> Later, I saw the problem with missing IRP_MJ_INTERNAL_DEVICE_CONTROL
> handling in the drivers below me (function drivers). Some of the
> function drivers had no implementation of
> IRP_MJ_INTERNAL_DEVICE_CONTROL at all and I have no the driver's code.
> That's why I have to write the filter...
>
> I decided to inject the filter below the function drivers and talk
> direcrly to the generic parent. For visibility and access to my filter
> I use the approach of shadowing or extra device object described by
> Walter Oney and implemented by Eliyas Yakub
> http://support.microsoft.com/default.aspx?scid=kb;en-us;Q262305. I
> created a symbolic link to call talk directly to this extra device
> object, thus bypassing the device stack above me. This guarantee that
> my filter will got the ioctl targeted to it.
>
> Now everything seems to work. I see the Urbs being sent from my lower
> function filter driver to the generic parent/bus driver (I have a
> composite device). I use Compuware Numega wdm sniffer.
>
> I am hoping to be able to construct an 'ideal' Setup packet for my
> device - I need to put very specific values there and send them to
> control enpoint 0.
> For this purpose I am going to use UsbBuildVendorSpecific request and I
> hope this function implements the underlaying setup packet for me. I am
> going to trace the packets by CATS chief analyzer tomorrow.
>
> UsbBuildVendorSpecific is not very well documented and I am going to
> use it, but I wonder if MS puts some wrapping or padding or whatever
> that can change the setup packet contents...
>
> I would be glad if someone of you can share his experience about this.
>
> Thanks once again for your help and support!
>
> Dim
>
> Tim Roberts wrote:
>> Dukkov@yahoo.com wrote:
>> >
>> >Thanks for the reply Alex!
>> >
>> >Now I see one potentional problem--
>> >
>> >Upon creation of the device object I put the device type
>> >FILE_DEVICE_UNKNOWN, but what I see on my IRP package sniffer the
>> >actual device type in the outgoing device control IRP is
>> >FILE_DEVICE_VIDEO. How comes?
>>
>> Shouldn't be. From usbioctl.h:
>>
>> #define IOCTL_INTERNAL_USB_SUBMIT_URB CTL_CODE(FILE_DEVICE_USB, \
>> USB_SUBMIT_URB, \
>> METHOD_NEITHER, \
>> FILE_ANY_ACCESS)
>>
>>
>> #define FILE_DEVICE_USB FILE_DEVICE_UNKNOWN
>>
>> From ntddk.h:
>>
>> #define FILE_DEVICE_UNKNOWN 0x00000022
>> #define FILE_DEVICE_VIDEO 0x00000023
>>
>> Is your IRP package sniffer cracking the fields properly?
>> --
>> - Tim Roberts, timr@probo.com
>> Providenza & Boekelheide, Inc.
>



Thank you! Re: IoCallDriver() returns STATUS_INVALID_DEVICE_REQUEST 0xc0000010 by Dukkov

Dukkov
Mon Feb 06 14:15:30 CST 2006

Thanks a lot Doron!

Thanks a lot Mr.Oney, Tim, Alex!

UsbBuildVendorSpecific already formatted my Setup packet and everything
works just fine!
I have checked the packet structure with CATS chief and it is formatted
as expected.
Now I have a lower function filter driver with extra device object
implemented and ready to go! Great book Mr.Oney!

Thanks once again all of you experts!

Best regards,
Dim


Doron Holan [MS] wrote:
> UsbBuildVendorSpecific just formats the fields of the 8 byte header for the
> control endpoint. there is no other padding. just format the values the
> way you want and you will be fine.
>
> d
>
> --
> Please do not send e-mail directly to this alias. this alias is for
> newsgroup purposes only.
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
>
> <Dukkov@yahoo.com> wrote in message
> news:1139183297.180940.122790@g47g2000cwa.googlegroups.com...
> > Thanks a lot for your responses, Doron, Tim!
> >
> > I found an error in the ioctl handler in my FilterDispatchIo above.
> > According to the swicth- default-break the filter will handle all
> > IOCTL_MY_CUSTOM ioctls and will report any other ioctl as
> > STATUS_INVALID_PARAMETER. Probably the first ioctl to come to my filter
> > is from the video device (FILE_DEVICE_VIDEO) and because of my error -
> > it returns with STATUS_INVALID_PARAMETER. I have already fixed this -
> > for my IOCTL_MY_CUSTOM I generate and submit my Irp with Urb, then call
> > CompleteRequest.
> > For any other ioctls I call FilterPass - to pass them down the stack.
> >
> > Later, I saw the problem with missing IRP_MJ_INTERNAL_DEVICE_CONTROL
> > handling in the drivers below me (function drivers). Some of the
> > function drivers had no implementation of
> > IRP_MJ_INTERNAL_DEVICE_CONTROL at all and I have no the driver's code.
> > That's why I have to write the filter...
> >
> > I decided to inject the filter below the function drivers and talk
> > direcrly to the generic parent. For visibility and access to my filter
> > I use the approach of shadowing or extra device object described by
> > Walter Oney and implemented by Eliyas Yakub
> > http://support.microsoft.com/default.aspx?scid=kb;en-us;Q262305. I
> > created a symbolic link to call talk directly to this extra device
> > object, thus bypassing the device stack above me. This guarantee that
> > my filter will got the ioctl targeted to it.
> >
> > Now everything seems to work. I see the Urbs being sent from my lower
> > function filter driver to the generic parent/bus driver (I have a
> > composite device). I use Compuware Numega wdm sniffer.
> >
> > I am hoping to be able to construct an 'ideal' Setup packet for my
> > device - I need to put very specific values there and send them to
> > control enpoint 0.
> > For this purpose I am going to use UsbBuildVendorSpecific request and I
> > hope this function implements the underlaying setup packet for me. I am
> > going to trace the packets by CATS chief analyzer tomorrow.
> >
> > UsbBuildVendorSpecific is not very well documented and I am going to
> > use it, but I wonder if MS puts some wrapping or padding or whatever
> > that can change the setup packet contents...
> >
> > I would be glad if someone of you can share his experience about this.
> >
> > Thanks once again for your help and support!
> >
> > Dim
> >
> > Tim Roberts wrote:
> >> Dukkov@yahoo.com wrote:
> >> >
> >> >Thanks for the reply Alex!
> >> >
> >> >Now I see one potentional problem--
> >> >
> >> >Upon creation of the device object I put the device type
> >> >FILE_DEVICE_UNKNOWN, but what I see on my IRP package sniffer the
> >> >actual device type in the outgoing device control IRP is
> >> >FILE_DEVICE_VIDEO. How comes?
> >>
> >> Shouldn't be. From usbioctl.h:
> >>
> >> #define IOCTL_INTERNAL_USB_SUBMIT_URB CTL_CODE(FILE_DEVICE_USB, \
> >> USB_SUBMIT_URB, \
> >> METHOD_NEITHER, \
> >> FILE_ANY_ACCESS)
> >>
> >>
> >> #define FILE_DEVICE_USB FILE_DEVICE_UNKNOWN
> >>
> >> From ntddk.h:
> >>
> >> #define FILE_DEVICE_UNKNOWN 0x00000022
> >> #define FILE_DEVICE_VIDEO 0x00000023
> >>
> >> Is your IRP package sniffer cracking the fields properly?
> >> --
> >> - Tim Roberts, timr@probo.com
> >> Providenza & Boekelheide, Inc.
> >