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

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

Line-by-line coverage:

   1    :  // Copyright 2012 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 the AddDebugDirectoryEntryTransform. This find or creates a debug
  16    :  // directory entry of the specified type. It is intended to be used by other
  17    :  // transforms.
  18    :  //
  19    :  // After the transform has completed the 'offset' and 'block' members functions
  20    :  // point to the found or created debug directory entry with the type as
  21    :  // specified in the transform constructor.
  22    :  
  23    :  #ifndef SYZYGY_PE_TRANSFORMS_ADD_DEBUG_DIRECTORY_ENTRY_TRANSFORM_H_
  24    :  #define SYZYGY_PE_TRANSFORMS_ADD_DEBUG_DIRECTORY_ENTRY_TRANSFORM_H_
  25    :  
  26    :  #include <windows.h>
  27    :  
  28    :  #include "base/files/file_path.h"
  29    :  #include "syzygy/block_graph/transforms/named_transform.h"
  30    :  
  31    :  namespace pe {
  32    :  namespace transforms {
  33    :  
  34    :  using block_graph::BlockGraph;
  35    :  using block_graph::TransformPolicyInterface;
  36    :  using block_graph::transforms::NamedBlockGraphTransformImpl;
  37    :  
  38    :  // A PE BlockGraph transform for adding/updating the a debug directory entry
  39    :  // of a given type.
  40    :  class AddDebugDirectoryEntryTransform
  41    :      : public NamedBlockGraphTransformImpl<AddDebugDirectoryEntryTransform> {
  42    :   public:
  43    :    // Configures this transform.
  44    :    //
  45    :    // @param type the type of the debug directory entry to search for.
  46    :    // @param always_add if this is true a new debug directory entry will always
  47    :    //     be created, otherwise a new one will be created only if none already
  48    :    //     exists.
  49    :    AddDebugDirectoryEntryTransform(DWORD type, bool always_add)
  50    :        : type_(type), always_add_(always_add), added_(false), block_(NULL),
  51  E :          offset_(-1) {
  52  E :    }
  53    :  
  54    :    // Adds or finds the debug data directory of the given type.
  55    :    //
  56    :    // @param policy The policy object restricting how the transform is applied.
  57    :    // @param block_graph The block graph to transform.
  58    :    // @param dos_header_block The DOS header block of the block graph.
  59    :    // @returns true on success, false otherwise.
  60    :    virtual bool TransformBlockGraph(
  61    :        const TransformPolicyInterface* policy,
  62    :        BlockGraph* block_graph,
  63    :        BlockGraph::Block* dos_header_block) override;
  64    :  
  65    :    // Returns true if a new debug directory entry was created.
  66  E :    bool added() const { return added_; }
  67    :  
  68    :    // Access the block containing the found or created debug directory entry.
  69    :    //
  70    :    // @returns the block housing the debug directory entry.
  71  E :    BlockGraph::Block* block() const { return block_; }
  72    :  
  73    :    // Access the offset of the found or created debug directory entry.
  74    :    //
  75    :    // @returns the offset into the block of the debug directory entry.
  76  E :    BlockGraph::Offset offset() const { return offset_; }
  77    :  
  78    :    // The transform name.
  79    :    static const char kTransformName[];
  80    :  
  81    :   private:
  82    :    // The type of the debug directory entry to find or add.
  83    :    DWORD type_;
  84    :    // If this is true a new debug directory entry will always be added, even if
  85    :    // there exists another one.
  86    :    bool always_add_;
  87    :  
  88    :    // These member variables hold state after the transform has been applied.
  89    :  
  90    :    // Indicates if a new directory entry was added.
  91    :    bool added_;
  92    :    // Stores the block housing the debug data directory entries.
  93    :    BlockGraph::Block* block_;
  94    :    // Stores the offset into the block of the found or created debug data
  95    :    // directory entry.
  96    :    BlockGraph::Offset offset_;
  97    :  
  98    :    DISALLOW_COPY_AND_ASSIGN(AddDebugDirectoryEntryTransform);
  99    :  };
 100    :  
 101    :  }  // namespace transforms
 102    :  }  // namespace pe
 103    :  
 104    :  #endif  // SYZYGY_PE_TRANSFORMS_ADD_DEBUG_DIRECTORY_ENTRY_TRANSFORM_H_

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