question

RajkumarKamsani-2294 avatar image
0 Votes"
RajkumarKamsani-2294 asked RoyLi-MSFT edited

How to generate error or warning, if C/C++ run time libraries used driver

I have sample driver code, and in some part of the code sprintf() and other C/C++ functions are being used and compiler is not generated error as I included ntstrsafe.h header file in the project.


Currently sprintf() has been replaced with RtlStringCchPrintfA as suggested from MSDN docs, but I would like to generate the warning/error if such functions are being used in kernel space. How to do that. Please let me know.

windows-hardware-wdk
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

DoronHolan avatar image
0 Votes"
DoronHolan answered RajkumarKamsani-2294 commented

If the code compiles /kernel and in the links properly WDK build environment, the API itself is supported (underneath the covers, RtlSTringcchPrintfA calls _vsnprintf).

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hello DoroanHolan,

Thanks for the update. But my requirement is to add a check in compiler to avoid these library functions usage.(sprintf()). Is there any way to do that?

0 Votes 0 ·