[Bug 14855] New: Incorrect FindWindow/GetLastError error result when window not found
http://bugs.winehq.org/show_bug.cgi?id=14855 Summary: Incorrect FindWindow/GetLastError error result when window not found Product: Wine Version: 1.1.2 Platform: PC OS/Version: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: -unknown AssignedTo: wine-bugs(a)winehq.org ReportedBy: vesselinpeev(a)hotmail.com The following program (compiled to a Win32 binary) prints "Window not found (expected result)" under Microsoft Windows (tested with Vista), whereas it prints "Unexpected error, GetLastError() return value: 1407" when ran under Wine (tested with Wine 1.1.2). It seems that FindWindow does not set the correct error value (ERROR_FILE_NOT_FOUND) when it doesn't find a window. #include <windows.h> #include <stdio.h> int main() { HWND hWnd = FindWindow("SomeWindowThatDoesNotExist", NULL); if(hWnd) { printf("hWnd not NULL"); } else { DWORD dwResult = GetLastError(); if(dwResult == ERROR_FILE_NOT_FOUND) { printf("Window not found (expected result)\n"); } else { printf("Unexpected error, GetLastError() return value: %lu\n", dwResult); } } return 0; } -- Configure bugmail: http://bugs.winehq.org/userprefs.cgi?tab=email 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=14855 Dmitry Timoshkov <dmitry(a)codeweavers.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |testcase --- Comment #1 from Dmitry Timoshkov <dmitry(a)codeweavers.com> 2008-08-13 11:22:01 --- Please add a test case for this behaviour to dlls/user32/tests/win.c, test_hwnd_message(), after the comment /* test FindWindow behavior */. Don't forget to add SetLastError(0xdeadbeef) call right before the FindWindow() call to make sure it's really FindWindow() who sets the last error. -- Configure bugmail: http://bugs.winehq.org/userprefs.cgi?tab=email 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=14855 --- Comment #2 from Austin English <austinenglish(a)gmail.com> 2008-08-13 17:02:17 --- Created an attachment (id=15403) --> (http://bugs.winehq.org/attachment.cgi?id=15403) test in git format Here's the test in git format. I'll submit it shortly. -- Configure bugmail: http://bugs.winehq.org/userprefs.cgi?tab=email 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=14855 --- Comment #3 from Austin English <austinenglish(a)gmail.com> 2008-08-13 17:04:16 --- http://www.winehq.org/pipermail/wine-patches/2008-August/059427.html Sent -- Configure bugmail: http://bugs.winehq.org/userprefs.cgi?tab=email 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=14855 --- Comment #4 from Louis Lenders <xerox_xerox2000(a)yahoo.co.uk> 2008-08-20 15:45:40 --- Created an attachment (id=15508) --> (http://bugs.winehq.org/attachment.cgi?id=15508) patch here's a patch that fixes bug. i'll send it to wine-patches -- Configure bugmail: http://bugs.winehq.org/userprefs.cgi?tab=email 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=14855 Austin English <austinenglish(a)gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |patch -- Configure bugmail: http://bugs.winehq.org/userprefs.cgi?tab=email 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=14855 Nikolay Sivov <bunglehead(a)gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bunglehead(a)gmail.com Component|-unknown |user32 -- Configure bugmail: http://bugs.winehq.org/userprefs.cgi?tab=email 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=14855 Austin English <austinenglish(a)gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |download Status|UNCONFIRMED |NEW Ever Confirmed|0 |1 --- Comment #5 from Austin English <austinenglish(a)gmail.com> 2010-05-26 15:55:55 --- Still present. -- Configure bugmail: http://bugs.winehq.org/userprefs.cgi?tab=email 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=14855 Austin English <austinenglish(a)gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #15403|0 |1 is obsolete| | --- Comment #6 from Austin English <austinenglish(a)gmail.com> 2010-05-26 15:56:16 --- Created an attachment (id=28300) --> (http://bugs.winehq.org/attachment.cgi?id=28300) testcase, compiled with mingw -- Configure bugmail: http://bugs.winehq.org/userprefs.cgi?tab=email 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=14855 Nikolay Sivov <bunglehead(a)gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC|bunglehead(a)gmail.com | -- Configure bugmail: http://bugs.winehq.org/userprefs.cgi?tab=email 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=14855 butraxz(a)gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |butraxz(a)gmail.com --- Comment #7 from butraxz(a)gmail.com 2012-05-18 05:43:43 CDT --- This bug has not been updated for two years and OP by four. Is this still an issue i current (1.5.4) or newer wine ? You may also close this as abandoned if you feel that that this is issue is no longer relevant to you. -- Configure bugmail: http://bugs.winehq.org/userprefs.cgi?tab=email 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=14855 Bruno Jesus <00cpxxx(a)gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |00cpxxx(a)gmail.com --- Comment #8 from Bruno Jesus <00cpxxx(a)gmail.com> 2012-05-18 10:15:44 CDT --- Still present in wine 1.5.4. -- Configure bugmail: http://bugs.winehq.org/userprefs.cgi?tab=email 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=14855 --- Comment #9 from Ken Sharp <imwellcushtymelike(a)gmail.com> --- Is this still an issue in Wine 1.7.45 or later? -- 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=14855 super_man(a)post.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |super_man(a)post.com --- Comment #10 from super_man(a)post.com --- wine a.exe Unexpected error, GetLastError() return value: 1407 still valid 1.7.53 -- 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=14855 --- Comment #11 from super_man(a)post.com --- Patch partly applies. patching file dlls/user32/tests/win.c Hunk #1 FAILED at 4789. 1 out of 1 hunk FAILED -- saving rejects to file dlls/user32/tests/win.c.rej patching file dlls/user32/win.c Hunk #1 succeeded at 1958 (offset 345 lines). Hunk #2 succeeded at 1970 (offset 345 lines). wine 1.9.4-git -- 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=14855 super_man(a)post.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |xerox_xerox2000(a)yahoo.co.uk -- 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=14855 winetest(a)luukku.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |winetest(a)luukku.com -- 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=14855 Nikolay Sivov <bunglehead(a)gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|wine-bugs(a)winehq.org |bunglehead(a)gmail.com -- 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=14855 Nikolay Sivov <bunglehead(a)gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|bunglehead(a)gmail.com |wine-bugs(a)winehq.org -- 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=14855 Nikolay Sivov <bunglehead(a)gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|normal |enhancement Status|NEW |NEEDINFO --- Comment #12 from Nikolay Sivov <bunglehead(a)gmail.com> --- This behavior seems to apply to WinXP/2k3/Vista. Newer versions don't set this error. I'm not sure it's a good idea to make it match WinXP. -- 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=14855 joaopa <jeremielapuree(a)yahoo.fr> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jeremielapuree(a)yahoo.fr --- Comment #13 from joaopa <jeremielapuree(a)yahoo.fr> --- Bug still occurs with wine-5.4. -- 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=14855 --- Comment #14 from winetest(a)luukku.com --- Unexpected error, GetLastError() return value: 1407 wine 5.21 -- 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=14855 Anastasius Focht <focht(a)gmx.net> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEEDINFO |NEW CC| |focht(a)gmx.net --- Comment #15 from Anastasius Focht <focht(a)gmx.net> --- Hello folks, quoting from the discussion in https://stackoverflow.com/questions/63512609/findwindow-fails-but-getlasterr... --- quote --- The consensus from the comments seems to be that FindWindow simply doesn't set an error if no window is found (Though other errors do, which I tested). Personally, this seems like pretty misleading documentation, especially as other function in the windows api will set an error code if they fail to do their job, even if no actual errors occur, but I digress. --- quote --- --- quote --- GetLastError does give more information. If it returns ERROR_SUCCESS, it means, that you didn't find a window given your predicate, and this is not the result of an error internal to the API trying to find an answer. --- quote --- Even better: --- quote --- Like I said, it doesn't set an error at all, allowing previous errors to propagate through. I agree now that in the example I gave, the given error did give more info, but it doesn't always, which I think the documentation should specify. --- quote --- --- quote --- Are you saying that if you call SetLastError(42); prior to calling FindWindow (for a predicate that doesn't find a window), the return value is NULL and GetLastError still returns 42? If that is the case, then you should not just propose a documentation change, but also file a defect report. I don't know how to file an API defect report in this day and age, though. --- quote --- --- quote --- @IInspectable Yes, I tested to make sure, any previous errors will propagate though. However I read the docs for GetLastError, which states; "Most functions... ...set it when they fail... ...If the function is not documented to set the last-error code, the value returned by this function is simply the most recent last-error code to have been set". So it seems like this is simply how the windows api works. --- quote --- The whole thread didn't mention the actual Windows version where this behaviour was observed. Maybe Windows 10 but at least Windows 7. I would suggest you focus on Windows 7+ behaviour and don't touch lasterror at all in case the window wasn't found. Extend the tests for lasterror behaviour: https://source.winehq.org/git/wine.git/blob/2ad09b01673381261815bfc804a2f69c... https://source.winehq.org/git/wine.git/blob/2ad09b01673381261815bfc804a2f69c... Fix the lasterror behaviour of FindWindowA() by not setting 'ERROR_CANNOT_FIND_WND_CLASS' which would be consistent with FindWindowW() and -Ex(). https://source.winehq.org/git/wine.git/blob/2ad09b01673381261815bfc804a2f69c... Regards -- 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