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

Side by Side Diff: courgette/disassembler_win32_x86.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 unified diff | Download patch
« no previous file with comments | « courgette/disassembler_win32_x64_unittest.cc ('k') | courgette/disassembler_win32_x86.cc » ('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) 2011 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_DISASSEMBLER_WIN32_X86_H_ 5 #ifndef COURGETTE_DISASSEMBLER_WIN32_X86_H_
6 #define COURGETTE_DISASSEMBLER_WIN32_X86_H_ 6 #define COURGETTE_DISASSEMBLER_WIN32_X86_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "courgette/disassembler_win32.h" 12 #include "courgette/disassembler_win32.h"
13 #include "courgette/image_utils.h" 13 #include "courgette/image_utils.h"
14 #include "courgette/types_win_pe.h" 14 #include "courgette/types_win_pe.h"
15 15
16 namespace courgette { 16 namespace courgette {
17 17
18 class AssemblyProgram; 18 class AssemblyProgram;
19 19
20 class DisassemblerWin32X86 : public DisassemblerWin32 { 20 class DisassemblerWin32X86 : public DisassemblerWin32 {
21 public: 21 public:
22 DisassemblerWin32X86(const void* start, size_t length); 22 // Returns true if a valid executable is detected using only quick checks.
23 static bool QuickDetect(const uint8_t* start, size_t length) {
24 return DisassemblerWin32::QuickDetect(start, length,
25 kImageNtOptionalHdr32Magic);
26 }
27
28 DisassemblerWin32X86(const uint8_t* start, size_t length);
23 ~DisassemblerWin32X86() override = default; 29 ~DisassemblerWin32X86() override = default;
24 30
25 // Disassembler interfaces. 31 // Disassembler interfaces.
26 RVA PointerToTargetRVA(const uint8_t* p) const override; 32 RVA PointerToTargetRVA(const uint8_t* p) const override;
27 ExecutableType kind() const override { return EXE_WIN_32_X86; } 33 ExecutableType kind() const override { return EXE_WIN_32_X86; }
28 34
29 // (4) -> (5) (see AddressTranslator comment): Returns the RVA of the VA 35 // (4) -> (5) (see AddressTranslator comment): Returns the RVA of the VA
30 // specified by |address|, or kNoRVA if |address| lies outside of the image. 36 // specified by |address|, or kNoRVA if |address| lies outside of the image.
31 RVA Address32ToRVA(uint32_t address) const; 37 RVA Address32ToRVA(uint32_t address) const;
32 38
33 protected: 39 protected:
34 // DisassemblerWin32 interfaces. 40 // DisassemblerWin32 interfaces.
35 void ParseRel32RelocsFromSection(const Section* section) override; 41 void ParseRel32RelocsFromSection(const Section* section) override;
36 int AbsVAWidth() const override { return 4; } 42 int AbsVAWidth() const override { return 4; }
37 CheckBool EmitAbs(Label* label, AssemblyProgram* program) override; 43 CheckBool EmitAbs(Label* label, AssemblyProgram* program) override;
38 bool SupportsRelTableType(int type) const override { 44 bool SupportsRelTableType(int type) const override {
39 return type == 3; // IMAGE_REL_BASED_HIGHLOW 45 return type == 3; // IMAGE_REL_BASED_HIGHLOW
40 } 46 }
41 uint16_t OffsetOfDataDirectories() const override { 47 uint16_t OffsetOfDataDirectories() const override {
42 return kOffsetOfDataDirectoryFromImageOptionalHeader32; 48 return kOffsetOfDataDirectoryFromImageOptionalHeader32;
43 } 49 }
44 50
45 private: 51 private:
46 DISALLOW_COPY_AND_ASSIGN(DisassemblerWin32X86); 52 DISALLOW_COPY_AND_ASSIGN(DisassemblerWin32X86);
47 }; 53 };
48 54
49 } // namespace courgette 55 } // namespace courgette
50 56
51 #endif // COURGETTE_DISASSEMBLER_WIN32_X86_H_ 57 #endif // COURGETTE_DISASSEMBLER_WIN32_X86_H_
OLDNEW
« no previous file with comments | « courgette/disassembler_win32_x64_unittest.cc ('k') | courgette/disassembler_win32_x86.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698