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

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

?? usblspnp.c

?? microsoft usb開發(fā)包,能夠給大家一個很好的參考.
?? 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;

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
99re6这里只有精品视频在线观看| 天天色天天操综合| 高清在线不卡av| 日本一区二区在线不卡| 99视频精品免费视频| 亚洲欧美精品午睡沙发| 欧美在线短视频| 蜜臀久久99精品久久久久宅男| 8v天堂国产在线一区二区| 蜜臀久久99精品久久久久宅男| 精品久久人人做人人爽| 国产精品乡下勾搭老头1| 国产精品色哟哟| 色欧美片视频在线观看 | 激情五月婷婷综合网| 久久欧美中文字幕| 99久久99久久精品免费观看 | 一区二区三区欧美| 欧美一区二区三区人| 国产美女精品在线| 亚洲色图色小说| 制服丝袜亚洲色图| 国产二区国产一区在线观看| 自拍视频在线观看一区二区| 欧美精品黑人性xxxx| 激情五月播播久久久精品| 亚洲欧洲日韩av| 欧美一级夜夜爽| 成人自拍视频在线| 天天操天天干天天综合网| 2021国产精品久久精品| 色婷婷激情一区二区三区| 久久超级碰视频| 亚洲精品福利视频网站| 亚洲精品在线观| 日本高清免费不卡视频| 黑人巨大精品欧美一区| 亚洲色图欧美激情| 欧美www视频| 欧美午夜精品一区| 国产福利视频一区二区三区| 午夜精品aaa| 中文成人av在线| 欧美一区二区三区四区视频| 一本到不卡免费一区二区| 黄网站免费久久| 亚洲一区二区黄色| 国产精品女同互慰在线看| 欧美一区二区在线观看| 一本一道久久a久久精品综合蜜臀| 男人操女人的视频在线观看欧美| 中文字幕中文乱码欧美一区二区 | 国产一区在线看| 五月婷婷另类国产| 亚洲视频免费看| 久久精品欧美一区二区三区不卡 | 亚洲激情图片一区| 国产喷白浆一区二区三区| 日韩三级视频在线看| 欧美日韩一二三| 色嗨嗨av一区二区三区| 懂色av中文字幕一区二区三区| 麻豆免费看一区二区三区| 污片在线观看一区二区| 一级中文字幕一区二区| 亚洲欧美综合色| 国产精品久久久久久久久果冻传媒 | 99这里都是精品| 国产精品99久久久久久宅男| 蜜桃视频第一区免费观看| 亚洲一区二区黄色| 亚洲最快最全在线视频| 亚洲免费在线看| 亚洲日本在线视频观看| 国产精品大尺度| 中文字幕一区在线| 自拍偷拍欧美精品| 亚洲人成在线观看一区二区| 国产精品欧美经典| 国产精品久久久久精k8 | 精品国产区一区| 久久综合99re88久久爱| 久久人人爽爽爽人久久久| 国产丝袜美腿一区二区三区| 国产蜜臀av在线一区二区三区| 国产欧美一区在线| 国产欧美va欧美不卡在线| 国产亚洲欧美色| 中文字幕av一区二区三区| 国产日韩欧美精品在线| 国产精品欧美久久久久一区二区| 亚洲欧洲av另类| 亚洲国产日韩综合久久精品| 日韩福利电影在线| 精品在线观看免费| 国产成人免费9x9x人网站视频| 成人av电影观看| 欧美艳星brazzers| 欧美一级在线免费| 久久久99精品免费观看| 亚洲国产精品av| 亚洲欧美另类久久久精品| 午夜视频一区在线观看| 九九精品视频在线看| 成人网男人的天堂| 色综合视频一区二区三区高清| 欧美午夜片在线看| 精品福利视频一区二区三区| 欧美激情在线观看视频免费| 亚洲综合久久av| 另类人妖一区二区av| 成人免费视频国产在线观看| 欧美午夜精品一区二区蜜桃| wwww国产精品欧美| 亚洲精品一二三| 美日韩一区二区| 99视频在线精品| 日韩色视频在线观看| 亚洲婷婷综合久久一本伊一区 | 亚洲视频一区在线| 蜜桃91丨九色丨蝌蚪91桃色| 成人黄色免费短视频| 欧美日韩国产一区二区三区地区| www精品美女久久久tv| 亚洲激情图片小说视频| 国产自产高清不卡| 欧洲人成人精品| 久久久一区二区三区捆绑**| 亚洲一区二区视频| 国产精品18久久久久久vr| 欧美日韩黄色一区二区| 一区在线中文字幕| 另类小说图片综合网| 欧美性猛片aaaaaaa做受| 久久精品人人做人人综合 | 色94色欧美sute亚洲线路一久| 精品乱人伦小说| 亚洲精品成人少妇| 国产一区二区伦理| 欧美日韩国产在线观看| 日韩理论片一区二区| 激情五月婷婷综合网| 91精品国产综合久久久久久久久久 | 欧美吞精做爰啪啪高潮| 欧美一级搡bbbb搡bbbb| 日韩理论片网站| 国产宾馆实践打屁股91| 精品久久人人做人人爰| 天天亚洲美女在线视频| 在线看日本不卡| 国产精品久久久久久久蜜臀| 韩国在线一区二区| 555夜色666亚洲国产免| 亚洲一区二区黄色| 91麻豆视频网站| 国产精品国产精品国产专区不片| 久久激情五月婷婷| 欧美一区二区三区爱爱| 亚洲动漫第一页| 日本精品视频一区二区三区| 国产日韩欧美精品一区| 国产一区二区视频在线播放| 日韩免费高清电影| 爽爽淫人综合网网站| 欧美艳星brazzers| 一区二区三区四区中文字幕| 色哟哟一区二区在线观看| 亚洲区小说区图片区qvod| 成人av免费观看| 国产精品国产自产拍高清av| 国产成人免费网站| 国产欧美在线观看一区| 成人在线视频一区| 国产精品久久久久久久裸模| 99re热这里只有精品视频| 亚洲欧美另类小说| 欧美性猛交xxxx乱大交退制版| 亚洲午夜羞羞片| 在线播放视频一区| 日韩高清中文字幕一区| 日韩片之四级片| 狠狠色伊人亚洲综合成人| xnxx国产精品| 成人av在线播放网址| 亚洲人快播电影网| 欧美日韩视频在线观看一区二区三区 | 亚洲色图在线看| 精品视频免费看| 狂野欧美性猛交blacked| 久久久噜噜噜久噜久久综合| 国产盗摄女厕一区二区三区| 国产免费成人在线视频| 97精品久久久久中文字幕| 一级特黄大欧美久久久| 日韩欧美中文字幕一区| 国产mv日韩mv欧美| 一区二区中文字幕在线| 欧美精品1区2区3区| 国产精品资源网| 亚洲自拍另类综合|