| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 << std::hex << (rva - section->virtual_address) | 51 << std::hex << (rva - section->virtual_address) |
| 52 << ")"; | 52 << ")"; |
| 53 } | 53 } |
| 54 return s.str(); | 54 return s.str(); |
| 55 } | 55 } |
| 56 | 56 |
| 57 const Section* PEInfo::FindNextSection(uint32 fileOffset) const { | 57 const Section* PEInfo::FindNextSection(uint32 fileOffset) const { |
| 58 const Section* best = 0; | 58 const Section* best = 0; |
| 59 for (int i = 0; i < number_of_sections_; i++) { | 59 for (int i = 0; i < number_of_sections_; i++) { |
| 60 const Section* section = §ions_[i]; | 60 const Section* section = §ions_[i]; |
| 61 if (fileOffset <= section->file_offset_of_raw_data) { | 61 if (section->size_of_raw_data > 0) { // i.e. has data in file. |
| 62 if (best == 0 || | 62 if (fileOffset <= section->file_offset_of_raw_data) { |
| 63 section->file_offset_of_raw_data < best->file_offset_of_raw_data) { | 63 if (best == 0 || |
| 64 best = section; | 64 section->file_offset_of_raw_data < best->file_offset_of_raw_data) { |
| 65 best = section; |
| 66 } |
| 65 } | 67 } |
| 66 } | 68 } |
| 67 } | 69 } |
| 68 return best; | 70 return best; |
| 69 } | 71 } |
| 70 | 72 |
| 71 const Section* PEInfo::RVAToSection(RVA rva) const { | 73 const Section* PEInfo::RVAToSection(RVA rva) const { |
| 72 for (int i = 0; i < number_of_sections_; i++) { | 74 for (int i = 0; i < number_of_sections_; i++) { |
| 73 const Section* section = §ions_[i]; | 75 const Section* section = §ions_[i]; |
| 74 uint32 offset = rva - section->virtual_address; | 76 uint32 offset = rva - section->virtual_address; |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 | 384 |
| 383 block += size; | 385 block += size; |
| 384 } | 386 } |
| 385 | 387 |
| 386 std::sort(relocs->begin(), relocs->end()); | 388 std::sort(relocs->begin(), relocs->end()); |
| 387 | 389 |
| 388 return true; | 390 return true; |
| 389 } | 391 } |
| 390 | 392 |
| 391 } // namespace courgette | 393 } // namespace courgette |
| OLD | NEW |