// ForUsbDevice.cpp
// Implementation of ForUsbDevice device class
//
// Generated by DriverWizard version DriverStudio 2.7.0 (Build 562)
// Requires Compuware's DriverWorks classes
//
#pragma warning(disable:4065) // Allow switch statement with no cases
#include <vdw.h>
#include <kusb.h>
#include "..\common\ForUsbDeviceinterface.h"
#include "ForUsb.h"
#include "ForUsbDevice.h"
#include "..\common\ForUsbioctl.h"
#pragma hdrstop("ForUsb.pch")
extern KTrace t; // Global driver trace object
GUID ForUsbDevice_Guid = ForUsbDevice_CLASS_GUID;
////////////////////////////////////////////////////////////////////////
// ForUsbDevice::ForUsbDevice
//
// Routine Description:
// 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.
//
// Parameters:
// Pdo - Physical Device Object - this is a pointer to a system
// device object that represents the physical device.
//
// Unit - Unit number. This is a number to append to the device's
// base device name to form the Logical Device Object's name
//
// Return Value:
// None
//
// Comments:
// The object being constructed contains a data member (m_Lower) 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 class driver.
//
ForUsbDevice::ForUsbDevice(PDEVICE_OBJECT Pdo, ULONG Unit) :
KPnpDevice(Pdo, &ForUsbDevice_Guid)
{
t << "Entering ForUsbDevice::ForUsbDevice (constructor)\n";
// Check constructor status
if ( ! NT_SUCCESS(m_ConstructorStatus) )
{
return;
}
// Remember our unit number
m_Unit = Unit;
// Initialize the lower device
m_Lower.Initialize(this, Pdo);
// Initialize the interface object. The wizard generates code
// to support a single interface. You may create and add additional
// interfaces. By default, the wizard uses InterfaceNumber 0 (the
// first interface descriptor), ConfigurationValue 1 (the first
// configuration descriptor), and initial interface alternate
// setting of 0. If your device has multiple interfaces or alternate
// settings for an interface, you can add additional KUsbInterface
// objects or adjust the parameters passed to this function.
m_Interface.Initialize(
m_Lower, //KUsbLowerDevice
0, //InterfaceNumber
1, //ConfigurationValue
0 //Initial Interface Alternate Setting
);
// Initialize each Pipe object
m_Endpoint1IN.Initialize(m_Lower, 0x81, 16);
m_Endpoint1OUT.Initialize(m_Lower, 0x1, 16);
m_Endpoint2IN.Initialize(m_Lower, 0x82, 64);
m_Endpoint2OUT.Initialize(m_Lower, 0x2, 64);
// Inform the base class of the lower edge device object
SetLowerDevice(&m_Lower);
// Initialize the PnP Policy settings to the "standard" policy
SetPnpPolicy();
// TODO: Customize the PnP Policy for this device by setting
// flags in m_Policies.
// Initialize the Power Policy settings to the "standard" policy
SetPowerPolicy();
// TODO: Customize the Power Policy for this device by setting
// flags in m_PowerPolicies.
}
////////////////////////////////////////////////////////////////////////
// ForUsbDevice::~ForUsbDevice
//
// Routine Description:
// This is the destructor for the Functional Device Object, or FDO.
//
// Parameters:
// None
//
// Return Value:
// None
//
// Comments:
// None
//
ForUsbDevice::~ForUsbDevice()
{
t << "Entering ForUsbDevice::~ForUsbDevice() (destructor)\n";
}
////////////////////////////////////////////////////////////////////////
// PNPMinorFunctionName
//
// Routine Description:
// Return a string describing the Plug and Play minor function
//
// Parameters:
// mn - Minor function code
//
// Return Value:
// char * - Ascii name of minor function
//
// Comments:
// This function is used for tracing the IRPs. Remove the function,
// or conditionalize it for debug-only builds, if you want to save
// space in the driver image.
//
char *PNPMinorFunctionName(ULONG mn)
{
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",
"<unknown minor function>",
"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",
"IRP_MN_QUERY_LEGACY_BUS_INFORMATION"
};
if (mn > 0x18) // IRP_MN_QUERY_LEGACY_BUS_INFORMATION
return "<unknown minor function>";
else
return minors[mn];
}
////////////////////////////////////////////////////////////////////////
// ForUsbDevice::DefaultPnp
//
// Routine Description:
// Default handler for IRP_MJ_PNP
//
// Parameters:
// I - Current IRP
//
// Return Value:
// NTSTATUS - Result returned from lower device
//
// Comments:
// This routine just passes the IRP through to the lower device. 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.
//
NTSTATUS ForUsbDevice::DefaultPnp(KIrp I)
{
t << "Entering ForUsbDevice::DefaultPnp with IRP minor function="
<< PNPMinorFunctionName(I.MinorFunction()) << EOL;
I.ForceReuseOfCurrentStackLocationInCalldown();
return m_Lower.PnpCall(this, I);
}
////////////////////////////////////////////////////////////////////////
// ForUsbDevice::DefaultPower
//
// Routine Description:
// Default handler for IRP_MJ_POWER
//
// Parameters:
// I - Current IRP
//
// Return Value:
// NTSTATUS - Result returned from lower device
//
// Comments:
// This routine just passes the IRP through to the lower device. It is
// the default handler for IRP_MJ_POWER.
//
NTSTATUS ForUsbDevice::DefaultPower(KIrp I)
{
t << "Entering ForUsbDevice::DefaultPower\n";
I.IndicatePowerIrpProcessed();
I.CopyParametersDown();
return m_Lower.PnpPowerCall(this, I);
}
////////////////////////////////////////////////////////////////////////////////
// ForUsbDevice::SystemControl
//
// Routine Description:
// Default handler for IRP_MJ_SYSTEM_CONTROL
//
// Parameters:
// I - Current IRP
//
// Return Value:
// NTSTATUS - Result returned from lower device
//
// Comments:
// This routine just passes the IRP through to the next device since this driver
// is not a WMI provider.
//
NTSTATUS ForUsbDevice::SystemControl(KIrp I)
{
t << "Entering ForUsbDevice::SystemControl\n";
I.ForceReuseOfCurrentStackLocationInCalldown();
return m_Lower.PnpCall(this, I);
}
////////////////////////////////////////////////////////////////////////
// ForUsbDevice::OnStartDevice
//
// Routine Description:
// Handler for IRP_MJ_PNP subfcn IRP_MN_START_DEVICE
//
// Parameters:
// I - Current IRP
//
// Return Value:
// NTSTATUS - Result code
//
// Comments:
// Typically, the driver sends a SET CONFIGURATION request for the
// USB device by using KUsbLowerDevice::ActivateConfiguration with
// the ConfigurationValue to activate. The wizard generates code to
// support a single configuration. You may create and add additional
// configurations.
//
NTSTATUS ForUsbDevice::OnStartDevice(KIrp I)
{
t << "Entering ForUsbDev
没有合适的资源?快使用搜索试试~ 我知道了~
PDIUSBD12的USB驱动程序,用VC编写
共21个文件
h:3个
cpp:2个
sys:2个
4星 · 超过85%的资源 需积分: 34 49 下载量 100 浏览量
2009-06-13
22:00:22
上传
评论 2
收藏 92KB RAR 举报
温馨提示
PDIUSBD12的USB驱动程序,用VC编写 PDIUSBD12的USB驱动程序,用VC编写
资源推荐
资源详情
资源评论
收起资源包目录
PDIUSBD12的USB驱动程序,用VC编写简.rar (21个子文件)
driver
sources 1KB
function.h 509B
ForUsb.rc 2KB
ForUsb.dsp 13KB
ForUsb.aps 34KB
Checked
ForUsb.res 864B
ForUsb.sys 76KB
ForUsb.inf 3KB
makefile 290B
ForUsb.h 645B
ForUsb.ncb 81KB
buildchk.log 5KB
ForUsb.opt 49KB
ForUsbDevice.h 2KB
objchk
i386
forusb.idb 25KB
ForUsb.sys 81KB
forusb.pdb 28KB
ForUsbDevice.cpp 29KB
ForUsb.dsw 537B
ForUsb.plg 3KB
ForUsb.cpp 5KB
共 21 条
- 1
资源评论
- zz2012zz2013-10-24用着还可以吧
- 老老实实2014-08-07不知道怎么用。注释中写Generated by DriverWizard version DriverStudio 2.7.0,估计是自动生成的
- xuhanqin19892013-06-07很不错 这个还是很有用
Augusdi
- 粉丝: 1w+
- 资源: 5762
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功