OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 |
| 9 |
| 10 #include "base/file_path.h" |
| 11 |
8 namespace courgette { | 12 namespace courgette { |
9 | 13 |
10 // Status codes for Courgette APIs. | 14 // Status codes for Courgette APIs. |
11 // | 15 // |
12 // Client code should only rely on the distintion between C_OK and the other | 16 // Client code should only rely on the distintion between C_OK and the other |
13 // status codes. | 17 // status codes. |
14 // | 18 // |
15 enum Status { | 19 enum Status { |
16 C_OK = 1, // Successful operation. | 20 C_OK = 1, // Successful operation. |
17 | 21 |
(...skipping 19 matching lines...) Expand all Loading... |
37 // Internal errors. | 41 // Internal errors. |
38 C_STREAM_ERROR = 20, // Unexpected error from streams.h. | 42 C_STREAM_ERROR = 20, // Unexpected error from streams.h. |
39 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 |
40 // used up. | 44 // used up. |
41 C_SERIALIZATION_FAILED = 22, // | 45 C_SERIALIZATION_FAILED = 22, // |
42 C_DESERIALIZATION_FAILED = 23, // | 46 C_DESERIALIZATION_FAILED = 23, // |
43 C_INPUT_NOT_RECOGNIZED = 24, // Unrecognized input (not an executable). | 47 C_INPUT_NOT_RECOGNIZED = 24, // Unrecognized input (not an executable). |
44 C_DISASSEMBLY_FAILED = 25, // | 48 C_DISASSEMBLY_FAILED = 25, // |
45 C_ASSEMBLY_FAILED = 26, // | 49 C_ASSEMBLY_FAILED = 26, // |
46 C_ADJUSTMENT_FAILED = 27, // | 50 C_ADJUSTMENT_FAILED = 27, // |
47 | |
48 | |
49 }; | 51 }; |
50 | 52 |
51 class SinkStream; | 53 class SinkStream; |
52 class SinkStreamSet; | 54 class SinkStreamSet; |
53 class SourceStream; | 55 class SourceStream; |
54 class SourceStreamSet; | 56 class SourceStreamSet; |
55 | 57 |
56 class AssemblyProgram; | 58 class AssemblyProgram; |
57 class EncodedProgram; | 59 class EncodedProgram; |
58 | 60 |
59 // Applies the patch to the bytes in |old| and writes the transformed ensemble | 61 // Applies the patch to the bytes in |old| and writes the transformed ensemble |
60 // to |output|. | 62 // to |output|. |
61 // Returns C_OK unless something went wrong. | 63 // Returns C_OK unless something went wrong. |
62 Status ApplyEnsemblePatch(SourceStream* old, SourceStream* patch, | 64 Status ApplyEnsemblePatch(SourceStream* old, SourceStream* patch, |
63 SinkStream* output); | 65 SinkStream* output); |
64 | 66 |
65 // Applies the patch in |patch_file_name| to the bytes in |old_file_name| and | 67 // Applies the patch in |patch_file_name| to the bytes in |old_file_name| and |
66 // writes the transformed ensemble to |new_file_name|. | 68 // writes the transformed ensemble to |new_file_name|. |
67 // Returns C_OK unless something went wrong. | 69 // Returns C_OK unless something went wrong. |
68 // This function first validates that the patch file has a proper header, so the | 70 // This function first validates that the patch file has a proper header, so the |
69 // function can be used to 'try' a patch. | 71 // function can be used to 'try' a patch. |
70 Status ApplyEnsemblePatch(const wchar_t* old_file_name, | 72 |
71 const wchar_t* patch_file_name, | 73 Status ApplyEnsemblePatch(const FilePath::CharType* old_file_name, |
72 const wchar_t* new_file_name); | 74 const FilePath::CharType* patch_file_name, |
| 75 const FilePath::CharType* new_file_name); |
73 | 76 |
74 // Generates a patch that will transform the bytes in |old| into the bytes in | 77 // Generates a patch that will transform the bytes in |old| into the bytes in |
75 // |target|. | 78 // |target|. |
76 // Returns C_OK unless something when wrong (unexpected). | 79 // Returns C_OK unless something when wrong (unexpected). |
77 Status GenerateEnsemblePatch(SourceStream* old, SourceStream* target, | 80 Status GenerateEnsemblePatch(SourceStream* old, SourceStream* target, |
78 SinkStream* patch); | 81 SinkStream* patch); |
79 | 82 |
80 // Parses a Windows 32-bit 'Portable Executable' format file from memory, | 83 // Parses a Windows 32-bit 'Portable Executable' format file from memory, |
81 // storing the pointer to the AssemblyProgram in |*output|. | 84 // storing the pointer to the AssemblyProgram in |*output|. |
82 // Returns C_OK if successful, otherwise returns an error status and sets | 85 // Returns C_OK if successful, otherwise returns an error status and sets |
(...skipping 26 matching lines...) Expand all Loading... |
109 | 112 |
110 // Used to free an EncodedProgram returned by other APIs. | 113 // Used to free an EncodedProgram returned by other APIs. |
111 void DeleteEncodedProgram(EncodedProgram* encoded); | 114 void DeleteEncodedProgram(EncodedProgram* encoded); |
112 | 115 |
113 // Adjusts |program| to look more like |model|. | 116 // Adjusts |program| to look more like |model|. |
114 // | 117 // |
115 Status Adjust(const AssemblyProgram& model, AssemblyProgram *program); | 118 Status Adjust(const AssemblyProgram& model, AssemblyProgram *program); |
116 | 119 |
117 } // namespace courgette | 120 } // namespace courgette |
118 #endif // COURGETTE_COURGETTE_H_ | 121 #endif // COURGETTE_COURGETTE_H_ |
OLD | NEW |