mirror of
https://github.com/radareorg/radare2.git
synced 2025-01-22 22:06:50 +00:00
Priorize keystone plugins and other random changes
This commit is contained in:
parent
e18e1ffd36
commit
1f7db90e41
@ -354,6 +354,29 @@ R_API int r_asm_disassemble(RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
typedef int (*Ase)(RAsm *a, RAsmOp *op, const char *buf);
|
||||
|
||||
static Ase findAssembler(RAsm *a, const char *kw) {
|
||||
Ase ase = NULL;
|
||||
RAsmPlugin *h;
|
||||
RListIter *iter;
|
||||
r_list_foreach (a->plugins, iter, h) {
|
||||
if (h->arch && h->assemble
|
||||
&& has_bits (h, a->bits)
|
||||
&& !strncmp (a->cur->arch,
|
||||
h->arch,
|
||||
strlen (a->cur->arch))) {
|
||||
if (kw) {
|
||||
if (strstr (h->name, kw)) {
|
||||
return h->assemble;
|
||||
}
|
||||
} else {
|
||||
ase = h->assemble;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ase;
|
||||
}
|
||||
R_API int r_asm_assemble(RAsm *a, RAsmOp *op, const char *buf) {
|
||||
int ret = 0;
|
||||
RAsmPlugin *h;
|
||||
@ -364,21 +387,14 @@ R_API int r_asm_assemble(RAsm *a, RAsmOp *op, const char *buf) {
|
||||
r_str_case (b, 0); // to-lower
|
||||
memset (op, 0, sizeof (RAsmOp));
|
||||
if (a->cur) {
|
||||
int (*ase)(RAsm *a, RAsmOp *op, const char *buf) = NULL;
|
||||
Ase ase = NULL;
|
||||
if (!a->cur->assemble) {
|
||||
/* find callback if no assembler support in current plugin */
|
||||
r_list_foreach (a->plugins, iter, h) {
|
||||
if (h->arch && h->assemble
|
||||
&& has_bits (h, a->bits)
|
||||
&& !strncmp (a->cur->arch,
|
||||
h->arch,
|
||||
strlen (a->cur->arch))) {
|
||||
if (strstr (h->name, ".nz")) {
|
||||
ase = h->assemble;
|
||||
break;
|
||||
} else {
|
||||
ase = h->assemble;
|
||||
}
|
||||
ase = findAssembler (a, ".ks");
|
||||
if (!ase) {
|
||||
ase = findAssembler (a, ".nz");
|
||||
if (!ase) {
|
||||
ase = findAssembler (a, NULL);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -593,6 +609,7 @@ R_API RAsmCode* r_asm_massemble(RAsm *a, const char *buf) {
|
||||
continue;
|
||||
}
|
||||
if (*ptr_start == '.') { /* pseudo */
|
||||
/* TODO: move into a separate function */
|
||||
ptr = ptr_start;
|
||||
if (!strncmp (ptr, ".intel_syntax", 13))
|
||||
a->syntax = R_ASM_SYNTAX_INTEL;
|
||||
|
@ -111,11 +111,11 @@ typedef struct r_asm_t {
|
||||
typedef int (*RAsmModifyCallback)(RAsm *a, ut8 *buf, int field, ut64 val);
|
||||
|
||||
typedef struct r_asm_plugin_t {
|
||||
char *name;
|
||||
char *arch;
|
||||
char *cpus;
|
||||
char *desc;
|
||||
char *license;
|
||||
const char *name;
|
||||
const char *arch;
|
||||
const char *cpus;
|
||||
const char *desc;
|
||||
const char *license;
|
||||
void *user; // user data pointer
|
||||
int bits;
|
||||
bool (*init)(void *user);
|
||||
|
@ -135,9 +135,7 @@ R_API RLib *r_lib_free(RLib *lib) {
|
||||
|
||||
/* THIS IS WRONG */
|
||||
R_API int r_lib_dl_check_filename(const char *file) {
|
||||
if (strstr (file, "."R_LIB_EXT))
|
||||
return R_TRUE;
|
||||
return R_FALSE;
|
||||
return (strstr (file, "."R_LIB_EXT)) != NULL;
|
||||
}
|
||||
|
||||
/* high level api */
|
||||
@ -315,8 +313,11 @@ R_API int r_lib_opendir(RLib *lib, const char *path) {
|
||||
}
|
||||
while ((de = (struct dirent *)readdir (dh))) {
|
||||
snprintf (file, sizeof (file), "%s/%s", path, de->d_name);
|
||||
if (r_lib_dl_check_filename (file))
|
||||
if (r_lib_dl_check_filename (file)) {
|
||||
r_lib_open (lib, file);
|
||||
} else {
|
||||
IFDBG eprintf ("Cannot open %s\n", file);
|
||||
}
|
||||
}
|
||||
closedir (dh);
|
||||
return R_TRUE;
|
||||
|
Loading…
x
Reference in New Issue
Block a user