says that the function requires PASSIVE_LEVEL irql. But I don't understand why such a simple function needs to be at PASSIVE_LEVEL. Are there any alternatives that can be called at DISPATCH_LEVEL?
Of course, every buffer im using is nonpaged memory.
This could have been overaggressive editing. I know that many of the functions that work with Unicode strings are PASSIVE_LEVEL because the Unicode/ANSI translation tables are pageable, but that wouldn't apply to a ...A function.
If you are worried about it, you can write your own version of this function in something like 10 lines of code.
And since the source is NUL terminated (the length is not known in advance), and reading the very next byte could trigger an access violation, the optimizations that are possible are limited. Probably there will be no significant difference between what the compiler makes for you versus whatever Microsoft has created & optimized
no need to write your own version, copy the source from the header. But as previously said, the annotation is over aggressive and better to ignore/suppress it.