[M108 Migration][HBBTV] Implement ewk_context_register_jsplugin_mime_types API
[platform/framework/web/chromium-efl.git] / courgette / disassembler_win32_x64.h
1 // Copyright 2013 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef COURGETTE_DISASSEMBLER_WIN32_X64_H_
6 #define COURGETTE_DISASSEMBLER_WIN32_X64_H_
7
8 #include <stddef.h>
9 #include <stdint.h>
10
11 #include "courgette/disassembler_win32.h"
12 #include "courgette/image_utils.h"
13 #include "courgette/types_win_pe.h"
14
15 namespace courgette {
16
17 class InstructionReceptor;
18
19 class DisassemblerWin32X64 : public DisassemblerWin32 {
20  public:
21   // Returns true if a valid executable is detected using only quick checks.
22   static bool QuickDetect(const uint8_t* start, size_t length) {
23     return DisassemblerWin32::QuickDetect(start, length,
24                                           kImageNtOptionalHdr64Magic);
25   }
26
27   DisassemblerWin32X64(const uint8_t* start, size_t length);
28
29   DisassemblerWin32X64(const DisassemblerWin32X64&) = delete;
30   DisassemblerWin32X64& operator=(const DisassemblerWin32X64&) = delete;
31
32   ~DisassemblerWin32X64() override = default;
33
34   // Disassembler interfaces.
35   RVA PointerToTargetRVA(const uint8_t* p) const override;
36   ExecutableType kind() const override { return EXE_WIN_32_X64; }
37
38   // (4) -> (5) (see AddressTranslator comment): Returns the RVA of the VA
39   // specified by |address|, or kNoRVA if |address| lies outside of the image.
40   RVA Address64ToRVA(uint64_t address) const;
41
42  protected:
43   // DisassemblerWin32 interfaces.
44   void ParseRel32RelocsFromSection(const Section* section) override;
45   int AbsVAWidth() const override { return 8; }
46   CheckBool EmitAbs(Label* label, InstructionReceptor* receptor) const override;
47   bool SupportsRelTableType(int type) const override {
48     return type == 10;  // IMAGE_REL_BASED_DIR64
49   }
50   uint16_t RelativeOffsetOfDataDirectories() const override {
51     return kOffsetOfDataDirectoryFromImageOptionalHeader64;
52   }
53 };
54
55 }  // namespace courgette
56
57 #endif  // COURGETTE_DISASSEMBLER_WIN32_X64_H_