Any advice please... Console input issue

Eric Pouech eric.pouech at orange.fr
Sun Nov 11 07:09:58 CST 2012


Le 09/11/2012 22:49, Ann and Jason Edmeades a écrit :
> Hello,
>
> I've been looking at a patch which sorts out NUL and CON handling in a 
> part of the command shell, and have stumbled upon a problem I am not 
> sure how to fix because I really dont understand the underlying 
> console handling, and would appreciate someone pointing me in a 
> direction.
>
> 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!
>
> Thanks for any help!  I'll file a bug with my analysis and testcase, 
> but would rather fix the thing!
>
> Jason
>
>
>
>
from your (partial) explanation, I assume that :
- you're using a bare console, ie didn't run your app under wineconsole, 
but simply as wine foo.exe
- if so, does running your app under wineconsole provides the same bad 
effects ?
- another item to test would be to see if writeconsoleinput really 
enforces the generic_write flag as msdn states

but, for a bare handle, we have to convert unix console keystrokes into 
win32 keycodes, so we need to feed the keycodes into wine server

if we really have to enforce generic_write, then we should wrap for 
TERM_ functions the calls to writeconsoleinput with a helper that 
reopens the console with the right mode
A+



More information about the wine-devel mailing list