| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // This is the transformation and adjustment for Windows X86 executables. | 5 // This is the transformation and adjustment for all executables. |
| 6 // The same code can be used for Windows X64 executables. | 6 // The executable type is determined by ParseDetectedExecutable function. |
| 7 | 7 |
| 8 #ifndef COURGETTE_WIN32_X86_GENERATOR_H_ | 8 #ifndef COURGETTE_WIN32_X86_GENERATOR_H_ |
| 9 #define COURGETTE_WIN32_X86_GENERATOR_H_ | 9 #define COURGETTE_WIN32_X86_GENERATOR_H_ |
| 10 | 10 |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 | 13 |
| 14 #include "courgette/assembly_program.h" | 14 #include "courgette/assembly_program.h" |
| 15 #include "courgette/ensemble.h" | 15 #include "courgette/ensemble.h" |
| 16 | 16 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 return C_GENERAL_ERROR; | 60 return C_GENERAL_ERROR; |
| 61 | 61 |
| 62 // Generate old version of program using |corrected_parameters|. | 62 // Generate old version of program using |corrected_parameters|. |
| 63 // TODO(sra): refactor to use same code from patcher_. | 63 // TODO(sra): refactor to use same code from patcher_. |
| 64 AssemblyProgram* old_program = NULL; | 64 AssemblyProgram* old_program = NULL; |
| 65 Status old_parse_status = | 65 Status old_parse_status = |
| 66 ParseDetectedExecutable(old_element_->region().start(), | 66 ParseDetectedExecutable(old_element_->region().start(), |
| 67 old_element_->region().length(), | 67 old_element_->region().length(), |
| 68 &old_program); | 68 &old_program); |
| 69 if (old_parse_status != C_OK) { | 69 if (old_parse_status != C_OK) { |
| 70 LOG(ERROR) << "Cannot parse as WinPE " << old_element_->Name(); | 70 LOG(ERROR) << "Cannot parse an executable " << old_element_->Name(); |
| 71 return old_parse_status; | 71 return old_parse_status; |
| 72 } | 72 } |
| 73 | 73 |
| 74 AssemblyProgram* new_program = NULL; | 74 AssemblyProgram* new_program = NULL; |
| 75 Status new_parse_status = | 75 Status new_parse_status = |
| 76 ParseDetectedExecutable(new_element_->region().start(), | 76 ParseDetectedExecutable(new_element_->region().start(), |
| 77 new_element_->region().length(), | 77 new_element_->region().length(), |
| 78 &new_program); | 78 &new_program); |
| 79 if (new_parse_status != C_OK) { | 79 if (new_parse_status != C_OK) { |
| 80 DeleteAssemblyProgram(old_program); | 80 DeleteAssemblyProgram(old_program); |
| 81 LOG(ERROR) << "Cannot parse as WinPE " << new_element_->Name(); | 81 LOG(ERROR) << "Cannot parse an executable " << new_element_->Name(); |
| 82 return new_parse_status; | 82 return new_parse_status; |
| 83 } | 83 } |
| 84 | 84 |
| 85 // Trim labels below a certain threshold | 85 // Trim labels below a certain threshold |
| 86 Status trim_old_status = TrimLabels(old_program); | 86 Status trim_old_status = TrimLabels(old_program); |
| 87 if (trim_old_status != C_OK) { | 87 if (trim_old_status != C_OK) { |
| 88 DeleteAssemblyProgram(old_program); | 88 DeleteAssemblyProgram(old_program); |
| 89 return trim_old_status; | 89 return trim_old_status; |
| 90 } | 90 } |
| 91 | 91 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 private: | 141 private: |
| 142 virtual ~PatchGeneratorX86_32() { } | 142 virtual ~PatchGeneratorX86_32() { } |
| 143 | 143 |
| 144 ExecutableType kind_; | 144 ExecutableType kind_; |
| 145 | 145 |
| 146 DISALLOW_COPY_AND_ASSIGN(PatchGeneratorX86_32); | 146 DISALLOW_COPY_AND_ASSIGN(PatchGeneratorX86_32); |
| 147 }; | 147 }; |
| 148 | 148 |
| 149 } // namespace courgette | 149 } // namespace courgette |
| 150 #endif // COURGETTE_WIN32_X86_GENERATOR_H_ | 150 #endif // COURGETTE_WIN32_X86_GENERATOR_H_ |
| OLD | NEW |