Rizin
unix-like reverse engineering framework and cli tools
parse_dalvik_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>
#include "parse_common.c"

Go to the source code of this file.

Functions

static RzListdalvik_tokenize (const char *assembly, size_t length)
 
static bool parse (RzParse *parse, const char *assembly, RzStrBuf *sb)
 

Variables

static const RzPseudoGrammar dalvik_lexicon []
 
static const RzPseudoReplace dalvik_replace []
 
static const RzPseudoConfig dalvik_config = RZ_PSEUDO_DEFINE_CONFIG_NO_DIRECT(dalvik_lexicon, dalvik_replace, 4, dalvik_tokenize)
 
RzParsePlugin rz_parse_plugin_dalvik_pseudo
 
RZ_API RzLibStruct rizin_plugin
 

Function Documentation

◆ dalvik_tokenize()

RzList * dalvik_tokenize ( const char *  assembly,
size_t  length 
)
static

Definition at line 206 of file parse_dalvik_pseudo.c.

206  {
207  size_t i, p;
208  char *buf = NULL;
209  RzList *tokens = NULL;
210  const char *comma_replace = NULL;
211  bool keep = false;
212 
213  buf = rz_str_ndup(assembly, length);
214  if (!buf) {
215  return NULL;
216  }
217 
218  for (i = 0, p = 0; p < length; ++i, ++p) {
219  if (buf[p] == ',') {
220  if (!keep) {
221  p++;
222  } else if (buf[p + 1] == ' ') {
223  buf[i] = buf[p];
224  p++;
225  continue;
226  }
227  } else if (buf[p] == '{') {
228  keep = true;
229  comma_replace = ", ";
230  } else if (buf[p] == '}') {
231  keep = false;
232  }
233  if (p > i) {
234  buf[i] = buf[p];
235  }
236  }
237  buf[i] = 0;
238 
239  tokens = rz_str_split_duplist(buf, " ", true);
240  free(buf);
241  if (!tokens) {
242  return NULL;
243  }
244 
245  if (comma_replace) {
246  RzListIter *it;
247  rz_list_foreach (tokens, it, buf) {
248  it->data = rz_str_replace(buf, ",", comma_replace, 1);
249  }
250  }
251 
252  return tokens;
253 }
lzma_index ** i
Definition: index.h:629
#define NULL
Definition: cris-opc.c:27
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len static semflg const void static shmflg const struct timespec struct timespec static rem const char static group const void length
Definition: sflib.h:133
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
voidpf void * buf
Definition: ioapi.h:138
void * p
Definition: libc.cpp:67
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 RzList * rz_str_split_duplist(const char *str, const char *c, bool trim)
Split the string str according to the substring c and returns a RzList with the result.
Definition: str.c:3464
RZ_API char * rz_str_replace(char *str, const char *key, const char *val, int g)
Definition: str.c:1110
void * data
Definition: rz_list.h:14

References rz_list_iter_t::data, free(), i, length, NULL, p, rz_str_ndup(), rz_str_replace(), and rz_str_split_duplist().

◆ parse()

static bool parse ( RzParse parse,
const char *  assembly,
RzStrBuf sb 
)
static

Definition at line 255 of file parse_dalvik_pseudo.c.

255  {
256  return rz_pseudo_convert(&dalvik_config, assembly, sb);
257 }
static SblHeader sb
Definition: bin_mbn.c:26
static bool rz_pseudo_convert(const RzPseudoConfig *config, const char *assembly, RzStrBuf *sb)
Definition: parse_common.c:103
static const RzPseudoConfig dalvik_config

References dalvik_config, rz_pseudo_convert(), and sb.

Variable Documentation

◆ dalvik_config

◆ dalvik_lexicon

const RzPseudoGrammar dalvik_lexicon[]
static

Definition at line 18 of file parse_dalvik_pseudo.c.

◆ dalvik_replace

const RzPseudoReplace dalvik_replace[]
static
Initial value:
= {
}
#define RZ_PSEUDO_DEFINE_REPLACE(x, y, f)
Definition: parse_common.c:64

Definition at line 198 of file parse_dalvik_pseudo.c.

◆ rizin_plugin

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

Definition at line 268 of file parse_dalvik_pseudo.c.

◆ rz_parse_plugin_dalvik_pseudo

RzParsePlugin rz_parse_plugin_dalvik_pseudo
Initial value:
= {
.name = "dalvik.pseudo",
.desc = "DALVIK pseudo syntax",
.init = NULL,
.fini = NULL,
.parse = parse,
}
static bool parse(RzParse *parse, const char *assembly, RzStrBuf *sb)

Definition at line 259 of file parse_dalvik_pseudo.c.