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

[SHELL32][USER32] Fix icon regression and one test #5207

Merged
merged 5 commits into from May 21, 2023

Conversation

Doug-Lyons
Copy link
Contributor

Fix icon regression of cfdbccf and fix a shell32:ExtractIconEx test.

Even more failing tests will be fixed after #5169 is committed.

Modify some return values in exticon.c based on from where they are called.

JIRA issue: CORE-18897

Allow different icon count return values from shell32:ExtractIconEx and user32:PrivateExtractIcons.

Change some return values in common function ICO_ExtractIconExW based on from where they are called.

@github-actions github-actions bot added the Win32SS For Win32 subsystem (Win32k, GDI/USER DLLs, etc.) related components PRs. label Mar 30, 2023
@JoachimHenze
Copy link
Contributor

The bug that you do intend to fix here... does that happen also on Wine? If not, why not?
It seems as if parts or most of exticon.c was taken from Wine.

Copy link
Contributor

@HBelusca HBelusca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we also have tests (maybe in an apitest or winetest for user32) for the PrivateExtractIconsW and PrivateExtractIconExW (undocumented) functions?

win32ss/user/user32/misc/exticon.c Outdated Show resolved Hide resolved
@HBelusca HBelusca added the review pending For PRs undergoing review. label Mar 30, 2023
win32ss/user/user32/misc/exticon.c Outdated Show resolved Hide resolved
win32ss/user/user32/misc/exticon.c Outdated Show resolved Hide resolved
win32ss/user/user32/misc/exticon.c Outdated Show resolved Hide resolved
win32ss/user/user32/misc/exticon.c Show resolved Hide resolved
@@ -307,7 +307,7 @@ HRESULT CFSExtractIcon_CreateInstance(IShellFolder * psf, LPCITEMIDLIST pidl, RE
ILGetDisplayNameExW(psf, pidl, wTemp, ILGDN_FORPARSING);
icon_idx = 0;

INT ret = ExtractIconExW(wTemp, -1, NULL, NULL, 0);
INT ret = PrivateExtractIconsW(wTemp, 0, 0, 0, NULL, NULL, 0, 0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are other ExtractIconExW() calls in shell32 (and elsewhere).
Does only this one need to be changed? (Why?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you look at the problem in https://jira.reactos.org/browse/CORE-18897 you can see that some icons are shown correctly and others are shown with the IDI_SHELL_DOCUMENT default icon. I found that the problem icons were those that had a PNG icon embedded in them. So I created a new ROS.ico file with the properties of having one normal BMP icon and one PNG encoded icon in it. Then I looked at the tests for shell32:ExtractIconEx and user32:PrivateExtractIcons.
I wrote more tests to include the new ROS.ico in PR #5169 and PR #5209. My findings were that the expected result from this function needed to be more in line with PrivateExtractIcons because it returned "1" on the problematic icons (ROS.ico) which kept the default document icon from being applied in the code just below. (Backed by Tests)

* is zero (0) for PNG ones using ExtractIconEx and
* one (1) for PNG icons using PrivateExtractIcons.
* We can handle the difference using the fUser32 flag.*/
BOOL fUser32)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This explanation does not look fully clear to me:
your code difference seems to be between PrivateExtractIconsW() and PrivateExtractIconsExW(),
not ExtractIconExW() and PrivateExtractIconsW().
Then, param name looks somewhat odd too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please review comments elsewhere from you regarding:
There are other ExtractIconExW() calls in shell32 (and elsewhere).
Does only this one need to be changed? (Why?)

and from @HBeluse regarding:
Do we also have tests (maybe in an apitest or winetest for user32) for the PrivateExtractIconsW and PrivateExtractIconExW (undocumented) functions?

You can let me know if you still have questions. Thanks.

win32ss/user/user32/misc/exticon.c Outdated Show resolved Hide resolved
win32ss/user/user32/misc/exticon.c Show resolved Hide resolved
@Doug-Lyons
Copy link
Contributor Author

Doug-Lyons commented Mar 30, 2023

The bug that you do intend to fix here... does that happen also on Wine? If not, why not? It seems as if parts or most of exticon.c was taken from Wine.

I am not sure how to know if it happens on Wine. When I run explorer.exe on wine, I see the following on my 'icon' directory. It seems that nothing is shown at all for the icon image other than a default. On second thought, I think that with the present code, that is what is expected before these fixes.

Wine_Explorer_Icons

@Doug-Lyons
Copy link
Contributor Author

Doug-Lyons commented Mar 30, 2023

Do we also have tests (maybe in an apitest or winetest for user32) for the PrivateExtractIconsW and PrivateExtractIconExW (undocumented) functions?

We do have user32_apitest.exe for PrivateExtractIconsEx(W) and soon I will have a PR for additional tests for this. This is a documented API. For the PrivateExtractIconExW this is not a documented API, but only a ReactOS function, so there is probably no need for tests on it. It is actually the endpoint for the documented API for ExtractIconEx which is tested by our shell32_apitest:ExtractIconEx with more recent tests after the merge of my PR. The calls for ExtractIconEx are as follows:

Shell32 has ExtractIconExW in dll/win32/shell32/iconcache.cpp at about Line # 866. This calls PrivateExtractIconExW in win32/user/user32/misc/exticon.c at about Line# 884 using a GetProcAddress on User32.dll. PrivateExtractIconExW then calls ICO_ExtractIconExW at about existing Line# 838 in exticon.c.

The common function that is called from both Shell32 and User32 is ICO_ExtractIconExW in exticon.c. It either gets called from the API functions of ExtractIconEx(W) (in Shell32) or PrivateExtractIcons(W) (in User32). This was the reason for the 'fUser32' flag name. I am open to any suggestion for a new name for it if you please. Thanks.

@github-actions github-actions bot added the shell All PR's related to the shell (and shell extensions) label Apr 25, 2023
Co-authored-by: Joachim Henze <joachim.henze@reactos.org>
@katahiromz katahiromz changed the title [WIN32SS] Fix icon regression and one test [SHELL32][USER32] Fix icon regression and one test May 10, 2023
@learn-more learn-more merged commit 8a7b5a9 into reactos:master May 21, 2023
33 of 34 checks passed
@learn-more
Copy link
Member

Thanks for your contribution!

@Doug-Lyons Doug-Lyons deleted the icon_fixes branch May 21, 2023 10:30
@binarymaster binarymaster added bugfix For bugfix PRs. and removed review pending For PRs undergoing review. labels Jun 11, 2023
@binarymaster binarymaster added this to New PRs in ReactOS PRs via automation Jun 11, 2023
@binarymaster binarymaster moved this from New PRs to Done in ReactOS PRs Jun 11, 2023
JoachimHenze added a commit that referenced this pull request Aug 30, 2023
…RE-18897

by porting back:
0.4.15-dev-6030-g 8a7b5a9 [SHELL32][USER32] Fix icon regression and one test (#5207) CORE-18897

It regressed by 0.4.14-dev-459-g cfdbccf

I actually am not a huge fan of the code-flow-splitup and all those ifdefs, but it fixes the regression.
Therefore I will not port that back further than releases/0.4.14 for now.

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

Also partially pick 0.4.15-dev-3642-g 83be315 [SHELL32] Use wide char string literals. (only the part in CFSFolder.cpp)
I might pick the other parts later.

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

Binary size remains under control:
0.4.14 shell32.dll GCC4.7.2 RosBE2.1.6 dbg-cfg  9.345.024 -> 9.345.024
0.4.14 user32.dll  GCC4.7.2 RosBE2.1.6 dbg-cfg  1.448.448 -> 1.448.448
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix For bugfix PRs. shell All PR's related to the shell (and shell extensions) Win32SS For Win32 subsystem (Win32k, GDI/USER DLLs, etc.) related components PRs.
Projects
ReactOS PRs
  
Done
8 participants