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

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

?? bulkusb.c

?? 支持USB2.0 BULK傳輸范例
?? C
字號:
/*++


Module Name:

    bulkusb.c

Abstract:

    Main module

Author:

Environment:

    kernel mode only

Notes:

    All Rights Reserved.

--*/

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

//
// Globals
//

GLOBALS Globals;
ULONG   DebugLevel = 1;
BOOLEAN win98 = FALSE;

#ifdef PAGE_CODE
#ifdef ALLOC_PRAGMA
#pragma alloc_text(INIT, DriverEntry)
#pragma alloc_text(PAGE, BulkUsb_DriverUnload)
#endif
#endif


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

Routine Description:

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

Arguments:
    
    DriverObject - pointer to driver object 

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

Return Values:

    NT status value
    
--*/
{

    NTSTATUS        ntStatus;
    PUNICODE_STRING registryPath;

	// DriverEntry
	KdPrint((DRIVERNAME " - Entering DriverEntry: DriverObject %8.8lX\n", DriverObject));

	// Insist that OS support at least the WDM level of the DDK we use

	if (!IoIsWdmVersionAvailable(1, 0))
		{
		KdPrint((DRIVERNAME " - Expected version of WDM (%d.%2.2d) not available\n", 1, 0));
		return STATUS_UNSUCCESSFUL;
		}

	//
    // initialization of variables
    //

    registryPath = &Globals.BulkUsb_RegistryPath;

    //
    // Allocate pool to hold a null-terminated copy of the path.
    // Safe in paged pool since all registry routines execute at
    // PASSIVE_LEVEL.
    //

    registryPath->MaximumLength = UniRegistryPath->Length + sizeof(UNICODE_NULL);
    registryPath->Length        = UniRegistryPath->Length;
    registryPath->Buffer        = ExAllocatePool(PagedPool,
                                                 registryPath->MaximumLength);

    if (!registryPath->Buffer) {

        KdPrint( ("Failed to allocate memory for registryPath\n"));
        ntStatus = STATUS_INSUFFICIENT_RESOURCES;
        goto DriverEntry_Exit;
    } 


    RtlZeroMemory (registryPath->Buffer, 
                   registryPath->MaximumLength);
    RtlMoveMemory (registryPath->Buffer, 
                   UniRegistryPath->Buffer, 
                   UniRegistryPath->Length);

    ntStatus = STATUS_SUCCESS;

    //
    // Initialize the driver object with this driver's entry points.
    //
    DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = BulkUsb_DispatchDevCtrl;
    DriverObject->MajorFunction[IRP_MJ_POWER]          = BulkUsb_DispatchPower;
    DriverObject->MajorFunction[IRP_MJ_PNP]            = BulkUsb_DispatchPnP;
    DriverObject->MajorFunction[IRP_MJ_CREATE]         = BulkUsb_DispatchCreate;
    DriverObject->MajorFunction[IRP_MJ_CLOSE]          = BulkUsb_DispatchClose;
    DriverObject->MajorFunction[IRP_MJ_CLEANUP]        = BulkUsb_DispatchClean;
	DriverObject->MajorFunction[IRP_MJ_READ]           = BulkUsb_DispatchReadWrite;
    DriverObject->MajorFunction[IRP_MJ_WRITE]          = BulkUsb_DispatchReadWrite;
    DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = BulkUsb_DispatchSysCtrl;
    DriverObject->DriverUnload                         = BulkUsb_DriverUnload;
    DriverObject->DriverExtension->AddDevice           = (PDRIVER_ADD_DEVICE)
                                                         BulkUsb_AddDevice;
	
	
DriverEntry_Exit:

    return ntStatus;
}

VOID
BulkUsb_DriverUnload(
    IN PDRIVER_OBJECT DriverObject
    )
/*++

Description:

    This function will free the memory allocations in DriverEntry.

Arguments:

    DriverObject - pointer to driver object 

Return:
	
    None

--*/
{
    PUNICODE_STRING registryPath;
	KdPrint((DRIVERNAME " - Entering DriverEntry: DriverObject %8.8lX\n", DriverObject));

    KdPrint((DRIVERNAME " - Entering DriverUnload: DriverObject %8.8lX\n", DriverObject));

    registryPath = &Globals.BulkUsb_RegistryPath;

    if(registryPath->Buffer) {

        ExFreePool(registryPath->Buffer);
        registryPath->Buffer = NULL;
    }

    KdPrint( ("BulkUsb_DriverUnload - ends\n"));

    return;
}

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

Description:

Arguments:

    DriverObject - Store the pointer to the object representing us.

    PhysicalDeviceObject - Pointer to the device object created by the
                           undelying bus driver.

Return:
	
    STATUS_SUCCESS - if successful 
    STATUS_UNSUCCESSFUL - otherwise

--*/
{
    NTSTATUS          ntStatus;
    PDEVICE_OBJECT    deviceObject;
    PDEVICE_EXTENSION deviceExtension;
    POWER_STATE       state;
    KIRQL             oldIrql;

    KdPrint( (DRIVERNAME " - BulkUsb_AddDevice - begins %8.8lX\n"));

    deviceObject = NULL;

    ntStatus = IoCreateDevice(
                    DriverObject,                   // our driver object
                    sizeof(DEVICE_EXTENSION),       // extension size for us
                    NULL,                           // name for this device
                    FILE_DEVICE_UNKNOWN,
                    FILE_AUTOGENERATED_DEVICE_NAME, // device characteristics
                    FALSE,                          // Not exclusive
                    &deviceObject);                 // Our device object

    if(!NT_SUCCESS(ntStatus)) {
        //
        // returning failure here prevents the entire stack from functioning,
        // but most likely the rest of the stack will not be able to create
        // device objects either, so it is still OK.
        //                
        KdPrint( ("Failed to create device object\n"));
        return ntStatus;
    }

    //
    // Initialize the device extension
    //

    deviceExtension = (PDEVICE_EXTENSION) deviceObject->DeviceExtension;
    deviceExtension->FunctionalDeviceObject = deviceObject;
    deviceExtension->PhysicalDeviceObject = PhysicalDeviceObject;
    deviceObject->Flags |= DO_DIRECT_IO;
		
	//
    // initialize the device state lock and set the device state
    //

    KeInitializeSpinLock(&deviceExtension->DevStateLock);
    INITIALIZE_PNP_STATE(deviceExtension);

    //
    //initialize OpenHandleCount
    //
    deviceExtension->OpenHandleCount = 0;

    //
    // Initialize the selective suspend variables
    //
    KeInitializeSpinLock(&deviceExtension->IdleReqStateLock);
    deviceExtension->IdleReqPend = 0;
    deviceExtension->PendingIdleIrp = NULL;

    //
    // Hold requests until the device is started
    //

    deviceExtension->QueueState = HoldRequests;

    //
    // Initialize the queue and the queue spin lock
    //

    InitializeListHead(&deviceExtension->NewRequestsQueue);
    KeInitializeSpinLock(&deviceExtension->QueueLock);

    //
    // Initialize the remove event to not-signaled.
    //

    KeInitializeEvent(&deviceExtension->RemoveEvent, 
                      SynchronizationEvent, 
                      FALSE);

    //
    // Initialize the stop event to signaled.
    // This event is signaled when the OutstandingIO becomes 1
    //

    KeInitializeEvent(&deviceExtension->StopEvent, 
                      SynchronizationEvent, 
                      TRUE);

    //
    // OutstandingIo count biased to 1.
    // Transition to 0 during remove device means IO is finished.
    // Transition to 1 means the device can be stopped
    //

    deviceExtension->OutStandingIO = 1;
    KeInitializeSpinLock(&deviceExtension->IOCountLock);

    //
    // Delegating to WMILIB
    //
    ntStatus = BulkUsb_WmiRegistration(deviceExtension);

    if(!NT_SUCCESS(ntStatus)) {

        KdPrint( ("BulkUsb_WmiRegistration failed with %X\n", ntStatus));
        IoDeleteDevice(deviceObject);
        return ntStatus;
    }

    //
    // set the flags as underlying PDO
    //

    if(PhysicalDeviceObject->Flags & DO_POWER_PAGABLE) {

        deviceObject->Flags |= DO_POWER_PAGABLE;
    }

	
	

    //
    // Typically, the function driver for a device is its 
    // power policy owner, although for some devices another 
    // driver or system component may assume this role. 
    // Set the initial power state of the device, if known, by calling 
    // PoSetPowerState.
    // 

    deviceExtension->DevPower = PowerDeviceD0;
    deviceExtension->SysPower = PowerSystemWorking;

    state.DeviceState = PowerDeviceD0;
    PoSetPowerState(deviceObject, DevicePowerState, state);

    //
    // attach our driver to device stack
    // The return value of IoAttachDeviceToDeviceStack is the top of the
    // attachment chain.  This is where all the IRPs should be routed.
    //

    deviceExtension->TopOfStackDeviceObject = 
                IoAttachDeviceToDeviceStack(deviceObject,
                                            PhysicalDeviceObject);

    if(NULL == deviceExtension->TopOfStackDeviceObject) {

        BulkUsb_WmiDeRegistration(deviceExtension);
        IoDeleteDevice(deviceObject);
        return STATUS_NO_SUCH_DEVICE;
    }
        
    //
    // Register device interfaces
    //

    ntStatus = IoRegisterDeviceInterface(deviceExtension->PhysicalDeviceObject, 
                                         &GUID_INTERFACE_SILABS_BULK, 
                                         NULL, 
                                         &deviceExtension->InterfaceName);

    if(!NT_SUCCESS(ntStatus)) {

        BulkUsb_WmiDeRegistration(deviceExtension);
        IoDetachDevice(deviceExtension->TopOfStackDeviceObject);
        IoDeleteDevice(deviceObject);
        return ntStatus;
    }

    if(IoIsWdmVersionAvailable(1, 0x20)) {

        deviceExtension->WdmVersion = WinXpOrBetter;
    }
    else if(IoIsWdmVersionAvailable(1, 0x10)) {

        deviceExtension->WdmVersion = Win2kOrBetter;
    }
    else if(IoIsWdmVersionAvailable(1, 0x5)) {

        deviceExtension->WdmVersion = WinMeOrBetter;
    }
    else if(IoIsWdmVersionAvailable(1, 0x0)) {

        deviceExtension->WdmVersion = Win98OrBetter;
    }

    deviceExtension->SSRegistryEnable = 0;
    deviceExtension->SSEnable = 0;

    //
    // WinXP only
    // check the registry flag -
    // whether the device should selectively
    // suspend when idle
    //

    if(WinXpOrBetter == deviceExtension->WdmVersion) {

        BulkUsb_GetRegistryDword(INTUSB_REGISTRY_PARAMETERS_PATH,
                                 L"BulkUsbEnable",
                                 &deviceExtension->SSRegistryEnable);

        if(deviceExtension->SSRegistryEnable) {

            //
            // initialize DPC
            //
            KeInitializeDpc(&deviceExtension->DeferredProcCall, 
                            DpcRoutine, 
                            deviceObject);

            //
            // initialize the timer.
            // the DPC and the timer in conjunction, 
            // monitor the state of the device to 
            // selectively suspend the device.
            //
            KeInitializeTimerEx(&deviceExtension->Timer,
                                NotificationTimer);

            //
            // Initialize the NoDpcWorkItemPendingEvent to signaled state.
            // This event is cleared when a Dpc is fired and signaled
            // on completion of the work-item.
            //
            KeInitializeEvent(&deviceExtension->NoDpcWorkItemPendingEvent, 
                              NotificationEvent, 
                              TRUE);

            //
            // Initialize the NoIdleReqPendEvent to ensure that the idle request
            // is indeed complete before we unload the drivers.
            //
            KeInitializeEvent(&deviceExtension->NoIdleReqPendEvent,
                              NotificationEvent,
                              TRUE);
        }
    }

	
		
    //
    // Clear the DO_DEVICE_INITIALIZING flag.
    // Note: Do not clear this flag until the driver has set the
    // device power state and the power DO flags. 
    //

    deviceObject->Flags &= ~DO_DEVICE_INITIALIZING;

    KdPrint( ("BulkUsb_AddDevice - ends\n"));

    return ntStatus;
}


?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日韩亚洲丝袜制服| 91原创在线视频| 亚洲成人精品影院| 亚洲午夜视频在线| 亚洲在线视频一区| 亚洲三级在线看| 亚洲超碰97人人做人人爱| 午夜av一区二区| 蜜臀精品一区二区三区在线观看 | 午夜精品久久久久久久99水蜜桃| √…a在线天堂一区| 亚洲人xxxx| 亚洲va天堂va国产va久| 日本欧美久久久久免费播放网| 美国十次综合导航| 国产成人啪午夜精品网站男同| 岛国一区二区在线观看| 99久久99久久免费精品蜜臀| 在线观看欧美黄色| 日韩一区二区三| 久久久99精品免费观看| 最新国产成人在线观看| 亚洲成人久久影院| 国产成人综合网| 欧美视频一区二区三区在线观看| 日韩免费观看高清完整版| 亚洲国产精品二十页| 亚洲综合另类小说| 精品一区二区免费在线观看| 91视视频在线观看入口直接观看www| 91久久久免费一区二区| 欧美v国产在线一区二区三区| 中文一区二区完整视频在线观看| 亚洲国产精品久久艾草纯爱 | 国产69精品久久99不卡| 91片黄在线观看| 精品少妇一区二区| 亚洲精品成人少妇| 国产精品自拍在线| 欧美片在线播放| 国产精品日日摸夜夜摸av| 日韩电影一区二区三区四区| av电影一区二区| 久久蜜臀精品av| 丝袜a∨在线一区二区三区不卡| 成人黄色av网站在线| 精品欧美一区二区久久| 亚洲第一二三四区| 色综合久久中文综合久久97| 国产校园另类小说区| 蜜臂av日日欢夜夜爽一区| 在线免费亚洲电影| 国产欧美一区二区精品久导航| 蜜桃视频一区二区| 欧美精品久久99| 亚洲午夜激情av| 欧美写真视频网站| 亚洲日本va午夜在线影院| 国产99精品视频| 久久久久久免费网| 免费成人美女在线观看| 欧美精品粉嫩高潮一区二区| 一区二区三区四区不卡在线| av一区二区不卡| 中文字幕在线一区免费| 国产成人一区二区精品非洲| 亚洲精品一区二区三区福利| 麻豆精品一区二区综合av| 欧美日韩一区二区三区在线看 | 国产精品77777竹菊影视小说| 欧美mv和日韩mv国产网站| 日韩电影一区二区三区四区| 制服丝袜av成人在线看| 日韩黄色小视频| 91麻豆精品国产91久久久久| 日本免费新一区视频| 日韩欧美国产1| 国产乱码精品一品二品| 久久久国产精品午夜一区ai换脸| 国产福利91精品一区二区三区| 久久久蜜桃精品| 成人自拍视频在线观看| 中文字幕一区二区在线观看| av一区二区三区黑人| 亚洲影视在线播放| 884aa四虎影成人精品一区| 麻豆成人av在线| 欧美国产综合一区二区| 不卡的av网站| 亚洲二区在线视频| xvideos.蜜桃一区二区| 成人91在线观看| 亚洲成av人影院| 久久综合久久综合亚洲| 成人黄色a**站在线观看| 亚洲一卡二卡三卡四卡| 日韩免费高清视频| 99精品国产99久久久久久白柏 | 欧美不卡一区二区| 成人小视频在线观看| 一区二区免费在线播放| 欧美一区二区日韩| 成人av在线播放网站| 婷婷国产v国产偷v亚洲高清| 国产欧美一区二区精品性色超碰 | 国产乱码精品一区二区三区av | 亚洲大片在线观看| 精品88久久久久88久久久| 99精品视频在线观看免费| 午夜激情一区二区| 国产精品久久久久影院| 日韩一区二区三区电影| av亚洲精华国产精华| 日av在线不卡| 专区另类欧美日韩| 久久先锋影音av鲁色资源网| 91丨porny丨最新| 国产毛片精品一区| 五月开心婷婷久久| 亚洲精品一卡二卡| 久久久久久免费| 91.成人天堂一区| 91福利在线导航| 成人一区二区三区在线观看| 日本在线观看不卡视频| 亚洲欧美日韩国产成人精品影院| 欧美xxx久久| 欧美伦理视频网站| 在线观看区一区二| av亚洲精华国产精华| 国产很黄免费观看久久| 蜜桃精品视频在线| 亚洲一区二区三区自拍| 国产精品久久久久久久午夜片| 日韩欧美中文字幕精品| 色又黄又爽网站www久久| 成人动漫一区二区| 国产aⅴ综合色| 国产在线视频精品一区| 久久成人av少妇免费| 日韩avvvv在线播放| 日韩一区精品视频| 五月综合激情网| 首页国产欧美日韩丝袜| 日韩福利电影在线| 日韩高清不卡一区二区三区| 天天影视涩香欲综合网| 日韩中文字幕91| 青椒成人免费视频| 精品一区二区免费| 美腿丝袜一区二区三区| 国内国产精品久久| 国产麻豆91精品| 成人性生交大合| 91在线云播放| 欧美天天综合网| 日韩一区二区三区在线| www欧美成人18+| 中文字幕的久久| 亚洲精品va在线观看| 亚洲综合激情小说| 视频一区二区三区在线| 视频一区二区三区在线| 久久99精品久久久久| 国产精品综合二区| 成年人国产精品| 欧美欧美欧美欧美| 精品国内片67194| 国产欧美日韩在线视频| 亚洲色图欧美在线| 免费观看在线综合色| 国产麻豆精品一区二区| 色综合久久中文综合久久97| 欧美精品成人一区二区三区四区| 欧美电视剧在线观看完整版| 国产色婷婷亚洲99精品小说| 亚洲人成精品久久久久久| 日韩中文字幕一区二区三区| 国产一区二区三区蝌蚪| 色综合一区二区| 日韩区在线观看| 亚洲欧美中日韩| 日韩电影免费在线观看网站| 国产成人av电影在线播放| 欧洲另类一二三四区| 久久伊99综合婷婷久久伊| 国产精品成人在线观看| 日本成人中文字幕在线视频| av动漫一区二区| 欧美精品久久99久久在免费线| 欧美极品少妇xxxxⅹ高跟鞋| 天涯成人国产亚洲精品一区av| 国产福利一区二区三区视频 | 在线视频你懂得一区二区三区| 欧美一级片在线看| 亚洲你懂的在线视频| 国产精品1024久久| 欧美裸体一区二区三区| 亚洲美女在线一区| 国产精品一区二区三区网站|