Rizin
unix-like reverse engineering framework and cli tools
nxo.h File Reference

Go to the source code of this file.

Classes

struct  NXOStart
 
struct  MODHeader
 
struct  MODObject
 
struct  MODMeta
 
struct  RzBinNXOObj
 

Functions

void parseMod (RzBuffer *buf, RzBinNXOObj *bin, ut32 mod0, ut64 baddr)
 
const char * fileType (const ut8 *buf)
 

Function Documentation

◆ fileType()

const char* fileType ( const ut8 buf)

Definition at line 24 of file nxo.c.

24  {
25  if (!memcmp(buf, "NRO0", 4)) {
26  return "nro0";
27  }
28  if (!memcmp(buf, "NRR0", 4)) {
29  return "nrr0";
30  }
31  if (!memcmp(buf, "MOD0", 4)) {
32  return "mod0";
33  }
34  if (!memcmp(buf, "NSO0", 4)) {
35  return "nso0";
36  }
37  return NULL;
38 }
#define NULL
Definition: cris-opc.c:27
voidpf void * buf
Definition: ioapi.h:138

References NULL.

Referenced by check_buffer(), and info().

◆ parseMod()

void parseMod ( RzBuffer buf,
RzBinNXOObj bin,
ut32  mod0,
ut64  baddr 
)

Definition at line 130 of file nxo.c.

130  {
131  ut32 ptr;
132  if (!rz_buf_read_le32_at(buf, mod0, &ptr)) {
133  return;
134  }
135 
136  RZ_LOG_INFO("magic %x at 0x%x\n", ptr, mod0);
137  if (ptr == 0x30444f4d) { // MOD0
138  RZ_LOG_INFO("is mode0\n");
139  MODHeader mh = { 0 };
140  if (!rz_buf_read_le32_at(buf, mod0, &mh.magic) ||
141  !rz_buf_read_le32_at(buf, mod0 + 4, &mh.dynamic) ||
142  !rz_buf_read_le32_at(buf, mod0 + 8, &mh.bss_start) ||
143  !rz_buf_read_le32_at(buf, mod0 + 12, &mh.bss_end) ||
144  !rz_buf_read_le32_at(buf, mod0 + 16, &mh.unwind_start) ||
145  !rz_buf_read_le32_at(buf, mod0 + 20, &mh.unwind_end) ||
146  !rz_buf_read_le32_at(buf, mod0 + 24, &mh.mod_object)) {
147  return;
148  }
149  mh.mod_object += mod0;
150  RZ_LOG_INFO("magic 0x%x\n", mh.magic);
151  RZ_LOG_INFO("dynamic 0x%x\n", mh.dynamic);
152  RZ_LOG_INFO("bss 0x%x 0x%x\n", mh.bss_start, mh.bss_end);
153  RZ_LOG_INFO("unwind 0x%x 0x%x\n", mh.unwind_start, mh.unwind_end);
154  RZ_LOG_INFO("-------------\n");
155  RZ_LOG_INFO("mod 0x%x\n", mh.mod_object);
156 #define MO_(x) rz_buf_read_le64_at(buf, mh.mod_object + rz_offsetof(MODObject, x), &mo.x)
157  MODObject mo = { 0 };
158  if (!MO_(next) || !MO_(prev) || !MO_(relplt) || !MO_(reldyn) ||
159  !MO_(base) || !MO_(dynamic) || !MO_(is_rela) ||
160  !MO_(relplt_size) || !MO_(init) || !MO_(fini) ||
161  !MO_(bucket) || !MO_(chain) || !MO_(strtab) ||
162  !MO_(symtab) || !MO_(strtab_size)) {
163  return;
164  };
165  RZ_LOG_INFO("next 0x%" PFMT64x "\n", mo.next);
166  RZ_LOG_INFO("prev 0x%" PFMT64x "\n", mo.prev);
167  RZ_LOG_INFO("base 0x%" PFMT64x "\n", mo.base);
168  RZ_LOG_INFO("init 0x%" PFMT64x "\n", mo.init);
169  RZ_LOG_INFO("fini 0x%" PFMT64x "\n", mo.fini);
170  RZ_LOG_INFO("relplt 0x%" PFMT64x "\n", mo.relplt - mo.base);
171  RZ_LOG_INFO("symtab = 0x%" PFMT64x "\n", mo.symtab - mo.base);
172  RZ_LOG_INFO("strtab = 0x%" PFMT64x "\n", mo.strtab - mo.base);
173  RZ_LOG_INFO("strtabsz = 0x%" PFMT64x "\n", mo.strtab_size);
174  // ut32 modo = mh.mod_object;
175  ut64 strtab = mo.strtab - mo.base;
176  ut64 symtab = mo.symtab - mo.base;
177  walkSymbols(buf, bin, symtab, strtab, mo.strtab_size, mo.relplt - mo.base, baddr);
178  }
179 }
static bool fini(void *user)
static ut64 baddr(RzBinFile *bf)
Definition: bin_any.c:58
uint32_t ut32
#define MO_(x)
static void walkSymbols(RzBuffer *buf, RzBinNXOObj *bin, ut64 symtab, ut64 strtab, ut64 strtab_size, ut64 relplt, ut64 baddr)
Definition: nxo.c:40
int dynamic(struct state *s)
Definition: puff.c:665
#define rz_buf_read_le32_at(b, addr, result)
Definition: rz_buf.h:271
#define RZ_LOG_INFO(fmtstr,...)
Definition: rz_log.h:54
#define PFMT64x
Definition: rz_types.h:393
Definition: nxo.h:13
ut32 magic
Definition: nxo.h:14
ut32 bss_end
Definition: nxo.h:17
ut32 bss_start
Definition: nxo.h:16
ut32 dynamic
Definition: nxo.h:15
ut32 unwind_start
Definition: nxo.h:18
ut32 mod_object
Definition: nxo.h:20
ut32 unwind_end
Definition: nxo.h:19
Definition: nxo.h:23
ut64 prev
Definition: nxo.h:25
ut64 fini
Definition: nxo.h:33
ut64 symtab
Definition: nxo.h:37
ut64 init
Definition: nxo.h:32
ut64 next
Definition: nxo.h:24
ut64 strtab_size
Definition: nxo.h:38
ut64 base
Definition: nxo.h:28
ut64 relplt
Definition: nxo.h:26
ut64 strtab
Definition: nxo.h:36
Definition: malloc.c:26
bool init
Definition: core.c:77
ut64(WINAPI *w32_GetEnabledXStateFeatures)()

References baddr(), MODObject::base, MODHeader::bss_end, MODHeader::bss_start, MODHeader::dynamic, dynamic(), fini(), MODObject::fini, MODObject::init, init, MODHeader::magic, MO_, MODHeader::mod_object, MODObject::next, PFMT64x, MODObject::prev, MODObject::relplt, rz_buf_read_le32_at, RZ_LOG_INFO, MODObject::strtab, MODObject::strtab_size, MODObject::symtab, MODHeader::unwind_end, MODHeader::unwind_start, ut64(), and walkSymbols().

Referenced by load_buffer().