GameFinder
GameFinder copied to clipboard
WMIHelper can't handle multiple result objects
In my case this happens when trying to get the display adpater for building the EA Desktop decryption key.
This is probably not too common, but I have WMI showing more than one display adapter (the second one being created by the VR software Virtual Desktop
).
This might actually be a good thing in this case, because the "wrong" display adapter is listed first, which as far as I can tell would have created an invalid decryption key.
For this specific scenario it should be possible to determine the correct display adapter by checking the Status
of the devices returned by WMI, because Virtual Desktop keeps the adapter disabled unless it is actively used (VD's adapter shows a status of Error
, while the real one shows OK
).
Stacktrace:
System.Management.ManagementException: Call cancelled
at System.Management.ManagementException.ThrowWithExtendedInfo(ManagementStatus errorCode)
at System.Management.ManagementObjectCollection.ManagementObjectEnumerator.MoveNext()
at System.Management.ManagementObjectCollection.CopyTo(Array array, Int32 index)
at System.Management.ManagementObjectCollection.CopyTo(ManagementBaseObject[] objectCollection, Int32 index)
at GameFinder.StoreHandlers.EADesktop.Crypto.Windows.WMIHelper.GetWMIProperty(String className, String propertyName) in D:\Programming\CSharp\Projects\_git\GitHub\GameFinder\src\GameFinder.StoreHandlers.EADesktop\Crypto\Windows\WMIHelper.cs:line 39
Full Win32_VideoController
output, in case you want to look for a better way of getting the right one:
Caption : Virtual Desktop Monitor
Description : Virtual Desktop Monitor
InstallDate :
Name : Virtual Desktop Monitor
Status : Error
Availability : 8
ConfigManagerErrorCode : 22
ConfigManagerUserConfig : False
CreationClassName : Win32_VideoController
DeviceID : VideoController1
ErrorCleared :
ErrorDescription :
LastErrorCode :
PNPDeviceID : ROOT\DISPLAY\0000
PowerManagementCapabilities :
PowerManagementSupported :
StatusInfo :
SystemCreationClassName : Win32_ComputerSystem
SystemName : CMC-DATA
MaxNumberControlled :
ProtocolSupported :
TimeOfLastReset :
AcceleratorCapabilities :
CapabilityDescriptions :
CurrentBitsPerPixel :
CurrentHorizontalResolution :
CurrentNumberOfColors :
CurrentNumberOfColumns :
CurrentNumberOfRows :
CurrentRefreshRate :
CurrentScanMode :
CurrentVerticalResolution :
MaxMemorySupported :
MaxRefreshRate :
MinRefreshRate :
NumberOfVideoPages :
VideoMemoryType : 2
VideoProcessor :
NumberOfColorPlanes :
VideoArchitecture : 5
VideoMode :
AdapterCompatibility : Virtual Desktop, Inc.
AdapterDACType :
AdapterRAM :
ColorTableEntries :
DeviceSpecificPens :
DitherType :
DriverDate : 2022-06-30 02:00:00
DriverVersion : 15.39.56.845
ICMIntent :
ICMMethod :
InfFilename : oem86.inf
InfSection : MyDevice_Install.NT
InstalledDisplayDrivers :
Monochrome : False
ReservedSystemPaletteEntries :
SpecificationVersion :
SystemPaletteEntries :
VideoModeDescription :
PSComputerName :
Caption : NVIDIA GeForce RTX 3080
Description : NVIDIA GeForce RTX 3080
InstallDate :
Name : NVIDIA GeForce RTX 3080
Status : OK
Availability : 3
ConfigManagerErrorCode : 0
ConfigManagerUserConfig : False
CreationClassName : Win32_VideoController
DeviceID : VideoController2
ErrorCleared :
ErrorDescription :
LastErrorCode :
PNPDeviceID : PCI\VEN_10DE&DEV_2216&SUBSYS_88221043&REV_A1\4&37732CF4&0&0008
PowerManagementCapabilities :
PowerManagementSupported :
StatusInfo :
SystemCreationClassName : Win32_ComputerSystem
SystemName : CMC-DATA
MaxNumberControlled :
ProtocolSupported :
TimeOfLastReset :
AcceleratorCapabilities :
CapabilityDescriptions :
CurrentBitsPerPixel : 32
CurrentHorizontalResolution : 2560
CurrentNumberOfColors : 4294967296
CurrentNumberOfColumns : 0
CurrentNumberOfRows : 0
CurrentRefreshRate : 164
CurrentScanMode : 4
CurrentVerticalResolution : 1440
MaxMemorySupported :
MaxRefreshRate : 164
MinRefreshRate : 50
NumberOfVideoPages :
VideoMemoryType : 2
VideoProcessor : NVIDIA GeForce RTX 3080
NumberOfColorPlanes :
VideoArchitecture : 5
VideoMode :
AdapterCompatibility : NVIDIA
AdapterDACType : Integrated RAMDAC
AdapterRAM : 4293918720
ColorTableEntries :
DeviceSpecificPens :
DitherType : 0
DriverDate : 2023-06-08 02:00:00
DriverVersion : 31.0.15.3623
ICMIntent :
ICMMethod :
InfFilename : oem139.inf
InfSection : Section070
InstalledDisplayDrivers : C:\WINDOWS\System32\DriverStore\FileRepository\nv_dispig.inf_amd64_7e5fd280efaa5445\nvld
umdx.dll,C:\WINDOWS\System32\DriverStore\FileRepository\nv_dispig.inf_amd64_7e5fd280efaa
5445\nvldumdx.dll,C:\WINDOWS\System32\DriverStore\FileRepository\nv_dispig.inf_amd64_7e5
fd280efaa5445\nvldumdx.dll,C:\WINDOWS\System32\DriverStore\FileRepository\nv_dispig.inf_
amd64_7e5fd280efaa5445\nvldumdx.dll
Monochrome : False
ReservedSystemPaletteEntries :
SpecificationVersion :
SystemPaletteEntries :
VideoModeDescription : 2560 x 1440 x 4294967296 colors
PSComputerName :
Note this can also occur with dual-graphics laptops with e.g., an embedded Intel GPU and a discrete AMD or NVIDIA GPU.
EDIT: Y'know, I think my wife has one of these. I'll test it when I get a chance.
Sorry that "when I get a chance" turned out to be 3 months. The existing code does in fact crash on my wife's laptop, so I whipped up a quick PR that works for her. Based on some experiments with an EA integration for GOG Galaxy, picking the first entry yields the correct result for others that were in this boat.
The OP's situation does seem a bit different, though. @UrbanCMC : Can you confirm that this PR doesn't work for you before we add a check for the Status field?
With your PR the decryption key is created successfully. Looks like EA didn't consider this edge case either.
Fixed by #132.