Rizin
unix-like reverse engineering framework and cli tools
assembler.c
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2021 deroad <wargio@libero.it>
2 // SPDX-License-Identifier: LGPL-3.0-only
3 
4 #include "assembler.h"
5 #include "const.h"
6 
7 #define return_error_if_size_lt(a, b) \
8  do { \
9  if (a < b) { \
10  RZ_LOG_ERROR("[!] java_assembler: no enough output buffer (requires %d bytes).\n", b); \
11  return false; \
12  } \
13  } while (0)
14 
15 #define return_error_if_empty_input(a, b) \
16  do { \
17  if (RZ_STR_ISEMPTY(a) || b < 1) { \
18  RZ_LOG_ERROR("[!] java_assembler: the input is empty.\n"); \
19  return false; \
20  } \
21  } while (0)
22 
23 typedef bool (*AsmEncoder)(ut8 bytecode, const char *input, st32 input_size, ut8 *output, st32 output_size, ut64 pc, st32 *written);
24 
25 typedef struct _jasm {
26  const char *opcode;
31 
32 static bool encode_not_implemented(ut8 bytecode, const char *input, st32 input_size, ut8 *output, st32 output_size, ut64 pc, st32 *written) {
33  RZ_LOG_ERROR("[!] java_assembler: not implemented.\n");
34  return false;
35 }
36 
37 static bool encode_only_bcode(ut8 bytecode, const char *input, st32 input_size, ut8 *output, st32 output_size, ut64 pc, st32 *written) {
38  return_error_if_size_lt(output_size, 1);
39 
40  *written = 1;
41  output[0] = bytecode;
42  return true;
43 }
44 
45 static bool encode_st8(ut8 bytecode, const char *input, st32 input_size, ut8 *output, st32 output_size, ut64 pc, st32 *written) {
46  return_error_if_size_lt(output_size, 2);
48 
50  RZ_LOG_ERROR("[!] java_assembler: '%s' is not a valid number between %d and %d (inclusive).\n", input, INT8_MIN, INT8_MAX);
51  return false;
52  }
53 
54  *written = 2;
55  output[0] = bytecode;
56  ((st8 *)output)[1] = (st8)strtoll(input, NULL, 0);
57  return true;
58 }
59 
60 static bool encode_ut8(ut8 bytecode, const char *input, st32 input_size, ut8 *output, st32 output_size, ut64 pc, st32 *written) {
61  return_error_if_size_lt(output_size, 2);
63 
65  RZ_LOG_ERROR("[!] java_assembler: '%s' is not a valid number between %d and %d (inclusive).\n", input, INT8_MIN, INT8_MAX);
66  return false;
67  }
68 
69  *written = 2;
70  output[0] = bytecode;
71  output[1] = (ut8)strtoll(input, NULL, 0);
72  return true;
73 }
74 
75 static bool encode_addr32(ut8 bytecode, const char *input, st32 input_size, ut8 *output, st32 output_size, ut64 pc, st32 *written) {
76  return_error_if_size_lt(output_size, 5);
78 
80  RZ_LOG_ERROR("[!] java_assembler: '%s' is not a valid number between %d and %d (inclusive).\n", input, INT16_MIN, INT16_MAX);
81  return false;
82  }
83 
84  *written = 5;
85  output[0] = bytecode;
86  st64 n = strtoll(input, NULL, 0);
87  st32 addr = n - pc;
89  return true;
90 }
91 
92 static bool encode_addr16(ut8 bytecode, const char *input, st32 input_size, ut8 *output, st32 output_size, ut64 pc, st32 *written) {
93  return_error_if_size_lt(output_size, 3);
95 
97  RZ_LOG_ERROR("[!] java_assembler: '%s' is not a valid number between %d and %d (inclusive).\n", input, INT16_MIN, INT16_MAX);
98  return false;
99  }
100 
101  *written = 3;
102  output[0] = bytecode;
103  st64 n = strtoll(input, NULL, 0);
104  st16 addr = n - pc;
105  rz_write_be16(output + 1, addr);
106  return true;
107 }
108 
109 static bool encode_st16(ut8 bytecode, const char *input, st32 input_size, ut8 *output, st32 output_size, ut64 pc, st32 *written) {
110  return_error_if_size_lt(output_size, 3);
111  return_error_if_empty_input(input, input_size);
112 
114  RZ_LOG_ERROR("[!] java_assembler: '%s' is not a valid number between %d and %d (inclusive).\n", input, INT16_MIN, INT16_MAX);
115  return false;
116  }
117 
118  *written = 3;
119  output[0] = bytecode;
120  st16 n = strtoll(input, NULL, 0);
121  rz_write_be16(output + 1, n);
122  return true;
123 }
124 
125 static bool encode_const_pool8(ut8 bytecode, const char *input, st32 input_size, ut8 *output, st32 output_size, ut64 pc, st32 *written) {
126  return_error_if_size_lt(output_size, 2);
127  return_error_if_empty_input(input, input_size);
128 
129  ut32 cpool_len = strlen(JAVA_ASM_CONSTANT_POOL_STR);
130  if (!strncmp(input, JAVA_ASM_CONSTANT_POOL_STR, cpool_len)) {
131  input += cpool_len;
132  }
133 
135  RZ_LOG_ERROR("[!] java_assembler: '%s' is not a valid number between 0 and %u (inclusive).\n", input, UINT8_MAX);
136  return false;
137  }
138 
139  *written = 2;
140  output[0] = bytecode;
141  output[1] = (ut8)strtoll(input, NULL, 0);
142  return true;
143 }
144 
145 static bool encode_const_pool16(ut8 bytecode, const char *input, st32 input_size, ut8 *output, st32 output_size, ut64 pc, st32 *written) {
146  return_error_if_size_lt(output_size, 3);
147  return_error_if_empty_input(input, input_size);
148 
149  ut32 cpool_len = strlen(JAVA_ASM_CONSTANT_POOL_STR);
150  if (!strncmp(input, JAVA_ASM_CONSTANT_POOL_STR, cpool_len)) {
151  input += cpool_len;
152  }
153 
155  RZ_LOG_ERROR("[!] java_assembler: '%s' is not a valid number between 0 and %u (inclusive).\n", input, UINT16_MAX);
156  return false;
157  }
158 
159  *written = 3;
160  output[0] = bytecode;
161  ut16 n = (ut16)strtoll(input, NULL, 0);
162  rz_write_be16(output + 1, n);
163  return true;
164 }
165 
166 static bool encode_const_pool16_ut8(ut8 bytecode, const char *input, st32 input_size, ut8 *output, st32 output_size, ut64 pc, st32 *written) {
167  return_error_if_size_lt(output_size, 4);
168  return_error_if_empty_input(input, input_size);
169 
170  ut32 cpool_len = strlen(JAVA_ASM_CONSTANT_POOL_STR);
171  if (!strncmp(input, JAVA_ASM_CONSTANT_POOL_STR, cpool_len)) {
172  input += cpool_len;
173  }
174 
176  RZ_LOG_ERROR("[!] java_assembler: '%s' is not a valid number between 0 and %u (inclusive).\n", input, UINT16_MAX);
177  return false;
178  }
179 
180  const char *next = NULL;
181  char *tmp = NULL;
182  ut16 cpool = (ut16)strtoll(input, &tmp, 0);
183  if (!tmp || tmp == (input + input_size) || !(next = rz_str_trim_head_ro(tmp))) {
184  RZ_LOG_ERROR("[!] java_assembler: '%s' is not a valid number between 0 and %u (inclusive).\n", tmp, UINT8_MAX);
185  }
186 
187  if (!rz_is_valid_input_num_value(NULL, next)) {
188  RZ_LOG_ERROR("[!] java_assembler: '%s' is not a valid number between 0 and %u (inclusive).\n", input, UINT8_MAX);
189  return false;
190  }
191  ut8 num = (ut8)strtoll(next, NULL, 0);
192 
193  *written = 4;
194  output[0] = bytecode;
195  rz_write_be16(output + 1, cpool);
196  output[3] = num;
197  return true;
198 }
199 
200 static bool encode_ut8x2(ut8 bytecode, const char *input, st32 input_size, ut8 *output, st32 output_size, ut64 pc, st32 *written) {
201  return_error_if_size_lt(output_size, 3);
202  return_error_if_empty_input(input, input_size);
203 
205  RZ_LOG_ERROR("[!] java_assembler: '%s' is not a valid number between 0 and %u (inclusive).\n", input, UINT8_MAX);
206  return false;
207  }
208 
209  const char *next = NULL;
210  char *tmp = NULL;
211  ut16 arg0 = (ut16)strtoll(input, &tmp, 0);
212  if (!tmp || tmp == (input + input_size) || !(next = rz_str_trim_head_ro(tmp))) {
213  RZ_LOG_ERROR("[!] java_assembler: '%s' is not a valid number between 0 and %u (inclusive).\n", tmp, UINT8_MAX);
214  }
215 
216  if (!rz_is_valid_input_num_value(NULL, next)) {
217  RZ_LOG_ERROR("[!] java_assembler: '%s' is not a valid number between 0 and %u (inclusive).\n", input, UINT8_MAX);
218  return false;
219  }
220  ut8 arg1 = (ut8)strtoll(next, NULL, 0);
221 
222  *written = 3;
223  output[0] = bytecode;
224  output[1] = arg0;
225  output[2] = arg1;
226  return true;
227 }
228 
229 static bool encode_atype(ut8 bytecode, const char *input, st32 input_size, ut8 *output, st32 output_size, ut64 pc, st32 *written) {
230  return_error_if_size_lt(output_size, 2);
231  return_error_if_empty_input(input, input_size);
232 
233  ut8 byte = 0;
234  /* bool 4, char 5, float 6, double 7, byte 8, short 9, int 10, long 11 */
235  if (!strncmp(input, "bool", strlen("bool"))) {
236  byte = 4;
237  } else if (!strncmp(input, "char", strlen("char"))) {
238  byte = 5;
239  } else if (!strncmp(input, "float", strlen("float"))) {
240  byte = 6;
241  } else if (!strncmp(input, "double", strlen("double"))) {
242  byte = 7;
243  } else if (!strncmp(input, "byte", strlen("byte"))) {
244  byte = 8;
245  } else if (!strncmp(input, "short", strlen("short"))) {
246  byte = 9;
247  } else if (!strncmp(input, "int", strlen("int"))) {
248  byte = 10;
249  } else if (!strncmp(input, "long", strlen("long"))) {
250  byte = 11;
251  } else {
252  RZ_LOG_ERROR("[!] java_assembler: '%s' is not a valid native type (accepted: bool, char, float, double, byte, short, int, long).\n", input);
253  return false;
254  }
255 
256  *written = 2;
257  output[0] = bytecode;
258  output[1] = byte;
259  return true;
260 }
261 
262 #define NS(x) x, (sizeof(x) - 1)
263 static const JavaAsm instructions[205] = {
264  { NS("wide") /* */, BYTECODE_C4_WIDE /* */, encode_only_bcode },
265  { NS("tableswitch") /* */, BYTECODE_AA_TABLESWITCH /* */, encode_not_implemented },
266  { NS("swap") /* */, BYTECODE_5F_SWAP /* */, encode_only_bcode },
267  { NS("sipush") /* */, BYTECODE_11_SIPUSH /* */, encode_st16 },
268  { NS("sastore") /* */, BYTECODE_56_SASTORE /* */, encode_only_bcode },
269  { NS("saload") /* */, BYTECODE_35_SALOAD /* */, encode_only_bcode },
270  { NS("return") /* */, BYTECODE_B1_RETURN /* */, encode_only_bcode },
271  { NS("ret") /* */, BYTECODE_A9_RET /* */, encode_ut8 },
272  { NS("putstatic") /* */, BYTECODE_B3_PUTSTATIC /* */, encode_const_pool16 },
273  { NS("putfield") /* */, BYTECODE_B5_PUTFIELD /* */, encode_const_pool16 },
274  { NS("pop2") /* */, BYTECODE_58_POP2 /* */, encode_only_bcode },
275  { NS("pop") /* */, BYTECODE_57_POP /* */, encode_only_bcode },
276  { NS("nop") /* */, BYTECODE_00_NOP /* */, encode_only_bcode },
277  { NS("newarray") /* */, BYTECODE_BC_NEWARRAY /* */, encode_atype },
278  { NS("new") /* */, BYTECODE_BB_NEW /* */, encode_const_pool16 },
279  { NS("multianewarray") /* */, BYTECODE_C5_MULTIANEWARRAY /* */, encode_const_pool16_ut8 },
280  { NS("monitorexit") /* */, BYTECODE_C3_MONITOREXIT /* */, encode_only_bcode },
281  { NS("monitorenter") /* */, BYTECODE_C2_MONITORENTER /* */, encode_only_bcode },
282  { NS("lxor") /* */, BYTECODE_83_LXOR /* */, encode_only_bcode },
283  { NS("lushr") /* */, BYTECODE_7D_LUSHR /* */, encode_only_bcode },
284  { NS("lsub") /* */, BYTECODE_65_LSUB /* */, encode_only_bcode },
285  { NS("lstore_3") /* */, BYTECODE_42_LSTORE_3 /* */, encode_only_bcode },
286  { NS("lstore_2") /* */, BYTECODE_41_LSTORE_2 /* */, encode_only_bcode },
287  { NS("lstore_1") /* */, BYTECODE_40_LSTORE_1 /* */, encode_only_bcode },
288  { NS("lstore_0") /* */, BYTECODE_3F_LSTORE_0 /* */, encode_only_bcode },
289  { NS("lstore") /* */, BYTECODE_37_LSTORE /* */, encode_ut8 },
290  { NS("lshr") /* */, BYTECODE_7B_LSHR /* */, encode_only_bcode },
291  { NS("lshl") /* */, BYTECODE_79_LSHL /* */, encode_only_bcode },
292  { NS("lreturn") /* */, BYTECODE_AD_LRETURN /* */, encode_only_bcode },
293  { NS("lrem") /* */, BYTECODE_71_LREM /* */, encode_only_bcode },
294  { NS("lor") /* */, BYTECODE_81_LOR /* */, encode_only_bcode },
295  { NS("lookupswitch") /* */, BYTECODE_AB_LOOKUPSWITCH /* */, encode_not_implemented },
296  { NS("lneg") /* */, BYTECODE_75_LNEG /* */, encode_only_bcode },
297  { NS("lmul") /* */, BYTECODE_69_LMUL /* */, encode_only_bcode },
298  { NS("lload_3") /* */, BYTECODE_21_LLOAD_3 /* */, encode_only_bcode },
299  { NS("lload_2") /* */, BYTECODE_20_LLOAD_2 /* */, encode_only_bcode },
300  { NS("lload_1") /* */, BYTECODE_1F_LLOAD_1 /* */, encode_only_bcode },
301  { NS("lload_0") /* */, BYTECODE_1E_LLOAD_0 /* */, encode_only_bcode },
302  { NS("lload") /* */, BYTECODE_16_LLOAD /* */, encode_ut8 },
303  { NS("ldiv") /* */, BYTECODE_6D_LDIV /* */, encode_only_bcode },
304  { NS("ldc_w") /* */, BYTECODE_13_LDC_W /* */, encode_const_pool16 },
305  { NS("ldc2_w") /* */, BYTECODE_14_LDC2_W /* */, encode_const_pool16 },
306  { NS("ldc") /* */, BYTECODE_12_LDC /* */, encode_const_pool8 },
307  { NS("lconst_1") /* */, BYTECODE_0A_LCONST_1 /* */, encode_only_bcode },
308  { NS("lconst_0") /* */, BYTECODE_09_LCONST_0 /* */, encode_only_bcode },
309  { NS("lcmp") /* */, BYTECODE_94_LCMP /* */, encode_only_bcode },
310  { NS("lastore") /* */, BYTECODE_50_LASTORE /* */, encode_only_bcode },
311  { NS("land") /* */, BYTECODE_7F_LAND /* */, encode_only_bcode },
312  { NS("laload") /* */, BYTECODE_2F_LALOAD /* */, encode_only_bcode },
313  { NS("ladd") /* */, BYTECODE_61_LADD /* */, encode_only_bcode },
314  { NS("l2i") /* */, BYTECODE_88_L2I /* */, encode_only_bcode },
315  { NS("l2f") /* */, BYTECODE_89_L2F /* */, encode_only_bcode },
316  { NS("l2d") /* */, BYTECODE_8A_L2D /* */, encode_only_bcode },
317  { NS("jsr_w") /* */, BYTECODE_C9_JSR_W /* */, encode_addr32 },
318  { NS("jsr") /* */, BYTECODE_A8_JSR /* */, encode_addr16 },
319  { NS("ixor") /* */, BYTECODE_82_IXOR /* */, encode_only_bcode },
320  { NS("iushr") /* */, BYTECODE_7C_IUSHR /* */, encode_only_bcode },
321  { NS("isub") /* */, BYTECODE_64_ISUB /* */, encode_only_bcode },
322  { NS("istore_3") /* */, BYTECODE_3E_ISTORE_3 /* */, encode_only_bcode },
323  { NS("istore_2") /* */, BYTECODE_3D_ISTORE_2 /* */, encode_only_bcode },
324  { NS("istore_1") /* */, BYTECODE_3C_ISTORE_1 /* */, encode_only_bcode },
325  { NS("istore_0") /* */, BYTECODE_3B_ISTORE_0 /* */, encode_only_bcode },
326  { NS("istore") /* */, BYTECODE_36_ISTORE /* */, encode_ut8 },
327  { NS("ishr") /* */, BYTECODE_7A_ISHR /* */, encode_only_bcode },
328  { NS("ishl") /* */, BYTECODE_78_ISHL /* */, encode_only_bcode },
329  { NS("ireturn") /* */, BYTECODE_AC_IRETURN /* */, encode_only_bcode },
330  { NS("irem") /* */, BYTECODE_70_IREM /* */, encode_only_bcode },
331  { NS("ior") /* */, BYTECODE_80_IOR /* */, encode_only_bcode },
332  { NS("invokevirtual") /* */, BYTECODE_B6_INVOKEVIRTUAL /* */, encode_const_pool16 },
333  { NS("invokestatic") /* */, BYTECODE_B8_INVOKESTATIC /* */, encode_const_pool16 },
334  { NS("invokespecial") /* */, BYTECODE_B7_INVOKESPECIAL /* */, encode_const_pool16 },
335  { NS("invokeinterface") , BYTECODE_B9_INVOKEINTERFACE , encode_const_pool16_ut8 },
336  { NS("invokedynamic") /* */, BYTECODE_BA_INVOKEDYNAMIC /* */, encode_const_pool16_ut8 },
337  { NS("instanceof") /* */, BYTECODE_C1_INSTANCEOF /* */, encode_const_pool16 },
338  { NS("ineg") /* */, BYTECODE_74_INEG /* */, encode_only_bcode },
339  { NS("imul") /* */, BYTECODE_68_IMUL /* */, encode_only_bcode },
340  { NS("impdep2") /* */, BYTECODE_FF_IMPDEP2 /* */, encode_only_bcode },
341  { NS("impdep1") /* */, BYTECODE_FE_IMPDEP1 /* */, encode_only_bcode },
342  { NS("iload_3") /* */, BYTECODE_1D_ILOAD_3 /* */, encode_only_bcode },
343  { NS("iload_2") /* */, BYTECODE_1C_ILOAD_2 /* */, encode_only_bcode },
344  { NS("iload_1") /* */, BYTECODE_1B_ILOAD_1 /* */, encode_only_bcode },
345  { NS("iload_0") /* */, BYTECODE_1A_ILOAD_0 /* */, encode_only_bcode },
346  { NS("iload") /* */, BYTECODE_15_ILOAD /* */, encode_ut8 },
347  { NS("iinc") /* */, BYTECODE_84_IINC /* */, encode_ut8x2 },
348  { NS("ifnull") /* */, BYTECODE_C6_IFNULL /* */, encode_addr16 },
349  { NS("ifnonnull") /* */, BYTECODE_C7_IFNONNULL /* */, encode_addr16 },
350  { NS("ifne") /* */, BYTECODE_9A_IFNE /* */, encode_addr16 },
351  { NS("iflt") /* */, BYTECODE_9B_IFLT /* */, encode_addr16 },
352  { NS("ifle") /* */, BYTECODE_9E_IFLE /* */, encode_addr16 },
353  { NS("ifgt") /* */, BYTECODE_9D_IFGT /* */, encode_addr16 },
354  { NS("ifge") /* */, BYTECODE_9C_IFGE /* */, encode_addr16 },
355  { NS("ifeq") /* */, BYTECODE_99_IFEQ /* */, encode_addr16 },
356  { NS("if_icmpne") /* */, BYTECODE_A0_IF_ICMPNE /* */, encode_addr16 },
357  { NS("if_icmplt") /* */, BYTECODE_A1_IF_ICMPLT /* */, encode_addr16 },
358  { NS("if_icmple") /* */, BYTECODE_A4_IF_ICMPLE /* */, encode_addr16 },
359  { NS("if_icmpgt") /* */, BYTECODE_A3_IF_ICMPGT /* */, encode_addr16 },
360  { NS("if_icmpge") /* */, BYTECODE_A2_IF_ICMPGE /* */, encode_addr16 },
361  { NS("if_icmpeq") /* */, BYTECODE_9F_IF_ICMPEQ /* */, encode_addr16 },
362  { NS("if_acmpne") /* */, BYTECODE_A6_IF_ACMPNE /* */, encode_addr16 },
363  { NS("if_acmpeq") /* */, BYTECODE_A5_IF_ACMPEQ /* */, encode_addr16 },
364  { NS("idiv") /* */, BYTECODE_6C_IDIV /* */, encode_only_bcode },
365  { NS("iconst_m1") /* */, BYTECODE_02_ICONST_M1 /* */, encode_only_bcode },
366  { NS("iconst_5") /* */, BYTECODE_08_ICONST_5 /* */, encode_only_bcode },
367  { NS("iconst_4") /* */, BYTECODE_07_ICONST_4 /* */, encode_only_bcode },
368  { NS("iconst_3") /* */, BYTECODE_06_ICONST_3 /* */, encode_only_bcode },
369  { NS("iconst_2") /* */, BYTECODE_05_ICONST_2 /* */, encode_only_bcode },
370  { NS("iconst_1") /* */, BYTECODE_04_ICONST_1 /* */, encode_only_bcode },
371  { NS("iconst_0") /* */, BYTECODE_03_ICONST_0 /* */, encode_only_bcode },
372  { NS("iastore") /* */, BYTECODE_4F_IASTORE /* */, encode_only_bcode },
373  { NS("iand") /* */, BYTECODE_7E_IAND /* */, encode_only_bcode },
374  { NS("iaload") /* */, BYTECODE_2E_IALOAD /* */, encode_only_bcode },
375  { NS("iadd") /* */, BYTECODE_60_IADD /* */, encode_only_bcode },
376  { NS("i2s") /* */, BYTECODE_93_I2S /* */, encode_only_bcode },
377  { NS("i2l") /* */, BYTECODE_85_I2L /* */, encode_only_bcode },
378  { NS("i2f") /* */, BYTECODE_86_I2F /* */, encode_only_bcode },
379  { NS("i2d") /* */, BYTECODE_87_I2D /* */, encode_only_bcode },
380  { NS("i2c") /* */, BYTECODE_92_I2C /* */, encode_only_bcode },
381  { NS("i2b") /* */, BYTECODE_91_I2B /* */, encode_only_bcode },
382  { NS("goto_w") /* */, BYTECODE_C8_GOTO_W /* */, encode_addr32 },
383  { NS("goto") /* */, BYTECODE_A7_GOTO /* */, encode_addr16 },
384  { NS("getstatic") /* */, BYTECODE_B2_GETSTATIC /* */, encode_const_pool16 },
385  { NS("getfield") /* */, BYTECODE_B4_GETFIELD /* */, encode_const_pool16 },
386  { NS("fsub") /* */, BYTECODE_66_FSUB /* */, encode_only_bcode },
387  { NS("fstore_3") /* */, BYTECODE_46_FSTORE_3 /* */, encode_only_bcode },
388  { NS("fstore_2") /* */, BYTECODE_45_FSTORE_2 /* */, encode_only_bcode },
389  { NS("fstore_1") /* */, BYTECODE_44_FSTORE_1 /* */, encode_only_bcode },
390  { NS("fstore_0") /* */, BYTECODE_43_FSTORE_0 /* */, encode_only_bcode },
391  { NS("fstore") /* */, BYTECODE_38_FSTORE /* */, encode_ut8 },
392  { NS("freturn") /* */, BYTECODE_AE_FRETURN /* */, encode_only_bcode },
393  { NS("frem") /* */, BYTECODE_72_FREM /* */, encode_only_bcode },
394  { NS("fneg") /* */, BYTECODE_76_FNEG /* */, encode_only_bcode },
395  { NS("fmul") /* */, BYTECODE_6A_FMUL /* */, encode_only_bcode },
396  { NS("fload_3") /* */, BYTECODE_25_FLOAD_3 /* */, encode_only_bcode },
397  { NS("fload_2") /* */, BYTECODE_24_FLOAD_2 /* */, encode_only_bcode },
398  { NS("fload_1") /* */, BYTECODE_23_FLOAD_1 /* */, encode_only_bcode },
399  { NS("fload_0") /* */, BYTECODE_22_FLOAD_0 /* */, encode_only_bcode },
400  { NS("fload") /* */, BYTECODE_17_FLOAD /* */, encode_ut8 },
401  { NS("fdiv") /* */, BYTECODE_6E_FDIV /* */, encode_only_bcode },
402  { NS("fconst_2") /* */, BYTECODE_0D_FCONST_2 /* */, encode_only_bcode },
403  { NS("fconst_1") /* */, BYTECODE_0C_FCONST_1 /* */, encode_only_bcode },
404  { NS("fconst_0") /* */, BYTECODE_0B_FCONST_0 /* */, encode_only_bcode },
405  { NS("fcmpl") /* */, BYTECODE_95_FCMPL /* */, encode_only_bcode },
406  { NS("fcmpg") /* */, BYTECODE_96_FCMPG /* */, encode_only_bcode },
407  { NS("fastore") /* */, BYTECODE_51_FASTORE /* */, encode_only_bcode },
408  { NS("faload") /* */, BYTECODE_30_FALOAD /* */, encode_only_bcode },
409  { NS("fadd") /* */, BYTECODE_62_FADD /* */, encode_only_bcode },
410  { NS("f2l") /* */, BYTECODE_8C_F2L /* */, encode_only_bcode },
411  { NS("f2i") /* */, BYTECODE_8B_F2I /* */, encode_only_bcode },
412  { NS("f2d") /* */, BYTECODE_8D_F2D /* */, encode_only_bcode },
413  { NS("dup_x2") /* */, BYTECODE_5B_DUP_X2 /* */, encode_only_bcode },
414  { NS("dup_x1") /* */, BYTECODE_5A_DUP_X1 /* */, encode_only_bcode },
415  { NS("dup2_x2") /* */, BYTECODE_5E_DUP2_X2 /* */, encode_only_bcode },
416  { NS("dup2_x1") /* */, BYTECODE_5D_DUP2_X1 /* */, encode_only_bcode },
417  { NS("dup2") /* */, BYTECODE_5C_DUP2 /* */, encode_only_bcode },
418  { NS("dup") /* */, BYTECODE_59_DUP /* */, encode_only_bcode },
419  { NS("dsub") /* */, BYTECODE_67_DSUB /* */, encode_only_bcode },
420  { NS("dstore_3") /* */, BYTECODE_4A_DSTORE_3 /* */, encode_only_bcode },
421  { NS("dstore_2") /* */, BYTECODE_49_DSTORE_2 /* */, encode_only_bcode },
422  { NS("dstore_1") /* */, BYTECODE_48_DSTORE_1 /* */, encode_only_bcode },
423  { NS("dstore_0") /* */, BYTECODE_47_DSTORE_0 /* */, encode_only_bcode },
424  { NS("dstore") /* */, BYTECODE_39_DSTORE /* */, encode_ut8 },
425  { NS("dreturn") /* */, BYTECODE_AF_DRETURN /* */, encode_only_bcode },
426  { NS("drem") /* */, BYTECODE_73_DREM /* */, encode_only_bcode },
427  { NS("dneg") /* */, BYTECODE_77_DNEG /* */, encode_only_bcode },
428  { NS("dmul") /* */, BYTECODE_6B_DMUL /* */, encode_only_bcode },
429  { NS("dload_3") /* */, BYTECODE_29_DLOAD_3 /* */, encode_only_bcode },
430  { NS("dload_2") /* */, BYTECODE_28_DLOAD_2 /* */, encode_only_bcode },
431  { NS("dload_1") /* */, BYTECODE_27_DLOAD_1 /* */, encode_only_bcode },
432  { NS("dload_0") /* */, BYTECODE_26_DLOAD_0 /* */, encode_only_bcode },
433  { NS("dload") /* */, BYTECODE_18_DLOAD /* */, encode_ut8 },
434  { NS("ddiv") /* */, BYTECODE_6F_DDIV /* */, encode_only_bcode },
435  { NS("dconst_1") /* */, BYTECODE_0F_DCONST_1 /* */, encode_only_bcode },
436  { NS("dconst_0") /* */, BYTECODE_0E_DCONST_0 /* */, encode_only_bcode },
437  { NS("dcmpl") /* */, BYTECODE_97_DCMPL /* */, encode_only_bcode },
438  { NS("dcmpg") /* */, BYTECODE_98_DCMPG /* */, encode_only_bcode },
439  { NS("dastore") /* */, BYTECODE_52_DASTORE /* */, encode_only_bcode },
440  { NS("daload") /* */, BYTECODE_31_DALOAD /* */, encode_only_bcode },
441  { NS("dadd") /* */, BYTECODE_63_DADD /* */, encode_only_bcode },
442  { NS("d2l") /* */, BYTECODE_8F_D2L /* */, encode_only_bcode },
443  { NS("d2i") /* */, BYTECODE_8E_D2I /* */, encode_only_bcode },
444  { NS("d2f") /* */, BYTECODE_90_D2F /* */, encode_only_bcode },
445  { NS("checkcast") /* */, BYTECODE_C0_CHECKCAST /* */, encode_const_pool16 },
446  { NS("castore") /* */, BYTECODE_55_CASTORE /* */, encode_only_bcode },
447  { NS("caload") /* */, BYTECODE_34_CALOAD /* */, encode_only_bcode },
448  { NS("breakpoint") /* */, BYTECODE_CA_BREAKPOINT /* */, encode_only_bcode },
449  { NS("bipush") /* */, BYTECODE_10_BIPUSH /* */, encode_st8 },
450  { NS("bastore") /* */, BYTECODE_54_BASTORE /* */, encode_only_bcode },
451  { NS("baload") /* */, BYTECODE_33_BALOAD /* */, encode_only_bcode },
452  { NS("athrow") /* */, BYTECODE_BF_ATHROW /* */, encode_only_bcode },
453  { NS("astore_3") /* */, BYTECODE_4E_ASTORE_3 /* */, encode_only_bcode },
454  { NS("astore_2") /* */, BYTECODE_4D_ASTORE_2 /* */, encode_only_bcode },
455  { NS("astore_1") /* */, BYTECODE_4C_ASTORE_1 /* */, encode_only_bcode },
456  { NS("astore_0") /* */, BYTECODE_4B_ASTORE_0 /* */, encode_only_bcode },
457  { NS("astore") /* */, BYTECODE_3A_ASTORE /* */, encode_ut8 },
458  { NS("arraylength") /* */, BYTECODE_BE_ARRAYLENGTH /* */, encode_only_bcode },
459  { NS("areturn") /* */, BYTECODE_B0_ARETURN /* */, encode_only_bcode },
460  { NS("anewarray") /* */, BYTECODE_BD_ANEWARRAY /* */, encode_const_pool16 },
461  { NS("aload_3") /* */, BYTECODE_2D_ALOAD_3 /* */, encode_only_bcode },
462  { NS("aload_2") /* */, BYTECODE_2C_ALOAD_2 /* */, encode_only_bcode },
463  { NS("aload_1") /* */, BYTECODE_2B_ALOAD_1 /* */, encode_only_bcode },
464  { NS("aload_0") /* */, BYTECODE_2A_ALOAD_0 /* */, encode_only_bcode },
465  { NS("aload") /* */, BYTECODE_19_ALOAD /* */, encode_ut8 },
466  { NS("aconst_null") /* */, BYTECODE_01_ACONST_NULL /* */, encode_only_bcode },
467  { NS("aastore") /* */, BYTECODE_53_AASTORE /* */, encode_only_bcode },
468  { NS("aaload") /* */, BYTECODE_32_AALOAD /* */, encode_only_bcode }
469 };
470 #undef NS
471 
472 bool java_assembler(const char *input, st32 input_size, ut8 *output, st32 output_size, ut64 pc, st32 *written) {
473  rz_return_val_if_fail(input && output && input_size > 0 && output_size > 0, false);
474 
475  for (ut32 i = 0; i < RZ_ARRAY_SIZE(instructions); ++i) {
476  if (input_size < instructions[i].length) {
477  continue;
478  }
480  const char *p = rz_str_trim_head_ro(input + instructions[i].length);
481  st32 used = p ? (p - input) : input_size;
482  return instructions[i].encode(instructions[i].bytecode, p, input_size - used, output, output_size, pc, written);
483  }
484  }
485 
486  RZ_LOG_ERROR("[!] java_assembler: invalid assembly.\n");
487  return false;
488 }
lzma_index ** i
Definition: index.h:629
#define BYTECODE_C7_IFNONNULL
Definition: bytecode.h:207
#define BYTECODE_9A_IFNE
Definition: bytecode.h:162
#define BYTECODE_C8_GOTO_W
Definition: bytecode.h:208
#define BYTECODE_33_BALOAD
Definition: bytecode.h:59
#define BYTECODE_C3_MONITOREXIT
Definition: bytecode.h:203
#define BYTECODE_35_SALOAD
Definition: bytecode.h:61
#define BYTECODE_36_ISTORE
Definition: bytecode.h:62
#define BYTECODE_69_LMUL
Definition: bytecode.h:113
#define BYTECODE_76_FNEG
Definition: bytecode.h:126
#define BYTECODE_3E_ISTORE_3
Definition: bytecode.h:70
#define BYTECODE_17_FLOAD
Definition: bytecode.h:31
#define BYTECODE_BF_ATHROW
Definition: bytecode.h:199
#define BYTECODE_FE_IMPDEP1
Definition: bytecode.h:211
#define BYTECODE_78_ISHL
Definition: bytecode.h:128
#define BYTECODE_31_DALOAD
Definition: bytecode.h:57
#define BYTECODE_56_SASTORE
Definition: bytecode.h:94
#define BYTECODE_53_AASTORE
Definition: bytecode.h:91
#define BYTECODE_8C_F2L
Definition: bytecode.h:148
#define BYTECODE_09_LCONST_0
Definition: bytecode.h:17
#define BYTECODE_86_I2F
Definition: bytecode.h:142
#define BYTECODE_00_NOP
Definition: bytecode.h:8
#define BYTECODE_1C_ILOAD_2
Definition: bytecode.h:36
#define BYTECODE_90_D2F
Definition: bytecode.h:152
#define BYTECODE_85_I2L
Definition: bytecode.h:141
#define BYTECODE_66_FSUB
Definition: bytecode.h:110
#define BYTECODE_BB_NEW
Definition: bytecode.h:195
#define BYTECODE_73_DREM
Definition: bytecode.h:123
#define BYTECODE_A3_IF_ICMPGT
Definition: bytecode.h:171
#define BYTECODE_98_DCMPG
Definition: bytecode.h:160
#define BYTECODE_C5_MULTIANEWARRAY
Definition: bytecode.h:205
#define BYTECODE_5A_DUP_X1
Definition: bytecode.h:98
#define BYTECODE_A0_IF_ICMPNE
Definition: bytecode.h:168
#define BYTECODE_3B_ISTORE_0
Definition: bytecode.h:67
#define BYTECODE_93_I2S
Definition: bytecode.h:155
#define BYTECODE_6D_LDIV
Definition: bytecode.h:117
#define BYTECODE_06_ICONST_3
Definition: bytecode.h:14
#define BYTECODE_B9_INVOKEINTERFACE
Definition: bytecode.h:193
#define BYTECODE_45_FSTORE_2
Definition: bytecode.h:77
#define BYTECODE_B0_ARETURN
Definition: bytecode.h:184
#define BYTECODE_08_ICONST_5
Definition: bytecode.h:16
#define BYTECODE_70_IREM
Definition: bytecode.h:120
#define BYTECODE_82_IXOR
Definition: bytecode.h:138
#define BYTECODE_68_IMUL
Definition: bytecode.h:112
#define BYTECODE_19_ALOAD
Definition: bytecode.h:33
#define BYTECODE_07_ICONST_4
Definition: bytecode.h:15
#define BYTECODE_40_LSTORE_1
Definition: bytecode.h:72
#define BYTECODE_C6_IFNULL
Definition: bytecode.h:206
#define BYTECODE_3D_ISTORE_2
Definition: bytecode.h:69
#define BYTECODE_51_FASTORE
Definition: bytecode.h:89
#define BYTECODE_38_FSTORE
Definition: bytecode.h:64
#define BYTECODE_10_BIPUSH
Definition: bytecode.h:24
#define BYTECODE_72_FREM
Definition: bytecode.h:122
#define BYTECODE_4A_DSTORE_3
Definition: bytecode.h:82
#define BYTECODE_6C_IDIV
Definition: bytecode.h:116
#define BYTECODE_AE_FRETURN
Definition: bytecode.h:182
#define BYTECODE_25_FLOAD_3
Definition: bytecode.h:45
#define BYTECODE_89_L2F
Definition: bytecode.h:145
#define BYTECODE_50_LASTORE
Definition: bytecode.h:88
#define BYTECODE_8D_F2D
Definition: bytecode.h:149
#define BYTECODE_8A_L2D
Definition: bytecode.h:146
#define BYTECODE_3F_LSTORE_0
Definition: bytecode.h:71
#define BYTECODE_97_DCMPL
Definition: bytecode.h:159
#define BYTECODE_4F_IASTORE
Definition: bytecode.h:87
#define BYTECODE_29_DLOAD_3
Definition: bytecode.h:49
#define BYTECODE_A2_IF_ICMPGE
Definition: bytecode.h:170
#define BYTECODE_5B_DUP_X2
Definition: bytecode.h:99
#define BYTECODE_11_SIPUSH
Definition: bytecode.h:25
#define BYTECODE_B2_GETSTATIC
Definition: bytecode.h:186
#define BYTECODE_7D_LUSHR
Definition: bytecode.h:133
#define BYTECODE_26_DLOAD_0
Definition: bytecode.h:46
#define BYTECODE_59_DUP
Definition: bytecode.h:97
#define BYTECODE_94_LCMP
Definition: bytecode.h:156
#define BYTECODE_28_DLOAD_2
Definition: bytecode.h:48
#define BYTECODE_7E_IAND
Definition: bytecode.h:134
#define BYTECODE_B8_INVOKESTATIC
Definition: bytecode.h:192
#define BYTECODE_CA_BREAKPOINT
Definition: bytecode.h:210
#define BYTECODE_02_ICONST_M1
Definition: bytecode.h:10
#define BYTECODE_4B_ASTORE_0
Definition: bytecode.h:83
#define BYTECODE_42_LSTORE_3
Definition: bytecode.h:74
#define BYTECODE_44_FSTORE_1
Definition: bytecode.h:76
#define BYTECODE_BE_ARRAYLENGTH
Definition: bytecode.h:198
#define BYTECODE_4C_ASTORE_1
Definition: bytecode.h:84
#define BYTECODE_AC_IRETURN
Definition: bytecode.h:180
#define BYTECODE_92_I2C
Definition: bytecode.h:154
#define BYTECODE_0A_LCONST_1
Definition: bytecode.h:18
#define BYTECODE_83_LXOR
Definition: bytecode.h:139
#define BYTECODE_B4_GETFIELD
Definition: bytecode.h:188
#define BYTECODE_AF_DRETURN
Definition: bytecode.h:183
#define BYTECODE_AA_TABLESWITCH
Definition: bytecode.h:178
#define BYTECODE_BC_NEWARRAY
Definition: bytecode.h:196
#define BYTECODE_AD_LRETURN
Definition: bytecode.h:181
#define BYTECODE_24_FLOAD_2
Definition: bytecode.h:44
#define BYTECODE_46_FSTORE_3
Definition: bytecode.h:78
#define BYTECODE_12_LDC
Definition: bytecode.h:26
#define BYTECODE_8E_D2I
Definition: bytecode.h:150
#define BYTECODE_1D_ILOAD_3
Definition: bytecode.h:37
#define BYTECODE_52_DASTORE
Definition: bytecode.h:90
#define BYTECODE_04_ICONST_1
Definition: bytecode.h:12
#define BYTECODE_61_LADD
Definition: bytecode.h:105
#define BYTECODE_96_FCMPG
Definition: bytecode.h:158
#define BYTECODE_80_IOR
Definition: bytecode.h:136
#define BYTECODE_74_INEG
Definition: bytecode.h:124
#define BYTECODE_C1_INSTANCEOF
Definition: bytecode.h:201
#define BYTECODE_6F_DDIV
Definition: bytecode.h:119
#define BYTECODE_63_DADD
Definition: bytecode.h:107
#define BYTECODE_0B_FCONST_0
Definition: bytecode.h:19
#define BYTECODE_87_I2D
Definition: bytecode.h:143
#define BYTECODE_6B_DMUL
Definition: bytecode.h:115
#define BYTECODE_0E_DCONST_0
Definition: bytecode.h:22
#define BYTECODE_A7_GOTO
Definition: bytecode.h:175
#define BYTECODE_03_ICONST_0
Definition: bytecode.h:11
#define BYTECODE_2A_ALOAD_0
Definition: bytecode.h:50
#define BYTECODE_43_FSTORE_0
Definition: bytecode.h:75
#define BYTECODE_13_LDC_W
Definition: bytecode.h:27
#define BYTECODE_7A_ISHR
Definition: bytecode.h:130
#define BYTECODE_71_LREM
Definition: bytecode.h:121
#define BYTECODE_9E_IFLE
Definition: bytecode.h:166
#define BYTECODE_99_IFEQ
Definition: bytecode.h:161
#define BYTECODE_C4_WIDE
Definition: bytecode.h:204
#define BYTECODE_6E_FDIV
Definition: bytecode.h:118
#define BYTECODE_B7_INVOKESPECIAL
Definition: bytecode.h:191
#define BYTECODE_C9_JSR_W
Definition: bytecode.h:209
#define BYTECODE_30_FALOAD
Definition: bytecode.h:56
#define BYTECODE_1A_ILOAD_0
Definition: bytecode.h:34
#define BYTECODE_27_DLOAD_1
Definition: bytecode.h:47
#define BYTECODE_5C_DUP2
Definition: bytecode.h:100
#define BYTECODE_4D_ASTORE_2
Definition: bytecode.h:85
#define BYTECODE_79_LSHL
Definition: bytecode.h:129
#define BYTECODE_22_FLOAD_0
Definition: bytecode.h:42
#define BYTECODE_32_AALOAD
Definition: bytecode.h:58
#define BYTECODE_84_IINC
Definition: bytecode.h:140
#define BYTECODE_8F_D2L
Definition: bytecode.h:151
#define BYTECODE_A6_IF_ACMPNE
Definition: bytecode.h:174
#define BYTECODE_9B_IFLT
Definition: bytecode.h:163
#define BYTECODE_9D_IFGT
Definition: bytecode.h:165
#define BYTECODE_FF_IMPDEP2
Definition: bytecode.h:212
#define BYTECODE_5E_DUP2_X2
Definition: bytecode.h:102
#define BYTECODE_2F_LALOAD
Definition: bytecode.h:55
#define BYTECODE_49_DSTORE_2
Definition: bytecode.h:81
#define BYTECODE_58_POP2
Definition: bytecode.h:96
#define BYTECODE_81_LOR
Definition: bytecode.h:137
#define BYTECODE_0F_DCONST_1
Definition: bytecode.h:23
#define BYTECODE_21_LLOAD_3
Definition: bytecode.h:41
#define BYTECODE_77_DNEG
Definition: bytecode.h:127
#define BYTECODE_62_FADD
Definition: bytecode.h:106
#define BYTECODE_9F_IF_ICMPEQ
Definition: bytecode.h:167
#define BYTECODE_54_BASTORE
Definition: bytecode.h:92
#define BYTECODE_AB_LOOKUPSWITCH
Definition: bytecode.h:179
#define BYTECODE_1E_LLOAD_0
Definition: bytecode.h:38
#define BYTECODE_6A_FMUL
Definition: bytecode.h:114
#define BYTECODE_88_L2I
Definition: bytecode.h:144
#define BYTECODE_05_ICONST_2
Definition: bytecode.h:13
#define BYTECODE_2C_ALOAD_2
Definition: bytecode.h:52
#define BYTECODE_15_ILOAD
Definition: bytecode.h:29
#define BYTECODE_BA_INVOKEDYNAMIC
Definition: bytecode.h:194
#define BYTECODE_47_DSTORE_0
Definition: bytecode.h:79
#define BYTECODE_7C_IUSHR
Definition: bytecode.h:132
#define BYTECODE_39_DSTORE
Definition: bytecode.h:65
#define BYTECODE_01_ACONST_NULL
Definition: bytecode.h:9
#define BYTECODE_B3_PUTSTATIC
Definition: bytecode.h:187
#define BYTECODE_A4_IF_ICMPLE
Definition: bytecode.h:172
#define BYTECODE_1B_ILOAD_1
Definition: bytecode.h:35
#define BYTECODE_B5_PUTFIELD
Definition: bytecode.h:189
#define BYTECODE_A1_IF_ICMPLT
Definition: bytecode.h:169
#define BYTECODE_0C_FCONST_1
Definition: bytecode.h:20
#define BYTECODE_4E_ASTORE_3
Definition: bytecode.h:86
#define BYTECODE_57_POP
Definition: bytecode.h:95
#define BYTECODE_20_LLOAD_2
Definition: bytecode.h:40
#define BYTECODE_A8_JSR
Definition: bytecode.h:176
#define BYTECODE_7F_LAND
Definition: bytecode.h:135
#define BYTECODE_1F_LLOAD_1
Definition: bytecode.h:39
#define BYTECODE_48_DSTORE_1
Definition: bytecode.h:80
#define BYTECODE_23_FLOAD_1
Definition: bytecode.h:43
#define BYTECODE_0D_FCONST_2
Definition: bytecode.h:21
#define BYTECODE_5D_DUP2_X1
Definition: bytecode.h:101
#define BYTECODE_3A_ASTORE
Definition: bytecode.h:66
#define BYTECODE_C0_CHECKCAST
Definition: bytecode.h:200
#define BYTECODE_41_LSTORE_2
Definition: bytecode.h:73
#define BYTECODE_95_FCMPL
Definition: bytecode.h:157
#define BYTECODE_B1_RETURN
Definition: bytecode.h:185
#define BYTECODE_18_DLOAD
Definition: bytecode.h:32
#define BYTECODE_3C_ISTORE_1
Definition: bytecode.h:68
#define BYTECODE_7B_LSHR
Definition: bytecode.h:131
#define BYTECODE_A9_RET
Definition: bytecode.h:177
#define BYTECODE_2D_ALOAD_3
Definition: bytecode.h:53
#define BYTECODE_8B_F2I
Definition: bytecode.h:147
#define BYTECODE_60_IADD
Definition: bytecode.h:104
#define BYTECODE_BD_ANEWARRAY
Definition: bytecode.h:197
#define BYTECODE_14_LDC2_W
Definition: bytecode.h:28
#define BYTECODE_67_DSUB
Definition: bytecode.h:111
#define BYTECODE_91_I2B
Definition: bytecode.h:153
#define BYTECODE_5F_SWAP
Definition: bytecode.h:103
#define BYTECODE_34_CALOAD
Definition: bytecode.h:60
#define BYTECODE_2B_ALOAD_1
Definition: bytecode.h:51
#define BYTECODE_75_LNEG
Definition: bytecode.h:125
#define BYTECODE_9C_IFGE
Definition: bytecode.h:164
#define BYTECODE_37_LSTORE
Definition: bytecode.h:63
#define BYTECODE_A5_IF_ACMPEQ
Definition: bytecode.h:173
#define BYTECODE_16_LLOAD
Definition: bytecode.h:30
#define BYTECODE_55_CASTORE
Definition: bytecode.h:93
#define BYTECODE_C2_MONITORENTER
Definition: bytecode.h:202
#define BYTECODE_64_ISUB
Definition: bytecode.h:108
#define BYTECODE_65_LSUB
Definition: bytecode.h:109
#define BYTECODE_B6_INVOKEVIRTUAL
Definition: bytecode.h:190
#define BYTECODE_2E_IALOAD
Definition: bytecode.h:54
#define JAVA_ASM_CONSTANT_POOL_STR
Definition: const.h:7
#define NULL
Definition: cris-opc.c:27
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len static semflg const void static shmflg const struct timespec struct timespec static rem const char static group const void length
Definition: sflib.h:133
#define ut8
Definition: dcpu16.h:8
uint16_t ut16
uint32_t ut32
static bool encode_ut8x2(ut8 bytecode, const char *input, st32 input_size, ut8 *output, st32 output_size, ut64 pc, st32 *written)
Definition: assembler.c:200
static bool encode_addr16(ut8 bytecode, const char *input, st32 input_size, ut8 *output, st32 output_size, ut64 pc, st32 *written)
Definition: assembler.c:92
static bool encode_not_implemented(ut8 bytecode, const char *input, st32 input_size, ut8 *output, st32 output_size, ut64 pc, st32 *written)
Definition: assembler.c:32
static bool encode_const_pool16(ut8 bytecode, const char *input, st32 input_size, ut8 *output, st32 output_size, ut64 pc, st32 *written)
Definition: assembler.c:145
#define NS(x)
Definition: assembler.c:262
#define return_error_if_empty_input(a, b)
Definition: assembler.c:15
static bool encode_addr32(ut8 bytecode, const char *input, st32 input_size, ut8 *output, st32 output_size, ut64 pc, st32 *written)
Definition: assembler.c:75
static bool encode_const_pool16_ut8(ut8 bytecode, const char *input, st32 input_size, ut8 *output, st32 output_size, ut64 pc, st32 *written)
Definition: assembler.c:166
static bool encode_ut8(ut8 bytecode, const char *input, st32 input_size, ut8 *output, st32 output_size, ut64 pc, st32 *written)
Definition: assembler.c:60
bool java_assembler(const char *input, st32 input_size, ut8 *output, st32 output_size, ut64 pc, st32 *written)
Definition: assembler.c:472
bool(* AsmEncoder)(ut8 bytecode, const char *input, st32 input_size, ut8 *output, st32 output_size, ut64 pc, st32 *written)
Definition: assembler.c:23
static bool encode_st16(ut8 bytecode, const char *input, st32 input_size, ut8 *output, st32 output_size, ut64 pc, st32 *written)
Definition: assembler.c:109
static bool encode_const_pool8(ut8 bytecode, const char *input, st32 input_size, ut8 *output, st32 output_size, ut64 pc, st32 *written)
Definition: assembler.c:125
static bool encode_st8(ut8 bytecode, const char *input, st32 input_size, ut8 *output, st32 output_size, ut64 pc, st32 *written)
Definition: assembler.c:45
struct _jasm JavaAsm
static const JavaAsm instructions[205]
Definition: assembler.c:263
#define return_error_if_size_lt(a, b)
Definition: assembler.c:7
static bool encode_only_bcode(ut8 bytecode, const char *input, st32 input_size, ut8 *output, st32 output_size, ut64 pc, st32 *written)
Definition: assembler.c:37
static bool encode_atype(ut8 bytecode, const char *input, st32 input_size, ut8 *output, st32 output_size, ut64 pc, st32 *written)
Definition: assembler.c:229
uint8_t ut8
Definition: lh5801.h:11
void * p
Definition: libc.cpp:67
static static fork const void static count static fd const char const char static newpath char char char static envp time_t static t const char static mode static whence const char static dir time_t static t unsigned static seconds const char struct utimbuf static buf static inc static sig const char static mode static oldfd struct tms static buf static getgid static geteuid const char static filename static arg static mask struct ustat static ubuf static getppid static setsid static egid sigset_t static set struct timeval struct timezone static tz fd_set fd_set fd_set struct timeval static timeout const char char static bufsiz const char static swapflags void static offset const char static length static mode static who const char struct statfs static buf unsigned unsigned num
Definition: sflib.h:126
int n
Definition: mipsasm.c:19
#define rz_return_val_if_fail(expr, val)
Definition: rz_assert.h:108
static void rz_write_be16(void *dest, ut16 val)
Definition: rz_endian.h:60
static void rz_write_be32(void *dest, ut32 val)
Definition: rz_endian.h:98
#define RZ_LOG_ERROR(fmtstr,...)
Definition: rz_log.h:58
RZ_API bool rz_is_valid_input_num_value(RzNum *num, const char *input_value)
Definition: unum.c:735
RZ_API const char * rz_str_trim_head_ro(const char *str)
Definition: str_trim.c:86
RZ_API int rz_str_ncasecmp(const char *dst, const char *orig, size_t n)
Definition: str.c:129
#define RZ_ARRAY_SIZE(x)
Definition: rz_types.h:300
#define st8
Definition: rz_types_base.h:16
#define st64
Definition: rz_types_base.h:10
#define st16
Definition: rz_types_base.h:14
#define st32
Definition: rz_types_base.h:12
#define UINT16_MAX
#define INT8_MIN
#define INT8_MAX
#define INT16_MAX
#define INT16_MIN
#define UINT8_MAX
st32 length
Definition: assembler.c:27
AsmEncoder encode
Definition: assembler.c:29
const char * opcode
Definition: assembler.c:26
ut8 bytecode
Definition: assembler.c:28
#define bool
Definition: sysdefs.h:146
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
static int addr
Definition: z80asm.c:58
static bool input(void *ud, zip_uint8_t *data, zip_uint64_t length)
diff_output_t output
Definition: zipcmp.c:237