OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/image_info.h" | 5 #include "courgette/image_info.h" |
6 | 6 |
7 #include <memory.h> | 7 #include <memory.h> |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 // header to see if the section contains instructions. | 303 // header to see if the section contains instructions. |
304 if (memcmp(section->name, ".text", 6) == 0) | 304 if (memcmp(section->name, ".text", 6) == 0) |
305 has_text_section_ = true; | 305 has_text_section_ = true; |
306 | 306 |
307 uint32 section_end = | 307 uint32 section_end = |
308 section->file_offset_of_raw_data + section->size_of_raw_data; | 308 section->file_offset_of_raw_data + section->size_of_raw_data; |
309 if (section_end > file_length_) | 309 if (section_end > file_length_) |
310 file_length_ = section_end; | 310 file_length_ = section_end; |
311 } | 311 } |
312 | 312 |
| 313 if (!is_32bit()) { |
| 314 return Bad("64 bit executables are not yet supported"); |
| 315 } |
| 316 |
| 317 if (!has_text_section()) { |
| 318 return Bad("Resource-only executables are not yet supported"); |
| 319 } |
| 320 |
313 failure_reason_ = NULL; | 321 failure_reason_ = NULL; |
314 return true; | 322 return true; |
315 } | 323 } |
316 | 324 |
317 bool PEInfo::ReadDataDirectory(int index, ImageDataDirectory* directory) { | 325 bool PEInfo::ReadDataDirectory(int index, ImageDataDirectory* directory) { |
318 if (index < number_of_data_directories_) { | 326 if (index < number_of_data_directories_) { |
319 size_t offset = index * 8 + offset_of_data_directories_; | 327 size_t offset = index * 8 + offset_of_data_directories_; |
320 if (offset >= size_of_optional_header_) | 328 if (offset >= size_of_optional_header_) |
321 return Bad("number of data directories inconsistent"); | 329 return Bad("number of data directories inconsistent"); |
322 const uint8* data_directory = optional_header_ + offset; | 330 const uint8* data_directory = optional_header_ + offset; |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 | 410 |
403 block += size; | 411 block += size; |
404 } | 412 } |
405 | 413 |
406 std::sort(relocs->begin(), relocs->end()); | 414 std::sort(relocs->begin(), relocs->end()); |
407 | 415 |
408 return true; | 416 return true; |
409 } | 417 } |
410 | 418 |
411 } // namespace courgette | 419 } // namespace courgette |
OLD | NEW |