Coverage for /Syzygy/pe/transforms/coff_rename_symbols_transform.h

CoverageLines executed / instrumented / missingexe / inst / missLanguageGroup
100.0%550.C++source

Line-by-line coverage:

   1    :  // Copyright 2013 Google Inc. All Rights Reserved.
   2    :  //
   3    :  // Licensed under the Apache License, Version 2.0 (the "License");
   4    :  // you may not use this file except in compliance with the License.
   5    :  // You may obtain a copy of the License at
   6    :  //
   7    :  //     http://www.apache.org/licenses/LICENSE-2.0
   8    :  //
   9    :  // Unless required by applicable law or agreed to in writing, software
  10    :  // distributed under the License is distributed on an "AS IS" BASIS,
  11    :  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12    :  // See the License for the specific language governing permissions and
  13    :  // limitations under the License.
  14    :  //
  15    :  // Declares a transform for renaming symbols in COFF files. A symbol is a
  16    :  // named object to be defined by another translation unit. Renaming them is
  17    :  // equivalent to redirecting an import for a PE file. This is used by some
  18    :  // instrumentation methods to redirect functions to instrumented equivalents.
  19    :  
  20    :  #ifndef SYZYGY_PE_TRANSFORMS_COFF_RENAME_SYMBOLS_TRANSFORM_H_
  21    :  #define SYZYGY_PE_TRANSFORMS_COFF_RENAME_SYMBOLS_TRANSFORM_H_
  22    :  
  23    :  #include <map>
  24    :  
  25    :  #include "base/strings/string_piece.h"
  26    :  #include "syzygy/block_graph/transforms/named_transform.h"
  27    :  
  28    :  namespace pe {
  29    :  namespace transforms {
  30    :  
  31    :  // A transform for renaming COFF symbols in a given block graph.
  32    :  class CoffRenameSymbolsTransform
  33    :      : public block_graph::transforms::NamedBlockGraphTransformImpl<
  34    :            CoffRenameSymbolsTransform> {
  35    :   public:
  36    :    typedef block_graph::BlockGraph BlockGraph;
  37    :    typedef block_graph::TransformPolicyInterface TransformPolicyInterface;
  38    :  
  39    :    // Construct an empty CoffRenameSymbolsTransform; initially, no symbol is
  40    :    // set to be renamed. By default, the input symbol of any specified mapping
  41    :    // must exist, otherwise the transform will fail.
  42  E :    CoffRenameSymbolsTransform() : symbols_must_exist_(true) {}
  43    :  
  44    :    // Add the specified mapping to be applied.
  45    :    // @param from the symbol to rename.
  46    :    // @param to the replacement symbol name.
  47    :    void AddSymbolMapping(const base::StringPiece& from,
  48    :                          const base::StringPiece& to);
  49    :  
  50    :    // Perform the transform. Rename symbols according to the mappings
  51    :    // previously added.
  52    :    // @param policy the policy object restricting how the transform is applied.
  53    :    // @param block_graph the BlockGraph to transform.
  54    :    // @param headers_block the block containing the headers.
  55    :    // @returns true on success, false otherwise.
  56    :    virtual bool TransformBlockGraph(const TransformPolicyInterface* policy,
  57    :                                     BlockGraph* block_graph,
  58    :                                     BlockGraph::Block* headers_block) override;
  59    :  
  60    :    // The name of this transform.
  61    :    static const char kTransformName[];
  62    :  
  63    :    // @name Accessors and mutators.
  64    :    // @{
  65  E :    bool symbols_must_exist() const { return symbols_must_exist_; }
  66  E :    void set_symbols_must_exist(bool symbols_must_exist) {
  67  E :      symbols_must_exist_ = symbols_must_exist;
  68  E :    }
  69    :    // @}
  70    :  
  71    :   protected:
  72    :    typedef std::vector<std::pair<std::string, std::string>> SymbolMap;
  73    :    SymbolMap mappings_;
  74    :    bool symbols_must_exist_;
  75    :  
  76    :    DISALLOW_COPY_AND_ASSIGN(CoffRenameSymbolsTransform);
  77    :  };
  78    :  
  79    :  }  // namespace transforms
  80    :  }  // namespace pe
  81    :  
  82    :  #endif  // SYZYGY_PE_TRANSFORMS_COFF_RENAME_SYMBOLS_TRANSFORM_H_

Coverage information generated Thu Jan 14 17:40:38 2016.