Rizin
unix-like reverse engineering framework and cli tools
rtr.c File Reference
#include "rz_core.h"
#include "rz_socket.h"
#include <libgdbr.h>
#include <gdbserver/core.h>
#include "rtr_http.c"
#include "rtr_shell.c"

Go to the source code of this file.

Classes

struct  rz_core_rtr_host_t
 
struct  TextLog
 
struct  RapThread
 

Macros

#define rtr_n   core->rtr_n
 
#define rtr_host   core->rtr_host
 

Functions

RZ_API void rz_core_wait (RzCore *core)
 
static void http_logf (RzCore *core, const char *fmt,...)
 
static char * rtrcmd (TextLog T, const char *str)
 
static void showcursor (RzCore *core, int x)
 
RZ_API int rz_core_rtr_http_stop (RzCore *u)
 
static char * rtr_dir_files (const char *path)
 
static void activateDieTime (RzCore *core)
 
static int write_reg_val (char *buf, ut64 sz, ut64 reg, int regsize, bool bigendian)
 
static int write_big_reg (char *buf, ut64 sz, const utX *val, int regsize, bool bigendian)
 
static int swap_big_regs (char *dest, ut64 sz, const char *src, int regsz)
 
static int rz_core_rtr_gdb_cb (libgdbr_t *g, void *core_ptr, const char *cmd, char *out_buf, size_t max_len)
 
static int rz_core_rtr_gdb_run (RzCore *core, int launch, const char *path)
 
RZ_API int rz_core_rtr_gdb (RzCore *core, int launch, const char *path)
 
RZ_API void rz_core_rtr_pushout (RzCore *core, const char *input)
 
RZ_API void rz_core_rtr_list (RzCore *core)
 
RZ_API void rz_core_rtr_add (RzCore *core, const char *_input)
 
RZ_API void rz_core_rtr_remove (RzCore *core, const char *input)
 
RZ_API void rz_core_rtr_session (RzCore *core, const char *input)
 
static bool rz_core_rtr_rap_run (RzCore *core, const char *input)
 
static void * rz_core_rtr_rap_thread (RapThread *rt)
 
RZ_API void rz_core_rtr_cmd (RzCore *core, const char *input)
 
RZ_API char * rz_core_rtr_cmds_query (RzCore *core, const char *host, const char *port, const char *cmd)
 
RZ_API bool rz_core_rtr_init (RZ_NONNULL RzCore *core)
 Allocates core rtr structure. More...
 
RZ_API int rz_core_rtr_cmds (RzCore *core, const char *port)
 

Variables

static RzSockets = NULL
 
static RzThreadrapthread = NULL
 
static const char * listenport = NULL
 

Macro Definition Documentation

◆ rtr_host

#define rtr_host   core->rtr_host

Definition at line 26 of file rtr.c.

◆ rtr_n

#define rtr_n   core->rtr_n

Definition at line 25 of file rtr.c.

Function Documentation

◆ activateDieTime()

static void activateDieTime ( RzCore core)
static

Definition at line 156 of file rtr.c.

156  {
157  int dt = rz_config_get_i(core->config, "http.dietime");
158  if (dt > 0) {
159 #if __UNIX__
160  rz_sys_signal(SIGALRM, dietime);
161  alarm(dt);
162 #else
163  eprintf("http.dietime only works on *nix systems\n");
164 #endif
165  }
166 }
RZ_API ut64 rz_config_get_i(RzConfig *cfg, RZ_NONNULL const char *name)
Definition: config.c:119
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 alarm
Definition: sflib.h:55
#define eprintf(x, y...)
Definition: rlcc.c:7
RZ_API int rz_sys_signal(int sig, void(*handler)(int))
Definition: sys.c:178
RzConfig * config
Definition: rz_core.h:300

References alarm, rz_core_t::config, eprintf, rz_config_get_i(), and rz_sys_signal().

Referenced by rz_core_rtr_http_run().

◆ http_logf()

static void http_logf ( RzCore core,
const char *  fmt,
  ... 
)
static

Definition at line 61 of file rtr.c.

61  {
62  bool http_log_enabled = rz_config_get_i(core->config, "http.log");
63  va_list ap;
64  va_start(ap, fmt);
65  if (http_log_enabled) {
66  const char *http_log_file = rz_config_get(core->config, "http.logfile");
67  if (http_log_file && *http_log_file) {
68  char *msg = calloc(4096, 1);
69  if (msg) {
70  vsnprintf(msg, 4095, fmt, ap);
71  rz_file_dump(http_log_file, (const ut8 *)msg, -1, true);
72  free(msg);
73  }
74  } else {
75  vfprintf(stderr, fmt, ap);
76  }
77  }
78  va_end(ap);
79 }
RZ_API RZ_BORROW const char * rz_config_get(RzConfig *cfg, RZ_NONNULL const char *name)
Definition: config.c:75
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
vsnprintf
Definition: kernel.h:366
uint8_t ut8
Definition: lh5801.h:11
void * calloc(size_t number, size_t size)
Definition: malloc.c:102
RZ_API bool rz_file_dump(const char *file, const ut8 *buf, int len, bool append)
Definition: file.c:838
static struct sockaddr static addrlen static backlog const void msg
Definition: sfsocketcall.h:119

References calloc(), rz_core_t::config, free(), msg, rz_config_get(), rz_config_get_i(), rz_file_dump(), and vsnprintf.

Referenced by rz_core_rtr_http_run().

◆ rtr_dir_files()

static char* rtr_dir_files ( const char *  path)
static

Definition at line 131 of file rtr.c.

131  {
132  char *ptr = strdup("<html><body>\n");
133  const char *file;
134  RzListIter *iter;
135  // list files
137  eprintf("Listing directory %s\n", path);
138  rz_list_foreach (files, iter, file) {
139  if (file[0] == '.') {
140  continue;
141  }
142  ptr = rz_str_appendf(ptr, "<a href=\"%s%s\">%s</a><br />\n",
143  path, file, file);
144  }
146  return rz_str_append(ptr, "</body></html>\n");
147 }
static static fork const void static count static fd const char const char static newpath const char static path const char path
Definition: sflib.h:35
checking print the parsed form of the magic use in n conjunction with m to debug a new magic file n before installing it n output MIME type special files
Definition: file_opts.h:46
RZ_API void rz_list_free(RZ_NONNULL RzList *list)
Empties the list and frees the list pointer.
Definition: list.c:137
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")
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
RZ_API RzList * rz_sys_dir(const char *path)
Definition: sys.c:216
Definition: gzappend.c:170
static int file
Definition: z80asm.c:58

References eprintf, file, files, path, rz_list_free(), rz_str_append(), rz_str_appendf(), rz_sys_dir(), and strdup().

Referenced by rz_core_rtr_http_run().

◆ rtrcmd()

static char* rtrcmd ( TextLog  T,
const char *  str 
)
static

Definition at line 81 of file rtr.c.

81  {
82  char *res, *ptr2;
83  char *ptr = rz_str_uri_encode(str);
84  char *uri = rz_str_newf("http://%s:%s/%s%s", T.host, T.port, T.file, ptr ? ptr : str);
85  int len;
86  free(ptr);
87  ptr2 = rz_socket_http_get(uri, NULL, &len);
88  free(uri);
89  if (ptr2) {
90  ptr2[len] = 0;
91  res = strstr(ptr2, "\n\n");
92  if (res) {
93  res = strstr(res + 1, "\n\n");
94  }
95  return res ? res + 2 : ptr2;
96  }
97  return NULL;
98 }
size_t len
Definition: 6502dis.c:15
#define T(op)
#define NULL
Definition: cris-opc.c:27
RZ_API char * rz_socket_http_get(const char *url, int *code, int *rlen)
Definition: socket_http.c:287
RZ_API char * rz_str_uri_encode(const char *buf)
Definition: str.c:2860
RZ_API char * rz_str_newf(const char *fmt,...) RZ_PRINTF_CHECK(1

References free(), len, NULL, rz_socket_http_get(), rz_str_newf(), rz_str_uri_encode(), cmd_descs_generate::str, and T.

Referenced by rtr_visual().

◆ rz_core_rtr_add()

RZ_API void rz_core_rtr_add ( RzCore core,
const char *  _input 
)

Definition at line 651 of file rtr.c.

651  {
652  char *port, input[1024], *file = NULL, *ptr = NULL;
653  int i, timeout, ret;
654  RzSocket *fd;
655 
656  timeout = rz_config_get_i(core->config, "http.timeout");
657  strncpy(input, _input, sizeof(input) - 4);
658  input[sizeof(input) - 4] = '\0';
659 
660  int proto = RTR_PROTOCOL_RAP;
661  char *host = (char *)rz_str_trim_head_ro(input);
662  char *pikaboo = strstr(host, "://");
663  if (pikaboo) {
664  struct {
665  const char *name;
666  int protocol;
667  } uris[7] = {
668  { "tcp", RTR_PROTOCOL_TCP },
669  { "udp", RTR_PROTOCOL_UDP },
670  { "rap", RTR_PROTOCOL_RAP },
671  { "r2p", RTR_PROTOCOL_RAP },
672  { "http", RTR_PROTOCOL_HTTP },
673  { "unix", RTR_PROTOCOL_UNIX },
674  { NULL, 0 }
675  };
676  char *s = rz_str_ndup(input, pikaboo - input);
677  // int nlen = pikaboo - input;
678  for (i = 0; uris[i].name; i++) {
679  if (rz_str_endswith(s, uris[i].name)) {
680  proto = uris[i].protocol;
681  host = pikaboo + 3;
682  break;
683  }
684  }
685  free(s);
686  }
687  if (host) {
688  if (!(ptr = strchr(host, ':'))) {
689  ptr = host;
690  port = "80";
691  } else {
692  *ptr++ = '\0';
693  port = ptr;
694  rz_str_trim(port);
695  }
696  } else {
697  port = NULL;
698  }
699  file = strchr(ptr, '/');
700  if (file) {
701  *file = 0;
702  file = (char *)rz_str_trim_head_ro(file + 1);
703  } else {
704  if (*host == ':' || strstr(host, "://:")) { // listen
705  // it's fine to listen without serving a file
706  } else {
707  file = "cmd/";
708  eprintf("Error: Missing '/'\n");
709  // c:wreturn;
710  }
711  }
712 
713  fd = rz_socket_new(false);
714  if (!fd) {
715  eprintf("Error: Cannot create new socket\n");
716  return;
717  }
718  switch (proto) {
719  case RTR_PROTOCOL_HTTP: {
720  int len;
721  char *uri = rz_str_newf("http://%s:%s/%s", host, port, file);
722  char *str = rz_socket_http_get(uri, NULL, &len);
723  if (!str) {
724  eprintf("Cannot find peer\n");
725  return;
726  }
727  core->num->value = 0;
728  // eprintf ("Connected to: 'http://%s:%s'\n", host, port);
729  free(str);
730  } break;
731  case RTR_PROTOCOL_RAP:
732  if (!rz_socket_connect_tcp(fd, host, port, timeout)) { // TODO: Use rap.ssl
733  eprintf("Error: Cannot connect to '%s' (%s)\n", host, port);
735  return;
736  } else {
737  int n = rz_socket_rap_client_open(fd, file, 0);
738  eprintf("opened as fd = %d\n", n);
739  }
740  break;
741  case RTR_PROTOCOL_UNIX:
742  if (!rz_socket_connect_unix(fd, host)) {
743  core->num->value = 1;
744  eprintf("Error: Cannot connect to 'unix://%s'\n", host);
746  return;
747  }
748  core->num->value = 0;
749  eprintf("Connected to: 'unix://%s'\n", host);
750  break;
751  case RTR_PROTOCOL_TCP:
752  if (!rz_socket_connect_tcp(fd, host, port, timeout)) { // TODO: Use rap.ssl
753  core->num->value = 1;
754  eprintf("Error: Cannot connect to '%s' (%s)\n", host, port);
756  return;
757  }
758  core->num->value = 0;
759  eprintf("Connected to: %s at port %s\n", host, port);
760  break;
761  case RTR_PROTOCOL_UDP:
762  if (!rz_socket_connect_udp(fd, host, port, timeout)) { // TODO: Use rap.ssl
763  core->num->value = 1;
764  eprintf("Error: Cannot connect to '%s' (%s)\n", host, port);
766  return;
767  }
768  core->num->value = 0;
769  eprintf("Connected to: %s at port %s\n", host, port);
770  break;
771  }
772  ret = core->num->value;
773  for (i = 0; i < RTR_MAX_HOSTS; i++) {
774  if (rtr_host[i].fd) {
775  continue;
776  }
777  rtr_host[i].proto = proto;
778  strncpy(rtr_host[i].host, host, sizeof(rtr_host[i].host) - 1);
779  rtr_host[i].port = rz_num_get(core->num, port);
780  if (!file) {
781  file = "";
782  }
783  strncpy(rtr_host[i].file, file, sizeof(rtr_host[i].file) - 1);
784  rtr_host[i].fd = fd;
785  rtr_n = i;
786  break;
787  }
788  core->num->value = ret;
789  // double free wtf is freed this here? rz_socket_free(fd);
790  // rz_core_rtr_list (core);
791 }
lzma_index ** i
Definition: index.h:629
int n
Definition: mipsasm.c:19
const char * name
Definition: op.c:541
static RzSocket * s
Definition: rtr.c:28
#define rtr_host
Definition: rtr.c:26
#define rtr_n
Definition: rtr.c:25
#define RTR_PROTOCOL_UNIX
Definition: rz_core.h:92
#define RTR_PROTOCOL_UDP
Definition: rz_core.h:90
#define RTR_MAX_HOSTS
Definition: rz_core.h:94
#define RTR_PROTOCOL_TCP
Definition: rz_core.h:89
#define RTR_PROTOCOL_RAP
Definition: rz_core.h:88
#define RTR_PROTOCOL_HTTP
Definition: rz_core.h:91
RZ_API ut64 rz_num_get(RzNum *num, const char *str)
Definition: unum.c:172
#define rz_socket_connect_unix(a, b)
Definition: rz_socket.h:104
RZ_API int rz_socket_rap_client_open(RzSocket *s, const char *file, int rw)
#define rz_socket_connect_tcp(a, b, c, d)
Definition: rz_socket.h:99
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
#define rz_socket_connect_udp(a, b, c, d)
Definition: rz_socket.h:100
RZ_API char * rz_str_ndup(RZ_NULLABLE const char *ptr, int len)
Create new copy of string ptr limited to size len.
Definition: str.c:1006
RZ_API const char * rz_str_trim_head_ro(const char *str)
Definition: str_trim.c:86
RZ_API void rz_str_trim(RZ_NONNULL RZ_INOUT char *str)
Removes whitespace characters (space, tab, newline etc.) from the beginning and end of a string.
Definition: str_trim.c:190
RZ_API bool rz_str_endswith(RZ_NONNULL const char *str, RZ_NONNULL const char *needle)
Checks if a string ends with a specifc sequence of characters (case sensitive)
Definition: str.c:3329
Definition: z80asm.h:102
RzNum * num
Definition: rz_core.h:316
ut64 value
Definition: rz_num.h:63
uv_timer_t timeout
Definition: main.c:9
static const z80_opcode fd[]
Definition: z80_tab.h:997
static bool input(void *ud, zip_uint8_t *data, zip_uint64_t length)

References rz_core_t::config, eprintf, fd, free(), i, input(), len, n, name, NULL, rz_core_t::num, rtr_host, RTR_MAX_HOSTS, rtr_n, RTR_PROTOCOL_HTTP, RTR_PROTOCOL_RAP, RTR_PROTOCOL_TCP, RTR_PROTOCOL_UDP, RTR_PROTOCOL_UNIX, rz_config_get_i(), rz_num_get(), rz_socket_connect_tcp, rz_socket_connect_udp, rz_socket_connect_unix, rz_socket_free(), rz_socket_http_get(), rz_socket_new(), rz_socket_rap_client_open(), rz_str_endswith(), rz_str_ndup(), rz_str_newf(), rz_str_trim(), rz_str_trim_head_ro(), s, cmd_descs_generate::str, timeout, and rz_num_t::value.

Referenced by rz_cmd_remote(), and rz_remote_add_handler().

◆ rz_core_rtr_cmd()

RZ_API void rz_core_rtr_cmd ( RzCore core,
const char *  input 
)

Definition at line 850 of file rtr.c.

850  {
851  unsigned int cmd_len = 0;
852  int fd = atoi(input);
853  if (!fd && *input != '0') {
854  fd = -1;
855  }
856  const char *cmd = strchr(rz_str_trim_head_ro(input), ' ');
857  if (cmd) {
858  cmd++;
859  cmd_len = strlen(cmd);
860  }
861  // "=:"
862  if (*input == ':' && !strchr(input + 1, ':')) {
863  void *bed = rz_cons_sleep_begin();
864  rz_core_rtr_rap_run(core, input);
865  rz_cons_sleep_end(bed);
866  return;
867  }
868 
869  if (*input == '&') { // "Rh&" "R&:9090"
870  if (rapthread) {
871  eprintf("RAP Thread is already running\n");
872  eprintf("This is experimental and probably buggy. Use at your own risk\n");
873  } else {
874  // TODO: use tasks
875  RapThread *rap_th = RZ_NEW0(RapThread);
876  if (!rap_th) {
877  RZ_LOG_ERROR("cannot allocate RapThread\n");
878  return;
879  }
880  rap_th->core = core;
881  rap_th->input = strdup(input + 1);
882  rap_th->loop = rz_atomic_bool_new(true);
883 
885  if (!rap_th) {
886  RZ_LOG_ERROR("cannot spawn the RzThread\n");
887  return;
888  }
889  int cpuaff = (int)rz_config_get_i(core->config, "cfg.cpuaffinity");
890  if (cpuaff) {
891  // modify the affinity only when the flag is actually set.
892  rz_th_set_affinity(rapthread, cpuaff);
893  }
894  rz_th_set_name(rapthread, "rapthread");
895  RZ_LOG_WARN("Background rap server started.\n");
896  }
897  return;
898  }
899 
900  if (fd != -1) {
901  if (fd >= 0 && fd < RTR_MAX_HOSTS) {
902  rtr_n = fd;
903  }
904  } else {
905  // XXX
906  cmd = input;
907  }
908 
909  if (!rtr_host[rtr_n].fd) {
910  eprintf("Error: Unknown host\n");
911  core->num->value = 1; // fail
912  return;
913  }
914 
915  if (rtr_host[rtr_n].proto == RTR_PROTOCOL_TCP) {
916  RzCoreRtrHost *rh = &rtr_host[rtr_n];
917  RzSocket *s = rh->fd;
918  if (cmd_len < 1 || cmd_len > 16384) {
919  return;
920  }
922  if (!rz_socket_connect(s, rh->host, sdb_fmt("%d", rh->port), RZ_SOCKET_PROTO_TCP, 0)) {
923  eprintf("Error: Cannot connect to '%s' (%d)\n", rh->host, rh->port);
924  rz_socket_free(s);
925  return;
926  }
927  rz_socket_write(s, (ut8 *)cmd, cmd_len);
928  rz_socket_write(s, "\n", 2);
929  int maxlen = 4096; // rz_read_le32 (blen);
930  char *cmd_output = calloc(1, maxlen + 1);
931  if (!cmd_output) {
932  eprintf("Error: Allocating cmd output\n");
933  return;
934  }
935  (void)rz_socket_read_block(s, (ut8 *)cmd_output, maxlen);
936  // ensure the termination
938  cmd_output[maxlen] = 0;
939  rz_cons_println(cmd_output);
940  free((void *)cmd_output);
941  return;
942  }
943 
944  if (rtr_host[rtr_n].proto == RTR_PROTOCOL_HTTP) {
945  RzCoreRtrHost *rh = &rtr_host[rtr_n];
946  if (cmd_len < 1 || cmd_len > 16384) {
947  return;
948  }
949  int len;
950  char *uri = rz_str_newf("http://%s:%d/cmd/%s", rh->host, rh->port, cmd);
951  char *str = rz_socket_http_get(uri, NULL, &len);
952  if (!str) {
953  eprintf("Cannot find '%s'\n", uri);
954  free(uri);
955  return;
956  }
957  core->num->value = 0;
958  str[len] = 0;
959  rz_cons_print(str);
960  free((void *)str);
961  free((void *)uri);
962  return;
963  }
964 
965  if (rtr_host[rtr_n].proto == RTR_PROTOCOL_RAP) {
966  core->num->value = 0; // that's fine
968  RzSocket *fh = rtr_host[rtr_n].fd;
969  if (!strlen(cmd)) {
970  // just check if we can connect
972  return;
973  }
974  char *cmd_output = rz_socket_rap_client_command(fh, cmd, &core->analysis->coreb);
975  rz_cons_println(cmd_output);
976  free(cmd_output);
977  return;
978  }
979  eprintf("Error: Unknown protocol\n");
980 }
FILE * fh
Definition: cabinfo.c:52
RZ_API void * rz_cons_sleep_begin(void)
Definition: cons.c:443
RZ_API void rz_cons_println(const char *str)
Definition: cons.c:233
RZ_API void rz_cons_sleep_end(void *user)
Definition: cons.c:450
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 cmd
Definition: sflib.h:79
RZ_API char * sdb_fmt(const char *fmt,...)
Definition: fmt.c:26
RZ_API bool rz_th_set_affinity(RZ_NONNULL RzThread *th, int cpuid)
Sets the thread cpu affinity.
Definition: thread.c:122
RZ_API RZ_OWN RzThread * rz_th_new(RZ_NONNULL RzThreadFunction function, RZ_NULLABLE void *user)
Creates and starts a new thread.
Definition: thread.c:198
RZ_API bool rz_th_set_name(RZ_NONNULL RzThread *th, RZ_NONNULL const char *name)
Sets the name of the thread.
Definition: thread.c:44
static void * rz_core_rtr_rap_thread(RapThread *rt)
Definition: rtr.c:838
static RzThread * rapthread
Definition: rtr.c:29
static bool rz_core_rtr_rap_run(RzCore *core, const char *input)
Definition: rtr.c:818
#define RZ_LOG_WARN(fmtstr,...)
Definition: rz_log.h:56
#define RZ_LOG_ERROR(fmtstr,...)
Definition: rz_log.h:58
RZ_API char * rz_socket_rap_client_command(RzSocket *s, const char *cmd, RzCoreBind *c)
RZ_API int rz_socket_close(RzSocket *s)
Definition: socket.c:419
RZ_API int rz_socket_read_block(RzSocket *s, unsigned char *buf, int len)
Definition: socket.c:808
RZ_API bool rz_socket_connect(RzSocket *s, const char *host, const char *port, int proto, unsigned int timeout)
Definition: socket.c:257
#define RZ_SOCKET_PROTO_TCP
Definition: rz_socket.h:87
RZ_API int rz_socket_write(RzSocket *s, void *buf, int len)
Definition: socket.c:724
void *(* RzThreadFunction)(void *user)
Definition: rz_th.h:28
#define RZ_NEW0(x)
Definition: rz_types.h:284
static int
Definition: sfsocketcall.h:114
Definition: rtr.c:46
RzAtomicBool * loop
Definition: rtr.c:49
RzCore * core
Definition: rtr.c:47
char * input
Definition: rtr.c:48
RzCoreBind coreb
Definition: rz_analysis.h:580
RzSocket * fd
Definition: rtr.c:37
char host[512]
Definition: rtr.c:34
RzAnalysis * analysis
Definition: rz_core.h:322
ut64 maxlen
Definition: core.c:76
RZ_API RZ_OWN RzAtomicBool * rz_atomic_bool_new(bool value)
Initialize a thread safe bool type container.
Definition: thread_types.c:24

References rz_core_t::analysis, calloc(), cmd, rz_core_t::config, RapThread::core, rz_analysis_t::coreb, eprintf, fd, rz_core_rtr_host_t::fd, fh, free(), rz_core_rtr_host_t::host, RapThread::input, input(), int, len, RapThread::loop, maxlen, NULL, rz_core_t::num, rz_core_rtr_host_t::port, rapthread, rtr_host, RTR_MAX_HOSTS, rtr_n, RTR_PROTOCOL_HTTP, RTR_PROTOCOL_RAP, RTR_PROTOCOL_TCP, rz_atomic_bool_new(), rz_config_get_i(), rz_cons_println(), rz_cons_sleep_begin(), rz_cons_sleep_end(), rz_core_rtr_rap_run(), rz_core_rtr_rap_thread(), RZ_LOG_ERROR, RZ_LOG_WARN, RZ_NEW0, rz_socket_close(), rz_socket_connect(), rz_socket_free(), rz_socket_http_get(), RZ_SOCKET_PROTO_TCP, rz_socket_rap_client_command(), rz_socket_read_block(), rz_socket_write(), rz_str_newf(), rz_str_trim_head_ro(), rz_th_new(), rz_th_set_affinity(), rz_th_set_name(), s, sdb_fmt(), cmd_descs_generate::str, strdup(), and rz_num_t::value.

Referenced by __rtr_shell(), handle_ts_stmt(), rz_cmd_remote(), rz_remote_handler(), rz_remote_rap_bg_handler(), and rz_remote_rap_handler().

◆ rz_core_rtr_cmds()

RZ_API int rz_core_rtr_cmds ( RzCore core,
const char *  port 
)

Definition at line 1225 of file rtr.c.

1225  {
1226  unsigned char buf[4097];
1227  RzSocket *ch = NULL;
1228  int i, ret;
1229  char *str;
1230 
1231  if (!port || port[0] == '?') {
1232  rz_cons_printf("Usage: .:[tcp-port] run rizin commands for clients\n");
1233  return false;
1234  }
1235 
1236  RzSocket *s = rz_socket_new(0);
1237  s->local = rz_config_get_i(core->config, "tcp.islocal");
1238 
1239  if (!rz_socket_listen(s, port, NULL)) {
1240  eprintf("Error listening on port %s\n", port);
1241  rz_socket_free(s);
1242  return false;
1243  }
1244 
1245  eprintf("Listening for commands on port %s\n", port);
1246  listenport = port;
1247  rz_cons_break_push((RzConsBreak)rz_core_rtr_http_stop, core);
1248  for (;;) {
1249  if (rz_cons_is_breaked()) {
1250  break;
1251  }
1252  void *bed = rz_cons_sleep_begin();
1253  ch = rz_socket_accept(s);
1254  buf[0] = 0;
1255  ret = rz_socket_read(ch, buf, sizeof(buf) - 1);
1256  rz_cons_sleep_end(bed);
1257  if (ret > 0) {
1258  buf[ret] = 0;
1259  for (i = 0; buf[i]; i++) {
1260  if (buf[i] == '\n') {
1261  buf[i] = buf[i + 1] ? ';' : '\0';
1262  }
1263  }
1264  if ((!rz_config_get_i(core->config, "scr.prompt") &&
1265  !strcmp((char *)buf, "q!")) ||
1266  !strcmp((char *)buf, ".--")) {
1267  rz_socket_close(ch);
1268  break;
1269  }
1270  str = rz_core_cmd_str(core, (const char *)buf);
1271  bed = rz_cons_sleep_begin();
1272  if (str && *str) {
1273  rz_socket_write(ch, str, strlen(str));
1274  } else {
1275  rz_socket_write(ch, "\n", 1);
1276  }
1277  rz_cons_sleep_end(bed);
1278  free(str);
1279  }
1280  rz_socket_close(ch);
1281  rz_socket_free(ch);
1282  ch = NULL;
1283  }
1285  rz_socket_free(s);
1286  rz_socket_free(ch);
1287  return 0;
1288 }
RZ_API char * rz_core_cmd_str(RzCore *core, const char *cmd)
Executes a rizin command and returns the stdout as a string.
Definition: cmd.c:5513
RZ_API void rz_cons_break_pop(void)
Definition: cons.c:361
RZ_API void rz_cons_break_push(RzConsBreak cb, void *user)
Definition: cons.c:357
RZ_API int rz_cons_printf(const char *format,...)
Definition: cons.c:1202
RZ_API bool rz_cons_is_breaked(void)
Definition: cons.c:373
voidpf void * buf
Definition: ioapi.h:138
static const char * listenport
Definition: rtr.c:30
RZ_API int rz_core_rtr_http_stop(RzCore *u)
Definition: rtr.c:110
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

References rz_core_t::config, eprintf, free(), i, listenport, rz_socket_t::local, NULL, rz_config_get_i(), rz_cons_break_pop(), rz_cons_break_push(), rz_cons_is_breaked(), rz_cons_printf(), rz_cons_sleep_begin(), rz_cons_sleep_end(), rz_core_cmd_str(), rz_core_rtr_http_stop(), rz_socket_accept(), rz_socket_close(), rz_socket_free(), rz_socket_listen(), rz_socket_new(), rz_socket_read(), rz_socket_write(), s, and cmd_descs_generate::str.

Referenced by rz_remote_tcp_handler().

◆ rz_core_rtr_cmds_query()

RZ_API char* rz_core_rtr_cmds_query ( RzCore core,
const char *  host,
const char *  port,
const char *  cmd 
)

Definition at line 983 of file rtr.c.

983  {
984  RzSocket *s = rz_socket_new(0);
985  const int timeout = 0;
986  char *rbuf = NULL;
987  int retries = 6;
988  ut8 buf[1024];
989 
990  for (; retries > 0; rz_sys_usleep(10 * 1000)) {
991  if (rz_socket_connect(s, host, port, RZ_SOCKET_PROTO_TCP, timeout)) {
992  break;
993  }
994  retries--;
995  }
996  if (retries > 0) {
997  rbuf = strdup("");
998  rz_socket_write(s, (void *)cmd, strlen(cmd));
999  // rz_socket_write (s, "px\n", 3);
1000  for (;;) {
1001  int ret = rz_socket_read(s, buf, sizeof(buf));
1002  if (ret < 1) {
1003  break;
1004  }
1005  buf[ret] = 0;
1006  rbuf = rz_str_append(rbuf, (const char *)buf);
1007  }
1008  } else {
1009  eprintf("Cannot connect\n");
1010  }
1011  rz_socket_free(s);
1012  return rbuf;
1013 }
RZ_API int rz_sys_usleep(int usecs)
Sleep for usecs microseconds.
Definition: sys.c:317

References cmd, eprintf, NULL, rz_socket_connect(), rz_socket_free(), rz_socket_new(), RZ_SOCKET_PROTO_TCP, rz_socket_read(), rz_socket_write(), rz_str_append(), rz_sys_usleep(), s, strdup(), and timeout.

Referenced by rz_remote_tcp_handler().

◆ rz_core_rtr_gdb()

RZ_API int rz_core_rtr_gdb ( RzCore core,
int  launch,
const char *  path 
)

Definition at line 571 of file rtr.c.

571  {
572  int ret;
573  // TODO: do stuff with launch
574  if (core->gdbserver_up) {
575  eprintf("gdbserver is already running\n");
576  return -1;
577  }
578  ret = rz_core_rtr_gdb_run(core, launch, path);
579  return ret;
580 }
static int rz_core_rtr_gdb_run(RzCore *core, int launch, const char *path)
Definition: rtr.c:480
int gdbserver_up
Definition: rz_core.h:356

References eprintf, rz_core_t::gdbserver_up, path, and rz_core_rtr_gdb_run().

Referenced by rz_equal_g_handler_old().

◆ rz_core_rtr_gdb_cb()

static int rz_core_rtr_gdb_cb ( libgdbr_t g,
void *  core_ptr,
const char *  cmd,
char *  out_buf,
size_t  max_len 
)
static

Definition at line 278 of file rtr.c.

279  {
280  int ret;
281  RzList *list;
282  RzListIter *iter;
284  RzRegItem *r;
285  utX val_big;
286  ut64 m_off, reg_val;
287  bool be;
288  RzDebugPid *dbgpid;
289  if (!core_ptr || !cmd) {
290  return -1;
291  }
292  RzCore *core = (RzCore *)core_ptr;
293  switch (cmd[0]) {
294  case '?': // Stop reason
295  if (!out_buf) {
296  return -1;
297  }
298  // dbg->reason.signum and dbg->reason.tid are not correct for native
299  // debugger. This is a hack
300  switch (core->dbg->reason.type) {
304  default: // remove when possible
305  return snprintf(out_buf, max_len - 1, "T05thread:%x;",
306  core->dbg->tid);
307  }
308  // Fallback for when it's fixed
309  /*
310  return snprintf (out_buf, max_len - 1, "T%02xthread:%x;",
311  core->dbg->reason.type, core->dbg->reason.tid);
312  */
313  case 'd':
314  switch (cmd[1]) {
315  case 'm': // dm
316  if (snprintf(out_buf, max_len - 1, "%" PFMT64x, rz_debug_get_baddr(core->dbg, NULL)) < 0) {
317  return -1;
318  }
319  return 0;
320  case 'p': // dp
321  switch (cmd[2]) {
322  case '\0': // dp
323  // TODO support multiprocess
324  snprintf(out_buf, max_len - 1, "QC%x", core->dbg->tid);
325  return 0;
326  case 't':
327  switch (cmd[3]) {
328  case '\0': // dpt
329  if (!core->dbg->cur->threads) {
330  return -1;
331  }
332  if (!(list = core->dbg->cur->threads(core->dbg, core->dbg->pid))) {
333  return -1;
334  }
335  memset(out_buf, 0, max_len);
336  out_buf[0] = 'm';
337  ret = 1;
338  rz_list_foreach (list, iter, dbgpid) {
339  // Max length of a hex pid = 8?
340  if (ret >= max_len - 9) {
341  break;
342  }
343  snprintf(out_buf + ret, max_len - ret - 1, "%x,", dbgpid->pid);
344  ret = strlen(out_buf);
345  }
346  if (ret > 1) {
347  ret--;
348  out_buf[ret] = '\0';
349  }
350  return 0;
351  case 'r': // dptr -> return current tid as int
352  return core->dbg->tid;
353  default:
354  return rz_core_cmd(core, cmd, 0);
355  }
356  }
357  break;
358  case 'r': // dr
359  rz_debug_reg_sync(core->dbg, RZ_REG_TYPE_ANY, false);
360  be = rz_config_get_i(core->config, "cfg.bigendian");
361  if (isspace((ut8)cmd[2])) { // dr reg
362  const char *name, *val_ptr;
363  char new_cmd[128] = { 0 };
364  int off = 0;
365  name = cmd + 3;
366  // Temporarily using new_cmd to store reg name
367  if ((val_ptr = strchr(name, '='))) {
368  strncpy(new_cmd, name, RZ_MIN(val_ptr - name, sizeof(new_cmd) - 1));
369  } else {
370  strncpy(new_cmd, name, sizeof(new_cmd) - 1);
371  }
372  if (!(r = rz_reg_get(core->dbg->reg, new_cmd, -1))) {
373  return -1;
374  }
375  if (val_ptr) { // dr reg=val
376  val_ptr++;
377  off = val_ptr - cmd;
378  if (be) {
379  // We don't need to swap
380  rz_core_cmd(core, cmd, 0);
381  }
382  // Previous contents are overwritten, since len(name) < off
383  strncpy(new_cmd, cmd, off);
384  if (r->size <= 64) {
385  reg_val = strtoll(val_ptr, NULL, 16);
386  if (write_reg_val(new_cmd + off, sizeof(new_cmd) - off - 1,
387  reg_val, r->size / 8, be) < 0) {
388  return -1;
389  }
390  return rz_core_cmd(core, new_cmd, 0);
391  }
392  // Big registers
393  if (swap_big_regs(new_cmd + off, sizeof(new_cmd) - off - 1,
394  val_ptr, r->size / 8) < 0) {
395  return -1;
396  }
397  return rz_core_cmd(core, new_cmd, 0);
398  }
399  if (r->size <= 64) {
400  reg_val = rz_reg_get_value(core->dbg->reg, r);
401  return write_reg_val(out_buf, max_len - 1,
402  reg_val, r->size / 8, be);
403  }
405  r, &val_big);
406  return write_big_reg(out_buf, max_len - 1,
407  &val_big, r->size / 8, be);
408  }
409  // dr - Print all registers
410  ret = 0;
411  if (!(gdb_reg = g->registers)) {
412  return -1;
413  }
414  while (*gdb_reg->name) {
415  if (ret + gdb_reg->size * 2 >= max_len - 1) {
416  return -1;
417  }
418  if (gdb_reg->size <= 8) {
419  reg_val = rz_reg_getv(core->dbg->reg, gdb_reg->name);
420  if (write_reg_val(out_buf + ret,
421  gdb_reg->size * 2 + 1,
422  reg_val, gdb_reg->size, be) < 0) {
423  return -1;
424  }
425  } else {
427  rz_reg_get(core->dbg->reg, gdb_reg->name, -1),
428  &val_big);
429  if (write_big_reg(out_buf + ret, gdb_reg->size * 2 + 1,
430  &val_big, gdb_reg->size, be) < 0) {
431  return -1;
432  }
433  }
434  ret += gdb_reg->size * 2;
435  gdb_reg++;
436  }
437  out_buf[ret] = '\0';
438  return ret;
439  default:
440  return rz_core_cmd(core, cmd, 0);
441  }
442  break;
443  case 'i':
444  switch (cmd[1]) {
445  case 'f': {
446  ut64 off, len, sz, namelen;
447  RzIODesc *desc = core && core->file ? rz_io_desc_get(core->io, core->file->fd) : NULL;
448  if (sscanf(cmd + 2, "%" PFMT64x ",%" PFMT64x, &off, &len) != 2) {
449  strcpy(out_buf, "E00");
450  return 0;
451  }
452  namelen = desc ? strlen(desc->name) : 0;
453  if (off >= namelen) {
454  out_buf[0] = 'l';
455  return 0;
456  }
457  sz = RZ_MIN(max_len, len + 2);
458  len = snprintf(out_buf, sz, "l%s", desc ? (desc->name + off) : "");
459  if (len >= sz) {
460  // There's more left
461  out_buf[0] = 'm';
462  }
463  return 0;
464  }
465  }
466  break;
467  case 'm':
468  sscanf(cmd + 1, "%" PFMT64x ",%x", &m_off, &ret);
469  if (rz_io_read_at(core->io, m_off, (ut8 *)out_buf, ret)) {
470  return ret;
471  }
472  return -1;
473  default:
474  return rz_core_cmd(core, cmd, 0);
475  }
476  return -1;
477 }
const char * desc
Definition: bin_vsf.c:19
RZ_API int rz_core_cmd(RzCore *core, const char *cstr, int log)
Definition: cmd.c:5328
static io_buf out_buf
Definition: coder.c:40
#define r
Definition: crypto_rc6.c:12
RZ_API int rz_debug_reg_sync(RzDebug *dbg, int type, int write)
Definition: dreg.c:9
struct @667 g
snprintf
Definition: kernel.h:364
return memset(p, 0, total)
RZ_API ut64 rz_debug_get_baddr(RzDebug *dbg, const char *file)
Definition: debug.c:1682
static void list(RzEgg *egg)
Definition: rz-gg.c:52
int off
Definition: pal.c:13
RZ_API ut64 rz_reg_getv(RzReg *reg, const char *name)
Definition: reg.c:332
RZ_API RzRegItem * rz_reg_get(RzReg *reg, const char *name, int type)
Definition: reg.c:344
static int write_reg_val(char *buf, ut64 sz, ut64 reg, int regsize, bool bigendian)
Definition: rtr.c:171
static int write_big_reg(char *buf, ut64 sz, const utX *val, int regsize, bool bigendian)
Definition: rtr.c:194
static int swap_big_regs(char *dest, ut64 sz, const char *src, int regsz)
Definition: rtr.c:231
RZ_API ut64 rz_reg_get_value_big(RzReg *reg, RzRegItem *item, utX *val)
Definition: rvalue.c:60
RZ_API ut64 rz_reg_get_value(RzReg *reg, RzRegItem *item)
Definition: rvalue.c:114
@ RZ_DEBUG_REASON_STEP
Definition: rz_debug.h:98
@ RZ_DEBUG_REASON_BREAKPOINT
Definition: rz_debug.h:94
@ RZ_DEBUG_REASON_TRAP
Definition: rz_debug.h:111
RZ_API bool rz_io_read_at(RzIO *io, ut64 addr, ut8 *buf, int len)
Definition: io.c:300
RZ_API RzIODesc * rz_io_desc_get(RzIO *io, int fd)
Definition: io_desc.c:73
@ RZ_REG_TYPE_ANY
Definition: rz_reg.h:35
#define PFMT64x
Definition: rz_types.h:393
#define RZ_MIN(x, y)
#define isspace(c)
Definition: safe-ctype.h:141
Definition: arch.h:13
char name[32]
Definition: arch.h:14
uint64_t size
Definition: arch.h:16
RzDebug * dbg
Definition: rz_core.h:329
RzIO * io
Definition: rz_core.h:313
RzCoreFile * file
Definition: rz_core.h:314
RzList *(* threads)(RzDebug *dbg, int pid)
Definition: rz_debug.h:375
RzDebugReason reason
Definition: rz_debug.h:276
struct rz_debug_plugin_t * cur
Definition: rz_debug.h:295
RzReg * reg
Definition: rz_debug.h:286
ut64(WINAPI *w32_GetEnabledXStateFeatures)()

References cmd, rz_core_t::config, rz_debug_t::cur, rz_core_t::dbg, desc, rz_core_file_t::fd, rz_core_t::file, g, rz_core_t::io, isspace, len, list(), memset(), name, gdb_reg::name, NULL, off, out_buf, PFMT64x, rz_debug_t::pid, rz_debug_pid_t::pid, r, rz_debug_t::reason, rz_debug_t::reg, rz_config_get_i(), rz_core_cmd(), rz_debug_get_baddr(), RZ_DEBUG_REASON_BREAKPOINT, RZ_DEBUG_REASON_STEP, RZ_DEBUG_REASON_TRAP, rz_debug_reg_sync(), rz_io_desc_get(), rz_io_read_at(), RZ_MIN, rz_reg_get(), rz_reg_get_value(), rz_reg_get_value_big(), rz_reg_getv(), RZ_REG_TYPE_ANY, gdb_reg::size, snprintf, swap_big_regs(), rz_debug_plugin_t::threads, rz_debug_t::tid, rz_debug_reason_t::type, ut64(), write_big_reg(), and write_reg_val().

Referenced by rz_core_rtr_gdb_run().

◆ rz_core_rtr_gdb_run()

static int rz_core_rtr_gdb_run ( RzCore core,
int  launch,
const char *  path 
)
static

Definition at line 480 of file rtr.c.

480  {
481  RzSocket *sock;
482  int p, ret;
483  bool debug_msg = false;
484  char port[10];
485  char *file = NULL, *args = NULL;
486  libgdbr_t *g;
487 
488  if (!core || !path) {
489  return -1;
490  }
491  if (*path == '!') {
492  debug_msg = true;
493  path++;
494  }
495  if (!(path = rz_str_trim_head_ro(path)) || !*path) {
496  eprintf("gdbserver: Port not specified\n");
497  return -1;
498  }
499  if (!(p = atoi(path)) || p < 0 || p > 65535) {
500  eprintf("gdbserver: Invalid port: %s\n", port);
501  return -1;
502  }
503  snprintf(port, sizeof(port) - 1, "%d", p);
504  if (!(file = strchr(path, ' '))) {
505  eprintf("gdbserver: File not specified\n");
506  return -1;
507  }
508  if (!(file = (char *)rz_str_trim_head_ro(file)) || !*file) {
509  eprintf("gdbserver: File not specified\n");
510  return -1;
511  }
512  args = strchr(file, ' ');
513  if (args) {
514  *args++ = '\0';
515  if (!(args = (char *)rz_str_trim_head_ro(args))) {
516  args = "";
517  }
518  } else {
519  args = "";
520  }
521 
522  if (!rz_core_file_open(core, file, RZ_PERM_R, 0)) {
523  eprintf("Cannot open file (%s)\n", file);
524  return -1;
525  }
526  ut64 baddr = rz_config_get_i(core->config, "bin.baddr");
527  rz_core_bin_load(core, NULL, baddr);
529 
530  if (!(sock = rz_socket_new(false))) {
531  eprintf("gdbserver: Could not open socket for listening\n");
532  return -1;
533  }
534  if (!rz_socket_listen(sock, port, NULL)) {
535  rz_socket_free(sock);
536  eprintf("gdbserver: Cannot listen on port: %s\n", port);
537  return -1;
538  }
539  if (!(g = RZ_NEW0(libgdbr_t))) {
540  rz_socket_free(sock);
541  eprintf("gdbserver: Cannot alloc libgdbr instance\n");
542  return -1;
543  }
544  gdbr_init(g, true);
545  g->server_debug = debug_msg;
546  int arch = rz_sys_arch_id(rz_config_get(core->config, "asm.arch"));
547  int bits = rz_config_get_i(core->config, "asm.bits");
549  core->gdbserver_up = 1;
550  eprintf("gdbserver started on port: %s, file: %s\n", port, file);
551 
552  for (;;) {
553  if (!(g->sock = rz_socket_accept(sock))) {
554  break;
555  }
556  g->connected = 1;
557  ret = gdbr_server_serve(g, rz_core_rtr_gdb_cb, (void *)core);
558  rz_socket_close(g->sock);
559  g->connected = 0;
560  if (ret < 0) {
561  break;
562  }
563  }
564  core->gdbserver_up = 0;
565  gdbr_cleanup(g);
566  free(g);
567  rz_socket_free(sock);
568  return 0;
569 }
static ut64 baddr(RzBinFile *bf)
Definition: bin_any.c:58
int bits(struct state *s, int need)
Definition: blast.c:72
RZ_API void rz_core_file_reopen_debug(RzCore *core, const char *args)
Definition: cfile.c:269
RZ_API RZ_BORROW RzCoreFile * rz_core_file_open(RZ_NONNULL RzCore *r, RZ_NONNULL const char *file, int flags, ut64 loadaddr)
Tries to open the file as is, otherwise tries as is a compilation of files.
Definition: cfile.c:1182
RZ_API bool rz_core_bin_load(RZ_NONNULL RzCore *r, RZ_NULLABLE const char *filenameuri, ut64 baddr)
Definition: cfile.c:942
cs_arch arch
Definition: cstool.c:13
void * p
Definition: libc.cpp:67
bool gdbr_set_architecture(libgdbr_t *g, int arch, int bits)
Function initializes the architecture of the gdbsession.
Definition: libgdbr.c:52
int gdbr_cleanup(libgdbr_t *g)
frees all buffers and cleans the libgdbr instance stuff
Definition: libgdbr.c:146
int gdbr_init(libgdbr_t *g, bool is_server)
Function initializes the libgdbr lib.
Definition: libgdbr.c:9
int args
Definition: mipsasm.c:18
static int rz_core_rtr_gdb_cb(libgdbr_t *g, void *core_ptr, const char *cmd, char *out_buf, size_t max_len)
Definition: rtr.c:278
RZ_API int rz_sys_arch_id(const char *arch)
Definition: sys.c:788
#define RZ_PERM_R
Definition: rz_types.h:93
int gdbr_server_serve(libgdbr_t *g, gdbr_server_cmd_cb cmd_cb, void *core_ptr)
Definition: core.c:495

References arch, args, baddr(), bits(), rz_core_t::config, eprintf, free(), g, gdbr_cleanup(), gdbr_init(), gdbr_server_serve(), gdbr_set_architecture(), rz_core_t::gdbserver_up, NULL, p, path, rz_config_get(), rz_config_get_i(), rz_core_bin_load(), rz_core_file_open(), rz_core_file_reopen_debug(), rz_core_rtr_gdb_cb(), RZ_NEW0, RZ_PERM_R, rz_socket_accept(), rz_socket_close(), rz_socket_free(), rz_socket_listen(), rz_socket_new(), rz_str_trim_head_ro(), rz_sys_arch_id(), snprintf, and ut64().

Referenced by rz_core_rtr_gdb().

◆ rz_core_rtr_http_stop()

RZ_API int rz_core_rtr_http_stop ( RzCore u)

Definition at line 110 of file rtr.c.

110  {
111  RzCore *core = (RzCore *)u;
112  const int timeout = 1; // 1 second
113  const char *port;
114  RzSocket *sock;
115 
116 #if __WINDOWS__
118 #endif
119  if (((size_t)u) > 0xff) {
120  port = listenport ? listenport : rz_config_get(core->config, "http.port");
121  sock = rz_socket_new(0);
122  (void)rz_socket_connect(sock, "localhost",
124  rz_socket_free(sock);
125  }
126  rz_socket_free(s);
127  s = NULL;
128  return 0;
129 }
RZ_API RzCons * rz_cons_singleton(void)
Definition: cons.c:300
RZ_API void rz_socket_http_server_set_breaked(bool *b)

References rz_core_t::config, listenport, NULL, rz_config_get(), rz_cons_singleton(), rz_socket_connect(), rz_socket_free(), rz_socket_http_server_set_breaked(), rz_socket_new(), RZ_SOCKET_PROTO_TCP, s, and timeout.

Referenced by rz_core_rtr_cmds(), and rz_core_rtr_http_run().

◆ rz_core_rtr_init()

RZ_API bool rz_core_rtr_init ( RZ_NONNULL RzCore core)

Allocates core rtr structure.

Parameters
coreRzCore to initialize rtr structure

Definition at line 1020 of file rtr.c.

1020  {
1021  rz_return_val_if_fail(core, false);
1023  return rtr_host;
1024 }
#define rz_return_val_if_fail(expr, val)
Definition: rz_assert.h:108
#define RZ_NEWS0(x, y)
Definition: rz_types.h:282

References rtr_host, RTR_MAX_HOSTS, RZ_NEWS0, and rz_return_val_if_fail.

Referenced by rz_core_init().

◆ rz_core_rtr_list()

RZ_API void rz_core_rtr_list ( RzCore core)

Definition at line 631 of file rtr.c.

631  {
632  int i;
633  for (i = 0; i < RTR_MAX_HOSTS; i++) {
634  if (!rtr_host[i].fd) {
635  continue;
636  }
637  const char *proto = "rap";
638  switch (rtr_host[i].proto) {
639  case RTR_PROTOCOL_HTTP: proto = "http"; break;
640  case RTR_PROTOCOL_TCP: proto = "tcp"; break;
641  case RTR_PROTOCOL_UDP: proto = "udp"; break;
642  case RTR_PROTOCOL_RAP: proto = "rap"; break;
643  case RTR_PROTOCOL_UNIX: proto = "unix"; break;
644  }
645  rz_cons_printf("%d fd:%i %s://%s:%i/%s\n",
646  i, (int)rtr_host[i].fd->fd, proto, rtr_host[i].host,
647  rtr_host[i].port, rtr_host[i].file);
648  }
649 }

References fd, i, rtr_host, RTR_MAX_HOSTS, RTR_PROTOCOL_HTTP, RTR_PROTOCOL_RAP, RTR_PROTOCOL_TCP, RTR_PROTOCOL_UDP, RTR_PROTOCOL_UNIX, and rz_cons_printf().

Referenced by rz_cmd_remote(), and rz_remote_handler().

◆ rz_core_rtr_pushout()

RZ_API void rz_core_rtr_pushout ( RzCore core,
const char *  input 
)

Definition at line 582 of file rtr.c.

582  {
583  int fd = atoi(input);
584  const char *cmd = NULL;
585  char *str = NULL;
586  if (fd) {
587  for (rtr_n = 0; rtr_host[rtr_n].fd && rtr_n < RTR_MAX_HOSTS - 1; rtr_n++) {
588  if (rtr_host[rtr_n].fd->fd != fd) {
589  continue;
590  }
591  }
592  if (!(cmd = strchr(input, ' '))) {
593  eprintf("Error\n");
594  return;
595  }
596  } else {
597  cmd = input;
598  }
599 
600  if (!rtr_host[rtr_n].fd || !rtr_host[rtr_n].fd->fd) {
601  eprintf("Error: Unknown host\n");
602  return;
603  }
604 
605  if (!(str = rz_core_cmd_str(core, cmd))) {
606  eprintf("Error: rizin_cmd_str returned NULL\n");
607  return;
608  }
609 
610  switch (rtr_host[rtr_n].proto) {
611  case RTR_PROTOCOL_RAP:
612  eprintf("Error: Cannot use '=<' to a rap connection.\n");
613  break;
614  case RTR_PROTOCOL_UNIX:
615  rz_socket_write(rtr_host[rtr_n].fd, str, strlen(str));
616  break;
617  case RTR_PROTOCOL_HTTP:
618  eprintf("TODO\n");
619  break;
620  case RTR_PROTOCOL_TCP:
621  case RTR_PROTOCOL_UDP:
622  rz_socket_write(rtr_host[rtr_n].fd, str, strlen(str));
623  break;
624  default:
625  eprintf("Unknown protocol\n");
626  break;
627  }
628  free(str);
629 }

References cmd, eprintf, fd, free(), input(), NULL, rtr_host, RTR_MAX_HOSTS, rtr_n, RTR_PROTOCOL_HTTP, RTR_PROTOCOL_RAP, RTR_PROTOCOL_TCP, RTR_PROTOCOL_UDP, RTR_PROTOCOL_UNIX, rz_core_cmd_str(), rz_socket_write(), and cmd_descs_generate::str.

Referenced by rz_cmd_remote(), and rz_remote_send_handler().

◆ rz_core_rtr_rap_run()

static bool rz_core_rtr_rap_run ( RzCore core,
const char *  input 
)
static

Definition at line 818 of file rtr.c.

818  {
819  char *file = rz_str_newf("rap://%s", input);
820  int flags = RZ_PERM_RW;
821  RzIODesc *fd = rz_io_open_nomap(core->io, file, flags, 0644);
822  if (fd) {
823  if (rz_io_is_listener(core->io)) {
824  if (!rz_core_serve(core, fd)) {
825  rz_cons_singleton()->context->breaked = true;
826  }
828  // avoid double free, we are not the owners of this fd so we can't destroy it
829  // rz_io_desc_free (fd);
830  }
831  } else {
832  rz_cons_singleton()->context->breaked = true;
833  }
834  return !rz_cons_singleton()->context->breaked;
835  // rz_core_cmdf (core, "o rap://%s", input);
836 }
RZ_API bool rz_core_serve(RzCore *core, RzIODesc *file)
Definition: core.c:2904
RZ_API bool rz_io_is_listener(RzIO *io)
Definition: io.c:404
RZ_API RzIODesc * rz_io_open_nomap(RzIO *io, const char *uri, int flags, int mode)
Definition: io.c:145
RZ_API bool rz_io_desc_close(RzIODesc *desc)
Definition: io_desc.c:165
#define RZ_PERM_RW
Definition: rz_types.h:96
static struct sockaddr static addrlen static backlog const void static flags void flags
Definition: sfsocketcall.h:123
RzConsContext * context
Definition: rz_cons.h:502

References rz_cons_context_t::breaked, rz_cons_t::context, fd, flags, input(), rz_core_t::io, rz_cons_singleton(), rz_core_serve(), rz_io_desc_close(), rz_io_is_listener(), rz_io_open_nomap(), RZ_PERM_RW, and rz_str_newf().

Referenced by rz_core_rtr_cmd(), and rz_core_rtr_rap_thread().

◆ rz_core_rtr_rap_thread()

static void* rz_core_rtr_rap_thread ( RapThread rt)
static

Definition at line 838 of file rtr.c.

838  {
839  if (!rt || !rt->core) {
840  return false;
841  }
842  bool loop = true;
843  while (loop) {
844  loop = rz_atomic_bool_get(rt->loop) &&
845  rz_core_rtr_rap_run(rt->core, rt->input);
846  }
847  return NULL;
848 }
uv_loop_t * loop
Definition: main.c:7
RZ_API bool rz_atomic_bool_get(RZ_NONNULL RzAtomicBool *tbool)
Gets the current value hold by the RzAtomicBool structure.
Definition: thread_types.c:54

References RapThread::core, RapThread::input, RapThread::loop, loop, NULL, rz_atomic_bool_get(), and rz_core_rtr_rap_run().

Referenced by rz_core_rtr_cmd().

◆ rz_core_rtr_remove()

RZ_API void rz_core_rtr_remove ( RzCore core,
const char *  input 
)

Definition at line 793 of file rtr.c.

793  {
794  int i;
795 
796  if (IS_DIGIT(input[0])) {
797  i = rz_num_math(core->num, input);
798  if (i >= 0 && i < RTR_MAX_HOSTS) {
800  rtr_host[i].fd = NULL;
801  }
802  } else {
803  for (i = 0; i < RTR_MAX_HOSTS; i++) {
804  if (rtr_host[i].fd) {
806  rtr_host[i].fd = NULL;
807  }
808  }
809  memset(rtr_host, '\0', RTR_MAX_HOSTS * sizeof(RzCoreRtrHost));
810  rtr_n = 0;
811  }
812 }
RZ_API ut64 rz_num_math(RzNum *num, const char *str)
Definition: unum.c:456
#define IS_DIGIT(x)
Definition: rz_str_util.h:11

References fd, i, input(), IS_DIGIT, memset(), NULL, rz_core_t::num, rtr_host, RTR_MAX_HOSTS, rtr_n, rz_num_math(), and rz_socket_free().

Referenced by rz_cmd_remote(), and rz_remote_del_handler().

◆ rz_core_rtr_session()

RZ_API void rz_core_rtr_session ( RzCore core,
const char *  input 
)

Definition at line 814 of file rtr.c.

814  {
815  __rtr_shell(core, atoi(input));
816 }
static void __rtr_shell(RzCore *core, int nth)
Definition: rtr_shell.c:182

References __rtr_shell(), and input().

Referenced by rz_cmd_remote(), and rz_remote_open_handler().

◆ rz_core_wait()

RZ_API void rz_core_wait ( RzCore core)

Definition at line 52 of file rtr.c.

52  {
54  if (rapthread) {
56  rz_atomic_bool_set(rt->loop, false);
58  }
59 }
RZ_API RZ_OWN void * rz_th_get_user(RZ_NONNULL RzThread *th)
Returns user pointer of thread.
Definition: thread.c:263
RZ_API bool rz_th_wait(RZ_NONNULL RzThread *th)
Awaits indefinetely for a thread to join.
Definition: thread.c:231
RZ_API void rz_atomic_bool_set(RZ_NONNULL RzAtomicBool *tbool, bool value)
Sets the value int the RzAtomicBool structure.
Definition: thread_types.c:68

References rz_cons_context_t::breaked, rz_cons_t::context, RapThread::loop, rapthread, rz_atomic_bool_set(), rz_cons_singleton(), rz_th_get_user(), and rz_th_wait().

Referenced by rz_core_fini().

◆ showcursor()

static void showcursor ( RzCore core,
int  x 
)
static

Definition at line 100 of file rtr.c.

100  {
101  if (core && core->vmode) {
103  rz_cons_enable_mouse(x ? rz_config_get_i(core->config, "scr.wheel") : false);
104  } else {
105  rz_cons_enable_mouse(false);
106  }
107  rz_cons_flush();
108 }
RZ_API bool rz_cons_enable_mouse(const bool enable)
Definition: cons.c:500
RZ_API void rz_cons_show_cursor(int cursor)
Definition: cons.c:1581
RZ_API void rz_cons_flush(void)
Definition: cons.c:959
int x
Definition: mipsasm.c:20
bool vmode
Definition: rz_core.h:309

References rz_core_t::config, rz_config_get_i(), rz_cons_enable_mouse(), rz_cons_flush(), rz_cons_show_cursor(), rz_core_t::vmode, and x.

◆ swap_big_regs()

static int swap_big_regs ( char *  dest,
ut64  sz,
const char *  src,
int  regsz 
)
static

Definition at line 231 of file rtr.c.

231  {
232  utX val;
233  char sdup[128] = { 0 };
234  if (!src || !src[0] || !src[1]) {
235  return -1;
236  }
237  strncpy(sdup, src + 2, sizeof(sdup) - 1);
238  int len = strlen(sdup);
239  memset(&val, 0, sizeof(val));
240  switch (regsz) {
241  case 10:
242  if (len <= 4) {
243  val.v80.High = (ut16)strtoul(sdup, NULL, 16);
244  } else {
245  val.v80.High = (ut16)strtoul(sdup + (len - 4), NULL, 16);
246  sdup[len - 4] = '\0';
247  val.v80.Low = (ut64)strtoull(sdup, NULL, 16);
248  }
249  return snprintf(dest, sz, "0x%04x%016" PFMT64x,
250  val.v80.High, val.v80.Low);
251  case 12:
252  if (len <= 8) {
253  val.v96.High = (ut32)strtoul(sdup, NULL, 16);
254  } else {
255  val.v96.High = (ut32)strtoul(sdup + (len - 8), NULL, 16);
256  sdup[len - 8] = '\0';
257  val.v96.Low = (ut64)strtoull(sdup, NULL, 16);
258  }
259  return snprintf(dest, sz, "0x%08x%016" PFMT64x,
260  val.v96.High, val.v96.Low);
261  case 16:
262  if (len <= 16) {
263  val.v128.High = (ut64)strtoul(sdup, NULL, 16);
264  } else {
265  val.v128.High = (ut64)strtoul(sdup + (len - 16), NULL, 16);
266  sdup[len - 16] = '\0';
267  val.v128.Low = (ut64)strtoull(sdup, NULL, 16);
268  }
269  return snprintf(dest, sz, "0x%016" PFMT64x "%016" PFMT64x,
270  val.v128.High, val.v128.Low);
271  default:
272  eprintf("%s: big registers (%d byte(s)) not yet supported\n",
273  __func__, regsz);
274  return -1;
275  }
276 }
lzma_index * src
Definition: index.h:567
ut16 val
Definition: armass64_const.h:6
uint16_t ut16
uint32_t ut32
char * dest
Definition: lz4.h:697

References dest, eprintf, len, memset(), NULL, PFMT64x, snprintf, src, ut64(), and val.

Referenced by rz_core_rtr_gdb_cb().

◆ write_big_reg()

static int write_big_reg ( char *  buf,
ut64  sz,
const utX val,
int  regsize,
bool  bigendian 
)
static

Definition at line 194 of file rtr.c.

194  {
195  switch (regsize) {
196  case 10:
197  if (bigendian) {
198  return snprintf(buf, sz,
199  "%04x%016" PFMT64x, val->v80.High,
200  val->v80.Low);
201  }
202  return snprintf(buf, sz,
203  "%016" PFMT64x "%04x", rz_swap_ut64(val->v80.Low),
204  rz_swap_ut16(val->v80.High));
205  case 12:
206  if (bigendian) {
207  return snprintf(buf, sz,
208  "%08" PFMT32x "%016" PFMT64x, val->v96.High,
209  val->v96.Low);
210  }
211  return snprintf(buf, sz,
212  "%016" PFMT64x "%08" PFMT32x, rz_swap_ut64(val->v96.Low),
213  rz_swap_ut32(val->v96.High));
214  case 16:
215  if (bigendian) {
216  return snprintf(buf, sz,
217  "%016" PFMT64x "%016" PFMT64x, val->v128.High,
218  val->v128.Low);
219  }
220  return snprintf(buf, sz,
221  "%016" PFMT64x "%016" PFMT64x,
222  rz_swap_ut64(val->v128.Low),
223  rz_swap_ut64(val->v128.High));
224  default:
225  eprintf("%s: big registers (%d byte(s)) not yet supported\n",
226  __func__, regsize);
227  return -1;
228  }
229 }
#define PFMT32x
static ut32 rz_swap_ut32(ut32 val)
Definition: rz_endian.h:580
static ut16 rz_swap_ut16(ut16 val)
Definition: rz_endian.h:571
static ut64 rz_swap_ut64(ut64 val)
Definition: rz_endian.h:590

References eprintf, PFMT32x, PFMT64x, rz_swap_ut16(), rz_swap_ut32(), rz_swap_ut64(), snprintf, and val.

Referenced by rz_core_rtr_gdb_cb().

◆ write_reg_val()

static int write_reg_val ( char *  buf,
ut64  sz,
ut64  reg,
int  regsize,
bool  bigendian 
)
static

Definition at line 171 of file rtr.c.

171  {
172  if (!bigendian) {
173  switch (regsize) {
174  case 2:
175  reg = rz_swap_ut16(reg);
176  break;
177  case 4:
178  reg = rz_swap_ut32(reg);
179  break;
180  case 8:
181  reg = rz_swap_ut64(reg);
182  break;
183  default:
184  eprintf("%s: Unsupported reg size: %d\n",
185  __func__, regsize);
186  return -1;
187  }
188  }
189  return snprintf(buf, sz, regsize == 2 ? "%04" PFMT64x : regsize == 4 ? "%08" PFMT64x
190  : "%016" PFMT64x,
191  reg);
192 }
#define reg(n)

References eprintf, PFMT64x, reg, rz_swap_ut16(), rz_swap_ut32(), rz_swap_ut64(), and snprintf.

Referenced by rz_core_rtr_gdb_cb().

Variable Documentation

◆ listenport

const char* listenport = NULL
static

Definition at line 30 of file rtr.c.

Referenced by rz_core_rtr_cmds(), and rz_core_rtr_http_stop().

◆ rapthread

RzThread* rapthread = NULL
static

Definition at line 29 of file rtr.c.

Referenced by rz_core_rtr_cmd(), and rz_core_wait().

◆ s

RzSocket* s = NULL
static

Definition at line 28 of file rtr.c.

Referenced by __calculator_cb(), __create_default_panels(), __create_iter_sections(), __esil_step_range_cb(), __fortune_cb(), __getUtf8Length(), __getUtf8Length2(), __hashify(), __is_true_or_false(), __isAnsiSequence(), __nth_nibble(), __parse_string_on_cursor(), __print_hexdump_cb(), __print_stack_cb(), __rap_lseek(), __rap_open(), __rap_read(), __rap_system(), __rap_write(), __replaceRegisters(), __rtr_shell(), __set_cmd_str_cache(), __set_read_only(), _cb_hit(), _fill_bin_import(), _fill_bin_symbol(), _insert_into_disk(), _remove_afer_insert(), _tr_align(), _tr_flush_bits(), _tr_flush_block(), _tr_init(), _tr_stored_block(), _tr_tally(), _zip_read_string(), _zip_string_crc32(), _zip_string_free(), _zip_string_length(), _zip_string_new(), _zip_string_write(), add_footer(), analysis_class_print(), annotated_hexdump(), arcAnalyzeInstr(), arch_xap_disasm(), ARCTangent_decodeInstr(), arg(), arg_p(), arg_p2(), args_preprocessing(), argv_call_cb(), asciiart_backtrace(), ascmatch(), asn1_stringify_tag(), assemble(), autocmplt_arch(), autocmplt_at_stmt(), autocmplt_bits(), autocmplt_bits_plugin(), autocmplt_cmd_arg(), autocmplt_cmd_arg_alias_type(), autocmplt_cmd_arg_any_type(), autocmplt_cmd_arg_choices(), autocmplt_cmd_arg_enum_type(), autocmplt_cmd_arg_env(), autocmplt_cmd_arg_eval_full(), autocmplt_cmd_arg_eval_key(), autocmplt_cmd_arg_fcn(), autocmplt_cmd_arg_fcn_var(), autocmplt_cmd_arg_file(), autocmplt_cmd_arg_flag(), autocmplt_cmd_arg_global_var(), autocmplt_cmd_arg_help_var(), autocmplt_cmd_arg_macro(), autocmplt_cmd_arg_reg_filter(), autocmplt_cmd_arg_reg_type(), autocmplt_cmd_arg_rznum(), autocmplt_cmd_arg_struct_type(), autocmplt_cmd_arg_union_type(), autocmplt_cmdidentifier(), autocmplt_flag_space(), autocmplt_reg(), autocomplete_flagspaces(), autocomplete_process_path(), autocompleteFilename(), backref(), backtrace_vars(), bi_flush(), bi_windup(), bin_section_from_section(), bin_section_from_segment(), bin_symbol_from_symbol(), bits(), blast(), brute_force_match(), buffer_flush(), buffer_init(), buffer_putalign(), buffer_putflush(), build_bl_tree(), build_immediate_table(), build_tree(), bytes_to_skip(), call_cd(), cb_asmarch(), check_label(), chunk_fini(), clusterLoadConfig(), clusterLookupNode(), clusterRenameNode(), cmd_print_blocks(), cmd_print_fromage(), cmd_pxr(), codes(), collect_changes(), compress_block(), compute_dtable(), compute_itable(), cons_stack_free(), core_esil_init(), core_objc_new(), cplus_demangle_fill_name(), crc32(), cris_constraint(), d_append_buffer(), d_append_string(), d_array_type(), d_expr_primary(), d_growable_string_append_buffer(), d_growable_string_callback_adapter(), d_identifier(), d_make_demangle_mangled_name(), d_make_name(), d_substitution(), decode(), decode_fixed(), decode_known(), decomp(), DEFINE_HANDLE_TS_FCN_AND_SYMBOL(), deflate(), deflate_fast(), deflate_huff(), deflate_rle(), deflate_slow(), deflate_stored(), deflateBound(), deflateGetDictionary(), deflateInit2_(), deflateParams(), deflatePrime(), deflateResetKeep(), deflateSetDictionary(), deflateStateCheck(), deflateTune(), demangle_classname(), detect_data_type(), dfs_node(), disasm_strings(), disassemble(), do_handle_ts_unescape_arg(), do_iter_offsets(), doinsert(), ds_newline(), ds_print_esil_analysis(), ds_print_ptr(), dynamic(), emit_string(), empty_signature(), encode_immediate_bitfield(), end_state(), env(), error(), escape_special_chars(), esil_add(), esil_addeq(), esil_bits(), esil_dec(), esil_div(), esil_diveq(), esil_inc(), esil_mem_addeq_n(), esil_mem_andeq_n(), esil_mem_deceq_n(), esil_mem_diveq_n(), esil_mem_inceq_n(), esil_mem_lsleq_n(), esil_mem_lsreq_n(), esil_mem_modeq_n(), esil_mem_muleq_n(), esil_mem_oreq_n(), esil_mem_subeq_n(), esil_mem_xoreq_n(), esil_mod(), esil_modeq(), esil_mul(), esil_muleq(), esil_set_delay_slot(), esil_set_jump_target(), esil_set_jump_target_set(), esil_signed_div(), esil_signed_mod(), esil_sub(), esil_subeq(), esil_trap(), export_base_type_cb(), export_callable_cb(), export_typelink_cb(), exprmatchreg(), exprtoken(), fcnjoin(), file_showstr(), fill_autocmplt_data_cmdarg(), fill_children_chars(), fill_window(), findBreakChar(), findEnd(), findmust(), fixed(), flush_pending(), format_output(), fseek_u32(), gen_bitlen(), get_cf_offset(), get_class_ro_t(), get_crossing_matrix(), get_die_name(), get_ext_suffix(), get_fcn_name(), get_float_object(), get_graph_string(), get_import_addr_x86_manual(), get_max_common_pfx(), get_operand(), get_operator_code(), get_segments(), get_specification_die_name(), get_symbols(), get_symbols_list(), get_va_symbol(), getbytes(), getnum(), getrange(), GetSegmentHeapBlocks(), getstr(), getstring(), getswi(), go_uvariant(), gprobe_getdeviceid(), gzputs(), handle_ts_stmt(), TestArm::hexString2Byte(), TestArm64::hexString2Byte(), TestM680x::hexString2Byte(), TestMips::hexString2Byte(), TestPpc::hexString2Byte(), TestSparc::hexString2Byte(), TestSystemz::hexString2Byte(), TestX86::hexString2Byte(), TestXcore::hexString2Byte(), hudstuff_append(), inBetween(), index_stream_end(), index_stream_init(), init_block(), init_crc32_table(), init_crc64_table(), initializeEsil(), INST_HANDLER(), is_at_cmd(), is_comment(), is_data_section(), is_env_cmd(), is_file_symbol(), is_imported_symbol(), is_interpret_cmd(), is_number(), is_pf_cmd(), is_remote_cmd(), is_section_symbol(), is_special_symbol(), isSkippable(), keyHashSlot(), libdemangle_handler_swift(), lm_init(), load_ctx_init(), load_token(), longest_match(), LZ4_calloc(), LZ4_compress_destSize_extState(), LZ4_malloc(), LZ4_wildCopy8(), LZ4IO_readLE32(), LZMA_API(), lzma_sha256_init(), M68K_getInstruction(), major_minor(), match(), mcopy(), meta_count_for(), meta_unset_for(), mget(), mips_assemble(), mpc_ast_state(), mpc_noneof(), mpc_oneof(), mpc_print_unretained(), mpc_range(), mpc_state_invalid(), mpc_state_new(), mpc_string(), mpc_sym(), mpc_test_fail(), mpc_test_pass(), mpca_stmt_list_apply_to(), mpcaf_grammar_char(), mpcaf_grammar_id(), mpcaf_grammar_string(), mpcf_escape_new(), mpcf_input_state_ast(), mpcf_re_escape(), mpcf_re_range(), mpcf_state_ast(), mpcf_strtriml(), mpcf_strtrimr(), mpcf_unescape_new(), name_space_cmp(), next_inst(), nextword(), noned_decompress(), nonreturn_print(), nonreturn_print_json(), ns_free_exc_list(), ns_sync(), num_callback(), objc_name_toc(), objc_type_toc(), offset_comp(), operator<<(), overlaps_with_token(), pager_all_matches(), pager_splitlines(), parse(), parse_atomic_type(), parse_dbi_dbg_header(), parse_dbi_stream(), parse_dbi_stream_ex_header(), parse_dbi_stream_header(), parse_format(), parse_gdata_stream(), parse_offset(), parse_omap_stream(), parse_options(), parse_pdb_stream(), parse_pe_stream(), parse_size(), parse_tmp_evals(), parse_tpi_stream(), parse_tpi_stream_header(), parse_type(), parseHeap(), pj_d(), pj_f(), pj_i(), pj_N(), pj_n(), TestBasic.platform::platform(), pluscount(), pqdownheap(), print_addr(), print_bin_string(), print_crc32_table(), print_crc64_table(), print_insn_hppa(), print_insn_lanai(), print_insn_mips16(), print_insn_sparc(), print_section(), print_source_info(), print_string(), print_with_operands(), processNode(), puff(), putShortMSB(), rax(), rcc_next(), rcc_set_callname(), rd_label(), re_assemble_16(), read_be16(), read_bin(), read_variable_length(), references_handler(), replace_buffer_text(), replace_file_contents(), replace_whitespaces(), replaceWords(), reverse_bits(), reverse_bits_8(), reverse_lt_8bits(), revert_cdiv_magic(), rotl(), rotr(), rz_agraph_add_node_with_color(), rz_analysis_add_device_peripheral_map(), rz_analysis_function_xrefs_handler(), rz_analysis_get_jmptbl_info(), rz_analysis_noreturn_functions(), rz_analysis_stackop_tostring(), rz_asm_pseudo_intN(), rz_asm_token_string_new(), rz_asm_tokenize_asm_regex(), rz_asn1_create_string(), rz_bin_addr2line(), rz_bin_addr2text(), rz_bin_le_get_sections(), rz_bin_ne_get_entrypoints(), rz_bin_ne_get_relocs(), rz_bin_object_get_vaddr(), rz_bin_section_new(), rz_bin_source_line_sample_is_closing(), rz_bin_symbol_name(), rz_cmd_alias_set(), rz_cmd_debug(), rz_cmd_debug_continue_mapped_io_handler(), rz_cmd_debug_step_prog_handler(), rz_cmd_help(), rz_cmd_info_section_bars_handler(), rz_cmd_kuery(), rz_cmd_print(), rz_cmd_search(), rz_cmd_state_output_print(), rz_comment_unique_handler(), rz_cons_breakword(), rz_cons_canvas_write(), rz_cons_get_buffer_dup(), rz_cons_hud_file(), rz_cons_hud_string(), rz_core_analysis_address(), rz_core_analysis_cc_init(), rz_core_analysis_coverage_count(), rz_core_analysis_hasrefs_to_depth(), rz_core_analysis_stats_free(), rz_core_analysis_stats_get_block_from(), rz_core_analysis_stats_get_block_to(), rz_core_arch_bits_at(), rz_core_bin_pdb_load(), rz_core_bin_print_source_line_sample(), rz_core_bin_sections_print(), rz_core_clippy(), rz_core_cmd_foreach3(), rz_core_cmd_str_pipe(), rz_core_cmd_subst_i(), rz_core_file_loadlib(), rz_core_get_boundaries_prot(), rz_core_get_section_name(), rz_core_meta_print(), rz_core_print_scrollbar(), rz_core_print_scrollbar_bottom(), rz_core_project_load_for_cli(), rz_core_rtr_add(), rz_core_rtr_cmd(), rz_core_rtr_cmds(), rz_core_rtr_cmds_query(), rz_core_rtr_http_run(), rz_core_rtr_http_stop(), rz_core_spaces_print(), rz_core_sym_is_export(), rz_core_visual_cmd(), rz_core_visual_hudstuff(), rz_core_visual_trackflags(), rz_core_write_base64_at(), rz_core_write_base64d_at(), rz_core_write_length_string_at(), rz_core_write_string_at(), rz_core_write_string_wide_at(), rz_core_write_string_zero_at(), rz_debug_bochs_reg_read(), rz_debug_traces_ascii(), rz_egg_lang_include_init(), rz_file_copy(), rz_file_root(), rz_get_size(), rz_hex_from_py_str(), rz_id_storage_list(), rz_io_zip_flush_file(), rz_leb128(), rz_line_completion_push(), rz_line_readchar_utf8(), rz_main_rizin(), rz_main_rz_agent(), rz_main_rz_asm(), rz_mem_dup(), rz_meta_set_string(), rz_num_conditional(), rz_num_get(), rz_num_math(), RZ_PACKED(), rz_parse_assemble(), rz_pkcs7_cms_json(), rz_pkcs7_cms_to_string(), rz_print_addr(), rz_print_byte(), rz_print_hexdump_str(), rz_print_hexpair(), rz_print_json_human(), rz_print_json_indent(), rz_print_json_path(), rz_print_offset_sg(), rz_project_migrate_v1_v2(), rz_project_migrate_v2_v3(), rz_project_migrate_v3_v4(), rz_rbtree_aug_delete(), rz_read_at_be16(), rz_read_at_be24(), rz_read_at_be32(), rz_read_at_be64(), rz_read_at_be_double(), rz_read_at_be_float(), rz_read_at_le16(), rz_read_at_le32(), rz_read_at_le64(), rz_read_at_le_double(), rz_read_at_le_float(), rz_read_at_me16(), rz_read_at_me32(), rz_read_at_me64(), rz_read_at_me_double(), rz_read_at_me_float(), rz_read_be16(), rz_read_be32(), rz_read_le16(), rz_read_le32(), rz_read_me16(), rz_read_me32(), rz_read_me32_arc(), rz_reg_cc_handler(), rz_regex_error(), rz_reopen_debug_rzrun_handler(), rz_run_parsefile(), rz_scan_strings_raw(), rz_search_aes_update(), rz_search_begin(), rz_search_deltakey_update(), rz_search_find(), rz_search_free(), rz_search_hit_new(), rz_search_kw_add(), rz_search_kw_reset(), rz_search_mybinparse_update(), rz_search_new(), rz_search_pattern(), rz_search_pattern_size(), rz_search_privkey_update(), rz_search_regexp_update(), rz_search_reset(), rz_search_set_callback(), rz_search_set_distance(), rz_search_set_mode(), rz_search_set_string_limits(), rz_search_string_prepare_backward(), rz_search_strings_update(), rz_search_update(), rz_search_update_i(), rz_socket_accept(), rz_socket_accept_timeout(), rz_socket_block_time(), rz_socket_close(), rz_socket_close_fd(), rz_socket_connect(), rz_socket_flush(), rz_socket_free(), rz_socket_gets(), rz_socket_http_accept(), rz_socket_http_post(), rz_socket_is_connected(), rz_socket_listen(), rz_socket_new(), rz_socket_new_from_fd(), rz_socket_printf(), rz_socket_proc_gets(), rz_socket_proc_printf(), rz_socket_proc_read(), rz_socket_proc_ready(), rz_socket_proc_write(), rz_socket_puts(), rz_socket_rap_client_command(), rz_socket_rap_client_open(), rz_socket_rap_client_read(), rz_socket_rap_client_seek(), rz_socket_rap_client_write(), rz_socket_rap_server_accept(), rz_socket_rap_server_continue(), rz_socket_rap_server_free(), rz_socket_rap_server_listen(), rz_socket_rap_server_new(), rz_socket_read(), rz_socket_read_block(), rz_socket_ready(), rz_socket_slurp(), rz_socket_spawn(), rz_socket_to_string(), rz_socket_write(), rz_spaces_add(), rz_spaces_count(), rz_spaces_pop(), rz_spaces_rename(), rz_spaces_unset(), rz_stack_free(), rz_stack_is_empty(), rz_stack_new(), rz_stack_newf(), rz_stack_peek(), rz_stack_pop(), rz_stack_push(), rz_stack_size(), rz_str_ansi_crop(), rz_str_char_fullwidth(), rz_str_closer_chr(), rz_str_djb2_hash(), rz_str_firstbut(), rz_str_is_false(), rz_str_is_true(), rz_str_lastbut(), rz_str_len_utf8(), rz_str_len_utf8char(), rz_str_nextword(), rz_str_nstr(), rz_str_prefix_all(), rz_str_replace_ch(), rz_str_replace_char(), rz_str_replace_char_once(), rz_str_rstr(), rz_str_sanitize_sdb_key(), rz_str_scale(), rz_str_split_lines(), rz_str_str_xy(), rz_str_trim_lines(), rz_str_trim_nc(), rz_str_trim_path(), rz_str_uri_decode(), rz_str_uri_encode(), rz_str_utf16_decode(), rz_str_utf16_encode(), rz_str_utf8_codepoint(), rz_str_word_set0_stack(), rz_strbuf_append(), rz_strbuf_append_n(), rz_strbuf_new(), rz_strbuf_prepend(), rz_strbuf_set(), rz_strbuf_setbin(), rz_strbuf_setptr(), rz_strbuf_slice(), rz_strpool_append(), rz_strpool_fit(), rz_strpool_get_i(), rz_strpool_get_index(), rz_strpool_memcat(), rz_sys_chdir(), rz_sys_signal(), rz_syscall_free(), rz_syscall_get(), rz_syscall_get_i(), rz_syscall_get_num(), rz_syscall_get_swi(), rz_syscall_item_new_from_string(), rz_syscall_list(), rz_syscall_setup(), rz_sysreg_get(), rz_sysreg_item_free(), rz_sysreg_set_arch(), rz_table_tofancystring(), rz_table_tostring(), rz_table_visual_list(), rz_test_main(), rz_type_db_struct_names(), rz_type_format_data_internal(), rz_type_format_uleb(), rz_uleb128(), rz_uleb128_decode(), rz_uleb128_encode(), rz_write_from_socket_handler(), rz_wstr_clen(), rz_x509_signedinfo_dump(), rz_x509_signedinfo_json(), scan_tree(), sdb_add(), sdb_array_add(), sdb_array_add_num(), sdb_array_add_sorted(), sdb_array_add_sorted_num(), sdb_array_append(), sdb_array_append_num(), sdb_array_contains(), sdb_array_contains_num(), sdb_array_delete(), sdb_array_get(), sdb_array_get_num(), sdb_array_indexof(), sdb_array_insert(), sdb_array_insert_num(), sdb_array_length(), sdb_array_pop(), sdb_array_pop_head(), sdb_array_pop_num(), sdb_array_pop_tail(), sdb_array_prepend(), sdb_array_prepend_num(), sdb_array_push(), sdb_array_push_num(), sdb_array_remove(), sdb_array_remove_num(), sdb_array_set(), sdb_array_set_num(), sdb_array_size(), sdb_array_sort(), sdb_array_sort_num(), sdb_array_unset(), sdb_atoi(), sdb_close(), sdb_concat(), sdb_concat_by_path(), sdb_config(), sdb_const_get(), sdb_const_get_len(), sdb_count(), sdb_disk_create(), sdb_disk_finish(), sdb_disk_insert(), sdb_disk_unlink(), sdb_drain(), sdb_dump_begin(), sdb_dump_dupnext(), sdb_dump_hasnext(), sdb_exists(), sdb_expire_get(), sdb_expire_set(), sdb_file(), sdb_fini(), sdb_foreach(), sdb_foreach_cdb(), sdb_foreach_end(), sdb_foreach_list(), sdb_foreach_list_filter(), sdb_foreach_list_filter_user(), sdb_foreach_match(), sdb_free(), sdb_get(), sdb_get_len(), sdb_hash(), sdb_hash_byte(), sdb_hash_len(), sdb_hook(), sdb_hook_call(), sdb_hook_free(), sdb_isempty(), sdb_isnum(), sdb_itoa(), sdb_journal_clear(), sdb_journal_close(), sdb_journal_filename(), sdb_journal_load(), sdb_journal_log(), sdb_journal_open(), sdb_journal_unlink(), sdb_like(), sdb_lock(), sdb_lock_wait(), sdb_merge(), sdb_new(), sdb_ns(), sdb_ns_free_all(), sdb_ns_lock(), sdb_ns_new(), sdb_ns_path(), sdb_ns_set(), sdb_ns_sync(), sdb_ns_unset(), sdb_num_add(), sdb_num_base(), sdb_num_dec(), sdb_num_exists(), sdb_num_get(), sdb_num_inc(), sdb_num_set(), sdb_open(), sdb_query(), sdb_query_file(), sdb_query_lines(), sdb_queryf(), sdb_querys(), sdb_querysf(), sdb_remove(), sdb_reset(), sdb_set(), sdb_set_internal(), sdb_set_owned(), sdb_stats(), sdb_sync(), sdb_text_load(), sdb_text_load_buf(), sdb_text_save(), sdb_text_save_fd(), sdb_uncat(), sdb_unhook(), sdb_unlink(), sdb_unlock(), sdb_unset(), sdb_unset_like(), search_hash(), sections(), send_all_trees(), send_tree(), set_attr(), set_nested(), set_p_add(), set_p_contains(), set_p_delete(), set_prompt(), set_u_add(), set_u_contains(), set_u_delete(), set_u_free(), setcompression(), show_config_options(), showstr(), sigdb_entry_hash(), skipnum(), skipspaces(), slide_hash(), socket_http_answer(), socket_http_get_recursive(), socket_slurp(), space_free(), space_node_free(), spp_proc_eval(), SStream_concat0(), step(), stored(), str2na(), str_split_list_common_regex(), strbuf_append_calc(), strbuf_rev_append_char(), strbuf_rev_prepend_char(), strchr_ns(), strchr_skip_color_codes(), string_clear(), string_free(), string_init(), string_printf(), string_scan_range_cfstring(), strings_print(), strlen0(), swap2(), swap4(), swap8(), symbols(), syscall_reload_needed(), sysregs_reload_needed(), tcpme(), text_save(), tree_dfs_node(), trim(), trim_comments(), ts_subtree__write_char_to_string(), type_string_cache_rollback(), unescape_special_chars(), unescape_string(), unz64local_CheckCurrentFileCoherencyHeader(), unz64local_GetCurrentFileInfoInternal(), unzClose(), unzCloseCurrentFile(), unzeof(), unzGetCurrentFileZStreamPos64(), unzGetFilePos64(), unzGetGlobalComment(), unzGetGlobalInfo(), unzGetGlobalInfo64(), unzGetLocalExtrafield(), unzGetOffset64(), unzGoToFilePos64(), unzGoToFirstFile(), unzGoToNextFile(), unzLocateFile(), unzOpenCurrentFile3(), unzOpenInternal(), unzReadCurrentFile(), unzSetOffset64(), unztell(), unztell64(), update_flags_from_cpsr(), ut32_pack(), ut32_pack_big(), ut32_unpack(), ut64join(), uv__fs_copyfile(), uv__idna_toascii(), uv__idna_toascii_label(), uv__random_readpath(), uv__strdup(), uv__stream_close(), uv__stream_osx_interrupt_select(), uv__strndup(), uv__strscpy(), uv_guess_handle(), uv_inet_pton(), uv_resident_set_memory(), uv_setup_args(), UV_UNUSED(), uv_utf8_to_utf16_alloc(), va2pa(), var_state_free(), vernum(), walk_exports(), windbg_init(), windbg_map_get(), windbg_open(), winkd_sync(), xap_decode(), xap_op(), XXH_malloc(), yxml_symlen(), z80asm(), zip_dir_add(), zip_error_strerror(), and zip_get_file_comment().