10 static byte[] hexString2Byte(String s) {
13 byte[]
data =
new byte[
len / 2];
14 for (
int i = 0;
i <
len;
i += 2) {
15 data[
i / 2] = (
byte) ((Character.digit(s.charAt(
i), 16) << 4)
16 + Character.digit(s.charAt(
i+1), 16));
21 static final String XCORE_CODE =
"fe0ffe171317c6feec1797f8ec4f1ffdec3707f2455bf9fa02061b1009fdeca7";
23 public static Capstone
cs;
25 private static String
hex(
int i) {
26 return Integer.toString(
i, 16);
29 private static String
hex(
long i) {
30 return Long.toString(
i, 16);
34 System.out.printf(
"0x%x:\t%s\t%s\n", ins.address, ins.mnemonic, ins.opStr);
38 if (operands.op.length != 0) {
39 System.out.printf(
"\top_count: %d\n", operands.op.length);
40 for (
int c=0;
c<operands.op.length;
c++) {
43 System.out.printf(
"\t\toperands[%d].type: REG = %s\n",
c, ins.regName(
i.value.reg));
45 System.out.printf(
"\t\toperands[%d].type: IMM = 0x%x\n",
c,
i.value.imm);
47 System.out.printf(
"\t\toperands[%d].type: MEM\n",
c);
49 System.out.printf(
"\t\t\toperands[%d].mem.base: REG = %s\n",
c, ins.regName(
i.value.mem.base));
51 System.out.printf(
"\t\t\toperands[%d].mem.index: REG = %s\n",
c, ins.regName(
i.value.mem.index));
52 if (
i.value.mem.disp != 0)
53 System.out.printf(
"\t\t\toperands[%d].mem.disp: 0x%x\n",
c,
i.value.mem.disp);
54 if (
i.value.mem.direct != 1)
55 System.out.printf(
"\t\t\toperands[%d].mem.direct: -1\n",
c);
61 public static void main(String argv[]) {
69 System.out.println(
new String(
new char[16]).replace(
"\0",
"*"));
70 System.out.println(
"Platform: " +
test.comment);
72 System.out.println(
"Disasm:");
75 cs.setDetail(Capstone.CS_OPT_ON);
76 Capstone.CsInsn[] all_ins =
cs.disasm(
test.code, 0x1000);
78 for (
int j = 0; j < all_ins.length; j++) {
82 System.out.printf(
"0x%x:\n\n", (all_ins[all_ins.length-1].address + all_ins[all_ins.length-1].size));