Example #1
0
R_API RDebug *r_debug_new(int hard) {
	RDebug *dbg = R_NEW (RDebug);
	if (dbg) {
		// R_SYS_ARCH
		dbg->arch = r_sys_arch_id (R_SYS_ARCH); // 0 is native by default
		dbg->bits = R_SYS_BITS;
		dbg->anal = NULL;
		dbg->pid = -1;
		dbg->tid = -1;
		dbg->graph = r_graph_new ();
		dbg->swstep = 0;
		dbg->newstate = 0;
		dbg->reason = R_DBG_REASON_UNKNOWN;
		dbg->stop_all_threads = R_FALSE;
		dbg->trace = r_debug_trace_new ();
		dbg->printf = (void *)printf;
		dbg->reg = r_reg_new ();
		dbg->h = NULL;
		/* TODO: needs a redesign? */
		dbg->maps = r_debug_map_list_new ();
		dbg->maps_user = r_debug_map_list_new ();
		if (hard) {
			dbg->bp = r_bp_new ();
			r_debug_plugin_init (dbg);
			dbg->bp->iob.init = R_FALSE;
		}
	}
	return dbg;
}
Example #2
0
emu *emu_new()
{
	struct emu_t *e = R_NEW0(emu);
	e->reg = r_reg_new();
	e->io = r_io_new();
	e->bin = r_bin_new();
	e->lib = r_lib_new("ramulate_plugin");
	e->plugins = r_list_new();
	e->a = r_asm_new();
	e->op = R_NEW0(RAsmOp);
	e->anal = r_anal_new();
	e->anop = r_anal_op_new();
	e->next_vs_id = 0;
	e->screen = NULL;
	r_lib_add_handler(e->lib, RAMULATE_EMU_PLUGIN, "emulation plugin handler", &emu_plugin_cb, &emu_plugin_cb_end, e);
	return e;
}
Example #3
0
R_API RDebug *r_debug_new(int hard) {
	RDebug *dbg = R_NEW0 (RDebug);
	if (!dbg) return NULL;
	// R_SYS_ARCH
	dbg->arch = r_sys_arch_id (R_SYS_ARCH); // 0 is native by default
	dbg->bits = R_SYS_BITS;
	dbg->trace_forks = 1;
	dbg->trace_clone = 0;
	R_FREE (dbg->btalgo);
	dbg->trace_execs = 0;
	dbg->anal = NULL;
	dbg->snaps = r_list_newf (r_debug_snap_free);
	dbg->pid = -1;
	dbg->bpsize = 1;
	dbg->tid = -1;
	dbg->tree = r_tree_new ();
	dbg->tracenodes = sdb_new0 ();
	dbg->swstep = 0;
	dbg->newstate = 0;
	dbg->signum = 0;
	dbg->reason = R_DBG_REASON_UNKNOWN;
	dbg->stop_all_threads = R_FALSE;
	dbg->trace = r_debug_trace_new ();
	dbg->printf = (void *)printf;
	dbg->reg = r_reg_new ();
	dbg->num = r_num_new (r_debug_num_callback, dbg);
	dbg->h = NULL;
	/* TODO: needs a redesign? */
	dbg->maps = r_debug_map_list_new ();
	dbg->maps_user = r_debug_map_list_new ();
	r_debug_signal_init (dbg);
	if (hard) {
		dbg->bp = r_bp_new ();
		r_debug_plugin_init (dbg);
		dbg->bp->iob.init = R_FALSE;
	}
	return dbg;
}
Example #4
0
int main() {
	int i;
	int foo[128];
	const char *type;
	struct r_reg_t *reg;

	for (i=0;i<128;i++)
		foo[i] = i;

	reg = r_reg_new ();
	r_reg_set_profile (reg, "./test.regs");
	r_reg_read_regs (reg, (const ut8 *)foo, sizeof(foo));
{
	ut64 a;
	RRegItem *item;
	item = r_reg_get (reg, "eflags", R_REG_TYPE_GPR);
	r_reg_set_value (reg, item, 0x00000346); //0xffffffffffff);
	a = r_reg_get_value (reg, item);
	eprintf ("A32 = 0x%x\n", (int)a);
	if ((int)a != -1) {
		eprintf ("1 FAIL\n");
	}

print_eflags_bits (reg);
	item = r_reg_get (reg, "zf", R_REG_TYPE_GPR);
	a = r_reg_get_value (reg, item);
	eprintf ("A = %d\n", (int)a);
	if (a != 1) {
		eprintf ("2 FAIL\n");
	}

	item = r_reg_get (reg, "zf", R_REG_TYPE_GPR);
	r_reg_set_value (reg, item, 1);
	a = r_reg_get_value (reg, item);
	eprintf ("A = %d\n", (int)a);
	if (a != 1) {
		eprintf ("3 FAIL\n");
	}
	r_reg_set_value (reg, item, 0);
	a = r_reg_get_value (reg, item);
	eprintf ("A = %d\n", (int)a);
	if (a != 0) {
		eprintf ("4 FAIL\n");
	}
}
	show_regs (reg, 1); //32);

exit (0);
	show_regs (reg, 32);
	/* --- */
	r_reg_set_profile(reg, "../p/x86-linux.regs");
	printf ("Program counter is named: %s\n", r_reg_get_name (reg, R_REG_NAME_PC));
	show_regs (reg, 32);
	r_reg_set_value(reg, r_reg_get(reg, "eax", -1), 0x414141);
	r_reg_set_value(reg, r_reg_get(reg, "ecx", -1), 666);
	show_regs(reg, 32);
	r_reg_set_value(reg, r_reg_get(reg, "al", -1), 0x22);
	show_regs(reg, 33);

	r_reg_set_value (reg, r_reg_get (reg, "zero", -1), 0);
	show_regs (reg, 1);
	r_reg_set_value (reg, r_reg_get (reg, "zero", -1), 1);
	show_regs (reg, 1);

	for (i=0; (type=r_reg_get_type (i));i++)
		printf (" - %s\n", type);

	r_reg_arena_push (reg);
	r_reg_arena_pop (reg);

	r_reg_arena_push (reg);
	r_reg_arena_push (reg);
	r_reg_arena_push (reg);
	r_reg_arena_pop (reg);
	r_reg_arena_pop (reg);
	r_reg_arena_push (reg);
	r_reg_arena_pop (reg);
	r_reg_arena_pop (reg);
/*
	r_reg_arena_pop(reg);
	r_reg_arena_pop(reg);
	r_reg_arena_pop(reg);
	r_reg_arena_pop(reg);
*/
	return 0;
}