symlink fix

This commit is contained in:
DavidXanatos 2024-04-28 15:19:13 +02:00
parent 18a6535bac
commit f5070bbe81
2 changed files with 16 additions and 3 deletions

View File

@ -558,7 +558,7 @@ _FX WCHAR* File_TranslateNtToDosPath2(const WCHAR *NtPath)
WCHAR *DosPath = NULL;
ULONG len_nt;
len_nt = wcslen(NtPath) + 11;
len_nt = wcslen(NtPath) + 16;
DosPath = Dll_Alloc(len_nt * sizeof(WCHAR));
wcscpy(DosPath, NtPath);

View File

@ -3353,9 +3353,19 @@ _FX NTSTATUS File_SetReparsePoint(
//TargetPath = Dll_Alloc((wcslen(CopyPath) + 4) * sizeof(WCHAR));
//wcscpy(TargetPath, CopyPath);
WCHAR* NewSubstituteNameBuffer = NULL;
WCHAR* OldPrintNameBuffer = PrintNameBuffer; // we don't need to change the display name
if (Data->ReparseTag) {
SubstituteNameLength = wcslen(CopyPath) * sizeof(WCHAR);
NewSubstituteNameBuffer = File_TranslateNtToDosPath2(CopyPath);
memmove(NewSubstituteNameBuffer + 4, NewSubstituteNameBuffer, (wcslen(NewSubstituteNameBuffer) + 1) * sizeof(wchar_t)); // File_TranslateNtToDosPath2 alocates 16 extry chars for such cases
wcsncpy(NewSubstituteNameBuffer, L"\\??\\", 4);
} else
NewSubstituteNameBuffer = CopyPath;
SubstituteNameLength = wcslen(NewSubstituteNameBuffer) * sizeof(WCHAR);
NewDataLen += SubstituteNameLength + sizeof(WCHAR) + PrintNameLength + sizeof(WCHAR) + 8;
NewData = Dll_Alloc(NewDataLen);
@ -3385,9 +3395,12 @@ _FX NTSTATUS File_SetReparsePoint(
PrintNameBuffer = &NewData->MountPointReparseBuffer.PathBuffer[NewData->MountPointReparseBuffer.PrintNameOffset/sizeof(WCHAR)];
}
memcpy(SubstituteNameBuffer, CopyPath, SubstituteNameLength + sizeof(WCHAR));
memcpy(SubstituteNameBuffer, NewSubstituteNameBuffer, SubstituteNameLength + sizeof(WCHAR));
memcpy(PrintNameBuffer, OldPrintNameBuffer, PrintNameLength + sizeof(WCHAR));
if (Data->ReparseTag)
Dll_Free(NewSubstituteNameBuffer);
} __except (EXCEPTION_EXECUTE_HANDLER) {
status = GetExceptionCode();
}