📄 hidmini.cpp
字号:
/*++
Copyright (c) 1996 - 1998 Microsoft Corporation
Module Name:
hidmini.c
Abstract: Human Input Device (HID) minidriver that creates an example
device.
--*/
#include "common.h"
#include "device.h"
//g_debug_level
//
// 0 = errors only (dbgLogError())
// 1 = trace and errors only (dbgLogError(), dbgLogTrace())
// 2 = verbose - errors, trace, and info (dbgLogError(), dbgLogTrace(), dbgLogInfo())
LONG g_debug_level = 0;
//g_break_on_error
//
// Set to TRUE to hit a breakpoint when a dbgLogError() statement is executed
BOOLEAN g_break_on_error = FALSE;
/////////////////////////////////////////////////////////////////////////////////////////
//DriverEntry
//
// This is the main entry point of the driver. An HID minidriver needs to fill in the
// driver object with pointers to any IRP handler functions and then register with the
// HID class driver.
//
NTSTATUS
DriverEntry(
IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING registryPath
)
{
dbgLogTrace(("DriverEntry Enter\n"));
dbgLogTrace(("DriverObject (%lx)\n", DriverObject));
//
// Create dispatch points
//
// All of the other dispatch routines are handled by HIDCLASS, except for
// IRP_MJ_POWER, which isn't implemented yet.
//
DriverObject->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = Device::static_internalDeviceControl;
DriverObject->MajorFunction[IRP_MJ_PNP] = Device::static_pnp;
DriverObject->MajorFunction[IRP_MJ_POWER] = Device::static_power;
DriverObject->DriverExtension->AddDevice = Device::static_add;
DriverObject->DriverUnload = DriverUnload;
//
// Register Sample layer with HIDCLASS.SYS module
//
HID_MINIDRIVER_REGISTRATION HidMinidriverRegistration;
RtlZeroMemory(&HidMinidriverRegistration, sizeof(HID_MINIDRIVER_REGISTRATION));
HidMinidriverRegistration.Revision = HID_REVISION;
HidMinidriverRegistration.DriverObject = DriverObject;
HidMinidriverRegistration.RegistryPath = registryPath;
HidMinidriverRegistration.DeviceExtensionSize = sizeof(DEVICE_EXTENSION);
HidMinidriverRegistration.DevicesArePolled = FALSE;
dbgLogTrace(("DeviceExtensionSize = %x\n", HidMinidriverRegistration.DeviceExtensionSize));
dbgLogTrace(("Registering with HIDCLASS.SYS\n"));
//
// After registering with HIDCLASS, it takes over control of the device, and sends
// things our way if they need device specific processing.
//
NTSTATUS ntStatus = HidRegisterMinidriver(&HidMinidriverRegistration);
dbgLogInfo(("DriverEntry Exit = %x\n", ntStatus));
return ntStatus;
}
/////////////////////////////////////////////////////////////////////////////////////////
//DriverUnload.
//
// This is called as the driver is being unloaded from memory. Currently it doesn't do
// anything
//
VOID
DriverUnload(
IN PDRIVER_OBJECT DriverObject)
{
dbgLogInfo(("DriverUnload\n"));
dbgLogTrace(("Unloading DriverObject = %x\n", DriverObject));
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -