Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(72)

Side by Side Diff: courgette/image_info.cc

Issue 113917: When iterating over the sections in a file, omit sections that have no raw da... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « courgette/image_info.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 = &sections_[i]; 60 const Section* section = &sections_[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 = &sections_[i]; 75 const Section* section = &sections_[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
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
OLDNEW
« no previous file with comments | « courgette/image_info.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698