Merge commit '802798ce3c8baa4697120580f87bc1ee377306d3' as 'external/capstone'

This commit is contained in:
2026-05-11 11:55:07 +02:00
3968 changed files with 2967598 additions and 0 deletions
+76
View File
@@ -0,0 +1,76 @@
This directory contains bindings & test code for Python, Java & OCaml.
See `<language>/README.md` for how to compile & install each binding.
More bindings created & maintained by the community are available as followings.
- Gapstone: Go binding (by Scott Knight).
https://github.com/knightsc/gapstone
- Crabstone: Ruby binding for Capstone 3+ (by david942j).
https://github.com/david942j/crabstone
- Crabstone: Ruby binding (by Ben Nagy).
https://github.com/bnagy/crabstone
- Capstone-Vala: Vala binding (by Pancake).
https://github.com/radare/capstone-vala
- Node-Capstone: NodeJS binding (by Jason Oster).
https://github.com/parasyte/node-capstone
- CCcapstone: C++ binding (by Peter Hlavaty).
https://github.com/zer0mem/cccapstone
- LuaCapstone: Lua binding (by Antonio Davide).
https://github.com/Dax89/LuaCapstone
- Capstone-RS: Rust binding (by Richo Healey).
https://github.com/capstone-rust/capstone-rs
- Capstone.NET: .NET framework binding (by Ahmed Garhy).
https://github.com/9ee1/Capstone.NET
- CapstoneJ: High level Java wrapper for Capstone-java (by Keve Müller).
https://github.com/kevemueller/capstonej
- Hapstone: Haskell binding (by ibabushkin)
https://github.com/ibabushkin/hapstone
- CL-Capstone: Common Lisp bindings (by GrammaTech).
https://github.com/GrammaTech/cl-capstone
- Emacs-capstone: Emacs (elisp) binding (by Bas Alberts)
https://github.com/collarchoke/emacs-capstone
- C# binding (by Matt Graeber). Note: this is only for Capstone v2.0.
https://github.com/mattifestation/capstone
- PowerShell binding (by Ruben Boonen).
https://github.com/aquynh/capstone/tree/master/bindings/powershell
- PHP binding (by Fadhil Mandaga).
https://github.com/firodj/php-capstone
- capstone-d: D binding (by Dimitri Bohlender)
https://github.com/bohlender/capstone-d
- Swift binding (by Jesús A. Álvarez)
https://github.com/zydeco/capstone-swift
+337
View File
@@ -0,0 +1,337 @@
# Capstone Disassembler Engine
# By Dang Hoang Vu, 2013
from __future__ import print_function
import sys
import re
INCL_DIR = '../include/capstone/'
include = ['arm.h', 'aarch64.h', 'm68k.h', 'mips.h', 'x86.h', 'ppc.h', 'sparc.h', 'systemz.h', 'xcore.h',
'tms320c64x.h', 'm680x.h', 'evm.h', 'mos65xx.h', 'wasm.h', 'bpf.h', 'riscv.h', 'sh.h', 'tricore.h',
'alpha.h', 'hppa.h', 'loongarch.h', 'arc.h', 'xtensa.h']
template = {
'java': {
'header': "// For Capstone Engine. AUTO-GENERATED FILE, DO NOT EDIT\npackage capstone;\n\npublic class %s_const {\n",
'footer': "}",
'line_format': '\tpublic static final int %s = %s;\n',
'out_file': './java/capstone/%s_const.java',
# prefixes for constant filenames of all archs - case sensitive
'arm.h': 'Arm',
'm68k.h': 'M68k',
'mips.h': 'Mips',
'x86.h': 'X86',
'ppc.h': 'Ppc',
'sparc.h': 'Sparc',
'systemz.h': 'Systemz',
'xcore.h': 'Xcore',
'tms320c64x.h': 'TMS320C64x',
'm680x.h': 'M680x',
'evm.h': 'Evm',
'wasm.h': 'Wasm',
'comment_open': '\t//',
'comment_close': '',
},
'python': {
'header': (
"from . import CS_OP_INVALID, CS_OP_REG, CS_OP_IMM, CS_OP_FP, CS_OP_PRED, CS_OP_SPECIAL, CS_OP_MEM, CS_OP_MEM_REG, CS_OP_MEM_IMM, UINT16_MAX, UINT8_MAX\n"
"# For Capstone Engine. AUTO-GENERATED FILE, DO NOT EDIT [%s_const.py]\n"
),
'footer': "",
'line_format': '%s = %s\n',
'out_file': './python/capstone/%s_const.py',
# prefixes for constant filenames of all archs - case sensitive
'arm.h': 'arm',
'aarch64.h': ['AArch64', 'AARCH64'],
'm68k.h': 'm68k',
'mips.h': 'mips',
'x86.h': 'x86',
'ppc.h': 'ppc',
'sparc.h': 'sparc',
'systemz.h': 'systemz',
'xcore.h': 'xcore',
'tms320c64x.h': 'tms320c64x',
'm680x.h': 'm680x',
'evm.h': 'evm',
'wasm.h': 'wasm',
'mos65xx.h': 'mos65xx',
'bpf.h': 'bpf',
'riscv.h': 'riscv',
'sh.h': 'sh',
'tricore.h': ['TRICORE', 'TriCore'],
'alpha.h': ['ALPHA', 'Alpha'],
'hppa.h': 'hppa',
'loongarch.h': 'loongarch',
'xtensa.h': 'xtensa',
'arc.h': 'arc',
'comment_open': '#',
'comment_close': '',
},
'ocaml': {
'header': "(* For Capstone Engine. AUTO-GENERATED FILE, DO NOT EDIT [%s_const.ml] *)\n",
'footer': "",
'line_format': 'let _%s = %s;;\n',
'out_file': './ocaml/%s_const.ml',
# prefixes for constant filenames of all archs - case sensitive
'arm.h': 'arm',
'mips.h': 'mips',
'm68k.h': 'm68k',
'x86.h': 'x86',
'ppc.h': 'ppc',
'sparc.h': 'sparc',
'systemz.h': 'systemz',
'xcore.h': 'xcore',
'tms320c64x.h': 'tms320c64x',
'm680x.h': 'm680x',
'evm.h': 'evm',
'wasm.h': 'wasm',
'comment_open': '(*',
'comment_close': ' *)',
},
}
excluded_prefixes = {
'arm.h': ["ARMCC_CondCodes", "ARMVCC_VPTCodes"],
'aarch64.h': ["AArch64CC_CondCode", "AArch64Layout_VectorLayout"],
}
# markup for comments to be added to autogen files
MARKUP = '//>'
def camelize(name):
parts = name.split('_')
return parts[0].lower() + ''.join(map(str.capitalize, parts[1:]))
def pascalize(name):
parts = name.split('_')
return ''.join(map(str.capitalize, parts))
def pascalize_const(name):
parts = name.split('_',2)
match = re.match('^(CC|DISP|MOD|DIR|BCAST|RM|FLAGS|SIZE|BR_DISP_SIZE)_', parts[2])
if match:
parts = name.split('_', 2 + match.group(0).count('_'))
item = camelize(parts[-1])
if item[0].isdigit():
item = parts[-2].lower() + item
return (pascalize('_'.join(parts[0:-1])), item)
def enum_type(name, templ):
for enum_type, pattern in templ['enum_types'].items():
if re.match(pattern, name):
return enum_type
return templ['enum_default_type']
def write_enum_extra_options(outfile, templ, enum, enum_values):
if 'enum_extra_options' in templ and enum in templ['enum_extra_options']:
for name, value in templ['enum_extra_options'][enum].items():
if type(value) is str:
# evaluate within existing enum
value = eval(value, None, enum_values)
outfile.write((templ['line_format'] %(name, value)).encode("utf-8"))
def gen(lang):
global include, INCL_DIR
print('Generating bindings for', lang)
templ = template[lang]
print('Generating bindings for', lang)
for target in include:
if target not in templ:
print("Warning: No binding found for %s" % target)
continue
prefix = templ[target]
prefixs = []
if isinstance(prefix, list):
prefixs = prefix
prefix = prefix[0].lower()
outfile = open(templ['out_file'] %(prefix), 'wb') # open as binary prevents windows newlines
outfile.write((templ['header'] % (prefix)).encode("utf-8"))
lines = open(INCL_DIR + target).readlines()
enums = {}
values = {}
doc_lines = []
rhs = ""
count = 0
for line in lines:
line = line.strip()
if line.startswith(MARKUP): # markup for comments
outfile.write(("\n%s%s%s\n" %(templ['comment_open'], \
line.replace(MARKUP, ''), \
templ['comment_close']) ).encode("utf-8"))
continue
if line.startswith('/// ') and 'enum_doc' in templ:
doc_lines.append(line[4: ])
continue
elif line.startswith('}') or line.startswith('#'):
doc_lines = []
pass
elif re.search(r"^(\s*typedef\s+)?enum", line):
# First new enum value should be 0.
# Because `rhs` is incremented later, it must be set to -1 here.
# Everything about this code is so broken -.-
rhs = "-1"
if line == '' or line.startswith('//'):
continue
if line.startswith('#define '):
line = line[8:] #cut off define
xline = re.split(r'\s+', line, maxsplit=1) #split to at most 2 express
if len(xline) != 2:
continue
if '(' in xline[0] or ')' in xline[0]: #does it look like a function
continue
xline.insert(1, '=') # insert an = so the expression below can parse it
line = ' '.join(xline)
def has_special_arch_prefix(x):
if target in excluded_prefixes and any(x.startswith(excl_pre) for excl_pre in excluded_prefixes[target]):
return False
if prefixs:
return any(x.startswith(pre) for pre in prefixs)
else:
return x.startswith(prefix.upper())
if not has_special_arch_prefix(line):
continue
tmp = line.strip().split(',')
for t in tmp:
t = t.strip()
if not t or t.startswith('//'): continue
# hacky: remove type cast (uint64_t)
t = t.replace('(uint64_t)', '')
t = re.sub(r'\((\d+)ULL << (\d+)\)', r'\1 << \2', t) # (1ULL<<1) to 1 << 1
f = re.split(r'\s+', t)
if not has_special_arch_prefix(f[0]):
continue
if len(f) > 1 and f[1] not in ('//', '///<', '='):
print("Error: Unable to convert %s" % f)
continue
elif len(f) > 1 and f[1] == '=':
rhs = ''.join(f[2:])
else:
# Dirty fix: This line is reached for enum values which
# have no value assigned (as in `ARCH_SOMETHING,`).
# Because the binding constants require a fixed value,
# `count` was used (as it is now the `except` case).
# Which is of course incorrect,
# because it doesn't match the actual value in the C code.
# So we just test here if the previous `rhs` was an actual number,
# and set `rhs = rhs + 1`. If it wasn't a number, we just continue the incorrect design and
# set it to `str(count)`.
try:
if "0x" in rhs:
prev_val = int(rhs, 16)
else:
prev_val = int(rhs)
prev_val += 1
rhs = str(prev_val)
except ValueError:
rhs = str(count)
count += 1
try:
count = int(rhs) + 1
if (count == 1):
outfile.write(("\n").encode("utf-8"))
except ValueError:
if lang == 'ocaml':
# ocaml uses lsl for '<<', lor for '|'
rhs = rhs.replace('<<', ' lsl ')
rhs = rhs.replace('|', ' lor ')
# ocaml variable has _ as prefix
if rhs[0].isalpha():
rhs = '_' + rhs
if lang == 'swift':
value = eval(rhs, None, values)
exec('%s = %d' %(f[0].strip(), value), None, values)
else:
value = rhs
name = f[0].strip()
if 'rename' in templ:
# constant renaming
for pattern, replacement in templ['rename'].items():
if re.match(pattern, name):
name = re.sub(pattern, replacement, name)
break
if 'enum_header' in templ:
# separate constants by enums based on name
enum, name = pascalize_const(name)
if enum not in enums:
if len(enums) > 0:
write_enum_extra_options(outfile, templ, last_enum, enums[last_enum])
outfile.write((templ['enum_footer']).encode("utf-8"))
last_enum = enum
if 'enum_doc' in templ:
for doc_line in doc_lines:
outfile.write((templ['enum_doc'] %(doc_line)).encode("utf-8"))
doc_lines = []
if 'option_sets' in templ and enum in templ['option_sets']:
outfile.write((templ['option_set_header'] %(enum, templ['option_sets'][enum])).encode("utf-8"))
else:
outfile.write((templ['enum_header'] %(enum, enum_type(enum, templ))).encode("utf-8"))
enums[enum] = {}
if 'option_sets' in templ and enum in templ['option_sets']:
# option set format
line_format = templ['option_format'].format(option='%s',type=enum,value='%s')
if value == 0:
continue # skip empty option
# option set values need not be literals
value = rhs
elif 'dup_line_format' in templ and value in enums[enum].values():
# different format for duplicate values?
line_format = templ['dup_line_format']
else:
line_format = templ['line_format']
enums[enum][name] = value
# escape reserved words
if 'reserved_words' in templ and name in templ['reserved_words']:
name = templ['reserved_word_format'] %(name)
# print documentation?
if 'doc_line_format' in templ and '///<' in line:
doc = line.split('///<')[1].strip()
outfile.write((templ['doc_line_format'] %(doc)).encode("utf-8"))
else:
line_format = templ['line_format']
outfile.write((line_format %(name, value)).encode("utf-8"))
if 'enum_footer' in templ:
write_enum_extra_options(outfile, templ, enum, enums[enum])
outfile.write((templ['enum_footer']).encode("utf-8"))
outfile.write((templ['footer']).encode("utf-8"))
outfile.close()
def main():
try:
if sys.argv[1] == 'all':
for key in template.keys():
gen(key)
else:
gen(sys.argv[1])
except:
raise RuntimeError("Unsupported binding %s" % sys.argv[1])
if __name__ == "__main__":
if len(sys.argv) < 2:
print("Usage:", sys.argv[0], " <bindings: java|python|ocaml|all>")
sys.exit(1)
main()
@@ -0,0 +1,2 @@
*.class
tags
+71
View File
@@ -0,0 +1,71 @@
# Capstone Disassembler Engine
# By Nguyen Anh Quynh <aquynh@gmail.com>, 2013>
ifndef BUILDDIR
BLDIR = .
OBJDIR = .
else
BLDIR = $(abspath $(BUILDDIR))/bindings/java
OBJDIR = $(abspath $(BUILDDIR))/obj/bindings/java
endif
JNA = /usr/share/java/jna/jna.jar
ifneq ($(wildcard $(JNA)),)
else
ifneq ($(wildcard /usr/share/java/jna.jar),)
JNA = /usr/share/java/jna.jar
else
JNA =
endif
endif
PYTHON2 ?= python
CAPSTONE_JAVA = Capstone.java Arm_const.java Arm64_const.java Mips_const.java \
X86_const.java Xcore_const.java Ppc_const.java Sparc_const.java\
Sysz_const.java M680x_const.java \
Arm.java Arm64.java Mips.java X86.java Xcore.java Ppc.java\
Sparc.java Systemz.java M680x.java
all: gen_const capstone tests
capstone: capstone_class
@mkdir -p $(BLDIR)
cd $(OBJDIR) && jar cf $(BLDIR)/capstone.jar capstone/*.class
capstone_class: jna
ifdef BUILDDIR
@mkdir -p $(OBJDIR)
cd capstone && javac -d $(OBJDIR) -classpath $(JNA) $(CAPSTONE_JAVA)
else
cd capstone && javac -classpath $(JNA) $(CAPSTONE_JAVA)
endif
tests: capstone_class jna
@mkdir -p $(OBJDIR)
javac -d $(OBJDIR) -classpath "$(JNA):$(BLDIR)/capstone.jar" TestBasic.java\
TestArm.java TestArm64.java TestMips.java TestX86.java TestXcore.java\
TestPpc.java TestSparc.java TestSystemz.java TestM680x.java
gen_const:
cd ../ && $(PYTHON2) const_generator.py java
jna:
@if [ ! $(JNA) ]; then echo "*** Unable to find JNA ***"; exit 1; fi
clean:
rm -rf $(OBJDIR)/capstone/*.class
rm -rf $(OBJDIR)/*.class $(OBJDIR)/*.log $(BLDIR)/*.jar
ifdef BUILDDIR
rm -rf $(BLDIR)
rm -rf $(OBJDIR)
endif
TESTS = testbasic arm arm64 m680x mips ppc sparc systemz x86 xcore
check:
@for t in $(TESTS); do \
echo Check $$t ... ; \
./run.sh $$t > /dev/null && echo OK || echo FAILED; \
done
+30
View File
@@ -0,0 +1,30 @@
This has been tested with OpenJDK version 6 & 7 on Ubuntu-12.04 and
Arch Linux-3.11, 64-bit.
- OpenJDK is required to compile and run this test code.
For example, install OpenJDK 6 with:
`$ sudo apt-get install openjdk-6-jre-headless openjdk-6-jdk`
- Java Native Access is required to run the code, you can install it with:
`$ sudo apt-get install libjna-java`
- To compile and run this Java test code:
```
$ make
$ ./run.sh
```
This directory contains some test code to show how to use Capstone API.
- TestBasic.java
This code shows the most simple form of API where we only want to get basic
information out of disassembled instruction, such as address, mnemonic and
operand string.
- Test<arch>.java
These code show how to retrieve architecture-specific information for each
architecture.
+142
View File
@@ -0,0 +1,142 @@
// Capstone Java binding
// By Nguyen Anh Quynh & Dang Hoang Vu, 2013
import capstone.Capstone;
import capstone.Arm;
import static capstone.Arm_const.*;
public class TestArm {
static byte[] hexString2Byte(String s) {
// from http://stackoverflow.com/questions/140131/convert-a-string-representation-of-a-hex-dump-to-a-byte-array-using-java
int len = s.length();
byte[] data = new byte[len / 2];
for (int i = 0; i < len; i += 2) {
data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
+ Character.digit(s.charAt(i+1), 16));
}
return data;
}
static final String ARM_CODE = "EDFFFFEB04e02de500000000e08322e5f102030e0000a0e30230c1e7000053e3000201f10540d0e8";
static final String ARM_CODE2 = "d1e800f0f02404071f3cf2c000004ff00001466c";
static final String THUMB_CODE2 = "4ff00001bde80088d1e800f018bfadbff3ff0b0c86f3008980f3008c4ffa99f6d0ffa201";
static final String THUMB_CODE = "7047eb4683b0c9681fb130bfaff32084";
public static Capstone cs;
private static String hex(int i) {
return Integer.toString(i, 16);
}
private static String hex(long i) {
return Long.toString(i, 16);
}
public static void print_ins_detail(Capstone.CsInsn ins) {
System.out.printf("0x%x:\t%s\t%s\n", ins.address, ins.mnemonic, ins.opStr);
Arm.OpInfo operands = (Arm.OpInfo) ins.operands;
if (operands.op.length != 0) {
System.out.printf("\top_count: %d\n", operands.op.length);
for (int c=0; c<operands.op.length; c++) {
Arm.Operand i = (Arm.Operand) operands.op[c];
String imm = hex(i.value.imm);
if (i.type == ARM_OP_SYSREG)
System.out.printf("\t\toperands[%d].type: SYSREG = %d\n", c, i.value.reg);
if (i.type == ARM_OP_REG)
System.out.printf("\t\toperands[%d].type: REG = %s\n", c, ins.regName(i.value.reg));
if (i.type == ARM_OP_IMM)
System.out.printf("\t\toperands[%d].type: IMM = 0x%x\n", c, i.value.imm);
if (i.type == ARM_OP_PIMM)
System.out.printf("\t\toperands[%d].type: P-IMM = %d\n", c, i.value.imm);
if (i.type == ARM_OP_CIMM)
System.out.printf("\t\toperands[%d].type: C-IMM = %d\n", c, i.value.imm);
if (i.type == ARM_OP_SETEND)
System.out.printf("\t\toperands[%d].type: SETEND = %s\n", c, i.value.setend == ARM_SETEND_BE? "be" : "le");
if (i.type == ARM_OP_FP)
System.out.printf("\t\toperands[%d].type: FP = %f\n", c, i.value.fp);
if (i.type == ARM_OP_MEM) {
System.out.printf("\t\toperands[%d].type: MEM\n",c);
String base = ins.regName(i.value.mem.base);
String index = ins.regName(i.value.mem.index);
if (base != null)
System.out.printf("\t\t\toperands[%d].mem.base: REG = %s\n", c, base);
if (index != null)
System.out.printf("\t\t\toperands[%d].mem.index: REG = %s\n", c, index);
if (i.value.mem.scale != 1)
System.out.printf("\t\t\toperands[%d].mem.scale: %d\n", c, (i.value.mem.scale));
if (i.value.mem.disp != 0)
System.out.printf("\t\t\toperands[%d].mem.disp: 0x%x\n", c, (i.value.mem.disp));
if (i.value.mem.lshift != 0)
System.out.printf("\t\t\toperands[%d].mem.lshift: 0x%x\n", c, (i.value.mem.lshift));
}
if (i.vector_index > 0)
System.out.printf("\t\t\toperands[%d].vector_index = %d\n", c, (i.vector_index));
if (i.shift.type != ARM_SFT_INVALID && i.shift.value > 0)
System.out.printf("\t\t\tShift: %d = %d\n", i.shift.type, i.shift.value);
if (i.subtracted)
System.out.printf("\t\t\toperands[%d].subtracted = True\n", c);
}
}
if (operands.writeback)
System.out.println("\tWrite-back: True");
if (operands.updateFlags)
System.out.println("\tUpdate-flags: True");
if (operands.cc != ARM_CC_AL && operands.cc != ARM_CC_INVALID)
System.out.printf("\tCode condition: %d\n", operands.cc);
if (operands.cpsMode > 0)
System.out.printf("\tCPSI-mode: %d\n", operands.cpsMode);
if (operands.cpsFlag > 0)
System.out.printf("\tCPSI-flag: %d\n", operands.cpsFlag);
if (operands.vectorData > 0)
System.out.printf("\tVector-data: %d\n", operands.vectorData);
if (operands.vectorSize > 0)
System.out.printf("\tVector-size: %d\n", operands.vectorSize);
if (operands.usermode)
System.out.printf("\tUser-mode: True\n");
}
public static void main(String argv[]) {
final TestBasic.platform[] all_tests = {
new TestBasic.platform(Capstone.CS_ARCH_ARM, Capstone.CS_MODE_ARM, hexString2Byte(ARM_CODE), "ARM"),
new TestBasic.platform(Capstone.CS_ARCH_ARM, Capstone.CS_MODE_THUMB, hexString2Byte(THUMB_CODE), "Thumb"),
new TestBasic.platform(Capstone.CS_ARCH_ARM, Capstone.CS_MODE_THUMB, hexString2Byte(ARM_CODE2), "Thumb-mixed"),
new TestBasic.platform(Capstone.CS_ARCH_ARM, Capstone.CS_MODE_THUMB, Capstone.CS_OPT_SYNTAX_NOREGNAME, hexString2Byte(THUMB_CODE2), "Thumb-2 & register named with numbers"),
};
for (int i=0; i<all_tests.length; i++) {
TestBasic.platform test = all_tests[i];
System.out.println(new String(new char[16]).replace("\0", "*"));
System.out.println("Platform: " + test.comment);
System.out.println("Code: " + TestBasic.stringToHex(test.code));
System.out.println("Disasm:");
cs = new Capstone(test.arch, test.mode);
cs.setDetail(Capstone.CS_OPT_ON);
if (test.syntax != 0)
cs.setSyntax(test.syntax);
Capstone.CsInsn[] all_ins = cs.disasm(test.code, 0x1000);
for (int j = 0; j < all_ins.length; j++) {
print_ins_detail(all_ins[j]);
System.out.println();
}
System.out.printf("0x%x:\n\n", (all_ins[all_ins.length-1].address + all_ins[all_ins.length-1].size));
// Close when done
cs.close();
}
}
}
+124
View File
@@ -0,0 +1,124 @@
// Capstone Java binding
// By Nguyen Anh Quynh & Dang Hoang Vu, 2013
import capstone.Capstone;
import capstone.Arm64;
import static capstone.Arm64_const.*;
public class TestArm64 {
static byte[] hexString2Byte(String s) {
// from http://stackoverflow.com/questions/140131/convert-a-string-representation-of-a-hex-dump-to-a-byte-array-using-java
int len = s.length();
byte[] data = new byte[len / 2];
for (int i = 0; i < len; i += 2) {
data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
+ Character.digit(s.charAt(i+1), 16));
}
return data;
}
static final String ARM64_CODE = "090038d5bf4000d50c0513d52050020e20e43d0f0018a05fa200ae9e9f3703d5bf3303d5df3f03d5217c029b217c00530040214be10b40b9200481da2008028b105be83c";
public static Capstone cs;
private static String hex(int i) {
return Integer.toString(i, 16);
}
private static String hex(long i) {
return Long.toString(i, 16);
}
public static void print_ins_detail(Capstone.CsInsn ins) {
System.out.printf("0x%x:\t%s\t%s\n", ins.address, ins.mnemonic, ins.opStr);
Arm64.OpInfo operands = (Arm64.OpInfo) ins.operands;
if (operands.op.length != 0) {
System.out.printf("\top_count: %d\n", operands.op.length);
for (int c=0; c<operands.op.length; c++) {
Arm64.Operand i = (Arm64.Operand) operands.op[c];
String imm = hex(i.value.imm);
if (i.type == ARM64_OP_REG)
System.out.printf("\t\toperands[%d].type: REG = %s\n", c, ins.regName(i.value.reg));
if (i.type == ARM64_OP_REG_MRS)
System.out.printf("\t\toperands[%d].type: REG_MRS = 0x%x\n", c, i.value.reg);
if (i.type == ARM64_OP_REG_MSR)
System.out.printf("\t\toperands[%d].type: REG_MSR = 0x%x\n", c, i.value.reg);
if (i.type == ARM64_OP_PSTATE)
System.out.printf("\t\toperands[%d].type: PSTATE = 0x%x\n", c, i.value.imm);
if (i.type == ARM64_OP_BARRIER)
System.out.printf("\t\toperands[%d].type: BARRIER = 0x%x\n", c, i.value.imm);
if (i.type == ARM64_OP_IMM)
System.out.printf("\t\toperands[%d].type: IMM = 0x%x\n", c, i.value.imm);
if (i.type == ARM64_OP_CIMM)
System.out.printf("\t\toperands[%d].type: C-IMM = %d\n", c, i.value.imm);
if (i.type == ARM64_OP_FP)
System.out.printf("\t\toperands[%d].type: FP = %f\n", c, i.value.fp);
if (i.type == ARM64_OP_MEM) {
System.out.printf("\t\toperands[%d].type: MEM\n",c);
String base = ins.regName(i.value.mem.base);
String index = ins.regName(i.value.mem.index);
if (base != null)
System.out.printf("\t\t\toperands[%d].mem.base: REG = %s\n", c, base);
if (index != null)
System.out.printf("\t\t\toperands[%d].mem.index: REG = %s\n", c, index);
if (i.value.mem.disp != 0)
System.out.printf("\t\t\toperands[%d].mem.disp: 0x%x\n", c, i.value.mem.disp);
}
if (i.shift.type != ARM64_SFT_INVALID && i.shift.value > 0)
System.out.printf("\t\t\tShift: type = %d, value = %d\n", i.shift.type, i.shift.value);
if (i.ext != ARM64_EXT_INVALID)
System.out.printf("\t\t\tExt: %d\n", i.ext);
if (i.vas != ARM64_VAS_INVALID)
System.out.printf("\t\t\tVector Arrangement Specifier: 0x%x\n", i.vas);
if (i.vector_index != -1)
System.out.printf("\t\t\tVector Index: %d\n", i.vector_index);
}
}
if (operands.writeback)
System.out.println("\tWrite-back: True");
if (operands.updateFlags)
System.out.println("\tUpdate-flags: True");
if (operands.cc != ARM64_CC_AL && operands.cc != ARM64_CC_INVALID)
System.out.printf("\tCode-condition: %d\n", operands.cc);
}
public static void main(String argv[]) {
final TestBasic.platform[] all_tests = {
new TestBasic.platform(Capstone.CS_ARCH_ARM64, Capstone.CS_MODE_ARM, hexString2Byte(ARM64_CODE), "ARM-64"),
};
for (int i=0; i<all_tests.length; i++) {
TestBasic.platform test = all_tests[i];
System.out.println(new String(new char[16]).replace("\0", "*"));
System.out.println("Platform: " + test.comment);
System.out.println("Code: " + TestBasic.stringToHex(test.code));
System.out.println("Disasm:");
cs = new Capstone(test.arch, test.mode);
cs.setDetail(Capstone.CS_OPT_ON);
Capstone.CsInsn[] all_ins = cs.disasm(test.code, 0x2c);
for (int j = 0; j < all_ins.length; j++) {
print_ins_detail(all_ins[j]);
System.out.println();
}
System.out.printf("0x%x: \n\n", all_ins[all_ins.length-1].address + all_ins[all_ins.length-1].size);
// Close when done
cs.close();
}
}
}
+178
View File
@@ -0,0 +1,178 @@
/* Capstone Disassembler Engine */
/* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013> */
import capstone.Capstone;
public class TestBasic {
public static class platform {
public int arch;
public int mode;
public int syntax;
public byte[] code;
public String comment;
public platform(int a, int m, int syt, byte[] c, String s) {
arch = a;
mode = m;
code = c;
comment = s;
syntax = syt;
}
public platform(int a, int m, byte[] c, String s) {
arch = a;
mode = m;
code = c;
comment = s;
}
};
static public String stringToHex(byte[] code) {
StringBuilder buf = new StringBuilder(200);
for (byte ch: code) {
if (buf.length() > 0)
buf.append(' ');
buf.append(String.format("0x%02x", ch));
}
return buf.toString();
}
public static final byte[] PPC_CODE = new byte[] {(byte)0x80, (byte)0x20, (byte)0x00, (byte)0x00, (byte)0x80, (byte)0x3f, (byte)0x00, (byte)0x00, (byte)0x10, (byte)0x43, (byte)0x23, (byte)0x0e, (byte)0xd0, (byte)0x44, (byte)0x00, (byte)0x80, (byte)0x4c, (byte)0x43, (byte)0x22, (byte)0x02, (byte)0x2d, (byte)0x03, (byte)0x00, (byte)0x80, (byte)0x7c, (byte)0x43, (byte)0x20, (byte)0x14, (byte)0x7c, (byte)0x43, (byte)0x20, (byte)0x93, (byte)0x4f, (byte)0x20, (byte)0x00, (byte)0x21, (byte)0x4c, (byte)0xc8, (byte)0x00, (byte)0x21 };
public static final byte[] X86_CODE = new byte[] { (byte)0x8d, (byte)0x4c, (byte)0x32, (byte)0x08, (byte)0x01, (byte)0xd8, (byte)0x81, (byte)0xc6, (byte)0x34, (byte)0x12, (byte)0x00, (byte)0x00 };
public static final byte[] SPARC_CODE = new byte[] { (byte)0x80, (byte)0xa0, (byte)0x40, (byte)0x02, (byte)0x85, (byte)0xc2, (byte)0x60, (byte)0x08, (byte)0x85, (byte)0xe8, (byte)0x20, (byte)0x01, (byte)0x81, (byte)0xe8, (byte)0x00, (byte)0x00, (byte)0x90, (byte)0x10, (byte)0x20, (byte)0x01, (byte)0xd5, (byte)0xf6, (byte)0x10, (byte)0x16, (byte)0x21, (byte)0x00, (byte)0x00, (byte)0x0a, (byte)0x86, (byte)0x00, (byte)0x40, (byte)0x02, (byte)0x01, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x12, (byte)0xbf, (byte)0xff, (byte)0xff, (byte)0x10, (byte)0xbf, (byte)0xff, (byte)0xff, (byte)0xa0, (byte)0x02, (byte)0x00, (byte)0x09, (byte)0x0d, (byte)0xbf, (byte)0xff, (byte)0xff, (byte)0xd4, (byte)0x20, (byte)0x60, (byte)0x00, (byte)0xd4, (byte)0x4e, (byte)0x00, (byte)0x16, (byte)0x2a, (byte)0xc2, (byte)0x80, (byte)0x03 };
public static final byte[] SYSZ_CODE = new byte[] { (byte)0xed, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x1a, (byte)0x5a, (byte)0x0f, (byte)0x1f, (byte)0xff, (byte)0xc2, (byte)0x09, (byte)0x80, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x07, (byte)0xf7, (byte)0xeb, (byte)0x2a, (byte)0xff, (byte)0xff, (byte)0x7f, (byte)0x57, (byte)0xe3, (byte)0x01, (byte)0xff, (byte)0xff, (byte)0x7f, (byte)0x57, (byte)0xeb, (byte)0x00, (byte)0xf0, (byte)0x00, (byte)0x00, (byte)0x24, (byte)0xb2, (byte)0x4f, (byte)0x00, (byte)0x78 };
public static final byte[] SPARCV9_CODE = new byte[] { (byte)0x81, (byte)0xa8, (byte)0x0a, (byte)0x24, (byte)0x89, (byte)0xa0, (byte)0x10, (byte)0x20, (byte)0x89, (byte)0xa0, (byte)0x1a, (byte)0x60, (byte)0x89, (byte)0xa0, (byte)0x00, (byte)0xe0 };
public static final byte[] XCORE_CODE = new byte[] { (byte)0xfe, (byte)0x0f, (byte)0xfe, (byte)0x17, (byte)0x13, (byte)0x17, (byte)0xc6, (byte)0xfe, (byte)0xec, (byte)0x17, (byte)0x97, (byte)0xf8, (byte)0xec, (byte)0x4f, (byte)0x1f, (byte)0xfd, (byte)0xec, (byte)0x37, (byte)0x07, (byte)0xf2, (byte)0x45, (byte)0x5b, (byte)0xf9, (byte)0xfa, (byte)0x02, (byte)0x06, (byte)0x1b, (byte)0x10 };
static public void main(String argv[]) {
platform[] platforms = {
new platform(
Capstone.CS_ARCH_X86,
Capstone.CS_MODE_16,
Capstone.CS_OPT_SYNTAX_INTEL,
new byte[] { (byte)0x8d, (byte)0x4c, (byte)0x32, (byte)0x08, (byte)0x01, (byte)0xd8, (byte)0x81, (byte)0xc6, (byte)0x34, (byte)0x12, (byte)0x00, (byte)0x00 },
"X86 16bit (Intel syntax)"
),
new platform(
Capstone.CS_ARCH_X86,
Capstone.CS_MODE_32,
Capstone.CS_OPT_SYNTAX_ATT,
X86_CODE,
"X86 32bit (ATT syntax)"
),
new platform(
Capstone.CS_ARCH_X86,
Capstone.CS_MODE_32,
X86_CODE,
"X86 32 (Intel syntax)"
),
new platform(
Capstone.CS_ARCH_X86,
Capstone.CS_MODE_64,
new byte[] {(byte)0x55, (byte)0x48, (byte)0x8b, (byte)0x05, (byte)0xb8, (byte)0x13, (byte)0x00, (byte)0x00 },
"X86 64 (Intel syntax)"
),
new platform(
Capstone.CS_ARCH_ARM,
Capstone.CS_MODE_ARM,
new byte[] { (byte)0xED, (byte)0xFF, (byte)0xFF, (byte)0xEB, (byte)0x04, (byte)0xe0, (byte)0x2d, (byte)0xe5, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xe0, (byte)0x83, (byte)0x22, (byte)0xe5, (byte)0xf1, (byte)0x02, (byte)0x03, (byte)0x0e, (byte)0x00, (byte)0x00, (byte)0xa0, (byte)0xe3, (byte)0x02, (byte)0x30, (byte)0xc1, (byte)0xe7, (byte)0x00, (byte)0x00, (byte)0x53, (byte)0xe3 },
"ARM"
),
new platform(
Capstone.CS_ARCH_ARM,
Capstone.CS_MODE_THUMB,
new byte[] {(byte)0x4f, (byte)0xf0, (byte)0x00, (byte)0x01, (byte)0xbd, (byte)0xe8, (byte)0x00, (byte)0x88, (byte)0xd1, (byte)0xe8, (byte)0x00, (byte)0xf0 },
"THUMB-2"
),
new platform(
Capstone.CS_ARCH_ARM,
Capstone.CS_MODE_ARM,
new byte[] {(byte)0x10, (byte)0xf1, (byte)0x10, (byte)0xe7, (byte)0x11, (byte)0xf2, (byte)0x31, (byte)0xe7, (byte)0xdc, (byte)0xa1, (byte)0x2e, (byte)0xf3, (byte)0xe8, (byte)0x4e, (byte)0x62, (byte)0xf3 },
"ARM: Cortex-A15 + NEON"
),
new platform(
Capstone.CS_ARCH_ARM,
Capstone.CS_MODE_THUMB,
new byte[] {(byte)0x70, (byte)0x47, (byte)0xeb, (byte)0x46, (byte)0x83, (byte)0xb0, (byte)0xc9, (byte)0x68 },
"THUMB"
),
new platform(
Capstone.CS_ARCH_MIPS,
Capstone.CS_MODE_MIPS32 + Capstone.CS_MODE_BIG_ENDIAN,
new byte[] {(byte)0x0C, (byte)0x10, (byte)0x00, (byte)0x97, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x24, (byte)0x02, (byte)0x00, (byte)0x0c, (byte)0x8f, (byte)0xa2, (byte)0x00, (byte)0x00, (byte)0x34, (byte)0x21, (byte)0x34, (byte)0x56 },
"MIPS-32 (Big-endian)"
),
new platform(
Capstone.CS_ARCH_MIPS,
Capstone.CS_MODE_MIPS64+ Capstone.CS_MODE_LITTLE_ENDIAN,
new byte[] {(byte)0x56, (byte)0x34, (byte)0x21, (byte)0x34, (byte)0xc2, (byte)0x17, (byte)0x01, (byte)0x00 },
"MIPS-64-EL (Little-endian)"
),
new platform(
Capstone.CS_ARCH_ARM64,
Capstone.CS_MODE_ARM,
new byte [] { 0x21, 0x7c, 0x02, (byte)0x9b, 0x21, 0x7c, 0x00, 0x53, 0x00, 0x40, 0x21, 0x4b, (byte)0xe1, 0x0b, 0x40, (byte)0xb9 },
"ARM-64"
),
new platform (
Capstone.CS_ARCH_PPC,
Capstone.CS_MODE_BIG_ENDIAN,
PPC_CODE,
"PPC-64"
),
new platform (
Capstone.CS_ARCH_PPC,
Capstone.CS_MODE_BIG_ENDIAN,
Capstone.CS_OPT_SYNTAX_NOREGNAME,
PPC_CODE,
"PPC-64, print register with number only"
),
new platform (
Capstone.CS_ARCH_SPARC,
Capstone.CS_MODE_BIG_ENDIAN,
SPARC_CODE,
"Sparc"
),
new platform (
Capstone.CS_ARCH_SPARC,
Capstone.CS_MODE_BIG_ENDIAN + Capstone.CS_MODE_V9,
SPARCV9_CODE,
"SparcV9"
),
new platform (
Capstone.CS_ARCH_SYSZ,
0,
SYSZ_CODE,
"SystemZ"
),
new platform (
Capstone.CS_ARCH_XCORE,
0,
XCORE_CODE,
"XCore"
),
};
for (int j = 0; j < platforms.length; j++) {
System.out.println("****************");
System.out.println(String.format("Platform: %s", platforms[j].comment));
System.out.println(String.format("Code: %s", stringToHex(platforms[j].code)));
System.out.println("Disasm:");
Capstone cs = new Capstone(platforms[j].arch, platforms[j].mode);
if (platforms[j].syntax != 0)
cs.setSyntax(platforms[j].syntax);
Capstone.CsInsn[] all_insn = cs.disasm(platforms[j].code, 0x1000);
for (int i = 0; i < all_insn.length; i++) {
System.out.println(String.format("0x%x: \t%s\t%s", all_insn[i].address,
all_insn[i].mnemonic, all_insn[i].opStr));
}
System.out.printf("0x%x:\n\n", all_insn[all_insn.length-1].address + all_insn[all_insn.length-1].size);
// Close when done
cs.close();
}
}
}
+207
View File
@@ -0,0 +1,207 @@
// Capstone Java binding
/* M680X Backend by Wolfgang Schwotzer <wolfgang.schwotzer@gmx.net> 2017 */
import java.lang.*;
import capstone.Capstone;
import capstone.M680x;
import static capstone.M680x_const.*;
public class TestM680x {
static final String sAccess[] = {
"UNCHANGED", "READ", "WRITE", "READ | WRITE",
};
static final String M6800_CODE = "010936647f7410009010A410b6100039";
static final String M6801_CODE = "04053c3d389310ec10ed1039";
static final String M6805_CODE = "047f00172228002e0040425a708e979ca015ad00c31000da1234e57ffe";
static final String M6808_CODE = "31220035224510004b005110525e226265123472848586878a8b8c9495a710af109e607f9e6b7f009ed610009ee67f";
static final String HD6301_CODE = "6b100071100072101039";
static final String M6809_CODE = "0610191a551e0123e931063455a681a7897fffa69d1000a791a69f100011ac99100039A607A627A647A667A60FA610A680A681A682A683A684A685A686A6887FA68880A6897FFFA6898000A68BA68C10A68D1000A691A693A694A695A696A6987FA69880A6997FFFA6998000A69BA69C10A69D1000A69F1000";
static final String M6811_CODE = "0203127f100013990800147f02157f011e7f20008fcf18081830183c1867188c1000188f18ce100018ff10001aa37f1aac1aee7f1aef7fcdac7f";
static final String CPU12_CODE = "000401000c00800e008000111e100080003b4a1000044b01044f7f80008f1000b752b7b1a667a6fea6f71802e23039e21000180c30391000181118121000181900181e00183e183f00";
static final String HD6309_CODE = "0110106210107b101000cd499602d21030231038103b1053105d1130431011372510113812113923113b34118e100011af1011ab1011f68000";
static final String HCS08_CODE = "3210009eae9ece7f9ebe10009efe7f3e10009ef37f9610009eff7f82";
static byte[] hexString2Byte(String s) {
// from http://stackoverflow.com/questions/140131/convert-a-string-representation-of-a-hex-dump-to-a-byte-array-using-java
int len = s.length();
byte[] data = new byte[len / 2];
for (int i = 0; i < len; i += 2) {
data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
+ Character.digit(s.charAt(i+1), 16));
}
return data;
}
static public String stringToHexUc(byte[] code) {
StringBuilder buf = new StringBuilder(800);
for (byte ch: code) {
buf.append(String.format(" 0x%02x", ch));
}
return buf.toString();
}
static public String stringToHexShortUc(byte[] code) {
StringBuilder buf = new StringBuilder(800);
for (byte ch: code) {
buf.append(String.format("%02x", ch));
}
return buf.toString();
}
public static Capstone cs;
/*
private static String hex(int i) {
return Integer.toString(i, 16);
}
private static String hex(long i) {
return Long.toString(i, 16);
}
*/
public static void print_ins_detail(Capstone.CsInsn ins) {
String bytes = stringToHexShortUc(ins.bytes);
System.out.printf("0x%04x:\t%s\t%s\t%s\n", ins.address, bytes, ins.mnemonic, ins.opStr);
M680x.OpInfo operands = (M680x.OpInfo) ins.operands;
if (operands.op.length != 0) {
System.out.printf("\top_count: %d\n", operands.op.length);
for (int c = 0; c < operands.op.length; c++) {
M680x.Operand i = (M680x.Operand) operands.op[c];
if (i.type == M680X_OP_REGISTER) {
String comment = "";
if ((c == 0 && ((operands.flags & M680X_FIRST_OP_IN_MNEM) != 0)) ||
(c == 1 && ((operands.flags & M680X_SECOND_OP_IN_MNEM) != 0)))
comment = " (in mnemonic)";
System.out.printf("\t\toperands[%d].type: REGISTER = %s%s\n", c, ins.regName(i.value.reg), comment);
}
if (i.type == M680X_OP_CONSTANT)
System.out.printf("\t\toperands[%d].type: CONSTANT = %d\n", c, i.value.const_val);
if (i.type == M680X_OP_IMMEDIATE)
System.out.printf("\t\toperands[%d].type: IMMEDIATE = #%d\n", c, i.value.imm);
if (i.type == M680X_OP_DIRECT)
System.out.printf("\t\toperands[%d].type: DIRECT = 0x%02x\n", c, i.value.direct_addr);
if (i.type == M680X_OP_EXTENDED)
System.out.printf("\t\toperands[%d].type: EXTENDED %s = 0x%04x\n", c,
i.value.ext.indirect != 0 ? "INDIRECT" : "", i.value.ext.address);
if (i.type == M680X_OP_RELATIVE)
System.out.printf("\t\toperands[%d].type: RELATIVE = 0x%04x\n", c, i.value.rel.address );
if (i.type == M680X_OP_INDEXED) {
System.out.printf("\t\toperands[%d].type: INDEXED%s\n", c,
(i.value.idx.flags & M680X_IDX_INDIRECT) != 0 ? " INDIRECT" : "");
if (i.value.idx.base_reg != M680X_REG_INVALID) {
String regName = ins.regName(i.value.idx.base_reg);
if (regName != null)
System.out.printf("\t\t\tbase register: %s\n", regName);
}
if (i.value.idx.offset_reg != M680X_REG_INVALID) {
String regName = ins.regName(i.value.idx.offset_reg);
if (regName != null)
System.out.printf("\t\t\toffset register: %s\n", regName);
}
if ((i.value.idx.offset_bits != 0) &&
(i.value.idx.offset_reg == M680X_REG_INVALID) &&
(i.value.idx.inc_dec == 0)) {
System.out.printf("\t\t\toffset: %d\n", i.value.idx.offset);
if (i.value.idx.base_reg == M680X_REG_PC)
System.out.printf("\t\t\toffset address: 0x%04x\n", i.value.idx.offset_addr);
System.out.printf("\t\t\toffset bits: %d\n", i.value.idx.offset_bits);
}
if (i.value.idx.inc_dec != 0) {
String post_pre =
(i.value.idx.flags & M680X_IDX_POST_INC_DEC) != 0 ?
"post" : "pre";
String inc_dec =
i.value.idx.inc_dec > 0 ? "increment" : "decrement";
System.out.printf("\t\t\t%s %s: %d\n", post_pre, inc_dec,
Math.abs(i.value.idx.inc_dec));
}
}
if (i.size != 0)
System.out.printf("\t\t\tsize: %d\n", i.size);
if (i.access != Capstone.CS_AC_INVALID)
System.out.printf("\t\t\taccess: %s\n", sAccess[i.access]);
}
}
if (ins.regsRead.length > 0) {
System.out.printf("\tRegisters read:");
for (int c = 0; c < ins.regsRead.length; c++) {
System.out.printf(" %s", ins.regName(ins.regsRead[c]));
}
System.out.printf("\n");
}
if (ins.regsWrite.length > 0) {
System.out.printf("\tRegisters modified:");
for (int c = 0; c < ins.regsWrite.length; c++) {
System.out.printf(" %s", ins.regName(ins.regsWrite[c]));
}
System.out.printf("\n");
}
if (ins.groups.length > 0)
System.out.printf("\tgroups_count: %d\n", ins.groups.length);
}
public static void main(String argv[]) {
final TestBasic.platform[] all_tests = {
new TestBasic.platform(Capstone.CS_ARCH_M680X,
Capstone.CS_MODE_M680X_6301,
hexString2Byte(HD6301_CODE), "M680X_HD6301"),
new TestBasic.platform(Capstone.CS_ARCH_M680X,
Capstone.CS_MODE_M680X_6309,
hexString2Byte(HD6309_CODE), "M680X_HD6309"),
new TestBasic.platform(Capstone.CS_ARCH_M680X,
Capstone.CS_MODE_M680X_6800,
hexString2Byte(M6800_CODE), "M680X_M6800"),
new TestBasic.platform(Capstone.CS_ARCH_M680X,
Capstone.CS_MODE_M680X_6801,
hexString2Byte(M6801_CODE), "M680X_M6801"),
new TestBasic.platform(Capstone.CS_ARCH_M680X,
Capstone.CS_MODE_M680X_6805,
hexString2Byte(M6805_CODE), "M680X_M68HC05"),
new TestBasic.platform(Capstone.CS_ARCH_M680X,
Capstone.CS_MODE_M680X_6808,
hexString2Byte(M6808_CODE), "M680X_M68HC08"),
new TestBasic.platform(Capstone.CS_ARCH_M680X,
Capstone.CS_MODE_M680X_6809,
hexString2Byte(M6809_CODE), "M680X_M6809"),
new TestBasic.platform(Capstone.CS_ARCH_M680X,
Capstone.CS_MODE_M680X_6811,
hexString2Byte(M6811_CODE), "M680X_M68HC11"),
new TestBasic.platform(Capstone.CS_ARCH_M680X,
Capstone.CS_MODE_M680X_CPU12,
hexString2Byte(CPU12_CODE), "M680X_CPU12"),
new TestBasic.platform(Capstone.CS_ARCH_M680X,
Capstone.CS_MODE_M680X_HCS08,
hexString2Byte(HCS08_CODE), "M680X_HCS08"),
};
for (int i=0; i<all_tests.length; i++) {
TestBasic.platform test = all_tests[i];
System.out.println(new String(new char[20]).replace("\0", "*"));
System.out.println("Platform: " + test.comment);
System.out.println("Code: " + stringToHexUc(test.code));
System.out.println("Disasm:");
cs = new Capstone(test.arch, test.mode);
cs.setDetail(Capstone.CS_OPT_ON);
Capstone.CsInsn[] all_ins = cs.disasm(test.code, 0x1000);
for (int j = 0; j < all_ins.length; j++) {
print_ins_detail(all_ins[j]);
System.out.println();
}
// Close when done
cs.close();
}
}
}
+91
View File
@@ -0,0 +1,91 @@
// Capstone Java binding
// By Nguyen Anh Quynh & Dang Hoang Vu, 2013
import capstone.Capstone;
import capstone.Mips;
import static capstone.Mips_const.*;
public class TestMips {
static byte[] hexString2Byte(String s) {
// from http://stackoverflow.com/questions/140131/convert-a-string-representation-of-a-hex-dump-to-a-byte-array-using-java
int len = s.length();
byte[] data = new byte[len / 2];
for (int i = 0; i < len; i += 2) {
data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
+ Character.digit(s.charAt(i+1), 16));
}
return data;
}
static final String MIPS_CODE = "0C100097000000002402000c8fa2000034213456";
static final String MIPS_CODE2 = "56342134c2170100";
public static Capstone cs;
private static String hex(int i) {
return Integer.toString(i, 16);
}
private static String hex(long i) {
return Long.toString(i, 16);
}
public static void print_ins_detail(Capstone.CsInsn ins) {
System.out.printf("0x%x:\t%s\t%s\n", ins.address, ins.mnemonic, ins.opStr);
Mips.OpInfo operands = (Mips.OpInfo) ins.operands;
if (operands.op.length != 0) {
System.out.printf("\top_count: %d\n", operands.op.length);
for (int c=0; c<operands.op.length; c++) {
Mips.Operand i = (Mips.Operand) operands.op[c];
String imm = hex(i.value.imm);
if (i.type == MIPS_OP_REG)
System.out.printf("\t\toperands[%d].type: REG = %s\n", c, ins.regName(i.value.reg));
if (i.type == MIPS_OP_IMM)
System.out.printf("\t\toperands[%d].type: IMM = 0x%x\n", c, i.value.imm);
if (i.type == MIPS_OP_MEM) {
System.out.printf("\t\toperands[%d].type: MEM\n",c);
String base = ins.regName(i.value.mem.base);
if (base != null)
System.out.printf("\t\t\toperands[%d].mem.base: REG = %s\n", c, base);
if (i.value.mem.disp != 0)
System.out.printf("\t\t\toperands[%d].mem.disp: %s\n", c, hex(i.value.mem.disp));
}
}
}
}
public static void main(String argv[]) {
final TestBasic.platform[] all_tests = {
new TestBasic.platform(Capstone.CS_ARCH_MIPS, Capstone.CS_MODE_MIPS32 + Capstone.CS_MODE_BIG_ENDIAN, hexString2Byte(MIPS_CODE), "MIPS-32 (Big-endian)"),
new TestBasic.platform(Capstone.CS_ARCH_MIPS, Capstone.CS_MODE_MIPS64 + Capstone.CS_MODE_LITTLE_ENDIAN, hexString2Byte(MIPS_CODE2), "MIPS-64-EL (Little-endian)"),
};
for (int i=0; i<all_tests.length; i++) {
TestBasic.platform test = all_tests[i];
System.out.println(new String(new char[16]).replace("\0", "*"));
System.out.println("Platform: " + test.comment);
System.out.println("Code: " + TestBasic.stringToHex(test.code));
System.out.println("Disasm:");
cs = new Capstone(test.arch, test.mode);
cs.setDetail(Capstone.CS_OPT_ON);
Capstone.CsInsn[] all_ins = cs.disasm(test.code, 0x1000);
for (int j = 0; j < all_ins.length; j++) {
print_ins_detail(all_ins[j]);
System.out.println();
}
System.out.printf("0x%x:\n\n", all_ins[all_ins.length-1].address + all_ins[all_ins.length-1].size);
// Close when done
cs.close();
}
}
}
+96
View File
@@ -0,0 +1,96 @@
// Capstone Java binding
// By Nguyen Anh Quynh & Dang Hoang Vu, 2013
import capstone.Capstone;
import capstone.Ppc;
import static capstone.Ppc_const.*;
public class TestPpc {
static byte[] hexString2Byte(String s) {
// from http://stackoverflow.com/questions/140131/convert-a-string-representation-of-a-hex-dump-to-a-byte-array-using-java
int len = s.length();
byte[] data = new byte[len / 2];
for (int i = 0; i < len; i += 2) {
data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
+ Character.digit(s.charAt(i+1), 16));
}
return data;
}
static final String PPC_CODE = "80200000803f00001043230ed04400804c4322022d0300807c4320147c4320934f2000214cc8002140820014";
public static Capstone cs;
private static String hex(int i) {
return Integer.toString(i, 16);
}
private static String hex(long i) {
return Long.toString(i, 16);
}
public static void print_ins_detail(Capstone.CsInsn ins) {
System.out.printf("0x%x:\t%s\t%s\n", ins.address, ins.mnemonic, ins.opStr);
Ppc.OpInfo operands = (Ppc.OpInfo) ins.operands;
if (operands.op.length != 0) {
System.out.printf("\top_count: %d\n", operands.op.length);
for (int c=0; c<operands.op.length; c++) {
Ppc.Operand i = (Ppc.Operand) operands.op[c];
if (i.type == PPC_OP_REG)
System.out.printf("\t\toperands[%d].type: REG = %s\n", c, ins.regName(i.value.reg));
if (i.type == PPC_OP_IMM)
System.out.printf("\t\toperands[%d].type: IMM = 0x%x\n", c, i.value.imm);
if (i.type == PPC_OP_MEM) {
System.out.printf("\t\toperands[%d].type: MEM\n", c);
if (i.value.mem.base != PPC_REG_INVALID)
System.out.printf("\t\t\toperands[%d].mem.base: REG = %s\n", c, ins.regName(i.value.mem.base));
if (i.value.mem.disp != 0)
System.out.printf("\t\t\toperands[%d].mem.disp: 0x%x\n", c, i.value.mem.disp);
}
}
}
if (operands.bc != 0)
System.out.printf("\tBranch code: %d\n", operands.bc);
if (operands.bh != 0)
System.out.printf("\tBranch hint: %d\n", operands.bh);
if (operands.updateCr0)
System.out.printf("\tUpdate-CR0: True\n");
}
public static void main(String argv[]) {
final TestBasic.platform[] all_tests = {
new TestBasic.platform(Capstone.CS_ARCH_PPC, Capstone.CS_MODE_BIG_ENDIAN, hexString2Byte(PPC_CODE), "PPC-64"),
};
for (int i=0; i<all_tests.length; i++) {
TestBasic.platform test = all_tests[i];
System.out.println(new String(new char[16]).replace("\0", "*"));
System.out.println("Platform: " + test.comment);
System.out.println("Code: " + TestBasic.stringToHex(test.code));
System.out.println("Disasm:");
cs = new Capstone(test.arch, test.mode);
cs.setDetail(Capstone.CS_OPT_ON);
Capstone.CsInsn[] all_ins = cs.disasm(test.code, 0x1000);
for (int j = 0; j < all_ins.length; j++) {
print_ins_detail(all_ins[j]);
System.out.println();
}
System.out.printf("0x%x:\n\n", (all_ins[all_ins.length-1].address + all_ins[all_ins.length-1].size));
// Close when done
cs.close();
}
}
}
+97
View File
@@ -0,0 +1,97 @@
// Capstone Java binding
// By Nguyen Anh Quynh & Dang Hoang Vu, 2013-2014
import capstone.Capstone;
import capstone.Sparc;
import static capstone.Sparc_const.*;
public class TestSparc {
static byte[] hexString2Byte(String s) {
// from http://stackoverflow.com/questions/140131/convert-a-string-representation-of-a-hex-dump-to-a-byte-array-using-java
int len = s.length();
byte[] data = new byte[len / 2];
for (int i = 0; i < len; i += 2) {
data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
+ Character.digit(s.charAt(i+1), 16));
}
return data;
}
static final String SPARC_CODE = "80a0400285c2600885e8200181e8000090102001d5f610162100000a860040020100000012bfffff10bfffffa00200090dbfffffd4206000d44e00162ac28003";
static final String SPARCV9_CODE = "81a80a2489a0102089a01a6089a000e0";
public static Capstone cs;
private static String hex(int i) {
return Integer.toString(i, 16);
}
private static String hex(long i) {
return Long.toString(i, 16);
}
public static void print_ins_detail(Capstone.CsInsn ins) {
System.out.printf("0x%x:\t%s\t%s\n", ins.address, ins.mnemonic, ins.opStr);
Sparc.OpInfo operands = (Sparc.OpInfo) ins.operands;
if (operands.op.length != 0) {
System.out.printf("\top_count: %d\n", operands.op.length);
for (int c=0; c<operands.op.length; c++) {
Sparc.Operand i = (Sparc.Operand) operands.op[c];
if (i.type == SPARC_OP_REG)
System.out.printf("\t\toperands[%d].type: REG = %s\n", c, ins.regName(i.value.reg));
if (i.type == SPARC_OP_IMM)
System.out.printf("\t\toperands[%d].type: IMM = 0x%x\n", c, i.value.imm);
if (i.type == SPARC_OP_MEM) {
System.out.printf("\t\toperands[%d].type: MEM\n", c);
if (i.value.mem.base != SPARC_REG_INVALID)
System.out.printf("\t\t\toperands[%d].mem.base: REG = %s\n", c, ins.regName(i.value.mem.base));
if (i.value.mem.index != SPARC_REG_INVALID)
System.out.printf("\t\t\toperands[%d].mem.index: REG = %s\n", c, ins.regName(i.value.mem.index));
if (i.value.mem.disp != 0)
System.out.printf("\t\t\toperands[%d].mem.disp: 0x%x\n", c, i.value.mem.disp);
}
}
}
if (operands.cc != 0)
System.out.printf("\tCode condition: %d\n", operands.cc);
if (operands.hint != 0)
System.out.printf("\tHint code: %d\n", operands.hint);
}
public static void main(String argv[]) {
final TestBasic.platform[] all_tests = {
new TestBasic.platform(Capstone.CS_ARCH_SPARC, Capstone.CS_MODE_BIG_ENDIAN, hexString2Byte(SPARC_CODE), "Sparc"),
new TestBasic.platform(Capstone.CS_ARCH_SPARC, Capstone.CS_MODE_BIG_ENDIAN + Capstone.CS_MODE_V9, hexString2Byte(SPARCV9_CODE), "SparcV9"),
};
for (int i=0; i<all_tests.length; i++) {
TestBasic.platform test = all_tests[i];
System.out.println(new String(new char[16]).replace("\0", "*"));
System.out.println("Platform: " + test.comment);
System.out.println("Code: " + TestBasic.stringToHex(test.code));
System.out.println("Disasm:");
cs = new Capstone(test.arch, test.mode);
cs.setDetail(Capstone.CS_OPT_ON);
Capstone.CsInsn[] all_ins = cs.disasm(test.code, 0x1000);
for (int j = 0; j < all_ins.length; j++) {
print_ins_detail(all_ins[j]);
System.out.println();
}
System.out.printf("0x%x:\n\n", (all_ins[all_ins.length-1].address + all_ins[all_ins.length-1].size));
// Close when done
cs.close();
}
}
}
+96
View File
@@ -0,0 +1,96 @@
// Capstone Java binding
// By Nguyen Anh Quynh & Dang Hoang Vu, 2013-2014
import capstone.Capstone;
import capstone.Systemz;
import static capstone.Sysz_const.*;
public class TestSystemz {
static byte[] hexString2Byte(String s) {
// from http://stackoverflow.com/questions/140131/convert-a-string-representation-of-a-hex-dump-to-a-byte-array-using-java
int len = s.length();
byte[] data = new byte[len / 2];
for (int i = 0; i < len; i += 2) {
data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
+ Character.digit(s.charAt(i+1), 16));
}
return data;
}
static final String SYSZ_CODE = "ed000000001a5a0f1fffc2098000000007f7eb2affff7f57e301ffff7f57eb00f0000024b24f0078ec180000c17f";
public static Capstone cs;
private static String hex(int i) {
return Integer.toString(i, 16);
}
private static String hex(long i) {
return Long.toString(i, 16);
}
public static void print_ins_detail(Capstone.CsInsn ins) {
System.out.printf("0x%x:\t%s\t%s\n", ins.address, ins.mnemonic, ins.opStr);
Systemz.OpInfo operands = (Systemz.OpInfo) ins.operands;
if (operands.op.length != 0) {
System.out.printf("\top_count: %d\n", operands.op.length);
for (int c=0; c<operands.op.length; c++) {
Systemz.Operand i = (Systemz.Operand) operands.op[c];
if (i.type == SYSZ_OP_REG)
System.out.printf("\t\toperands[%d].type: REG = %s\n", c, ins.regName(i.value.reg));
if (i.type == SYSZ_OP_ACREG)
System.out.printf("\t\toperands[%d].type: ACREG = %s\n", c, i.value.reg);
if (i.type == SYSZ_OP_IMM)
System.out.printf("\t\toperands[%d].type: IMM = 0x%x\n", c, i.value.imm);
if (i.type == SYSZ_OP_MEM) {
System.out.printf("\t\toperands[%d].type: MEM\n", c);
if (i.value.mem.base != SYSZ_REG_INVALID)
System.out.printf("\t\t\toperands[%d].mem.base: REG = %s\n", c, ins.regName(i.value.mem.base));
if (i.value.mem.index != SYSZ_REG_INVALID)
System.out.printf("\t\t\toperands[%d].mem.index: REG = %s\n", c, ins.regName(i.value.mem.index));
if (i.value.mem.length != 0)
System.out.printf("\t\t\toperands[%d].mem.length: 0x%x\n", c, i.value.mem.disp);
if (i.value.mem.disp != 0)
System.out.printf("\t\t\toperands[%d].mem.disp: 0x%x\n", c, i.value.mem.disp);
}
}
}
if (operands.cc != 0)
System.out.printf("\tConditional code: %d\n", operands.cc);
}
public static void main(String argv[]) {
final TestBasic.platform[] all_tests = {
new TestBasic.platform(Capstone.CS_ARCH_SYSZ, 0, hexString2Byte(SYSZ_CODE), "SystemZ"),
};
for (int i=0; i<all_tests.length; i++) {
TestBasic.platform test = all_tests[i];
System.out.println(new String(new char[16]).replace("\0", "*"));
System.out.println("Platform: " + test.comment);
System.out.println("Code: " + TestBasic.stringToHex(test.code));
System.out.println("Disasm:");
cs = new Capstone(test.arch, test.mode);
cs.setDetail(Capstone.CS_OPT_ON);
Capstone.CsInsn[] all_ins = cs.disasm(test.code, 0x1000);
for (int j = 0; j < all_ins.length; j++) {
print_ins_detail(all_ins[j]);
System.out.println();
}
System.out.printf("0x%x:\n\n", (all_ins[all_ins.length-1].address + all_ins[all_ins.length-1].size));
// Close when done
cs.close();
}
}
}
+227
View File
@@ -0,0 +1,227 @@
// Capstone Java binding
// By Nguyen Anh Quynh & Dang Hoang Vu, 2013
import capstone.Capstone;
import static capstone.Capstone.CS_AC_READ;
import static capstone.Capstone.CS_AC_WRITE;
import capstone.Capstone.CsRegsAccess;
import capstone.X86;
import static capstone.X86_const.*;
public class TestX86 {
static byte[] hexString2Byte(String s) {
// from http://stackoverflow.com/questions/140131/convert-a-string-representation-of-a-hex-dump-to-a-byte-array-using-java
int len = s.length();
byte[] data = new byte[len / 2];
for (int i = 0; i < len; i += 2) {
data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
+ Character.digit(s.charAt(i+1), 16));
}
return data;
}
static final String X86_CODE64 = "55488b05b8130000";
static final String X86_CODE16 = "8d4c320801d881c6341200000523010000368b849123010000418d8439896700008d8789670000b4c6";
static final String X86_CODE32 = "8d4c320801d881c6341200000523010000368b849123010000418d8439896700008d8789670000b4c6";
public static Capstone cs;
private static String hex(int i) {
return Integer.toString(i, 16);
}
private static String hex(long i) {
return Long.toString(i, 16);
}
private static String array2hex(byte[] arr) {
String ret = "";
for (int i=0 ;i<arr.length; i++)
ret += String.format("0x%02x ", arr[i]);
return ret;
}
public static void print_ins_detail(Capstone.CsInsn ins) {
System.out.printf("0x%x:\t%s\t%s\n", ins.address, ins.mnemonic, ins.opStr);
X86.OpInfo operands = (X86.OpInfo) ins.operands;
System.out.printf("\tPrefix: %s\n", array2hex(operands.prefix));
System.out.printf("\tOpcode: %s\n", array2hex(operands.opcode));
// print REX prefix (non-zero value is relevant for x86_64)
System.out.printf("\trex: 0x%x\n", operands.rex);
// print address size
System.out.printf("\taddr_size: %d\n", operands.addrSize);
// print modRM byte
System.out.printf("\tmodrm: 0x%x\n", operands.modrm);
// print modRM offset
if (operands.encoding.modrmOffset != 0) {
System.out.printf("\tmodrm offset: 0x%x\n", operands.encoding.modrmOffset);
}
// print displacement value
System.out.printf("\tdisp: 0x%x\n", operands.disp);
// print displacement offset
if (operands.encoding.dispOffset != 0) {
System.out.printf("\tdisp offset: 0x%x\n", operands.encoding.dispOffset);
}
//print displacement size
if (operands.encoding.dispSize != 0) {
System.out.printf("\tdisp size: 0x%x\n", operands.encoding.dispSize);
}
// SIB is not available in 16-bit mode
if ( (cs.mode & Capstone.CS_MODE_16) == 0) {
// print SIB byte
System.out.printf("\tsib: 0x%x\n", operands.sib);
if (operands.sib != 0)
System.out.printf("\t\tsib_base: %s\n\t\tsib_index: %s\n\t\tsib_scale: %d\n",
ins.regName(operands.sibBase), ins.regName(operands.sibIndex), operands.sibScale);
}
if (operands.xopCC != 0)
System.out.printf("\txop_cc: %u\n", operands.xopCC);
if (operands.sseCC != 0)
System.out.printf("\tsse_cc: %u\n", operands.sseCC);
if (operands.avxCC != 0)
System.out.printf("\tavx_cc: %u\n", operands.avxCC);
if (operands.avxSae)
System.out.printf("\tavx_sae: TRUE\n");
if (operands.avxRm != 0)
System.out.printf("\tavx_rm: %u\n", operands.avxRm);
int count = ins.opCount(X86_OP_IMM);
if (count > 0) {
System.out.printf("\timm_count: %d\n", count);
System.out.printf("\timm offset: 0x%x\n", operands.encoding.immOffset);
System.out.printf("\timm size: 0x%x\n", operands.encoding.immSize);
for (int i=0; i<count; i++) {
int index = ins.opIndex(X86_OP_IMM, i + 1);
System.out.printf("\t\timms[%d]: 0x%x\n", i+1, (operands.op[index].value.imm));
}
}
if (operands.op.length != 0) {
System.out.printf("\top_count: %d\n", operands.op.length);
for (int c=0; c<operands.op.length; c++) {
X86.Operand i = (X86.Operand) operands.op[c];
String imm = hex(i.value.imm);
if (i.type == X86_OP_REG)
System.out.printf("\t\toperands[%d].type: REG = %s\n", c, ins.regName(i.value.reg));
if (i.type == X86_OP_IMM)
System.out.printf("\t\toperands[%d].type: IMM = 0x%x\n", c, i.value.imm);
if (i.type == X86_OP_MEM) {
System.out.printf("\t\toperands[%d].type: MEM\n",c);
String segment = ins.regName(i.value.mem.segment);
String base = ins.regName(i.value.mem.base);
String index = ins.regName(i.value.mem.index);
if (segment != null)
System.out.printf("\t\t\toperands[%d].mem.segment: REG = %s\n", c, segment);
if (base != null)
System.out.printf("\t\t\toperands[%d].mem.base: REG = %s\n", c, base);
if (index != null)
System.out.printf("\t\t\toperands[%d].mem.index: REG = %s\n", c, index);
if (i.value.mem.scale != 1)
System.out.printf("\t\t\toperands[%d].mem.scale: %d\n", c, i.value.mem.scale);
if (i.value.mem.disp != 0)
System.out.printf("\t\t\toperands[%d].mem.disp: 0x%x\n", c, i.value.mem.disp);
}
// AVX broadcast type
if (i.avx_bcast != X86_AVX_BCAST_INVALID) {
System.out.printf("\t\toperands[%d].avx_bcast: %d\n", c, i.avx_bcast);
}
// AVX zero opmask {z}
if (i.avx_zero_opmask) {
System.out.printf("\t\toperands[%d].avx_zero_opmask: TRUE\n", c);
}
System.out.printf("\t\toperands[%d].size: %d\n", c, i.size);
switch(i.access) {
case CS_AC_READ:
System.out.printf("\t\toperands[%d].access: READ\n", c);
break;
case CS_AC_WRITE:
System.out.printf("\t\toperands[%d].access: WRITE\n", c);
break;
case CS_AC_READ | CS_AC_WRITE:
System.out.printf("\t\toperands[%d].access: READ | WRITE\n", c);
break;
}
}
// Print out all registers accessed by this instruction (either implicit or explicit)
CsRegsAccess regsAccess = ins.regsAccess();
if (regsAccess != null) {
short[] regsRead = regsAccess.regsRead;
short[] regsWrite = regsAccess.regsWrite;
if (regsRead.length > 0) {
System.out.printf("\tRegisters read:");
for (int i = 0; i < regsRead.length; i++) {
System.out.printf(" %s", ins.regName(regsRead[i]));
}
System.out.print("\n");
}
if (regsWrite.length > 0) {
System.out.printf("\tRegister modified:");
for (int i = 0; i < regsWrite.length; i++) {
System.out.printf(" %s", ins.regName(regsWrite[i]));
}
System.out.print("\n");
}
}
}
}
public static void main(String argv[]) {
final TestBasic.platform[] all_tests = {
new TestBasic.platform(Capstone.CS_ARCH_X86, Capstone.CS_MODE_16, hexString2Byte(X86_CODE16), "X86 16bit (Intel syntax)"),
new TestBasic.platform(Capstone.CS_ARCH_X86, Capstone.CS_MODE_32, Capstone.CS_OPT_SYNTAX_ATT, hexString2Byte(X86_CODE32), "X86 32 (AT&T syntax)"),
new TestBasic.platform(Capstone.CS_ARCH_X86, Capstone.CS_MODE_32, hexString2Byte(X86_CODE32), "X86 32 (Intel syntax)"),
new TestBasic.platform(Capstone.CS_ARCH_X86, Capstone.CS_MODE_64, hexString2Byte(X86_CODE64), "X86 64 (Intel syntax)"),
};
for (int i=0; i<all_tests.length; i++) {
TestBasic.platform test = all_tests[i];
System.out.println(new String(new char[16]).replace("\0", "*"));
System.out.println("Platform: " + test.comment);
System.out.println("Code: " + TestBasic.stringToHex(test.code));
System.out.println("Disasm:");
cs = new Capstone(test.arch, test.mode);
cs.setDetail(Capstone.CS_OPT_ON);
if (test.syntax != 0) {
cs.setSyntax(test.syntax);
}
Capstone.CsInsn[] all_ins = cs.disasm(test.code, 0x1000);
for (int j = 0; j < all_ins.length; j++) {
print_ins_detail(all_ins[j]);
System.out.println();
}
System.out.printf("0x%x:\n\n", all_ins[all_ins.length-1].address + all_ins[all_ins.length-1].size);
// Close when done
cs.close();
}
}
}
+89
View File
@@ -0,0 +1,89 @@
// Capstone Java binding
// By Nguyen Anh Quynh & Dang Hoang Vu, 2013-2014
import capstone.Capstone;
import capstone.Xcore;
import static capstone.Xcore_const.*;
public class TestXcore {
static byte[] hexString2Byte(String s) {
// from http://stackoverflow.com/questions/140131/convert-a-string-representation-of-a-hex-dump-to-a-byte-array-using-java
int len = s.length();
byte[] data = new byte[len / 2];
for (int i = 0; i < len; i += 2) {
data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
+ Character.digit(s.charAt(i+1), 16));
}
return data;
}
static final String XCORE_CODE = "fe0ffe171317c6feec1797f8ec4f1ffdec3707f2455bf9fa02061b1009fdeca7";
public static Capstone cs;
private static String hex(int i) {
return Integer.toString(i, 16);
}
private static String hex(long i) {
return Long.toString(i, 16);
}
public static void print_ins_detail(Capstone.CsInsn ins) {
System.out.printf("0x%x:\t%s\t%s\n", ins.address, ins.mnemonic, ins.opStr);
Xcore.OpInfo operands = (Xcore.OpInfo) ins.operands;
if (operands.op.length != 0) {
System.out.printf("\top_count: %d\n", operands.op.length);
for (int c=0; c<operands.op.length; c++) {
Xcore.Operand i = (Xcore.Operand) operands.op[c];
if (i.type == XCORE_OP_REG)
System.out.printf("\t\toperands[%d].type: REG = %s\n", c, ins.regName(i.value.reg));
if (i.type == XCORE_OP_IMM)
System.out.printf("\t\toperands[%d].type: IMM = 0x%x\n", c, i.value.imm);
if (i.type == XCORE_OP_MEM) {
System.out.printf("\t\toperands[%d].type: MEM\n", c);
if (i.value.mem.base != XCORE_REG_INVALID)
System.out.printf("\t\t\toperands[%d].mem.base: REG = %s\n", c, ins.regName(i.value.mem.base));
if (i.value.mem.index != XCORE_REG_INVALID)
System.out.printf("\t\t\toperands[%d].mem.index: REG = %s\n", c, ins.regName(i.value.mem.index));
if (i.value.mem.disp != 0)
System.out.printf("\t\t\toperands[%d].mem.disp: 0x%x\n", c, i.value.mem.disp);
if (i.value.mem.direct != 1)
System.out.printf("\t\t\toperands[%d].mem.direct: -1\n", c);
}
}
}
}
public static void main(String argv[]) {
final TestBasic.platform[] all_tests = {
new TestBasic.platform(Capstone.CS_ARCH_XCORE, Capstone.CS_MODE_BIG_ENDIAN, hexString2Byte(XCORE_CODE), "XCore"),
};
for (int i=0; i<all_tests.length; i++) {
TestBasic.platform test = all_tests[i];
System.out.println(new String(new char[16]).replace("\0", "*"));
System.out.println("Platform: " + test.comment);
System.out.println("Code: " + TestBasic.stringToHex(test.code));
System.out.println("Disasm:");
cs = new Capstone(test.arch, test.mode);
cs.setDetail(Capstone.CS_OPT_ON);
Capstone.CsInsn[] all_ins = cs.disasm(test.code, 0x1000);
for (int j = 0; j < all_ins.length; j++) {
print_ins_detail(all_ins[j]);
System.out.println();
}
System.out.printf("0x%x:\n\n", (all_ins[all_ins.length-1].address + all_ins[all_ins.length-1].size));
// Close when done
cs.close();
}
}
}
+153
View File
@@ -0,0 +1,153 @@
// Capstone Java binding
// By Nguyen Anh Quynh & Dang Hoang Vu, 2013
package capstone;
import com.sun.jna.Structure;
import com.sun.jna.Union;
import java.util.List;
import java.util.Arrays;
import static capstone.Arm_const.*;
public class Arm {
public static class MemType extends Structure {
public int base;
public int index;
public int scale;
public int disp;
public int lshift;
@Override
public List getFieldOrder() {
return Arrays.asList("base", "index", "scale", "disp", "lshift");
}
}
public static class OpValue extends Union {
public int reg;
public int imm;
public double fp;
public MemType mem;
public int setend;
@Override
public List getFieldOrder() {
return Arrays.asList("reg", "imm", "fp", "mem", "setend");
}
}
public static class OpShift extends Structure {
public int type;
public int value;
@Override
public List getFieldOrder() {
return Arrays.asList("type","value");
}
}
public static class Operand extends Structure {
public int vector_index;
public OpShift shift;
public int type;
public OpValue value;
public boolean subtracted;
public byte access;
public byte neon_lane;
public void read() {
readField("vector_index");
readField("type");
if (type == ARM_OP_MEM)
value.setType(MemType.class);
if (type == ARM_OP_FP)
value.setType(Double.TYPE);
if (type == ARM_OP_PIMM || type == ARM_OP_IMM || type == ARM_OP_CIMM)
value.setType(Integer.TYPE);
if (type == ARM_OP_REG)
value.setType(Integer.TYPE);
if (type == ARM_OP_INVALID)
return;
readField("value");
readField("shift");
readField("subtracted");
readField("access");
readField("neon_lane");
}
@Override
public List getFieldOrder() {
return Arrays.asList("vector_index", "shift", "type", "value", "subtracted", "access", "neon_lane");
}
}
public static class UnionOpInfo extends Capstone.UnionOpInfo {
public boolean usermode;
public int vector_size;
public int vector_data;
public int cps_mode;
public int cps_flag;
public int cc;
public byte update_flags;
public byte writeback;
public int mem_barrier;
public byte op_count;
public Operand [] op;
public UnionOpInfo() {
op = new Operand[36];
}
public void read() {
readField("usermode");
readField("vector_size");
readField("vector_data");
readField("cps_mode");
readField("cps_flag");
readField("cc");
readField("update_flags");
readField("writeback");
readField("mem_barrier");
readField("op_count");
op = new Operand[op_count];
if (op_count != 0)
readField("op");
}
@Override
public List getFieldOrder() {
return Arrays.asList("usermode", "vector_size", "vector_data",
"cps_mode", "cps_flag", "cc", "update_flags", "writeback", "mem_barrier", "op_count", "op");
}
}
public static class OpInfo extends Capstone.OpInfo {
public boolean usermode;
public int vectorSize;
public int vectorData;
public int cpsMode;
public int cpsFlag;
public int cc;
public boolean updateFlags;
public boolean writeback;
public int memBarrier;
public Operand [] op = null;
public OpInfo(UnionOpInfo op_info) {
usermode = op_info.usermode;
vectorSize = op_info.vector_size;
vectorData = op_info.vector_data;
cpsMode = op_info.cps_mode;
cpsFlag = op_info.cps_flag;
cc = op_info.cc;
updateFlags = (op_info.update_flags > 0);
writeback = (op_info.writeback > 0);
memBarrier = op_info.mem_barrier;
op = op_info.op;
}
}
}
+127
View File
@@ -0,0 +1,127 @@
// Capstone Java binding
// By Nguyen Anh Quynh & Dang Hoang Vu, 2013
package capstone;
import com.sun.jna.Structure;
import com.sun.jna.Union;
import java.util.List;
import java.util.Arrays;
import static capstone.Arm64_const.*;
public class Arm64 {
public static class MemType extends Structure {
public int base;
public int index;
public int disp;
@Override
public List getFieldOrder() {
return Arrays.asList("base", "index", "disp");
}
}
public static class OpValue extends Union {
public int reg;
public long imm;
public double fp;
public MemType mem;
public int pstate;
public int sys;
public int prefetch;
public int barrier;
@Override
public List getFieldOrder() {
return Arrays.asList("reg", "imm", "fp", "mem", "pstate", "sys", "prefetch", "barrier");
}
}
public static class OpShift extends Structure {
public int type;
public int value;
@Override
public List getFieldOrder() {
return Arrays.asList("type","value");
}
}
public static class Operand extends Structure {
public int vector_index;
public int vas;
public OpShift shift;
public int ext;
public int type;
public OpValue value;
public byte access;
public void read() {
readField("type");
if (type == ARM64_OP_MEM)
value.setType(MemType.class);
if (type == ARM64_OP_FP)
value.setType(Double.TYPE);
if (type == ARM64_OP_IMM || type == ARM64_OP_CIMM || type == ARM64_OP_REG || type == ARM64_OP_REG_MRS || type == ARM64_OP_REG_MSR || type == ARM64_OP_PSTATE || type == ARM64_OP_SYS || type == ARM64_OP_PREFETCH || type == ARM64_OP_BARRIER)
value.setType(Integer.TYPE);
if (type == ARM64_OP_INVALID)
return;
readField("value");
readField("ext");
readField("shift");
readField("vas");
readField("vector_index");
readField("access");
}
@Override
public List getFieldOrder() {
return Arrays.asList("vector_index", "vas", "shift", "ext", "type", "value", "access");
}
}
public static class UnionOpInfo extends Capstone.UnionOpInfo {
public int cc;
public byte _update_flags;
public byte _writeback;
public byte op_count;
public Operand [] op;
public UnionOpInfo() {
op = new Operand[8];
}
public void read() {
readField("cc");
readField("_update_flags");
readField("_writeback");
readField("op_count");
op = new Operand[op_count];
if (op_count != 0)
readField("op");
}
@Override
public List getFieldOrder() {
return Arrays.asList("cc", "_update_flags", "_writeback", "op_count", "op");
}
}
public static class OpInfo extends Capstone.OpInfo {
public int cc;
public boolean updateFlags;
public boolean writeback;
public Operand [] op = null;
public OpInfo(UnionOpInfo op_info) {
cc = op_info.cc;
updateFlags = (op_info._update_flags > 0);
writeback = (op_info._writeback > 0);
op = op_info.op;
}
}
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+549
View File
@@ -0,0 +1,549 @@
// Capstone Java binding
// By Nguyen Anh Quynh & Dang Hoang Vu, 2013
package capstone;
import com.sun.jna.Library;
import com.sun.jna.Memory;
import com.sun.jna.Native;
import com.sun.jna.NativeLong;
import com.sun.jna.ptr.ByteByReference;
import com.sun.jna.ptr.NativeLongByReference;
import com.sun.jna.Structure;
import com.sun.jna.Union;
import com.sun.jna.Pointer;
import com.sun.jna.ptr.PointerByReference;
import com.sun.jna.ptr.IntByReference;
import java.util.List;
import java.util.Arrays;
import java.lang.RuntimeException;
public class Capstone {
protected static abstract class OpInfo {};
protected static abstract class UnionOpInfo extends Structure {};
public static class UnionArch extends Union {
public static class ByValue extends UnionArch implements Union.ByValue {};
public Arm.UnionOpInfo arm;
public Arm64.UnionOpInfo arm64;
public X86.UnionOpInfo x86;
public Mips.UnionOpInfo mips;
public Ppc.UnionOpInfo ppc;
public Sparc.UnionOpInfo sparc;
public Systemz.UnionOpInfo sysz;
public Xcore.UnionOpInfo xcore;
public M680x.UnionOpInfo m680x;
}
protected static class _cs_insn extends Structure {
// instruction ID.
public int id;
// instruction address.
public long address;
// instruction size.
public short size;
// machine bytes of instruction.
public byte[] bytes;
// instruction mnemonic. NOTE: irrelevant for diet engine.
public byte[] mnemonic;
// instruction operands. NOTE: irrelevant for diet engine.
public byte[] op_str;
// detail information of instruction.
public _cs_detail.ByReference cs_detail;
public _cs_insn() {
bytes = new byte[24];
mnemonic = new byte[32];
op_str = new byte[160];
java.util.Arrays.fill(mnemonic, (byte) 0);
java.util.Arrays.fill(op_str, (byte) 0);
}
public _cs_insn(Pointer p) {
this();
useMemory(p);
read();
}
@Override
public List getFieldOrder() {
return Arrays.asList("id", "address", "size", "bytes", "mnemonic", "op_str", "cs_detail");
}
}
protected static class _cs_detail extends Structure {
public static class ByReference extends _cs_detail implements Structure.ByReference {};
// list of all implicit registers being read.
public short[] regs_read = new short[16];
public byte regs_read_count;
// list of all implicit registers being written.
public short[] regs_write = new short[20];
public byte regs_write_count;
// list of semantic groups this instruction belongs to.
public byte[] groups = new byte[16];
public byte groups_count;
public UnionArch arch;
@Override
public List getFieldOrder() {
return Arrays.asList("regs_read", "regs_read_count", "regs_write", "regs_write_count", "groups", "groups_count", "arch");
}
}
public static class CsInsn {
private Pointer csh;
private CS cs;
private _cs_insn raw;
private int arch;
// instruction ID.
public int id;
// instruction address.
public long address;
// instruction size.
public short size;
// Machine bytes of this instruction, with number of bytes indicated by size above
public byte[] bytes;
// instruction mnemonic. NOTE: irrelevant for diet engine.
public String mnemonic;
// instruction operands. NOTE: irrelevant for diet engine.
public String opStr;
// list of all implicit registers being read.
public short[] regsRead;
// list of all implicit registers being written.
public short[] regsWrite;
// list of semantic groups this instruction belongs to.
public byte[] groups;
public OpInfo operands;
public CsInsn (_cs_insn insn, int _arch, Pointer _csh, CS _cs, boolean diet) {
id = insn.id;
address = insn.address;
size = insn.size;
if (!diet) {
int lm = 0;
while (insn.mnemonic[lm++] != 0);
int lo = 0;
while (insn.op_str[lo++] != 0);
mnemonic = new String(insn.mnemonic, 0, lm-1);
opStr = new String(insn.op_str, 0, lo-1);
bytes = Arrays.copyOf(insn.bytes, insn.size);
}
cs = _cs;
arch = _arch;
raw = insn;
csh = _csh;
if (insn.cs_detail != null) {
if (!diet) {
regsRead = new short[insn.cs_detail.regs_read_count];
for (int i=0; i<regsRead.length; i++)
regsRead[i] = insn.cs_detail.regs_read[i];
regsWrite = new short[insn.cs_detail.regs_write_count];
for (int i=0; i<regsWrite.length; i++)
regsWrite[i] = insn.cs_detail.regs_write[i];
groups = new byte[insn.cs_detail.groups_count];
for (int i=0; i<groups.length; i++)
groups[i] = insn.cs_detail.groups[i];
}
operands = getOptInfo(insn.cs_detail);
}
}
private OpInfo getOptInfo(_cs_detail detail) {
OpInfo op_info = null;
switch (this.arch) {
case CS_ARCH_ARM:
detail.arch.setType(Arm.UnionOpInfo.class);
detail.arch.read();
op_info = new Arm.OpInfo((Arm.UnionOpInfo) detail.arch.arm);
break;
case CS_ARCH_ARM64:
detail.arch.setType(Arm64.UnionOpInfo.class);
detail.arch.read();
op_info = new Arm64.OpInfo((Arm64.UnionOpInfo) detail.arch.arm64);
break;
case CS_ARCH_MIPS:
detail.arch.setType(Mips.UnionOpInfo.class);
detail.arch.read();
op_info = new Mips.OpInfo((Mips.UnionOpInfo) detail.arch.mips);
break;
case CS_ARCH_X86:
detail.arch.setType(X86.UnionOpInfo.class);
detail.arch.read();
op_info = new X86.OpInfo((X86.UnionOpInfo) detail.arch.x86);
break;
case CS_ARCH_SPARC:
detail.arch.setType(Sparc.UnionOpInfo.class);
detail.arch.read();
op_info = new Sparc.OpInfo((Sparc.UnionOpInfo) detail.arch.sparc);
break;
case CS_ARCH_SYSZ:
detail.arch.setType(Systemz.UnionOpInfo.class);
detail.arch.read();
op_info = new Systemz.OpInfo((Systemz.UnionOpInfo) detail.arch.sysz);
break;
case CS_ARCH_PPC:
detail.arch.setType(Ppc.UnionOpInfo.class);
detail.arch.read();
op_info = new Ppc.OpInfo((Ppc.UnionOpInfo) detail.arch.ppc);
break;
case CS_ARCH_XCORE:
detail.arch.setType(Xcore.UnionOpInfo.class);
detail.arch.read();
op_info = new Xcore.OpInfo((Xcore.UnionOpInfo) detail.arch.xcore);
break;
case CS_ARCH_M680X:
detail.arch.setType(M680x.UnionOpInfo.class);
detail.arch.read();
op_info = new M680x.OpInfo((M680x.UnionOpInfo) detail.arch.m680x);
break;
default:
}
return op_info;
}
public int opCount(int type) {
return cs.cs_op_count(csh, raw.getPointer(), type);
}
public int opIndex(int type, int index) {
return cs.cs_op_index(csh, raw.getPointer(), type, index);
}
public boolean regRead(int reg_id) {
return cs.cs_reg_read(csh, raw.getPointer(), reg_id) != 0;
}
public boolean regWrite(int reg_id) {
return cs.cs_reg_write(csh, raw.getPointer(), reg_id) != 0;
}
public int errno() {
return cs.cs_errno(csh);
}
public String regName(int reg_id) {
return cs.cs_reg_name(csh, reg_id);
}
public String insnName() {
return cs.cs_insn_name(csh, id);
}
public String groupName(int id) {
return cs.cs_group_name(csh, id);
}
public boolean group(int gid) {
return cs.cs_insn_group(csh, raw.getPointer(), gid) != 0;
}
public CsRegsAccess regsAccess() {
Memory regsReadMemory = new Memory(64*2);
ByteByReference regsReadCountRef = new ByteByReference();
Memory regsWriteMemory = new Memory(64*2);
ByteByReference regsWriteCountRef = new ByteByReference();
int c = cs.cs_regs_access(csh, raw.getPointer(), regsReadMemory, regsReadCountRef, regsWriteMemory, regsWriteCountRef);
if (c != CS_ERR_OK) {
return null;
}
byte regsReadCount = regsReadCountRef.getValue();
byte regsWriteCount = regsWriteCountRef.getValue();
short[] regsRead = new short[regsReadCount];
regsReadMemory.read(0, regsRead, 0, regsReadCount);
short[] regsWrite = new short[regsWriteCount];
regsWriteMemory.read(0, regsWrite, 0, regsWriteCount);
return new CsRegsAccess(regsRead, regsWrite);
}
}
public static class CsRegsAccess {
public short[] regsRead;
public short[] regsWrite;
public CsRegsAccess(short[] regsRead, short[] regsWrite) {
this.regsRead = regsRead;
this.regsWrite = regsWrite;
}
}
private CsInsn[] fromArrayRaw(_cs_insn[] arr_raw) {
CsInsn[] arr = new CsInsn[arr_raw.length];
for (int i = 0; i < arr_raw.length; i++) {
arr[i] = new CsInsn(arr_raw[i], this.arch, ns.csh, cs, this.diet);
}
return arr;
}
private interface CS extends Library {
public int cs_open(int arch, int mode, PointerByReference handle);
public NativeLong cs_disasm(Pointer handle, byte[] code, NativeLong code_len,
long addr, NativeLong count, PointerByReference insn);
public void cs_free(Pointer p, NativeLong count);
public int cs_close(PointerByReference handle);
public int cs_option(Pointer handle, int option, NativeLong optionValue);
public String cs_reg_name(Pointer csh, int id);
public int cs_op_count(Pointer csh, Pointer insn, int type);
public int cs_op_index(Pointer csh, Pointer insn, int type, int index);
public String cs_insn_name(Pointer csh, int id);
public String cs_group_name(Pointer csh, int id);
public byte cs_insn_group(Pointer csh, Pointer insn, int id);
public byte cs_reg_read(Pointer csh, Pointer insn, int id);
public byte cs_reg_write(Pointer csh, Pointer insn, int id);
public int cs_errno(Pointer csh);
public int cs_version(IntByReference major, IntByReference minor);
public boolean cs_support(int query);
public String cs_strerror(int code);
public int cs_regs_access(Pointer handle, Pointer insn, Pointer regs_read, ByteByReference regs_read_count, Pointer regs_write, ByteByReference regs_write_count);
}
// Capstone API version
public static final int CS_API_MAJOR = 5;
public static final int CS_API_MINOR = 0;
// architectures
public static final int CS_ARCH_ARM = 0;
public static final int CS_ARCH_ARM64 = 1;
public static final int CS_ARCH_MIPS = 2;
public static final int CS_ARCH_X86 = 3;
public static final int CS_ARCH_PPC = 4;
public static final int CS_ARCH_SPARC = 5;
public static final int CS_ARCH_SYSZ = 6;
public static final int CS_ARCH_XCORE = 7;
public static final int CS_ARCH_M68K = 8;
public static final int CS_ARCH_TMS320C64X = 9;
public static final int CS_ARCH_M680X = 10;
public static final int CS_ARCH_MAX = 11;
public static final int CS_ARCH_ALL = 0xFFFF; // query id for cs_support()
// disasm mode
public static final int CS_MODE_LITTLE_ENDIAN = 0; // little-endian mode (default mode)
public static final int CS_MODE_ARM = 0; // 32-bit ARM
public static final int CS_MODE_16 = 1 << 1; // 16-bit mode for X86
public static final int CS_MODE_32 = 1 << 2; // 32-bit mode for X86
public static final int CS_MODE_64 = 1 << 3; // 64-bit mode for X86, PPC
public static final int CS_MODE_THUMB = 1 << 4; // ARM's Thumb mode, including Thumb-2
public static final int CS_MODE_MCLASS = 1 << 5; // ARM's Cortex-M series
public static final int CS_MODE_V8 = 1 << 6; // ARMv8 A32 encodings for ARM
public static final int CS_MODE_MICRO = 1 << 4; // MicroMips mode (Mips arch)
public static final int CS_MODE_MIPS3 = 1 << 5; // Mips III ISA
public static final int CS_MODE_MIPS32R6 = 1 << 6; // Mips32r6 ISA
public static final int CS_MODE_MIPS2 = 1 << 7; // Mips II ISA
public static final int CS_MODE_BIG_ENDIAN = 1 << 31; // big-endian mode
public static final int CS_MODE_V9 = 1 << 4; // SparcV9 mode (Sparc arch)
public static final int CS_MODE_MIPS32 = CS_MODE_32; // Mips32 ISA
public static final int CS_MODE_MIPS64 = CS_MODE_64; // Mips64 ISA
public static final int CS_MODE_QPX = 1 << 4; // Quad Processing eXtensions mode (PPC)
public static final int CS_MODE_SPE = 1 << 5; // Signal Processing Engine mode (PPC)
public static final int CS_MODE_BOOKE = 1 << 6; // Book-E mode (PPC)
public static final int CS_MODE_PS = 1 << 7; // Paired-singles mode (PPC)
public static final int CS_MODE_M680X_6301 = 1 << 1; // M680X Hitachi 6301,6303 mode
public static final int CS_MODE_M680X_6309 = 1 << 2; // M680X Hitachi 6309 mode
public static final int CS_MODE_M680X_6800 = 1 << 3; // M680X Motorola 6800,6802 mode
public static final int CS_MODE_M680X_6801 = 1 << 4; // M680X Motorola 6801,6803 mode
public static final int CS_MODE_M680X_6805 = 1 << 5; // M680X Motorola 6805 mode
public static final int CS_MODE_M680X_6808 = 1 << 6; // M680X Motorola 6808 mode
public static final int CS_MODE_M680X_6809 = 1 << 7; // M680X Motorola 6809 mode
public static final int CS_MODE_M680X_6811 = 1 << 8; // M680X Motorola/Freescale 68HC11 mode
public static final int CS_MODE_M680X_CPU12 = 1 << 9; // M680X Motorola/Freescale/NXP CPU12 mode
public static final int CS_MODE_M680X_HCS08 = 1 << 10; // M680X Freescale HCS08 mode
// Capstone error
public static final int CS_ERR_OK = 0;
public static final int CS_ERR_MEM = 1; // Out-Of-Memory error
public static final int CS_ERR_ARCH = 2; // Unsupported architecture
public static final int CS_ERR_HANDLE = 3; // Invalid handle
public static final int CS_ERR_CSH = 4; // Invalid csh argument
public static final int CS_ERR_MODE = 5; // Invalid/unsupported mode
public static final int CS_ERR_OPTION = 6; // Invalid/unsupported option: cs_option()
public static final int CS_ERR_DETAIL = 7; // Invalid/unsupported option: cs_option()
public static final int CS_ERR_MEMSETUP = 8;
public static final int CS_ERR_VERSION = 9; //Unsupported version (bindings)
public static final int CS_ERR_DIET = 10; //Information irrelevant in diet engine
public static final int CS_ERR_SKIPDATA = 11; //Access irrelevant data for "data" instruction in SKIPDATA mode
public static final int CS_ERR_X86_ATT = 12; //X86 AT&T syntax is unsupported (opt-out at compile time)
public static final int CS_ERR_X86_INTEL = 13; //X86 Intel syntax is unsupported (opt-out at compile time)
// Capstone option type
public static final int CS_OPT_SYNTAX = 1; // Intel X86 asm syntax (CS_ARCH_X86 arch)
public static final int CS_OPT_DETAIL = 2; // Break down instruction structure into details
public static final int CS_OPT_MODE = 3; // Change engine's mode at run-time
// Capstone option value
public static final int CS_OPT_OFF = 0; // Turn OFF an option - default option of CS_OPT_DETAIL
public static final int CS_OPT_SYNTAX_INTEL = 1; // Intel X86 asm syntax - default syntax on X86 (CS_OPT_SYNTAX, CS_ARCH_X86)
public static final int CS_OPT_SYNTAX_ATT = 2; // ATT asm syntax (CS_OPT_SYNTAX, CS_ARCH_X86)
public static final int CS_OPT_ON = 3; // Turn ON an option (CS_OPT_DETAIL)
public static final int CS_OPT_SYNTAX_NOREGNAME = 3; // PPC asm syntax: Prints register name with only number (CS_OPT_SYNTAX)
// Common instruction operand types - to be consistent across all architectures.
public static final int CS_OP_INVALID = 0;
public static final int CS_OP_REG = 1;
public static final int CS_OP_IMM = 2;
public static final int CS_OP_MEM = 3;
public static final int CS_OP_FP = 4;
// Common instruction operand access types - to be consistent across all architectures.
// It is possible to combine access types, for example: CS_AC_READ | CS_AC_WRITE
public static final int CS_AC_INVALID = 0;
public static final int CS_AC_READ = 1 << 0;
public static final int CS_AC_WRITE = 1 << 1;
// Common instruction groups - to be consistent across all architectures.
public static final int CS_GRP_INVALID = 0; // uninitialized/invalid group.
public static final int CS_GRP_JUMP = 1; // all jump instructions (conditional+direct+indirect jumps)
public static final int CS_GRP_CALL = 2; // all call instructions
public static final int CS_GRP_RET = 3; // all return instructions
public static final int CS_GRP_INT = 4; // all interrupt instructions (int+syscall)
public static final int CS_GRP_IRET = 5; // all interrupt return instructions
public static final int CS_GRP_PRIVILEGE = 6; // all privileged instructions
// Query id for cs_support()
public static final int CS_SUPPORT_DIET = CS_ARCH_ALL+1; // diet mode
public static final int CS_SUPPORT_X86_REDUCE = CS_ARCH_ALL+2; // X86 reduce mode
protected class NativeStruct {
private Pointer csh;
private PointerByReference handleRef;
}
private static final CsInsn[] EMPTY_INSN = new CsInsn[0];
protected NativeStruct ns; // for memory retention
private CS cs;
public int arch;
public int mode;
private int syntax;
private int detail;
private boolean diet;
public Capstone(int arch, int mode) {
cs = (CS)Native.loadLibrary("capstone", CS.class);
int coreVersion = cs.cs_version(null, null);
int bindingVersion = (CS_API_MAJOR << 8) + CS_API_MINOR;
if (coreVersion != bindingVersion) {
throw new RuntimeException("Different API version between core " + coreVersion +
" & binding " + bindingVersion + " (CS_ERR_VERSION)");
}
this.arch = arch;
this.mode = mode;
ns = new NativeStruct();
ns.handleRef = new PointerByReference();
if (cs.cs_open(arch, mode, ns.handleRef) != CS_ERR_OK) {
throw new RuntimeException("ERROR: Wrong arch or mode");
}
ns.csh = ns.handleRef.getValue();
this.detail = CS_OPT_OFF;
this.diet = cs.cs_support(CS_SUPPORT_DIET);
}
// return combined API version
public int version() {
return cs.cs_version(null, null);
}
// set Assembly syntax
public void setSyntax(int syntax) {
if (cs.cs_option(ns.csh, CS_OPT_SYNTAX, new NativeLong(syntax)) == CS_ERR_OK) {
this.syntax = syntax;
} else {
throw new RuntimeException("ERROR: Failed to set assembly syntax");
}
}
// set detail option at run-time
public void setDetail(int opt) {
if (cs.cs_option(ns.csh, CS_OPT_DETAIL, new NativeLong(opt)) == CS_ERR_OK) {
this.detail = opt;
} else {
throw new RuntimeException("ERROR: Failed to set detail option");
}
}
// set mode option at run-time
public void setMode(int opt) {
if (cs.cs_option(ns.csh, CS_OPT_MODE, new NativeLong(opt)) == CS_ERR_OK) {
this.mode = opt;
} else {
throw new RuntimeException("ERROR: Failed to set mode option");
}
}
// destructor automatically called at destroyed time.
protected void finalize() {
// FIXME: crashed on Ubuntu 14.04 64bit, OpenJDK java 1.6.0_33
// cs.cs_close(ns.handleRef);
}
// destructor automatically called at destroyed time.
public int close() {
return cs.cs_close(ns.handleRef);
}
/**
* Disassemble instructions from @code assumed to be located at @address,
* stop when encountering first broken instruction.
*
* @param code The source machine code bytes.
* @param address The address of the first machine code byte.
* @return the array of successfully disassembled instructions, empty if no instruction could be disassembled.
*/
public CsInsn[] disasm(byte[] code, long address) {
return disasm(code, address, 0);
}
/**
* Disassemble up to @count instructions from @code assumed to be located at @address,
* stop when encountering first broken instruction.
*
* @param code The source machine code bytes.
* @param address The address of the first machine code byte.
* @param count The maximum number of instructions to disassemble, 0 for no maximum.
* @return the array of successfully disassembled instructions, empty if no instruction could be disassembled.
*/
public CsInsn[] disasm(byte[] code, long address, long count) {
PointerByReference insnRef = new PointerByReference();
NativeLong c = cs.cs_disasm(ns.csh, code, new NativeLong(code.length), address, new NativeLong(count), insnRef);
if (0 == c.intValue()) {
return EMPTY_INSN;
}
Pointer p = insnRef.getValue();
_cs_insn byref = new _cs_insn(p);
CsInsn[] allInsn = fromArrayRaw((_cs_insn[]) byref.toArray(c.intValue()));
// free allocated memory
// cs.cs_free(p, c);
// FIXME(danghvu): Can't free because memory is still inside CsInsn
return allInsn;
}
public String strerror(int code) {
return cs.cs_strerror(code);
}
}
+167
View File
@@ -0,0 +1,167 @@
// For Capstone Engine. AUTO-GENERATED FILE, DO NOT EDIT
package capstone;
public class Evm_const {
public static final int EVM_INS_STOP = 0;
public static final int EVM_INS_ADD = 1;
public static final int EVM_INS_MUL = 2;
public static final int EVM_INS_SUB = 3;
public static final int EVM_INS_DIV = 4;
public static final int EVM_INS_SDIV = 5;
public static final int EVM_INS_MOD = 6;
public static final int EVM_INS_SMOD = 7;
public static final int EVM_INS_ADDMOD = 8;
public static final int EVM_INS_MULMOD = 9;
public static final int EVM_INS_EXP = 10;
public static final int EVM_INS_SIGNEXTEND = 11;
public static final int EVM_INS_LT = 16;
public static final int EVM_INS_GT = 17;
public static final int EVM_INS_SLT = 18;
public static final int EVM_INS_SGT = 19;
public static final int EVM_INS_EQ = 20;
public static final int EVM_INS_ISZERO = 21;
public static final int EVM_INS_AND = 22;
public static final int EVM_INS_OR = 23;
public static final int EVM_INS_XOR = 24;
public static final int EVM_INS_NOT = 25;
public static final int EVM_INS_BYTE = 26;
public static final int EVM_INS_SHL = 27;
public static final int EVM_INS_SHR = 28;
public static final int EVM_INS_SAR = 29;
public static final int EVM_INS_SHA3 = 32;
public static final int EVM_INS_ADDRESS = 48;
public static final int EVM_INS_BALANCE = 49;
public static final int EVM_INS_ORIGIN = 50;
public static final int EVM_INS_CALLER = 51;
public static final int EVM_INS_CALLVALUE = 52;
public static final int EVM_INS_CALLDATALOAD = 53;
public static final int EVM_INS_CALLDATASIZE = 54;
public static final int EVM_INS_CALLDATACOPY = 55;
public static final int EVM_INS_CODESIZE = 56;
public static final int EVM_INS_CODECOPY = 57;
public static final int EVM_INS_GASPRICE = 58;
public static final int EVM_INS_EXTCODESIZE = 59;
public static final int EVM_INS_EXTCODECOPY = 60;
public static final int EVM_INS_RETURNDATASIZE = 61;
public static final int EVM_INS_RETURNDATACOPY = 62;
public static final int EVM_INS_BLOCKHASH = 64;
public static final int EVM_INS_COINBASE = 65;
public static final int EVM_INS_TIMESTAMP = 66;
public static final int EVM_INS_NUMBER = 67;
public static final int EVM_INS_DIFFICULTY = 68;
public static final int EVM_INS_GASLIMIT = 69;
public static final int EVM_INS_CHAINID = 70;
public static final int EVM_INS_SELFBALANCE = 71;
public static final int EVM_INS_BASEFEE = 72;
public static final int EVM_INS_BLOBHASH = 73;
public static final int EVM_INS_BLOBBASEFEE = 74;
public static final int EVM_INS_POP = 80;
public static final int EVM_INS_MLOAD = 81;
public static final int EVM_INS_MSTORE = 82;
public static final int EVM_INS_MSTORE8 = 83;
public static final int EVM_INS_SLOAD = 84;
public static final int EVM_INS_SSTORE = 85;
public static final int EVM_INS_JUMP = 86;
public static final int EVM_INS_JUMPI = 87;
public static final int EVM_INS_PC = 88;
public static final int EVM_INS_MSIZE = 89;
public static final int EVM_INS_GAS = 90;
public static final int EVM_INS_JUMPDEST = 91;
public static final int EVM_INS_TLOAD = 92;
public static final int EVM_INS_TSTORE = 93;
public static final int EVM_INS_MCOPY = 94;
public static final int EVM_INS_PUSH0 = 95;
public static final int EVM_INS_PUSH1 = 96;
public static final int EVM_INS_PUSH2 = 97;
public static final int EVM_INS_PUSH3 = 98;
public static final int EVM_INS_PUSH4 = 99;
public static final int EVM_INS_PUSH5 = 100;
public static final int EVM_INS_PUSH6 = 101;
public static final int EVM_INS_PUSH7 = 102;
public static final int EVM_INS_PUSH8 = 103;
public static final int EVM_INS_PUSH9 = 104;
public static final int EVM_INS_PUSH10 = 105;
public static final int EVM_INS_PUSH11 = 106;
public static final int EVM_INS_PUSH12 = 107;
public static final int EVM_INS_PUSH13 = 108;
public static final int EVM_INS_PUSH14 = 109;
public static final int EVM_INS_PUSH15 = 110;
public static final int EVM_INS_PUSH16 = 111;
public static final int EVM_INS_PUSH17 = 112;
public static final int EVM_INS_PUSH18 = 113;
public static final int EVM_INS_PUSH19 = 114;
public static final int EVM_INS_PUSH20 = 115;
public static final int EVM_INS_PUSH21 = 116;
public static final int EVM_INS_PUSH22 = 117;
public static final int EVM_INS_PUSH23 = 118;
public static final int EVM_INS_PUSH24 = 119;
public static final int EVM_INS_PUSH25 = 120;
public static final int EVM_INS_PUSH26 = 121;
public static final int EVM_INS_PUSH27 = 122;
public static final int EVM_INS_PUSH28 = 123;
public static final int EVM_INS_PUSH29 = 124;
public static final int EVM_INS_PUSH30 = 125;
public static final int EVM_INS_PUSH31 = 126;
public static final int EVM_INS_PUSH32 = 127;
public static final int EVM_INS_DUP1 = 128;
public static final int EVM_INS_DUP2 = 129;
public static final int EVM_INS_DUP3 = 130;
public static final int EVM_INS_DUP4 = 131;
public static final int EVM_INS_DUP5 = 132;
public static final int EVM_INS_DUP6 = 133;
public static final int EVM_INS_DUP7 = 134;
public static final int EVM_INS_DUP8 = 135;
public static final int EVM_INS_DUP9 = 136;
public static final int EVM_INS_DUP10 = 137;
public static final int EVM_INS_DUP11 = 138;
public static final int EVM_INS_DUP12 = 139;
public static final int EVM_INS_DUP13 = 140;
public static final int EVM_INS_DUP14 = 141;
public static final int EVM_INS_DUP15 = 142;
public static final int EVM_INS_DUP16 = 143;
public static final int EVM_INS_SWAP1 = 144;
public static final int EVM_INS_SWAP2 = 145;
public static final int EVM_INS_SWAP3 = 146;
public static final int EVM_INS_SWAP4 = 147;
public static final int EVM_INS_SWAP5 = 148;
public static final int EVM_INS_SWAP6 = 149;
public static final int EVM_INS_SWAP7 = 150;
public static final int EVM_INS_SWAP8 = 151;
public static final int EVM_INS_SWAP9 = 152;
public static final int EVM_INS_SWAP10 = 153;
public static final int EVM_INS_SWAP11 = 154;
public static final int EVM_INS_SWAP12 = 155;
public static final int EVM_INS_SWAP13 = 156;
public static final int EVM_INS_SWAP14 = 157;
public static final int EVM_INS_SWAP15 = 158;
public static final int EVM_INS_SWAP16 = 159;
public static final int EVM_INS_LOG0 = 160;
public static final int EVM_INS_LOG1 = 161;
public static final int EVM_INS_LOG2 = 162;
public static final int EVM_INS_LOG3 = 163;
public static final int EVM_INS_LOG4 = 164;
public static final int EVM_INS_CREATE = 240;
public static final int EVM_INS_CALL = 241;
public static final int EVM_INS_CALLCODE = 242;
public static final int EVM_INS_RETURN = 243;
public static final int EVM_INS_DELEGATECALL = 244;
public static final int EVM_INS_CREATE2 = 245;
public static final int EVM_INS_STATICCALL = 250;
public static final int EVM_INS_REVERT = 253;
public static final int EVM_INS_INVALID = 254;
public static final int EVM_INS_SELFDESTRUCT = 255;
public static final int EVM_INS_ENDING = 256;
public static final int EVM_GRP_INVALID = 0;
public static final int EVM_GRP_JUMP = 1;
public static final int EVM_GRP_MATH = 8;
public static final int EVM_GRP_STACK_WRITE = 9;
public static final int EVM_GRP_STACK_READ = 10;
public static final int EVM_GRP_MEM_WRITE = 11;
public static final int EVM_GRP_MEM_READ = 12;
public static final int EVM_GRP_STORE_WRITE = 13;
public static final int EVM_GRP_STORE_READ = 14;
public static final int EVM_GRP_HALT = 15;
public static final int EVM_GRP_ENDING = 16;
}
+132
View File
@@ -0,0 +1,132 @@
// Capstone Java binding
/* M680X Backend by Wolfgang Schwotzer <wolfgang.schwotzer@gmx.net> 2017 */
package capstone;
import com.sun.jna.Structure;
import com.sun.jna.Union;
import java.util.List;
import java.util.Arrays;
import static capstone.M680x_const.*;
public class M680x {
public static class OpIndexed extends Structure {
public int base_reg;
public int offset_reg;
public short offset;
public short offset_addr;
public byte offset_bits;
public byte inc_dec;
public byte flags;
@Override
public List getFieldOrder() {
return Arrays.asList("base_reg", "offset_reg", "offset", "offset_addr", "offset_bits", "inc_dec", "flags");
}
}
public static class OpRelative extends Structure {
public short address;
public short offset;
@Override
public List getFieldOrder() {
return Arrays.asList("address", "offset");
}
}
public static class OpExtended extends Structure {
public short address;
public byte indirect;
@Override
public List getFieldOrder() {
return Arrays.asList("address", "indirect");
}
}
public static class OpValue extends Union {
public int imm;
public int reg;
public OpIndexed idx;
public OpRelative rel;
public OpExtended ext;
public byte direct_addr;
public byte const_val;
@Override
public List getFieldOrder() {
return Arrays.asList("imm", "reg", "idx", "rel", "ext", "direct_addr", "const_val");
}
}
public static class Operand extends Structure {
public int type;
public OpValue value;
public byte size;
public byte access;
public void read() {
readField("type");
if (type == M680X_OP_IMMEDIATE)
value.setType(Integer.TYPE);
if (type == M680X_OP_REGISTER)
value.setType(Integer.TYPE);
if (type == M680X_OP_INDEXED)
value.setType(OpIndexed.class);
if (type == M680X_OP_RELATIVE)
value.setType(OpRelative.class);
if (type == M680X_OP_EXTENDED)
value.setType(OpExtended.class);
if (type == M680X_OP_DIRECT)
value.setType(Integer.TYPE);
if (type == M680X_OP_INVALID)
return;
readField("value");
readField("size");
readField("access");
}
@Override
public List getFieldOrder() {
return Arrays.asList("type", "value", "size", "access");
}
}
public static class UnionOpInfo extends Capstone.UnionOpInfo {
public byte flags;
public byte op_count;
public Operand [] op;
public UnionOpInfo() {
op = new Operand[9];
}
public void read() {
readField("flags");
readField("op_count");
op = new Operand[op_count];
if (op_count != 0)
readField("op");
}
@Override
public List getFieldOrder() {
return Arrays.asList("flags", "op_count", "op");
}
}
public static class OpInfo extends Capstone.OpInfo {
public byte flags;
public Operand [] op = null;
public OpInfo(UnionOpInfo op_info) {
flags = op_info.flags;
op = op_info.op;
}
}
}
@@ -0,0 +1,418 @@
// For Capstone Engine. AUTO-GENERATED FILE, DO NOT EDIT
package capstone;
public class M680x_const {
public static final int M680X_OPERAND_COUNT = 9;
public static final int M680X_REG_INVALID = 0;
public static final int M680X_REG_A = 1;
public static final int M680X_REG_B = 2;
public static final int M680X_REG_E = 3;
public static final int M680X_REG_F = 4;
public static final int M680X_REG_0 = 5;
public static final int M680X_REG_D = 6;
public static final int M680X_REG_W = 7;
public static final int M680X_REG_CC = 8;
public static final int M680X_REG_DP = 9;
public static final int M680X_REG_MD = 10;
public static final int M680X_REG_HX = 11;
public static final int M680X_REG_H = 12;
public static final int M680X_REG_X = 13;
public static final int M680X_REG_Y = 14;
public static final int M680X_REG_S = 15;
public static final int M680X_REG_U = 16;
public static final int M680X_REG_V = 17;
public static final int M680X_REG_Q = 18;
public static final int M680X_REG_PC = 19;
public static final int M680X_REG_TMP2 = 20;
public static final int M680X_REG_TMP3 = 21;
public static final int M680X_REG_ENDING = 22;
public static final int M680X_OP_INVALID = CS_OP_INVALID;
public static final int M680X_OP_REGISTER = CS_OP_REG;
public static final int M680X_OP_IMMEDIATE = CS_OP_IMM;
public static final int M680X_OP_INDEXED = CS_OP_SPECIAL+0;
public static final int M680X_OP_EXTENDED = CS_OP_SPECIAL+1;
public static final int M680X_OP_DIRECT = CS_OP_SPECIAL+2;
public static final int M680X_OP_RELATIVE = CS_OP_SPECIAL+3;
public static final int M680X_OP_CONSTANT = CS_OP_SPECIAL+4;
public static final int M680X_OFFSET_NONE = 0;
public static final int M680X_OFFSET_BITS_5 = 5;
public static final int M680X_OFFSET_BITS_8 = 8;
public static final int M680X_OFFSET_BITS_9 = 9;
public static final int M680X_OFFSET_BITS_16 = 16;
public static final int M680X_IDX_INDIRECT = 1;
public static final int M680X_IDX_NO_COMMA = 2;
public static final int M680X_IDX_POST_INC_DEC = 4;
public static final int M680X_GRP_INVALID = 0;
public static final int M680X_GRP_JUMP = 1;
public static final int M680X_GRP_CALL = 2;
public static final int M680X_GRP_RET = 3;
public static final int M680X_GRP_INT = 4;
public static final int M680X_GRP_IRET = 5;
public static final int M680X_GRP_PRIV = 6;
public static final int M680X_GRP_BRAREL = 7;
public static final int M680X_GRP_ENDING = 8;
public static final int M680X_FIRST_OP_IN_MNEM = 1;
public static final int M680X_SECOND_OP_IN_MNEM = 2;
public static final int M680X_INS_INVLD = 0;
public static final int M680X_INS_ABA = 1;
public static final int M680X_INS_ABX = 2;
public static final int M680X_INS_ABY = 3;
public static final int M680X_INS_ADC = 4;
public static final int M680X_INS_ADCA = 5;
public static final int M680X_INS_ADCB = 6;
public static final int M680X_INS_ADCD = 7;
public static final int M680X_INS_ADCR = 8;
public static final int M680X_INS_ADD = 9;
public static final int M680X_INS_ADDA = 10;
public static final int M680X_INS_ADDB = 11;
public static final int M680X_INS_ADDD = 12;
public static final int M680X_INS_ADDE = 13;
public static final int M680X_INS_ADDF = 14;
public static final int M680X_INS_ADDR = 15;
public static final int M680X_INS_ADDW = 16;
public static final int M680X_INS_AIM = 17;
public static final int M680X_INS_AIS = 18;
public static final int M680X_INS_AIX = 19;
public static final int M680X_INS_AND = 20;
public static final int M680X_INS_ANDA = 21;
public static final int M680X_INS_ANDB = 22;
public static final int M680X_INS_ANDCC = 23;
public static final int M680X_INS_ANDD = 24;
public static final int M680X_INS_ANDR = 25;
public static final int M680X_INS_ASL = 26;
public static final int M680X_INS_ASLA = 27;
public static final int M680X_INS_ASLB = 28;
public static final int M680X_INS_ASLD = 29;
public static final int M680X_INS_ASR = 30;
public static final int M680X_INS_ASRA = 31;
public static final int M680X_INS_ASRB = 32;
public static final int M680X_INS_ASRD = 33;
public static final int M680X_INS_ASRX = 34;
public static final int M680X_INS_BAND = 35;
public static final int M680X_INS_BCC = 36;
public static final int M680X_INS_BCLR = 37;
public static final int M680X_INS_BCS = 38;
public static final int M680X_INS_BEOR = 39;
public static final int M680X_INS_BEQ = 40;
public static final int M680X_INS_BGE = 41;
public static final int M680X_INS_BGND = 42;
public static final int M680X_INS_BGT = 43;
public static final int M680X_INS_BHCC = 44;
public static final int M680X_INS_BHCS = 45;
public static final int M680X_INS_BHI = 46;
public static final int M680X_INS_BIAND = 47;
public static final int M680X_INS_BIEOR = 48;
public static final int M680X_INS_BIH = 49;
public static final int M680X_INS_BIL = 50;
public static final int M680X_INS_BIOR = 51;
public static final int M680X_INS_BIT = 52;
public static final int M680X_INS_BITA = 53;
public static final int M680X_INS_BITB = 54;
public static final int M680X_INS_BITD = 55;
public static final int M680X_INS_BITMD = 56;
public static final int M680X_INS_BLE = 57;
public static final int M680X_INS_BLS = 58;
public static final int M680X_INS_BLT = 59;
public static final int M680X_INS_BMC = 60;
public static final int M680X_INS_BMI = 61;
public static final int M680X_INS_BMS = 62;
public static final int M680X_INS_BNE = 63;
public static final int M680X_INS_BOR = 64;
public static final int M680X_INS_BPL = 65;
public static final int M680X_INS_BRCLR = 66;
public static final int M680X_INS_BRSET = 67;
public static final int M680X_INS_BRA = 68;
public static final int M680X_INS_BRN = 69;
public static final int M680X_INS_BSET = 70;
public static final int M680X_INS_BSR = 71;
public static final int M680X_INS_BVC = 72;
public static final int M680X_INS_BVS = 73;
public static final int M680X_INS_CALL = 74;
public static final int M680X_INS_CBA = 75;
public static final int M680X_INS_CBEQ = 76;
public static final int M680X_INS_CBEQA = 77;
public static final int M680X_INS_CBEQX = 78;
public static final int M680X_INS_CLC = 79;
public static final int M680X_INS_CLI = 80;
public static final int M680X_INS_CLR = 81;
public static final int M680X_INS_CLRA = 82;
public static final int M680X_INS_CLRB = 83;
public static final int M680X_INS_CLRD = 84;
public static final int M680X_INS_CLRE = 85;
public static final int M680X_INS_CLRF = 86;
public static final int M680X_INS_CLRH = 87;
public static final int M680X_INS_CLRW = 88;
public static final int M680X_INS_CLRX = 89;
public static final int M680X_INS_CLV = 90;
public static final int M680X_INS_CMP = 91;
public static final int M680X_INS_CMPA = 92;
public static final int M680X_INS_CMPB = 93;
public static final int M680X_INS_CMPD = 94;
public static final int M680X_INS_CMPE = 95;
public static final int M680X_INS_CMPF = 96;
public static final int M680X_INS_CMPR = 97;
public static final int M680X_INS_CMPS = 98;
public static final int M680X_INS_CMPU = 99;
public static final int M680X_INS_CMPW = 100;
public static final int M680X_INS_CMPX = 101;
public static final int M680X_INS_CMPY = 102;
public static final int M680X_INS_COM = 103;
public static final int M680X_INS_COMA = 104;
public static final int M680X_INS_COMB = 105;
public static final int M680X_INS_COMD = 106;
public static final int M680X_INS_COME = 107;
public static final int M680X_INS_COMF = 108;
public static final int M680X_INS_COMW = 109;
public static final int M680X_INS_COMX = 110;
public static final int M680X_INS_CPD = 111;
public static final int M680X_INS_CPHX = 112;
public static final int M680X_INS_CPS = 113;
public static final int M680X_INS_CPX = 114;
public static final int M680X_INS_CPY = 115;
public static final int M680X_INS_CWAI = 116;
public static final int M680X_INS_DAA = 117;
public static final int M680X_INS_DBEQ = 118;
public static final int M680X_INS_DBNE = 119;
public static final int M680X_INS_DBNZ = 120;
public static final int M680X_INS_DBNZA = 121;
public static final int M680X_INS_DBNZX = 122;
public static final int M680X_INS_DEC = 123;
public static final int M680X_INS_DECA = 124;
public static final int M680X_INS_DECB = 125;
public static final int M680X_INS_DECD = 126;
public static final int M680X_INS_DECE = 127;
public static final int M680X_INS_DECF = 128;
public static final int M680X_INS_DECW = 129;
public static final int M680X_INS_DECX = 130;
public static final int M680X_INS_DES = 131;
public static final int M680X_INS_DEX = 132;
public static final int M680X_INS_DEY = 133;
public static final int M680X_INS_DIV = 134;
public static final int M680X_INS_DIVD = 135;
public static final int M680X_INS_DIVQ = 136;
public static final int M680X_INS_EDIV = 137;
public static final int M680X_INS_EDIVS = 138;
public static final int M680X_INS_EIM = 139;
public static final int M680X_INS_EMACS = 140;
public static final int M680X_INS_EMAXD = 141;
public static final int M680X_INS_EMAXM = 142;
public static final int M680X_INS_EMIND = 143;
public static final int M680X_INS_EMINM = 144;
public static final int M680X_INS_EMUL = 145;
public static final int M680X_INS_EMULS = 146;
public static final int M680X_INS_EOR = 147;
public static final int M680X_INS_EORA = 148;
public static final int M680X_INS_EORB = 149;
public static final int M680X_INS_EORD = 150;
public static final int M680X_INS_EORR = 151;
public static final int M680X_INS_ETBL = 152;
public static final int M680X_INS_EXG = 153;
public static final int M680X_INS_FDIV = 154;
public static final int M680X_INS_IBEQ = 155;
public static final int M680X_INS_IBNE = 156;
public static final int M680X_INS_IDIV = 157;
public static final int M680X_INS_IDIVS = 158;
public static final int M680X_INS_ILLGL = 159;
public static final int M680X_INS_INC = 160;
public static final int M680X_INS_INCA = 161;
public static final int M680X_INS_INCB = 162;
public static final int M680X_INS_INCD = 163;
public static final int M680X_INS_INCE = 164;
public static final int M680X_INS_INCF = 165;
public static final int M680X_INS_INCW = 166;
public static final int M680X_INS_INCX = 167;
public static final int M680X_INS_INS = 168;
public static final int M680X_INS_INX = 169;
public static final int M680X_INS_INY = 170;
public static final int M680X_INS_JMP = 171;
public static final int M680X_INS_JSR = 172;
public static final int M680X_INS_LBCC = 173;
public static final int M680X_INS_LBCS = 174;
public static final int M680X_INS_LBEQ = 175;
public static final int M680X_INS_LBGE = 176;
public static final int M680X_INS_LBGT = 177;
public static final int M680X_INS_LBHI = 178;
public static final int M680X_INS_LBLE = 179;
public static final int M680X_INS_LBLS = 180;
public static final int M680X_INS_LBLT = 181;
public static final int M680X_INS_LBMI = 182;
public static final int M680X_INS_LBNE = 183;
public static final int M680X_INS_LBPL = 184;
public static final int M680X_INS_LBRA = 185;
public static final int M680X_INS_LBRN = 186;
public static final int M680X_INS_LBSR = 187;
public static final int M680X_INS_LBVC = 188;
public static final int M680X_INS_LBVS = 189;
public static final int M680X_INS_LDA = 190;
public static final int M680X_INS_LDAA = 191;
public static final int M680X_INS_LDAB = 192;
public static final int M680X_INS_LDB = 193;
public static final int M680X_INS_LDBT = 194;
public static final int M680X_INS_LDD = 195;
public static final int M680X_INS_LDE = 196;
public static final int M680X_INS_LDF = 197;
public static final int M680X_INS_LDHX = 198;
public static final int M680X_INS_LDMD = 199;
public static final int M680X_INS_LDQ = 200;
public static final int M680X_INS_LDS = 201;
public static final int M680X_INS_LDU = 202;
public static final int M680X_INS_LDW = 203;
public static final int M680X_INS_LDX = 204;
public static final int M680X_INS_LDY = 205;
public static final int M680X_INS_LEAS = 206;
public static final int M680X_INS_LEAU = 207;
public static final int M680X_INS_LEAX = 208;
public static final int M680X_INS_LEAY = 209;
public static final int M680X_INS_LSL = 210;
public static final int M680X_INS_LSLA = 211;
public static final int M680X_INS_LSLB = 212;
public static final int M680X_INS_LSLD = 213;
public static final int M680X_INS_LSLX = 214;
public static final int M680X_INS_LSR = 215;
public static final int M680X_INS_LSRA = 216;
public static final int M680X_INS_LSRB = 217;
public static final int M680X_INS_LSRD = 218;
public static final int M680X_INS_LSRW = 219;
public static final int M680X_INS_LSRX = 220;
public static final int M680X_INS_MAXA = 221;
public static final int M680X_INS_MAXM = 222;
public static final int M680X_INS_MEM = 223;
public static final int M680X_INS_MINA = 224;
public static final int M680X_INS_MINM = 225;
public static final int M680X_INS_MOV = 226;
public static final int M680X_INS_MOVB = 227;
public static final int M680X_INS_MOVW = 228;
public static final int M680X_INS_MUL = 229;
public static final int M680X_INS_MULD = 230;
public static final int M680X_INS_NEG = 231;
public static final int M680X_INS_NEGA = 232;
public static final int M680X_INS_NEGB = 233;
public static final int M680X_INS_NEGD = 234;
public static final int M680X_INS_NEGX = 235;
public static final int M680X_INS_NOP = 236;
public static final int M680X_INS_NSA = 237;
public static final int M680X_INS_OIM = 238;
public static final int M680X_INS_ORA = 239;
public static final int M680X_INS_ORAA = 240;
public static final int M680X_INS_ORAB = 241;
public static final int M680X_INS_ORB = 242;
public static final int M680X_INS_ORCC = 243;
public static final int M680X_INS_ORD = 244;
public static final int M680X_INS_ORR = 245;
public static final int M680X_INS_PSHA = 246;
public static final int M680X_INS_PSHB = 247;
public static final int M680X_INS_PSHC = 248;
public static final int M680X_INS_PSHD = 249;
public static final int M680X_INS_PSHH = 250;
public static final int M680X_INS_PSHS = 251;
public static final int M680X_INS_PSHSW = 252;
public static final int M680X_INS_PSHU = 253;
public static final int M680X_INS_PSHUW = 254;
public static final int M680X_INS_PSHX = 255;
public static final int M680X_INS_PSHY = 256;
public static final int M680X_INS_PULA = 257;
public static final int M680X_INS_PULB = 258;
public static final int M680X_INS_PULC = 259;
public static final int M680X_INS_PULD = 260;
public static final int M680X_INS_PULH = 261;
public static final int M680X_INS_PULS = 262;
public static final int M680X_INS_PULSW = 263;
public static final int M680X_INS_PULU = 264;
public static final int M680X_INS_PULUW = 265;
public static final int M680X_INS_PULX = 266;
public static final int M680X_INS_PULY = 267;
public static final int M680X_INS_REV = 268;
public static final int M680X_INS_REVW = 269;
public static final int M680X_INS_ROL = 270;
public static final int M680X_INS_ROLA = 271;
public static final int M680X_INS_ROLB = 272;
public static final int M680X_INS_ROLD = 273;
public static final int M680X_INS_ROLW = 274;
public static final int M680X_INS_ROLX = 275;
public static final int M680X_INS_ROR = 276;
public static final int M680X_INS_RORA = 277;
public static final int M680X_INS_RORB = 278;
public static final int M680X_INS_RORD = 279;
public static final int M680X_INS_RORW = 280;
public static final int M680X_INS_RORX = 281;
public static final int M680X_INS_RSP = 282;
public static final int M680X_INS_RTC = 283;
public static final int M680X_INS_RTI = 284;
public static final int M680X_INS_RTS = 285;
public static final int M680X_INS_SBA = 286;
public static final int M680X_INS_SBC = 287;
public static final int M680X_INS_SBCA = 288;
public static final int M680X_INS_SBCB = 289;
public static final int M680X_INS_SBCD = 290;
public static final int M680X_INS_SBCR = 291;
public static final int M680X_INS_SEC = 292;
public static final int M680X_INS_SEI = 293;
public static final int M680X_INS_SEV = 294;
public static final int M680X_INS_SEX = 295;
public static final int M680X_INS_SEXW = 296;
public static final int M680X_INS_SLP = 297;
public static final int M680X_INS_STA = 298;
public static final int M680X_INS_STAA = 299;
public static final int M680X_INS_STAB = 300;
public static final int M680X_INS_STB = 301;
public static final int M680X_INS_STBT = 302;
public static final int M680X_INS_STD = 303;
public static final int M680X_INS_STE = 304;
public static final int M680X_INS_STF = 305;
public static final int M680X_INS_STOP = 306;
public static final int M680X_INS_STHX = 307;
public static final int M680X_INS_STQ = 308;
public static final int M680X_INS_STS = 309;
public static final int M680X_INS_STU = 310;
public static final int M680X_INS_STW = 311;
public static final int M680X_INS_STX = 312;
public static final int M680X_INS_STY = 313;
public static final int M680X_INS_SUB = 314;
public static final int M680X_INS_SUBA = 315;
public static final int M680X_INS_SUBB = 316;
public static final int M680X_INS_SUBD = 317;
public static final int M680X_INS_SUBE = 318;
public static final int M680X_INS_SUBF = 319;
public static final int M680X_INS_SUBR = 320;
public static final int M680X_INS_SUBW = 321;
public static final int M680X_INS_SWI = 322;
public static final int M680X_INS_SWI2 = 323;
public static final int M680X_INS_SWI3 = 324;
public static final int M680X_INS_SYNC = 325;
public static final int M680X_INS_TAB = 326;
public static final int M680X_INS_TAP = 327;
public static final int M680X_INS_TAX = 328;
public static final int M680X_INS_TBA = 329;
public static final int M680X_INS_TBEQ = 330;
public static final int M680X_INS_TBL = 331;
public static final int M680X_INS_TBNE = 332;
public static final int M680X_INS_TEST = 333;
public static final int M680X_INS_TFM = 334;
public static final int M680X_INS_TFR = 335;
public static final int M680X_INS_TIM = 336;
public static final int M680X_INS_TPA = 337;
public static final int M680X_INS_TST = 338;
public static final int M680X_INS_TSTA = 339;
public static final int M680X_INS_TSTB = 340;
public static final int M680X_INS_TSTD = 341;
public static final int M680X_INS_TSTE = 342;
public static final int M680X_INS_TSTF = 343;
public static final int M680X_INS_TSTW = 344;
public static final int M680X_INS_TSTX = 345;
public static final int M680X_INS_TSX = 346;
public static final int M680X_INS_TSY = 347;
public static final int M680X_INS_TXA = 348;
public static final int M680X_INS_TXS = 349;
public static final int M680X_INS_TYS = 350;
public static final int M680X_INS_WAI = 351;
public static final int M680X_INS_WAIT = 352;
public static final int M680X_INS_WAV = 353;
public static final int M680X_INS_WAVR = 354;
public static final int M680X_INS_XGDX = 355;
public static final int M680X_INS_XGDY = 356;
public static final int M680X_INS_ENDING = 357;
}
+488
View File
@@ -0,0 +1,488 @@
// For Capstone Engine. AUTO-GENERATED FILE, DO NOT EDIT
package capstone;
public class M68k_const {
public static final int M68K_OPERAND_COUNT = 4;
public static final int M68K_REG_INVALID = 0;
public static final int M68K_REG_D0 = 1;
public static final int M68K_REG_D1 = 2;
public static final int M68K_REG_D2 = 3;
public static final int M68K_REG_D3 = 4;
public static final int M68K_REG_D4 = 5;
public static final int M68K_REG_D5 = 6;
public static final int M68K_REG_D6 = 7;
public static final int M68K_REG_D7 = 8;
public static final int M68K_REG_A0 = 9;
public static final int M68K_REG_A1 = 10;
public static final int M68K_REG_A2 = 11;
public static final int M68K_REG_A3 = 12;
public static final int M68K_REG_A4 = 13;
public static final int M68K_REG_A5 = 14;
public static final int M68K_REG_A6 = 15;
public static final int M68K_REG_A7 = 16;
public static final int M68K_REG_FP0 = 17;
public static final int M68K_REG_FP1 = 18;
public static final int M68K_REG_FP2 = 19;
public static final int M68K_REG_FP3 = 20;
public static final int M68K_REG_FP4 = 21;
public static final int M68K_REG_FP5 = 22;
public static final int M68K_REG_FP6 = 23;
public static final int M68K_REG_FP7 = 24;
public static final int M68K_REG_PC = 25;
public static final int M68K_REG_SR = 26;
public static final int M68K_REG_CCR = 27;
public static final int M68K_REG_SFC = 28;
public static final int M68K_REG_DFC = 29;
public static final int M68K_REG_USP = 30;
public static final int M68K_REG_VBR = 31;
public static final int M68K_REG_CACR = 32;
public static final int M68K_REG_CAAR = 33;
public static final int M68K_REG_MSP = 34;
public static final int M68K_REG_ISP = 35;
public static final int M68K_REG_TC = 36;
public static final int M68K_REG_ITT0 = 37;
public static final int M68K_REG_ITT1 = 38;
public static final int M68K_REG_DTT0 = 39;
public static final int M68K_REG_DTT1 = 40;
public static final int M68K_REG_MMUSR = 41;
public static final int M68K_REG_URP = 42;
public static final int M68K_REG_SRP = 43;
public static final int M68K_REG_FPCR = 44;
public static final int M68K_REG_FPSR = 45;
public static final int M68K_REG_FPIAR = 46;
public static final int M68K_REG_ENDING = 47;
public static final int M68K_AM_NONE = 0;
public static final int M68K_AM_REG_DIRECT_DATA = 1;
public static final int M68K_AM_REG_DIRECT_ADDR = 2;
public static final int M68K_AM_REGI_ADDR = 3;
public static final int M68K_AM_REGI_ADDR_POST_INC = 4;
public static final int M68K_AM_REGI_ADDR_PRE_DEC = 5;
public static final int M68K_AM_REGI_ADDR_DISP = 6;
public static final int M68K_AM_AREGI_INDEX_8_BIT_DISP = 7;
public static final int M68K_AM_AREGI_INDEX_BASE_DISP = 8;
public static final int M68K_AM_MEMI_POST_INDEX = 9;
public static final int M68K_AM_MEMI_PRE_INDEX = 10;
public static final int M68K_AM_PCI_DISP = 11;
public static final int M68K_AM_PCI_INDEX_8_BIT_DISP = 12;
public static final int M68K_AM_PCI_INDEX_BASE_DISP = 13;
public static final int M68K_AM_PC_MEMI_POST_INDEX = 14;
public static final int M68K_AM_PC_MEMI_PRE_INDEX = 15;
public static final int M68K_AM_ABSOLUTE_DATA_SHORT = 16;
public static final int M68K_AM_ABSOLUTE_DATA_LONG = 17;
public static final int M68K_AM_IMMEDIATE = 18;
public static final int M68K_AM_BRANCH_DISPLACEMENT = 19;
public static final int M68K_OP_INVALID = CS_OP_INVALID;
public static final int M68K_OP_REG = CS_OP_REG;
public static final int M68K_OP_IMM = CS_OP_IMM;
public static final int M68K_OP_FP_SINGLE = CS_OP_SPECIAL+0;
public static final int M68K_OP_FP_DOUBLE = CS_OP_SPECIAL+1;
public static final int M68K_OP_REG_BITS = CS_OP_SPECIAL+2;
public static final int M68K_OP_REG_PAIR = CS_OP_SPECIAL+3;
public static final int M68K_OP_BR_DISP = CS_OP_SPECIAL+4;
public static final int M68K_OP_MEM = CS_OP_MEM;
public static final int M68K_OP_BR_DISP_SIZE_INVALID = 0;
public static final int M68K_OP_BR_DISP_SIZE_BYTE = 1;
public static final int M68K_OP_BR_DISP_SIZE_WORD = 2;
public static final int M68K_OP_BR_DISP_SIZE_LONG = 4;
public static final int M68K_CPU_SIZE_NONE = 0;
public static final int M68K_CPU_SIZE_BYTE = 1;
public static final int M68K_CPU_SIZE_WORD = 2;
public static final int M68K_CPU_SIZE_LONG = 4;
public static final int M68K_FPU_SIZE_NONE = 0;
public static final int M68K_FPU_SIZE_SINGLE = 4;
public static final int M68K_FPU_SIZE_DOUBLE = 8;
public static final int M68K_FPU_SIZE_EXTENDED = 12;
public static final int M68K_SIZE_TYPE_INVALID = 0;
public static final int M68K_SIZE_TYPE_CPU = 1;
public static final int M68K_SIZE_TYPE_FPU = 2;
public static final int M68K_INS_INVALID = 0;
public static final int M68K_INS_ABCD = 1;
public static final int M68K_INS_ADD = 2;
public static final int M68K_INS_ADDA = 3;
public static final int M68K_INS_ADDI = 4;
public static final int M68K_INS_ADDQ = 5;
public static final int M68K_INS_ADDX = 6;
public static final int M68K_INS_AND = 7;
public static final int M68K_INS_ANDI = 8;
public static final int M68K_INS_ASL = 9;
public static final int M68K_INS_ASR = 10;
public static final int M68K_INS_BHS = 11;
public static final int M68K_INS_BLO = 12;
public static final int M68K_INS_BHI = 13;
public static final int M68K_INS_BLS = 14;
public static final int M68K_INS_BCC = 15;
public static final int M68K_INS_BCS = 16;
public static final int M68K_INS_BNE = 17;
public static final int M68K_INS_BEQ = 18;
public static final int M68K_INS_BVC = 19;
public static final int M68K_INS_BVS = 20;
public static final int M68K_INS_BPL = 21;
public static final int M68K_INS_BMI = 22;
public static final int M68K_INS_BGE = 23;
public static final int M68K_INS_BLT = 24;
public static final int M68K_INS_BGT = 25;
public static final int M68K_INS_BLE = 26;
public static final int M68K_INS_BRA = 27;
public static final int M68K_INS_BSR = 28;
public static final int M68K_INS_BCHG = 29;
public static final int M68K_INS_BCLR = 30;
public static final int M68K_INS_BSET = 31;
public static final int M68K_INS_BTST = 32;
public static final int M68K_INS_BFCHG = 33;
public static final int M68K_INS_BFCLR = 34;
public static final int M68K_INS_BFEXTS = 35;
public static final int M68K_INS_BFEXTU = 36;
public static final int M68K_INS_BFFFO = 37;
public static final int M68K_INS_BFINS = 38;
public static final int M68K_INS_BFSET = 39;
public static final int M68K_INS_BFTST = 40;
public static final int M68K_INS_BKPT = 41;
public static final int M68K_INS_CALLM = 42;
public static final int M68K_INS_CAS = 43;
public static final int M68K_INS_CAS2 = 44;
public static final int M68K_INS_CHK = 45;
public static final int M68K_INS_CHK2 = 46;
public static final int M68K_INS_CLR = 47;
public static final int M68K_INS_CMP = 48;
public static final int M68K_INS_CMPA = 49;
public static final int M68K_INS_CMPI = 50;
public static final int M68K_INS_CMPM = 51;
public static final int M68K_INS_CMP2 = 52;
public static final int M68K_INS_CINVL = 53;
public static final int M68K_INS_CINVP = 54;
public static final int M68K_INS_CINVA = 55;
public static final int M68K_INS_CPUSHL = 56;
public static final int M68K_INS_CPUSHP = 57;
public static final int M68K_INS_CPUSHA = 58;
public static final int M68K_INS_DBT = 59;
public static final int M68K_INS_DBF = 60;
public static final int M68K_INS_DBHI = 61;
public static final int M68K_INS_DBLS = 62;
public static final int M68K_INS_DBCC = 63;
public static final int M68K_INS_DBCS = 64;
public static final int M68K_INS_DBNE = 65;
public static final int M68K_INS_DBEQ = 66;
public static final int M68K_INS_DBVC = 67;
public static final int M68K_INS_DBVS = 68;
public static final int M68K_INS_DBPL = 69;
public static final int M68K_INS_DBMI = 70;
public static final int M68K_INS_DBGE = 71;
public static final int M68K_INS_DBLT = 72;
public static final int M68K_INS_DBGT = 73;
public static final int M68K_INS_DBLE = 74;
public static final int M68K_INS_DBRA = 75;
public static final int M68K_INS_DIVS = 76;
public static final int M68K_INS_DIVSL = 77;
public static final int M68K_INS_DIVU = 78;
public static final int M68K_INS_DIVUL = 79;
public static final int M68K_INS_EOR = 80;
public static final int M68K_INS_EORI = 81;
public static final int M68K_INS_EXG = 82;
public static final int M68K_INS_EXT = 83;
public static final int M68K_INS_EXTB = 84;
public static final int M68K_INS_FABS = 85;
public static final int M68K_INS_FSABS = 86;
public static final int M68K_INS_FDABS = 87;
public static final int M68K_INS_FACOS = 88;
public static final int M68K_INS_FADD = 89;
public static final int M68K_INS_FSADD = 90;
public static final int M68K_INS_FDADD = 91;
public static final int M68K_INS_FASIN = 92;
public static final int M68K_INS_FATAN = 93;
public static final int M68K_INS_FATANH = 94;
public static final int M68K_INS_FBF = 95;
public static final int M68K_INS_FBEQ = 96;
public static final int M68K_INS_FBOGT = 97;
public static final int M68K_INS_FBOGE = 98;
public static final int M68K_INS_FBOLT = 99;
public static final int M68K_INS_FBOLE = 100;
public static final int M68K_INS_FBOGL = 101;
public static final int M68K_INS_FBOR = 102;
public static final int M68K_INS_FBUN = 103;
public static final int M68K_INS_FBUEQ = 104;
public static final int M68K_INS_FBUGT = 105;
public static final int M68K_INS_FBUGE = 106;
public static final int M68K_INS_FBULT = 107;
public static final int M68K_INS_FBULE = 108;
public static final int M68K_INS_FBNE = 109;
public static final int M68K_INS_FBT = 110;
public static final int M68K_INS_FBSF = 111;
public static final int M68K_INS_FBSEQ = 112;
public static final int M68K_INS_FBGT = 113;
public static final int M68K_INS_FBGE = 114;
public static final int M68K_INS_FBLT = 115;
public static final int M68K_INS_FBLE = 116;
public static final int M68K_INS_FBGL = 117;
public static final int M68K_INS_FBGLE = 118;
public static final int M68K_INS_FBNGLE = 119;
public static final int M68K_INS_FBNGL = 120;
public static final int M68K_INS_FBNLE = 121;
public static final int M68K_INS_FBNLT = 122;
public static final int M68K_INS_FBNGE = 123;
public static final int M68K_INS_FBNGT = 124;
public static final int M68K_INS_FBSNE = 125;
public static final int M68K_INS_FBST = 126;
public static final int M68K_INS_FCMP = 127;
public static final int M68K_INS_FCOS = 128;
public static final int M68K_INS_FCOSH = 129;
public static final int M68K_INS_FDBF = 130;
public static final int M68K_INS_FDBEQ = 131;
public static final int M68K_INS_FDBOGT = 132;
public static final int M68K_INS_FDBOGE = 133;
public static final int M68K_INS_FDBOLT = 134;
public static final int M68K_INS_FDBOLE = 135;
public static final int M68K_INS_FDBOGL = 136;
public static final int M68K_INS_FDBOR = 137;
public static final int M68K_INS_FDBUN = 138;
public static final int M68K_INS_FDBUEQ = 139;
public static final int M68K_INS_FDBUGT = 140;
public static final int M68K_INS_FDBUGE = 141;
public static final int M68K_INS_FDBULT = 142;
public static final int M68K_INS_FDBULE = 143;
public static final int M68K_INS_FDBNE = 144;
public static final int M68K_INS_FDBT = 145;
public static final int M68K_INS_FDBSF = 146;
public static final int M68K_INS_FDBSEQ = 147;
public static final int M68K_INS_FDBGT = 148;
public static final int M68K_INS_FDBGE = 149;
public static final int M68K_INS_FDBLT = 150;
public static final int M68K_INS_FDBLE = 151;
public static final int M68K_INS_FDBGL = 152;
public static final int M68K_INS_FDBGLE = 153;
public static final int M68K_INS_FDBNGLE = 154;
public static final int M68K_INS_FDBNGL = 155;
public static final int M68K_INS_FDBNLE = 156;
public static final int M68K_INS_FDBNLT = 157;
public static final int M68K_INS_FDBNGE = 158;
public static final int M68K_INS_FDBNGT = 159;
public static final int M68K_INS_FDBSNE = 160;
public static final int M68K_INS_FDBST = 161;
public static final int M68K_INS_FDIV = 162;
public static final int M68K_INS_FSDIV = 163;
public static final int M68K_INS_FDDIV = 164;
public static final int M68K_INS_FETOX = 165;
public static final int M68K_INS_FETOXM1 = 166;
public static final int M68K_INS_FGETEXP = 167;
public static final int M68K_INS_FGETMAN = 168;
public static final int M68K_INS_FINT = 169;
public static final int M68K_INS_FINTRZ = 170;
public static final int M68K_INS_FLOG10 = 171;
public static final int M68K_INS_FLOG2 = 172;
public static final int M68K_INS_FLOGN = 173;
public static final int M68K_INS_FLOGNP1 = 174;
public static final int M68K_INS_FMOD = 175;
public static final int M68K_INS_FMOVE = 176;
public static final int M68K_INS_FSMOVE = 177;
public static final int M68K_INS_FDMOVE = 178;
public static final int M68K_INS_FMOVECR = 179;
public static final int M68K_INS_FMOVEM = 180;
public static final int M68K_INS_FMUL = 181;
public static final int M68K_INS_FSMUL = 182;
public static final int M68K_INS_FDMUL = 183;
public static final int M68K_INS_FNEG = 184;
public static final int M68K_INS_FSNEG = 185;
public static final int M68K_INS_FDNEG = 186;
public static final int M68K_INS_FNOP = 187;
public static final int M68K_INS_FREM = 188;
public static final int M68K_INS_FRESTORE = 189;
public static final int M68K_INS_FSAVE = 190;
public static final int M68K_INS_FSCALE = 191;
public static final int M68K_INS_FSGLDIV = 192;
public static final int M68K_INS_FSGLMUL = 193;
public static final int M68K_INS_FSIN = 194;
public static final int M68K_INS_FSINCOS = 195;
public static final int M68K_INS_FSINH = 196;
public static final int M68K_INS_FSQRT = 197;
public static final int M68K_INS_FSSQRT = 198;
public static final int M68K_INS_FDSQRT = 199;
public static final int M68K_INS_FSF = 200;
public static final int M68K_INS_FSBEQ = 201;
public static final int M68K_INS_FSOGT = 202;
public static final int M68K_INS_FSOGE = 203;
public static final int M68K_INS_FSOLT = 204;
public static final int M68K_INS_FSOLE = 205;
public static final int M68K_INS_FSOGL = 206;
public static final int M68K_INS_FSOR = 207;
public static final int M68K_INS_FSUN = 208;
public static final int M68K_INS_FSUEQ = 209;
public static final int M68K_INS_FSUGT = 210;
public static final int M68K_INS_FSUGE = 211;
public static final int M68K_INS_FSULT = 212;
public static final int M68K_INS_FSULE = 213;
public static final int M68K_INS_FSNE = 214;
public static final int M68K_INS_FST = 215;
public static final int M68K_INS_FSSF = 216;
public static final int M68K_INS_FSSEQ = 217;
public static final int M68K_INS_FSGT = 218;
public static final int M68K_INS_FSGE = 219;
public static final int M68K_INS_FSLT = 220;
public static final int M68K_INS_FSLE = 221;
public static final int M68K_INS_FSGL = 222;
public static final int M68K_INS_FSGLE = 223;
public static final int M68K_INS_FSNGLE = 224;
public static final int M68K_INS_FSNGL = 225;
public static final int M68K_INS_FSNLE = 226;
public static final int M68K_INS_FSNLT = 227;
public static final int M68K_INS_FSNGE = 228;
public static final int M68K_INS_FSNGT = 229;
public static final int M68K_INS_FSSNE = 230;
public static final int M68K_INS_FSST = 231;
public static final int M68K_INS_FSUB = 232;
public static final int M68K_INS_FSSUB = 233;
public static final int M68K_INS_FDSUB = 234;
public static final int M68K_INS_FTAN = 235;
public static final int M68K_INS_FTANH = 236;
public static final int M68K_INS_FTENTOX = 237;
public static final int M68K_INS_FTRAPF = 238;
public static final int M68K_INS_FTRAPEQ = 239;
public static final int M68K_INS_FTRAPOGT = 240;
public static final int M68K_INS_FTRAPOGE = 241;
public static final int M68K_INS_FTRAPOLT = 242;
public static final int M68K_INS_FTRAPOLE = 243;
public static final int M68K_INS_FTRAPOGL = 244;
public static final int M68K_INS_FTRAPOR = 245;
public static final int M68K_INS_FTRAPUN = 246;
public static final int M68K_INS_FTRAPUEQ = 247;
public static final int M68K_INS_FTRAPUGT = 248;
public static final int M68K_INS_FTRAPUGE = 249;
public static final int M68K_INS_FTRAPULT = 250;
public static final int M68K_INS_FTRAPULE = 251;
public static final int M68K_INS_FTRAPNE = 252;
public static final int M68K_INS_FTRAPT = 253;
public static final int M68K_INS_FTRAPSF = 254;
public static final int M68K_INS_FTRAPSEQ = 255;
public static final int M68K_INS_FTRAPGT = 256;
public static final int M68K_INS_FTRAPGE = 257;
public static final int M68K_INS_FTRAPLT = 258;
public static final int M68K_INS_FTRAPLE = 259;
public static final int M68K_INS_FTRAPGL = 260;
public static final int M68K_INS_FTRAPGLE = 261;
public static final int M68K_INS_FTRAPNGLE = 262;
public static final int M68K_INS_FTRAPNGL = 263;
public static final int M68K_INS_FTRAPNLE = 264;
public static final int M68K_INS_FTRAPNLT = 265;
public static final int M68K_INS_FTRAPNGE = 266;
public static final int M68K_INS_FTRAPNGT = 267;
public static final int M68K_INS_FTRAPSNE = 268;
public static final int M68K_INS_FTRAPST = 269;
public static final int M68K_INS_FTST = 270;
public static final int M68K_INS_FTWOTOX = 271;
public static final int M68K_INS_HALT = 272;
public static final int M68K_INS_ILLEGAL = 273;
public static final int M68K_INS_JMP = 274;
public static final int M68K_INS_JSR = 275;
public static final int M68K_INS_LEA = 276;
public static final int M68K_INS_LINK = 277;
public static final int M68K_INS_LPSTOP = 278;
public static final int M68K_INS_LSL = 279;
public static final int M68K_INS_LSR = 280;
public static final int M68K_INS_MOVE = 281;
public static final int M68K_INS_MOVEA = 282;
public static final int M68K_INS_MOVEC = 283;
public static final int M68K_INS_MOVEM = 284;
public static final int M68K_INS_MOVEP = 285;
public static final int M68K_INS_MOVEQ = 286;
public static final int M68K_INS_MOVES = 287;
public static final int M68K_INS_MOVE16 = 288;
public static final int M68K_INS_MULS = 289;
public static final int M68K_INS_MULU = 290;
public static final int M68K_INS_NBCD = 291;
public static final int M68K_INS_NEG = 292;
public static final int M68K_INS_NEGX = 293;
public static final int M68K_INS_NOP = 294;
public static final int M68K_INS_NOT = 295;
public static final int M68K_INS_OR = 296;
public static final int M68K_INS_ORI = 297;
public static final int M68K_INS_PACK = 298;
public static final int M68K_INS_PEA = 299;
public static final int M68K_INS_PFLUSH = 300;
public static final int M68K_INS_PFLUSHA = 301;
public static final int M68K_INS_PFLUSHAN = 302;
public static final int M68K_INS_PFLUSHN = 303;
public static final int M68K_INS_PLOADR = 304;
public static final int M68K_INS_PLOADW = 305;
public static final int M68K_INS_PLPAR = 306;
public static final int M68K_INS_PLPAW = 307;
public static final int M68K_INS_PMOVE = 308;
public static final int M68K_INS_PMOVEFD = 309;
public static final int M68K_INS_PTESTR = 310;
public static final int M68K_INS_PTESTW = 311;
public static final int M68K_INS_PULSE = 312;
public static final int M68K_INS_REMS = 313;
public static final int M68K_INS_REMU = 314;
public static final int M68K_INS_RESET = 315;
public static final int M68K_INS_ROL = 316;
public static final int M68K_INS_ROR = 317;
public static final int M68K_INS_ROXL = 318;
public static final int M68K_INS_ROXR = 319;
public static final int M68K_INS_RTD = 320;
public static final int M68K_INS_RTE = 321;
public static final int M68K_INS_RTM = 322;
public static final int M68K_INS_RTR = 323;
public static final int M68K_INS_RTS = 324;
public static final int M68K_INS_SBCD = 325;
public static final int M68K_INS_ST = 326;
public static final int M68K_INS_SF = 327;
public static final int M68K_INS_SHI = 328;
public static final int M68K_INS_SLS = 329;
public static final int M68K_INS_SCC = 330;
public static final int M68K_INS_SHS = 331;
public static final int M68K_INS_SCS = 332;
public static final int M68K_INS_SLO = 333;
public static final int M68K_INS_SNE = 334;
public static final int M68K_INS_SEQ = 335;
public static final int M68K_INS_SVC = 336;
public static final int M68K_INS_SVS = 337;
public static final int M68K_INS_SPL = 338;
public static final int M68K_INS_SMI = 339;
public static final int M68K_INS_SGE = 340;
public static final int M68K_INS_SLT = 341;
public static final int M68K_INS_SGT = 342;
public static final int M68K_INS_SLE = 343;
public static final int M68K_INS_STOP = 344;
public static final int M68K_INS_SUB = 345;
public static final int M68K_INS_SUBA = 346;
public static final int M68K_INS_SUBI = 347;
public static final int M68K_INS_SUBQ = 348;
public static final int M68K_INS_SUBX = 349;
public static final int M68K_INS_SWAP = 350;
public static final int M68K_INS_TAS = 351;
public static final int M68K_INS_TRAP = 352;
public static final int M68K_INS_TRAPV = 353;
public static final int M68K_INS_TRAPT = 354;
public static final int M68K_INS_TRAPF = 355;
public static final int M68K_INS_TRAPHI = 356;
public static final int M68K_INS_TRAPLS = 357;
public static final int M68K_INS_TRAPCC = 358;
public static final int M68K_INS_TRAPHS = 359;
public static final int M68K_INS_TRAPCS = 360;
public static final int M68K_INS_TRAPLO = 361;
public static final int M68K_INS_TRAPNE = 362;
public static final int M68K_INS_TRAPEQ = 363;
public static final int M68K_INS_TRAPVC = 364;
public static final int M68K_INS_TRAPVS = 365;
public static final int M68K_INS_TRAPPL = 366;
public static final int M68K_INS_TRAPMI = 367;
public static final int M68K_INS_TRAPGE = 368;
public static final int M68K_INS_TRAPLT = 369;
public static final int M68K_INS_TRAPGT = 370;
public static final int M68K_INS_TRAPLE = 371;
public static final int M68K_INS_TST = 372;
public static final int M68K_INS_UNLK = 373;
public static final int M68K_INS_UNPK = 374;
public static final int M68K_INS_ENDING = 375;
public static final int M68K_GRP_INVALID = 0;
public static final int M68K_GRP_JUMP = 1;
public static final int M68K_GRP_RET = 3;
public static final int M68K_GRP_IRET = 5;
public static final int M68K_GRP_BRANCH_RELATIVE = 7;
public static final int M68K_GRP_ENDING = 8;
}
+88
View File
@@ -0,0 +1,88 @@
// Capstone Java binding
// By Nguyen Anh Quynh & Dang Hoang Vu, 2013
package capstone;
import com.sun.jna.Structure;
import com.sun.jna.Union;
import java.util.List;
import java.util.Arrays;
import static capstone.Mips_const.*;
public class Mips {
public static class MemType extends Structure {
public int base;
public long disp;
@Override
public List getFieldOrder() {
return Arrays.asList("base", "disp");
}
}
public static class OpValue extends Union {
public int reg;
public long imm;
public MemType mem;
@Override
public List getFieldOrder() {
return Arrays.asList("reg", "imm", "mem");
}
}
public static class Operand extends Structure {
public int type;
public OpValue value;
public void read() {
super.read();
if (type == MIPS_OP_MEM)
value.setType(MemType.class);
if (type == MIPS_OP_IMM)
value.setType(Long.TYPE);
if (type == MIPS_OP_REG)
value.setType(Integer.TYPE);
if (type == MIPS_OP_INVALID)
return;
readField("value");
}
@Override
public List getFieldOrder() {
return Arrays.asList("type", "value");
}
}
public static class UnionOpInfo extends Capstone.UnionOpInfo {
public byte op_count;
public Operand [] op;
public UnionOpInfo() {
op = new Operand[10];
}
public void read() {
readField("op_count");
op = new Operand[op_count];
if (op_count != 0)
readField("op");
}
@Override
public List getFieldOrder() {
return Arrays.asList("op_count", "op");
}
}
public static class OpInfo extends Capstone.OpInfo {
public Operand [] op;
public OpInfo(UnionOpInfo e) {
op = e.op;
}
}
}
File diff suppressed because it is too large Load Diff
+109
View File
@@ -0,0 +1,109 @@
// Capstone Java binding
// By Nguyen Anh Quynh & Dang Hoang Vu, 2013
package capstone;
import com.sun.jna.Structure;
import com.sun.jna.Union;
import java.util.List;
import java.util.Arrays;
import static capstone.Ppc_const.*;
public class Ppc {
public static class MemType extends Structure {
public int base;
public int disp;
@Override
public List getFieldOrder() {
return Arrays.asList("base", "disp");
}
}
public static class CrxType extends Structure {
public int scale;
public int reg;
public int cond;
@Override
public List getFieldOrder() {
return Arrays.asList("scale", "reg", "cond");
}
}
public static class OpValue extends Union {
public int reg;
public long imm;
public MemType mem;
public CrxType crx;
}
public static class Operand extends Structure {
public int type;
public OpValue value;
public void read() {
readField("type");
if (type == PPC_OP_MEM)
value.setType(MemType.class);
if (type == PPC_OP_CRX)
value.setType(CrxType.class);
if (type == PPC_OP_IMM || type == PPC_OP_REG)
value.setType(Integer.TYPE);
if (type == PPC_OP_INVALID)
return;
readField("value");
}
@Override
public List getFieldOrder() {
return Arrays.asList("type", "value");
}
}
public static class UnionOpInfo extends Capstone.UnionOpInfo {
public int bc;
public int bh;
public byte update_cr0;
public byte op_count;
public Operand [] op;
public UnionOpInfo() {
op = new Operand[8];
}
public void read() {
readField("bc");
readField("bh");
readField("update_cr0");
readField("op_count");
op = new Operand[op_count];
if (op_count != 0)
readField("op");
}
@Override
public List getFieldOrder() {
return Arrays.asList("bc", "bh", "update_cr0", "op_count", "op");
}
}
public static class OpInfo extends Capstone.OpInfo {
public int bc;
public int bh;
public boolean updateCr0;
public Operand [] op;
public OpInfo(UnionOpInfo op_info) {
bc = op_info.bc;
bh = op_info.bh;
updateCr0 = (op_info.update_cr0 > 0);
op = op_info.op;
}
}
}
File diff suppressed because it is too large Load Diff
+92
View File
@@ -0,0 +1,92 @@
// Capstone Java binding
// By Nguyen Anh Quynh & Dang Hoang Vu, 2013
package capstone;
import com.sun.jna.Structure;
import com.sun.jna.Union;
import java.util.List;
import java.util.Arrays;
import static capstone.Sparc_const.*;
public class Sparc {
public static class MemType extends Structure {
public byte base;
public byte index;
public int disp;
@Override
public List getFieldOrder() {
return Arrays.asList("base", "index", "disp");
}
}
public static class OpValue extends Union {
public int reg;
public int imm;
public MemType mem;
}
public static class Operand extends Structure {
public int type;
public OpValue value;
public void read() {
readField("type");
if (type == SPARC_OP_MEM)
value.setType(MemType.class);
if (type == SPARC_OP_IMM || type == SPARC_OP_REG)
value.setType(Integer.TYPE);
if (type == SPARC_OP_INVALID)
return;
readField("value");
}
@Override
public List getFieldOrder() {
return Arrays.asList("type", "value");
}
}
public static class UnionOpInfo extends Capstone.UnionOpInfo {
public int cc;
public int hint;
public byte op_count;
public Operand [] op;
public UnionOpInfo() {
op = new Operand[4];
}
public void read() {
readField("cc");
readField("hint");
readField("op_count");
op = new Operand[op_count];
if (op_count != 0)
readField("op");
}
@Override
public List getFieldOrder() {
return Arrays.asList("cc", "hint", "op_count", "op");
}
}
public static class OpInfo extends Capstone.OpInfo {
public int cc;
public int hint;
public Operand [] op;
public OpInfo(UnionOpInfo op_info) {
cc = op_info.cc;
hint = op_info.hint;
op = op_info.op;
}
}
}
File diff suppressed because it is too large Load Diff
+91
View File
@@ -0,0 +1,91 @@
// Capstone Java binding
// By Nguyen Anh Quynh & Dang Hoang Vu, 2013
package capstone;
import com.sun.jna.Structure;
import com.sun.jna.Union;
import java.util.List;
import java.util.Arrays;
import static capstone.Sysz_const.*;
public class Systemz {
public static class MemType extends Structure {
public byte base;
public byte index;
public long length;
public long disp;
@Override
public List getFieldOrder() {
return Arrays.asList("base", "index", "length", "disp");
}
}
public static class OpValue extends Union {
public int reg;
public long imm;
public MemType mem;
}
public static class Operand extends Structure {
public int type;
public OpValue value;
public void read() {
readField("type");
if (type == SYSZ_OP_MEM)
value.setType(MemType.class);
if (type == SYSZ_OP_IMM)
value.setType(Long.TYPE);
if (type == SYSZ_OP_REG || type == SYSZ_OP_ACREG)
value.setType(Integer.TYPE);
if (type == SYSZ_OP_INVALID)
return;
readField("value");
}
@Override
public List getFieldOrder() {
return Arrays.asList("type", "value");
}
}
public static class UnionOpInfo extends Capstone.UnionOpInfo {
public int cc;
public byte op_count;
public Operand [] op;
public UnionOpInfo() {
op = new Operand[6];
}
public void read() {
readField("cc");
readField("op_count");
op = new Operand[op_count];
if (op_count != 0)
readField("op");
}
@Override
public List getFieldOrder() {
return Arrays.asList("cc", "op_count", "op");
}
}
public static class OpInfo extends Capstone.OpInfo {
public int cc;
public Operand [] op;
public OpInfo(UnionOpInfo op_info) {
cc = op_info.cc;
op = op_info.op;
}
}
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,280 @@
// For Capstone Engine. AUTO-GENERATED FILE, DO NOT EDIT
package capstone;
public class TMS320C64x_const {
public static final int TMS320C64X_OP_INVALID = CS_OP_INVALID;
public static final int TMS320C64X_OP_REG = CS_OP_REG;
public static final int TMS320C64X_OP_IMM = CS_OP_IMM;
public static final int TMS320C64X_OP_REGPAIR = CS_OP_SPECIAL+0;
public static final int TMS320C64X_OP_MEM = CS_OP_MEM;
public static final int TMS320C64X_MEM_DISP_INVALID = 0;
public static final int TMS320C64X_MEM_DISP_CONSTANT = 1;
public static final int TMS320C64X_MEM_DISP_REGISTER = 2;
public static final int TMS320C64X_MEM_DIR_INVALID = 0;
public static final int TMS320C64X_MEM_DIR_FW = 1;
public static final int TMS320C64X_MEM_DIR_BW = 2;
public static final int TMS320C64X_MEM_MOD_INVALID = 0;
public static final int TMS320C64X_MEM_MOD_NO = 1;
public static final int TMS320C64X_MEM_MOD_PRE = 2;
public static final int TMS320C64X_MEM_MOD_POST = 3;
public static final int TMS320C64X_REG_INVALID = 0;
public static final int TMS320C64X_REG_AMR = 1;
public static final int TMS320C64X_REG_CSR = 2;
public static final int TMS320C64X_REG_DIER = 3;
public static final int TMS320C64X_REG_DNUM = 4;
public static final int TMS320C64X_REG_ECR = 5;
public static final int TMS320C64X_REG_GFPGFR = 6;
public static final int TMS320C64X_REG_GPLYA = 7;
public static final int TMS320C64X_REG_GPLYB = 8;
public static final int TMS320C64X_REG_ICR = 9;
public static final int TMS320C64X_REG_IER = 10;
public static final int TMS320C64X_REG_IERR = 11;
public static final int TMS320C64X_REG_ILC = 12;
public static final int TMS320C64X_REG_IRP = 13;
public static final int TMS320C64X_REG_ISR = 14;
public static final int TMS320C64X_REG_ISTP = 15;
public static final int TMS320C64X_REG_ITSR = 16;
public static final int TMS320C64X_REG_NRP = 17;
public static final int TMS320C64X_REG_NTSR = 18;
public static final int TMS320C64X_REG_REP = 19;
public static final int TMS320C64X_REG_RILC = 20;
public static final int TMS320C64X_REG_SSR = 21;
public static final int TMS320C64X_REG_TSCH = 22;
public static final int TMS320C64X_REG_TSCL = 23;
public static final int TMS320C64X_REG_TSR = 24;
public static final int TMS320C64X_REG_A0 = 25;
public static final int TMS320C64X_REG_A1 = 26;
public static final int TMS320C64X_REG_A2 = 27;
public static final int TMS320C64X_REG_A3 = 28;
public static final int TMS320C64X_REG_A4 = 29;
public static final int TMS320C64X_REG_A5 = 30;
public static final int TMS320C64X_REG_A6 = 31;
public static final int TMS320C64X_REG_A7 = 32;
public static final int TMS320C64X_REG_A8 = 33;
public static final int TMS320C64X_REG_A9 = 34;
public static final int TMS320C64X_REG_A10 = 35;
public static final int TMS320C64X_REG_A11 = 36;
public static final int TMS320C64X_REG_A12 = 37;
public static final int TMS320C64X_REG_A13 = 38;
public static final int TMS320C64X_REG_A14 = 39;
public static final int TMS320C64X_REG_A15 = 40;
public static final int TMS320C64X_REG_A16 = 41;
public static final int TMS320C64X_REG_A17 = 42;
public static final int TMS320C64X_REG_A18 = 43;
public static final int TMS320C64X_REG_A19 = 44;
public static final int TMS320C64X_REG_A20 = 45;
public static final int TMS320C64X_REG_A21 = 46;
public static final int TMS320C64X_REG_A22 = 47;
public static final int TMS320C64X_REG_A23 = 48;
public static final int TMS320C64X_REG_A24 = 49;
public static final int TMS320C64X_REG_A25 = 50;
public static final int TMS320C64X_REG_A26 = 51;
public static final int TMS320C64X_REG_A27 = 52;
public static final int TMS320C64X_REG_A28 = 53;
public static final int TMS320C64X_REG_A29 = 54;
public static final int TMS320C64X_REG_A30 = 55;
public static final int TMS320C64X_REG_A31 = 56;
public static final int TMS320C64X_REG_B0 = 57;
public static final int TMS320C64X_REG_B1 = 58;
public static final int TMS320C64X_REG_B2 = 59;
public static final int TMS320C64X_REG_B3 = 60;
public static final int TMS320C64X_REG_B4 = 61;
public static final int TMS320C64X_REG_B5 = 62;
public static final int TMS320C64X_REG_B6 = 63;
public static final int TMS320C64X_REG_B7 = 64;
public static final int TMS320C64X_REG_B8 = 65;
public static final int TMS320C64X_REG_B9 = 66;
public static final int TMS320C64X_REG_B10 = 67;
public static final int TMS320C64X_REG_B11 = 68;
public static final int TMS320C64X_REG_B12 = 69;
public static final int TMS320C64X_REG_B13 = 70;
public static final int TMS320C64X_REG_B14 = 71;
public static final int TMS320C64X_REG_B15 = 72;
public static final int TMS320C64X_REG_B16 = 73;
public static final int TMS320C64X_REG_B17 = 74;
public static final int TMS320C64X_REG_B18 = 75;
public static final int TMS320C64X_REG_B19 = 76;
public static final int TMS320C64X_REG_B20 = 77;
public static final int TMS320C64X_REG_B21 = 78;
public static final int TMS320C64X_REG_B22 = 79;
public static final int TMS320C64X_REG_B23 = 80;
public static final int TMS320C64X_REG_B24 = 81;
public static final int TMS320C64X_REG_B25 = 82;
public static final int TMS320C64X_REG_B26 = 83;
public static final int TMS320C64X_REG_B27 = 84;
public static final int TMS320C64X_REG_B28 = 85;
public static final int TMS320C64X_REG_B29 = 86;
public static final int TMS320C64X_REG_B30 = 87;
public static final int TMS320C64X_REG_B31 = 88;
public static final int TMS320C64X_REG_PCE1 = 89;
public static final int TMS320C64X_REG_ENDING = 90;
public static final int TMS320C64X_REG_EFR = TMS320C64X_REG_ECR;
public static final int TMS320C64X_REG_IFR = TMS320C64X_REG_ISR;
public static final int TMS320C64X_INS_INVALID = 0;
public static final int TMS320C64X_INS_ABS = 1;
public static final int TMS320C64X_INS_ABS2 = 2;
public static final int TMS320C64X_INS_ADD = 3;
public static final int TMS320C64X_INS_ADD2 = 4;
public static final int TMS320C64X_INS_ADD4 = 5;
public static final int TMS320C64X_INS_ADDAB = 6;
public static final int TMS320C64X_INS_ADDAD = 7;
public static final int TMS320C64X_INS_ADDAH = 8;
public static final int TMS320C64X_INS_ADDAW = 9;
public static final int TMS320C64X_INS_ADDK = 10;
public static final int TMS320C64X_INS_ADDKPC = 11;
public static final int TMS320C64X_INS_ADDU = 12;
public static final int TMS320C64X_INS_AND = 13;
public static final int TMS320C64X_INS_ANDN = 14;
public static final int TMS320C64X_INS_AVG2 = 15;
public static final int TMS320C64X_INS_AVGU4 = 16;
public static final int TMS320C64X_INS_B = 17;
public static final int TMS320C64X_INS_BDEC = 18;
public static final int TMS320C64X_INS_BITC4 = 19;
public static final int TMS320C64X_INS_BNOP = 20;
public static final int TMS320C64X_INS_BPOS = 21;
public static final int TMS320C64X_INS_CLR = 22;
public static final int TMS320C64X_INS_CMPEQ = 23;
public static final int TMS320C64X_INS_CMPEQ2 = 24;
public static final int TMS320C64X_INS_CMPEQ4 = 25;
public static final int TMS320C64X_INS_CMPGT = 26;
public static final int TMS320C64X_INS_CMPGT2 = 27;
public static final int TMS320C64X_INS_CMPGTU4 = 28;
public static final int TMS320C64X_INS_CMPLT = 29;
public static final int TMS320C64X_INS_CMPLTU = 30;
public static final int TMS320C64X_INS_DEAL = 31;
public static final int TMS320C64X_INS_DOTP2 = 32;
public static final int TMS320C64X_INS_DOTPN2 = 33;
public static final int TMS320C64X_INS_DOTPNRSU2 = 34;
public static final int TMS320C64X_INS_DOTPRSU2 = 35;
public static final int TMS320C64X_INS_DOTPSU4 = 36;
public static final int TMS320C64X_INS_DOTPU4 = 37;
public static final int TMS320C64X_INS_EXT = 38;
public static final int TMS320C64X_INS_EXTU = 39;
public static final int TMS320C64X_INS_GMPGTU = 40;
public static final int TMS320C64X_INS_GMPY4 = 41;
public static final int TMS320C64X_INS_LDB = 42;
public static final int TMS320C64X_INS_LDBU = 43;
public static final int TMS320C64X_INS_LDDW = 44;
public static final int TMS320C64X_INS_LDH = 45;
public static final int TMS320C64X_INS_LDHU = 46;
public static final int TMS320C64X_INS_LDNDW = 47;
public static final int TMS320C64X_INS_LDNW = 48;
public static final int TMS320C64X_INS_LDW = 49;
public static final int TMS320C64X_INS_LMBD = 50;
public static final int TMS320C64X_INS_MAX2 = 51;
public static final int TMS320C64X_INS_MAXU4 = 52;
public static final int TMS320C64X_INS_MIN2 = 53;
public static final int TMS320C64X_INS_MINU4 = 54;
public static final int TMS320C64X_INS_MPY = 55;
public static final int TMS320C64X_INS_MPY2 = 56;
public static final int TMS320C64X_INS_MPYH = 57;
public static final int TMS320C64X_INS_MPYHI = 58;
public static final int TMS320C64X_INS_MPYHIR = 59;
public static final int TMS320C64X_INS_MPYHL = 60;
public static final int TMS320C64X_INS_MPYHLU = 61;
public static final int TMS320C64X_INS_MPYHSLU = 62;
public static final int TMS320C64X_INS_MPYHSU = 63;
public static final int TMS320C64X_INS_MPYHU = 64;
public static final int TMS320C64X_INS_MPYHULS = 65;
public static final int TMS320C64X_INS_MPYHUS = 66;
public static final int TMS320C64X_INS_MPYLH = 67;
public static final int TMS320C64X_INS_MPYLHU = 68;
public static final int TMS320C64X_INS_MPYLI = 69;
public static final int TMS320C64X_INS_MPYLIR = 70;
public static final int TMS320C64X_INS_MPYLSHU = 71;
public static final int TMS320C64X_INS_MPYLUHS = 72;
public static final int TMS320C64X_INS_MPYSU = 73;
public static final int TMS320C64X_INS_MPYSU4 = 74;
public static final int TMS320C64X_INS_MPYU = 75;
public static final int TMS320C64X_INS_MPYU4 = 76;
public static final int TMS320C64X_INS_MPYUS = 77;
public static final int TMS320C64X_INS_MVC = 78;
public static final int TMS320C64X_INS_MVD = 79;
public static final int TMS320C64X_INS_MVK = 80;
public static final int TMS320C64X_INS_MVKL = 81;
public static final int TMS320C64X_INS_MVKLH = 82;
public static final int TMS320C64X_INS_NOP = 83;
public static final int TMS320C64X_INS_NORM = 84;
public static final int TMS320C64X_INS_OR = 85;
public static final int TMS320C64X_INS_PACK2 = 86;
public static final int TMS320C64X_INS_PACKH2 = 87;
public static final int TMS320C64X_INS_PACKH4 = 88;
public static final int TMS320C64X_INS_PACKHL2 = 89;
public static final int TMS320C64X_INS_PACKL4 = 90;
public static final int TMS320C64X_INS_PACKLH2 = 91;
public static final int TMS320C64X_INS_ROTL = 92;
public static final int TMS320C64X_INS_SADD = 93;
public static final int TMS320C64X_INS_SADD2 = 94;
public static final int TMS320C64X_INS_SADDU4 = 95;
public static final int TMS320C64X_INS_SADDUS2 = 96;
public static final int TMS320C64X_INS_SAT = 97;
public static final int TMS320C64X_INS_SET = 98;
public static final int TMS320C64X_INS_SHFL = 99;
public static final int TMS320C64X_INS_SHL = 100;
public static final int TMS320C64X_INS_SHLMB = 101;
public static final int TMS320C64X_INS_SHR = 102;
public static final int TMS320C64X_INS_SHR2 = 103;
public static final int TMS320C64X_INS_SHRMB = 104;
public static final int TMS320C64X_INS_SHRU = 105;
public static final int TMS320C64X_INS_SHRU2 = 106;
public static final int TMS320C64X_INS_SMPY = 107;
public static final int TMS320C64X_INS_SMPY2 = 108;
public static final int TMS320C64X_INS_SMPYH = 109;
public static final int TMS320C64X_INS_SMPYHL = 110;
public static final int TMS320C64X_INS_SMPYLH = 111;
public static final int TMS320C64X_INS_SPACK2 = 112;
public static final int TMS320C64X_INS_SPACKU4 = 113;
public static final int TMS320C64X_INS_SSHL = 114;
public static final int TMS320C64X_INS_SSHVL = 115;
public static final int TMS320C64X_INS_SSHVR = 116;
public static final int TMS320C64X_INS_SSUB = 117;
public static final int TMS320C64X_INS_STB = 118;
public static final int TMS320C64X_INS_STDW = 119;
public static final int TMS320C64X_INS_STH = 120;
public static final int TMS320C64X_INS_STNDW = 121;
public static final int TMS320C64X_INS_STNW = 122;
public static final int TMS320C64X_INS_STW = 123;
public static final int TMS320C64X_INS_SUB = 124;
public static final int TMS320C64X_INS_SUB2 = 125;
public static final int TMS320C64X_INS_SUB4 = 126;
public static final int TMS320C64X_INS_SUBAB = 127;
public static final int TMS320C64X_INS_SUBABS4 = 128;
public static final int TMS320C64X_INS_SUBAH = 129;
public static final int TMS320C64X_INS_SUBAW = 130;
public static final int TMS320C64X_INS_SUBC = 131;
public static final int TMS320C64X_INS_SUBU = 132;
public static final int TMS320C64X_INS_SWAP4 = 133;
public static final int TMS320C64X_INS_UNPKHU4 = 134;
public static final int TMS320C64X_INS_UNPKLU4 = 135;
public static final int TMS320C64X_INS_XOR = 136;
public static final int TMS320C64X_INS_XPND2 = 137;
public static final int TMS320C64X_INS_XPND4 = 138;
public static final int TMS320C64X_INS_IDLE = 139;
public static final int TMS320C64X_INS_MV = 140;
public static final int TMS320C64X_INS_NEG = 141;
public static final int TMS320C64X_INS_NOT = 142;
public static final int TMS320C64X_INS_SWAP2 = 143;
public static final int TMS320C64X_INS_ZERO = 144;
public static final int TMS320C64X_INS_ENDING = 145;
public static final int TMS320C64X_GRP_INVALID = 0;
public static final int TMS320C64X_GRP_JUMP = 1;
public static final int TMS320C64X_GRP_FUNIT_D = 128;
public static final int TMS320C64X_GRP_FUNIT_L = 129;
public static final int TMS320C64X_GRP_FUNIT_M = 130;
public static final int TMS320C64X_GRP_FUNIT_S = 131;
public static final int TMS320C64X_GRP_FUNIT_NO = 132;
public static final int TMS320C64X_GRP_ENDING = 133;
public static final int TMS320C64X_FUNIT_INVALID = 0;
public static final int TMS320C64X_FUNIT_D = 1;
public static final int TMS320C64X_FUNIT_L = 2;
public static final int TMS320C64X_FUNIT_M = 3;
public static final int TMS320C64X_FUNIT_S = 4;
public static final int TMS320C64X_FUNIT_NO = 5;
}
+194
View File
@@ -0,0 +1,194 @@
// For Capstone Engine. AUTO-GENERATED FILE, DO NOT EDIT
package capstone;
public class Wasm_const {
public static final int WASM_OP_INVALID = CS_OP_INVALID;
public static final int WASM_OP_IMM = CS_OP_IMM;
public static final int WASM_OP_NONE = CS_OP_SPECIAL+0;
public static final int WASM_OP_INT7 = CS_OP_SPECIAL+1;
public static final int WASM_OP_VARUINT32 = CS_OP_SPECIAL+2;
public static final int WASM_OP_VARUINT64 = CS_OP_SPECIAL+3;
public static final int WASM_OP_UINT32 = CS_OP_SPECIAL+4;
public static final int WASM_OP_UINT64 = CS_OP_SPECIAL+5;
public static final int WASM_OP_BRTABLE = CS_OP_SPECIAL+6;
public static final int WASM_INS_UNREACHABLE = 0x0;
public static final int WASM_INS_NOP = 0x1;
public static final int WASM_INS_BLOCK = 0x2;
public static final int WASM_INS_LOOP = 0x3;
public static final int WASM_INS_IF = 0x4;
public static final int WASM_INS_ELSE = 0x5;
public static final int WASM_INS_END = 0xb;
public static final int WASM_INS_BR = 0xc;
public static final int WASM_INS_BR_IF = 0xd;
public static final int WASM_INS_BR_TABLE = 0xe;
public static final int WASM_INS_RETURN = 0xf;
public static final int WASM_INS_CALL = 0x10;
public static final int WASM_INS_CALL_INDIRECT = 0x11;
public static final int WASM_INS_DROP = 0x1a;
public static final int WASM_INS_SELECT = 0x1b;
public static final int WASM_INS_GET_LOCAL = 0x20;
public static final int WASM_INS_SET_LOCAL = 0x21;
public static final int WASM_INS_TEE_LOCAL = 0x22;
public static final int WASM_INS_GET_GLOBAL = 0x23;
public static final int WASM_INS_SET_GLOBAL = 0x24;
public static final int WASM_INS_I32_LOAD = 0x28;
public static final int WASM_INS_I64_LOAD = 0x29;
public static final int WASM_INS_F32_LOAD = 0x2a;
public static final int WASM_INS_F64_LOAD = 0x2b;
public static final int WASM_INS_I32_LOAD8_S = 0x2c;
public static final int WASM_INS_I32_LOAD8_U = 0x2d;
public static final int WASM_INS_I32_LOAD16_S = 0x2e;
public static final int WASM_INS_I32_LOAD16_U = 0x2f;
public static final int WASM_INS_I64_LOAD8_S = 0x30;
public static final int WASM_INS_I64_LOAD8_U = 0x31;
public static final int WASM_INS_I64_LOAD16_S = 0x32;
public static final int WASM_INS_I64_LOAD16_U = 0x33;
public static final int WASM_INS_I64_LOAD32_S = 0x34;
public static final int WASM_INS_I64_LOAD32_U = 0x35;
public static final int WASM_INS_I32_STORE = 0x36;
public static final int WASM_INS_I64_STORE = 0x37;
public static final int WASM_INS_F32_STORE = 0x38;
public static final int WASM_INS_F64_STORE = 0x39;
public static final int WASM_INS_I32_STORE8 = 0x3a;
public static final int WASM_INS_I32_STORE16 = 0x3b;
public static final int WASM_INS_I64_STORE8 = 0x3c;
public static final int WASM_INS_I64_STORE16 = 0x3d;
public static final int WASM_INS_I64_STORE32 = 0x3e;
public static final int WASM_INS_CURRENT_MEMORY = 0x3f;
public static final int WASM_INS_GROW_MEMORY = 0x40;
public static final int WASM_INS_I32_CONST = 0x41;
public static final int WASM_INS_I64_CONST = 0x42;
public static final int WASM_INS_F32_CONST = 0x43;
public static final int WASM_INS_F64_CONST = 0x44;
public static final int WASM_INS_I32_EQZ = 0x45;
public static final int WASM_INS_I32_EQ = 0x46;
public static final int WASM_INS_I32_NE = 0x47;
public static final int WASM_INS_I32_LT_S = 0x48;
public static final int WASM_INS_I32_LT_U = 0x49;
public static final int WASM_INS_I32_GT_S = 0x4a;
public static final int WASM_INS_I32_GT_U = 0x4b;
public static final int WASM_INS_I32_LE_S = 0x4c;
public static final int WASM_INS_I32_LE_U = 0x4d;
public static final int WASM_INS_I32_GE_S = 0x4e;
public static final int WASM_INS_I32_GE_U = 0x4f;
public static final int WASM_INS_I64_EQZ = 0x50;
public static final int WASM_INS_I64_EQ = 0x51;
public static final int WASM_INS_I64_NE = 0x52;
public static final int WASM_INS_I64_LT_S = 0x53;
public static final int WASM_INS_I64_LT_U = 0x54;
public static final int WASM_INS_I64_GT_U = 0x56;
public static final int WASM_INS_I64_LE_S = 0x57;
public static final int WASM_INS_I64_LE_U = 0x58;
public static final int WASM_INS_I64_GE_S = 0x59;
public static final int WASM_INS_I64_GE_U = 0x5a;
public static final int WASM_INS_F32_EQ = 0x5b;
public static final int WASM_INS_F32_NE = 0x5c;
public static final int WASM_INS_F32_LT = 0x5d;
public static final int WASM_INS_F32_GT = 0x5e;
public static final int WASM_INS_F32_LE = 0x5f;
public static final int WASM_INS_F32_GE = 0x60;
public static final int WASM_INS_F64_EQ = 0x61;
public static final int WASM_INS_F64_NE = 0x62;
public static final int WASM_INS_F64_LT = 0x63;
public static final int WASM_INS_F64_GT = 0x64;
public static final int WASM_INS_F64_LE = 0x65;
public static final int WASM_INS_F64_GE = 0x66;
public static final int WASM_INS_I32_CLZ = 0x67;
public static final int WASM_INS_I32_CTZ = 0x68;
public static final int WASM_INS_I32_POPCNT = 0x69;
public static final int WASM_INS_I32_ADD = 0x6a;
public static final int WASM_INS_I32_SUB = 0x6b;
public static final int WASM_INS_I32_MUL = 0x6c;
public static final int WASM_INS_I32_DIV_S = 0x6d;
public static final int WASM_INS_I32_DIV_U = 0x6e;
public static final int WASM_INS_I32_REM_S = 0x6f;
public static final int WASM_INS_I32_REM_U = 0x70;
public static final int WASM_INS_I32_AND = 0x71;
public static final int WASM_INS_I32_OR = 0x72;
public static final int WASM_INS_I32_XOR = 0x73;
public static final int WASM_INS_I32_SHL = 0x74;
public static final int WASM_INS_I32_SHR_S = 0x75;
public static final int WASM_INS_I32_SHR_U = 0x76;
public static final int WASM_INS_I32_ROTL = 0x77;
public static final int WASM_INS_I32_ROTR = 0x78;
public static final int WASM_INS_I64_CLZ = 0x79;
public static final int WASM_INS_I64_CTZ = 0x7a;
public static final int WASM_INS_I64_POPCNT = 0x7b;
public static final int WASM_INS_I64_ADD = 0x7c;
public static final int WASM_INS_I64_SUB = 0x7d;
public static final int WASM_INS_I64_MUL = 0x7e;
public static final int WASM_INS_I64_DIV_S = 0x7f;
public static final int WASM_INS_I64_DIV_U = 0x80;
public static final int WASM_INS_I64_REM_S = 0x81;
public static final int WASM_INS_I64_REM_U = 0x82;
public static final int WASM_INS_I64_AND = 0x83;
public static final int WASM_INS_I64_OR = 0x84;
public static final int WASM_INS_I64_XOR = 0x85;
public static final int WASM_INS_I64_SHL = 0x86;
public static final int WASM_INS_I64_SHR_S = 0x87;
public static final int WASM_INS_I64_SHR_U = 0x88;
public static final int WASM_INS_I64_ROTL = 0x89;
public static final int WASM_INS_I64_ROTR = 0x8a;
public static final int WASM_INS_F32_ABS = 0x8b;
public static final int WASM_INS_F32_NEG = 0x8c;
public static final int WASM_INS_F32_CEIL = 0x8d;
public static final int WASM_INS_F32_FLOOR = 0x8e;
public static final int WASM_INS_F32_TRUNC = 0x8f;
public static final int WASM_INS_F32_NEAREST = 0x90;
public static final int WASM_INS_F32_SQRT = 0x91;
public static final int WASM_INS_F32_ADD = 0x92;
public static final int WASM_INS_F32_SUB = 0x93;
public static final int WASM_INS_F32_MUL = 0x94;
public static final int WASM_INS_F32_DIV = 0x95;
public static final int WASM_INS_F32_MIN = 0x96;
public static final int WASM_INS_F32_MAX = 0x97;
public static final int WASM_INS_F32_COPYSIGN = 0x98;
public static final int WASM_INS_F64_ABS = 0x99;
public static final int WASM_INS_F64_NEG = 0x9a;
public static final int WASM_INS_F64_CEIL = 0x9b;
public static final int WASM_INS_F64_FLOOR = 0x9c;
public static final int WASM_INS_F64_TRUNC = 0x9d;
public static final int WASM_INS_F64_NEAREST = 0x9e;
public static final int WASM_INS_F64_SQRT = 0x9f;
public static final int WASM_INS_F64_ADD = 0xa0;
public static final int WASM_INS_F64_SUB = 0xa1;
public static final int WASM_INS_F64_MUL = 0xa2;
public static final int WASM_INS_F64_DIV = 0xa3;
public static final int WASM_INS_F64_MIN = 0xa4;
public static final int WASM_INS_F64_MAX = 0xa5;
public static final int WASM_INS_F64_COPYSIGN = 0xa6;
public static final int WASM_INS_I32_WARP_I64 = 0xa7;
public static final int WASM_INS_I32_TRUNC_U_F32 = 0xa9;
public static final int WASM_INS_I32_TRUNC_S_F64 = 0xaa;
public static final int WASM_INS_I32_TRUNC_U_F64 = 0xab;
public static final int WASM_INS_I64_EXTEND_S_I32 = 0xac;
public static final int WASM_INS_I64_EXTEND_U_I32 = 0xad;
public static final int WASM_INS_I64_TRUNC_S_F32 = 0xae;
public static final int WASM_INS_I64_TRUNC_U_F32 = 0xaf;
public static final int WASM_INS_I64_TRUNC_S_F64 = 0xb0;
public static final int WASM_INS_I64_TRUNC_U_F64 = 0xb1;
public static final int WASM_INS_F32_CONVERT_S_I32 = 0xb2;
public static final int WASM_INS_F32_CONVERT_U_I32 = 0xb3;
public static final int WASM_INS_F32_CONVERT_S_I64 = 0xb4;
public static final int WASM_INS_F32_CONVERT_U_I64 = 0xb5;
public static final int WASM_INS_F32_DEMOTE_F64 = 0xb6;
public static final int WASM_INS_F64_CONVERT_S_I32 = 0xb7;
public static final int WASM_INS_F64_CONVERT_U_I32 = 0xb8;
public static final int WASM_INS_F64_CONVERT_S_I64 = 0xb9;
public static final int WASM_INS_F64_CONVERT_U_I64 = 0xba;
public static final int WASM_INS_F64_PROMOTE_F32 = 0xbb;
public static final int WASM_INS_I32_REINTERPRET_F32 = 0xbc;
public static final int WASM_INS_I64_REINTERPRET_F64 = 0xbd;
public static final int WASM_INS_F32_REINTERPRET_I32 = 0xbe;
public static final int WASM_INS_F64_REINTERPRET_I64 = 0xbf;
public static final int WASM_INS_INVALID = 512;
public static final int WASM_INS_ENDING = 513;
public static final int WASM_GRP_INVALID = 0;
public static final int WASM_GRP_NUMBERIC = 8;
public static final int WASM_GRP_PARAMETRIC = 9;
public static final int WASM_GRP_VARIABLE = 10;
public static final int WASM_GRP_MEMORY = 11;
public static final int WASM_GRP_CONTROL = 12;
public static final int WASM_GRP_ENDING = 13;
}
+165
View File
@@ -0,0 +1,165 @@
// Capstone Java binding
// By Nguyen Anh Quynh & Dang Hoang Vu, 2013
package capstone;
import com.sun.jna.Structure;
import com.sun.jna.Union;
import java.util.List;
import java.util.Arrays;
import static capstone.X86_const.*;
public class X86 {
public static class MemType extends Structure {
public int segment;
public int base;
public int index;
public int scale;
public long disp;
@Override
public List getFieldOrder() {
return Arrays.asList("segment", "base", "index", "scale", "disp");
}
}
public static class Encoding extends Structure {
public byte modrmOffset;
public byte dispOffset;
public byte dispSize;
public byte immOffset;
public byte immSize;
@Override
public List getFieldOrder() {
return Arrays.asList("modrmOffset", "dispOffset", "dispSize", "immOffset", "immSize");
}
}
public static class OpValue extends Union {
public int reg;
public long imm;
public MemType mem;
@Override
public List getFieldOrder() {
return Arrays.asList("reg", "imm", "mem");
}
}
public static class Operand extends Structure {
public int type;
public OpValue value;
public byte size;
public byte access;
public int avx_bcast;
public boolean avx_zero_opmask;
public void read() {
super.read();
if (type == X86_OP_MEM)
value.setType(MemType.class);
if (type == X86_OP_IMM)
value.setType(Long.TYPE);
if (type == X86_OP_REG)
value.setType(Integer.TYPE);
if (type == X86_OP_INVALID)
return;
readField("value");
}
@Override
public List getFieldOrder() {
return Arrays.asList("type", "value", "size", "access", "avx_bcast", "avx_zero_opmask");
}
}
public static class UnionOpInfo extends Capstone.UnionOpInfo {
public byte [] prefix;
public byte [] opcode;
public byte rex;
public byte addr_size;
public byte modrm;
public byte sib;
public long disp;
public int sib_index;
public byte sib_scale;
public int sib_base;
public int xop_cc;
public int sse_cc;
public int avx_cc;
public byte avx_sae;
public int avx_rm;
public long eflags;
public byte op_count;
public Operand [] op;
public Encoding encoding;
public UnionOpInfo() {
op = new Operand[8];
opcode = new byte[4];
prefix = new byte[4];
}
@Override
public List getFieldOrder() {
return Arrays.asList("prefix", "opcode", "rex", "addr_size",
"modrm", "sib", "disp", "sib_index", "sib_scale", "sib_base", "xop_cc", "sse_cc", "avx_cc", "avx_sae", "avx_rm", "eflags", "op_count", "op", "encoding");
}
}
public static class OpInfo extends Capstone.OpInfo {
public byte [] prefix;
public byte [] opcode;
public byte opSize;
public byte rex;
public byte addrSize;
public byte dispSize;
public byte immSize;
public byte modrm;
public byte sib;
public long disp;
public int sibIndex;
public byte sibScale;
public int sibBase;
public int xopCC;
public int sseCC;
public int avxCC;
public boolean avxSae;
public int avxRm;
public long eflags;
public Operand[] op;
public Encoding encoding;
public OpInfo(UnionOpInfo e) {
prefix = e.prefix;
opcode = e.opcode;
rex = e.rex;
addrSize = e.addr_size;
modrm = e.modrm;
sib = e.sib;
disp = e.disp;
sibIndex = e.sib_index;
sibScale = e.sib_scale;
sibBase = e.sib_base;
xopCC = e.xop_cc;
sseCC = e.sse_cc;
avxCC = e.avx_cc;
avxSae = e.avx_sae > 0;
avxRm = e.avx_rm;
eflags = e.eflags;
op = new Operand[e.op_count];
for (int i=0; i<e.op_count; i++)
op[i] = e.op[i];
encoding = e.encoding;
}
}
}
File diff suppressed because it is too large Load Diff
+83
View File
@@ -0,0 +1,83 @@
// Capstone Java binding
// By Nguyen Anh Quynh & Dang Hoang Vu, 2013
package capstone;
import com.sun.jna.Structure;
import com.sun.jna.Union;
import java.util.List;
import java.util.Arrays;
import static capstone.Xcore_const.*;
public class Xcore {
public static class MemType extends Structure {
public byte base;
public byte index;
public int disp;
public int direct;
@Override
public List getFieldOrder() {
return Arrays.asList("base", "index", "disp", "direct");
}
}
public static class OpValue extends Union {
public int reg;
public int imm;
public MemType mem;
}
public static class Operand extends Structure {
public int type;
public OpValue value;
public void read() {
readField("type");
if (type == XCORE_OP_MEM)
value.setType(MemType.class);
if (type == XCORE_OP_IMM || type == XCORE_OP_REG)
value.setType(Integer.TYPE);
if (type == XCORE_OP_INVALID)
return;
readField("value");
}
@Override
public List getFieldOrder() {
return Arrays.asList("type", "value");
}
}
public static class UnionOpInfo extends Capstone.UnionOpInfo {
public byte op_count;
public Operand [] op;
public UnionOpInfo() {
op = new Operand[8];
}
public void read() {
readField("op_count");
op = new Operand[op_count];
if (op_count != 0)
readField("op");
}
@Override
public List getFieldOrder() {
return Arrays.asList("op_count", "op");
}
}
public static class OpInfo extends Capstone.OpInfo {
public Operand [] op;
public OpInfo(UnionOpInfo op_info) {
op = op_info.op;
}
}
}
@@ -0,0 +1,164 @@
// For Capstone Engine. AUTO-GENERATED FILE, DO NOT EDIT
package capstone;
public class Xcore_const {
public static final int XCORE_OP_INVALID = CS_OP_INVALID;
public static final int XCORE_OP_REG = CS_OP_REG;
public static final int XCORE_OP_IMM = CS_OP_IMM;
public static final int XCORE_OP_MEM = CS_OP_MEM;
public static final int XCORE_REG_INVALID = 0;
public static final int XCORE_REG_CP = 1;
public static final int XCORE_REG_DP = 2;
public static final int XCORE_REG_LR = 3;
public static final int XCORE_REG_SP = 4;
public static final int XCORE_REG_R0 = 5;
public static final int XCORE_REG_R1 = 6;
public static final int XCORE_REG_R2 = 7;
public static final int XCORE_REG_R3 = 8;
public static final int XCORE_REG_R4 = 9;
public static final int XCORE_REG_R5 = 10;
public static final int XCORE_REG_R6 = 11;
public static final int XCORE_REG_R7 = 12;
public static final int XCORE_REG_R8 = 13;
public static final int XCORE_REG_R9 = 14;
public static final int XCORE_REG_R10 = 15;
public static final int XCORE_REG_R11 = 16;
public static final int XCORE_REG_PC = 17;
public static final int XCORE_REG_SCP = 18;
public static final int XCORE_REG_SSR = 19;
public static final int XCORE_REG_ET = 20;
public static final int XCORE_REG_ED = 21;
public static final int XCORE_REG_SED = 22;
public static final int XCORE_REG_KEP = 23;
public static final int XCORE_REG_KSP = 24;
public static final int XCORE_REG_ID = 25;
public static final int XCORE_REG_ENDING = 26;
public static final int XCORE_INS_INVALID = 0;
public static final int XCORE_INS_ADD = 1;
public static final int XCORE_INS_ANDNOT = 2;
public static final int XCORE_INS_AND = 3;
public static final int XCORE_INS_ASHR = 4;
public static final int XCORE_INS_BAU = 5;
public static final int XCORE_INS_BITREV = 6;
public static final int XCORE_INS_BLA = 7;
public static final int XCORE_INS_BLAT = 8;
public static final int XCORE_INS_BL = 9;
public static final int XCORE_INS_BF = 10;
public static final int XCORE_INS_BT = 11;
public static final int XCORE_INS_BU = 12;
public static final int XCORE_INS_BRU = 13;
public static final int XCORE_INS_BYTEREV = 14;
public static final int XCORE_INS_CHKCT = 15;
public static final int XCORE_INS_CLRE = 16;
public static final int XCORE_INS_CLRPT = 17;
public static final int XCORE_INS_CLRSR = 18;
public static final int XCORE_INS_CLZ = 19;
public static final int XCORE_INS_CRC8 = 20;
public static final int XCORE_INS_CRC32 = 21;
public static final int XCORE_INS_DCALL = 22;
public static final int XCORE_INS_DENTSP = 23;
public static final int XCORE_INS_DGETREG = 24;
public static final int XCORE_INS_DIVS = 25;
public static final int XCORE_INS_DIVU = 26;
public static final int XCORE_INS_DRESTSP = 27;
public static final int XCORE_INS_DRET = 28;
public static final int XCORE_INS_ECALLF = 29;
public static final int XCORE_INS_ECALLT = 30;
public static final int XCORE_INS_EDU = 31;
public static final int XCORE_INS_EEF = 32;
public static final int XCORE_INS_EET = 33;
public static final int XCORE_INS_EEU = 34;
public static final int XCORE_INS_ENDIN = 35;
public static final int XCORE_INS_ENTSP = 36;
public static final int XCORE_INS_EQ = 37;
public static final int XCORE_INS_EXTDP = 38;
public static final int XCORE_INS_EXTSP = 39;
public static final int XCORE_INS_FREER = 40;
public static final int XCORE_INS_FREET = 41;
public static final int XCORE_INS_GETD = 42;
public static final int XCORE_INS_GET = 43;
public static final int XCORE_INS_GETN = 44;
public static final int XCORE_INS_GETR = 45;
public static final int XCORE_INS_GETSR = 46;
public static final int XCORE_INS_GETST = 47;
public static final int XCORE_INS_GETTS = 48;
public static final int XCORE_INS_INCT = 49;
public static final int XCORE_INS_INIT = 50;
public static final int XCORE_INS_INPW = 51;
public static final int XCORE_INS_INSHR = 52;
public static final int XCORE_INS_INT = 53;
public static final int XCORE_INS_IN = 54;
public static final int XCORE_INS_KCALL = 55;
public static final int XCORE_INS_KENTSP = 56;
public static final int XCORE_INS_KRESTSP = 57;
public static final int XCORE_INS_KRET = 58;
public static final int XCORE_INS_LADD = 59;
public static final int XCORE_INS_LD16S = 60;
public static final int XCORE_INS_LD8U = 61;
public static final int XCORE_INS_LDA16 = 62;
public static final int XCORE_INS_LDAP = 63;
public static final int XCORE_INS_LDAW = 64;
public static final int XCORE_INS_LDC = 65;
public static final int XCORE_INS_LDW = 66;
public static final int XCORE_INS_LDIVU = 67;
public static final int XCORE_INS_LMUL = 68;
public static final int XCORE_INS_LSS = 69;
public static final int XCORE_INS_LSUB = 70;
public static final int XCORE_INS_LSU = 71;
public static final int XCORE_INS_MACCS = 72;
public static final int XCORE_INS_MACCU = 73;
public static final int XCORE_INS_MJOIN = 74;
public static final int XCORE_INS_MKMSK = 75;
public static final int XCORE_INS_MSYNC = 76;
public static final int XCORE_INS_MUL = 77;
public static final int XCORE_INS_NEG = 78;
public static final int XCORE_INS_NOT = 79;
public static final int XCORE_INS_OR = 80;
public static final int XCORE_INS_OUTCT = 81;
public static final int XCORE_INS_OUTPW = 82;
public static final int XCORE_INS_OUTSHR = 83;
public static final int XCORE_INS_OUTT = 84;
public static final int XCORE_INS_OUT = 85;
public static final int XCORE_INS_PEEK = 86;
public static final int XCORE_INS_REMS = 87;
public static final int XCORE_INS_REMU = 88;
public static final int XCORE_INS_RETSP = 89;
public static final int XCORE_INS_SETCLK = 90;
public static final int XCORE_INS_SET = 91;
public static final int XCORE_INS_SETC = 92;
public static final int XCORE_INS_SETD = 93;
public static final int XCORE_INS_SETEV = 94;
public static final int XCORE_INS_SETN = 95;
public static final int XCORE_INS_SETPSC = 96;
public static final int XCORE_INS_SETPT = 97;
public static final int XCORE_INS_SETRDY = 98;
public static final int XCORE_INS_SETSR = 99;
public static final int XCORE_INS_SETTW = 100;
public static final int XCORE_INS_SETV = 101;
public static final int XCORE_INS_SEXT = 102;
public static final int XCORE_INS_SHL = 103;
public static final int XCORE_INS_SHR = 104;
public static final int XCORE_INS_SSYNC = 105;
public static final int XCORE_INS_ST16 = 106;
public static final int XCORE_INS_ST8 = 107;
public static final int XCORE_INS_STW = 108;
public static final int XCORE_INS_SUB = 109;
public static final int XCORE_INS_SYNCR = 110;
public static final int XCORE_INS_TESTCT = 111;
public static final int XCORE_INS_TESTLCL = 112;
public static final int XCORE_INS_TESTWCT = 113;
public static final int XCORE_INS_TSETMR = 114;
public static final int XCORE_INS_START = 115;
public static final int XCORE_INS_WAITEF = 116;
public static final int XCORE_INS_WAITET = 117;
public static final int XCORE_INS_WAITEU = 118;
public static final int XCORE_INS_XOR = 119;
public static final int XCORE_INS_ZEXT = 120;
public static final int XCORE_INS_ENDING = 121;
public static final int XCORE_GRP_INVALID = 0;
public static final int XCORE_GRP_JUMP = 1;
public static final int XCORE_GRP_ENDING = 2;
}
+26
View File
@@ -0,0 +1,26 @@
#!/bin/sh
JNA=/usr/share/java/jna.jar
if [ ! -f ${JNA} ]; then
if [ ! -f /usr/share/java/jna/jna.jar ]; then
echo "*** Unable to find jna.jar *** ";
exit;
else
JNA=/usr/share/java/jna/jna.jar;
fi
fi
case "$1" in
"") java -classpath ${JNA}:. TestBasic ;;
"testbasic") java -classpath ${JNA}:. TestBasic ;;
"arm") java -classpath ${JNA}:. TestArm ;;
"arm64") java -classpath ${JNA}:. TestArm64 ;;
"mips") java -classpath ${JNA}:. TestMips ;;
"x86") java -classpath ${JNA}:. TestX86 ;;
"xcore") java -classpath ${JNA}:. TestXcore; ;;
"ppc") java -classpath ${JNA}:. TestPpc ;;
"sparc") java -classpath ${JNA}:. TestSparc ;;
"systemz") java -classpath ${JNA}:. TestSystemz ;;
"m680x") java -classpath ${JNA}:. TestM680x ;;
* ) echo "Usage: ./run.sh [arm|arm64|m680x|mips|ppc|sparc|systemz|x86]"; exit 1;;
esac
+299
View File
@@ -0,0 +1,299 @@
# Capstone Disassembler Engine
# By Nguyen Anh Quynh <aquynh@gmail.com>, 2013-2015
LIB = capstone
FLAGS = '-Wall -Wextra -Wwrite-strings'
PYTHON2 ?= python
all: arm_const.cmxa arm64_const.cmxa m680x_const.cmxa mips_const.cmxa ppc_const.cmxa sparc_const.cmxa sysz_const.cmxa x86_const.cmxa xcore_const.cmxa arm.cmxa arm64.cmxa m680x.cmxa mips.cmxa ppc.cmxa x86.cmxa sparc.cmxa systemz.cmxa xcore.cmxa capstone.cmxa test_basic.cmx test_detail.cmx test_x86.cmx test_arm.cmx test_aarch64.cmx test_mips.cmx test_ppc.cmx test_sparc.cmx test_systemz.cmx test_xcore.cmx test_m680x.cmx ocaml.o
ocamlopt -o test_basic -ccopt $(FLAGS) ocaml.o capstone.cmx test_basic.cmx -cclib -l$(LIB)
ocamlopt -o test_detail -ccopt $(FLAGS) capstone.cmx ocaml.o test_detail.cmx -cclib -l$(LIB)
ocamlopt -o test_x86 -ccopt $(FLAGS) capstone.cmx ocaml.o x86.cmx x86_const.cmx test_x86.cmx -cclib -l$(LIB)
ocamlopt -o test_arm -ccopt $(FLAGS) capstone.cmx ocaml.o arm.cmx arm_const.cmx test_arm.cmx -cclib -l$(LIB)
ocamlopt -o test_aarch64 -ccopt $(FLAGS) capstone.cmx ocaml.o arm64.cmx arm64_const.cmx test_aarch64.cmx -cclib -l$(LIB)
ocamlopt -o test_mips -ccopt $(FLAGS) capstone.cmx ocaml.o mips.cmx mips_const.cmx test_mips.cmx -cclib -l$(LIB)
ocamlopt -o test_ppc -ccopt $(FLAGS) capstone.cmx ocaml.o ppc.cmx ppc_const.cmx test_ppc.cmx -cclib -l$(LIB)
ocamlopt -o test_sparc -ccopt $(FLAGS) capstone.cmx ocaml.o sparc.cmx sparc_const.cmx test_sparc.cmx -cclib -l$(LIB)
ocamlopt -o test_systemz -ccopt $(FLAGS) capstone.cmx ocaml.o systemz.cmx sysz_const.cmx test_systemz.cmx -cclib -l$(LIB)
ocamlopt -o test_xcore -ccopt $(FLAGS) capstone.cmx ocaml.o xcore.cmx xcore_const.cmx test_xcore.cmx -cclib -l$(LIB)
ocamlopt -o test_m680x -ccopt $(FLAGS) capstone.cmx ocaml.o m680x.cmx m680x_const.cmx test_m680x.cmx -cclib -l$(LIB)
test_basic.cmx: test_basic.ml
ocamlopt -ccopt $(FLAGS) -c $< -cclib -l$(LIB)
test_detail.cmx: test_detail.ml
ocamlopt -ccopt $(FLAGS) -c $< -cclib -l$(LIB)
test_x86.cmx: test_x86.ml
ocamlopt -ccopt $(FLAGS) -c $< -cclib -l$(LIB)
test_arm.cmx: test_arm.ml
ocamlopt -ccopt $(FLAGS) -c $< -cclib -l$(LIB)
test_aarch64.cmx: test_aarch64.ml
ocamlopt -ccopt $(FLAGS) -c $< -cclib -l$(LIB)
test_mips.cmx: test_mips.ml
ocamlopt -ccopt $(FLAGS) -c $< -cclib -l$(LIB)
test_ppc.cmx: test_ppc.ml
ocamlopt -ccopt $(FLAGS) -c $< -cclib -l$(LIB)
test_sparc.cmx: test_sparc.ml
ocamlopt -ccopt $(FLAGS) -c $< -cclib -l$(LIB)
test_systemz.cmx: test_systemz.ml
ocamlopt -ccopt $(FLAGS) -c $< -cclib -l$(LIB)
test_xcore.cmx: test_xcore.ml
ocamlopt -ccopt $(FLAGS) -c $< -cclib -l$(LIB)
test_m680x.cmx: test_m680x.ml
ocamlopt -ccopt $(FLAGS) -c $< -cclib -l$(LIB)
ocaml.o: ocaml.c
ocamlc -ccopt $(FLAGS) -c $<
capstone.mli: capstone.ml
ocamlc -ccopt $(FLAGS) -i $< > $@
capstone.cmi: capstone.mli
ocamlc -ccopt $(FLAGS) -c $<
capstone.cmx: capstone.ml capstone.cmi
ocamlopt -ccopt $(FLAGS) -c $< -cclib -l$(LIB)
capstone.cmxa: capstone.cmx
ocamlopt -ccopt $(FLAGS) -a -o $@ $< -cclib -lsb_ocaml -cclib -l$(LIB)
x86.mli: x86.ml
ocamlc -ccopt $(FLAGS) -i $< > $@
x86.cmi: x86.mli
ocamlc -ccopt $(FLAGS) -c $<
x86.cmx: x86.ml x86.cmi
ocamlopt -ccopt $(FLAGS) -c $<
x86.cmxa: x86.cmx
ocamlopt -ccopt $(FLAGS) -a -o $@ $<
x86_const.mli: x86_const.ml
ocamlc -ccopt $(FLAGS) -i $< > $@
x86_const.cmi: x86_const.mli
ocamlc -ccopt $(FLAGS) -c $<
x86_const.cmx: x86_const.ml x86_const.cmi
ocamlopt -ccopt $(FLAGS) -c $<
x86_const.cmxa: x86_const.cmx
ocamlopt -ccopt $(FLAGS) -a -o $@ $<
arm.mli: arm.ml
ocamlc -ccopt $(FLAGS) -i $< > $@
arm.cmi: arm.mli
ocamlc -ccopt $(FLAGS) -c $<
arm.cmx: arm.ml arm.cmi
ocamlopt -ccopt $(FLAGS) -c $<
arm.cmxa: arm.cmx
ocamlopt -ccopt $(FLAGS) -a -o $@ $<
arm_const.mli: arm_const.ml
ocamlc -ccopt $(FLAGS) -i $< > $@
arm_const.cmi: arm_const.mli
ocamlc -ccopt $(FLAGS) -c $<
arm_const.cmx: arm_const.ml arm_const.cmi
ocamlopt -ccopt $(FLAGS) -c $<
arm_const.cmxa: arm_const.cmx
ocamlopt -ccopt $(FLAGS) -a -o $@ $<
arm64.mli: arm64.ml
ocamlc -ccopt $(FLAGS) -i $< > $@
arm64.cmi: arm64.mli
ocamlc -ccopt $(FLAGS) -c $<
arm64.cmx: arm64.ml arm64.cmi
ocamlopt -ccopt $(FLAGS) -c $<
arm64.cmxa: arm64.cmx
ocamlopt -ccopt $(FLAGS) -a -o $@ $<
arm64_const.mli: arm64_const.ml
ocamlc -ccopt $(FLAGS) -i $< > $@
arm64_const.cmi: arm64_const.mli
ocamlc -ccopt $(FLAGS) -c $<
arm64_const.cmx: arm64_const.ml arm64_const.cmi
ocamlopt -ccopt $(FLAGS) -c $<
arm64_const.cmxa: arm64_const.cmx
ocamlopt -ccopt $(FLAGS) -a -o $@ $<
m680x.mli: m680x.ml
ocamlc -ccopt $(FLAGS) -i $< > $@
m680x.cmi: m680x.mli
ocamlc -ccopt $(FLAGS) -c $<
m680x.cmx: m680x.ml m680x.cmi
ocamlopt -ccopt $(FLAGS) -c $<
m680x.cmxa: m680x.cmx
ocamlopt -ccopt $(FLAGS) -a -o $@ $<
m680x_const.mli: m680x_const.ml
ocamlc -ccopt $(FLAGS) -i $< > $@
m680x_const.cmi: m680x_const.mli
ocamlc -ccopt $(FLAGS) -c $<
m680x_const.cmx: m680x_const.ml m680x_const.cmi
ocamlopt -ccopt $(FLAGS) -c $<
m680x_const.cmxa: m680x_const.cmx
ocamlopt -ccopt $(FLAGS) -a -o $@ $<
mips.mli: mips.ml
ocamlc -ccopt $(FLAGS) -i $< > $@
mips.cmi: mips.mli
ocamlc -ccopt $(FLAGS) -c $<
mips.cmx: mips.ml mips.cmi
ocamlopt -ccopt $(FLAGS) -c $<
mips.cmxa: mips.cmx
ocamlopt -ccopt $(FLAGS) -a -o $@ $<
mips_const.mli: mips_const.ml
ocamlc -ccopt $(FLAGS) -i $< > $@
mips_const.cmi: mips_const.mli
ocamlc -ccopt $(FLAGS) -c $<
mips_const.cmx: mips_const.ml mips_const.cmi
ocamlopt -ccopt $(FLAGS) -c $<
mips_const.cmxa: mips_const.cmx
ocamlopt -ccopt $(FLAGS) -a -o $@ $<
ppc.mli: ppc.ml
ocamlc -ccopt $(FLAGS) -i $< > $@
ppc.cmi: ppc.mli
ocamlc -ccopt $(FLAGS) -c $<
ppc.cmx: ppc.ml ppc.cmi
ocamlopt -ccopt $(FLAGS) -c $<
ppc.cmxa: ppc.cmx
ocamlopt -ccopt $(FLAGS) -a -o $@ $<
ppc_const.mli: ppc_const.ml
ocamlc -ccopt $(FLAGS) -i $< > $@
ppc_const.cmi: ppc_const.mli
ocamlc -ccopt $(FLAGS) -c $<
ppc_const.cmx: ppc_const.ml ppc_const.cmi
ocamlopt -ccopt $(FLAGS) -c $<
ppc_const.cmxa: ppc_const.cmx
ocamlopt -ccopt $(FLAGS) -a -o $@ $<
sparc.mli: sparc.ml
ocamlc -ccopt $(FLAGS) -i $< > $@
sparc.cmi: sparc.mli
ocamlc -ccopt $(FLAGS) -c $<
sparc.cmx: sparc.ml sparc.cmi
ocamlopt -ccopt $(FLAGS) -c $<
sparc.cmxa: sparc.cmx
ocamlopt -ccopt $(FLAGS) -a -o $@ $<
sparc_const.mli: sparc_const.ml
ocamlc -ccopt $(FLAGS) -i $< > $@
sparc_const.cmi: sparc_const.mli
ocamlc -ccopt $(FLAGS) -c $<
sparc_const.cmx: sparc_const.ml sparc_const.cmi
ocamlopt -ccopt $(FLAGS) -c $<
sparc_const.cmxa: sparc_const.cmx
ocamlopt -ccopt $(FLAGS) -a -o $@ $<
systemz.mli: systemz.ml
ocamlc -ccopt $(FLAGS) -i $< > $@
systemz.cmi: systemz.mli
ocamlc -ccopt $(FLAGS) -c $<
systemz.cmx: systemz.ml systemz.cmi
ocamlopt -ccopt $(FLAGS) -c $<
systemz.cmxa: systemz.cmx
ocamlopt -ccopt $(FLAGS) -a -o $@ $<
sysz_const.mli: sysz_const.ml
ocamlc -ccopt $(FLAGS) -i $< > $@
sysz_const.cmi: sysz_const.mli
ocamlc -ccopt $(FLAGS) -c $<
sysz_const.cmx: sysz_const.ml sysz_const.cmi
ocamlopt -ccopt $(FLAGS) -c $<
sysz_const.cmxa: sysz_const.cmx
ocamlopt -ccopt $(FLAGS) -a -o $@ $<
xcore.mli: xcore.ml
ocamlc -ccopt $(FLAGS) -i $< > $@
xcore.cmi: xcore.mli
ocamlc -ccopt $(FLAGS) -c $<
xcore.cmx: xcore.ml xcore.cmi
ocamlopt -ccopt $(FLAGS) -c $<
xcore.cmxa: xcore.cmx
ocamlopt -ccopt $(FLAGS) -a -o $@ $<
xcore_const.mli: xcore_const.ml
ocamlc -ccopt $(FLAGS) -i $< > $@
xcore_const.cmi: xcore_const.mli
ocamlc -ccopt $(FLAGS) -c $<
xcore_const.cmx: xcore_const.ml xcore_const.cmi
ocamlopt -ccopt $(FLAGS) -c $<
xcore_const.cmxa: xcore_const.cmx
ocamlopt -ccopt $(FLAGS) -a -o $@ $<
clean:
rm -f *.[oa] *.so *.cm[ixoa] *.cmxa *.mli test_basic test_detail test_x86 test_arm test_aarch64 test_mips test_ppc test_sparc test_systemz test_xcore test_m680x
gen_const:
cd .. && $(PYTHON2) const_generator.py ocaml
TESTS = test_basic test_detail test_arm test_aarch64 test_m680x test_mips test_ppc
TESTS += test_sparc test_systemz test_x86 test_xcore
check:
@for t in $(TESTS); do \
echo Check $$t ... ; \
./$$t > /dev/null && echo OK || echo FAILED; \
done
+25
View File
@@ -0,0 +1,25 @@
To compile Ocaml binding, Ocaml toolchain is needed. On Ubuntu Linux,
you can install Ocaml with:
```
$ sudo apt-get install ocaml-nox
```
To compile Ocaml binding, simply run "make" on the command line.
This directory also contains some test code to show how to use Capstone API.
- test_basic.ml
This code shows the most simple form of API where we only want to get basic
information out of disassembled instruction, such as address, mnemonic and
operand string.
- test_detail.ml:
This code shows how to access to architecture-neutral information in disassembled
instructions, such as implicit registers read/written, or groups of instructions
that this instruction belong to.
- test_<arch>.ml
These code show how to access architecture-specific information for each
architecture.
+55
View File
@@ -0,0 +1,55 @@
(* Capstone Disassembly Engine
* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013-2014 *)
open Arm_const
let _CS_OP_ARCH = 5;;
let _CS_OP_CIMM = _CS_OP_ARCH (* C-Immediate *)
let _CS_OP_PIMM = _CS_OP_ARCH + 1 (* P-Immediate *)
(* architecture specific info of instruction *)
type arm_op_shift = {
shift_type: int; (* TODO: covert this to pattern like arm_op_value? *)
shift_value: int;
}
type arm_op_mem = {
base: int;
index: int;
scale: int;
disp: int;
lshift: int;
}
type arm_op_value =
| ARM_OP_INVALID of int
| ARM_OP_REG of int
| ARM_OP_CIMM of int
| ARM_OP_PIMM of int
| ARM_OP_IMM of int
| ARM_OP_FP of float
| ARM_OP_MEM of arm_op_mem
| ARM_OP_SETEND of int
type arm_op = {
vector_index: int;
shift: arm_op_shift;
value: arm_op_value;
subtracted: bool;
access: int;
neon_lane: int;
}
type cs_arm = {
usermode: bool;
vector_size: int;
vector_data: int;
cps_mode: int;
cps_flag: int;
cc: int;
update_flags: bool;
writeback: bool;
mem_barrier: int;
operands: arm_op array;
}
+45
View File
@@ -0,0 +1,45 @@
(* Capstone Disassembly Engine
* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013-2014 *)
open Arm64_const
(* architecture specific info of instruction *)
type arm64_op_shift = {
shift_type: int;
shift_value: int;
}
type arm64_op_mem = {
base: int;
index: int;
disp: int
}
type arm64_op_value =
| ARM64_OP_INVALID of int
| ARM64_OP_REG of int
| ARM64_OP_CIMM of int
| ARM64_OP_IMM of int
| ARM64_OP_FP of float
| ARM64_OP_MEM of arm64_op_mem
| ARM64_OP_REG_MRS of int
| ARM64_OP_REG_MSR of int
| ARM64_OP_PSTATE of int
| ARM64_OP_SYS of int
| ARM64_OP_PREFETCH of int
| ARM64_OP_BARRIER of int
type arm64_op = {
vector_index: int;
vas: int;
shift: arm64_op_shift;
ext: int;
value: arm64_op_value;
}
type cs_arm64 = {
cc: int;
update_flags: bool;
writeback: bool;
operands: arm64_op array;
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+217
View File
@@ -0,0 +1,217 @@
(* Capstone Disassembly Engine
* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013-2014 *)
open Arm
open Arm64
open Mips
open Ppc
open X86
open Sparc
open Systemz
open Xcore
open M680x
open Printf (* debug *)
(* Hardware architectures *)
type arch =
| CS_ARCH_ARM
| CS_ARCH_ARM64
| CS_ARCH_MIPS
| CS_ARCH_X86
| CS_ARCH_PPC
| CS_ARCH_SPARC
| CS_ARCH_SYSZ
| CS_ARCH_XCORE
| CS_ARCH_M68K
| CS_ARCH_TMS320C64X
| CS_ARCH_M680X
(* Hardware modes *)
type mode =
| CS_MODE_LITTLE_ENDIAN (* little-endian mode (default mode) *)
| CS_MODE_ARM (* ARM mode *)
| CS_MODE_16 (* 16-bit mode (for X86) *)
| CS_MODE_32 (* 32-bit mode (for X86) *)
| CS_MODE_64 (* 64-bit mode (for X86, PPC) *)
| CS_MODE_THUMB (* ARM's Thumb mode, including Thumb-2 *)
| CS_MODE_MCLASS (* ARM's MClass mode *)
| CS_MODE_V8 (* ARMv8 A32 encodings for ARM *)
| CS_MODE_MICRO (* MicroMips mode (MIPS architecture) *)
| CS_MODE_MIPS3 (* Mips3 mode (MIPS architecture) *)
| CS_MODE_MIPS32R6 (* Mips32-R6 mode (MIPS architecture) *)
| CS_MODE_MIPS2 (* Mips2 mode (MIPS architecture) *)
| CS_MODE_V9 (* SparcV9 mode (Sparc architecture) *)
| CS_MODE_BIG_ENDIAN (* big-endian mode *)
| CS_MODE_MIPS32 (* Mips32 mode (for Mips) *)
| CS_MODE_MIPS64 (* Mips64 mode (for Mips) *)
| CS_MODE_QPX (* Quad Processing eXtensions mode (PowerPC) *)
| CS_MODE_SPE (* Signal Processing Engine mode (PowerPC) *)
| CS_MODE_BOOKE (* Book-E mode (PowerPC) *)
| CS_MODE_PS (* Paired-singles mode (PowerPC) *)
| CS_MODE_M680X_6301 (* M680X Hitachi 6301,6303 mode *)
| CS_MODE_M680X_6309 (* M680X Hitachi 6309 mode *)
| CS_MODE_M680X_6800 (* M680X Motorola 6800,6802 mode *)
| CS_MODE_M680X_6801 (* M680X Motorola 6801,6803 mode *)
| CS_MODE_M680X_6805 (* M680X Motorola 6805 mode *)
| CS_MODE_M680X_6808 (* M680X Motorola 6808 mode *)
| CS_MODE_M680X_6809 (* M680X Motorola 6809 mode *)
| CS_MODE_M680X_6811 (* M680X Motorola/Freescale 68HC11 mode *)
| CS_MODE_M680X_CPU12 (* M680X Motorola/Freescale/NXP CPU12 mode *)
| CS_MODE_M680X_HCS08 (* M680X Freescale HCS08 mode *)
(* Runtime option for the disassembled engine *)
type opt_type =
| CS_OPT_SYNTAX (* Assembly output syntax *)
| CS_OPT_DETAIL (* Break down instruction structure into details *)
| CS_OPT_MODE (* Change engine's mode at run-time *)
| CS_OPT_MEM (* User-defined dynamic memory related functions *)
| CS_OPT_SKIPDATA (* Skip data when disassembling. Then engine is in SKIPDATA mode. *)
| CS_OPT_SKIPDATA_SETUP (* Setup user-defined function for SKIPDATA option *)
(* Common instruction operand access types - to be consistent across all architectures. *)
(* It is possible to combine access types, for example: CS_AC_READ | CS_AC_WRITE *)
let _CS_AC_INVALID = 0;; (* Uninitialized/invalid access type. *)
let _CS_AC_READ = 1 lsl 0;; (* Operand read from memory or register. *)
let _CS_AC_WRITE = 1 lsl 1;; (* Operand write to memory or register. *)
(* Runtime option value (associated with option type above) *)
let _CS_OPT_OFF = 0L;; (* Turn OFF an option - default option of CS_OPT_DETAIL, CS_OPT_SKIPDATA. *)
let _CS_OPT_ON = 3L;; (* Turn ON an option (CS_OPT_DETAIL, CS_OPT_SKIPDATA). *)
let _CS_OPT_SYNTAX_DEFAULT = 0L;; (* Default asm syntax (CS_OPT_SYNTAX). *)
let _CS_OPT_SYNTAX_INTEL = 1L;; (* X86 Intel asm syntax - default on X86 (CS_OPT_SYNTAX). *)
let _CS_OPT_SYNTAX_ATT = 2L;; (* X86 ATT asm syntax (CS_OPT_SYNTAX). *)
let _CS_OPT_SYNTAX_NOREGNAME = 3L;; (* Prints register name with only number (CS_OPT_SYNTAX) *)
(* Common instruction operand types - to be consistent across all architectures. *)
let _CS_OP_INVALID = 0;; (* uninitialized/invalid operand. *)
let _CS_OP_REG = 1;; (* Register operand. *)
let _CS_OP_IMM = 2;; (* Immediate operand. *)
let _CS_OP_MEM = 3;; (* Memory operand. *)
let _CS_OP_FP = 4;; (* Floating-Point operand. *)
(* Common instruction groups - to be consistent across all architectures. *)
let _CS_GRP_INVALID = 0;; (* uninitialized/invalid group. *)
let _CS_GRP_JUMP = 1;; (* all jump instructions (conditional+direct+indirect jumps) *)
let _CS_GRP_CALL = 2;; (* all call instructions *)
let _CS_GRP_RET = 3;; (* all return instructions *)
let _CS_GRP_INT = 4;; (* all interrupt instructions (int+syscall) *)
let _CS_GRP_IRET = 5;; (* all interrupt return instructions *)
let _CS_GRP_PRIVILEGE = 6;; (* all privileged instructions *)
type cs_arch =
| CS_INFO_ARM of cs_arm
| CS_INFO_ARM64 of cs_arm64
| CS_INFO_MIPS of cs_mips
| CS_INFO_X86 of cs_x86
| CS_INFO_PPC of cs_ppc
| CS_INFO_SPARC of cs_sparc
| CS_INFO_SYSZ of cs_sysz
| CS_INFO_XCORE of cs_xcore
| CS_INFO_M680X of cs_m680x
type csh = {
h: Int64.t;
a: arch;
}
type cs_insn0 = {
id: int;
address: int;
size: int;
bytes: int array;
mnemonic: string;
op_str: string;
regs_read: int array;
regs_write: int array;
groups: int array;
arch: cs_arch;
}
external _cs_open: arch -> mode list -> Int64.t option = "ocaml_open"
external cs_disasm_quick: arch -> mode list -> string -> Int64.t -> Int64.t -> cs_insn0 list = "ocaml_cs_disasm"
external _cs_disasm_internal: arch -> Int64.t -> string -> Int64.t -> Int64.t -> cs_insn0 list = "ocaml_cs_disasm_internal"
external _cs_reg_name: Int64.t -> int -> string = "ocaml_register_name"
external _cs_insn_name: Int64.t -> int -> string = "ocaml_instruction_name"
external _cs_group_name: Int64.t -> int -> string = "ocaml_group_name"
external cs_version: unit -> int = "ocaml_version"
external _cs_option: Int64.t -> opt_type -> Int64.t -> int = "ocaml_option"
external _cs_close: Int64.t -> int = "ocaml_close"
let cs_open _arch _mode: csh = (
let _handle = _cs_open _arch _mode in (
match _handle with
| None -> { h = 0L; a = _arch }
| Some v -> { h = v; a = _arch }
);
);;
let cs_close handle = (
_cs_close handle.h;
)
let cs_option handle opt value = (
_cs_option handle.h opt value;
);;
let cs_disasm handle code address count = (
_cs_disasm_internal handle.a handle.h code address count;
);;
let cs_reg_name handle id = (
_cs_reg_name handle.h id;
);;
let cs_insn_name handle id = (
_cs_insn_name handle.h id;
);;
let cs_group_name handle id = (
_cs_group_name handle.h id;
);;
class cs_insn c a =
let csh = c in
let (id, address, size, bytes, mnemonic, op_str, regs_read,
regs_write, groups, arch) =
(a.id, a.address, a.size, a.bytes, a.mnemonic, a.op_str,
a.regs_read, a.regs_write, a.groups, a.arch) in
object
method id = id;
method address = address;
method size = size;
method bytes = bytes;
method mnemonic = mnemonic;
method op_str = op_str;
method regs_read = regs_read;
method regs_write = regs_write;
method groups = groups;
method arch = arch;
method reg_name id = _cs_reg_name csh.h id;
method insn_name id = _cs_insn_name csh.h id;
method group_name id = _cs_group_name csh.h id;
end;;
let cs_insn_group handle insn group_id =
List.exists (fun g -> g == group_id) (Array.to_list insn.groups);;
let cs_reg_read handle insn reg_id =
List.exists (fun g -> g == reg_id) (Array.to_list insn.regs_read);;
let cs_reg_write handle insn reg_id =
List.exists (fun g -> g == reg_id) (Array.to_list insn.regs_write);;
class cs a m =
let mode = m and arch = a in
let handle = cs_open arch mode in
object
method disasm code offset count =
let insns = (_cs_disasm_internal arch handle.h code offset count) in
List.map (fun x -> new cs_insn handle x) insns;
end;;
+163
View File
@@ -0,0 +1,163 @@
(* For Capstone Engine. AUTO-GENERATED FILE, DO NOT EDIT [evm_const.ml] *)
let _EVM_INS_STOP = 0;;
let _EVM_INS_ADD = 1;;
let _EVM_INS_MUL = 2;;
let _EVM_INS_SUB = 3;;
let _EVM_INS_DIV = 4;;
let _EVM_INS_SDIV = 5;;
let _EVM_INS_MOD = 6;;
let _EVM_INS_SMOD = 7;;
let _EVM_INS_ADDMOD = 8;;
let _EVM_INS_MULMOD = 9;;
let _EVM_INS_EXP = 10;;
let _EVM_INS_SIGNEXTEND = 11;;
let _EVM_INS_LT = 16;;
let _EVM_INS_GT = 17;;
let _EVM_INS_SLT = 18;;
let _EVM_INS_SGT = 19;;
let _EVM_INS_EQ = 20;;
let _EVM_INS_ISZERO = 21;;
let _EVM_INS_AND = 22;;
let _EVM_INS_OR = 23;;
let _EVM_INS_XOR = 24;;
let _EVM_INS_NOT = 25;;
let _EVM_INS_BYTE = 26;;
let _EVM_INS_SHL = 27;;
let _EVM_INS_SHR = 28;;
let _EVM_INS_SAR = 29;;
let _EVM_INS_SHA3 = 32;;
let _EVM_INS_ADDRESS = 48;;
let _EVM_INS_BALANCE = 49;;
let _EVM_INS_ORIGIN = 50;;
let _EVM_INS_CALLER = 51;;
let _EVM_INS_CALLVALUE = 52;;
let _EVM_INS_CALLDATALOAD = 53;;
let _EVM_INS_CALLDATASIZE = 54;;
let _EVM_INS_CALLDATACOPY = 55;;
let _EVM_INS_CODESIZE = 56;;
let _EVM_INS_CODECOPY = 57;;
let _EVM_INS_GASPRICE = 58;;
let _EVM_INS_EXTCODESIZE = 59;;
let _EVM_INS_EXTCODECOPY = 60;;
let _EVM_INS_RETURNDATASIZE = 61;;
let _EVM_INS_RETURNDATACOPY = 62;;
let _EVM_INS_BLOCKHASH = 64;;
let _EVM_INS_COINBASE = 65;;
let _EVM_INS_TIMESTAMP = 66;;
let _EVM_INS_NUMBER = 67;;
let _EVM_INS_DIFFICULTY = 68;;
let _EVM_INS_GASLIMIT = 69;;
let _EVM_INS_CHAINID = 70;;
let _EVM_INS_SELFBALANCE = 71;;
let _EVM_INS_BASEFEE = 72;;
let _EVM_INS_BLOBHASH = 73;;
let _EVM_INS_BLOBBASEFEE = 74;;
let _EVM_INS_POP = 80;;
let _EVM_INS_MLOAD = 81;;
let _EVM_INS_MSTORE = 82;;
let _EVM_INS_MSTORE8 = 83;;
let _EVM_INS_SLOAD = 84;;
let _EVM_INS_SSTORE = 85;;
let _EVM_INS_JUMP = 86;;
let _EVM_INS_JUMPI = 87;;
let _EVM_INS_PC = 88;;
let _EVM_INS_MSIZE = 89;;
let _EVM_INS_GAS = 90;;
let _EVM_INS_JUMPDEST = 91;;
let _EVM_INS_TLOAD = 92;;
let _EVM_INS_TSTORE = 93;;
let _EVM_INS_MCOPY = 94;;
let _EVM_INS_PUSH0 = 95;;
let _EVM_INS_PUSH1 = 96;;
let _EVM_INS_PUSH2 = 97;;
let _EVM_INS_PUSH3 = 98;;
let _EVM_INS_PUSH4 = 99;;
let _EVM_INS_PUSH5 = 100;;
let _EVM_INS_PUSH6 = 101;;
let _EVM_INS_PUSH7 = 102;;
let _EVM_INS_PUSH8 = 103;;
let _EVM_INS_PUSH9 = 104;;
let _EVM_INS_PUSH10 = 105;;
let _EVM_INS_PUSH11 = 106;;
let _EVM_INS_PUSH12 = 107;;
let _EVM_INS_PUSH13 = 108;;
let _EVM_INS_PUSH14 = 109;;
let _EVM_INS_PUSH15 = 110;;
let _EVM_INS_PUSH16 = 111;;
let _EVM_INS_PUSH17 = 112;;
let _EVM_INS_PUSH18 = 113;;
let _EVM_INS_PUSH19 = 114;;
let _EVM_INS_PUSH20 = 115;;
let _EVM_INS_PUSH21 = 116;;
let _EVM_INS_PUSH22 = 117;;
let _EVM_INS_PUSH23 = 118;;
let _EVM_INS_PUSH24 = 119;;
let _EVM_INS_PUSH25 = 120;;
let _EVM_INS_PUSH26 = 121;;
let _EVM_INS_PUSH27 = 122;;
let _EVM_INS_PUSH28 = 123;;
let _EVM_INS_PUSH29 = 124;;
let _EVM_INS_PUSH30 = 125;;
let _EVM_INS_PUSH31 = 126;;
let _EVM_INS_PUSH32 = 127;;
let _EVM_INS_DUP1 = 128;;
let _EVM_INS_DUP2 = 129;;
let _EVM_INS_DUP3 = 130;;
let _EVM_INS_DUP4 = 131;;
let _EVM_INS_DUP5 = 132;;
let _EVM_INS_DUP6 = 133;;
let _EVM_INS_DUP7 = 134;;
let _EVM_INS_DUP8 = 135;;
let _EVM_INS_DUP9 = 136;;
let _EVM_INS_DUP10 = 137;;
let _EVM_INS_DUP11 = 138;;
let _EVM_INS_DUP12 = 139;;
let _EVM_INS_DUP13 = 140;;
let _EVM_INS_DUP14 = 141;;
let _EVM_INS_DUP15 = 142;;
let _EVM_INS_DUP16 = 143;;
let _EVM_INS_SWAP1 = 144;;
let _EVM_INS_SWAP2 = 145;;
let _EVM_INS_SWAP3 = 146;;
let _EVM_INS_SWAP4 = 147;;
let _EVM_INS_SWAP5 = 148;;
let _EVM_INS_SWAP6 = 149;;
let _EVM_INS_SWAP7 = 150;;
let _EVM_INS_SWAP8 = 151;;
let _EVM_INS_SWAP9 = 152;;
let _EVM_INS_SWAP10 = 153;;
let _EVM_INS_SWAP11 = 154;;
let _EVM_INS_SWAP12 = 155;;
let _EVM_INS_SWAP13 = 156;;
let _EVM_INS_SWAP14 = 157;;
let _EVM_INS_SWAP15 = 158;;
let _EVM_INS_SWAP16 = 159;;
let _EVM_INS_LOG0 = 160;;
let _EVM_INS_LOG1 = 161;;
let _EVM_INS_LOG2 = 162;;
let _EVM_INS_LOG3 = 163;;
let _EVM_INS_LOG4 = 164;;
let _EVM_INS_CREATE = 240;;
let _EVM_INS_CALL = 241;;
let _EVM_INS_CALLCODE = 242;;
let _EVM_INS_RETURN = 243;;
let _EVM_INS_DELEGATECALL = 244;;
let _EVM_INS_CREATE2 = 245;;
let _EVM_INS_STATICCALL = 250;;
let _EVM_INS_REVERT = 253;;
let _EVM_INS_INVALID = 254;;
let _EVM_INS_SELFDESTRUCT = 255;;
let _EVM_INS_ENDING = 256;;
let _EVM_GRP_INVALID = 0;;
let _EVM_GRP_JUMP = 1;;
let _EVM_GRP_MATH = 8;;
let _EVM_GRP_STACK_WRITE = 9;;
let _EVM_GRP_STACK_READ = 10;;
let _EVM_GRP_MEM_WRITE = 11;;
let _EVM_GRP_MEM_READ = 12;;
let _EVM_GRP_STORE_WRITE = 13;;
let _EVM_GRP_STORE_READ = 14;;
let _EVM_GRP_HALT = 15;;
let _EVM_GRP_ENDING = 16;;
+48
View File
@@ -0,0 +1,48 @@
(* Capstone Disassembly Engine
* M680X Backend by Wolfgang Schwotzer <wolfgang.schwotzer@gmx.net> 2017 *)
open M680x_const
(* architecture specific info of instruction *)
type m680x_op_idx = {
base_reg: int;
offset_reg: int;
offset: int;
offset_addr: int;
offset_bits: int;
inc_dec: int;
flags: int;
}
type m680x_op_rel = {
addr_rel: int;
offset: int;
}
type m680x_op_ext = {
addr_ext: int;
indirect: bool;
}
type m680x_op_value =
| M680X_OP_INVALID of int
| M680X_OP_IMMEDIATE of int
| M680X_OP_REGISTER of int
| M680X_OP_INDEXED of m680x_op_idx
| M680X_OP_RELATIVE of m680x_op_rel
| M680X_OP_EXTENDED of m680x_op_ext
| M680X_OP_DIRECT of int
| M680X_OP_CONSTANT of int
type m680x_op = {
value: m680x_op_value;
size: int;
access: int;
}
type cs_m680x = {
flags: int;
operands: m680x_op array;
}
+414
View File
@@ -0,0 +1,414 @@
(* For Capstone Engine. AUTO-GENERATED FILE, DO NOT EDIT [m680x_const.ml] *)
let _M680X_OPERAND_COUNT = 9;;
let _M680X_REG_INVALID = 0;;
let _M680X_REG_A = 1;;
let _M680X_REG_B = 2;;
let _M680X_REG_E = 3;;
let _M680X_REG_F = 4;;
let _M680X_REG_0 = 5;;
let _M680X_REG_D = 6;;
let _M680X_REG_W = 7;;
let _M680X_REG_CC = 8;;
let _M680X_REG_DP = 9;;
let _M680X_REG_MD = 10;;
let _M680X_REG_HX = 11;;
let _M680X_REG_H = 12;;
let _M680X_REG_X = 13;;
let _M680X_REG_Y = 14;;
let _M680X_REG_S = 15;;
let _M680X_REG_U = 16;;
let _M680X_REG_V = 17;;
let _M680X_REG_Q = 18;;
let _M680X_REG_PC = 19;;
let _M680X_REG_TMP2 = 20;;
let _M680X_REG_TMP3 = 21;;
let _M680X_REG_ENDING = 22;;
let _M680X_OP_INVALID = _CS_OP_INVALID;;
let _M680X_OP_REGISTER = _CS_OP_REG;;
let _M680X_OP_IMMEDIATE = _CS_OP_IMM;;
let _M680X_OP_INDEXED = _CS_OP_SPECIAL+0;;
let _M680X_OP_EXTENDED = _CS_OP_SPECIAL+1;;
let _M680X_OP_DIRECT = _CS_OP_SPECIAL+2;;
let _M680X_OP_RELATIVE = _CS_OP_SPECIAL+3;;
let _M680X_OP_CONSTANT = _CS_OP_SPECIAL+4;;
let _M680X_OFFSET_NONE = 0;;
let _M680X_OFFSET_BITS_5 = 5;;
let _M680X_OFFSET_BITS_8 = 8;;
let _M680X_OFFSET_BITS_9 = 9;;
let _M680X_OFFSET_BITS_16 = 16;;
let _M680X_IDX_INDIRECT = 1;;
let _M680X_IDX_NO_COMMA = 2;;
let _M680X_IDX_POST_INC_DEC = 4;;
let _M680X_GRP_INVALID = 0;;
let _M680X_GRP_JUMP = 1;;
let _M680X_GRP_CALL = 2;;
let _M680X_GRP_RET = 3;;
let _M680X_GRP_INT = 4;;
let _M680X_GRP_IRET = 5;;
let _M680X_GRP_PRIV = 6;;
let _M680X_GRP_BRAREL = 7;;
let _M680X_GRP_ENDING = 8;;
let _M680X_FIRST_OP_IN_MNEM = 1;;
let _M680X_SECOND_OP_IN_MNEM = 2;;
let _M680X_INS_INVLD = 0;;
let _M680X_INS_ABA = 1;;
let _M680X_INS_ABX = 2;;
let _M680X_INS_ABY = 3;;
let _M680X_INS_ADC = 4;;
let _M680X_INS_ADCA = 5;;
let _M680X_INS_ADCB = 6;;
let _M680X_INS_ADCD = 7;;
let _M680X_INS_ADCR = 8;;
let _M680X_INS_ADD = 9;;
let _M680X_INS_ADDA = 10;;
let _M680X_INS_ADDB = 11;;
let _M680X_INS_ADDD = 12;;
let _M680X_INS_ADDE = 13;;
let _M680X_INS_ADDF = 14;;
let _M680X_INS_ADDR = 15;;
let _M680X_INS_ADDW = 16;;
let _M680X_INS_AIM = 17;;
let _M680X_INS_AIS = 18;;
let _M680X_INS_AIX = 19;;
let _M680X_INS_AND = 20;;
let _M680X_INS_ANDA = 21;;
let _M680X_INS_ANDB = 22;;
let _M680X_INS_ANDCC = 23;;
let _M680X_INS_ANDD = 24;;
let _M680X_INS_ANDR = 25;;
let _M680X_INS_ASL = 26;;
let _M680X_INS_ASLA = 27;;
let _M680X_INS_ASLB = 28;;
let _M680X_INS_ASLD = 29;;
let _M680X_INS_ASR = 30;;
let _M680X_INS_ASRA = 31;;
let _M680X_INS_ASRB = 32;;
let _M680X_INS_ASRD = 33;;
let _M680X_INS_ASRX = 34;;
let _M680X_INS_BAND = 35;;
let _M680X_INS_BCC = 36;;
let _M680X_INS_BCLR = 37;;
let _M680X_INS_BCS = 38;;
let _M680X_INS_BEOR = 39;;
let _M680X_INS_BEQ = 40;;
let _M680X_INS_BGE = 41;;
let _M680X_INS_BGND = 42;;
let _M680X_INS_BGT = 43;;
let _M680X_INS_BHCC = 44;;
let _M680X_INS_BHCS = 45;;
let _M680X_INS_BHI = 46;;
let _M680X_INS_BIAND = 47;;
let _M680X_INS_BIEOR = 48;;
let _M680X_INS_BIH = 49;;
let _M680X_INS_BIL = 50;;
let _M680X_INS_BIOR = 51;;
let _M680X_INS_BIT = 52;;
let _M680X_INS_BITA = 53;;
let _M680X_INS_BITB = 54;;
let _M680X_INS_BITD = 55;;
let _M680X_INS_BITMD = 56;;
let _M680X_INS_BLE = 57;;
let _M680X_INS_BLS = 58;;
let _M680X_INS_BLT = 59;;
let _M680X_INS_BMC = 60;;
let _M680X_INS_BMI = 61;;
let _M680X_INS_BMS = 62;;
let _M680X_INS_BNE = 63;;
let _M680X_INS_BOR = 64;;
let _M680X_INS_BPL = 65;;
let _M680X_INS_BRCLR = 66;;
let _M680X_INS_BRSET = 67;;
let _M680X_INS_BRA = 68;;
let _M680X_INS_BRN = 69;;
let _M680X_INS_BSET = 70;;
let _M680X_INS_BSR = 71;;
let _M680X_INS_BVC = 72;;
let _M680X_INS_BVS = 73;;
let _M680X_INS_CALL = 74;;
let _M680X_INS_CBA = 75;;
let _M680X_INS_CBEQ = 76;;
let _M680X_INS_CBEQA = 77;;
let _M680X_INS_CBEQX = 78;;
let _M680X_INS_CLC = 79;;
let _M680X_INS_CLI = 80;;
let _M680X_INS_CLR = 81;;
let _M680X_INS_CLRA = 82;;
let _M680X_INS_CLRB = 83;;
let _M680X_INS_CLRD = 84;;
let _M680X_INS_CLRE = 85;;
let _M680X_INS_CLRF = 86;;
let _M680X_INS_CLRH = 87;;
let _M680X_INS_CLRW = 88;;
let _M680X_INS_CLRX = 89;;
let _M680X_INS_CLV = 90;;
let _M680X_INS_CMP = 91;;
let _M680X_INS_CMPA = 92;;
let _M680X_INS_CMPB = 93;;
let _M680X_INS_CMPD = 94;;
let _M680X_INS_CMPE = 95;;
let _M680X_INS_CMPF = 96;;
let _M680X_INS_CMPR = 97;;
let _M680X_INS_CMPS = 98;;
let _M680X_INS_CMPU = 99;;
let _M680X_INS_CMPW = 100;;
let _M680X_INS_CMPX = 101;;
let _M680X_INS_CMPY = 102;;
let _M680X_INS_COM = 103;;
let _M680X_INS_COMA = 104;;
let _M680X_INS_COMB = 105;;
let _M680X_INS_COMD = 106;;
let _M680X_INS_COME = 107;;
let _M680X_INS_COMF = 108;;
let _M680X_INS_COMW = 109;;
let _M680X_INS_COMX = 110;;
let _M680X_INS_CPD = 111;;
let _M680X_INS_CPHX = 112;;
let _M680X_INS_CPS = 113;;
let _M680X_INS_CPX = 114;;
let _M680X_INS_CPY = 115;;
let _M680X_INS_CWAI = 116;;
let _M680X_INS_DAA = 117;;
let _M680X_INS_DBEQ = 118;;
let _M680X_INS_DBNE = 119;;
let _M680X_INS_DBNZ = 120;;
let _M680X_INS_DBNZA = 121;;
let _M680X_INS_DBNZX = 122;;
let _M680X_INS_DEC = 123;;
let _M680X_INS_DECA = 124;;
let _M680X_INS_DECB = 125;;
let _M680X_INS_DECD = 126;;
let _M680X_INS_DECE = 127;;
let _M680X_INS_DECF = 128;;
let _M680X_INS_DECW = 129;;
let _M680X_INS_DECX = 130;;
let _M680X_INS_DES = 131;;
let _M680X_INS_DEX = 132;;
let _M680X_INS_DEY = 133;;
let _M680X_INS_DIV = 134;;
let _M680X_INS_DIVD = 135;;
let _M680X_INS_DIVQ = 136;;
let _M680X_INS_EDIV = 137;;
let _M680X_INS_EDIVS = 138;;
let _M680X_INS_EIM = 139;;
let _M680X_INS_EMACS = 140;;
let _M680X_INS_EMAXD = 141;;
let _M680X_INS_EMAXM = 142;;
let _M680X_INS_EMIND = 143;;
let _M680X_INS_EMINM = 144;;
let _M680X_INS_EMUL = 145;;
let _M680X_INS_EMULS = 146;;
let _M680X_INS_EOR = 147;;
let _M680X_INS_EORA = 148;;
let _M680X_INS_EORB = 149;;
let _M680X_INS_EORD = 150;;
let _M680X_INS_EORR = 151;;
let _M680X_INS_ETBL = 152;;
let _M680X_INS_EXG = 153;;
let _M680X_INS_FDIV = 154;;
let _M680X_INS_IBEQ = 155;;
let _M680X_INS_IBNE = 156;;
let _M680X_INS_IDIV = 157;;
let _M680X_INS_IDIVS = 158;;
let _M680X_INS_ILLGL = 159;;
let _M680X_INS_INC = 160;;
let _M680X_INS_INCA = 161;;
let _M680X_INS_INCB = 162;;
let _M680X_INS_INCD = 163;;
let _M680X_INS_INCE = 164;;
let _M680X_INS_INCF = 165;;
let _M680X_INS_INCW = 166;;
let _M680X_INS_INCX = 167;;
let _M680X_INS_INS = 168;;
let _M680X_INS_INX = 169;;
let _M680X_INS_INY = 170;;
let _M680X_INS_JMP = 171;;
let _M680X_INS_JSR = 172;;
let _M680X_INS_LBCC = 173;;
let _M680X_INS_LBCS = 174;;
let _M680X_INS_LBEQ = 175;;
let _M680X_INS_LBGE = 176;;
let _M680X_INS_LBGT = 177;;
let _M680X_INS_LBHI = 178;;
let _M680X_INS_LBLE = 179;;
let _M680X_INS_LBLS = 180;;
let _M680X_INS_LBLT = 181;;
let _M680X_INS_LBMI = 182;;
let _M680X_INS_LBNE = 183;;
let _M680X_INS_LBPL = 184;;
let _M680X_INS_LBRA = 185;;
let _M680X_INS_LBRN = 186;;
let _M680X_INS_LBSR = 187;;
let _M680X_INS_LBVC = 188;;
let _M680X_INS_LBVS = 189;;
let _M680X_INS_LDA = 190;;
let _M680X_INS_LDAA = 191;;
let _M680X_INS_LDAB = 192;;
let _M680X_INS_LDB = 193;;
let _M680X_INS_LDBT = 194;;
let _M680X_INS_LDD = 195;;
let _M680X_INS_LDE = 196;;
let _M680X_INS_LDF = 197;;
let _M680X_INS_LDHX = 198;;
let _M680X_INS_LDMD = 199;;
let _M680X_INS_LDQ = 200;;
let _M680X_INS_LDS = 201;;
let _M680X_INS_LDU = 202;;
let _M680X_INS_LDW = 203;;
let _M680X_INS_LDX = 204;;
let _M680X_INS_LDY = 205;;
let _M680X_INS_LEAS = 206;;
let _M680X_INS_LEAU = 207;;
let _M680X_INS_LEAX = 208;;
let _M680X_INS_LEAY = 209;;
let _M680X_INS_LSL = 210;;
let _M680X_INS_LSLA = 211;;
let _M680X_INS_LSLB = 212;;
let _M680X_INS_LSLD = 213;;
let _M680X_INS_LSLX = 214;;
let _M680X_INS_LSR = 215;;
let _M680X_INS_LSRA = 216;;
let _M680X_INS_LSRB = 217;;
let _M680X_INS_LSRD = 218;;
let _M680X_INS_LSRW = 219;;
let _M680X_INS_LSRX = 220;;
let _M680X_INS_MAXA = 221;;
let _M680X_INS_MAXM = 222;;
let _M680X_INS_MEM = 223;;
let _M680X_INS_MINA = 224;;
let _M680X_INS_MINM = 225;;
let _M680X_INS_MOV = 226;;
let _M680X_INS_MOVB = 227;;
let _M680X_INS_MOVW = 228;;
let _M680X_INS_MUL = 229;;
let _M680X_INS_MULD = 230;;
let _M680X_INS_NEG = 231;;
let _M680X_INS_NEGA = 232;;
let _M680X_INS_NEGB = 233;;
let _M680X_INS_NEGD = 234;;
let _M680X_INS_NEGX = 235;;
let _M680X_INS_NOP = 236;;
let _M680X_INS_NSA = 237;;
let _M680X_INS_OIM = 238;;
let _M680X_INS_ORA = 239;;
let _M680X_INS_ORAA = 240;;
let _M680X_INS_ORAB = 241;;
let _M680X_INS_ORB = 242;;
let _M680X_INS_ORCC = 243;;
let _M680X_INS_ORD = 244;;
let _M680X_INS_ORR = 245;;
let _M680X_INS_PSHA = 246;;
let _M680X_INS_PSHB = 247;;
let _M680X_INS_PSHC = 248;;
let _M680X_INS_PSHD = 249;;
let _M680X_INS_PSHH = 250;;
let _M680X_INS_PSHS = 251;;
let _M680X_INS_PSHSW = 252;;
let _M680X_INS_PSHU = 253;;
let _M680X_INS_PSHUW = 254;;
let _M680X_INS_PSHX = 255;;
let _M680X_INS_PSHY = 256;;
let _M680X_INS_PULA = 257;;
let _M680X_INS_PULB = 258;;
let _M680X_INS_PULC = 259;;
let _M680X_INS_PULD = 260;;
let _M680X_INS_PULH = 261;;
let _M680X_INS_PULS = 262;;
let _M680X_INS_PULSW = 263;;
let _M680X_INS_PULU = 264;;
let _M680X_INS_PULUW = 265;;
let _M680X_INS_PULX = 266;;
let _M680X_INS_PULY = 267;;
let _M680X_INS_REV = 268;;
let _M680X_INS_REVW = 269;;
let _M680X_INS_ROL = 270;;
let _M680X_INS_ROLA = 271;;
let _M680X_INS_ROLB = 272;;
let _M680X_INS_ROLD = 273;;
let _M680X_INS_ROLW = 274;;
let _M680X_INS_ROLX = 275;;
let _M680X_INS_ROR = 276;;
let _M680X_INS_RORA = 277;;
let _M680X_INS_RORB = 278;;
let _M680X_INS_RORD = 279;;
let _M680X_INS_RORW = 280;;
let _M680X_INS_RORX = 281;;
let _M680X_INS_RSP = 282;;
let _M680X_INS_RTC = 283;;
let _M680X_INS_RTI = 284;;
let _M680X_INS_RTS = 285;;
let _M680X_INS_SBA = 286;;
let _M680X_INS_SBC = 287;;
let _M680X_INS_SBCA = 288;;
let _M680X_INS_SBCB = 289;;
let _M680X_INS_SBCD = 290;;
let _M680X_INS_SBCR = 291;;
let _M680X_INS_SEC = 292;;
let _M680X_INS_SEI = 293;;
let _M680X_INS_SEV = 294;;
let _M680X_INS_SEX = 295;;
let _M680X_INS_SEXW = 296;;
let _M680X_INS_SLP = 297;;
let _M680X_INS_STA = 298;;
let _M680X_INS_STAA = 299;;
let _M680X_INS_STAB = 300;;
let _M680X_INS_STB = 301;;
let _M680X_INS_STBT = 302;;
let _M680X_INS_STD = 303;;
let _M680X_INS_STE = 304;;
let _M680X_INS_STF = 305;;
let _M680X_INS_STOP = 306;;
let _M680X_INS_STHX = 307;;
let _M680X_INS_STQ = 308;;
let _M680X_INS_STS = 309;;
let _M680X_INS_STU = 310;;
let _M680X_INS_STW = 311;;
let _M680X_INS_STX = 312;;
let _M680X_INS_STY = 313;;
let _M680X_INS_SUB = 314;;
let _M680X_INS_SUBA = 315;;
let _M680X_INS_SUBB = 316;;
let _M680X_INS_SUBD = 317;;
let _M680X_INS_SUBE = 318;;
let _M680X_INS_SUBF = 319;;
let _M680X_INS_SUBR = 320;;
let _M680X_INS_SUBW = 321;;
let _M680X_INS_SWI = 322;;
let _M680X_INS_SWI2 = 323;;
let _M680X_INS_SWI3 = 324;;
let _M680X_INS_SYNC = 325;;
let _M680X_INS_TAB = 326;;
let _M680X_INS_TAP = 327;;
let _M680X_INS_TAX = 328;;
let _M680X_INS_TBA = 329;;
let _M680X_INS_TBEQ = 330;;
let _M680X_INS_TBL = 331;;
let _M680X_INS_TBNE = 332;;
let _M680X_INS_TEST = 333;;
let _M680X_INS_TFM = 334;;
let _M680X_INS_TFR = 335;;
let _M680X_INS_TIM = 336;;
let _M680X_INS_TPA = 337;;
let _M680X_INS_TST = 338;;
let _M680X_INS_TSTA = 339;;
let _M680X_INS_TSTB = 340;;
let _M680X_INS_TSTD = 341;;
let _M680X_INS_TSTE = 342;;
let _M680X_INS_TSTF = 343;;
let _M680X_INS_TSTW = 344;;
let _M680X_INS_TSTX = 345;;
let _M680X_INS_TSX = 346;;
let _M680X_INS_TSY = 347;;
let _M680X_INS_TXA = 348;;
let _M680X_INS_TXS = 349;;
let _M680X_INS_TYS = 350;;
let _M680X_INS_WAI = 351;;
let _M680X_INS_WAIT = 352;;
let _M680X_INS_WAV = 353;;
let _M680X_INS_WAVR = 354;;
let _M680X_INS_XGDX = 355;;
let _M680X_INS_XGDY = 356;;
let _M680X_INS_ENDING = 357;;
+484
View File
@@ -0,0 +1,484 @@
(* For Capstone Engine. AUTO-GENERATED FILE, DO NOT EDIT [m68k_const.ml] *)
let _M68K_OPERAND_COUNT = 4;;
let _M68K_REG_INVALID = 0;;
let _M68K_REG_D0 = 1;;
let _M68K_REG_D1 = 2;;
let _M68K_REG_D2 = 3;;
let _M68K_REG_D3 = 4;;
let _M68K_REG_D4 = 5;;
let _M68K_REG_D5 = 6;;
let _M68K_REG_D6 = 7;;
let _M68K_REG_D7 = 8;;
let _M68K_REG_A0 = 9;;
let _M68K_REG_A1 = 10;;
let _M68K_REG_A2 = 11;;
let _M68K_REG_A3 = 12;;
let _M68K_REG_A4 = 13;;
let _M68K_REG_A5 = 14;;
let _M68K_REG_A6 = 15;;
let _M68K_REG_A7 = 16;;
let _M68K_REG_FP0 = 17;;
let _M68K_REG_FP1 = 18;;
let _M68K_REG_FP2 = 19;;
let _M68K_REG_FP3 = 20;;
let _M68K_REG_FP4 = 21;;
let _M68K_REG_FP5 = 22;;
let _M68K_REG_FP6 = 23;;
let _M68K_REG_FP7 = 24;;
let _M68K_REG_PC = 25;;
let _M68K_REG_SR = 26;;
let _M68K_REG_CCR = 27;;
let _M68K_REG_SFC = 28;;
let _M68K_REG_DFC = 29;;
let _M68K_REG_USP = 30;;
let _M68K_REG_VBR = 31;;
let _M68K_REG_CACR = 32;;
let _M68K_REG_CAAR = 33;;
let _M68K_REG_MSP = 34;;
let _M68K_REG_ISP = 35;;
let _M68K_REG_TC = 36;;
let _M68K_REG_ITT0 = 37;;
let _M68K_REG_ITT1 = 38;;
let _M68K_REG_DTT0 = 39;;
let _M68K_REG_DTT1 = 40;;
let _M68K_REG_MMUSR = 41;;
let _M68K_REG_URP = 42;;
let _M68K_REG_SRP = 43;;
let _M68K_REG_FPCR = 44;;
let _M68K_REG_FPSR = 45;;
let _M68K_REG_FPIAR = 46;;
let _M68K_REG_ENDING = 47;;
let _M68K_AM_NONE = 0;;
let _M68K_AM_REG_DIRECT_DATA = 1;;
let _M68K_AM_REG_DIRECT_ADDR = 2;;
let _M68K_AM_REGI_ADDR = 3;;
let _M68K_AM_REGI_ADDR_POST_INC = 4;;
let _M68K_AM_REGI_ADDR_PRE_DEC = 5;;
let _M68K_AM_REGI_ADDR_DISP = 6;;
let _M68K_AM_AREGI_INDEX_8_BIT_DISP = 7;;
let _M68K_AM_AREGI_INDEX_BASE_DISP = 8;;
let _M68K_AM_MEMI_POST_INDEX = 9;;
let _M68K_AM_MEMI_PRE_INDEX = 10;;
let _M68K_AM_PCI_DISP = 11;;
let _M68K_AM_PCI_INDEX_8_BIT_DISP = 12;;
let _M68K_AM_PCI_INDEX_BASE_DISP = 13;;
let _M68K_AM_PC_MEMI_POST_INDEX = 14;;
let _M68K_AM_PC_MEMI_PRE_INDEX = 15;;
let _M68K_AM_ABSOLUTE_DATA_SHORT = 16;;
let _M68K_AM_ABSOLUTE_DATA_LONG = 17;;
let _M68K_AM_IMMEDIATE = 18;;
let _M68K_AM_BRANCH_DISPLACEMENT = 19;;
let _M68K_OP_INVALID = _CS_OP_INVALID;;
let _M68K_OP_REG = _CS_OP_REG;;
let _M68K_OP_IMM = _CS_OP_IMM;;
let _M68K_OP_FP_SINGLE = _CS_OP_SPECIAL+0;;
let _M68K_OP_FP_DOUBLE = _CS_OP_SPECIAL+1;;
let _M68K_OP_REG_BITS = _CS_OP_SPECIAL+2;;
let _M68K_OP_REG_PAIR = _CS_OP_SPECIAL+3;;
let _M68K_OP_BR_DISP = _CS_OP_SPECIAL+4;;
let _M68K_OP_MEM = _CS_OP_MEM;;
let _M68K_OP_BR_DISP_SIZE_INVALID = 0;;
let _M68K_OP_BR_DISP_SIZE_BYTE = 1;;
let _M68K_OP_BR_DISP_SIZE_WORD = 2;;
let _M68K_OP_BR_DISP_SIZE_LONG = 4;;
let _M68K_CPU_SIZE_NONE = 0;;
let _M68K_CPU_SIZE_BYTE = 1;;
let _M68K_CPU_SIZE_WORD = 2;;
let _M68K_CPU_SIZE_LONG = 4;;
let _M68K_FPU_SIZE_NONE = 0;;
let _M68K_FPU_SIZE_SINGLE = 4;;
let _M68K_FPU_SIZE_DOUBLE = 8;;
let _M68K_FPU_SIZE_EXTENDED = 12;;
let _M68K_SIZE_TYPE_INVALID = 0;;
let _M68K_SIZE_TYPE_CPU = 1;;
let _M68K_SIZE_TYPE_FPU = 2;;
let _M68K_INS_INVALID = 0;;
let _M68K_INS_ABCD = 1;;
let _M68K_INS_ADD = 2;;
let _M68K_INS_ADDA = 3;;
let _M68K_INS_ADDI = 4;;
let _M68K_INS_ADDQ = 5;;
let _M68K_INS_ADDX = 6;;
let _M68K_INS_AND = 7;;
let _M68K_INS_ANDI = 8;;
let _M68K_INS_ASL = 9;;
let _M68K_INS_ASR = 10;;
let _M68K_INS_BHS = 11;;
let _M68K_INS_BLO = 12;;
let _M68K_INS_BHI = 13;;
let _M68K_INS_BLS = 14;;
let _M68K_INS_BCC = 15;;
let _M68K_INS_BCS = 16;;
let _M68K_INS_BNE = 17;;
let _M68K_INS_BEQ = 18;;
let _M68K_INS_BVC = 19;;
let _M68K_INS_BVS = 20;;
let _M68K_INS_BPL = 21;;
let _M68K_INS_BMI = 22;;
let _M68K_INS_BGE = 23;;
let _M68K_INS_BLT = 24;;
let _M68K_INS_BGT = 25;;
let _M68K_INS_BLE = 26;;
let _M68K_INS_BRA = 27;;
let _M68K_INS_BSR = 28;;
let _M68K_INS_BCHG = 29;;
let _M68K_INS_BCLR = 30;;
let _M68K_INS_BSET = 31;;
let _M68K_INS_BTST = 32;;
let _M68K_INS_BFCHG = 33;;
let _M68K_INS_BFCLR = 34;;
let _M68K_INS_BFEXTS = 35;;
let _M68K_INS_BFEXTU = 36;;
let _M68K_INS_BFFFO = 37;;
let _M68K_INS_BFINS = 38;;
let _M68K_INS_BFSET = 39;;
let _M68K_INS_BFTST = 40;;
let _M68K_INS_BKPT = 41;;
let _M68K_INS_CALLM = 42;;
let _M68K_INS_CAS = 43;;
let _M68K_INS_CAS2 = 44;;
let _M68K_INS_CHK = 45;;
let _M68K_INS_CHK2 = 46;;
let _M68K_INS_CLR = 47;;
let _M68K_INS_CMP = 48;;
let _M68K_INS_CMPA = 49;;
let _M68K_INS_CMPI = 50;;
let _M68K_INS_CMPM = 51;;
let _M68K_INS_CMP2 = 52;;
let _M68K_INS_CINVL = 53;;
let _M68K_INS_CINVP = 54;;
let _M68K_INS_CINVA = 55;;
let _M68K_INS_CPUSHL = 56;;
let _M68K_INS_CPUSHP = 57;;
let _M68K_INS_CPUSHA = 58;;
let _M68K_INS_DBT = 59;;
let _M68K_INS_DBF = 60;;
let _M68K_INS_DBHI = 61;;
let _M68K_INS_DBLS = 62;;
let _M68K_INS_DBCC = 63;;
let _M68K_INS_DBCS = 64;;
let _M68K_INS_DBNE = 65;;
let _M68K_INS_DBEQ = 66;;
let _M68K_INS_DBVC = 67;;
let _M68K_INS_DBVS = 68;;
let _M68K_INS_DBPL = 69;;
let _M68K_INS_DBMI = 70;;
let _M68K_INS_DBGE = 71;;
let _M68K_INS_DBLT = 72;;
let _M68K_INS_DBGT = 73;;
let _M68K_INS_DBLE = 74;;
let _M68K_INS_DBRA = 75;;
let _M68K_INS_DIVS = 76;;
let _M68K_INS_DIVSL = 77;;
let _M68K_INS_DIVU = 78;;
let _M68K_INS_DIVUL = 79;;
let _M68K_INS_EOR = 80;;
let _M68K_INS_EORI = 81;;
let _M68K_INS_EXG = 82;;
let _M68K_INS_EXT = 83;;
let _M68K_INS_EXTB = 84;;
let _M68K_INS_FABS = 85;;
let _M68K_INS_FSABS = 86;;
let _M68K_INS_FDABS = 87;;
let _M68K_INS_FACOS = 88;;
let _M68K_INS_FADD = 89;;
let _M68K_INS_FSADD = 90;;
let _M68K_INS_FDADD = 91;;
let _M68K_INS_FASIN = 92;;
let _M68K_INS_FATAN = 93;;
let _M68K_INS_FATANH = 94;;
let _M68K_INS_FBF = 95;;
let _M68K_INS_FBEQ = 96;;
let _M68K_INS_FBOGT = 97;;
let _M68K_INS_FBOGE = 98;;
let _M68K_INS_FBOLT = 99;;
let _M68K_INS_FBOLE = 100;;
let _M68K_INS_FBOGL = 101;;
let _M68K_INS_FBOR = 102;;
let _M68K_INS_FBUN = 103;;
let _M68K_INS_FBUEQ = 104;;
let _M68K_INS_FBUGT = 105;;
let _M68K_INS_FBUGE = 106;;
let _M68K_INS_FBULT = 107;;
let _M68K_INS_FBULE = 108;;
let _M68K_INS_FBNE = 109;;
let _M68K_INS_FBT = 110;;
let _M68K_INS_FBSF = 111;;
let _M68K_INS_FBSEQ = 112;;
let _M68K_INS_FBGT = 113;;
let _M68K_INS_FBGE = 114;;
let _M68K_INS_FBLT = 115;;
let _M68K_INS_FBLE = 116;;
let _M68K_INS_FBGL = 117;;
let _M68K_INS_FBGLE = 118;;
let _M68K_INS_FBNGLE = 119;;
let _M68K_INS_FBNGL = 120;;
let _M68K_INS_FBNLE = 121;;
let _M68K_INS_FBNLT = 122;;
let _M68K_INS_FBNGE = 123;;
let _M68K_INS_FBNGT = 124;;
let _M68K_INS_FBSNE = 125;;
let _M68K_INS_FBST = 126;;
let _M68K_INS_FCMP = 127;;
let _M68K_INS_FCOS = 128;;
let _M68K_INS_FCOSH = 129;;
let _M68K_INS_FDBF = 130;;
let _M68K_INS_FDBEQ = 131;;
let _M68K_INS_FDBOGT = 132;;
let _M68K_INS_FDBOGE = 133;;
let _M68K_INS_FDBOLT = 134;;
let _M68K_INS_FDBOLE = 135;;
let _M68K_INS_FDBOGL = 136;;
let _M68K_INS_FDBOR = 137;;
let _M68K_INS_FDBUN = 138;;
let _M68K_INS_FDBUEQ = 139;;
let _M68K_INS_FDBUGT = 140;;
let _M68K_INS_FDBUGE = 141;;
let _M68K_INS_FDBULT = 142;;
let _M68K_INS_FDBULE = 143;;
let _M68K_INS_FDBNE = 144;;
let _M68K_INS_FDBT = 145;;
let _M68K_INS_FDBSF = 146;;
let _M68K_INS_FDBSEQ = 147;;
let _M68K_INS_FDBGT = 148;;
let _M68K_INS_FDBGE = 149;;
let _M68K_INS_FDBLT = 150;;
let _M68K_INS_FDBLE = 151;;
let _M68K_INS_FDBGL = 152;;
let _M68K_INS_FDBGLE = 153;;
let _M68K_INS_FDBNGLE = 154;;
let _M68K_INS_FDBNGL = 155;;
let _M68K_INS_FDBNLE = 156;;
let _M68K_INS_FDBNLT = 157;;
let _M68K_INS_FDBNGE = 158;;
let _M68K_INS_FDBNGT = 159;;
let _M68K_INS_FDBSNE = 160;;
let _M68K_INS_FDBST = 161;;
let _M68K_INS_FDIV = 162;;
let _M68K_INS_FSDIV = 163;;
let _M68K_INS_FDDIV = 164;;
let _M68K_INS_FETOX = 165;;
let _M68K_INS_FETOXM1 = 166;;
let _M68K_INS_FGETEXP = 167;;
let _M68K_INS_FGETMAN = 168;;
let _M68K_INS_FINT = 169;;
let _M68K_INS_FINTRZ = 170;;
let _M68K_INS_FLOG10 = 171;;
let _M68K_INS_FLOG2 = 172;;
let _M68K_INS_FLOGN = 173;;
let _M68K_INS_FLOGNP1 = 174;;
let _M68K_INS_FMOD = 175;;
let _M68K_INS_FMOVE = 176;;
let _M68K_INS_FSMOVE = 177;;
let _M68K_INS_FDMOVE = 178;;
let _M68K_INS_FMOVECR = 179;;
let _M68K_INS_FMOVEM = 180;;
let _M68K_INS_FMUL = 181;;
let _M68K_INS_FSMUL = 182;;
let _M68K_INS_FDMUL = 183;;
let _M68K_INS_FNEG = 184;;
let _M68K_INS_FSNEG = 185;;
let _M68K_INS_FDNEG = 186;;
let _M68K_INS_FNOP = 187;;
let _M68K_INS_FREM = 188;;
let _M68K_INS_FRESTORE = 189;;
let _M68K_INS_FSAVE = 190;;
let _M68K_INS_FSCALE = 191;;
let _M68K_INS_FSGLDIV = 192;;
let _M68K_INS_FSGLMUL = 193;;
let _M68K_INS_FSIN = 194;;
let _M68K_INS_FSINCOS = 195;;
let _M68K_INS_FSINH = 196;;
let _M68K_INS_FSQRT = 197;;
let _M68K_INS_FSSQRT = 198;;
let _M68K_INS_FDSQRT = 199;;
let _M68K_INS_FSF = 200;;
let _M68K_INS_FSBEQ = 201;;
let _M68K_INS_FSOGT = 202;;
let _M68K_INS_FSOGE = 203;;
let _M68K_INS_FSOLT = 204;;
let _M68K_INS_FSOLE = 205;;
let _M68K_INS_FSOGL = 206;;
let _M68K_INS_FSOR = 207;;
let _M68K_INS_FSUN = 208;;
let _M68K_INS_FSUEQ = 209;;
let _M68K_INS_FSUGT = 210;;
let _M68K_INS_FSUGE = 211;;
let _M68K_INS_FSULT = 212;;
let _M68K_INS_FSULE = 213;;
let _M68K_INS_FSNE = 214;;
let _M68K_INS_FST = 215;;
let _M68K_INS_FSSF = 216;;
let _M68K_INS_FSSEQ = 217;;
let _M68K_INS_FSGT = 218;;
let _M68K_INS_FSGE = 219;;
let _M68K_INS_FSLT = 220;;
let _M68K_INS_FSLE = 221;;
let _M68K_INS_FSGL = 222;;
let _M68K_INS_FSGLE = 223;;
let _M68K_INS_FSNGLE = 224;;
let _M68K_INS_FSNGL = 225;;
let _M68K_INS_FSNLE = 226;;
let _M68K_INS_FSNLT = 227;;
let _M68K_INS_FSNGE = 228;;
let _M68K_INS_FSNGT = 229;;
let _M68K_INS_FSSNE = 230;;
let _M68K_INS_FSST = 231;;
let _M68K_INS_FSUB = 232;;
let _M68K_INS_FSSUB = 233;;
let _M68K_INS_FDSUB = 234;;
let _M68K_INS_FTAN = 235;;
let _M68K_INS_FTANH = 236;;
let _M68K_INS_FTENTOX = 237;;
let _M68K_INS_FTRAPF = 238;;
let _M68K_INS_FTRAPEQ = 239;;
let _M68K_INS_FTRAPOGT = 240;;
let _M68K_INS_FTRAPOGE = 241;;
let _M68K_INS_FTRAPOLT = 242;;
let _M68K_INS_FTRAPOLE = 243;;
let _M68K_INS_FTRAPOGL = 244;;
let _M68K_INS_FTRAPOR = 245;;
let _M68K_INS_FTRAPUN = 246;;
let _M68K_INS_FTRAPUEQ = 247;;
let _M68K_INS_FTRAPUGT = 248;;
let _M68K_INS_FTRAPUGE = 249;;
let _M68K_INS_FTRAPULT = 250;;
let _M68K_INS_FTRAPULE = 251;;
let _M68K_INS_FTRAPNE = 252;;
let _M68K_INS_FTRAPT = 253;;
let _M68K_INS_FTRAPSF = 254;;
let _M68K_INS_FTRAPSEQ = 255;;
let _M68K_INS_FTRAPGT = 256;;
let _M68K_INS_FTRAPGE = 257;;
let _M68K_INS_FTRAPLT = 258;;
let _M68K_INS_FTRAPLE = 259;;
let _M68K_INS_FTRAPGL = 260;;
let _M68K_INS_FTRAPGLE = 261;;
let _M68K_INS_FTRAPNGLE = 262;;
let _M68K_INS_FTRAPNGL = 263;;
let _M68K_INS_FTRAPNLE = 264;;
let _M68K_INS_FTRAPNLT = 265;;
let _M68K_INS_FTRAPNGE = 266;;
let _M68K_INS_FTRAPNGT = 267;;
let _M68K_INS_FTRAPSNE = 268;;
let _M68K_INS_FTRAPST = 269;;
let _M68K_INS_FTST = 270;;
let _M68K_INS_FTWOTOX = 271;;
let _M68K_INS_HALT = 272;;
let _M68K_INS_ILLEGAL = 273;;
let _M68K_INS_JMP = 274;;
let _M68K_INS_JSR = 275;;
let _M68K_INS_LEA = 276;;
let _M68K_INS_LINK = 277;;
let _M68K_INS_LPSTOP = 278;;
let _M68K_INS_LSL = 279;;
let _M68K_INS_LSR = 280;;
let _M68K_INS_MOVE = 281;;
let _M68K_INS_MOVEA = 282;;
let _M68K_INS_MOVEC = 283;;
let _M68K_INS_MOVEM = 284;;
let _M68K_INS_MOVEP = 285;;
let _M68K_INS_MOVEQ = 286;;
let _M68K_INS_MOVES = 287;;
let _M68K_INS_MOVE16 = 288;;
let _M68K_INS_MULS = 289;;
let _M68K_INS_MULU = 290;;
let _M68K_INS_NBCD = 291;;
let _M68K_INS_NEG = 292;;
let _M68K_INS_NEGX = 293;;
let _M68K_INS_NOP = 294;;
let _M68K_INS_NOT = 295;;
let _M68K_INS_OR = 296;;
let _M68K_INS_ORI = 297;;
let _M68K_INS_PACK = 298;;
let _M68K_INS_PEA = 299;;
let _M68K_INS_PFLUSH = 300;;
let _M68K_INS_PFLUSHA = 301;;
let _M68K_INS_PFLUSHAN = 302;;
let _M68K_INS_PFLUSHN = 303;;
let _M68K_INS_PLOADR = 304;;
let _M68K_INS_PLOADW = 305;;
let _M68K_INS_PLPAR = 306;;
let _M68K_INS_PLPAW = 307;;
let _M68K_INS_PMOVE = 308;;
let _M68K_INS_PMOVEFD = 309;;
let _M68K_INS_PTESTR = 310;;
let _M68K_INS_PTESTW = 311;;
let _M68K_INS_PULSE = 312;;
let _M68K_INS_REMS = 313;;
let _M68K_INS_REMU = 314;;
let _M68K_INS_RESET = 315;;
let _M68K_INS_ROL = 316;;
let _M68K_INS_ROR = 317;;
let _M68K_INS_ROXL = 318;;
let _M68K_INS_ROXR = 319;;
let _M68K_INS_RTD = 320;;
let _M68K_INS_RTE = 321;;
let _M68K_INS_RTM = 322;;
let _M68K_INS_RTR = 323;;
let _M68K_INS_RTS = 324;;
let _M68K_INS_SBCD = 325;;
let _M68K_INS_ST = 326;;
let _M68K_INS_SF = 327;;
let _M68K_INS_SHI = 328;;
let _M68K_INS_SLS = 329;;
let _M68K_INS_SCC = 330;;
let _M68K_INS_SHS = 331;;
let _M68K_INS_SCS = 332;;
let _M68K_INS_SLO = 333;;
let _M68K_INS_SNE = 334;;
let _M68K_INS_SEQ = 335;;
let _M68K_INS_SVC = 336;;
let _M68K_INS_SVS = 337;;
let _M68K_INS_SPL = 338;;
let _M68K_INS_SMI = 339;;
let _M68K_INS_SGE = 340;;
let _M68K_INS_SLT = 341;;
let _M68K_INS_SGT = 342;;
let _M68K_INS_SLE = 343;;
let _M68K_INS_STOP = 344;;
let _M68K_INS_SUB = 345;;
let _M68K_INS_SUBA = 346;;
let _M68K_INS_SUBI = 347;;
let _M68K_INS_SUBQ = 348;;
let _M68K_INS_SUBX = 349;;
let _M68K_INS_SWAP = 350;;
let _M68K_INS_TAS = 351;;
let _M68K_INS_TRAP = 352;;
let _M68K_INS_TRAPV = 353;;
let _M68K_INS_TRAPT = 354;;
let _M68K_INS_TRAPF = 355;;
let _M68K_INS_TRAPHI = 356;;
let _M68K_INS_TRAPLS = 357;;
let _M68K_INS_TRAPCC = 358;;
let _M68K_INS_TRAPHS = 359;;
let _M68K_INS_TRAPCS = 360;;
let _M68K_INS_TRAPLO = 361;;
let _M68K_INS_TRAPNE = 362;;
let _M68K_INS_TRAPEQ = 363;;
let _M68K_INS_TRAPVC = 364;;
let _M68K_INS_TRAPVS = 365;;
let _M68K_INS_TRAPPL = 366;;
let _M68K_INS_TRAPMI = 367;;
let _M68K_INS_TRAPGE = 368;;
let _M68K_INS_TRAPLT = 369;;
let _M68K_INS_TRAPGT = 370;;
let _M68K_INS_TRAPLE = 371;;
let _M68K_INS_TST = 372;;
let _M68K_INS_UNLK = 373;;
let _M68K_INS_UNPK = 374;;
let _M68K_INS_ENDING = 375;;
let _M68K_GRP_INVALID = 0;;
let _M68K_GRP_JUMP = 1;;
let _M68K_GRP_RET = 3;;
let _M68K_GRP_IRET = 5;;
let _M68K_GRP_BRANCH_RELATIVE = 7;;
let _M68K_GRP_ENDING = 8;;
+24
View File
@@ -0,0 +1,24 @@
(* Capstone Disassembly Engine
* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013-2014 *)
open Mips_const
(* architecture specific info of instruction *)
type mips_op_mem = {
base: int;
disp: int
}
type mips_op_value =
| MIPS_OP_INVALID of int
| MIPS_OP_REG of int
| MIPS_OP_IMM of int
| MIPS_OP_MEM of mips_op_mem
type mips_op = {
value: mips_op_value;
}
type cs_mips = {
operands: mips_op array;
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+34
View File
@@ -0,0 +1,34 @@
(* Capstone Disassembly Engine
* By Guillaume Jeanne <guillaume.jeanne@ensimag.fr>, 2014> *)
open Ppc_const
type ppc_op_mem = {
base: int;
disp: int;
}
type ppc_op_crx = {
scale: int;
reg: int;
cond: int;
}
type ppc_op_value =
| PPC_OP_INVALID of int
| PPC_OP_REG of int
| PPC_OP_IMM of int
| PPC_OP_MEM of ppc_op_mem
| PPC_OP_CRX of ppc_op_crx
type ppc_op = {
value: ppc_op_value;
}
type cs_ppc = {
bc: int;
bh: int;
update_cr0: bool;
operands: ppc_op array;
}
File diff suppressed because it is too large Load Diff
+27
View File
@@ -0,0 +1,27 @@
(* Capstone Disassembly Engine
* By Guillaume Jeanne <guillaume.jeanne@ensimag.fr>, 2014> *)
open Sparc_const
type sparc_op_mem = {
base: int;
index: int;
disp: int;
}
type sparc_op_value =
| SPARC_OP_INVALID of int
| SPARC_OP_REG of int
| SPARC_OP_IMM of int
| SPARC_OP_MEM of sparc_op_mem
type sparc_op = {
value: sparc_op_value;
}
type cs_sparc = {
cc: int;
hint: int;
operands: sparc_op array;
}
File diff suppressed because it is too large Load Diff
+27
View File
@@ -0,0 +1,27 @@
(* Capstone Disassembly Engine
* By Guillaume Jeanne <guillaume.jeanne@ensimag.fr>, 2014> *)
open Sysz_const
type sysz_op_mem = {
base: int;
index: int;
length: int64;
disp: int64;
}
type sysz_op_value =
| SYSZ_OP_INVALID of int
| SYSZ_OP_REG of int
| SYSZ_OP_ACREG of int
| SYSZ_OP_IMM of int
| SYSZ_OP_MEM of sysz_op_mem
type sysz_op = {
value: sysz_op_value;
}
type cs_sysz = {
cc: int;
operands: sysz_op array;
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+105
View File
@@ -0,0 +1,105 @@
(* Capstone Disassembly Engine
* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013-2014 *)
open Printf
open Capstone
open Arm
open Arm_const
let print_string_hex comment str =
printf "%s" comment;
for i = 0 to (Array.length str - 1) do
printf "0x%02x " str.(i)
done;
printf "\n"
let _ARM_CODE = "\xED\xFF\xFF\xEB\x04\xe0\x2d\xe5\x00\x00\x00\x00\xe0\x83\x22\xe5\xf1\x02\x03\x0e\x00\x00\xa0\xe3\x02\x30\xc1\xe7\x00\x00\x53\xe3";;
let _ARM_CODE2 = "\xd1\xe8\x00\xf0\xf0\x24\x04\x07\x1f\x3c\xf2\xc0\x00\x00\x4f\xf0\x00\x01\x46\x6c";;
let _THUMB_CODE2 = "\x4f\xf0\x00\x01\xbd\xe8\x00\x88\xd1\xe8\x00\xf0";;
let _THUMB_CODE = "\x70\x47\xeb\x46\x83\xb0\xc9\x68\x1f\xb1";;
let all_tests = [
(CS_ARCH_ARM, [CS_MODE_ARM], _ARM_CODE, "ARM");
(CS_ARCH_ARM, [CS_MODE_THUMB], _THUMB_CODE, "Thumb");
(CS_ARCH_ARM, [CS_MODE_THUMB], _ARM_CODE2, "Thumb-mixed");
(CS_ARCH_ARM, [CS_MODE_THUMB], _THUMB_CODE2, "Thumb-2");
];;
let print_op handle i op =
( match op.value with
| ARM_OP_INVALID _ -> (); (* this would never happens *)
| ARM_OP_REG reg -> printf "\t\top[%d]: REG = %s\n" i (cs_reg_name handle reg);
| ARM_OP_CIMM imm -> printf "\t\top[%d]: C-IMM = %u\n" i imm;
| ARM_OP_PIMM imm -> printf "\t\top[%d]: P-IMM = %u\n" i imm;
| ARM_OP_IMM imm -> printf "\t\top[%d]: IMM = 0x%x\n" i imm;
| ARM_OP_FP fp -> printf "\t\top[%d]: FP = %f\n" i fp;
| ARM_OP_MEM mem -> ( printf "\t\top[%d]: MEM\n" i;
if mem.base != 0 then
printf "\t\t\toperands[%u].mem.base: REG = %s\n" i (cs_reg_name handle mem.base);
if mem.index != 0 then
printf "\t\t\toperands[%u].mem.index: REG = %s\n" i (cs_reg_name handle mem.index);
if mem.scale != 1 then
printf "\t\t\toperands[%u].mem.scale: %d\n" i mem.scale;
if mem.disp != 0 then
printf "\t\t\toperands[%u].mem.disp: 0x%x\n" i mem.disp;
if mem.lshift != 0 then
printf "\t\t\toperands[%u].mem.lshift: 0x%x\n" i mem.lshift;
);
| ARM_OP_SETEND sd -> printf "\t\top[%d]: SETEND = %u\n" i sd;
);
if op.shift.shift_type != _ARM_SFT_INVALID && op.shift.shift_value > 0 then
printf "\t\t\tShift: type = %u, value = %u\n"
op.shift.shift_type op.shift.shift_value;
();;
let print_detail handle insn =
match insn.arch with
| CS_INFO_ARM arm -> (
if arm.cc != _ARM_CC_AL && arm.cc != _ARM_CC_INVALID then
printf "\tCode condition: %u\n" arm.cc;
if arm.update_flags then
printf "\tUpdate-flags: True\n";
if arm.writeback then
printf "\tWriteback: True\n";
(* print all operands info (type & value) *)
if (Array.length arm.operands) > 0 then (
printf "\top_count: %d\n" (Array.length arm.operands);
Array.iteri (print_op handle) arm.operands;
);
printf "\n";
);
| _ -> ();
;;
let print_insn handle insn =
printf "0x%x\t%s\t%s\n" insn.address insn.mnemonic insn.op_str;
print_detail handle insn
let print_arch x =
let (arch, mode, code, comment) = x in
let handle = cs_open arch mode in
let err = cs_option handle CS_OPT_DETAIL _CS_OPT_ON in
match err with
| _ -> ();
let insns = cs_disasm handle code 0x1000L 0L in
printf "*************\n";
printf "Platform: %s\n" comment;
List.iter (print_insn handle) insns;
match cs_close handle with
| 0 -> ();
| _ -> printf "Failed to close handle";
;;
List.iter print_arch all_tests;;
+101
View File
@@ -0,0 +1,101 @@
(* Capstone Disassembly Engine
* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013-2014 *)
open Printf
open Capstone
open Arm64
open Arm64_const
let print_string_hex comment str =
printf "%s" comment;
for i = 0 to (Array.length str - 1) do
printf "0x%02x " str.(i)
done;
printf "\n"
let _ARM64_CODE = "\x21\x7c\x02\x9b\x21\x7c\x00\x53\x00\x40\x21\x4b\xe1\x0b\x40\xb9\x20\x04\x81\xda\x20\x08\x02\x8b";;
let all_tests = [
(CS_ARCH_ARM64, [CS_MODE_ARM], _ARM64_CODE, "ARM-64");
];;
let print_op handle i op =
( match op.value with
| ARM64_OP_INVALID _ -> (); (* this would never happens *)
| ARM64_OP_REG reg -> printf "\t\top[%d]: REG = %s\n" i (cs_reg_name handle reg);
| ARM64_OP_CIMM imm -> printf "\t\top[%d]: C-IMM = %u\n" i imm;
| ARM64_OP_IMM imm -> printf "\t\top[%d]: IMM = 0x%x\n" i imm;
| ARM64_OP_FP fp -> printf "\t\top[%d]: FP = %f\n" i fp;
| ARM64_OP_MEM mem -> ( printf "\t\top[%d]: MEM\n" i;
if mem.base != 0 then
printf "\t\t\toperands[%u].mem.base: REG = %s\n" i (cs_reg_name handle mem.base);
if mem.index != 0 then
printf "\t\t\toperands[%u].mem.index: REG = %s\n" i (cs_reg_name handle mem.index);
if mem.disp != 0 then
printf "\t\t\toperands[%u].mem.disp: 0x%x\n" i mem.disp;
);
| ARM64_OP_REG_MRS reg -> printf "\t\top[%d]: REG_MRS = %u\n" i reg;
| ARM64_OP_REG_MSR reg -> printf "\t\top[%d]: REG_MSR = %u\n" i reg;
| ARM64_OP_PSTATE v -> printf "\t\top[%d]: PSTATE = %u\n" i v;
| ARM64_OP_SYS v -> printf "\t\top[%d]: SYS = %u\n" i v;
| ARM64_OP_PREFETCH v -> printf "\t\top[%d]: PREFETCH = %u\n" i v;
| ARM64_OP_BARRIER v -> printf "\t\top[%d]: BARRIER = %u\n" i v;
);
if op.shift.shift_type != _ARM64_SFT_INVALID && op.shift.shift_value > 0 then
printf "\t\t\tShift: type = %u, value = %u\n"
op.shift.shift_type op.shift.shift_value;
if op.ext != _ARM64_EXT_INVALID then
printf "\t\t\tExt: %u\n" op.ext;
();;
let print_detail handle insn =
match insn.arch with
| CS_INFO_ARM64 arm64 -> (
if arm64.cc != _ARM64_CC_AL && arm64.cc != _ARM64_CC_INVALID then
printf "\tCode condition: %u\n" arm64.cc;
if arm64.update_flags then
printf "\tUpdate-flags: True\n";
if arm64.writeback then
printf "\tWriteback: True\n";
(* print all operands info (type & value) *)
if (Array.length arm64.operands) > 0 then (
printf "\top_count: %d\n" (Array.length arm64.operands);
Array.iteri (print_op handle) arm64.operands;
);
printf "\n";
)
| _ -> ();
;;
let print_insn handle insn =
printf "0x%x\t%s\t%s\n" insn.address insn.mnemonic insn.op_str;
print_detail handle insn
let print_arch x =
let (arch, mode, code, comment) = x in
let handle = cs_open arch mode in
let err = cs_option handle CS_OPT_DETAIL _CS_OPT_ON in
match err with
| _ -> ();
let insns = cs_disasm handle code 0x1000L 0L in
printf "*************\n";
printf "Platform: %s\n" comment;
List.iter (print_insn handle) insns;
match cs_close handle with
| 0 -> ();
| _ -> printf "Failed to close handle";
;;
List.iter print_arch all_tests;;
+67
View File
@@ -0,0 +1,67 @@
(* Capstone Disassembly Engine
* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013-2014 *)
open Printf
open List
open Capstone
let _X86_CODE16 = "\x8d\x4c\x32\x08\x01\xd8\x81\xc6\x34\x12\x00\x00";;
let _X86_CODE32 = "\x8d\x4c\x32\x08\x01\xd8\x81\xc6\x34\x12\x00\x00";;
let _X86_CODE64 = "\x55\x48\x8b\x05\xb8\x13\x00\x00";;
let _ARM_CODE = "\xED\xFF\xFF\xEB\x04\xe0\x2d\xe5\x00\x00\x00\x00\xe0\x83\x22\xe5\xf1\x02\x03\x0e\x00\x00\xa0\xe3\x02\x30\xc1\xe7\x00\x00\x53\xe3";;
let _ARM_CODE2 = "\x10\xf1\x10\xe7\x11\xf2\x31\xe7\xdc\xa1\x2e\xf3\xe8\x4e\x62\xf3";;
let _THUMB_CODE = "\x70\x47\xeb\x46\x83\xb0\xc9\x68";;
let _THUMB_CODE2 = "\x4f\xf0\x00\x01\xbd\xe8\x00\x88";;
let _MIPS_CODE = "\x0C\x10\x00\x97\x00\x00\x00\x00\x24\x02\x00\x0c\x8f\xa2\x00\x00\x34\x21\x34\x56";;
let _MIPS_CODE2 = "\x56\x34\x21\x34\xc2\x17\x01\x00";;
let _ARM64_CODE = "\x21\x7c\x02\x9b\x21\x7c\x00\x53\x00\x40\x21\x4b\xe1\x0b\x40\xb9";;
let _PPC_CODE = "\x80\x20\x00\x00\x80\x3f\x00\x00\x10\x43\x23\x0e\xd0\x44\x00\x80\x4c\x43\x22\x02\x2d\x03\x00\x80\x7c\x43\x20\x14\x7c\x43\x20\x93\x4f\x20\x00\x21\x4c\xc8\x00\x21";;
let _SPARC_CODE = "\x80\xa0\x40\x02\x85\xc2\x60\x08\x85\xe8\x20\x01\x81\xe8\x00\x00\x90\x10\x20\x01\xd5\xf6\x10\x16\x21\x00\x00\x0a\x86\x00\x40\x02\x01\x00\x00\x00\x12\xbf\xff\xff\x10\xbf\xff\xff\xa0\x02\x00\x09\x0d\xbf\xff\xff\xd4\x20\x60\x00\xd4\x4e\x00\x16\x2a\xc2\x80\x03";;
let _SPARCV9_CODE = "\x81\xa8\x0a\x24\x89\xa0\x10\x20\x89\xa0\x1a\x60\x89\xa0\x00\xe0";;
let _SYSZ_CODE = "\xed\x00\x00\x00\x00\x1a\x5a\x0f\x1f\xff\xc2\x09\x80\x00\x00\x00\x07\xf7\xeb\x2a\xff\xff\x7f\x57\xe3\x01\xff\xff\x7f\x57\xeb\x00\xf0\x00\x00\x24\xb2\x4f\x00\x78";;
let _XCORE_CODE = "\xfe\x0f\xfe\x17\x13\x17\xc6\xfe\xec\x17\x97\xf8\xec\x4f\x1f\xfd\xec\x37\x07\xf2\x45\x5b\xf9\xfa\x02\x06\x1b\x10";;
let all_tests = [
(CS_ARCH_X86, [CS_MODE_16], _X86_CODE16, "X86 16bit (Intel syntax)", 0L);
(CS_ARCH_X86, [CS_MODE_32], _X86_CODE32, "X86 32bit (ATT syntax)", _CS_OPT_SYNTAX_ATT);
(CS_ARCH_X86, [CS_MODE_32], _X86_CODE32, "X86 32 (Intel syntax)", 0L);
(CS_ARCH_X86, [CS_MODE_64], _X86_CODE64, "X86 64 (Intel syntax)", 0L);
(CS_ARCH_ARM, [CS_MODE_ARM], _ARM_CODE, "ARM", 0L);
(CS_ARCH_ARM, [CS_MODE_ARM], _ARM_CODE2, "ARM: Cortex-A15 + NEON", 0L);
(CS_ARCH_ARM, [CS_MODE_THUMB], _THUMB_CODE, "THUMB", 0L);
(CS_ARCH_ARM, [CS_MODE_THUMB], _THUMB_CODE2, "THUMB-2", 0L);
(CS_ARCH_ARM64, [CS_MODE_ARM], _ARM64_CODE, "ARM-64", 0L);
(CS_ARCH_MIPS, [CS_MODE_MIPS32; CS_MODE_BIG_ENDIAN], _MIPS_CODE, "MIPS-32 (Big-endian)", 0L);
(CS_ARCH_MIPS, [CS_MODE_MIPS64; CS_MODE_LITTLE_ENDIAN], _MIPS_CODE2, "MIPS-64-EL (Little-endian)", 0L);
(CS_ARCH_PPC, [CS_MODE_BIG_ENDIAN], _PPC_CODE, "PPC-64", 0L);
(CS_ARCH_PPC, [CS_MODE_BIG_ENDIAN], _PPC_CODE, "PPC-64, print register with number only", 0L);
(CS_ARCH_SPARC, [CS_MODE_BIG_ENDIAN], _SPARC_CODE, "Sparc", 0L);
(CS_ARCH_SPARC, [CS_MODE_BIG_ENDIAN; CS_MODE_V9], _SPARCV9_CODE, "SparcV9", 0L);
(CS_ARCH_SYSZ, [CS_MODE_LITTLE_ENDIAN], _SYSZ_CODE, "SystemZ", 0L);
(CS_ARCH_XCORE, [CS_MODE_LITTLE_ENDIAN], _XCORE_CODE, "XCore", 0L);
];;
let print_insn insn =
printf "0x%x\t%s\t%s\n" insn.address insn.mnemonic insn.op_str;;
let print_arch x =
let (arch, mode, code, comment, syntax) = x in
let handle = cs_open arch mode in (
if syntax != 0L then (
let err = cs_option handle CS_OPT_SYNTAX syntax in
match err with
| _ -> ();
);
let insns = cs_disasm handle code 0x1000L 0L in (
printf "*************\n";
printf "Platform: %s\n" comment;
List.iter print_insn insns;
);
match cs_close handle with
| 0 -> ();
| _ -> printf "Failed to close handle";
);;
List.iter print_arch all_tests;;
+87
View File
@@ -0,0 +1,87 @@
(* Capstone Disassembly Engine
* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013-2014 *)
open Printf
open List
open Capstone
let _X86_CODE16 = "\x8d\x4c\x32\x08\x01\xd8\x81\xc6\x34\x12\x00\x00";;
let _X86_CODE32 = "\x8d\x4c\x32\x08\x01\xd8\x81\xc6\x34\x12\x00\x00";;
let _X86_CODE64 = "\x55\x48\x8b\x05\xb8\x13\x00\x00";;
let _ARM_CODE = "\xED\xFF\xFF\xEB\x04\xe0\x2d\xe5\x00\x00\x00\x00\xe0\x83\x22\xe5\xf1\x02\x03\x0e\x00\x00\xa0\xe3\x02\x30\xc1\xe7\x00\x00\x53\xe3";;
let _ARM_CODE2 = "\x10\xf1\x10\xe7\x11\xf2\x31\xe7\xdc\xa1\x2e\xf3\xe8\x4e\x62\xf3";;
let _THUMB_CODE = "\x70\x47\xeb\x46\x83\xb0\xc9\x68";;
let _THUMB_CODE2 = "\x4f\xf0\x00\x01\xbd\xe8\x00\x88";;
let _MIPS_CODE = "\x0C\x10\x00\x97\x00\x00\x00\x00\x24\x02\x00\x0c\x8f\xa2\x00\x00\x34\x21\x34\x56";;
let _MIPS_CODE2 = "\x56\x34\x21\x34\xc2\x17\x01\x00";;
let _ARM64_CODE = "\x21\x7c\x02\x9b\x21\x7c\x00\x53\x00\x40\x21\x4b\xe1\x0b\x40\xb9";;
let _PPC_CODE = "\x80\x20\x00\x00\x80\x3f\x00\x00\x10\x43\x23\x0e\xd0\x44\x00\x80\x4c\x43\x22\x02\x2d\x03\x00\x80\x7c\x43\x20\x14\x7c\x43\x20\x93\x4f\x20\x00\x21\x4c\xc8\x00\x21";;
let _SPARC_CODE = "\x80\xa0\x40\x02\x85\xc2\x60\x08\x85\xe8\x20\x01\x81\xe8\x00\x00\x90\x10\x20\x01\xd5\xf6\x10\x16\x21\x00\x00\x0a\x86\x00\x40\x02\x01\x00\x00\x00\x12\xbf\xff\xff\x10\xbf\xff\xff\xa0\x02\x00\x09\x0d\xbf\xff\xff\xd4\x20\x60\x00\xd4\x4e\x00\x16\x2a\xc2\x80\x03";;
let _SPARCV9_CODE = "\x81\xa8\x0a\x24\x89\xa0\x10\x20\x89\xa0\x1a\x60\x89\xa0\x00\xe0";;
let _SYSZ_CODE = "\xed\x00\x00\x00\x00\x1a\x5a\x0f\x1f\xff\xc2\x09\x80\x00\x00\x00\x07\xf7\xeb\x2a\xff\xff\x7f\x57\xe3\x01\xff\xff\x7f\x57\xeb\x00\xf0\x00\x00\x24\xb2\x4f\x00\x78";;
let _XCORE_CODE = "\xfe\x0f\xfe\x17\x13\x17\xc6\xfe\xec\x17\x97\xf8\xec\x4f\x1f\xfd\xec\x37\x07\xf2\x45\x5b\xf9\xfa\x02\x06\x1b\x10";;
let all_tests = [
(CS_ARCH_X86, [CS_MODE_16], _X86_CODE16, "X86 16bit (Intel syntax)", 0);
(CS_ARCH_X86, [CS_MODE_32], _X86_CODE32, "X86 32bit (ATT syntax)", 0);
(CS_ARCH_X86, [CS_MODE_32], _X86_CODE32, "X86 32 (Intel syntax)", 0);
(CS_ARCH_X86, [CS_MODE_64], _X86_CODE64, "X86 64 (Intel syntax)", 0);
(CS_ARCH_ARM, [CS_MODE_ARM], _ARM_CODE, "ARM", 0);
(CS_ARCH_ARM, [CS_MODE_ARM], _ARM_CODE2, "ARM: Cortex-A15 + NEON", 0);
(CS_ARCH_ARM, [CS_MODE_THUMB], _THUMB_CODE, "THUMB", 0);
(CS_ARCH_ARM, [CS_MODE_THUMB], _THUMB_CODE2, "THUMB-2", 0);
(CS_ARCH_ARM64, [CS_MODE_ARM], _ARM64_CODE, "ARM-64", 0);
(CS_ARCH_MIPS, [CS_MODE_MIPS32; CS_MODE_BIG_ENDIAN], _MIPS_CODE, "MIPS-32 (Big-endian)", 0);
(CS_ARCH_MIPS, [CS_MODE_MIPS64; CS_MODE_LITTLE_ENDIAN], _MIPS_CODE2, "MIPS-64-EL (Little-endian)", 0);
(CS_ARCH_PPC, [CS_MODE_64; CS_MODE_BIG_ENDIAN], _PPC_CODE, "PPC-64", 0);
(CS_ARCH_SPARC, [CS_MODE_BIG_ENDIAN], _SPARC_CODE, "Sparc", 0);
(CS_ARCH_SPARC, [CS_MODE_BIG_ENDIAN; CS_MODE_V9], _SPARCV9_CODE, "SparcV9", 0);
(CS_ARCH_SYSZ, [CS_MODE_LITTLE_ENDIAN], _SYSZ_CODE, "SystemZ", 0);
(CS_ARCH_XCORE, [CS_MODE_LITTLE_ENDIAN], _XCORE_CODE, "XCore", 0);
];;
let print_detail handle insn =
(* print immediate operands *)
if (Array.length insn.regs_read) > 0 then begin
printf "\tImplicit registers read: ";
Array.iter (fun x -> printf "%s "(cs_reg_name handle x)) insn.regs_read;
printf "\n";
end;
if (Array.length insn.regs_write) > 0 then begin
printf "\tImplicit registers written: ";
Array.iter (fun x -> printf "%s "(cs_reg_name handle x)) insn.regs_write;
printf "\n";
end;
if (Array.length insn.groups) > 0 then begin
printf "\tThis instruction belongs to groups: ";
Array.iter (printf "%u ") insn.groups;
printf "\n";
end;
printf "\n";;
let print_insn handle insn =
printf "0x%x\t%s\t%s\n" insn.address insn.mnemonic insn.op_str;
print_detail handle insn
let print_arch x =
let (arch, mode, code, comment, syntax) = x in
let handle = cs_open arch mode in
let err = cs_option handle CS_OPT_DETAIL _CS_OPT_ON in
match err with
| _ -> ();
let insns = cs_disasm handle code 0x1000L 0L in
printf "*************\n";
printf "Platform: %s\n" comment;
List.iter (print_insn handle) insns;
match cs_close handle with
| 0 -> ();
| _ -> printf "Failed to close handle";
;;
List.iter print_arch all_tests;;
+167
View File
@@ -0,0 +1,167 @@
(* Capstone Disassembly Engine
* M680X Backend by Wolfgang Schwotzer <wolfgang.schwotzer@gmx.net> 2017 *)
open Printf
open Capstone
open M680x
open M680x_const
let print_char_hex ch =
printf " 0x%02x" (Char.code ch)
let print_int_hex_short value =
printf "%02x" value
let print_string_hex comment str =
printf "%s" comment;
String.iter print_char_hex str;
printf "\n"
let print_array_hex_short arr =
Array.iter print_int_hex_short arr
let s_access = [
"UNCHANGED"; "READ"; "WRITE"; "READ | WRITE" ];;
let _M6800_CODE = "\x01\x09\x36\x64\x7f\x74\x10\x00\x90\x10\xA4\x10\xb6\x10\x00\x39";;
let _M6801_CODE = "\x04\x05\x3c\x3d\x38\x93\x10\xec\x10\xed\x10\x39";;
let _M6805_CODE = "\x04\x7f\x00\x17\x22\x28\x00\x2e\x00\x40\x42\x5a\x70\x8e\x97\x9c\xa0\x15\xad\x00\xc3\x10\x00\xda\x12\x34\xe5\x7f\xfe";;
let _M6808_CODE = "\x31\x22\x00\x35\x22\x45\x10\x00\x4b\x00\x51\x10\x52\x5e\x22\x62\x65\x12\x34\x72\x84\x85\x86\x87\x8a\x8b\x8c\x94\x95\xa7\x10\xaf\x10\x9e\x60\x7f\x9e\x6b\x7f\x00\x9e\xd6\x10\x00\x9e\xe6\x7f";;
let _HD6301_CODE = "\x6b\x10\x00\x71\x10\x00\x72\x10\x10\x39";;
let _M6809_CODE = "\x06\x10\x19\x1a\x55\x1e\x01\x23\xe9\x31\x06\x34\x55\xa6\x81\xa7\x89\x7f\xff\xa6\x9d\x10\x00\xa7\x91\xa6\x9f\x10\x00\x11\xac\x99\x10\x00\x39\xA6\x07\xA6\x27\xA6\x47\xA6\x67\xA6\x0F\xA6\x10\xA6\x80\xA6\x81\xA6\x82\xA6\x83\xA6\x84\xA6\x85\xA6\x86\xA6\x88\x7F\xA6\x88\x80\xA6\x89\x7F\xFF\xA6\x89\x80\x00\xA6\x8B\xA6\x8C\x10\xA6\x8D\x10\x00\xA6\x91\xA6\x93\xA6\x94\xA6\x95\xA6\x96\xA6\x98\x7F\xA6\x98\x80\xA6\x99\x7F\xFF\xA6\x99\x80\x00\xA6\x9B\xA6\x9C\x10\xA6\x9D\x10\x00\xA6\x9F\x10\x00";;
let _HD6309_CODE = "\x01\x10\x10\x62\x10\x10\x7b\x10\x10\x00\xcd\x49\x96\x02\xd2\x10\x30\x23\x10\x38\x10\x3b\x10\x53\x10\x5d\x11\x30\x43\x10\x11\x37\x25\x10\x11\x38\x12\x11\x39\x23\x11\x3b\x34\x11\x8e\x10\x00\x11\xaf\x10\x11\xab\x10\x11\xf6\x80\x00";;
let _M6811_CODE = "\x02\x03\x12\x7f\x10\x00\x13\x99\x08\x00\x14\x7f\x02\x15\x7f\x01\x1e\x7f\x20\x00\x8f\xcf\x18\x08\x18\x30\x18\x3c\x18\x67\x18\x8c\x10\x00\x18\x8f\x18\xce\x10\x00\x18\xff\x10\x00\x1a\xa3\x7f\x1a\xac\x1a\xee\x7f\x1a\xef\x7f\xcd\xac\x7f";;
let _CPU12_CODE = "\x00\x04\x01\x00\x0c\x00\x80\x0e\x00\x80\x00\x11\x1e\x10\x00\x80\x00\x3b\x4a\x10\x00\x04\x4b\x01\x04\x4f\x7f\x80\x00\x8f\x10\x00\xb7\x52\xb7\xb1\xa6\x67\xa6\xfe\xa6\xf7\x18\x02\xe2\x30\x39\xe2\x10\x00\x18\x0c\x30\x39\x10\x00\x18\x11\x18\x12\x10\x00\x18\x19\x00\x18\x1e\x00\x18\x3e\x18\x3f\x00";;
let _HCS08_CODE = "\x32\x10\x00\x9e\xae\x9e\xce\x7f\x9e\xbe\x10\x00\x9e\xfe\x7f\x3e\x10\x00\x9e\xf3\x7f\x96\x10\x00\x9e\xff\x7f\x82";;
let bit_set value mask =
value land mask != 0
let all_tests = [
(CS_ARCH_M680X, [CS_MODE_M680X_6301], _HD6301_CODE, "M680X_HD6301");
(CS_ARCH_M680X, [CS_MODE_M680X_6309], _HD6309_CODE, "M680X_HD6309");
(CS_ARCH_M680X, [CS_MODE_M680X_6800], _M6800_CODE, "M680X_M6800");
(CS_ARCH_M680X, [CS_MODE_M680X_6801], _M6801_CODE, "M680X_M6801");
(CS_ARCH_M680X, [CS_MODE_M680X_6805], _M6805_CODE, "M680X_M68HC05");
(CS_ARCH_M680X, [CS_MODE_M680X_6808], _M6808_CODE, "M680X_M68HC08");
(CS_ARCH_M680X, [CS_MODE_M680X_6809], _M6809_CODE, "M680X_M6809");
(CS_ARCH_M680X, [CS_MODE_M680X_6811], _M6811_CODE, "M680X_M68HC11");
(CS_ARCH_M680X, [CS_MODE_M680X_CPU12], _CPU12_CODE, "M680X_CPU12");
(CS_ARCH_M680X, [CS_MODE_M680X_HCS08], _HCS08_CODE, "M680X_HCS08");
];;
let print_inc_dec inc_dec is_post = (
printf "\t\t\t";
if is_post then printf "post" else printf "pre";
if inc_dec > 0 then
printf " increment: %d\n" inc_dec
else
printf " decrement: %d\n" (abs inc_dec);
);
();;
let print_op handle flags i op =
( match op.value with
| M680X_OP_INVALID _ -> (); (* this would never happens *)
| M680X_OP_REGISTER reg -> (
printf "\t\toperands[%d].type: REGISTER = %s" i (cs_reg_name handle reg);
if (((i == 0) && (bit_set flags _M680X_FIRST_OP_IN_MNEM)) ||
((i == 1) && (bit_set flags _M680X_SECOND_OP_IN_MNEM))) then
printf " (in mnemonic)";
printf "\n";
);
| M680X_OP_IMMEDIATE imm ->
printf "\t\toperands[%d].type: IMMEDIATE = #%d\n" i imm;
| M680X_OP_DIRECT direct_addr ->
printf "\t\toperands[%d].type: DIRECT = 0x%02x\n" i direct_addr;
| M680X_OP_EXTENDED ext -> (
printf "\t\toperands[%d].type: EXTENDED " i;
if ext.indirect then
printf "INDIRECT";
printf " = 0x%04x\n" ext.addr_ext;
);
| M680X_OP_RELATIVE rel ->
printf "\t\toperands[%d].type: RELATIVE = 0x%04x\n" i rel.addr_rel;
| M680X_OP_INDEXED idx -> (
printf "\t\toperands[%d].type: INDEXED" i;
if (bit_set idx.flags _M680X_IDX_INDIRECT) then
printf " INDIRECT";
printf "\n";
if idx.base_reg != _M680X_REG_INVALID then
printf "\t\t\tbase register: %s\n" (cs_reg_name handle idx.base_reg);
if idx.offset_reg != _M680X_REG_INVALID then
printf "\t\t\toffset register: %s\n" (cs_reg_name handle idx.offset_reg);
if idx.offset_bits != 0 && idx.offset_reg == 0 && idx.inc_dec == 0 then begin
printf "\t\t\toffset: %d\n" idx.offset;
if idx.base_reg == _M680X_REG_PC then
printf "\t\t\toffset address: 0x%x\n" idx.offset_addr;
printf "\t\t\toffset bits: %u\n" idx.offset_bits;
end;
if idx.inc_dec != 0 then
print_inc_dec idx.inc_dec (bit_set idx.flags _M680X_IDX_POST_INC_DEC);
);
| M680X_OP_CONSTANT const_val ->
printf "\t\toperands[%d].type: CONSTANT = %d\n" i const_val;
);
if op.size != 0 then
printf "\t\t\tsize: %d\n" op.size;
if op.access != _CS_AC_INVALID then
printf "\t\t\taccess: %s\n" (List.nth s_access op.access);
();;
let print_detail handle insn =
match insn.arch with
| CS_INFO_M680X m680x -> (
(* print all operands info (type & value) *)
if (Array.length m680x.operands) > 0 then (
printf "\top_count: %d\n" (Array.length m680x.operands);
Array.iteri (print_op handle m680x.flags) m680x.operands;
);
);
| _ -> ();
;;
let print_reg handle reg =
printf " %s" (cs_reg_name handle reg)
let print_insn handle insn =
printf "0x%04x:\t" insn.address;
print_array_hex_short insn.bytes;
printf "\t%s\t%s\n" insn.mnemonic insn.op_str;
print_detail handle insn;
if (Array.length insn.regs_read) > 0 then begin
printf "\tRegisters read:";
Array.iter (print_reg handle) insn.regs_read;
printf "\n";
end;
if (Array.length insn.regs_write) > 0 then begin
printf "\tRegisters modified:";
Array.iter (print_reg handle) insn.regs_write;
printf "\n";
end;
if (Array.length insn.groups) > 0 then
printf "\tgroups_count: %d\n" (Array.length insn.groups);
printf "\n"
let print_arch x =
let (arch, mode, code, comment) = x in
let handle = cs_open arch mode in
let err = cs_option handle CS_OPT_DETAIL _CS_OPT_ON in
match err with
| _ -> ();
let insns = cs_disasm handle code 0x1000L 0L in
printf "********************\n";
printf "Platform: %s\n" comment;
print_string_hex "Code: " code;
printf "Disasm:\n";
List.iter (print_insn handle) insns;
match cs_close handle with
| 0 -> ();
| _ -> printf "Failed to close handle";
;;
List.iter print_arch all_tests;;
+75
View File
@@ -0,0 +1,75 @@
(* Capstone Disassembly Engine
* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013-2014 *)
open Printf
open Capstone
open Mips
let print_string_hex comment str =
printf "%s" comment;
for i = 0 to (Array.length str - 1) do
printf "0x%02x " str.(i)
done;
printf "\n"
let _MIPS_CODE = "\x0C\x10\x00\x97\x00\x00\x00\x00\x24\x02\x00\x0c\x8f\xa2\x00\x00\x34\x21\x34\x56";;
let _MIPS_CODE2 = "\x56\x34\x21\x34\xc2\x17\x01\x00";;
let all_tests = [
(CS_ARCH_MIPS, [CS_MODE_MIPS32; CS_MODE_BIG_ENDIAN], _MIPS_CODE, "MIPS-32 (Big-endian)");
(CS_ARCH_MIPS, [CS_MODE_MIPS64; CS_MODE_LITTLE_ENDIAN], _MIPS_CODE2, "MIPS-64-EL (Little-endian)");
];;
let print_op handle i op =
( match op.value with
| MIPS_OP_INVALID _ -> (); (* this would never happens *)
| MIPS_OP_REG reg -> printf "\t\top[%d]: REG = %s\n" i (cs_reg_name handle reg);
| MIPS_OP_IMM imm -> printf "\t\top[%d]: IMM = 0x%x\n" i imm;
| MIPS_OP_MEM mem -> ( printf "\t\top[%d]: MEM\n" i;
if mem.base != 0 then
printf "\t\t\toperands[%u].mem.base: REG = %s\n" i (cs_reg_name handle mem.base);
if mem.disp != 0 then
printf "\t\t\toperands[%u].mem.disp: 0x%x\n" i mem.disp;
);
);
();;
let print_detail handle insn =
match insn.arch with
| CS_INFO_MIPS mips -> (
(* print all operands info (type & value) *)
if (Array.length mips.operands) > 0 then (
printf "\top_count: %d\n" (Array.length mips.operands);
Array.iteri (print_op handle) mips.operands;
);
printf "\n";
);
| _ -> ();
;;
let print_insn handle insn =
printf "0x%x\t%s\t%s\n" insn.address insn.mnemonic insn.op_str;
print_detail handle insn
let print_arch x =
let (arch, mode, code, comment) = x in
let handle = cs_open arch mode in
let err = cs_option handle CS_OPT_DETAIL _CS_OPT_ON in
match err with
| _ -> ();
let insns = cs_disasm handle code 0x1000L 0L in
printf "*************\n";
printf "Platform: %s\n" comment;
List.iter (print_insn handle) insns;
match cs_close handle with
| 0 -> ();
| _ -> printf "Failed to close handle";
;;
List.iter print_arch all_tests;;
+81
View File
@@ -0,0 +1,81 @@
(* Capstone Disassembly Engine
* By Guillaume Jeanne <guillaume.jeanne@ensimag.fr>, 2014> *)
open Printf
open Capstone
open Ppc
let print_string_hex comment str =
printf "%s" comment;
for i = 0 to (Array.length str - 1) do
printf "0x%02x " str.(i)
done;
printf "\n"
let _PPC_CODE = "\x80\x20\x00\x00\x80\x3f\x00\x00\x10\x43\x23\x0e\xd0\x44\x00\x80\x4c\x43\x22\x02\x2d\x03\x00\x80\x7c\x43\x20\x14\x7c\x43\x20\x93\x4f\x20\x00\x21\x4c\xc8\x00\x21";;
let all_tests = [
(CS_ARCH_PPC, [CS_MODE_64; CS_MODE_BIG_ENDIAN], _PPC_CODE, "PPC-64");
];;
let print_op handle i op =
( match op.value with
| PPC_OP_INVALID _ -> (); (* this would never happens *)
| PPC_OP_REG reg -> printf "\t\top[%d]: REG = %s\n" i (cs_reg_name handle reg);
| PPC_OP_IMM imm -> printf "\t\top[%d]: IMM = 0x%x\n" i imm;
| PPC_OP_MEM mem -> ( printf "\t\top[%d]: MEM\n" i;
if mem.base != 0 then
printf "\t\t\toperands[%u].mem.base: REG = %s\n" i (cs_reg_name handle mem.base);
if mem.disp != 0 then
printf "\t\t\toperands[%u].mem.disp: 0x%x\n" i mem.disp;
);
| PPC_OP_CRX crx -> ( printf "\t\top[%d]: CRX\n" i;
if crx.scale != 0 then
printf "\t\t\toperands[%u].crx.scale = %u\n" i crx.scale;
if crx.reg != 0 then
printf "\t\t\toperands[%u].crx.reg = %s\n" i (cs_reg_name handle crx.reg);
if crx.cond != 0 then
printf "\t\t\toperands[%u].crx.cond = 0x%x\n" i crx.cond;
);
);
();;
let print_detail handle insn =
match insn.arch with
| CS_INFO_PPC ppc -> (
(* print all operands info (type & value) *)
if (Array.length ppc.operands) > 0 then (
printf "\top_count: %d\n" (Array.length ppc.operands);
Array.iteri (print_op handle) ppc.operands;
);
printf "\n";
);
| _ -> ();
;;
let print_insn handle insn =
printf "0x%x\t%s\t%s\n" insn.address insn.mnemonic insn.op_str;
print_detail handle insn
let print_arch x =
let (arch, mode, code, comment) = x in
let handle = cs_open arch mode in
let err = cs_option handle CS_OPT_DETAIL _CS_OPT_ON in
match err with
| _ -> ();
let insns = cs_disasm handle code 0x1000L 0L in
printf "*************\n";
printf "Platform: %s\n" comment;
List.iter (print_insn handle) insns;
match cs_close handle with
| 0 -> ();
| _ -> printf "Failed to close handle";
;;
List.iter print_arch all_tests;;
+79
View File
@@ -0,0 +1,79 @@
(* Capstone Disassembly Engine
* By Guillaume Jeanne <guillaume.jeanne@ensimag.fr>, 2014> *)
open Printf
open Capstone
open Sparc
let print_string_hex comment str =
printf "%s" comment;
for i = 0 to (Array.length str - 1) do
printf "0x%02x " str.(i)
done;
printf "\n"
let _SPARC_CODE = "\x80\xa0\x40\x02\x85\xc2\x60\x08\x85\xe8\x20\x01\x81\xe8\x00\x00\x90\x10\x20\x01\xd5\xf6\x10\x16\x21\x00\x00\x0a\x86\x00\x40\x02\x01\x00\x00\x00\x12\xbf\xff\xff\x10\xbf\xff\xff\xa0\x02\x00\x09\x0d\xbf\xff\xff\xd4\x20\x60\x00\xd4\x4e\x00\x16\x2a\xc2\x80\x03";;
let _SPARCV9_CODE = "\x81\xa8\x0a\x24\x89\xa0\x10\x20\x89\xa0\x1a\x60\x89\xa0\x00\xe0";;
let all_tests = [
(CS_ARCH_SPARC, [CS_MODE_BIG_ENDIAN], _SPARC_CODE, "Sparc");
(CS_ARCH_SPARC, [CS_MODE_BIG_ENDIAN; CS_MODE_V9], _SPARCV9_CODE, "SparcV9");
];;
let print_op handle i op =
( match op.value with
| SPARC_OP_INVALID _ -> (); (* this would never happens *)
| SPARC_OP_REG reg -> printf "\t\top[%d]: REG = %s\n" i (cs_reg_name handle reg);
| SPARC_OP_IMM imm -> printf "\t\top[%d]: IMM = 0x%x\n" i imm;
| SPARC_OP_MEM mem -> ( printf "\t\top[%d]: MEM\n" i;
if mem.base != 0 then
printf "\t\t\toperands[%u].mem.base: REG = %s\n" i (cs_reg_name handle mem.base);
if mem.index != 0 then
printf "\t\t\toperands[%u].mem.index: 0x%x\n" i mem.index;
if mem.disp != 0 then
printf "\t\t\toperands[%u].mem.disp: 0x%x\n" i mem.disp;
);
);
();;
let print_detail handle insn =
match insn.arch with
| CS_INFO_SPARC sparc -> (
(* print all operands info (type & value) *)
if (Array.length sparc.operands) > 0 then (
printf "\top_count: %d\n" (Array.length sparc.operands);
Array.iteri (print_op handle) sparc.operands;
);
printf "\n";
);
| _ -> ();
;;
let print_insn handle insn =
printf "0x%x\t%s\t%s\n" insn.address insn.mnemonic insn.op_str;
print_detail handle insn
let print_arch x =
let (arch, mode, code, comment) = x in
let handle = cs_open arch mode in
let err = cs_option handle CS_OPT_DETAIL _CS_OPT_ON in
match err with
| _ -> ();
let insns = cs_disasm handle code 0x1000L 0L in
printf "*************\n";
printf "Platform: %s\n" comment;
List.iter (print_insn handle) insns;
match cs_close handle with
| 0 -> ();
| _ -> printf "Failed to close handle";
;;
List.iter print_arch all_tests;;
+80
View File
@@ -0,0 +1,80 @@
(* Capstone Disassembly Engine
* By Guillaume Jeanne <guillaume.jeanne@ensimag.fr>, 2014> *)
open Printf
open Capstone
open Systemz
let print_string_hex comment str =
printf "%s" comment;
for i = 0 to (Array.length str - 1) do
printf "0x%02x " str.(i)
done;
printf "\n"
let _SYSZ_CODE = "\xed\x00\x00\x00\x00\x1a\x5a\x0f\x1f\xff\xc2\x09\x80\x00\x00\x00\x07\xf7\xeb\x2a\xff\xff\x7f\x57\xe3\x01\xff\xff\x7f\x57\xeb\x00\xf0\x00\x00\x24\xb2\x4f\x00\x78";;
let all_tests = [
(CS_ARCH_SYSZ, [CS_MODE_LITTLE_ENDIAN], _SYSZ_CODE, "SystemZ");
];;
let print_op handle i op =
( match op.value with
| SYSZ_OP_INVALID _ -> (); (* this would never happens *)
| SYSZ_OP_REG reg -> printf "\t\top[%d]: REG = %s\n" i (cs_reg_name handle reg);
| SYSZ_OP_ACREG reg -> printf "\t\top[%d]: ACREG = %u\n" i reg;
| SYSZ_OP_IMM imm -> printf "\t\top[%d]: IMM = 0x%x\n" i imm;
| SYSZ_OP_MEM mem -> ( printf "\t\top[%d]: MEM\n" i;
if mem.base != 0 then
printf "\t\t\toperands[%u].mem.base: REG = %s\n" i (cs_reg_name handle mem.base);
if mem.index != 0 then
printf "\t\t\toperands[%u].mem.index: 0x%x\n" i mem.index;
if mem.length != 0L then
printf "\t\t\toperands[%u].mem.length: 0x%Lx\n" i mem.length;
if mem.disp != 0L then
printf "\t\t\toperands[%u].mem.disp: 0x%Lx\n" i mem.disp;
);
);
();;
let print_detail handle insn =
match insn.arch with
| CS_INFO_SYSZ sysz -> (
(* print all operands info (type & value) *)
if (Array.length sysz.operands) > 0 then (
printf "\top_count: %d\n" (Array.length sysz.operands);
Array.iteri (print_op handle) sysz.operands;
);
printf "\n";
);
| _ -> ();
;;
let print_insn handle insn =
printf "0x%x\t%s\t%s\n" insn.address insn.mnemonic insn.op_str;
print_detail handle insn
let print_arch x =
let (arch, mode, code, comment) = x in
let handle = cs_open arch mode in
let err = cs_option handle CS_OPT_DETAIL _CS_OPT_ON in
match err with
| _ -> ();
let insns = cs_disasm handle code 0x1000L 0L in
printf "*************\n";
printf "Platform: %s\n" comment;
List.iter (print_insn handle) insns;
match cs_close handle with
| 0 -> ();
| _ -> printf "Failed to close handle";
;;
List.iter print_arch all_tests;;
+117
View File
@@ -0,0 +1,117 @@
(* Capstone Disassembly Engine
* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013-2014 *)
open Printf
open Capstone
open X86
open X86_const
let print_string_hex comment str =
printf "%s" comment;
for i = 0 to (Array.length str - 1) do
printf "0x%02x " str.(i)
done;
printf "\n"
let _X86_CODE16 = "\x8d\x4c\x32\x08\x01\xd8\x81\xc6\x34\x12\x00\x00";;
let _X86_CODE32 = "\x8d\x4c\x32\x08\x01\xd8\x81\xc6\x34\x12\x00\x00";;
let _X86_CODE64 = "\x55\x48\x8b\x05\xb8\x13\x00\x00";;
let all_tests = [
(CS_ARCH_X86, [CS_MODE_16], _X86_CODE16, "X86 16bit (Intel syntax)", 0L);
(CS_ARCH_X86, [CS_MODE_32], _X86_CODE32, "X86 32bit (ATT syntax)", _CS_OPT_SYNTAX_ATT);
(CS_ARCH_X86, [CS_MODE_32], _X86_CODE32, "X86 32 (Intel syntax)", 0L);
(CS_ARCH_X86, [CS_MODE_64], _X86_CODE64, "X86 64 (Intel syntax)", 0L);
];;
let print_op handle i op =
( match op.value with
| X86_OP_INVALID _ -> (); (* this would never happens *)
| X86_OP_REG reg -> printf "\t\top[%d]: REG = %s [sz=%d]\n" i (cs_reg_name handle reg) op.size;
| X86_OP_IMM imm -> printf "\t\top[%d]: IMM = 0x%x [sz=%d]\n" i imm op.size;
| X86_OP_MEM mem -> ( printf "\t\top[%d]: MEM [sz=%d]\n" i op.size;
if mem.base != 0 then
printf "\t\t\toperands[%u].mem.base: REG = %s\n" i (cs_reg_name handle mem.base);
if mem.index != 0 then
printf "\t\t\toperands[%u].mem.index: REG = %s\n" i (cs_reg_name handle mem.index);
if mem.scale != 1 then
printf "\t\t\toperands[%u].mem.scale: %d\n" i mem.scale;
if mem.disp != 0 then
printf "\t\t\toperands[%u].mem.disp: 0x%x\n" i mem.disp;
);
);
();;
let print_detail handle mode insn =
match insn.arch with
| CS_INFO_X86 x86 -> (
print_string_hex "\tPrefix: " x86.prefix;
(* print instruction's opcode *)
print_string_hex "\tOpcode: " x86.opcode;
(* print operand's size, address size, displacement size & immediate size *)
printf "\taddr_size: %u\n" x86.addr_size;
(* print modRM byte *)
printf "\tmodrm: 0x%x\n" x86.modrm;
(* print displacement value *)
if x86.disp != 0 then
printf "\tdisp: 0x%x\n" x86.disp;
(* SIB is invalid in 16-bit mode *)
if not (List.mem CS_MODE_16 mode) then (
(* print SIB byte *)
printf "\tsib: 0x%x\n" x86.sib;
(* print sib index/scale/base (if applicable) *)
if x86.sib_index != _X86_REG_INVALID then
printf "\tsib_index: %s, sib_scale: %u, sib_base: %s\n"
(cs_reg_name handle x86.sib_index)
x86.sib_scale
(cs_reg_name handle x86.sib_base);
);
(* print all operands info (type & value) *)
if (Array.length x86.operands) > 0 then (
printf "\top_count: %d\n" (Array.length x86.operands);
Array.iteri (print_op handle) x86.operands;
);
printf "\n";
);
| _ -> ();
;;
let print_insn handle mode insn =
printf "0x%x\t%s\t%s\n" insn.address insn.mnemonic insn.op_str;
print_detail handle mode insn
let print_arch x =
let (arch, mode, code, comment, syntax) = x in
let handle = cs_open arch mode in (
if syntax != 0L then (
let err = cs_option handle CS_OPT_SYNTAX syntax in
match err with
| _ -> ();
);
let err = cs_option handle CS_OPT_DETAIL _CS_OPT_ON in
match err with
| _ -> ();
let insns = cs_disasm handle code 0x1000L 0L in (
printf "*************\n";
printf "Platform: %s\n" comment;
List.iter (print_insn handle mode) insns;
);
match cs_close handle with
| 0 -> ();
| _ -> printf "Failed to close handle";
);;
List.iter print_arch all_tests;;
+78
View File
@@ -0,0 +1,78 @@
(* Capstone Disassembly Engine
* By Guillaume Jeanne <guillaume.jeanne@ensimag.fr>, 2014> *)
open Printf
open Capstone
open Xcore
let print_string_hex comment str =
printf "%s" comment;
for i = 0 to (Array.length str - 1) do
printf "0x%02x " str.(i)
done;
printf "\n"
let _XCORE_CODE = "\xfe\x0f\xfe\x17\x13\x17\xc6\xfe\xec\x17\x97\xf8\xec\x4f\x1f\xfd\xec\x37\x07\xf2\x45\x5b\xf9\xfa\x02\x06\x1b\x10";;
let all_tests = [
(CS_ARCH_XCORE, [CS_MODE_LITTLE_ENDIAN], _XCORE_CODE, "XCore");
];;
let print_op handle i op =
( match op.value with
| XCORE_OP_INVALID _ -> (); (* this would never happens *)
| XCORE_OP_REG reg -> printf "\t\top[%d]: REG = %s\n" i (cs_reg_name handle reg);
| XCORE_OP_IMM imm -> printf "\t\top[%d]: IMM = 0x%x\n" i imm;
| XCORE_OP_MEM mem -> ( printf "\t\top[%d]: MEM\n" i;
if mem.base != 0 then
printf "\t\t\toperands[%u].mem.base: REG = %s\n" i (cs_reg_name handle mem.base);
if mem.index != 0 then
printf "\t\t\toperands[%u].mem.index: 0x%x\n" i mem.index;
if mem.disp != 0 then
printf "\t\t\toperands[%u].mem.disp: 0x%x\n" i mem.disp;
if mem.direct != 0 then
printf "\t\t\toperands[%u].mem.direct: 0x%x\n" i mem.direct;
);
);
();;
let print_detail handle insn =
match insn.arch with
| CS_INFO_XCORE xcore -> (
(* print all operands info (type & value) *)
if (Array.length xcore.operands) > 0 then (
printf "\top_count: %d\n" (Array.length xcore.operands);
Array.iteri (print_op handle) xcore.operands;
);
printf "\n";
);
| _ -> ();
;;
let print_insn handle insn =
printf "0x%x\t%s\t%s\n" insn.address insn.mnemonic insn.op_str;
print_detail handle insn
let print_arch x =
let (arch, mode, code, comment) = x in
let handle = cs_open arch mode in
let err = cs_option handle CS_OPT_DETAIL _CS_OPT_ON in
match err with
| _ -> ();
let insns = cs_disasm handle code 0x1000L 0L in
printf "*************\n";
printf "Platform: %s\n" comment;
List.iter (print_insn handle) insns;
match cs_close handle with
| 0 -> ();
| _ -> printf "Failed to close handle";
;;
List.iter print_arch all_tests;;
+276
View File
@@ -0,0 +1,276 @@
(* For Capstone Engine. AUTO-GENERATED FILE, DO NOT EDIT [tms320c64x_const.ml] *)
let _TMS320C64X_OP_INVALID = _CS_OP_INVALID;;
let _TMS320C64X_OP_REG = _CS_OP_REG;;
let _TMS320C64X_OP_IMM = _CS_OP_IMM;;
let _TMS320C64X_OP_REGPAIR = _CS_OP_SPECIAL+0;;
let _TMS320C64X_OP_MEM = _CS_OP_MEM;;
let _TMS320C64X_MEM_DISP_INVALID = 0;;
let _TMS320C64X_MEM_DISP_CONSTANT = 1;;
let _TMS320C64X_MEM_DISP_REGISTER = 2;;
let _TMS320C64X_MEM_DIR_INVALID = 0;;
let _TMS320C64X_MEM_DIR_FW = 1;;
let _TMS320C64X_MEM_DIR_BW = 2;;
let _TMS320C64X_MEM_MOD_INVALID = 0;;
let _TMS320C64X_MEM_MOD_NO = 1;;
let _TMS320C64X_MEM_MOD_PRE = 2;;
let _TMS320C64X_MEM_MOD_POST = 3;;
let _TMS320C64X_REG_INVALID = 0;;
let _TMS320C64X_REG_AMR = 1;;
let _TMS320C64X_REG_CSR = 2;;
let _TMS320C64X_REG_DIER = 3;;
let _TMS320C64X_REG_DNUM = 4;;
let _TMS320C64X_REG_ECR = 5;;
let _TMS320C64X_REG_GFPGFR = 6;;
let _TMS320C64X_REG_GPLYA = 7;;
let _TMS320C64X_REG_GPLYB = 8;;
let _TMS320C64X_REG_ICR = 9;;
let _TMS320C64X_REG_IER = 10;;
let _TMS320C64X_REG_IERR = 11;;
let _TMS320C64X_REG_ILC = 12;;
let _TMS320C64X_REG_IRP = 13;;
let _TMS320C64X_REG_ISR = 14;;
let _TMS320C64X_REG_ISTP = 15;;
let _TMS320C64X_REG_ITSR = 16;;
let _TMS320C64X_REG_NRP = 17;;
let _TMS320C64X_REG_NTSR = 18;;
let _TMS320C64X_REG_REP = 19;;
let _TMS320C64X_REG_RILC = 20;;
let _TMS320C64X_REG_SSR = 21;;
let _TMS320C64X_REG_TSCH = 22;;
let _TMS320C64X_REG_TSCL = 23;;
let _TMS320C64X_REG_TSR = 24;;
let _TMS320C64X_REG_A0 = 25;;
let _TMS320C64X_REG_A1 = 26;;
let _TMS320C64X_REG_A2 = 27;;
let _TMS320C64X_REG_A3 = 28;;
let _TMS320C64X_REG_A4 = 29;;
let _TMS320C64X_REG_A5 = 30;;
let _TMS320C64X_REG_A6 = 31;;
let _TMS320C64X_REG_A7 = 32;;
let _TMS320C64X_REG_A8 = 33;;
let _TMS320C64X_REG_A9 = 34;;
let _TMS320C64X_REG_A10 = 35;;
let _TMS320C64X_REG_A11 = 36;;
let _TMS320C64X_REG_A12 = 37;;
let _TMS320C64X_REG_A13 = 38;;
let _TMS320C64X_REG_A14 = 39;;
let _TMS320C64X_REG_A15 = 40;;
let _TMS320C64X_REG_A16 = 41;;
let _TMS320C64X_REG_A17 = 42;;
let _TMS320C64X_REG_A18 = 43;;
let _TMS320C64X_REG_A19 = 44;;
let _TMS320C64X_REG_A20 = 45;;
let _TMS320C64X_REG_A21 = 46;;
let _TMS320C64X_REG_A22 = 47;;
let _TMS320C64X_REG_A23 = 48;;
let _TMS320C64X_REG_A24 = 49;;
let _TMS320C64X_REG_A25 = 50;;
let _TMS320C64X_REG_A26 = 51;;
let _TMS320C64X_REG_A27 = 52;;
let _TMS320C64X_REG_A28 = 53;;
let _TMS320C64X_REG_A29 = 54;;
let _TMS320C64X_REG_A30 = 55;;
let _TMS320C64X_REG_A31 = 56;;
let _TMS320C64X_REG_B0 = 57;;
let _TMS320C64X_REG_B1 = 58;;
let _TMS320C64X_REG_B2 = 59;;
let _TMS320C64X_REG_B3 = 60;;
let _TMS320C64X_REG_B4 = 61;;
let _TMS320C64X_REG_B5 = 62;;
let _TMS320C64X_REG_B6 = 63;;
let _TMS320C64X_REG_B7 = 64;;
let _TMS320C64X_REG_B8 = 65;;
let _TMS320C64X_REG_B9 = 66;;
let _TMS320C64X_REG_B10 = 67;;
let _TMS320C64X_REG_B11 = 68;;
let _TMS320C64X_REG_B12 = 69;;
let _TMS320C64X_REG_B13 = 70;;
let _TMS320C64X_REG_B14 = 71;;
let _TMS320C64X_REG_B15 = 72;;
let _TMS320C64X_REG_B16 = 73;;
let _TMS320C64X_REG_B17 = 74;;
let _TMS320C64X_REG_B18 = 75;;
let _TMS320C64X_REG_B19 = 76;;
let _TMS320C64X_REG_B20 = 77;;
let _TMS320C64X_REG_B21 = 78;;
let _TMS320C64X_REG_B22 = 79;;
let _TMS320C64X_REG_B23 = 80;;
let _TMS320C64X_REG_B24 = 81;;
let _TMS320C64X_REG_B25 = 82;;
let _TMS320C64X_REG_B26 = 83;;
let _TMS320C64X_REG_B27 = 84;;
let _TMS320C64X_REG_B28 = 85;;
let _TMS320C64X_REG_B29 = 86;;
let _TMS320C64X_REG_B30 = 87;;
let _TMS320C64X_REG_B31 = 88;;
let _TMS320C64X_REG_PCE1 = 89;;
let _TMS320C64X_REG_ENDING = 90;;
let _TMS320C64X_REG_EFR = _TMS320C64X_REG_ECR;;
let _TMS320C64X_REG_IFR = _TMS320C64X_REG_ISR;;
let _TMS320C64X_INS_INVALID = 0;;
let _TMS320C64X_INS_ABS = 1;;
let _TMS320C64X_INS_ABS2 = 2;;
let _TMS320C64X_INS_ADD = 3;;
let _TMS320C64X_INS_ADD2 = 4;;
let _TMS320C64X_INS_ADD4 = 5;;
let _TMS320C64X_INS_ADDAB = 6;;
let _TMS320C64X_INS_ADDAD = 7;;
let _TMS320C64X_INS_ADDAH = 8;;
let _TMS320C64X_INS_ADDAW = 9;;
let _TMS320C64X_INS_ADDK = 10;;
let _TMS320C64X_INS_ADDKPC = 11;;
let _TMS320C64X_INS_ADDU = 12;;
let _TMS320C64X_INS_AND = 13;;
let _TMS320C64X_INS_ANDN = 14;;
let _TMS320C64X_INS_AVG2 = 15;;
let _TMS320C64X_INS_AVGU4 = 16;;
let _TMS320C64X_INS_B = 17;;
let _TMS320C64X_INS_BDEC = 18;;
let _TMS320C64X_INS_BITC4 = 19;;
let _TMS320C64X_INS_BNOP = 20;;
let _TMS320C64X_INS_BPOS = 21;;
let _TMS320C64X_INS_CLR = 22;;
let _TMS320C64X_INS_CMPEQ = 23;;
let _TMS320C64X_INS_CMPEQ2 = 24;;
let _TMS320C64X_INS_CMPEQ4 = 25;;
let _TMS320C64X_INS_CMPGT = 26;;
let _TMS320C64X_INS_CMPGT2 = 27;;
let _TMS320C64X_INS_CMPGTU4 = 28;;
let _TMS320C64X_INS_CMPLT = 29;;
let _TMS320C64X_INS_CMPLTU = 30;;
let _TMS320C64X_INS_DEAL = 31;;
let _TMS320C64X_INS_DOTP2 = 32;;
let _TMS320C64X_INS_DOTPN2 = 33;;
let _TMS320C64X_INS_DOTPNRSU2 = 34;;
let _TMS320C64X_INS_DOTPRSU2 = 35;;
let _TMS320C64X_INS_DOTPSU4 = 36;;
let _TMS320C64X_INS_DOTPU4 = 37;;
let _TMS320C64X_INS_EXT = 38;;
let _TMS320C64X_INS_EXTU = 39;;
let _TMS320C64X_INS_GMPGTU = 40;;
let _TMS320C64X_INS_GMPY4 = 41;;
let _TMS320C64X_INS_LDB = 42;;
let _TMS320C64X_INS_LDBU = 43;;
let _TMS320C64X_INS_LDDW = 44;;
let _TMS320C64X_INS_LDH = 45;;
let _TMS320C64X_INS_LDHU = 46;;
let _TMS320C64X_INS_LDNDW = 47;;
let _TMS320C64X_INS_LDNW = 48;;
let _TMS320C64X_INS_LDW = 49;;
let _TMS320C64X_INS_LMBD = 50;;
let _TMS320C64X_INS_MAX2 = 51;;
let _TMS320C64X_INS_MAXU4 = 52;;
let _TMS320C64X_INS_MIN2 = 53;;
let _TMS320C64X_INS_MINU4 = 54;;
let _TMS320C64X_INS_MPY = 55;;
let _TMS320C64X_INS_MPY2 = 56;;
let _TMS320C64X_INS_MPYH = 57;;
let _TMS320C64X_INS_MPYHI = 58;;
let _TMS320C64X_INS_MPYHIR = 59;;
let _TMS320C64X_INS_MPYHL = 60;;
let _TMS320C64X_INS_MPYHLU = 61;;
let _TMS320C64X_INS_MPYHSLU = 62;;
let _TMS320C64X_INS_MPYHSU = 63;;
let _TMS320C64X_INS_MPYHU = 64;;
let _TMS320C64X_INS_MPYHULS = 65;;
let _TMS320C64X_INS_MPYHUS = 66;;
let _TMS320C64X_INS_MPYLH = 67;;
let _TMS320C64X_INS_MPYLHU = 68;;
let _TMS320C64X_INS_MPYLI = 69;;
let _TMS320C64X_INS_MPYLIR = 70;;
let _TMS320C64X_INS_MPYLSHU = 71;;
let _TMS320C64X_INS_MPYLUHS = 72;;
let _TMS320C64X_INS_MPYSU = 73;;
let _TMS320C64X_INS_MPYSU4 = 74;;
let _TMS320C64X_INS_MPYU = 75;;
let _TMS320C64X_INS_MPYU4 = 76;;
let _TMS320C64X_INS_MPYUS = 77;;
let _TMS320C64X_INS_MVC = 78;;
let _TMS320C64X_INS_MVD = 79;;
let _TMS320C64X_INS_MVK = 80;;
let _TMS320C64X_INS_MVKL = 81;;
let _TMS320C64X_INS_MVKLH = 82;;
let _TMS320C64X_INS_NOP = 83;;
let _TMS320C64X_INS_NORM = 84;;
let _TMS320C64X_INS_OR = 85;;
let _TMS320C64X_INS_PACK2 = 86;;
let _TMS320C64X_INS_PACKH2 = 87;;
let _TMS320C64X_INS_PACKH4 = 88;;
let _TMS320C64X_INS_PACKHL2 = 89;;
let _TMS320C64X_INS_PACKL4 = 90;;
let _TMS320C64X_INS_PACKLH2 = 91;;
let _TMS320C64X_INS_ROTL = 92;;
let _TMS320C64X_INS_SADD = 93;;
let _TMS320C64X_INS_SADD2 = 94;;
let _TMS320C64X_INS_SADDU4 = 95;;
let _TMS320C64X_INS_SADDUS2 = 96;;
let _TMS320C64X_INS_SAT = 97;;
let _TMS320C64X_INS_SET = 98;;
let _TMS320C64X_INS_SHFL = 99;;
let _TMS320C64X_INS_SHL = 100;;
let _TMS320C64X_INS_SHLMB = 101;;
let _TMS320C64X_INS_SHR = 102;;
let _TMS320C64X_INS_SHR2 = 103;;
let _TMS320C64X_INS_SHRMB = 104;;
let _TMS320C64X_INS_SHRU = 105;;
let _TMS320C64X_INS_SHRU2 = 106;;
let _TMS320C64X_INS_SMPY = 107;;
let _TMS320C64X_INS_SMPY2 = 108;;
let _TMS320C64X_INS_SMPYH = 109;;
let _TMS320C64X_INS_SMPYHL = 110;;
let _TMS320C64X_INS_SMPYLH = 111;;
let _TMS320C64X_INS_SPACK2 = 112;;
let _TMS320C64X_INS_SPACKU4 = 113;;
let _TMS320C64X_INS_SSHL = 114;;
let _TMS320C64X_INS_SSHVL = 115;;
let _TMS320C64X_INS_SSHVR = 116;;
let _TMS320C64X_INS_SSUB = 117;;
let _TMS320C64X_INS_STB = 118;;
let _TMS320C64X_INS_STDW = 119;;
let _TMS320C64X_INS_STH = 120;;
let _TMS320C64X_INS_STNDW = 121;;
let _TMS320C64X_INS_STNW = 122;;
let _TMS320C64X_INS_STW = 123;;
let _TMS320C64X_INS_SUB = 124;;
let _TMS320C64X_INS_SUB2 = 125;;
let _TMS320C64X_INS_SUB4 = 126;;
let _TMS320C64X_INS_SUBAB = 127;;
let _TMS320C64X_INS_SUBABS4 = 128;;
let _TMS320C64X_INS_SUBAH = 129;;
let _TMS320C64X_INS_SUBAW = 130;;
let _TMS320C64X_INS_SUBC = 131;;
let _TMS320C64X_INS_SUBU = 132;;
let _TMS320C64X_INS_SWAP4 = 133;;
let _TMS320C64X_INS_UNPKHU4 = 134;;
let _TMS320C64X_INS_UNPKLU4 = 135;;
let _TMS320C64X_INS_XOR = 136;;
let _TMS320C64X_INS_XPND2 = 137;;
let _TMS320C64X_INS_XPND4 = 138;;
let _TMS320C64X_INS_IDLE = 139;;
let _TMS320C64X_INS_MV = 140;;
let _TMS320C64X_INS_NEG = 141;;
let _TMS320C64X_INS_NOT = 142;;
let _TMS320C64X_INS_SWAP2 = 143;;
let _TMS320C64X_INS_ZERO = 144;;
let _TMS320C64X_INS_ENDING = 145;;
let _TMS320C64X_GRP_INVALID = 0;;
let _TMS320C64X_GRP_JUMP = 1;;
let _TMS320C64X_GRP_FUNIT_D = 128;;
let _TMS320C64X_GRP_FUNIT_L = 129;;
let _TMS320C64X_GRP_FUNIT_M = 130;;
let _TMS320C64X_GRP_FUNIT_S = 131;;
let _TMS320C64X_GRP_FUNIT_NO = 132;;
let _TMS320C64X_GRP_ENDING = 133;;
let _TMS320C64X_FUNIT_INVALID = 0;;
let _TMS320C64X_FUNIT_D = 1;;
let _TMS320C64X_FUNIT_L = 2;;
let _TMS320C64X_FUNIT_M = 3;;
let _TMS320C64X_FUNIT_S = 4;;
let _TMS320C64X_FUNIT_NO = 5;;
+190
View File
@@ -0,0 +1,190 @@
(* For Capstone Engine. AUTO-GENERATED FILE, DO NOT EDIT [wasm_const.ml] *)
let _WASM_OP_INVALID = _CS_OP_INVALID;;
let _WASM_OP_IMM = _CS_OP_IMM;;
let _WASM_OP_NONE = _CS_OP_SPECIAL+0;;
let _WASM_OP_INT7 = _CS_OP_SPECIAL+1;;
let _WASM_OP_VARUINT32 = _CS_OP_SPECIAL+2;;
let _WASM_OP_VARUINT64 = _CS_OP_SPECIAL+3;;
let _WASM_OP_UINT32 = _CS_OP_SPECIAL+4;;
let _WASM_OP_UINT64 = _CS_OP_SPECIAL+5;;
let _WASM_OP_BRTABLE = _CS_OP_SPECIAL+6;;
let _WASM_INS_UNREACHABLE = 0x0;;
let _WASM_INS_NOP = 0x1;;
let _WASM_INS_BLOCK = 0x2;;
let _WASM_INS_LOOP = 0x3;;
let _WASM_INS_IF = 0x4;;
let _WASM_INS_ELSE = 0x5;;
let _WASM_INS_END = 0xb;;
let _WASM_INS_BR = 0xc;;
let _WASM_INS_BR_IF = 0xd;;
let _WASM_INS_BR_TABLE = 0xe;;
let _WASM_INS_RETURN = 0xf;;
let _WASM_INS_CALL = 0x10;;
let _WASM_INS_CALL_INDIRECT = 0x11;;
let _WASM_INS_DROP = 0x1a;;
let _WASM_INS_SELECT = 0x1b;;
let _WASM_INS_GET_LOCAL = 0x20;;
let _WASM_INS_SET_LOCAL = 0x21;;
let _WASM_INS_TEE_LOCAL = 0x22;;
let _WASM_INS_GET_GLOBAL = 0x23;;
let _WASM_INS_SET_GLOBAL = 0x24;;
let _WASM_INS_I32_LOAD = 0x28;;
let _WASM_INS_I64_LOAD = 0x29;;
let _WASM_INS_F32_LOAD = 0x2a;;
let _WASM_INS_F64_LOAD = 0x2b;;
let _WASM_INS_I32_LOAD8_S = 0x2c;;
let _WASM_INS_I32_LOAD8_U = 0x2d;;
let _WASM_INS_I32_LOAD16_S = 0x2e;;
let _WASM_INS_I32_LOAD16_U = 0x2f;;
let _WASM_INS_I64_LOAD8_S = 0x30;;
let _WASM_INS_I64_LOAD8_U = 0x31;;
let _WASM_INS_I64_LOAD16_S = 0x32;;
let _WASM_INS_I64_LOAD16_U = 0x33;;
let _WASM_INS_I64_LOAD32_S = 0x34;;
let _WASM_INS_I64_LOAD32_U = 0x35;;
let _WASM_INS_I32_STORE = 0x36;;
let _WASM_INS_I64_STORE = 0x37;;
let _WASM_INS_F32_STORE = 0x38;;
let _WASM_INS_F64_STORE = 0x39;;
let _WASM_INS_I32_STORE8 = 0x3a;;
let _WASM_INS_I32_STORE16 = 0x3b;;
let _WASM_INS_I64_STORE8 = 0x3c;;
let _WASM_INS_I64_STORE16 = 0x3d;;
let _WASM_INS_I64_STORE32 = 0x3e;;
let _WASM_INS_CURRENT_MEMORY = 0x3f;;
let _WASM_INS_GROW_MEMORY = 0x40;;
let _WASM_INS_I32_CONST = 0x41;;
let _WASM_INS_I64_CONST = 0x42;;
let _WASM_INS_F32_CONST = 0x43;;
let _WASM_INS_F64_CONST = 0x44;;
let _WASM_INS_I32_EQZ = 0x45;;
let _WASM_INS_I32_EQ = 0x46;;
let _WASM_INS_I32_NE = 0x47;;
let _WASM_INS_I32_LT_S = 0x48;;
let _WASM_INS_I32_LT_U = 0x49;;
let _WASM_INS_I32_GT_S = 0x4a;;
let _WASM_INS_I32_GT_U = 0x4b;;
let _WASM_INS_I32_LE_S = 0x4c;;
let _WASM_INS_I32_LE_U = 0x4d;;
let _WASM_INS_I32_GE_S = 0x4e;;
let _WASM_INS_I32_GE_U = 0x4f;;
let _WASM_INS_I64_EQZ = 0x50;;
let _WASM_INS_I64_EQ = 0x51;;
let _WASM_INS_I64_NE = 0x52;;
let _WASM_INS_I64_LT_S = 0x53;;
let _WASM_INS_I64_LT_U = 0x54;;
let _WASM_INS_I64_GT_U = 0x56;;
let _WASM_INS_I64_LE_S = 0x57;;
let _WASM_INS_I64_LE_U = 0x58;;
let _WASM_INS_I64_GE_S = 0x59;;
let _WASM_INS_I64_GE_U = 0x5a;;
let _WASM_INS_F32_EQ = 0x5b;;
let _WASM_INS_F32_NE = 0x5c;;
let _WASM_INS_F32_LT = 0x5d;;
let _WASM_INS_F32_GT = 0x5e;;
let _WASM_INS_F32_LE = 0x5f;;
let _WASM_INS_F32_GE = 0x60;;
let _WASM_INS_F64_EQ = 0x61;;
let _WASM_INS_F64_NE = 0x62;;
let _WASM_INS_F64_LT = 0x63;;
let _WASM_INS_F64_GT = 0x64;;
let _WASM_INS_F64_LE = 0x65;;
let _WASM_INS_F64_GE = 0x66;;
let _WASM_INS_I32_CLZ = 0x67;;
let _WASM_INS_I32_CTZ = 0x68;;
let _WASM_INS_I32_POPCNT = 0x69;;
let _WASM_INS_I32_ADD = 0x6a;;
let _WASM_INS_I32_SUB = 0x6b;;
let _WASM_INS_I32_MUL = 0x6c;;
let _WASM_INS_I32_DIV_S = 0x6d;;
let _WASM_INS_I32_DIV_U = 0x6e;;
let _WASM_INS_I32_REM_S = 0x6f;;
let _WASM_INS_I32_REM_U = 0x70;;
let _WASM_INS_I32_AND = 0x71;;
let _WASM_INS_I32_OR = 0x72;;
let _WASM_INS_I32_XOR = 0x73;;
let _WASM_INS_I32_SHL = 0x74;;
let _WASM_INS_I32_SHR_S = 0x75;;
let _WASM_INS_I32_SHR_U = 0x76;;
let _WASM_INS_I32_ROTL = 0x77;;
let _WASM_INS_I32_ROTR = 0x78;;
let _WASM_INS_I64_CLZ = 0x79;;
let _WASM_INS_I64_CTZ = 0x7a;;
let _WASM_INS_I64_POPCNT = 0x7b;;
let _WASM_INS_I64_ADD = 0x7c;;
let _WASM_INS_I64_SUB = 0x7d;;
let _WASM_INS_I64_MUL = 0x7e;;
let _WASM_INS_I64_DIV_S = 0x7f;;
let _WASM_INS_I64_DIV_U = 0x80;;
let _WASM_INS_I64_REM_S = 0x81;;
let _WASM_INS_I64_REM_U = 0x82;;
let _WASM_INS_I64_AND = 0x83;;
let _WASM_INS_I64_OR = 0x84;;
let _WASM_INS_I64_XOR = 0x85;;
let _WASM_INS_I64_SHL = 0x86;;
let _WASM_INS_I64_SHR_S = 0x87;;
let _WASM_INS_I64_SHR_U = 0x88;;
let _WASM_INS_I64_ROTL = 0x89;;
let _WASM_INS_I64_ROTR = 0x8a;;
let _WASM_INS_F32_ABS = 0x8b;;
let _WASM_INS_F32_NEG = 0x8c;;
let _WASM_INS_F32_CEIL = 0x8d;;
let _WASM_INS_F32_FLOOR = 0x8e;;
let _WASM_INS_F32_TRUNC = 0x8f;;
let _WASM_INS_F32_NEAREST = 0x90;;
let _WASM_INS_F32_SQRT = 0x91;;
let _WASM_INS_F32_ADD = 0x92;;
let _WASM_INS_F32_SUB = 0x93;;
let _WASM_INS_F32_MUL = 0x94;;
let _WASM_INS_F32_DIV = 0x95;;
let _WASM_INS_F32_MIN = 0x96;;
let _WASM_INS_F32_MAX = 0x97;;
let _WASM_INS_F32_COPYSIGN = 0x98;;
let _WASM_INS_F64_ABS = 0x99;;
let _WASM_INS_F64_NEG = 0x9a;;
let _WASM_INS_F64_CEIL = 0x9b;;
let _WASM_INS_F64_FLOOR = 0x9c;;
let _WASM_INS_F64_TRUNC = 0x9d;;
let _WASM_INS_F64_NEAREST = 0x9e;;
let _WASM_INS_F64_SQRT = 0x9f;;
let _WASM_INS_F64_ADD = 0xa0;;
let _WASM_INS_F64_SUB = 0xa1;;
let _WASM_INS_F64_MUL = 0xa2;;
let _WASM_INS_F64_DIV = 0xa3;;
let _WASM_INS_F64_MIN = 0xa4;;
let _WASM_INS_F64_MAX = 0xa5;;
let _WASM_INS_F64_COPYSIGN = 0xa6;;
let _WASM_INS_I32_WARP_I64 = 0xa7;;
let _WASM_INS_I32_TRUNC_U_F32 = 0xa9;;
let _WASM_INS_I32_TRUNC_S_F64 = 0xaa;;
let _WASM_INS_I32_TRUNC_U_F64 = 0xab;;
let _WASM_INS_I64_EXTEND_S_I32 = 0xac;;
let _WASM_INS_I64_EXTEND_U_I32 = 0xad;;
let _WASM_INS_I64_TRUNC_S_F32 = 0xae;;
let _WASM_INS_I64_TRUNC_U_F32 = 0xaf;;
let _WASM_INS_I64_TRUNC_S_F64 = 0xb0;;
let _WASM_INS_I64_TRUNC_U_F64 = 0xb1;;
let _WASM_INS_F32_CONVERT_S_I32 = 0xb2;;
let _WASM_INS_F32_CONVERT_U_I32 = 0xb3;;
let _WASM_INS_F32_CONVERT_S_I64 = 0xb4;;
let _WASM_INS_F32_CONVERT_U_I64 = 0xb5;;
let _WASM_INS_F32_DEMOTE_F64 = 0xb6;;
let _WASM_INS_F64_CONVERT_S_I32 = 0xb7;;
let _WASM_INS_F64_CONVERT_U_I32 = 0xb8;;
let _WASM_INS_F64_CONVERT_S_I64 = 0xb9;;
let _WASM_INS_F64_CONVERT_U_I64 = 0xba;;
let _WASM_INS_F64_PROMOTE_F32 = 0xbb;;
let _WASM_INS_I32_REINTERPRET_F32 = 0xbc;;
let _WASM_INS_I64_REINTERPRET_F64 = 0xbd;;
let _WASM_INS_F32_REINTERPRET_I32 = 0xbe;;
let _WASM_INS_F64_REINTERPRET_I64 = 0xbf;;
let _WASM_INS_INVALID = 512;;
let _WASM_INS_ENDING = 513;;
let _WASM_GRP_INVALID = 0;;
let _WASM_GRP_NUMBERIC = 8;;
let _WASM_GRP_PARAMETRIC = 9;;
let _WASM_GRP_VARIABLE = 10;;
let _WASM_GRP_MEMORY = 11;;
let _WASM_GRP_CONTROL = 12;;
let _WASM_GRP_ENDING = 13;;
+47
View File
@@ -0,0 +1,47 @@
(* Capstone Disassembly Engine
* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013-2014 *)
open X86_const
(* architecture specific info of instruction *)
type x86_op_mem = {
segment: int;
base: int;
index: int;
scale: int;
disp: int;
}
type x86_op_value =
| X86_OP_INVALID of int
| X86_OP_REG of int
| X86_OP_IMM of int
| X86_OP_MEM of x86_op_mem
type x86_op = {
value: x86_op_value;
size: int;
access: int;
avx_bcast: int;
avx_zero_opmask: int;
}
type cs_x86 = {
prefix: int array;
opcode: int array;
rex: int;
addr_size: int;
modrm: int;
sib: int;
disp: int;
sib_index: int;
sib_scale: int;
sib_base: int;
xop_cc: int;
sse_cc: int;
avx_cc: int;
avx_sae: int;
avx_rm: int;
eflags: int;
operands: x86_op array;
}
File diff suppressed because it is too large Load Diff
+26
View File
@@ -0,0 +1,26 @@
(* Capstone Disassembly Engine
* By Guillaume Jeanne <guillaume.jeanne@ensimag.fr>, 2014> *)
open Xcore_const
type xcore_op_mem = {
base: int;
index: int;
disp: int;
direct: int;
}
type xcore_op_value =
| XCORE_OP_INVALID of int
| XCORE_OP_REG of int
| XCORE_OP_IMM of int
| XCORE_OP_MEM of xcore_op_mem
type xcore_op = {
value: xcore_op_value;
}
type cs_xcore = {
operands: xcore_op array;
}
+160
View File
@@ -0,0 +1,160 @@
(* For Capstone Engine. AUTO-GENERATED FILE, DO NOT EDIT [xcore_const.ml] *)
let _XCORE_OP_INVALID = _CS_OP_INVALID;;
let _XCORE_OP_REG = _CS_OP_REG;;
let _XCORE_OP_IMM = _CS_OP_IMM;;
let _XCORE_OP_MEM = _CS_OP_MEM;;
let _XCORE_REG_INVALID = 0;;
let _XCORE_REG_CP = 1;;
let _XCORE_REG_DP = 2;;
let _XCORE_REG_LR = 3;;
let _XCORE_REG_SP = 4;;
let _XCORE_REG_R0 = 5;;
let _XCORE_REG_R1 = 6;;
let _XCORE_REG_R2 = 7;;
let _XCORE_REG_R3 = 8;;
let _XCORE_REG_R4 = 9;;
let _XCORE_REG_R5 = 10;;
let _XCORE_REG_R6 = 11;;
let _XCORE_REG_R7 = 12;;
let _XCORE_REG_R8 = 13;;
let _XCORE_REG_R9 = 14;;
let _XCORE_REG_R10 = 15;;
let _XCORE_REG_R11 = 16;;
let _XCORE_REG_PC = 17;;
let _XCORE_REG_SCP = 18;;
let _XCORE_REG_SSR = 19;;
let _XCORE_REG_ET = 20;;
let _XCORE_REG_ED = 21;;
let _XCORE_REG_SED = 22;;
let _XCORE_REG_KEP = 23;;
let _XCORE_REG_KSP = 24;;
let _XCORE_REG_ID = 25;;
let _XCORE_REG_ENDING = 26;;
let _XCORE_INS_INVALID = 0;;
let _XCORE_INS_ADD = 1;;
let _XCORE_INS_ANDNOT = 2;;
let _XCORE_INS_AND = 3;;
let _XCORE_INS_ASHR = 4;;
let _XCORE_INS_BAU = 5;;
let _XCORE_INS_BITREV = 6;;
let _XCORE_INS_BLA = 7;;
let _XCORE_INS_BLAT = 8;;
let _XCORE_INS_BL = 9;;
let _XCORE_INS_BF = 10;;
let _XCORE_INS_BT = 11;;
let _XCORE_INS_BU = 12;;
let _XCORE_INS_BRU = 13;;
let _XCORE_INS_BYTEREV = 14;;
let _XCORE_INS_CHKCT = 15;;
let _XCORE_INS_CLRE = 16;;
let _XCORE_INS_CLRPT = 17;;
let _XCORE_INS_CLRSR = 18;;
let _XCORE_INS_CLZ = 19;;
let _XCORE_INS_CRC8 = 20;;
let _XCORE_INS_CRC32 = 21;;
let _XCORE_INS_DCALL = 22;;
let _XCORE_INS_DENTSP = 23;;
let _XCORE_INS_DGETREG = 24;;
let _XCORE_INS_DIVS = 25;;
let _XCORE_INS_DIVU = 26;;
let _XCORE_INS_DRESTSP = 27;;
let _XCORE_INS_DRET = 28;;
let _XCORE_INS_ECALLF = 29;;
let _XCORE_INS_ECALLT = 30;;
let _XCORE_INS_EDU = 31;;
let _XCORE_INS_EEF = 32;;
let _XCORE_INS_EET = 33;;
let _XCORE_INS_EEU = 34;;
let _XCORE_INS_ENDIN = 35;;
let _XCORE_INS_ENTSP = 36;;
let _XCORE_INS_EQ = 37;;
let _XCORE_INS_EXTDP = 38;;
let _XCORE_INS_EXTSP = 39;;
let _XCORE_INS_FREER = 40;;
let _XCORE_INS_FREET = 41;;
let _XCORE_INS_GETD = 42;;
let _XCORE_INS_GET = 43;;
let _XCORE_INS_GETN = 44;;
let _XCORE_INS_GETR = 45;;
let _XCORE_INS_GETSR = 46;;
let _XCORE_INS_GETST = 47;;
let _XCORE_INS_GETTS = 48;;
let _XCORE_INS_INCT = 49;;
let _XCORE_INS_INIT = 50;;
let _XCORE_INS_INPW = 51;;
let _XCORE_INS_INSHR = 52;;
let _XCORE_INS_INT = 53;;
let _XCORE_INS_IN = 54;;
let _XCORE_INS_KCALL = 55;;
let _XCORE_INS_KENTSP = 56;;
let _XCORE_INS_KRESTSP = 57;;
let _XCORE_INS_KRET = 58;;
let _XCORE_INS_LADD = 59;;
let _XCORE_INS_LD16S = 60;;
let _XCORE_INS_LD8U = 61;;
let _XCORE_INS_LDA16 = 62;;
let _XCORE_INS_LDAP = 63;;
let _XCORE_INS_LDAW = 64;;
let _XCORE_INS_LDC = 65;;
let _XCORE_INS_LDW = 66;;
let _XCORE_INS_LDIVU = 67;;
let _XCORE_INS_LMUL = 68;;
let _XCORE_INS_LSS = 69;;
let _XCORE_INS_LSUB = 70;;
let _XCORE_INS_LSU = 71;;
let _XCORE_INS_MACCS = 72;;
let _XCORE_INS_MACCU = 73;;
let _XCORE_INS_MJOIN = 74;;
let _XCORE_INS_MKMSK = 75;;
let _XCORE_INS_MSYNC = 76;;
let _XCORE_INS_MUL = 77;;
let _XCORE_INS_NEG = 78;;
let _XCORE_INS_NOT = 79;;
let _XCORE_INS_OR = 80;;
let _XCORE_INS_OUTCT = 81;;
let _XCORE_INS_OUTPW = 82;;
let _XCORE_INS_OUTSHR = 83;;
let _XCORE_INS_OUTT = 84;;
let _XCORE_INS_OUT = 85;;
let _XCORE_INS_PEEK = 86;;
let _XCORE_INS_REMS = 87;;
let _XCORE_INS_REMU = 88;;
let _XCORE_INS_RETSP = 89;;
let _XCORE_INS_SETCLK = 90;;
let _XCORE_INS_SET = 91;;
let _XCORE_INS_SETC = 92;;
let _XCORE_INS_SETD = 93;;
let _XCORE_INS_SETEV = 94;;
let _XCORE_INS_SETN = 95;;
let _XCORE_INS_SETPSC = 96;;
let _XCORE_INS_SETPT = 97;;
let _XCORE_INS_SETRDY = 98;;
let _XCORE_INS_SETSR = 99;;
let _XCORE_INS_SETTW = 100;;
let _XCORE_INS_SETV = 101;;
let _XCORE_INS_SEXT = 102;;
let _XCORE_INS_SHL = 103;;
let _XCORE_INS_SHR = 104;;
let _XCORE_INS_SSYNC = 105;;
let _XCORE_INS_ST16 = 106;;
let _XCORE_INS_ST8 = 107;;
let _XCORE_INS_STW = 108;;
let _XCORE_INS_SUB = 109;;
let _XCORE_INS_SYNCR = 110;;
let _XCORE_INS_TESTCT = 111;;
let _XCORE_INS_TESTLCL = 112;;
let _XCORE_INS_TESTWCT = 113;;
let _XCORE_INS_TSETMR = 114;;
let _XCORE_INS_START = 115;;
let _XCORE_INS_WAITEF = 116;;
let _XCORE_INS_WAITET = 117;;
let _XCORE_INS_WAITEU = 118;;
let _XCORE_INS_XOR = 119;;
let _XCORE_INS_ZEXT = 120;;
let _XCORE_INS_ENDING = 121;;
let _XCORE_GRP_INVALID = 0;;
let _XCORE_GRP_JUMP = 1;;
let _XCORE_GRP_ENDING = 2;;
@@ -0,0 +1,157 @@
<?xml version="1.0" encoding="utf-8" ?>
<Configuration>
<DefaultSettings>
<EnumerableExpansions>
<EnumerableExpansion>
<Expand>Both</Expand>
</EnumerableExpansion>
</EnumerableExpansions>
</DefaultSettings>
<ViewDefinitions>
<View>
<Name>CapstoneDisassemblyViewSimple</Name>
<ViewSelectedBy>
<TypeName>CapstoneDisassembly.Simple</TypeName>
</ViewSelectedBy>
<ListControl>
<ListEntries>
<ListEntry>
<ListItems>
<ListItem>
<PropertyName>Address</PropertyName>
<FormatString>0x{0:X}</FormatString>
</ListItem>
<ListItem>
<PropertyName>Instruction</PropertyName>
</ListItem>
</ListItems>
</ListEntry>
</ListEntries>
</ListControl>
</View>
<View>
<Name>CapstoneDisassemblyViewSimple</Name>
<ViewSelectedBy>
<TypeName>CapstoneDisassembly.Simple</TypeName>
</ViewSelectedBy>
<TableControl>
<TableHeaders>
<TableColumnHeader>
<Label>Address</Label>
</TableColumnHeader>
<TableColumnHeader>
<Label>Instruction</Label>
</TableColumnHeader>
</TableHeaders>
<TableRowEntries>
<TableRowEntry>
<TableColumnItems>
<TableColumnItem>
<PropertyName>Address</PropertyName>
<FormatString>0x{0:x}</FormatString>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Instruction</PropertyName>
</TableColumnItem>
</TableColumnItems>
</TableRowEntry>
</TableRowEntries>
</TableControl>
</View>
<View>
<Name>CapstoneDisassemblyViewDetailed</Name>
<ViewSelectedBy>
<TypeName>CapstoneDisassembly.Detailed</TypeName>
</ViewSelectedBy>
<ListControl>
<ListEntries>
<ListEntry>
<ListItems>
<ListItem>
<PropertyName>Address</PropertyName>
<FormatString>0x{0:X}</FormatString>
</ListItem>
<ListItem>
<PropertyName>Mnemonic</PropertyName>
</ListItem>
<ListItem>
<PropertyName>Operands</PropertyName>
</ListItem>
<ListItem>
<PropertyName>Bytes</PropertyName>
</ListItem>
<ListItem>
<PropertyName>Size</PropertyName>
</ListItem>
<ListItem>
<PropertyName>RegRead</PropertyName>
</ListItem>
<ListItem>
<PropertyName>RegWrite</PropertyName>
</ListItem>
</ListItems>
</ListEntry>
</ListEntries>
</ListControl>
</View>
<View>
<Name>CapstoneDisassemblyViewDetailed</Name>
<ViewSelectedBy>
<TypeName>CapstoneDisassembly.Detailed</TypeName>
</ViewSelectedBy>
<TableControl>
<TableHeaders>
<TableColumnHeader>
<Label>Address</Label>
</TableColumnHeader>
<TableColumnHeader>
<Label>Mnemonic</Label>
</TableColumnHeader>
<TableColumnHeader>
<Label>Operands</Label>
</TableColumnHeader>
<TableColumnHeader>
<Label>Bytes</Label>
</TableColumnHeader>
<TableColumnHeader>
<Label>Size</Label>
</TableColumnHeader>
<TableColumnHeader>
<Label>RegRead</Label>
</TableColumnHeader>
<TableColumnHeader>
<Label>RegWrite</Label>
</TableColumnHeader>
</TableHeaders>
<TableRowEntries>
<TableRowEntry>
<TableColumnItems>
<TableColumnItem>
<PropertyName>Address</PropertyName>
<FormatString>0x{0:x}</FormatString>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Mnemonic</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Operands</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Bytes</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Size</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>RegRead</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>RegWrite</PropertyName>
</TableColumnItem>
</TableColumnItems>
</TableRowEntry>
</TableRowEntries>
</TableControl>
</View>
</ViewDefinitions>
</Configuration>
+118
View File
@@ -0,0 +1,118 @@
#
# Module manifest for module 'Capstone'
#
@{
# Script module or binary module file associated with this manifest.
ModuleToProcess = 'Capstone.psm1'
# Version number of this module.
ModuleVersion = '0.0.0.2'
# Supported PSEditions
# CompatiblePSEditions = @()
# ID used to uniquely identify this module
GUID = 'd34db33f-9958-436d-a2d8-a77844a2bda5'
# Author of this module
Author = 'Ruben Boonen, beatcracker'
# Company or vendor of this module
# CompanyName = 'Unknown'
# Copyright statement for this module
Copyright = 'BSD 3-Clause'
# Description of the functionality provided by this module
Description = 'Capstone Engine Binding Module'
# Minimum version of the Windows PowerShell engine required by this module
PowerShellVersion = '2.0'
# Name of the Windows PowerShell host required by this module
# PowerShellHostName = ''
# Minimum version of the Windows PowerShell host required by this module
# PowerShellHostVersion = ''
# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
# DotNetFrameworkVersion = ''
# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
# CLRVersion = ''
# Processor architecture (None, X86, Amd64) required by this module
# ProcessorArchitecture = ''
# Modules that must be imported into the global environment prior to importing this module
# RequiredModules = @()
# Assemblies that must be loaded prior to importing this module
# RequiredAssemblies = @()
# Script files (.ps1) that are run in the caller's environment prior to importing this module.
# ScriptsToProcess = @()
# Type files (.ps1xml) to be loaded when importing this module
# TypesToProcess = @()
# Format files (.ps1xml) to be loaded when importing this module
FormatsToProcess = 'Capstone.Format.ps1xml'
# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
# NestedModules = @()
# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
FunctionsToExport = 'Get-CapstoneVersion', 'Get-CapstoneDisassembly'
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
CmdletsToExport = @()
# Variables to export from this module
VariablesToExport = @()
# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
AliasesToExport = @()
# DSC resources to export from this module
# DscResourcesToExport = @()
# List of all modules packaged with this module
# ModuleList = @()
# List of all files packaged with this module
# FileList = @()
# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
PrivateData = @{
PSData = @{
# Tags applied to this module. These help with module discovery in online galleries.
# Tags = @()
# A URL to the license for this module.
# LicenseUri = ''
# A URL to the main website for this project.
# ProjectUri = ''
# A URL to an icon representing this module.
# IconUri = ''
# ReleaseNotes of this module
# ReleaseNotes = ''
} # End of PSData hashtable
} # End of PrivateData hashtable
# HelpInfo URI of this module
# HelpInfoURI = ''
# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
# DefaultCommandPrefix = ''
}
+500
View File
@@ -0,0 +1,500 @@
<#
.SYNOPSIS
Get Capstone version as Version object
#>
function Get-CapstoneVersion {
$Version = [System.BitConverter]::GetBytes(
[Capstone]::cs_version($null, $null)
)
New-Object -TypeName version -ArgumentList @(
$Version[1]
$Version[0]
0
0
)
}
<#
.SYNOPSIS
Create C# bindings for capstone.dll
.PARAMETER DllPath
Path to capstone.dll
#>
function Initialize-Capstone {
[CmdletBinding()]
Param (
[Parameter(Mandatory = $true)]
[ValidateScript( {
try {
Test-Path -Path $_ -PathType Leaf -ErrorAction Stop
} catch {
throw "Capstone DLL is missing: $DllPath"
}
})]
[ValidateNotNullOrEmpty()]
[string]$DllPath
)
# Escape path for use in inline C#
$DllPath = $DllPath.Replace('\', '\\')
# Inline C# to parse the unmanaged capstone DLL
# http://stackoverflow.com/questions/16552801/how-do-i-conditionally-add-a-class-with-add-type-typedefinition-if-it-isnt-add
if (-not ([System.Management.Automation.PSTypeName]'Capstone').Type) {
Add-Type -TypeDefinition @"
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Security.Principal;
[StructLayout(LayoutKind.Sequential)]
public struct cs_insn
{
public uint id;
public ulong address;
public ushort size;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 24)]
public byte[] bytes;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
public string mnemonic;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 160)]
public string operands;
public IntPtr detail;
}
/// Partial, only architecture-independent internal data
[StructLayout(LayoutKind.Sequential)]
public struct cs_detail
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
public byte[] regs_read;
public byte regs_read_count;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)]
public byte[] regs_write;
public byte regs_write_count;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public byte[] groups;
public byte groups_count;
}
public enum cs_err : int
{
CS_ERR_OK = 0, /// No error: everything was fine
CS_ERR_MEM, /// Out-Of-Memory error: cs_open(), cs_disasm(), cs_disasm_iter()
CS_ERR_ARCH, /// Unsupported architecture: cs_open()
CS_ERR_HANDLE, /// Invalid handle: cs_op_count(), cs_op_index()
CS_ERR_CSH, /// Invalid csh argument: cs_close(), cs_errno(), cs_option()
CS_ERR_MODE, /// Invalid/unsupported mode: cs_open()
CS_ERR_OPTION, /// Invalid/unsupported option: cs_option()
CS_ERR_DETAIL, /// Information is unavailable because detail option is OFF
CS_ERR_MEMSETUP, /// Dynamic memory management uninitialized (see CS_OPT_MEM)
CS_ERR_VERSION, /// Unsupported version (bindings)
CS_ERR_DIET, /// Access irrelevant data in "diet" engine
CS_ERR_SKIPDATA, /// Access irrelevant data for "data" instruction in SKIPDATA mode
CS_ERR_X86_ATT, /// X86 AT&T syntax is unsupported (opt-out at compile time)
CS_ERR_X86_INTEL, /// X86 Intel syntax is unsupported (opt-out at compile time)
}
public enum cs_arch : int
{
CS_ARCH_ARM = 0, /// ARM architecture (including Thumb, Thumb-2)
CS_ARCH_ARM64, /// ARM-64, also called AArch64
CS_ARCH_MIPS, /// Mips architecture
CS_ARCH_X86, /// X86 architecture (including x86 & x86-64)
CS_ARCH_PPC, /// PowerPC architecture
CS_ARCH_SPARC, /// Sparc architecture
CS_ARCH_SYSZ, /// SystemZ architecture
CS_ARCH_XCORE, /// XCore architecture
CS_ARCH_MAX,
CS_ARCH_ALL = 0xFFFF, /// All architectures - for cs_support()
}
public enum cs_mode : int
{
CS_MODE_LITTLE_ENDIAN = 0, /// little-endian mode (default mode)
CS_MODE_ARM = 0, /// 32-bit ARM
CS_MODE_16 = 1 << 1, /// 16-bit mode (X86)
CS_MODE_32 = 1 << 2, /// 32-bit mode (X86)
CS_MODE_64 = 1 << 3, /// 64-bit mode (X86, PPC)
CS_MODE_THUMB = 1 << 4, /// ARM's Thumb mode, including Thumb-2
CS_MODE_MCLASS = 1 << 5, /// ARM's Cortex-M series
CS_MODE_V8 = 1 << 6, /// ARMv8 A32 encodings for ARM
CS_MODE_MICRO = 1 << 4, /// MicroMips mode (MIPS)
CS_MODE_MIPS3 = 1 << 5, /// Mips III ISA
CS_MODE_MIPS32R6 = 1 << 6, /// Mips32r6 ISA
CS_MODE_MIPSGP64 = 1 << 7, /// General Purpose Registers are 64-bit wide (MIPS)
CS_MODE_V9 = 1 << 4, /// SparcV9 mode (Sparc)
CS_MODE_BIG_ENDIAN = 1 << 31, /// big-endian mode
CS_MODE_MIPS32 = CS_MODE_32, /// Mips32 ISA (Mips)
CS_MODE_MIPS64 = CS_MODE_64, /// Mips64 ISA (Mips)
}
public static class Capstone
{
[DllImport("$DllPath")]
public static extern cs_err cs_open(
cs_arch arch,
cs_mode mode,
ref IntPtr handle);
[DllImport("$DllPath")]
public static extern UInt32 cs_disasm(
IntPtr handle,
byte[] code,
int code_size,
ulong address,
int count,
ref IntPtr insn);
[DllImport("$DllPath")]
public static extern bool cs_free(
IntPtr insn,
int count);
[DllImport("$DllPath")]
public static extern cs_err cs_close(
ref IntPtr handle);
[DllImport("$DllPath")]
public static extern cs_err cs_option(
IntPtr handle,
int type,
int value);
[DllImport("$DllPath", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr cs_reg_name(
IntPtr handle,
uint reg_id);
[DllImport("$DllPath")]
public static extern int cs_version(
uint major,
uint minor);
}
"@
} else {
Write-Verbose 'C# bindings are already compiled'
}
}
function Get-CapstoneDisassembly {
<#
.SYNOPSIS
Powershell wrapper for Capstone (using inline C#).
.DESCRIPTION
Author: Ruben Boonen (@FuzzySec), @beatcracker
License: BSD 3-Clause
Required Dependencies: None
Optional Dependencies: None
.PARAMETER Architecture
Architecture type.
.PARAMETER Mode
Mode type.
.PARAMETER Bytes
Byte array to be disassembled.
.PARAMETER Syntax
Syntax for output assembly.
.PARAMETER Address
Assign address for the first instruction to be disassembled.
.PARAMETER Detailed
Return detailed output.
.PARAMETER Version
Print ASCII version banner.
.EXAMPLE
C:\PS> $Bytes = [byte[]] @( 0x10, 0xf1, 0x10, 0xe7, 0x11, 0xf2, 0x31, 0xe7, 0xdc, 0xa1, 0x2e, 0xf3, 0xe8, 0x4e, 0x62, 0xf3 )
C:\PS> Get-CapstoneDisassembly -Architecture CS_ARCH_ARM -Mode CS_MODE_ARM -Bytes $Bytes
Address : 0x100000
Instruction : sdiv r0, r0, r1
Address : 0x100004
Instruction : udiv r1, r1, r2
Address : 0x100008
Instruction : vbit q5, q15, q6
Address : 0x10000C
Instruction : vcgt.f32 q10, q9, q12
.EXAMPLE
# Detailed mode & ATT syntax
C:\PS> $Bytes = [byte[]] @( 0xB8, 0x0A, 0x00, 0x00, 0x00, 0xF7, 0xF3 )
C:\PS> Get-CapstoneDisassembly -Architecture CS_ARCH_X86 -Mode CS_MODE_32 -Bytes $Bytes -Syntax ATT -Detailed
Address : 0x100000
Mnemonic : movl
Operands : $0xa, %eax
Bytes : {184, 10, 0, 0...}
Size : 5
RegRead :
RegWrite :
Address : 0x100005
Mnemonic : divl
Operands : %ebx
Bytes : {247, 243}
Size : 2
RegRead : {eax, edx}
RegWrite : {eax, edx, eflags}
.EXAMPLE
# Get-CapstoneDisassembly emits objects
C:\PS> $Bytes = [byte[]] @( 0xB8, 0x0A, 0x00, 0x00, 0x00, 0xF7, 0xF3 )
C:\PS> $Object = Get-CapstoneDisassembly -Architecture CS_ARCH_X86 -Mode CS_MODE_32 -Bytes $Bytes -Detailed
C:\PS> $Object | Select-Object -Property Size, Mnemonic, Operands
Size Mnemonic Operands
---- -------- --------
5 mov eax, 0xa
2 div ebx
#>
[CmdletBinding(DefaultParameterSetName = 'Capstone')]
Param (
[Parameter(ParameterSetName = 'Capstone', Mandatory = $true)]
[ValidateSet(
'CS_ARCH_ARM',
'CS_ARCH_ARM64',
'CS_ARCH_MIPS',
'CS_ARCH_X86',
'CS_ARCH_PPC',
'CS_ARCH_SPARC',
'CS_ARCH_SYSZ',
'CS_ARCH_XCORE',
'CS_ARCH_MAX',
'CS_ARCH_ALL'
)]
[string]$Architecture,
[Parameter(ParameterSetName = 'Capstone', Mandatory = $true)]
[ValidateSet(
'CS_MODE_LITTLE_ENDIAN',
'CS_MODE_ARM',
'CS_MODE_16',
'CS_MODE_32',
'CS_MODE_64',
'CS_MODE_THUMB',
'CS_MODE_MCLASS',
'CS_MODE_V8',
'CS_MODE_MICRO',
'CS_MODE_MIPS3',
'CS_MODE_MIPS32R6',
'CS_MODE_MIPSGP64',
'CS_MODE_V9',
'CS_MODE_BIG_ENDIAN',
'CS_MODE_MIPS32',
'CS_MODE_MIPS64'
)]
[string]$Mode,
[Parameter(ParameterSetName = 'Capstone', Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[byte[]]$Bytes,
[Parameter(ParameterSetName = 'Capstone')]
[ValidateSet(
'Intel',
'ATT'
)]
[string]$Syntax = 'Intel',
[Parameter(ParameterSetName = 'Capstone')]
[uint64]$Address = 0x100000,
[Parameter(ParameterSetName = 'Capstone')]
[switch]$Detailed,
[Parameter(ParameterSetName = 'Version')]
[switch]$Version
)
if ($Version) {
$Banner = @'
(((;
(; "((((\
;((((((; "((((;
((((""\(((( "((((
((((" ((\ "(((( "(((\
;(((/ ((((((( "(((( \(((
((((" (((* "(((( \(((;"(((\
((((";((("/(( \(((;"(((\"(((\
(((( (((( ((((" "(((\ ((() (((\
;((("(((( (((* **"" ((()"(((;
(((" ((( (((( ((((((((((((((:*(((
(((( (((*)((( ********"""" ;;(((((;
(((* ((( (((((((((((((((((((((*"" (
((("(((( """***********"""" ;;(((((
"" (((((((((((((((((((((((((((*""
"""****(((((****"""
-=[Capstone Engine v{0}]=-
'@ -f (Get-CapstoneVersion).ToString(2)
# Mmm ASCII version banner!
return $Banner
}
# Disasm Handle
$DisAsmHandle = [System.IntPtr]::Zero
# Initialize Capstone with cs_open()
$CallResult = [Capstone]::cs_open($Architecture, $Mode, [ref]$DisAsmHandle)
if ($CallResult -ne 'CS_ERR_OK') {
if ($CallResult -eq 'CS_ERR_MODE') {
throw "Invalid Architecture/Mode combination: $Architecture/$Mode"
} else {
throw "cs_open error: $CallResult"
}
}
# Set disassembly syntax
#---
# cs_opt_type -> CS_OPT_SYNTAX = 1
#---
# cs_opt_value -> CS_OPT_SYNTAX_INTEL = 1
# -> CS_OPT_SYNTAX_ATT = 2
if ($Syntax -eq 'Intel') {
$CS_OPT_SYNTAX = 1
} else {
$CS_OPT_SYNTAX = 2
}
$CallResult = [Capstone]::cs_option($DisAsmHandle, 1, $CS_OPT_SYNTAX)
if ($CallResult -ne 'CS_ERR_OK') {
$CallResult = [Capstone]::cs_close([ref]$DisAsmHandle)
throw "cs_option error: $CallResult"
}
# Set disassembly detail
#---
# cs_opt_type -> CS_OPT_DETAIL = 2
#---
# cs_opt_value -> CS_OPT_ON = 3
# -> CS_OPT_OFF = 0
if ($Detailed) {
$CS_OPT = 3
} else {
$CS_OPT = 0
}
$CallResult = [Capstone]::cs_option($DisAsmHandle, 2, $CS_OPT)
if ($CallResult -ne 'CS_ERR_OK') {
$CallResult = [Capstone]::cs_close([ref]$DisAsmHandle)
throw "cs_option error: $CallResult"
}
# Out Buffer Handle
$InsnHandle = [System.IntPtr]::Zero
# Disassemble bytes
$Count = [Capstone]::cs_disasm($DisAsmHandle, $Bytes, $Bytes.Count, $Address, 0, [ref]$InsnHandle)
if ($Count -gt 0) {
# Result struct
$cs_insn = if ($PSVersionTable.PSVersion.Major -gt 2) {
[cs_insn]@{}
} else {
New-Object -TypeName cs_insn
}
$cs_insn_size = [System.Runtime.InteropServices.Marshal]::SizeOf($cs_insn)
$cs_insn = $cs_insn.GetType()
# Result detail struct
$cs_detail = if ($PSVersionTable.PSVersion.Major -gt 2) {
[cs_detail]@{}
} else {
New-Object -TypeName cs_detail
}
$cs_detail = $cs_detail.GetType()
# Result buffer offset
$BuffOffset = $InsnHandle.ToInt64()
for ($i = 0 ; $i -lt $Count ; $i++) {
# Cast Offset to cs_insn
$Cast = [System.Runtime.InteropServices.Marshal]::PtrToStructure([System.Intptr]$BuffOffset, [type]$cs_insn)
if ($CS_OPT -eq 0) {
$Disassembly = @{
Address = $Cast.address
Instruction = '{0} {1}' -f $Cast.mnemonic, $Cast.operands
}
if ($PSVersionTable.PSVersion.Major -gt 2) {
# Add TypeName for PS formatting and output result
$Disassembly.PSTypeName ='CapstoneDisassembly.Simple'
[pscustomobject]$Disassembly
} else {
$Disassembly = New-Object -TypeName PSObject -Property $Disassembly
# Add TypeName for PS formatting and output result
$Disassembly.PSObject.TypeNames.Insert(0, 'CapstoneDisassembly.Simple')
$Disassembly
}
} else {
$DetailCast = [System.Runtime.InteropServices.Marshal]::PtrToStructure($Cast.detail, [type]$cs_detail)
if ($DetailCast.regs_read_count -gt 0) {
$RegRead = for ($r = 0 ; $r -lt $DetailCast.regs_read_count ; $r++) {
$NamePointer = [Capstone]::cs_reg_name($DisAsmHandle, $DetailCast.regs_read[$r])
[System.Runtime.InteropServices.Marshal]::PtrToStringAnsi($NamePointer)
}
}
if ($DetailCast.regs_write_count -gt 0) {
$RegWrite = for ($r = 0 ; $r -lt $DetailCast.regs_write_count ; $r++) {
$NamePointer = [Capstone]::cs_reg_name($DisAsmHandle, $DetailCast.regs_write[$r])
[System.Runtime.InteropServices.Marshal]::PtrToStringAnsi($NamePointer)
}
}
$Disassembly = @{
Address = $Cast.address
Mnemonic = $Cast.mnemonic
Operands = $Cast.operands
Bytes = $Cast.bytes[0..($Cast.size - 1)]
Size = $Cast.size
RegRead = $RegRead
RegWrite = $RegWrite
}
if ($PSVersionTable.PSVersion.Major -gt 2) {
# Add TypeName for PS formatting and output result
$Disassembly.PSTypeName = 'CapstoneDisassembly.Detailed'
[pscustomobject]$Disassembly
} else {
$Disassembly = New-Object -TypeName PSObject -Property $Disassembly
# Add TypeName for PS formatting and output result
$Disassembly.PSObject.TypeNames.Insert(0, 'CapstoneDisassembly.Detailed')
$Disassembly
}
}
$BuffOffset = $BuffOffset + $cs_insn_size
}
} else {
$CallResult = [Capstone]::cs_close([ref]$DisAsmHandle)
throw 'Disassembly Failed'
}
# Free Buffer Handle
$CallResult = [Capstone]::cs_free($InsnHandle, $Count)
}
#region Init
Initialize-Capstone -DllPath (
Join-Path -Path $PSScriptRoot -ChildPath 'Lib\Capstone\capstone.dll'
) -ErrorAction Stop
#endregion
+30
View File
@@ -0,0 +1,30 @@
This documentation explains how to install & use the PowerShell binding for Capstone.
Install
------
Compile the relevant version (x86/x64) of `capstone.dll` and place it in
`./Capstone/Lib/Capstone/`.
Alternatively, pre-compiled DLLs can be obtained from the Capstone homepage
at http://capstone-engine.org/download
Usage
-----
To use the PowerShell binding, the entire Capstone folder should be added to
one of the PowerShell module directories:
# Global PSModulePath path
%Windir%\System32\WindowsPowerShell\v1.0\Modules
# User PSModulePath path
%UserProfile%\Documents\WindowsPowerShell\Modules
Once this is done the module can be initialized by typing “Import-Module Capstone”
in a new PowerShell terminal. Further information on the usage of the binding
can be obtained with the following command:
Get-Help Get-CapstoneDisassembly -Full
@@ -0,0 +1,8 @@
MANIFEST
dist/
capstone/lib
capstone/include
pyx/lib
pyx/include
pyx/*.c
pyx/*.pyx
+32
View File
@@ -0,0 +1,32 @@
0. This documentation explains how to install the Python bindings for Capstone
from source. If you want to install it from a PyPi package (recommended if
you are on Windows), see README.md.
1. To install Capstone and the Python bindings on *nix, run the command below:
```
pip install bindings/python/
```
2. Building cstest_py
To run the disassembler tests you can install `cstest_py` as alternative to the normal `cstest`.
In contrast to `cstest`, `cstest_py` also runs on Windows and Mac.
Install with:
```
pip install bindings/python/cstest_py/
```
It requires the bindings of course.
3. The tests directory contains some test code to show how to use the Capstone API.
- test_lite.py
Similarly to test_basic.py, but this code shows how to use disasm_lite(), a lighter
method to disassemble binary. Unlike disasm() API (used by test_basic.py), which returns
CsInsn objects, this API just returns tuples of (address, size, mnemonic, op_str).
The main reason for using this API is better performance: disasm_lite() is at least
20% faster than disasm(). Memory usage is also less. So if you just need basic
information out of disassembler, use disasm_lite() instead of disasm().
+31
View File
@@ -0,0 +1,31 @@
This is the software license for Capstone disassembly framework.
Capstone has been designed & implemented by Nguyen Anh Quynh <aquynh@gmail.com>
See http://www.capstone-engine.org for further information.
Copyright (c) 2013, COSEINC.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the developer(s) nor the names of its
contributors may be used to endorse or promote products derived from this
software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
+8
View File
@@ -0,0 +1,8 @@
recursive-include src *
recursive-include prebuilt *
include BUILDING.md
graft capstone/lib
graft capstone/include
global-include *.dll
global-include *.dylib
global-include *.so.*
+64
View File
@@ -0,0 +1,64 @@
To install Capstone, you should run `pip install capstone`.
If you would like to build and install Capstone with just the source distribution,
just run `python -m pip install .`, considering you are in the folder with setup.py in it.
In order to use this source distribution, you will need an environment that can
compile C code. On Linux, this is usually easy, but on Windows, this involves
installing Visual Studio and using the "Developer Command Prompt" to perform the
installation. See BUILDING.md for more information.
By default, attempting to install the python bindings will trigger a build of
the capstone native core. If this is undesirable for whatever reason, for
instance, you already have a globally installed copy of libcapstone, you may
inhibit the build by setting the environment variable LIBCAPSTONE_PATH. The
exact value is not checked, just setting it will inhibit the build. During
execution, this variable may be set to the path of a directory containing a
specific version of libcapstone you would like to use.
If you don't want to build your own copy of Capstone, you can use a precompiled
binary distribution from PyPI. Saying `pip install capstone` should
automatically obtain an appropriate copy for your system. If it does not, please
open an issue at https://github.com/capstone-engine/capstone.
--------------------------------------------------------------------------------
Capstone is a disassembly framework with the target of becoming the ultimate
disasm engine for binary analysis and reversing in the security community.
Created by Nguyen Anh Quynh, then developed and maintained by a small community,
Capstone offers some unparalleled features:
- Support multiple hardware architectures: ARM, AARCH64 (ARMv8), Mips, PPC, Sparc,
SystemZ, XCore and X86 (including X86_64).
- Having clean/simple/lightweight/intuitive architecture-neutral API.
- Provide details on disassembled instruction (called “decomposer” by others).
- Provide semantics of the disassembled instruction, such as list of implicit
registers read & written.
- Implemented in pure C language, with lightweight wrappers for C++, C#, Go,
Java, NodeJS, Ocaml, Python, Ruby & Vala ready (available in main code,
or provided externally by the community).
- Native support for all popular platforms: Windows, Mac OSX, iOS, Android,
Linux, *BSD, Solaris, etc.
- Thread-safe by design.
- Special support for embedding into firmware or OS kernel.
- High performance & suitable for malware analysis (capable of handling various
X86 malware tricks).
- Distributed under the open source BSD license.
Further information is available at http://www.capstone-engine.org
## License
This project is released under the BSD license. If you redistribute the binary
or source code of Capstone, please attach file LICENSE.TXT with your products.
File diff suppressed because it is too large Load Diff
+159
View File
@@ -0,0 +1,159 @@
# Capstone Python bindings, by Nguyen Anh Quynnh <aquynh@gmail.com>
import ctypes
from . import copy_ctypes_list
from .aarch64_const import *
# define the API
class AArch64OpMem(ctypes.Structure):
_fields_ = (
('base', ctypes.c_uint),
('index', ctypes.c_uint),
('disp', ctypes.c_int32),
)
class AArch64ImmRange(ctypes.Structure):
_fields_ = (
('first', ctypes.c_int8),
('offset', ctypes.c_int8),
)
class AArch64SMESliceOffset(ctypes.Union):
_fields_ = (
('imm', ctypes.c_int8),
('imm_range', AArch64ImmRange)
)
class AArch64OpSme(ctypes.Structure):
_fields_ = (
('type', ctypes.c_uint),
('tile', ctypes.c_uint),
('slice_reg', ctypes.c_uint),
('slice_offset', AArch64SMESliceOffset),
('has_range_offset', ctypes.c_bool),
('is_vertical', ctypes.c_bool),
)
class AArch64OpPred(ctypes.Structure):
_fields_ = (
('reg', ctypes.c_uint),
('vec_select', ctypes.c_uint),
('imm_index', ctypes.c_int),
)
class AArch64OpShift(ctypes.Structure):
_fields_ = (
('type', ctypes.c_uint),
('value', ctypes.c_uint),
)
class AArch64SysOpSysReg(ctypes.Union):
_fields_ = (
('sysreg', ctypes.c_uint),
('tlbi', ctypes.c_uint),
('ic', ctypes.c_uint),
('raw_val', ctypes.c_int),
)
class AArch64SysOpSysImm(ctypes.Union):
_fields_ = (
('dbnxs', ctypes.c_uint),
('exactfpimm', ctypes.c_uint),
('raw_val', ctypes.c_int),
)
class AArch64SysOpSysAlias(ctypes.Union):
_fields_ = (
('svcr', ctypes.c_uint),
('at', ctypes.c_uint),
('db', ctypes.c_uint),
('dc', ctypes.c_uint),
('isb', ctypes.c_uint),
('tsb', ctypes.c_uint),
('prfm', ctypes.c_uint),
('sveprfm', ctypes.c_uint),
('rprfm', ctypes.c_uint),
('pstateimm0_15', ctypes.c_uint),
('pstateimm0_1', ctypes.c_uint),
('psb', ctypes.c_uint),
('bti', ctypes.c_uint),
('svepredpat', ctypes.c_uint),
('sveveclenspecifier', ctypes.c_uint),
('raw_val', ctypes.c_int),
)
class AArch64SysOp(ctypes.Structure):
_fields_ = (
('reg', AArch64SysOpSysReg),
('imm', AArch64SysOpSysImm),
('alias', AArch64SysOpSysAlias),
('sub_type', ctypes.c_uint),
)
class AArch64OpValue(ctypes.Union):
_fields_ = (
('reg', ctypes.c_uint),
('imm', ctypes.c_int64),
('imm_range', AArch64ImmRange),
('fp', ctypes.c_double),
('mem', AArch64OpMem),
('sme', AArch64OpSme),
('pred', AArch64OpPred),
)
class AArch64Op(ctypes.Structure):
_fields_ = (
('vector_index', ctypes.c_int),
('vas', ctypes.c_uint),
('shift', AArch64OpShift),
('ext', ctypes.c_uint),
('type', ctypes.c_uint),
('is_vreg', ctypes.c_bool),
('value', AArch64OpValue),
('sysop', AArch64SysOp),
('access', ctypes.c_uint),
('is_list_member', ctypes.c_bool),
)
@property
def imm(self):
return self.value.imm
@property
def reg(self):
return self.value.reg
@property
def fp(self):
return self.value.fp
@property
def mem(self):
return self.value.mem
@property
def imm_range(self):
return self.value.imm_range
@property
def sysop(self):
return self.sysop
@property
def sme(self):
return self.value.sme
class CsAArch64(ctypes.Structure):
_fields_ = (
('cc', ctypes.c_uint),
('update_flags', ctypes.c_bool),
('post_index', ctypes.c_bool),
('is_doing_sme', ctypes.c_bool),
('op_count', ctypes.c_uint8),
('operands', AArch64Op * 8),
)
def get_arch_info(a):
return (a.cc, a.update_flags, a.post_index, copy_ctypes_list(a.operands[:a.op_count]))
File diff suppressed because it is too large Load Diff
+43
View File
@@ -0,0 +1,43 @@
import ctypes
from . import copy_ctypes_list
from .alpha_const import *
class AlphaOpMem(ctypes.Structure):
_fields_ = (
('base', ctypes.c_uint8),
('disp', ctypes.c_int32),
)
class AlphaOpValue(ctypes.Union):
_fields_ = (
('reg', ctypes.c_uint),
('imm', ctypes.c_int64),
)
class AlphaOp(ctypes.Structure):
_fields_ = (
('type', ctypes.c_uint),
('value', AlphaOpValue),
('access', ctypes.c_uint)
)
@property
def imm(self):
return self.value.imm
@property
def reg(self):
return self.value.reg
# Instruction structure
class CsAlpha(ctypes.Structure):
_fields_ = (
('op_count', ctypes.c_uint8),
('operands', AlphaOp * 3)
)
def get_arch_info(a):
return (copy_ctypes_list(a.operands[:a.op_count]))
@@ -0,0 +1,241 @@
from . import CS_OP_INVALID, CS_OP_REG, CS_OP_IMM, CS_OP_FP, CS_OP_PRED, CS_OP_SPECIAL, CS_OP_MEM, CS_OP_MEM_REG, CS_OP_MEM_IMM, UINT16_MAX, UINT8_MAX
# For Capstone Engine. AUTO-GENERATED FILE, DO NOT EDIT [alpha_const.py]
# Operand type for instruction's operands
ALPHA_OP_INVALID = CS_OP_INVALID
ALPHA_OP_REG = CS_OP_REG
ALPHA_OP_IMM = CS_OP_IMM
# Alpha registers
Alpha_REG_INVALID = 0
Alpha_REG_F0 = 1
Alpha_REG_F1 = 2
Alpha_REG_F2 = 3
Alpha_REG_F3 = 4
Alpha_REG_F4 = 5
Alpha_REG_F5 = 6
Alpha_REG_F6 = 7
Alpha_REG_F7 = 8
Alpha_REG_F8 = 9
Alpha_REG_F9 = 10
Alpha_REG_F10 = 11
Alpha_REG_F11 = 12
Alpha_REG_F12 = 13
Alpha_REG_F13 = 14
Alpha_REG_F14 = 15
Alpha_REG_F15 = 16
Alpha_REG_F16 = 17
Alpha_REG_F17 = 18
Alpha_REG_F18 = 19
Alpha_REG_F19 = 20
Alpha_REG_F20 = 21
Alpha_REG_F21 = 22
Alpha_REG_F22 = 23
Alpha_REG_F23 = 24
Alpha_REG_F24 = 25
Alpha_REG_F25 = 26
Alpha_REG_F26 = 27
Alpha_REG_F27 = 28
Alpha_REG_F28 = 29
Alpha_REG_F29 = 30
Alpha_REG_F30 = 31
Alpha_REG_F31 = 32
Alpha_REG_R0 = 33
Alpha_REG_R1 = 34
Alpha_REG_R2 = 35
Alpha_REG_R3 = 36
Alpha_REG_R4 = 37
Alpha_REG_R5 = 38
Alpha_REG_R6 = 39
Alpha_REG_R7 = 40
Alpha_REG_R8 = 41
Alpha_REG_R9 = 42
Alpha_REG_R10 = 43
Alpha_REG_R11 = 44
Alpha_REG_R12 = 45
Alpha_REG_R13 = 46
Alpha_REG_R14 = 47
Alpha_REG_R15 = 48
Alpha_REG_R16 = 49
Alpha_REG_R17 = 50
Alpha_REG_R18 = 51
Alpha_REG_R19 = 52
Alpha_REG_R20 = 53
Alpha_REG_R21 = 54
Alpha_REG_R22 = 55
Alpha_REG_R23 = 56
Alpha_REG_R24 = 57
Alpha_REG_R25 = 58
Alpha_REG_R26 = 59
Alpha_REG_R27 = 60
Alpha_REG_R28 = 61
Alpha_REG_R29 = 62
Alpha_REG_R30 = 63
Alpha_REG_R31 = 64
Alpha_REG_ENDING = 65
# Alpha instruction
Alpha_INS_INVALID = 0
Alpha_INS_ADDL = 1
Alpha_INS_ADDQ = 2
Alpha_INS_ADDSsSU = 3
Alpha_INS_ADDTsSU = 4
Alpha_INS_AND = 5
Alpha_INS_BEQ = 6
Alpha_INS_BGE = 7
Alpha_INS_BGT = 8
Alpha_INS_BIC = 9
Alpha_INS_BIS = 10
Alpha_INS_BLBC = 11
Alpha_INS_BLBS = 12
Alpha_INS_BLE = 13
Alpha_INS_BLT = 14
Alpha_INS_BNE = 15
Alpha_INS_BR = 16
Alpha_INS_BSR = 17
Alpha_INS_CMOVEQ = 18
Alpha_INS_CMOVGE = 19
Alpha_INS_CMOVGT = 20
Alpha_INS_CMOVLBC = 21
Alpha_INS_CMOVLBS = 22
Alpha_INS_CMOVLE = 23
Alpha_INS_CMOVLT = 24
Alpha_INS_CMOVNE = 25
Alpha_INS_CMPBGE = 26
Alpha_INS_CMPEQ = 27
Alpha_INS_CMPLE = 28
Alpha_INS_CMPLT = 29
Alpha_INS_CMPTEQsSU = 30
Alpha_INS_CMPTLEsSU = 31
Alpha_INS_CMPTLTsSU = 32
Alpha_INS_CMPTUNsSU = 33
Alpha_INS_CMPULE = 34
Alpha_INS_CMPULT = 35
Alpha_INS_COND_BRANCH = 36
Alpha_INS_CPYSE = 37
Alpha_INS_CPYSN = 38
Alpha_INS_CPYS = 39
Alpha_INS_CTLZ = 40
Alpha_INS_CTPOP = 41
Alpha_INS_CTTZ = 42
Alpha_INS_CVTQSsSUI = 43
Alpha_INS_CVTQTsSUI = 44
Alpha_INS_CVTSTsS = 45
Alpha_INS_CVTTQsSVC = 46
Alpha_INS_CVTTSsSUI = 47
Alpha_INS_DIVSsSU = 48
Alpha_INS_DIVTsSU = 49
Alpha_INS_ECB = 50
Alpha_INS_EQV = 51
Alpha_INS_EXCB = 52
Alpha_INS_EXTBL = 53
Alpha_INS_EXTLH = 54
Alpha_INS_EXTLL = 55
Alpha_INS_EXTQH = 56
Alpha_INS_EXTQL = 57
Alpha_INS_EXTWH = 58
Alpha_INS_EXTWL = 59
Alpha_INS_FBEQ = 60
Alpha_INS_FBGE = 61
Alpha_INS_FBGT = 62
Alpha_INS_FBLE = 63
Alpha_INS_FBLT = 64
Alpha_INS_FBNE = 65
Alpha_INS_FCMOVEQ = 66
Alpha_INS_FCMOVGE = 67
Alpha_INS_FCMOVGT = 68
Alpha_INS_FCMOVLE = 69
Alpha_INS_FCMOVLT = 70
Alpha_INS_FCMOVNE = 71
Alpha_INS_FETCH = 72
Alpha_INS_FETCH_M = 73
Alpha_INS_FTOIS = 74
Alpha_INS_FTOIT = 75
Alpha_INS_INSBL = 76
Alpha_INS_INSLH = 77
Alpha_INS_INSLL = 78
Alpha_INS_INSQH = 79
Alpha_INS_INSQL = 80
Alpha_INS_INSWH = 81
Alpha_INS_INSWL = 82
Alpha_INS_ITOFS = 83
Alpha_INS_ITOFT = 84
Alpha_INS_JMP = 85
Alpha_INS_JSR = 86
Alpha_INS_JSR_COROUTINE = 87
Alpha_INS_LDA = 88
Alpha_INS_LDAH = 89
Alpha_INS_LDBU = 90
Alpha_INS_LDL = 91
Alpha_INS_LDL_L = 92
Alpha_INS_LDQ = 93
Alpha_INS_LDQ_L = 94
Alpha_INS_LDQ_U = 95
Alpha_INS_LDS = 96
Alpha_INS_LDT = 97
Alpha_INS_LDWU = 98
Alpha_INS_MB = 99
Alpha_INS_MSKBL = 100
Alpha_INS_MSKLH = 101
Alpha_INS_MSKLL = 102
Alpha_INS_MSKQH = 103
Alpha_INS_MSKQL = 104
Alpha_INS_MSKWH = 105
Alpha_INS_MSKWL = 106
Alpha_INS_MULL = 107
Alpha_INS_MULQ = 108
Alpha_INS_MULSsSU = 109
Alpha_INS_MULTsSU = 110
Alpha_INS_ORNOT = 111
Alpha_INS_RC = 112
Alpha_INS_RET = 113
Alpha_INS_RPCC = 114
Alpha_INS_RS = 115
Alpha_INS_S4ADDL = 116
Alpha_INS_S4ADDQ = 117
Alpha_INS_S4SUBL = 118
Alpha_INS_S4SUBQ = 119
Alpha_INS_S8ADDL = 120
Alpha_INS_S8ADDQ = 121
Alpha_INS_S8SUBL = 122
Alpha_INS_S8SUBQ = 123
Alpha_INS_SEXTB = 124
Alpha_INS_SEXTW = 125
Alpha_INS_SLL = 126
Alpha_INS_SQRTSsSU = 127
Alpha_INS_SQRTTsSU = 128
Alpha_INS_SRA = 129
Alpha_INS_SRL = 130
Alpha_INS_STB = 131
Alpha_INS_STL = 132
Alpha_INS_STL_C = 133
Alpha_INS_STQ = 134
Alpha_INS_STQ_C = 135
Alpha_INS_STQ_U = 136
Alpha_INS_STS = 137
Alpha_INS_STT = 138
Alpha_INS_STW = 139
Alpha_INS_SUBL = 140
Alpha_INS_SUBQ = 141
Alpha_INS_SUBSsSU = 142
Alpha_INS_SUBTsSU = 143
Alpha_INS_TRAPB = 144
Alpha_INS_UMULH = 145
Alpha_INS_WH64 = 146
Alpha_INS_WH64EN = 147
Alpha_INS_WMB = 148
Alpha_INS_XOR = 149
Alpha_INS_ZAPNOT = 150
ALPHA_INS_ENDING = 151
# Group of Alpha instructions
Alpha_GRP_INVALID = 0
# Generic groups
Alpha_GRP_CALL = 1
Alpha_GRP_JUMP = 2
Alpha_GRP_BRANCH_RELATIVE = 3
Alpha_GRP_ENDING = 4
+39
View File
@@ -0,0 +1,39 @@
# Capstone Python bindings, by R33v0LT <sibirtsevdl@gmail.com>
import ctypes
from . import copy_ctypes_list
from .arc_const import *
class ARCOpValue(ctypes.Union):
_fields_ = (
('reg', ctypes.c_uint),
('imm', ctypes.c_int64)
)
class ARCOp(ctypes.Structure):
_fields_ = (
('type', ctypes.c_int),
('value', ARCOpValue),
('access', ctypes.c_uint)
)
@property
def imm(self):
return self.value.imm
@property
def reg(self):
return self.value.reg
# Instruction structure
class CsARC(ctypes.Structure):
_fields_ = (
('op_count', ctypes.c_uint8),
('operands', ARCOp * 8),
)
def get_arch_info(a):
return (copy_ctypes_list(a.operands[:a.op_count]))
+274
View File
@@ -0,0 +1,274 @@
from . import CS_OP_INVALID, CS_OP_REG, CS_OP_IMM, CS_OP_FP, CS_OP_PRED, CS_OP_SPECIAL, CS_OP_MEM, CS_OP_MEM_REG, CS_OP_MEM_IMM, UINT16_MAX, UINT8_MAX
# For Capstone Engine. AUTO-GENERATED FILE, DO NOT EDIT [arc_const.py]
ARC_OP_INVALID = CS_OP_INVALID
ARC_OP_REG = CS_OP_REG
ARC_OP_IMM = CS_OP_IMM
ARC_REG_INVALID = 0
ARC_REG_BLINK = 1
ARC_REG_FP = 2
ARC_REG_GP = 3
ARC_REG_ILINK = 4
ARC_REG_SP = 5
ARC_REG_R0 = 6
ARC_REG_R1 = 7
ARC_REG_R2 = 8
ARC_REG_R3 = 9
ARC_REG_R4 = 10
ARC_REG_R5 = 11
ARC_REG_R6 = 12
ARC_REG_R7 = 13
ARC_REG_R8 = 14
ARC_REG_R9 = 15
ARC_REG_R10 = 16
ARC_REG_R11 = 17
ARC_REG_R12 = 18
ARC_REG_R13 = 19
ARC_REG_R14 = 20
ARC_REG_R15 = 21
ARC_REG_R16 = 22
ARC_REG_R17 = 23
ARC_REG_R18 = 24
ARC_REG_R19 = 25
ARC_REG_R20 = 26
ARC_REG_R21 = 27
ARC_REG_R22 = 28
ARC_REG_R23 = 29
ARC_REG_R24 = 30
ARC_REG_R25 = 31
ARC_REG_R30 = 32
ARC_REG_R32 = 33
ARC_REG_R33 = 34
ARC_REG_R34 = 35
ARC_REG_R35 = 36
ARC_REG_R36 = 37
ARC_REG_R37 = 38
ARC_REG_R38 = 39
ARC_REG_R39 = 40
ARC_REG_R40 = 41
ARC_REG_R41 = 42
ARC_REG_R42 = 43
ARC_REG_R43 = 44
ARC_REG_R44 = 45
ARC_REG_R45 = 46
ARC_REG_R46 = 47
ARC_REG_R47 = 48
ARC_REG_R48 = 49
ARC_REG_R49 = 50
ARC_REG_R50 = 51
ARC_REG_R51 = 52
ARC_REG_R52 = 53
ARC_REG_R53 = 54
ARC_REG_R54 = 55
ARC_REG_R55 = 56
ARC_REG_R56 = 57
ARC_REG_R57 = 58
ARC_REG_R58 = 59
ARC_REG_R59 = 60
ARC_REG_R60 = 61
ARC_REG_R61 = 62
ARC_REG_R62 = 63
ARC_REG_R63 = 64
ARC_REG_STATUS32 = 65
ARC_REG_ENDING = 66
ARC_INS_INVALID = 0
ARC_INS_h = 1
ARC_INS_PBR = 2
ARC_INS_ERROR_FLS = 3
ARC_INS_ERROR_FFS = 4
ARC_INS_PLDFI = 5
ARC_INS_STB_FAR = 6
ARC_INS_STH_FAR = 7
ARC_INS_ST_FAR = 8
ARC_INS_ADC = 9
ARC_INS_ADC_F = 10
ARC_INS_ADD_S = 11
ARC_INS_ADD = 12
ARC_INS_ADD_F = 13
ARC_INS_AND = 14
ARC_INS_AND_F = 15
ARC_INS_ASL_S = 16
ARC_INS_ASL = 17
ARC_INS_ASL_F = 18
ARC_INS_ASR_S = 19
ARC_INS_ASR = 20
ARC_INS_ASR_F = 21
ARC_INS_BCLR_S = 22
ARC_INS_BEQ_S = 23
ARC_INS_BGE_S = 24
ARC_INS_BGT_S = 25
ARC_INS_BHI_S = 26
ARC_INS_BHS_S = 27
ARC_INS_BL = 28
ARC_INS_BLE_S = 29
ARC_INS_BLO_S = 30
ARC_INS_BLS_S = 31
ARC_INS_BLT_S = 32
ARC_INS_BL_S = 33
ARC_INS_BMSK_S = 34
ARC_INS_BNE_S = 35
ARC_INS_B = 36
ARC_INS_BREQ_S = 37
ARC_INS_BRNE_S = 38
ARC_INS_BR = 39
ARC_INS_BSET_S = 40
ARC_INS_BTST_S = 41
ARC_INS_B_S = 42
ARC_INS_CMP_S = 43
ARC_INS_CMP = 44
ARC_INS_LD_S = 45
ARC_INS_MOV_S = 46
ARC_INS_EI_S = 47
ARC_INS_ENTER_S = 48
ARC_INS_FFS_F = 49
ARC_INS_FFS = 50
ARC_INS_FLS_F = 51
ARC_INS_FLS = 52
ARC_INS_ABS_S = 53
ARC_INS_ADD1_S = 54
ARC_INS_ADD2_S = 55
ARC_INS_ADD3_S = 56
ARC_INS_AND_S = 57
ARC_INS_BIC_S = 58
ARC_INS_BRK_S = 59
ARC_INS_EXTB_S = 60
ARC_INS_EXTH_S = 61
ARC_INS_JEQ_S = 62
ARC_INS_JL_S = 63
ARC_INS_JL_S_D = 64
ARC_INS_JNE_S = 65
ARC_INS_J_S = 66
ARC_INS_J_S_D = 67
ARC_INS_LSR_S = 68
ARC_INS_MPYUW_S = 69
ARC_INS_MPYW_S = 70
ARC_INS_MPY_S = 71
ARC_INS_NEG_S = 72
ARC_INS_NOP_S = 73
ARC_INS_NOT_S = 74
ARC_INS_OR_S = 75
ARC_INS_SEXB_S = 76
ARC_INS_SEXH_S = 77
ARC_INS_SUB_S = 78
ARC_INS_SUB_S_NE = 79
ARC_INS_SWI_S = 80
ARC_INS_TRAP_S = 81
ARC_INS_TST_S = 82
ARC_INS_UNIMP_S = 83
ARC_INS_XOR_S = 84
ARC_INS_LDB_S = 85
ARC_INS_LDH_S = 86
ARC_INS_J = 87
ARC_INS_JL = 88
ARC_INS_JLI_S = 89
ARC_INS_LDB_AB = 90
ARC_INS_LDB_AW = 91
ARC_INS_LDB_DI_AB = 92
ARC_INS_LDB_DI_AW = 93
ARC_INS_LDB_DI = 94
ARC_INS_LDB_X_AB = 95
ARC_INS_LDB_X_AW = 96
ARC_INS_LDB_X_DI_AB = 97
ARC_INS_LDB_X_DI_AW = 98
ARC_INS_LDB_X_DI = 99
ARC_INS_LDB_X = 100
ARC_INS_LDB = 101
ARC_INS_LDH_AB = 102
ARC_INS_LDH_AW = 103
ARC_INS_LDH_DI_AB = 104
ARC_INS_LDH_DI_AW = 105
ARC_INS_LDH_DI = 106
ARC_INS_LDH_S_X = 107
ARC_INS_LDH_X_AB = 108
ARC_INS_LDH_X_AW = 109
ARC_INS_LDH_X_DI_AB = 110
ARC_INS_LDH_X_DI_AW = 111
ARC_INS_LDH_X_DI = 112
ARC_INS_LDH_X = 113
ARC_INS_LDH = 114
ARC_INS_LDI_S = 115
ARC_INS_LD_AB = 116
ARC_INS_LD_AW = 117
ARC_INS_LD_DI_AB = 118
ARC_INS_LD_DI_AW = 119
ARC_INS_LD_DI = 120
ARC_INS_LD_S_AS = 121
ARC_INS_LD = 122
ARC_INS_LEAVE_S = 123
ARC_INS_LR = 124
ARC_INS_LSR = 125
ARC_INS_LSR_F = 126
ARC_INS_MAX = 127
ARC_INS_MAX_F = 128
ARC_INS_MIN = 129
ARC_INS_MIN_F = 130
ARC_INS_MOV_S_NE = 131
ARC_INS_MOV = 132
ARC_INS_MOV_F = 133
ARC_INS_MPYMU = 134
ARC_INS_MPYMU_F = 135
ARC_INS_MPYM = 136
ARC_INS_MPYM_F = 137
ARC_INS_MPY = 138
ARC_INS_MPY_F = 139
ARC_INS_NORMH_F = 140
ARC_INS_NORMH = 141
ARC_INS_NORM_F = 142
ARC_INS_NORM = 143
ARC_INS_OR = 144
ARC_INS_OR_F = 145
ARC_INS_POP_S = 146
ARC_INS_PUSH_S = 147
ARC_INS_ROR = 148
ARC_INS_ROR_F = 149
ARC_INS_RSUB = 150
ARC_INS_RSUB_F = 151
ARC_INS_SBC = 152
ARC_INS_SBC_F = 153
ARC_INS_SETEQ = 154
ARC_INS_SETEQ_F = 155
ARC_INS_SEXB_F = 156
ARC_INS_SEXB = 157
ARC_INS_SEXH_F = 158
ARC_INS_SEXH = 159
ARC_INS_STB_S = 160
ARC_INS_ST_S = 161
ARC_INS_STB_AB = 162
ARC_INS_STB_AW = 163
ARC_INS_STB_DI_AB = 164
ARC_INS_STB_DI_AW = 165
ARC_INS_STB_DI = 166
ARC_INS_STB = 167
ARC_INS_STH_AB = 168
ARC_INS_STH_AW = 169
ARC_INS_STH_DI_AB = 170
ARC_INS_STH_DI_AW = 171
ARC_INS_STH_DI = 172
ARC_INS_STH_S = 173
ARC_INS_STH = 174
ARC_INS_ST_AB = 175
ARC_INS_ST_AW = 176
ARC_INS_ST_DI_AB = 177
ARC_INS_ST_DI_AW = 178
ARC_INS_ST_DI = 179
ARC_INS_ST = 180
ARC_INS_SUB1 = 181
ARC_INS_SUB1_F = 182
ARC_INS_SUB2 = 183
ARC_INS_SUB2_F = 184
ARC_INS_SUB3 = 185
ARC_INS_SUB3_F = 186
ARC_INS_SUB = 187
ARC_INS_SUB_F = 188
ARC_INS_XOR = 189
ARC_INS_XOR_F = 190
# Group of ARC instructions
ARC_GRP_INVALID = 0
ARC_GRP_JUMP = 1
ARC_GRP_CALL = 2
ARC_GRP_RET = 3
ARC_GRP_BRANCH_RELATIVE = 4
ARC_GRP_ENDING = 5
+109
View File
@@ -0,0 +1,109 @@
# Capstone Python bindings, by Nguyen Anh Quynnh <aquynh@gmail.com>
import ctypes
from . import copy_ctypes_list
from .arm_const import *
# define the API
class ArmOpMem(ctypes.Structure):
_fields_ = (
('base', ctypes.c_int),
('index', ctypes.c_int),
('scale', ctypes.c_int),
('disp', ctypes.c_int),
('align', ctypes.c_uint),
)
class ArmOpShift(ctypes.Structure):
_fields_ = (
('type', ctypes.c_uint),
('value', ctypes.c_uint),
)
class ArmSysopReg(ctypes.Union):
_fields_ = (
('mclasssysreg', ctypes.c_uint),
('bankedreg', ctypes.c_uint),
('raw_val', ctypes.c_int),
)
class ArmOpSysop(ctypes.Structure):
_fields_ = (
('reg', ArmSysopReg),
('psr_bits', ctypes.c_uint),
('sysm', ctypes.c_uint16),
('msr_mask', ctypes.c_uint8),
)
class ArmOpValue(ctypes.Union):
_fields_ = (
('reg', ctypes.c_uint),
('sysop', ArmOpSysop),
('imm', ctypes.c_int64),
('pred', ctypes.c_int),
('fp', ctypes.c_double),
('mem', ArmOpMem),
('setend', ctypes.c_int),
)
class ArmOp(ctypes.Structure):
_fields_ = (
('vector_index', ctypes.c_int),
('shift', ArmOpShift),
('type', ctypes.c_uint),
('value', ArmOpValue),
('subtracted', ctypes.c_bool),
('access', ctypes.c_uint),
('neon_lane', ctypes.c_int8),
)
@property
def reg(self):
return self.value.reg
@property
def sysop(self):
return self.value.sysop
@property
def imm(self):
return self.value.imm
@property
def pred(self):
return self.value.pred
@property
def fp(self):
return self.value.fp
@property
def mem(self):
return self.value.mem
@property
def setend(self):
return self.value.setend
class CsArm(ctypes.Structure):
_fields_ = (
('usermode', ctypes.c_bool),
('vector_size', ctypes.c_int),
('vector_data', ctypes.c_int),
('cps_mode', ctypes.c_int),
('cps_flag', ctypes.c_int),
('cc', ctypes.c_uint),
('vcc', ctypes.c_uint),
('update_flags', ctypes.c_bool),
('post_index', ctypes.c_bool),
('mem_barrier', ctypes.c_int),
('pred_mask', ctypes.c_uint8),
('op_count', ctypes.c_uint8),
('operands', ArmOp * 36),
)
def get_arch_info(a):
return (a.usermode, a.vector_size, a.vector_data, a.cps_mode, a.cps_flag, a.cc, a.vcc, a.update_flags, \
a.post_index, a.mem_barrier, a.pred_mask, copy_ctypes_list(a.operands[:a.op_count]))
+4
View File
@@ -0,0 +1,4 @@
# Copyright © 2024 Peace-Maker <peacemakerctf@gmail.com>
# SPDX-License-Identifier: BSD-3
# Compatibility header with pre v6 API
from .arm64_const import *
@@ -0,0 +1,18 @@
# Copyright © 2024 Peace-Maker <peacemakerctf@gmail.com>
# SPDX-License-Identifier: BSD-3
# Compatibility header with pre v6 API
import capstone
import capstone.aarch64_const
setattr(capstone, "CS_ARCH_ARM64", capstone.CS_ARCH_AARCH64)
setattr(capstone, "__all__", getattr(capstone, "__all__") + ["CS_ARCH_ARM64"])
globals().update(
(name.replace("AARCH64", "ARM64"), getattr(capstone.aarch64_const, name))
for name in capstone.aarch64_const.__dict__
if name.startswith("AARCH64")
)
globals().update(
(name.replace("AArch64CC", "ARM64_CC"), getattr(capstone.aarch64_const, name))
for name in capstone.aarch64_const.__dict__
if name.startswith("AArch64CC")
)
File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More