// USB001Device.cpp
//
// Generated by DriverWizard 3.2.0 (Build 2485)
// Requires DDK and DriverWorks
// File created on 10/13/2010
//
// This source file contains the implementation of a subclass of KDevice.
// WDM drivers implement a subclass of KPnpDevice and override member
// functions to handle requests (IRPs) from the system.
//
#include <vdw.h>
#include <kusb.h>
#include <kusbbusintf.h>
#include "USB001Driver.h"
#include "USB001Device.h"
#include "..\\intrface.h"
#pragma hdrstop("USB001.pch")
// Global driver trace object
// TODO: Use KDebugOnlyTrace if you want trace messages
// to appear only in checked builds. Use KTrace if
// you want trace messages to always appear. Call
// method SetOutputLevel to set the output threshold.
extern KDebugOnlyTrace T;
///////////////////////////////////////////////////////////////////////////////////////////////////
// USB001Device::USB001Device
// This is the constructor for the class representing 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.
// 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.
//
// Arguments:
// IN Pdo
// Physical Device Object. This is a pointer to a system
// device object that represents the physical device.
//
// IN Unit
// Unit number to append to the device's base device name
// to distinguish multiple units of this device type.
//
// Return Value:
// none
//
USB001Device::USB001Device(PDEVICE_OBJECT Pdo, ULONG Unit) :
DeviceName(NULL),
KPnpDevice(Pdo, &GUID_DEVINTERFACE_USB001)
{
if (!NT_SUCCESS(m_ConstructorStatus))
{
T.Trace(TraceError, __FUNCTION__": Failed to create device USB001Device"
" unit number %d status %x\n", Unit, m_ConstructorStatus);
ASSERT(FALSE);
return;
}
// 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
Ep1In.Initialize(m_Lower, 0x81, 64);
Ep1Out.Initialize(m_Lower, 0x01, 64);
Ep2In.Initialize(m_Lower, 0x82, 64);
Ep2Out.Initialize(m_Lower, 0x02, 64);
Ep3In.Initialize(m_Lower, 0x83, 64);
Ep3Out.Initialize(m_Lower, 0x03, 64);
#if (_WDM_ && (WDM_MAJORVERSION > 1 ||((WDM_MAJORVERSION == 1) && (WDM_MINORVERSION >= 0x20))))
// Initialize USB direct client access interface
if (STATUS_SUCCESS == m_BusIntf.Initialize(m_Lower.TopOfStack()))
m_fBusIntfAvailable = TRUE;
else
m_fBusIntfAvailable = FALSE;
#endif
// 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.
LoadRegistryParameters();
}
///////////////////////////////////////////////////////////////////////////////////////////////////
// USB001Device::~USB001Device
// This is the destructor for the class.
//
// Arguments:
// none
//
// Return Value:
// none
//
USB001Device::~USB001Device()
{
}
///////////////////////////////////////////////////////////////////////////////////////////////////
// USB001Device::LoadRegistryParameters
// Read the registry to initialize driver data members.
//
// Arguments:
// none
//
// Return Value:
// none
//
void USB001Device::LoadRegistryParameters()
{
// Read the driver's registry values from the registry
NTSTATUS status = STATUS_SUCCESS;
UNICODE_STRING regPath;
KRegistryKey RegKey;
ULONG length;
status = RegKey.Initialize(
m_Lower.DeviceObject(),
PLUGPLAY_REGKEY_DRIVER,
KEY_ALL_ACCESS
);
if (!NT_SUCCESS(status))
{
T.Trace(TraceWarning, __FUNCTION__":: Failed to open root key for DeviceName %x", status);
}
else
{
length = 0;
// Attempt to read the value key
status = RegKey.QueryValue(
L"DeviceName",
DeviceName,
length,
PagedPool
);
if (NT_SUCCESS(status) && DeviceName != NULL)
{
T.Trace(TraceInfo, __FUNCTION__ ": RegKey.QueryValue returned %d bytes, DeviceName = %S\n", length, DeviceName);
}
else
{
T.Trace(TraceWarning, __FUNCTION__ ": RegKey.QueryValue failed to get DeviceName, STATUS %x\n", status);
}
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////
// USB001Device::DefaultPnp
// Default handler for IRP_MJ_PNP.
// This routine just passes the IRP through to the lower device. 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.
//
// Arguments:
// IN I
// the plug and play IRP
//
// Return Value:
// NTSTATUS
// Result returned from lower device
//
NTSTATUS USB001Device::DefaultPnp(KIrp I)
{
T.Trace(TraceInfo, __FUNCTION__"++. IRP %p\n", I);
T << I;
I.ForceReuseOfCurrentStackLocationInCalldown();
NTSTATUS status = m_Lower.PnpCall(this, I);
T.Trace(TraceInfo, __FUNCTION__"--. IRP %p, STATUS %x\n", I, status);
return status;
}
///////////////////////////////////////////////////////////////////////////////////////////////////
// USB001Device::DefaultPower
// Default handler for IRP_MJ_POWER.
// This routine just passes the IRP through to the lower device. IRPs
// that correspond to any virtual members of KpnpDevice that handle
// minor functions of IRP_MJ_POWER and that are not overridden get
// passed to this routine.
//
// Arguments:
// IN I
// the power IRP
//
// Return Value:
// NTSTATUS
// Result returned from lower device
//
NTSTATUS USB001Device::DefaultPower(KIrp I)
{
T.Trace(TraceInfo, __FUNCTION__"++. IRP %p\n", I);
T << I;
I.IndicatePowerIrpProcessed();
I.CopyParametersDown();
NTSTATUS status = m_Lower.PnpPowerCall(this, I);
T.Trace(TraceInfo, __FUNCTION__"--. IRP %p, STATUS %x\n", I, status);
return status;
}
///////////////////////////////////////////////////////////////////////////////////////////////////
// USB001Device::SystemControl
// Default 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.
//
// Arguments:
// IN I
// the system control (WMI) IRP
//
// Return Value:
// NTSTATUS
// Result returned from lower device
//
NTSTATUS USB001Device::SystemControl(KIrp I)
{
T.Trace(TraceInfo, __FUNCTION__"++. IRP %p\n", I);
T << I;
NTSTATUS status = STATUS_SUCCESS;
I.ForceReuseOfCurrentStackLocationInCalldown();
status = m_Lower.PnpCall(this, I);
T.Trace(TraceInfo, __FUNCTION__"--. IRP %p, STATUS %x\n", I, st
USBqudong.zip_driverstdio_ncxus one usbqudong_usb001.sys
版权申诉
121 浏览量
2022-09-24
16:23:16
上传
评论
收藏 1.39MB ZIP 举报
JonSco
- 粉丝: 75
- 资源: 1万+
最新资源
- pcb原理图.PcbDoc
- 计算机视觉-人脸识别-开发包-商业应用-人脸识别开发包(免费,可商用,有演示、范例、说明书)完整项目实例源码.zip
- Libraries-Comm-Controller
- 豆瓣电影爬虫 爬取top电影的评论 + 每个用户的看过的电影的评论 用于推荐系统的 协同过滤+源代码+文档说明
- 交互设计课程竞品分析内容案例设计
- c07c4b30caf2ab290c3f2eea8339b34b.mp4
- emqx服务器搭建文件
- Libraries-Comm-Controller-DOC-V2-0-1-en.pdf
- update9-20240601.5.205.slice.img.7z.003
- 9f9ae03ea06c5c991afa26c5813d8831.amr
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈