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

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

?? bulkdev.c

?? 微軟DDK中關于WDM驅動程序模型中USB設備驅動程序的例子,實現了BULK通道的數據傳輸,對于利用DDK編寫USB驅動程序的朋友是個很好的參考.
?? C
?? 第 1 頁 / 共 3 頁
字號:
/*++

Copyright (c) 2000  Microsoft Corporation

Module Name:

    bulkdev.c

Abstract:

    This file contains dispatch routines for create, 
    close and selective suspend. 
    The selective suspend feature is enabled if
    the SSRegistryEnable key in the registry is set to 1.

Environment:

    Kernel mode

Notes:

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

--*/

#include "bulkusb.h"
#include "bulkpnp.h"
#include "bulkpwr.h"
#include "bulkdev.h"
#include "bulkusr.h"
#include "bulkwmi.h"
#include "bulkrwr.h"

NTSTATUS
BulkUsb_DispatchCreate(
    IN PDEVICE_OBJECT DeviceObject,
    IN PIRP           Irp
    )
/*++
 
Routine Description:

    Dispatch routine for create.

Arguments:

    DeviceObject - pointer to device object
    Irp - I/O request packet.

Return Value:

    NT status value

--*/
{
    ULONG                       i;
    NTSTATUS                    ntStatus;
    PFILE_OBJECT                fileObject;
    PDEVICE_EXTENSION           deviceExtension;
    PIO_STACK_LOCATION          irpStack;
    PBULKUSB_PIPE_CONTEXT       pipeContext;
    PUSBD_INTERFACE_INFORMATION interface;

    PAGED_CODE();

    BulkUsb_DbgPrint(3, ("BulkUsb_DispatchCreate - begins\n"));

    //
    // initialize variables
    //
    irpStack = IoGetCurrentIrpStackLocation(Irp);
    fileObject = irpStack->FileObject;
    deviceExtension = (PDEVICE_EXTENSION) DeviceObject->DeviceExtension;

    if(deviceExtension->DeviceState != Working) {

        ntStatus = STATUS_INVALID_DEVICE_STATE;
        goto BulkUsb_DispatchCreate_Exit;
    }

    if(deviceExtension->UsbInterface) {

        interface = deviceExtension->UsbInterface;
    }
    else {

        BulkUsb_DbgPrint(1, ("UsbInterface not found\n"));

        ntStatus = STATUS_INVALID_DEVICE_STATE;
        goto BulkUsb_DispatchCreate_Exit;
    }

    //
    // FsContext is Null for the device
    //
    if(fileObject) {
        
        fileObject->FsContext = NULL; 
    }
    else {

        ntStatus = STATUS_INVALID_PARAMETER;
        goto BulkUsb_DispatchCreate_Exit;
    }

    if(0 == fileObject->FileName.Length) {

        //
        // opening a device as opposed to pipe.
        //
        ntStatus = STATUS_SUCCESS;

        InterlockedIncrement(&deviceExtension->OpenHandleCount);

        //
        // the device is idle if it has no open handles or pending PnP Irps
        // since we just received an open handle request, cancel idle req.
        //
        if(deviceExtension->SSEnable) {
        
            CancelSelectSuspend(deviceExtension);
        }

        goto BulkUsb_DispatchCreate_Exit;
    }
    
    pipeContext = BulkUsb_PipeWithName(DeviceObject, &fileObject->FileName);

    if(pipeContext == NULL) {

        ntStatus = STATUS_INVALID_PARAMETER;
        goto BulkUsb_DispatchCreate_Exit;
    }

    ntStatus = STATUS_INVALID_PARAMETER;

    for(i=0; i<interface->NumberOfPipes; i++) {

        if(pipeContext == &deviceExtension->PipeContext[i]) {

            //
            // found a match
            //
            BulkUsb_DbgPrint(3, ("open pipe %d\n", i));

            fileObject->FsContext = &interface->Pipes[i];
            
            ASSERT(fileObject->FsContext);

            pipeContext->PipeOpen = TRUE;

            ntStatus = STATUS_SUCCESS;

            //
            // increment OpenHandleCounts
            //
            InterlockedIncrement(&deviceExtension->OpenHandleCount);

            //
            // the device is idle if it has no open handles or pending PnP Irps
            // since we just received an open handle request, cancel idle req.
            //
            if(deviceExtension->SSEnable) {

                CancelSelectSuspend(deviceExtension);
            }
        }
    }

BulkUsb_DispatchCreate_Exit:

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

    IoCompleteRequest(Irp, IO_NO_INCREMENT);

    BulkUsb_DbgPrint(3, ("BulkUsb_DispatchCreate - ends\n"));
    
    return ntStatus;
}

NTSTATUS
BulkUsb_DispatchClose(
    IN PDEVICE_OBJECT DeviceObject,
    IN PIRP           Irp
    )
/*++
 
Routine Description:

    Dispatch routine for close.

Arguments:

    DeviceObject - pointer to device object
    Irp - I/O request packet

Return Value:

    NT status value

--*/
{
    NTSTATUS               ntStatus;
    PFILE_OBJECT           fileObject;
    PDEVICE_EXTENSION      deviceExtension;
    PIO_STACK_LOCATION     irpStack;
    PBULKUSB_PIPE_CONTEXT  pipeContext;
    PUSBD_PIPE_INFORMATION pipeInformation;
    
    PAGED_CODE();

    //
    // initialize variables
    //
    irpStack = IoGetCurrentIrpStackLocation(Irp);
    fileObject = irpStack->FileObject;
    pipeContext = NULL;
    pipeInformation = NULL;
    deviceExtension = (PDEVICE_EXTENSION) DeviceObject->DeviceExtension;

    BulkUsb_DbgPrint(3, ("BulkUsb_DispatchClose - begins\n"));

    if(fileObject && fileObject->FsContext) {

        pipeInformation = fileObject->FsContext;

        if(0 != fileObject->FileName.Length) {

            pipeContext = BulkUsb_PipeWithName(DeviceObject, 
                                               &fileObject->FileName);
        }

        if(pipeContext && pipeContext->PipeOpen) {
            
            pipeContext->PipeOpen = FALSE;
        }
    }

    //
    // set ntStatus to STATUS_SUCCESS 
    //
    ntStatus = STATUS_SUCCESS;

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

    IoCompleteRequest(Irp, IO_NO_INCREMENT);

    InterlockedDecrement(&deviceExtension->OpenHandleCount);

    BulkUsb_DbgPrint(3, ("BulkUsb_DispatchClose - ends\n"));

    return ntStatus;
}

NTSTATUS
BulkUsb_DispatchDevCtrl(
    IN PDEVICE_OBJECT DeviceObject,
    IN PIRP Irp
    )
/*++
 
Routine Description:

    Dispatch routine for IRP_MJ_DEVICE_CONTROL

Arguments:

    DeviceObject - pointer to device object
    Irp - I/O request packet

Return Value:

    NT status value

--*/
{
    ULONG              code;
    PVOID              ioBuffer;
    ULONG              inputBufferLength;
    ULONG              outputBufferLength;
    ULONG              info;
    NTSTATUS           ntStatus;
    PDEVICE_EXTENSION  deviceExtension;
    PIO_STACK_LOCATION irpStack;

    //
    // initialize variables
    //
    info = 0;
    irpStack = IoGetCurrentIrpStackLocation(Irp);
    code = irpStack->Parameters.DeviceIoControl.IoControlCode;
    deviceExtension = (PDEVICE_EXTENSION) DeviceObject->DeviceExtension;

    ioBuffer           = Irp->AssociatedIrp.SystemBuffer;
    inputBufferLength  = irpStack->Parameters.DeviceIoControl.InputBufferLength;
    outputBufferLength = irpStack->Parameters.DeviceIoControl.OutputBufferLength;

    if(deviceExtension->DeviceState != Working) {

        BulkUsb_DbgPrint(1, ("Invalid device state\n"));

        Irp->IoStatus.Status = ntStatus = STATUS_INVALID_DEVICE_STATE;
        Irp->IoStatus.Information = info;

        IoCompleteRequest(Irp, IO_NO_INCREMENT);
        return ntStatus;
    }

    BulkUsb_DbgPrint(3, ("BulkUsb_DispatchDevCtrl::"));
    BulkUsb_IoIncrement(deviceExtension);

    //
    // It is true that the client driver cancelled the selective suspend
    // request in the dispatch routine for create.
    // But there is no guarantee that it has indeed been completed.
    // so wait on the NoIdleReqPendEvent and proceed only if this event
    // is signalled.
    //
    BulkUsb_DbgPrint(3, ("Waiting on the IdleReqPendEvent\n"));
    
    //
    // make sure that the selective suspend request has been completed.
    //

    if(deviceExtension->SSEnable) {

        KeWaitForSingleObject(&deviceExtension->NoIdleReqPendEvent, 
                              Executive, 
                              KernelMode, 
                              FALSE, 
                              NULL);
    }

    switch(code) {

    case IOCTL_BULKUSB_RESET_PIPE:
    {
        PFILE_OBJECT           fileObject;
        PUSBD_PIPE_INFORMATION pipe;

        pipe = NULL;
        fileObject = NULL;

        //
        // FileObject is the address of the kernel file object to
        // which the IRP is directed. Drivers use the FileObject
        // to correlate IRPs in a queue.
        //
        fileObject = irpStack->FileObject;

        if(fileObject == NULL) {

            ntStatus = STATUS_INVALID_PARAMETER;

            break;
        }

        pipe = (PUSBD_PIPE_INFORMATION) fileObject->FsContext;

        if(pipe == NULL) {

            ntStatus = STATUS_INVALID_PARAMETER;
        }
        else {
            
            ntStatus = BulkUsb_ResetPipe(DeviceObject, pipe);
        }

        break;
    }

    case IOCTL_BULKUSB_GET_CONFIG_DESCRIPTOR:
    {
        ULONG length;

        if(deviceExtension->UsbConfigurationDescriptor) {

            length = deviceExtension->UsbConfigurationDescriptor->wTotalLength;

            if(outputBufferLength >= length) {

                RtlCopyMemory(ioBuffer,
                              deviceExtension->UsbConfigurationDescriptor,
                              length);

                info = length;

                ntStatus = STATUS_SUCCESS;
            }
            else {
                
                ntStatus = STATUS_BUFFER_TOO_SMALL;
            }
        }
        else {
            
            ntStatus = STATUS_UNSUCCESSFUL;
        }

        break;
    }

    case IOCTL_BULKUSB_RESET_DEVICE:
        
        ntStatus = BulkUsb_ResetDevice(DeviceObject);

        break;

    default :

        ntStatus = STATUS_INVALID_DEVICE_REQUEST;

        break;
    }

    Irp->IoStatus.Status = ntStatus;
    Irp->IoStatus.Information = info;

    IoCompleteRequest(Irp, IO_NO_INCREMENT);

    BulkUsb_DbgPrint(3, ("BulkUsb_DispatchDevCtrl::"));
    BulkUsb_IoDecrement(deviceExtension);

    return ntStatus;
}

NTSTATUS
BulkUsb_ResetPipe(
    IN PDEVICE_OBJECT         DeviceObject,
    IN PUSBD_PIPE_INFORMATION PipeInfo
    )
/*++
 
Routine Description:

    This routine synchronously submits a URB_FUNCTION_RESET_PIPE
    request down the stack.

Arguments:

    DeviceObject - pointer to device object
    PipeInfo - pointer to PipeInformation structure
               to retrieve the pipe handle

Return Value:

    NT status value

--*/
{
    PURB              urb;
    NTSTATUS          ntStatus;
    PDEVICE_EXTENSION deviceExtension;

    //
    // initialize variables
    //

    urb = NULL;
    deviceExtension = (PDEVICE_EXTENSION) DeviceObject->DeviceExtension;


    urb = ExAllocatePool(NonPagedPool, 
                         sizeof(struct _URB_PIPE_REQUEST));

    if(urb) {

        urb->UrbHeader.Length = (USHORT) sizeof(struct _URB_PIPE_REQUEST);
        urb->UrbHeader.Function = URB_FUNCTION_RESET_PIPE;
        urb->UrbPipeRequest.PipeHandle = PipeInfo->PipeHandle;

        ntStatus = CallUSBD(DeviceObject, urb);

        ExFreePool(urb);
    }
    else {

        ntStatus = STATUS_INSUFFICIENT_RESOURCES;
    }

    if(NT_SUCCESS(ntStatus)) {
    

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美综合一区二区| 自拍视频在线观看一区二区| 18涩涩午夜精品.www| 国产一区二区在线观看免费| 欧美专区在线观看一区| 国产人久久人人人人爽| 国产一区二区三区久久久| 91精品国产免费久久综合| 一区二区三区在线观看视频| av欧美精品.com| 亚洲男人电影天堂| 色呦呦一区二区三区| 亚洲久草在线视频| 欧美在线啊v一区| 日韩一区精品视频| 日韩免费看的电影| 国产一区二区三区观看| 国产欧美日韩不卡| 91蝌蚪porny| 日韩精品福利网| 久久蜜桃av一区精品变态类天堂| 国产精品羞羞答答xxdd| 日韩一区欧美一区| 在线播放视频一区| 国产精品免费看片| 91色视频在线| 久久99久久久欧美国产| 国产午夜精品久久| 欧美日韩一区二区电影| 国产资源在线一区| 亚洲欧美激情在线| 欧美tickling网站挠脚心| eeuss鲁片一区二区三区| 亚洲大尺度视频在线观看| 久久这里只精品最新地址| 一本一道久久a久久精品综合蜜臀| 亚洲成人久久影院| 国产精品久久久久桃色tv| 欧美性大战久久久久久久| 国内精品在线播放| 亚洲国产成人高清精品| 久久久精品免费免费| 欧美日韩在线一区二区| 成人a级免费电影| 韩国女主播一区| 秋霞影院一区二区| 午夜国产精品一区| 亚洲图片欧美色图| 亚洲精品菠萝久久久久久久| 日本一区二区在线不卡| 日韩精品一区二区三区在线观看 | 成人妖精视频yjsp地址| 老司机精品视频在线| 蜜臀久久99精品久久久画质超高清 | 亚洲欧美另类久久久精品 | 国产精品私人影院| 久久日韩粉嫩一区二区三区| 欧美在线免费播放| 欧美日韩国产一二三| 欧美性大战久久久久久久蜜臀| 99国产一区二区三精品乱码| 成人激情小说乱人伦| 99视频有精品| 日本精品一区二区三区四区的功能| a亚洲天堂av| 欧美婷婷六月丁香综合色| 成人黄色在线视频| 色综合中文字幕国产 | 成人精品一区二区三区四区| 成人午夜在线免费| 91视视频在线观看入口直接观看www | 天天操天天综合网| 激情综合网最新| eeuss鲁片一区二区三区在线观看 eeuss鲁片一区二区三区在线看 | 一本一道综合狠狠老| 6080yy午夜一二三区久久| 久久久不卡网国产精品一区| 国产精品久久久久aaaa| 亚洲国产精品久久一线不卡| 免费一级片91| 91女人视频在线观看| 91麻豆精品国产91| 国产精品色婷婷久久58| 麻豆成人91精品二区三区| 色噜噜狠狠色综合中国| 久久一区二区三区四区| 亚洲综合在线观看视频| 国产乱子伦一区二区三区国色天香| 色www精品视频在线观看| 久久久久久久久伊人| 蜜臀av一级做a爰片久久| 一本大道久久a久久综合| 久久精品综合网| 久99久精品视频免费观看| 欧美日韩精品综合在线| 亚洲与欧洲av电影| 久久午夜电影网| 国产亚洲欧美中文| 国产在线精品一区二区不卡了| 欧洲一区二区三区免费视频| 国产精品美女久久久久av爽李琼| 日本色综合中文字幕| 欧美精品乱码久久久久久| 亚洲一区二区三区四区五区中文 | 久久91精品久久久久久秒播| 在线播放/欧美激情| 热久久久久久久| 2020国产精品自拍| 成人午夜碰碰视频| 国产精品成人免费| 欧美中文字幕亚洲一区二区va在线| 亚洲欧美日韩成人高清在线一区| 972aa.com艺术欧美| 一区二区免费在线| 欧美视频在线播放| 国产麻豆日韩欧美久久| 国产女主播视频一区二区| 91女神在线视频| 亚洲123区在线观看| 日韩一区二区三区三四区视频在线观看| 午夜精品123| 精品成人一区二区| 成人在线综合网站| 丝瓜av网站精品一区二区| 欧美大片拔萝卜| 色999日韩国产欧美一区二区| 亚洲国产日产av| 国产欧美精品一区| 666欧美在线视频| 色婷婷av一区二区三区gif| 视频一区二区三区中文字幕| 精品国产污网站| 日本精品免费观看高清观看| 精品一区二区在线观看| 国产精品福利电影一区二区三区四区| 精品视频免费在线| 色婷婷综合激情| 成人sese在线| 成人美女在线视频| 久久国产视频网| 亚洲影视资源网| 亚洲精品中文在线观看| 国产欧美视频在线观看| 精品电影一区二区三区| 欧美人妇做爰xxxⅹ性高电影 | 欧美精品日韩精品| 日本精品一级二级| 日本高清成人免费播放| 成人国产亚洲欧美成人综合网| 国内精品国产三级国产a久久 | 国产精品三级av在线播放| 91精品国产黑色紧身裤美女| 欧美日韩美女一区二区| 精品婷婷伊人一区三区三| 欧美在线不卡一区| 欧美日韩视频在线一区二区| 欧美性受极品xxxx喷水| 欧美午夜电影网| 3atv在线一区二区三区| 日韩精品专区在线影院重磅| 欧美一二三区在线观看| 欧美成人一级视频| 国产精品婷婷午夜在线观看| 中文字幕一区二区三区乱码在线| 国产精品毛片久久久久久| 亚洲天天做日日做天天谢日日欢 | 婷婷六月综合网| 精品一区二区影视| 国产成人啪午夜精品网站男同| 不卡的av网站| 欧美成人三级电影在线| 国产女主播视频一区二区| 一区二区三区中文字幕| 天天综合网天天综合色| 国产成人综合在线播放| 在线国产电影不卡| 久久久不卡网国产精品一区| 亚洲激情网站免费观看| 国产在线精品不卡| 欧美丝袜丝nylons| 国产精品免费aⅴ片在线观看| 日产精品久久久久久久性色| 不卡av免费在线观看| 精品999在线播放| 日韩激情视频在线观看| 99精品欧美一区| 久久精品人人爽人人爽| 蜜桃视频在线观看一区二区| 成人h动漫精品| 国产欧美精品一区二区色综合| 日韩电影免费在线看| 欧美高清视频www夜色资源网| 亚洲欧洲av一区二区三区久久| 国产乱妇无码大片在线观看| 91精品免费在线| 美日韩黄色大片| 日韩精品最新网址| 国内成人精品2018免费看| 精品日韩成人av| 久久国产剧场电影|