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

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

?? usbls120.c

?? 一個好用的MS的USB驅動編程工具包,希望有用.
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*++

Copyright (c) 1999 Microsoft Corporation

Module Name:

    Usbls120.c 

Abstract:

    USB device driver for USB LS-120 drive
    Main 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:

    01/13/99: MRB  Adapted from BULKUSB DDK sample.

--*/
#define GLOBAL_VARS

#include "wdm.h"
#include "stdarg.h"
#include "stdio.h"
#include "usbdi.h"
#include "usbdlib.h"
#include "usbls120.h"
#include "USBLS120.h"


NTSTATUS
DriverEntry(
    IN PDRIVER_OBJECT DriverObject,
    IN PUNICODE_STRING RegistryPath
    )
/*++

Routine Description:

    Installable driver initialization entry point.
    This entry point is called directly by the I/O system.

Arguments:

    DriverObject - pointer to the driver object

    RegistryPath - pointer to a unicode string representing the path
		   to driver-specific key in the registry

Return Value:

    STATUS_SUCCESS if successful,
    STATUS_UNSUCCESSFUL otherwise

--*/
{
    NTSTATUS ntStatus = STATUS_SUCCESS;
    PDEVICE_OBJECT deviceObject = NULL;
    BOOLEAN fRes;

#if DBG
	// should be done before any debug output is done.
    // read our debug verbosity level from the registry
    USBLS120_GetRegistryDword( USBLS120_REGISTRY_PARAMETERS_PATH, //absolute registry path
				     L"DebugLevel",     // REG_DWORD ValueName
				     &gDebugLevel );    // Value receiver
#endif

    USBLS120_KdPrint( DBGLVL_MINIMUM ,("Entering DriverEntry(), RegistryPath=\n    %ws\n", RegistryPath->Buffer ));

    // Remember our driver object, for when we create our child PDO
    USBLS120DriverObject = DriverObject;

    //
    // Create dispatch points for create, close, unload
    DriverObject->MajorFunction[IRP_MJ_CREATE] = USBLS120_DispatchIrp;
    DriverObject->MajorFunction[IRP_MJ_CLOSE] = USBLS120_DispatchIrp;
    DriverObject->DriverUnload = USBLS120_Unload;

    // User mode DeviceIoControl() calls will be routed here
    DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = USBLS120_DispatchIrp;

    // User mode ReadFile()/WriteFile() calls will be routed here
    DriverObject->MajorFunction[IRP_MJ_WRITE] = USBLS120_DispatchIrp;
    DriverObject->MajorFunction[IRP_MJ_READ] = USBLS120_DispatchIrp;

    // routines for handling system PNP and power management requests
    DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = USBLS120_DispatchIrp;
    DriverObject->MajorFunction[IRP_MJ_PNP] = USBLS120_DispatchIrp;
    DriverObject->MajorFunction[IRP_MJ_POWER] = USBLS120_DispatchIrp;

    // The Functional Device Object (FDO) will not be created for PNP devices until 
    // this routine is called upon device plug-in.
    DriverObject->DriverExtension->AddDevice = USBLS120_PnPAddDevice;


    USBLS120_KdPrint( DBGLVL_DEFAULT,("exiting DriverEntry (%x)\n", ntStatus));

    return ntStatus;
}


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

Routine Description:

    IRP dispatch routine.  
    
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;
    NTSTATUS ntStatus = STATUS_SUCCESS;
    PDEVICE_EXTENSION DeviceExtension;
	
    DeviceExtension = DeviceObject->DeviceExtension;
    IrpStack = IoGetCurrentIrpStackLocation (Irp);

    if (DO_FDO == DeviceExtension->DeviceObjectType) {
        switch (IrpStack->MajorFunction) {

            case IRP_MJ_SYSTEM_CONTROL:
                ntStatus = USBLS120_ProcessSysControlIrp(DeviceObject, Irp);
                break;

            case IRP_MJ_PNP:
                ntStatus = USBLS120_ProcessPnPIrp(DeviceObject, Irp);
                break;

            case IRP_MJ_POWER:
                ntStatus = USBLS120_ProcessPowerIrp(DeviceObject, Irp);
                break;
        }
    }
    else
    if (DO_PDO == DeviceExtension->DeviceObjectType) {
        switch (IrpStack->MajorFunction) {

            case IRP_MJ_PNP:
                ntStatus = USBLS120_PdoProcessPnPIrp(DeviceObject, Irp);
                break;

            case IRP_MJ_POWER:
                ntStatus = USBLS120_PdoProcessPowerIrp(DeviceObject, Irp);
                break;
        }
			
        Irp->IoStatus.Status = ntStatus;
        IoCompleteRequest(Irp, IO_NO_INCREMENT);
    }

    return ntStatus;
}


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

Routine Description:

    Main dispatch table routine for IRP_MJ_SYSTEM_CONTROL
	We basically just pass these down to the PDO

Arguments:

    DeviceObject - pointer to FDO device object

    Irp          - pointer to an I/O Request Packet

Return Value:

	Status returned from lower driver


--*/
{

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

    Irp->IoStatus.Status = STATUS_SUCCESS;
    Irp->IoStatus.Information = 0;

    //
    // 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_HIGH, ( "enter USBLS120_ProcessSysControlIrp()\n") );

    USBLS120_IncrementIoCount(DeviceObject);

    USBLS120_ASSERT( IRP_MJ_SYSTEM_CONTROL == irpStack->MajorFunction );

    IoCopyCurrentIrpStackLocationToNext(Irp);


    ntStatus = IoCallDriver(stackDeviceObject,
			    Irp);

    USBLS120_DecrementIoCount(DeviceObject);

    USBLS120_KdPrint( DBGLVL_HIGH,("USBLS120_ProcessSysControlIrp() Exit USBLS120_ProcessSysControlIrp %x\n", ntStatus));

    return ntStatus;
}


VOID
USBLS120_Unload(
    IN PDRIVER_OBJECT DriverObject
    )
/*++

Routine Description:

    Free all the allocated resources, etc.

Arguments:

    DriverObject - pointer to a driver object

Return Value:


--*/
{
    USBLS120_KdPrint( DBGLVL_HIGH,("enter USBLS120_Unload\n"));

    //
    // Free any global resources allocated
    // in DriverEntry.

    // We have few or none because for a PNP device, almost all
    // allocation is done in PnpAddDevice() and all freeing 
    // while handling IRP_MN_REMOVE_DEVICE:
    //
    USBLS120_ASSERT( gExAllocCount == 0 );

    USBLS120_KdPrint( DBGLVL_DEFAULT,("exit USBLS120_Unload\n"));
}



NTSTATUS
USBLS120_CreateDeviceObject(
    IN PDRIVER_OBJECT DriverObject,
    IN PDEVICE_OBJECT PhysicalDeviceObject,
    IN PDEVICE_OBJECT *DeviceObject
    )
/*++

Routine Description:

    Creates a Functional DeviceObject

Arguments:

    DriverObject - pointer to the driver object for device

    DeviceObject - pointer to DeviceObject pointer to return
		    created device object.

    Instance - instance of the device create.

Return Value:

    STATUS_SUCCESS if successful,
    STATUS_UNSUCCESSFUL otherwise

--*/
{
    NTSTATUS ntStatus;
    PDEVICE_EXTENSION deviceExtension;
    USHORT i;

    USBLS120_KdPrint( DBGLVL_DEFAULT,("enter USBLS120_CreateDeviceObject() \n"));

    ntStatus = IoCreateDevice(
        DriverObject,
        sizeof (DEVICE_EXTENSION),
        NULL,
        FILE_DEVICE_UNKNOWN,
        FILE_AUTOGENERATED_DEVICE_NAME,
        FALSE,
        DeviceObject
        );

    if (NT_SUCCESS(ntStatus))  {
        deviceExtension = (PDEVICE_EXTENSION) ((*DeviceObject)->DeviceExtension);
    }

    USBLS120_KdPrintCond(
        DBGLVL_DEFAULT,
        (!(NT_SUCCESS(ntStatus))),
        ("USBLS120_CreateDeviceObject() IoCreateDevice() FAILED\n"));

 
    if (!NT_SUCCESS(ntStatus))  {
        return ntStatus;
     }

    deviceExtension->DeviceObjectType = DO_FDO;

    //default maximum transfer size per io request
    deviceExtension->MaximumTransferSize =  USBLS120_MAX_TRANSFER_SIZE ;

    // this event is triggered when there is no pending io of any kind and device is removed
    KeInitializeEvent(&deviceExtension->RemoveEvent, NotificationEvent, FALSE);

    // this event is triggered when self-requested power irps complete
    KeInitializeEvent(&deviceExtension->SelfRequestedPowerIrpEvent, NotificationEvent, FALSE);

    // this event is triggered when there is no pending io  (pending io count == 1 )
    KeInitializeEvent(&deviceExtension->NoPendingIoEvent, NotificationEvent, FALSE);

    // spinlock used to protect inc/dec iocount logic
    KeInitializeSpinLock (&deviceExtension->IoCountSpinLock);

    return ntStatus;
}


NTSTATUS
USBLS120_CallUSBD(
    IN PDEVICE_OBJECT DeviceObject,
    IN PURB Urb
    )
/*++

Routine Description:

    Passes a URB to the USBD class driver
    The client device driver passes USB request block (URB) structures 
    to the class driver as a parameter in an IRP with Irp->MajorFunction
    set to IRP_MJ_INTERNAL_DEVICE_CONTROL and the next IRP stack location 
    Parameters.DeviceIoControl.IoControlCode field set to 
    IOCTL_INTERNAL_USB_SUBMIT_URB. 

Arguments:

    DeviceObject - pointer to the physical device object (PDO)

    Urb - pointer to an already-formatted Urb request block

Return Value:

    STATUS_SUCCESS if successful,
    STATUS_UNSUCCESSFUL otherwise

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

    USBLS120_KdPrint( DBGLVL_MAXIMUM,("enter USBLS120_CallUSBD\n"));

    deviceExtension = DeviceObject->DeviceExtension;

    //
    // issue a synchronous request
    //

    KeInitializeEvent(&event, NotificationEvent, FALSE);

    irp = IoBuildDeviceIoControlRequest(
              IOCTL_INTERNAL_USB_SUBMIT_URB,
              deviceExtension->TopOfStackDeviceObject, //Points to the next-lower driver's device object
              NULL, // optional input bufer; none needed here
              0,    // input buffer len if used
              NULL, // optional output bufer; none needed here
              0,    // output buffer len if used
              TRUE, // If InternalDeviceControl is TRUE the target driver's Dispatch
                    //  outine for IRP_MJ_INTERNAL_DEVICE_CONTROL or IRP_MJ_SCSI 
                    // is called; otherwise, the Dispatch routine for 
                    // IRP_MJ_DEVICE_CONTROL is called.
              &event,     // event to be signalled on completion
              &ioStatus);  // Specifies an I/O status block to be set when the request is completed the lower driver. 

    //
    // Call the class driver to perform the operation.  If the returned status
    // is PENDING, wait for the request to complete.
    //

    nextStack = IoGetNextIrpStackLocation(irp);
    USBLS120_ASSERT(nextStack != NULL);

    //
    // pass the URB to the USB driver stack
    //
    nextStack->Parameters.Others.Argument1 = Urb;

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

    USBLS120_KdPrint( DBGLVL_MAXIMUM,("USBLS120_CallUSBD() return from IoCallDriver USBD %x\n", ntStatus));

    if (ntStatus == STATUS_PENDING) {

        status = KeWaitForSingleObject(
                     &event,
                     Suspended,
                     KernelMode,
                     FALSE,
                     NULL);

    } else {
	ioStatus.Status = ntStatus;
    }

    USBLS120_KdPrint( DBGLVL_MAXIMUM,("USBLS120_CallUSBD() URB status = %x status = %x irp status %x\n",
	Urb->UrbHeader.Status, status, ioStatus.Status));

    //
    // USBD maps the error code for us
    //
    ntStatus = ioStatus.Status;

    USBLS120_KdPrintCond( DBGLVL_MAXIMUM, !NT_SUCCESS( ntStatus ), ("exit USBLS120_CallUSBD FAILED (%x)\n", ntStatus));

    return ntStatus;
}


NTSTATUS
USBLS120_ConfigureDevice(
    IN  PDEVICE_OBJECT DeviceObject
    )
/*++

Routine Description:

    Initializes a given instance of the device on the USB and
    selects and saves the configuration.

Arguments:

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91麻豆免费视频| 精品久久久久久久久久久久包黑料 | 日韩成人免费电影| 狠狠狠色丁香婷婷综合激情| 99riav一区二区三区| 日韩免费视频一区| 亚洲国产成人av网| 成人av午夜影院| 久久久99精品免费观看| 手机精品视频在线观看| 色综合久久久久久久久久久| 精品少妇一区二区三区日产乱码 | 日韩精品免费视频人成| 91小视频在线观看| 国产亚洲综合色| 老司机精品视频在线| 欧美性大战xxxxx久久久| 国产精品嫩草99a| 国产成人99久久亚洲综合精品| 欧美tickling挠脚心丨vk| 五月婷婷欧美视频| 欧美日韩在线精品一区二区三区激情| 国产精品三级电影| 粉嫩av亚洲一区二区图片| 26uuu国产电影一区二区| 蜜臀av性久久久久蜜臀aⅴ四虎| 在线观看免费视频综合| 亚洲精品成人精品456| 成人av在线资源网站| 欧美激情一区二区三区不卡 | 久久国产婷婷国产香蕉| 精品国产乱码久久| 日本亚洲天堂网| 欧美精选一区二区| 人人精品人人爱| 欧美mv和日韩mv国产网站| 狠狠久久亚洲欧美| 国产日韩精品一区二区三区在线| 国产乱子轮精品视频| 精品国产乱码久久久久久蜜臀| 韩国女主播一区| 中文子幕无线码一区tr| 99re热这里只有精品免费视频| 亚洲欧美激情在线| 欧美群妇大交群中文字幕| 日本不卡1234视频| 国产色产综合产在线视频| 99在线热播精品免费| 一区二区三区在线免费| 在线播放国产精品二区一二区四区| 天天色 色综合| 精品国产露脸精彩对白 | 中文字幕国产一区二区| 成人av免费在线| 亚洲妇熟xx妇色黄| 欧美tk—视频vk| 99国产精品久久久久久久久久| 亚洲夂夂婷婷色拍ww47| 91精品国产美女浴室洗澡无遮挡| 韩国一区二区视频| 亚洲人成网站在线| 91麻豆精品国产| 国产成人免费视频一区| 亚洲丰满少妇videoshd| 欧美一级黄色片| 99这里都是精品| 久久精品国产在热久久| 亚洲色图在线播放| 欧美va天堂va视频va在线| 99久久免费国产| 久久超级碰视频| 亚洲欧美乱综合| 久久网这里都是精品| 91官网在线观看| 国产一区二区三区日韩| 一区二区日韩av| 国产欧美日韩在线视频| 在线不卡一区二区| aaa欧美色吧激情视频| 免费亚洲电影在线| 亚洲三级小视频| 2021中文字幕一区亚洲| 欧美亚洲一区二区三区四区| 国产精品中文字幕一区二区三区| 亚洲六月丁香色婷婷综合久久| 欧美精品一区在线观看| 欧美色综合网站| 91丨porny丨最新| 大胆亚洲人体视频| 另类小说色综合网站| 亚洲综合色噜噜狠狠| 国产精品网曝门| 久久免费午夜影院| 欧美一级二级三级蜜桃| 91国产精品成人| 色哟哟一区二区在线观看| 国产99一区视频免费| 精品一区二区三区视频在线观看| 亚洲中国最大av网站| 国产精品久久久久国产精品日日| 精品国产露脸精彩对白| 欧美另类变人与禽xxxxx| 欧美午夜宅男影院| 欧美优质美女网站| 欧美一区三区二区| 欧美日韩国产片| 欧美日精品一区视频| 色哟哟一区二区| 欧美视频完全免费看| 欧美日韩在线直播| 欧美色综合久久| 欧美日韩在线免费视频| 欧美三级资源在线| 欧美日韩和欧美的一区二区| 在线免费观看一区| 91成人看片片| 精品视频一区二区不卡| 欧美视频在线播放| 777久久久精品| 日韩女同互慰一区二区| 精品久久久久av影院| 久久精品水蜜桃av综合天堂| 国产亚洲1区2区3区| 国产精品私人影院| 亚洲人成7777| 性久久久久久久久| 麻豆精品视频在线| 国产一区999| 91麻豆国产在线观看| 色婷婷精品久久二区二区蜜臀av | 久久影音资源网| 国产欧美一区二区三区网站| 亚洲四区在线观看| 亚洲一区二区三区视频在线| 婷婷成人激情在线网| 激情五月激情综合网| 国产精品18久久久久久久久久久久| 成人a免费在线看| 欧美三级资源在线| 久久人人爽人人爽| 亚洲乱码国产乱码精品精可以看| 亚洲一区二区三区四区不卡 | 日韩—二三区免费观看av| 久草热8精品视频在线观看| 国产成人av一区二区三区在线| 色哟哟欧美精品| 2020国产精品久久精品美国| 亚洲欧洲日韩综合一区二区| 亚洲电影你懂得| 国产高清亚洲一区| 欧美中文字幕一二三区视频| 欧美一级日韩一级| 日本一区二区三区在线观看| 亚洲妇女屁股眼交7| 国产精品66部| 欧美日韩mp4| 国产精品视频一二三区| 天堂在线一区二区| 99久久亚洲一区二区三区青草| 欧美一区二区三区免费观看视频| 国产日韩欧美激情| 日韩电影一区二区三区四区| 成人性生交大合| 欧美一级日韩一级| 一区二区三区欧美视频| 国产在线视频一区二区三区| 91国内精品野花午夜精品 | 欧美精品一区二区三区蜜桃视频 | 中文字幕亚洲电影| 久久99热这里只有精品| 色偷偷成人一区二区三区91 | 欧美精品久久天天躁| 国产精品灌醉下药二区| 久久精品免费看| 欧美巨大另类极品videosbest| 国产精品久久精品日日| 美女一区二区三区在线观看| 色综合网站在线| 国产精品午夜在线| 精品一区二区国语对白| 欧美伦理电影网| 一区二区三区高清不卡| jvid福利写真一区二区三区| 久久久三级国产网站| 蜜桃91丨九色丨蝌蚪91桃色| 欧美在线视频你懂得| 中文字幕一区在线观看| 国产一区福利在线| 亚洲精品在线观| 免费观看91视频大全| 91精品国产综合久久久久| 亚洲综合一区在线| 在线观看亚洲专区| 综合久久综合久久| 92国产精品观看| 中文字幕中文在线不卡住| 国产99一区视频免费| 国产精品久久久久aaaa| 成人黄色综合网站| 成人免费在线播放视频|