JDK-8300173 : Handle E_PENDING result for IExtractIconW::GetIconLocation
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 17
  • Priority: P4
  • Status: New
  • Resolution: Unresolved
  • OS: windows
  • Submitted: 2023-01-14
  • Updated: 2023-01-14
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Relates :  
Relates :  
Description
When IExtractIconW::GetIconLocation [1] is used with GIL_ASYNC flag, it can return E_PENDING.

The usage of GIL_ASYNC is the reason why the drives lost their custom icons [2]. If I remove the GIL_ASYNC flag, a customised icon is returned.

In Remarks section [3], the documentation for GetIconLocation says:
"When a client sets the GIL_ASYNC flag in uFlags and receives E_PENDING as a return value, it typically creates a background thread to extract the icon. It calls GetIconLocation from that thread, without the GIL_ASYNC flag, to retrieve the icon location. It then calls IExtractIcon::Extract to extract the icon. Returning E_PENDING implies that the object is free threaded. In other words, it can safely be called concurrently by multiple threads."

[1] https://learn.microsoft.com/en-us/windows/win32/api/shlobj_core/nf-shlobj_core-iextracticonw-geticonlocation
[2] https://github.com/openjdk/jdk/pull/380#issuecomment-704590746
[3] https://learn.microsoft.com/en-us/windows/win32/api/shlobj_core/nf-shlobj_core-iextracticonw-geticonlocation#remarks
Comments
I noticed this behaviour while I was testing the fix for JDK-8293862. getIcon : Windows-SSD (C:) 16(16) (C:\\) GetIconLocation(hres: 0x8000000a, uFlags=0x22 (GIL_ASYNC | GIL_FORSHELL), flags=0x4 (GIL_PERCLASS), index=-32) == E_PENDING) - szBuf=C:\\WINDOWS\\system32\\imageres.dll !!! hIcon(8000000a) == E_PENDING: Windows-SSD (C:) 16(16) (C:\\) GetIconLocation(uFlags=0x40 (GIL_DEFAULTICON), flags=0x4, index=-32) SUCCESS - szBuf=C:\\WINDOWS\\system32\\imageres.dll Extract == hres: 0x0, hIcon=0000000004EC0A89, hIconSmall=00000000036D0A85, size=16(0x100020) SUCCEEDED hIcon = 0x36d0a85 16(16) : Windows-SSD (C:) (C:\\) If I run it without GIL_ASYNC: getIcon : Windows-SSD (C:) 16(16) (C:\\) GetIconLocation(uFlags=2, flags=4, index=-36) SUCCESS - szBuf=C:\\WINDOWS\\system32\\imageres.dll Extract == hres: 0, hIcon=0000000001B204F7, hIconSmall=0000000003DF09F7, size=16(0x100020) SUCCEEDED hIcon = 0x3df09f7 16(16) : Windows-SSD (C:) (C:\\)
14-01-2023