FsRtlIsNameInExpression never matches anything

I am matching strings in the kernel driver using the Boyer-Moore algorithm , but I also need to implement basic wildcard support. This answer to SO mentions a function FsRtlIsNameInExpressionthat looks right for my needs. It even looks like it handles case insensitivity for Unicode strings.

But he can't even get him to match a simple string with himself.

I tried a few things, but FsRtlIsNameInExpression never matches anything. Here is the code I used for testing (I put a call MyTestat the end of my routine DriverEntry).

NTSTATUS MyTest()
{
    int matches = 0;

    UNICODE_STRING a3times;
    UNICODE_STRING A5times;
    UNICODE_STRING bbb;
    UNICODE_STRING patterna;
    UNICODE_STRING patternb;

    RtlInitUnicodeString(&a3times, L"aaa");
    RtlInitUnicodeString(&A5times, L"AAAAA");
    RtlInitUnicodeString(&bbb, L"bbb");

    RtlInitUnicodeString(&patterna, L"a*a");
    RtlInitUnicodeString(&patternb, L"b*");

    if(FsRtlIsNameInExpression(&patterna, &a3times, TRUE, 0)) 
        ++matches;            // a*a should match aaa

    if(FsRtlIsNameInExpression(&patterna, &A5times, FALSE, 0))
        ++matches;            // a*a should match (insensitive) AAAAA

    if(FsRtlIsNameInExpression(&a3times, &a3times, TRUE, 0))
        ++matches;            //aaa should match aaa

    if(FsRtlIsNameInExpression(&patternb, &bbb, TRUE, 0))
        ++matches;            //b* should match bbb

    return matches;   //Should be 4, but is 0
}

For the record:

  • WDK- 7600.16385.1, ( , Windows)
  • , 64- 64- Windows 7 Pro 64- Windows 7 Ultimate.
  • ,

, ?

+3
1

IgnoreCase TRUE, Expression .

, . IgnoreCase CaseSensitive.

:

  • IgnoreCase, TRUE -
  • , IgnoreCase FALSE, -
  • IgnoreCase, TRUE -
  • IgnoreCase, TRUE -

, :)

+1

All Articles