12 const char *
keys =
"[]<>+-,.";
13 const char *cidx = strchr(
keys, ch);
14 return cidx ? cidx -
keys + 1 : 0;
18 #define BF_ADDR_MEM 0x10000
19 #define BF_ADDR_SIZE 64
20 #define BF_BYTE_SIZE 8
21 #define BF_ID_STACK 32
23 #define bf_il_ptr() rz_il_op_new_var("ptr", RZ_IL_VAR_KIND_GLOBAL)
24 #define bf_il_set_ptr(x) rz_il_op_new_set("ptr", false, x)
25 #define bf_il_one(l) rz_il_op_new_bitv_from_ut64(l, 1)
99 static const ut64 max_dist = 2048;
102 while (dist < max_dist) {
266 .desc =
"brainfuck code analysis plugin",
275 #ifndef RZ_PLUGIN_INCORE
static void bf_syscall_read(RzILVM *vm, RzILOpEffect *op)
static char * get_reg_profile(RzAnalysis *analysis)
RzILOpEffect * bf_right_arrow()
static RzAnalysisILConfig * il_config(RzAnalysis *analysis)
static int getid(char ch)
RzILOpEffect * bf_left_arrow()
static void bf_syscall_write(RzILVM *vm, RzILOpEffect *op)
static ut64 find_matching_bracket(RzAnalysis *analysis, ut64 addr, int dir)
RZ_API RzLibStruct rizin_plugin
static int bf_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf, int len, RzAnalysisOpMask mask)
RzAnalysisPlugin rz_analysis_plugin_bf
RzILOpEffect * bf_rlimit(RzAnalysis *analysis, ut64 addr, ut64 target)
RzILOpEffect * bf_llimit(RzAnalysis *analysis, ut64 addr, ut64 target)
RZ_API void rz_analysis_il_config_add_label(RZ_NONNULL RzAnalysisILConfig *cfg, RZ_NONNULL RZ_OWN RzILEffectLabel *label)
RZ_API RZ_OWN RzAnalysisILConfig * rz_analysis_il_config_new(ut32 pc_size, bool big_endian, ut32 mem_key_size)
RZ_API void rz_analysis_il_config_free(RzAnalysisILConfig *cfg)
RZ_API RzAnalysisILInitState * rz_analysis_il_init_state_new()
RZ_API void rz_analysis_il_init_state_set_var(RZ_NONNULL RzAnalysisILInitState *state, RZ_NONNULL const char *name, RZ_NONNULL RZ_OWN RzILVal *val)
RZ_API RZ_OWN RzILVal * rz_il_value_new_bitv(RZ_NONNULL RzBitVector *bv)
RZ_API RZ_OWN RzILOpPure * rz_il_op_new_load(RzILMemIndex mem, RZ_NONNULL RzILOpPure *key)
Helper to create RzILOpArgsLoad.
RZ_API RZ_OWN RzILOpEffect * rz_il_op_new_branch(RZ_NONNULL RzILOpBool *condition, RZ_NULLABLE RzILOpEffect *true_eff, RZ_NULLABLE RzILOpEffect *false_eff)
op structure for branch (bool -> 'a eff -> 'a eff -> 'a eff)
RZ_API RZ_OWN RzILOpBitVector * rz_il_op_new_sub(RZ_NONNULL RzILOpBitVector *x, RZ_NONNULL RzILOpBitVector *y)
op structure for two-operand algorithm and logical operations ('s bitv -> 's bitv -> 's bitv)
RZ_API RZ_OWN RzILOpEffect * rz_il_op_new_jmp(RZ_NONNULL RzILOpBitVector *dst)
op structure for jmp (_ bitv -> ctrl eff)
RZ_API RZ_OWN RzILOpEffect * rz_il_op_new_store(RzILMemIndex mem, RZ_NONNULL RzILOpBitVector *key, RZ_NONNULL RzILOpBitVector *value)
Helper to create RzILOpArgsStoreW.
RZ_API RZ_OWN RzILOpEffect * rz_il_op_new_goto(RZ_NONNULL const char *lbl)
op structure for goto (label -> ctrl eff)
RZ_API RZ_OWN RzILOpBool * rz_il_op_new_bitv_from_ut64(ut32 length, ut64 number)
op structure for bitvector converted from ut64
RZ_API RZ_OWN RzILOpBool * rz_il_op_new_non_zero(RZ_NONNULL RzILOpPure *bv)
RZ_API RZ_OWN RzILOpBitVector * rz_il_op_new_add(RZ_NONNULL RzILOpBitVector *x, RZ_NONNULL RzILOpBitVector *y)
op structure for two-operand algorithm and logical operations ('s bitv -> 's bitv -> 's bitv)
RZ_API RZ_OWN RzILOpPure * rz_il_op_new_var(RZ_NONNULL const char *v, RzILVarKind kind)
op structure for var ('a var -> 'a pure)
RZ_API RZ_OWN RzILOpEffect * rz_il_op_new_nop()
RZ_API RZ_BORROW RzILVal * rz_il_vm_get_var_value(RZ_NONNULL RzILVM *vm, RzILVarKind kind, const char *name)
RZ_API void rz_il_vm_mem_store(RzILVM *vm, RzILMemIndex index, RzBitVector *key, RzBitVector *value)
RZ_API RzBitVector * rz_il_vm_mem_load(RzILVM *vm, RzILMemIndex index, RzBitVector *key)
RZ_API RzILEffectLabel * rz_il_effect_label_new(RZ_NONNULL const char *name, RzILEffectLabelType type)
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 struct @218 keys[]
void * load(const char *name, size_t *len)
@ RZ_ANALYSIS_OP_TYPE_SUB
@ RZ_ANALYSIS_OP_TYPE_LOAD
@ RZ_ANALYSIS_OP_TYPE_UJMP
@ RZ_ANALYSIS_OP_TYPE_TRAP
@ RZ_ANALYSIS_OP_TYPE_ADD
@ RZ_ANALYSIS_OP_TYPE_STORE
@ RZ_ANALYSIS_OP_TYPE_CJMP
@ RZ_ANALYSIS_OP_TYPE_NOP
#define rz_warn_if_reached()
#define rz_return_val_if_fail(expr, val)
RZ_API void rz_bv_free(RZ_NULLABLE RzBitVector *bv)
RZ_API ut32 rz_bv_to_ut32(RZ_NONNULL const RzBitVector *x)
RZ_API RZ_OWN RzBitVector * rz_bv_new_from_ut64(ut32 length, ut64 value)
@ RZ_IL_TYPE_PURE_BITVECTOR
#define cond(bop, top, mask, flags)
Description of the global context of an RzAnalysisILVM.
RZ_NULLABLE RzAnalysisILInitState * init_state
optional, initial contents for variables/registers, etc.
bool(* read_at)(struct rz_analysis_t *analysis, ut64 addr, ut8 *buf, int len)
void * hook
Function pointer if EFFECT_LABEL_SYSCALL / EFFECT_LABEL_HOOK.
An IL op performing a pure computation, 'a pure.
RzValUnion data
data pointer
RzILTypePure type
type of value
Low-level VM to execute raw IL code.
@ RZ_IL_VAR_KIND_GLOBAL
global var, usually bound to a physical representation like a register.
ut64(WINAPI *w32_GetEnabledXStateFeatures)()