mirror of
https://github.com/radareorg/radare2.git
synced 2025-01-20 20:55:32 +00:00
Define and use R_NOTNULL in RBinPlugin.load_bytes
This commit is contained in:
parent
5280575d49
commit
95bb7bb74e
@ -16,7 +16,7 @@ static Sdb* get_sdb (RBinObject *o) {
|
||||
}
|
||||
|
||||
static void * load_bytes(const ut8 *buf, ut64 sz, ut64 loadaddr, Sdb *sdb){
|
||||
return (void*)(size_t)1;
|
||||
return R_NOTNULL;
|
||||
}
|
||||
|
||||
static int load(RBinFile *arch) {
|
||||
|
@ -18,7 +18,7 @@ static Sdb* get_sdb (RBinObject *o) {
|
||||
static void * load_bytes(const ut8 *buf, ut64 sz, ut64 loadaddr, Sdb *sdb){
|
||||
check_bytes (buf, sz);
|
||||
// XXX: this may be wrong if check_bytes is true
|
||||
return NULL;
|
||||
return R_NOTNULL;
|
||||
}
|
||||
|
||||
static int load(RBinFile *arch) {
|
||||
|
@ -29,9 +29,8 @@ static Sdb* get_sdb (RBinObject *o) {
|
||||
static void * load_bytes(const ut8 *buf, ut64 sz, ut64 loadaddr, Sdb *sdb){
|
||||
void *res = NULL;
|
||||
RBuffer *tbuf = NULL;
|
||||
|
||||
if (!buf || sz == 0 || sz == UT64_MAX) return NULL;
|
||||
tbuf = r_buf_new();
|
||||
tbuf = r_buf_new ();
|
||||
r_buf_set_bytes (tbuf, buf, sz);
|
||||
res = r_bin_dex_new_buf (tbuf);
|
||||
r_buf_free (tbuf);
|
||||
|
@ -55,7 +55,7 @@ static Sdb* get_sdb (RBinObject *o) {
|
||||
|
||||
static void * load_bytes(const ut8 *buf, ut64 sz, ut64 loadaddr, Sdb *sdb){
|
||||
if (check_bytes (buf, sz))
|
||||
return (void*)R_TRUE;
|
||||
return R_NOTNULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ static int check_bytes(const ut8 *buf, ut64 length) {
|
||||
}
|
||||
|
||||
static void * load_bytes(const ut8 *buf, ut64 sz, ut64 loadaddr, Sdb *sdb) {
|
||||
return memcpy(&loaded_header, buf, sizeof(struct nds_hdr));
|
||||
return memcpy (&loaded_header, buf, sizeof(struct nds_hdr));
|
||||
}
|
||||
|
||||
static int load(RBinFile *arch) {
|
||||
|
@ -18,7 +18,7 @@ static Sdb* get_sdb (RBinObject *o) {
|
||||
}
|
||||
|
||||
static void * load_bytes(const ut8 *buf, ut64 sz, ut64 loadaddr, Sdb *sdb){
|
||||
return (void*)R_TRUFAE;
|
||||
return R_NOTNULL;
|
||||
}
|
||||
|
||||
static int check(RBinFile *arch) {
|
||||
|
@ -9,7 +9,6 @@
|
||||
|
||||
static int check(RBinFile *arch);
|
||||
int check_bytes(const ut8 *buf, ut64 length);
|
||||
static void * load_bytes(const ut8 *buf, ut64 sz, ut64 loadaddr, Sdb *sdb);
|
||||
|
||||
static int check(RBinFile *arch) {
|
||||
const ut8 *bytes = arch ? r_buf_buffer (arch->buf) : NULL;
|
||||
@ -19,7 +18,6 @@ static int check(RBinFile *arch) {
|
||||
}
|
||||
|
||||
int check_bytes(const ut8 *buf, ut64 length) {
|
||||
|
||||
ut8 lict[156];
|
||||
if (!buf || length < 160)
|
||||
return 0;
|
||||
@ -34,15 +32,10 @@ static Sdb* get_sdb (RBinObject *o) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void * load_bytes(const ut8 *buf, ut64 sz, ut64 loadaddr, Sdb *sdb){
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int load(RBinFile *arch) {
|
||||
const ut8 *bytes = arch ? r_buf_buffer (arch->buf) : NULL;
|
||||
ut64 sz = arch ? r_buf_size (arch->buf): 0;
|
||||
if (!arch || !arch->o) return R_FALSE;
|
||||
arch->o->bin_obj = load_bytes (bytes, sz, arch->o->loadaddr, arch->sdb);
|
||||
return check_bytes (bytes, sz);
|
||||
}
|
||||
|
||||
@ -106,7 +99,6 @@ struct r_bin_plugin_t r_bin_plugin_ningba = {
|
||||
.fini = NULL,
|
||||
.get_sdb = &get_sdb,
|
||||
.load = &load,
|
||||
.load_bytes = &load_bytes,
|
||||
.destroy = &destroy,
|
||||
.check = &check,
|
||||
.check_bytes = &check_bytes,
|
||||
|
@ -18,6 +18,7 @@
|
||||
#define R_FALSE 0
|
||||
#define R_TRUE 1
|
||||
#define R_TRUFAE 2
|
||||
#define R_NOTNULL (void*)(size_t)1
|
||||
|
||||
/* limits */
|
||||
#undef UT64_MAX
|
||||
|
Loading…
x
Reference in New Issue
Block a user