Rizin
unix-like reverse engineering framework and cli tools
parse_wasm_pseudo.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <rz_lib.h>
#include <rz_util.h>
#include <rz_flag.h>
#include <rz_analysis.h>
#include <rz_parse.h>

Go to the source code of this file.

Functions

static char * get_fcn_name (RzAnalysis *analysis, ut32 fcn_id)
 
static bool subvar (RzParse *p, RzAnalysisFunction *f, RzAnalysisOp *op, char *data, char *str, int len)
 

Variables

RzParsePlugin rz_parse_plugin_wasm_pseudo
 
RZ_API RzLibStruct rizin_plugin
 

Function Documentation

◆ get_fcn_name()

static char* get_fcn_name ( RzAnalysis analysis,
ut32  fcn_id 
)
static

Definition at line 13 of file parse_wasm_pseudo.c.

13  {
14  rz_cons_push();
15  char *s = analysis->coreb.cmdstrf(analysis->coreb.core, "is~FUNC[6:%u]", fcn_id);
16  rz_cons_pop();
17  if (s) {
18  size_t namelen = strlen(s);
19  s[namelen - 1] = 0;
20  }
21  return s;
22 }
RZ_API void rz_cons_pop(void)
Definition: cons.c:876
RZ_API void rz_cons_push(void)
Definition: cons.c:860
static RzSocket * s
Definition: rtr.c:28
RzCoreBind coreb
Definition: rz_analysis.h:580
RzCoreCmdStrF cmdstrf
Definition: rz_bind.h:35
void * core
Definition: rz_bind.h:31

References rz_core_bind_t::cmdstrf, rz_core_bind_t::core, rz_analysis_t::coreb, rz_cons_pop(), rz_cons_push(), and s.

Referenced by subvar().

◆ subvar()

static bool subvar ( RzParse p,
RzAnalysisFunction f,
RzAnalysisOp op,
char *  data,
char *  str,
int  len 
)
static

Definition at line 24 of file parse_wasm_pseudo.c.

24  {
25  char *fcn_name = NULL;
26  str[0] = 0;
27  if (!strncmp(data, "call ", 5)) {
28  ut32 fcn_id = (ut32)rz_num_get(NULL, data + 5);
29  if (!(fcn_name = get_fcn_name(p->analb.analysis, fcn_id))) {
30  return false;
31  }
32  snprintf(str, len, "call sym.%s", fcn_name);
33  free(fcn_name);
34  return true;
35  }
36  return false;
37 }
size_t len
Definition: 6502dis.c:15
#define NULL
Definition: cris-opc.c:27
uint32_t ut32
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
snprintf
Definition: kernel.h:364
void * p
Definition: libc.cpp:67
static char * get_fcn_name(RzAnalysis *analysis, ut32 fcn_id)
RZ_API ut64 rz_num_get(RzNum *num, const char *str)
Definition: unum.c:172

References free(), get_fcn_name(), len, NULL, p, rz_num_get(), snprintf, and cmd_descs_generate::str.

Variable Documentation

◆ rizin_plugin

RZ_API RzLibStruct rizin_plugin
Initial value:
= {
.version = RZ_VERSION
}
RzParsePlugin rz_parse_plugin_wasm_pseudo
@ RZ_LIB_TYPE_PARSE
Definition: rz_lib.h:74
#define RZ_VERSION
Definition: rz_version.h:8

Definition at line 46 of file parse_wasm_pseudo.c.

◆ rz_parse_plugin_wasm_pseudo

RzParsePlugin rz_parse_plugin_wasm_pseudo
Initial value:
= {
.name = "wasm.pseudo",
.desc = "WASM pseudo syntax",
.subvar = &subvar,
}
static bool subvar(RzParse *p, RzAnalysisFunction *f, RzAnalysisOp *op, char *data, char *str, int len)

Definition at line 39 of file parse_wasm_pseudo.c.