亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
精品一区二区精品| 欧美大片一区二区| 91精品国产色综合久久| 国产亚洲va综合人人澡精品| 一区二区三区91| 国产精品18久久久久久vr| 欧洲一区在线观看| 欧美激情一区二区| 韩国女主播一区二区三区| 欧洲国内综合视频| 国产精品少妇自拍| 激情综合亚洲精品| 欧美丰满少妇xxxbbb| 亚洲视频1区2区| 丁香啪啪综合成人亚洲小说| 欧美成人bangbros| 日韩精品免费专区| 欧美亚洲国产一区在线观看网站| 中文字幕免费不卡在线| 国产在线播放一区二区三区| 88在线观看91蜜桃国自产| 久久久午夜电影| 精品国免费一区二区三区| 一区二区视频在线| 洋洋av久久久久久久一区| 岛国精品在线播放| 亚洲国产精品v| 国产精品456| 国产亚洲综合在线| 国产精品亚洲第一区在线暖暖韩国 | 丝袜美腿亚洲综合| 色婷婷综合久久久久中文一区二区| 国产亲近乱来精品视频 | 成人激情免费网站| 久久久久久久电影| 高清成人在线观看| 国产精品福利电影一区二区三区四区 | 日本高清无吗v一区| 亚洲猫色日本管| 色婷婷激情久久| 亚洲精品福利视频网站| 欧美无砖砖区免费| 蜜桃av一区二区三区| 日韩美女主播在线视频一区二区三区| 日本一区中文字幕| 欧美精品一区二区三区久久久| 激情综合色丁香一区二区| 欧美精品一区二区三区很污很色的| 国内精品国产成人国产三级粉色| 久久久一区二区| 成年人网站91| 亚洲综合色婷婷| 欧美精品乱码久久久久久按摩| 青青草国产成人99久久| 日韩欧美的一区二区| 高清不卡一区二区| 亚洲一区二区在线视频| 日韩免费高清视频| 97久久超碰精品国产| 天堂久久一区二区三区| 久久一日本道色综合| 色悠悠亚洲一区二区| 日本免费新一区视频| 久久久精品国产免大香伊| 日本伦理一区二区| 激情综合五月天| 亚洲女与黑人做爰| 欧美tk丨vk视频| 91社区在线播放| 激情综合亚洲精品| 一区二区三区精品在线| 日韩欧美成人激情| 日本韩国视频一区二区| 国产在线视频一区二区| 亚洲欧美乱综合| 久久视频一区二区| 欧美日韩国产三级| 懂色av噜噜一区二区三区av | 专区另类欧美日韩| 日韩一区二区三区视频在线观看| 国产成人激情av| 午夜a成v人精品| 中文在线免费一区三区高中清不卡| 欧美日韩美少妇| 94-欧美-setu| 国产精品亚洲一区二区三区在线 | 国产一区二区三区最好精华液| 悠悠色在线精品| 亚洲国产精品99久久久久久久久 | 中文字幕免费不卡| 日韩午夜三级在线| 欧洲国内综合视频| 91蜜桃传媒精品久久久一区二区 | 久久99蜜桃精品| 一二三四区精品视频| 国产精品免费丝袜| 日本一区二区三区四区在线视频| 欧美日韩国产一级片| 日本福利一区二区| 99久久99久久综合| 丁香激情综合国产| 国产成人精品免费看| 国产在线不卡视频| 韩日精品视频一区| 日本麻豆一区二区三区视频| 亚洲国产va精品久久久不卡综合 | 91精品91久久久中77777| 国产成人精品影视| 国产综合一区二区| 久久国产精品72免费观看| 三级欧美韩日大片在线看| 一二三四社区欧美黄| 一区二区三区丝袜| 亚洲一区二区三区国产| 一区二区三区四区不卡在线| 亚洲欧美一区二区不卡| 中文字幕综合网| 一区二区免费视频| 亚洲一区影音先锋| 首页综合国产亚洲丝袜| 视频精品一区二区| 青娱乐精品视频| 美女视频黄频大全不卡视频在线播放| 天堂一区二区在线免费观看| 日韩电影在线免费看| 日韩电影网1区2区| 激情五月激情综合网| 国产v日产∨综合v精品视频| 国产aⅴ精品一区二区三区色成熟| 国产精品99精品久久免费| 国产成人精品免费看| 91免费观看在线| 欧美日韩激情在线| 日韩女优制服丝袜电影| 久久人人爽爽爽人久久久| 国产精品久久久久久久久快鸭 | 欧美三级电影网| 制服丝袜av成人在线看| 欧美xxxx老人做受| 国产精品白丝在线| 婷婷丁香久久五月婷婷| 韩国av一区二区| 91麻豆精品秘密| 欧美日韩国产成人在线91| 日韩精品一区二区三区在线观看| 国产亚洲精品中文字幕| 亚洲欧美aⅴ...| 美女视频免费一区| www.久久久久久久久| 制服.丝袜.亚洲.另类.中文| 久久蜜桃一区二区| 亚洲一区二区四区蜜桃| 精品一区二区三区免费观看| 99久久综合国产精品| 欧美电影在哪看比较好| 国产精品丝袜91| 日韩不卡一区二区三区| 国产成都精品91一区二区三| 欧美自拍丝袜亚洲| 欧美国产一区二区| 日本女优在线视频一区二区| 国产成人av电影在线| 在线播放视频一区| 亚洲日本护士毛茸茸| 精品一区二区三区免费观看| 91久久国产综合久久| 欧美—级在线免费片| 日韩—二三区免费观看av| 不卡一区二区在线| 精品国产乱码久久久久久久久| 又紧又大又爽精品一区二区| 国产99久久久久久免费看农村| 欧美日韩久久一区| 日韩伦理电影网| 国产美女av一区二区三区| 欧美福利电影网| 亚洲精品第一国产综合野| 成人性生交大片免费看视频在线| 欧美日本在线观看| 夜夜揉揉日日人人青青一国产精品| 国产成人av一区二区三区在线| 欧美日韩在线播放一区| 亚洲色图欧美偷拍| 粉嫩在线一区二区三区视频| 日韩精品资源二区在线| 香蕉成人啪国产精品视频综合网| 成人黄色a**站在线观看| 亚洲精品在线观看视频| 日本va欧美va欧美va精品| 色94色欧美sute亚洲线路一ni| 国产精品成人一区二区艾草| 成人一区二区三区中文字幕| 国产午夜精品理论片a级大结局 | 亚洲福利视频导航| 91在线码无精品| 中文无字幕一区二区三区| 国产91对白在线观看九色| 国产精品天美传媒沈樵| 国产电影一区二区三区| 国产三级一区二区|