| OLD | NEW |
| 1 // Copyright (c) 2009 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/file_path.h" | 10 #include "base/file_path.h" |
| 11 | 11 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 C_STREAM_NOT_CONSUMED = 21, // Stream has extra data, is expected to be | 43 C_STREAM_NOT_CONSUMED = 21, // Stream has extra data, is expected to be |
| 44 // used up. | 44 // used up. |
| 45 C_SERIALIZATION_FAILED = 22, // | 45 C_SERIALIZATION_FAILED = 22, // |
| 46 C_DESERIALIZATION_FAILED = 23, // | 46 C_DESERIALIZATION_FAILED = 23, // |
| 47 C_INPUT_NOT_RECOGNIZED = 24, // Unrecognized input (not an executable). | 47 C_INPUT_NOT_RECOGNIZED = 24, // Unrecognized input (not an executable). |
| 48 C_DISASSEMBLY_FAILED = 25, // | 48 C_DISASSEMBLY_FAILED = 25, // |
| 49 C_ASSEMBLY_FAILED = 26, // | 49 C_ASSEMBLY_FAILED = 26, // |
| 50 C_ADJUSTMENT_FAILED = 27, // | 50 C_ADJUSTMENT_FAILED = 27, // |
| 51 }; | 51 }; |
| 52 | 52 |
| 53 // What type of executable is something |
| 54 // Generally corresponds to CourgettePatchFile::TransformationMethodId |
| 55 enum ExecutableType { |
| 56 UNKNOWN, |
| 57 WIN32_X86 |
| 58 }; |
| 59 |
| 53 class SinkStream; | 60 class SinkStream; |
| 54 class SinkStreamSet; | 61 class SinkStreamSet; |
| 55 class SourceStream; | 62 class SourceStream; |
| 56 class SourceStreamSet; | 63 class SourceStreamSet; |
| 57 | 64 |
| 58 class AssemblyProgram; | 65 class AssemblyProgram; |
| 59 class EncodedProgram; | 66 class EncodedProgram; |
| 60 | 67 |
| 61 // Applies the patch to the bytes in |old| and writes the transformed ensemble | 68 // Applies the patch to the bytes in |old| and writes the transformed ensemble |
| 62 // to |output|. | 69 // to |output|. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 77 // Generates a patch that will transform the bytes in |old| into the bytes in | 84 // Generates a patch that will transform the bytes in |old| into the bytes in |
| 78 // |target|. | 85 // |target|. |
| 79 // Returns C_OK unless something when wrong (unexpected). | 86 // Returns C_OK unless something when wrong (unexpected). |
| 80 Status GenerateEnsemblePatch(SourceStream* old, SourceStream* target, | 87 Status GenerateEnsemblePatch(SourceStream* old, SourceStream* target, |
| 81 SinkStream* patch); | 88 SinkStream* patch); |
| 82 | 89 |
| 83 // Parses a Windows 32-bit 'Portable Executable' format file from memory, | 90 // Parses a Windows 32-bit 'Portable Executable' format file from memory, |
| 84 // storing the pointer to the AssemblyProgram in |*output|. | 91 // storing the pointer to the AssemblyProgram in |*output|. |
| 85 // Returns C_OK if successful, otherwise returns an error status and sets | 92 // Returns C_OK if successful, otherwise returns an error status and sets |
| 86 // |*output| to NULL. | 93 // |*output| to NULL. |
| 87 Status ParseWin32X86PE(const void* buffer, size_t length, | 94 ExecutableType DetectExecutableType(const void* buffer, size_t length); |
| 88 AssemblyProgram** output); | 95 |
| 96 // Attempts to detect the type of executable, and parse it with the |
| 97 // appropriate tools, storing the pointer to the AssemblyProgram in |*output|. |
| 98 // Returns C_OK if successful, otherwise returns an error status and sets |
| 99 // |*output| to NULL. |
| 100 Status ParseDetectedExecutable(const void* buffer, size_t length, |
| 101 AssemblyProgram** output); |
| 89 | 102 |
| 90 // Converts |program| into encoded form, returning it as |*output|. | 103 // Converts |program| into encoded form, returning it as |*output|. |
| 91 // Returns C_OK if succeeded, otherwise returns an error status and | 104 // Returns C_OK if succeeded, otherwise returns an error status and |
| 92 // sets |*output| to NULL | 105 // sets |*output| to NULL |
| 93 Status Encode(AssemblyProgram* program, EncodedProgram** output); | 106 Status Encode(AssemblyProgram* program, EncodedProgram** output); |
| 94 | 107 |
| 95 | 108 |
| 96 // Serializes |encoded| into the stream set. | 109 // Serializes |encoded| into the stream set. |
| 97 // Returns C_OK if succeeded, otherwise returns an error status. | 110 // Returns C_OK if succeeded, otherwise returns an error status. |
| 98 Status WriteEncodedProgram(EncodedProgram* encoded, SinkStreamSet* sink); | 111 Status WriteEncodedProgram(EncodedProgram* encoded, SinkStreamSet* sink); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 112 | 125 |
| 113 // Used to free an EncodedProgram returned by other APIs. | 126 // Used to free an EncodedProgram returned by other APIs. |
| 114 void DeleteEncodedProgram(EncodedProgram* encoded); | 127 void DeleteEncodedProgram(EncodedProgram* encoded); |
| 115 | 128 |
| 116 // Adjusts |program| to look more like |model|. | 129 // Adjusts |program| to look more like |model|. |
| 117 // | 130 // |
| 118 Status Adjust(const AssemblyProgram& model, AssemblyProgram *program); | 131 Status Adjust(const AssemblyProgram& model, AssemblyProgram *program); |
| 119 | 132 |
| 120 } // namespace courgette | 133 } // namespace courgette |
| 121 #endif // COURGETTE_COURGETTE_H_ | 134 #endif // COURGETTE_COURGETTE_H_ |
| OLD | NEW |