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