OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_X64_H_ | 5 #ifndef COURGETTE_DISASSEMBLER_WIN32_X64_H_ |
6 #define COURGETTE_DISASSEMBLER_WIN32_X64_H_ | 6 #define COURGETTE_DISASSEMBLER_WIN32_X64_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 class InstructionReceptor; |
19 | 20 |
20 class DisassemblerWin32X64 : public DisassemblerWin32 { | 21 class DisassemblerWin32X64 : public DisassemblerWin32 { |
21 public: | 22 public: |
22 // Returns true if a valid executable is detected using only quick checks. | 23 // Returns true if a valid executable is detected using only quick checks. |
23 static bool QuickDetect(const uint8_t* start, size_t length) { | 24 static bool QuickDetect(const uint8_t* start, size_t length) { |
24 return DisassemblerWin32::QuickDetect(start, length, | 25 return DisassemblerWin32::QuickDetect(start, length, |
25 kImageNtOptionalHdr64Magic); | 26 kImageNtOptionalHdr64Magic); |
26 } | 27 } |
27 | 28 |
28 DisassemblerWin32X64(const uint8_t* start, size_t length); | 29 DisassemblerWin32X64(const uint8_t* start, size_t length); |
29 ~DisassemblerWin32X64() override = default; | 30 ~DisassemblerWin32X64() override = default; |
30 | 31 |
31 // Disassembler interfaces. | 32 // Disassembler interfaces. |
32 RVA PointerToTargetRVA(const uint8_t* p) const override; | 33 RVA PointerToTargetRVA(const uint8_t* p) const override; |
33 ExecutableType kind() const override { return EXE_WIN_32_X64; } | 34 ExecutableType kind() const override { return EXE_WIN_32_X64; } |
34 | 35 |
35 // (4) -> (5) (see AddressTranslator comment): Returns the RVA of the VA | 36 // (4) -> (5) (see AddressTranslator comment): Returns the RVA of the VA |
36 // specified by |address|, or kNoRVA if |address| lies outside of the image. | 37 // specified by |address|, or kNoRVA if |address| lies outside of the image. |
37 RVA Address64ToRVA(uint64_t address) const; | 38 RVA Address64ToRVA(uint64_t address) const; |
38 | 39 |
39 protected: | 40 protected: |
40 // Disassembler interfaces. | 41 // DisassemblerWin32 interfaces. |
41 void ParseRel32RelocsFromSection(const Section* section) override; | 42 void ParseRel32RelocsFromSection(const Section* section) override; |
42 int AbsVAWidth() const override { return 8; } | 43 int AbsVAWidth() const override { return 8; } |
43 CheckBool EmitAbs(Label* label, AssemblyProgram* program) override; | 44 CheckBool EmitAbs(Label* label, InstructionReceptor* receptor) const override; |
44 bool SupportsRelTableType(int type) const override { | 45 bool SupportsRelTableType(int type) const override { |
45 return type == 10; // IMAGE_REL_BASED_DIR64 | 46 return type == 10; // IMAGE_REL_BASED_DIR64 |
46 } | 47 } |
47 uint16_t OffsetOfDataDirectories() const override { | 48 uint16_t OffsetOfDataDirectories() const override { |
48 return kOffsetOfDataDirectoryFromImageOptionalHeader64; | 49 return kOffsetOfDataDirectoryFromImageOptionalHeader64; |
49 } | 50 } |
50 | 51 |
51 private: | 52 private: |
52 DISALLOW_COPY_AND_ASSIGN(DisassemblerWin32X64); | 53 DISALLOW_COPY_AND_ASSIGN(DisassemblerWin32X64); |
53 }; | 54 }; |
54 | 55 |
55 } // namespace courgette | 56 } // namespace courgette |
56 | 57 |
57 #endif // COURGETTE_DISASSEMBLER_WIN32_X64_H_ | 58 #endif // COURGETTE_DISASSEMBLER_WIN32_X64_H_ |
OLD | NEW |