MINGW-packages/mingw-w64-python-setuptools/0009-launcher-revert-symlink-resolve.patch
2023-08-14 18:16:15 +02:00

22 lines
754 B
Diff

diff --git a/launcher.c b/launcher.c
index 83b487898a..b87cb32ad6 100644
--- a/launcher.c
+++ b/launcher.c
@@ -260,6 +260,16 @@ int run(int argc, char **argv, int is_gui) {
/* compute script name from our .exe name*/
GetModuleFileNameA(NULL, script, sizeof(script));
+ /* resolve final path in case script name is symlink */
+ HANDLE hFile = CreateFile(script,
+ GENERIC_READ,
+ FILE_SHARE_READ,
+ NULL,
+ OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
+ GetFinalPathNameByHandle(hFile, script, 256, VOLUME_NAME_DOS);
+
end = script + strlen(script);
while( end>script && *end != '.')
*end-- = '\0';