<div dir="ltr">Hi Alistair,<div class="gmail_extra"><br><div class="gmail_quote">On Mon, Apr 23, 2018 at 1:06 PM, Alistair Grant <span dir="ltr"><<a href="mailto:akgrant0710@gmail.com" target="_blank">akgrant0710@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"> <br>
Hi Eliot & Vincent,<br>
<span class="gmail-"><br>
On Mon, Apr 23, 2018 at 10:00:12AM -0700, Eliot Miranda wrote:<br>
>  <br>
> Hi Alistair,<br>
> <br>
> <br>
> > On Apr 23, 2018, at 2:46 AM, Alistair Grant <<a href="mailto:akgrant0710@gmail.com">akgrant0710@gmail.com</a>> wrote:<br>
> > <br>
> > <br>
> > Hi Everyone,<br>
> > <br>
> > <br>
> > I have some test code that correctly identifies whether stdin on Windows<br>
> > is a console or redirected, in both windows command terminals (cmd.exe)<br>
> > and cygwin mintty (the current code only works for cmd.exe, not for<br>
> > cygwin terminals).<br>
> > <br>
> > However it relies on the Windows Vista API, i.e. _WIN32_WINNT >=<br>
> > 0x0600, and at the moment we set the minimum supported version to<br>
> > Windows XP (0x0501).<br>
> > <br>
> > Since Windows XP is no longer supported, I can't see any problem with<br>
> > raising the minimum version to Windows Vista (which also isn't<br>
> > supported, but should give us maximum compatibility), but wanted to<br>
> > check first.<br>
> > <br>
> > Are there any objections to raising the minimum API level to Windows<br>
> > Vista?<br>
> <br>
> Not from me.  But it would be nice if the resulting executable still <br>
> ran in Windows NT.  Is that still possible?  What does the code look <br>
> like?<br>
<br>
</span>If we make this change I think the chances of it working on NT are next <br>
to zero.<br>
<br>
Actually, I'd be surprised if the current VM ran on NT since it is <br>
explicitly asking for the XP API, but I haven't tested it.<br>
<br>
The code is available at:<br>
<br>
<a href="https://fossies.org/linux/misc/vim-8.0.tar.bz2/vim80/src/iscygpty.c" rel="noreferrer" target="_blank">https://fossies.org/linux/<wbr>misc/vim-8.0.tar.bz2/vim80/<wbr>src/iscygpty.c</a><br>
<a href="https://fossies.org/linux/misc/vim-8.0.tar.bz2/vim80/src/iscygpty.h" rel="noreferrer" target="_blank">https://fossies.org/linux/<wbr>misc/vim-8.0.tar.bz2/vim80/<wbr>src/iscygpty.h</a></blockquote><div><br></div><div>So if you look at lines 60 through 101 you'll see the standard technique for getting around the version issue:</div><div><br></div><div><div>   60 //#define USE_DYNFILEID</div><div>   61 #ifdef USE_DYNFILEID</div><div>   62 typedef BOOL (WINAPI *pfnGetFileInformationByHandleEx)(</div><div>   63         HANDLE                    hFile,</div><div>   64         FILE_INFO_BY_HANDLE_CLASS FileInformationClass,</div><div>   65         LPVOID                    lpFileInformation,</div><div>   66         DWORD                     dwBufferSize</div><div>   67 );</div><div>   68 static pfnGetFileInformationByHandleEx pGetFileInformationByHandleEx = NULL;</div><div>   69 </div><div>   70 # ifndef USE_FILEEXTD</div><div>   71 static BOOL WINAPI stub_GetFileInformationByHandleEx(</div><div>   72         HANDLE                    hFile,</div><div>   73         FILE_INFO_BY_HANDLE_CLASS FileInformationClass,</div><div>   74         LPVOID                    lpFileInformation,</div><div>   75         DWORD                     dwBufferSize</div><div>   76         )</div><div>   77 {</div><div>   78     return FALSE;</div><div>   79 }</div><div>   80 # endif</div><div>   81 </div><div>   82 static void setup_fileid_api(void)</div><div>   83 {</div><div>   84     if (pGetFileInformationByHandleEx != NULL) {</div><div>   85         return;</div><div>   86     }</div><div>   87     pGetFileInformationByHandleEx = (pfnGetFileInformationByHandleEx)</div><div>   88         GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")),</div><div>   89                 "GetFileInformationByHandleEx");</div><div>   90     if (pGetFileInformationByHandleEx == NULL) {</div><div>   91 # ifdef USE_FILEEXTD</div><div>   92         pGetFileInformationByHandleEx = GetFileInformationByHandleEx;</div><div>   93 # else</div><div>   94         pGetFileInformationByHandleEx = stub_GetFileInformationByHandleEx;</div><div>   95 # endif</div><div>   96     }</div><div>   97 }</div><div>   98 #else</div><div>   99 # define pGetFileInformationByHandleEx  GetFileInformationByHandleEx</div><div>  100 # define setup_fileid_api()</div><div>  101 #endif</div></div><div><br></div><div> </div><div>If USE_DYNFILEID is defined then the code searches kernel32.dll and uses the function if found.  So the safe way to write this is to follow the approach given by USE_DYNFILEID (no need to implement setup_fileid_api; all thats needed is the statements therefore prepended to the use of pGetFileInformationByHandleEx).  If GetFileInformationByHandleEx exists in kernel32.dll use it, otherwise fall back on our existing code.  That way we should be able to keep the Windows XP build level.  People still use it a lot (especially students in poor countries) and I'd rather wait until we can jump forward beyond Vista to make the change ;-) ;-) ;-)</div><div><br></div><div><br></div><div>Does that make sense?  You'll see some of this code in the win32 subsystem already; grep GetProcAddress  platforms/win32/vm/* platforms/win32/plugins/*/*</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><span class="gmail-">
On Mon, Apr 23, 2018 at 05:37:45PM +0000, <a href="mailto:Vincent.Blondeau@lamresearch.com">Vincent.Blondeau@lamresearch.<wbr>com</a> wrote:<br>
>  <br>
> Hi Alistair,<br>
> <br>
> I made some code that have the same goal, but I am also stuck to <br>
> identify the Cygwin and minty terminals, I tried the approach with the <br>
> name of the pipes, but the pipes have always the same name. You can <br>
> take a look at my code there:<br>
> <a href="https://github.com/OpenSmalltalk/opensmalltalk-vm/compare/Cog...VincentBlondeau:addStdoutIsConsolePrimitive" rel="noreferrer" target="_blank">https://github.com/<wbr>OpenSmalltalk/opensmalltalk-<wbr>vm/compare/Cog...<wbr>VincentBlondeau:<wbr>addStdoutIsConsolePrimitive</a><br>
<br>
</span>The vim code does something very similar, but haven't looked closely.<br>
<span class="gmail-"><br>
<br>
> Have you been thinking to another solution?<br>
<br>
</span>No :-)<br>
<span class="gmail-"><br>
<br>
> Which function do you need that is not existing under XP?<br>
<br>
</span>The use of FILE_NAME_INFO and GetFileInformationByHandleEx() requires <br>
Vista (see iscygpty.c above).<br>
<br>
<br>
Cheers,<br>
Alistair<br>
<span class="gmail-"><br>
<br>
<br>
> Thanks,<br>
> <br>
> Cheers,<br>
> Vincent<br>
> <br>
> -----Original Message-----<br>
> From: Vm-dev [mailto:<a href="mailto:vm-dev-bounces@lists.squeakfoundation.org">vm-dev-bounces@lists.<wbr>squeakfoundation.org</a>] On Behalf Of Alistair Grant<br>
> Sent: Monday, April 23, 2018 2:47<br>
> To: Open Smalltalk Virtual Machine Development Discussion <<a href="mailto:vm-dev@lists.squeakfoundation.org">vm-dev@lists.<wbr>squeakfoundation.org</a>><br>
> Subject: [Vm-dev] Raise minimum supported Windows API from XP to Vista (was: Identify console executable and standard one)<br>
> <br>
>  <br>
</span><span class="gmail-">> Hi Everyone,<br>
> <br>
> <br>
> I have some test code that correctly identifies whether stdin on Windows is a console or redirected, in both windows command terminals (cmd.exe) and cygwin mintty (the current code only works for cmd.exe, not for cygwin terminals).<br>
> <br>
> However it relies on the Windows Vista API, i.e. _WIN32_WINNT >= 0x0600, and at the moment we set the minimum supported version to Windows XP (0x0501).<br>
> <br>
> Since Windows XP is no longer supported, I can't see any problem with raising the minimum version to Windows Vista (which also isn't supported, but should give us maximum compatibility), but wanted to check first.<br>
> <br>
> Are there any objections to raising the minimum API level to Windows Vista?<br>
> <br>
> <br>
> <br>
</span>> Thanks,<br>
> Alistair<br>
<br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><span style="font-size:small;border-collapse:separate"><div>_,,,^..^,,,_<br></div><div>best, Eliot</div></span></div></div></div>
</div></div>