Hello,<div><br></div><div>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. </div>
<div><br></div><div>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:</div><div>Opens the device ("\\.\CON") with CreateFile with GENERIC_READ rights (which internally opens a CONIN$ device with the same access rights)</div>
<div>Reads from the device with ReadFile</div><div>- Because its a console device, this drops through to ReadConsoleW, which creates a CONOUT$ and then waits on a keystroke</div><div>- Once the key is pressed (WCEL_Get) the key is 'inserted' into the input buffer by calling WriteConsoleInputW</div>
<div><br></div><div>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.</div>
<div><br></div><div>Now on windows, this works... the question is how to make it work on wine... </div><div><br></div><div>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!</div>
<div><br></div><div>Thanks for any help!  I'll file a bug with my analysis and testcase, but would rather fix the thing!</div><div><br></div><div>Jason</div><div><br></div><div><br></div><div><br></div><div><br></div>