Chapter 16 Working with VB .NET


VB .NET reverse engineering preprocessing

VB .NET files may contain conditional code that needs to be handled by preprocessing directives during reverse engineering. A preprocessing directive is a command placed within the source code that directs the compiler to do a certain thing before the rest of the source code is parsed and compiled. The preprocessing directive has the following structure:

#directive symbol

Where # is followed by the name of the directive, and symbol is a conditional compiler constant used to select particular sections of code and exclude other sections.

In VB .NET symbols have values.

In the following example, the #if directive is used with symbols FrenchVersion and GermanVersion to output French or German language versions of the same application from the same source code:

      #if FrenchVersion Then
       '  <code specific to French language version>.
      #ElseIf GermanVersion Then
        ' <code specific to French language version>.
      #Else
        ' <code specific to other language version>.
      #End If

You can declare a list of symbols for preprocessing directives. These symbols are parsed by preprocessing directives: if the directive condition is true the statement is kept, otherwise the statement is removed.

 


Copyright (C) 2007. Sybase Inc. All rights reserved.