diff --git a/lib/std/debug/SelfInfo.zig b/lib/std/debug/SelfInfo.zig index 544cf0ac6ff4..7f07ea1e8b0e 100644 --- a/lib/std/debug/SelfInfo.zig +++ b/lib/std/debug/SelfInfo.zig @@ -1003,7 +1003,7 @@ fn readCoffDebugInfo(allocator: Allocator, coff_obj: *coff.Coff) !Module { di.dwarf = dwarf; } - const raw_path = try coff_obj.getPdbPath() orelse return di; + const raw_path = (coff_obj.getPdbPath() catch return error.InvalidDebugInfo) orelse return di; const path = blk: { if (fs.path.isAbsolute(raw_path)) { break :blk raw_path; diff --git a/lib/std/os/windows.zig b/lib/std/os/windows.zig index ceed0618d1f1..d3123500219d 100644 --- a/lib/std/os/windows.zig +++ b/lib/std/os/windows.zig @@ -1292,6 +1292,18 @@ pub fn GetFinalPathNameByHandle( return final_path; }, .Dos => { + // The "\??\" directory contains a bunch of symlinks that translates DOS volume names (like "C:") + // into NT volume names (like "\Device\HarddiskVolume2"). However, we want the DOS volume name, so + // we can just strip the "\??\" and return the subpath into that directory. + // + // Based on: + // - this stackoverflow post https://stackoverflow.com/questions/23041983/path-prefixes-and + // - downloading the WinObj program and inspecting the contents of "\??\" + const nt_device_alias_directory_prefix = std.unicode.utf8ToUtf16LeStringLiteral("\\??\\"); + if (mem.startsWith(u16, final_path, nt_device_alias_directory_prefix)) { + return final_path[nt_device_alias_directory_prefix.len..]; + } + // parse the string to separate volume path from file path const expected_prefix = std.unicode.utf8ToUtf16LeStringLiteral("\\Device\\");