PEVerify Tool (peverify.exe)

The PEVerify tool helps developers who generate common intermediate language (CIL), such as compiler writers, script engine developers, and so forth, to determine whether their CIL code and associated metadata meet type safety requirements.

The application file for the PEVerify tool is named peverify.exe in the Shared Source CLI (SSCLI) when on Microsoft Windows®.

Some compilers generate verifiably type-safe code only if you avoid using certain language constructs. If, as a developer, you are using such a compiler, you might want to verify that you have not compromised the type safety of your code. In this situation, you can run the PEVerify tool on your files to check the CIL and metadata.

Usage

peverify filename [/md] [/il] [/break=maxErrorCount]
[/hresult] [/ignore= hex.code] [/ignore=@responseFile]
[/unique] [/quiet]
Argument Description
filename The portable executable (PE) file for which to check the CIL and metadata.

Options

Options can be specified using either a dash ('-') or a slash ('/').

Option Description
/break=maxErrorCount Aborts verification after maxErrorCount errors.
/clock Measures and reports the following verification times in milliseconds:
  • MD Val. cycle
    • Metadata validation cycle
  • MD Val. pure
    • Metadata validation pure
  • IL Ver. cycle
    • Common intermediate language (CIL) verification cycle
  • IL Ver pure
    • CIL verification pure

The MD Val. cycle and IL Ver. cycle times include the time required to perform necessary startup and shutdown procedures. The MD Val. pure and IL Ver pure times reflect the time required to perform the validation or verification only.

/help Displays command syntax and options for the tool.
/hresult Displays error codes in hexadecimal format.
/ignore=hex.code [, hex.code] Ignores the specified error codes.
/ignore=@responseFile Ignores the error codes listed in the specified response file.
/il Performs CIL type safety verification checks for methods implemented in the assembly specified by filename. The tool returns detailed descriptions for each problem found unless you specify the /quiet option.
/md Performs metadata validation checks on the assembly specified by filename. This walks the full metadata structure within the file and reports all validation problems encountered.
/quiet Specifies quiet mode; suppresses output of the verification problem reports. The PEVerify tool still reports whether the file is type safe, but does not report information on problems preventing type safety verification.
/unique Ignores repeating error codes.
/? Displays command syntax and options for the tool.

Remarks

The common language runtime relies on the type-safe execution of application code to enforce security and isolation mechanisms. Normally, code that is not verifiably type safe cannot run, although you can set security policy to allow the execution of trusted but unverifiable code.

If neither the /md nor /il options are specified, the PEVerify tool performs both types of checks. The PEVerify tool performs /md checks first. If there are no errors, /il checks are made. If you specify both /md and /il, /il checks are made even if there are errors in the metadata. Thus, if there are no metadata errors,

peverify filename

is equivalent to:

peverify filename /md /il.

The PEVerify tool performs comprehensive CIL verification checks based on dataflow analysis plus a list of several hundred rules on valid metadata.

Examples

The following command performs metadata validation checks and CIL type safety verification checks for methods implemented in the assembly myAssembly.exe.

peverify myAssembly.exe /md /il

Upon successful completion of the above request, the PEVerify tool displays the following message.

All classes and methods in myAssembly.exe Verified

The following command performs metadata validation checks and CIL type safety verification checks for methods implemented in the assembly myAssembly.exe. The tool displays the time required to perform these checks.

peverify myAssembly.exe /md /il /clock

Upon successful completion of the above request, the PEVerify tool displays the following message.

All classes and methods in myAssembly.exe Verified
Timing: Total run     320 msec
        MD Val.cycle  40 msec
        MD Val.pure   10 msec
        IL Ver.cycle  270 msec
        IL Ver.pure   230 msec

The following command performs metadata validation checks and CIL type safety verification checks for methods implemented in the assembly myAssembly.exe. the PEVerify tool stops, however, when it reaches the maximum error count of 100. The tool also ignores the specified error codes.

peverify myAssembly.exe /break=100 /ignore=0x12345678,0xABCD1234

The following command produces the same result as the previous example, but specifies the error codes to ignore in the response file ignoreErrors.rsp.

peverify myAssembly.exe /break=100 /ignore@ignoreErrors.rsp

The response file can contain a comma-separated list of error codes.

0x12345678, 0xABCD1234

Alternatively, the response file can be formatted with one error code per line.

0x12345678
0xABCD1234
See Also

Tools Index


Copyright (c) 2006 Microsoft Corporation. All rights reserved.