Commit Graph
10 Commits
Author SHA1 Message Date
Hermès Bélusca-Maïto a46e1e96ec [BOOTDATA][CMAKE][MKSHELLLINK] Improve shell link shortcuts creation for the LiveImage (#8936)
CORE-15156, CORE-19691, CORE-19692

Finally get rid of the livecd_start.cmd hack introduced waaaay back
in commit ff6d7b0236 (r54514)!
See also commits ea682b6909 (r54512) and 71867403fd (r54513).

For target paths, use the shell "special shell folder" syntax:
`shell:windows\...` or `shell:system\...`, introduced in commit
7b081be46d (PR #7158) by Whindmar Saksit.

Specify an explicit icon path and index for the "Read Me.lnk" shortcut.

Includes ideas from PR #7154 by Katayama Hirofumi MZ.

The generated shell links are confirmed to work on ReactOS, but also on
Windows 2003 and Windows 7.

- Change the MKSHELLLINK icon parameter syntax to be: `-i [icon_path[,nr]]`
  where, either both `icon_path` and icon index are given, separated by
  a comma ',' , or, either the `icon_path` is given but the index is
  optional (default: 0), or, only the icon index is given, in which case
  the icon path is set to the target instead.

- Use a `VERBATIM` command-line for `add_custom_command()`, so that *nix
  builds can cope with parameters containing backslashes.

- The shortcut target path, working directory, command-line arguments,
  and icon path all may specify explicit Win32 environment variables
  (like `%SystemRoot%`, `%HOMEDRIVE%`, etc.). Because these environment
  variables are specified as data given to the build tool via CMake,
  **AND** we have to workaround keeping these variables unexpanded when
  they are transmitted to the tool via CMD.EXE (on builds made on Windows),
  specify these variables in an "escaped" format, using `^%` instead:
  `^%SystemRoot^%`, etc.
  Additionally these paths may be explicitly quoted and passed that way
  to the MKSHELLLINK tool.

  In order to deal with both unquoting the strings and unescaping the
  environment variables, introduce a helper function and invoke them on
  the aforementioned strings.
2026-05-13 22:16:07 +02:00
Hermès Bélusca-Maïto bc70254ad9 [MKSHELLLINK] Add a verbose mode for diagnostics, disabled by default (#8936) 2026-05-13 22:16:06 +02:00
Hermès Bélusca-Maïto af0cb55edb [MKSHELLLINK] Support link target and icon paths containing environment variables (#8936)
CORE-15156, CORE-19691, CORE-19692

- When specifying a "special shell folder" in the shortcut target,
  e.g.: `shell:windows\system32\cmd.exe` , or: `shell:system\cmd.exe`,
  resolve it using a ReactOS-specific path, but also use a version
  using unexpanded environment variables: for both examples,
  `%SystemRoot%\system32\cmd.exe`

- Whenever the shortcut target or the icon path contains unexpanded
  environment variables, add associated `EXP_SZ_LINK` data blocks.

- Use the previously-introduced ANSI-to-UTF16 `my_mbstowcs()` routine
  to convert the ANSI strings to Unicode for the `EXP_SZ_LINK` data blocks.
2026-05-13 22:16:05 +02:00
Hermès Bélusca-Maïto e505a8dbaa [MKSHELLLINK] Support creating Unicode-aware shortcuts (#8936)
Support the creation of shortcuts that can use Unicode versions of
their name (description), relative path, working directory, command-
line arguments, and icon location.
This option can be selected at runtime with a switch.

Additionally:

- Ensure that `wchar_t` is 16-bit wide.

- Introduce and use a "poor-man" ANSI-to-UTF16LE `my_mbstowcs()` routine
  to convert the ANSI strings, for the Unicode scenario mentioned above.
  We cannot use the host mbstowcs() routine, since on *nix systems the
  iconv library being used may have been compiled with a 32-bit `wchar_t`
  (even if the tool is compiled with: `-fshort-wchar -fwide-exec-charset=UTF-16LE`),
  as this is the case with the GitHub actions build bots.
2026-05-13 22:16:04 +02:00
Hermès Bélusca-Maïto b36fd06b70 [MKSHELLLINK] Don't care about the DOS name of PIDL path elements (#8936)
Keep the old code just for reference purposes.
2026-05-13 22:16:03 +02:00
Hermès Bélusca-Maïto d6f4c0887a [MKSHELLLINK] Fix a bug in the special shell folder handling code (#8936)
Addendum to commit 7b081be46d (PR #7158).

CORE-15156, CORE-19691, CORE-19692

Since commit 7b081be46d (PR #7158), one can create shell links that
point to a file in a subdirectory of SystemRoot (e.g. X:\reactos) or
SystemRoot\system32 using a shell "special shell folder" syntax, for
example:
  `shell:windows\Readme.txt` (--> X:\reactos\Readme.txt) ,
  `shell:windows\system32\cmd.exe` , or:
  `shell:system\cmd.exe` (--> X:\reactos\system32\cmd.exe) .

An `EXP_SPECIAL_FOLDER` data block allows parts of a shortcuts pidl
to be overridden by such a special folder.

- In these cases, try to build the shortcut pidl such that it faithfully
  mirrors the intended path. For example, when using `shell:system\cmd.exe`,
  resolve the `shell:system` part to `X:\reactos\system32` instead of
  just `X:\reactos` ; this helps understanding what happens when
  spelunking into such a shell link. This also helps when converting
  such a path to one containing unexpanded environment variables, for
  the purposes of making the Windows explorer shell show the correct
  shortcut target path, or resolve it independently of the SystemRoot
  being used; and, to be able to use the path for the shortcut icon.

- Get rid of the `index`/`specialindex` variables.
  These were used for making the `EXP_SPECIAL_FOLDER` data block point
  to the correct path suffix part that follows the special path prefix
  in the ID list.

  Hardcoding its value caused problems when the special path prefix is
  made to contain more path elements than just "X:\reactos". For example,
  "X:\reactos\system32" in the case of the `shell:system` prefix.
  Instead, retrieve the length of the special path prefix, then, compare
  it with the length of the path elements being parsed in the loop.

  ----

  This problem was made explicit when the the following code path is run:
  ```
  shell32!CShellLink.cpp:CShellLink::Load(IStream *stm)
  --> ILCombine(folder, m_pPidl + pSpecial->cbOffset)
  ```
2026-05-13 22:16:03 +02:00
Hermès Bélusca-Maïto 55092de280 [MKSHELLLINK] Enhance the code (#8936)
- Use the `bool` type from `stdbool.h`

- Update "Specification" URL, using instead the
  "[MS-SHLLINK]: Shell Link (.LNK) Binary File Format"

- Document which structures in `undocshell.h` correspond to those
  in MKSHELLLINK.

- Add `SLDF_*` constants from PSDK `shlobj.h` for consumption, and
  alias the tool-specific `LINK_*` ones to these.

- The first member of the `LNK_HEADER`/`SHELL_LINK_HEADER` structure
  is not a signature, but its size.
  Fix the `FILETIME` fields ordering. The `IconIndex` member is signed.
  The `HotKey` member is a 16-bits value.

- The third member of the `ID_LIST_GUID`/`tagGUIDStruct` structure is
  not "dummy", but is a sort-order. Add also some known corresponding
  values, and unhardcode the value used in the code.

- Make the `is_path_separator()` return a `bool`, and use the helper
  more thoroughly in the code.

- Improve the help/usage text shown by the tool.

- In case an invalid/unknown argument is encountered, set the `bHelp`
  flag just after showing the error, so as to display the tool usage
  and bail out early.

- Improve/clarify some code comments.

- Update the file header notice.
2026-05-13 22:16:02 +02:00
Whindmar Saksit 7b081be46d [SHELL32][MKSHELLLINK] Support EXP_SPECIAL_FOLDER datablock in shortcuts (#7158)
CORE-19692
2024-09-14 13:10:49 +02:00
Timo Kreuzer f47f45dbdd [TOOLS] Fix/suppress all MSVC/x64 warnings (#1525) 2019-04-28 23:21:48 +02:00
Colin Finck c2c66aff7d Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys. 2017-10-03 07:45:34 +00:00