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

Side by Side Diff: courgette/courgette.h

Issue 7920004: Start refactoring to reduce executable type knowledge. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years, 3 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
OLDNEW
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 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"
(...skipping 32 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 being patched?
54 enum ExecutableType {
55 UNKNOWN,
56 WIN32_X86
57 };
58
53 class SinkStream; 59 class SinkStream;
54 class SinkStreamSet; 60 class SinkStreamSet;
55 class SourceStream; 61 class SourceStream;
56 class SourceStreamSet; 62 class SourceStreamSet;
57 63
58 class AssemblyProgram; 64 class AssemblyProgram;
59 class EncodedProgram; 65 class EncodedProgram;
60 66
61 // Applies the patch to the bytes in |old| and writes the transformed ensemble 67 // Applies the patch to the bytes in |old| and writes the transformed ensemble
62 // to |output|. 68 // to |output|.
(...skipping 14 matching lines...) Expand all
77 // Generates a patch that will transform the bytes in |old| into the bytes in 83 // Generates a patch that will transform the bytes in |old| into the bytes in
78 // |target|. 84 // |target|.
79 // Returns C_OK unless something when wrong (unexpected). 85 // Returns C_OK unless something when wrong (unexpected).
80 Status GenerateEnsemblePatch(SourceStream* old, SourceStream* target, 86 Status GenerateEnsemblePatch(SourceStream* old, SourceStream* target,
81 SinkStream* patch); 87 SinkStream* patch);
82 88
83 // Parses a Windows 32-bit 'Portable Executable' format file from memory, 89 // Parses a Windows 32-bit 'Portable Executable' format file from memory,
84 // storing the pointer to the AssemblyProgram in |*output|. 90 // storing the pointer to the AssemblyProgram in |*output|.
85 // Returns C_OK if successful, otherwise returns an error status and sets 91 // Returns C_OK if successful, otherwise returns an error status and sets
86 // |*output| to NULL. 92 // |*output| to NULL.
87 Status ParseWin32X86PE(const void* buffer, size_t length, 93 ExecutableType DetectExecutableType(const void* buffer, size_t length);
88 AssemblyProgram** output); 94
95 // Attempts to detect the type of executable, and parse it with the
96 // appropriate tools, storing the pointer to the AssemblyProgram in |*output|.
97 // Returns C_OK if successful, otherwise returns an error status and sets
98 // |*output| to NULL.
99 Status ParseDetectedExecutable(const void* buffer, size_t length,
100 AssemblyProgram** output);
89 101
90 // Converts |program| into encoded form, returning it as |*output|. 102 // Converts |program| into encoded form, returning it as |*output|.
91 // Returns C_OK if succeeded, otherwise returns an error status and 103 // Returns C_OK if succeeded, otherwise returns an error status and
92 // sets |*output| to NULL 104 // sets |*output| to NULL
93 Status Encode(AssemblyProgram* program, EncodedProgram** output); 105 Status Encode(AssemblyProgram* program, EncodedProgram** output);
94 106
95 107
96 // Serializes |encoded| into the stream set. 108 // Serializes |encoded| into the stream set.
97 // Returns C_OK if succeeded, otherwise returns an error status. 109 // Returns C_OK if succeeded, otherwise returns an error status.
98 Status WriteEncodedProgram(EncodedProgram* encoded, SinkStreamSet* sink); 110 Status WriteEncodedProgram(EncodedProgram* encoded, SinkStreamSet* sink);
(...skipping 13 matching lines...) Expand all
112 124
113 // Used to free an EncodedProgram returned by other APIs. 125 // Used to free an EncodedProgram returned by other APIs.
114 void DeleteEncodedProgram(EncodedProgram* encoded); 126 void DeleteEncodedProgram(EncodedProgram* encoded);
115 127
116 // Adjusts |program| to look more like |model|. 128 // Adjusts |program| to look more like |model|.
117 // 129 //
118 Status Adjust(const AssemblyProgram& model, AssemblyProgram *program); 130 Status Adjust(const AssemblyProgram& model, AssemblyProgram *program);
119 131
120 } // namespace courgette 132 } // namespace courgette
121 #endif // COURGETTE_COURGETTE_H_ 133 #endif // COURGETTE_COURGETTE_H_
OLDNEW
« no previous file with comments | « .gitignore ('k') | courgette/courgette.gyp » ('j') | courgette/versioning_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698