如何从\\。\ SCSI句柄获取PCIe总线/设备/功能?

时间:2018-09-26 03:55:43

标签: winapi wmi nvme

我有一个通过\\.\SCSI#:创建的CreateFile()句柄。我知道它指向特定的HBA或(对于我而言)NVMe控制器。它必须具有与其枚举关联的总线/设备/功能。

到目前为止,尽管我不仅仅愿意通过WinApi来使用C解决方案,我还是尝试通过wmi来解决这个问题。 (实际上,更喜欢用C解决方案)。

通过使用以下方法获取对象:

gwmi -namespace root\cimv2 -class Win32_SCSIController  | format-list *

它会像这样产生我的NVMe设备:

PSComputerName              : DESK
Status                      : OK
Name                        : Standard NVM Express Controller
StatusInfo                  : 3
__GENUS                     : 2
__CLASS                     : Win32_SCSIController
__SUPERCLASS                : CIM_SCSIController
__DYNASTY                   : CIM_ManagedSystemElement
__RELPATH                   : Win32_SCSIController.DeviceID="PCI\\VEN_1987&DEV_5008&SUBSYS_50081987&REV_01\\4&CB74546&0&00E8"
__PROPERTY_COUNT            : 31
__DERIVATION                : {CIM_SCSIController, CIM_Controller, CIM_LogicalDevice, CIM_LogicalElement...}
__SERVER                    : DESK
__NAMESPACE                 : root\cimv2
__PATH                      : \\DESK\root\cimv2:Win32_SCSIController.DeviceID="PCI\\VEN_1987&DEV_5008&SUBSYS_50081987&REV_01\\4&CB74546&0&00E8"
Availability                : 3
Caption                     : Standard NVM Express Controller
ConfigManagerErrorCode      : 0
ConfigManagerUserConfig     : False
ControllerTimeouts          :
CreationClassName           : Win32_SCSIController
Description                 : Standard NVM Express Controller
DeviceID                    : PCI\VEN_1987&DEV_5008&SUBSYS_50081987&REV_01\4&CB74546&0&00E8
DeviceMap                   :
DriverName                  : stornvme
ErrorCleared                :
ErrorDescription            :
HardwareVersion             :
Index                       :
InstallDate                 :
LastErrorCode               :
Manufacturer                : Standard NVM Express Controller
MaxDataWidth                :
MaxNumberControlled         :
MaxTransferRate             :
PNPDeviceID                 : PCI\VEN_1987&DEV_5008&SUBSYS_50081987&REV_01\4&CB74546&0&00E8
PowerManagementCapabilities :
PowerManagementSupported    :
ProtectionManagement        :
ProtocolSupported           : 2
SystemCreationClassName     : Win32_ComputerSystem
SystemName                  : DESK
TimeOfLastReset             :
Scope                       : System.Management.ManagementScope
Path                        : \\DESK\root\cimv2:Win32_SCSIController.DeviceID="PCI\\VEN_1987&DEV_5008&SUBSYS_50081987&REV_01\\4&CB74546&0&00E8"
Options                     : System.Management.ObjectGetOptions
ClassPath                   : \\DESK\root\cimv2:Win32_SCSIController
Properties                  : {Availability, Caption, ConfigManagerErrorCode, ConfigManagerUserConfig...}
SystemProperties            : {__GENUS, __CLASS, __SUPERCLASS, __DYNASTY...}
Qualifiers                  : {dynamic, Locale, provider, UUID}
Site                        :                     :

请注意索引如何为空...我想这应该是\。\ SCSI#中的数字:

多玩一点,我可以从中获得总线/设备/功能:

$a = gwmi -namespace root\cimv2 -class Win32_PnPEntity -filter "DeviceId='PCI\\VEN_1987&DEV_5008&SUBSYS_50081987&REV_01\\4&CB74546&0&00E8'"

$a.GetDeviceProperties('DEVPKEY_Device_LocationInfo').deviceProperties.Data
PCI bus 5, device 0, function 0

我还考虑过在\\.\SCSI#:句柄上调用IOCTL_SCSI_GET_ADDRESS,尽管那是行不通的(因为这不是lun句柄,而是控制器,所以这很有意义)

如何将PCIe总线/设备/功能信息与\\.\SCSI#:句柄相关联?

0 个答案:

没有答案