Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash when starting from non ASCII path #8

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Sylmir
Copy link

@Sylmir Sylmir commented Dec 28, 2024

This fixes a crash that occurs when the launcher is started from a folder whose absolute path does contain non ASCII characters. This was due to the use of the WshRuntimeLibrary (a wrapper around COM libraries) that does not handle Unicode (as far as my deductions go). When assigning the target path to the shortcut object, the runtime would error.

This commit replaces the WshRuntimeLibrary with a COM wrapper around the IShellLink interface, using its Unicode oriented functions.

The WshRuntimeLibrary is removed from dependencies and the .NET framework is updated to 4.8 as 4.0 has reached EOL.

Tested on: Win10 64-bits.

Warning: The code is taken from https://stackoverflow.com/a/14632782 As you can see from the comments, some people argue this does not work on all versions of Windows, possibly something tied to 32 / 64 bits. Further testing on other Win versions and archs is probably required

@@ -8,9 +8,10 @@
<OutputType>WinExe</OutputType>
<RootNamespace>UniversalTombLauncher</RootNamespace>
<AssemblyName>launch</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We cannot upgrade the version to 4.8 as this launcher is intended to work on systems as far back as Windows XP and on Windows 7 without having to manually install .NET 4, as it comes preinstalled with the system.

This fixes a crash that occurs when the launcher is started from a
folder whose absolute path does contain non ASCII characters. This
was due to the use of the WshRuntimeLibrary (a wrapper around COM
libraries) that does not handle Unicode (as far as my deductions
go). When assigning the target path to the shortcut object, the
runtime would error.

This commit replaces the WshRuntimeLibrary with a COM wrapper around
the IShellLink interface, using its Unicode oriented functions.

The WshRuntimeLibrary is removed from dependencies and the .NET
framework is updated to 4.8 as 4.0 has reached EOL.

Tested on: Win10 64-bits.
@Sylmir Sylmir force-pushed the sylmir/fix_shortcut_unicode branch from 036e218 to 37d1176 Compare December 31, 2024 12:22
@Sylmir
Copy link
Author

Sylmir commented Dec 31, 2024

Updated. Windows won't let me install .NET 4.0 because I already have 4.8 (or later) installed, so I cannot check for sure if it even builds, hope for the best (it built and ran successfully with 4.8, I don't think there's any reason it wouldn't build or run with 4.0, but who knows...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants