WEB开发网
开发学院软件开发VC 使用DriverStudio构造USB过滤驱动程序 阅读

使用DriverStudio构造USB过滤驱动程序

 2010-08-22 20:48:26 来源:WEB开发网   
核心提示:程序由两个类组成,一个是Driver类,使用DriverStudio构造USB过滤驱动程序(2),一个是Device类,Driver类包括:入口函数DriverEntry:DECLARE_DRIVER_CLASS(UsbFilterDriver, NULL)/// Driver Entry//NTSTATUS UsbF

程序由两个类组成,一个是Driver类,一个是Device类。Driver类包括:

入口函数DriverEntry:

DECLARE_DRIVER_CLASS(UsbFilterDriver, NULL)
/////////////////////////////////////////////////////////////////////
// Driver Entry
//
NTSTATUS UsbFilterDriver::DriverEntry(PUNICODE_STRING RegistryPath)
{
   T << "UsbFilterDriver::DriverEntry\n";
   m_Unit = 0;
   return STATUS_SUCCESS;
   // The following macro simply allows compilation at Warning Level 4
   // If you reference this parameter in the function simply remove the macro.
   UNREFERENCED_PARAMETER(RegistryPath);
}
  AddDevice函数
NTSTATUS UsbFilterDriver::AddDevice(PDEVICE_OBJECT Pdo)
{
   T << "UsbFilterDriver::AddDevice\n";
   UsbFilterDevice * pFilterDevice = new (
       static_cast<PCWSTR>(NULL),
       FILE_DEVICE_UNKNOWN,
       static_cast<PCWSTR>(NULL),
       0,
       DO_DIRECT_IO
       )
     UsbFilterDevice(Pdo, m_Unit);
   if (pFilterDevice)
   {
     NTSTATUS status = pFilterDevice->ConstructorStatus();
     if ( !NT_SUCCESS(status) )
     {
       T << "Failed to construct UsbFilterDevice"
        << (ULONG) m_Unit
        << " status = "
        << status
        << "\n";
       delete pFilterDevice;
     }
     else
     {
       m_Unit++;
     }
     return status;
   }
   else
   {
     T << "Failed to allocate UsbFilterDevice"
      << (ULONG) m_Unit
      << "\n";
     return STATUS_INSUFFICIENT_RESOURCES;
   }
}

上一页  1 2 3 4 5  下一页

Tags:使用 DriverStudio 构造

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接