Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(287)

Side by Side Diff: courgette/courgette.h

Issue 8344037: Start refactoring to reduce executable type knowledge. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Fix comment. Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « courgette/base_test_unittest.cc ('k') | courgette/courgette.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 10 matching lines...) Expand all
73 Status ApplyEnsemblePatch(const FilePath::CharType* old_file_name, 80 Status ApplyEnsemblePatch(const FilePath::CharType* old_file_name,
74 const FilePath::CharType* patch_file_name, 81 const FilePath::CharType* patch_file_name,
75 const FilePath::CharType* new_file_name); 82 const FilePath::CharType* new_file_name);
76 83
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 // Detects the type of an executable, and returns UNKNOWN if it cannot
84 // storing the pointer to the AssemblyProgram in |*output|. 91 // be parsed.
92 ExecutableType DetectExecutableType(const void* buffer, size_t length);
93
94 // Attempts to detect the type of executable, and parse it with the
95 // appropriate tools, storing the pointer to the AssemblyProgram in |*output|.
85 // Returns C_OK if successful, otherwise returns an error status and sets 96 // Returns C_OK if successful, otherwise returns an error status and sets
86 // |*output| to NULL. 97 // |*output| to NULL.
87 Status ParseWin32X86PE(const void* buffer, size_t length, 98 Status ParseDetectedExecutable(const void* buffer, size_t length,
88 AssemblyProgram** output); 99 AssemblyProgram** output);
89 100
90 // Converts |program| into encoded form, returning it as |*output|. 101 // Converts |program| into encoded form, returning it as |*output|.
91 // Returns C_OK if succeeded, otherwise returns an error status and 102 // Returns C_OK if succeeded, otherwise returns an error status and
92 // sets |*output| to NULL 103 // sets |*output| to NULL
93 Status Encode(AssemblyProgram* program, EncodedProgram** output); 104 Status Encode(AssemblyProgram* program, EncodedProgram** output);
94 105
95 106
96 // Serializes |encoded| into the stream set. 107 // Serializes |encoded| into the stream set.
97 // Returns C_OK if succeeded, otherwise returns an error status. 108 // Returns C_OK if succeeded, otherwise returns an error status.
98 Status WriteEncodedProgram(EncodedProgram* encoded, SinkStreamSet* sink); 109 Status WriteEncodedProgram(EncodedProgram* encoded, SinkStreamSet* sink);
(...skipping 13 matching lines...) Expand all
112 123
113 // Used to free an EncodedProgram returned by other APIs. 124 // Used to free an EncodedProgram returned by other APIs.
114 void DeleteEncodedProgram(EncodedProgram* encoded); 125 void DeleteEncodedProgram(EncodedProgram* encoded);
115 126
116 // Adjusts |program| to look more like |model|. 127 // Adjusts |program| to look more like |model|.
117 // 128 //
118 Status Adjust(const AssemblyProgram& model, AssemblyProgram *program); 129 Status Adjust(const AssemblyProgram& model, AssemblyProgram *program);
119 130
120 } // namespace courgette 131 } // namespace courgette
121 #endif // COURGETTE_COURGETTE_H_ 132 #endif // COURGETTE_COURGETTE_H_
OLDNEW
« no previous file with comments | « courgette/base_test_unittest.cc ('k') | courgette/courgette.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698