Rizin
unix-like reverse engineering framework and cli tools
vle.h File Reference
#include <rz_types.h>

Go to the source code of this file.

Classes

struct  vle_handle
 
struct  vle_field_t
 
struct  vle_t
 

Macros

#define VLE_DEFAULTS   0
 
#define VLE_INTERNAL_PPC   1
 
#define TYPE_NONE   0
 
#define TYPE_REG   1
 
#define TYPE_IMM   2
 
#define TYPE_MEM   3
 
#define TYPE_JMP   4
 
#define TYPE_CR   5
 

Functions

int vle_init (vle_handle *handle, const ut8 *buffer, const ut32 size)
 
vle_tvle_next (vle_handle *handle)
 
int vle_option (vle_handle *handle, ut32 option)
 
void vle_free (vle_t *instr)
 
void vle_snprint (char *str, int size, ut32 addr, vle_t *instr)
 

Macro Definition Documentation

◆ TYPE_CR

#define TYPE_CR   5

Definition at line 16 of file vle.h.

◆ TYPE_IMM

#define TYPE_IMM   2

Definition at line 13 of file vle.h.

◆ TYPE_JMP

#define TYPE_JMP   4

Definition at line 15 of file vle.h.

◆ TYPE_MEM

#define TYPE_MEM   3

Definition at line 14 of file vle.h.

◆ TYPE_NONE

#define TYPE_NONE   0

Definition at line 11 of file vle.h.

◆ TYPE_REG

#define TYPE_REG   1

Definition at line 12 of file vle.h.

◆ VLE_DEFAULTS

#define VLE_DEFAULTS   0

Definition at line 8 of file vle.h.

◆ VLE_INTERNAL_PPC

#define VLE_INTERNAL_PPC   1

Definition at line 9 of file vle.h.

Function Documentation

◆ vle_free()

void vle_free ( vle_t instr)

Definition at line 911 of file vle.c.

911  {
912  free(instr);
913 }
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130

References free().

Referenced by analop_vle(), and decompile_vle().

◆ vle_init()

int vle_init ( vle_handle handle,
const ut8 buffer,
const ut32  size 
)

Definition at line 870 of file vle.c.

870  {
871  if (!handle || !buffer || size < 2) {
872  return 1;
873  }
874  handle->pos = buffer;
875  handle->end = buffer + size;
876  handle->inc = 0;
877  handle->options = VLE_DEFAULTS;
878  return 0;
879 }
static mcore_handle handle
Definition: asm_mcore.c:8
struct buffer buffer
voidpf void uLong size
Definition: ioapi.h:138
Definition: buffer.h:15
const ut8 * pos
Definition: mcore.h:31
ut16 inc
Definition: mcore.h:32
const ut8 * end
Definition: mcore.h:30
#define VLE_DEFAULTS
Definition: vle.h:8

References mcore_handle::end, handle, mcore_handle::inc, mcore_handle::pos, and VLE_DEFAULTS.

Referenced by analop_vle(), and decompile_vle().

◆ vle_next()

vle_t* vle_next ( vle_handle handle)

Definition at line 889 of file vle.c.

889  {
890  vle_t *op = NULL;
891  if (!handle || handle->pos + handle->inc >= handle->end) {
892  return NULL;
893  }
894  handle->pos += handle->inc;
895  // 'e-32' always before 'se-16'
896 
897  if (USE_INTERNAL_PPC(handle) && handle->pos + 4 <= handle->end) {
898  op = find_ppc(handle->pos);
899  }
900  if (!op && handle->pos + 4 <= handle->end) {
901  op = find_e(handle->pos);
902  }
903  if (!op && handle->pos + 2 <= handle->end) {
904  op = find_se(handle->pos);
905  }
906 
907  handle->inc = op ? op->size : 0;
908  return op;
909 }
ut8 op
Definition: 6502dis.c:13
#define NULL
Definition: cris-opc.c:27
Definition: vle.h:30
Definition: dis.c:32
static vle_t * find_se(const ut8 *buffer)
Definition: vle.c:833
static vle_t * find_e(const ut8 *buffer)
Definition: vle.c:813
static vle_t * find_ppc(const ut8 *buffer)
Definition: vle.c:793
#define USE_INTERNAL_PPC(x)
Definition: vle.c:7

References mcore_handle::end, find_e(), find_ppc(), find_se(), handle, mcore_handle::inc, NULL, op, mcore_handle::pos, and USE_INTERNAL_PPC.

Referenced by analop_vle(), and decompile_vle().

◆ vle_option()

int vle_option ( vle_handle handle,
ut32  option 
)

Definition at line 881 of file vle.c.

881  {
882  if (!handle) {
883  return 1;
884  }
885  handle->options |= option;
886  return 0;
887 }
static int option
Definition: vmenus.c:2426

References handle, and option.

◆ vle_snprint()

void vle_snprint ( char *  str,
int  size,
ut32  addr,
vle_t instr 
)

Definition at line 915 of file vle.c.

915  {
916  ut32 i;
917  int bufsize = size, add = 0;
918  add = snprintf(str, bufsize, "%s", instr->name);
919  for (i = 0; add > 0 && i < instr->n && add < bufsize; i++) {
920  if (instr->fields[i].type == TYPE_REG) {
921  if (i < instr->n - 1 && instr->fields[i + 1].type == TYPE_MEM) {
922  add += snprintf(str + add, bufsize - add, " 0x%x(r%d)", instr->fields[i + 1].value, instr->fields[i].value);
923  i++;
924  } else {
925  add += snprintf(str + add, bufsize - add, " r%u", instr->fields[i].value);
926  }
927  } else if (instr->fields[i].type == TYPE_IMM) {
928  add += snprintf(str + add, bufsize - add, " 0x%x", instr->fields[i].value);
929  } else if (instr->fields[i].type == TYPE_JMP) {
930  add += snprintf(str + add, bufsize - add, " 0x%" PFMT32x, addr + instr->fields[i].value);
931  } else if (instr->fields[i].type == TYPE_CR) {
932  add += snprintf(str + add, bufsize - add, " cr%u", instr->fields[i].value);
933  }
934  }
935 }
#define PFMT32x
lzma_index ** i
Definition: index.h:629
@ TYPE_IMM
Definition: armass.c:35
@ TYPE_MEM
Definition: armass.c:36
uint32_t ut32
snprintf
Definition: kernel.h:364
#define TYPE_CR
#define TYPE_REG
Definition: mcore.h:22
#define TYPE_JMP
Definition: mcore.h:25
int n
Definition: mipsasm.c:19
ut16 type
Definition: vle.h:27
ut32 value
Definition: vle.h:26
const char * name
Definition: vle.h:31
vle_field_t fields[10]
Definition: vle.h:32
ut16 n
Definition: vle.h:33
static int addr
Definition: z80asm.c:58
static int add(char *argv[])
Definition: ziptool.c:84

References add(), addr, vle_t::fields, i, n, vle_t::n, vle_t::name, PFMT32x, snprintf, cmd_descs_generate::str, vle_field_t::type, TYPE_CR, TYPE_IMM, TYPE_JMP, TYPE_MEM, TYPE_REG, and vle_field_t::value.

Referenced by decompile_vle().