Welcome to MSDN Blogs Sign in | Join | Help

Customizing a Microsoft Auto Code Review (OACR) Project

Microsoft Auto Code Review (known by the acronym OACR) integrates PREfast for Drivers (PFD) into the WDK build environment and is available when you install the latest WDK for Windows 7. OACR automatically begins working when you open a build environment window, so you can start using OACR and PFD without any special setup.

Side note- the name game

When you expand the acronym OACR it should spell Microsoft Auto Code Review. For some reason, and I won’t mention names, it was inadvertently converted to Windows Auto Code Review in earlier documentation. Go figure. This oversight has been corrected and the expanded name will appear as it should in future documentation. I apologize for any confusion this mix-up might have caused.

OACR configuration files

OACR uses two configuration files OACR.ini and OACRUser.ini to set preferences and to configure projects. Projects are your build targets, that is, a project is whatever driver or library you are building with the WDK build utility. The names of projects are determined by the directory where you are building and settings in the configuration file, OACR.ini, and by the projects.mk file. The OACRuser.ini file can be used by individuals to override the project settings in the OACR.ini configuration file. The location of the OACRUser.ini file is specified by the UserIniLocation setting in the OACR.ini file. The default setting in the WDK is as follows:

UserIniLocation=%BASEDIR%\config\ 

If you want to use an OACRUser.ini file, you will need to create the file and the %BASEDIR% \config directory. The file and the directory are not provided when you install the WDK. The %BASEDIR% is the root directory of your WDK installation (for example, C:\WinDDK\7600\).

OACR projects in the WDK

In the WDK, OACR is configured for two projects: WDKsamples and Root. The WDKsamples project settings are used any time you build something under the %BASEDIR% of WDK (for example, C:\WinDDK\7600\). The Root project is the default build project and is used for anything built outside of the WDK directory structure (for example, C:\myproj\src).

Creating a private project using a custom include file

You can add your own projects to the default OACR configuration file, as described in Creating or Modifying an OACR Project. However, if you want to create a private project and you don’t want to add it to the OACR.ini file, you can set up and environment variable and point to an include file. The settings in the include file are then added to OACR.ini. Wait! What about the OACRUser.ini configuration file? Why can’t you use that? Well, the OACRUser.ini file is used to override the project settings in the OACR.ini configuration file and cannot be used to add projects. Here is how you go about creating a private project.

1. Shutdown the OACR Monitor

Right click the OACR Monitor icon in the taskbar and click Close. Or type oacr stop in a build environment window. Close any build environment window you have open. You need to stop OACR and close the windows so that OACR can pick up the changes you will make in the following steps.

2. Set the environment variable OACRUserFIles

Edit the System Properties on your computer and create the OACRUserFIles environment variable. Set the variable to point to a directory where you will create and store your private OACR project configuration file.

set OACRUserFIles=c:\myOACRprojects

3. Add the #include directive to the OACR.ini file

The OACR.ini file is in the %BASEDIR%\version\bin\arch\OACR directory. Add the following line at the end of the file:

#include optional %OACRUserFiles%\oacr.include.ini

The oacr.include.ini file is optional, so OACR does not complain if it doesn’t exist.

4. Create the include file and define your OACR projects

Create the oacr.include.ini file in the %OACRUserFIles% directory. This include file is where you define your private OACR projects. For example, the following settings in the oacr.include.ini file create a project called MyProject.

; project 'myProject': the code under src; relies on %OACRUserFIles%\project.mk
[MyProject]
; WarningLocations=^%BASEDIR%\\src
WarningNumbers=<level0>;<level1>;<level2>;<level3_PFD_samples>;
ErrorNumbers=<level0>;<level1>;
; Use PFD's settings for these
PREfastOptions=/MAXPATHS=256 /STACKHOGTHRESHOLD=1024
%_PREFAST_CYCLOMATIC%=2147483647
%PREFAST_DRIVERS%=0
[MyProject:x86] 
[MyProject:x86fre] 
[MyProject:x86chk]
[MyProject:amd64] 
[MyProject:amd64fre] 
[MyProject:amd64chk]

5. Create a project.mk file in the target project directory

Just as with any new OACR project that you add to the OACR.ini file, you need to create a project.mk file and place that in the root directory of your source files. For more information, see Creating or Modifying an OACR Project . The project.mk file for MyProject, would look like this:

_project_=MyProject

6. Restart the OACR Monitor

Open a new build environment window to start OACR. You need to open a new build environment window so that your %OACRUserFIles% environment variable is used. When OACR starts up it reads the oacr.include.ini file and treats its content as if it were part of Oacr.ini.

7. Verify that your OACR project is configured correctly

In a build environment window, use the oacr checkini command to verify that your configuration files are set up correctly.  You should see something similar to the following:

c:\WinDDK\7138.0.0>oacr checkini
 
Configuration : C:\WinDDK\7138.0.0\bin\x86\OACR\oacr.ini
   Includes   : C:\WinDDK\7138.0.0\bin\oacr_base.ini
                C:\MyOACRProjects\oacr.include.ini
   Defines    : x86
Customizations: C:\WinDDK\7138.0.0\config\oacruser.ini
 
No problems found
 

Use the oacr showconfig project command to verify that OACR can successfully read your project settings.

oacr showconfig MyProject

If your project is set up correctly, OACR shows the project configuration.

Note that you can also use the OACR commands oacr stop and oacr monitor to stop and start OACR. These commands are useful if you need to make changes to fix problems in the configuration files.

8. Build your driver or library

After you have verified that your OACR project is setup correctly, you can build your driver or library just as you are accustomed to doing. You only need to open a build environment window and navigate to you build target directory. OACR will use all of your project-specific settings.

What Next?

There is a lot you can do to customize the build environment and your OACR and PFD settings. But the good news is you don’t have to. You can build your driver code just as you always have and still benefit from the integration of OACR in the WDK build environment.

To learn more, read the documentation about Microsoft Auto Code Review (OACR) and PREfast for Drivers (PFD) and check for new information in the monthly updates on MSDN. Also see the Static Driver Tools blog, it provides a wealth of information about using and customizing the static analysis tools, including PFD and Static Driver Verifier. A recent blog posting describes the steps to create a “Static Driver Verifier Prerequisites” filter. For more information, see Make Static Driver Verifier More Efficient: Add a Preset Filter to PFD/OACR Defect Viewer .

  -- Dave Hagen [MSFT], Programming Writer

Published Friday, July 10, 2009 10:09 PM by wdkblog

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

Friday, July 10, 2009 6:25 PM by alanfeld

# re: Customizing a Microsoft Auto Code Review (OACR) Project

The feedback form at http://blogs.msdn.com/wdkdocs/contact.aspx submits one's e-mail but the e-mail winds up getting rejected saying that wdkblog@microsoft.com is an unknown user.

Cheers,

 Alan

Friday, July 10, 2009 6:25 PM by alanfeld

# re: Customizing a Microsoft Auto Code Review (OACR) Project

Dave,

Thanks for the explanation of the OACR acronym but ... it still doesn't explain what the "O" stands for ... ;-)

If the name was originally "Windows Auto Code Review" shouldn't the acronym have been WACR?

Just curious what the "O" stands for ... ;-)

Cheers,

 Alan

Friday, July 10, 2009 7:24 PM by Don Burn

# re: Customizing a Microsoft Auto Code Review (OACR) Project

OACR has more options than one can imagine and no documetation on any of these options.  The lack of documentation along with the default behavior that was setup by the WDK are probably the biggest reasons most of the experienced driver developers I know detest the tool.

It the doc team doing anything to fix the docuemtation for this tool.

Thursday, July 23, 2009 9:59 PM by Dave Hagen [MSFT]

# re: Customizing a Microsoft Auto Code Review (OACR) Project

Thanks for your comments. Yes, we are working on an update to the OACR documentation that will include a command and reference section and that should help address some of the short comings. The updated documentation will appear in our next MSDN refresh (coming soon).

You are absolutely right about the number of OACR options. There are a ton of them. However, this can be a good thing. Using the OACR options and the commands you should be able to set up an environment so that OACR does what you want and expect. What would help us, however, is if you could let us know what it is you are trying to do. One of the first things we documented was how to turn OACR off! (oacr set off) Not the ideal solution for any of us, but a scenario that we needed to cover. Hearing from you helps. So whatever it is, send us feedback and let us know what you are interested in or would like to see documented. Thanks!

P.S. Good question about the "O" in OACR! I don't want to spoil a mystery. Some say it comes from the "O" in Microsoft.  But which one, you might ask.

Friday, July 24, 2009 8:58 AM by don burn

# re: Customizing a Microsoft Auto Code Review (OACR) Project

On what people want every one is different.  For instance, I do a "prefast build" followed by a "prefast list" and my only complaint is that if I need to switch projects I loose the data from the prefast for the first project.  Ive been told that OACR can theoretically fix that.  I do not want any delay, in the reporting of prefast list since I view a warning from prefast the same as an error from the compiler

Note, I don't like prefast view and I detest popups, so these are some of the reasons I can't stand the default actions of OACR.  

Friday, July 24, 2009 2:44 PM by Dave Hagen [MSFT]

# re: Customizing a Microsoft Auto Code Review (OACR) Project

OK. Thank you for the feedback. You can give this try to see if it works for you. To duplicate the PFD behavior with OACR, you will need to make some changes to the OACR.ini file(s), or use the command line to over-ride the default settings.

In the OACR.ini file, make sure you have the following project default settings:

CheckWhen=compile

FilesToCheck=all

ErrorNumbers=

The ErrorNumbers setting needs to be empty because error-level defects will break the build when CheckWhen=compile. Although, you might want to leave it as it is so that you are forced to deal with those errors. If you use the default settings, OACR runs as a background process (CheckWhen=daemon) and adds minimal overhead to the build. Setting this to compile will add to the build time, pretty much as if you were to run prefast build –cz.

You could also use the oacr set commands to set the first two options:

oacr set compile

oacr set all

Then run your build command (build –cz)

To display the warnings (if any), use the command: oacr list <project:flavor>

For example:  oacr list WDKSamples:x86chk

If you configure separate projects for your build targets, you will be able to switch back and forth to view the warning logs.

Saturday, July 25, 2009 1:50 PM by alanfeld

# re: Customizing a Microsoft Auto Code Review (OACR) Project

Ohhh that's ... strange ... about the "O" coming from "Microsoft" ... but thanks anyway. So I guess you did spoil the mystery -- but mysteries are meant to be spoiled. ;-) Cheers.

Friday, August 07, 2009 1:08 PM by zhzhtst

# re: Customizing a Microsoft Auto Code Review (OACR) Project

In fact, OACR stands for "Office Auto Code Review".

Friday, August 07, 2009 7:05 PM by alanfeld

# re: Customizing a Microsoft Auto Code Review (OACR) Project

Ohhh ... thanks zhzhtst! You're right! I see now that the OACR was in fact referred to as "Office Auto Code Review" in the description of a session at the Microsoft Windows Driver Developer Conference 2008 titled "Using Static Analysis Tools When Developing Drivers - DDE-T690" presented by Adam Shapiro. Interestingly enough, inside his PowerPoint presentation he then refers to it as "Microsoft Auto Code Review" as that appears to be the tool's official name now.

Anyway OACR == Office Auto Code Review ... now THAT makes much more sense as to what the acronym originally stood for. Thanks for the info zhzhtst! :-)

Sunday, August 09, 2009 4:24 PM by don burn

# re: Customizing a Microsoft Auto Code Review (OACR) Project

With the release version of OACR being especially obnoxious since OACR STOP now only stops OACR until you build again, coule we please get real documentation?

I know it is not the documentation teams fault since they are always the last in the process and management demands the schedule be met (I've managed documetors in my past), but OACR documentation is at present worthless.  There is no way to understand what the tool can do, and how to configure it as we will be comfortable.  We need a comprehensive guide not 3 pages as are currently present.

Leave a Comment

(required) 
required 
(required) 

  
Enter Code Here: Required
 
Page view tracker