Skip to content

Commit b848716

Browse files
committed
app: fix Windows app-path resolution
Fix another bug in how we compute the Application Executable path on Windows. It some cases we can still get a relative/non-absolute path to the entry executable. If we get a filename/non-path from the native API calls then return null and fallback to using process/module image resolution instead. For .NET Framework on Windows, this is OK. We will want to revisit this on .NET (Core) on Windows, if and when we get around to that...
1 parent f2d6ceb commit b848716

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/shared/Core/PlatformUtils.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,11 @@ private static string GetWindowsEntryPath()
289289
IntPtr argv0Ptr = Marshal.ReadIntPtr(argvPtr);
290290
string argv0 = Marshal.PtrToStringAuto(argv0Ptr);
291291
Interop.Windows.Native.Kernel32.LocalFree(argvPtr);
292-
return argv0;
292+
293+
// If this isn't absolute then we should return null to prevent any
294+
// caller that expect only an absolute path from mis-using this result.
295+
// They will have to fall-back to other mechanisms for getting the entry path.
296+
return Path.IsPathRooted(argv0) ? argv0 : null;
293297
}
294298

295299
#endregion

0 commit comments

Comments
 (0)