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

Unified Diff: courgette/program_detector.h

Issue 2055343002: Courgette: Add static method QuickDetect() to optimize program detection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sync Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « courgette/disassembler_win32_x86_unittest.cc ('k') | courgette/program_detector.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: courgette/program_detector.h
diff --git a/courgette/program_detector.h b/courgette/program_detector.h
index 06f1da3f84762791181742776de0d466ded7dec8..62f4dc91f131df294464280f1c67afeacb516285 100644
--- a/courgette/program_detector.h
+++ b/courgette/program_detector.h
@@ -6,6 +6,7 @@
#define COURGETTE_PROGRAM_DETECTOR_H_
#include <stddef.h>
+#include <stdint.h>
#include <memory>
@@ -23,11 +24,21 @@ class AssemblyProgram;
// On failure:
// Fills in |type| with UNKNOWN, |detected_length| with 0, and returns
// C_INPUT_NOT_RECOGNIZED.
-Status DetectExecutableType(const void* buffer,
+Status DetectExecutableType(const uint8_t* buffer,
size_t length,
ExecutableType* type,
size_t* detected_length);
+// Same as above, takes void* instead.
+// TODO(etiennep): Propagate "const uint8_t*" upwards.
+inline Status DetectExecutableType(const void* buffer,
+ size_t length,
+ ExecutableType* type,
+ size_t* detected_length) {
+ return DetectExecutableType(reinterpret_cast<const uint8_t*>(buffer), length,
+ type, detected_length);
+}
+
// Attempts to detect the type of executable, and parse it with the appropriate
// tools.
// On success:
@@ -35,10 +46,20 @@ Status DetectExecutableType(const void* buffer,
// C_OK.
// On failure:
// Returns an error status and assigns |*output| to null.
-Status ParseDetectedExecutable(const void* buffer,
+Status ParseDetectedExecutable(const uint8_t* buffer,
size_t length,
std::unique_ptr<AssemblyProgram>* output);
+// Same as above, takes void* instead.
+// TODO(etiennep): Propagate "const uint8_t*" upwards.
+inline Status ParseDetectedExecutable(
+ const void* buffer,
+ size_t length,
+ std::unique_ptr<AssemblyProgram>* output) {
+ return ParseDetectedExecutable(reinterpret_cast<const uint8_t*>(buffer),
+ length, output);
+}
+
} // namespace courgette
#endif // COURGETTE_PROGRAM_DETECTOR_H_
« no previous file with comments | « courgette/disassembler_win32_x86_unittest.cc ('k') | courgette/program_detector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698