Rizin
unix-like reverse engineering framework and cli tools
TestBasic Class Reference

Classes

class  platform
 

Static Public Member Functions

static String stringToHex (byte[] code)
 
static void main (String argv[])
 

Static Public Attributes

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 }
 
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 }
 
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 }
 
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 }
 
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 }
 
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 }
 

Detailed Description

Definition at line 6 of file TestBasic.java.

Member Function Documentation

◆ main()

static void TestBasic.main ( String  argv[])
inlinestatic

Definition at line 47 of file TestBasic.java.

47  {
48  platform[] platforms = {
49  new platform(
50  Capstone.CS_ARCH_X86,
51  Capstone.CS_MODE_16,
52  Capstone.CS_OPT_SYNTAX_INTEL,
53  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 },
54  "X86 16bit (Intel syntax)"
55  ),
56  new platform(
57  Capstone.CS_ARCH_X86,
58  Capstone.CS_MODE_32,
59  Capstone.CS_OPT_SYNTAX_ATT,
60  X86_CODE,
61  "X86 32bit (ATT syntax)"
62  ),
63  new platform(
64  Capstone.CS_ARCH_X86,
65  Capstone.CS_MODE_32,
66  X86_CODE,
67  "X86 32 (Intel syntax)"
68  ),
69  new platform(
70  Capstone.CS_ARCH_X86,
71  Capstone.CS_MODE_64,
72  new byte[] {(byte)0x55, (byte)0x48, (byte)0x8b, (byte)0x05, (byte)0xb8, (byte)0x13, (byte)0x00, (byte)0x00 },
73  "X86 64 (Intel syntax)"
74  ),
75  new platform(
76  Capstone.CS_ARCH_ARM,
77  Capstone.CS_MODE_ARM,
78  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 },
79  "ARM"
80  ),
81  new platform(
82  Capstone.CS_ARCH_ARM,
83  Capstone.CS_MODE_THUMB,
84  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 },
85  "THUMB-2"
86  ),
87  new platform(
88  Capstone.CS_ARCH_ARM,
89  Capstone.CS_MODE_ARM,
90  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 },
91  "ARM: Cortex-A15 + NEON"
92  ),
93  new platform(
94  Capstone.CS_ARCH_ARM,
95  Capstone.CS_MODE_THUMB,
96  new byte[] {(byte)0x70, (byte)0x47, (byte)0xeb, (byte)0x46, (byte)0x83, (byte)0xb0, (byte)0xc9, (byte)0x68 },
97  "THUMB"
98  ),
99  new platform(
100  Capstone.CS_ARCH_MIPS,
101  Capstone.CS_MODE_MIPS32 + Capstone.CS_MODE_BIG_ENDIAN,
102  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 },
103  "MIPS-32 (Big-endian)"
104  ),
105  new platform(
106  Capstone.CS_ARCH_MIPS,
107  Capstone.CS_MODE_MIPS64+ Capstone.CS_MODE_LITTLE_ENDIAN,
108  new byte[] {(byte)0x56, (byte)0x34, (byte)0x21, (byte)0x34, (byte)0xc2, (byte)0x17, (byte)0x01, (byte)0x00 },
109  "MIPS-64-EL (Little-endian)"
110  ),
111  new platform(
112  Capstone.CS_ARCH_ARM64,
113  Capstone.CS_MODE_ARM,
114  new byte [] { 0x21, 0x7c, 0x02, (byte)0x9b, 0x21, 0x7c, 0x00, 0x53, 0x00, 0x40, 0x21, 0x4b, (byte)0xe1, 0x0b, 0x40, (byte)0xb9 },
115  "ARM-64"
116  ),
117  new platform (
118  Capstone.CS_ARCH_PPC,
119  Capstone.CS_MODE_BIG_ENDIAN,
120  PPC_CODE,
121  "PPC-64"
122  ),
123  new platform (
124  Capstone.CS_ARCH_PPC,
125  Capstone.CS_MODE_BIG_ENDIAN,
126  Capstone.CS_OPT_SYNTAX_NOREGNAME,
127  PPC_CODE,
128  "PPC-64, print register with number only"
129  ),
130  new platform (
131  Capstone.CS_ARCH_SPARC,
132  Capstone.CS_MODE_BIG_ENDIAN,
133  SPARC_CODE,
134  "Sparc"
135  ),
136  new platform (
137  Capstone.CS_ARCH_SPARC,
138  Capstone.CS_MODE_BIG_ENDIAN + Capstone.CS_MODE_V9,
139  SPARCV9_CODE,
140  "SparcV9"
141  ),
142  new platform (
143  Capstone.CS_ARCH_SYSZ,
144  0,
145  SYSZ_CODE,
146  "SystemZ"
147  ),
148  new platform (
149  Capstone.CS_ARCH_XCORE,
150  0,
151  XCORE_CODE,
152  "XCore"
153  ),
154  };
155 
156  for (int j = 0; j < platforms.length; j++) {
157  System.out.println("****************");
158  System.out.println(String.format("Platform: %s", platforms[j].comment));
159  System.out.println(String.format("Code: %s", stringToHex(platforms[j].code)));
160  System.out.println("Disasm:");
161 
162  Capstone cs = new Capstone(platforms[j].arch, platforms[j].mode);
163  if (platforms[j].syntax != 0)
164  cs.setSyntax(platforms[j].syntax);
165 
166  Capstone.CsInsn[] all_insn = cs.disasm(platforms[j].code, 0x1000);
167 
168  for (int i = 0; i < all_insn.length; i++) {
169  System.out.println(String.format("0x%x: \t%s\t%s", all_insn[i].address,
170  all_insn[i].mnemonic, all_insn[i].opStr));
171  }
172  System.out.printf("0x%x:\n\n", all_insn[all_insn.length-1].address + all_insn[all_insn.length-1].size);
173 
174  // Close when done
175  cs.close();
176  }
177  }
lzma_index ** i
Definition: index.h:629
static final byte[] SPARC_CODE
Definition: TestBasic.java:42
static String stringToHex(byte[] code)
Definition: TestBasic.java:30
static final byte[] PPC_CODE
Definition: TestBasic.java:40
static final byte[] SPARCV9_CODE
Definition: TestBasic.java:44
static final byte[] X86_CODE
Definition: TestBasic.java:41
static final byte[] XCORE_CODE
Definition: TestBasic.java:45
static final byte[] SYSZ_CODE
Definition: TestBasic.java:43
cs_arch arch
Definition: cstool.c:13
struct platform platforms[]
Definition: fuzz_diff.c:18
const char int mode
Definition: ioapi.h:137
Definition: inftree9.h:24

References arch, TestBasic.platform.comment, test_evm.cs, i, platforms, PPC_CODE, SPARC_CODE, SPARCV9_CODE, stringToHex(), benchmark.syntax, SYSZ_CODE, X86_CODE, and XCORE_CODE.

◆ stringToHex()

static String TestBasic.stringToHex ( byte[]  code)
inlinestatic

Definition at line 30 of file TestBasic.java.

30  {
31  StringBuilder buf = new StringBuilder(200);
32  for (byte ch: code) {
33  if (buf.length() > 0)
34  buf.append(' ');
35  buf.append(String.format("0x%02x", ch));
36  }
37  return buf.toString();
38  }
voidpf void * buf
Definition: ioapi.h:138

Referenced by TestArm.main(), TestArm64.main(), main(), TestMips.main(), TestPpc.main(), TestSparc.main(), TestSystemz.main(), TestX86.main(), and TestXcore.main().

Member Data Documentation

◆ PPC_CODE

final byte [] TestBasic.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 }
static

Definition at line 40 of file TestBasic.java.

Referenced by main().

◆ SPARC_CODE

final byte [] TestBasic.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 }
static

Definition at line 42 of file TestBasic.java.

Referenced by main().

◆ SPARCV9_CODE

final byte [] TestBasic.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 }
static

Definition at line 44 of file TestBasic.java.

Referenced by main().

◆ SYSZ_CODE

final byte [] TestBasic.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 }
static

Definition at line 43 of file TestBasic.java.

Referenced by main().

◆ X86_CODE

final byte [] TestBasic.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 }
static

Definition at line 41 of file TestBasic.java.

Referenced by main().

◆ XCORE_CODE

final byte [] TestBasic.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

Definition at line 45 of file TestBasic.java.

Referenced by main().


The documentation for this class was generated from the following file: