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

 

相关文章:

  • 2022-12-23
  • 2021-09-25
  • 2021-11-29
  • 2022-12-23
  • 2022-12-23
  • 2021-12-20
  • 2022-12-23
  • 2021-09-29
猜你喜欢
  • 2021-12-22
  • 2021-05-28
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-21
  • 2022-02-26
相关资源
相似解决方案