資源簡介
USB過濾驅動程序,通過USB的PID和VID判斷是否是合法U盤。

代碼片段和文件信息
#include?“stddcls.h“
#include?“driver.h“
#include?
#include?
#include?
#include?
#include?
NTSTATUS?AddDevice(IN?PDRIVER_object?Driverobject?IN?PDEVICE_object?pdo);
VOID?DriverUnload(IN?PDRIVER_object?fido);
NTSTATUS?DispatchAny(IN?PDEVICE_object?fido?IN?PIRP?Irp);
NTSTATUS?DispatchPower(IN?PDEVICE_object?fido?IN?PIRP?Irp);
NTSTATUS?DispatchPnp(IN?PDEVICE_object?fido?IN?PIRP?Irp);
NTSTATUS?DispatchWmi(IN?PDEVICE_object?fido?IN?PIRP?Irp);
ULONG?GetDeviceTypeToUse(PDEVICE_object?pdo);
NTSTATUS?PnpStartDevice(IN?PDEVICE_object?fido?IN?PIRP?Irp);
NTSTATUS?ReadDeviceDescriptor(IN?PDEVICE_object?fido);
NTSTATUS?CallRemoveUSBDevice(IN?PDEVICE_object?fido);
NTSTATUS?StartDeviceCompletionRoutine(PDEVICE_object?fido?PIRP?Irp?PDEVICE_EXTENSION?pdx);
NTSTATUS?StartPnPQueryDeviceCompletionRoutine(PDEVICE_object?fido?PIRP?Irp?PDEVICE_EXTENSION?pdx);
NTSTATUS?QueryDeviceRelationCompletionRoutine(PDEVICE_object?fido?PIRP?Irp?PDEVICE_EXTENSION?pdx);
NTSTATUS?UsageNotificationCompletionRoutine(PDEVICE_object?fido?PIRP?Irp?PDEVICE_EXTENSION?pdx);
LONG BulkUsb_IoDecrement(IN?OUT?PDEVICE_EXTENSION?DeviceExtension);
LONG BulkUsb_IoIncrement(IN?OUT?PDEVICE_EXTENSION?DeviceExtension);
int QueryRegDWORD(UNICODE_STRING?*pValueName?ULONG?*pReturn);
int SetRegDWORD(UNICODE_STRING?*pValueName?ULONG?nSetValue);?
bool USBDeviceIsRegist(ULONG?vid_pid);
///////////////////////////////////////////////////////////////////////////////
#pragma?INITCODE?
extern?“C“?NTSTATUS?DriverEntry(IN?PDRIVER_object?Driverobject
IN?PUNICODE_STRING?RegistryPath)
{ //?DriverEntry
KdPrint((DRIVERNAME?“?-?Entering?DriverEntry:?Driverobject?%8.8lX\n“?Driverobject));
//?Initialize?function?pointers
UNICODE_STRING?ValueName;
RtlInitUnicodeString(?&ValueName?L“FilterIsRun“);?
SetRegDWORD(&ValueName?0);
Driverobject->DriverUnload?=?DriverUnload;
Driverobject->DriverExtension->AddDevice?=?AddDevice;
for?(int?i?=?0;?i?ject->MajorFunction);?++i)
Driverobject->MajorFunction[i]?=?DispatchAny;
Driverobject->MajorFunction[IRP_MJ_POWER]?=?DispatchPower;
Driverobject->MajorFunction[IRP_MJ_PNP]?=?DispatchPnp;
Driverobject->MajorFunction[IRP_MJ_SCSI]?=?DispatchForSCSI;
return?STATUS_SUCCESS;
} //?DriverEntry
///////////////////////////////////////////////////////////////////////////////
#pragma?PAGEDCODE
VOID?DriverUnload(IN?PDRIVER_object?Driverobject)
{ //?DriverUnload
UNICODE_STRING?ValueName;
PAGED_CODE();
RtlInitUnicodeString(?&ValueName?L“FilterIsRun“);?
SetRegDWORD(&ValueName?0);
KdPrint((DRIVERNAME?“?-?Entering?DriverUnload:?Driverobject?%8.8lX\n“?Driverobject));
} //?DriverUnload
///////////////////////////////////////////////////////////////////////////////
NTSTATUS?AddDevice(IN?PDRIVER_object?Driverobject?IN?PDEVICE_object?pdo)
{ //?AddDevice
PAGED_CODE();
NTSTATUS?status;
UNICODE_STRING?ValueName;?
ULONG?dwReturn
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2012-04-28?21:07??usbfilter\
?????文件????????1323??2010-09-14?14:16??usbfilter\Driver.h
?????文件???????32867??2010-10-11?11:49??usbfilter\DriverEntry.cpp
?????文件????????3242??2010-09-14?00:51??usbfilter\MyFilter.dsp
?????文件?????????539??2010-10-11?11:21??usbfilter\MyFilter.dsw
?????文件???????50176??2012-04-28?21:07??usbfilter\MyFilter.ncb
?????文件??????687616??2012-04-28?21:07??usbfilter\MyFilter.opt
?????文件?????????916??2010-09-07?11:07??usbfilter\makefile
?????文件?????????190??2010-09-06?16:33??usbfilter\sources
?????文件?????????149??2003-03-07?15:57??usbfilter\stddcls.cpp
?????文件?????????809??2003-03-07?15:57??usbfilter\stddcls.h
?????文件????????1044??2010-09-06?16:38??usbfilter\usbfilter.inf
評論
共有 條評論