Squashed 'external/capstone/' content from commit e46f64fa
git-subtree-dir: external/capstone git-subtree-split: e46f64fadb351e9ecd05264fab26f2772feb0994
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
*.class
|
||||
tags
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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
@@ -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
@@ -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
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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
@@ -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;
|
||||
}
|
||||
Executable
+26
@@ -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
|
||||
Reference in New Issue
Block a user