| 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 12 matching lines...) Expand all Loading... |
| 23 #include "base/basictypes.h" | 23 #include "base/basictypes.h" |
| 24 | 24 |
| 25 #include "courgette/courgette.h" | 25 #include "courgette/courgette.h" |
| 26 #include "courgette/region.h" | 26 #include "courgette/region.h" |
| 27 #include "courgette/streams.h" | 27 #include "courgette/streams.h" |
| 28 | 28 |
| 29 namespace courgette { | 29 namespace courgette { |
| 30 | 30 |
| 31 // Forward declarations: | 31 // Forward declarations: |
| 32 class Ensemble; | 32 class Ensemble; |
| 33 class PEInfo; | |
| 34 | 33 |
| 35 // An Element is a region of an Ensemble with an identifyable kind. | 34 // An Element is a region of an Ensemble with an identifyable kind. |
| 36 // | 35 // |
| 37 class Element { | 36 class Element { |
| 38 public: | 37 public: |
| 39 Element(ExecutableType kind, | 38 Element(ExecutableType kind, |
| 40 Ensemble* ensemble, | 39 Ensemble* ensemble, |
| 41 const Region& region, | 40 const Region& region); |
| 42 PEInfo*info); | |
| 43 | 41 |
| 44 virtual ~Element(); | 42 virtual ~Element(); |
| 45 | 43 |
| 46 ExecutableType kind() const { return kind_; } | 44 ExecutableType kind() const { return kind_; } |
| 47 const Region& region() const { return region_; } | 45 const Region& region() const { return region_; } |
| 48 | 46 |
| 49 // The name is used only for debugging and logging. | 47 // The name is used only for debugging and logging. |
| 50 virtual std::string Name() const; | 48 virtual std::string Name() const; |
| 51 | 49 |
| 52 // Returns the byte position of this Element relative to the start of | 50 // Returns the byte position of this Element relative to the start of |
| 53 // containing Ensemble. | 51 // containing Ensemble. |
| 54 size_t offset_in_ensemble() const; | 52 size_t offset_in_ensemble() const; |
| 55 | 53 |
| 56 // The ImageInfo for this executable | |
| 57 virtual PEInfo* GetImageInfo() const { return info_; } | |
| 58 | |
| 59 private: | 54 private: |
| 60 ExecutableType kind_; | 55 ExecutableType kind_; |
| 61 Ensemble* ensemble_; | 56 Ensemble* ensemble_; |
| 62 Region region_; | 57 Region region_; |
| 63 PEInfo *info_; | |
| 64 | 58 |
| 65 DISALLOW_COPY_AND_ASSIGN(Element); | 59 DISALLOW_COPY_AND_ASSIGN(Element); |
| 66 }; | 60 }; |
| 67 | 61 |
| 68 | 62 |
| 69 class Ensemble { | 63 class Ensemble { |
| 70 public: | 64 public: |
| 71 Ensemble(const Region& region, const char* name) | 65 Ensemble(const Region& region, const char* name) |
| 72 : region_(region), name_(name) {} | 66 : region_(region), name_(name) {} |
| 73 ~Ensemble(); | 67 ~Ensemble(); |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 SinkStream* reformed_element); | 245 SinkStream* reformed_element); |
| 252 | 246 |
| 253 protected: | 247 protected: |
| 254 Element* old_element_; | 248 Element* old_element_; |
| 255 Element* new_element_; | 249 Element* new_element_; |
| 256 TransformationPatcher* patcher_; | 250 TransformationPatcher* patcher_; |
| 257 }; | 251 }; |
| 258 | 252 |
| 259 } // namespace | 253 } // namespace |
| 260 #endif // COURGETTE_ENSEMBLE_H_ | 254 #endif // COURGETTE_ENSEMBLE_H_ |
| OLD | NEW |