smallworld-re 1.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (166) hide show
  1. smallworld/__init__.py +35 -0
  2. smallworld/analyses/__init__.py +14 -0
  3. smallworld/analyses/analysis.py +88 -0
  4. smallworld/analyses/code_coverage.py +31 -0
  5. smallworld/analyses/colorizer.py +682 -0
  6. smallworld/analyses/colorizer_summary.py +100 -0
  7. smallworld/analyses/field_detection/__init__.py +14 -0
  8. smallworld/analyses/field_detection/field_analysis.py +536 -0
  9. smallworld/analyses/field_detection/guards.py +26 -0
  10. smallworld/analyses/field_detection/hints.py +133 -0
  11. smallworld/analyses/field_detection/malloc.py +211 -0
  12. smallworld/analyses/forced_exec/__init__.py +3 -0
  13. smallworld/analyses/forced_exec/forced_exec.py +87 -0
  14. smallworld/analyses/underlays/__init__.py +4 -0
  15. smallworld/analyses/underlays/basic.py +13 -0
  16. smallworld/analyses/underlays/underlay.py +31 -0
  17. smallworld/analyses/unstable/__init__.py +4 -0
  18. smallworld/analyses/unstable/angr/__init__.py +0 -0
  19. smallworld/analyses/unstable/angr/base.py +12 -0
  20. smallworld/analyses/unstable/angr/divergence.py +274 -0
  21. smallworld/analyses/unstable/angr/model.py +383 -0
  22. smallworld/analyses/unstable/angr/nwbt.py +63 -0
  23. smallworld/analyses/unstable/angr/typedefs.py +170 -0
  24. smallworld/analyses/unstable/angr/utils.py +25 -0
  25. smallworld/analyses/unstable/angr/visitor.py +315 -0
  26. smallworld/analyses/unstable/angr_nwbt.py +106 -0
  27. smallworld/analyses/unstable/code_coverage.py +54 -0
  28. smallworld/analyses/unstable/code_reachable.py +44 -0
  29. smallworld/analyses/unstable/control_flow_tracer.py +71 -0
  30. smallworld/analyses/unstable/pointer_finder.py +90 -0
  31. smallworld/arch/__init__.py +0 -0
  32. smallworld/arch/aarch64_arch.py +286 -0
  33. smallworld/arch/amd64_arch.py +86 -0
  34. smallworld/arch/i386_arch.py +44 -0
  35. smallworld/emulators/__init__.py +14 -0
  36. smallworld/emulators/angr/__init__.py +7 -0
  37. smallworld/emulators/angr/angr.py +1652 -0
  38. smallworld/emulators/angr/default.py +15 -0
  39. smallworld/emulators/angr/exceptions.py +7 -0
  40. smallworld/emulators/angr/exploration/__init__.py +9 -0
  41. smallworld/emulators/angr/exploration/bounds.py +27 -0
  42. smallworld/emulators/angr/exploration/default.py +17 -0
  43. smallworld/emulators/angr/exploration/terminate.py +22 -0
  44. smallworld/emulators/angr/factory.py +55 -0
  45. smallworld/emulators/angr/machdefs/__init__.py +35 -0
  46. smallworld/emulators/angr/machdefs/aarch64.py +292 -0
  47. smallworld/emulators/angr/machdefs/amd64.py +192 -0
  48. smallworld/emulators/angr/machdefs/arm.py +387 -0
  49. smallworld/emulators/angr/machdefs/i386.py +221 -0
  50. smallworld/emulators/angr/machdefs/machdef.py +138 -0
  51. smallworld/emulators/angr/machdefs/mips.py +184 -0
  52. smallworld/emulators/angr/machdefs/mips64.py +189 -0
  53. smallworld/emulators/angr/machdefs/ppc.py +101 -0
  54. smallworld/emulators/angr/machdefs/riscv.py +261 -0
  55. smallworld/emulators/angr/machdefs/xtensa.py +255 -0
  56. smallworld/emulators/angr/memory/__init__.py +7 -0
  57. smallworld/emulators/angr/memory/default.py +10 -0
  58. smallworld/emulators/angr/memory/fixups.py +43 -0
  59. smallworld/emulators/angr/memory/memtrack.py +105 -0
  60. smallworld/emulators/angr/scratch.py +43 -0
  61. smallworld/emulators/angr/simos.py +53 -0
  62. smallworld/emulators/angr/utils.py +70 -0
  63. smallworld/emulators/emulator.py +1013 -0
  64. smallworld/emulators/hookable.py +252 -0
  65. smallworld/emulators/panda/__init__.py +5 -0
  66. smallworld/emulators/panda/machdefs/__init__.py +28 -0
  67. smallworld/emulators/panda/machdefs/aarch64.py +93 -0
  68. smallworld/emulators/panda/machdefs/amd64.py +71 -0
  69. smallworld/emulators/panda/machdefs/arm.py +89 -0
  70. smallworld/emulators/panda/machdefs/i386.py +36 -0
  71. smallworld/emulators/panda/machdefs/machdef.py +86 -0
  72. smallworld/emulators/panda/machdefs/mips.py +94 -0
  73. smallworld/emulators/panda/machdefs/mips64.py +91 -0
  74. smallworld/emulators/panda/machdefs/ppc.py +79 -0
  75. smallworld/emulators/panda/panda.py +575 -0
  76. smallworld/emulators/unicorn/__init__.py +13 -0
  77. smallworld/emulators/unicorn/machdefs/__init__.py +28 -0
  78. smallworld/emulators/unicorn/machdefs/aarch64.py +310 -0
  79. smallworld/emulators/unicorn/machdefs/amd64.py +326 -0
  80. smallworld/emulators/unicorn/machdefs/arm.py +321 -0
  81. smallworld/emulators/unicorn/machdefs/i386.py +137 -0
  82. smallworld/emulators/unicorn/machdefs/machdef.py +117 -0
  83. smallworld/emulators/unicorn/machdefs/mips.py +202 -0
  84. smallworld/emulators/unicorn/unicorn.py +684 -0
  85. smallworld/exceptions/__init__.py +5 -0
  86. smallworld/exceptions/exceptions.py +85 -0
  87. smallworld/exceptions/unstable/__init__.py +1 -0
  88. smallworld/exceptions/unstable/exceptions.py +25 -0
  89. smallworld/extern/__init__.py +4 -0
  90. smallworld/extern/ctypes.py +94 -0
  91. smallworld/extern/unstable/__init__.py +1 -0
  92. smallworld/extern/unstable/ghidra.py +129 -0
  93. smallworld/helpers.py +107 -0
  94. smallworld/hinting/__init__.py +8 -0
  95. smallworld/hinting/hinting.py +214 -0
  96. smallworld/hinting/hints.py +427 -0
  97. smallworld/hinting/unstable/__init__.py +2 -0
  98. smallworld/hinting/utils.py +19 -0
  99. smallworld/instructions/__init__.py +18 -0
  100. smallworld/instructions/aarch64.py +20 -0
  101. smallworld/instructions/arm.py +18 -0
  102. smallworld/instructions/bsid.py +67 -0
  103. smallworld/instructions/instructions.py +258 -0
  104. smallworld/instructions/mips.py +21 -0
  105. smallworld/instructions/x86.py +100 -0
  106. smallworld/logging.py +90 -0
  107. smallworld/platforms.py +95 -0
  108. smallworld/py.typed +0 -0
  109. smallworld/state/__init__.py +6 -0
  110. smallworld/state/cpus/__init__.py +32 -0
  111. smallworld/state/cpus/aarch64.py +563 -0
  112. smallworld/state/cpus/amd64.py +676 -0
  113. smallworld/state/cpus/arm.py +630 -0
  114. smallworld/state/cpus/cpu.py +71 -0
  115. smallworld/state/cpus/i386.py +239 -0
  116. smallworld/state/cpus/mips.py +374 -0
  117. smallworld/state/cpus/mips64.py +372 -0
  118. smallworld/state/cpus/powerpc.py +229 -0
  119. smallworld/state/cpus/riscv.py +357 -0
  120. smallworld/state/cpus/xtensa.py +80 -0
  121. smallworld/state/memory/__init__.py +7 -0
  122. smallworld/state/memory/code.py +70 -0
  123. smallworld/state/memory/elf/__init__.py +3 -0
  124. smallworld/state/memory/elf/elf.py +564 -0
  125. smallworld/state/memory/elf/rela/__init__.py +32 -0
  126. smallworld/state/memory/elf/rela/aarch64.py +27 -0
  127. smallworld/state/memory/elf/rela/amd64.py +32 -0
  128. smallworld/state/memory/elf/rela/arm.py +51 -0
  129. smallworld/state/memory/elf/rela/i386.py +32 -0
  130. smallworld/state/memory/elf/rela/mips.py +45 -0
  131. smallworld/state/memory/elf/rela/ppc.py +45 -0
  132. smallworld/state/memory/elf/rela/rela.py +63 -0
  133. smallworld/state/memory/elf/rela/riscv64.py +27 -0
  134. smallworld/state/memory/elf/rela/xtensa.py +15 -0
  135. smallworld/state/memory/elf/structs.py +55 -0
  136. smallworld/state/memory/heap.py +85 -0
  137. smallworld/state/memory/memory.py +181 -0
  138. smallworld/state/memory/stack/__init__.py +31 -0
  139. smallworld/state/memory/stack/aarch64.py +22 -0
  140. smallworld/state/memory/stack/amd64.py +42 -0
  141. smallworld/state/memory/stack/arm.py +66 -0
  142. smallworld/state/memory/stack/i386.py +22 -0
  143. smallworld/state/memory/stack/mips.py +34 -0
  144. smallworld/state/memory/stack/mips64.py +34 -0
  145. smallworld/state/memory/stack/ppc.py +34 -0
  146. smallworld/state/memory/stack/riscv.py +22 -0
  147. smallworld/state/memory/stack/stack.py +127 -0
  148. smallworld/state/memory/stack/xtensa.py +34 -0
  149. smallworld/state/models/__init__.py +6 -0
  150. smallworld/state/models/mmio.py +186 -0
  151. smallworld/state/models/model.py +163 -0
  152. smallworld/state/models/posix.py +455 -0
  153. smallworld/state/models/x86/__init__.py +2 -0
  154. smallworld/state/models/x86/microsoftcdecl.py +35 -0
  155. smallworld/state/models/x86/systemv.py +240 -0
  156. smallworld/state/state.py +962 -0
  157. smallworld/state/unstable/__init__.py +0 -0
  158. smallworld/state/unstable/elf.py +393 -0
  159. smallworld/state/x86_registers.py +30 -0
  160. smallworld/utils.py +935 -0
  161. smallworld_re-1.0.0.dist-info/LICENSE.txt +21 -0
  162. smallworld_re-1.0.0.dist-info/METADATA +189 -0
  163. smallworld_re-1.0.0.dist-info/RECORD +166 -0
  164. smallworld_re-1.0.0.dist-info/WHEEL +5 -0
  165. smallworld_re-1.0.0.dist-info/entry_points.txt +2 -0
  166. smallworld_re-1.0.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,310 @@
1
+ import capstone
2
+ import unicorn
3
+
4
+ from ....platforms import Architecture, Byteorder
5
+ from .machdef import UnicornMachineDef
6
+
7
+
8
+ class AArch64MachineDef(UnicornMachineDef):
9
+ arch = Architecture.AARCH64
10
+ byteorder = Byteorder.LITTLE
11
+
12
+ uc_arch = unicorn.UC_ARCH_ARM64
13
+ uc_mode = unicorn.UC_MODE_ARM
14
+
15
+ cs_arch = capstone.CS_ARCH_ARM64
16
+ cs_mode = capstone.CS_MODE_ARM
17
+
18
+ pc_reg = "pc"
19
+
20
+ _registers = {
21
+ # *** General Purpose Registers ***
22
+ "x0": (unicorn.arm64_const.UC_ARM64_REG_X0, "x0", 8, 0),
23
+ "w0": (unicorn.arm64_const.UC_ARM64_REG_W0, "x0", 4, 0),
24
+ "x1": (unicorn.arm64_const.UC_ARM64_REG_X1, "x1", 8, 0),
25
+ "w1": (unicorn.arm64_const.UC_ARM64_REG_W1, "x1", 4, 0),
26
+ "x2": (unicorn.arm64_const.UC_ARM64_REG_X2, "x2", 8, 0),
27
+ "w2": (unicorn.arm64_const.UC_ARM64_REG_W2, "x2", 4, 0),
28
+ "x3": (unicorn.arm64_const.UC_ARM64_REG_X3, "x3", 8, 0),
29
+ "w3": (unicorn.arm64_const.UC_ARM64_REG_W3, "x3", 4, 0),
30
+ "x4": (unicorn.arm64_const.UC_ARM64_REG_X4, "x4", 8, 0),
31
+ "w4": (unicorn.arm64_const.UC_ARM64_REG_W4, "x4", 4, 0),
32
+ "x5": (unicorn.arm64_const.UC_ARM64_REG_X5, "x5", 8, 0),
33
+ "w5": (unicorn.arm64_const.UC_ARM64_REG_W5, "x5", 4, 0),
34
+ "x6": (unicorn.arm64_const.UC_ARM64_REG_X6, "x6", 8, 0),
35
+ "w6": (unicorn.arm64_const.UC_ARM64_REG_W6, "x6", 4, 0),
36
+ "x7": (unicorn.arm64_const.UC_ARM64_REG_X7, "x7", 8, 0),
37
+ "w7": (unicorn.arm64_const.UC_ARM64_REG_W7, "x7", 4, 0),
38
+ "x8": (unicorn.arm64_const.UC_ARM64_REG_X8, "x8", 8, 0),
39
+ "w8": (unicorn.arm64_const.UC_ARM64_REG_W8, "x8", 4, 0),
40
+ "x9": (unicorn.arm64_const.UC_ARM64_REG_X9, "x9", 8, 0),
41
+ "w9": (unicorn.arm64_const.UC_ARM64_REG_W9, "x9", 4, 0),
42
+ "x10": (unicorn.arm64_const.UC_ARM64_REG_X10, "x10", 8, 0),
43
+ "w10": (unicorn.arm64_const.UC_ARM64_REG_W10, "x10", 4, 0),
44
+ "x11": (unicorn.arm64_const.UC_ARM64_REG_X11, "x11", 8, 0),
45
+ "w11": (unicorn.arm64_const.UC_ARM64_REG_W11, "x11", 4, 0),
46
+ "x12": (unicorn.arm64_const.UC_ARM64_REG_X12, "x12", 8, 0),
47
+ "w12": (unicorn.arm64_const.UC_ARM64_REG_W12, "x12", 4, 0),
48
+ "x13": (unicorn.arm64_const.UC_ARM64_REG_X13, "x13", 8, 0),
49
+ "w13": (unicorn.arm64_const.UC_ARM64_REG_W13, "x13", 4, 0),
50
+ "x14": (unicorn.arm64_const.UC_ARM64_REG_X14, "x14", 8, 0),
51
+ "w14": (unicorn.arm64_const.UC_ARM64_REG_W14, "x14", 4, 0),
52
+ "x15": (unicorn.arm64_const.UC_ARM64_REG_X15, "x15", 8, 0),
53
+ "w15": (unicorn.arm64_const.UC_ARM64_REG_W15, "x15", 4, 0),
54
+ "x16": (unicorn.arm64_const.UC_ARM64_REG_X16, "x16", 8, 0),
55
+ "w16": (unicorn.arm64_const.UC_ARM64_REG_W16, "x16", 4, 0),
56
+ "x17": (unicorn.arm64_const.UC_ARM64_REG_X17, "x17", 8, 0),
57
+ "w17": (unicorn.arm64_const.UC_ARM64_REG_W17, "x17", 4, 0),
58
+ "x18": (unicorn.arm64_const.UC_ARM64_REG_X18, "x18", 8, 0),
59
+ "w18": (unicorn.arm64_const.UC_ARM64_REG_W18, "x18", 4, 0),
60
+ "x19": (unicorn.arm64_const.UC_ARM64_REG_X19, "x19", 8, 0),
61
+ "w19": (unicorn.arm64_const.UC_ARM64_REG_W19, "x19", 4, 0),
62
+ "x20": (unicorn.arm64_const.UC_ARM64_REG_X20, "x20", 8, 0),
63
+ "w20": (unicorn.arm64_const.UC_ARM64_REG_W20, "x20", 4, 0),
64
+ "x21": (unicorn.arm64_const.UC_ARM64_REG_X21, "x21", 8, 0),
65
+ "w21": (unicorn.arm64_const.UC_ARM64_REG_W21, "x21", 4, 0),
66
+ "x22": (unicorn.arm64_const.UC_ARM64_REG_X22, "x22", 8, 0),
67
+ "w22": (unicorn.arm64_const.UC_ARM64_REG_W22, "x22", 4, 0),
68
+ "x23": (unicorn.arm64_const.UC_ARM64_REG_X23, "x23", 8, 0),
69
+ "w23": (unicorn.arm64_const.UC_ARM64_REG_W23, "x23", 4, 0),
70
+ "x24": (unicorn.arm64_const.UC_ARM64_REG_X24, "x24", 8, 0),
71
+ "w24": (unicorn.arm64_const.UC_ARM64_REG_W24, "x24", 4, 0),
72
+ "x25": (unicorn.arm64_const.UC_ARM64_REG_X25, "x25", 8, 0),
73
+ "w25": (unicorn.arm64_const.UC_ARM64_REG_W25, "x25", 4, 0),
74
+ "x26": (unicorn.arm64_const.UC_ARM64_REG_X26, "x26", 8, 0),
75
+ "w26": (unicorn.arm64_const.UC_ARM64_REG_W26, "x26", 4, 0),
76
+ "x27": (unicorn.arm64_const.UC_ARM64_REG_X27, "x27", 8, 0),
77
+ "w27": (unicorn.arm64_const.UC_ARM64_REG_W27, "x27", 4, 0),
78
+ "x28": (unicorn.arm64_const.UC_ARM64_REG_X28, "x28", 8, 0),
79
+ "w28": (unicorn.arm64_const.UC_ARM64_REG_W28, "x28", 4, 0),
80
+ "x29": (unicorn.arm64_const.UC_ARM64_REG_X29, "x29", 8, 0),
81
+ "w29": (unicorn.arm64_const.UC_ARM64_REG_W29, "x29", 4, 0),
82
+ "x30": (unicorn.arm64_const.UC_ARM64_REG_X30, "x30", 8, 0),
83
+ "w30": (unicorn.arm64_const.UC_ARM64_REG_W30, "x30", 4, 0),
84
+ # *** Program Counter ***
85
+ "pc": (unicorn.arm64_const.UC_ARM64_REG_PC, "pc", 8, 0),
86
+ # *** Stack Pointer ***
87
+ "sp": (unicorn.arm64_const.UC_ARM64_REG_SP, "sp", 8, 0),
88
+ "wsp": (unicorn.arm64_const.UC_ARM64_REG_WSP, "wsp", 4, 0),
89
+ # *** Frame Pointer ***
90
+ "fp": (unicorn.arm64_const.UC_ARM64_REG_FP, "x29", 8, 0),
91
+ # *** Link Register ***
92
+ "lr": (unicorn.arm64_const.UC_ARM64_REG_LR, "x30", 8, 0),
93
+ # *** Zero Register ***
94
+ "xzr": (unicorn.arm64_const.UC_ARM64_REG_INVALID, "xzr", 8, 0),
95
+ "wzr": (unicorn.arm64_const.UC_ARM64_REG_INVALID, "wzr", 4, 0),
96
+ # *** System Control Registers ***
97
+ # NOTE: "_elX" indicates that only exception level X or greater can access this register.
98
+ # NOTE: This list is far from complete; it only covers what Unicorn supports
99
+ # Condition Code Register
100
+ "fpcr": (unicorn.arm64_const.UC_ARM64_REG_FPCR, "fpcr", 8, 0),
101
+ # Floating Point Status Register
102
+ "fpsr": (unicorn.arm64_const.UC_ARM64_REG_FPSR, "fpsr", 8, 0),
103
+ # Banked stack pointers for exception handlers
104
+ "sp_el0": (unicorn.arm64_const.UC_ARM64_REG_SP_EL0, "sp_el0", 8, 0),
105
+ "sp_el1": (unicorn.arm64_const.UC_ARM64_REG_SP_EL1, "sp_el1", 8, 0),
106
+ "sp_el2": (unicorn.arm64_const.UC_ARM64_REG_SP_EL2, "sp_el2", 8, 0),
107
+ "sp_el3": (unicorn.arm64_const.UC_ARM64_REG_SP_EL3, "sp_el3", 8, 0),
108
+ # Banked link registers for exception handlers
109
+ # NOTE: Unicorn thinks there's an elr_el0; according to docs, it doesn't exist
110
+ "elr_el1": (unicorn.arm64_const.UC_ARM64_REG_ELR_EL1, "elr_el1", 8, 0),
111
+ "elr_el2": (unicorn.arm64_const.UC_ARM64_REG_ELR_EL2, "elr_el2", 8, 0),
112
+ "elr_el3": (unicorn.arm64_const.UC_ARM64_REG_ELR_EL3, "elr_el3", 8, 0),
113
+ # Banked exception syndrome registers for exception handlers
114
+ # NOTE: Unicorn thinks there's a far_el0; according to docs, it doesn't exist
115
+ "far_el1": (unicorn.arm64_const.UC_ARM64_REG_FAR_EL1, "far_el1", 8, 0),
116
+ "far_el2": (unicorn.arm64_const.UC_ARM64_REG_FAR_EL2, "far_el2", 8, 0),
117
+ "far_el3": (unicorn.arm64_const.UC_ARM64_REG_FAR_EL3, "far_el3", 8, 0),
118
+ # Banked vector base address registers for exception handlers
119
+ # NOTE: vbar_el0 and vbar_el1 are aliases for each other.
120
+ # Since vbar_el0 doesn't exist in angr, vbar_el1 has to be the "real" copy.
121
+ "vbar_el1": (unicorn.arm64_const.UC_ARM64_REG_VBAR_EL1, "vbar_el1", 8, 0),
122
+ "vbar_el0": (unicorn.arm64_const.UC_ARM64_REG_VBAR_EL0, "vbar_el1", 8, 0),
123
+ "vbar_el2": (unicorn.arm64_const.UC_ARM64_REG_VBAR_EL2, "vbar_el2", 8, 0),
124
+ "vbar_el3": (unicorn.arm64_const.UC_ARM64_REG_VBAR_EL3, "vbar_el3", 8, 0),
125
+ # Coprocessor access control register
126
+ "cpacr_el1": (unicorn.arm64_const.UC_ARM64_REG_CPACR_EL1, "cpacr_el1", 8, 0),
127
+ # Memory Attribute Indirection Register
128
+ "mair_el1": (unicorn.arm64_const.UC_ARM64_REG_MAIR_EL1, "mair_el1", 8, 0),
129
+ # Physical Address Register
130
+ "par_el1": (unicorn.arm64_const.UC_ARM64_REG_PAR_EL1, "par_el1", 8, 0),
131
+ # Translation Table Zero Base Register
132
+ "ttbr0_el1": (unicorn.arm64_const.UC_ARM64_REG_TTBR0_EL1, "ttbr0_el1", 8, 0),
133
+ # Translation Table One Base Register
134
+ "ttbr1_el1": (unicorn.arm64_const.UC_ARM64_REG_TTBR1_EL1, "ttbr1_el1", 8, 0),
135
+ # Thread ID Register
136
+ # NOTE: According to docs, there should be an el2 and el3 copy, too.
137
+ "tpidr_el0": (unicorn.arm64_const.UC_ARM64_REG_TPIDR_EL0, "tpidr_el0", 8, 0),
138
+ "tpidr_el1": (unicorn.arm64_const.UC_ARM64_REG_TPIDR_EL1, "tpidr_el1", 8, 0),
139
+ # Userspace-visible Thread ID register
140
+ "tpidrro_el0": (
141
+ unicorn.arm64_const.UC_ARM64_REG_TPIDRRO_EL0,
142
+ "tpidrro_el0",
143
+ 8,
144
+ 0,
145
+ ),
146
+ # *** Floating Point Registers ***
147
+ # Scalar Floating Point Registers
148
+ "q0": (unicorn.arm64_const.UC_ARM64_REG_Q0, "q0", 16, 0),
149
+ "d0": (unicorn.arm64_const.UC_ARM64_REG_D0, "q0", 8, 0),
150
+ "s0": (unicorn.arm64_const.UC_ARM64_REG_S0, "q0", 4, 0),
151
+ "h0": (unicorn.arm64_const.UC_ARM64_REG_H0, "q0", 2, 0),
152
+ "b0": (unicorn.arm64_const.UC_ARM64_REG_B0, "q0", 1, 0),
153
+ "q1": (unicorn.arm64_const.UC_ARM64_REG_Q1, "q1", 16, 0),
154
+ "d1": (unicorn.arm64_const.UC_ARM64_REG_D1, "q1", 8, 0),
155
+ "s1": (unicorn.arm64_const.UC_ARM64_REG_S1, "q1", 4, 0),
156
+ "h1": (unicorn.arm64_const.UC_ARM64_REG_H1, "q1", 2, 0),
157
+ "b1": (unicorn.arm64_const.UC_ARM64_REG_B1, "q1", 1, 0),
158
+ "q2": (unicorn.arm64_const.UC_ARM64_REG_Q2, "q2", 16, 0),
159
+ "d2": (unicorn.arm64_const.UC_ARM64_REG_D2, "q2", 8, 0),
160
+ "s2": (unicorn.arm64_const.UC_ARM64_REG_S2, "q2", 4, 0),
161
+ "h2": (unicorn.arm64_const.UC_ARM64_REG_H2, "q2", 2, 0),
162
+ "b2": (unicorn.arm64_const.UC_ARM64_REG_B2, "q2", 1, 0),
163
+ "q3": (unicorn.arm64_const.UC_ARM64_REG_Q3, "q3", 16, 0),
164
+ "d3": (unicorn.arm64_const.UC_ARM64_REG_D3, "q3", 8, 0),
165
+ "s3": (unicorn.arm64_const.UC_ARM64_REG_S3, "q3", 4, 0),
166
+ "h3": (unicorn.arm64_const.UC_ARM64_REG_H3, "q3", 2, 0),
167
+ "b3": (unicorn.arm64_const.UC_ARM64_REG_B3, "q3", 1, 0),
168
+ "q4": (unicorn.arm64_const.UC_ARM64_REG_Q4, "q4", 16, 0),
169
+ "d4": (unicorn.arm64_const.UC_ARM64_REG_D4, "q4", 8, 0),
170
+ "s4": (unicorn.arm64_const.UC_ARM64_REG_S4, "q4", 4, 0),
171
+ "h4": (unicorn.arm64_const.UC_ARM64_REG_H4, "q4", 2, 0),
172
+ "b4": (unicorn.arm64_const.UC_ARM64_REG_B4, "q4", 1, 0),
173
+ "q5": (unicorn.arm64_const.UC_ARM64_REG_Q5, "q5", 16, 0),
174
+ "d5": (unicorn.arm64_const.UC_ARM64_REG_D5, "q5", 8, 0),
175
+ "s5": (unicorn.arm64_const.UC_ARM64_REG_S5, "q5", 4, 0),
176
+ "h5": (unicorn.arm64_const.UC_ARM64_REG_H5, "q5", 2, 0),
177
+ "b5": (unicorn.arm64_const.UC_ARM64_REG_B5, "q5", 1, 0),
178
+ "q6": (unicorn.arm64_const.UC_ARM64_REG_Q6, "q6", 16, 0),
179
+ "d6": (unicorn.arm64_const.UC_ARM64_REG_D6, "q6", 8, 0),
180
+ "s6": (unicorn.arm64_const.UC_ARM64_REG_S6, "q6", 4, 0),
181
+ "h6": (unicorn.arm64_const.UC_ARM64_REG_H6, "q6", 2, 0),
182
+ "b6": (unicorn.arm64_const.UC_ARM64_REG_B6, "q6", 1, 0),
183
+ "q7": (unicorn.arm64_const.UC_ARM64_REG_Q7, "q7", 16, 0),
184
+ "d7": (unicorn.arm64_const.UC_ARM64_REG_D7, "q7", 8, 0),
185
+ "s7": (unicorn.arm64_const.UC_ARM64_REG_S7, "q7", 4, 0),
186
+ "h7": (unicorn.arm64_const.UC_ARM64_REG_H7, "q7", 2, 0),
187
+ "b7": (unicorn.arm64_const.UC_ARM64_REG_B7, "q7", 1, 0),
188
+ "q8": (unicorn.arm64_const.UC_ARM64_REG_Q8, "q8", 16, 0),
189
+ "d8": (unicorn.arm64_const.UC_ARM64_REG_D8, "q8", 8, 0),
190
+ "s8": (unicorn.arm64_const.UC_ARM64_REG_S8, "q8", 4, 0),
191
+ "h8": (unicorn.arm64_const.UC_ARM64_REG_H8, "q8", 2, 0),
192
+ "b8": (unicorn.arm64_const.UC_ARM64_REG_B8, "q8", 1, 0),
193
+ "q9": (unicorn.arm64_const.UC_ARM64_REG_Q9, "q9", 16, 0),
194
+ "d9": (unicorn.arm64_const.UC_ARM64_REG_D9, "q9", 8, 0),
195
+ "s9": (unicorn.arm64_const.UC_ARM64_REG_S9, "q9", 4, 0),
196
+ "h9": (unicorn.arm64_const.UC_ARM64_REG_H9, "q9", 2, 0),
197
+ "b9": (unicorn.arm64_const.UC_ARM64_REG_B9, "q9", 1, 0),
198
+ "q10": (unicorn.arm64_const.UC_ARM64_REG_Q10, "q10", 16, 0),
199
+ "d10": (unicorn.arm64_const.UC_ARM64_REG_D10, "q10", 8, 0),
200
+ "s10": (unicorn.arm64_const.UC_ARM64_REG_S10, "q10", 4, 0),
201
+ "h10": (unicorn.arm64_const.UC_ARM64_REG_H10, "q10", 2, 0),
202
+ "b10": (unicorn.arm64_const.UC_ARM64_REG_B10, "q10", 1, 0),
203
+ "q11": (unicorn.arm64_const.UC_ARM64_REG_Q11, "q11", 16, 0),
204
+ "d11": (unicorn.arm64_const.UC_ARM64_REG_D11, "q11", 8, 0),
205
+ "s11": (unicorn.arm64_const.UC_ARM64_REG_S11, "q11", 4, 0),
206
+ "h11": (unicorn.arm64_const.UC_ARM64_REG_H11, "q11", 2, 0),
207
+ "b11": (unicorn.arm64_const.UC_ARM64_REG_B11, "q11", 1, 0),
208
+ "q12": (unicorn.arm64_const.UC_ARM64_REG_Q12, "q12", 16, 0),
209
+ "d12": (unicorn.arm64_const.UC_ARM64_REG_D12, "q12", 8, 0),
210
+ "s12": (unicorn.arm64_const.UC_ARM64_REG_S12, "q12", 4, 0),
211
+ "h12": (unicorn.arm64_const.UC_ARM64_REG_H12, "q12", 2, 0),
212
+ "b12": (unicorn.arm64_const.UC_ARM64_REG_B12, "q12", 1, 0),
213
+ "q13": (unicorn.arm64_const.UC_ARM64_REG_Q13, "q13", 16, 0),
214
+ "d13": (unicorn.arm64_const.UC_ARM64_REG_D13, "q13", 8, 0),
215
+ "s13": (unicorn.arm64_const.UC_ARM64_REG_S13, "q13", 4, 0),
216
+ "h13": (unicorn.arm64_const.UC_ARM64_REG_H13, "q13", 2, 0),
217
+ "b13": (unicorn.arm64_const.UC_ARM64_REG_B13, "q13", 1, 0),
218
+ "q14": (unicorn.arm64_const.UC_ARM64_REG_Q14, "q14", 16, 0),
219
+ "d14": (unicorn.arm64_const.UC_ARM64_REG_D14, "q14", 8, 0),
220
+ "s14": (unicorn.arm64_const.UC_ARM64_REG_S14, "q14", 4, 0),
221
+ "h14": (unicorn.arm64_const.UC_ARM64_REG_H14, "q14", 2, 0),
222
+ "b14": (unicorn.arm64_const.UC_ARM64_REG_B14, "q14", 1, 0),
223
+ "q15": (unicorn.arm64_const.UC_ARM64_REG_Q15, "q15", 16, 0),
224
+ "d15": (unicorn.arm64_const.UC_ARM64_REG_D15, "q15", 8, 0),
225
+ "s15": (unicorn.arm64_const.UC_ARM64_REG_S15, "q15", 4, 0),
226
+ "h15": (unicorn.arm64_const.UC_ARM64_REG_H15, "q15", 2, 0),
227
+ "b15": (unicorn.arm64_const.UC_ARM64_REG_B15, "q15", 1, 0),
228
+ "q16": (unicorn.arm64_const.UC_ARM64_REG_Q16, "q16", 16, 0),
229
+ "d16": (unicorn.arm64_const.UC_ARM64_REG_D16, "q16", 8, 0),
230
+ "s16": (unicorn.arm64_const.UC_ARM64_REG_S16, "q16", 4, 0),
231
+ "h16": (unicorn.arm64_const.UC_ARM64_REG_H16, "q16", 2, 0),
232
+ "b16": (unicorn.arm64_const.UC_ARM64_REG_B16, "q16", 1, 0),
233
+ "q17": (unicorn.arm64_const.UC_ARM64_REG_Q17, "q17", 16, 0),
234
+ "d17": (unicorn.arm64_const.UC_ARM64_REG_D17, "q17", 8, 0),
235
+ "s17": (unicorn.arm64_const.UC_ARM64_REG_S17, "q17", 4, 0),
236
+ "h17": (unicorn.arm64_const.UC_ARM64_REG_H17, "q17", 2, 0),
237
+ "b17": (unicorn.arm64_const.UC_ARM64_REG_B17, "q17", 1, 0),
238
+ "q18": (unicorn.arm64_const.UC_ARM64_REG_Q18, "q18", 16, 0),
239
+ "d18": (unicorn.arm64_const.UC_ARM64_REG_D18, "q18", 8, 0),
240
+ "s18": (unicorn.arm64_const.UC_ARM64_REG_S18, "q18", 4, 0),
241
+ "h18": (unicorn.arm64_const.UC_ARM64_REG_H18, "q18", 2, 0),
242
+ "b18": (unicorn.arm64_const.UC_ARM64_REG_B18, "q18", 1, 0),
243
+ "q19": (unicorn.arm64_const.UC_ARM64_REG_Q19, "q19", 16, 0),
244
+ "d19": (unicorn.arm64_const.UC_ARM64_REG_D19, "q19", 8, 0),
245
+ "s19": (unicorn.arm64_const.UC_ARM64_REG_S19, "q19", 4, 0),
246
+ "h19": (unicorn.arm64_const.UC_ARM64_REG_H19, "q19", 2, 0),
247
+ "b19": (unicorn.arm64_const.UC_ARM64_REG_B19, "q19", 1, 0),
248
+ "q20": (unicorn.arm64_const.UC_ARM64_REG_Q20, "q20", 16, 0),
249
+ "d20": (unicorn.arm64_const.UC_ARM64_REG_D20, "q20", 8, 0),
250
+ "s20": (unicorn.arm64_const.UC_ARM64_REG_S20, "q20", 4, 0),
251
+ "h20": (unicorn.arm64_const.UC_ARM64_REG_H20, "q20", 2, 0),
252
+ "b20": (unicorn.arm64_const.UC_ARM64_REG_B20, "q20", 1, 0),
253
+ "q21": (unicorn.arm64_const.UC_ARM64_REG_Q21, "q21", 16, 0),
254
+ "d21": (unicorn.arm64_const.UC_ARM64_REG_D21, "q21", 8, 0),
255
+ "s21": (unicorn.arm64_const.UC_ARM64_REG_S21, "q21", 4, 0),
256
+ "h21": (unicorn.arm64_const.UC_ARM64_REG_H21, "q21", 2, 0),
257
+ "b21": (unicorn.arm64_const.UC_ARM64_REG_B21, "q21", 1, 0),
258
+ "q22": (unicorn.arm64_const.UC_ARM64_REG_Q22, "q22", 16, 0),
259
+ "d22": (unicorn.arm64_const.UC_ARM64_REG_D22, "q22", 8, 0),
260
+ "s22": (unicorn.arm64_const.UC_ARM64_REG_S22, "q22", 4, 0),
261
+ "h22": (unicorn.arm64_const.UC_ARM64_REG_H22, "q22", 2, 0),
262
+ "b22": (unicorn.arm64_const.UC_ARM64_REG_B22, "q22", 1, 0),
263
+ "q23": (unicorn.arm64_const.UC_ARM64_REG_Q23, "q23", 16, 0),
264
+ "d23": (unicorn.arm64_const.UC_ARM64_REG_D23, "q23", 8, 0),
265
+ "s23": (unicorn.arm64_const.UC_ARM64_REG_S23, "q23", 4, 0),
266
+ "h23": (unicorn.arm64_const.UC_ARM64_REG_H23, "q23", 2, 0),
267
+ "b23": (unicorn.arm64_const.UC_ARM64_REG_B23, "q23", 1, 0),
268
+ "q24": (unicorn.arm64_const.UC_ARM64_REG_Q24, "q24", 16, 0),
269
+ "d24": (unicorn.arm64_const.UC_ARM64_REG_D24, "q24", 8, 0),
270
+ "s24": (unicorn.arm64_const.UC_ARM64_REG_S24, "q24", 4, 0),
271
+ "h24": (unicorn.arm64_const.UC_ARM64_REG_H24, "q24", 2, 0),
272
+ "b24": (unicorn.arm64_const.UC_ARM64_REG_B24, "q24", 1, 0),
273
+ "q25": (unicorn.arm64_const.UC_ARM64_REG_Q25, "q25", 16, 0),
274
+ "d25": (unicorn.arm64_const.UC_ARM64_REG_D25, "q25", 8, 0),
275
+ "s25": (unicorn.arm64_const.UC_ARM64_REG_S25, "q25", 4, 0),
276
+ "h25": (unicorn.arm64_const.UC_ARM64_REG_H25, "q25", 2, 0),
277
+ "b25": (unicorn.arm64_const.UC_ARM64_REG_B25, "q25", 1, 0),
278
+ "q26": (unicorn.arm64_const.UC_ARM64_REG_Q26, "q26", 16, 0),
279
+ "d26": (unicorn.arm64_const.UC_ARM64_REG_D26, "q26", 8, 0),
280
+ "s26": (unicorn.arm64_const.UC_ARM64_REG_S26, "q26", 4, 0),
281
+ "h26": (unicorn.arm64_const.UC_ARM64_REG_H26, "q26", 2, 0),
282
+ "b26": (unicorn.arm64_const.UC_ARM64_REG_B26, "q26", 1, 0),
283
+ "q27": (unicorn.arm64_const.UC_ARM64_REG_Q27, "q27", 16, 0),
284
+ "d27": (unicorn.arm64_const.UC_ARM64_REG_D27, "q27", 8, 0),
285
+ "s27": (unicorn.arm64_const.UC_ARM64_REG_S27, "q27", 4, 0),
286
+ "h27": (unicorn.arm64_const.UC_ARM64_REG_H27, "q27", 2, 0),
287
+ "b27": (unicorn.arm64_const.UC_ARM64_REG_B27, "q27", 1, 0),
288
+ "q28": (unicorn.arm64_const.UC_ARM64_REG_Q28, "q28", 16, 0),
289
+ "d28": (unicorn.arm64_const.UC_ARM64_REG_D28, "q28", 8, 0),
290
+ "s28": (unicorn.arm64_const.UC_ARM64_REG_S28, "q28", 4, 0),
291
+ "h28": (unicorn.arm64_const.UC_ARM64_REG_H28, "q28", 2, 0),
292
+ "b28": (unicorn.arm64_const.UC_ARM64_REG_B28, "q28", 1, 0),
293
+ "q29": (unicorn.arm64_const.UC_ARM64_REG_Q29, "q29", 16, 0),
294
+ "d29": (unicorn.arm64_const.UC_ARM64_REG_D29, "q29", 8, 0),
295
+ "s29": (unicorn.arm64_const.UC_ARM64_REG_S29, "q29", 4, 0),
296
+ "h29": (unicorn.arm64_const.UC_ARM64_REG_H29, "q29", 2, 0),
297
+ "b29": (unicorn.arm64_const.UC_ARM64_REG_B29, "q29", 1, 0),
298
+ "q30": (unicorn.arm64_const.UC_ARM64_REG_Q30, "q30", 16, 0),
299
+ "d30": (unicorn.arm64_const.UC_ARM64_REG_D30, "q30", 8, 0),
300
+ "s30": (unicorn.arm64_const.UC_ARM64_REG_S30, "q30", 4, 0),
301
+ "h30": (unicorn.arm64_const.UC_ARM64_REG_H30, "q30", 2, 0),
302
+ "b30": (unicorn.arm64_const.UC_ARM64_REG_B30, "q30", 1, 0),
303
+ "q31": (unicorn.arm64_const.UC_ARM64_REG_Q31, "q31", 16, 0),
304
+ "d31": (unicorn.arm64_const.UC_ARM64_REG_D31, "q31", 8, 0),
305
+ "s31": (unicorn.arm64_const.UC_ARM64_REG_S31, "q31", 4, 0),
306
+ "h31": (unicorn.arm64_const.UC_ARM64_REG_H31, "q31", 2, 0),
307
+ "b31": (unicorn.arm64_const.UC_ARM64_REG_B31, "q31", 1, 0),
308
+ # Vector registers
309
+ # TODO: Figure out how to model these
310
+ }
@@ -0,0 +1,326 @@
1
+ import capstone
2
+ import unicorn
3
+
4
+ from ....platforms import Architecture, Byteorder
5
+ from .machdef import UnicornMachineDef
6
+
7
+
8
+ class AMD64MachineDef(UnicornMachineDef):
9
+ """Unicorn machine definition for amd64"""
10
+
11
+ byteorder = Byteorder.LITTLE
12
+
13
+ uc_arch = unicorn.UC_ARCH_X86
14
+ uc_mode = unicorn.UC_MODE_64
15
+
16
+ cs_arch = capstone.CS_ARCH_X86
17
+ cs_mode = capstone.CS_MODE_64
18
+
19
+ pc_reg = "rip"
20
+
21
+ def __init__(self):
22
+ self._registers = {
23
+ # *** General Purpose Registers ***
24
+ "rax": (unicorn.x86_const.UC_X86_REG_RAX, "rax", 8, 0),
25
+ "eax": (unicorn.x86_const.UC_X86_REG_EAX, "rax", 4, 0),
26
+ "ax": (unicorn.x86_const.UC_X86_REG_AX, "rax", 2, 0),
27
+ "al": (unicorn.x86_const.UC_X86_REG_AL, "rax", 1, 0),
28
+ "ah": (unicorn.x86_const.UC_X86_REG_AH, "rax", 1, 1),
29
+ "rbx": (unicorn.x86_const.UC_X86_REG_RBX, "rbx", 8, 0),
30
+ "ebx": (unicorn.x86_const.UC_X86_REG_EBX, "rbx", 4, 0),
31
+ "bx": (unicorn.x86_const.UC_X86_REG_BX, "rbx", 2, 0),
32
+ "bl": (unicorn.x86_const.UC_X86_REG_BL, "rbx", 1, 0),
33
+ "bh": (unicorn.x86_const.UC_X86_REG_BH, "rbx", 1, 1),
34
+ "rcx": (unicorn.x86_const.UC_X86_REG_RCX, "rcx", 8, 0),
35
+ "ecx": (unicorn.x86_const.UC_X86_REG_ECX, "rcx", 4, 0),
36
+ "cx": (unicorn.x86_const.UC_X86_REG_CX, "rcx", 2, 0),
37
+ "cl": (unicorn.x86_const.UC_X86_REG_CL, "rcx", 1, 0),
38
+ "ch": (unicorn.x86_const.UC_X86_REG_CH, "rcx", 1, 1),
39
+ "rdx": (unicorn.x86_const.UC_X86_REG_RDX, "rdx", 8, 0),
40
+ "edx": (unicorn.x86_const.UC_X86_REG_EDX, "rdx", 4, 0),
41
+ "dx": (unicorn.x86_const.UC_X86_REG_DX, "rdx", 2, 0),
42
+ "dl": (unicorn.x86_const.UC_X86_REG_DL, "rdx", 1, 0),
43
+ "dh": (unicorn.x86_const.UC_X86_REG_DH, "rdx", 1, 1),
44
+ "r8": (unicorn.x86_const.UC_X86_REG_R8, "r8", 8, 0),
45
+ "r8d": (unicorn.x86_const.UC_X86_REG_R8D, "r8", 4, 0),
46
+ "r8w": (unicorn.x86_const.UC_X86_REG_R8W, "r8", 2, 0),
47
+ "r8b": (unicorn.x86_const.UC_X86_REG_R8B, "r8", 1, 0),
48
+ "r9": (unicorn.x86_const.UC_X86_REG_R9, "r9", 8, 0),
49
+ "r9d": (unicorn.x86_const.UC_X86_REG_R9D, "r9", 4, 0),
50
+ "r9w": (unicorn.x86_const.UC_X86_REG_R9W, "r9", 2, 0),
51
+ "r9b": (unicorn.x86_const.UC_X86_REG_R9B, "r9", 1, 0),
52
+ "r10": (unicorn.x86_const.UC_X86_REG_R10, "r10", 8, 0),
53
+ "r10d": (unicorn.x86_const.UC_X86_REG_R10D, "r10", 4, 0),
54
+ "r10w": (unicorn.x86_const.UC_X86_REG_R10W, "r10", 2, 0),
55
+ "r10b": (unicorn.x86_const.UC_X86_REG_R10B, "r10", 1, 0),
56
+ "r11": (unicorn.x86_const.UC_X86_REG_R11, "r11", 8, 0),
57
+ "r11d": (unicorn.x86_const.UC_X86_REG_R11D, "r11", 4, 0),
58
+ "r11w": (unicorn.x86_const.UC_X86_REG_R11W, "r11", 2, 0),
59
+ "r11b": (unicorn.x86_const.UC_X86_REG_R11B, "r11", 1, 0),
60
+ "r12": (unicorn.x86_const.UC_X86_REG_R12, "r12", 8, 0),
61
+ "r12d": (unicorn.x86_const.UC_X86_REG_R12D, "r12", 4, 0),
62
+ "r12w": (unicorn.x86_const.UC_X86_REG_R12W, "r12", 2, 0),
63
+ "r12b": (unicorn.x86_const.UC_X86_REG_R12B, "r12", 1, 0),
64
+ "r13": (unicorn.x86_const.UC_X86_REG_R13, "r13", 8, 0),
65
+ "r13d": (unicorn.x86_const.UC_X86_REG_R13D, "r13", 4, 0),
66
+ "r13w": (unicorn.x86_const.UC_X86_REG_R13W, "r13", 2, 0),
67
+ "r13b": (unicorn.x86_const.UC_X86_REG_R13B, "r13", 1, 0),
68
+ "r14": (unicorn.x86_const.UC_X86_REG_R14, "r14", 8, 0),
69
+ "r14d": (unicorn.x86_const.UC_X86_REG_R14D, "r14", 4, 0),
70
+ "r14w": (unicorn.x86_const.UC_X86_REG_R14W, "r14", 2, 0),
71
+ "r14b": (unicorn.x86_const.UC_X86_REG_R14B, "r14", 1, 0),
72
+ "r15": (unicorn.x86_const.UC_X86_REG_R15, "r15", 8, 0),
73
+ "r15d": (unicorn.x86_const.UC_X86_REG_R15D, "r15", 4, 0),
74
+ "r15w": (unicorn.x86_const.UC_X86_REG_R15W, "r15", 2, 0),
75
+ "r15b": (unicorn.x86_const.UC_X86_REG_R15B, "r15", 1, 0),
76
+ "rdi": (unicorn.x86_const.UC_X86_REG_RDI, "rdi", 8, 0),
77
+ "edi": (unicorn.x86_const.UC_X86_REG_EDI, "rdi", 4, 0),
78
+ "di": (unicorn.x86_const.UC_X86_REG_DI, "rdi", 2, 0),
79
+ "dil": (unicorn.x86_const.UC_X86_REG_DIL, "rdi", 1, 0),
80
+ "rsi": (unicorn.x86_const.UC_X86_REG_RSI, "rsi", 8, 0),
81
+ "esi": (unicorn.x86_const.UC_X86_REG_ESI, "rsi", 4, 0),
82
+ "si": (unicorn.x86_const.UC_X86_REG_SI, "rsi", 2, 0),
83
+ "sil": (unicorn.x86_const.UC_X86_REG_SIL, "rsi", 1, 0),
84
+ "rsp": (unicorn.x86_const.UC_X86_REG_RSP, "rsp", 8, 0),
85
+ "esp": (unicorn.x86_const.UC_X86_REG_ESP, "rsp", 4, 0),
86
+ "sp": (unicorn.x86_const.UC_X86_REG_SP, "rsp", 2, 0),
87
+ "spl": (unicorn.x86_const.UC_X86_REG_SPL, "rsp", 1, 0),
88
+ "rbp": (unicorn.x86_const.UC_X86_REG_RBP, "rbp", 8, 0),
89
+ "ebp": (unicorn.x86_const.UC_X86_REG_EBP, "rbp", 4, 0),
90
+ "bp": (unicorn.x86_const.UC_X86_REG_BP, "rbp", 2, 0),
91
+ "bpl": (unicorn.x86_const.UC_X86_REG_BPL, "rbp", 1, 0),
92
+ # *** Instruction Pointer ***
93
+ "rip": (unicorn.x86_const.UC_X86_REG_RIP, "rip", 8, 0),
94
+ "eip": (unicorn.x86_const.UC_X86_REG_EIP, "rip", 4, 0),
95
+ "ip": (unicorn.x86_const.UC_X86_REG_IP, "rip", 2, 0),
96
+ # *** Flags register ***
97
+ "rflags": (unicorn.x86_const.UC_X86_REG_RFLAGS, "rflags", 8, 0),
98
+ "eflags": (unicorn.x86_const.UC_X86_REG_EFLAGS, "rflags", 4, 0),
99
+ "flags": (unicorn.x86_const.UC_X86_REG_FLAGS, "rflags", 2, 0),
100
+ # *** Segment Registers ***
101
+ "cs": (unicorn.x86_const.UC_X86_REG_CS, "cs", 2, 0),
102
+ "ds": (unicorn.x86_const.UC_X86_REG_DS, "ds", 2, 0),
103
+ "es": (unicorn.x86_const.UC_X86_REG_ES, "es", 2, 0),
104
+ "fs": (unicorn.x86_const.UC_X86_REG_FS, "fs", 2, 0),
105
+ "gs": (unicorn.x86_const.UC_X86_REG_GS, "gs", 2, 0),
106
+ # *** Control Registers ***
107
+ "cr0": (unicorn.x86_const.UC_X86_REG_CR0, "cr0", 8, 0),
108
+ "cr1": (unicorn.x86_const.UC_X86_REG_CR1, "cr1", 8, 0),
109
+ "cr2": (unicorn.x86_const.UC_X86_REG_CR2, "cr2", 8, 0),
110
+ "cr3": (unicorn.x86_const.UC_X86_REG_CR3, "cr3", 8, 0),
111
+ "cr4": (unicorn.x86_const.UC_X86_REG_CR4, "cr4", 8, 0),
112
+ "cr8": (unicorn.x86_const.UC_X86_REG_INVALID, "cr8", 8, 0),
113
+ # *** Debug Registers ***
114
+ "dr0": (unicorn.x86_const.UC_X86_REG_DR0, "dr0", 8, 0),
115
+ "dr1": (unicorn.x86_const.UC_X86_REG_DR1, "dr1", 8, 0),
116
+ "dr2": (unicorn.x86_const.UC_X86_REG_DR2, "dr2", 8, 0),
117
+ "dr3": (unicorn.x86_const.UC_X86_REG_DR3, "dr3", 8, 0),
118
+ "dr6": (unicorn.x86_const.UC_X86_REG_DR6, "dr6", 8, 0),
119
+ "dr7": (unicorn.x86_const.UC_X86_REG_DR7, "dr7", 8, 0),
120
+ "dr8": (unicorn.x86_const.UC_X86_REG_INVALID, "dr8", 8, 0),
121
+ "dr9": (unicorn.x86_const.UC_X86_REG_INVALID, "dr9", 8, 0),
122
+ "dr10": (unicorn.x86_const.UC_X86_REG_INVALID, "dr10", 8, 0),
123
+ "dr11": (unicorn.x86_const.UC_X86_REG_INVALID, "dr11", 8, 0),
124
+ "dr12": (unicorn.x86_const.UC_X86_REG_INVALID, "dr12", 8, 0),
125
+ "dr13": (unicorn.x86_const.UC_X86_REG_INVALID, "dr13", 8, 0),
126
+ "dr14": (unicorn.x86_const.UC_X86_REG_INVALID, "dr14", 8, 0),
127
+ "dr15": (unicorn.x86_const.UC_X86_REG_INVALID, "dr15", 8, 0),
128
+ # *** Descriptor Table Registers ***
129
+ "gdtr": (unicorn.x86_const.UC_X86_REG_GDTR, "gdtr", 10, 0),
130
+ "idtr": (unicorn.x86_const.UC_X86_REG_IDTR, "idtr", 10, 0),
131
+ "ldtr": (unicorn.x86_const.UC_X86_REG_LDTR, "ldtr", 10, 0),
132
+ # *** Task Register ***
133
+ "tr": (unicorn.x86_const.UC_X86_REG_TR, "tr", 2, 0),
134
+ # *** x87 registers ***
135
+ # NOTE: x87 is supported by Unicorn, but not by SmallWorld.
136
+ # Values are represented as tuples (exponent: int, mantissa: int).
137
+ # If you need x87 support, open a ticket.
138
+ "fpr0": (unicorn.x86_const.UC_X86_REG_INVALID, "fpr0", 10, 0),
139
+ "fpr1": (unicorn.x86_const.UC_X86_REG_INVALID, "fpr1", 10, 0),
140
+ "fpr2": (unicorn.x86_const.UC_X86_REG_INVALID, "fpr2", 10, 0),
141
+ "fpr3": (unicorn.x86_const.UC_X86_REG_INVALID, "fpr3", 10, 0),
142
+ "fpr4": (unicorn.x86_const.UC_X86_REG_INVALID, "fpr4", 10, 0),
143
+ "fpr5": (unicorn.x86_const.UC_X86_REG_INVALID, "fpr5", 10, 0),
144
+ "fpr6": (unicorn.x86_const.UC_X86_REG_INVALID, "fpr6", 10, 0),
145
+ "fpr7": (unicorn.x86_const.UC_X86_REG_INVALID, "fpr7", 10, 0),
146
+ # x87 Control Register
147
+ "fctrl": (unicorn.x86_const.UC_X86_REG_FPCW, "fctrl", 2, 0),
148
+ # x87 Status Register
149
+ "fstat": (unicorn.x86_const.UC_X86_REG_FPCW, "fstat", 2, 0),
150
+ # x87 Tag Register
151
+ "ftag": (unicorn.x86_const.UC_X86_REG_FPTAG, "ftag", 2, 0),
152
+ # x87 Last Instruction Register
153
+ "fip": (unicorn.x86_const.UC_X86_REG_FIP, "fip", 8, 0),
154
+ # x87 Last Operand Pointer
155
+ "fdp": (unicorn.x86_const.UC_X86_REG_FDP, "fdp", 8, 0),
156
+ # x87 Last Opcode
157
+ "fop": (unicorn.x86_const.UC_X86_REG_FOP, "fop", 2, 0),
158
+ # NOTE: Docs disagree on the format of fip and fdp.
159
+ # One source describes them as 48-bit offset-plus-segment,
160
+ # the other describes them as 64-bit.
161
+ # There may also be separate segment registers.
162
+ # If you care about the x87 debug info, please feel free to update.
163
+ # *** MMX Registers ***
164
+ # NOTE: The MMX registers are aliases for the low 8 bytes of the x87 registers.
165
+ # The two subsystems cannot be used simultaneously.
166
+ "mm0": (unicorn.x86_const.UC_X86_REG_MM0, "fpr0", 8, 0),
167
+ "mm1": (unicorn.x86_const.UC_X86_REG_MM1, "fpr1", 8, 0),
168
+ "mm2": (unicorn.x86_const.UC_X86_REG_MM2, "fpr2", 8, 0),
169
+ "mm3": (unicorn.x86_const.UC_X86_REG_MM3, "fpr3", 8, 0),
170
+ "mm4": (unicorn.x86_const.UC_X86_REG_MM4, "fpr4", 8, 0),
171
+ "mm5": (unicorn.x86_const.UC_X86_REG_MM5, "fpr5", 8, 0),
172
+ "mm6": (unicorn.x86_const.UC_X86_REG_MM6, "fpr6", 8, 0),
173
+ "mm7": (unicorn.x86_const.UC_X86_REG_MM7, "fpr7", 8, 0),
174
+ }
175
+
176
+
177
+ class AMD64AVX2MachineDef(AMD64MachineDef):
178
+ arch = Architecture.X86_64
179
+
180
+ def __init__(self):
181
+ super().__init__()
182
+ self._registers.update(
183
+ {
184
+ # *** SSE/AVX registers ***
185
+ "ymm0": (unicorn.x86_const.UC_X86_REG_YMM0, "ymm0", 32, 0),
186
+ "xmm0": (unicorn.x86_const.UC_X86_REG_XMM0, "ymm0", 16, 0),
187
+ "ymm1": (unicorn.x86_const.UC_X86_REG_YMM1, "ymm1", 32, 0),
188
+ "xmm1": (unicorn.x86_const.UC_X86_REG_XMM1, "ymm1", 16, 0),
189
+ "ymm2": (unicorn.x86_const.UC_X86_REG_YMM2, "ymm2", 32, 0),
190
+ "xmm2": (unicorn.x86_const.UC_X86_REG_XMM2, "ymm2", 16, 0),
191
+ "ymm3": (unicorn.x86_const.UC_X86_REG_YMM3, "ymm3", 32, 0),
192
+ "xmm3": (unicorn.x86_const.UC_X86_REG_XMM3, "ymm3", 16, 0),
193
+ "ymm4": (unicorn.x86_const.UC_X86_REG_YMM4, "ymm4", 32, 0),
194
+ "xmm4": (unicorn.x86_const.UC_X86_REG_XMM4, "ymm4", 16, 0),
195
+ "ymm5": (unicorn.x86_const.UC_X86_REG_YMM5, "ymm5", 32, 0),
196
+ "xmm5": (unicorn.x86_const.UC_X86_REG_XMM5, "ymm5", 16, 0),
197
+ "ymm6": (unicorn.x86_const.UC_X86_REG_YMM6, "ymm6", 32, 0),
198
+ "xmm6": (unicorn.x86_const.UC_X86_REG_XMM6, "ymm6", 16, 0),
199
+ "ymm7": (unicorn.x86_const.UC_X86_REG_YMM7, "ymm7", 32, 0),
200
+ "xmm7": (unicorn.x86_const.UC_X86_REG_XMM7, "ymm7", 16, 0),
201
+ "ymm8": (unicorn.x86_const.UC_X86_REG_YMM8, "ymm8", 32, 0),
202
+ "xmm8": (unicorn.x86_const.UC_X86_REG_XMM8, "ymm8", 16, 0),
203
+ "ymm9": (unicorn.x86_const.UC_X86_REG_YMM9, "ymm9", 32, 0),
204
+ "xmm9": (unicorn.x86_const.UC_X86_REG_XMM9, "ymm9", 16, 0),
205
+ "ymm10": (unicorn.x86_const.UC_X86_REG_YMM10, "ymm10", 32, 0),
206
+ "xmm10": (unicorn.x86_const.UC_X86_REG_XMM10, "ymm10", 16, 0),
207
+ "ymm11": (unicorn.x86_const.UC_X86_REG_YMM11, "ymm11", 32, 0),
208
+ "xmm11": (unicorn.x86_const.UC_X86_REG_XMM11, "ymm11", 16, 0),
209
+ "ymm12": (unicorn.x86_const.UC_X86_REG_YMM12, "ymm12", 32, 0),
210
+ "xmm12": (unicorn.x86_const.UC_X86_REG_XMM12, "ymm12", 16, 0),
211
+ "ymm13": (unicorn.x86_const.UC_X86_REG_YMM13, "ymm13", 32, 0),
212
+ "xmm13": (unicorn.x86_const.UC_X86_REG_XMM13, "ymm13", 16, 0),
213
+ "ymm14": (unicorn.x86_const.UC_X86_REG_YMM14, "ymm14", 32, 0),
214
+ "xmm14": (unicorn.x86_const.UC_X86_REG_XMM14, "ymm14", 16, 0),
215
+ "ymm15": (unicorn.x86_const.UC_X86_REG_YMM15, "ymm15", 32, 0),
216
+ "xmm15": (unicorn.x86_const.UC_X86_REG_XMM15, "ymm15", 16, 0),
217
+ }
218
+ )
219
+
220
+
221
+ class AMD64AVX512MachineDef(AMD64MachineDef):
222
+ arch = Architecture.X86_64_AVX512
223
+
224
+ def __init__(self):
225
+ super().__init__()
226
+ self._registers.update(
227
+ {
228
+ # *** SSE/AVX registers ***
229
+ "zmm0": (unicorn.x86_const.UC_X86_REG_ZMM0, "zmm0", 64, 0),
230
+ "ymm0": (unicorn.x86_const.UC_X86_REG_YMM0, "zmm0", 32, 0),
231
+ "xmm0": (unicorn.x86_const.UC_X86_REG_XMM0, "zmm0", 16, 0),
232
+ "zmm1": (unicorn.x86_const.UC_X86_REG_ZMM1, "zmm1", 64, 0),
233
+ "ymm1": (unicorn.x86_const.UC_X86_REG_YMM1, "zmm1", 32, 0),
234
+ "xmm1": (unicorn.x86_const.UC_X86_REG_XMM1, "zmm1", 16, 0),
235
+ "zmm2": (unicorn.x86_const.UC_X86_REG_ZMM2, "zmm2", 64, 0),
236
+ "ymm2": (unicorn.x86_const.UC_X86_REG_YMM2, "zmm2", 32, 0),
237
+ "xmm2": (unicorn.x86_const.UC_X86_REG_XMM2, "zmm2", 16, 0),
238
+ "zmm3": (unicorn.x86_const.UC_X86_REG_ZMM3, "zmm3", 64, 0),
239
+ "ymm3": (unicorn.x86_const.UC_X86_REG_YMM3, "zmm3", 32, 0),
240
+ "xmm3": (unicorn.x86_const.UC_X86_REG_XMM3, "zmm3", 16, 0),
241
+ "zmm4": (unicorn.x86_const.UC_X86_REG_ZMM4, "zmm4", 64, 0),
242
+ "ymm4": (unicorn.x86_const.UC_X86_REG_YMM4, "zmm4", 32, 0),
243
+ "xmm4": (unicorn.x86_const.UC_X86_REG_XMM4, "zmm4", 16, 0),
244
+ "zmm5": (unicorn.x86_const.UC_X86_REG_ZMM5, "zmm5", 64, 0),
245
+ "ymm5": (unicorn.x86_const.UC_X86_REG_YMM5, "zmm5", 32, 0),
246
+ "xmm5": (unicorn.x86_const.UC_X86_REG_XMM5, "zmm5", 16, 0),
247
+ "zmm6": (unicorn.x86_const.UC_X86_REG_ZMM6, "zmm6", 64, 0),
248
+ "ymm6": (unicorn.x86_const.UC_X86_REG_YMM6, "zmm6", 32, 0),
249
+ "xmm6": (unicorn.x86_const.UC_X86_REG_XMM6, "zmm6", 16, 0),
250
+ "zmm7": (unicorn.x86_const.UC_X86_REG_ZMM7, "zmm7", 64, 0),
251
+ "ymm7": (unicorn.x86_const.UC_X86_REG_YMM7, "zmm7", 32, 0),
252
+ "xmm7": (unicorn.x86_const.UC_X86_REG_XMM7, "zmm7", 16, 0),
253
+ "zmm8": (unicorn.x86_const.UC_X86_REG_ZMM8, "zmm8", 64, 0),
254
+ "ymm8": (unicorn.x86_const.UC_X86_REG_YMM8, "zmm8", 32, 0),
255
+ "xmm8": (unicorn.x86_const.UC_X86_REG_XMM8, "zmm8", 16, 0),
256
+ "zmm9": (unicorn.x86_const.UC_X86_REG_ZMM9, "zmm9", 64, 0),
257
+ "ymm9": (unicorn.x86_const.UC_X86_REG_YMM9, "zmm9", 32, 0),
258
+ "xmm9": (unicorn.x86_const.UC_X86_REG_XMM9, "zmm9", 16, 0),
259
+ "zmm10": (unicorn.x86_const.UC_X86_REG_ZMM10, "zmm10", 64, 0),
260
+ "ymm10": (unicorn.x86_const.UC_X86_REG_YMM10, "zmm10", 32, 0),
261
+ "xmm10": (unicorn.x86_const.UC_X86_REG_XMM10, "zmm10", 16, 0),
262
+ "zmm11": (unicorn.x86_const.UC_X86_REG_ZMM11, "zmm11", 64, 0),
263
+ "ymm11": (unicorn.x86_const.UC_X86_REG_YMM11, "zmm11", 32, 0),
264
+ "xmm11": (unicorn.x86_const.UC_X86_REG_XMM11, "zmm11", 16, 0),
265
+ "zmm12": (unicorn.x86_const.UC_X86_REG_ZMM12, "zmm12", 64, 0),
266
+ "ymm12": (unicorn.x86_const.UC_X86_REG_YMM12, "zmm12", 32, 0),
267
+ "xmm12": (unicorn.x86_const.UC_X86_REG_XMM12, "zmm12", 16, 0),
268
+ "zmm13": (unicorn.x86_const.UC_X86_REG_ZMM13, "zmm13", 64, 0),
269
+ "ymm13": (unicorn.x86_const.UC_X86_REG_YMM13, "zmm13", 32, 0),
270
+ "xmm13": (unicorn.x86_const.UC_X86_REG_XMM13, "zmm13", 16, 0),
271
+ "zmm14": (unicorn.x86_const.UC_X86_REG_ZMM14, "zmm14", 64, 0),
272
+ "ymm14": (unicorn.x86_const.UC_X86_REG_YMM14, "zmm14", 32, 0),
273
+ "xmm14": (unicorn.x86_const.UC_X86_REG_XMM14, "zmm14", 16, 0),
274
+ "zmm15": (unicorn.x86_const.UC_X86_REG_ZMM15, "zmm15", 64, 0),
275
+ "ymm15": (unicorn.x86_const.UC_X86_REG_YMM15, "zmm15", 32, 0),
276
+ "xmm15": (unicorn.x86_const.UC_X86_REG_XMM15, "zmm15", 16, 0),
277
+ "zmm16": (unicorn.x86_const.UC_X86_REG_ZMM16, "zmm16", 64, 0),
278
+ "ymm16": (unicorn.x86_const.UC_X86_REG_YMM16, "zmm16", 32, 0),
279
+ "xmm16": (unicorn.x86_const.UC_X86_REG_XMM16, "zmm16", 16, 0),
280
+ "zmm17": (unicorn.x86_const.UC_X86_REG_ZMM17, "zmm17", 64, 0),
281
+ "ymm17": (unicorn.x86_const.UC_X86_REG_YMM17, "zmm17", 32, 0),
282
+ "xmm17": (unicorn.x86_const.UC_X86_REG_XMM17, "zmm17", 16, 0),
283
+ "zmm18": (unicorn.x86_const.UC_X86_REG_ZMM18, "zmm18", 64, 0),
284
+ "ymm18": (unicorn.x86_const.UC_X86_REG_YMM18, "zmm18", 32, 0),
285
+ "xmm18": (unicorn.x86_const.UC_X86_REG_XMM18, "zmm18", 16, 0),
286
+ "zmm19": (unicorn.x86_const.UC_X86_REG_ZMM19, "zmm19", 64, 0),
287
+ "ymm19": (unicorn.x86_const.UC_X86_REG_YMM19, "zmm19", 32, 0),
288
+ "xmm19": (unicorn.x86_const.UC_X86_REG_XMM19, "zmm19", 16, 0),
289
+ "zmm20": (unicorn.x86_const.UC_X86_REG_ZMM20, "zmm20", 64, 0),
290
+ "ymm20": (unicorn.x86_const.UC_X86_REG_YMM20, "zmm20", 32, 0),
291
+ "xmm20": (unicorn.x86_const.UC_X86_REG_XMM20, "zmm20", 16, 0),
292
+ "zmm21": (unicorn.x86_const.UC_X86_REG_ZMM21, "zmm21", 64, 0),
293
+ "ymm21": (unicorn.x86_const.UC_X86_REG_YMM21, "zmm21", 32, 0),
294
+ "xmm21": (unicorn.x86_const.UC_X86_REG_XMM21, "zmm21", 16, 0),
295
+ "zmm22": (unicorn.x86_const.UC_X86_REG_ZMM22, "zmm22", 64, 0),
296
+ "ymm22": (unicorn.x86_const.UC_X86_REG_YMM22, "zmm22", 32, 0),
297
+ "xmm22": (unicorn.x86_const.UC_X86_REG_XMM22, "zmm22", 16, 0),
298
+ "zmm23": (unicorn.x86_const.UC_X86_REG_ZMM23, "zmm23", 64, 0),
299
+ "ymm23": (unicorn.x86_const.UC_X86_REG_YMM23, "zmm23", 32, 0),
300
+ "xmm23": (unicorn.x86_const.UC_X86_REG_XMM23, "zmm23", 16, 0),
301
+ "zmm24": (unicorn.x86_const.UC_X86_REG_ZMM24, "zmm24", 64, 0),
302
+ "ymm24": (unicorn.x86_const.UC_X86_REG_YMM24, "zmm24", 32, 0),
303
+ "xmm24": (unicorn.x86_const.UC_X86_REG_XMM24, "zmm24", 16, 0),
304
+ "zmm25": (unicorn.x86_const.UC_X86_REG_ZMM25, "zmm25", 64, 0),
305
+ "ymm25": (unicorn.x86_const.UC_X86_REG_YMM25, "zmm25", 32, 0),
306
+ "xmm25": (unicorn.x86_const.UC_X86_REG_XMM25, "zmm25", 16, 0),
307
+ "zmm26": (unicorn.x86_const.UC_X86_REG_ZMM26, "zmm26", 64, 0),
308
+ "ymm26": (unicorn.x86_const.UC_X86_REG_YMM26, "zmm26", 32, 0),
309
+ "xmm26": (unicorn.x86_const.UC_X86_REG_XMM26, "zmm26", 16, 0),
310
+ "zmm27": (unicorn.x86_const.UC_X86_REG_ZMM27, "zmm27", 64, 0),
311
+ "ymm27": (unicorn.x86_const.UC_X86_REG_YMM27, "zmm27", 32, 0),
312
+ "xmm27": (unicorn.x86_const.UC_X86_REG_XMM27, "zmm27", 16, 0),
313
+ "zmm28": (unicorn.x86_const.UC_X86_REG_ZMM28, "zmm28", 64, 0),
314
+ "ymm28": (unicorn.x86_const.UC_X86_REG_YMM28, "zmm28", 32, 0),
315
+ "xmm28": (unicorn.x86_const.UC_X86_REG_XMM28, "zmm28", 16, 0),
316
+ "zmm29": (unicorn.x86_const.UC_X86_REG_ZMM29, "zmm29", 64, 0),
317
+ "ymm29": (unicorn.x86_const.UC_X86_REG_YMM29, "zmm29", 32, 0),
318
+ "xmm29": (unicorn.x86_const.UC_X86_REG_XMM29, "zmm29", 16, 0),
319
+ "zmm30": (unicorn.x86_const.UC_X86_REG_ZMM30, "zmm30", 64, 0),
320
+ "ymm30": (unicorn.x86_const.UC_X86_REG_YMM30, "zmm30", 32, 0),
321
+ "xmm30": (unicorn.x86_const.UC_X86_REG_XMM30, "zmm30", 16, 0),
322
+ "zmm31": (unicorn.x86_const.UC_X86_REG_ZMM31, "zmm31", 64, 0),
323
+ "ymm31": (unicorn.x86_const.UC_X86_REG_YMM31, "zmm31", 32, 0),
324
+ "xmm31": (unicorn.x86_const.UC_X86_REG_XMM31, "zmm31", 16, 0),
325
+ }
326
+ )