Fix build

This commit is contained in:
pancake 2017-03-08 23:30:54 +01:00
parent 2f72e83338
commit 8d986c2e2c
11 changed files with 86 additions and 88 deletions

View File

@ -12,6 +12,28 @@ static Sdb* get_sdb (RBinObject *o) {
return NULL;
}
static bool check_bytes(const ut8 *buf, ut64 length) {
if (buf && length > 0xffff && buf[0] != 0xcf) {
const ut32 ep = length - 0x10000 + 0xfff0; /* F000:FFF0 address */
/* hacky check to avoid detecting multidex bins as bios */
/* need better fix for this */
if (!memcmp (buf, "dex", 3)) {
return 0;
}
/* Check if this a 'jmp' opcode */
if ((buf[ep] == 0xea) || (buf[ep] == 0xe9)) {
return 1;
}
}
return 0;
}
static bool check(RBinFile *arch) {
const ut8 *bytes = arch ? r_buf_buffer (arch->buf) : NULL;
ut64 sz = arch ? r_buf_size (arch->buf): 0;
return check_bytes (bytes, sz);
}
static void * load_bytes(RBinFile *arch, const ut8 *buf, ut64 sz, ut64 loadaddr, Sdb *sdb){
if (!check_bytes (buf, sz)) {
return NULL;
@ -59,28 +81,6 @@ static RBinInfo* info(RBinFile *arch) {
return ret;
}
static bool check_bytes(const ut8 *buf, ut64 length) {
if (buf && length > 0xffff && buf[0] != 0xcf) {
const ut32 ep = length - 0x10000 + 0xfff0; /* F000:FFF0 address */
/* hacky check to avoid detecting multidex bins as bios */
/* need better fix for this */
if (!memcmp (buf, "dex", 3)) {
return 0;
}
/* Check if this a 'jmp' opcode */
if ((buf[ep] == 0xea) || (buf[ep] == 0xe9)) {
return 1;
}
}
return 0;
}
static bool check(RBinFile *arch) {
const ut8 *bytes = arch ? r_buf_buffer (arch->buf) : NULL;
ut64 sz = arch ? r_buf_size (arch->buf): 0;
return check_bytes (bytes, sz);
}
static RList* sections(RBinFile *arch) {
RList *ret = NULL;
RBinSection *ptr = NULL;

View File

@ -3,12 +3,6 @@
#define R_BIN_ELF64 1
#include "bin_elf.c"
static bool check(RBinFile *arch) {
const ut8 *bytes = arch ? r_buf_buffer (arch->buf) : NULL;
ut64 sz = arch ? r_buf_size (arch->buf): 0;
return check_bytes (bytes, sz);
}
static bool check_bytes(const ut8 *buf, ut64 length) {
if (buf && length >= 5) {
if (!memcmp (buf, "\x7F\x45\x4c\x46\x02", 5)) {
@ -18,6 +12,12 @@ static bool check_bytes(const ut8 *buf, ut64 length) {
return false;
}
static bool check(RBinFile *arch) {
const ut8 *bytes = arch ? r_buf_buffer (arch->buf) : NULL;
ut64 sz = arch ? r_buf_size (arch->buf): 0;
return check_bytes (bytes, sz);
}
extern struct r_bin_dbginfo_t r_bin_dbginfo_elf64;
extern struct r_bin_write_t r_bin_write_elf64;

View File

@ -50,6 +50,19 @@ static Sdb* get_sdb (RBinObject *o) {
return NULL;
}
static bool check_bytes(const ut8 *buf, ut64 length) {
if (!buf || (st64)length <1) return false;
char *p = fsname (buf, length);
free (p);
return p != NULL;
}
static bool check(RBinFile *arch) {
const ut8 *bytes = arch ? r_buf_buffer (arch->buf) : NULL;
ut64 sz = arch ? r_buf_size (arch->buf): 0;
return check_bytes (bytes, sz);
}
static void * load_bytes(RBinFile *arch, const ut8 *buf, ut64 sz, ut64 loadaddr, Sdb *sdb){
if (check_bytes (buf, sz))
return R_NOTNULL;
@ -103,19 +116,6 @@ static RBinInfo* info(RBinFile *arch) {
return ret;
}
static bool check_bytes(const ut8 *buf, ut64 length) {
if (!buf || (st64)length <1) return false;
char *p = fsname (buf, length);
free (p);
return p != NULL;
}
static bool check(RBinFile *arch) {
const ut8 *bytes = arch ? r_buf_buffer (arch->buf) : NULL;
ut64 sz = arch ? r_buf_size (arch->buf): 0;
return check_bytes (bytes, sz);
}
RBinPlugin r_bin_plugin_fs = {
.name = "fs",
.desc = "filesystem bin plugin",

View File

@ -4,11 +4,6 @@
#include <r_lib.h>
#include "nes/nes_specs.h"
static void * load_bytes(RBinFile *arch, const ut8 *buf, ut64 sz, ut64 loadaddr, Sdb *sdb){
check_bytes (buf, sz);
return R_NOTNULL;
}
static bool check_bytes(const ut8 *buf, ut64 length) {
if (!buf || length < 4) return false;
return (!memcmp (buf, INES_MAGIC, 4));
@ -20,6 +15,11 @@ static bool check(RBinFile *arch) {
return check_bytes (bytes, sz);
}
static void * load_bytes(RBinFile *arch, const ut8 *buf, ut64 sz, ut64 loadaddr, Sdb *sdb){
check_bytes (buf, sz);
return R_NOTNULL;
}
static RBinInfo* info(RBinFile *arch) {
RBinInfo *ret = NULL;
ines_hdr ihdr;

View File

@ -10,12 +10,6 @@
static struct n3ds_firm_hdr loaded_header;
static bool check(RBinFile *arch) {
const ut8 *bytes = arch ? r_buf_buffer (arch->buf) : NULL;
ut64 sz = arch ? r_buf_size (arch->buf): 0;
return check_bytes (bytes, sz);
}
static bool check_bytes(const ut8 *buf, ut64 length) {
if (!buf || length < sizeof (struct n3ds_firm_hdr)) {
return false;
@ -23,6 +17,12 @@ static bool check_bytes(const ut8 *buf, ut64 length) {
return (!memcmp (buf, "FIRM", 4));
}
static bool check(RBinFile *arch) {
const ut8 *bytes = arch ? r_buf_buffer (arch->buf) : NULL;
ut64 sz = arch ? r_buf_size (arch->buf): 0;
return check_bytes (bytes, sz);
}
static void * load_bytes(RBinFile *arch, const ut8 *buf, ut64 sz, ut64 loadaddr, Sdb *sdb) {
return memcpy (&loaded_header, buf, sizeof (struct n3ds_firm_hdr));
}

View File

@ -6,11 +6,6 @@
#include <r_bin.h>
#include "psxexe/psxexe.h"
static void* load_bytes(RBinFile *arch, const ut8 *buf, ut64 sz, ut64 loadaddr, Sdb *sdb) {
check_bytes (buf, sz);
return R_NOTNULL;
}
static bool check_bytes(const ut8 *buf, ut64 length) {
if (!buf || (length < PSXEXE_ID_LEN)) {
return false;
@ -25,6 +20,11 @@ static bool check(RBinFile *arch) {
return check_bytes (r_buf_buffer (arch->buf), r_buf_size (arch->buf));
}
static void* load_bytes(RBinFile *arch, const ut8 *buf, ut64 sz, ut64 loadaddr, Sdb *sdb) {
check_bytes (buf, sz);
return R_NOTNULL;
}
static RBinInfo* info(RBinFile* arch) {
RBinInfo* ret = NULL;
psxexe_header psxheader;

View File

@ -1,4 +1,4 @@
/* radare - LGPL3 - 2015-2016 - pancake */
/* radare - LGPL3 - 2015-2017 - pancake */
#include <r_bin.h>
@ -91,13 +91,6 @@ typedef struct gen_vect {
};
} SMD_Vectors;
static void * load_bytes(RBinFile *arch, const ut8 *buf, ut64 sz, ut64 loadaddr, Sdb *sdb){
check_bytes (buf, sz);
return R_NOTNULL;
}
static bool check_bytes(const ut8 *buf, ut64 length) {
if (length > 0x190 && !memcmp (buf+0x100, "SEGA", 4)) {
return true;
@ -111,6 +104,11 @@ static bool check(RBinFile *arch) {
return check_bytes (bytes, sz);
}
static void * load_bytes(RBinFile *arch, const ut8 *buf, ut64 sz, ut64 loadaddr, Sdb *sdb){
check_bytes (buf, sz);
return R_NOTNULL;
}
static RBinInfo* info(RBinFile *arch) {
RBinInfo *ret = NULL;
if (!(ret = R_NEW0 (RBinInfo)))
@ -296,7 +294,7 @@ static RList* entries(RBinFile *arch) { //Should be 3 offsets pointed by NMI, RE
return ret;
}
struct r_bin_plugin_t r_bin_plugin_smd = {
RBinPlugin r_bin_plugin_smd = {
.name = "smd",
.desc = "SEGA Genesis/Megadrive",
.license = "LGPL3",
@ -312,7 +310,7 @@ struct r_bin_plugin_t r_bin_plugin_smd = {
};
#ifndef CORELIB
struct r_lib_struct_t radare_plugin = {
RLibStruct radare_plugin = {
.type = R_LIB_TYPE_BIN,
.data = &r_bin_plugin_smd,
.version = R2_VERSION

View File

@ -11,11 +11,6 @@ typedef struct gen_hdr {
ut8 RegionRomSize; //Low 4 bits RomSize, Top 4 bits Region
} SMS_Header;
static void * load_bytes(RBinFile *arch, const ut8 *buf, ut64 sz, ut64 loadaddr, Sdb *sdb){
check_bytes (buf, sz);
return R_NOTNULL;
}
#define CMP8(o,x) strncmp((const char*)bs+o,x,8)
#define CMP4(o,x) strncmp((const char*)bs+o,x,4)
static bool check_bytes(const ut8 *bs, ut64 length) {
@ -43,6 +38,11 @@ static bool check(RBinFile *arch) {
return check_bytes (bytes, sz);
}
static void * load_bytes(RBinFile *arch, const ut8 *buf, ut64 sz, ut64 loadaddr, Sdb *sdb){
check_bytes (buf, sz);
return R_NOTNULL;
}
static RBinInfo* info(RBinFile *arch) {
const char *bs;
SMS_Header *hdr = NULL;

View File

@ -4,11 +4,6 @@
#include <r_lib.h>
#include "../format/spc700/spc_specs.h"
static void * load_bytes(RBinFile *arch, const ut8 *buf, ut64 sz, ut64 loadaddr, Sdb *sdb){
check_bytes (buf, sz);
return R_NOTNULL;
}
static bool check_bytes(const ut8 *buf, ut64 length) {
if (!buf || length < 27) {
return false;
@ -22,6 +17,11 @@ static bool check(RBinFile *arch) {
return check_bytes (bytes, sz);
}
static void * load_bytes(RBinFile *arch, const ut8 *buf, ut64 sz, ut64 loadaddr, Sdb *sdb){
check_bytes (buf, sz);
return R_NOTNULL;
}
static RBinInfo* info(RBinFile *arch) {
RBinInfo *ret = NULL;
spc_hdr spchdr;

View File

@ -144,6 +144,10 @@ static RBinInfo* info(RBinFile *arch) {
return ret;
}
static bool check_bytes(const ut8 *buf, ut64 length) {
return (buf && length > 2 && !memcmp (buf, "\x56\x5a", 2));
}
static bool check(RBinFile *arch) {
const ut8 *bytes = arch ? r_buf_buffer (arch->buf) : NULL;
ut64 sz = arch ? r_buf_size (arch->buf): 0;
@ -151,10 +155,6 @@ static bool check(RBinFile *arch) {
}
static bool check_bytes(const ut8 *buf, ut64 length) {
return (buf && length > 2 && !memcmp (buf, "\x56\x5a", 2));
}
RBinPlugin r_bin_plugin_te = {
.name = "te",
.desc = "TE bin plugin", // Terse Executable format

View File

@ -44,12 +44,6 @@ static ut64 baddr(RBinFile *arch) {
return 0;
}
static bool check(RBinFile *arch) {
const ut8 *bytes = arch ? r_buf_buffer (arch->buf) : NULL;
ut64 sz = arch ? r_buf_size (arch->buf): 0;
return check_bytes (bytes, sz);
}
static bool check_bytes(const ut8 *buf, ut64 length) {
if (buf && length >= 8) {
// Checking ARM zImage kernel
@ -61,6 +55,12 @@ static bool check_bytes(const ut8 *buf, ut64 length) {
return false;
}
static bool check(RBinFile *arch) {
const ut8 *bytes = arch ? r_buf_buffer (arch->buf) : NULL;
ut64 sz = arch ? r_buf_size (arch->buf): 0;
return check_bytes (bytes, sz);
}
static RBinInfo *info(RBinFile *arch) {
RBinInfo *ret = R_NEW0 (RBinInfo);
if (!ret) return NULL;
@ -94,7 +94,7 @@ struct r_bin_plugin_t r_bin_plugin_zimg = {
};
#ifndef CORELIB
struct r_lib_struct_t radare_plugin = {
RLibStruct radare_plugin = {
.type = R_LIB_TYPE_BIN,
.data = &r_bin_plugin_zimg,
.version = R2_VERSION