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 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/logging.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 | 12 |
13 #include "courgette/ensemble.h" | 13 #include "courgette/ensemble.h" |
14 | 14 |
15 namespace courgette { | 15 namespace courgette { |
16 | 16 |
17 class CourgetteWin32X86PatchGenerator : public TransformationPatchGenerator { | 17 class PatchGeneratorX86_32 : public TransformationPatchGenerator { |
18 public: | 18 public: |
19 CourgetteWin32X86PatchGenerator(Element* old_element, | 19 PatchGeneratorX86_32(Element* old_element, |
20 Element* new_element, | 20 Element* new_element, |
21 CourgetteWin32X86Patcher* patcher) | 21 PatcherX86_32* patcher, |
22 : TransformationPatchGenerator(old_element, new_element, patcher) { | 22 ExecutableType kind) |
| 23 : TransformationPatchGenerator(old_element, new_element, patcher), |
| 24 kind_(kind) { |
23 } | 25 } |
24 | 26 |
25 CourgettePatchFile::TransformationMethodId Kind() { | 27 virtual ExecutableType Kind() { return kind_; } |
26 return CourgettePatchFile::T_COURGETTE_WIN32_X86; | |
27 } | |
28 | 28 |
29 Status WriteInitialParameters(SinkStream* parameter_stream) { | 29 Status WriteInitialParameters(SinkStream* parameter_stream) { |
30 if (!parameter_stream->WriteSizeVarint32( | 30 if (!parameter_stream->WriteSizeVarint32( |
31 old_element_->offset_in_ensemble()) || | 31 old_element_->offset_in_ensemble()) || |
32 !parameter_stream->WriteSizeVarint32(old_element_->region().length())) { | 32 !parameter_stream->WriteSizeVarint32(old_element_->region().length())) { |
33 return C_STREAM_ERROR; | 33 return C_STREAM_ERROR; |
34 } | 34 } |
35 return C_OK; | 35 return C_OK; |
36 // TODO(sra): Initialize |patcher_| with these parameters. | 36 // TODO(sra): Initialize |patcher_| with these parameters. |
37 } | 37 } |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 return C_OK; | 117 return C_OK; |
118 } | 118 } |
119 | 119 |
120 Status Reform(SourceStreamSet* transformed_element, | 120 Status Reform(SourceStreamSet* transformed_element, |
121 SinkStream* reformed_element) { | 121 SinkStream* reformed_element) { |
122 return TransformationPatchGenerator::Reform(transformed_element, | 122 return TransformationPatchGenerator::Reform(transformed_element, |
123 reformed_element); | 123 reformed_element); |
124 } | 124 } |
125 | 125 |
126 private: | 126 private: |
127 ~CourgetteWin32X86PatchGenerator() { } | 127 virtual ~PatchGeneratorX86_32() { } |
128 | 128 |
129 DISALLOW_COPY_AND_ASSIGN(CourgetteWin32X86PatchGenerator); | 129 ExecutableType kind_; |
| 130 |
| 131 DISALLOW_COPY_AND_ASSIGN(PatchGeneratorX86_32); |
130 }; | 132 }; |
131 | 133 |
132 } // namespace courgette | 134 } // namespace courgette |
133 #endif // COURGETTE_WIN32_X86_GENERATOR_H_ | 135 #endif // COURGETTE_WIN32_X86_GENERATOR_H_ |
OLD | NEW |