Coverage for /Syzygy/refinery/process_state/process_state_util.h

CoverageLines executed / instrumented / missingexe / inst / missLanguageGroup
0.0%0036.C++source

Line-by-line coverage:

   1    :  // Copyright 2015 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    :  #ifndef SYZYGY_REFINERY_PROCESS_STATE_PROCESS_STATE_UTIL_H_
  16    :  #define SYZYGY_REFINERY_PROCESS_STATE_PROCESS_STATE_UTIL_H_
  17    :  
  18    :  #include <string>
  19    :  
  20    :  #include "base/strings/string_piece.h"
  21    :  #include "syzygy/refinery/core/address.h"
  22    :  #include "syzygy/refinery/process_state/layer_data.h"
  23    :  #include "syzygy/refinery/process_state/process_state.h"
  24    :  #include "syzygy/refinery/process_state/refinery.pb.h"
  25    :  #include "syzygy/refinery/types/type.h"
  26    :  
  27  m :  namespace refinery {
  28    :  
  29  m :  using BytesLayerPtr = scoped_refptr<ProcessState::Layer<Bytes>>;
  30  m :  using BytesRecordPtr = ProcessState::Layer<Bytes>::RecordPtr;
  31    :  
  32  m :  using StackLayerPtr = scoped_refptr<ProcessState::Layer<Stack>>;
  33  m :  using StackRecordPtr = ProcessState::Layer<Stack>::RecordPtr;
  34    :  
  35  m :  using StackFrameLayerPtr = scoped_refptr<ProcessState::Layer<StackFrame>>;
  36  m :  using StackFrameRecordPtr = ProcessState::Layer<StackFrame>::RecordPtr;
  37    :  
  38  m :  using TypedBlockLayerPtr = scoped_refptr<ProcessState::Layer<TypedBlock>>;
  39  m :  using TypedBlockRecordPtr = ProcessState::Layer<TypedBlock>::RecordPtr;
  40    :  
  41  m :  using ModuleLayerPtr = scoped_refptr<ProcessState::Layer<Module>>;
  42  m :  using ModuleRecordPtr = ProcessState::Layer<Module>::RecordPtr;
  43    :  
  44  m :  using HeapMetadataLayerPtr = scoped_refptr<ProcessState::Layer<HeapMetadata>>;
  45  m :  using HeapMetadataRecordPtr = ProcessState::Layer<HeapMetadata>::RecordPtr;
  46    :  
  47  m :  using HeapAllocationLayerPtr =
  48  m :      scoped_refptr<ProcessState::Layer<HeapAllocation>>;
  49  m :  using HeapAllocationRecordPtr = ProcessState::Layer<HeapAllocation>::RecordPtr;
  50    :  
  51    :  // A class for interacting with a ProcessState's module layer.
  52  m :  class ModuleLayerAccessor {
  53  m :   public:
  54  m :    explicit ModuleLayerAccessor(ProcessState* process_state);
  55    :  
  56    :    // Adds a module instance record to the process state. Also updates the module
  57    :    // layer's data if the instance is for a new module.
  58    :    // @note If the module is added to the layer's data, it is with a signature
  59    :    // that has a load address of 0, as we fold multiple module instances to a
  60    :    // single module identifier (and signature).
  61    :    // @param range the module instance's memory range.
  62    :    // @param checksum the module's checksum.
  63    :    // @param timestamp the module's timestamp.
  64    :    // @param path the module's path.
  65  m :    void AddModuleRecord(const AddressRange& range,
  66  m :                         const uint32 checksum,
  67  m :                         const uint32 timestamp,
  68  m :                         const std::wstring& path);
  69    :  
  70    :    // Retrieves the signature of the module instance containing @p va.
  71    :    // @note On success, the signature's base address is set to the module
  72    :    //     instance's actual load address.
  73    :    // @param va virtual address for which to get a module signature.
  74    :    // @param signature on success, the module signature.
  75    :    // @returns true on success, false on failure.
  76  m :    bool GetModuleSignature(const Address va, pe::PEFile::Signature* signature);
  77    :  
  78    :    // Retrieves the signature of module @p id.
  79    :    // @note On success, the returned signature's base address is 0.
  80    :    // @param id module identifier for which to get a module signature.
  81    :    // @param signature on success, the module signature.
  82    :    // @returns true on success, false on failure.
  83  m :    bool GetModuleSignature(const ModuleId id, pe::PEFile::Signature* signature);
  84    :  
  85    :    // Retrieves the module identifier corresponding to @p va.
  86    :    // @param virtual address for which to get a module identifier.
  87    :    // @returns the module identifier, or kNoModuleId if @p va does not correspond
  88    :    //     to a module.
  89  m :    ModuleId GetModuleId(const Address va);
  90    :  
  91    :    // Retrieves the module identifier corresponding to @p signature.
  92    :    // @param signature for which to get a module identifier.
  93    :    // @returns the module identifier, or kNoModuleId if @p signature does not
  94    :    //     correspond to a module known to the process state.
  95  m :    ModuleId GetModuleId(const pe::PEFile::Signature& signature);
  96    :  
  97  m :   private:
  98  m :    ProcessState* process_state_;  // Not owned, must outlive this class.
  99  m :  };
 100    :  
 101    :  // Adds a typed block record to @p process_state.
 102    :  // TODO(manzagop): avoid adding typed block duplicates. Longer term we may
 103    :  // introduce more complex handling (eg notions of certainty).
 104  m :  bool AddTypedBlockRecord(const AddressRange& range,
 105  m :                           base::StringPiece16 data_name,
 106  m :                           ModuleId module_id,
 107  m :                           TypeId type_id,
 108  m :                           ProcessState* process_state);
 109    :  
 110  m :  }  // namespace refinery
 111    :  
 112    :  #endif  // SYZYGY_REFINERY_PROCESS_STATE_PROCESS_STATE_UTIL_H_

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