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

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

?? vusb.c

?? USB HASP key emulator, based on USB bus driver
?? C
字號:
/*++

Copyright (c) 2004 Chingachguk & Denger2k All Rights Reserved

Module Name:

    VUSB.C

Abstract:

    This module contains the entry points for a virtual USB bus driver.

Environment:

    kernel mode only

Revision History:


--*/

#include <stdarg.h>
#include <ntddk.h>
#include <stdio.h>
#include ".\Include\driver.h"
#include "vusb.h"

//
// Global Debug Level
//

ULONG VUsbDebugLevel = BUS_DEFAULT_DEBUG_OUTPUT_LEVEL;

GLOBALS Globals;

#ifdef ALLOC_PRAGMA
#pragma alloc_text (INIT, DriverEntry)
#pragma alloc_text (PAGE, Bus_DriverUnload)
#pragma alloc_text (PAGE, Bus_CreateClose)
#pragma alloc_text (PAGE, Bus_IoCtl)
#ifdef DEBUG_FULL
#pragma alloc_text (PAGE, PrintBufferContent)
#pragma alloc_text (PAGE, LogMessage)
#endif
#endif

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

    Initialize the driver dispatch table. 

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:

  NT Status Code

--*/
{

    Bus_KdPrint_Def (BUS_DBG_SS_TRACE, ("Driver Entry\n"));

    //
    // Save the RegistryPath
    //

    Globals.RegistryPath.MaximumLength = RegistryPath->Length +
                                          sizeof(UNICODE_NULL);
    Globals.RegistryPath.Length = RegistryPath->Length;
    Globals.RegistryPath.Buffer = ExAllocatePoolWithTag(
                                       PagedPool,
                                       Globals.RegistryPath.MaximumLength,
                                       VUSB_POOL_TAG
                                       );    

    if (!Globals.RegistryPath.Buffer) {

        return STATUS_INSUFFICIENT_RESOURCES;
    }
    
    RtlCopyUnicodeString(&Globals.RegistryPath, RegistryPath);

    //
    // Set entry points into the driver
    //
    DriverObject->MajorFunction [IRP_MJ_CREATE] =
    DriverObject->MajorFunction [IRP_MJ_CLOSE]  = Bus_CreateClose;
    DriverObject->MajorFunction [IRP_MJ_PNP]    = Bus_PnP;
    DriverObject->MajorFunction [IRP_MJ_POWER]  = Bus_Power;
    DriverObject->MajorFunction [IRP_MJ_DEVICE_CONTROL] = Bus_IoCtl;
    DriverObject->MajorFunction [IRP_MJ_INTERNAL_DEVICE_CONTROL] = Bus_HandleUSBIoCtl;
    DriverObject->DriverUnload = Bus_DriverUnload;
    DriverObject->DriverExtension->AddDevice = Bus_AddDevice;

    return STATUS_SUCCESS;
}

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

    Some outside source is trying to create a file against us.

    If this is for the FDO (the bus itself) then the caller 
    is trying to open the proprietary connection to tell us 
    to enumerate or remove a device.

    If this is for the PDO (an object on the bus) then this 
    is a client that wishes to use the VUSB device.
    
Arguments:

   DeviceObject - pointer to a device object.

   Irp - pointer to an I/O Request Packet.

Return Value:

   NT status code

--*/
{
    PIO_STACK_LOCATION  irpStack;
    NTSTATUS            status;
    PFDO_DEVICE_DATA    fdoData;

    PAGED_CODE ();

    fdoData = (PFDO_DEVICE_DATA) DeviceObject->DeviceExtension;

    status = STATUS_INVALID_DEVICE_REQUEST;
    Irp->IoStatus.Information = 0;
    
    //
    // If it's not for the FDO. We don't allow create/close on PDO
    // 
    if (fdoData->IsFDO) {
        
        //
        // Increment IO count on FDO
        //
        Bus_IncIoCount (fdoData);
        
        //
        // Check to see whether the bus is removed
        //
       
        if (fdoData->DevicePnPState == Deleted){         
            status = STATUS_DELETE_PENDING;
        } else {

            irpStack = IoGetCurrentIrpStackLocation (Irp);

            switch (irpStack->MajorFunction) {
            case IRP_MJ_CREATE:
                Bus_KdPrint_Def (BUS_DBG_SS_TRACE, ("Create \n"));
                status = STATUS_SUCCESS;
                break;

            case IRP_MJ_CLOSE:
                Bus_KdPrint_Def (BUS_DBG_SS_TRACE, ("Close \n"));
                status = STATUS_SUCCESS;
                break;
             default:
                break;
            } 
        }
        
    }

    Irp->IoStatus.Status = status;
    IoCompleteRequest (Irp, IO_NO_INCREMENT);

    //
    // Decrement IO count on FDO
    //
    if (fdoData->IsFDO)
        Bus_DecIoCount (fdoData);

    return status;
}

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

    Handle user mode PlugIn, UnPlug and device Eject requests.

Arguments:

   DeviceObject - pointer to a device object.

   Irp - pointer to an I/O Request Packet.

Return Value:

   NT status code

--*/
{
    PIO_STACK_LOCATION      irpStack;
    NTSTATUS                status;
    ULONG                   inlen, outlen;
    PFDO_DEVICE_DATA        fdoData;
    PVOID                   buffer;

    PAGED_CODE ();
    
    fdoData = (PFDO_DEVICE_DATA) DeviceObject->DeviceExtension;

    //
    // We only take Device Control requests for the FDO.
    // That is the bus itself.
    //

    if (!fdoData->IsFDO) {
    
        //
        // These commands are only allowed to go to the FDO.
        //   
        status = STATUS_INVALID_DEVICE_REQUEST;
        Irp->IoStatus.Status = status;
        IoCompleteRequest (Irp, IO_NO_INCREMENT);
        return status;

    }

    //
    // Check to see whether the bus is removed
    //
    
    if (fdoData->DevicePnPState == Deleted) {
        Irp->IoStatus.Status = status = STATUS_DELETE_PENDING;
        IoCompleteRequest (Irp, IO_NO_INCREMENT);
        return status;
    }
    
    Bus_IncIoCount (fdoData);
    
    irpStack = IoGetCurrentIrpStackLocation (Irp);

    buffer = Irp->AssociatedIrp.SystemBuffer;  
    inlen = irpStack->Parameters.DeviceIoControl.InputBufferLength;
    outlen = irpStack->Parameters.DeviceIoControl.OutputBufferLength;

    status = STATUS_INVALID_PARAMETER;
    
    switch (irpStack->Parameters.DeviceIoControl.IoControlCode) {
    case IOCTL_VUSB_PLUGIN_HARDWARE:
        if ((inlen == outlen) &&
            //
            // Make sure it has at least two nulls and the size 
            // field is set to the declared size of the struct
            //
            ((sizeof (VUSB_PLUGIN_HARDWARE) + sizeof(UNICODE_NULL) * 2) <=
             inlen) &&

            //
            // The size field should be set to the sizeof the struct as declared
            // and *not* the size of the struct plus the multi_sz
            //
            (sizeof (VUSB_PLUGIN_HARDWARE) ==
             ((PVUSB_PLUGIN_HARDWARE) buffer)->Size)) {

            Bus_KdPrint(fdoData, BUS_DBG_IOCTL_TRACE, ("PlugIn called\n"));

            status= Bus_PlugInDevice((PVUSB_PLUGIN_HARDWARE)buffer,
                                inlen, fdoData);
            if (NT_SUCCESS (status))
                IoInvalidateDeviceRelations (fdoData->UnderlyingPDO, BusRelations);

            Irp->IoStatus.Information = outlen;

        }
        break;

    case IOCTL_VUSB_UNPLUG_HARDWARE:

        if ((sizeof (VUSB_UNPLUG_HARDWARE) == inlen) &&
            (inlen == outlen) &&
            (((PVUSB_UNPLUG_HARDWARE)buffer)->Size == inlen)) {

            Bus_KdPrint(fdoData, BUS_DBG_IOCTL_TRACE, ("UnPlug called\n"));

            status= Bus_UnPlugDevice(
                    (PVUSB_UNPLUG_HARDWARE)buffer, fdoData);
            Irp->IoStatus.Information = outlen;

        }
        break;

    case IOCTL_VUSB_EJECT_HARDWARE:
    
        if ((sizeof (VUSB_EJECT_HARDWARE) == inlen) &&
            (inlen == outlen) &&
            (((PVUSB_EJECT_HARDWARE)buffer)->Size == inlen)) {

            Bus_KdPrint(fdoData, BUS_DBG_IOCTL_TRACE, ("Eject called\n"));

            status= Bus_EjectDevice((PVUSB_EJECT_HARDWARE)buffer, fdoData);
            Irp->IoStatus.Information = outlen;

        }
        break;   

    default:
        break; // default status is STATUS_INVALID_PARAMETER
    }

    Irp->IoStatus.Status = status;
    IoCompleteRequest (Irp, IO_NO_INCREMENT);
    Bus_DecIoCount (fdoData);
    return status;
}

VOID
Bus_DriverUnload (
    IN PDRIVER_OBJECT DriverObject
    )
/*++
Routine Description:
    Clean up everything we did in driver entry.

Arguments:

   DriverObject - pointer to this driverObject.


Return Value:

--*/
{
    PAGED_CODE ();

    Bus_KdPrint_Def (BUS_DBG_SS_TRACE, ("Unload\n"));
    
    //
    // All the device objects should be gone.
    //

    ASSERT (NULL == DriverObject->DeviceObject);

    //
    // Here we free all the resources allocated in the DriverEntry
    //

    if(Globals.RegistryPath.Buffer)
        ExFreePool(Globals.RegistryPath.Buffer);   
        
    return;
}

VOID
Bus_IncIoCount (
    IN  PFDO_DEVICE_DATA   FdoData
    )   

/*++

Routine Description:

    This routine increments the number of requests the device receives
    

Arguments:

    FdoData - pointer to the FDO device extension.
    
Return Value:

    VOID

--*/

{

    LONG            result;


    result = InterlockedIncrement(&FdoData->OutstandingIO);

    ASSERT(result > 0);
    //
    // Need to clear StopEvent (when OutstandingIO bumps from 1 to 2) 
    //
    if (result == 2) {
        //
        // We need to clear the event
        //
        KeClearEvent(&FdoData->StopEvent);
    }

    return;
}

VOID
Bus_DecIoCount(
    IN  PFDO_DEVICE_DATA  FdoData
    )   

/*++

Routine Description:

    This routine decrements as it complete the request it receives

Arguments:

    FdoData - pointer to the FDO device extension.
    
Return Value:

    VOID

--*/
{

    LONG            result;
    
    result = InterlockedDecrement(&FdoData->OutstandingIO);

    ASSERT(result >= 0);

    if (result == 1) {
        //
        // Set the stop event. Note that when this happens
        // (i.e. a transition from 2 to 1), the type of requests we 
        // want to be processed are already held instead of being 
        // passed away, so that we can't "miss" a request that
        // will appear between the decrement and the moment when
        // the value is actually used.
        //
 
        KeSetEvent (&FdoData->StopEvent, IO_NO_INCREMENT, FALSE);
        
    }
    
    if (result == 0) {

        //
        // The count is 1-biased, so it can be zero only if an 
        // extra decrement is done when a remove Irp is received 
        //

        ASSERT(FdoData->DevicePnPState == Deleted);

        //
        // Set the remove event, so the device object can be deleted
        //

        KeSetEvent (&FdoData->RemoveEvent, IO_NO_INCREMENT, FALSE);
        
    }

    return;
}

#ifdef DEBUG_FULL
void PrintBufferContent(OUT PWCHAR outStr, UCHAR *buf, LONG length) {
/*++
Routine Description:

   Print buffer content in hex format into string

Arguments:

   outStr - ptr to output string buffer

   buf - ptr to buffer

   length - length of buffer

Return Value:

   none

--*/
    PWCHAR tmpBuf;
    LONG i;
    // Check parameters
    if (!buf) {
       swprintf(outStr, L"NULL (ptr to data)");
       return;
    }
    if (length<=0) {
       swprintf(outStr, L"NULL (length)");
       return;
    }

    // Create string
    outStr[0]=0;
    outStr[1]=0;
    outStr[2]=0;
    outStr[3]=0;
    tmpBuf = ExAllocatePoolWithTag (PagedPool, 512, VUSB_POOL_TAG);
    if (!tmpBuf)
       return;
    for (i=0; i<length ; i++) {
        swprintf(tmpBuf, L"%02X ", (ULONG) ((UCHAR *)buf)[i]);
        wcscat(outStr, tmpBuf);                              
    }

    ExFreePool(tmpBuf);
}

NTSTATUS LogMessage(PCHAR szFormat, ...) {
/*++
Routine Description:

   Log msg into debug console and file

Arguments:

   szFormat - message format string

   ... - data

Return Value:

   NT status code

--*/
    ULONG Length;
    char messagebuf[1024];
    va_list va;
    IO_STATUS_BLOCK  IoStatus;
    OBJECT_ATTRIBUTES objectAttributes;
    NTSTATUS status;
    HANDLE FileHandle;
    UNICODE_STRING fileName;
    
    //format the string
    va_start(va,szFormat);
    _vsnprintf(messagebuf,sizeof(messagebuf),szFormat,va);
    va_end(va);
    
    //get a handle to the log file object
    fileName.Buffer = NULL;
    fileName.Length = 0;
    fileName.MaximumLength = sizeof(DEFAULT_LOG_FILE_NAME) + sizeof(UNICODE_NULL);
    fileName.Buffer = ExAllocatePool(PagedPool,
                                     fileName.MaximumLength);
    if (!fileName.Buffer) {
        DbgPrint ("LogMessageInFile: FAIL. ExAllocatePool Failed.\n");
        return FALSE;
    }
    RtlZeroMemory(fileName.Buffer, fileName.MaximumLength);
    status = RtlAppendUnicodeToString(&fileName, (PWSTR)DEFAULT_LOG_FILE_NAME);
     
    InitializeObjectAttributes (&objectAttributes,
                                (PUNICODE_STRING)&fileName,
                                OBJ_CASE_INSENSITIVE,
                                NULL,
                                NULL );
    
    status = ZwCreateFile( &FileHandle,
                           FILE_APPEND_DATA,
                           &objectAttributes,
                           &IoStatus,
                           0, 
                           FILE_ATTRIBUTE_NORMAL,
                           FILE_SHARE_WRITE,
                           FILE_OPEN_IF,
                           FILE_SYNCHRONOUS_IO_NONALERT,
                           NULL,     
                           0 );
    
    if( NT_SUCCESS(status) ) {
        CHAR buf[1024];
        
        sprintf(buf,"%s",messagebuf);
        
        //format the string to make sure it appends a newline carrage-return to the 
        //end of the string.
        Length=strlen(buf);
        if( buf[Length-1]=='\n' ) {
            buf[Length-1]='\r';
            strcat(buf,"\n");
            Length++;
        } else {
            strcat(buf,"\r\n");
            Length+=2;
        }
        
        DbgPrint("%s", buf); 

        ZwWriteFile( FileHandle, NULL, NULL, NULL, &IoStatus, buf, Length, NULL, NULL );
        
        ZwClose( FileHandle );
    }

    if( fileName.Buffer ) {
        ExFreePool (fileName.Buffer);
    }

    return STATUS_SUCCESS;
}
#endif

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久99这里只有精品| 亚洲国产一区视频| 亚洲精品欧美综合四区| 美国精品在线观看| 欧美影院一区二区| 中文字幕精品一区二区精品绿巨人| 亚洲专区一二三| 9l国产精品久久久久麻豆| 日韩三级伦理片妻子的秘密按摩| 亚洲色图在线播放| 成人动漫精品一区二区| 精品少妇一区二区三区在线视频| 亚洲国产日韩在线一区模特| 99精品国产热久久91蜜凸| 久久久久久久久久看片| 奇米888四色在线精品| 欧美三级电影在线看| 亚洲视频电影在线| 成人激情视频网站| 欧美国产成人在线| 国产激情偷乱视频一区二区三区| 欧美一区二区三区视频| 亚洲黄色av一区| 91亚洲国产成人精品一区二三| 久久久夜色精品亚洲| 精品一区二区影视| 精品国内二区三区| 久久不见久久见免费视频1| 日韩一区二区三区视频在线| 丝袜美腿亚洲一区| 欧美一二三区在线观看| 日本美女一区二区| 日韩三级在线免费观看| 精品综合久久久久久8888| 精品国产免费视频| 国产高清不卡一区二区| 国产精品你懂的| 99re热这里只有精品免费视频| ㊣最新国产の精品bt伙计久久| eeuss鲁片一区二区三区| 国产精品二三区| 成a人片国产精品| 亚洲理论在线观看| 欧美日韩精品欧美日韩精品一综合| 亚洲电影在线免费观看| 91精品国产91综合久久蜜臀| 喷水一区二区三区| 国产视频一区二区三区在线观看| 国产69精品久久777的优势| 日韩一区日韩二区| 欧美喷潮久久久xxxxx| 精品一区免费av| 国产精品成人免费在线| 欧美日韩国产综合视频在线观看| 日日欢夜夜爽一区| 亚洲精品在线三区| 91视频一区二区三区| 丝袜美腿亚洲综合| 欧美高清一级片在线观看| 色哦色哦哦色天天综合| 美日韩黄色大片| 国产精品乱码一区二区三区软件 | 日韩久久久精品| 国产福利一区在线| 亚洲午夜私人影院| 日韩欧美国产wwwww| 99天天综合性| 青青青伊人色综合久久| 中文字幕中文字幕中文字幕亚洲无线| 欧美伊人久久久久久午夜久久久久| 美女视频黄 久久| 国产精品国产成人国产三级 | 精品久久久久av影院| 成人h动漫精品一区二区| 亚洲一卡二卡三卡四卡 | 国产精品欧美精品| 欧美精品久久99久久在免费线| 国产精品中文字幕欧美| 亚洲成人精品影院| 国产精品国产三级国产aⅴ中文| 欧美日韩精品一区视频| 99久久免费视频.com| 久久国产精品露脸对白| 一区2区3区在线看| 欧美经典一区二区| 精品三级在线观看| 欧美日韩精品综合在线| 99久久99久久精品免费看蜜桃| 另类小说一区二区三区| 有坂深雪av一区二区精品| 久久精品欧美一区二区三区不卡| 欧美另类变人与禽xxxxx| av一本久道久久综合久久鬼色| 国模大尺度一区二区三区| 日韩中文字幕一区二区三区| 亚洲人成在线播放网站岛国| 久久久精品黄色| 精品伦理精品一区| 91麻豆精品国产91久久久久久久久 | 黄页视频在线91| 秋霞午夜av一区二区三区| 亚洲一区二区三区视频在线| 1000精品久久久久久久久| 中文字幕不卡三区| 久久精品免费在线观看| 久久久久久麻豆| 久久久久久久综合狠狠综合| 日韩精品一区二区三区在线| 欧美一区二区三区在线视频 | 精品少妇一区二区| 日韩欧美国产综合在线一区二区三区| 欧美在线视频你懂得| 色老汉av一区二区三区| 91美女福利视频| 91偷拍与自偷拍精品| 99精品视频在线观看| 99国产精品久| 欧美中文字幕一区二区三区亚洲| 一本在线高清不卡dvd| 在线观看日韩一区| 欧美日韩视频在线一区二区| 欧美综合欧美视频| 欧美一区二区三区视频免费播放| 欧美一区二区人人喊爽| 欧美不卡一二三| 国产肉丝袜一区二区| 中文字幕欧美一| 悠悠色在线精品| 天天av天天翘天天综合网 | 亚洲综合清纯丝袜自拍| 亚洲一区二区欧美激情| 日韩电影免费在线看| 国产在线播放一区三区四| 国产aⅴ精品一区二区三区色成熟| 国产成都精品91一区二区三| 波多野结衣精品在线| 一本大道综合伊人精品热热| 在线免费观看成人短视频| 4438x成人网最大色成网站| 精品国精品国产| 亚洲人成小说网站色在线| 一区二区日韩电影| 久久99精品久久久| av男人天堂一区| 日韩一区二区视频在线观看| 中国色在线观看另类| 一区二区欧美在线观看| 激情欧美一区二区三区在线观看| 国产成人免费高清| 欧美色视频在线观看| 久久久久免费观看| 亚洲福利视频一区二区| 国产尤物一区二区在线| 91官网在线免费观看| 精品奇米国产一区二区三区| 1024亚洲合集| 六月婷婷色综合| 在线精品亚洲一区二区不卡| 精品美女一区二区| 亚洲图片欧美色图| jiyouzz国产精品久久| 日韩一区国产二区欧美三区| 成人免费在线观看入口| 久久超碰97人人做人人爱| 欧美亚洲日本国产| 国产精品视频你懂的| 久久精品国产第一区二区三区| 91麻豆精品在线观看| 337p粉嫩大胆噜噜噜噜噜91av| 一区二区三区成人| 成人av电影在线网| 26uuu亚洲| 日本欧美韩国一区三区| 91黄色激情网站| 国产精品狼人久久影院观看方式| 日本特黄久久久高潮| 欧美中文字幕不卡| 亚洲视频免费在线| av电影在线观看一区| 久久精品一区二区三区四区| 奇米影视7777精品一区二区| 91福利在线播放| 亚洲色图19p| yourporn久久国产精品| 精品国产3级a| 麻豆国产精品视频| 欧美一区中文字幕| 午夜视频一区二区| 欧美日韩免费高清一区色橹橹| 中文字幕亚洲区| 成人18视频日本| 国产精品电影院| 成人精品国产免费网站| 国产精品看片你懂得| 成人午夜精品一区二区三区| 国产欧美日韩激情| 成人蜜臀av电影| 中文字幕视频一区| 一本大道综合伊人精品热热 | 在线免费观看不卡av|