<div class="gmail_quote">
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div><br>> so it would make more sense to simply let WriteConsoleW fail when<br>> is_console_handle(hConsoleOutput) is FALSE ?<br>> (similar functions as WriteConsoleA, ReadConsoleA/W should be protected<br>> the same way)<br>
<br></div>Currently only three APIs in console.c check is_console_handle():<br>VerifyConsoleIoHandle(), DuplicateConsoleHandle() and<br>CloseConsoleHandle(). That could certainly be extended to others and<br>things even seems to work if I add a simple 'if<br>
(!is_console_handle(hConsoleOutput)) return FALSE;' at the start of<br>WriteConsoleW().<br><br></blockquote>
<div>then that's the correct way to fix it</div>
<div> </div>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">One could then rip out the code in the WriteFile() branch but I'm not<br>sure what the consequences of all this would be or why the WriteFile()<br>
case was added in the first place. The author of that code would<br>probably know better than me<g>.<br></blockquote>
<div>no, the WriteFile stuff must be kept</div></div>
<div> </div>
<div>basically, we need to handle three cases (h being the handle passed to WriteConsole)</div>
<div>C1/ h isn't a console handle (ie lower bits not set) => fail (return FALSE)</div>
<div>C2/ h is a console handle, and removing the lower bits we have a handle to a console object in wine server => call wineserver</div>
<div>C3/ h is a console handle, and removing the lower bits we have a handle to a file object in wine server => call WriteFile => ...</div>
<div> </div>
<div>you get :</div>
<div>- C1 when output is redirected to a file/pipe...</div>
<div>- C2 when running wineconsole net.exe</div>
<div>- C3 when running wine net.exe</div>
<div><br>note that we're playing with handles, and hidding behind console handles (with lower bit sets) handles to other objects...</div>
<div>(in fact, from your first post, there is no infinite loop as the calls are made on different objects)</div>
<div> </div>
<div>you can safely provide the patches with protecting WriteConsole and friends with a if (!is_console_handle(???)) return FALSE; line</div>
<div> </div>
<div>A+<br>-- <br>Eric Pouech<br></div>