zoukankan      html  css  js  c++  java
  • 获得FDO by name

        NTSTATUS            ntStatus = STATUS_SUCCESS;  
        PDEVICE_OBJECT  DeviceObject = NULL;  
        PFILE_OBJECT        FileObject = NULL;    
        ntStatus = IoGetDeviceObjectPointer(pObjectName,FILE_ALL_ACCESS,&FileObject,&DeviceObject);  
        if(!NT_SUCCESS(ntStatus))  
        {  
            KdPrint(("IoGetDeviceObjectPointer Failed,ntStatus = 0x%08lX\n",ntStatus));  
            goto _EXIT0_;  
        }  
        KdPrint(("IoGetDeviceObjectPointer succeed!\n"));  
     
        DeviceObject = IoGetLowerDeviceObject(DeviceObject);  
        if(!DeviceObject)  
        {  
            KdPrint(("IoGetLowerDeviceObject Failed,ntStatus = 0x%08lX!\n",ntStatus));  
            ntStatus = STATUS_UNSUCCESSFUL;  
            goto _EXIT1_;  
        }  
     
        while(!(DeviceObject->Flags & DO_BUS_ENUMERATED_DEVICE))  
        {  
            ObDereferenceObject(DeviceObject);  
            DeviceObject = IoGetLowerDeviceObject(DeviceObject);  
            if(!DeviceObject)  
            {  
                ObDereferenceObject(FileObject);  
                ntStatus = STATUS_UNSUCCESSFUL;  
                goto _EXIT1_;  
            }   
        }

    照例pdo设备都会在Flags中设置DO_BUS_ENUMERATED_DEVICE,这也是判断PDO和FDO的标准之一

    The IoGetLowerDeviceObject routine returns a pointer to the next-lower-level device object on the driver stack.

    Ntifs.h (include Ntifs.h)

    <= DISPATCH_LEVEL

  • 相关阅读:
    LeetCode-079-单词搜索
    awk学习笔记
    Python实现排列组合算法
    python模拟登录人人
    Python的SQLite数据库使用方法
    C语言排序算法——插入排序算法
    C语言排序算法——简单选择排序算法
    C语言排序算法——冒泡排序算法
    Python学习——python的函数参数传递
    Python学习——实现secure copy功能
  • 原文地址:https://www.cnblogs.com/ahuo/p/2011449.html
Copyright © 2011-2022 走看看