program_detector.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Copyright 2016 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 COURGETTE_PROGRAM_DETECTOR_H_
  5. #define COURGETTE_PROGRAM_DETECTOR_H_
  6. #include <stddef.h>
  7. #include <stdint.h>
  8. #include <memory>
  9. #include "courgette/courgette.h"
  10. namespace courgette {
  11. class Disassembler;
  12. // Returns a new instance of Disassembler inherited class if binary data given
  13. // in |buffer| and |length| match a known binary format, otherwise null.
  14. std::unique_ptr<Disassembler> DetectDisassembler(const uint8_t* buffer,
  15. size_t length);
  16. // Detects the type of an executable file, and it's length. The length may be
  17. // slightly smaller than some executables (like ELF), but will include all bytes
  18. // the courgette algorithm has special benefit for.
  19. // On success:
  20. // Fills in |type| and |detected_length|, and returns C_OK.
  21. // On failure:
  22. // Fills in |type| with UNKNOWN, |detected_length| with 0, and returns
  23. // C_INPUT_NOT_RECOGNIZED.
  24. Status DetectExecutableType(const uint8_t* buffer,
  25. size_t length,
  26. ExecutableType* type,
  27. size_t* detected_length);
  28. } // namespace courgette
  29. #endif // COURGETTE_PROGRAM_DETECTOR_H_