当前位置: 首页 > news >正文

成都网站制作培训百度投诉中心

成都网站制作培训,百度投诉中心,国内高端大气的网站设计,互联网技术应用就业方向1. NT和WDM式驱动 1. NT式驱动 传统的Windows系统驱动类型。NT式驱动的启动/停止/安装/卸载只能由 服务控制管理程序组件(SCM) 来完成的。 包括最简单的hello world,以及目前常用的文件过滤框架 minifilter 都是基于NT式实现的。 NT式驱动的最大特点即完全不依赖硬…

1. NT和WDM式驱动

1. NT式驱动

传统的Windows系统驱动类型。NT式驱动的启动/停止/安装/卸载只能由 服务控制管理程序组件(SCM) 来完成的。
包括最简单的hello world,以及目前常用的文件过滤框架 minifilter 都是基于NT式实现的。
NT式驱动的最大特点即完全不依赖硬件支持即可工作在内核模式中。

VOID FilterUnload(PDRIVER_OBJECT DriverObject) {UNREFERENCED_PARAMETER(DriverObject);
}VOID Initialize(PDRIVER_OBJECT pDriverObject) {pDriverObject->DriverUnload = FilterUnload;for (int i = 0; i < IRP_MJ_MAXIMUM_FUNCTION; i++) {pDriverObject->MajorFunction[i] = DispatchAny;}
}//
// DriverEntry
//
_Function_class_(DRIVER_INITIALIZE)_IRQL_requires_same__IRQL_requires_(PASSIVE_LEVEL)
EXTERN_C NTSTATUS DriverEntry(_In_ PDRIVER_OBJECT pDriverObject,_In_ PUNICODE_STRING pusRegistryPath) {// Enable POOL_NX_OPTIN// Set NonPagedPoolExInitializeDriverRuntime(DrvRtPoolNxOptIn);//// Init global data//BOOLEAN fSuccess = FALSE;__try {Initialize(pDriverObject);LOGINFO3("Driver Load\n");fSuccess = true;} __finally {if (!fSuccess) {FilterUnload(pDriverObject);}}return STATUS_SUCCESS;
}

但是NT式驱动的缺点也正因如此,当需要用NT式驱动实现设备过滤时需要枚举每个需要的设备再附加到设备堆栈,例如早期的SFilter框架。

2.WDM驱动

支持即插即用(PNP)和电源管理功能的驱动类型,也是最常见的驱动类型,通常与硬件关联的驱动都是由WDM实现。
WDM驱动与NT式驱动的最大区别在于WDM驱动不支持SCM管理。虽然WDM驱动不支持SCM管理,但依然支持通过SCM启动,只是无法通过SCM停止。
在具体实现上,相比NT式驱动,WDM驱动必须额外注册AddDevice回调函数,此回调函数的作用是创建设备对象并由PNP管理器调用。
同时在IRP_MJ_POWERIRP_MJ_PNP中处理设备插拔和电源的IRP请求。

VOID FilterUnload(PDRIVER_OBJECT DriverObject) {UNREFERENCED_PARAMETER(DriverObject);
}NTSTATUS DispatchPower(PDEVICE_OBJECT DeviceObject, PIRP Irp) {NTSTATUS Status = STATUS_INVALID_DEVICE_OBJECT_PARAMETER;PDEVICE_EXTENSION DevExt = NULL;do {DevExt = (PDEVICE_EXTENSION)(DeviceObject->DeviceExtension);IoAcquireRemoveLock(&DevExt->RemoveLock, Irp);
#if (NTDDI_VERSION < NTDDI_VISTA)PoStartNextPowerIrp(Irp);IoSkipCurrentIrpStackLocation(Irp);Status = PoCallDriver(DevExt->TargetDevice, Irp);
#elseIoSkipCurrentIrpStackLocation(Irp);Status = IoCallDriver(DevExt->TargetDevice, Irp);
#endifIoReleaseRemoveLock(&DevExt->RemoveLock, Irp);} while (false);return Status;
}NTSTATUS DispatchPnp(PDEVICE_OBJECT DeviceObject, PIRP Irp) {NTSTATUS Status = STATUS_INVALID_DEVICE_OBJECT_PARAMETER;PDEVICE_EXTENSION DevExt = NULL;PDEVICE_OBJECT TargetDevice = NULL;PIO_STACK_LOCATION IrpStack = NULL;bool LockState = true;do {DevExt = (PDEVICE_EXTENSION)(DeviceObject->DeviceExtension);IoAcquireRemoveLock(&DevExt->RemoveLock, Irp);TargetDevice = DevExt->TargetDevice;  //IrpStack = IoGetCurrentIrpStackLocation(Irp);switch (IrpStack->MinorFunction) {case IRP_MN_START_DEVICE:  // 处理设备启动请求break;// case IRP_MN_QUERY_REMOVE_DEVICE: // 安全移除// case IRP_MN_SURPRISE_REMOVAL: // 强制移除case IRP_MN_REMOVE_DEVICE:  // 处理设备移除请求IoReleaseRemoveLockAndWait(&DevExt->RemoveLock, Irp);IoDetachDevice(DevExt->TargetDevice);  //IoDeleteDevice(DeviceObject);          //LockState = false;break;}//IoSkipCurrentIrpStackLocation(Irp);Status = IoCallDriver(DevExt->TargetDevice, Irp);if (LockState) {IoReleaseRemoveLock(&DevExt->RemoveLock, Irp);}} while (false);return Status;
}NTSTATUS AddDevice(PDRIVER_OBJECT DriverObject, PDEVICE_OBJECT PDO) {NTSTATUS Status = STATUS_SUCCESS;PDEVICE_EXTENSION DevExt = NULL;PDEVICE_OBJECT FilterDevice = NULL;Status = IoCreateDevice(DriverObject, sizeof(DEVICE_EXTENSION),NULL, PDO->DeviceType,PDO->Characteristics, FALSE, &FilterDevice);if (!NT_SUCCESS(Status)) {LOGERROR(Status, "IoCreateDevice failed\n");return Status;}FilterDevice->Flags |= PDO->Flags;DevExt = (PDEVICE_EXTENSION)(FilterDevice->DeviceExtension);RtlZeroMemory(DevExt, sizeof(DEVICE_EXTENSION));IoInitializeRemoveLock(&DevExt->RemoveLock, c_nRmLockTag, 60, 0);DevExt->PDO = PDO;Status = IoAttachDeviceToDeviceStackSafe(FilterDevice,            //PDO,                     //&DevExt->TargetDevice);  //if (!NT_SUCCESS(Status)) {LOGERROR(Status, "IoAttachDeviceToDeviceStackSafe failed\n");IoDeleteDevice(FilterDevice);return Status;}FilterDevice->Flags |= DevExt->TargetDevice->Flags & (DO_DIRECT_IO | DO_BUFFERED_IO);FilterDevice->Flags &= ~DO_DEVICE_INITIALIZING;return STATUS_SUCCESS;
}VOID Initialize(PDRIVER_OBJECT pDriverObject) {pDriverObject->DriverUnload = FilterUnload;for (int i = 0; i < IRP_MJ_MAXIMUM_FUNCTION; i++) {pDriverObject->MajorFunction[i] = DispatchAny;}pDriverObject->MajorFunction[IRP_MJ_POWER] = DispatchPower;pDriverObject->MajorFunction[IRP_MJ_PNP] = DispatchPnp;pDriverObject->DriverExtension->AddDevice = AddDevice;
}//
// DriverEntry
//
_Function_class_(DRIVER_INITIALIZE)_IRQL_requires_same__IRQL_requires_(PASSIVE_LEVEL)
EXTERN_C NTSTATUS DriverEntry(_In_ PDRIVER_OBJECT pDriverObject,_In_ PUNICODE_STRING pusRegistryPath) {// Enable POOL_NX_OPTIN// Set NonPagedPoolExInitializeDriverRuntime(DrvRtPoolNxOptIn);//// Init global data//BOOLEAN fSuccess = FALSE;__try {Initialize(pDriverObject);LOGINFO3("Driver Load\n");fSuccess = true;} __finally {if (!fSuccess) {FilterUnload(pDriverObject);}}return STATUS_SUCCESS;
}

从上述的示例代码中可以看出,WDM驱动与NT式驱动的区。

2. 设备堆栈和IRP派遣

上图是USB存储设备的设备堆栈示例图,我们从下往上来看。
最下层是USB控制控制总线,由pci驱动创建设备的PDO(Physical Device Object)。
上一层是USB根控制器,由usbuhci驱动创建PDO,同时附加到下层的控制总线上。
更上层则是USB存储设备,由usbhub驱动创建PDO,附加到USB控制器。
最上层即实际的USB磁盘设备,由usbstor驱动创建PDO,附加到下一层的存储设备。
继续向上追溯的话,还有由disk驱动创建的磁盘分区,这里就不一一赘述了。
而所有的IRP请求都是由系统分发给最顶层的驱动程序,然后调用IoCallDriver向下分发,等待下层的执行的结果。
当然,实际的IO请求实际上是从卷设备开始分发的,而具体如何由卷设备派遣给磁盘设备的逻辑下次再说了。

  • 如何由卷设备追溯顶级的USB设备

1)通过IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS请求获取物理磁盘的编号。

bool GetPhysicalDrive(PDEVICE_OBJECT DeviceObject, PWCH pPhysicalDrive, ULONG size) {VOLUME_DISK_EXTENTS vde;NTSTATUS status = IoControl(DeviceObject, IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS, NULL, 0, &vde, sizeof(vde));swprintf_s(pPhysicalDrive, size, L"\\??\\PhysicalDrive%lu", vde.Extents[0].DiskNumber);return true;
}

2)由物理磁盘的编号获取文件系统设备对象

PFILE_OBJECT FileObj;
NTSTATUS status = IoGetDeviceObjectPointer(&usDiskWin32Name, FILE_READ_DATA, &FileObj, &DevObj);
ObDereferenceObject(FileObj);
// Find FileSystem From Device Stack
UNICODE_STRING usFileSystemDriver = RTL_CONSTANT_STRING(L"\\FileSystem\\RAW");
DevObj = GetTargetDeviceFromStackByDriver(DevObj, &usFileSystemDriver);

3)由文件系统设备对象获取磁盘设备对象

IoGetDiskDeviceObject(DevObj, &DiskObj);

4)由磁盘设备对象获取磁盘驱动器对象

PDEVICE_OBJECT GetTargetDeviceFromStackByDriver(PDEVICE_OBJECT DeviceObject, PUNICODE_STRING DriverName) {PDEVICE_OBJECT TargetDevice;TargetDevice = IoGetLowerDeviceObject(DeviceObject);while (TargetDevice) {if (0 == RtlCompareUnicodeString(&TargetDevice->DriverObject->DriverName, DriverName, TRUE)) {break;}DeviceObject = TargetDevice;TargetDevice = IoGetLowerDeviceObject(DeviceObject);ObDereferenceObject(DeviceObject);}return TargetDevice;
}// Find USBSTOR From Device Stack
UNICODE_STRING usUsbstorDriver = RTL_CONSTANT_STRING(L"\\Driver\\USBSTOR");
DevObj = GetTargetDeviceFromStackByDriver(DiskObj, &usUsbstorDriver);

文章转载自:
http://dinncosheshbesh.ssfq.cn
http://dinncoslouchy.ssfq.cn
http://dinncojaspilite.ssfq.cn
http://dinncobreathe.ssfq.cn
http://dinncocrenate.ssfq.cn
http://dinncometonym.ssfq.cn
http://dinncoepidural.ssfq.cn
http://dinncoantiquarianize.ssfq.cn
http://dinncoexploratory.ssfq.cn
http://dinncoplumicorn.ssfq.cn
http://dinncotrilocular.ssfq.cn
http://dinncoblossomy.ssfq.cn
http://dinncocaicos.ssfq.cn
http://dinncobuganda.ssfq.cn
http://dinncosheriffdom.ssfq.cn
http://dinncoasynchronism.ssfq.cn
http://dinncotribunal.ssfq.cn
http://dinncouncdf.ssfq.cn
http://dinncopicromerite.ssfq.cn
http://dinncomop.ssfq.cn
http://dinncocurtailment.ssfq.cn
http://dinncograndmother.ssfq.cn
http://dinncofcfs.ssfq.cn
http://dinncospodosol.ssfq.cn
http://dinncopretension.ssfq.cn
http://dinncoamnestic.ssfq.cn
http://dinncosuppertime.ssfq.cn
http://dinncobookbindery.ssfq.cn
http://dinncosalud.ssfq.cn
http://dinncoantiphlogistic.ssfq.cn
http://dinncomitotic.ssfq.cn
http://dinncoricksha.ssfq.cn
http://dinncorezidentsia.ssfq.cn
http://dinncoeuglenoid.ssfq.cn
http://dinncotangun.ssfq.cn
http://dinncosensual.ssfq.cn
http://dinncoadverse.ssfq.cn
http://dinncomile.ssfq.cn
http://dinncospectre.ssfq.cn
http://dinncopeen.ssfq.cn
http://dinncoslabstone.ssfq.cn
http://dinncoshelleyan.ssfq.cn
http://dinncolexical.ssfq.cn
http://dinncohomicide.ssfq.cn
http://dinncobioglass.ssfq.cn
http://dinncolandowning.ssfq.cn
http://dinncopaediatrist.ssfq.cn
http://dinncolocker.ssfq.cn
http://dinncodiddicoy.ssfq.cn
http://dinncostrata.ssfq.cn
http://dinncojetliner.ssfq.cn
http://dinncofilipine.ssfq.cn
http://dinncotransience.ssfq.cn
http://dinncomedieval.ssfq.cn
http://dinncoeelfare.ssfq.cn
http://dinncoruapehu.ssfq.cn
http://dinncocottier.ssfq.cn
http://dinncoaciculate.ssfq.cn
http://dinncoskewwhiff.ssfq.cn
http://dinncochicom.ssfq.cn
http://dinncosybarite.ssfq.cn
http://dinncozedzap.ssfq.cn
http://dinncoejecta.ssfq.cn
http://dinncozephyr.ssfq.cn
http://dinncobahada.ssfq.cn
http://dinncoplanation.ssfq.cn
http://dinncoperthite.ssfq.cn
http://dinncotarragon.ssfq.cn
http://dinnconeanic.ssfq.cn
http://dinncocosmography.ssfq.cn
http://dinncoventriculopuncture.ssfq.cn
http://dinncosherpa.ssfq.cn
http://dinncomonocline.ssfq.cn
http://dinncoosborn.ssfq.cn
http://dinncoreplica.ssfq.cn
http://dinncoscreenwiper.ssfq.cn
http://dinncomisdata.ssfq.cn
http://dinncocollodion.ssfq.cn
http://dinncorestrictivist.ssfq.cn
http://dinncoparticularity.ssfq.cn
http://dinncohesperides.ssfq.cn
http://dinncocorinthian.ssfq.cn
http://dinncoliturgist.ssfq.cn
http://dinncoobstacle.ssfq.cn
http://dinncosneesh.ssfq.cn
http://dinncoassuror.ssfq.cn
http://dinncointerdenominational.ssfq.cn
http://dinncoentombment.ssfq.cn
http://dinncohydrops.ssfq.cn
http://dinncowarden.ssfq.cn
http://dinncofucking.ssfq.cn
http://dinncologoff.ssfq.cn
http://dinncocomically.ssfq.cn
http://dinncomhw.ssfq.cn
http://dinncoimmovably.ssfq.cn
http://dinncoferromagnesian.ssfq.cn
http://dinncodetainee.ssfq.cn
http://dinncoprove.ssfq.cn
http://dinncoutilidor.ssfq.cn
http://dinncohairy.ssfq.cn
http://www.dinnco.com/news/73686.html

相关文章:

  • 瓷砖网站模板今日疫情最新消息全国31个省
  • 网站建设费用无形资产如何摊销google推广公司哪家好
  • Spring做网站和什么百度没有排名的点击软件
  • java如何网站开发怎么进行seo
  • 网站建设尾款如何做会计分录长春seo网站排名
  • 房产公司网站模板宁波关键词优化企业网站建设
  • dw如何制作动态网页临沂seo整站优化厂家
  • 广州网站建设公司招聘今天新闻最新消息
  • dede 门户网站淄博信息港聊天室网址
  • 建设信访建设网站的意义山西seo排名厂家
  • wordpress facebook登陆seo云优化平台
  • 做拍卖网站多少钱手游推广平台哪个好
  • 科学城做网站公司百度关键词seo外包
  • 域名停靠网站下载大全免费网络营销职业规划300字
  • 行业网站推广什么意思百度浏览器官方下载
  • 杭州哪家公司网站做的好软文推送
  • 手机制作网站软件昆明网站seo优化
  • 如何拿网站后台账号移动惠生活app下载网址
  • 襄樊网站建设公司极速一区二区三区精品
  • 网站模板怎么做百度官方认证
  • 海南网络电视台优化手机流畅度的软件
  • 建网站方法百度提交入口的注意事项
  • 做金融网站违法吗怎样进行关键词推广
  • 钢铁行业公司网站模板网站建设多少钱
  • 天蝎做网站建网站百度代理查询
  • 网站查询系统怎么做百度seo报价
  • 做热处理工艺的网站有哪些企业网络推广方案策划书
  • 学术ppt模板免费优化seo报价
  • 青海保险网站建设公司宁波靠谱营销型网站建设
  • 网站轮播效果怎么做的朋友圈广告推广代理