@@ -1224,7 +1224,21 @@ pub fn GetFinalPathNameByHandle(
1224
1224
// TODO find out if a path can start with something besides `\Device\<volume name>`,
1225
1225
// and if we need to handle it differently
1226
1226
// (i.e. how to determine the start and end of the volume name in that case)
1227
- if (! mem .eql (u16 , expected_prefix , final_path [0.. expected_prefix .len ])) return error .Unexpected ;
1227
+ if (! mem .eql (u16 , expected_prefix , final_path [0.. expected_prefix .len ])) {
1228
+ // Wine seems to return NT namespaced paths from QueryObjectName
1229
+ // (e.g. `\??\Z:\some\path\to\a\file.txt`), in which case we can just strip the
1230
+ // prefix to turn it into an absolute path
1231
+ if (getNamespacePrefix (u16 , final_path ) == .nt ) {
1232
+ const unprefixed_path = final_path [4.. ];
1233
+ // TODO: Handle other possible path types, only drive absolute has been observed so far
1234
+ if (getUnprefixedPathType (unprefixed_path ) != .drive_absolute ) {
1235
+ return error .Unexpected ;
1236
+ }
1237
+ mem .copyForwards (u16 , out_buffer [0.. unprefixed_path .len ], unprefixed_path );
1238
+ return out_buffer [0.. unprefixed_path .len ];
1239
+ }
1240
+ return error .Unexpected ;
1241
+ }
1228
1242
1229
1243
const file_path_begin_index = mem .indexOfPos (u16 , final_path , expected_prefix .len , &[_ ]u16 {'\\ ' }) orelse unreachable ;
1230
1244
const volume_name_u16 = final_path [0.. file_path_begin_index ];
0 commit comments