Implement and export RtlGetLengthWithoutTrailingPathSeperators (aka. RtlGetLengthWithoutTrailingPathSeparators) (needed for win2k3's basesrv.dll).
Patch by David Quintana, where I simplified the loop (and reduced the number of local variables).
CORE-7482 #comment Function committed in revision 60348, thanks ;)

svn path=/trunk/; revision=60348
This commit is contained in:
Hermès Bélusca-Maïto 2013-09-24 22:16:30 +00:00
parent 655b467d9a
commit 8c96a4e9a2
3 changed files with 52 additions and 1 deletions

View file

@ -630,7 +630,7 @@
@ stdcall RtlGetLastWin32Error()
@ stdcall RtlGetLengthWithoutLastFullDosOrNtPathElement(long ptr ptr)
; Yes, Microsoft really misspelled this one!
;@ stdcall RtlGetLengthWithoutTrailingPathSeperators
@ stdcall RtlGetLengthWithoutTrailingPathSeperators(long ptr ptr) RtlGetLengthWithoutTrailingPathSeparators
@ stdcall RtlGetLongestNtPathLength()
@ stdcall RtlGetNativeSystemInformation(long long long long) NtQuerySystemInformation
@ stdcall RtlGetNextRange(ptr ptr long)

View file

@ -2725,6 +2725,15 @@ RtlGetFullPathName_UstrEx(
_Out_opt_ PSIZE_T LengthNeeded
);
NTSYSAPI
NTSTATUS
NTAPI
RtlGetLengthWithoutTrailingPathSeparators(
_In_ ULONG Flags,
_In_ PCUNICODE_STRING PathString,
_Out_ PULONG Length
);
NTSYSAPI
ULONG
NTAPI

View file

@ -1251,6 +1251,48 @@ RtlGetLongestNtPathLength(VOID)
return MAX_PATH + RtlpDosDevicesUncPrefix.Length / sizeof(WCHAR) + sizeof(ANSI_NULL);
}
/*
* @implemented
* @note: the export is called RtlGetLengthWithoutTrailingPathSeperators
* (with a 'e' instead of a 'a' in "Seperators").
*/
NTSTATUS
NTAPI
RtlGetLengthWithoutTrailingPathSeparators(IN ULONG Flags,
IN PCUNICODE_STRING PathString,
OUT PULONG Length)
{
ULONG NumChars;
/* Parameters validation */
if (Length == NULL) return STATUS_INVALID_PARAMETER;
*Length = 0;
if (PathString == NULL) return STATUS_INVALID_PARAMETER;
/* No flags are supported yet */
if (Flags != 0) return STATUS_INVALID_PARAMETER;
NumChars = PathString->Length / sizeof(WCHAR);
/*
* Notice that we skip the last character, therefore:
* - if we have: "some/path/f" we test for: "some/path/"
* - if we have: "some/path/" we test for: "some/path"
* - if we have: "s" we test for: ""
* - if we have: "" then NumChars was already zero and we aren't there
*/
while (NumChars > 0 && IS_PATH_SEPARATOR(PathString->Buffer[NumChars - 1]))
{
--NumChars;
}
*Length = NumChars;
return STATUS_SUCCESS;
}
/*
* @implemented
*/