OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COURGETTE_PROGRAM_DETECTOR_H_ | 5 #ifndef COURGETTE_PROGRAM_DETECTOR_H_ |
6 #define COURGETTE_PROGRAM_DETECTOR_H_ | 6 #define COURGETTE_PROGRAM_DETECTOR_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include <memory> |
| 11 |
11 #include "courgette/courgette.h" | 12 #include "courgette/courgette.h" |
12 | 13 |
13 namespace courgette { | 14 namespace courgette { |
14 | 15 |
15 class AssemblyProgram; | 16 class AssemblyProgram; |
16 | 17 |
17 // Detects the type of an executable file, and it's length. The length may be | 18 // Detects the type of an executable file, and it's length. The length may be |
18 // slightly smaller than some executables (like ELF), but will include all bytes | 19 // slightly smaller than some executables (like ELF), but will include all bytes |
19 // the courgette algorithm has special benefit for. | 20 // the courgette algorithm has special benefit for. |
20 // On success: | 21 // On success: |
21 // Fills in |type| and |detected_length|, and returns C_OK. | 22 // Fills in |type| and |detected_length|, and returns C_OK. |
22 // On failure: | 23 // On failure: |
23 // Fills in |type| with UNKNOWN, |detected_length| with 0, and returns | 24 // Fills in |type| with UNKNOWN, |detected_length| with 0, and returns |
24 // C_INPUT_NOT_RECOGNIZED. | 25 // C_INPUT_NOT_RECOGNIZED. |
25 Status DetectExecutableType(const void* buffer, | 26 Status DetectExecutableType(const void* buffer, |
26 size_t length, | 27 size_t length, |
27 ExecutableType* type, | 28 ExecutableType* type, |
28 size_t* detected_length); | 29 size_t* detected_length); |
29 | 30 |
30 // Attempts to detect the type of executable, and parse it with the appropriate | 31 // Attempts to detect the type of executable, and parse it with the appropriate |
31 // tools. | 32 // tools. |
32 // On success: | 33 // On success: |
33 // Parses the executable into a new AssemblyProgram in |*output|, and returns | 34 // Parses the executable into a new AssemblyProgram in |*output|, and returns |
34 // C_OK. | 35 // C_OK. |
35 // On failure: | 36 // On failure: |
36 // Returns an error status and assigns |*output| to null. | 37 // Returns an error status and assigns |*output| to null. |
37 Status ParseDetectedExecutable(const void* buffer, | 38 Status ParseDetectedExecutable(const void* buffer, |
38 size_t length, | 39 size_t length, |
39 scoped_ptr<AssemblyProgram>* output); | 40 std::unique_ptr<AssemblyProgram>* output); |
40 | 41 |
41 } // namespace courgette | 42 } // namespace courgette |
42 | 43 |
43 #endif // COURGETTE_PROGRAM_DETECTOR_H_ | 44 #endif // COURGETTE_PROGRAM_DETECTOR_H_ |
OLD | NEW |