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::transforms::NamedBlockGraphTransformImpl;
  36    :  
  37    :  // A PE BlockGraph transform for adding/updating the a debug directory entry
  38    :  // of a given type.
  39    :  class AddDebugDirectoryEntryTransform
  40    :      : public NamedBlockGraphTransformImpl<AddDebugDirectoryEntryTransform> {
  41    :   public:
  42    :    // Configures this transform.
  43    :    //
  44    :    // @param type the type of the debug directory entry to search for.
  45    :    // @param always_add if this is true a new debug directory entry will always
  46    :    //     be created, otherwise a new one will be created only if none already
  47    :    //     exists.
  48    :    AddDebugDirectoryEntryTransform(DWORD type, bool always_add)
  49    :        : type_(type), always_add_(always_add), added_(false), block_(NULL),
  50  E :          offset_(-1) {
  51  E :    }
  52    :  
  53    :    // Adds or finds the debug data directory of the given type.
  54    :    //
  55    :    // @param block_graph The block graph to transform.
  56    :    // @param dos_header_block The DOS header block of the block graph.
  57    :    // @returns true on success, false otherwise.
  58    :    virtual bool TransformBlockGraph(
  59    :        BlockGraph* block_graph, BlockGraph::Block* dos_header_block) OVERRIDE;
  60    :  
  61    :    // Returns true if a new debug directory entry was created.
  62  E :    bool added() const { return added_; }
  63    :  
  64    :    // Access the block containing the found or created debug directory entry.
  65    :    //
  66    :    // @returns the block housing the debug directory entry.
  67  E :    BlockGraph::Block* block() const { return block_; }
  68    :  
  69    :    // Access the offset of the found or created debug directory entry.
  70    :    //
  71    :    // @returns the offset into the block of the debug directory entry.
  72  E :    BlockGraph::Offset offset() const { return offset_; }
  73    :  
  74    :    // The transform name.
  75    :    static const char kTransformName[];
  76    :  
  77    :   private:
  78    :    // The type of the debug directory entry to find or add.
  79    :    DWORD type_;
  80    :    // If this is true a new debug directory entry will always be added, even if
  81    :    // there exists another one.
  82    :    bool always_add_;
  83    :  
  84    :    // These member variables hold state after the transform has been applied.
  85    :  
  86    :    // Indicates if a new directory entry was added.
  87    :    bool added_;
  88    :    // Stores the block housing the debug data directory entries.
  89    :    BlockGraph::Block* block_;
  90    :    // Stores the offset into the block of the found or craeted debug data
  91    :    // directory entry.
  92    :    BlockGraph::Offset offset_;
  93    :  
  94    :    DISALLOW_COPY_AND_ASSIGN(AddDebugDirectoryEntryTransform);
  95    :  };
  96    :  
  97    :  }  // namespace transforms
  98    :  }  // namespace pe
  99    :  
 100    :  #endif  // SYZYGY_PE_TRANSFORMS_ADD_DEBUG_DIRECTORY_ENTRY_TRANSFORM_H_

Coverage information generated Thu Jul 04 09:34:53 2013.