Rizin
unix-like reverse engineering framework and cli tools
asm_dalvik.c File Reference
#include <stdio.h>
#include <string.h>
#include <rz_types.h>
#include <rz_lib.h>
#include <rz_asm.h>
#include <dalvik/opcode.h>

Go to the source code of this file.

Functions

static int dalvik_disassemble (RzAsm *a, RzAsmOp *op, const ut8 *buf, int len)
 
static int dalvik_assemble (RzAsm *a, RzAsmOp *op, const char *buf)
 

Variables

RzAsmPlugin rz_asm_plugin_dalvik
 
RZ_API RzLibStruct rizin_plugin
 

Function Documentation

◆ dalvik_assemble()

static int dalvik_assemble ( RzAsm a,
RzAsmOp op,
const char *  buf 
)
static

Definition at line 531 of file asm_dalvik.c.

531  {
532  int i;
533  char *p = strchr(buf, ' ');
534  if (p) {
535  *p = 0;
536  }
537  // TODO: use a hashtable here
538  for (i = 0; i < 256; i++) {
539  if (!strcmp(dalvik_opcodes[i].name, buf)) {
540  ut8 buf[4];
541  rz_write_ble32(buf, i, a->big_endian);
542  rz_strbuf_setbin(&op->buf, buf, sizeof(buf));
543  op->size = dalvik_opcodes[i].len;
544  return op->size;
545  }
546  }
547  return 0;
548 }
lzma_index ** i
Definition: index.h:629
static const struct dalvik_opcodes_t dalvik_opcodes[256]
Definition: opcode.h:52
voidpf void * buf
Definition: ioapi.h:138
uint8_t ut8
Definition: lh5801.h:11
void * p
Definition: libc.cpp:67
static void rz_write_ble32(void *dest, ut32 val, bool big_endian)
Definition: rz_endian.h:540
RZ_API bool rz_strbuf_setbin(RzStrBuf *sb, const ut8 *s, size_t len)
Definition: strbuf.c:85
#define a(i)
Definition: sha256.c:41
Definition: z80asm.h:102
Definition: dis.c:32

References a, dalvik_opcodes, i, dalvik_opcodes_t::len, p, rz_strbuf_setbin(), and rz_write_ble32().

◆ dalvik_disassemble()

static int dalvik_disassemble ( RzAsm a,
RzAsmOp op,
const ut8 buf,
int  len 
)
static

Definition at line 15 of file asm_dalvik.c.

15  {
16  rz_return_val_if_fail(a && op && buf && len > 0, -1);
17 
18  int vA, vB, vC, vD, vE, vF, vG, vH, payload = 0, i = (int)buf[0];
19  int size = dalvik_opcodes[i].len;
20  char str[1024], *strasm = NULL;
21  ut64 offset = 0;
22  char *flag_str = NULL;
23  a->dataalign = 2;
24 
25  const char *buf_asm = NULL;
26  if (buf[0] == 0x00) { /* nop */
27  if (len < 2) {
28  return -1;
29  }
30  switch (buf[1]) {
31  case 0x01: /* packed-switch-payload */
32  // ushort size
33  // int first_key
34  // int[size] = relative offsets
35  {
36  ut16 array_size = buf[2] | (buf[3] << 8);
37  int first_key = buf[4] | (buf[5] << 8) | (buf[6] << 16) | (buf[7] << 24);
38  buf_asm = sdb_fmt("packed-switch-payload %d, %d", array_size, first_key);
39  size = 8;
40  payload = 2 * (array_size * 2);
41  len = 0;
42  }
43  break;
44  case 0x02: /* sparse-switch-payload */
45  // ushort size
46  // int[size] keys
47  // int[size] relative offsets
48  {
49  ut16 array_size = buf[2] | (buf[3] << 8);
50  buf_asm = sdb_fmt("sparse-switch-payload %d", array_size);
51  size = 4;
52  payload = 2 * (array_size * 4);
53  len = 0;
54  }
55  break;
56  case 0x03: /* fill-array-data-payload */
57  // element_width = 2 bytes ushort little endian
58  // size = 4 bytes uint
59  // ([size*element_width+1)/2)+4
60  if (len > 7) {
61  ut16 elem_width = buf[2] | (buf[3] << 8);
62  ut32 array_size = buf[4] | (buf[5] << 8) | (buf[6] << 16) | (buf[7] << 24);
63  buf_asm = sdb_fmt("fill-array-data-payload %d, %d", elem_width, array_size);
64  payload = array_size * elem_width;
65  }
66  size = 8;
67  len = 0;
68  break;
69  default:
70  /* nop */
71  break;
72  }
73  }
74  if (buf_asm) {
75  rz_strbuf_set(&op->buf_asm, buf_asm);
76  }
77  strasm = NULL;
78  if (size <= len) {
79  strasm = strdup(dalvik_opcodes[i].name);
81  switch (dalvik_opcodes[i].fmt) {
82  case fmtop: break;
83  case fmtopvAvB:
84  vA = buf[1] & 0x0f;
85  vB = (buf[1] & 0xf0) >> 4;
86  rz_strf(str, " v%i, v%i", vA, vB);
87  strasm = rz_str_append(strasm, str);
88  break;
89  case fmtopvAAvBBBB:
90  vA = (int)buf[1];
91  vB = (buf[3] << 8) | buf[2];
92  rz_strf(str, " v%i, v%i", vA, vB);
93  strasm = rz_str_append(strasm, str);
94  break;
95  case fmtopvAAAAvBBBB: // buf[1] seems useless :/
96  vA = (buf[3] << 8) | buf[2];
97  vB = (buf[5] << 8) | buf[4];
98  rz_strf(str, " v%i, v%i", vA, vB);
99  strasm = rz_str_append(strasm, str);
100  break;
101  case fmtopvAA:
102  vA = (int)buf[1];
103  rz_strf(str, " v%i", vA);
104  strasm = rz_str_append(strasm, str);
105  break;
106  case fmtopvAcB:
107  vA = buf[1] & 0x0f;
108  vB = (buf[1] & 0xf0) >> 4;
109  rz_strf(str, " v%i, %#x", vA, vB);
110  strasm = rz_str_append(strasm, str);
111  break;
112  case fmtopvAAcBBBB:
113  vA = (int)buf[1];
114  {
115  short sB = (buf[3] << 8) | buf[2];
116  rz_strf(str, " v%i, %#04hx", vA, sB);
117  strasm = rz_str_append(strasm, str);
118  }
119  break;
120  case fmtopvAAcBBBBBBBB:
121  vA = (int)buf[1];
122  vB = buf[2] | (buf[3] << 8) | (buf[4] << 16) | (buf[5] << 24);
123  if (buf[0] == 0x17) { // const-wide/32
124  rz_strf(str, " v%i:v%i, 0x%08x", vA, vA + 1, vB);
125  } else { // const
126  rz_strf(str, " v%i, 0x%08x", vA, vB);
127  }
128  strasm = rz_str_append(strasm, str);
129  break;
130  case fmtopvAAcBBBB0000:
131  vA = (int)buf[1];
132  // vB = 0|(buf[3]<<16)|(buf[2]<<24);
133  vB = 0 | (buf[2] << 16) | (buf[3] << 24);
134  if (buf[0] == 0x19) { // const-wide/high16
135  rz_strf(str, " v%i:v%i, 0x%08x", vA, vA + 1, vB);
136  } else {
137  rz_strf(str, " v%i, 0x%08x", vA, vB);
138  }
139  strasm = rz_str_append(strasm, str);
140  break;
142  vA = (int)buf[1];
143  ut64 lB = (ut64)buf[2] | ((ut64)buf[3] << 8) |
144  ((ut64)buf[4] << 16) | ((ut64)buf[5] << 24) |
145  ((ut64)buf[6] << 32) | ((ut64)buf[7] << 40) |
146  ((ut64)(buf[8] & 0xff) << 48) | ((ut64)(buf[9] & 0xff) << 56);
147  rz_strf(str, " v%i:v%i, 0x%" PFMT64x, vA, vA + 1, lB);
148  strasm = rz_str_append(strasm, str);
149  break;
150  case fmtopvAAvBBvCC:
151  vA = (int)buf[1];
152  vB = (int)buf[2];
153  vC = (int)buf[3];
154  rz_strf(str, " v%i, v%i, v%i", vA, vB, vC);
155  strasm = rz_str_append(strasm, str);
156  break;
157  case fmtopvAAvBBcCC:
158  vA = (int)buf[1];
159  vB = (int)buf[2];
160  vC = (int)buf[3];
161  rz_strf(str, " v%i, v%i, %#x", vA, vB, vC);
162  strasm = rz_str_append(strasm, str);
163  break;
164  case fmtopvAvBcCCCC:
165  vA = buf[1] & 0x0f;
166  vB = (buf[1] & 0xf0) >> 4;
167  vC = (buf[3] << 8) | buf[2];
168  rz_strf(str, " v%i, v%i, %#x", vA, vB, vC);
169  strasm = rz_str_append(strasm, str);
170  break;
171  case fmtoppAA:
172  vA = (signed char)buf[1];
173  // snprintf (str, sizeof (str), " %i", vA*2); // vA : word -> byte
174  rz_strf(str, " 0x%08" PFMT64x, a->pc + (vA * 2)); // vA : word -> byte
175  strasm = rz_str_append(strasm, str);
176  break;
177  case fmtoppAAAA:
178  vA = (short)(buf[3] << 8 | buf[2]);
179  rz_strf(str, " 0x%08" PFMT64x, a->pc + (vA * 2)); // vA : word -> byte
180  strasm = rz_str_append(strasm, str);
181  break;
182  case fmtopvAApBBBB: // if-*z
183  vA = (int)buf[1];
184  vB = (int)(buf[3] << 8 | buf[2]);
185  // snprintf (str, sizeof (str), " v%i, %i", vA, vB);
186  rz_strf(str, " v%i, 0x%08" PFMT64x, vA, a->pc + (vB * 2));
187  strasm = rz_str_append(strasm, str);
188  break;
189  case fmtoppAAAAAAAA:
190  vA = (int)(buf[2] | (buf[3] << 8) | (buf[4] << 16) | (buf[5] << 24));
191  // snprintf (str, sizeof (str), " %#08x", vA*2); // vA: word -> byte
192  rz_strf(str, " 0x%08" PFMT64x, a->pc + (vA * 2)); // vA : word -> byte
193  strasm = rz_str_append(strasm, str);
194  break;
195  case fmtopvAvBpCCCC: // if-*
196  vA = buf[1] & 0x0f;
197  vB = (buf[1] & 0xf0) >> 4;
198  vC = (int)(buf[3] << 8 | buf[2]);
199  // snprintf (str, sizeof (str), " v%i, v%i, %i", vA, vB, vC);
200  rz_strf(str, " v%i, v%i, 0x%08" PFMT64x, vA, vB, a->pc + (vC * 2));
201  strasm = rz_str_append(strasm, str);
202  break;
203  case fmtopvAApBBBBBBBB:
204  vA = (int)buf[1];
205  vB = (short)(buf[2] | (buf[3] << 8) | (buf[4] << 16) | (buf[5] << 24));
206  rz_strf(str, " v%i, 0x%08" PFMT64x, vA, a->pc + (vB * 2) + 8);
207  strasm = rz_str_append(strasm, str);
208  break;
209  case fmtoptinlineI:
210  vA = (int)(buf[1] & 0x0f);
211  vB = (buf[3] << 8) | buf[2];
212  *str = 0;
213  switch (vA) {
214  case 1:
215  rz_strf(str, " {v%i}", buf[4] & 0x0f);
216  break;
217  case 2:
218  rz_strf(str, " {v%i, v%i}", buf[4] & 0x0f, (buf[4] & 0xf0) >> 4);
219  break;
220  case 3:
221  rz_strf(str, " {v%i, v%i, v%i}", buf[4] & 0x0f, (buf[4] & 0xf0) >> 4, buf[5] & 0x0f);
222  break;
223  case 4:
224  rz_strf(str, " {v%i, v%i, v%i, v%i}", buf[4] & 0x0f,
225  (buf[4] & 0xf0) >> 4, buf[5] & 0x0f, (buf[5] & 0xf0) >> 4);
226  break;
227  default:
228  rz_strf(str, " {}");
229  }
230  strasm = rz_str_append(strasm, str);
231  rz_strf(str, ", [%04x]", vB);
232  strasm = rz_str_append(strasm, str);
233  break;
234  case fmtoptinlineIR:
235  case fmtoptinvokeVSR:
236  vA = (int)buf[1];
237  vB = (buf[3] << 8) | buf[2];
238  vC = (buf[5] << 8) | buf[4];
239  rz_strf(str, " {v%i..v%i}, [%04x]", vC, vC + vA - 1, vB);
240  strasm = rz_str_append(strasm, str);
241  break;
242  case fmtoptinvokeVS:
243  vA = (int)(buf[1] & 0xf0) >> 4;
244  vB = (buf[3] << 8) | buf[2];
245  switch (vA) {
246  case 1:
247  rz_strf(str, " {v%i}", buf[4] & 0x0f);
248  break;
249  case 2:
250  rz_strf(str, " {v%i, v%i}", buf[4] & 0x0f, (buf[4] & 0xf0) >> 4);
251  break;
252  case 3:
253  rz_strf(str, " {v%i, v%i, v%i}", buf[4] & 0x0f,
254  (buf[4] & 0xf0) >> 4, buf[5] & 0x0f);
255  break;
256  case 4:
257  rz_strf(str, " {v%i, v%i, v%i, v%i}", buf[4] & 0x0f,
258  (buf[4] & 0xf0) >> 4, buf[5] & 0x0f, (buf[5] & 0xf0) >> 4);
259  break;
260  default:
261  rz_strf(str, " {}");
262  break;
263  }
264  strasm = rz_str_append(strasm, str);
265  rz_strf(str, ", [%04x]", vB);
266  strasm = rz_str_append(strasm, str);
267  break;
268  case fmtopvAAtBBBB: // "sput-*"
269  vA = (int)buf[1];
270  vB = (buf[3] << 8) | buf[2];
271  if (buf[0] == 0x1a) {
272  offset = RZ_ASM_GET_OFFSET(a, 's', vB);
273  if (offset == UT64_MAX) {
274  rz_strf(str, " v%i, string+%i", vA, vB);
275  } else {
276  rz_strf(str, " v%i, 0x%" PFMT64x, vA, offset);
277  }
278  } else if (buf[0] == 0x1c || buf[0] == 0x1f || buf[0] == 0x22) {
279  flag_str = RZ_ASM_GET_NAME(a, 'c', vB);
280  if (!flag_str) {
281  rz_strf(str, " v%i, class+%i", vA, vB);
282  } else {
283  rz_strf(str, " v%i, %s", vA, flag_str);
284  }
285  } else {
286  flag_str = RZ_ASM_GET_NAME(a, 'f', vB);
287  if (!flag_str) {
288  rz_strf(str, " v%i, field+%i", vA, vB);
289  } else {
290  rz_strf(str, " v%i, %s", vA, flag_str);
291  }
292  }
293  strasm = rz_str_append(strasm, str);
294  break;
295  case fmtoptopvAvBoCCCC:
296  vA = (buf[1] & 0x0f);
297  vB = (buf[1] & 0xf0) >> 4;
298  vC = (buf[3] << 8) | buf[2];
299  offset = RZ_ASM_GET_OFFSET(a, 'o', vC);
300  if (offset == UT64_MAX) {
301  rz_strf(str, " v%i, v%i, [obj+%04x]", vA, vB, vC);
302  } else {
303  rz_strf(str, " v%i, v%i, [0x%" PFMT64x "]", vA, vB, offset);
304  }
305  strasm = rz_str_append(strasm, str);
306  break;
307  case fmtopAAtBBBB:
308  vA = (int)buf[1];
309  vB = (buf[3] << 8) | buf[2];
310  offset = RZ_ASM_GET_OFFSET(a, 't', vB);
311  if (offset == UT64_MAX) {
312  rz_strf(str, " v%i, thing+%i", vA, vB);
313  } else {
314  rz_strf(str, " v%i, 0x%" PFMT64x, vA, offset);
315  }
316  strasm = rz_str_append(strasm, str);
317  break;
318  case fmtopvAvBtCCCC:
319  vA = (buf[1] & 0x0f);
320  vB = (buf[1] & 0xf0) >> 4;
321  vC = (buf[3] << 8) | buf[2];
322  if (buf[0] == 0x20 || buf[0] == 0x23) { // instance-of & new-array
323  flag_str = RZ_ASM_GET_NAME(a, 'c', vC);
324  if (RZ_STR_ISNOTEMPTY(flag_str)) {
325  rz_strf(str, " v%i, v%i, %s", vA, vB, flag_str);
326  } else {
327  rz_strf(str, " v%i, v%i, class+%i", vA, vB, vC);
328  }
329  } else {
330  flag_str = RZ_ASM_GET_NAME(a, 'f', vC);
331  if (RZ_STR_ISNOTEMPTY(flag_str)) {
332  rz_strf(str, " v%i, v%i, %s", vA, vB, flag_str);
333  } else {
334  rz_strf(str, " v%i, v%i, field+%i", vA, vB, vC);
335  }
336  }
337  strasm = rz_str_append(strasm, str);
338  break;
339  case fmtopvAAtBBBBBBBB:
340  vA = (int)buf[1];
341  vB = (int)(buf[5] | (buf[4] << 8) | (buf[3] << 16) | (buf[2] << 24));
342  offset = RZ_ASM_GET_OFFSET(a, 's', vB);
343  if (offset == UT64_MAX) {
344  rz_strf(str, " v%i, string+%i", vA, vB);
345  } else {
346  rz_strf(str, " v%i, 0x%" PFMT64x, vA, offset);
347  }
348  strasm = rz_str_append(strasm, str);
349  break;
350  case fmtopvCCCCmBBBB:
351  vA = (int)buf[1];
352  vB = (buf[3] << 8) | buf[2];
353  vC = (buf[5] << 8) | buf[4];
354  if (buf[0] == 0x25) { // filled-new-array/range
355  flag_str = RZ_ASM_GET_NAME(a, 'c', vB);
356  if (RZ_STR_ISNOTEMPTY(flag_str)) {
357  rz_strf(str, " {v%i..v%i}, %s", vC, vC + vA - 1, flag_str);
358  } else {
359  rz_strf(str, " {v%i..v%i}, class+%i", vC, vC + vA - 1, vB);
360  }
361  } else if (buf[0] == 0xfd) { // invoke-custom/range
362  flag_str = RZ_ASM_GET_NAME(a, 's', vB);
363  if (RZ_STR_ISNOTEMPTY(flag_str)) {
364  rz_strf(str, " {v%i..v%i}, %s", vC, vC + vA - 1, flag_str);
365  } else {
366  rz_strf(str, " {v%i..v%i}, call_site+%i", vC, vC + vA - 1, vB);
367  }
368  } else {
369  flag_str = RZ_ASM_GET_NAME(a, 'm', vB);
370  if (RZ_STR_ISNOTEMPTY(flag_str)) {
371  rz_strf(str, " {v%i..v%i}, %s", vC, vC + vA - 1, flag_str);
372  } else {
373  rz_strf(str, " {v%i..v%i}, method+%i", vC, vC + vA - 1, vB);
374  }
375  }
376  strasm = rz_str_append(strasm, str);
377  break;
378  case fmtopvXtBBBB:
379  vA = (int)(buf[1] & 0xf0) >> 4;
380  vB = (buf[3] << 8) | buf[2];
381  switch (vA) {
382  case 1:
383  rz_strf(str, " {v%i}", buf[4] & 0x0f);
384  break;
385  case 2:
386  rz_strf(str, " {v%i, v%i}", buf[4] & 0x0f, (buf[4] & 0xf0) >> 4);
387  break;
388  case 3:
389  rz_strf(str, " {v%i, v%i, v%i}", buf[4] & 0x0f,
390  (buf[4] & 0xf0) >> 4, buf[5] & 0x0f);
391  break;
392  case 4:
393  rz_strf(str, " {v%i, v%i, v%i, v%i}", buf[4] & 0x0f,
394  (buf[4] & 0xf0) >> 4, buf[5] & 0x0f, (buf[5] & 0xf0) >> 4);
395  break;
396  case 5:
397  rz_strf(str, " {v%i, v%i, v%i, v%i, v%i}", buf[4] & 0x0f,
398  (buf[4] & 0xf0) >> 4, buf[5] & 0x0f, (buf[5] & 0xf0) >> 4, buf[1] & 0x0f); // TOODO: recheck this
399  break;
400  default:
401  rz_strf(str, " {}");
402  }
403  strasm = rz_str_append(strasm, str);
404  if (buf[0] == 0x24) { // filled-new-array
405  flag_str = RZ_ASM_GET_NAME(a, 'c', vB);
406  if (RZ_STR_ISEMPTY(flag_str)) {
407  rz_strf(str, ", class+%i", vB);
408  } else {
409  rz_strf(str, ", %s", flag_str);
410  }
411  } else if (buf[0] == 0xfc) { // invoke-custom
412  flag_str = RZ_ASM_GET_NAME(a, 's', vB);
413  if (RZ_STR_ISEMPTY(flag_str)) {
414  rz_strf(str, ", call_site+%i", vB);
415  } else {
416  rz_strf(str, ", %s", flag_str);
417  }
418  } else { // invoke-kind
419  flag_str = RZ_ASM_GET_NAME(a, 'm', vB);
420  if (RZ_STR_ISNOTEMPTY(flag_str)) {
421  rz_strf(str, ", %s", flag_str);
422  } else {
423  rz_strf(str, ", method+%i", vB);
424  }
425  }
426  free(flag_str);
427  strasm = rz_str_append(strasm, str);
428  break;
429  case fmtop45CC:
430  vA = (buf[1] & 0xf0) >> 4;
431  vG = (buf[1] & 0x0f);
432  vB = (buf[3] << 8) | buf[2];
433  vD = (buf[4] & 0xf0) >> 4;
434  vC = (buf[4] & 0x0f);
435  vF = (buf[5] & 0xf0) >> 4;
436  vE = (buf[5] & 0x0f);
437  vH = (buf[7] << 8) | buf[6];
438 
439  switch (vA) {
440  case 1:
441  rz_strf(str, " {v%d}", vC);
442  break;
443  case 2:
444  rz_strf(str, " {v%d, v%d}", vC, vD);
445  break;
446  case 3:
447  rz_strf(str, " {v%d, v%d, v%d}", vC, vD, vE);
448  break;
449  case 4:
450  rz_strf(str, " {v%d, v%d, v%d, v%d}", vC, vD, vE, vF);
451  break;
452  case 5:
453  rz_strf(str, " {v%d, v%d, v%d, v%d, v%d}", vC, vD, vE, vF, vG);
454  break;
455  default:
456  rz_strf(str, " %d", vC);
457  break;
458  }
459  strasm = rz_str_append(strasm, str);
460 
461  flag_str = RZ_ASM_GET_NAME(a, 'm', vB);
462  if (RZ_STR_ISNOTEMPTY(flag_str)) {
463  strasm = rz_str_appendf(strasm, ", %s", flag_str);
464  } else {
465  strasm = rz_str_appendf(strasm, ", method+%i", vB);
466  }
467 
468  flag_str = RZ_ASM_GET_NAME(a, 'p', vH);
469  if (RZ_STR_ISNOTEMPTY(flag_str)) {
470  strasm = rz_str_appendf(strasm, ", %s", flag_str);
471  } else {
472  strasm = rz_str_appendf(strasm, ", proto+%i", vH);
473  }
474  break;
475  case fmtop4RCC:
476  vA = (int)buf[1];
477  vB = (buf[3] << 8) | buf[2];
478  vC = (buf[5] << 8) | buf[4];
479  vH = (buf[7] << 8) | buf[6];
480  flag_str = RZ_ASM_GET_NAME(a, 'm', vB);
481  if (RZ_STR_ISNOTEMPTY(flag_str)) {
482  rz_strf(str, " {v%i..v%i}, %s", vC, vC + vA - 1, flag_str);
483  } else {
484  rz_strf(str, " {v%i..v%i}, method+%i", vC, vC + vA - 1, vB);
485  }
486  strasm = rz_str_append(strasm, str);
487 
488  flag_str = RZ_ASM_GET_NAME(a, 'p', vH);
489  if (RZ_STR_ISNOTEMPTY(flag_str)) {
490  rz_strf(str, ", %s", flag_str);
491  } else {
492  rz_strf(str, ", proto+%i", vH);
493  }
494  strasm = rz_str_append(strasm, str);
495  break;
496  case fmtoptinvokeI: // Any opcode has this formats
497  case fmtoptinvokeIR:
498  case fmt00:
499  default:
500  free(strasm);
501  strasm = NULL;
502  size = 2;
503  }
504  rz_strbuf_set(&op->buf_asm, strasm ? strasm : "invalid");
505  } else if (len > 0) {
506  rz_strbuf_set(&op->buf_asm, "invalid");
507  op->size = len;
508  size = len;
509  }
510 
511  if (payload < 0) {
512  op->payload = 0;
513  } else if (len > 0 && payload >= len) {
514  op->payload = len;
515  } else {
516  op->payload = payload;
517  }
518 
519  if (size + op->payload < 0) {
520  op->size = 0;
521  } else if (size + op->payload >= len) {
522  op->size = len;
523  } else {
524  op->size = size + op->payload;
525  }
526  free(strasm);
527  return size;
528 }
size_t len
Definition: 6502dis.c:15
#define NULL
Definition: cris-opc.c:27
@ fmtopvAAtBBBBBBBB
Definition: opcode.h:31
@ fmtopvAAcBBBB
Definition: opcode.h:18
@ fmtopvAAvBBBB
Definition: opcode.h:16
@ fmtoptinvokeIR
Definition: opcode.h:37
@ fmtopvAvBpCCCC
Definition: opcode.h:23
@ fmtoptinvokeVS
Definition: opcode.h:33
@ fmtop4RCC
Definition: opcode.h:42
@ fmtopvAAvBBvCC
Definition: opcode.h:21
@ fmtopAAtBBBB
Definition: opcode.h:14
@ fmtopvXtBBBB
Definition: opcode.h:32
@ fmt00
Definition: opcode.h:8
@ fmtopvAAtBBBB
Definition: opcode.h:20
@ fmtopvCCCCmBBBB
Definition: opcode.h:35
@ fmtopvAAcBBBBBBBB
Definition: opcode.h:30
@ fmtopvAApBBBB
Definition: opcode.h:17
@ fmtoptinvokeVSR
Definition: opcode.h:36
@ fmtopvAvBcCCCC
Definition: opcode.h:24
@ fmtopvAAAAvBBBB
Definition: opcode.h:27
@ fmtoppAA
Definition: opcode.h:13
@ fmtoppAAAA
Definition: opcode.h:15
@ fmtoptinlineI
Definition: opcode.h:38
@ fmtopvAApBBBBBBBB
Definition: opcode.h:29
@ fmtoptinlineIR
Definition: opcode.h:39
@ fmtopvAA
Definition: opcode.h:12
@ fmtopvAvB
Definition: opcode.h:10
@ fmtopvAvBtCCCC
Definition: opcode.h:25
@ fmtoptinvokeI
Definition: opcode.h:34
@ fmtopvAAvBBcCC
Definition: opcode.h:22
@ fmtop
Definition: opcode.h:9
@ fmtopvAAcBBBB0000
Definition: opcode.h:19
@ fmtopvAcB
Definition: opcode.h:11
@ fmtopvAAcBBBBBBBBBBBBBBBB
Definition: opcode.h:40
@ fmtop45CC
Definition: opcode.h:41
@ fmtoptopvAvBoCCCC
Definition: opcode.h:26
@ fmtoppAAAAAAAA
Definition: opcode.h:28
uint16_t ut16
uint32_t ut32
RZ_API char * sdb_fmt(const char *fmt,...)
Definition: fmt.c:26
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
voidpf void uLong size
Definition: ioapi.h:138
voidpf uLong offset
Definition: ioapi.h:144
return strdup("=SP r13\n" "=LR r14\n" "=PC r15\n" "=A0 r0\n" "=A1 r1\n" "=A2 r2\n" "=A3 r3\n" "=ZF zf\n" "=SF nf\n" "=OF vf\n" "=CF cf\n" "=SN or0\n" "gpr lr .32 56 0\n" "gpr pc .32 60 0\n" "gpr cpsr .32 64 0 ____tfiae_________________qvczn\n" "gpr or0 .32 68 0\n" "gpr tf .1 64.5 0 thumb\n" "gpr ef .1 64.9 0 endian\n" "gpr jf .1 64.24 0 java\n" "gpr qf .1 64.27 0 sticky_overflow\n" "gpr vf .1 64.28 0 overflow\n" "gpr cf .1 64.29 0 carry\n" "gpr zf .1 64.30 0 zero\n" "gpr nf .1 64.31 0 negative\n" "gpr itc .4 64.10 0 if_then_count\n" "gpr gef .4 64.16 0 great_or_equal\n" "gpr r0 .32 0 0\n" "gpr r1 .32 4 0\n" "gpr r2 .32 8 0\n" "gpr r3 .32 12 0\n" "gpr r4 .32 16 0\n" "gpr r5 .32 20 0\n" "gpr r6 .32 24 0\n" "gpr r7 .32 28 0\n" "gpr r8 .32 32 0\n" "gpr r9 .32 36 0\n" "gpr r10 .32 40 0\n" "gpr r11 .32 44 0\n" "gpr r12 .32 48 0\n" "gpr r13 .32 52 0\n" "gpr r14 .32 56 0\n" "gpr r15 .32 60 0\n" "gpr r16 .32 64 0\n" "gpr r17 .32 68 0\n")
#define RZ_ASM_GET_NAME(x, y, z)
Definition: rz_asm.h:45
#define RZ_ASM_GET_OFFSET(x, y, z)
Definition: rz_asm.h:42
#define rz_return_val_if_fail(expr, val)
Definition: rz_assert.h:108
#define RZ_STR_ISNOTEMPTY(x)
Definition: rz_str.h:68
RZ_API char * rz_str_appendf(char *ptr, const char *fmt,...) RZ_PRINTF_CHECK(2
RZ_API char * rz_str_append(char *ptr, const char *string)
Definition: str.c:1063
#define RZ_STR_ISEMPTY(x)
Definition: rz_str.h:67
#define rz_strf(buf,...)
Convenience macro for local temporary strings.
Definition: rz_str.h:59
RZ_API const char * rz_strbuf_set(RzStrBuf *sb, const char *s)
Definition: strbuf.c:153
#define PFMT64x
Definition: rz_types.h:393
#define UT64_MAX
Definition: rz_types_base.h:86
static int
Definition: sfsocketcall.h:114
ut64(WINAPI *w32_GetEnabledXStateFeatures)()

References a, dalvik_opcodes, fmt00, fmtop, fmtop45CC, fmtop4RCC, fmtopAAtBBBB, fmtoppAA, fmtoppAAAA, fmtoppAAAAAAAA, fmtoptinlineI, fmtoptinlineIR, fmtoptinvokeI, fmtoptinvokeIR, fmtoptinvokeVS, fmtoptinvokeVSR, fmtoptopvAvBoCCCC, fmtopvAA, fmtopvAAAAvBBBB, fmtopvAAcBBBB, fmtopvAAcBBBB0000, fmtopvAAcBBBBBBBB, fmtopvAAcBBBBBBBBBBBBBBBB, fmtopvAApBBBB, fmtopvAApBBBBBBBB, fmtopvAAtBBBB, fmtopvAAtBBBBBBBB, fmtopvAAvBBBB, fmtopvAAvBBcCC, fmtopvAAvBBvCC, fmtopvAcB, fmtopvAvB, fmtopvAvBcCCCC, fmtopvAvBpCCCC, fmtopvAvBtCCCC, fmtopvCCCCmBBBB, fmtopvXtBBBB, free(), i, int, len, dalvik_opcodes_t::len, NULL, PFMT64x, RZ_ASM_GET_NAME, RZ_ASM_GET_OFFSET, rz_return_val_if_fail, rz_str_append(), rz_str_appendf(), RZ_STR_ISEMPTY, RZ_STR_ISNOTEMPTY, rz_strbuf_set(), rz_strf, sdb_fmt(), cmd_descs_generate::str, strdup(), ut64(), and UT64_MAX.

Variable Documentation

◆ rizin_plugin

RZ_API RzLibStruct rizin_plugin
Initial value:
= {
.type = RZ_LIB_TYPE_ASM,
}
RzAsmPlugin rz_asm_plugin_dalvik
Definition: asm_dalvik.c:550
@ RZ_LIB_TYPE_ASM
Definition: rz_lib.h:72
#define RZ_VERSION
Definition: rz_version.h:8
const char * version
Definition: rz_asm.h:133

Definition at line 562 of file asm_dalvik.c.

◆ rz_asm_plugin_dalvik

RzAsmPlugin rz_asm_plugin_dalvik
Initial value:
= {
.name = "dalvik",
.arch = "dalvik",
.license = "LGPL3",
.desc = "AndroidVM Dalvik",
.bits = 32 | 64,
.disassemble = &dalvik_disassemble,
.assemble = &dalvik_assemble,
}
static int dalvik_assemble(RzAsm *a, RzAsmOp *op, const char *buf)
Definition: asm_dalvik.c:531
static int dalvik_disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len)
Definition: asm_dalvik.c:15
#define RZ_SYS_ENDIAN_LITTLE
Definition: rz_types.h:526

Definition at line 550 of file asm_dalvik.c.