Questions tagged [prefast]

PREfast is a static analysis tool that identifies defects in C/C++ programs.

Docs Documentation

15 questions
7
votes
3 answers

Prefast with Visual studio 2008

Is there any way to enable Prefast in Visual Studio 2008 Professional addition? I am trying to compile native c++ code. I have tried following things, Downloaded Windows SDK Set compiler's Bin / Include / Lib paths to the SDK. Added additional…
vrrathod
  • 1,230
  • 2
  • 18
  • 28
6
votes
1 answer

Prefast annotations to fix IRQL level warnings

I am writing a device driver for windows 7 32 bit. I'm using the WDK version 7600.16385.1. So far things are going well, but prefast keeps telling me I'm messing up the IRQL level. In-particular when I try to lock/unlock a shared buffer. I have a…
Daniel Knueven
  • 222
  • 1
  • 11
4
votes
1 answer

Prefast for Visual Studio 2008

Where can I find a download of Prefast for Visual Studio 2008? I am not able find it through Google or the MSDN Website.
Praveen
2
votes
2 answers

PreFast in VS 2010?

Which version of VS 2010 has PreFast static code analyzer for native c++? I have downloaded VS 2010 Ultimate edition trial version in hope that it would contain all the features, but could not found inbuilt PreFast in it. I tried to link VS 2010 to…
Subodh
  • 75
  • 1
  • 10
2
votes
0 answers

Where is a good place to ask questions about PREfast?

Where is a good place to ask questions about PREfast? Clearly there are limitations to PREfast - some which seem silly: it cannot recognize a CString as being const TCHAR * binary compatible). it fails to understand that an if (FooClass const &…
Mordachai
  • 9,412
  • 6
  • 60
  • 112
2
votes
1 answer

Does this pattern work in C++?

I'm running PREfast static code analysis on my our projects, and it is giving me C6001 'using uninitialized memory' errors for this pattern: // AutoSelectGDIObject is a class if (AutoSelectGDIObject & select_image = AutoSelectGDIObject(hDCImgSource,…
Mordachai
  • 9,412
  • 6
  • 60
  • 112
2
votes
0 answers

libcmt.lib delete

Recently we did some big architectural changes (i.e. mutlithreading support) to our cloud print module. Now I have to run a PreFast check on it, but because the current edition of Visual Studio 2008 that we are using does not have integrated PreFast…
Anusha
  • 81
  • 2
2
votes
1 answer

PREfast annotation for structure members

In my company's code we have general get() and set() methods for interop between certain components. However, if I try to run PREfast I get inundated with warnings because PREfast doesn't realize that the get() method initializes the given…
Daniel Rose
  • 17,233
  • 9
  • 65
  • 88
1
vote
0 answers

Log file write error while using Cmake, Ninja, PREFast with MSVC

Turning on the /analyze flag to run PREFast for Windows builds using MSVC non deterministically throws the below error. I think this is because ninja is trying to optimize builds by compiling files from the same target simultaneously but since each…
rstr1112
  • 308
  • 4
  • 13
1
vote
1 answer

How Microsoft SAL can prevent off-by-one error

Here's an example given on MSDN (http://msdn.microsoft.com/en-us/library/hh916383.aspx) that tried to explain SAL annotation could help find a common off-by-one error. wchar_t * wmemcpy( _Out_writes_all_(count) wchar_t *dest, _In_reads_(count)…
Allan Jiang
  • 11,063
  • 27
  • 104
  • 165
0
votes
1 answer

Invalid access of pointer (reading 4 bytes of 0*1) error from PREfast

I'm trying to compile a bit of code that looks something like so: (examples starts on line 38, throw is 45) VSShader::VSShader(_In_ ICore * const pCore, _In_ const String & path, _In_opt_ const char ** ppArgs) : m_Core(pCore), m_Name(path),…
ssube
  • 47,010
  • 7
  • 103
  • 140
0
votes
2 answers

Annotations for NULL Dereference in Prefast and Compiling on GCC

I have the following example code and would like to know what kind of annotations I can use to avoid them. int Function(classA* pInput) { if (pInput == NULL) { classA::Create(pInput); } return pInput->value; } The problem is that…
Setheron
  • 3,520
  • 3
  • 34
  • 52
0
votes
1 answer

Prefast Warning:"Arithmetic Overflow: 32-bit value is shifted, then cast to 64-bit value."

I have declared macros like this: #define F_MASK_4_BIT 0xF #define GET_F_4BIT_MASK(F, P) (((F) & (F_MASK_4_BIT << (P * 4))) >> (4 * P)) using macro like this: uint8_t Feature = GET_F_4BIT_MASK(E, P); Where E is uint64_t datatype P is…
0
votes
3 answers

How to set the output path for native code analysis logs, when running MSBUILD on command line

I build my solution using MSBUILD on command line like this: msbuild %SOLUTION% /m /fl /flp:LogFile="%OUTPUTFILE%" /p:Configuration=%BUILDCONFIG% /p:RunCodeAnalysis=True Having /p:RunCodeAnalysis=True creats code analysis results for both native…
0
votes
1 answer

WDK7: Using IoAttachDeviceToDeviceStack gives "Memory must be held" warning in PREfast

I am using PREFast to check some driver code build for Windows7. The following line of code stackDeviceObject = IoAttachDeviceToDeviceStack(deviceObject, PhysicalDeviceObject); Gives the warning: warning 28107: The Memory 'deviceObject' must be…
giles123
  • 361
  • 7
  • 17