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

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

?? busbdev.cpp

?? WDM的驅(qū)動程序?qū)嵗?可供自學(xué)開發(fā)WDM者參考,其是在VC和COMPUWARE下的.
?? 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);
}

////////////////////////////////////////////////////////////////////////////////
// Handler for IRP_MJ_SYSTEM_CONTROL 
//
// This routine just passes the IRP through to the next device since this driver
// is not a WMI provider.
//
NTSTATUS BasicUsbDevice::SystemControl(KIrp I) 
{
	I.ForceReuseOfCurrentStackLocationInCalldown();
	return m_Usb.PnpCall(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.

	_try
	{
		// Fetch a configuration descriptor

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

		// 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;
			_leave;
		}

		// 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) )
			_leave;

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

		// Initialize an Interface object

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

		if ( !NT_SUCCESS(status) )
			_leave;

		// 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;
		}

	} 
	_finally {}

	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()
			);

		if( NULL == pUrb )
		{
			status = STATUS_INSUFFICIENT_RESOURCES;
			break;
		}

	// 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

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

		return STATUS_PENDING;
	}

	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一区二区三区| 亚洲精品免费在线| 成人夜色视频网站在线观看| 欧美va亚洲va| 美腿丝袜亚洲色图| 欧美一区二区人人喊爽| 国产精品毛片久久久久久| 成人免费看的视频| 中文字幕亚洲一区二区va在线| 日韩成人av影视| 日韩欧美在线综合网| 日韩av中文字幕一区二区三区| 欧美午夜精品一区二区蜜桃| 亚洲一区二区视频在线| 97久久精品人人澡人人爽| 国产精品视频一二三区| 蜜桃一区二区三区在线| 亚洲精品一区二区三区蜜桃下载 | 懂色一区二区三区免费观看| 欧美精品一区二区三区蜜臀| 国产盗摄一区二区三区| 亚洲欧洲日产国码二区| 国产精品亚洲视频| 国产精品久久一级| 在线观看日韩av先锋影音电影院| 91精品久久久久久久99蜜桃| 天堂蜜桃一区二区三区| 日韩欧美一区电影| 国产成人一区在线| 亚洲美女屁股眼交3| 制服丝袜在线91| 国产91精品精华液一区二区三区| 亚洲色图欧洲色图| 欧美一区欧美二区| 国产在线精品一区二区三区不卡| 欧美电影精品一区二区| 成人av网站在线观看免费| 亚洲综合偷拍欧美一区色| 欧美丝袜丝交足nylons| 国产乱子轮精品视频| 亚洲免费在线视频| 日韩精品一区国产麻豆| 成人短视频下载| 天天做天天摸天天爽国产一区 | 日韩中文字幕区一区有砖一区| 国产精品996| 亚洲精品成人悠悠色影视| 精品视频在线看| 国产成人免费视频网站高清观看视频| ㊣最新国产の精品bt伙计久久| 精品视频123区在线观看| 偷窥少妇高潮呻吟av久久免费| 成人免费高清视频在线观看| 性久久久久久久| 国产精品素人视频| 欧美sm极限捆绑bd| 在线看国产一区| 国产98色在线|日韩| 三级久久三级久久久| 亚洲色图清纯唯美| 国产亚洲精品bt天堂精选| 欧美人妇做爰xxxⅹ性高电影| 亚洲理论在线观看| 国产午夜精品理论片a级大结局| 欧美放荡的少妇| 国产成人自拍网| 老司机免费视频一区二区三区| 亚洲另类一区二区| 中文字幕一区二区视频| www国产成人| 91麻豆精品国产91久久久久久久久| www.在线欧美| 日本人妖一区二区| 亚洲午夜精品网| 亚洲猫色日本管| 91精品国产乱码| 在线视频一区二区三区| 99久久综合精品| 国产电影精品久久禁18| 国产综合久久久久久鬼色| 亚洲成人动漫一区| 亚洲日本丝袜连裤袜办公室| 日本一区二区在线不卡| 在线一区二区三区四区| 国产成人a级片| 美女视频第一区二区三区免费观看网站| 精品成人免费观看| 91精品在线一区二区| 欧美在线免费视屏| 在线观看一区二区精品视频| 国产成都精品91一区二区三| 国产福利不卡视频| 国产白丝网站精品污在线入口| 九色porny丨国产精品| 久久精品99国产国产精| 麻豆国产欧美一区二区三区| 日韩国产欧美在线播放| 亚洲一区二区三区三| 亚洲一区二区三区中文字幕| 亚洲精品视频在线看| 国产精品久久三区| 亚洲视频你懂的| 自拍av一区二区三区| 一区二区三区在线免费观看| 一区二区三区中文在线| 亚洲国产色一区| 日本aⅴ免费视频一区二区三区 | 成人免费一区二区三区视频 | 一区二区三区在线影院| 最近日韩中文字幕| 国产精品午夜久久| 亚洲三级免费电影| 欧美午夜一区二区三区 | 国产亚洲精品aa| ●精品国产综合乱码久久久久| 久久久久久久久久电影| 精品国产91乱码一区二区三区 | 中文字幕永久在线不卡| 国产精品女上位| 日韩理论在线观看| 国产精品麻豆视频| 亚洲超丰满肉感bbw| 日韩中文字幕区一区有砖一区| 一区二区欧美视频| 亚洲午夜一区二区| 亚洲精品中文在线观看| 精品乱码亚洲一区二区不卡| 欧美国产精品久久| 一区二区免费在线| 精品一区二区三区不卡| 免播放器亚洲一区| 国内精品写真在线观看| 暴力调教一区二区三区| 欧美日韩亚洲另类| 国产午夜精品一区二区三区四区| 国产精品私房写真福利视频| 午夜视频在线观看一区二区三区| 精品中文字幕一区二区小辣椒| 国产激情精品久久久第一区二区| 99精品欧美一区二区蜜桃免费 | 国产精品一级在线| 色琪琪一区二区三区亚洲区| 精品精品国产高清a毛片牛牛| 自拍偷拍国产精品| 久久99这里只有精品| 在线观看国产日韩| 日本一区二区免费在线观看视频| 亚洲国产aⅴ成人精品无吗| 久久国产婷婷国产香蕉| 国产真实乱对白精彩久久| 欧美日韩一级黄| 中文字幕欧美日本乱码一线二线| 国产精品区一区二区三区 | 欧美日韩一区二区三区四区五区 | 天堂在线亚洲视频| 99国产精品99久久久久久| 91麻豆免费观看| 久久精品人人做人人爽人人| 日韩精品亚洲专区| 一本色道亚洲精品aⅴ| 欧美色图片你懂的| 欧美日韩一区二区三区免费看 | 亚洲成人免费在线| 91一区二区在线| 91精品国产一区二区| 欧美性视频一区二区三区| 国产欧美精品日韩区二区麻豆天美| 青青草91视频| 色悠悠亚洲一区二区| 欧美一区三区四区| 亚洲视频一区二区免费在线观看| 国产高清不卡一区| 欧美成人伊人久久综合网| 午夜视频在线观看一区二区| 欧美色爱综合网| 亚洲三级在线免费| 91蜜桃传媒精品久久久一区二区| 在线观看区一区二| 中文字幕 久热精品 视频在线| 激情偷乱视频一区二区三区| 欧美精品tushy高清| 国产欧美一区二区精品婷婷 | 久久久99免费| 五月天激情综合网| 欧美日韩一区二区欧美激情| 亚洲国产精品久久久男人的天堂| 91久久久免费一区二区| 一区二区欧美在线观看| 欧美天堂亚洲电影院在线播放| 亚洲午夜精品在线| 欧美精品乱码久久久久久| 国产精品久久久一区麻豆最新章节| 成人小视频免费观看| 久久久久久免费网| 成人app网站| 精品国产一区二区亚洲人成毛片 | 三级在线观看一区二区| 制服丝袜中文字幕亚洲|