hidden hit counter
Help!

Regarding DFU+ IOCTL_INTERNAL_USB_CYCLE_PORT

 
  

Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> Device Driver RSS
Next:  Customizing the taskbar  
Author Message
zyx
External


Since: Dec 13, 2006
Posts: 14



PostPosted: Fri Jan 05, 2007 3:13 am    Post subject: Regarding DFU+ IOCTL_INTERNAL_USB_CYCLE_PORT
Archived from groups: microsoft>public>windowsxp>device_driver>dev (more info?)

Hi,
I am implementing DFU support to the usb function driver.For DFU
support,I need to re enumerate the device so that while enumerating all
the other drivers are unloaded and DFU supported USB function driver
gets loaded.I have posted my piece of code down.

PAGED_CODE();
NTSTATUS status;
PDEVICE_EXTENSION pdx = (PDEVICE_EXTENSION) fdo->DeviceExtension;
KEVENT event;
KeInitializeEvent(&event, NotificationEvent, FALSE);
IO_STATUS_BLOCK iostatus;

PIRP Irp =
IoBuildDeviceIoControlRequest(IOCTL_INTERNAL_USB_CYCLE_PORT,
pdx->LowerDeviceObject, NULL, 0, NULL, 0, TRUE, &event,
&iostatus);
KdPrint((DRIVERNAME " - IoBuildDeviceIoControlRequest %X \n",
iostatus.Status));
KdPrint((DRIVERNAME " - IRP Pointer %X \n", Irp));
PIO_STACK_LOCATION stack = IoGetNextIrpStackLocation(Irp);
stack->MajorFunction = IRP_MJ_INTERNAL_DEVICE_CONTROL;
stack->Parameters.DeviceIoControl.IoControlCode =
IOCTL_INTERNAL_USB_CYCLE_PORT;
//stack->Parameters.Others.Argument1 = (PVOID) urb;

status = IoCallDriver(pdx->LowerDeviceObject, Irp);
KdPrint((DRIVERNAME " - After IoCallDriver %X \n", status));

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

}
KdPrint((DRIVERNAME " - IoBuildDeviceIoControlRequest %X \n",
iostatus.Status));
if (!NT_SUCCESS(status))
{
KdPrint((DRIVERNAME " - Error %X trying to reset device\n",
status));
}
KdPrint((DRIVERNAME " - Returning DFUReset status %X \n", status));
return status;.


The problem here is my device is getting reset.But when it enumerates
again I am getting STATUS_NAME_OBJECT_COLLISION error.IoCreateDevice
fails.
The hardware device I am using is a bluetooth dongle.
Help me thru this.
Back to top
zyx
External


Since: Dec 13, 2006
Posts: 14



PostPosted: Fri Jan 05, 2007 4:07 am    Post subject: Re: Regarding DFU+ IOCTL_INTERNAL_USB_CYCLE_PORT [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Hi,
I will also post the debug prints that I got from dbgview.

Returning DFUReset status 0
PNP Request (IRP_MN_QUERY_DEVICE_RELATIONS)
PNP Request (IRP_MN_QUERY_DEVICE_RELATIONS)
PNP Request (IRP_MN_SURPRISE_REMOVAL)
To SURPRISEREMOVED from WORKING
status IoCallDriver:103
status SendAwaitUrb:c000009d
Error C000009D trying to deconfigure device
IoDeleteSymbolic link 0
NEW Entering AddDevice: DriverObject 86268030, pdo 857D2030 (Max Dev
Count 1)
IoCreateDevice returned - c0000035
Device count - 0.
Failed to create deivce object - c0000035
IRP_MJ_CLEANUP
status :0
IRP_MJ_CLOSE
No queue elements for freeing.
PNP Request (IRP_MN_REMOVE_DEVICE)
To REMOVED from SURPRISEREMOVED
Entering DriverUnload: DriverObject 86268030
NU Entering DriverEntry: DriverObject 86268030

In the above log u can see that symbolic link is also destroyed
correctly in surprise removal function.
My application calls createfile,deviceIocontrol with custom reset
command and close file.






zyx wrote:
> Hi,
> I am implementing DFU support to the usb function driver.For DFU
> support,I need to re enumerate the device so that while enumerating all
> the other drivers are unloaded and DFU supported USB function driver
> gets loaded.I have posted my piece of code down.
>
> PAGED_CODE();
> NTSTATUS status;
> PDEVICE_EXTENSION pdx = (PDEVICE_EXTENSION) fdo->DeviceExtension;
> KEVENT event;
> KeInitializeEvent(&event, NotificationEvent, FALSE);
> IO_STATUS_BLOCK iostatus;
>
> PIRP Irp =
> IoBuildDeviceIoControlRequest(IOCTL_INTERNAL_USB_CYCLE_PORT,
> pdx->LowerDeviceObject, NULL, 0, NULL, 0, TRUE, &event,
> &iostatus);
> KdPrint((DRIVERNAME " - IoBuildDeviceIoControlRequest %X \n",
> iostatus.Status));
> KdPrint((DRIVERNAME " - IRP Pointer %X \n", Irp));
> PIO_STACK_LOCATION stack = IoGetNextIrpStackLocation(Irp);
> stack->MajorFunction = IRP_MJ_INTERNAL_DEVICE_CONTROL;
> stack->Parameters.DeviceIoControl.IoControlCode =
> IOCTL_INTERNAL_USB_CYCLE_PORT;
> //stack->Parameters.Others.Argument1 = (PVOID) urb;
>
> status = IoCallDriver(pdx->LowerDeviceObject, Irp);
> KdPrint((DRIVERNAME " - After IoCallDriver %X \n", status));
>
> if (status == STATUS_PENDING)
> {
> KeWaitForSingleObject(&event, Executive, KernelMode, FALSE,
> NULL);
> status = iostatus.Status;
>
> }
> KdPrint((DRIVERNAME " - IoBuildDeviceIoControlRequest %X \n",
> iostatus.Status));
> if (!NT_SUCCESS(status))
> {
> KdPrint((DRIVERNAME " - Error %X trying to reset device\n",
> status));
> }
> KdPrint((DRIVERNAME " - Returning DFUReset status %X \n", status));
> return status;.
>
>
> The problem here is my device is getting reset.But when it enumerates
> again I am getting STATUS_NAME_OBJECT_COLLISION error.IoCreateDevice
> fails.
> The hardware device I am using is a bluetooth dongle.
> Help me thru this.
Back to top
Doron Holan MS1
External


Since: Jan 28, 2004
Posts: 61



PostPosted: Sun Jan 07, 2007 7:04 pm    Post subject: Re: Regarding DFU+ IOCTL_INTERNAL_USB_CYCLE_PORT [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

on supriser remove you need to delete the symbolic link you created. for
the actual devobj name, if there is a collision, you need to iterate and
give it a new name (instead of \Device\Foo1, \Device\Foo2). In reality, the
best way to do this is not give your device a name at all and use device
interfaces (IoRegisterDeviceInterface/IoSetDeviceInterfaceState). If you
really need to create a NT4 symbolic link, get the PDO's name
(IoGetDeviceProperty(DevicePropertyPhysicalDeviceObjectName )) and create a
symbolic link to it (and again delete the symbolic link during surprise
remove).

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.


"zyx" <vidhya_542001 DeleteThis @yahoo.co.in> wrote in message
news:1167998832.906269.16930@51g2000cwl.googlegroups.com...
> Hi,
> I will also post the debug prints that I got from dbgview.
>
> Returning DFUReset status 0
> PNP Request (IRP_MN_QUERY_DEVICE_RELATIONS)
> PNP Request (IRP_MN_QUERY_DEVICE_RELATIONS)
> PNP Request (IRP_MN_SURPRISE_REMOVAL)
> To SURPRISEREMOVED from WORKING
> status IoCallDriver:103
> status SendAwaitUrb:c000009d
> Error C000009D trying to deconfigure device
> IoDeleteSymbolic link 0
> NEW Entering AddDevice: DriverObject 86268030, pdo 857D2030 (Max Dev
> Count 1)
> IoCreateDevice returned - c0000035
> Device count - 0.
> Failed to create deivce object - c0000035
> IRP_MJ_CLEANUP
> status :0
> IRP_MJ_CLOSE
> No queue elements for freeing.
> PNP Request (IRP_MN_REMOVE_DEVICE)
> To REMOVED from SURPRISEREMOVED
> Entering DriverUnload: DriverObject 86268030
> NU Entering DriverEntry: DriverObject 86268030
>
> In the above log u can see that symbolic link is also destroyed
> correctly in surprise removal function.
> My application calls createfile,deviceIocontrol with custom reset
> command and close file.
>
>
>
>
>
>
> zyx wrote:
>> Hi,
>> I am implementing DFU support to the usb function driver.For DFU
>> support,I need to re enumerate the device so that while enumerating all
>> the other drivers are unloaded and DFU supported USB function driver
>> gets loaded.I have posted my piece of code down.
>>
>> PAGED_CODE();
>> NTSTATUS status;
>> PDEVICE_EXTENSION pdx = (PDEVICE_EXTENSION) fdo->DeviceExtension;
>> KEVENT event;
>> KeInitializeEvent(&event, NotificationEvent, FALSE);
>> IO_STATUS_BLOCK iostatus;
>>
>> PIRP Irp =
>> IoBuildDeviceIoControlRequest(IOCTL_INTERNAL_USB_CYCLE_PORT,
>> pdx->LowerDeviceObject, NULL, 0, NULL, 0, TRUE, &event,
>> &iostatus);
>> KdPrint((DRIVERNAME " - IoBuildDeviceIoControlRequest %X \n",
>> iostatus.Status));
>> KdPrint((DRIVERNAME " - IRP Pointer %X \n", Irp));
>> PIO_STACK_LOCATION stack = IoGetNextIrpStackLocation(Irp);
>> stack->MajorFunction = IRP_MJ_INTERNAL_DEVICE_CONTROL;
>> stack->Parameters.DeviceIoControl.IoControlCode =
>> IOCTL_INTERNAL_USB_CYCLE_PORT;
>> //stack->Parameters.Others.Argument1 = (PVOID) urb;
>>
>> status = IoCallDriver(pdx->LowerDeviceObject, Irp);
>> KdPrint((DRIVERNAME " - After IoCallDriver %X \n", status));
>>
>> if (status == STATUS_PENDING)
>> {
>> KeWaitForSingleObject(&event, Executive, KernelMode, FALSE,
>> NULL);
>> status = iostatus.Status;
>>
>> }
>> KdPrint((DRIVERNAME " - IoBuildDeviceIoControlRequest %X \n",
>> iostatus.Status));
>> if (!NT_SUCCESS(status))
>> {
>> KdPrint((DRIVERNAME " - Error %X trying to reset device\n",
>> status));
>> }
>> KdPrint((DRIVERNAME " - Returning DFUReset status %X \n", status));
>> return status;.
>>
>>
>> The problem here is my device is getting reset.But when it enumerates
>> again I am getting STATUS_NAME_OBJECT_COLLISION error.IoCreateDevice
>> fails.
>> The hardware device I am using is a bluetooth dongle.
>> Help me thru this.
>
Back to top
usbva



Joined: Oct 20, 2008
Posts: 2



PostPosted: Mon Oct 20, 2008 8:18 am    Post subject: IOCTL_INTERNAL_USB_CYCLE_PORT [Login to view extended thread Info.]

Hey,
I have the same requirement as yours.
"I am implementing DFU support to the usb function driver.For DFU
support,I need to re enumerate the device so that while enumerating all
the other drivers are unloaded and DFU supported USB function driver
gets loaded."
I tried to put the same piece of code that is pasted in your first post.but it requires header files for compilation.
Does this need to be complied under Windows DDK environment? or can it be run from Visual studio as C++ application?
Do you have the working code now?

Thanks in advance!
usbva
Back to top
Display posts from previous:   
Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> Device Driver All times are: Eastern Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum