| 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 #ifndef COURGETTE_COURGETTE_H_ | 5 #ifndef COURGETTE_COURGETTE_H_ |
| 6 #define COURGETTE_COURGETTE_H_ | 6 #define COURGETTE_COURGETTE_H_ |
| 7 | 7 |
| 8 #include <stddef.h> // Required to define size_t on GCC | 8 #include <stddef.h> // Required to define size_t on GCC |
| 9 | 9 |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 Status ApplyEnsemblePatch(const base::FilePath::CharType* old_file_name, | 83 Status ApplyEnsemblePatch(const base::FilePath::CharType* old_file_name, |
| 84 const base::FilePath::CharType* patch_file_name, | 84 const base::FilePath::CharType* patch_file_name, |
| 85 const base::FilePath::CharType* new_file_name); | 85 const base::FilePath::CharType* new_file_name); |
| 86 | 86 |
| 87 // Generates a patch that will transform the bytes in |old| into the bytes in | 87 // Generates a patch that will transform the bytes in |old| into the bytes in |
| 88 // |target|. | 88 // |target|. |
| 89 // Returns C_OK unless something when wrong (unexpected). | 89 // Returns C_OK unless something when wrong (unexpected). |
| 90 Status GenerateEnsemblePatch(SourceStream* old, SourceStream* target, | 90 Status GenerateEnsemblePatch(SourceStream* old, SourceStream* target, |
| 91 SinkStream* patch); | 91 SinkStream* patch); |
| 92 | 92 |
| 93 // Detects the type of an executable file, and it's length. The length | |
| 94 // may be slightly smaller than some executables (like ELF), but will include | |
| 95 // all bytes the courgette algorithm has special benefit for. | |
| 96 // On success: | |
| 97 // Fill in type and detected_length, and return C_OK. | |
| 98 // On failure: | |
| 99 // Fill in type with UNKNOWN, detected_length with 0, and | |
| 100 // return C_INPUT_NOT_RECOGNIZED | |
| 101 Status DetectExecutableType(const void* buffer, size_t length, | |
| 102 ExecutableType* type, | |
| 103 size_t* detected_length); | |
| 104 | |
| 105 // Attempts to detect the type of executable, and parse it with the | |
| 106 // appropriate tools, storing the pointer to the AssemblyProgram in |*output|. | |
| 107 // Returns C_OK if successful, otherwise returns an error status and sets | |
| 108 // |*output| to NULL. | |
| 109 Status ParseDetectedExecutable(const void* buffer, size_t length, | |
| 110 AssemblyProgram** output); | |
| 111 | |
| 112 // Converts |program| into encoded form, returning it as |*output|. | |
| 113 // Returns C_OK if succeeded, otherwise returns an error status and | |
| 114 // sets |*output| to NULL | |
| 115 Status Encode(AssemblyProgram* program, EncodedProgram** output); | |
| 116 | |
| 117 // Serializes |encoded| into the stream set. | 93 // Serializes |encoded| into the stream set. |
| 118 // Returns C_OK if succeeded, otherwise returns an error status. | 94 // Returns C_OK if succeeded, otherwise returns an error status. |
| 119 Status WriteEncodedProgram(EncodedProgram* encoded, SinkStreamSet* sink); | 95 Status WriteEncodedProgram(EncodedProgram* encoded, SinkStreamSet* sink); |
| 120 | 96 |
| 121 // Assembles |encoded|, emitting the bytes into |buffer|. | 97 // Assembles |encoded|, emitting the bytes into |buffer|. |
| 122 // Returns C_OK if succeeded, otherwise returns an error status and leaves | 98 // Returns C_OK if succeeded, otherwise returns an error status and leaves |
| 123 // |buffer| in an undefined state. | 99 // |buffer| in an undefined state. |
| 124 Status Assemble(EncodedProgram* encoded, SinkStream* buffer); | 100 Status Assemble(EncodedProgram* encoded, SinkStream* buffer); |
| 125 | 101 |
| 126 // Deserializes program from the stream set. | |
| 127 // Returns C_OK if succeeded, otherwise returns an error status and | |
| 128 // sets |*output| to NULL | |
| 129 Status ReadEncodedProgram(SourceStreamSet* source, EncodedProgram** output); | |
| 130 | |
| 131 // Used to free an AssemblyProgram returned by other APIs. | |
| 132 void DeleteAssemblyProgram(AssemblyProgram* program); | |
| 133 | |
| 134 // Used to free an EncodedProgram returned by other APIs. | |
| 135 void DeleteEncodedProgram(EncodedProgram* encoded); | |
| 136 | |
| 137 // Adjusts |program| to look more like |model|. | 102 // Adjusts |program| to look more like |model|. |
| 138 // | 103 // |
| 139 Status Adjust(const AssemblyProgram& model, AssemblyProgram *program); | 104 Status Adjust(const AssemblyProgram& model, AssemblyProgram *program); |
| 140 | 105 |
| 141 } // namespace courgette | 106 } // namespace courgette |
| 107 |
| 142 #endif // COURGETTE_COURGETTE_H_ | 108 #endif // COURGETTE_COURGETTE_H_ |
| OLD | NEW |