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 // The main idea in Courgette is to do patching *under a tranformation*. The | 5 // The main idea in Courgette is to do patching *under a tranformation*. The |
6 // input is transformed into a new representation, patching occurs in the new | 6 // input is transformed into a new representation, patching occurs in the new |
7 // repesentation, and then the tranform is reversed to get the patched data. | 7 // repesentation, and then the tranform is reversed to get the patched data. |
8 // | 8 // |
9 // The idea is applied to pieces (or 'Elements') of the whole (or 'Ensemble'). | 9 // The idea is applied to pieces (or 'Elements') of the whole (or 'Ensemble'). |
10 // Each of the elements has to go through the same set of steps in lock-step, | 10 // Each of the elements has to go through the same set of steps in lock-step, |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 // stream 3: | 126 // stream 3: |
127 // correction: | 127 // correction: |
128 // base-file | 128 // base-file |
129 // element-1 | 129 // element-1 |
130 // element-2 | 130 // element-2 |
131 // ... | 131 // ... |
132 | 132 |
133 static const uint32 kMagic = 'C' | ('o' << 8) | ('u' << 16); | 133 static const uint32 kMagic = 'C' | ('o' << 8) | ('u' << 16); |
134 | 134 |
135 static const uint32 kVersion = 20110216; | 135 static const uint32 kVersion = 20110216; |
136 | |
137 // Transformation method IDs. These are embedded in generated files, so | |
138 // never remove or change an existing id. | |
139 enum TransformationMethodId { | |
140 T_COURGETTE_WIN32_X86 = 1, // Windows 32 bit 'Portable Executable' x86. | |
141 }; | |
142 }; | 136 }; |
143 | 137 |
144 // For any transform you would implement both a TransformationPatcher and a | 138 // For any transform you would implement both a TransformationPatcher and a |
145 // TransformationPatchGenerator. | 139 // TransformationPatchGenerator. |
146 // | 140 // |
147 // TransformationPatcher is the interface which abstracts out the actual | 141 // TransformationPatcher is the interface which abstracts out the actual |
148 // transformation used on an Element. The patching itself happens outside the | 142 // transformation used on an Element. The patching itself happens outside the |
149 // actions of a TransformationPatcher. There are four steps. | 143 // actions of a TransformationPatcher. There are four steps. |
150 // | 144 // |
151 // The first step is an Init step. The parameters to the Init step identify the | 145 // The first step is an Init step. The parameters to the Init step identify the |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 // | 195 // |
202 class TransformationPatchGenerator { | 196 class TransformationPatchGenerator { |
203 public: | 197 public: |
204 TransformationPatchGenerator(Element* old_element, | 198 TransformationPatchGenerator(Element* old_element, |
205 Element* new_element, | 199 Element* new_element, |
206 TransformationPatcher* patcher); | 200 TransformationPatcher* patcher); |
207 | 201 |
208 virtual ~TransformationPatchGenerator(); | 202 virtual ~TransformationPatchGenerator(); |
209 | 203 |
210 // Returns the TransformationMethodId that identies this transformation. | 204 // Returns the TransformationMethodId that identies this transformation. |
211 virtual CourgettePatchFile::TransformationMethodId Kind() = 0; | 205 virtual ExecutableType Kind() = 0; |
212 | 206 |
213 // Writes the parameters that will be passed to TransformationPatcher::Init. | 207 // Writes the parameters that will be passed to TransformationPatcher::Init. |
214 virtual Status WriteInitialParameters(SinkStream* parameter_stream) = 0; | 208 virtual Status WriteInitialParameters(SinkStream* parameter_stream) = 0; |
215 | 209 |
216 // Predicts the transform parameters for the |old_element|. This must match | 210 // Predicts the transform parameters for the |old_element|. This must match |
217 // exactly the output that will be produced by the PredictTransformParameters | 211 // exactly the output that will be produced by the PredictTransformParameters |
218 // method of the corresponding subclass of TransformationPatcher. This method | 212 // method of the corresponding subclass of TransformationPatcher. This method |
219 // is not pure. The default implementation delegates to the patcher to | 213 // is not pure. The default implementation delegates to the patcher to |
220 // guarantee matching output. | 214 // guarantee matching output. |
221 virtual Status PredictTransformParameters(SinkStreamSet* prediction); | 215 virtual Status PredictTransformParameters(SinkStreamSet* prediction); |
(...skipping 23 matching lines...) Expand all Loading... |
245 SinkStream* reformed_element); | 239 SinkStream* reformed_element); |
246 | 240 |
247 protected: | 241 protected: |
248 Element* old_element_; | 242 Element* old_element_; |
249 Element* new_element_; | 243 Element* new_element_; |
250 TransformationPatcher* patcher_; | 244 TransformationPatcher* patcher_; |
251 }; | 245 }; |
252 | 246 |
253 } // namespace | 247 } // namespace |
254 #endif // COURGETTE_ENSEMBLE_H_ | 248 #endif // COURGETTE_ENSEMBLE_H_ |
OLD | NEW |