On Fri, 7 Aug 2026 08:53:51 GMT, Matthias Baesken <[email protected]> wrote:

> There is a RegOpenKeyExA call present, but we do not close the handle. This 
> should be changed.
> The MS docu says 
> https://learn.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regopenkeyexa
> 'A pointer to a variable that receives a handle to the opened key. If the key 
> is not one of the predefined registry keys, call the 
> [RegCloseKey](https://learn.microsoft.com/en-us/windows/desktop/api/winreg/nf-winreg-regclosekey)
>  function after you have finished using the handle.'
> And in this coding we call
> `LONG lRet = ::RegOpenKeyExA(hRootKey, lpszSubKey, 0, KEY_ALL_ACCESS, &hKey);
> `
> with a non_NULL `lpszSubKey `so the RegCloseKey has to be done.
> 
> Also fixed a typo while at it.
> 
> ---------
> - [x] I confirm that I make this contribution in accordance with the [OpenJDK 
> Interim AI Policy](https://openjdk.org/legal/ai).

See also the MS example here
https://learn.microsoft.com/en-us/windows/win32/winprog64/example-of-registry-reflection-and-redirection-on-wow64

where they use
RegOpenKeyEx  in function AccessRegistryKeyValue 
and the keys array contains those predefined keys but  non - NULL/empty subkeys

    KEYDATA Keys[] =
    {
        { HKEY_LOCAL_MACHINE, L"HKLM", L"Software\\Hello World" },
        { HKEY_CLASSES_ROOT,  L"HKCR", L"Hello" },
        { HKEY_CLASSES_ROOT,  L"HKCR", 
L"CLSID\{00000000-0000-0000-0000-ABCD00000000}" },
        { HKEY_CLASSES_ROOT,  L"HKCR", 
L"CLSID\{00000000-0000-0000-0000-ABCD00000000}\\InprocServer32" },
        { HKEY_CLASSES_ROOT,  L"HKCR", 
L"CLSID\{00000000-0000-0000-0000-ABCD00000000}\\LocalServer32" }
    };


They call RegCloseKey (probably because of the non-null/empty subkeys).

-------------

PR Comment: https://git.openjdk.org/jdk/pull/32249#issuecomment-5237536838

Reply via email to