OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 CHROME_COMMON_SAFE_BROWSING_MACH_O_IMAGE_READER_MAC_H_ | 5 #ifndef CHROME_COMMON_SAFE_BROWSING_MACH_O_IMAGE_READER_MAC_H_ |
6 #define CHROME_COMMON_SAFE_BROWSING_MACH_O_IMAGE_READER_MAC_H_ | 6 #define CHROME_COMMON_SAFE_BROWSING_MACH_O_IMAGE_READER_MAC_H_ |
7 | 7 |
8 #include <mach-o/loader.h> | 8 #include <mach-o/loader.h> |
9 #include <stddef.h> | 9 #include <stddef.h> |
10 #include <stdint.h> | 10 #include <stdint.h> |
11 | 11 |
12 #include <memory> | 12 #include <memory> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "base/logging.h" | 15 #include "base/logging.h" |
16 #include "base/macros.h" | 16 #include "base/macros.h" |
17 #include "base/memory/scoped_vector.h" | |
18 | 17 |
19 namespace safe_browsing { | 18 namespace safe_browsing { |
20 | 19 |
21 class ByteSlice; | 20 class ByteSlice; |
22 | 21 |
23 // MachOImageReader is used to extract information about a Mach-O binary image. | 22 // MachOImageReader is used to extract information about a Mach-O binary image. |
24 // This class supports fat and thin images. Initialize() must be called before | 23 // This class supports fat and thin images. Initialize() must be called before |
25 // any other methods; if it returns false, it is illegal to call any other | 24 // any other methods; if it returns false, it is illegal to call any other |
26 // methods on this class. | 25 // methods on this class. |
27 class MachOImageReader { | 26 class MachOImageReader { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 const std::vector<MachOImageReader::LoadCommand>& GetLoadCommands(); | 87 const std::vector<MachOImageReader::LoadCommand>& GetLoadCommands(); |
89 | 88 |
90 // If the image has a LC_CODE_SIGNATURE command, this retreives the code | 89 // If the image has a LC_CODE_SIGNATURE command, this retreives the code |
91 // signature blob in the __LINKEDIT segment. | 90 // signature blob in the __LINKEDIT segment. |
92 bool GetCodeSignatureInfo(std::vector<uint8_t>* info); | 91 bool GetCodeSignatureInfo(std::vector<uint8_t>* info); |
93 | 92 |
94 private: | 93 private: |
95 std::unique_ptr<ByteSlice> data_; | 94 std::unique_ptr<ByteSlice> data_; |
96 | 95 |
97 bool is_fat_; | 96 bool is_fat_; |
98 ScopedVector<MachOImageReader> fat_images_; | 97 std::vector<std::unique_ptr<MachOImageReader>> fat_images_; |
99 | 98 |
100 bool is_64_bit_; | 99 bool is_64_bit_; |
101 std::vector<LoadCommand> commands_; | 100 std::vector<LoadCommand> commands_; |
102 | 101 |
103 DISALLOW_COPY_AND_ASSIGN(MachOImageReader); | 102 DISALLOW_COPY_AND_ASSIGN(MachOImageReader); |
104 }; | 103 }; |
105 | 104 |
106 } // namespace safe_browsing | 105 } // namespace safe_browsing |
107 | 106 |
108 #endif // CHROME_COMMON_SAFE_BROWSING_MACH_O_IMAGE_READER_MAC_H_ | 107 #endif // CHROME_COMMON_SAFE_BROWSING_MACH_O_IMAGE_READER_MAC_H_ |
OLD | NEW |