亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? bulkpnp.c

?? 微軟DDK中關(guān)于WDM驅(qū)動(dòng)程序模型中USB設(shè)備驅(qū)動(dòng)程序的例子,實(shí)現(xiàn)了BULK通道的數(shù)據(jù)傳輸,對(duì)于利用DDK編寫USB驅(qū)動(dòng)程序的朋友是個(gè)很好的參考.
?? C
?? 第 1 頁 / 共 5 頁
字號(hào):

        siz = sizeof(USB_CONFIGURATION_DESCRIPTOR);
        configurationDescriptor = ExAllocatePool(NonPagedPool, siz);

        if(configurationDescriptor) {

            UsbBuildGetDescriptorRequest(
                    urb, 
                    (USHORT) sizeof(struct _URB_CONTROL_DESCRIPTOR_REQUEST),
                    USB_CONFIGURATION_DESCRIPTOR_TYPE, 
                    0, 
                    0, 
                    configurationDescriptor,
                    NULL, 
                    sizeof(USB_CONFIGURATION_DESCRIPTOR), 
                    NULL);

            ntStatus = CallUSBD(DeviceObject, urb);

            if(!NT_SUCCESS(ntStatus)) {

                BulkUsb_DbgPrint(1, ("UsbBuildGetDescriptorRequest failed\n"));
                goto ConfigureDevice_Exit;
            }
        }
        else {

            BulkUsb_DbgPrint(1, ("Failed to allocate mem for config Descriptor\n"));

            ntStatus = STATUS_INSUFFICIENT_RESOURCES;
            goto ConfigureDevice_Exit;
        }

        siz = configurationDescriptor->wTotalLength;

        ExFreePool(configurationDescriptor);

        configurationDescriptor = ExAllocatePool(NonPagedPool, siz);

        if(configurationDescriptor) {

            UsbBuildGetDescriptorRequest(
                    urb, 
                    (USHORT)sizeof(struct _URB_CONTROL_DESCRIPTOR_REQUEST),
                    USB_CONFIGURATION_DESCRIPTOR_TYPE,
                    0, 
                    0, 
                    configurationDescriptor, 
                    NULL, 
                    siz, 
                    NULL);

            ntStatus = CallUSBD(DeviceObject, urb);

            if(!NT_SUCCESS(ntStatus)) {

                BulkUsb_DbgPrint(1,("Failed to read configuration descriptor"));
                goto ConfigureDevice_Exit;
            }
        }
        else {

            BulkUsb_DbgPrint(1, ("Failed to alloc mem for config Descriptor\n"));
            ntStatus = STATUS_INSUFFICIENT_RESOURCES;
            goto ConfigureDevice_Exit;
        }
    }
    else {

        BulkUsb_DbgPrint(1, ("Failed to allocate memory for urb\n"));
        ntStatus = STATUS_INSUFFICIENT_RESOURCES;
        goto ConfigureDevice_Exit;
    }

    if(configurationDescriptor) {

        //
        // save a copy of configurationDescriptor in deviceExtension
        // remember to free it later.
        //
        deviceExtension->UsbConfigurationDescriptor = configurationDescriptor;

        if(configurationDescriptor->bmAttributes & REMOTE_WAKEUP_MASK)
        {
            //
            // this configuration supports remote wakeup
            //
            deviceExtension->WaitWakeEnable = 1;
        }
        else
        {
            deviceExtension->WaitWakeEnable = 0;
        }

        ntStatus = SelectInterfaces(DeviceObject, configurationDescriptor);
    }
    else {

        deviceExtension->UsbConfigurationDescriptor = NULL;
    }

ConfigureDevice_Exit:

    if(urb) {

        ExFreePool(urb);
    }

    return ntStatus;
}

NTSTATUS
SelectInterfaces(
    IN PDEVICE_OBJECT                DeviceObject,
    IN PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor
    )
/*++
 
Routine Description:

    This helper routine selects the configuration

Arguments:

    DeviceObject - pointer to device object
    ConfigurationDescriptor - pointer to the configuration
    descriptor for the device

Return Value:

    NT status value

--*/
{
    LONG                        numberOfInterfaces, 
                                interfaceNumber, 
                                interfaceindex;
    ULONG                       i;
    PURB                        urb;
    PUCHAR                      pInf;
    NTSTATUS                    ntStatus;
    PDEVICE_EXTENSION           deviceExtension;
    PUSB_INTERFACE_DESCRIPTOR   interfaceDescriptor;
    PUSBD_INTERFACE_LIST_ENTRY  interfaceList, 
                                tmp;
    PUSBD_INTERFACE_INFORMATION Interface;

    //
    // initialize the variables
    //

    urb = NULL;
    Interface = NULL;
    interfaceDescriptor = NULL;
    deviceExtension = DeviceObject->DeviceExtension;
    numberOfInterfaces = ConfigurationDescriptor->bNumInterfaces;
    interfaceindex = interfaceNumber = 0;

    //
    // Parse the configuration descriptor for the interface;
    //

    tmp = interfaceList =
        ExAllocatePool(
               NonPagedPool, 
               sizeof(USBD_INTERFACE_LIST_ENTRY) * (numberOfInterfaces + 1));

    if(!tmp) {

        BulkUsb_DbgPrint(1, ("Failed to allocate mem for interfaceList\n"));
        return STATUS_INSUFFICIENT_RESOURCES;
    }


    while(interfaceNumber < numberOfInterfaces) {

        interfaceDescriptor = USBD_ParseConfigurationDescriptorEx(
                                            ConfigurationDescriptor, 
                                            ConfigurationDescriptor,
                                            interfaceindex,
                                            0, -1, -1, -1);

        if(interfaceDescriptor) {

            interfaceList->InterfaceDescriptor = interfaceDescriptor;
            interfaceList->Interface = NULL;
            interfaceList++;
            interfaceNumber++;
        }

        interfaceindex++;
    }

    interfaceList->InterfaceDescriptor = NULL;
    interfaceList->Interface = NULL;
    urb = USBD_CreateConfigurationRequestEx(ConfigurationDescriptor, tmp);

    if(urb) {

        Interface = &urb->UrbSelectConfiguration.Interface;

        for(i=0; i<Interface->NumberOfPipes; i++) {

            //
            // perform pipe initialization here
            // set the transfer size and any pipe flags we use
            // USBD sets the rest of the Interface struct members
            //

            Interface->Pipes[i].MaximumTransferSize = 
                                USBD_DEFAULT_MAXIMUM_TRANSFER_SIZE;
        }

        ntStatus = CallUSBD(DeviceObject, urb);

        if(NT_SUCCESS(ntStatus)) {

            //
            // save a copy of interface information in the device extension.
            //
            deviceExtension->UsbInterface = ExAllocatePool(NonPagedPool,
                                                           Interface->Length);

            if(deviceExtension->UsbInterface) {
                
                RtlCopyMemory(deviceExtension->UsbInterface,
                              Interface,
                              Interface->Length);
            }
            else {

                ntStatus = STATUS_INSUFFICIENT_RESOURCES;
                BulkUsb_DbgPrint(1, ("memory alloc for UsbInterface failed\n"));
            }

            //
            // Dump the interface to the debugger
            //

            Interface = &urb->UrbSelectConfiguration.Interface;

            BulkUsb_DbgPrint(3, ("---------\n"));
            BulkUsb_DbgPrint(3, ("NumberOfPipes 0x%x\n", 
                                 Interface->NumberOfPipes));
            BulkUsb_DbgPrint(3, ("Length 0x%x\n", 
                                 Interface->Length));
            BulkUsb_DbgPrint(3, ("Alt Setting 0x%x\n", 
                                 Interface->AlternateSetting));
            BulkUsb_DbgPrint(3, ("Interface Number 0x%x\n", 
                                 Interface->InterfaceNumber));
            BulkUsb_DbgPrint(3, ("Class, subclass, protocol 0x%x 0x%x 0x%x\n",
                                 Interface->Class,
                                 Interface->SubClass,
                                 Interface->Protocol));
            //
            // Initialize the PipeContext
            // Dump the pipe info
            //

            deviceExtension->PipeContext = ExAllocatePool(
                                                NonPagedPool,
                                                Interface->NumberOfPipes *
                                                sizeof(BULKUSB_PIPE_CONTEXT));

            if(deviceExtension->PipeContext) {
                
                for(i=0; i<Interface->NumberOfPipes; i++) {

                    deviceExtension->PipeContext[i].PipeOpen = FALSE;
                }
            }
            else {
                    
                ntStatus = STATUS_INSUFFICIENT_RESOURCES;
                BulkUsb_DbgPrint(1, ("memory alloc for UsbInterface failed\n"));
            }

            for(i=0; i<Interface->NumberOfPipes; i++) {

                BulkUsb_DbgPrint(3, ("---------\n"));
                BulkUsb_DbgPrint(3, ("PipeType 0x%x\n", 
                                     Interface->Pipes[i].PipeType));
                BulkUsb_DbgPrint(3, ("EndpointAddress 0x%x\n", 
                                     Interface->Pipes[i].EndpointAddress));
                BulkUsb_DbgPrint(3, ("MaxPacketSize 0x%x\n", 
                                    Interface->Pipes[i].MaximumPacketSize));
                BulkUsb_DbgPrint(3, ("Interval 0x%x\n", 
                                     Interface->Pipes[i].Interval));
                BulkUsb_DbgPrint(3, ("Handle 0x%x\n", 
                                     Interface->Pipes[i].PipeHandle));
                BulkUsb_DbgPrint(3, ("MaximumTransferSize 0x%x\n", 
                                    Interface->Pipes[i].MaximumTransferSize));
            }

            BulkUsb_DbgPrint(3, ("---------\n"));
        }
        else {

            BulkUsb_DbgPrint(1, ("Failed to select an interface\n"));
        }
    }
    else {
        
        BulkUsb_DbgPrint(1, ("USBD_CreateConfigurationRequestEx failed\n"));
        ntStatus = STATUS_INSUFFICIENT_RESOURCES;
    }

    if(tmp) {

        ExFreePool(tmp);
    }

    if(urb) {

        ExFreePool(urb);
    }

    return ntStatus;
}


NTSTATUS
DeconfigureDevice(
    IN PDEVICE_OBJECT DeviceObject
    )
/*++
 
Routine Description:

    This routine is invoked when the device is removed or stopped.
    This routine de-configures the usb device.

Arguments:

    DeviceObject - pointer to device object

Return Value:

    NT status value

--*/
{
    PURB     urb;
    ULONG    siz;
    NTSTATUS ntStatus;
    
    //
    // initialize variables
    //

    siz = sizeof(struct _URB_SELECT_CONFIGURATION);
    urb = ExAllocatePool(NonPagedPool, siz);

    if(urb) {

        UsbBuildSelectConfigurationRequest(urb, (USHORT)siz, NULL);

        ntStatus = CallUSBD(DeviceObject, urb);

        if(!NT_SUCCESS(ntStatus)) {

            BulkUsb_DbgPrint(3, ("Failed to deconfigure device\n"));
        }

        ExFreePool(urb);
    }
    else {

        BulkUsb_DbgPrint(1, ("Failed to allocate urb\n"));
        ntStatus = STATUS_INSUFFICIENT_RESOURCES;
    }

    return ntStatus;
}

NTSTATUS
CallUSBD(
    IN PDEVICE_OBJECT DeviceObject,
    IN PURB           Urb
    )
/*++
 
Routine Description:

    This routine synchronously submits an urb down the stack.

Arguments:

    DeviceObject - pointer to device object
    Urb - USB request block

Return Value:

--*/
{
    PIRP               irp;
    KEVENT             event;
    NTSTATUS           ntStatus;
    IO_STATUS_BLOCK    ioStatus;
    PIO_STACK_LOCATION nextStack;
    PDEVICE_EXTENSION  deviceExtension;

    //
    // initialize the variables
    //

    irp = NULL;
    deviceExtension = DeviceObject->DeviceExtension;
    
    KeInitializeEvent(&event, NotificationEvent, FALSE);

    irp = IoBuildDeviceIoControlRequest(IOCTL_INTERNAL_USB_SUBMIT_URB, 
                                        deviceExtension->TopOfStackDeviceObject,
                                        NULL, 
                                        0, 
                                        NULL, 
                                        0, 
                                        TRUE, 
                                        &event, 
                                        &ioStatus);

    if(!irp) {

        BulkUsb_DbgPrint(1, ("IoBuildDeviceIoControlRequest failed\n"));
        return STATUS_INSUFFICIENT_RESOURCES;
    }

    nextStack = IoGetNextIrpStackLocation(irp);
    ASSERT(nextStack != NULL);
    nextStack->Parameters.Others.Argument1 = Urb;

    BulkUsb_DbgPrint(3, ("CallUSBD::"));
    BulkUsb_IoIncrement(deviceExtension);

    ntStatus = IoCallDriver(deviceExtension->TopOfStackDeviceObject, irp);

    if(ntStatus == STATUS_PENDING) {

        KeWaitForSingleObject(&event, 
                              Executive, 
                              KernelMode, 
                              FALSE, 
                              NULL);

        ntStatus = ioStatus.Status;
    }
    
    BulkUsb_DbgPrint(3, ("CallUSBD::"));
    BulkUsb_IoDecrement(deviceExtension);
    return ntStatus;
}

NTSTATUS
HandleQueryStopDevice(
    IN PDEVICE_OBJECT DeviceObject,
    IN PIRP           Irp
    )
/*++
 
Routine Description:

    This routine services the Irps of minor type IRP_MN_QUERY_STOP_DEVICE

Arguments:

    DeviceObject - pointer to device object
    Irp - I/O request packet sent by the pnp manager.

Return Value:

    NT status value

--*/
{
    KIRQL             oldIrql;
    NTSTATUS          ntStatus;
    PDEVICE_EXTENSION deviceExtension;

    BulkUsb_DbgPrint(3, ("HandleQueryStopDevice - begins\n"));

    //
    // initialize variables
    //

    deviceExtension = (PDEVICE_EXTENSION) DeviceObject->DeviceExtension;

    //
    // If we can stop the device, we need to set the QueueState to 
    // HoldRequests so further requests will be queued.
    //

    KeAcquireSpinLock(&deviceExtension->DevStateLock, &oldIrql);
    
    SET_NEW_PNP_STATE(deviceExtension, PendingStop);
    deviceExtension->QueueState = HoldRequests;
    
    KeReleaseSpinLock(&deviceExtension->DevStateLock, oldIrql);

    //
    // wait for the existing ones to be finished.

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产成人aaa| 精品国产免费人成在线观看| 99精品国产热久久91蜜凸| 国产成人在线网站| 国产黄色精品网站| 国产一区二区在线看| 麻豆国产精品777777在线| 日本欧美在线看| 麻豆精品在线播放| 国产一区二区三区四区五区入口 | 国内外精品视频| 加勒比av一区二区| 国产乱国产乱300精品| 国产成人自拍高清视频在线免费播放| 国产精品18久久久久久久久久久久| 国产麻豆精品95视频| 成人一区二区视频| 色综合色狠狠综合色| 在线一区二区观看| 在线不卡一区二区| 精品国产免费视频| 一区二区中文视频| 亚洲午夜久久久久久久久电影院| 午夜欧美在线一二页| 美日韩一区二区| 国产成人av一区| 色哟哟国产精品免费观看| 欧美精品日韩一本| 久久久一区二区| 亚洲精品乱码久久久久久| 水野朝阳av一区二区三区| 激情久久五月天| 91一区在线观看| 91精品欧美一区二区三区综合在| 久久这里只精品最新地址| 成人免费小视频| 五月综合激情日本mⅴ| 国产精品一区二区你懂的| 91在线视频免费观看| 91精品国产色综合久久久蜜香臀| 国产亚洲一本大道中文在线| 亚洲麻豆国产自偷在线| 美日韩黄色大片| 91亚洲永久精品| 日韩一区二区不卡| 欧美丰满嫩嫩电影| 777奇米成人网| 精品国产电影一区二区| 国产精品久久久久久久久动漫| 亚洲午夜久久久久| 国产精品白丝jk黑袜喷水| 日本黄色一区二区| 久久久久久97三级| 性久久久久久久久| 成人av集中营| 欧美xxxx在线观看| 亚洲愉拍自拍另类高清精品| 国产一区二区三区免费看| 欧美色网站导航| 国产视频一区不卡| 欧美aⅴ一区二区三区视频| 99久久精品99国产精品| 精品国产露脸精彩对白| 午夜久久久久久久久| 成人久久18免费网站麻豆| 日韩欧美国产综合| 午夜精品123| 99精品久久只有精品| 国产亚洲污的网站| 免费精品视频在线| 欧美吻胸吃奶大尺度电影| 亚洲欧洲精品一区二区三区| 国产综合久久久久久鬼色 | 精品乱人伦小说| 亚洲午夜精品在线| 色综合天天综合给合国产| 久久九九久精品国产免费直播| 天天影视网天天综合色在线播放| 99热精品一区二区| 国产人成亚洲第一网站在线播放| 日本不卡一二三区黄网| 欧美亚洲国产一区二区三区va| 中文字幕精品—区二区四季| 国内欧美视频一区二区| 欧美一区二区三区白人| 亚洲国产成人91porn| 成人免费视频国产在线观看| 久久久九九九九| 国产精品综合网| 久久一区二区三区国产精品| 日本中文字幕不卡| 欧美疯狂做受xxxx富婆| 夜色激情一区二区| 一本大道久久a久久精品综合| 中日韩免费视频中文字幕| 国产酒店精品激情| 久久久久久久久久久久久女国产乱 | 日韩一区二区免费在线观看| 午夜精品一区二区三区三上悠亚| 91社区在线播放| 亚洲品质自拍视频| 91免费看视频| 亚洲视频在线一区二区| 91免费精品国自产拍在线不卡| 国产精品卡一卡二卡三| 成人三级在线视频| 国产精品成人一区二区艾草| 成人久久18免费网站麻豆 | 国产精品1区二区.| 国产欧美精品一区二区三区四区| 国产精品一二三四五| 久久亚洲一级片| 成人午夜大片免费观看| 中文字幕日韩一区二区| 91视频观看视频| 亚洲国产精品精华液网站| 欧美日韩综合在线| 日本在线不卡一区| 日韩欧美卡一卡二| 国产黑丝在线一区二区三区| 中文字幕高清一区| 色婷婷久久久久swag精品| 亚洲成人黄色小说| 日韩欧美一级在线播放| 国产精品主播直播| 亚洲欧洲日韩av| 欧美日韩一区二区三区视频| 蜜桃免费网站一区二区三区| 久久久久久免费网| 99久久精品免费看| 视频一区视频二区中文| 国产校园另类小说区| 93久久精品日日躁夜夜躁欧美| 亚洲电影一区二区| 精品欧美一区二区三区精品久久| 国产一区二区成人久久免费影院| 国产精品黄色在线观看| 欧美在线综合视频| 狂野欧美性猛交blacked| 中文字幕精品综合| 在线观看亚洲a| 狠狠色丁香婷综合久久| 成人免费小视频| 日韩精品专区在线影院观看| 粉嫩av一区二区三区在线播放 | 一本一本大道香蕉久在线精品| 香蕉成人伊视频在线观看| 久久香蕉国产线看观看99| 色呦呦一区二区三区| 狠狠狠色丁香婷婷综合激情 | 91蜜桃婷婷狠狠久久综合9色| 午夜一区二区三区视频| 久久亚洲一区二区三区四区| 91视频免费看| 精品亚洲成a人| 亚洲日本免费电影| 久久麻豆一区二区| 欧美日韩黄色影视| 国产suv精品一区二区三区| 亚洲成人免费观看| 中文字幕av不卡| 欧美一区二区三区视频免费播放| 成人黄色电影在线| 日韩高清不卡在线| 亚洲色图欧美激情| 国产亚洲精品中文字幕| 这里只有精品电影| 色综合久久天天综合网| 国产美女一区二区| 亚洲bt欧美bt精品| 最近日韩中文字幕| 久久亚洲精华国产精华液| 欧美乱妇15p| 色婷婷久久一区二区三区麻豆| 国产精品亚洲一区二区三区妖精 | 国产精品网站在线观看| 欧美一区国产二区| 色诱亚洲精品久久久久久| 国产大片一区二区| 蜜臀久久99精品久久久画质超高清| 亚洲免费观看视频| 欧美激情在线一区二区三区| 欧美成人vps| 4438亚洲最大| 欧美日韩一级二级| 91女神在线视频| 不卡av免费在线观看| 国产精品伊人色| 九九精品一区二区| 日本午夜精品一区二区三区电影| 一区二区三区精品久久久| 中文字幕中文字幕一区二区| 亚洲精品在线三区| 精品国产一区二区精华| 日韩欧美另类在线| 欧美成人免费网站| 日韩一区二区三免费高清| 91精品免费在线| 这里只有精品免费| 制服.丝袜.亚洲.另类.中文|