| 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 // *** File comments | 5 // *** File comments |
| 6 | 6 |
| 7 #include "courgette/ensemble.h" | 7 #include "courgette/ensemble.h" |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 while (position < length) { | 56 while (position < length) { |
| 57 // Quick test; Windows executables begin with 'MZ'. | 57 // Quick test; Windows executables begin with 'MZ'. |
| 58 if (start[position] == 'M' && | 58 if (start[position] == 'M' && |
| 59 position + 1 < length && start[position + 1] == 'Z') { | 59 position + 1 < length && start[position + 1] == 'Z') { |
| 60 courgette::PEInfo *info = new courgette::PEInfo(); | 60 courgette::PEInfo *info = new courgette::PEInfo(); |
| 61 info->Init(start + position, length - position); | 61 info->Init(start + position, length - position); |
| 62 if (info->ParseHeader()) { | 62 if (info->ParseHeader()) { |
| 63 Region region(start + position, info->length()); | 63 Region region(start + position, info->length()); |
| 64 | 64 |
| 65 if (info->has_text_section()) { | 65 if (info->has_text_section()) { |
| 66 Element* element = new ElementWinPE(Element::WIN32_X86_WITH_CODE, | 66 if (info->is_32bit()) { |
| 67 this, region, info); | 67 Element* element = new ElementWinPE(Element::WIN32_X86_WITH_CODE, |
| 68 owned_elements_.push_back(element); | 68 this, region, info); |
| 69 elements_.push_back(element); | 69 owned_elements_.push_back(element); |
| 70 position += region.length(); | 70 elements_.push_back(element); |
| 71 continue; | 71 position += region.length(); |
| 72 continue; |
| 73 } |
| 74 // TODO(sra): Extend to 64-bit executables. |
| 72 } | 75 } |
| 73 | 76 |
| 74 // If we had a clever transformation for resource-only executables we | 77 // If we had a clever transformation for resource-only executables we |
| 75 // should identify the suitable elements here: | 78 // should identify the suitable elements here: |
| 76 if (!info->has_text_section() && false) { | 79 if (!info->has_text_section() && false) { |
| 77 Element* element = new ElementWinPE(Element::WIN32_NOCODE, | 80 Element* element = new ElementWinPE(Element::WIN32_NOCODE, |
| 78 this, region, info); | 81 this, region, info); |
| 79 owned_elements_.push_back(element); | 82 owned_elements_.push_back(element); |
| 80 elements_.push_back(element); | 83 elements_.push_back(element); |
| 81 position += region.length(); | 84 position += region.length(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 93 } | 96 } |
| 94 return C_OK; | 97 return C_OK; |
| 95 } | 98 } |
| 96 | 99 |
| 97 Ensemble::~Ensemble() { | 100 Ensemble::~Ensemble() { |
| 98 for (size_t i = 0; i < owned_elements_.size(); ++i) | 101 for (size_t i = 0; i < owned_elements_.size(); ++i) |
| 99 delete owned_elements_[i]; | 102 delete owned_elements_[i]; |
| 100 } | 103 } |
| 101 | 104 |
| 102 } // namespace | 105 } // namespace |
| OLD | NEW |