3
我在使用Boyer-Moore algorithm的内核驱动程序中进行了字符串匹配,但我也需要实现基本的通配符支持。 This answer on SO提到功能FsRtlIsNameInExpression
,这看起来恰好符合我的需求。它甚至看起来像处理Unicode字符串的大小写不敏感。FsRtlIsNameInExpression从不匹配任何内容
但它甚至不能让它匹配一个简单的字符串与自己。
我尝试了一些事情,但FsRtlIsNameInExpression从不匹配任何东西。这里是我用来测试的一些代码(我在DriverEntry
程序结尾处拨打MyTest
)。
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
}
为了记录在案:
- 我使用WDK版本7600.16385.1,在虚拟盒检查版本(我的代码,而不是Windows)
- 的驱动程序运行托管的Windows 7专业版64在我的Windows 7旗舰版64位位
- 司机被测试证书签名
- 我跟踪代码的内核调试器
- 代码不会崩溃,但不能在用户模式下调用
什么是显而易见的我失踪?
另一个证明,墨菲在深夜潜伏!它的工作原理是,我能够将'J'aidéjàtestéçaet j'aidétestéça'与'* TE?TÉ*'相匹配。 – ixe013
很高兴为您服务! J'adore le code,et il vous aimera en retour。 Détestele code,et il vousdétestele dos。 –