http://bugs.winehq.org/show_bug.cgi?id=32183
Bug #: 32183 Summary: Cannot open console device read only, then read from it to get input Product: Wine Version: 1.5.17 Platform: x86 OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: kernel32 AssignedTo: wine-bugs@winehq.org ReportedBy: us@edmeades.me.uk Classification: Unclassified
Created attachment 42462 --> http://bugs.winehq.org/attachment.cgi?id=42462 CON test program (source and exe)
(Email sent to wine-devel for assistance, but logging bug to track issue in case I do not get anywhere)
CreateFile("\.\CON", GENERIC_READ...) followed by ReadFile(...) works on windows and fails on wine. I need this particular sequence of events to work in order for a patch I have for cmd.exe to support CON input 'nicely' (read 'without hacks').
For simplicity sake I've cut this down to a tiny test program, which works on windows and fails on wine which does the following:
Opens the device ("\.\CON") with CreateFile with GENERIC_READ rights (which internally opens a CONIN$ device with the same access rights) Reads from the device with ReadFile - Because its a console device, this drops through to ReadConsoleW, which creates a CONOUT$ and then waits on a keystroke - Once the key is pressed (WCEL_Get) the key is 'inserted' into the input buffer by calling WriteConsoleInputW
The issue is that WriteConsoleInputW requires GENERIC_WRITE access, but the CON device (\.\CON) was opened as GENERIC_READ (and in fact fails if I try to open it with GENERIC_WRITE). CreateFile("CONIN$"...) will let me open in GENERIC_READ/GENERIC_WRITE mode and the program works on both windows and wine, but if you open CONIN$ GENERIC_READ only then it fails on wine and works on windows, with the same issue.
Now on windows, this works... the question is how to make it work on wine...
My gut feeling, with nothing backing this at all, is that WCEL_Get should not use WriteConsoleInputW to inject the values into the input buffer, instead making the server call directly, but passing through to the server call something to indicate that it is ok to add the data to the buffer, but I'm fast getting out of my depth!
How to reproduce: Compile sample source (exe provided in zip)...
Run as: "test 1" - this is the one I need to work... \.\CON GENERIC_READ case "test 2" - this is a similar problem but opens CONIN$ GENERIC_READ "test 3" - this works on both windows and wine, opening CONIN$ GENERIC_READ|GENERIC_WRITE "test 4" - this fails on both windows and wine as you cannot open CON device with WRITE access
Except for case 4, When its 'failing' - when you press a key in wine, it exits. When its 'working' it reads from keyboard, echos to screen until ctrl+Z (crtl+D on wine) is pressed and ends
http://bugs.winehq.org/show_bug.cgi?id=32183
Jason Edmeades us@edmeades.me.uk changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords| |testcase
http://bugs.winehq.org/show_bug.cgi?id=32183
Austin English austinenglish@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords| |download
http://bugs.winehq.org/show_bug.cgi?id=32183
Jason Edmeades us@edmeades.me.uk changed:
What |Removed |Added ---------------------------------------------------------------------------- Blocks| |16214
http://bugs.winehq.org/show_bug.cgi?id=32183
Jason Edmeades us@edmeades.me.uk changed:
What |Removed |Added ---------------------------------------------------------------------------- AssignedTo|wine-bugs@winehq.org |us@edmeades.me.uk
http://bugs.winehq.org/show_bug.cgi?id=32183
Julian Rüger jr98@gmx.net changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |jr98@gmx.net
https://bugs.winehq.org/show_bug.cgi?id=32183
Ken Sharp imwellcushtymelike@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords| |source
--- Comment #1 from Ken Sharp imwellcushtymelike@gmail.com --- Is this still an issue in Wine 1.7.45 or later?
https://bugs.winehq.org/show_bug.cgi?id=32183
super_man@post.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |super_man@post.com
--- Comment #2 from super_man@post.com --- wine test 1 CON device path:\.\CON CON test, read only Done
wine test 2 CON device path:\.\CON CONIN test, read only Done
wine test 3 CON device path:\.\CON CONIN test, read/write only
Terminating process 2f on event 0 (didnt wait too long?)
wine test 4 CON device path:\.\CON CON test, read/write only Failed to open, 2
wine 1.9.12
Conclusion?
https://bugs.winehq.org/show_bug.cgi?id=32183
Jason Edmeades us@edmeades.me.uk changed:
What |Removed |Added ---------------------------------------------------------------------------- Assignee|us@edmeades.me.uk |wine-bugs@winehq.org
https://bugs.winehq.org/show_bug.cgi?id=32183
Jacek Caban jacek@codeweavers.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |jacek@codeweavers.com
--- Comment #3 from Jacek Caban jacek@codeweavers.com --- This is fixed in git for consoles backed use conhost (pseudo and unix consoles). In those cases, ReadConsole is implemented in conhost and kernel32 only does one ioctl requiring read access. It will be fixed for console windows when they are migrated to conhost.
https://bugs.winehq.org/show_bug.cgi?id=32183
--- Comment #4 from Jacek Caban jacek@codeweavers.com --- The original problem with access rights is fixes for a while in Wine (calls that were previously problematic are internal to conhost.exe, which does the right thing). However, the test showed another problem with path handling, which is likely a regression. I sent a patch for the remaining problem: https://source.winehq.org/patches/data/222786
https://bugs.winehq.org/show_bug.cgi?id=32183
Jacek Caban jacek@codeweavers.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Fixed by SHA1| |32b81bfaff734164143343657bb | |40ea4e2c073e0 Resolution|--- |FIXED Status|NEW |RESOLVED
--- Comment #5 from Jacek Caban jacek@codeweavers.com --- This is fixed in git: https://source.winehq.org/git/wine.git/?a=commit;h=32b81bfaff734164143343657...
https://bugs.winehq.org/show_bug.cgi?id=32183
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #6 from Alexandre Julliard julliard@winehq.org --- Closing bugs fixed in 7.0-rc4.
https://bugs.winehq.org/show_bug.cgi?id=32183
Michael Stefaniuc mstefani@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|--- |6.0.x
https://bugs.winehq.org/show_bug.cgi?id=32183
Michael Stefaniuc mstefani@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|6.0.x |---
--- Comment #7 from Michael Stefaniuc mstefani@winehq.org --- Removing the 6.0.x milestone from bug fixes included in 6.0.4.