mirror of
https://github.com/radareorg/radare2.git
synced 2025-01-14 17:48:28 +00:00
Support r2 -B for NES roms
This commit is contained in:
parent
21aa34726e
commit
8926ef0e6b
@ -5,7 +5,9 @@
|
||||
#include "nes/nes_specs.h"
|
||||
|
||||
static bool check_bytes(const ut8 *buf, ut64 length) {
|
||||
if (!buf || length < 4) return false;
|
||||
if (!buf || length < 4) {
|
||||
return false;
|
||||
}
|
||||
return (!memcmp (buf, INES_MAGIC, 4));
|
||||
}
|
||||
|
||||
@ -73,7 +75,7 @@ static RList* symbols(RBinFile *arch) {
|
||||
addsym (ret, "JOYPAD_PORT", JOYPAD_PORT,0x1);
|
||||
addsym (ret, "JOYPAD_PORT1", JOYPAD_PORT1,0x1);
|
||||
addsym (ret, "JOYPAD_PORT2", JOYPAD_PORT2,0x1);
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static RList* sections(RBinFile *arch) {
|
||||
@ -86,10 +88,12 @@ static RList* sections(RBinFile *arch) {
|
||||
eprintf ("Truncated Header\n");
|
||||
return NULL;
|
||||
}
|
||||
if (!(ret = r_list_new ()))
|
||||
if (!(ret = r_list_new ())) {
|
||||
return NULL;
|
||||
if (!(ptr = R_NEW0 (RBinSection)))
|
||||
}
|
||||
if (!(ptr = R_NEW0 (RBinSection))) {
|
||||
return ret;
|
||||
}
|
||||
strcpy (ptr->name, "ROM");
|
||||
ptr->paddr = INES_HDR_SIZE;
|
||||
ptr->size = ihdr.prg_page_count_16k * PRG_PAGE_SIZE;
|
||||
@ -104,8 +108,9 @@ static RList* sections(RBinFile *arch) {
|
||||
static RList *mem (RBinFile *arch) {
|
||||
RList *ret;
|
||||
RBinMem *m, *n;
|
||||
if (!(ret = r_list_new()))
|
||||
if (!(ret = r_list_new())) {
|
||||
return NULL;
|
||||
}
|
||||
ret->free = free;
|
||||
if (!(m = R_NEW0 (RBinMem))) {
|
||||
r_list_free (ret);
|
||||
@ -116,8 +121,9 @@ static RList *mem (RBinFile *arch) {
|
||||
m->size = RAM_SIZE;
|
||||
m->perms = r_str_rwx ("rwx");
|
||||
r_list_append (ret, m);
|
||||
if (!(n = R_NEW0 (RBinMem)))
|
||||
if (!(n = R_NEW0 (RBinMem))) {
|
||||
return ret;
|
||||
}
|
||||
m->mirrors = r_list_new();
|
||||
n->name = strdup ("RAM_MIRROR_2");
|
||||
n->addr = RAM_MIRROR_2_ADDRESS;
|
||||
@ -143,7 +149,7 @@ static RList *mem (RBinFile *arch) {
|
||||
m->size = PPU_REG_SIZE;
|
||||
m->perms = r_str_rwx ("rwx");
|
||||
r_list_append (ret, m);
|
||||
m->mirrors = r_list_new();
|
||||
m->mirrors = r_list_new ();
|
||||
int i;
|
||||
for (i = 1; i < 1024; i++) {
|
||||
if (!(n = R_NEW0 (RBinMem))) {
|
||||
@ -175,7 +181,6 @@ static RList *mem (RBinFile *arch) {
|
||||
m->size = SRAM_SIZE;
|
||||
m->perms = r_str_rwx ("rwx");
|
||||
r_list_append (ret, m);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -194,11 +199,17 @@ static RList* entries(RBinFile *arch) { //Should be 3 offsets pointed by NMI, RE
|
||||
return ret;
|
||||
}
|
||||
|
||||
static ut64 baddr(RBinFile *arch) {
|
||||
// having this we make r2 -B work, otherwise it doesnt works :??
|
||||
return 0;
|
||||
}
|
||||
|
||||
RBinPlugin r_bin_plugin_nes = {
|
||||
.name = "nes",
|
||||
.desc = "NES",
|
||||
.license = "LGPL3",
|
||||
.load_bytes = &load_bytes,
|
||||
.baddr = &baddr,
|
||||
.check_bytes = &check_bytes,
|
||||
.entries = &entries,
|
||||
.sections = sections,
|
||||
|
Loading…
x
Reference in New Issue
Block a user