Hi Eric, Thanks for taking the time to reply<br><br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
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). </blockquote></div></div></blockquote>
<div><br></div><div>You said... </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
- you're using a bare console, ie didn't run your app under wineconsole, but simply as wine foo.exe</blockquote></div></div></blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
- if so, does running your app under wineconsole provides the same bad effects ?<br></blockquote><div><br></div><div>Correct, I was running wine <testpgm> (Program is attached to bug 32183). I had not tried it under wineconsole but just have. It works (passes) for all 3 test cases, ie read only file i/o, read and r/w CONIN$. (It does give a slightly different GetLastError result to windows for the 4th testcase, which I really dont care about as it is supposed to fail!)). So its really only failing in bare console mode.</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
- another item to test would be to see if writeconsoleinput really enforces the generic_write flag as msdn states<br></blockquote><div><br></div><div>So some tests seem to show on windows:</div><div>- WriteConsoleInput does fail if CONIN$ isnt opened for write</div>
<div>- WriteConsoleInput does not seem to work at all for a handle opened with WriteFile, which I do not understand (Returns gle 3). </div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

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</blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

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<br></blockquote><div><br></div><div> Do you mean TERM_? The only caller to WriteConsoleInput is console.c, and I think the 'guilty' routine is bare_console_fetch_input. I think you are saying that in read_console_input where we determine that it is a bare fd (get_console_bare_fd == -1), we wrap the call to bare_console_fetch_input by reopening the handle with r/w first?  If so, is there any obvious way to do this.. ideally we would want to test for write ability first, but I cant see an API to do that, so I could just open CONIN$ r/w, call bare_console_fetch_input and then close CONIN$ afterwards, is that what you mean? </div>
<div><br></div><div>I tested the following</div><div><div>          HANDLE hConRW = CreateFileA("CONIN$"</div><div>                             , GENERIC_READ | GENERIC_WRITE,</div><div>                             FILE_SHARE_READ, NULL, OPEN_EXISTING,</div>
<div>                             FILE_ATTRIBUTE_NORMAL, 0);</div><div>          if (hConRW == INVALID_HANDLE_VALUE) hConRW = handle;</div><div>          ret = bare_console_fetch_input(hConRW, fd, timeout);</div><div>          if (hConRW!=handle) CloseHandle(hConRW);</div>
</div><div><br></div><div>It works a charm, although feels inefficient for the times handle was already r/w - (it feels slightly odd that the 'handle' we are working on is unrelated to the handle passed in (I was worried about stdin redirection, but that seems to work fine even after the change).</div>
<div><br></div><div>Was this what you meant or have I gone off on a tangent?</div><div><br></div><div>Jason</div></div><br>