From: Rayhan Faizel rayhan.faizel@hotmail.com
--- dlls/ntdll/path.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-)
diff --git a/dlls/ntdll/path.c b/dlls/ntdll/path.c index 3ec5e48d5ca..26228d127e6 100644 --- a/dlls/ntdll/path.c +++ b/dlls/ntdll/path.c @@ -409,19 +409,24 @@ NTSTATUS WINAPI RtlDosPathNameToRelativeNtPathName_U_WithStatus(const WCHAR *dos IO_STATUS_BLOCK io; OBJECT_ATTRIBUTES attr; NTSTATUS ret_rel, nts; - UNICODE_STRING* cur_dir, cur_dir_nt; + UNICODE_STRING *cur_dir, cur_dir_nt; int dos_path_len = wcslen(dos_path);
- WCHAR *converted_path = RtlAllocateHeap(GetProcessHeap(), 0, dos_path_len * sizeof(WCHAR));; + WCHAR *converted_path = RtlAllocateHeap(GetProcessHeap(), 0, (dos_path_len+1) * sizeof(WCHAR));; wcscpy(converted_path, dos_path); - collapse_path(converted_path, 3); + collapse_path(converted_path, 0);
+ if (wcslen(converted_path) == 0) + { + memset(relative,0,sizeof(*relative)); // Collapsed path is empty so don't bother + goto out; + } if (NtCurrentTeb()->Tib.SubSystemTib) /* FIXME: hack */ cur_dir = &((WIN16_SUBSYSTEM_TIB *)NtCurrentTeb()->Tib.SubSystemTib)->curdir.DosPath; else cur_dir = &NtCurrentTeb()->Peb->ProcessParameters->CurrentDirectory.DosPath;
- /* FIXME: Better way besides invoking this function twice? */ + /* FIXME: Better way besides invoking this function twice? Maybe a more direct way of getting current dir in nt path form? */ ret_rel = RtlDosPathNameToNtPathName_U_WithStatus(cur_dir->Buffer, &cur_dir_nt, NULL, NULL); if (ret_rel != STATUS_SUCCESS) goto out; @@ -433,16 +438,21 @@ NTSTATUS WINAPI RtlDosPathNameToRelativeNtPathName_U_WithStatus(const WCHAR *dos attr.SecurityDescriptor = NULL; attr.SecurityQualityOfService = NULL;
+ // Give open directory handle nts = NtOpenFile(&handle, FILE_READ_ATTRIBUTES | SYNCHRONIZE, &attr, &io, - FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, + FILE_SHARE_READ | FILE_SHARE_WRITE, FILE_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT);
if (nts != STATUS_SUCCESS) goto out; + RtlInitUnicodeString(&(relative->RelativeName),converted_path); relative->ContainerDirectory = handle; - // No idea what this does. + + // FIXME: No idea what this does. Some reference count or something? relative->CurDirRef = NULL; + + RtlFreeUnicodeString(&cur_dir_nt); } else {