From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin-patches@cygwin.com
Subject: Re: [PATCH 1/2] Treat Windows Store's "app execution aliases" as symbolic links
Date: Mon, 15 Mar 2021 20:52:33 +0100 [thread overview]
Message-ID: <YE+7ATqy4vJdHAp7@calimero.vinschen.de> (raw)
In-Reply-To: <nycvar.QRO.7.76.6.2103121611440.50@tvgsbejvaqbjf.bet>
Hi Johannes,
I'm not opposed to treat these applinks as symlinks. I have a
suggestion and a style nit, though.
On Mar 12 16:11, Johannes Schindelin via Cygwin-patches wrote:
> When the Windows Store version of Python is installed, so-called "app
> execution aliases" are put into the `PATH`. These are reparse points
> under the hood, with an undocumented format.
>
> We do know a bit about this format, though, as per the excellent analysis:
> https://www.tiraniddo.dev/2019/09/overview-of-windows-execution-aliases.html
>
> The first 4 bytes is the reparse tag, in this case it's
> 0x8000001B which is documented in the Windows SDK as
> IO_REPARSE_TAG_APPEXECLINK. Unfortunately there doesn't seem to
> be a corresponding structure, but with a bit of reverse
> engineering we can work out the format is as follows:
>
> Version: <4 byte integer>
> Package ID: <NUL Terminated Unicode String>
> Entry Point: <NUL Terminated Unicode String>
> Executable: <NUL Terminated Unicode String>
> Application Type: <NUL Terminated Unicode String>
Given we know this layout, what about introducing a matching struct,
like I did for REPARSE_LX_SYMLINK_BUFFER, for instructional purposes?
I. e.
typedef struct _REPARSE_APPEXECLINK_BUFFER
{
DWORD ReparseTag;
WORD ReparseDataLength;
WORD Reserved;
struct {
DWORD Version; /* Take member name with a grain of salt. */
WCHAR Strings[1]; /* Four serialized, NUL-terminated WCHAR strings:
- Package ID
- Entry Point
- Executable Path
- Application Type
We're only interested in the Executable Path */
} AppExecLinkReparseBuffer;
} REPARSE_APPEXECLINK_BUFFER,*PREPARSE_APPEXECLINK_BUFFER;
> + else if (!remote && rp->ReparseTag == IO_REPARSE_TAG_APPEXECLINK)
> + {
> + /* App execution aliases are commonly used by Windows Store apps. */
> + WCHAR *buf = (WCHAR *)(rp->GenericReparseBuffer.DataBuffer + 4);
Analogue:
PREPARSE_APPEXECLINK_BUFFER rpl = (PREPARSE_APPEXECLINK_BUFFER) rp;
WCHAR *buf = rpl->AppExecLinkReparseBuffer.Strings;
Maybe use 'str' or 'strp' here, instead of buf?
> + for (int i = 0; i < 3 && size > 0; i++)
> + {
> + n = wcsnlen (buf, size - 1);
> + if (i == 2 && n > 0 && n < size)
> + {
> + RtlInitCountedUnicodeString (psymbuf, buf, n * sizeof(WCHAR));
^^^
space
Thanks,
Corinna
prev parent reply other threads:[~2021-03-15 19:52 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-12 15:11 Johannes Schindelin
2021-03-12 17:03 ` Joe Lowe
2021-03-14 0:21 ` Johannes Schindelin
2021-03-14 3:41 ` Joe Lowe
2021-03-15 3:19 ` Johannes Schindelin
2021-03-15 19:04 ` Hans-Bernhard Bröker
2021-03-22 15:22 ` Johannes Schindelin
2021-03-22 21:54 ` Hans-Bernhard Bröker
2021-03-23 9:30 ` Corinna Vinschen
2021-03-24 18:55 ` Hans-Bernhard Bröker
2021-03-24 20:58 ` Ken Brown
2021-03-26 1:29 ` Hans-Bernhard Bröker
2021-03-15 10:17 ` Corinna Vinschen
2021-03-15 19:52 ` Corinna Vinschen [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=YE+7ATqy4vJdHAp7@calimero.vinschen.de \
--to=corinna-cygwin@cygwin.com \
--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).