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

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

?? bulkdev.c

?? Windows2000/xp下的usb WDM驅(qū)動程序源代碼
?? C
?? 第 1 頁 / 共 3 頁
字號:
        ntStatus = STATUS_SUCCESS;
    }
    else {

        BulkUsb_DbgPrint(1, ("BulkUsb_ResetPipe - failed\n"));
    }

    return ntStatus;
}

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

    This routine invokes BulkUsb_ResetParentPort to reset the device

Arguments:

    DeviceObject - pointer to device object

Return Value:

    NT status value

--*/
{
    NTSTATUS ntStatus;
    ULONG    portStatus;

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

    ntStatus = BulkUsb_GetPortStatus(DeviceObject, &portStatus);

    if((NT_SUCCESS(ntStatus))                 &&
       (!(portStatus & USBD_PORT_ENABLED))    &&
       (portStatus & USBD_PORT_CONNECTED)) {

        ntStatus = BulkUsb_ResetParentPort(DeviceObject);
    }

    BulkUsb_DbgPrint(3, ("BulkUsb_ResetDevice - ends\n"));

    return ntStatus;
}

NTSTATUS
BulkUsb_GetPortStatus(
    IN PDEVICE_OBJECT DeviceObject,
    IN OUT PULONG     PortStatus
    )
/*++
 
Routine Description:

    This routine retrieves the status value

Arguments:

    DeviceObject - pointer to device object
    PortStatus - port status

Return Value:

    NT status value

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

    //
    // initialize variables
    //
    deviceExtension = (PDEVICE_EXTENSION) DeviceObject->DeviceExtension;
    *PortStatus = 0;

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

    KeInitializeEvent(&event, NotificationEvent, FALSE);

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

    if(NULL == irp) {

        BulkUsb_DbgPrint(1, ("memory alloc for irp failed\n"));
        return STATUS_INSUFFICIENT_RESOURCES;
    }

    nextStack = IoGetNextIrpStackLocation(irp);

    ASSERT(nextStack != NULL);

    nextStack->Parameters.Others.Argument1 = PortStatus;

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

    if(STATUS_PENDING == ntStatus) {

        KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, NULL);
    }
    else {

        ioStatus.Status = ntStatus;
    }

    ntStatus = ioStatus.Status;

    BulkUsb_DbgPrint(3, ("BulkUsb_GetPortStatus - ends\n"));

    return ntStatus;
}

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

    This routine sends an IOCTL_INTERNAL_USB_RESET_PORT
    synchronously down the stack.

Arguments:

Return Value:

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

    //
    // initialize variables
    //
    deviceExtension = (PDEVICE_EXTENSION) DeviceObject->DeviceExtension;

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

    KeInitializeEvent(&event, NotificationEvent, FALSE);

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

    if(NULL == irp) {

        BulkUsb_DbgPrint(1, ("memory alloc for irp failed\n"));
        return STATUS_INSUFFICIENT_RESOURCES;
    }

    nextStack = IoGetNextIrpStackLocation(irp);

    ASSERT(nextStack != NULL);

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

    if(STATUS_PENDING == ntStatus) {

        KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, NULL);
    }
    else {

        ioStatus.Status = ntStatus;
    }

    ntStatus = ioStatus.Status;

    BulkUsb_DbgPrint(3, ("BulkUsb_ResetParentPort - ends\n"));

    return ntStatus;
}


NTSTATUS
SubmitIdleRequestIrp(
    IN PDEVICE_EXTENSION DeviceExtension
    )
/*++
 
Routine Description:

    This routine builds an idle request irp with an associated callback routine
    and a completion routine in the driver and passes the irp down the stack.

Arguments:

    DeviceExtension - pointer to device extension

Return Value:

    NT status value

--*/
{
    PIRP                    irp;
    NTSTATUS                ntStatus;
    KIRQL                   oldIrql;
    PUSB_IDLE_CALLBACK_INFO idleCallbackInfo;
    PIO_STACK_LOCATION      nextStack;

    //
    // initialize variables
    //
    
    irp = NULL;
    idleCallbackInfo = NULL;

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

    ASSERT(KeGetCurrentIrql() == PASSIVE_LEVEL);

    if(PowerDeviceD0 != DeviceExtension->DevPower) {

        ntStatus = STATUS_POWER_STATE_INVALID;

        goto SubmitIdleRequestIrp_Exit;
    }

    KeAcquireSpinLock(&DeviceExtension->IdleReqStateLock, &oldIrql);

    if(InterlockedExchange(&DeviceExtension->IdleReqPend, 1)) {

        BulkUsb_DbgPrint(1, ("Idle request pending..\n"));

        KeReleaseSpinLock(&DeviceExtension->IdleReqStateLock, oldIrql);

        ntStatus = STATUS_DEVICE_BUSY;

        goto SubmitIdleRequestIrp_Exit;
    }

    //
    // clear the NoIdleReqPendEvent because we are about 
    // to submit an idle request. Since we are so early
    // to clear this event, make sure that if we fail this
    // request we set back the event.
    //
    KeClearEvent(&DeviceExtension->NoIdleReqPendEvent);

    idleCallbackInfo = ExAllocatePool(NonPagedPool, 
                                      sizeof(struct _USB_IDLE_CALLBACK_INFO));

    if(idleCallbackInfo) {

        idleCallbackInfo->IdleCallback = IdleNotificationCallback;

        idleCallbackInfo->IdleContext = (PVOID)DeviceExtension;

        ASSERT(DeviceExtension->IdleCallbackInfo == NULL);

        DeviceExtension->IdleCallbackInfo = idleCallbackInfo;

        //
        // we use IoAllocateIrp to create an irp to selectively suspend the 
        // device. This irp lies pending with the hub driver. When appropriate
        // the hub driver will invoked callback, where we power down. The completion
        // routine is invoked when we power back.
        //
        irp = IoAllocateIrp(DeviceExtension->TopOfStackDeviceObject->StackSize,
                            FALSE);

        if(irp == NULL) {

            BulkUsb_DbgPrint(1, ("cannot build idle request irp\n"));

            KeSetEvent(&DeviceExtension->NoIdleReqPendEvent,
                       IO_NO_INCREMENT,
                       FALSE);

            InterlockedExchange(&DeviceExtension->IdleReqPend, 0);

            KeReleaseSpinLock(&DeviceExtension->IdleReqStateLock, oldIrql);

            ExFreePool(idleCallbackInfo);

            ntStatus = STATUS_INSUFFICIENT_RESOURCES;

            goto SubmitIdleRequestIrp_Exit;
        }

        nextStack = IoGetNextIrpStackLocation(irp);

        nextStack->MajorFunction = 
                    IRP_MJ_INTERNAL_DEVICE_CONTROL;

        nextStack->Parameters.DeviceIoControl.IoControlCode = 
                    IOCTL_INTERNAL_USB_SUBMIT_IDLE_NOTIFICATION;

        nextStack->Parameters.DeviceIoControl.Type3InputBuffer =
                    idleCallbackInfo;

        nextStack->Parameters.DeviceIoControl.InputBufferLength =
                    sizeof(struct _USB_IDLE_CALLBACK_INFO);


        IoSetCompletionRoutine(irp, 
                               IdleNotificationRequestComplete,
                               DeviceExtension, 
                               TRUE, 
                               TRUE, 
                               TRUE);

        DeviceExtension->PendingIdleIrp = irp;

        //
        // we initialize the count to 2.
        // The reason is, if the CancelSelectSuspend routine manages
        // to grab the irp from the device extension, then the last of the
        // CancelSelectSuspend routine/IdleNotificationRequestComplete routine 
        // to execute will free this irp. We need to have this schema so that
        // 1. completion routine does not attempt to touch the irp freed by 
        //    CancelSelectSuspend routine.
        // 2. CancelSelectSuspend routine doesnt wait for ever for the completion
        //    routine to complete!
        //
        DeviceExtension->FreeIdleIrpCount = 2;

        KeReleaseSpinLock(&DeviceExtension->IdleReqStateLock, oldIrql);

        //
        // check if the device is idle.
        // A check here ensures that a race condition did not 
        // completely reverse the call sequence of SubmitIdleRequestIrp
        // and CancelSelectiveSuspend
        //

        if(!CanDeviceSuspend(DeviceExtension) ||
           PowerDeviceD0 != DeviceExtension->DevPower) {

            //
            // IRPs created using IoBuildDeviceIoControlRequest should be
            // completed by calling IoCompleteRequest and not merely 
            // deallocated.
            //
     
            BulkUsb_DbgPrint(1, ("Device is not idle\n"));

            KeAcquireSpinLock(&DeviceExtension->IdleReqStateLock, &oldIrql);

            DeviceExtension->IdleCallbackInfo = NULL;

            DeviceExtension->PendingIdleIrp = NULL;

            KeSetEvent(&DeviceExtension->NoIdleReqPendEvent,
                       IO_NO_INCREMENT,
                       FALSE);

            InterlockedExchange(&DeviceExtension->IdleReqPend, 0);

            KeReleaseSpinLock(&DeviceExtension->IdleReqStateLock, oldIrql);

            if(idleCallbackInfo) {

                ExFreePool(idleCallbackInfo);
            }

            //
            // it is still safe to touch the local variable "irp" here.
            // the irp has not been passed down the stack, the irp has
            // no cancellation routine. The worse position is that the
            // CancelSelectSuspend has run after we released the spin 
            // lock above. It is still essential to free the irp.
            //
            if(irp) {

                IoFreeIrp(irp);
            }

            ntStatus = STATUS_UNSUCCESSFUL;

            goto SubmitIdleRequestIrp_Exit;
        }

        BulkUsb_DbgPrint(3, ("Cancel the timers\n"));
        //
        // Cancel the timer so that the DPCs are no longer fired.
        // Thus, we are making judicious usage of our resources.
        // we do not need DPCs because we already have an idle irp pending.
        // The timers are re-initialized in the completion routine.
        //
        KeCancelTimer(&DeviceExtension->Timer);

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

        if(!NT_SUCCESS(ntStatus)) {

            BulkUsb_DbgPrint(1, ("IoCallDriver failed\n"));

            goto SubmitIdleRequestIrp_Exit;
        }
    }
    else {

        BulkUsb_DbgPrint(1, ("Memory allocation for idleCallbackInfo failed\n"));

        KeSetEvent(&DeviceExtension->NoIdleReqPendEvent,
                   IO_NO_INCREMENT,
                   FALSE);

        InterlockedExchange(&DeviceExtension->IdleReqPend, 0);

        KeReleaseSpinLock(&DeviceExtension->IdleReqStateLock, oldIrql);

        ntStatus = STATUS_INSUFFICIENT_RESOURCES;
    }

SubmitIdleRequestIrp_Exit:

    BulkUsb_DbgPrint(3, ("SubmitIdleRequest - ends\n"));

    return ntStatus;
}


VOID
IdleNotificationCallback(
    IN PDEVICE_EXTENSION DeviceExtension
    )
/*++
 
Routine Description:

  "A pointer to a callback function in your driver is passed down the stack with
   this IOCTL, and it is this callback function that is called by USBHUB when it
   safe for your device to power down."

  "When the callback in your driver is called, all you really need to do is to
   to first ensure that a WaitWake Irp has been submitted for your device, if 
   remote wake is possible for your device and then request a SetD2 (or DeviceWake)"

Arguments:

    DeviceExtension - pointer to device extension

Return Value:

    NT status value

--*/
{
    NTSTATUS                ntStatus;
    POWER_STATE             powerState;
    KEVENT                  irpCompletionEvent;
    PIRP_COMPLETION_CONTEXT irpContext;

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

    //
    // Dont idle, if the device was just disconnected or being stopped
    // i.e. return for the following DeviceState(s)
    // NotStarted, Stopped, PendingStop, PendingRemove, SurpriseRemoved, Removed
    //

    if(DeviceExtension->DeviceState != Working) {

        return;
    }

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
肉色丝袜一区二区| 一区二区三区高清在线| 欧美色大人视频| 国产成+人+日韩+欧美+亚洲| 午夜国产不卡在线观看视频| 中文字幕第一区| 欧美一级片在线看| 欧美性生活影院| 成人av综合一区| 国精产品一区一区三区mba桃花 | 91影院在线免费观看| 免费美女久久99| 亚洲国产日韩a在线播放| 国产精品色在线| 国产视频一区不卡| 欧美电视剧在线观看完整版| 欧美精品日韩一本| 欧洲生活片亚洲生活在线观看| 成人激情动漫在线观看| 国产在线麻豆精品观看| 六月丁香综合在线视频| 日韩精品一卡二卡三卡四卡无卡| 亚洲综合丝袜美腿| 亚洲乱码中文字幕| 国产精品女人毛片| 国产日产亚洲精品系列| 2020国产精品| 亚洲精品一区二区三区影院| 在线成人午夜影院| 欧美日韩成人激情| 欧美午夜电影在线播放| 在线视频你懂得一区| 日本韩国欧美在线| 在线亚洲人成电影网站色www| av电影在线不卡| 91在线免费视频观看| av动漫一区二区| 色综合一个色综合亚洲| 91丨porny丨户外露出| 一本大道久久a久久精二百| 99在线精品视频| 色综合久久综合中文综合网| 一本色道久久综合狠狠躁的推荐 | 高清不卡在线观看av| 国产麻豆视频一区二区| 国产高清在线观看免费不卡| 国产精品影视在线观看| 国产伦精品一区二区三区在线观看 | 亚洲综合视频在线| 亚洲一区在线免费观看| 日韩精品亚洲一区| 麻豆91免费观看| 国产一区二区三区久久悠悠色av| 国产精品12区| 91一区在线观看| 欧美日韩在线免费视频| 91精品国产乱码久久蜜臀| 欧美成人高清电影在线| 国产亚洲欧洲一区高清在线观看| 国产精品乱子久久久久| 亚洲欧美日韩国产综合在线 | 日韩中文字幕一区二区三区| 免费高清在线视频一区·| 国产一区欧美一区| 97久久超碰精品国产| 欧美日韩精品欧美日韩精品一| 91精品国模一区二区三区| 久久综合丝袜日本网| 中文字幕在线一区| 午夜精品123| 国产专区欧美精品| 99精品在线免费| 日韩一区二区电影在线| 欧美精彩视频一区二区三区| 一区二区三区资源| 黄网站免费久久| 色噜噜狠狠一区二区三区果冻| 91精品国产欧美一区二区| 欧美激情一区二区三区在线| 亚洲一区日韩精品中文字幕| 精品一区二区三区在线观看| 99re这里只有精品首页| 日韩欧美中文字幕制服| 18成人在线观看| 麻豆91免费看| 欧洲亚洲精品在线| 久久久久久99久久久精品网站| 理论片日本一区| 成人精品小蝌蚪| 欧美精品乱码久久久久久| 国产女人aaa级久久久级| 亚洲影院理伦片| 国产不卡视频在线观看| 69久久夜色精品国产69蝌蚪网| 国产欧美日韩另类视频免费观看| 亚洲综合激情另类小说区| 久久精品久久久精品美女| 日本久久一区二区三区| 久久精品亚洲乱码伦伦中文| 亚洲电影在线免费观看| www.性欧美| 日韩情涩欧美日韩视频| 亚洲国产精品精华液网站| 成人毛片在线观看| 欧美精品一区二区三区蜜桃视频 | 久久蜜桃av一区精品变态类天堂 | 国产精品中文字幕欧美| 欧美精品久久99久久在免费线| 国产精品看片你懂得| 韩国毛片一区二区三区| 91精品在线观看入口| 亚洲免费在线视频一区 二区| 国产一区二区免费在线| 欧美一级一区二区| 午夜欧美大尺度福利影院在线看| 91看片淫黄大片一级在线观看| 国产片一区二区三区| 国产在线国偷精品免费看| 欧美男人的天堂一二区| 一区二区三区精品在线| 91蜜桃网址入口| 国产精品久久久久一区| 懂色av一区二区夜夜嗨| 久久夜色精品国产噜噜av| 久久国产夜色精品鲁鲁99| 欧美一区二区成人6969| 五月激情综合色| 欧美日本一道本在线视频| 亚洲小少妇裸体bbw| 欧美三级资源在线| 亚洲va韩国va欧美va| 欧美日韩免费观看一区二区三区| 亚洲精品国久久99热| 色综合久久久久综合| 亚洲三级理论片| av电影天堂一区二区在线| 亚洲欧美怡红院| 99riav一区二区三区| 国产伦精品一区二区三区免费| 日韩欧美国产综合一区 | 欧美日本不卡视频| 婷婷丁香激情综合| 欧美一级片在线观看| 六月丁香综合在线视频| 欧美精品一区二区三区四区 | 日韩免费成人网| 国产一区二区视频在线| 国产日韩欧美一区二区三区综合| 成人免费三级在线| 亚洲人成人一区二区在线观看| 在线区一区二视频| 日本一道高清亚洲日美韩| 精品美女被调教视频大全网站| 国产精品自拍网站| 国产精品成人一区二区三区夜夜夜| 91美女片黄在线| 亚洲成人av中文| 精品va天堂亚洲国产| 从欧美一区二区三区| 艳妇臀荡乳欲伦亚洲一区| 91精品国产欧美日韩| 国产成人精品一区二区三区网站观看 | 日本电影亚洲天堂一区| 午夜精品福利在线| 久久亚洲精品小早川怜子| eeuss鲁片一区二区三区在线观看| 一区二区欧美视频| 欧美成人精精品一区二区频| 成人丝袜视频网| 亚洲一级二级三级在线免费观看| 日韩欧美色电影| 91女人视频在线观看| 免费看日韩精品| 亚洲视频中文字幕| 日韩欧美一卡二卡| 91热门视频在线观看| 美腿丝袜亚洲一区| 亚洲人成电影网站色mp4| 欧美一区二区三区视频免费播放| 国产精品一区在线观看你懂的| 亚洲欧美在线观看| 日韩精品一区二区三区四区 | 日韩免费电影一区| 99久久免费精品| 麻豆成人久久精品二区三区红| 日韩一区在线看| 精品久久一二三区| 色婷婷久久综合| 极品少妇一区二区三区精品视频| 1024国产精品| 26uuu久久综合| 欧美乱妇一区二区三区不卡视频| 丁香婷婷综合色啪| 青青青爽久久午夜综合久久午夜 | 午夜久久久久久久久久一区二区| 久久久一区二区三区捆绑**| 欧美性色黄大片| 不卡av免费在线观看| 在线观看av一区| 国产精品一二三区在线|