zucchini_tools.h 1.7 KB

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