sys: FspFileNameCompare, FspFileNameIsPrefix

This commit is contained in:
Bill Zissimopoulos 2016-10-14 16:01:05 -07:00
parent 32c289fa34
commit 5a5a1008de
3 changed files with 20 additions and 2 deletions

View File

@ -631,7 +631,7 @@ PVOID FspFsvolDeviceEnumerateContextByName(PDEVICE_OBJECT DeviceObject, PUNICODE
0, 0, NextFlag, &RestartKey->RestartKey, &RestartKey->DeleteCount, &FileName); 0, 0, NextFlag, &RestartKey->RestartKey, &RestartKey->DeleteCount, &FileName);
if (0 != Result && if (0 != Result &&
RtlPrefixUnicodeString(FileName, Result->FileName, CaseInsensitive) && FspFileNameIsPrefix(FileName, Result->FileName, CaseInsensitive, 0) &&
FileName->Length < Result->FileName->Length && FileName->Length < Result->FileName->Length &&
'\\' == Result->FileName->Buffer[FileName->Length / sizeof(WCHAR)]) '\\' == Result->FileName->Buffer[FileName->Length / sizeof(WCHAR)])
return Result->Context; return Result->Context;
@ -699,7 +699,7 @@ static RTL_GENERIC_COMPARE_RESULTS NTAPI FspFsvolDeviceCompareContextByName(
PUNICODE_STRING SecondFileName = *(PUNICODE_STRING *)SecondElement; PUNICODE_STRING SecondFileName = *(PUNICODE_STRING *)SecondElement;
LONG ComparisonResult; LONG ComparisonResult;
ComparisonResult = RtlCompareUnicodeString(FirstFileName, SecondFileName, CaseInsensitive); ComparisonResult = FspFileNameCompare(FirstFileName, SecondFileName, CaseInsensitive, 0);
if (0 > ComparisonResult) if (0 > ComparisonResult)
return GenericLessThan; return GenericLessThan;

View File

@ -436,6 +436,21 @@ enum
BOOLEAN FspFileNameIsValid(PUNICODE_STRING Path, PUNICODE_STRING StreamPart, PULONG StreamType); BOOLEAN FspFileNameIsValid(PUNICODE_STRING Path, PUNICODE_STRING StreamPart, PULONG StreamType);
BOOLEAN FspFileNameIsValidPattern(PUNICODE_STRING Pattern); BOOLEAN FspFileNameIsValidPattern(PUNICODE_STRING Pattern);
VOID FspFileNameSuffix(PUNICODE_STRING Path, PUNICODE_STRING Remain, PUNICODE_STRING Suffix); VOID FspFileNameSuffix(PUNICODE_STRING Path, PUNICODE_STRING Remain, PUNICODE_STRING Suffix);
#if 0
LONG FspFileNameCompare(
PUNICODE_STRING Name1,
PUNICODE_STRING Name2,
BOOLEAN IgnoreCase,
PCWCH UpcaseTable);
BOOLEAN FspFileNameIsPrefix(
PCUNICODE_STRING Name1,
PCUNICODE_STRING Name2,
BOOLEAN IgnoreCase,
PCWCH UpcaseTable);
#else
#define FspFileNameCompare(N1,N2,I,U) (ASSERT(0 == (U)), RtlCompareUnicodeString(N1,N2,I))
#define FspFileNameIsPrefix(N1,N2,I,U) (ASSERT(0 == (U)), RtlPrefixUnicodeString(N1,N2,I))
#endif
NTSTATUS FspFileNameInExpression( NTSTATUS FspFileNameInExpression(
PUNICODE_STRING Expression, PUNICODE_STRING Expression,
PUNICODE_STRING Name, PUNICODE_STRING Name,

View File

@ -211,6 +211,9 @@ NTSTATUS FspFileNameInExpression(
{ {
PAGED_CODE(); PAGED_CODE();
/* we do not support non-NULL UpcaseTable yet */
ASSERT(0 == UpcaseTable);
try try
{ {
*PResult = FsRtlIsNameInExpression(Expression, Name, IgnoreCase, UpcaseTable); *PResult = FsRtlIsNameInExpression(Expression, Name, IgnoreCase, UpcaseTable);