[Bug 46254] New: EnumResourceTypesW should return True if there are no resources to enumerate
https://bugs.winehq.org/show_bug.cgi?id=46254 Bug ID: 46254 Summary: EnumResourceTypesW should return True if there are no resources to enumerate Product: Wine Version: 3.17 Hardware: x86 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: kernel32 Assignee: wine-bugs(a)winehq.org Reporter: stu.axon(a)gmail.com Distribution: --- EnumResourceTypesW -- When there are no resource types to enumerate the function instead of True will return False (see https://github.com/wine-mirror/wine/blob/master/dlls/kernel32/resource.c#L25...) This bug was originally reported in pywin32-ctypes https://github.com/enthought/pywin32-ctypes/issues/59 -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=46254 Nikolay Sivov <bunglehead(a)gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEEDINFO Ever confirmed|0 |1 --- Comment #1 from Nikolay Sivov <bunglehead(a)gmail.com> --- How did you test this? I tried this: ret = EnumResourceTypesW(NULL, enum_res_proc, 0); ok(ret, "Unexpected return value %d, error %d.\n", ret, GetLastError()); in some module without resources, and I get 0 return value, and error 1812, same on Windows and Wine. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=46254 Fabian Maurer <dark.shadow4(a)web.de> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |dark.shadow4(a)web.de --- Comment #2 from Fabian Maurer <dark.shadow4(a)web.de> --- Any news? -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=46254 Janne <janne.kekkonen(a)gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |janne.kekkonen(a)gmail.com --- Comment #3 from Janne <janne.kekkonen(a)gmail.com> --- Created attachment 79049 --> http://bugs.winehq.org/attachment.cgi?id=79049 EnumResourceTypesA test code I made simpple application which calls EnumResourceTypesA. Application was tested on Wine 10.9 and on Windows 11. In case callback function returns TRUE. EnumResourceTypesA returns TRUE In Windows11: GetLastError returns 126. In Wine: GetLastError returns 126. If callback function returns FALSE. EnumResourceTypesA returns FALSE. In Windows11: GetLastError returns 15106. In Wine: GetLastError returns 126. If callback function pointer is NULL. In Windows11: EnumResourceTypesA returns FALSE. GetLastError returns: 998. Wine Crashes. Source of my test application attached. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=46254 Maotong Zhang <zmtong1988(a)gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |zmtong1988(a)gmail.com --- Comment #4 from Maotong Zhang <zmtong1988(a)gmail.com> --- (In reply to Janne from comment #3)
Created attachment 79049 [details] EnumResourceTypesA test code
I made simpple application which calls EnumResourceTypesA.
Application was tested on Wine 10.9 and on Windows 11.
In case callback function returns TRUE. EnumResourceTypesA returns TRUE In Windows11: GetLastError returns 126. In Wine: GetLastError returns 126.
If callback function returns FALSE. EnumResourceTypesA returns FALSE. In Windows11: GetLastError returns 15106. In Wine: GetLastError returns 126.
If callback function pointer is NULL.
In Windows11: EnumResourceTypesA returns FALSE. GetLastError returns: 998.
Wine Crashes.
Source of my test application attached.
In what situations is it necessary to pass NULL to EnumResourceTypes? -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=46254 --- Comment #5 from Janne <janne.kekkonen(a)gmail.com> --- (In reply to Maotong Zhang from comment #4)
(In reply to Janne from comment #3)
Created attachment 79049 [details] EnumResourceTypesA test code
I made simpple application which calls EnumResourceTypesA.
Application was tested on Wine 10.9 and on Windows 11.
In case callback function returns TRUE. EnumResourceTypesA returns TRUE In Windows11: GetLastError returns 126. In Wine: GetLastError returns 126.
If callback function returns FALSE. EnumResourceTypesA returns FALSE. In Windows11: GetLastError returns 15106. In Wine: GetLastError returns 126.
If callback function pointer is NULL.
In Windows11: EnumResourceTypesA returns FALSE. GetLastError returns: 998.
Wine Crashes.
Source of my test application attached.
In what situations is it necessary to pass NULL to EnumResourceTypes? Most likely thee are not situations where NULL is passed to EnumResourceTypes. But there seems to be a difference in behavior between Wine & Windows.
-- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=46254 --- Comment #6 from Maotong Zhang <zmtong1988(a)gmail.com> --- I tested your program and it didn’t crash. Try applying the patch from Bug 46255 and test again to see if it still crashes. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=46254 --- Comment #7 from Janne <janne.kekkonen(a)gmail.com> --- Created attachment 79055 --> http://bugs.winehq.org/attachment.cgi?id=79055 console logs of tests Applied both patches from bug-46255. Build 32 and 64bit versions of Wine. Build 32 and 64 bit version of the application. 64bit version of the application seems to behave same way on Wine & Windows. 32bit version has differeneses on output. Also application crashes, but that might me my build of the Wine causing this. I attached terminal/console logs. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=46254 --- Comment #8 from Stuart Axon <stu.axon(a)gmail.com> --- Hi all, It's great to see some progress on this. There's a bit more context on the pywin32-ctypes bug https://github.com/enthought/pywin32-ctypes/issues/59 -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=46254 --- Comment #9 from Maotong Zhang <zmtong1988(a)gmail.com> --- (In reply to Janne from comment #7)
Created attachment 79055 [details] console logs of tests
Applied both patches from bug-46255. Build 32 and 64bit versions of Wine. Build 32 and 64 bit version of the application.
64bit version of the application seems to behave same way on Wine & Windows. 32bit version has differeneses on output. Also application crashes, but that might me my build of the Wine causing this.
I attached terminal/console logs.
I compiled it this way into test program. 32bit: i686-w64-mingw32-gcc -Wall -g3 enumresource.c -static -lkernel32 -o enumresource_32.exe 64bit: x86_64-w64-mingw32-gcc -Wall -g3 enumresource.c -static -lkernel32 -o enumresource.exe -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=46254 --- Comment #10 from Janne <janne.kekkonen(a)gmail.com> --- (In reply to Maotong Zhang from comment #9)
(In reply to Janne from comment #7)
Created attachment 79055 [details] console logs of tests
Applied both patches from bug-46255. Build 32 and 64bit versions of Wine. Build 32 and 64 bit version of the application.
64bit version of the application seems to behave same way on Wine & Windows. 32bit version has differeneses on output. Also application crashes, but that might me my build of the Wine causing this.
I attached terminal/console logs.
I compiled it this way into test program. 32bit: i686-w64-mingw32-gcc -Wall -g3 enumresource.c -static -lkernel32 -o enumresource_32.exe
64bit: x86_64-w64-mingw32-gcc -Wall -g3 enumresource.c -static -lkernel32 -o enumresource.exe
I recompiled test application with same parameters. Now both 32&64bit versions crash on NULL pointer situation. If application is compiled with clang crash do not happen. With clang i used these parameters to compile: clang -m64 enumresource.c -o enumresource_64_clang.exe I could not spot any changes to function EnumResourceTypesW in patches at bug-46255. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=46254 --- Comment #11 from Maotong Zhang <zmtong1988(a)gmail.com> --- (In reply to Janne from comment #10)
(In reply to Maotong Zhang from comment #9)
(In reply to Janne from comment #7)
Created attachment 79055 [details] console logs of tests
Applied both patches from bug-46255. Build 32 and 64bit versions of Wine. Build 32 and 64 bit version of the application.
64bit version of the application seems to behave same way on Wine & Windows. 32bit version has differeneses on output. Also application crashes, but that might me my build of the Wine causing this.
I attached terminal/console logs.
I compiled it this way into test program. 32bit: i686-w64-mingw32-gcc -Wall -g3 enumresource.c -static -lkernel32 -o enumresource_32.exe
64bit: x86_64-w64-mingw32-gcc -Wall -g3 enumresource.c -static -lkernel32 -o enumresource.exe
I recompiled test application with same parameters.
Now both 32&64bit versions crash on NULL pointer situation.
If application is compiled with clang crash do not happen. With clang i used these parameters to compile: clang -m64 enumresource.c -o enumresource_64_clang.exe
I could not spot any changes to function EnumResourceTypesW in patches at bug-46255.
I'm a bit confused — the test program I compiled runs under Wine without crashing, and the results are the same as on Windows 11. What could be different between our setups? Could you upload the test program you compiled? I'd like to test it on my side and see. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=46254 --- Comment #12 from Janne <janne.kekkonen(a)gmail.com> --- Created attachment 79058 --> http://bugs.winehq.org/attachment.cgi?id=79058 64bit test application Test application 64bit version. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=46254 --- Comment #13 from Janne <janne.kekkonen(a)gmail.com> --- I changed my test application slightly. With this modified application i can define the address of callback function. Application was compiled with these parameters: gcc -m32 enumresource_2.c -o test.exe On Wine result looks like this: C:\temp>test 3405695742 argv[1]=3405695742 (cafecafe) wine: Unhandled page fault on execute access to CAFECAFE at address CAFECAFE (thread 012c), starting debugger. Code: tmp=atoi(argv[1]); printf("argv[1]=%s (%x)\r\n",argv[1],tmp); ret = EnumResourceTypesW(NULL, (HANDLE) tmp, lval); printf("lParam:%d Ret val:%d LastError:%d\r\n",lval,ret,GetLastError()); -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=46254 --- Comment #14 from Maotong Zhang <zmtong1988(a)gmail.com> --- (In reply to Janne from comment #13)
I changed my test application slightly. With this modified application i can define the address of callback function.
Application was compiled with these parameters: gcc -m32 enumresource_2.c -o test.exe
On Wine result looks like this:
C:\temp>test 3405695742 argv[1]=3405695742 (cafecafe) wine: Unhandled page fault on execute access to CAFECAFE at address CAFECAFE (thread 012c), starting debugger.
Code: tmp=atoi(argv[1]); printf("argv[1]=%s (%x)\r\n",argv[1],tmp); ret = EnumResourceTypesW(NULL, (HANDLE) tmp, lval); printf("lParam:%d Ret val:%d LastError:%d\r\n",lval,ret,GetLastError());
The test program you compiled does crash on my side. I'll continue analyzing the cause of the crash. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=46254 --- Comment #15 from Maotong Zhang <zmtong1988(a)gmail.com> --- (In reply to Maotong Zhang from comment #9)
(In reply to Janne from comment #7)
Created attachment 79055 [details] console logs of tests
Applied both patches from bug-46255. Build 32 and 64bit versions of Wine. Build 32 and 64 bit version of the application.
64bit version of the application seems to behave same way on Wine & Windows. 32bit version has differeneses on output. Also application crashes, but that might me my build of the Wine causing this.
I attached terminal/console logs.
I compiled it this way into test program. 32bit: i686-w64-mingw32-gcc -Wall -g3 enumresource.c -static -lkernel32 -o enumresource_32.exe
64bit: x86_64-w64-mingw32-gcc -Wall -g3 enumresource.c -static -lkernel32 -o enumresource.exe
I compiled the test program using MinGW under Linux. You can give it a try. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=46254 --- Comment #16 from Janne <janne.kekkonen(a)gmail.com> --- Created attachment 79059 --> http://bugs.winehq.org/attachment.cgi?id=79059 patch I tested to patch EnumResourceTypesW. After patch test application do not crash anymore with NULL pointer. Also gives same error 998 as Windows. patch attached. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=46254 --- Comment #17 from Maotong Zhang <zmtong1988(a)gmail.com> --- (In reply to Janne from comment #16)
Created attachment 79059 [details] patch
I tested to patch EnumResourceTypesW. After patch test application do not crash anymore with NULL pointer. Also gives same error 998 as Windows. patch attached.
Issue resolved. I think unsigned int should be changed to ULONG_PTR. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=46254 --- Comment #18 from Janne <janne.kekkonen(a)gmail.com> --- (In reply to Maotong Zhang from comment #15)
(In reply to Maotong Zhang from comment #9)
(In reply to Janne from comment #7)
Created attachment 79055 [details] console logs of tests
Applied both patches from bug-46255. Build 32 and 64bit versions of Wine. Build 32 and 64 bit version of the application.
64bit version of the application seems to behave same way on Wine & Windows. 32bit version has differeneses on output. Also application crashes, but that might me my build of the Wine causing this.
I attached terminal/console logs.
I compiled it this way into test program. 32bit: i686-w64-mingw32-gcc -Wall -g3 enumresource.c -static -lkernel32 -o enumresource_32.exe
64bit: x86_64-w64-mingw32-gcc -Wall -g3 enumresource.c -static -lkernel32 -o enumresource.exe
I compiled the test program using MinGW under Linux. You can give it a try.
I tested compiling test application in Wine. Command used: x86_64-w64-mingw32-gcc -Wall -g3 enumresource.c -static -lkernel32 -o enumresource_wine.exe This application do not crash. So for some reason the application that is compiled on Windows causes the crash. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=46254 --- Comment #19 from Maotong Zhang <zmtong1988(a)gmail.com> --- (In reply to Janne from comment #18)
(In reply to Maotong Zhang from comment #15)
(In reply to Maotong Zhang from comment #9)
(In reply to Janne from comment #7)
Created attachment 79055 [details] console logs of tests
Applied both patches from bug-46255. Build 32 and 64bit versions of Wine. Build 32 and 64 bit version of the application.
64bit version of the application seems to behave same way on Wine & Windows. 32bit version has differeneses on output. Also application crashes, but that might me my build of the Wine causing this.
I attached terminal/console logs.
I compiled it this way into test program. 32bit: i686-w64-mingw32-gcc -Wall -g3 enumresource.c -static -lkernel32 -o enumresource_32.exe
64bit: x86_64-w64-mingw32-gcc -Wall -g3 enumresource.c -static -lkernel32 -o enumresource.exe
I compiled the test program using MinGW under Linux. You can give it a try.
I tested compiling test application in Wine.
Command used: x86_64-w64-mingw32-gcc -Wall -g3 enumresource.c -static -lkernel32 -o enumresource_wine.exe
This application do not crash.
So for some reason the application that is compiled on Windows causes the crash.
Thanks, I will take another look to see what's different. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=46254 --- Comment #20 from Janne <janne.kekkonen(a)gmail.com> --- Hello, I opened test application built in Wine and in Windows with Ghidra. When comparing main function generated by Ghidra there was no difference between the two. There was difference in mainCRTStartup function between Wine & Windows built application. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=46254 --- Comment #21 from Maotong Zhang <zmtong1988(a)gmail.com> --- Yes, you are correct. When compiled with Linux + MinGW, the initialization logic of mainCRTStartup is relatively simple and does not perform checks. However, the mainCRTStartup compiled on Windows performs function pointer checks, and it is precisely these checks that cause the crash. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=46254 Janne <janne.kekkonen(a)gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #79059|0 |1 is obsolete| | --- Comment #22 from Janne <janne.kekkonen(a)gmail.com> --- Created attachment 79402 --> http://bugs.winehq.org/attachment.cgi?id=79402 function pointer sanity check updated my previous patch. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
participants (2)
-
wine-bugs@winehq.org -
WineHQ Bugzilla