Regex library

Hi,

Does anyone know a Windows-Kernel-Development-Friendly regular expression library?

I don’t need advanced features like back references or class matching (they tend to use tables and will make the driver size big) but I can do things like adding unicode support.

Did some lookup but C++ libraries usually depends on std and C ones seems not fully tested.

Thanks,
Mauro.

What about T-Rex?
https://github.com/kimperator/T-Rex

It is written in quite portable manner (Linux/Windows) and AFAIK have no dependencies except C runtime library (which works quite well in kernelmode too). Of course, you need to port the library for the kernel land (and test it there) but it should not take you long to achieve that.

Hi @“Martin_Dráb”, I saw it but seems it has issues.

Thanks.

Any chance of redesigning the code so that the regex can be done in user mode? I wouldn’t trust trying to jam anything that complicated into kernel mode. If I can’t do it with FsRtlIsNameInExpression then I usually try to find another way around…

Hi @“Scott_Noone_(OSR)”, how are you?

Honestly I prefer to avoid it. Currently I have a simple wildcard matcher to match * and ? but I would like to match ** like Linux to match if a file is inside a folder or a subfolder but seems it is not straightforward to implement.

Kind regards,
Mauro.

Very well, thanks for asking! Back to school season around here so things are always a bit crazy…

I don’t have a generic solution to your problem (and I’m Linux illiterate), but if you’re looking for prefix matching there’s RtlPrefixUnicodeString.

And, in case it’s interesting, I was also recently made aware of a prefix matching package available in kernel mode. See RtlInitializeUnicodePrefix as a jumping off point for more info (have not ever used it so I have no practical experience to share).

Very well, thanks for asking! Back to school season around here so things are always a bit crazy…

Good to hear.

I don’t have a generic solution to your problem (and I’m Linux illiterate), but if you’re looking for prefix matching there’s RtlPrefixUnicodeString.

I’ll try to create some code. That double star addition was a simple and great idea.