?? vusb.h
字號:
/*++
Copyright (c) 2004 Chingachguk & Denger2k All Rights Reserved
Module Name:
VUSB.H
Abstract:
This module contains the common private declarations
for the virtual USB Bus enumerator.
Environment:
kernel mode only
Notes:
Revision History:
--*/
#ifndef VUSB_H
#define VUSB_H
#include "USBKeyEmu.h"
//
// Memory allocation tag
//
#define VUSB_POOL_TAG (ULONG) 'bsUV'
//
// Debugging Output Levels
//
#define BUS_DBG_ALWAYS 0x00000000
#define BUS_DBG_STARTUP_SHUTDOWN_MASK 0x0000000F
#define BUS_DBG_SS_NOISE 0x00000001
#define BUS_DBG_SS_TRACE 0x00000002
#define BUS_DBG_SS_INFO 0x00000004
#define BUS_DBG_SS_ERROR 0x00000008
#define BUS_DBG_PNP_MASK 0x000000F0
#define BUS_DBG_PNP_NOISE 0x00000010
#define BUS_DBG_PNP_TRACE 0x00000020
#define BUS_DBG_PNP_INFO 0x00000040
#define BUS_DBG_PNP_ERROR 0x00000080
#define BUS_DBG_IOCTL_MASK 0x00000F00
#define BUS_DBG_IOCTL_NOISE 0x00000100
#define BUS_DBG_IOCTL_TRACE 0x00000200
#define BUS_DBG_IOCTL_INFO 0x00000400
#define BUS_DBG_IOCTL_ERROR 0x00000800
#define BUS_DBG_POWER_MASK 0x0000F000
#define BUS_DBG_POWER_NOISE 0x00001000
#define BUS_DBG_POWER_TRACE 0x00002000
#define BUS_DBG_POWER_INFO 0x00004000
#define BUS_DBG_POWER_ERROR 0x00008000
#if DBG
#define BUS_DEFAULT_DEBUG_OUTPUT_LEVEL 0x000FFFFF
#define Bus_KdPrint(_d_,_l_, _x_) \
if (!(_l_) || (_d_)->DebugLevel & (_l_)) { \
DbgPrint ("vusbbus.sys: "); \
DbgPrint _x_; \
}
#define Bus_KdPrint_Cont(_d_,_l_, _x_) \
if (!(_l_) || (_d_)->DebugLevel & (_l_)) { \
DbgPrint _x_; \
}
#define Bus_KdPrint_Def(_l_, _x_) \
if (!(_l_) || VUsbDebugLevel & (_l_)) { \
DbgPrint ("vusbbus.sys: "); \
DbgPrint _x_; \
}
#define DbgRaiseIrql(_x_,_y_) KeRaiseIrql(_x_,_y_)
#define DbgLowerIrql(_x_) KeLowerIrql(_x_)
#else
#define BUS_DEFAULT_DEBUG_OUTPUT_LEVEL 0x0
#define Bus_KdPrint(_d_, _l_, _x_)
#define Bus_KdPrint_Cont(_d_, _l_, _x_)
#define Bus_KdPrint_Def(_l_, _x_)
#define DbgRaiseIrql(_x_,_y_)
#define DbgLowerIrql(_x_)
#endif
extern ULONG VUsbDebugLevel;
//
// These are the states a PDO or FDO transition upon
// receiving a specific PnP Irp. Refer to the PnP Device States
// diagram in DDK documentation for better understanding.
//
typedef enum _DEVICE_PNP_STATE {
NotStarted = 0, // Not started yet
Started, // Device has received the START_DEVICE IRP
StopPending, // Device has received the QUERY_STOP IRP
Stopped, // Device has received the STOP_DEVICE IRP
RemovePending, // Device has received the QUERY_REMOVE IRP
SurpriseRemovePending, // Device has received the SURPRISE_REMOVE IRP
Deleted, // Device has received the REMOVE_DEVICE IRP
UnKnown // Unknown state
} DEVICE_PNP_STATE;
typedef struct _GLOBALS {
//
// Path to the driver's Services Key in the registry
//
UNICODE_STRING RegistryPath;
} GLOBALS;
extern GLOBALS Globals;
//
// A common header for the device extensions of the PDOs and FDO
//
typedef struct _COMMON_DEVICE_DATA {
// A back pointer to the device object for which this is the extension
PDEVICE_OBJECT Self;
// This flag helps distinguish between PDO and FDO
BOOLEAN IsFDO;
// We track the state of the device with every PnP Irp
// that affects the device through these two variables.
DEVICE_PNP_STATE DevicePnPState;
DEVICE_PNP_STATE PreviousPnPState;
ULONG DebugLevel;
// Stores the current system power state
SYSTEM_POWER_STATE SystemPowerState;
// Stores current device power state
DEVICE_POWER_STATE DevicePowerState;
} COMMON_DEVICE_DATA, *PCOMMON_DEVICE_DATA;
//
// The device extension for the PDOs.
// That's of the USB HASP device which this bus driver enumerates.
//
typedef struct _PDO_DEVICE_DATA {
COMMON_DEVICE_DATA;
// A back pointer to the bus
PDEVICE_OBJECT ParentFdo;
// An array of (zero terminated wide character strings).
// The array itself also null terminated
PWCHAR HardwareIDs;
// Unique serail number of the device on the bus
ULONG SerialNo;
// Link point to hold all the PDOs for a single bus together
LIST_ENTRY Link;
//
// Present is set to TRUE when the PDO is exposed via PlugIn IOCTL,
// and set to FALSE when a UnPlug IOCTL is received.
// We will delete the PDO in IRP_MN_REMOVE only after we have reported
// to the Plug and Play manager that it's missing.
//
BOOLEAN Present;
BOOLEAN ReportedMissing;
UCHAR Reserved[2]; // for 4 byte alignment
//
// Used to track the intefaces handed out to other drivers.
// If this value is non-zero, we fail query-remove.
//
ULONG VUsbInterfaceRefCount;
//
// In order to reduce the complexity of the driver, I chose not
// to use any queues for holding IRPs when the system tries to
// rebalance resources to accommodate a new device, and stops our
// device temporarily. But in a real world driver this is required.
// If you hold Irps then you should also support Cancel and
// Cleanup functions. The function driver demonstrates these techniques.
//
// The queue where the incoming requests are held when
// the device is stopped for resource rebalance.
//LIST_ENTRY PendingQueue;
// The spin lock that protects access to the queue
//KSPIN_LOCK PendingQueueLock;
// 泥眄
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -