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 #include "chrome/browser/safe_browsing/pe_image_reader_win.h" | 5 #include "chrome/browser/safe_browsing/pe_image_reader_win.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 | 8 |
9 namespace safe_browsing { | 9 namespace safe_browsing { |
10 | 10 |
(...skipping 17 matching lines...) Expand all Loading... |
28 // underlying structure type from the point of view of the PeImageReader. | 28 // underlying structure type from the point of view of the PeImageReader. |
29 template<class OPTIONAL_HEADER_TYPE> | 29 template<class OPTIONAL_HEADER_TYPE> |
30 class PeImageReader::OptionalHeaderImpl : public PeImageReader::OptionalHeader { | 30 class PeImageReader::OptionalHeaderImpl : public PeImageReader::OptionalHeader { |
31 public: | 31 public: |
32 typedef OptionalHeaderTraits<OPTIONAL_HEADER_TYPE> TraitsType; | 32 typedef OptionalHeaderTraits<OPTIONAL_HEADER_TYPE> TraitsType; |
33 | 33 |
34 explicit OptionalHeaderImpl(const uint8_t* optional_header_start) | 34 explicit OptionalHeaderImpl(const uint8_t* optional_header_start) |
35 : optional_header_(reinterpret_cast<const OPTIONAL_HEADER_TYPE*>( | 35 : optional_header_(reinterpret_cast<const OPTIONAL_HEADER_TYPE*>( |
36 optional_header_start)) {} | 36 optional_header_start)) {} |
37 | 37 |
38 virtual WordSize GetWordSize() OVERRIDE { | 38 virtual WordSize GetWordSize() override { |
39 return TraitsType::word_size; | 39 return TraitsType::word_size; |
40 } | 40 } |
41 | 41 |
42 virtual size_t GetDataDirectoryOffset() OVERRIDE { | 42 virtual size_t GetDataDirectoryOffset() override { |
43 return offsetof(OPTIONAL_HEADER_TYPE, DataDirectory); | 43 return offsetof(OPTIONAL_HEADER_TYPE, DataDirectory); |
44 } | 44 } |
45 | 45 |
46 virtual DWORD GetDataDirectorySize() OVERRIDE { | 46 virtual DWORD GetDataDirectorySize() override { |
47 return optional_header_->NumberOfRvaAndSizes; | 47 return optional_header_->NumberOfRvaAndSizes; |
48 } | 48 } |
49 | 49 |
50 virtual const IMAGE_DATA_DIRECTORY* GetDataDirectoryEntries() OVERRIDE { | 50 virtual const IMAGE_DATA_DIRECTORY* GetDataDirectoryEntries() override { |
51 return &optional_header_->DataDirectory[0]; | 51 return &optional_header_->DataDirectory[0]; |
52 } | 52 } |
53 | 53 |
54 private: | 54 private: |
55 const OPTIONAL_HEADER_TYPE* optional_header_; | 55 const OPTIONAL_HEADER_TYPE* optional_header_; |
56 DISALLOW_COPY_AND_ASSIGN(OptionalHeaderImpl); | 56 DISALLOW_COPY_AND_ASSIGN(OptionalHeaderImpl); |
57 }; | 57 }; |
58 | 58 |
59 PeImageReader::PeImageReader() | 59 PeImageReader::PeImageReader() |
60 : image_data_(), | 60 : image_data_(), |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 if (data_offset >= header->SizeOfRawData || | 324 if (data_offset >= header->SizeOfRawData || |
325 header->SizeOfRawData - data_offset < entry->Size) { | 325 header->SizeOfRawData - data_offset < entry->Size) { |
326 return NULL; | 326 return NULL; |
327 } | 327 } |
328 | 328 |
329 *data_length = entry->Size; | 329 *data_length = entry->Size; |
330 return image_data_ + header->PointerToRawData + data_offset; | 330 return image_data_ + header->PointerToRawData + data_offset; |
331 } | 331 } |
332 | 332 |
333 } // namespace safe_browsing | 333 } // namespace safe_browsing |
OLD | NEW |