[Bug 32183] New: Cannot open console device read only, then read from it to get input

wine-bugs at winehq.org wine-bugs at winehq.org
Fri Nov 9 15:58:42 CST 2012


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 at winehq.org
        ReportedBy: us at 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

-- 
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.



More information about the wine-bugs mailing list