📄 charsampledevice.cpp
字号:
// CharSampleDevice.cpp
// Implementation of CharSampleDevice device class
//
// Generated by DriverWizard version DriverStudio 2.6.0 (Build 336)
// Requires Compuware's DriverWorks classes
//
#pragma warning(disable:4065) // Allow switch statement with no cases
#include <vdw.h>
#include "..\CharSampleDeviceinterface.h"
#include "CharSample.h"
#include "CharSampleDevice.h"
#include "..\CharSampleioctl.h"
#pragma hdrstop("CharSample.pch")
GUID CharSampleDevice_Guid = CharSampleDevice_CLASS_GUID;
extern KTrace T; // Global driver trace object
////////////////////////////////////////////////////////////////////////
// CharSampleDevice::CharSampleDevice
//
// 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.
//
CharSampleDevice::CharSampleDevice(PDEVICE_OBJECT Pdo, ULONG Unit) :
KPnpDevice(Pdo, &CharSampleDevice_Guid)
{
// 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);
// 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.
}
CharSampleDevice::~CharSampleDevice()
{
}
NTSTATUS CharSampleDevice::DefaultPnp(KIrp I)
{
I.ForceReuseOfCurrentStackLocationInCalldown();
return m_Lower.PnpCall(this, I);
}
NTSTATUS CharSampleDevice::DefaultPower(KIrp I)
{
I.IndicatePowerIrpProcessed();
I.CopyParametersDown();
return m_Lower.PnpPowerCall(this, I);
}
NTSTATUS CharSampleDevice::SystemControl(KIrp I)
{
I.ForceReuseOfCurrentStackLocationInCalldown();
return m_Lower.PnpCall(this, I);
}
NTSTATUS CharSampleDevice::OnStartDevice(KIrp I)
{
return STATUS_SUCCESS;
}
NTSTATUS CharSampleDevice::OnStopDevice(KIrp I)
{
return STATUS_SUCCESS;
}
NTSTATUS CharSampleDevice::OnRemoveDevice(KIrp I)
{
return STATUS_SUCCESS;
}
NTSTATUS CharSampleDevice::Create(KIrp I)
{
return I.PnpComplete(this, STATUS_SUCCESS, IO_NO_INCREMENT);
}
NTSTATUS CharSampleDevice::Close(KIrp I)
{
return I.PnpComplete(this, STATUS_SUCCESS, IO_NO_INCREMENT);
}
NTSTATUS CharSampleDevice::DeviceControl(KIrp I)
{
NTSTATUS status;
CHAR n,c[]="零一二三四五六七八九";
T << "CharSampleDevice::DeviceControl\n";
switch (I.IoctlCode())
{
case CHARSAMPLE_IOCTL_800:
n=*(CHAR *)I.IoctlBuffer();
if ((n >= '0') && (n <= '9'))
{
n -= '0';
strncpy((PCHAR)I.IoctlBuffer(),&c[n*2],2);
I.Information() = 2;
status = STATUS_SUCCESS;
}
else
status = STATUS_INVALID_PARAMETER;
break;
default:
// Unrecognized IOCTL request
status = STATUS_INVALID_PARAMETER;
break;
}
return I.PnpComplete(this, status);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -