That's a lot of similar checks. Maybe estimate minimal size first and then check once? Also, ntdll function is not tested by itself, and its prototype was not validated as far as I can tell, so it's not possible to tell now where checks should be placed. Maybe having them only in kernelbase function is enough.