OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_PE_IMAGE_READER_WIN_H_ | 5 #ifndef CHROME_COMMON_SAFE_BROWSING_PE_IMAGE_READER_WIN_H_ |
6 #define CHROME_COMMON_SAFE_BROWSING_PE_IMAGE_READER_WIN_H_ | 6 #define CHROME_COMMON_SAFE_BROWSING_PE_IMAGE_READER_WIN_H_ |
7 | 7 |
8 #include <windows.h> | |
9 #include <stddef.h> | 8 #include <stddef.h> |
10 #include <stdint.h> | 9 #include <stdint.h> |
| 10 #include <windows.h> |
| 11 |
| 12 #include <memory> |
11 | 13 |
12 #include "base/macros.h" | 14 #include "base/macros.h" |
13 #include "base/memory/scoped_ptr.h" | |
14 | 15 |
15 namespace safe_browsing { | 16 namespace safe_browsing { |
16 | 17 |
17 // Parses headers and various data from a PE image. This parser is safe for use | 18 // Parses headers and various data from a PE image. This parser is safe for use |
18 // on untrusted data. | 19 // on untrusted data. |
19 class PeImageReader { | 20 class PeImageReader { |
20 public: | 21 public: |
21 enum WordSize { | 22 enum WordSize { |
22 WORD_SIZE_32, | 23 WORD_SIZE_32, |
23 WORD_SIZE_64, | 24 WORD_SIZE_64, |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 return false; | 142 return false; |
142 if (structure_size > image_size_ - offset) | 143 if (structure_size > image_size_ - offset) |
143 return false; | 144 return false; |
144 *structure = reinterpret_cast<const T*>(image_data_ + offset); | 145 *structure = reinterpret_cast<const T*>(image_data_ + offset); |
145 return true; | 146 return true; |
146 } | 147 } |
147 | 148 |
148 const uint8_t* image_data_; | 149 const uint8_t* image_data_; |
149 size_t image_size_; | 150 size_t image_size_; |
150 uint32_t validation_state_; | 151 uint32_t validation_state_; |
151 scoped_ptr<OptionalHeader> optional_header_; | 152 std::unique_ptr<OptionalHeader> optional_header_; |
152 DISALLOW_COPY_AND_ASSIGN(PeImageReader); | 153 DISALLOW_COPY_AND_ASSIGN(PeImageReader); |
153 }; | 154 }; |
154 | 155 |
155 } // namespace safe_browsing | 156 } // namespace safe_browsing |
156 | 157 |
157 #endif // CHROME_COMMON_SAFE_BROWSING_PE_IMAGE_READER_WIN_H_ | 158 #endif // CHROME_COMMON_SAFE_BROWSING_PE_IMAGE_READER_WIN_H_ |
OLD | NEW |