| 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 // This is the transformation and adjustment for Windows X86 executables. | 5 // This is the transformation and adjustment for Windows X86 executables. |
| 6 | 6 |
| 7 #ifndef COURGETTE_WIN32_X86_GENERATOR_H_ | 7 #ifndef COURGETTE_WIN32_X86_GENERATOR_H_ |
| 8 #define COURGETTE_WIN32_X86_GENERATOR_H_ | 8 #define COURGETTE_WIN32_X86_GENERATOR_H_ |
| 9 | 9 |
| 10 #include "base/logging.h" |
| 10 #include "base/scoped_ptr.h" | 11 #include "base/scoped_ptr.h" |
| 11 | 12 |
| 12 #include "courgette/ensemble.h" | 13 #include "courgette/ensemble.h" |
| 13 | 14 |
| 14 namespace courgette { | 15 namespace courgette { |
| 15 | 16 |
| 16 class CourgetteWin32X86PatchGenerator : public TransformationPatchGenerator { | 17 class CourgetteWin32X86PatchGenerator : public TransformationPatchGenerator { |
| 17 public: | 18 public: |
| 18 CourgetteWin32X86PatchGenerator(Element* old_element, | 19 CourgetteWin32X86PatchGenerator(Element* old_element, |
| 19 Element* new_element, | 20 Element* new_element, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 if (!corrected_parameters->Empty()) | 54 if (!corrected_parameters->Empty()) |
| 54 return C_GENERAL_ERROR; | 55 return C_GENERAL_ERROR; |
| 55 | 56 |
| 56 // Generate old version of program using |corrected_parameters|. | 57 // Generate old version of program using |corrected_parameters|. |
| 57 // TODO(sra): refactor to use same code from patcher_. | 58 // TODO(sra): refactor to use same code from patcher_. |
| 58 AssemblyProgram* old_program = NULL; | 59 AssemblyProgram* old_program = NULL; |
| 59 Status old_parse_status = | 60 Status old_parse_status = |
| 60 ParseWin32X86PE(old_element_->region().start(), | 61 ParseWin32X86PE(old_element_->region().start(), |
| 61 old_element_->region().length(), | 62 old_element_->region().length(), |
| 62 &old_program); | 63 &old_program); |
| 63 if (old_parse_status != C_OK) | 64 if (old_parse_status != C_OK) { |
| 65 LOG(ERROR) << "Cannot parse as Win32X86PE " << old_element_->Name(); |
| 64 return old_parse_status; | 66 return old_parse_status; |
| 67 } |
| 65 | 68 |
| 66 AssemblyProgram* new_program = NULL; | 69 AssemblyProgram* new_program = NULL; |
| 67 Status new_parse_status = | 70 Status new_parse_status = |
| 68 ParseWin32X86PE(new_element_->region().start(), | 71 ParseWin32X86PE(new_element_->region().start(), |
| 69 new_element_->region().length(), | 72 new_element_->region().length(), |
| 70 &new_program); | 73 &new_program); |
| 71 if (new_parse_status != C_OK) { | 74 if (new_parse_status != C_OK) { |
| 72 DeleteAssemblyProgram(old_program); | 75 DeleteAssemblyProgram(old_program); |
| 76 LOG(ERROR) << "Cannot parse as Win32X86PE " << new_element_->Name(); |
| 73 return new_parse_status; | 77 return new_parse_status; |
| 74 } | 78 } |
| 75 | 79 |
| 76 EncodedProgram* old_encoded = NULL; | 80 EncodedProgram* old_encoded = NULL; |
| 77 Status old_encode_status = Encode(old_program, &old_encoded); | 81 Status old_encode_status = Encode(old_program, &old_encoded); |
| 78 if (old_encode_status != C_OK) { | 82 if (old_encode_status != C_OK) { |
| 79 DeleteAssemblyProgram(old_program); | 83 DeleteAssemblyProgram(old_program); |
| 80 return old_encode_status; | 84 return old_encode_status; |
| 81 } | 85 } |
| 82 | 86 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 } | 121 } |
| 118 | 122 |
| 119 private: | 123 private: |
| 120 ~CourgetteWin32X86PatchGenerator() { } | 124 ~CourgetteWin32X86PatchGenerator() { } |
| 121 | 125 |
| 122 DISALLOW_COPY_AND_ASSIGN(CourgetteWin32X86PatchGenerator); | 126 DISALLOW_COPY_AND_ASSIGN(CourgetteWin32X86PatchGenerator); |
| 123 }; | 127 }; |
| 124 | 128 |
| 125 } // namespace courgette | 129 } // namespace courgette |
| 126 #endif // COURGETTE_WIN32_X86_GENERATOR_H_ | 130 #endif // COURGETTE_WIN32_X86_GENERATOR_H_ |
| OLD | NEW |