CPCIIODriver.cpp
资源名称:driver.rar [点击查看]
上传用户:lu7552215
上传日期:2021-11-14
资源大小:15k
文件大小:5k
源码类别:
驱动编程
开发平台:
Visual C++
- // CPCIIODriver.cpp
- //
- // Generated by DriverWizard 3.2.0 (Build 2485)
- // Requires DDK and DriverWorks
- // File created on 10/22/2008
- //
- // This source file contains the implementation of a subclass of KDriver.
- // WDM drivers implement a subclass of KDriver and override member
- // function DriverEntry and AddDevice.
- //
- #define VDW_MAIN
- #include <vdw.h>
- #include "function.h"
- #include "CPCIIODriver.h"
- #include "CPCIIODevice.h"
- #pragma hdrstop("CPCIIO.pch")
- // Memory allocation pool tag
- // Override this value using the global function SetPoolTag().
- POOLTAG DefaultPoolTag('ICPC');
- // 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.
- KDebugOnlyTrace T("CPCIIO");
- ///////////////////////////////////////////////////////////////////////////////////////////////////
- // Begin INIT section
- #pragma code_seg("INIT")
- DECLARE_DRIVER_CLASS(CPCIIODriver, NULL)
- ///////////////////////////////////////////////////////////////////////////////////////////////////
- // CPCIIODriver::DriverEntry
- // This routine is called when the driver is loaded. Drivers often
- // read the registry for configurable parameters.
- //
- // Arguments:
- // IN RegistryPath
- // pointer to a unicode string representing the path to
- // driver-specific key in the registry. Look for:
- // HKLMSYSTEMCurrentControlSetServicesCPCIIO
- //
- // Return Value:
- // NTSTATUS code
- //
- NTSTATUS CPCIIODriver::DriverEntry(PUNICODE_STRING RegistryPath)
- {
- T.Trace(TraceInfo, __FUNCTION__"++. Compiled at " __TIME__ " on " __DATE__ "n");
- #ifdef DBG
- //DbgBreakPoint();
- #endif
- NTSTATUS status = STATUS_SUCCESS;
- m_Unit = 0;
- // This macro suppresses compiler warning for unreferenced variable.
- // If you reference this parameter, simply remove the macro.
- UNREFERENCED_PARAMETER(RegistryPath);
- T.Trace(TraceInfo, __FUNCTION__"--. STATUS %xn", status);
- return status;
- }
- ///////////////////////////////////////////////////////////////////////////////////////////////////
- #pragma code_seg() // end INIT code
- ///////////////////////////////////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////////////////////////////////
- // CPCIIODriver::AddDevice
- // This routine is called when the system detects a device for which this
- // driver is responsible. This function creates the Functional Device
- // Object, or FDO. The FDO enables this driver to handle requests for
- // the physical device.
- //
- // Arguments:
- // IN Pdo
- // Physical Device Object. This is a pointer to a system device
- // object that represents the physical device.
- //
- // Return Value:
- // NTSTATUS
- //
- NTSTATUS CPCIIODriver::AddDevice(PDEVICE_OBJECT Pdo)
- {
- T.Trace(TraceInfo, __FUNCTION__"++.n");
- NTSTATUS status = STATUS_SUCCESS;
- // Create CPCIIODevice using a form of "placement" new
- // that is a member operator of KDevice. This will use storage
- // in the system device object extension to store the class instance.
- CPCIIODevice* pDevice = new (
- static_cast<PCWSTR>(KUnitizedName(L"CPCIIODevice", m_Unit)),
- FILE_DEVICE_UNKNOWN,
- static_cast<PCWSTR>(KUnitizedName(L"CPCIIODevice", m_Unit)),
- 0,
- DO_DIRECT_IO
- | DO_EXCLUSIVE
- | DO_POWER_PAGABLE
- )
- CPCIIODevice(Pdo, m_Unit);
- if (pDevice == NULL)
- {
- status = STATUS_INSUFFICIENT_RESOURCES;
- }
- else
- {
- status = pDevice->ConstructorStatus();
- if (!NT_SUCCESS(status))
- {
- delete pDevice;
- }
- else
- {
- m_Unit++;
- pDevice->ReportNewDevicePowerState(PowerDeviceD0);
- }
- }
- T.Trace(TraceInfo, __FUNCTION__"--. STATUS %xn", status);
- return status;
- }
- ///////////////////////////////////////////////////////////////////////////////////////////////////
- // CPCIIODriver::Unload
- // This routine is called when the driver is unloaded. Delete any
- // device objects created in DriverEntry by calling base class method
- // Unload(). Cleanup any allocations made for registry values in
- // DriverEntry.
- //
- // Arguments:
- // none
- //
- // Return Value:
- // none
- //
- VOID CPCIIODriver::Unload(VOID)
- {
- T.Trace(TraceInfo, __FUNCTION__"++.n");
- // If you don't need to perform any functions
- // except to call the base class KDriver::Unload(),
- // then this entire routine may be safely deleted.
- // Call base class to delete all devices.
- KDriver::Unload();
- T.Trace(TraceInfo, __FUNCTION__"--.n");
- }
English
