Rizin
unix-like reverse engineering framework and cli tools
rz-gg.c
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2011-2020 pancake <pancake@nopcode.org>
2 // SPDX-License-Identifier: LGPL-3.0-only
3 
4 #include <rz_egg.h>
5 #include <rz_bin.h>
6 #include <rz_main.h>
7 #include <rz_util/rz_print.h>
8 #include <rz_util.h>
9 
10 static int usage(int v) {
11  printf("Usage: rz-gg [-FOLsrxhvz] [-a arch] [-b bits] [-k os] [-o file] [-I path]\n"
12  " [-i sc] [-e enc] [-B hex] [-c k=v] [-C file] [-p pad] [-q off]\n"
13  " [-S string] [-f fmt] [-nN dword] [-dDw off:hex] file|f.asm|-\n");
14  if (v) {
15  printf(
16  " -a [arch] select architecture (x86, mips, arm)\n"
17  " -b [bits] register size (32, 64, ..)\n"
18  " -B [hexpairs] append some hexpair bytes\n"
19  " -c [k=v] set configuration options\n"
20  " -C [file] append contents of file\n"
21  " -d [off:dword] patch dword (4 bytes) at given offset\n"
22  " -D [off:qword] patch qword (8 bytes) at given offset\n"
23  " -e [encoder] use specific encoder. see -L\n"
24  " -f [format] output format (raw, c, pe, elf, mach0, python, javascript)\n"
25  " -F output native format (osx=mach0, linux=elf, ..)\n"
26  " -h show this help\n"
27  " -i [shellcode] include shellcode plugin, uses options. see -L\n"
28  " -I [path] add include path\n"
29  " -k [os] operating system's kernel (linux,bsd,osx,w32)\n"
30  " -L list all plugins (shellcodes and encoders)\n"
31  " -n [dword] append 32bit number (4 bytes)\n"
32  " -N [dword] append 64bit number (8 bytes)\n"
33  " -o [file] output file\n"
34  " -O use default output file (filename without extension or a.out)\n"
35  " -p [padding] add padding after compilation (padding=n10s32)\n"
36  " ntas : begin nop, trap, 'a', sequence\n"
37  " NTAS : same as above, but at the end\n"
38  " -P [size] prepend debruijn pattern\n"
39  " -q [fragment] debruijn pattern offset\n"
40  " -r show raw bytes instead of hexpairs\n"
41  " -s show assembler\n"
42  " -S [string] append a string\n"
43  " -v show version\n"
44  " -w [off:hex] patch hexpairs at given offset\n"
45  " -x execute\n"
46  " -X [hexpairs] execute rop chain, using the stack provided\n"
47  " -z output in C string syntax\n");
48  }
49  return 1;
50 }
51 
52 static void list(RzEgg *egg) {
54  RzEggPlugin *p;
55  printf("shellcodes:\n");
56  rz_list_foreach (egg->plugins, iter, p) {
57  if (p->type == RZ_EGG_PLUGIN_SHELLCODE) {
58  printf("%10s : %s\n", p->name, p->desc);
59  }
60  }
61  printf("encoders:\n");
62  rz_list_foreach (egg->plugins, iter, p) {
63  if (p->type == RZ_EGG_PLUGIN_ENCODER) {
64  printf("%10s : %s\n", p->name, p->desc);
65  }
66  }
67 }
68 
69 static int create(const char *format, const char *arch, int bits, const ut8 *code, int codelen) {
70  RzBin *bin = rz_bin_new();
71  RzBinArchOptions opts;
72  RzBuffer *b;
74  b = rz_bin_create(bin, format, code, codelen, NULL, 0, &opts);
75  if (b) {
76  ut64 blen;
77  const ut8 *tmp = rz_buf_data(b, &blen);
78  if (write(1, tmp, blen) != blen) {
79  eprintf("Failed to write buffer\n");
80  }
81  rz_buf_free(b);
82  } else {
83  eprintf("Cannot create binary for this format '%s'.\n", format);
84  }
86  return 0;
87 }
88 
89 static int openfile(const char *f, int x) {
90  int fd = open(f, O_RDWR | O_CREAT, 0644);
91  if (fd == -1) {
92  fd = open(f, O_RDWR);
93  if (fd == -1) {
94  return -1;
95  }
96  }
97 #if __UNIX__
98  if (x) {
99  fchmod(fd, 0755);
100  }
101 #endif
102 #if _MSC_VER
103  int r = _chsize(fd, 0);
104 #else
105  int r = ftruncate(fd, 0);
106 #endif
107  if (r != 0) {
108  eprintf("Could not resize\n");
109  }
110  close(1);
111  dup2(fd, 1);
112  return fd;
113 }
114 #define ISEXEC (fmt != 'r')
115 
116 RZ_API int rz_main_rz_gg(int argc, const char **argv) {
117  const char *file = NULL;
118  const char *padding = NULL;
119  const char *pattern = NULL;
120  const char *str = NULL;
121  char *bytes = NULL;
122  const char *contents = NULL;
123  const char *arch = RZ_SYS_ARCH;
124  const char *os = RZ_EGG_OS_NAME;
125  const char *format = "raw";
126  bool show_execute = false;
127  bool show_execute_rop = false;
128  int show_hex = 1;
129  int show_asm = 0;
130  int show_raw = 0;
131  int append = 0;
132  int show_str = 0;
133  ut64 get_offset = 0;
134  const char *shellcode = NULL;
135  const char *encoder = NULL;
136  char *sequence = NULL;
137  int bits = (RZ_SYS_BITS & RZ_SYS_BITS_64) ? 64 : 32;
138  int fmt = 0;
139  const char *ofile = NULL;
140  int ofileauto = 0;
141  RzBuffer *b;
142  int c, i, fd = -1;
143  RzEgg *egg = rz_egg_new();
144 
145  RzGetopt opt;
146  rz_getopt_init(&opt, argc, argv, "n:N:he:a:b:f:o:sxXrk:FOI:Li:c:p:P:B:C:vd:D:w:zq:S:");
147  while ((c = rz_getopt_next(&opt)) != -1) {
148  switch (c) {
149  case 'a':
150  arch = opt.arg;
151  if (!strcmp(arch, "trace")) {
152  show_asm = 1;
153  show_hex = 0;
154  }
155  break;
156  case 'e':
157  encoder = opt.arg;
158  break;
159  case 'b':
160  bits = atoi(opt.arg);
161  break;
162  case 'B':
163  bytes = rz_str_append(bytes, opt.arg);
164  break;
165  case 'C':
166  if (RZ_STR_ISEMPTY(opt.arg)) {
167  eprintf("Cannot open empty contents path\n");
168  free(sequence);
169  rz_egg_free(egg);
170  return 1;
171  }
172  contents = opt.arg;
173  break;
174  case 'w': {
175  char *arg = strdup(opt.arg);
176  char *p = strchr(arg, ':');
177  if (p) {
178  int len, off;
179  ut8 *b;
180  *p++ = 0;
181  off = rz_num_math(NULL, arg);
182  b = malloc(strlen(opt.arg) + 1);
183  len = rz_hex_str2bin(p, b);
184  if (len > 0) {
185  rz_egg_patch(egg, off, (const ut8 *)b, len);
186  } else {
187  eprintf("Invalid hexstr for -w\n");
188  }
189  free(b);
190  } else {
191  eprintf("Missing colon in -w\n");
192  }
193  free(arg);
194  } break;
195  case 'n':
196  case 'N': {
197  ut64 n = rz_num_math(NULL, opt.arg);
198  // TODO: support big endian too
199  // (this is always little because rz_egg_setup is further below)
200  rz_egg_patch_num(egg, -1, n, c == 'N' ? 64 : 32);
201  append = 1;
202  } break;
203  case 'd':
204  case 'D': {
205  char *p = strchr(opt.arg, ':');
206  if (p) {
207  *p = '\0';
208  ut64 n, off = rz_num_math(NULL, opt.arg);
209  *p = ':';
210  n = rz_num_math(NULL, p + 1);
211  // TODO: support big endian too
212  // (this is always little because rz_egg_setup is further below)
213  rz_egg_patch_num(egg, off, n, c == 'D' ? 64 : 32);
214  } else {
215  eprintf("Missing colon in -%c\n", c);
216  }
217  } break;
218  case 'S':
219  str = opt.arg;
220  break;
221  case 'o':
222  ofile = opt.arg;
223  break;
224  case 'O':
225  ofileauto = 1;
226  break;
227  case 'I':
228  if (RZ_STR_ISEMPTY(opt.arg)) {
229  eprintf("Cannot open empty include path\n");
230  free(sequence);
231  rz_egg_free(egg);
232  return 1;
233  }
234  rz_egg_lang_include_path(egg, opt.arg);
235  break;
236  case 'i':
237  shellcode = opt.arg;
238  break;
239  case 'p':
240  padding = opt.arg;
241  break;
242  case 'P':
243  pattern = opt.arg;
244  break;
245  case 'c': {
246  char *p = strchr(opt.arg, '=');
247  if (p) {
248  *p++ = 0;
249  rz_egg_option_set(egg, opt.arg, p);
250  } else {
251  rz_egg_option_set(egg, opt.arg, "true");
252  }
253  } break;
254  case 'F':
255 #if __APPLE__
256  format = "mach0";
257 #elif __WINDOWS__
258  format = "pe";
259 #else
260  format = "elf";
261 #endif
262  show_asm = 0;
263  break;
264  case 'f':
265  format = opt.arg;
266  show_asm = 0;
267  break;
268  case 's':
269  show_asm = 1;
270  show_hex = 0;
271  break;
272  case 'k':
273  os = opt.arg;
274  break;
275  case 'r':
276  show_raw = 1;
277  break;
278  case 'x':
279  // execute
280  show_execute = true;
281  break;
282  case 'X':
283  // execute rop chain
284  show_execute = 1;
285  show_execute_rop = 1;
286  break;
287  case 'L':
288  list(egg);
289  rz_egg_free(egg);
290  free(sequence);
291  return 0;
292  case 'h':
293  rz_egg_free(egg);
294  free(sequence);
295  return usage(1);
296  case 'v':
297  free(sequence);
298  rz_egg_free(egg);
299  return rz_main_version_print("rz-gg");
300  case 'z':
301  show_str = 1;
302  break;
303  case 'q':
304  get_offset = 1;
305  sequence = strdup(opt.arg);
306  break;
307  default:
308  free(sequence);
309  rz_egg_free(egg);
310  return 1;
311  }
312  }
313 
314  if (opt.ind == argc && !shellcode && !bytes && !contents && !encoder && !padding && !pattern && !append && !get_offset && !str) {
315  free(sequence);
316  rz_egg_free(egg);
317  return usage(0);
318  } else {
319  file = argv[opt.ind];
320  }
321 
322  if (bits == 64) {
323  if (!strcmp(format, "mach0")) {
324  format = "mach064";
325  } else if (!strcmp(format, "elf")) {
326  format = "elf64";
327  }
328  }
329 
330  // catch this first
331  if (get_offset) {
332  if (strncmp(sequence, "0x", 2)) {
333  eprintf("Need hex value with `0x' prefix e.g. 0x41414142\n");
334  free(sequence);
335  rz_egg_free(egg);
336  return 1;
337  }
338 
339  get_offset = rz_num_math(0, sequence);
340  printf("Little endian: %d\n", rz_debruijn_offset(0, NULL, get_offset, false));
341  printf("Big endian: %d\n", rz_debruijn_offset(0, NULL, get_offset, true));
342  free(sequence);
343  rz_egg_free(egg);
344  return 0;
345  }
346 
347  // initialize egg
348  rz_egg_setup(egg, arch, bits, 0, os);
349  if (file) {
350  if (RZ_STR_ISEMPTY(file)) {
351  eprintf("Cannot open empty path\n");
352  goto fail;
353  }
354  if (!strcmp(file, "-")) {
355  char buf[1024];
356  for (;;) {
357  if (!fgets(buf, sizeof(buf), stdin)) {
358  break;
359  }
360  if (feof(stdin)) {
361  break;
362  }
363  rz_egg_load(egg, buf, 0);
364  }
365  } else {
366  if (!rz_egg_load_file(egg, file)) {
367  eprintf("Cannot load file \"%s\"\n", file);
368  }
369  }
370  }
371 
372  // compile source code to assembly
373  if (!rz_egg_compile(egg)) {
374  if (!fmt) {
375  eprintf("rz_egg_compile: fail\n");
376  free(sequence);
377  rz_egg_free(egg);
378  return 1;
379  }
380  }
381 
382  // append the provided string
383  if (str) {
384  int l = strlen(str);
385  if (l > 0) {
386  rz_egg_raw(egg, (const ut8 *)str, l);
387  }
388  }
389 
390  // add raw file
391  if (contents) {
392  size_t l;
393  char *buf = rz_file_slurp(contents, &l);
394  if (buf && l > 0) {
395  rz_egg_raw(egg, (const ut8 *)buf, (int)l);
396  } else {
397  eprintf("Error loading '%s'\n", contents);
398  }
399  free(buf);
400  }
401 
402  // add shellcode
403  if (shellcode) {
404  if (!rz_egg_shellcode(egg, shellcode)) {
405  eprintf("Unknown shellcode '%s'\n", shellcode);
406  goto fail;
407  }
408  }
409 
410  // add raw bytes
411  if (bytes) {
412  ut8 *b = malloc(strlen(bytes) + 1);
413  int len = rz_hex_str2bin(bytes, b);
414  if (len > 0) {
415  if (!rz_egg_raw(egg, b, len)) {
416  eprintf("Unknown '%s'\n", shellcode);
417  free(b);
418  goto fail;
419  }
420  } else {
421  eprintf("Invalid hexpair string for -B\n");
422  }
423  free(b);
424  free(bytes);
425  bytes = NULL;
426  }
427 
428  /* set output (create output file if needed) */
429  if (ofileauto) {
430  if (file) {
431  char *o, *q, *p = strdup(file);
432  if ((o = strchr(p, '.'))) {
433  while ((q = strchr(o + 1, '.'))) {
434  o = q;
435  }
436  *o = 0;
437  fd = openfile(p, ISEXEC);
438  } else {
439  fd = openfile("a.out", ISEXEC);
440  }
441  free(p);
442  } else {
443  fd = openfile("a.out", ISEXEC);
444  }
445  if (fd == -1) {
446  eprintf("cannot open file '%s'\n", opt.arg);
447  goto fail;
448  }
449  close(fd);
450  }
451  if (ofile) {
452  fd = openfile(ofile, ISEXEC);
453  if (fd == -1) {
454  eprintf("cannot open file '%s'\n", ofile);
455  goto fail;
456  }
457  }
458 
459  // assemble to binary
460  if (!rz_egg_assemble(egg)) {
461  eprintf("rz_egg_assemble: invalid assembly\n");
462  goto fail;
463  }
464  if (encoder) {
465  if (!rz_egg_encode(egg, encoder)) {
466  eprintf("Invalid encoder '%s'\n", encoder);
467  goto fail;
468  }
469  }
470 
471  // add padding
472  if (padding) {
473  rz_egg_padding(egg, padding);
474  }
475 
476  // add pattern
477  if (pattern) {
478  rz_egg_pattern(egg, rz_num_math(NULL, pattern));
479  }
480 
481  // apply patches
482  if (!egg->bin) {
483  egg->bin = rz_buf_new_with_bytes(NULL, 0);
484  }
485  if (!rz_egg_get_bin(egg)) {
486  eprintf("rz_egg_get_bin: invalid egg :(\n");
487  goto fail;
488  }
489  rz_egg_finalize(egg);
490 
491  if (show_asm) {
492  printf("%s\n", rz_egg_get_assembly(egg));
493  }
494 
495  if (show_raw || show_hex || show_execute) {
496  if (show_execute) {
497  int r;
498  if (show_execute_rop) {
499  r = rz_egg_run_rop(egg);
500  } else {
501  r = rz_egg_run(egg);
502  }
503  rz_egg_free(egg);
504  return r;
505  }
506  b = rz_egg_get_bin(egg);
507  if (show_raw) {
508  ut64 blen;
509  const ut8 *tmp = rz_buf_data(b, &blen);
510  if (write(1, tmp, blen) != blen) {
511  eprintf("Failed to write buffer\n");
512  goto fail;
513  }
514  } else {
515  if (!format) {
516  eprintf("No format specified\n");
517  goto fail;
518  }
519  char *code = NULL;
520  ut64 tmpsz;
521  const ut8 *tmp = rz_buf_data(b, &tmpsz);
522  switch (*format) {
523  case 'c':
525  printf("%s\n", code);
526  free(code);
527  break;
528  case 'j': // json
530  printf("%s\n", code);
531  free(code);
532  break;
533  case 'r':
534  if (show_str) {
535  printf("\"");
536  for (i = 0; i < tmpsz; i++) {
537  printf("\\x%02x", tmp[i]);
538  }
539  printf("\"\n");
540  } else if (show_hex) {
541  rz_buf_seek(b, 0, RZ_BUF_SET);
542  for (i = 0; i < tmpsz; i++) {
543  printf("%02x", tmp[i]);
544  }
545  printf("\n");
546  } // else show_raw is_above()
547  break;
548  case 'p': // PE
549  if (strlen(format) >= 2 && format[1] == 'y') { // Python
551  printf("%s\n", code);
552  free(code);
553  }
554  break;
555  case 'e': // ELF
556  case 'm': // MACH0
557  create(format, arch, bits, tmp, tmpsz);
558  break;
559  default:
560  eprintf("unknown executable format (%s)\n", format);
561  goto fail;
562  }
563  }
564  }
565  if (fd != -1) {
566  close(fd);
567  }
568  free(sequence);
569  rz_egg_free(egg);
570  return 0;
571 fail:
572  if (fd != -1) {
573  close(fd);
574  }
575  free(sequence);
576  rz_egg_free(egg);
577  return 1;
578 }
size_t len
Definition: 6502dis.c:15
lzma_index ** i
Definition: index.h:629
static ut8 bytes[32]
Definition: asm_arc.c:23
RZ_API RzBin * rz_bin_new(void)
Definition: bin.c:716
RZ_API void rz_bin_arch_options_init(RzBinArchOptions *opt, const char *arch, int bits)
Definition: bin.c:84
RZ_API RzBuffer * rz_bin_create(RzBin *bin, const char *p, const ut8 *code, int codelen, const ut8 *data, int datalen, RzBinArchOptions *opt)
Definition: bin.c:862
RZ_API void rz_bin_free(RzBin *bin)
Definition: bin.c:440
static ut64 get_offset(RzBinFile *bf, int type, int index)
Definition: bin_dex.c:206
int bits(struct state *s, int need)
Definition: blast.c:72
static char * ofile
Definition: cmd_magic.c:9
#define append(x, y)
Definition: cmd_print.c:1740
#define RZ_API
#define NULL
Definition: cris-opc.c:27
#define r
Definition: crypto_rc6.c:12
_Use_decl_annotations_ int __cdecl printf(const char *const _Format,...)
Definition: cs_driver.c:93
cs_arch arch
Definition: cstool.c:13
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 ftruncate
Definition: sflib.h:113
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 fchmod
Definition: sflib.h:84
static static fork write
Definition: sflib.h:33
static static fork const void static count close
Definition: sflib.h:33
const char * v
Definition: dsignal.c:12
RZ_API int rz_egg_shellcode(RzEgg *egg, const char *name)
Definition: egg.c:538
RZ_API int rz_egg_run_rop(RzEgg *egg)
Definition: egg.c:450
RZ_API void rz_egg_free(RzEgg *egg)
Definition: egg.c:111
RZ_API void rz_egg_finalize(RzEgg *egg)
Definition: egg.c:598
RZ_API RzEgg * rz_egg_new(void)
Definition: egg.c:44
RZ_API bool rz_egg_patch_num(RzEgg *egg, int off, ut64 num, ut32 bits)
Definition: egg.c:591
RZ_API bool rz_egg_load_file(RzEgg *egg, const char *file)
Definition: egg.c:214
RZ_API int rz_egg_padding(RzEgg *egg, const char *pad)
Definition: egg.c:472
RZ_API int rz_egg_run(RzEgg *egg)
Definition: egg.c:443
RZ_API int rz_egg_patch(RzEgg *egg, int off, const ut8 *buf, int len)
Definition: egg.c:576
RZ_API void rz_egg_pattern(RzEgg *egg, int size)
Definition: egg.c:625
RZ_API char * rz_egg_get_assembly(RzEgg *egg)
Definition: egg.c:434
RZ_API int rz_egg_encode(RzEgg *egg, const char *name)
Definition: egg.c:558
RZ_API int rz_egg_compile(RzEgg *egg)
Definition: egg.c:394
RZ_API RzBuffer * rz_egg_get_bin(RzEgg *egg)
Definition: egg.c:423
RZ_API void rz_egg_option_set(RzEgg *egg, const char *key, const char *val)
Definition: egg.c:530
RZ_API void rz_egg_load(RzEgg *egg, const char *code, int format)
Definition: egg.c:202
RZ_API bool rz_egg_assemble(RzEgg *egg)
Definition: egg.c:390
RZ_API bool rz_egg_setup(RzEgg *egg, const char *arch, int bits, int endian, const char *os)
Definition: egg.c:139
RZ_API int rz_egg_raw(RzEgg *egg, const ut8 *b, int len)
Definition: egg.c:281
RZ_API void rz_egg_lang_include_path(RzEgg *egg, const char *path)
Definition: egg_lang.c:149
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
voidpf void * buf
Definition: ioapi.h:138
uint8_t ut8
Definition: lh5801.h:11
void * p
Definition: libc.cpp:67
static int openfile(const char *f, int x)
Definition: rz-gg.c:89
static int usage(int v)
Definition: rz-gg.c:10
#define ISEXEC
Definition: rz-gg.c:114
static int create(const char *format, const char *arch, int bits, const ut8 *code, int codelen)
Definition: rz-gg.c:69
RZ_API int rz_main_rz_gg(int argc, const char **argv)
Definition: rz-gg.c:116
static void list(RzEgg *egg)
Definition: rz-gg.c:52
void * malloc(size_t size)
Definition: malloc.c:123
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")
static static fork const void static count static fd const char static mode const char static pathname const char static path const char static dev const char static group static getpid static getuid void void static data static pause const char static mode static sync const char const char static newpath const char static pathname unsigned long static filedes void static end_data_segment static handler static getegid char static len static pgid const char static path dup2
Definition: sflib.h:94
int x
Definition: mipsasm.c:20
int n
Definition: mipsasm.c:19
int off
Definition: pal.c:13
#define eprintf(x, y...)
Definition: rlcc.c:7
RZ_API st64 rz_buf_seek(RZ_NONNULL RzBuffer *b, st64 addr, int whence)
Modify the current cursor position in the buffer.
Definition: buf.c:1166
#define RZ_BUF_SET
Definition: rz_buf.h:14
RZ_API void rz_buf_free(RzBuffer *b)
Free all internal data hold by the buffer and the buffer.
Definition: buf.c:1253
RZ_API RZ_OWN RzBuffer * rz_buf_new_with_bytes(RZ_NULLABLE RZ_BORROW const ut8 *bytes, ut64 len)
Creates a new buffer with a bytes array.
Definition: buf.c:465
RZ_DEPRECATE RZ_API RZ_BORROW ut8 * rz_buf_data(RZ_NONNULL RzBuffer *b, RZ_NONNULL RZ_OUT ut64 *size)
Return a borrowed array of bytes representing the buffer data.
Definition: buf.c:1287
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
#define RZ_EGG_PLUGIN_SHELLCODE
Definition: rz_egg.h:19
#define RZ_EGG_PLUGIN_ENCODER
Definition: rz_egg.h:20
#define RZ_EGG_OS_NAME
Definition: rz_egg.h:148
RZ_API RZ_OWN char * rz_file_slurp(const char *str, RZ_NULLABLE size_t *usz)
Definition: file.c:454
RZ_API void rz_getopt_init(RzGetopt *go, int argc, const char **argv, const char *ostr)
Definition: getopt.c:17
RZ_API int rz_getopt_next(RzGetopt *opt)
Definition: getopt.c:29
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 RZ_OWN char * rz_lang_byte_array(RZ_NONNULL const ut8 *buffer, size_t size, RzLangByteArrayType type)
@ RZ_LANG_BYTE_ARRAY_C_CPP_BYTES
@ RZ_LANG_BYTE_ARRAY_PYTHON
@ RZ_LANG_BYTE_ARRAY_JSON
RZ_API int rz_main_version_print(const char *program)
Definition: main.c:49
RZ_API ut64 rz_num_math(RzNum *num, const char *str)
Definition: unum.c:456
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
@ RZ_SYS_BITS_64
Definition: rz_sys.h:21
#define RZ_SYS_BITS
Definition: rz_types.h:520
#define RZ_SYS_ARCH
Definition: rz_types.h:519
#define O_CREAT
Definition: sftypes.h:489
#define O_RDWR
Definition: sftypes.h:488
#define b(i)
Definition: sha256.c:42
#define f(i)
Definition: sha256.c:46
#define c(i)
Definition: sha256.c:43
Definition: malloc.c:26
Definition: inftree9.h:24
Definition: gzappend.c:170
RzList * plugins
Definition: rz_egg.h:103
RzBuffer * bin
Definition: rz_egg.h:96
const char * arg
Definition: rz_getopt.h:15
#define fail(test)
Definition: tests.h:29
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
static const z80_opcode fd[]
Definition: z80_tab.h:997