From: Takashi Yano <takashi.yano@nifty.ne.jp>
To: cygwin-patches@cygwin.com
Subject: Re: [PATCH] Cygwin: termios: Refactor the function is_console_app().
Date: Mon, 28 Aug 2023 20:53:49 +0900 [thread overview]
Message-ID: <20230828205349.5e88f193446048e42337685b@nifty.ne.jp> (raw)
In-Reply-To: <ZOx911vVsEZOgfgI@calimero.vinschen.de>
On Mon, 28 Aug 2023 12:58:31 +0200
Corinna Vinschen wrote:
> On Aug 28 18:21, Takashi Yano wrote:
> > Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
> > ---
> > winsup/cygwin/fhandler/termios.cc | 18 ++++++++----------
> > 1 file changed, 8 insertions(+), 10 deletions(-)
> >
> > diff --git a/winsup/cygwin/fhandler/termios.cc b/winsup/cygwin/fhandler/termios.cc
> > index 789ae0179..d106955dc 100644
> > --- a/winsup/cygwin/fhandler/termios.cc
> > +++ b/winsup/cygwin/fhandler/termios.cc
> > @@ -704,22 +704,20 @@ static bool
> > is_console_app (const WCHAR *filename)
> > {
> > HANDLE h;
> > - const int id_offset = 92;
> > h = CreateFileW (filename, GENERIC_READ, FILE_SHARE_READ,
> > NULL, OPEN_EXISTING, 0, NULL);
> > char buf[1024];
> > DWORD n;
> > ReadFile (h, buf, sizeof (buf), &n, 0);
> > CloseHandle (h);
> > - char *p = (char *) memmem (buf, n, "PE\0\0", 4);
> > - if (p && p + id_offset < buf + n)
> > - return p[id_offset] == '\003'; /* 02: GUI, 03: console */
> > - else
> > - {
> > - wchar_t *e = wcsrchr (filename, L'.');
> > - if (e && (wcscasecmp (e, L".bat") == 0 || wcscasecmp (e, L".cmd") == 0))
> > - return true;
> > - }
> > + /* The offset of Subsystem is the same for both IMAGE_NT_HEADERS32 and
> > + IMAGE_NT_HEADERS64, so only IMAGE_NT_HEADERS32 is used here. */
> > + IMAGE_NT_HEADERS32 *p = (IMAGE_NT_HEADERS32 *) memmem (buf, n, "PE\0\0", 4);
>
> Please use PIMAGE_NT_HEADERS instead and just drop the comment.
> We don't support 32 bit anyway.
This function is used for determining whether a non-cygwin
app is console app or not. Even in 64-bit cygwin, 32-bit
non-cygwin app can be executed. So we should support both
32-bit and 64-bit binary.
However, using IMAGE_NT_HEADERS may be better. Thanks.
--
Takashi Yano <takashi.yano@nifty.ne.jp>
prev parent reply other threads:[~2023-08-28 11:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-28 9:21 Takashi Yano
2023-08-28 10:58 ` Corinna Vinschen
2023-08-28 11:53 ` Takashi Yano [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230828205349.5e88f193446048e42337685b@nifty.ne.jp \
--to=takashi.yano@nifty.ne.jp \
--cc=cygwin-patches@cygwin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).