Appendix E - Offline Verification Tool Reference

Appendix E

Offline Verification Tool Reference

An offline verification tool for managed PE files, PEVerify.exe, is distributed with the Microsoft .NET Framework SDK. The tool includes two components: the metadata validator, MDValidator, and the IL verifier, ILVerifier.

MDValidator works on the module level, running validity checks of the metadata of a specified managed module (PE file). It does not matter whether the specified module is a prime module or an auxiliary. If the specified module is a prime module of an assembly, MDValidator does not automatically check other modules of the same assembly.

ILVerifier works on the assembly level, loading the assembly in full in memory, resolving internal references, and verifying the IL code of the methods contained in the assembly. Consequently, ILVerifier fails if the specified PE file is not the prime module of the assembly.

The result of this discrepancy in the approaches taken by MDValidator and ILVerifier is that only single-module assemblies can be fully validated and verified in one pass of the verification tool.

The PEVerify tool sets the exit code to 1 if errors are found during the PE file verification and sets the code to 0 otherwise.

The command-line format is as follows:

peverify <PE_file> [<option>*]

Unlike the IL Assembler and the IL Disassembler, the PEVerify tool does not allow arbitrary positioning of filename and options on the command line; rather, the name of the PE file being verified must be the first command-line parameter. Also, unlike the assembler and disassembler options, which are recognized by their first three characters only, PEVerify options must be fully spelled out.

PEVerify options are case-insensitive, and the option key can be a forward slash (/) character or a hyphen (-) character. The equality character (=) cannot be replaced with the colon character (:).

The command-line options include the following:

  • /IL  Check the PE structure and verify the IL code.

  • /MD  Check the PE structure and validate the metadata. If neither /MD nor /IL is specified, the metadata validation is performed first; then, if no metadata errors were found, the IL verification is performed. If either the /MD or /IL option is specified, only the metadata validation or the IL verification, respectively, is performed. If both /MD and /IL options are specified, the metadata validation is performed, followed by the IL verification, regardless of whether errors were found during the metadata validation phase.

  • /UNIQUE  Disregard repeating error codes; report only the first occurrence of each error type.

  • /HRESULT  Display error codes in hexadecimal format.

  • /CLOCK  Measure and report validation and verification times.

  • /IGNORE=<err_code>[,<err_code>...]  Ignore the specified error codes. Error codes must be specified in hexadecimal format.

  • /IGNORE=@<err_code_file>  Ignore the error codes specified in <err_code_file>, which is a text file containing comma-separated and/or line-separated hexadecimal error codes.

  • /BREAK=<maxErrorCount>  Abort verification after <maxErrorCount> errors. The value of <maxErrorCount> is a decimal number; if it is negative or unspecified, <maxErrorCount> is set to 1.

  • /QUIET  Suppress reporting the errors; report only the file being verified and the end result of the verification.

The following example shows verification of an exceptionally buggy PE file, created using IL Assembler with the /ERROR option:

D:\MTRY>peverify mtry.exe /md /il /hresult /unique Microsoft (R) .NET Framework PE Verifier  Version 1.0.3304.0 Copyright (C) Microsoft Corporation 1998-2001. All rights reserved. [MD](0x8013121D): Error: TypeDef is marked ValueType but not marked  Sealed. [token:0x02000002] [MD](0x80131256): Error: TypeDef is not marked Nested but has an  encloser type. [token:0x02000006] [MD](0x8013126D): Error: Global item (field,method) must be Public,  Private, or PrivateScope. [token:0x04000002] [MD](0x8013126E): Error: Global item (field,method) must be Static.  [token:0x04000002] [MD](0x8013126A): Error: Field name value__ is reserved for Enums only.[token:0x04000008] [MD](0x80131B24): Error: Illegal use of type 'void' in signature. [token:0x06000001] [MD](0x801312DB): Error: Constructor, initializer must return void. [token:0x06000005] [MD](0x801312DF): Error: ELEMENT_TYPE_SENTINEL is only allowed in  MemberRef signatures. [token:0x06000009] [MD](0x801312E2): Error: Trailing ELEMENT_TYPE_SENTINEL in signature.  [token:0x06000009] [MD](0x80131239): Error: Signature has invalid calling convention=0x00000023. [token:0x0600000D] [MD](0x801312E0): Error: Signature containing ELEMENT_TYPE_SENTINEL  must be VARARG. [token:0x0A000006] [MD](0x801312E1): Error: Multiple ELEMENT_TYPE_SENTINEL in signature.  [token:0x0A000006] [MD](0x80131230): Error: FieldLayout2 record has Field token=0x04000003marked Static. [token:0x00000001] 13 Errors Verifying mtry.exe



Inside Microsoft. NET IL Assembler
Inside Microsoft .NET IL Assembler
ISBN: 0735615470
EAN: 2147483647
Year: 2005
Pages: 147
Authors: SERGE LIDIN

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net