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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? usblspnp.c

?? 來自微軟的usb2.0開發包,加速USB驅動開發
?? C
?? 第 1 頁 / 共 3 頁
字號:
/*++

Copyright (c) 1999 Microsoft Corporation

Module Name:

    Usblspnp.c 

Abstract:

    USB LS-120 Mass Storage Device Sample Driver
    Plug and Play module

Environment:

    kernel mode only

Notes:

  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
  PURPOSE.

  Copyright (c) 1999 Microsoft Corporation.  All Rights Reserved.


Revision History:

    1/13/99: MRB	Adapted from the BULKUSB DDK sample.

--*/


#include "wdm.h"
#include "stdarg.h"
#include "stdio.h"

#include "usbdi.h"
#include "usbdlib.h"
#include "usbls120.h"
#include "guidls.h"


NTSTATUS
USBLS120_ProcessPnPIrp(
    IN PDEVICE_OBJECT DeviceObject,
    IN PIRP           Irp
    )
/*++

Routine Description:

    Dispatch table routine for IRP_MJ_PNP.
    Process the Plug and Play IRPs sent to this device.

Arguments:

    DeviceObject - pointer to our FDO (Functional Device Object)

    Irp          - pointer to an I/O Request Packet

Return Value:

    NT status code

--*/
{

    PIO_STACK_LOCATION irpStack;
    PDEVICE_EXTENSION deviceExtension;
    NTSTATUS ntStatus = STATUS_SUCCESS;
    NTSTATUS waitStatus;
    PDEVICE_OBJECT stackDeviceObject;
    KEVENT startDeviceEvent;


    //
    // Get a pointer to the current location in the Irp. This is where
    // the function codes and parameters are located.
    //
    irpStack = IoGetCurrentIrpStackLocation (Irp);

    //
    // Get a pointer to the device extension
    //

    deviceExtension = DeviceObject->DeviceExtension;
    stackDeviceObject = deviceExtension->TopOfStackDeviceObject;

    USBLS120_KdPrint( DBGLVL_MEDIUM, ( "enter USBLS120_ProcessPnPIrp() IRP_MJ_PNP, minor %s\n",
    USBLS120_StringForPnpMnFunc( irpStack->MinorFunction ) ));

    // inc the FDO device extension's pending IO count for this Irp
    USBLS120_IncrementIoCount(DeviceObject);

    USBLS120_ASSERT( IRP_MJ_PNP == irpStack->MajorFunction );

    switch (irpStack->MinorFunction)
    {
        case IRP_MN_START_DEVICE:

            // The PnP Manager sends this IRP after it has assigned resources, 
            // if any, to the device. The device may have been recently enumerated
            // and is being started for the first time, or the device may be 
            // restarting after being stopped for resource reconfiguration. 

            // Initialize an event we can wait on for the PDO to be done with this irp
            KeInitializeEvent(&startDeviceEvent, NotificationEvent, FALSE);
            IoCopyCurrentIrpStackLocationToNext(Irp);

            // Set a completion routine so it can signal our event when
            // the PDO is done with the Irp
            IoSetCompletionRoutine(
                Irp,
                USBLS120_IrpCompletionRoutine,
                &startDeviceEvent,  // pass the event to the completion routine as the Context
                TRUE,    // invoke on success
                TRUE,    // invoke on error
                TRUE     // invoke on cancellation
                );

            // let the PDO process the IRP
            ntStatus = IoCallDriver(stackDeviceObject, Irp);

            // if PDO is not done yet, wait for the event to be set in our completion routine
            if (ntStatus == STATUS_PENDING) {

                // wait for irp to complete
                waitStatus = KeWaitForSingleObject(
                    &startDeviceEvent,
                    Suspended,
                    KernelMode,
                    FALSE,
                    NULL
                    );
            }

            // Now we're ready to do our own startup processing.
            // USB client drivers such as us set up URBs (USB Request Packets) to send requests
            // to the host controller driver (HCD). The URB structure defines a format for all
            // possible commands that can be sent to a USB device.
            // Here, we request the device descriptor and store it,
            // and configure the device.
            ntStatus = USBLS120_StartDevice(DeviceObject);

            // Give the device a second to init, spinup, etc.
            KeStallExecutionProcessor(1000);
		
            Irp->IoStatus.Status = ntStatus;

            IoCompleteRequest (Irp, IO_NO_INCREMENT);

            USBLS120_DecrementIoCount(DeviceObject);

            return ntStatus;  // end, case IRP_MN_START_DEVICE


        case IRP_MN_QUERY_DEVICE_RELATIONS:
            // Enumerate our child PDO
            ntStatus = USBLS120_FdoDeviceQuery(DeviceObject, Irp);

            USBLS120_DecrementIoCount(DeviceObject);

            return ntStatus;


        case IRP_MN_QUERY_STOP_DEVICE:

            // The IRP_MN_QUERY_STOP_DEVICE/IRP_MN_STOP_DEVICE sequence only occurs
            // during "polite" shutdowns, such as the user explicitily requesting the
            // service be stopped in, or requesting unplug from the Pnp tray icon.
            // This sequence is NOT received during "impolite" shutdowns,
            // such as someone suddenly yanking the USB cord or otherwise 
            // unexpectedly disabling/resetting the device.

            // If a driver sets STATUS_SUCCESS for this IRP,
            // the driver must not start any operations on the device that
            // would prevent that driver from successfully completing an IRP_MN_STOP_DEVICE
            // for the device.
            // For mass storage devices such as disk drives, while the device is in the
            // stop-pending state,the driver holds IRPs that require access to the device,
            // but for most USB devices, there is no 'persistent storage', so we will just
            // refuse any more IO until restarted or the stop is cancelled

            // If a driver in the device stack determines that the device cannot be
            // stopped for resource reconfiguration, the driver is not required to pass
            // the IRP down the device stack. If a query-stop IRP fails,
            // the PnP Manager sends an IRP_MN_CANCEL_STOP_DEVICE to the device stack,
            // notifying the drivers for the device that the query has been cancelled
            // and that the device will not be stopped.
  

            // It is possible to receive this irp when the device has not been started
            //  ( as on a boot device )

            if (!deviceExtension->DeviceStarted) {
                // if get when never started, just pass on
                USBLS120_KdPrint( DBGLVL_MEDIUM,("USBLS120_ProcessPnPIrp() IRP_MN_QUERY_STOP_DEVICE when device not started\n"));
                IoSkipCurrentIrpStackLocation (Irp);
                ntStatus = IoCallDriver (deviceExtension->TopOfStackDeviceObject, Irp);
                USBLS120_DecrementIoCount(DeviceObject);

                return ntStatus;
            }


            // We'll not veto it; pass it on and flag that stop was requested.
            // Once StopDeviceRequested is set no new IOCTL or read/write irps will be passed
            // down the stack to lower drivers; all will be quickly failed
            deviceExtension->StopDeviceRequested = TRUE;

            break; // end, case IRP_MN_QUERY_STOP_DEVICE



        case IRP_MN_CANCEL_STOP_DEVICE:

            // The PnP Manager uses this IRP to inform the drivers for a device
            // that the device will not be stopped for resource reconfiguration.
            // This should only be received after a successful IRP_MN_QUERY_STOP_DEVICE.


            // It is possible to receive this irp when the device has not been started

            if (!deviceExtension->DeviceStarted) {
                // if get when never started, just pass on
                USBLS120_KdPrint( DBGLVL_MEDIUM,("USBLS120_ProcessPnPIrp() IRP_MN_CANCEL_STOP_DEVICE when device not started\n"));
                IoSkipCurrentIrpStackLocation (Irp);
                ntStatus = IoCallDriver (deviceExtension->TopOfStackDeviceObject, Irp);
                USBLS120_DecrementIoCount(DeviceObject);
                return ntStatus;
            }

            // Reset this flag so new IOCTL and IO Irp processing will be re-enabled
            deviceExtension->StopDeviceRequested = FALSE;
            break; // end, case IRP_MN_CANCEL_STOP_DEVICE


        case IRP_MN_STOP_DEVICE:

            // The PnP Manager sends this IRP to stop a device so it can reconfigure
            // its hardware resources. The PnP Manager only sends this IRP if a prior
            // IRP_MN_QUERY_STOP_DEVICE completed successfully.


            //
            // Send the select configuration urb with a NULL pointer for the configuration
            // handle, this closes the configuration and puts the device in the 'unconfigured'
            // state.
            //
            ntStatus = USBLS120_StopDevice(DeviceObject);

            break; // end, case IRP_MN_STOP_DEVICE



        case IRP_MN_QUERY_REMOVE_DEVICE:

            //  In response to this IRP, drivers indicate whether the device can be
            //  removed without disrupting the system.
            //  If a driver determines it is safe to remove the device,
            //  the driver completes any outstanding I/O requests, arranges to hold any subsequent
            //  read/write requests, and sets Irp->IoStatus.Status to STATUS_SUCCESS. Function
            //  and filter drivers then pass the IRP to the next-lower driver in the device stack.
            //  The underlying bus driver calls IoCompleteRequest.
        
            //  If a driver sets STATUS_SUCCESS for this IRP, the driver must not start any
            //  operations on the device that would prevent that driver from successfully completing
            //  an IRP_MN_REMOVE_DEVICE for the device. If a driver in the device stack determines
            //  that the device cannot be removed, the driver is not required to pass the
            //  query-remove IRP down the device stack. If a query-remove IRP fails, the PnP Manager
            //  sends an IRP_MN_CANCEL_REMOVE_DEVICE to the device stack, notifying the drivers for
            //  the device that the query has been cancelled and that the device will not be removed.
    
            // It is possible to receive this irp when the device has not been started
 
            if (!deviceExtension->DeviceStarted) {
                // if get when never started, just pass on
                USBLS120_KdPrint( DBGLVL_MEDIUM,("USBLS120_ProcessPnPIrp() IRP_MN_QUERY_STOP_DEVICE when device not started\n"));
                IoSkipCurrentIrpStackLocation (Irp);
                ntStatus = IoCallDriver (deviceExtension->TopOfStackDeviceObject, Irp);
                USBLS120_DecrementIoCount(DeviceObject);
         
                return ntStatus;
            }

            // Once RemoveDeviceRequested is set no new IOCTL or read/write irps will be passed
            // down the stack to lower drivers; all will be quickly failed
            deviceExtension->RemoveDeviceRequested = TRUE;

            // Wait for any io request pending in our driver to
            // complete before returning success.
            // This  event is set when deviceExtension->PendingIoCount goes to 1
            waitStatus = KeWaitForSingleObject(
                &deviceExtension->NoPendingIoEvent,
                Suspended,
                KernelMode,
                FALSE,
                NULL
                );

            break; // end, case IRP_MN_QUERY_REMOVE_DEVICE



        case IRP_MN_CANCEL_REMOVE_DEVICE:

            // The PnP Manager uses this IRP to inform the drivers
            // for a device that the device will not be removed.
            // It is sent only after a successful IRP_MN_QUERY_REMOVE_DEVICE.
    
            if (!deviceExtension->DeviceStarted) {
                // if get when never started, just pass on
                USBLS120_KdPrint( DBGLVL_MEDIUM,("USBLS120_ProcessPnPIrp() IRP_MN_CANCEL_REMOVE_DEVICE when device not started\n"));
                IoSkipCurrentIrpStackLocation (Irp);
                ntStatus = IoCallDriver (deviceExtension->TopOfStackDeviceObject, Irp);
                USBLS120_DecrementIoCount(DeviceObject);
                return ntStatus;
            }

            // Reset this flag so new IOCTL and IO Irp processing will be re-enabled
            deviceExtension->RemoveDeviceRequested = FALSE;
   
            break; // end, case IRP_MN_CANCEL_REMOVE_DEVICE
     


        case IRP_MN_SURPRISE_REMOVAL:

            USBLS120_KdPrint( DBGLVL_MEDIUM,("USBLS120_ProcessPnPIrp() IRP_MN_SURPRISE_REMOVAL\n"));
          
            // For a surprise-style device removal ( i.e. sudden cord yank ), 
            // the physical device has already been removed so the PnP Manager sends 
            // the remove IRP without a prior query-remove. A device can be in any state
            // when it receives a remove IRP as a result of a surprise-style removal.

            // match the inc at the begining of the dispatch routine
            USBLS120_DecrementIoCount(DeviceObject);

            //
            // Once DeviceRemoved is set no new IOCTL or read/write irps will be passed
            // down the stack to lower drivers; all will be quickly failed
            //
            deviceExtension->DeviceRemoved = TRUE;
     
            // If any pipes are still open, call USBD with URB_FUNCTION_ABORT_PIPE
            // This call will also close the pipes; if any user close calls get through,
            // they will be noops
            USBLS120_AbortPipes( DeviceObject );


            // We don't explicitly wait for the below driver to complete, but just make
            // the call and go on, finishing cleanup
            IoCopyCurrentIrpStackLocationToNext(Irp);

            ntStatus = IoCallDriver(stackDeviceObject, Irp);

            return ntStatus;



        case IRP_MN_REMOVE_DEVICE:

            // The PnP Manager uses this IRP to direct drivers to remove a device. 
            // For a "polite" device removal, the PnP Manager sends an 
            // IRP_MN_QUERY_REMOVE_DEVICE prior to the remove IRP. In this case, 
            // the device is in the remove-pending state when the remove IRP arrives.
            // For a surprise-style device removal ( i.e. sudden cord yank ), 
            // the physical device has already been removed and the PnP Manager may not 
            //  have sent IRP_MN_SURPRISE_REMOVAL. A device can be in any state
            // when it receives a remove IRP as a result of a surprise-style removal.

            // match the inc at the begining of the dispatch routine
            USBLS120_DecrementIoCount(DeviceObject);

            //
            // Once DeviceRemoved is set no new IOCTL or read/write irps will be passed
            // down the stack to lower drivers; all will be quickly failed
            //
            deviceExtension->DeviceRemoved = TRUE;

            // If any pipes are still open, call USBD with URB_FUNCTION_ABORT_PIPE
            // This call will also close the pipes; if any user close calls get through,
            // they will be noops
            USBLS120_AbortPipes( DeviceObject );
    
            // We don't explicitly wait for the below driver to complete, but just make
            // the call and go on, finishing cleanup
            IoCopyCurrentIrpStackLocationToNext(Irp);

            ntStatus = IoCallDriver(stackDeviceObject, Irp);

            //
            // The final decrement to device extension PendingIoCount == 0
            // will set deviceExtension->RemoveEvent, enabling device removal.
            // If there is no pending IO at this point, the below decrement will be it.
            //
            USBLS120_DecrementIoCount(DeviceObject);
      

            // wait for any io request pending in our driver to
            // complete for finishing the remove

            KeWaitForSingleObject(
                &deviceExtension->RemoveEvent,
                Suspended,
                KernelMode,
                FALSE,
                NULL
                );

            //
            // Delete the link and FDO we created
            //
            USBLS120_RemoveDevice(DeviceObject);
    

            USBLS120_KdPrint( DBGLVL_DEFAULT,("USBLS120_ProcessPnPIrp() Detaching from %08X\n",
                              deviceExtension->TopOfStackDeviceObject));

            IoDetachDevice(deviceExtension->TopOfStackDeviceObject);

            USBLS120_KdPrint( DBGLVL_DEFAULT,("USBLS120_ProcessPnPIrp() Deleting %08X\n",
                              DeviceObject));

            IoDeleteDevice (DeviceObject);

            return ntStatus; // end, case IRP_MN_REMOVE_DEVICE



        default:
            USBLS120_KdPrint( DBGLVL_MAXIMUM,("USBLS120_ProcessPnPIrp() Minor PnP IOCTL not handled\n"));

    } /* case MinorFunction  */


    if (!NT_SUCCESS(ntStatus)) {

        // if anything went wrong, return failure  without passing Irp down
        Irp->IoStatus.Status = ntStatus;
        IoCompleteRequest (Irp,
            IO_NO_INCREMENT
            );

        USBLS120_DecrementIoCount(DeviceObject);

        USBLS120_KdPrint( DBGLVL_MAXIMUM,("USBLS120_ProcessPnPIrp() Exit USBLS120_ProcessPnPIrp FAILURE %x\n", ntStatus));

        return ntStatus;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
色婷婷激情综合| 国产精品视频一区二区三区不卡| 日韩一级免费一区| 国产视频一区二区三区在线观看| 一级中文字幕一区二区| 国产在线不卡视频| 欧美日韩三级一区| 成人欧美一区二区三区1314| 久久99热这里只有精品| 欧美日韩欧美一区二区| 亚洲欧美色一区| 国产凹凸在线观看一区二区| 91精品欧美久久久久久动漫| 亚洲永久精品国产| www.成人网.com| 久久久久久久av麻豆果冻| 久久精品国产成人一区二区三区 | 精品无人区卡一卡二卡三乱码免费卡 | 国产又黄又大久久| 777亚洲妇女| 香蕉久久夜色精品国产使用方法| 99re成人在线| 中文字幕一区二区三中文字幕| 狠狠色丁香久久婷婷综合丁香| 欧美精品777| 午夜精品久久久久久久久久久| 在线观看视频一区| 亚洲午夜免费电影| 欧美在线你懂的| 亚洲影院久久精品| 欧美日韩免费观看一区二区三区| 亚洲欧美色一区| 欧美伊人久久大香线蕉综合69 | 午夜欧美视频在线观看| 欧美三级电影网| 亚洲成a人片综合在线| 精品视频资源站| 日韩一区欧美二区| 91麻豆精品国产91久久久使用方法| 日韩综合小视频| 日韩一区二区三区四区 | 波多野结衣一区二区三区| 国产精品嫩草99a| 色网站国产精品| 一区二区欧美精品| 在线不卡中文字幕| 久久精品久久精品| 中文字幕精品一区二区三区精品| 成人激情午夜影院| 一区二区三区成人| 欧美一级二级在线观看| 国产一区二区在线观看免费| 中文字幕不卡的av| 精品视频资源站| 久久成人综合网| 亚洲欧美中日韩| 91精品国产品国语在线不卡| 国产一区 二区 三区一级| 亚洲欧美另类小说视频| 欧美一级电影网站| jizzjizzjizz欧美| 日韩成人一级片| 国产精品无人区| 7777精品伊人久久久大香线蕉完整版 | 精品免费国产二区三区| eeuss鲁片一区二区三区在线观看| 一级特黄大欧美久久久| 精品国产sm最大网站| 成人h版在线观看| 日韩电影在线一区二区三区| 国产欧美日韩视频一区二区| 欧美在线免费观看视频| 国产一区不卡在线| 亚洲成人7777| 国产精品视频一二| 日韩女优电影在线观看| 色婷婷亚洲精品| 国产麻豆成人传媒免费观看| 亚洲第一久久影院| 中文字幕在线观看不卡视频| 欧美一区二区三区人| 91麻豆.com| 国产精品一级在线| 日韩精品乱码av一区二区| 亚洲图片你懂的| 国产色91在线| 日韩午夜精品视频| 欧美午夜一区二区三区免费大片| 国产精品 欧美精品| 美腿丝袜亚洲色图| 亚洲国产sm捆绑调教视频 | 国产亚洲自拍一区| 欧美欧美欧美欧美首页| 91亚洲永久精品| 国产成人久久精品77777最新版本| 亚洲自拍偷拍综合| 亚洲激情五月婷婷| 日韩一区日韩二区| 国产精品成人午夜| 国产色一区二区| 久久久久久久网| 久久一区二区三区国产精品| 9191成人精品久久| 欧美日韩国产欧美日美国产精品| 日本精品一区二区三区高清| 成人午夜电影久久影院| 国产精品69毛片高清亚洲| 国产伦精品一区二区三区视频青涩| 天堂成人国产精品一区| 亚洲一区欧美一区| 亚洲国产精品久久一线不卡| 亚洲一区二区三区四区在线免费观看 | 偷拍日韩校园综合在线| 亚洲成人动漫一区| 丝袜亚洲另类欧美综合| 婷婷开心激情综合| 日韩精品久久理论片| 免费成人结看片| 久久99精品久久久| 国产呦精品一区二区三区网站| 国产在线播放一区| 国产99一区视频免费| 99久久精品一区二区| 91精品91久久久中77777| 在线观看免费成人| 6080午夜不卡| 欧美va亚洲va| 中文字幕乱码日本亚洲一区二区| 国产精品美女久久久久久| 亚洲精品视频自拍| 青青草原综合久久大伊人精品优势| 久久电影网电视剧免费观看| 国产成人综合亚洲网站| 色悠悠久久综合| 日韩一级免费观看| 国产欧美一区二区精品仙草咪| 国产精品国产a| 午夜国产精品一区| 国产成人午夜精品5599| 色8久久人人97超碰香蕉987| 91精品国产综合久久香蕉麻豆| 亚洲精品在线电影| 亚洲免费在线观看视频| 日本成人在线一区| 成人午夜电影小说| 7777精品伊人久久久大香线蕉经典版下载 | 国产免费观看久久| 亚洲一区二区四区蜜桃| 激情文学综合丁香| 一本一本大道香蕉久在线精品| 欧美男男青年gay1069videost| 欧美成人aa大片| 亚洲女女做受ⅹxx高潮| 久久精品国产精品青草| 91在线视频观看| 日韩一区二区视频在线观看| 亚洲视频在线一区观看| 美女视频黄久久| 色婷婷国产精品| 国产欧美日韩视频在线观看| 婷婷久久综合九色国产成人| 成人午夜激情片| 日韩精品一区二区三区中文精品 | 色婷婷香蕉在线一区二区| 日韩欧美国产一区二区在线播放| 中文字幕亚洲在| 精品一区二区影视| 欧美日韩极品在线观看一区| 亚洲国产成人私人影院tom| 男女男精品视频| 欧美日韩三级一区| 一区视频在线播放| 国产精品一区久久久久| 欧美高清视频一二三区| 亚洲欧美日韩国产另类专区 | 欧洲视频一区二区| 亚洲国产经典视频| 激情五月激情综合网| 91精品国产欧美一区二区| 亚洲一区二区三区小说| 91网站最新地址| 国产欧美日韩在线观看| 国内精品伊人久久久久av一坑| 欧美顶级少妇做爰| 亚洲综合免费观看高清完整版| jizz一区二区| 日韩伦理电影网| a美女胸又www黄视频久久| 国产精品视频yy9299一区| 国产曰批免费观看久久久| 精品国产91久久久久久久妲己| 丝袜美腿亚洲一区二区图片| 欧美精品日韩一本| 午夜久久久影院| 51精品视频一区二区三区| 亚洲成人一区在线| 777亚洲妇女| 麻豆精品精品国产自在97香蕉| 日韩欧美一二三| 精品亚洲porn|