1 // Copyright 2017 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef COMPONENTS_ZUCCHINI_ZUCCHINI_TOOLS_H_ 6 #define COMPONENTS_ZUCCHINI_ZUCCHINI_TOOLS_H_ 7 8 #include <iosfwd> 9 #include <string> 10 #include <vector> 11 12 #include "components/zucchini/buffer_view.h" 13 #include "components/zucchini/zucchini.h" 14 15 namespace zucchini { 16 17 // The functions below are called to print diagnosis information, so outputs are 18 // printed using std::ostream instead of LOG(). 19 20 // Prints stats on references found in |image|. If |do_dump| is true, then 21 // prints all references (locations and targets). 22 status::Code ReadReferences(ConstBufferView image, 23 bool do_dump, 24 std::ostream& out); 25 26 // Prints regions and types of all detected executables in |image|. Appends 27 // detected subregions to |sub_image_list|. 28 status::Code DetectAll(ConstBufferView image, 29 std::ostream& out, 30 std::vector<ConstBufferView>* sub_image_list); 31 32 // Prints all matched regions from |old_image| to |new_image|. 33 // |imposed_matches|, if non-empty, encodes custom element matching to override 34 // the default element detection and matching heuristics, and is formatted as: 35 // "#+#=#+#,#+#=#+#,..." (e.g., "1+2=3+4", "1+2=3+4,5+6=7+8"), 36 // where "#+#=#+#" encodes a match as 4 unsigned integers: 37 // [offset in "old", size in "old", offset in "new", size in "new"]. 38 status::Code MatchAll(ConstBufferView old_image, 39 ConstBufferView new_image, 40 std::string imposed_matches, 41 std::ostream& out); 42 43 } // namespace zucchini 44 45 #endif // COMPONENTS_ZUCCHINI_ZUCCHINI_TOOLS_H_ 46