Hello everybody,
I use the mentioned function (FsRtlIsNameInExpression) in my minifilter to actually filter out some files that match some wildcard expressions, but I need case insensitive comparing.
The function works as it should if both the ExpressionParameter and Name are uppercase.
BOOLEAN FsRtlIsNameInExpression(
__in PUNICODE_STRING Expression,
__in PUNICODE_STRING Name,
__in BOOLEAN IgnoreCase,
__in_opt PWCH UpcaseTable
);
The Expression parameter, I already have in memory, and it is upper case, and I don’t want for performance reasons to perform an upcase to the Name string for the function to work correctly, for each IRP_MJ_CREATE for example.
I have read what I could on the internet about the UpcaseTable, and as far as I can tell if I provide the function with an upcasetable, than I won’t need to upper case the Name parameter as it would use the UpcaseTable for this. There is also another reason why I want to use this, and that is because the function RtlUpcaseUnicodeChar, does not work correctly for one of my country characters, this one: ‘?’ the upper version being of course ‘?’ , and RtlUpcaseUnicodeChar(‘?’) returns ‘?’ not ‘?’ . I don’t know if this is a bug or not, if that were not the case then what I want to create two different files on my computer called “?_test.txt” and “?_test.txt” I get an error, file already exists, so I am guessing that the file system somehow sees the uppser case version of ‘?’ is ‘?’ but RtlUpcaseUnicodeChar does not work, and RtlUpcaseUnicodeString as well. The funny thing is that for characters like ‘?’ or ‘?’ it works fine (the upcase functions I mean).
My current understanding is that the upcase table should the form of
UpcaseTable[‘a’] = ‘A’ am I right ?
This is one of the things that I am not sure about.
I have the upcase table of the size: 0x10000, as I see the declaration of FsRtlAreNamesEqual, gives me a hint on the size.
#if (NTDDI_VERSION >= NTDDI_WIN2K)
__checkReturn
__drv_maxIRQL(PASSIVE_LEVEL)
NTKERNELAPI
BOOLEAN
FsRtlAreNamesEqual (
__in PCUNICODE_STRING ConstantNameA,
__in PCUNICODE_STRING ConstantNameB,
__in BOOLEAN IgnoreCase,
__in_ecount_opt(0x10000) PCWCH UpcaseTable
);
#endif
I let almost all the characters in the table by the form of
UpcaseTable[‘*’] = ‘*’
UpcaseTable[‘%’] = ‘%’
except for letters ‘a’ to ‘z’ and other latin letters.
and for my special characters ‘?’ and ‘?’ .
The bad part is that FsRtlIsNameInExpression still fails to work. I am sure that I am doing something wrong. Maybe someone else used this, or has stumbled upon this.
Can you give me any tips on how can I make FsRtlIsNameInExpression work with an UpcaseTable ?
Thank you.