hexcore-capstone 1.2.0

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 (332) hide show
  1. package/LICENSE +26 -0
  2. package/README.md +191 -0
  3. package/binding.gyp +168 -0
  4. package/deps/capstone/LEB128.h +38 -0
  5. package/deps/capstone/MCDisassembler.h +14 -0
  6. package/deps/capstone/MCFixedLenDisassembler.h +32 -0
  7. package/deps/capstone/MCInst.c +270 -0
  8. package/deps/capstone/MCInst.h +165 -0
  9. package/deps/capstone/MCInstrDesc.c +41 -0
  10. package/deps/capstone/MCInstrDesc.h +167 -0
  11. package/deps/capstone/MCRegisterInfo.c +151 -0
  12. package/deps/capstone/MCRegisterInfo.h +116 -0
  13. package/deps/capstone/Mapping.c +254 -0
  14. package/deps/capstone/Mapping.h +174 -0
  15. package/deps/capstone/MathExtras.h +442 -0
  16. package/deps/capstone/SStream.c +181 -0
  17. package/deps/capstone/SStream.h +40 -0
  18. package/deps/capstone/arch/AArch64/AArch64AddressingModes.h +945 -0
  19. package/deps/capstone/arch/AArch64/AArch64BaseInfo.c +77 -0
  20. package/deps/capstone/arch/AArch64/AArch64BaseInfo.h +585 -0
  21. package/deps/capstone/arch/AArch64/AArch64Disassembler.c +2280 -0
  22. package/deps/capstone/arch/AArch64/AArch64Disassembler.h +18 -0
  23. package/deps/capstone/arch/AArch64/AArch64GenAsmWriter.inc +26589 -0
  24. package/deps/capstone/arch/AArch64/AArch64GenDisassemblerTables.inc +27322 -0
  25. package/deps/capstone/arch/AArch64/AArch64GenInstrInfo.inc +13194 -0
  26. package/deps/capstone/arch/AArch64/AArch64GenRegisterInfo.inc +3814 -0
  27. package/deps/capstone/arch/AArch64/AArch64GenRegisterName.inc +714 -0
  28. package/deps/capstone/arch/AArch64/AArch64GenRegisterV.inc +673 -0
  29. package/deps/capstone/arch/AArch64/AArch64GenSubtargetInfo.inc +229 -0
  30. package/deps/capstone/arch/AArch64/AArch64GenSystemOperands.inc +2863 -0
  31. package/deps/capstone/arch/AArch64/AArch64GenSystemOperands_enum.inc +21 -0
  32. package/deps/capstone/arch/AArch64/AArch64InstPrinter.c +3029 -0
  33. package/deps/capstone/arch/AArch64/AArch64InstPrinter.h +28 -0
  34. package/deps/capstone/arch/AArch64/AArch64Mapping.c +883 -0
  35. package/deps/capstone/arch/AArch64/AArch64Mapping.h +43 -0
  36. package/deps/capstone/arch/AArch64/AArch64MappingInsn.inc +37790 -0
  37. package/deps/capstone/arch/AArch64/AArch64MappingInsnName.inc +1282 -0
  38. package/deps/capstone/arch/AArch64/AArch64MappingInsnOp.inc +26994 -0
  39. package/deps/capstone/arch/AArch64/AArch64Module.c +44 -0
  40. package/deps/capstone/arch/AArch64/AArch64Module.h +12 -0
  41. package/deps/capstone/arch/ARM/ARMAddressingModes.h +698 -0
  42. package/deps/capstone/arch/ARM/ARMBaseInfo.h +486 -0
  43. package/deps/capstone/arch/ARM/ARMDisassembler.c +5763 -0
  44. package/deps/capstone/arch/ARM/ARMDisassembler.h +18 -0
  45. package/deps/capstone/arch/ARM/ARMGenAsmWriter.inc +9545 -0
  46. package/deps/capstone/arch/ARM/ARMGenDisassemblerTables.inc +15185 -0
  47. package/deps/capstone/arch/ARM/ARMGenInstrInfo.inc +6632 -0
  48. package/deps/capstone/arch/ARM/ARMGenRegisterInfo.inc +2102 -0
  49. package/deps/capstone/arch/ARM/ARMGenRegisterName.inc +231 -0
  50. package/deps/capstone/arch/ARM/ARMGenRegisterName_digit.inc +231 -0
  51. package/deps/capstone/arch/ARM/ARMGenSubtargetInfo.inc +162 -0
  52. package/deps/capstone/arch/ARM/ARMGenSystemRegister.inc +270 -0
  53. package/deps/capstone/arch/ARM/ARMInstPrinter.c +3364 -0
  54. package/deps/capstone/arch/ARM/ARMInstPrinter.h +43 -0
  55. package/deps/capstone/arch/ARM/ARMMapping.c +551 -0
  56. package/deps/capstone/arch/ARM/ARMMapping.h +40 -0
  57. package/deps/capstone/arch/ARM/ARMMappingInsn.inc +18772 -0
  58. package/deps/capstone/arch/ARM/ARMMappingInsnName.inc +475 -0
  59. package/deps/capstone/arch/ARM/ARMMappingInsnOp.inc +10729 -0
  60. package/deps/capstone/arch/ARM/ARMModule.c +63 -0
  61. package/deps/capstone/arch/ARM/ARMModule.h +12 -0
  62. package/deps/capstone/arch/BPF/BPFConstants.h +88 -0
  63. package/deps/capstone/arch/BPF/BPFDisassembler.c +464 -0
  64. package/deps/capstone/arch/BPF/BPFDisassembler.h +27 -0
  65. package/deps/capstone/arch/BPF/BPFInstPrinter.c +285 -0
  66. package/deps/capstone/arch/BPF/BPFInstPrinter.h +16 -0
  67. package/deps/capstone/arch/BPF/BPFMapping.c +513 -0
  68. package/deps/capstone/arch/BPF/BPFMapping.h +21 -0
  69. package/deps/capstone/arch/BPF/BPFModule.c +34 -0
  70. package/deps/capstone/arch/BPF/BPFModule.h +12 -0
  71. package/deps/capstone/arch/EVM/EVMDisassembler.c +379 -0
  72. package/deps/capstone/arch/EVM/EVMDisassembler.h +12 -0
  73. package/deps/capstone/arch/EVM/EVMInstPrinter.c +20 -0
  74. package/deps/capstone/arch/EVM/EVMInstPrinter.h +17 -0
  75. package/deps/capstone/arch/EVM/EVMMapping.c +344 -0
  76. package/deps/capstone/arch/EVM/EVMMapping.h +8 -0
  77. package/deps/capstone/arch/EVM/EVMMappingInsn.inc +259 -0
  78. package/deps/capstone/arch/EVM/EVMModule.c +33 -0
  79. package/deps/capstone/arch/EVM/EVMModule.h +12 -0
  80. package/deps/capstone/arch/M680X/M680XDisassembler.c +2307 -0
  81. package/deps/capstone/arch/M680X/M680XDisassembler.h +17 -0
  82. package/deps/capstone/arch/M680X/M680XDisassemblerInternals.h +57 -0
  83. package/deps/capstone/arch/M680X/M680XInstPrinter.c +360 -0
  84. package/deps/capstone/arch/M680X/M680XInstPrinter.h +25 -0
  85. package/deps/capstone/arch/M680X/M680XModule.c +77 -0
  86. package/deps/capstone/arch/M680X/M680XModule.h +12 -0
  87. package/deps/capstone/arch/M680X/cpu12.inc +335 -0
  88. package/deps/capstone/arch/M680X/hcs08.inc +60 -0
  89. package/deps/capstone/arch/M680X/hd6301.inc +15 -0
  90. package/deps/capstone/arch/M680X/hd6309.inc +259 -0
  91. package/deps/capstone/arch/M680X/insn_props.inc +367 -0
  92. package/deps/capstone/arch/M680X/m6800.inc +277 -0
  93. package/deps/capstone/arch/M680X/m6801.inc +39 -0
  94. package/deps/capstone/arch/M680X/m6805.inc +277 -0
  95. package/deps/capstone/arch/M680X/m6808.inc +91 -0
  96. package/deps/capstone/arch/M680X/m6809.inc +352 -0
  97. package/deps/capstone/arch/M680X/m6811.inc +105 -0
  98. package/deps/capstone/arch/M68K/M68KDisassembler.c +3668 -0
  99. package/deps/capstone/arch/M68K/M68KDisassembler.h +30 -0
  100. package/deps/capstone/arch/M68K/M68KInstPrinter.c +387 -0
  101. package/deps/capstone/arch/M68K/M68KInstPrinter.h +21 -0
  102. package/deps/capstone/arch/M68K/M68KInstructionTable.inc +65540 -0
  103. package/deps/capstone/arch/M68K/M68KModule.c +42 -0
  104. package/deps/capstone/arch/M68K/M68KModule.h +12 -0
  105. package/deps/capstone/arch/MOS65XX/MOS65XXDisassembler.c +544 -0
  106. package/deps/capstone/arch/MOS65XX/MOS65XXDisassembler.h +22 -0
  107. package/deps/capstone/arch/MOS65XX/MOS65XXDisassemblerInternals.h +23 -0
  108. package/deps/capstone/arch/MOS65XX/MOS65XXModule.c +79 -0
  109. package/deps/capstone/arch/MOS65XX/MOS65XXModule.h +12 -0
  110. package/deps/capstone/arch/MOS65XX/instruction_info.inc +106 -0
  111. package/deps/capstone/arch/MOS65XX/m6502.inc +256 -0
  112. package/deps/capstone/arch/MOS65XX/m65816.inc +256 -0
  113. package/deps/capstone/arch/MOS65XX/m65c02.inc +256 -0
  114. package/deps/capstone/arch/MOS65XX/mw65c02.inc +256 -0
  115. package/deps/capstone/arch/Mips/MipsDisassembler.c +1794 -0
  116. package/deps/capstone/arch/Mips/MipsDisassembler.h +16 -0
  117. package/deps/capstone/arch/Mips/MipsGenAsmWriter.inc +5725 -0
  118. package/deps/capstone/arch/Mips/MipsGenDisassemblerTables.inc +6942 -0
  119. package/deps/capstone/arch/Mips/MipsGenInstrInfo.inc +1805 -0
  120. package/deps/capstone/arch/Mips/MipsGenRegisterInfo.inc +1679 -0
  121. package/deps/capstone/arch/Mips/MipsGenSubtargetInfo.inc +52 -0
  122. package/deps/capstone/arch/Mips/MipsInstPrinter.c +424 -0
  123. package/deps/capstone/arch/Mips/MipsInstPrinter.h +25 -0
  124. package/deps/capstone/arch/Mips/MipsMapping.c +1070 -0
  125. package/deps/capstone/arch/Mips/MipsMapping.h +25 -0
  126. package/deps/capstone/arch/Mips/MipsMappingInsn.inc +9315 -0
  127. package/deps/capstone/arch/Mips/MipsModule.c +52 -0
  128. package/deps/capstone/arch/Mips/MipsModule.h +12 -0
  129. package/deps/capstone/arch/PowerPC/PPCDisassembler.c +627 -0
  130. package/deps/capstone/arch/PowerPC/PPCDisassembler.h +17 -0
  131. package/deps/capstone/arch/PowerPC/PPCGenAsmWriter.inc +11451 -0
  132. package/deps/capstone/arch/PowerPC/PPCGenDisassemblerTables.inc +6886 -0
  133. package/deps/capstone/arch/PowerPC/PPCGenInstrInfo.inc +4772 -0
  134. package/deps/capstone/arch/PowerPC/PPCGenRegisterInfo.inc +1122 -0
  135. package/deps/capstone/arch/PowerPC/PPCGenRegisterName.inc +278 -0
  136. package/deps/capstone/arch/PowerPC/PPCGenSubtargetInfo.inc +90 -0
  137. package/deps/capstone/arch/PowerPC/PPCInstPrinter.c +1238 -0
  138. package/deps/capstone/arch/PowerPC/PPCInstPrinter.h +15 -0
  139. package/deps/capstone/arch/PowerPC/PPCMapping.c +570 -0
  140. package/deps/capstone/arch/PowerPC/PPCMapping.h +40 -0
  141. package/deps/capstone/arch/PowerPC/PPCMappingInsn.inc +13220 -0
  142. package/deps/capstone/arch/PowerPC/PPCMappingInsnName.inc +1731 -0
  143. package/deps/capstone/arch/PowerPC/PPCModule.c +45 -0
  144. package/deps/capstone/arch/PowerPC/PPCModule.h +12 -0
  145. package/deps/capstone/arch/PowerPC/PPCPredicates.h +62 -0
  146. package/deps/capstone/arch/RISCV/RISCVBaseInfo.h +106 -0
  147. package/deps/capstone/arch/RISCV/RISCVDisassembler.c +433 -0
  148. package/deps/capstone/arch/RISCV/RISCVDisassembler.h +18 -0
  149. package/deps/capstone/arch/RISCV/RISCVGenAsmWriter.inc +2651 -0
  150. package/deps/capstone/arch/RISCV/RISCVGenDisassemblerTables.inc +1776 -0
  151. package/deps/capstone/arch/RISCV/RISCVGenInsnNameMaps.inc +275 -0
  152. package/deps/capstone/arch/RISCV/RISCVGenInstrInfo.inc +470 -0
  153. package/deps/capstone/arch/RISCV/RISCVGenRegisterInfo.inc +426 -0
  154. package/deps/capstone/arch/RISCV/RISCVGenSubtargetInfo.inc +33 -0
  155. package/deps/capstone/arch/RISCV/RISCVInstPrinter.c +447 -0
  156. package/deps/capstone/arch/RISCV/RISCVInstPrinter.h +24 -0
  157. package/deps/capstone/arch/RISCV/RISCVMapping.c +366 -0
  158. package/deps/capstone/arch/RISCV/RISCVMapping.h +22 -0
  159. package/deps/capstone/arch/RISCV/RISCVMappingInsn.inc +1635 -0
  160. package/deps/capstone/arch/RISCV/RISCVModule.c +42 -0
  161. package/deps/capstone/arch/RISCV/RISCVModule.h +12 -0
  162. package/deps/capstone/arch/SH/SHDisassembler.c +2221 -0
  163. package/deps/capstone/arch/SH/SHDisassembler.h +19 -0
  164. package/deps/capstone/arch/SH/SHInsnTable.inc +66 -0
  165. package/deps/capstone/arch/SH/SHInstPrinter.c +438 -0
  166. package/deps/capstone/arch/SH/SHInstPrinter.h +23 -0
  167. package/deps/capstone/arch/SH/SHModule.c +39 -0
  168. package/deps/capstone/arch/SH/SHModule.h +12 -0
  169. package/deps/capstone/arch/SH/mktable.rb +390 -0
  170. package/deps/capstone/arch/Sparc/Sparc.h +63 -0
  171. package/deps/capstone/arch/Sparc/SparcDisassembler.c +500 -0
  172. package/deps/capstone/arch/Sparc/SparcDisassembler.h +17 -0
  173. package/deps/capstone/arch/Sparc/SparcGenAsmWriter.inc +5709 -0
  174. package/deps/capstone/arch/Sparc/SparcGenDisassemblerTables.inc +2028 -0
  175. package/deps/capstone/arch/Sparc/SparcGenInstrInfo.inc +514 -0
  176. package/deps/capstone/arch/Sparc/SparcGenRegisterInfo.inc +451 -0
  177. package/deps/capstone/arch/Sparc/SparcGenSubtargetInfo.inc +27 -0
  178. package/deps/capstone/arch/Sparc/SparcInstPrinter.c +446 -0
  179. package/deps/capstone/arch/Sparc/SparcInstPrinter.h +17 -0
  180. package/deps/capstone/arch/Sparc/SparcMapping.c +665 -0
  181. package/deps/capstone/arch/Sparc/SparcMapping.h +34 -0
  182. package/deps/capstone/arch/Sparc/SparcMappingInsn.inc +2643 -0
  183. package/deps/capstone/arch/Sparc/SparcModule.c +45 -0
  184. package/deps/capstone/arch/Sparc/SparcModule.h +12 -0
  185. package/deps/capstone/arch/SystemZ/SystemZDisassembler.c +484 -0
  186. package/deps/capstone/arch/SystemZ/SystemZDisassembler.h +17 -0
  187. package/deps/capstone/arch/SystemZ/SystemZGenAsmWriter.inc +11575 -0
  188. package/deps/capstone/arch/SystemZ/SystemZGenDisassemblerTables.inc +10262 -0
  189. package/deps/capstone/arch/SystemZ/SystemZGenInsnNameMaps.inc +2348 -0
  190. package/deps/capstone/arch/SystemZ/SystemZGenInstrInfo.inc +2820 -0
  191. package/deps/capstone/arch/SystemZ/SystemZGenRegisterInfo.inc +741 -0
  192. package/deps/capstone/arch/SystemZ/SystemZGenSubtargetInfo.inc +49 -0
  193. package/deps/capstone/arch/SystemZ/SystemZInstPrinter.c +433 -0
  194. package/deps/capstone/arch/SystemZ/SystemZInstPrinter.h +15 -0
  195. package/deps/capstone/arch/SystemZ/SystemZMCTargetDesc.c +195 -0
  196. package/deps/capstone/arch/SystemZ/SystemZMCTargetDesc.h +51 -0
  197. package/deps/capstone/arch/SystemZ/SystemZMapping.c +479 -0
  198. package/deps/capstone/arch/SystemZ/SystemZMapping.h +23 -0
  199. package/deps/capstone/arch/SystemZ/SystemZMappingInsn.inc +14175 -0
  200. package/deps/capstone/arch/SystemZ/SystemZModule.c +44 -0
  201. package/deps/capstone/arch/SystemZ/SystemZModule.h +12 -0
  202. package/deps/capstone/arch/TMS320C64x/TMS320C64xDisassembler.c +628 -0
  203. package/deps/capstone/arch/TMS320C64x/TMS320C64xDisassembler.h +19 -0
  204. package/deps/capstone/arch/TMS320C64x/TMS320C64xGenAsmWriter.inc +684 -0
  205. package/deps/capstone/arch/TMS320C64x/TMS320C64xGenDisassemblerTables.inc +1352 -0
  206. package/deps/capstone/arch/TMS320C64x/TMS320C64xGenInstrInfo.inc +298 -0
  207. package/deps/capstone/arch/TMS320C64x/TMS320C64xGenRegisterInfo.inc +277 -0
  208. package/deps/capstone/arch/TMS320C64x/TMS320C64xInstPrinter.c +572 -0
  209. package/deps/capstone/arch/TMS320C64x/TMS320C64xInstPrinter.h +15 -0
  210. package/deps/capstone/arch/TMS320C64x/TMS320C64xMapping.c +1926 -0
  211. package/deps/capstone/arch/TMS320C64x/TMS320C64xMapping.h +26 -0
  212. package/deps/capstone/arch/TMS320C64x/TMS320C64xModule.c +39 -0
  213. package/deps/capstone/arch/TMS320C64x/TMS320C64xModule.h +12 -0
  214. package/deps/capstone/arch/TriCore/TriCore.td +134 -0
  215. package/deps/capstone/arch/TriCore/TriCoreCallingConv.td +61 -0
  216. package/deps/capstone/arch/TriCore/TriCoreDisassembler.c +1655 -0
  217. package/deps/capstone/arch/TriCore/TriCoreDisassembler.h +18 -0
  218. package/deps/capstone/arch/TriCore/TriCoreGenAsmWriter.inc +3691 -0
  219. package/deps/capstone/arch/TriCore/TriCoreGenCSFeatureName.inc +22 -0
  220. package/deps/capstone/arch/TriCore/TriCoreGenCSMappingInsn.inc +8938 -0
  221. package/deps/capstone/arch/TriCore/TriCoreGenCSMappingInsnName.inc +404 -0
  222. package/deps/capstone/arch/TriCore/TriCoreGenCSMappingInsnOp.inc +7994 -0
  223. package/deps/capstone/arch/TriCore/TriCoreGenCSOpGroup.inc +32 -0
  224. package/deps/capstone/arch/TriCore/TriCoreGenDisassemblerTables.inc +4044 -0
  225. package/deps/capstone/arch/TriCore/TriCoreGenInstrInfo.inc +2693 -0
  226. package/deps/capstone/arch/TriCore/TriCoreGenRegisterInfo.inc +295 -0
  227. package/deps/capstone/arch/TriCore/TriCoreGenSubtargetInfo.inc +40 -0
  228. package/deps/capstone/arch/TriCore/TriCoreInstPrinter.c +488 -0
  229. package/deps/capstone/arch/TriCore/TriCoreInstrFormats.td +773 -0
  230. package/deps/capstone/arch/TriCore/TriCoreInstrInfo.td +1873 -0
  231. package/deps/capstone/arch/TriCore/TriCoreLinkage.h +21 -0
  232. package/deps/capstone/arch/TriCore/TriCoreMapping.c +241 -0
  233. package/deps/capstone/arch/TriCore/TriCoreMapping.h +32 -0
  234. package/deps/capstone/arch/TriCore/TriCoreModule.c +44 -0
  235. package/deps/capstone/arch/TriCore/TriCoreModule.h +11 -0
  236. package/deps/capstone/arch/TriCore/TriCoreRegisterInfo.td +153 -0
  237. package/deps/capstone/arch/WASM/WASMDisassembler.c +1009 -0
  238. package/deps/capstone/arch/WASM/WASMDisassembler.h +12 -0
  239. package/deps/capstone/arch/WASM/WASMInstPrinter.c +47 -0
  240. package/deps/capstone/arch/WASM/WASMInstPrinter.h +18 -0
  241. package/deps/capstone/arch/WASM/WASMMapping.c +333 -0
  242. package/deps/capstone/arch/WASM/WASMMapping.h +9 -0
  243. package/deps/capstone/arch/WASM/WASMModule.c +33 -0
  244. package/deps/capstone/arch/WASM/WASMModule.h +12 -0
  245. package/deps/capstone/arch/X86/X86ATTInstPrinter.c +997 -0
  246. package/deps/capstone/arch/X86/X86BaseInfo.h +50 -0
  247. package/deps/capstone/arch/X86/X86Disassembler.c +1033 -0
  248. package/deps/capstone/arch/X86/X86Disassembler.h +28 -0
  249. package/deps/capstone/arch/X86/X86DisassemblerDecoder.c +2358 -0
  250. package/deps/capstone/arch/X86/X86DisassemblerDecoder.h +725 -0
  251. package/deps/capstone/arch/X86/X86DisassemblerDecoderCommon.h +483 -0
  252. package/deps/capstone/arch/X86/X86GenAsmWriter.inc +49199 -0
  253. package/deps/capstone/arch/X86/X86GenAsmWriter1.inc +33196 -0
  254. package/deps/capstone/arch/X86/X86GenAsmWriter1_reduce.inc +2531 -0
  255. package/deps/capstone/arch/X86/X86GenAsmWriter_reduce.inc +2855 -0
  256. package/deps/capstone/arch/X86/X86GenDisassemblerTables.inc +112961 -0
  257. package/deps/capstone/arch/X86/X86GenDisassemblerTables2.inc +102151 -0
  258. package/deps/capstone/arch/X86/X86GenDisassemblerTables_reduce.inc +28047 -0
  259. package/deps/capstone/arch/X86/X86GenDisassemblerTables_reduce2.inc +18827 -0
  260. package/deps/capstone/arch/X86/X86GenInstrInfo.inc +15158 -0
  261. package/deps/capstone/arch/X86/X86GenInstrInfo_reduce.inc +1564 -0
  262. package/deps/capstone/arch/X86/X86GenRegisterInfo.inc +1549 -0
  263. package/deps/capstone/arch/X86/X86GenRegisterName.inc +292 -0
  264. package/deps/capstone/arch/X86/X86GenRegisterName1.inc +291 -0
  265. package/deps/capstone/arch/X86/X86ImmSize.inc +335 -0
  266. package/deps/capstone/arch/X86/X86InstPrinter.h +26 -0
  267. package/deps/capstone/arch/X86/X86InstPrinterCommon.c +116 -0
  268. package/deps/capstone/arch/X86/X86InstPrinterCommon.h +16 -0
  269. package/deps/capstone/arch/X86/X86IntelInstPrinter.c +1061 -0
  270. package/deps/capstone/arch/X86/X86Lookup16.inc +16874 -0
  271. package/deps/capstone/arch/X86/X86Lookup16_reduce.inc +2308 -0
  272. package/deps/capstone/arch/X86/X86Mapping.c +2266 -0
  273. package/deps/capstone/arch/X86/X86Mapping.h +96 -0
  274. package/deps/capstone/arch/X86/X86MappingInsn.inc +105977 -0
  275. package/deps/capstone/arch/X86/X86MappingInsnName.inc +1527 -0
  276. package/deps/capstone/arch/X86/X86MappingInsnName_reduce.inc +348 -0
  277. package/deps/capstone/arch/X86/X86MappingInsnOp.inc +75700 -0
  278. package/deps/capstone/arch/X86/X86MappingInsnOp_reduce.inc +7729 -0
  279. package/deps/capstone/arch/X86/X86MappingInsn_reduce.inc +10819 -0
  280. package/deps/capstone/arch/X86/X86MappingReg.inc +280 -0
  281. package/deps/capstone/arch/X86/X86Module.c +94 -0
  282. package/deps/capstone/arch/X86/X86Module.h +12 -0
  283. package/deps/capstone/arch/XCore/XCoreDisassembler.c +794 -0
  284. package/deps/capstone/arch/XCore/XCoreDisassembler.h +17 -0
  285. package/deps/capstone/arch/XCore/XCoreGenAsmWriter.inc +772 -0
  286. package/deps/capstone/arch/XCore/XCoreGenDisassemblerTables.inc +853 -0
  287. package/deps/capstone/arch/XCore/XCoreGenInstrInfo.inc +267 -0
  288. package/deps/capstone/arch/XCore/XCoreGenRegisterInfo.inc +110 -0
  289. package/deps/capstone/arch/XCore/XCoreInstPrinter.c +250 -0
  290. package/deps/capstone/arch/XCore/XCoreInstPrinter.h +18 -0
  291. package/deps/capstone/arch/XCore/XCoreMapping.c +297 -0
  292. package/deps/capstone/arch/XCore/XCoreMapping.h +26 -0
  293. package/deps/capstone/arch/XCore/XCoreMappingInsn.inc +1287 -0
  294. package/deps/capstone/arch/XCore/XCoreModule.c +41 -0
  295. package/deps/capstone/arch/XCore/XCoreModule.h +12 -0
  296. package/deps/capstone/cs.c +1664 -0
  297. package/deps/capstone/cs_priv.h +101 -0
  298. package/deps/capstone/cs_simple_types.h +886 -0
  299. package/deps/capstone/include/capstone/arm.h +991 -0
  300. package/deps/capstone/include/capstone/arm64.h +3159 -0
  301. package/deps/capstone/include/capstone/bpf.h +209 -0
  302. package/deps/capstone/include/capstone/capstone.h +875 -0
  303. package/deps/capstone/include/capstone/evm.h +188 -0
  304. package/deps/capstone/include/capstone/m680x.h +537 -0
  305. package/deps/capstone/include/capstone/m68k.h +613 -0
  306. package/deps/capstone/include/capstone/mips.h +956 -0
  307. package/deps/capstone/include/capstone/mos65xx.h +204 -0
  308. package/deps/capstone/include/capstone/platform.h +122 -0
  309. package/deps/capstone/include/capstone/ppc.h +2108 -0
  310. package/deps/capstone/include/capstone/riscv.h +531 -0
  311. package/deps/capstone/include/capstone/sh.h +465 -0
  312. package/deps/capstone/include/capstone/sparc.h +520 -0
  313. package/deps/capstone/include/capstone/systemz.h +2601 -0
  314. package/deps/capstone/include/capstone/tms320c64x.h +359 -0
  315. package/deps/capstone/include/capstone/tricore.h +567 -0
  316. package/deps/capstone/include/capstone/wasm.h +250 -0
  317. package/deps/capstone/include/capstone/x86.h +1986 -0
  318. package/deps/capstone/include/capstone/xcore.h +235 -0
  319. package/deps/capstone/include/platform.h +110 -0
  320. package/deps/capstone/include/windowsce/intrin.h +12 -0
  321. package/deps/capstone/include/windowsce/stdint.h +133 -0
  322. package/deps/capstone/utils.c +140 -0
  323. package/deps/capstone/utils.h +54 -0
  324. package/index.d.ts +448 -0
  325. package/index.js +64 -0
  326. package/index.mjs +25 -0
  327. package/package.json +82 -0
  328. package/prebuilds/win32-x64/hexcore-capstone.node +0 -0
  329. package/src/capstone_wrapper.cpp +910 -0
  330. package/src/capstone_wrapper.h +147 -0
  331. package/src/disasm_async_worker.h +215 -0
  332. package/src/main.cpp +145 -0
@@ -0,0 +1,997 @@
1
+ //===-- X86ATTInstPrinter.cpp - AT&T assembly instruction printing --------===//
2
+ //
3
+ // The LLVM Compiler Infrastructure
4
+ //
5
+ // This file is distributed under the University of Illinois Open Source
6
+ // License. See LICENSE.TXT for details.
7
+ //
8
+ //===----------------------------------------------------------------------===//
9
+ //
10
+ // This file includes code for rendering MCInst instances as AT&T-style
11
+ // assembly.
12
+ //
13
+ //===----------------------------------------------------------------------===//
14
+
15
+ /* Capstone Disassembly Engine */
16
+ /* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013-2019 */
17
+
18
+ // this code is only relevant when DIET mode is disable
19
+ #if defined(CAPSTONE_HAS_X86) && !defined(CAPSTONE_DIET) && !defined(CAPSTONE_X86_ATT_DISABLE)
20
+
21
+ #if defined (WIN32) || defined (WIN64) || defined (_WIN32) || defined (_WIN64)
22
+ #pragma warning(disable:4996) // disable MSVC's warning on strncpy()
23
+ #pragma warning(disable:28719) // disable MSVC's warning on strncpy()
24
+ #endif
25
+
26
+ #if !defined(CAPSTONE_HAS_OSXKERNEL)
27
+ #include <ctype.h>
28
+ #endif
29
+ #include <capstone/platform.h>
30
+
31
+ #if defined(CAPSTONE_HAS_OSXKERNEL)
32
+ #include <Availability.h>
33
+ #include <libkern/libkern.h>
34
+ #else
35
+ #include <stdio.h>
36
+ #include <stdlib.h>
37
+ #endif
38
+
39
+ #include <string.h>
40
+
41
+ #include "../../utils.h"
42
+ #include "../../MCInst.h"
43
+ #include "../../SStream.h"
44
+ #include "../../MCRegisterInfo.h"
45
+ #include "X86Mapping.h"
46
+ #include "X86BaseInfo.h"
47
+ #include "X86InstPrinterCommon.h"
48
+
49
+ #define GET_INSTRINFO_ENUM
50
+ #ifdef CAPSTONE_X86_REDUCE
51
+ #include "X86GenInstrInfo_reduce.inc"
52
+ #else
53
+ #include "X86GenInstrInfo.inc"
54
+ #endif
55
+
56
+ #define GET_REGINFO_ENUM
57
+ #include "X86GenRegisterInfo.inc"
58
+
59
+ static void printMemReference(MCInst *MI, unsigned Op, SStream *O);
60
+ static void printOperand(MCInst *MI, unsigned OpNo, SStream *O);
61
+
62
+
63
+ static void set_mem_access(MCInst *MI, bool status)
64
+ {
65
+ if (MI->csh->detail != CS_OPT_ON)
66
+ return;
67
+
68
+ MI->csh->doing_mem = status;
69
+ if (!status)
70
+ // done, create the next operand slot
71
+ MI->flat_insn->detail->x86.op_count++;
72
+ }
73
+
74
+ static void printopaquemem(MCInst *MI, unsigned OpNo, SStream *O)
75
+ {
76
+ switch(MI->csh->mode) {
77
+ case CS_MODE_16:
78
+ switch(MI->flat_insn->id) {
79
+ default:
80
+ MI->x86opsize = 2;
81
+ break;
82
+ case X86_INS_LJMP:
83
+ case X86_INS_LCALL:
84
+ MI->x86opsize = 4;
85
+ break;
86
+ case X86_INS_SGDT:
87
+ case X86_INS_SIDT:
88
+ case X86_INS_LGDT:
89
+ case X86_INS_LIDT:
90
+ MI->x86opsize = 6;
91
+ break;
92
+ }
93
+ break;
94
+ case CS_MODE_32:
95
+ switch(MI->flat_insn->id) {
96
+ default:
97
+ MI->x86opsize = 4;
98
+ break;
99
+ case X86_INS_LJMP:
100
+ case X86_INS_JMP:
101
+ case X86_INS_LCALL:
102
+ case X86_INS_SGDT:
103
+ case X86_INS_SIDT:
104
+ case X86_INS_LGDT:
105
+ case X86_INS_LIDT:
106
+ MI->x86opsize = 6;
107
+ break;
108
+ }
109
+ break;
110
+ case CS_MODE_64:
111
+ switch(MI->flat_insn->id) {
112
+ default:
113
+ MI->x86opsize = 8;
114
+ break;
115
+ case X86_INS_LJMP:
116
+ case X86_INS_LCALL:
117
+ case X86_INS_SGDT:
118
+ case X86_INS_SIDT:
119
+ case X86_INS_LGDT:
120
+ case X86_INS_LIDT:
121
+ MI->x86opsize = 10;
122
+ break;
123
+ }
124
+ break;
125
+ default: // never reach
126
+ break;
127
+ }
128
+
129
+ printMemReference(MI, OpNo, O);
130
+ }
131
+
132
+ static void printi8mem(MCInst *MI, unsigned OpNo, SStream *O)
133
+ {
134
+ MI->x86opsize = 1;
135
+ printMemReference(MI, OpNo, O);
136
+ }
137
+
138
+ static void printi16mem(MCInst *MI, unsigned OpNo, SStream *O)
139
+ {
140
+ MI->x86opsize = 2;
141
+
142
+ printMemReference(MI, OpNo, O);
143
+ }
144
+
145
+ static void printi32mem(MCInst *MI, unsigned OpNo, SStream *O)
146
+ {
147
+ MI->x86opsize = 4;
148
+
149
+ printMemReference(MI, OpNo, O);
150
+ }
151
+
152
+ static void printi64mem(MCInst *MI, unsigned OpNo, SStream *O)
153
+ {
154
+ MI->x86opsize = 8;
155
+ printMemReference(MI, OpNo, O);
156
+ }
157
+
158
+ static void printi128mem(MCInst *MI, unsigned OpNo, SStream *O)
159
+ {
160
+ MI->x86opsize = 16;
161
+ printMemReference(MI, OpNo, O);
162
+ }
163
+
164
+ static void printi512mem(MCInst *MI, unsigned OpNo, SStream *O)
165
+ {
166
+ MI->x86opsize = 64;
167
+ printMemReference(MI, OpNo, O);
168
+ }
169
+
170
+ #ifndef CAPSTONE_X86_REDUCE
171
+ static void printi256mem(MCInst *MI, unsigned OpNo, SStream *O)
172
+ {
173
+ MI->x86opsize = 32;
174
+ printMemReference(MI, OpNo, O);
175
+ }
176
+
177
+ static void printf32mem(MCInst *MI, unsigned OpNo, SStream *O)
178
+ {
179
+ switch(MCInst_getOpcode(MI)) {
180
+ default:
181
+ MI->x86opsize = 4;
182
+ break;
183
+ case X86_FSTENVm:
184
+ case X86_FLDENVm:
185
+ // TODO: fix this in tablegen instead
186
+ switch(MI->csh->mode) {
187
+ default: // never reach
188
+ break;
189
+ case CS_MODE_16:
190
+ MI->x86opsize = 14;
191
+ break;
192
+ case CS_MODE_32:
193
+ case CS_MODE_64:
194
+ MI->x86opsize = 28;
195
+ break;
196
+ }
197
+ break;
198
+ }
199
+
200
+ printMemReference(MI, OpNo, O);
201
+ }
202
+
203
+ static void printf64mem(MCInst *MI, unsigned OpNo, SStream *O)
204
+ {
205
+ MI->x86opsize = 8;
206
+ printMemReference(MI, OpNo, O);
207
+ }
208
+
209
+ static void printf80mem(MCInst *MI, unsigned OpNo, SStream *O)
210
+ {
211
+ MI->x86opsize = 10;
212
+ printMemReference(MI, OpNo, O);
213
+ }
214
+
215
+ static void printf128mem(MCInst *MI, unsigned OpNo, SStream *O)
216
+ {
217
+ MI->x86opsize = 16;
218
+ printMemReference(MI, OpNo, O);
219
+ }
220
+
221
+ static void printf256mem(MCInst *MI, unsigned OpNo, SStream *O)
222
+ {
223
+ MI->x86opsize = 32;
224
+ printMemReference(MI, OpNo, O);
225
+ }
226
+
227
+ static void printf512mem(MCInst *MI, unsigned OpNo, SStream *O)
228
+ {
229
+ MI->x86opsize = 64;
230
+ printMemReference(MI, OpNo, O);
231
+ }
232
+
233
+ #endif
234
+
235
+ static void printRegName(SStream *OS, unsigned RegNo);
236
+
237
+ // local printOperand, without updating public operands
238
+ static void _printOperand(MCInst *MI, unsigned OpNo, SStream *O)
239
+ {
240
+ MCOperand *Op = MCInst_getOperand(MI, OpNo);
241
+ if (MCOperand_isReg(Op)) {
242
+ printRegName(O, MCOperand_getReg(Op));
243
+ } else if (MCOperand_isImm(Op)) {
244
+ uint8_t encsize;
245
+ uint8_t opsize = X86_immediate_size(MCInst_getOpcode(MI), &encsize);
246
+
247
+ // Print X86 immediates as signed values.
248
+ int64_t imm = MCOperand_getImm(Op);
249
+ if (imm < 0) {
250
+ if (MI->csh->imm_unsigned) {
251
+ if (opsize) {
252
+ switch(opsize) {
253
+ default:
254
+ break;
255
+ case 1:
256
+ imm &= 0xff;
257
+ break;
258
+ case 2:
259
+ imm &= 0xffff;
260
+ break;
261
+ case 4:
262
+ imm &= 0xffffffff;
263
+ break;
264
+ }
265
+ }
266
+
267
+ SStream_concat(O, "$0x%"PRIx64, imm);
268
+ } else {
269
+ if (imm < -HEX_THRESHOLD)
270
+ SStream_concat(O, "$-0x%"PRIx64, -imm);
271
+ else
272
+ SStream_concat(O, "$-%"PRIu64, -imm);
273
+ }
274
+ } else {
275
+ if (imm > HEX_THRESHOLD)
276
+ SStream_concat(O, "$0x%"PRIx64, imm);
277
+ else
278
+ SStream_concat(O, "$%"PRIu64, imm);
279
+ }
280
+ }
281
+ }
282
+
283
+ // convert Intel access info to AT&T access info
284
+ static void get_op_access(cs_struct *h, unsigned int id, uint8_t *access, uint64_t *eflags)
285
+ {
286
+ uint8_t count, i;
287
+ const uint8_t *arr = X86_get_op_access(h, id, eflags);
288
+
289
+ if (!arr) {
290
+ access[0] = 0;
291
+ return;
292
+ }
293
+
294
+ // find the non-zero last entry
295
+ for(count = 0; arr[count]; count++);
296
+
297
+ if (count == 0)
298
+ return;
299
+
300
+ // copy in reverse order this access array from Intel syntax -> AT&T syntax
301
+ count--;
302
+ for(i = 0; i <= count; i++) {
303
+ if (arr[count - i] != CS_AC_IGNORE)
304
+ access[i] = arr[count - i];
305
+ else
306
+ access[i] = 0;
307
+ }
308
+ }
309
+
310
+ static void printSrcIdx(MCInst *MI, unsigned Op, SStream *O)
311
+ {
312
+ MCOperand *SegReg;
313
+ int reg;
314
+
315
+ if (MI->csh->detail) {
316
+ uint8_t access[6];
317
+
318
+ MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].type = X86_OP_MEM;
319
+ MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].size = MI->x86opsize;
320
+ MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.segment = X86_REG_INVALID;
321
+ MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.base = X86_REG_INVALID;
322
+ MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.index = X86_REG_INVALID;
323
+ MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.scale = 1;
324
+ MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.disp = 0;
325
+
326
+ get_op_access(MI->csh, MCInst_getOpcode(MI), access, &MI->flat_insn->detail->x86.eflags);
327
+ MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].access = access[MI->flat_insn->detail->x86.op_count];
328
+ }
329
+
330
+ SegReg = MCInst_getOperand(MI, Op+1);
331
+ reg = MCOperand_getReg(SegReg);
332
+ // If this has a segment register, print it.
333
+ if (reg) {
334
+ _printOperand(MI, Op + 1, O);
335
+ SStream_concat0(O, ":");
336
+
337
+ if (MI->csh->detail) {
338
+ MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.segment = X86_register_map(reg);
339
+ }
340
+ }
341
+
342
+ SStream_concat0(O, "(");
343
+ set_mem_access(MI, true);
344
+
345
+ printOperand(MI, Op, O);
346
+
347
+ SStream_concat0(O, ")");
348
+ set_mem_access(MI, false);
349
+ }
350
+
351
+ static void printDstIdx(MCInst *MI, unsigned Op, SStream *O)
352
+ {
353
+ if (MI->csh->detail) {
354
+ uint8_t access[6];
355
+
356
+ MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].type = X86_OP_MEM;
357
+ MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].size = MI->x86opsize;
358
+ MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.segment = X86_REG_INVALID;
359
+ MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.base = X86_REG_INVALID;
360
+ MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.index = X86_REG_INVALID;
361
+ MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.scale = 1;
362
+ MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.disp = 0;
363
+
364
+ get_op_access(MI->csh, MCInst_getOpcode(MI), access, &MI->flat_insn->detail->x86.eflags);
365
+ MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].access = access[MI->flat_insn->detail->x86.op_count];
366
+ }
367
+
368
+ // DI accesses are always ES-based on non-64bit mode
369
+ if (MI->csh->mode != CS_MODE_64) {
370
+ SStream_concat0(O, "%es:(");
371
+ if (MI->csh->detail) {
372
+ MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.segment = X86_REG_ES;
373
+ }
374
+ } else
375
+ SStream_concat0(O, "(");
376
+
377
+ set_mem_access(MI, true);
378
+
379
+ printOperand(MI, Op, O);
380
+
381
+ SStream_concat0(O, ")");
382
+ set_mem_access(MI, false);
383
+ }
384
+
385
+ static void printSrcIdx8(MCInst *MI, unsigned OpNo, SStream *O)
386
+ {
387
+ MI->x86opsize = 1;
388
+ printSrcIdx(MI, OpNo, O);
389
+ }
390
+
391
+ static void printSrcIdx16(MCInst *MI, unsigned OpNo, SStream *O)
392
+ {
393
+ MI->x86opsize = 2;
394
+ printSrcIdx(MI, OpNo, O);
395
+ }
396
+
397
+ static void printSrcIdx32(MCInst *MI, unsigned OpNo, SStream *O)
398
+ {
399
+ MI->x86opsize = 4;
400
+ printSrcIdx(MI, OpNo, O);
401
+ }
402
+
403
+ static void printSrcIdx64(MCInst *MI, unsigned OpNo, SStream *O)
404
+ {
405
+ MI->x86opsize = 8;
406
+ printSrcIdx(MI, OpNo, O);
407
+ }
408
+
409
+ static void printDstIdx8(MCInst *MI, unsigned OpNo, SStream *O)
410
+ {
411
+ MI->x86opsize = 1;
412
+ printDstIdx(MI, OpNo, O);
413
+ }
414
+
415
+ static void printDstIdx16(MCInst *MI, unsigned OpNo, SStream *O)
416
+ {
417
+ MI->x86opsize = 2;
418
+ printDstIdx(MI, OpNo, O);
419
+ }
420
+
421
+ static void printDstIdx32(MCInst *MI, unsigned OpNo, SStream *O)
422
+ {
423
+ MI->x86opsize = 4;
424
+ printDstIdx(MI, OpNo, O);
425
+ }
426
+
427
+ static void printDstIdx64(MCInst *MI, unsigned OpNo, SStream *O)
428
+ {
429
+ MI->x86opsize = 8;
430
+ printDstIdx(MI, OpNo, O);
431
+ }
432
+
433
+ static void printMemOffset(MCInst *MI, unsigned Op, SStream *O)
434
+ {
435
+ MCOperand *DispSpec = MCInst_getOperand(MI, Op);
436
+ MCOperand *SegReg = MCInst_getOperand(MI, Op+1);
437
+ int reg;
438
+
439
+ if (MI->csh->detail) {
440
+ uint8_t access[6];
441
+
442
+ MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].type = X86_OP_MEM;
443
+ MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].size = MI->x86opsize;
444
+ MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.segment = X86_REG_INVALID;
445
+ MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.base = X86_REG_INVALID;
446
+ MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.index = X86_REG_INVALID;
447
+ MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.scale = 1;
448
+ MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.disp = 0;
449
+
450
+ get_op_access(MI->csh, MCInst_getOpcode(MI), access, &MI->flat_insn->detail->x86.eflags);
451
+ MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].access = access[MI->flat_insn->detail->x86.op_count];
452
+ }
453
+
454
+ // If this has a segment register, print it.
455
+ reg = MCOperand_getReg(SegReg);
456
+ if (reg) {
457
+ _printOperand(MI, Op + 1, O);
458
+ SStream_concat0(O, ":");
459
+
460
+ if (MI->csh->detail) {
461
+ MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.segment = X86_register_map(reg);
462
+ }
463
+ }
464
+
465
+ if (MCOperand_isImm(DispSpec)) {
466
+ int64_t imm = MCOperand_getImm(DispSpec);
467
+ if (MI->csh->detail)
468
+ MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.disp = imm;
469
+ if (imm < 0) {
470
+ SStream_concat(O, "0x%"PRIx64, arch_masks[MI->csh->mode] & imm);
471
+ } else {
472
+ if (imm > HEX_THRESHOLD)
473
+ SStream_concat(O, "0x%"PRIx64, imm);
474
+ else
475
+ SStream_concat(O, "%"PRIu64, imm);
476
+ }
477
+ }
478
+
479
+ if (MI->csh->detail)
480
+ MI->flat_insn->detail->x86.op_count++;
481
+ }
482
+
483
+ static void printU8Imm(MCInst *MI, unsigned Op, SStream *O)
484
+ {
485
+ uint8_t val = MCOperand_getImm(MCInst_getOperand(MI, Op)) & 0xff;
486
+
487
+ if (val > HEX_THRESHOLD)
488
+ SStream_concat(O, "$0x%x", val);
489
+ else
490
+ SStream_concat(O, "$%u", val);
491
+
492
+ if (MI->csh->detail) {
493
+ MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].type = X86_OP_IMM;
494
+ MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].imm = val;
495
+ MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].size = 1;
496
+ MI->flat_insn->detail->x86.op_count++;
497
+ }
498
+ }
499
+
500
+ static void printMemOffs8(MCInst *MI, unsigned OpNo, SStream *O)
501
+ {
502
+ MI->x86opsize = 1;
503
+ printMemOffset(MI, OpNo, O);
504
+ }
505
+
506
+ static void printMemOffs16(MCInst *MI, unsigned OpNo, SStream *O)
507
+ {
508
+ MI->x86opsize = 2;
509
+ printMemOffset(MI, OpNo, O);
510
+ }
511
+
512
+ static void printMemOffs32(MCInst *MI, unsigned OpNo, SStream *O)
513
+ {
514
+ MI->x86opsize = 4;
515
+ printMemOffset(MI, OpNo, O);
516
+ }
517
+
518
+ static void printMemOffs64(MCInst *MI, unsigned OpNo, SStream *O)
519
+ {
520
+ MI->x86opsize = 8;
521
+ printMemOffset(MI, OpNo, O);
522
+ }
523
+
524
+ /// printPCRelImm - This is used to print an immediate value that ends up
525
+ /// being encoded as a pc-relative value (e.g. for jumps and calls). These
526
+ /// print slightly differently than normal immediates. For example, a $ is not
527
+ /// emitted.
528
+ static void printPCRelImm(MCInst *MI, unsigned OpNo, SStream *O)
529
+ {
530
+ MCOperand *Op = MCInst_getOperand(MI, OpNo);
531
+ if (MCOperand_isImm(Op)) {
532
+ int64_t imm = MCOperand_getImm(Op) + MI->flat_insn->size + MI->address;
533
+
534
+ // truncat imm for non-64bit
535
+ if (MI->csh->mode != CS_MODE_64) {
536
+ imm = imm & 0xffffffff;
537
+ }
538
+
539
+ if (imm < 0) {
540
+ SStream_concat(O, "0x%"PRIx64, imm);
541
+ } else {
542
+ if (imm > HEX_THRESHOLD)
543
+ SStream_concat(O, "0x%"PRIx64, imm);
544
+ else
545
+ SStream_concat(O, "%"PRIu64, imm);
546
+ }
547
+ if (MI->csh->detail) {
548
+ MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].type = X86_OP_IMM;
549
+ MI->has_imm = true;
550
+ MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].imm = imm;
551
+ MI->flat_insn->detail->x86.op_count++;
552
+ }
553
+ }
554
+ }
555
+
556
+ static void printOperand(MCInst *MI, unsigned OpNo, SStream *O)
557
+ {
558
+ MCOperand *Op = MCInst_getOperand(MI, OpNo);
559
+ if (MCOperand_isReg(Op)) {
560
+ unsigned int reg = MCOperand_getReg(Op);
561
+ printRegName(O, reg);
562
+ if (MI->csh->detail) {
563
+ if (MI->csh->doing_mem) {
564
+ MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.base = X86_register_map(reg);
565
+ } else {
566
+ uint8_t access[6];
567
+
568
+ MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].type = X86_OP_REG;
569
+ MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].reg = X86_register_map(reg);
570
+ MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].size = MI->csh->regsize_map[X86_register_map(reg)];
571
+
572
+ get_op_access(MI->csh, MCInst_getOpcode(MI), access, &MI->flat_insn->detail->x86.eflags);
573
+ MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].access = access[MI->flat_insn->detail->x86.op_count];
574
+
575
+ MI->flat_insn->detail->x86.op_count++;
576
+ }
577
+ }
578
+ } else if (MCOperand_isImm(Op)) {
579
+ // Print X86 immediates as signed values.
580
+ uint8_t encsize;
581
+ int64_t imm = MCOperand_getImm(Op);
582
+ uint8_t opsize = X86_immediate_size(MCInst_getOpcode(MI), &encsize);
583
+
584
+ if (opsize == 1) // print 1 byte immediate in positive form
585
+ imm = imm & 0xff;
586
+
587
+ switch(MI->flat_insn->id) {
588
+ default:
589
+ if (imm >= 0) {
590
+ if (imm > HEX_THRESHOLD)
591
+ SStream_concat(O, "$0x%"PRIx64, imm);
592
+ else
593
+ SStream_concat(O, "$%"PRIu64, imm);
594
+ } else {
595
+ if (MI->csh->imm_unsigned) {
596
+ if (opsize) {
597
+ switch(opsize) {
598
+ default:
599
+ break;
600
+ case 1:
601
+ imm &= 0xff;
602
+ break;
603
+ case 2:
604
+ imm &= 0xffff;
605
+ break;
606
+ case 4:
607
+ imm &= 0xffffffff;
608
+ break;
609
+ }
610
+ }
611
+
612
+ SStream_concat(O, "$0x%"PRIx64, imm);
613
+ } else {
614
+ if (imm == 0x8000000000000000LL) // imm == -imm
615
+ SStream_concat0(O, "$0x8000000000000000");
616
+ else if (imm < -HEX_THRESHOLD)
617
+ SStream_concat(O, "$-0x%"PRIx64, -imm);
618
+ else
619
+ SStream_concat(O, "$-%"PRIu64, -imm);
620
+ }
621
+ }
622
+ break;
623
+
624
+ case X86_INS_MOVABS:
625
+ case X86_INS_MOV:
626
+ // do not print number in negative form
627
+ if (imm > HEX_THRESHOLD)
628
+ SStream_concat(O, "$0x%"PRIx64, imm);
629
+ else
630
+ SStream_concat(O, "$%"PRIu64, imm);
631
+ break;
632
+
633
+ case X86_INS_IN:
634
+ case X86_INS_OUT:
635
+ case X86_INS_INT:
636
+ // do not print number in negative form
637
+ imm = imm & 0xff;
638
+ if (imm >= 0 && imm <= HEX_THRESHOLD)
639
+ SStream_concat(O, "$%u", imm);
640
+ else {
641
+ SStream_concat(O, "$0x%x", imm);
642
+ }
643
+ break;
644
+
645
+ case X86_INS_LCALL:
646
+ case X86_INS_LJMP:
647
+ case X86_INS_JMP:
648
+ // always print address in positive form
649
+ if (OpNo == 1) { // selector is ptr16
650
+ imm = imm & 0xffff;
651
+ opsize = 2;
652
+ } else
653
+ opsize = 4;
654
+ SStream_concat(O, "$0x%"PRIx64, imm);
655
+ break;
656
+
657
+ case X86_INS_AND:
658
+ case X86_INS_OR:
659
+ case X86_INS_XOR:
660
+ // do not print number in negative form
661
+ if (imm >= 0 && imm <= HEX_THRESHOLD)
662
+ SStream_concat(O, "$%u", imm);
663
+ else {
664
+ imm = arch_masks[opsize? opsize : MI->imm_size] & imm;
665
+ SStream_concat(O, "$0x%"PRIx64, imm);
666
+ }
667
+ break;
668
+
669
+ case X86_INS_RET:
670
+ case X86_INS_RETF:
671
+ // RET imm16
672
+ if (imm >= 0 && imm <= HEX_THRESHOLD)
673
+ SStream_concat(O, "$%u", imm);
674
+ else {
675
+ imm = 0xffff & imm;
676
+ SStream_concat(O, "$0x%x", imm);
677
+ }
678
+ break;
679
+ }
680
+
681
+ if (MI->csh->detail) {
682
+ if (MI->csh->doing_mem) {
683
+ MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].type = X86_OP_MEM;
684
+ MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.disp = imm;
685
+ } else {
686
+ MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].type = X86_OP_IMM;
687
+ MI->has_imm = true;
688
+ MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].imm = imm;
689
+
690
+ if (opsize > 0) {
691
+ MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].size = opsize;
692
+ MI->flat_insn->detail->x86.encoding.imm_size = encsize;
693
+ } else if (MI->op1_size > 0)
694
+ MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].size = MI->op1_size;
695
+ else
696
+ MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].size = MI->imm_size;
697
+
698
+ MI->flat_insn->detail->x86.op_count++;
699
+ }
700
+ }
701
+ }
702
+ }
703
+
704
+ static void printMemReference(MCInst *MI, unsigned Op, SStream *O)
705
+ {
706
+ MCOperand *BaseReg = MCInst_getOperand(MI, Op + X86_AddrBaseReg);
707
+ MCOperand *IndexReg = MCInst_getOperand(MI, Op + X86_AddrIndexReg);
708
+ MCOperand *DispSpec = MCInst_getOperand(MI, Op + X86_AddrDisp);
709
+ MCOperand *SegReg = MCInst_getOperand(MI, Op + X86_AddrSegmentReg);
710
+ uint64_t ScaleVal;
711
+ int segreg;
712
+ int64_t DispVal = 1;
713
+
714
+ if (MI->csh->detail) {
715
+ uint8_t access[6];
716
+
717
+ MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].type = X86_OP_MEM;
718
+ MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].size = MI->x86opsize;
719
+ MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.segment = X86_REG_INVALID;
720
+ MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.base = X86_register_map(MCOperand_getReg(BaseReg));
721
+ if (MCOperand_getReg(IndexReg) != X86_EIZ) {
722
+ MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.index = X86_register_map(MCOperand_getReg(IndexReg));
723
+ }
724
+ MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.scale = 1;
725
+ MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.disp = 0;
726
+
727
+ get_op_access(MI->csh, MCInst_getOpcode(MI), access, &MI->flat_insn->detail->x86.eflags);
728
+ MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].access = access[MI->flat_insn->detail->x86.op_count];
729
+ }
730
+
731
+ // If this has a segment register, print it.
732
+ segreg = MCOperand_getReg(SegReg);
733
+ if (segreg) {
734
+ _printOperand(MI, Op + X86_AddrSegmentReg, O);
735
+ SStream_concat0(O, ":");
736
+
737
+ if (MI->csh->detail) {
738
+ MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.segment = X86_register_map(segreg);
739
+ }
740
+ }
741
+
742
+ if (MCOperand_isImm(DispSpec)) {
743
+ DispVal = MCOperand_getImm(DispSpec);
744
+ if (MI->csh->detail)
745
+ MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.disp = DispVal;
746
+ if (DispVal) {
747
+ if (MCOperand_getReg(IndexReg) || MCOperand_getReg(BaseReg)) {
748
+ printInt64(O, DispVal);
749
+ } else {
750
+ // only immediate as address of memory
751
+ if (DispVal < 0) {
752
+ SStream_concat(O, "0x%"PRIx64, arch_masks[MI->csh->mode] & DispVal);
753
+ } else {
754
+ if (DispVal > HEX_THRESHOLD)
755
+ SStream_concat(O, "0x%"PRIx64, DispVal);
756
+ else
757
+ SStream_concat(O, "%"PRIu64, DispVal);
758
+ }
759
+ }
760
+ }
761
+ }
762
+
763
+ if (MCOperand_getReg(IndexReg) || MCOperand_getReg(BaseReg)) {
764
+ SStream_concat0(O, "(");
765
+
766
+ if (MCOperand_getReg(BaseReg))
767
+ _printOperand(MI, Op + X86_AddrBaseReg, O);
768
+
769
+ if (MCOperand_getReg(IndexReg) && MCOperand_getReg(IndexReg) != X86_EIZ) {
770
+ SStream_concat0(O, ", ");
771
+ _printOperand(MI, Op + X86_AddrIndexReg, O);
772
+ ScaleVal = MCOperand_getImm(MCInst_getOperand(MI, Op + X86_AddrScaleAmt));
773
+ if (MI->csh->detail)
774
+ MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.scale = (int)ScaleVal;
775
+ if (ScaleVal != 1) {
776
+ SStream_concat(O, ", %u", ScaleVal);
777
+ }
778
+ }
779
+
780
+ SStream_concat0(O, ")");
781
+ } else {
782
+ if (!DispVal)
783
+ SStream_concat0(O, "0");
784
+ }
785
+
786
+ if (MI->csh->detail)
787
+ MI->flat_insn->detail->x86.op_count++;
788
+ }
789
+
790
+ static void printanymem(MCInst *MI, unsigned OpNo, SStream *O)
791
+ {
792
+ switch(MI->Opcode) {
793
+ default: break;
794
+ case X86_LEA16r:
795
+ MI->x86opsize = 2;
796
+ break;
797
+ case X86_LEA32r:
798
+ case X86_LEA64_32r:
799
+ MI->x86opsize = 4;
800
+ break;
801
+ case X86_LEA64r:
802
+ MI->x86opsize = 8;
803
+ break;
804
+ case X86_BNDCL32rm:
805
+ case X86_BNDCN32rm:
806
+ case X86_BNDCU32rm:
807
+ case X86_BNDSTXmr:
808
+ case X86_BNDLDXrm:
809
+ case X86_BNDCL64rm:
810
+ case X86_BNDCN64rm:
811
+ case X86_BNDCU64rm:
812
+ MI->x86opsize = 16;
813
+ break;
814
+ }
815
+
816
+ printMemReference(MI, OpNo, O);
817
+ }
818
+
819
+ #include "X86InstPrinter.h"
820
+
821
+ // Include the auto-generated portion of the assembly writer.
822
+ #ifdef CAPSTONE_X86_REDUCE
823
+ #include "X86GenAsmWriter_reduce.inc"
824
+ #else
825
+ #include "X86GenAsmWriter.inc"
826
+ #endif
827
+
828
+ #include "X86GenRegisterName.inc"
829
+
830
+ static void printRegName(SStream *OS, unsigned RegNo)
831
+ {
832
+ SStream_concat(OS, "%%%s", getRegisterName(RegNo));
833
+ }
834
+
835
+ void X86_ATT_printInst(MCInst *MI, SStream *OS, void *info)
836
+ {
837
+ x86_reg reg, reg2;
838
+ enum cs_ac_type access1, access2;
839
+ int i;
840
+
841
+ // perhaps this instruction does not need printer
842
+ if (MI->assembly[0]) {
843
+ strncpy(OS->buffer, MI->assembly, sizeof(OS->buffer));
844
+ return;
845
+ }
846
+
847
+ // Output CALLpcrel32 as "callq" in 64-bit mode.
848
+ // In Intel annotation it's always emitted as "call".
849
+ //
850
+ // TODO: Probably this hack should be redesigned via InstAlias in
851
+ // InstrInfo.td as soon as Requires clause is supported properly
852
+ // for InstAlias.
853
+ if (MI->csh->mode == CS_MODE_64 && MCInst_getOpcode(MI) == X86_CALLpcrel32) {
854
+ SStream_concat0(OS, "callq\t");
855
+ MCInst_setOpcodePub(MI, X86_INS_CALL);
856
+ printPCRelImm(MI, 0, OS);
857
+ return;
858
+ }
859
+
860
+ X86_lockrep(MI, OS);
861
+ printInstruction(MI, OS);
862
+
863
+ if (MI->has_imm) {
864
+ // if op_count > 1, then this operand's size is taken from the destination op
865
+ if (MI->flat_insn->detail->x86.op_count > 1) {
866
+ if (MI->flat_insn->id != X86_INS_LCALL && MI->flat_insn->id != X86_INS_LJMP && MI->flat_insn->id != X86_INS_JMP) {
867
+ for (i = 0; i < MI->flat_insn->detail->x86.op_count; i++) {
868
+ if (MI->flat_insn->detail->x86.operands[i].type == X86_OP_IMM)
869
+ MI->flat_insn->detail->x86.operands[i].size =
870
+ MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count - 1].size;
871
+ }
872
+ }
873
+ } else
874
+ MI->flat_insn->detail->x86.operands[0].size = MI->imm_size;
875
+ }
876
+
877
+ if (MI->csh->detail) {
878
+ uint8_t access[6] = {0};
879
+
880
+ // some instructions need to supply immediate 1 in the first op
881
+ switch(MCInst_getOpcode(MI)) {
882
+ default:
883
+ break;
884
+ case X86_SHL8r1:
885
+ case X86_SHL16r1:
886
+ case X86_SHL32r1:
887
+ case X86_SHL64r1:
888
+ case X86_SAL8r1:
889
+ case X86_SAL16r1:
890
+ case X86_SAL32r1:
891
+ case X86_SAL64r1:
892
+ case X86_SHR8r1:
893
+ case X86_SHR16r1:
894
+ case X86_SHR32r1:
895
+ case X86_SHR64r1:
896
+ case X86_SAR8r1:
897
+ case X86_SAR16r1:
898
+ case X86_SAR32r1:
899
+ case X86_SAR64r1:
900
+ case X86_RCL8r1:
901
+ case X86_RCL16r1:
902
+ case X86_RCL32r1:
903
+ case X86_RCL64r1:
904
+ case X86_RCR8r1:
905
+ case X86_RCR16r1:
906
+ case X86_RCR32r1:
907
+ case X86_RCR64r1:
908
+ case X86_ROL8r1:
909
+ case X86_ROL16r1:
910
+ case X86_ROL32r1:
911
+ case X86_ROL64r1:
912
+ case X86_ROR8r1:
913
+ case X86_ROR16r1:
914
+ case X86_ROR32r1:
915
+ case X86_ROR64r1:
916
+ case X86_SHL8m1:
917
+ case X86_SHL16m1:
918
+ case X86_SHL32m1:
919
+ case X86_SHL64m1:
920
+ case X86_SAL8m1:
921
+ case X86_SAL16m1:
922
+ case X86_SAL32m1:
923
+ case X86_SAL64m1:
924
+ case X86_SHR8m1:
925
+ case X86_SHR16m1:
926
+ case X86_SHR32m1:
927
+ case X86_SHR64m1:
928
+ case X86_SAR8m1:
929
+ case X86_SAR16m1:
930
+ case X86_SAR32m1:
931
+ case X86_SAR64m1:
932
+ case X86_RCL8m1:
933
+ case X86_RCL16m1:
934
+ case X86_RCL32m1:
935
+ case X86_RCL64m1:
936
+ case X86_RCR8m1:
937
+ case X86_RCR16m1:
938
+ case X86_RCR32m1:
939
+ case X86_RCR64m1:
940
+ case X86_ROL8m1:
941
+ case X86_ROL16m1:
942
+ case X86_ROL32m1:
943
+ case X86_ROL64m1:
944
+ case X86_ROR8m1:
945
+ case X86_ROR16m1:
946
+ case X86_ROR32m1:
947
+ case X86_ROR64m1:
948
+ // shift all the ops right to leave 1st slot for this new register op
949
+ memmove(&(MI->flat_insn->detail->x86.operands[1]), &(MI->flat_insn->detail->x86.operands[0]),
950
+ sizeof(MI->flat_insn->detail->x86.operands[0]) * (ARR_SIZE(MI->flat_insn->detail->x86.operands) - 1));
951
+ MI->flat_insn->detail->x86.operands[0].type = X86_OP_IMM;
952
+ MI->flat_insn->detail->x86.operands[0].imm = 1;
953
+ MI->flat_insn->detail->x86.operands[0].size = 1;
954
+ MI->flat_insn->detail->x86.op_count++;
955
+ }
956
+
957
+ // special instruction needs to supply register op
958
+ // first op can be embedded in the asm by llvm.
959
+ // so we have to add the missing register as the first operand
960
+
961
+ //printf(">>> opcode = %u\n", MCInst_getOpcode(MI));
962
+
963
+ reg = X86_insn_reg_att(MCInst_getOpcode(MI), &access1);
964
+ if (reg) {
965
+ // shift all the ops right to leave 1st slot for this new register op
966
+ memmove(&(MI->flat_insn->detail->x86.operands[1]), &(MI->flat_insn->detail->x86.operands[0]),
967
+ sizeof(MI->flat_insn->detail->x86.operands[0]) * (ARR_SIZE(MI->flat_insn->detail->x86.operands) - 1));
968
+ MI->flat_insn->detail->x86.operands[0].type = X86_OP_REG;
969
+ MI->flat_insn->detail->x86.operands[0].reg = reg;
970
+ MI->flat_insn->detail->x86.operands[0].size = MI->csh->regsize_map[reg];
971
+ MI->flat_insn->detail->x86.operands[0].access = access1;
972
+
973
+ MI->flat_insn->detail->x86.op_count++;
974
+ } else {
975
+ if (X86_insn_reg_att2(MCInst_getOpcode(MI), &reg, &access1, &reg2, &access2)) {
976
+
977
+ MI->flat_insn->detail->x86.operands[0].type = X86_OP_REG;
978
+ MI->flat_insn->detail->x86.operands[0].reg = reg;
979
+ MI->flat_insn->detail->x86.operands[0].size = MI->csh->regsize_map[reg];
980
+ MI->flat_insn->detail->x86.operands[0].access = access1;
981
+ MI->flat_insn->detail->x86.operands[1].type = X86_OP_REG;
982
+ MI->flat_insn->detail->x86.operands[1].reg = reg2;
983
+ MI->flat_insn->detail->x86.operands[1].size = MI->csh->regsize_map[reg2];
984
+ MI->flat_insn->detail->x86.operands[0].access = access2;
985
+ MI->flat_insn->detail->x86.op_count = 2;
986
+ }
987
+ }
988
+
989
+ #ifndef CAPSTONE_DIET
990
+ get_op_access(MI->csh, MCInst_getOpcode(MI), access, &MI->flat_insn->detail->x86.eflags);
991
+ MI->flat_insn->detail->x86.operands[0].access = access[0];
992
+ MI->flat_insn->detail->x86.operands[1].access = access[1];
993
+ #endif
994
+ }
995
+ }
996
+
997
+ #endif