OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 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 // Declare the AFL instrumenter. |
| 16 |
| 17 #ifndef SYZYGY_INSTRUMENT_INSTRUMENTERS_AFL_INSTRUMENTER_H_ |
| 18 #define SYZYGY_INSTRUMENT_INSTRUMENTERS_AFL_INSTRUMENTER_H_ |
| 19 |
| 20 #include <string> |
| 21 #include <unordered_set> |
| 22 |
| 23 #include "base/command_line.h" |
| 24 #include "syzygy/instrument/instrumenters/instrumenter_with_agent.h" |
| 25 #include "syzygy/instrument/mutators/add_indexed_data_ranges_stream.h" |
| 26 #include "syzygy/instrument/transforms/afl_transform.h" |
| 27 #include "syzygy/pe/pe_relinker.h" |
| 28 |
| 29 namespace instrument { |
| 30 namespace instrumenters { |
| 31 |
| 32 class AFLInstrumenter : public InstrumenterWithRelinker { |
| 33 public: |
| 34 typedef InstrumenterWithRelinker Super; |
| 35 |
| 36 AFLInstrumenter() : Super() {} |
| 37 |
| 38 // From InstrumenterWithRelinker |
| 39 bool InstrumentPrepare() override; |
| 40 bool InstrumentImpl() override; |
| 41 const char* InstrumentationMode() override; |
| 42 bool DoCommandLineParse(const base::CommandLine* command_line) override; |
| 43 |
| 44 protected: |
| 45 // Force decomposition flag. |
| 46 bool force_decomposition_; |
| 47 |
| 48 // Thread-safe instrumentation flag. |
| 49 bool multithread_mode_; |
| 50 |
| 51 // Store the whitelist / blacklist of functions to instrument or not. |
| 52 std::unordered_set<std::string> target_set_; |
| 53 bool whitelist_mode_; |
| 54 |
| 55 // Path to the JSON describing the instrumentation properties. |
| 56 base::FilePath config_path_; |
| 57 |
| 58 // Cookie check hook flag. |
| 59 bool cookie_check_hook_; |
| 60 |
| 61 // The transform for this agent. |
| 62 std::unique_ptr<instrument::transforms::AFLTransform> transformer_; |
| 63 |
| 64 // The PDB mutator for this agent. |
| 65 std::unique_ptr<instrument::mutators::AddIndexedDataRangesStreamPdbMutator> |
| 66 add_bb_addr_stream_mutator_; |
| 67 |
| 68 private: |
| 69 // Helper routines to read the JSON configuration file. |
| 70 bool ReadFromJSON(const std::string& json); |
| 71 bool ReadFromJSONPath(const base::FilePath& path); |
| 72 |
| 73 DISALLOW_COPY_AND_ASSIGN(AFLInstrumenter); |
| 74 }; |
| 75 |
| 76 } // namespace instrumenters |
| 77 } // namespace instrument |
| 78 |
| 79 #endif // SYZYGY_INSTRUMENT_INSTRUMENTERS_AFL_INSTRUMENTER_H_ |
OLD | NEW |