* Add 'FS' #define for w32 and *nix
* Add support for thumb mode ARM disassembler - Workaround a warning in r_vm for arm-16 * More work on drx.c, but still not integrated
This commit is contained in:
parent
fd084aca33
commit
ee39ba239a
2
TODO
2
TODO
|
@ -8,6 +8,8 @@
|
|||
|
||||
Questions
|
||||
=========
|
||||
* arm thumb supports some 32 bit instructions ADD.W ,...
|
||||
* Switch to 'arm' code analysis module
|
||||
* Add "pm ?" for bit print like in pb?
|
||||
* Only use uppercase KMG for Kilo,Mega,Giga in r_num?
|
||||
- 'g' is for double
|
||||
|
|
|
@ -642,8 +642,7 @@ static int __lib_bin_xtr_dt(struct r_lib_plugin_t *pl, void *p, void *u) {
|
|||
return R_TRUE;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int main(int argc, char **argv) {
|
||||
int c, bits = 0;
|
||||
int action = ACTION_UNK;
|
||||
const char *op = NULL;
|
||||
|
@ -795,7 +794,7 @@ int main(int argc, char **argv)
|
|||
if (action&ACTION_SRCLINE)
|
||||
rabin_show_srcline(at);
|
||||
if (action&ACTION_EXTRACT)
|
||||
rabin_extract((arch==NULL&&name==NULL&&bits==0));
|
||||
rabin_extract ((arch==NULL&&name==NULL&&bits==0));
|
||||
if (op != NULL && action&ACTION_OPERATION)
|
||||
rabin_do_operation (op);
|
||||
|
||||
|
|
|
@ -8,8 +8,6 @@ Before entering a 'call' you can identify the arguments passed to it using the '
|
|||
Use the '[' and ']' keys in visual mode to adjust the screen width (scr.width)
|
||||
Choose your architecture by typing: 'e asm.arch=ppc' (or arm, java, m68k, intel, intel16 or intel64)
|
||||
Move between your search hits in visual mode using the 'f' and 'F' keys
|
||||
Run python scripts with the python hack plugin. ('H python <filename>' command)
|
||||
Run LUA scripts with the lua hack plugin. ('H lua <filename>' command)
|
||||
Save your projects with 'Ps <project-filename>' and restore then with 'Po <project-filename>'
|
||||
Everytime you run radare. It removes a random file :)
|
||||
RADARE CUMS WITH ABSOLUTELY NO WARRANTY
|
||||
|
|
|
@ -10,14 +10,11 @@
|
|||
/* DEPRECATE ?? */
|
||||
#include "arm/arm.h"
|
||||
|
||||
// XXX: must be configured somewhere with anal.bits
|
||||
static int arm_mode = 32;
|
||||
|
||||
static unsigned int disarm_branch_offset ( unsigned int pc, unsigned int insoff ) {
|
||||
static unsigned int disarm_branch_offset (unsigned int pc, unsigned int insoff) {
|
||||
unsigned int add = insoff << 2;
|
||||
/* zero extend if higher is 1 (0x02000000) */
|
||||
if ( (add & 0x02000000) == 0x02000000 )
|
||||
add = add | 0xFC000000 ;
|
||||
if ((add & 0x02000000) == 0x02000000)
|
||||
add |= 0xFC000000;
|
||||
return add + pc + 8;
|
||||
}
|
||||
|
||||
|
@ -55,7 +52,7 @@ static int aop(RAnal *anal, RAnalOp *aop, ut64 addr, const ut8 *data, int len) {
|
|||
memset (aop, '\0', sizeof (RAnalOp));
|
||||
aop->addr = addr;
|
||||
aop->type = R_ANAL_OP_TYPE_UNK;
|
||||
aop->length = (arm_mode==16)?2:4;
|
||||
aop->length = (anal->bits==16)?2:4;
|
||||
aop->jump = aop->fail = -1;
|
||||
aop->ref = aop->value = -1;
|
||||
|
||||
|
@ -124,7 +121,6 @@ static int aop(RAnal *anal, RAnalOp *aop, ut64 addr, const ut8 *data, int len) {
|
|||
aop->eob = 1;
|
||||
} else
|
||||
if ((code[i] & ARM_DTX_LOAD)) { //IS_LOAD(code[i])) {
|
||||
int ret = arm_mode/8;
|
||||
ut32 ptr = 0;
|
||||
aop->type = R_ANAL_OP_TYPE_MOV;
|
||||
if (b[2]==0x1b) {
|
||||
|
@ -135,7 +131,7 @@ static int aop(RAnal *anal, RAnalOp *aop, ut64 addr, const ut8 *data, int len) {
|
|||
} else {
|
||||
//ut32 oaddr = addr+8+b[0];
|
||||
//XXX TODO ret = radare_read_at(oaddr, (ut8*)&ptr, 4);
|
||||
if (ret == 4) {
|
||||
if (anal->bits == 32) {
|
||||
b = (ut8*)&ptr;
|
||||
aop->ref = b[0] + (b[1]<<8) + (b[2]<<16) + (b[3]<<24);
|
||||
//XXX data_xrefs_add(oaddr, aop->ref, 1);
|
||||
|
|
|
@ -1549,7 +1549,7 @@ static unsigned int regname_selected = 1;
|
|||
#define arm_regnames regnames[regname_selected].reg_names
|
||||
|
||||
//static bfd_boolean force_thumb = FALSE;
|
||||
int force_thumb = FALSE;
|
||||
//int force_thumb = FALSE;
|
||||
|
||||
/* Current IT instruction state. This contains the same state as the IT
|
||||
bits in the CPSR. */
|
||||
|
@ -4052,17 +4052,12 @@ print_insn_arm (bfd_vma pc, struct disassemble_info *info)
|
|||
}
|
||||
#endif
|
||||
/* do not audotedtect thumb mode */
|
||||
int little;
|
||||
|
||||
little = (info->endian == BFD_ENDIAN_LITTLE);
|
||||
is_thumb |= (pc & 1);
|
||||
int little = (info->endian == BFD_ENDIAN_LITTLE);
|
||||
// is_thumb |= (pc & 1);
|
||||
is_thumb = (info->bytes_per_line == 2)?1:0;
|
||||
//is_thumb = 1;
|
||||
pc &= ~(bfd_vma)1;
|
||||
|
||||
if (force_thumb)
|
||||
is_thumb = TRUE;
|
||||
|
||||
info->bytes_per_line = 4;
|
||||
|
||||
if (is_data)
|
||||
{
|
||||
int i;
|
||||
|
|
|
@ -71,13 +71,15 @@ static int disassemble(struct r_asm_t *a, struct r_asm_aop_t *aop, ut8 *buf, ut6
|
|||
disasm_obj.endian = !a->big_endian;
|
||||
disasm_obj.fprintf_func = &buf_fprintf;
|
||||
disasm_obj.stream = stdout;
|
||||
disasm_obj.bytes_per_chunk =
|
||||
disasm_obj.bytes_per_line = (a->bits/8);
|
||||
|
||||
aop->buf_asm[0]='\0';
|
||||
aop->inst_len = print_insn_arm((bfd_vma)Offset, &disasm_obj);
|
||||
if (aop->inst_len == -1)
|
||||
strncpy(aop->buf_asm, " (data)", R_ASM_BUFSIZE);
|
||||
|
||||
return aop->inst_len;
|
||||
return aop->inst_len; //(a->bits/8); //aop->inst_len;
|
||||
}
|
||||
|
||||
int armass_assemble(const char *str, unsigned long off);
|
||||
|
|
|
@ -251,7 +251,7 @@ static int config_asm_bits_callback(void *user, void *data) {
|
|||
}
|
||||
if (!r_anal_set_bits (core->anal, node->i_value))
|
||||
eprintf ("asm.arch: Cannot setup '%i' bits analysis engine\n", (int)node->i_value);
|
||||
if(core->assembler->cur)
|
||||
if (core->assembler->cur)
|
||||
r_vm_set_arch (core->vm, core->assembler->cur->name, node->i_value);
|
||||
// TODO: change debugger backend bit profile here
|
||||
return ret;
|
||||
|
|
|
@ -56,7 +56,13 @@
|
|||
control |= (1 << (DR_LOCAL_ENABLE_SHIFT + DR_ENABLE_SIZE * (i)))
|
||||
#define I386_DR_GLOBAL_ENABLE(control, i) \
|
||||
control |= (1 << (DR_GLOBAL_ENABLE_SHIFT + DR_ENABLE_SIZE * (i)))
|
||||
|
||||
#define I386_DR_IS_LOCAL_ENABLED(control, i) \
|
||||
(control & (1 << (DR_LOCAL_ENABLE_SHIFT + DR_ENABLE_SIZE * (i))))
|
||||
/* enable/disable */
|
||||
#define I386_DR_IS_ENABLED(control, i) \
|
||||
control & (3 << (DR_ENABLE_SIZE * (i)))
|
||||
|
||||
#define I386_DR_ENABLE(control, i) \
|
||||
control |= (3 << (DR_ENABLE_SIZE * (i)))
|
||||
#define I386_DR_DISABLE(control, i) \
|
||||
|
@ -72,27 +78,14 @@
|
|||
|
||||
/* ----------------------------- */
|
||||
|
||||
#if 0
|
||||
options are:
|
||||
address
|
||||
length
|
||||
local/global
|
||||
type (rwxi)
|
||||
|
||||
|
||||
// DRX CHK
|
||||
|
||||
int drx_check() {
|
||||
return R_TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
int drx_set(drxt *drx, int n, ut64 addr, int len, int rwx, int global) {
|
||||
ut32 control = drx[DR_CONTROL];
|
||||
if (n<0 || n>4) {
|
||||
eprintf ("Invalid DRX index (0-4)\n");
|
||||
return R_FALSE;
|
||||
}
|
||||
if (rwx<0 || rwx>3)
|
||||
rwx = 0; // defaults to X
|
||||
switch (len) {
|
||||
case 1:
|
||||
len = 0;
|
||||
|
@ -110,23 +103,29 @@ int drx_set(drxt *drx, int n, ut64 addr, int len, int rwx, int global) {
|
|||
eprintf ("Invalid DRX length\n");
|
||||
return R_FALSE;
|
||||
}
|
||||
I386_DR_SET_RW_LEN (control, n, len);
|
||||
I386_DR_SET_RW_LEN (control, n, len|rwx);
|
||||
if (global) {
|
||||
I386_DR_GLOBAL_ENABLE (control, n);
|
||||
control |= DR_GLOBAL_SLOWDOWN;
|
||||
} else {
|
||||
I386_DR_LOCAL_ENABLE (control, n);
|
||||
control |= DR_LOCAL_SLOWDOWN;
|
||||
control |= DR_LOCAL_SLOWDOWN; // XXX: This is wrong
|
||||
}
|
||||
control &= I386_DR_CONTROL_MASK;
|
||||
drx[n] = addr;
|
||||
drx[DR_CONTROL] = control;
|
||||
}
|
||||
|
||||
ut64 drx_get(drxt *drx, int n, int *rwx, int *len, int *global) {
|
||||
ut64 drx_get(drxt *drx, int n, int *rwx, int *len, int *global, int *enabled) {
|
||||
int ret = I386_DR_GET_RW_LEN (drx[DR_CONTROL], n);
|
||||
if (global) *global = drx[DR_CONTROL] & DR_GLOBAL_SLOWDOWN;
|
||||
if (len) *len = (ret & 0xf)>>2;
|
||||
if (global) *global = I386_DR_IS_LOCAL_ENABLED (drx[7], n);
|
||||
if (len) switch ((ret&0x3)<<2) {
|
||||
case DR_LEN_1: *len = 1; break;
|
||||
case DR_LEN_2: *len = 2; break;
|
||||
case DR_LEN_4: *len = 4; break;
|
||||
case DR_LEN_8: *len = 8; break;
|
||||
}
|
||||
if (enabled) *enabled = I386_DR_IS_ENABLED (drx[7], n);
|
||||
if (rwx) *rwx = ret & 0x3;
|
||||
return (ut64)drx[n];
|
||||
}
|
||||
|
@ -141,27 +140,36 @@ int drx_next(drxt *drx) {
|
|||
|
||||
void drx_list(drxt *drx) {
|
||||
ut64 addr;
|
||||
int i, type, len, g;
|
||||
int i, rwx, len, g, en;
|
||||
for(i=0; i<4; i++) {
|
||||
addr = drx_get (drx, i, &type, &len, &g);
|
||||
printf ("DR%d %c%c%c%c 0x%08llx %d\n", i,
|
||||
g?'g':'l',
|
||||
(type&DR_RW_READ)? 'r':'-',
|
||||
(type&DR_RW_WRITE)? 'w':'-',
|
||||
(type&DR_RW_EXECUTE)? 'x':'-',
|
||||
addr = drx_get (drx, i, &rwx, &len, &g, &en);
|
||||
printf ("%c dr%d %c%c 0x%08llx %d\n",
|
||||
en?'*':'-', i, g?'g':'l',
|
||||
(rwx==DR_RW_READ)?'r':
|
||||
(rwx==DR_RW_WRITE)?'w':
|
||||
(rwx==DR_RW_EXECUTE)?'x':
|
||||
(rwx==DR_RW_IORW)?'i':'?',
|
||||
addr, len);
|
||||
}
|
||||
}
|
||||
|
||||
void drx_init(drxt *r) {
|
||||
memset (r, 0, sizeof (drxt)*DRXN);
|
||||
memset (r, 0, sizeof (drxt)*(DRXN+1));
|
||||
}
|
||||
|
||||
void drx_enable(drxt *r, int n, int enabled) {
|
||||
if (enabled) I386_DR_ENABLE (r[DR_CONTROL], n);
|
||||
else I386_DR_DISABLE (r[DR_CONTROL], n);
|
||||
}
|
||||
|
||||
#if MAIN
|
||||
int main() {
|
||||
drxt regs[DRXN];
|
||||
drx_init (regs);
|
||||
drx_set (regs, 1, 0x8048000, 1, DR_RW_EXECUTE, 0);
|
||||
drx_set (regs, 1, 0x8048123, 1, DR_RW_EXECUTE, 0);
|
||||
drx_set (regs, 0, 0x8048123, 4, DR_RW_READ, 1);
|
||||
//drx_enable (regs, 0, R_TRUE);
|
||||
// drx_enable (regs, 0, R_FALSE);
|
||||
drx_list (regs);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -15,6 +15,13 @@
|
|||
#include <stdarg.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#undef FS
|
||||
#if __WINDOWS__
|
||||
#define FS "\\"
|
||||
#else
|
||||
#define FS "/"
|
||||
#endif
|
||||
|
||||
/* provide a per-module debug-enabled feature */
|
||||
// TODO NOT USED. DEPREACATE
|
||||
#if R_DEBUG
|
||||
|
|
|
@ -175,7 +175,7 @@ R_API int r_vm_set_arch(RVm *vm, const char *name, int bits) {
|
|||
if (strstr (name, "arm")) {
|
||||
switch (bits) {
|
||||
case 16:
|
||||
//profile = vmprofile_arm_16;
|
||||
profile = vmprofile_arm_32; // XXX 16;
|
||||
break;
|
||||
case 32:
|
||||
profile = vmprofile_arm_32;
|
||||
|
@ -187,7 +187,7 @@ R_API int r_vm_set_arch(RVm *vm, const char *name, int bits) {
|
|||
r_vm_init (vm, 2);
|
||||
r_vm_cmd_eval (vm, str);
|
||||
free (str);
|
||||
} else eprintf ("No profile found for '%s' %d\n", name, bits);
|
||||
} else eprintf ("r_vm: No profile found for '%s' on %d bits\n", name, bits);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue