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

Raj kumar Kamsani 1 Reputation point
2021-03-31T09:09:49.707+00:00

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 Performance
Windows Hardware Performance
Windows: A family of Microsoft operating systems that run across personal computers, tablets, laptops, phones, internet of things devices, self-contained mixed reality headsets, large collaboration screens, and other devices.Hardware Performance: Delivering / providing hardware or hardware systems or adjusting / adapting hardware or hardware systems.
1,541 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Doron Holan 1,801 Reputation points
    2021-03-31T21:50:10.477+00:00

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