Skip to content

Windows registry value not found - PdhUtil.ENGLISH_COUNTER_KEY #633

Closed

Description

@RhuanKrum

Hello,

I have run into an issue on a Windows 7 machine while trying to get the processor information using the following code:

SystemInfo si = new SystemInfo();
si.getHardware().getProcessor();

Here are the relevant parts of the stack trace I got:

java.lang.ExceptionInInitializerError
at oshi.hardware.platform.windows.WindowsHardwareAbstractionLayer.getProcessor(WindowsHardwareAbstractionLayer.java:64)
...
Caused by: com.sun.jna.platform.win32.Win32Exception: The system cannot find the file specified.
at com.sun.jna.platform.win32.Advapi32Util.registryGetStringArray(Advapi32Util.java:800)
at com.sun.jna.platform.win32.Advapi32Util.registryGetStringArray(Advapi32Util.java:775)
at oshi.jna.platform.windows.PdhUtil.PdhLookupPerfIndexByEnglishName(PdhUtil.java:99)
at oshi.hardware.platform.windows.WindowsCentralProcessor.(WindowsCentralProcessor.java:68)
... 20 more

This machine does not have the registry value that Oshi tries to look for: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Perflib\009\Counter.

The OS is in English, and the expected value exists in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Perflib\CurrentLanguage.
Ps. All the machines I could get my hands on had the Counter value in this particular key (Windows 7 and Windows 10).

I was wondering if there is any particular reason to look for the key 009. I believe that machines running in different languages would have the same problem.

Thank you!

Activity

  1. self-assigned this
    on Sep 27, 2018
  2. added
    confirmed bug
    on Sep 27, 2018
  3. dbwiddis commented on Sep 27, 2018

    @dbwiddis
    Member

    According to Microsoft Docs, registry information should always be installed in that 009 key. However, I have noticed in my testing that occasionally that key is deleted on English Windows installs when it duplicates the CurrentLanguage, typically if the user has manipulated language settings.

    I believe this represents registry corruption and should be fixed using the lodctr /R command provided in the above link. However, OSHI should probably notify the user of the corruption (and how to fix it) or shouldn't be hard to have OSHI just check "CurrentLanguage" as a backup if 009 results in the exception you see.

  4. dbwiddis commented on Sep 27, 2018

    @dbwiddis
    Member

    Also, to be clear: Performance Counters in localized versions of windows will have both the localized language (e.g., French is 012) and in English (009) for programming consistency. This is what OSHI relies upon as the standard. See here:

    HKEY_LOCAL_MACHINE
       \SOFTWARE
          \Microsoft
             \Windows NT
                \CurrentVersion
                   \Perflib
                      Last Counter = highest counter index
                      Last Help = highest help index
                      \009
                         Counters = 2 System 4 Memory...
                         Help = 3 The System Object Type...
                      \supported language, other than English
                         Counters = ...
                         Help = ...
    
  5. added
    external dependency
    i18n
    and removed
    confirmed bug
    on Sep 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

external dependencyi18n

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions