Rizin
unix-like reverse engineering framework and cli tools
cmd_write.c
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2009-2021 pancake <pancake@nopcode.org>
2 // SPDX-License-Identifier: LGPL-3.0-only
3 
4 #include <rz_crypto.h>
5 #include <rz_config.h>
6 #include <rz_cons.h>
7 #include <rz_core.h>
8 #include <rz_io.h>
9 #include <rz_socket.h>
10 #include "../core_private.h"
11 
12 static void cmd_write_fail(RzCore *core) {
13  eprintf("Failed to write\n");
14  core->num->value = 1;
15 }
16 
17 static bool encrypt_or_decrypt_block(RzCore *core, const char *algo, const char *key, int direction, const char *iv) {
18  // TODO: generalise no_key_mode for all non key encoding/decoding.
19  int keylen = 0;
20  bool no_key_mode = !strcmp("base64", algo) || !strcmp("base91", algo) || !strcmp("punycode", algo);
21  ut8 *binkey = NULL;
22  if (!strncmp(key, "s:", 2)) {
23  binkey = (ut8 *)strdup(key + 2);
24  keylen = strlen(key + 2);
25  } else {
26  binkey = (ut8 *)strdup(key);
27  keylen = rz_hex_str2bin(key, binkey);
28  }
29  if (!no_key_mode && keylen < 1) {
30  eprintf("%s key not defined. Use -S [key]\n", ((!direction) ? "Encryption" : "Decryption"));
31  free(binkey);
32  return false;
33  }
34  RzCrypto *cry = rz_crypto_new();
35  if (rz_crypto_use(cry, algo)) {
36  if (!binkey) {
37  eprintf("Cannot allocate %d byte(s)\n", keylen);
38  rz_crypto_free(cry);
39  return false;
40  }
41  if (rz_crypto_set_key(cry, binkey, keylen, 0, direction)) {
42  if (iv) {
43  ut8 *biniv = malloc(strlen(iv) + 1);
44  int ivlen = rz_hex_str2bin(iv, biniv);
45  if (ivlen < 1) {
46  ivlen = strlen(iv);
47  strcpy((char *)biniv, iv);
48  }
49  if (!rz_crypto_set_iv(cry, biniv, ivlen)) {
50  eprintf("Invalid IV.\n");
51  return 0;
52  }
53  }
54  rz_crypto_update(cry, (const ut8 *)core->block, core->blocksize);
55  rz_crypto_final(cry, NULL, 0);
56 
57  int result_size = 0;
58  const ut8 *result = rz_crypto_get_output(cry, &result_size);
59  if (result) {
60  if (!rz_core_write_at(core, core->offset, result, result_size)) {
61  eprintf("rz_core_write_at failed at 0x%08" PFMT64x "\n", core->offset);
62  }
63  eprintf("Written %d byte(s)\n", result_size);
64  }
65  } else {
66  eprintf("Invalid key\n");
67  }
68  free(binkey);
69  rz_crypto_free(cry);
70  return 0;
71  } else {
72  eprintf("Unknown %s algorithm '%s'\n", ((!direction) ? "encryption" : "decryption"), algo);
73  }
74  rz_crypto_free(cry);
75  return 1;
76 }
77 
78 static void cmd_write_bits(RzCore *core, int set, ut64 val) {
79  ut64 ret, orig;
80  // used to set/unset bit in current address
81  rz_io_read_at(core->io, core->offset, (ut8 *)&orig, sizeof(orig));
82  if (set) {
83  ret = orig | val;
84  } else {
85  ret = orig & (~(val));
86  }
87  if (!rz_core_write_at(core, core->offset, (const ut8 *)&ret, sizeof(ret))) {
88  cmd_write_fail(core);
89  }
90 }
91 
92 #define WSEEK(x, y) \
93  if (wseek) \
94  rz_core_seek_delta(x, y, true)
95 
96 static RzCmdStatus common_write_value_handler(RzCore *core, const char *valstr, size_t sz) {
97  ut64 value = rz_num_math(core->num, valstr);
98  if (core->num->nc.errors) {
99  RZ_LOG_ERROR("Could not convert argument to number");
100  return RZ_CMD_STATUS_ERROR;
101  }
102 
104 }
105 
106 RZ_IPI RzCmdStatus rz_write_value_handler(RzCore *core, int argc, const char **argv) {
107  return common_write_value_handler(core, argv[1], 0);
108 }
109 
110 RZ_IPI RzCmdStatus rz_write_value1_handler(RzCore *core, int argc, const char **argv) {
111  return common_write_value_handler(core, argv[1], 1);
112 }
113 
114 RZ_IPI RzCmdStatus rz_write_value2_handler(RzCore *core, int argc, const char **argv) {
115  return common_write_value_handler(core, argv[1], 2);
116 }
117 
118 RZ_IPI RzCmdStatus rz_write_value4_handler(RzCore *core, int argc, const char **argv) {
119  return common_write_value_handler(core, argv[1], 4);
120 }
121 
122 RZ_IPI RzCmdStatus rz_write_value8_handler(RzCore *core, int argc, const char **argv) {
123  return common_write_value_handler(core, argv[1], 8);
124 }
125 
128 }
129 
132 }
133 
134 static bool ioMemcpy(RzCore *core, ut64 dst, ut64 src, int len) {
135  bool ret = false;
136  if (len > 0) {
137  ut8 *buf = calloc(1, len);
138  if (buf) {
139  if (rz_io_read_at(core->io, src, buf, len)) {
140  if (rz_io_write_at(core->io, dst, buf, len)) {
141  rz_core_block_read(core);
142  ret = true;
143  } else {
144  eprintf("rz_io_write_at failed at 0x%08" PFMT64x "\n", dst);
145  }
146  } else {
147  eprintf("rz_io_read_at failed at 0x%08" PFMT64x "\n", src);
148  }
149  free(buf);
150  }
151  }
152  return ret;
153 }
154 
155 RZ_IPI RzCmdStatus rz_write_from_io_handler(RzCore *core, int argc, const char **argv) {
156  ut64 addr = rz_num_math(core->num, argv[1]);
157  ut64 len = rz_num_math(core->num, argv[2]);
158  bool res = ioMemcpy(core, core->offset, addr, len);
159  return res ? RZ_CMD_STATUS_OK : RZ_CMD_STATUS_ERROR;
160 }
161 
163  ut64 dst = core->offset;
164  ut64 src = rz_num_math(core->num, argv[1]);
165  ut64 len = rz_num_math(core->num, argv[2]);
166  if (len < 0) {
167  return RZ_CMD_STATUS_ERROR;
168  }
169 
170  ut8 *buf = RZ_NEWS0(ut8, len);
171  if (!buf) {
172  return RZ_CMD_STATUS_ERROR;
173  }
174 
176  if (!rz_io_read_at(core->io, dst, buf, len)) {
177  eprintf("cmd_wfx: failed to read at 0x%08" PFMT64x "\n", dst);
178  goto err;
179  }
180 
181  ioMemcpy(core, core->offset, src, len);
182  if (!rz_io_write_at(core->io, src, buf, len)) {
183  eprintf("Failed to write at 0x%08" PFMT64x "\n", src);
184  goto err;
185  }
186 
187  rz_core_block_read(core);
188  res = RZ_CMD_STATUS_OK;
189 err:
190  free(buf);
191  return res;
192 }
193 
194 RZ_IPI RzCmdStatus rz_write_from_file_handler(RzCore *core, int argc, const char **argv) {
195  int wseek = rz_config_get_i(core->config, "cfg.wseek");
196  ut64 user_size = argc > 2 ? rz_num_math(core->num, argv[2]) : UT64_MAX;
197  ut64 offset = argc > 3 ? rz_num_math(core->num, argv[3]) : 0;
198  const char *filename = argv[1];
199 
201  char *data = NULL;
202  size_t size, w_size;
203  if (!strcmp(filename, "-")) {
204  data = rz_core_editor(core, NULL, NULL);
205  if (!data) {
206  eprintf("No data from editor\n");
207  return RZ_CMD_STATUS_ERROR;
208  }
209  size = strlen(data);
210  } else {
211  data = rz_file_slurp(filename, &size);
212  if (!data) {
213  eprintf("Cannot open file '%s'\n", filename);
214  return RZ_CMD_STATUS_ERROR;
215  }
216  }
217 
218  w_size = RZ_MIN(size, user_size);
219  if (offset > size) {
220  eprintf("Invalid offset provided\n");
221  goto err;
222  }
223  if (UT64_ADD_OVFCHK(offset, w_size) || offset + w_size > size) {
224  eprintf("Invalid offset/size provided\n");
225  goto err;
226  }
227 
228  rz_io_use_fd(core->io, core->file->fd);
229  if (!rz_io_write_at(core->io, core->offset, (ut8 *)data + offset, w_size)) {
230  eprintf("rz_io_write_at failed at 0x%08" PFMT64x "\n", core->offset);
231  goto err;
232  }
233  WSEEK(core, w_size);
234  rz_core_block_read(core);
235  res = RZ_CMD_STATUS_OK;
236 
237 err:
238  free(data);
239  return res;
240 }
241 
244  char *address = strdup(argv[1]);
245  ut64 sz = argc > 2 ? rz_num_math(core->num, argv[2]) : core->blocksize;
246 
247  size_t n_split = rz_str_split(address, ':');
248  if (n_split != 2) {
249  eprintf("Wrong format for <host:port>\n");
250  goto err;
251  }
252  char *host = address;
253  char *port = host + strlen(host) + 1;
254 
255  ut8 *buf = RZ_NEWS0(ut8, sz);
256  if (!buf) {
257  goto err;
258  }
259 
260  RzSocket *s = rz_socket_new(false);
261  if (!rz_socket_listen(s, port, NULL)) {
262  eprintf("Cannot listen on port %s\n", port);
263  goto socket_err;
264  }
265  int done = 0;
267  if (!c) {
268  eprintf("Failing to accept socket\n");
269  goto socket_err;
270  }
271 
272  eprintf("Receiving data from client...\n");
273  while (done < sz) {
274  int rc = rz_socket_read(c, buf + done, sz - done);
275  if (rc < 0) {
276  eprintf("Failing to read data from socket: %d\n", rc);
277  goto socket_err;
278  } else if (rc == 0) {
279  break;
280  }
281  done += rc;
282  }
283  if (!rz_io_write_at(core->io, core->offset, buf, done)) {
284  eprintf("Cannot write\n");
285  goto socket_err;
286  }
287  eprintf("Written %d bytes\n", done);
288  res = RZ_CMD_STATUS_OK;
289 
290 socket_err:
291  rz_socket_free(s);
292 err:
293  free(address);
294  return res;
295 }
296 
297 RZ_IPI RzCmdStatus rz_write_bits_handler(RzCore *core, int argc, const char **argv) {
298  cmd_write_bits(core, 1, rz_num_math(core->num, argv[1]));
299  return RZ_CMD_STATUS_OK;
300 }
301 
302 RZ_IPI RzCmdStatus rz_write_unset_bits_handler(RzCore *core, int argc, const char **argv) {
303  cmd_write_bits(core, 0, rz_num_math(core->num, argv[1]));
304  return RZ_CMD_STATUS_OK;
305 }
306 
307 RZ_IPI RzCmdStatus rz_write_zero_handler(RzCore *core, int argc, const char **argv) {
308  ut64 len = rz_num_math(core->num, argv[1]);
309  ut8 *buf = RZ_NEWS0(ut8, len);
310  if (!buf) {
311  RZ_LOG_ERROR("Cannot allocate %" PFMT64d " bytes", len);
312  return RZ_CMD_STATUS_ERROR;
313  }
314 
315  bool res = rz_core_write_at(core, core->offset, buf, len);
316  free(buf);
317 
318  return res ? RZ_CMD_STATUS_OK : RZ_CMD_STATUS_ERROR;
319 }
320 
321 static RzCmdStatus w_incdec_handler(RzCore *core, int argc, const char **argv, int inc_size) {
322  st64 num = argc > 1 ? rz_num_math(core->num, argv[1]) : 1;
323  const char *command = argv[0];
324  if (command[strlen(command) - 1] == '-') {
325  num *= -1;
326  }
327  return rz_core_write_value_inc_at(core, core->offset, num, inc_size) ? RZ_CMD_STATUS_OK : RZ_CMD_STATUS_ERROR;
328 }
329 
330 RZ_IPI RzCmdStatus rz_write_1_inc_handler(RzCore *core, int argc, const char **argv) {
331  return w_incdec_handler(core, argc, argv, 1);
332 }
333 RZ_IPI RzCmdStatus rz_write_1_dec_handler(RzCore *core, int argc, const char **argv) {
334  return w_incdec_handler(core, argc, argv, 1);
335 }
336 
337 RZ_IPI RzCmdStatus rz_write_2_inc_handler(RzCore *core, int argc, const char **argv) {
338  return w_incdec_handler(core, argc, argv, 2);
339 }
340 RZ_IPI RzCmdStatus rz_write_2_dec_handler(RzCore *core, int argc, const char **argv) {
341  return w_incdec_handler(core, argc, argv, 2);
342 }
343 
344 RZ_IPI RzCmdStatus rz_write_4_inc_handler(RzCore *core, int argc, const char **argv) {
345  return w_incdec_handler(core, argc, argv, 4);
346 }
347 RZ_IPI RzCmdStatus rz_write_4_dec_handler(RzCore *core, int argc, const char **argv) {
348  return w_incdec_handler(core, argc, argv, 4);
349 }
350 
351 RZ_IPI RzCmdStatus rz_write_8_inc_handler(RzCore *core, int argc, const char **argv) {
352  return w_incdec_handler(core, argc, argv, 8);
353 }
354 RZ_IPI RzCmdStatus rz_write_8_dec_handler(RzCore *core, int argc, const char **argv) {
355  return w_incdec_handler(core, argc, argv, 8);
356 }
357 
359  // TODO: implement it in an API RzCore.write_unified_hexpatch() is ETOOLONG
360  char *data = rz_file_slurp(argv[1], NULL);
361  if (!data) {
362  RZ_LOG_ERROR("Cannot read data from %s.\n", argv[1]);
363  return RZ_CMD_STATUS_ERROR;
364  }
365  int i;
366  char sign = ' ';
367  int line = 0, offs = 0, hexa = 0;
368  int newline = 1;
369  for (i = 0; data[i]; i++) {
370  switch (data[i]) {
371  case '+':
372  if (newline)
373  sign = 1;
374  break;
375  case '-':
376  if (newline) {
377  sign = 0;
378  offs = i + ((data[i + 1] == ' ') ? 2 : 1);
379  }
380  break;
381  case ' ':
382  data[i] = 0;
383  if (sign) {
384  if (!line)
385  line = i + 1;
386  else if (!hexa)
387  hexa = i + 1;
388  }
389  break;
390  case '\r':
391  break;
392  case '\n':
393  newline = 1;
394  if (sign == ' ') {
395  offs = 0;
396  line = 0;
397  hexa = 0;
398  } else if (sign) {
399  if (offs && hexa) {
400  ut64 dst = rz_num_math(core->num, data + offs);
401  ut8 *buf = RZ_NEWS(ut8, strlen(data + hexa));
402  if (buf) {
403  int len = rz_hex_str2bin(data + hexa, buf);
404  rz_core_write_at(core, dst, buf, len);
405  }
406  } else {
407  eprintf("food\n");
408  }
409  offs = 0;
410  line = 0;
411  } else
412  hexa = 0;
413  sign = -1;
414  continue;
415  }
416  newline = 0;
417  }
418  free(data);
419  return 0;
420 }
421 
422 RZ_IPI RzCmdStatus rz_write_random_handler(RzCore *core, int argc, const char **argv) {
423  if (!rz_num_is_valid_input(core->num, argv[1])) {
424  RZ_LOG_ERROR("Invalid length '%s'\n", argv[1]);
425  return RZ_CMD_STATUS_ERROR;
426  }
427  size_t length = rz_num_math(core->num, argv[1]);
429 }
430 
431 RZ_IPI RzCmdStatus rz_write_handler(RzCore *core, int argc, const char **argv) {
432  return bool2status(rz_core_write_string_at(core, core->offset, argv[1]));
433 }
434 
436  return bool2status(rz_core_write_string_zero_at(core, core->offset, argv[1]));
437 }
438 
440  return bool2status(rz_core_write_string_wide_at(core, core->offset, argv[1]));
441 }
442 
443 RZ_IPI RzCmdStatus rz_write_hex_handler(RzCore *core, int argc, const char **argv) {
444  return rz_core_write_hexpair(core, core->offset, argv[1]) > 0 ? RZ_CMD_STATUS_OK : RZ_CMD_STATUS_ERROR;
445 }
446 
448  char *buf;
449  if (!strcmp(argv[1], "-")) {
450  buf = rz_core_editor(core, NULL, NULL);
451  if (!buf) {
452  RZ_LOG_ERROR("Could not get anything from editor\n");
453  return RZ_CMD_STATUS_ERROR;
454  }
455  } else {
456  if (!rz_file_exists(argv[1])) {
457  RZ_LOG_ERROR("File '%s' does not exist\n", argv[1]);
458  return RZ_CMD_STATUS_ERROR;
459  }
460 
461  buf = rz_file_slurp(argv[1], NULL);
462  if (!buf) {
463  RZ_LOG_ERROR("Cannot open file '%s'\n", argv[1]);
464  return RZ_CMD_STATUS_ERROR;
465  }
466  }
467 
468  int res = rz_core_write_hexpair(core, core->offset, buf);
469  free(buf);
470  if (res < 0) {
471  RZ_LOG_ERROR("Could not write hexpairs to 0x%" PFMT64x "\n", core->offset);
472  return RZ_CMD_STATUS_ERROR;
473  }
474  return RZ_CMD_STATUS_OK;
475 }
476 
477 RZ_IPI RzCmdStatus rz_write_assembly_handler(RzCore *core, int argc, const char **argv) {
478  char *instructions = rz_str_array_join(argv + 1, argc - 1, "\n");
479  if (!instructions) {
480  return RZ_CMD_STATUS_ERROR;
481  }
482  int res = rz_core_write_assembly(core, core->offset, instructions);
484  return res >= 0 ? RZ_CMD_STATUS_OK : RZ_CMD_STATUS_ERROR;
485 }
486 
488  char *instructions = rz_str_array_join(argv + 1, argc - 1, "\n");
489  if (!instructions) {
490  return RZ_CMD_STATUS_ERROR;
491  }
492  int res = rz_core_write_assembly_fill(core, core->offset, instructions);
494  return res >= 0 ? RZ_CMD_STATUS_OK : RZ_CMD_STATUS_ERROR;
495 }
496 
498  char *instructions = rz_file_slurp(argv[1], NULL);
499  if (!instructions) {
500  RZ_LOG_ERROR("Cannot read file '%s'\n", argv[1]);
501  return RZ_CMD_STATUS_ERROR;
502  }
503  int res = rz_core_write_assembly(core, core->offset, instructions);
505  return res >= 0 ? RZ_CMD_STATUS_OK : RZ_CMD_STATUS_ERROR;
506 }
507 
509  return bool2status(rz_core_hack(core, argv[1]));
510 }
511 
512 RZ_IPI RzCmdStatus rz_write_block_handler(RzCore *core, int argc, const char **argv) {
513  ut8 *hex = RZ_NEWS0(ut8, (strlen(argv[1]) + 1) / 2);
514  if (!hex) {
515  return RZ_CMD_STATUS_ERROR;
516  }
517 
518  int len = rz_hex_str2bin(argv[1], hex);
519  if (len <= 0) {
520  free(hex);
521  RZ_LOG_ERROR("Cannot convert '%s' to hex data.\n", argv[1]);
522  return RZ_CMD_STATUS_ERROR;
523  }
524 
525  return bool2status(rz_core_write_block(core, core->offset, hex, len));
526 }
527 
528 RZ_IPI RzCmdStatus rz_write_mask_set_handler(RzCore *core, int argc, const char **argv) {
529  ut8 *buf = RZ_NEWS(ut8, strlen(argv[1]) / 2);
530  if (!buf) {
531  return RZ_CMD_STATUS_ERROR;
532  }
533  int size = rz_hex_str2bin(argv[1], buf);
534  bool result = rz_io_set_write_mask(core->io, buf, size);
535  free(buf);
536  return bool2status(result);
537 }
538 
539 RZ_IPI RzCmdStatus rz_write_mask_reset_handler(RzCore *core, int argc, const char **argv) {
540  return bool2status(rz_io_set_write_mask(core->io, NULL, 0));
541 }
542 
543 RZ_IPI RzCmdStatus rz_write_duplicate_handler(RzCore *core, int argc, const char **argv) {
544  ut64 src = rz_num_math(core->num, argv[1]);
545  int len = (int)rz_num_math(core->num, argv[2]);
546  if (len < 0) {
547  RZ_LOG_ERROR("Negative length is not valid.\n");
548  return RZ_CMD_STATUS_ERROR;
549  }
550  return bool2status(rz_core_write_duplicate_at(core, core->offset, src, len));
551 }
552 
555 }
556 
558  return rz_core_io_cache_print(core, state);
559 }
560 
562  ut64 from = argc > 1 ? rz_num_math(core->num, argv[1]) : core->offset;
563  ut64 to = argc > 2 ? rz_num_math(core->num, argv[2]) : from + core->blocksize;
564  int ninvalid = rz_io_cache_invalidate(core->io, from, to);
565  RZ_LOG_INFO("Invalidated %d cache(s)\n", ninvalid);
566  rz_core_block_read(core);
567  return RZ_CMD_STATUS_OK;
568 }
569 
571  rz_io_cache_reset(core->io, core->io->cached);
572  return RZ_CMD_STATUS_OK;
573 }
574 
576  ut64 from = argc > 1 ? rz_num_math(core->num, argv[1]) : core->offset;
577  ut64 to = argc > 2 ? rz_num_math(core->num, argv[2]) : from + core->blocksize;
578  rz_io_cache_commit(core->io, from, to);
579  return RZ_CMD_STATUS_OK;
580 }
581 
583  rz_io_cache_commit(core->io, 0, UT64_MAX);
584  rz_core_block_read(core);
585  return RZ_CMD_STATUS_OK;
586 }
587 
589  RzIODesc *desc = NULL;
590  if (argc > 1) {
591  int fd = (int)rz_num_math(core->num, argv[1]);
592  if (fd < 0) {
593  RZ_LOG_ERROR("Invalid fd argument %d.\n", fd);
594  return RZ_CMD_STATUS_ERROR;
595  }
596  desc = rz_io_desc_get(core->io, fd);
597  } else {
598  desc = core->io->desc;
599  }
600  if (!desc) {
601  RZ_LOG_ERROR("Cannot retrieve valid file.\n");
602  return RZ_CMD_STATUS_ERROR;
603  }
604  return rz_core_io_pcache_print(core, desc, state);
605 }
606 
608  RzIODesc *desc = NULL;
609  if (argc > 1) {
610  int fd = (int)rz_num_math(core->num, argv[1]);
611  if (fd < 0) {
612  RZ_LOG_ERROR("Invalid fd argument %d.\n", fd);
613  return RZ_CMD_STATUS_ERROR;
614  }
615  desc = rz_io_desc_get(core->io, fd);
616  } else {
617  desc = core->io->desc;
618  }
619  if (!desc) {
620  RZ_LOG_ERROR("Cannot retrieve valid file.\n");
621  return RZ_CMD_STATUS_ERROR;
622  }
624 }
625 
627  ut64 len = rz_num_math(core->num, argv[1]);
628  ut64 addr = argc > 2 ? rz_num_math(core->num, argv[2]) : core->offset;
629  return bool2status(rz_core_extend_at(core, addr, len));
630 }
631 
633  ut64 dist = rz_num_math(core->num, argv[1]);
634  ut64 block_size = argc > 2 ? rz_num_math(core->num, argv[2]) : 0;
635  if (dist == 0) {
636  RZ_LOG_ERROR("Cannot use '%s' as a distance.\n", argv[1]);
637  return RZ_CMD_STATUS_ERROR;
638  }
639  return bool2status(rz_core_shift_block(core, core->offset, block_size, dist));
640 }
641 
643  ut8 *bytes = RZ_NEWS(ut8, (strlen(argv[1]) + 1) / 2);
644  if (!bytes) {
645  return RZ_CMD_STATUS_ERROR;
646  }
647 
648  int len = rz_hex_str2bin(argv[1], bytes);
649  if (len <= 0) {
650  RZ_LOG_ERROR("Cannot convert '%s' to bytes values.\n", argv[1]);
651  free(bytes);
652  return RZ_CMD_STATUS_ERROR;
653  }
654 
655  ut64 addr = argc > 2 ? rz_num_math(core->num, argv[2]) : core->offset;
656  bool res = rz_core_extend_at(core, addr, len);
657  if (!res) {
658  RZ_LOG_ERROR("Cannot extend the file.\n");
659  free(bytes);
660  return RZ_CMD_STATUS_ERROR;
661  }
662  bool result = rz_core_write_at(core, addr, bytes, len);
663  free(bytes);
664  return bool2status(result);
665 }
666 
669 }
670 
673 }
674 
677 }
678 
679 static RzCmdStatus write_op_val(RzCore *core, int argc, const char **argv, RzCoreWriteOp op) {
681 
682  ut8 *hex = RZ_NEWS(ut8, (strlen(argv[1]) + 1) / 2);
683  if (!hex) {
684  return RZ_CMD_STATUS_ERROR;
685  }
686 
687  int hexlen = rz_hex_str2bin(argv[1], hex);
688  RzCmdStatus res = bool2status(rz_core_write_block_op_at(core, core->offset, op, hex, hexlen));
689  free(hex);
690  return res;
691 }
692 
693 RZ_IPI RzCmdStatus rz_write_op_add_handler(RzCore *core, int argc, const char **argv) {
694  return write_op_val(core, argc, argv, RZ_CORE_WRITE_OP_ADD);
695 }
696 
697 RZ_IPI RzCmdStatus rz_write_op_sub_handler(RzCore *core, int argc, const char **argv) {
698  return write_op_val(core, argc, argv, RZ_CORE_WRITE_OP_SUB);
699 }
700 
701 RZ_IPI RzCmdStatus rz_write_op_mul_handler(RzCore *core, int argc, const char **argv) {
702  return write_op_val(core, argc, argv, RZ_CORE_WRITE_OP_MUL);
703 }
704 
705 RZ_IPI RzCmdStatus rz_write_op_div_handler(RzCore *core, int argc, const char **argv) {
706  return write_op_val(core, argc, argv, RZ_CORE_WRITE_OP_DIV);
707 }
708 
709 RZ_IPI RzCmdStatus rz_write_op_xor_handler(RzCore *core, int argc, const char **argv) {
710  return write_op_val(core, argc, argv, RZ_CORE_WRITE_OP_XOR);
711 }
712 
713 RZ_IPI RzCmdStatus rz_write_op_and_handler(RzCore *core, int argc, const char **argv) {
714  return write_op_val(core, argc, argv, RZ_CORE_WRITE_OP_AND);
715 }
716 
717 RZ_IPI RzCmdStatus rz_write_op_or_handler(RzCore *core, int argc, const char **argv) {
718  return write_op_val(core, argc, argv, RZ_CORE_WRITE_OP_OR);
719 }
720 
721 RZ_IPI RzCmdStatus rz_write_op_shl_handler(RzCore *core, int argc, const char **argv) {
722  return write_op_val(core, argc, argv, RZ_CORE_WRITE_OP_SHIFT_LEFT);
723 }
724 
725 RZ_IPI RzCmdStatus rz_write_op_shr_handler(RzCore *core, int argc, const char **argv) {
726  return write_op_val(core, argc, argv, RZ_CORE_WRITE_OP_SHIFT_RIGHT);
727 }
728 
729 RZ_IPI RzCmdStatus rz_write_op_encrypt_handler(RzCore *core, int argc, const char **argv) {
730  const char *algo = argv[1];
731  const char *key = argv[2];
732  const char *iv = argv[3];
733  return bool2status(encrypt_or_decrypt_block(core, algo, key, 0, iv));
734 }
735 
736 RZ_IPI RzCmdStatus rz_write_op_decrypt_handler(RzCore *core, int argc, const char **argv) {
737  const char *algo = argv[1];
738  const char *key = argv[2];
739  const char *iv = argv[3];
740  return bool2status(encrypt_or_decrypt_block(core, algo, key, 1, iv));
741 }
742 
744  ut64 from = rz_num_math(NULL, argv[1]);
745  ut64 to = rz_num_math(NULL, argv[2]);
746  ut64 step = rz_num_math(NULL, argv[3]);
747  int value_size = (int)rz_num_math(NULL, argv[4]);
748  if (step < 1) {
749  RZ_LOG_ERROR("Invalid <step> value: %" PFMT64d "\n", step);
750  return RZ_CMD_STATUS_ERROR;
751  }
752  if (value_size != 1 && value_size != 2 && value_size != 4 && value_size != 8) {
753  RZ_LOG_ERROR("Invalid <value_size> value: %d\n", value_size);
754  return RZ_CMD_STATUS_ERROR;
755  }
756  ut64 max_val = (1ULL << (8 * value_size));
757  if (from >= max_val) {
758  RZ_LOG_ERROR("Invalid <from> value: %" PFMT64d "\n", from);
759  return RZ_CMD_STATUS_ERROR;
760  }
761  if (to >= max_val) {
762  RZ_LOG_ERROR("Invalid <to> value: %" PFMT64d "\n", to);
763  return RZ_CMD_STATUS_ERROR;
764  }
765 
766  return bool2status(rz_core_write_seq_at(core, core->offset, from, to, step, value_size));
767 }
768 
769 RZ_IPI RzCmdStatus rz_write_debruijn_handler(RzCore *core, int argc, const char **argv) {
770  int len = (int)rz_num_math(core->num, argv[1]);
771  if (len < 0) {
772  RZ_LOG_ERROR("Invalid length: %d\n", len);
773  return RZ_CMD_STATUS_ERROR;
774  }
775  char *p = rz_debruijn_pattern(len, 0, NULL);
776  if (!p) {
777  RZ_LOG_ERROR("Cannot create Debrujn sequence of length %d\n", len);
778  return RZ_CMD_STATUS_ERROR;
779  }
780  bool res = rz_core_write_string_at(core, core->offset, p);
781  free(p);
782  return bool2status(res);
783 }
784 
786  ut64 value = rz_num_math(core->num, argv[1]);
787  int offset = rz_debruijn_offset(0, NULL, value, rz_config_get_b(core->config, "cfg.bigendian"));
788  if (offset < 0) {
789  RZ_LOG_ERROR("Could not find value %" PFMT64x " in Debruijn sequence.\n", value);
790  return RZ_CMD_STATUS_ERROR;
791  }
792  rz_cons_printf("%d\n", offset);
793  return RZ_CMD_STATUS_OK;
794 }
size_t len
Definition: 6502dis.c:15
#define RZ_IPI
Definition: analysis_wasm.c:11
lzma_index ** i
Definition: index.h:629
lzma_index * src
Definition: index.h:567
ut16 val
Definition: armass64_const.h:6
static bool err
Definition: armass.c:435
static ut8 bytes[32]
Definition: asm_arc.c:23
static const AvrInstruction instructions[]
Definition: assembler.c:880
const char * desc
Definition: bin_vsf.c:19
RZ_API bool rz_core_write_block_op_at(RzCore *core, ut64 addr, RzCoreWriteOp op, ut8 *hex, int hexlen)
Write a full block of data according to the operation op and the hexvalue hex.
Definition: cio.c:1038
RZ_API bool rz_core_write_string_at(RzCore *core, ut64 addr, RZ_NONNULL const char *s)
Write a given string s at the specified addr.
Definition: cio.c:605
RZ_API bool rz_core_extend_at(RzCore *core, ut64 addr, ut64 size)
Extend the file at current offset by inserting size 0 bytes at addr.
Definition: cio.c:172
RZ_API bool rz_core_write_string_wide_at(RzCore *core, ut64 addr, const char *s)
Write a given string s as a wide string at the specified addr.
Definition: cio.c:630
RZ_API int rz_core_write_hexpair(RzCore *core, ut64 addr, const char *pairs)
Definition: cio.c:268
RZ_API bool rz_core_write_at(RzCore *core, ut64 addr, const ut8 *buf, int size)
Definition: cio.c:145
RZ_API bool rz_core_shift_block(RzCore *core, ut64 addr, ut64 b_size, st64 dist)
Shift a block of data from addr of size b_size left or right based on dist.
Definition: cio.c:197
RZ_API RzCmdStatus rz_core_io_pcache_print(RzCore *core, RzIODesc *desc, RzCmdStateOutput *state)
Definition: cio.c:854
RZ_API RzCmdStatus rz_core_io_cache_print(RzCore *core, RzCmdStateOutput *state)
Definition: cio.c:797
RZ_API bool rz_core_write_block(RzCore *core, ut64 addr, ut8 *data, size_t len)
Definition: cio.c:299
RZ_API bool rz_core_write_string_zero_at(RzCore *core, ut64 addr, const char *s)
Write a given string s, followed by the zero terminator, at the specified addr.
Definition: cio.c:905
RZ_API int rz_core_write_assembly(RzCore *core, ut64 addr, RZ_NONNULL const char *instructions)
Assembles instructions and writes the resulting data at the given offset.
Definition: cio.c:327
RZ_API int rz_core_block_read(RzCore *core)
Definition: cio.c:243
RZ_API bool rz_core_write_base64d_at(RzCore *core, ut64 addr, RZ_NONNULL const char *s)
Write a given base64 string s at the specified addr, decoded.
Definition: cio.c:745
RZ_API bool rz_core_write_value_inc_at(RzCore *core, ut64 addr, st64 value, int sz)
Write at addr the current value + value passed as argument.
Definition: cio.c:551
RZ_API bool rz_core_write_length_string_at(RzCore *core, ut64 addr, const char *s)
Write at the specified addr the length of the string in one byte, followed by the given string s.
Definition: cio.c:673
RZ_API bool rz_core_write_seq_at(RzCore *core, ut64 addr, ut64 from, ut64 to, ut64 step, int value_size)
Write a full block of data with a sequence.
Definition: cio.c:1069
RZ_API bool rz_core_write_base64_at(RzCore *core, ut64 addr, RZ_NONNULL const char *s)
Write a given string s at the specified addr encoded as base64.
Definition: cio.c:700
RZ_API bool rz_core_write_random_at(RzCore *core, ut64 addr, size_t len)
Write len random bytes at address addr.
Definition: cio.c:773
RZ_API int rz_core_write_assembly_fill(RzCore *core, ut64 addr, RZ_NONNULL const char *instructions)
Assemble instructions and write the resulting data inside the current instruction.
Definition: cio.c:365
RZ_API bool rz_core_write_duplicate_at(RzCore *core, ut64 addr, ut64 from, int len)
Copy len bytes from from to addr.
Definition: cio.c:1106
RZ_API bool rz_core_write_value_at(RzCore *core, ut64 addr, ut64 value, int sz)
Write a given value at the specified address, using sz bytes.
Definition: cio.c:506
static int value
Definition: cmd_api.c:93
RZ_IPI RzCmdStatus rz_write_cache_commit_all_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_write.c:582
RZ_IPI RzCmdStatus rz_write_assembly_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_write.c:477
RZ_IPI RzCmdStatus rz_write_assembly_file_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_write.c:497
RZ_IPI RzCmdStatus rz_write_mask_reset_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_write.c:539
RZ_IPI RzCmdStatus rz_write_debruijn_find_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_write.c:785
RZ_IPI RzCmdStatus rz_write_pcache_list_handler(RzCore *core, int argc, const char **argv, RzCmdStateOutput *state)
Definition: cmd_write.c:588
RZ_IPI RzCmdStatus rz_write_op_shr_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_write.c:725
RZ_IPI RzCmdStatus rz_write_op_encrypt_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_write.c:729
static bool encrypt_or_decrypt_block(RzCore *core, const char *algo, const char *key, int direction, const char *iv)
Definition: cmd_write.c:17
RZ_IPI RzCmdStatus rz_write_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_write.c:431
RZ_IPI RzCmdStatus rz_write_from_socket_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_write.c:242
RZ_IPI RzCmdStatus rz_write_op_sub_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_write.c:697
RZ_IPI RzCmdStatus rz_write_op_xor_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_write.c:709
RZ_IPI RzCmdStatus rz_write_op_mul_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_write.c:701
RZ_IPI RzCmdStatus rz_write_unified_patch_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_write.c:358
RZ_IPI RzCmdStatus rz_write_value_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_write.c:106
RZ_IPI RzCmdStatus rz_write_zero_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_write.c:307
RZ_IPI RzCmdStatus rz_write_2_inc_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_write.c:337
RZ_IPI RzCmdStatus rz_write_length_string_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_write.c:553
RZ_IPI RzCmdStatus rz_write_op_2byteswap_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_write.c:667
RZ_IPI RzCmdStatus rz_write_op_sequence_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_write.c:743
RZ_IPI RzCmdStatus rz_write_from_file_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_write.c:194
RZ_IPI RzCmdStatus rz_write_hex_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_write.c:443
RZ_IPI RzCmdStatus rz_write_op_or_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_write.c:717
RZ_IPI RzCmdStatus rz_write_value2_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_write.c:114
RZ_IPI RzCmdStatus rz_write_8_dec_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_write.c:354
static RzCmdStatus common_write_value_handler(RzCore *core, const char *valstr, size_t sz)
Definition: cmd_write.c:96
RZ_IPI RzCmdStatus rz_write_cache_remove_all_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_write.c:570
static void cmd_write_fail(RzCore *core)
Definition: cmd_write.c:12
RZ_IPI RzCmdStatus rz_write_value4_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_write.c:118
RZ_IPI RzCmdStatus rz_write_cache_remove_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_write.c:561
static bool ioMemcpy(RzCore *core, ut64 dst, ut64 src, int len)
Definition: cmd_write.c:134
RZ_IPI RzCmdStatus rz_write_value8_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_write.c:122
RZ_IPI RzCmdStatus rz_write_hex_from_file_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_write.c:447
RZ_IPI RzCmdStatus rz_write_cache_list_handler(RzCore *core, int argc, const char **argv, RzCmdStateOutput *state)
Definition: cmd_write.c:557
RZ_IPI RzCmdStatus rz_write_wide_string_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_write.c:439
RZ_IPI RzCmdStatus rz_write_extend_shift_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_write.c:632
RZ_IPI RzCmdStatus rz_write_1_inc_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_write.c:330
RZ_IPI RzCmdStatus rz_write_assembly_inside_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_write.c:487
RZ_IPI RzCmdStatus rz_write_extend_hexbytes_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_write.c:642
RZ_IPI RzCmdStatus rz_write_op_decrypt_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_write.c:736
RZ_IPI RzCmdStatus rz_write_1_dec_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_write.c:333
RZ_IPI RzCmdStatus rz_write_op_8byteswap_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_write.c:675
static void cmd_write_bits(RzCore *core, int set, ut64 val)
Definition: cmd_write.c:78
RZ_IPI RzCmdStatus rz_write_random_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_write.c:422
RZ_IPI RzCmdStatus rz_write_2_dec_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_write.c:340
static RzCmdStatus write_op_val(RzCore *core, int argc, const char **argv, RzCoreWriteOp op)
Definition: cmd_write.c:679
RZ_IPI RzCmdStatus rz_write_from_io_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_write.c:155
RZ_IPI RzCmdStatus rz_write_unset_bits_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_write.c:302
RZ_IPI RzCmdStatus rz_write_cache_commit_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_write.c:575
RZ_IPI RzCmdStatus rz_write_block_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_write.c:512
RZ_IPI RzCmdStatus rz_write_duplicate_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_write.c:543
RZ_IPI RzCmdStatus rz_write_assembly_opcode_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_write.c:508
RZ_IPI RzCmdStatus rz_write_op_shl_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_write.c:721
RZ_IPI RzCmdStatus rz_write_op_and_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_write.c:713
RZ_IPI RzCmdStatus rz_write_op_4byteswap_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_write.c:671
RZ_IPI RzCmdStatus rz_write_8_inc_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_write.c:351
RZ_IPI RzCmdStatus rz_write_base64_encode_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_write.c:126
RZ_IPI RzCmdStatus rz_write_extend_zero_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_write.c:626
RZ_IPI RzCmdStatus rz_write_zero_string_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_write.c:435
RZ_IPI RzCmdStatus rz_write_bits_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_write.c:297
RZ_IPI RzCmdStatus rz_write_op_add_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_write.c:693
RZ_IPI RzCmdStatus rz_write_value1_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_write.c:110
RZ_IPI RzCmdStatus rz_write_4_inc_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_write.c:344
#define WSEEK(x, y)
Definition: cmd_write.c:92
RZ_IPI RzCmdStatus rz_write_4_dec_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_write.c:347
RZ_IPI RzCmdStatus rz_write_pcache_commit_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_write.c:607
RZ_IPI RzCmdStatus rz_write_mask_set_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_write.c:528
static RzCmdStatus w_incdec_handler(RzCore *core, int argc, const char **argv, int inc_size)
Definition: cmd_write.c:321
RZ_IPI RzCmdStatus rz_write_base64_decode_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_write.c:130
RZ_IPI RzCmdStatus rz_write_op_div_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_write.c:705
RZ_IPI RzCmdStatus rz_write_from_io_xchg_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_write.c:162
RZ_IPI RzCmdStatus rz_write_debruijn_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_write.c:769
RZ_API ut64 rz_config_get_i(RzConfig *cfg, RZ_NONNULL const char *name)
Definition: config.c:119
RZ_API bool rz_config_get_b(RzConfig *cfg, RZ_NONNULL const char *name)
Definition: config.c:142
RZ_API int rz_cons_printf(const char *format,...)
Definition: cons.c:1202
static RzCmdStatus bool2status(bool val)
Definition: core_private.h:208
#define NULL
Definition: cris-opc.c:27
RZ_API int rz_crypto_update(RzCrypto *cry, const ut8 *buf, int len)
Definition: crypto.c:166
RZ_API bool rz_crypto_set_iv(RzCrypto *cry, const ut8 *iv, int ivlen)
Definition: crypto.c:161
RZ_API int rz_crypto_final(RzCrypto *cry, const ut8 *buf, int len)
Definition: crypto.c:170
RZ_API const ut8 * rz_crypto_get_output(RzCrypto *cry, int *size)
Definition: crypto.c:193
RZ_API bool rz_crypto_set_key(RzCrypto *cry, const ut8 *key, int keylen, int mode, int direction)
Definition: crypto.c:151
RZ_API void rz_crypto_free(RzCrypto *cry)
Definition: crypto.c:116
RZ_API RzCrypto * rz_crypto_new(void)
Definition: crypto.c:83
RZ_API bool rz_crypto_use(RzCrypto *cry, const char *algo)
Definition: crypto.c:130
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 key
Definition: sflib.h:118
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
static states step(struct re_guts *, sopno, sopno, states, int, states)
Definition: engine.c:888
struct tab * done
Definition: enough.c:233
RZ_API bool rz_core_hack(RzCore *core, const char *op)
Write/Modify instructions at current offset based on op.
Definition: hack.c:280
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
voidpf void uLong size
Definition: ioapi.h:138
const char * filename
Definition: ioapi.h:137
voidpf uLong offset
Definition: ioapi.h:144
voidpf void * buf
Definition: ioapi.h:138
uint8_t ut8
Definition: lh5801.h:11
void * p
Definition: libc.cpp:67
RZ_API RZ_OWN char * rz_core_editor(const RzCore *core, RZ_NULLABLE const char *file, RZ_NULLABLE const char *str)
Definition: core.c:3214
void * malloc(size_t size)
Definition: malloc.c:123
void * calloc(size_t number, size_t size)
Definition: malloc.c:102
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
static static fork const void static count static fd const char const char static newpath char char argv
Definition: sflib.h:40
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")
char * dst
Definition: lz4.h:724
line
Definition: setup.py:34
static const char hex[16]
Definition: print.c:21
#define eprintf(x, y...)
Definition: rlcc.c:7
static RzSocket * s
Definition: rtr.c:28
#define rz_return_val_if_fail(expr, val)
Definition: rz_assert.h:108
enum rz_cmd_status_t RzCmdStatus
@ RZ_CMD_STATUS_OK
command handler exited in the right way
Definition: rz_cmd.h:24
@ RZ_CMD_STATUS_WRONG_ARGS
command handler could not handle the arguments passed to it
Definition: rz_cmd.h:25
@ RZ_CMD_STATUS_ERROR
command handler had issues while running (e.g. allocation error, etc.)
Definition: rz_cmd.h:26
RzCoreWriteOp
Definition: rz_core.h:105
@ RZ_CORE_WRITE_OP_BYTESWAP8
Swap the endianess of 8-bytes values.
Definition: rz_core.h:108
@ RZ_CORE_WRITE_OP_SHIFT_LEFT
Write the shift left of existing byte by argument value.
Definition: rz_core.h:116
@ RZ_CORE_WRITE_OP_AND
Write the bitwise-and of existing byte and argument value.
Definition: rz_core.h:113
@ RZ_CORE_WRITE_OP_SHIFT_RIGHT
Write the shift right of existing byte and argument value.
Definition: rz_core.h:117
@ RZ_CORE_WRITE_OP_BYTESWAP2
Swap the endianess of 2-bytes values.
Definition: rz_core.h:106
@ RZ_CORE_WRITE_OP_OR
Write the bitwise-or of existing byte and argument value.
Definition: rz_core.h:114
@ RZ_CORE_WRITE_OP_ADD
Write the addition of existing byte and argument value.
Definition: rz_core.h:109
@ RZ_CORE_WRITE_OP_MUL
Write the multiplication of existing byte and argument value.
Definition: rz_core.h:112
@ RZ_CORE_WRITE_OP_DIV
Write the division of existing byte and argument value.
Definition: rz_core.h:111
@ RZ_CORE_WRITE_OP_BYTESWAP4
Swap the endianess of 4-bytes values.
Definition: rz_core.h:107
@ RZ_CORE_WRITE_OP_XOR
Write the bitwise-xor of existing byte and argument value.
Definition: rz_core.h:115
@ RZ_CORE_WRITE_OP_SUB
Write the subtraction of existing byte and argument value.
Definition: rz_core.h:110
RZ_API int rz_debruijn_offset(int start, const char *charset, ut64 value, bool is_big_endian)
Finds the offset of a given value in a debrujn sequence.
Definition: debruijn.c:112
RZ_API RZ_OWN char * rz_debruijn_pattern(int size, int start, const char *charset)
Generate a cyclic pattern following the Debruijn pattern.
Definition: debruijn.c:80
RZ_API bool rz_file_exists(const char *str)
Definition: file.c:192
RZ_API RZ_OWN char * rz_file_slurp(const char *str, RZ_NULLABLE size_t *usz)
Definition: file.c:454
RZ_API int rz_hex_str2bin(const char *in, ut8 *out)
Convert an input string in into the binary form in out.
Definition: hex.c:444
RZ_API int rz_io_cache_invalidate(RzIO *io, ut64 from, ut64 to)
Definition: io_cache.c:64
RZ_API bool rz_io_read_at(RzIO *io, ut64 addr, ut8 *buf, int len)
Definition: io.c:300
RZ_API void rz_io_cache_reset(RzIO *io, int set)
Definition: io_cache.c:57
RZ_API bool rz_io_desc_cache_commit(RzIODesc *desc)
Definition: p_cache.c:302
RZ_API bool rz_io_set_write_mask(RzIO *io, const ut8 *mask, int len)
Set a mask that is used on all following write operations.
Definition: io.c:517
RZ_API RzIODesc * rz_io_desc_get(RzIO *io, int fd)
Definition: io_desc.c:73
RZ_API bool rz_io_write_at(RzIO *io, ut64 addr, const ut8 *buf, int len)
Definition: io.c:358
RZ_API void rz_io_cache_commit(RzIO *io, ut64 from, ut64 to)
Definition: io_cache.c:35
RZ_API bool rz_io_use_fd(RzIO *io, int fd)
Definition: io_fd.c:118
#define RZ_LOG_INFO(fmtstr,...)
Definition: rz_log.h:54
#define RZ_LOG_ERROR(fmtstr,...)
Definition: rz_log.h:58
RZ_API ut64 rz_num_math(RzNum *num, const char *str)
Definition: unum.c:456
RZ_API int rz_num_is_valid_input(RzNum *num, const char *input_value)
Definition: unum.c:676
RZ_API RzSocket * rz_socket_accept(RzSocket *s)
Definition: socket.c:582
RZ_API bool rz_socket_listen(RzSocket *s, const char *port, const char *certfile)
Definition: socket.c:474
RZ_API void RZ_API int rz_socket_read(RzSocket *s, ut8 *read, int len)
Definition: socket.c:783
RZ_API RzSocket * rz_socket_new(bool is_ssl)
Definition: socket.c:179
RZ_API int rz_socket_free(RzSocket *s)
Definition: socket.c:453
RZ_API char * rz_str_array_join(const char **a, size_t n, const char *sep)
Definition: str.c:3861
RZ_API size_t rz_str_split(char *str, char ch)
Split string str in place by using ch as a delimiter.
Definition: str.c:406
#define RZ_NEWS(x, y)
Definition: rz_types.h:283
#define PFMT64d
Definition: rz_types.h:394
#define RZ_NEWS0(x, y)
Definition: rz_types.h:282
#define PFMT64x
Definition: rz_types.h:393
#define RZ_MIN(x, y)
#define st64
Definition: rz_types_base.h:10
#define UT64_MAX
Definition: rz_types_base.h:86
#define UT64_ADD_OVFCHK(x, y)
static struct sockaddr static addrlen static backlog const void static flags void struct sockaddr from
Definition: sfsocketcall.h:123
static struct sockaddr static addrlen static backlog const void static flags void struct sockaddr socklen_t static fromlen const void const struct sockaddr to
Definition: sfsocketcall.h:125
static int
Definition: sfsocketcall.h:114
#define c(i)
Definition: sha256.c:43
Represent the output state of a command handler.
Definition: rz_cmd.h:91
ut64 offset
Definition: rz_core.h:301
RzIO * io
Definition: rz_core.h:313
RzNum * num
Definition: rz_core.h:316
ut8 * block
Definition: rz_core.h:305
RzCoreFile * file
Definition: rz_core.h:314
ut32 blocksize
Definition: rz_core.h:303
RzConfig * config
Definition: rz_core.h:300
int cached
Definition: rz_io.h:69
struct rz_io_desc_t * desc
Definition: rz_io.h:60
int errors
Definition: rz_num.h:50
RzNumCalc nc
division by zero happened
Definition: rz_num.h:67
ut64 value
Definition: rz_num.h:63
Definition: dis.h:43
const char * command
Definition: main.c:7
Definition: dis.c:32
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
static const z80_opcode fd[]
Definition: z80_tab.h:997
static int addr
Definition: z80asm.c:58