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

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

?? usblspnp.c

?? 一個好用的MS的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在线播放网址| 国产a视频精品免费观看| 亚洲mv在线观看| 偷窥少妇高潮呻吟av久久免费| ●精品国产综合乱码久久久久| 国产精品理论片在线观看| 中文字幕av一区二区三区免费看 | 欧美日韩免费高清一区色橹橹 | 日韩欧美一区在线| 欧美国产日韩一二三区| 亚洲天堂网中文字| 亚洲品质自拍视频网站| 亚洲电影中文字幕在线观看| 久久国产精品第一页| 成人高清伦理免费影院在线观看| 成人app在线观看| 欧美高清精品3d| 中文在线一区二区| 亚洲福利一二三区| 久久精品国产99国产精品| 国产成人日日夜夜| 欧美欧美欧美欧美| 亚洲女女做受ⅹxx高潮| 婷婷久久综合九色综合绿巨人| 国产精品香蕉一区二区三区| 欧美三级三级三级| 国产精品视频你懂的| 日本不卡视频一二三区| 99riav久久精品riav| 国产精品理论在线观看| 国产最新精品精品你懂的| 欧美日韩国产片| 亚洲精品高清在线观看| 91啪亚洲精品| 国产精品丝袜久久久久久app| 久久国产尿小便嘘嘘尿| 欧美唯美清纯偷拍| 日韩理论电影院| www.亚洲精品| 亚洲私人黄色宅男| 99久久婷婷国产精品综合| 久久蜜臀精品av| 国产盗摄视频一区二区三区| 欧美韩日一区二区三区四区| 国产成人免费高清| 国产日韩综合av| 粉嫩av一区二区三区在线播放| 久久久久国产精品麻豆ai换脸 | 日本亚洲天堂网| 日韩免费一区二区三区在线播放| 视频一区二区中文字幕| 日韩一区二区在线观看视频播放 | 国产一区二区调教| 国产精品人人做人人爽人人添| 91官网在线观看| 丝袜美腿亚洲综合| 久久蜜桃av一区二区天堂| 国产一区二区三区黄视频 | 一区二区视频在线| 欧美高清视频www夜色资源网| 韩国av一区二区三区四区| 久久精品欧美日韩精品| av在线一区二区| 亚洲国产视频直播| 国产欧美精品一区二区三区四区| 91丨九色丨蝌蚪丨老版| 午夜精品久久久| 国产精品不卡在线观看| 精品福利在线导航| 欧美在线观看禁18| 精品综合免费视频观看| 一区二区三区波多野结衣在线观看| 94色蜜桃网一区二区三区| 极品少妇一区二区三区精品视频| 亚洲综合清纯丝袜自拍| 中文字幕久久午夜不卡| 国产亚洲欧美日韩日本| 日韩视频在线永久播放| 欧美日韩一级片在线观看| 成人午夜私人影院| 成熟亚洲日本毛茸茸凸凹| 国精产品一区一区三区mba视频| 亚洲亚洲精品在线观看| 中文字幕乱码日本亚洲一区二区 | 国产日韩精品一区二区浪潮av| 欧美色图12p| 欧美亚洲综合在线| 欧美日韩中文精品| 欧美美女喷水视频| 日韩精品一区在线观看| 欧美一区二区精品在线| 欧美一区二区三区啪啪| 国产无人区一区二区三区| 91在线免费视频观看| 国产iv一区二区三区| 国产成人一区二区精品非洲| 国产盗摄精品一区二区三区在线| 波多野洁衣一区| 欧美性xxxxxx少妇| 日韩午夜电影av| 中文字幕国产精品一区二区| 亚洲一线二线三线视频| 蜜乳av一区二区三区| 国产白丝精品91爽爽久久| 在线免费观看日韩欧美| 久久久久久麻豆| 亚洲欧美日本韩国| 国产.欧美.日韩| 欧美精选午夜久久久乱码6080| 日韩欧美不卡在线观看视频| 亚洲bt欧美bt精品777| 午夜成人免费电影| 激情久久五月天| 懂色av一区二区夜夜嗨| 欧美日韩一级视频| 椎名由奈av一区二区三区| 午夜精品久久久久久久99樱桃| 国产精品综合在线视频| 91精品国产综合久久久久久久| 亚洲视频精选在线| youjizz久久| 久久久www成人免费无遮挡大片| 日韩不卡免费视频| 91麻豆精品国产自产在线| 亚洲猫色日本管| 99精品一区二区三区| 久久久久久99久久久精品网站| 日本麻豆一区二区三区视频| 99久久99精品久久久久久| 精品国产1区二区| 精品一区二区三区蜜桃| 日韩限制级电影在线观看| 水蜜桃久久夜色精品一区的特点| 欧洲av一区二区嗯嗯嗯啊| 亚洲欧美另类小说视频| 91国模大尺度私拍在线视频| 亚洲精品第一国产综合野| 欧美精品tushy高清| 激情五月播播久久久精品| 日本一区二区三区免费乱视频| 国产成人综合亚洲91猫咪| 亚洲图片另类小说| 欧美一级二级三级乱码| 国产精品一级黄| 精品国产伦一区二区三区观看方式 | 国产欧美一区二区精品性色| 在线观看亚洲精品视频| 天天色天天操综合| 久久久久久一二三区| 99精品视频中文字幕| 青椒成人免费视频| 亚洲欧洲日韩av| 91精品在线观看入口| 成人激情文学综合网| 麻豆一区二区三区| 一区二区三区在线免费视频| 色婷婷久久一区二区三区麻豆| 麻豆精品国产91久久久久久| 亚洲精品国产精华液| 日本一区二区视频在线| 在线免费精品视频| 精品一区二区三区日韩| 日韩一区二区三区观看| 99久久国产免费看| 国产91对白在线观看九色| 欧美a级一区二区| 香蕉av福利精品导航| 亚洲欧洲综合另类| 欧美国产日韩亚洲一区| 久久久久久久久伊人| 久久丝袜美腿综合| 欧美本精品男人aⅴ天堂| 欧美老女人在线| 欧美性受xxxx黑人xyx| 在线观看视频一区二区欧美日韩| 成人午夜激情视频| 国产一区二区伦理| 国产精品白丝jk黑袜喷水| 欧美情侣在线播放| 日韩精品在线一区| 久久欧美中文字幕| 综合精品久久久| 一区二区三区美女| 蜜桃视频一区二区| 国产99久久久国产精品潘金 | 日韩高清欧美激情| 久久91精品久久久久久秒播| 国产一区高清在线| 欧美又粗又大又爽| 日韩一区国产二区欧美三区| 精品国产乱码久久久久久夜甘婷婷| 国产拍揄自揄精品视频麻豆| 亚洲精品乱码久久久久久久久| 亚洲国产欧美日韩另类综合| 精品一区二区三区久久| 视频在线观看一区二区三区| 久久精品国产精品亚洲红杏| 成人免费视频播放| 制服.丝袜.亚洲.另类.中文| 久久蜜桃香蕉精品一区二区三区|