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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? busbdev.cpp

?? 一個usb設(shè)備的驅(qū)動程序源代碼
?? CPP
字號:
// busbdev.cpp - device class implementation for basic USB sample driver
//=============================================================================
//
// Compuware Corporation
// NuMega Lab
// 9 Townsend West
// Nashua, NH 03060  USA
//
// Copyright (c) 1998 Compuware Corporation. All Rights Reserved.
// Unpublished - rights reserved under the Copyright laws of the
// United States.
//
//=============================================================================

#include <vdw.h>
#include <kusb.h>
#include "busbdev.h"
#include "busbioct.h"

////////////////////////////////////////////////////////////////////////////////
// Constructor
//
// This is the constructor for the Functional Device Object, or FDO. It
// is derived from KPnpDevice, which builds in automatic dispatching of
// subfunctions of IRP_MJ_POWER and IRP_MJ_PNP to virtual member functions.
//
// Input
//   Pdo       Physical Device Object - this is a pointer to a system device
//             object that represents the physical device.
//
// The object being constructed contains a data member (m_Usb) of type
// KPnpLowerDevice. By initializing it, the driver binds the FDO to the
// PDO and creates an interface to the upper edge of the system USB
// class driver.

BasicUsbDevice::BasicUsbDevice(PDEVICE_OBJECT Pdo, ULONG Unit) :
	KPnpDevice(
		Pdo,
		KUnitizedName(L"BasicUsb", Unit), 
		FILE_DEVICE_UNKNOWN,
		KUnitizedName(L"BasicUsb", Unit)
		)
{
	m_Usb.Initialize(this, Pdo);	// initialize the USB interface
	SetLowerDevice(&m_Usb);

	SetPnpPolicy();					// setup a standarad PnP policy
}

////////////////////////////////////////////////////////////////////////////////
// Default handler for IRP_MJ_PNP
//
// This routine just passes the IRP through to USBD. It is 
// the default handler for IRP_MJ_PNP. IRPs that correspond to
// any virtual members of KpnpDevice that handle minor functions of
// IRP_MJ_PNP and that are not overridden get passed to this routine.
//
// For diagnostic purposes, this routine is set up to emit the function
// name to the debugger.
//
NTSTATUS BasicUsbDevice::DefaultPnp(KIrp I) 
{
	static char* minors[] = {
		"IRP_MN_START_DEVICE",	
		"IRP_MN_QUERY_REMOVE_DEVICE",	
		"IRP_MN_REMOVE_DEVICE",	
		"IRP_MN_CANCEL_REMOVE_DEVICE",	
		"IRP_MN_STOP_DEVICE",	
		"IRP_MN_QUERY_STOP_DEVICE",	
		"IRP_MN_CANCEL_STOP_DEVICE",	
		"IRP_MN_QUERY_DEVICE_RELATIONS",	
		"IRP_MN_QUERY_INTERFACE",	
		"IRP_MN_QUERY_CAPABILITIES",	
		"IRP_MN_QUERY_RESOURCES",	
		"IRP_MN_QUERY_RESOURCE_REQUIREMENTS",	
		"IRP_MN_QUERY_DEVICE_TEXT",	
		"IRP_MN_FILTER_RESOURCE_REQUIREMENTS",	
		"IRP_MN_undefined",	
		"IRP_MN_READ_CONFIG",	
		"IRP_MN_WRITE_CONFIG",	
		"IRP_MN_EJECT",	
		"IRP_MN_SET_LOCK",	
		"IRP_MN_QUERY_ID",	
		"IRP_MN_QUERY_PNP_DEVICE_STATE",	
		"IRP_MN_QUERY_BUS_INFORMATION",	
		"IRP_MN_DEVICE_USAGE_NOTIFICATION",
		"IRP_MN_SURPRISE_REMOVAL"
	};

	ULONG Minor = I.MinorFunction();
	CHAR* IrpName;

	if ( Minor < IRP_MN_SURPRISE_REMOVAL )
		IrpName = minors[Minor];
	else
		IrpName = "<unknown>";

	DbgPrint("Pnp IRP minor function=%s\n", IrpName);

	I.ForceReuseOfCurrentStackLocationInCalldown();
	return m_Usb.PnpCall(this, I);
}

////////////////////////////////////////////////////////////////////////////////
// Default handler for IRP_MJ_POWER 
//
// This routine just passes the IRP through to USBD. It is 
// the default handler for IRP_MJ_POWER.
//
NTSTATUS BasicUsbDevice::DefaultPower(KIrp I) 
{
	I.IndicatePowerIrpProcessed();
	I.CopyParametersDown();
	return m_Usb.PnpPowerCall(this, I);
}

////////////////////////////////////////////////////////////////////////////////
// OnStartDevice - handler for IRP_MJ_PNP/IRP_MN_START_DEVICE
//
// This is the routine where the driver initializes the physical device and
// sets up its USB related data members.
//
// This device has one interface and one pipe. Other USB devices
// are more complex, but it simply a matter of adding more data
// members to the device class in order to support more interfaces
// or pipes.

NTSTATUS BasicUsbDevice::OnStartDevice(KIrp I)
{
	NTSTATUS status;

// The framework does a synchronous call to the lower device when IRP_MN_START_DEVICE
// is received. This is part of the 'standard' PnP policy:  m_ForwardToPdoPolicy.m_CallBeforeStart
// == TRUE. If the lower device returns success, then the framework calls this routine.

// Now we begin to initialize the device object. MOST OF THIS CODE CAN
// BE AVOIDED IF YOU USE ActivateConfiguration. See example USBBULK and
// USBISOCH to see how to do it the easier way.

	do // Not really a loop, just using 'break' functionality
	{
		// Fetch a configuration descriptor

		status = m_Usb.Preconfigure(0, 1024);
		if ( !NT_SUCCESS(status) )
			break;

		// Configure an interface. First locate an interface.

		PVOID Start=NULL;
		PUSB_ENDPOINT_DESCRIPTOR pEndpoints;
		PUSB_INTERFACE_DESCRIPTOR pIntfDesc;

		pIntfDesc = m_Usb.LocateInterface(
						&Start, 
						&pEndpoints
						);
		if (pIntfDesc == NULL)
		{
			status = STATUS_UNSUCCESSFUL;
			break;
		}

		// We found an interface. Now add it to the set of interfaces
		// that the driver will support. 

		status = m_Usb.PreconfigureInterface(pIntfDesc);
		if ( !NT_SUCCESS(status) )
			break;

		// Now set the configuration
			
		status = m_Usb.Configure();
		if ( !NT_SUCCESS(status) )
			break;

		// Initialize an Interface object

		status = m_Interface.Initialize(
			m_Usb, 
			pIntfDesc->bInterfaceNumber
			);

		if ( !NT_SUCCESS(status) )
			break;

		// Initialize a pipe object

		m_Pipe.Initialize(m_Interface, 0);

		// Send a class specific URB to set up the device

		PURB pSetupUrb = m_Pipe.BuildClassRequest(
			(PUCHAR)NULL,	// TransferBuffer
			0,				// TransferBufferLength
			0x22, 			// RequestTypeReservedBits
			0xa,			// Request
			0,				// Value
			FALSE,			// bIn
			FALSE,			// bShortOk
			NULL			// Urb Link
			);

		if (pSetupUrb != NULL)
		{
			status = m_Pipe.SubmitUrb( pSetupUrb );
			delete pSetupUrb;
		}

	} while (FALSE); // do once (allowing "break" for block exit)

	return status;
}

///////////////////////////////////////////////////////////////////////////////////
// OnStopDevice
//
// The system calls this when the device is stopped. Completion of the Irp is handled
// by the framework.

NTSTATUS BasicUsbDevice::OnStopDevice(KIrp I)
{
	return m_Usb.Unconfigure();
}

///////////////////////////////////////////////////////////////////////////////
// Dispatchers
//
// Nothing to do on Create and Close. A real driver would add additional
// dispatchers for data operations such as Read and Write. The compiler
// will combine identically coded functions.

NTSTATUS BasicUsbDevice::Create(KIrp I)
{ 
	I.ForceReuseOfCurrentStackLocationInCalldown();
	return m_Usb.PnpCall(this, I);
}

NTSTATUS BasicUsbDevice::Close(KIrp I)
{
	I.ForceReuseOfCurrentStackLocationInCalldown();
	return m_Usb.PnpCall(this, I);
}

NTSTATUS BasicUsbDevice::InternalDeviceControl(KIrp I)
{ 
	I.ForceReuseOfCurrentStackLocationInCalldown();
	return m_Usb.PnpCall(this, I);
}

///////////////////////////////////////////////////////////////////////////////////
// DeviceControl
//
// The system calls this when an application issues DeviceIoControl
//
NTSTATUS BasicUsbDevice::DeviceControl(KIrp I)
{ 
	NTSTATUS status;

	I.Information() = 0;

	switch (I.IoctlCode())
	{
	case IOCTL_TEST_XFER:
	{

	// Build a transfer request

		PURB pUrb = m_Pipe.BuildInterruptTransfer(
			I.IoctlBuffer(), 
			I.IoctlOutputBufferSize()
			);

	// We are about to submit a request to the USB driver, so
	// bump the outstanding request count. Note that the counter
	// is also by the base class to count requests coming into 
	// our driver. We will decrement the count in the completion
	// routine. This enables us to handle removals cleanly.

		IncrementOutstandingRequestCount();

	// Pass the request down on the same IRP. This is the
	// asynchronous form -- note use of completion routine

		status = m_Pipe.SubmitUrb(
			I,
			pUrb,
			LinkTo(TransferComplete), 	
			this
			);

		break;
	}

	case IOCTL_TEST_STATUS:
	{
		USHORT DeviceStatus;
		USHORT InterfaceStatus;
		USHORT PipeStatus;

		m_Usb.GetStatus(&DeviceStatus);
		m_Interface.GetStatus(&InterfaceStatus);
		m_Pipe.GetStatus(&PipeStatus);

		((USHORT*)I.IoctlBuffer())[0] = DeviceStatus;
		((USHORT*)I.IoctlBuffer())[1] = InterfaceStatus;
		((USHORT*)I.IoctlBuffer())[2] = PipeStatus;

		I.Information() = 3*sizeof USHORT;
		status = STATUS_SUCCESS;
		break;
	}

	case IOCTL_TEST_RESET:
	{
		status = m_Pipe.Reset();

		((ULONG*)I.IoctlBuffer())[0] = status;

		I.Information() = sizeof ULONG;
		break;
	}

	default:
		status = STATUS_INVALID_PARAMETER;
	}

	return I.PnpComplete(this, status);
}

///////////////////////////////////////////////////////////////////////////////////
// TransferComplete
//
// Completion routine for transfer test
//
NTSTATUS BasicUsbDevice::TransferComplete(
	KIrp I, 
	_URB_BULK_OR_INTERRUPT_TRANSFER* pUrb
	)
{
	if (I->PendingReturned)
		I.MarkPending();

	// Set number of bytes transferred from URB to IRP

	I.Information() = pUrb->TransferBufferLength;

	// Release the URB

	delete pUrb;

	DecrementOutstandingRequestCount();

	return STATUS_SUCCESS;
}

///////////////////////////////////////////////////////////////////////////////////
// Linkage code for completion routine
//
// This is the first code called on completion of the xfer IRP. It
// just invokes the non-static function. For this simple example,
// it's not really necessary to find the device object, but this 
// shows how it can be done for more complex drivers.
//
NTSTATUS BasicUsbDevice::LinkTo(TransferComplete)(
	PDEVICE_OBJECT DeviceObject,
	PIRP Irp,
	PVOID Context
    )
{

// get pointer to instance of BasicUsbDevice

	BasicUsbDevice* pDevice = (BasicUsbDevice*)KDevicePTR(DeviceObject);

// call non-static member function

	return pDevice->TransferComplete(
		KIrp(Irp),
		(_URB_BULK_OR_INTERRUPT_TRANSFER*)Context
		);
}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
蜜臂av日日欢夜夜爽一区| 色狠狠一区二区| av亚洲产国偷v产偷v自拍| 欧洲国产伦久久久久久久| 亚洲乱码一区二区三区在线观看| 一区二区三区免费在线观看| 蜜桃av一区二区在线观看| 久久国产精品99久久久久久老狼| 9i在线看片成人免费| 91精品免费观看| 国产清纯在线一区二区www| 国产亚洲制服色| 奇米在线7777在线精品| 懂色av一区二区三区免费观看| 色婷婷久久久综合中文字幕| 久久久国产精华| 日本欧美肥老太交大片| 97久久精品人人澡人人爽| 精品久久久久av影院| 免费不卡在线观看| 欧美日韩在线直播| 综合在线观看色| 成人福利视频在线| 欧美精品一区二区三区一线天视频 | 亚洲伦在线观看| 国产乱码精品1区2区3区| 欧美日韩激情一区二区三区| 国产精品白丝在线| 国产一区二区精品久久91| 97aⅴ精品视频一二三区| www国产成人免费观看视频 深夜成人网| 亚洲人精品午夜| zzijzzij亚洲日本少妇熟睡| 亚洲精品在线电影| 久久精品999| 正在播放亚洲一区| 亚洲精品菠萝久久久久久久| 99久久99久久精品免费看蜜桃| 精品黑人一区二区三区久久| 日韩电影在线免费| 精品国免费一区二区三区| 午夜一区二区三区视频| 91麻豆国产在线观看| 中文字幕在线一区免费| 成熟亚洲日本毛茸茸凸凹| 久久众筹精品私拍模特| 精品制服美女久久| 精品乱人伦一区二区三区| 精品综合免费视频观看| 精品国产亚洲在线| 国内一区二区在线| 久久久无码精品亚洲日韩按摩| 免费看欧美美女黄的网站| 欧美一区二区三区播放老司机| 亚洲一区二区美女| 欧美肥胖老妇做爰| 久久91精品久久久久久秒播| 久久综合九色综合欧美就去吻 | 国产欧美精品一区二区三区四区| 国产精品一区二区在线观看不卡| 精品卡一卡二卡三卡四在线| 老司机精品视频一区二区三区| 日韩精品在线一区二区| 国产乱码字幕精品高清av | 欧美日韩国产一区二区三区地区| 蜜臀av一区二区| 国产精品久久久久影院色老大| 欧美性生活久久| 国产激情视频一区二区在线观看 | 久久亚洲捆绑美女| 日本韩国欧美一区二区三区| 热久久久久久久| 中文字幕制服丝袜一区二区三区| 欧美日韩国产美| 成人国产精品免费观看| 三级久久三级久久| 国产精品不卡在线| 2021中文字幕一区亚洲| 欧美日韩一级片在线观看| 国产成人亚洲综合a∨婷婷图片| 亚洲一区二区成人在线观看| 久久久99久久| 欧美岛国在线观看| 8v天堂国产在线一区二区| thepron国产精品| 国产精品1024久久| 精品一区二区成人精品| 性久久久久久久久久久久| 中文字幕精品在线不卡| 欧美变态tickle挠乳网站| 7777精品伊人久久久大香线蕉的 | 成人激情免费网站| 国内精品久久久久影院薰衣草 | 久久久久久久久久久99999| 欧美日韩成人在线| 91黄色激情网站| 91麻豆国产福利在线观看| 国产激情视频一区二区三区欧美| 秋霞电影网一区二区| 午夜视频一区在线观看| 亚洲自拍欧美精品| 亚洲小说欧美激情另类| 亚洲精选免费视频| 亚洲色图欧美偷拍| 自拍偷在线精品自拍偷无码专区| 久久久久久久久久久黄色| 精品国产伦一区二区三区观看体验| 欧美精品在线观看一区二区| 欧美三级日韩三级| 欧美色综合网站| 欧美午夜精品久久久久久孕妇| 成人美女视频在线看| 成人中文字幕在线| 成人av在线影院| 91在线精品秘密一区二区| 色偷偷久久一区二区三区| 在线看日本不卡| 欧美美女网站色| 日韩欧美国产精品一区| 日韩免费视频一区二区| 久久综合久久综合亚洲| 国产欧美一区二区精品婷婷| 欧美—级在线免费片| 亚洲男帅同性gay1069| 亚洲夂夂婷婷色拍ww47| 亚洲第一电影网| 久久99精品视频| 丰满少妇在线播放bd日韩电影| www.欧美.com| 精品视频在线免费| 日韩西西人体444www| 久久精品水蜜桃av综合天堂| 欧美韩日一区二区三区四区| 国产精品久久久久久久久晋中| 亚洲欧美另类综合偷拍| 日韩vs国产vs欧美| 欧美三级视频在线观看| 精品国产髙清在线看国产毛片| 久久一留热品黄| 亚洲精品精品亚洲| 免费黄网站欧美| 国产高清亚洲一区| 欧美视频一区二区| 久久久综合视频| 亚洲综合图片区| 国产一区不卡视频| 在线观看91视频| 精品国产91乱码一区二区三区| 国产精品久久久久永久免费观看| 亚洲综合色噜噜狠狠| 韩国v欧美v亚洲v日本v| 一本大道久久a久久综合| 9191久久久久久久久久久| 久久精品一区二区三区不卡牛牛| 综合自拍亚洲综合图不卡区| 麻豆免费精品视频| 欧洲视频一区二区| 国产日韩欧美精品综合| 天天综合色天天综合| 成人91在线观看| 欧美成人aa大片| 亚洲国产精品久久久男人的天堂| 韩国v欧美v日本v亚洲v| 欧美日韩国产中文| 亚洲免费观看高清| 国产99精品国产| 日韩美一区二区三区| 亚洲午夜在线视频| www.av精品| 国产午夜精品福利| 久久精品国产77777蜜臀| 在线影院国内精品| 国产精品高清亚洲| 国产成人在线网站| 欧美大片国产精品| 婷婷久久综合九色综合伊人色| av午夜精品一区二区三区| 久久先锋影音av鲁色资源网| 日韩av一区二区三区四区| 在线看日韩精品电影| 中文字幕一区二区三区四区不卡 | 欧美国产成人精品| 九九久久精品视频| 欧美一区二区免费视频| 天堂一区二区在线| 欧美日韩一区精品| 亚洲一区二区三区四区五区中文| 99精品视频免费在线观看| 国产精品久久毛片a| a美女胸又www黄视频久久| 国产视频亚洲色图| 粉嫩一区二区三区性色av| 久久精品人人爽人人爽| 国产精品正在播放| 国产亚洲1区2区3区| 国产成人精品一区二| 国产欧美综合色| 99久久99久久精品国产片果冻| 中文久久乱码一区二区| av在线这里只有精品|