Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WMIHelper can't handle multiple result objects #114

Closed
UrbanCMC opened this issue Nov 2, 2023 · 4 comments
Closed

WMIHelper can't handle multiple result objects #114

UrbanCMC opened this issue Nov 2, 2023 · 4 comments

Comments

@UrbanCMC
Copy link

UrbanCMC commented Nov 2, 2023

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               :
@Nutzzz
Copy link
Contributor

Nutzzz commented Nov 20, 2023

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.

Nutzzz added a commit to Nutzzz/GameCollector that referenced this issue Feb 28, 2024
This fixes the crash mentioned in erri120#114 when multiple video controllers exist.  Naively picking the first entry may not work for everyone, but it seems to be the right choice most of the time.
@Nutzzz
Copy link
Contributor

Nutzzz commented Feb 28, 2024

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?

Nutzzz added a commit to Nutzzz/GameCollector that referenced this issue Feb 28, 2024
Fixes erri120#114. Naively picking the first entry may not work for everyone, but it seems to be the right choice most of the time.
Nutzzz added a commit to Nutzzz/GameCollector that referenced this issue Feb 28, 2024
Fixes erri120#114. Naively picking the first entry may not work for everyone, but it seems to be the right choice most of the time.
@UrbanCMC
Copy link
Author

With your PR the decryption key is created successfully. Looks like EA didn't consider this edge case either.

Nutzzz added a commit to Nutzzz/GameCollector that referenced this issue Feb 28, 2024
This fixes the crash mentioned in erri120#114 when multiple video controllers exist.  Naively picking the first entry may not work for everyone, but it seems to be the right choice most of the time.
Nutzzz added a commit to Nutzzz/GameCollector that referenced this issue Feb 28, 2024
This fixes the crash mentioned in erri120#114 when multiple video controllers exist.  Naively picking the first entry may not work for everyone, but it seems to be the right choice most of the time.
@erri120
Copy link
Owner

erri120 commented Jun 6, 2024

Fixed by #132.

@erri120 erri120 closed this as completed Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants