| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "courgette/disassembler.h" | 5 #include "courgette/disassembler.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 Disassembler* disassembler = DetectDisassembler(buffer, length); | 43 Disassembler* disassembler = DetectDisassembler(buffer, length); |
| 44 | 44 |
| 45 if (disassembler) { | 45 if (disassembler) { |
| 46 *type = disassembler->kind(); | 46 *type = disassembler->kind(); |
| 47 *detected_length = disassembler->length(); | 47 *detected_length = disassembler->length(); |
| 48 delete disassembler; | 48 delete disassembler; |
| 49 return C_OK; | 49 return C_OK; |
| 50 } | 50 } |
| 51 | 51 |
| 52 // We failed to detect anything | 52 // We failed to detect anything |
| 53 *type = UNKNOWN; | 53 *type = EXE_UNKNOWN; |
| 54 *detected_length = 0; | 54 *detected_length = 0; |
| 55 return C_INPUT_NOT_RECOGNIZED; | 55 return C_INPUT_NOT_RECOGNIZED; |
| 56 } | 56 } |
| 57 | 57 |
| 58 Status ParseDetectedExecutable(const void* buffer, size_t length, | 58 Status ParseDetectedExecutable(const void* buffer, size_t length, |
| 59 AssemblyProgram** output) { | 59 AssemblyProgram** output) { |
| 60 *output = NULL; | 60 *output = NULL; |
| 61 | 61 |
| 62 Disassembler* disassembler = DetectDisassembler(buffer, length); | 62 Disassembler* disassembler = DetectDisassembler(buffer, length); |
| 63 | 63 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 failure_reason_ = reason; | 106 failure_reason_ = reason; |
| 107 return false; | 107 return false; |
| 108 } | 108 } |
| 109 | 109 |
| 110 void Disassembler::ReduceLength(size_t reduced_length) { | 110 void Disassembler::ReduceLength(size_t reduced_length) { |
| 111 if (reduced_length < length_) | 111 if (reduced_length < length_) |
| 112 length_ = reduced_length; | 112 length_ = reduced_length; |
| 113 } | 113 } |
| 114 | 114 |
| 115 } // namespace courgette | 115 } // namespace courgette |
| OLD | NEW |