Rizin
unix-like reverse engineering framework and cli tools
bin_zimg.c File Reference
#include <rz_types.h>
#include <rz_util.h>
#include <rz_lib.h>
#include <rz_bin.h>
#include "zimg/zimg.h"

Go to the source code of this file.

Functions

static Sdbget_sdb (RzBinFile *bf)
 
static bool load_buffer (RzBinFile *bf, RzBinObject *obj, RzBuffer *b, Sdb *sdb)
 
static ut64 baddr (RzBinFile *bf)
 
static bool check_buffer (RzBuffer *b)
 
static RzBinInfoinfo (RzBinFile *bf)
 

Variables

RzBinPlugin rz_bin_plugin_zimg
 
RZ_API RzLibStruct rizin_plugin
 

Function Documentation

◆ baddr()

static ut64 baddr ( RzBinFile bf)
static

Definition at line 21 of file bin_zimg.c.

21  {
22  return 0;
23 }

◆ check_buffer()

static bool check_buffer ( RzBuffer b)
static

Definition at line 25 of file bin_zimg.c.

25  {
26  ut8 zimghdr[8];
27  if (rz_buf_read_at(b, 0, zimghdr, sizeof(zimghdr))) {
28  // Checking ARM zImage kernel
29  if (!memcmp(zimghdr, "\x00\x00\xa0\xe1\x00\x00\xa0\xe1", 8)) {
30  return true;
31  }
32  }
33  return false;
34 }
uint8_t ut8
Definition: lh5801.h:11
RZ_API st64 rz_buf_read_at(RZ_NONNULL RzBuffer *b, ut64 addr, RZ_NONNULL RZ_OUT ut8 *buf, ut64 len)
Read len bytes of the buffer at the specified address.
Definition: buf.c:1136
#define b(i)
Definition: sha256.c:42

References b, and rz_buf_read_at().

◆ get_sdb()

static Sdb* get_sdb ( RzBinFile bf)
static

Definition at line 10 of file bin_zimg.c.

10  {
11  rz_return_val_if_fail(bf && bf->o, false);
12  struct rz_bin_zimg_obj_t *bin = (struct rz_bin_zimg_obj_t *)bf->o->bin_obj;
13  return bin ? bin->kv : NULL;
14 }
#define NULL
Definition: cris-opc.c:27
#define rz_return_val_if_fail(expr, val)
Definition: rz_assert.h:108
Definition: malloc.c:26
RzBinObject * o
Definition: rz_bin.h:305
void * bin_obj
Definition: rz_bin.h:293

References rz_bin_object_t::bin_obj, NULL, rz_bin_file_t::o, and rz_return_val_if_fail.

◆ info()

static RzBinInfo* info ( RzBinFile bf)
static

Definition at line 36 of file bin_zimg.c.

36  {
37  RzBinInfo *ret = RZ_NEW0(RzBinInfo);
38  if (!ret) {
39  return NULL;
40  }
41  ret->file = bf->file ? strdup(bf->file) : NULL;
42  ret->type = strdup("Linux zImage Kernel");
43  ret->has_va = false;
44  ret->bclass = strdup("Compressed Linux Kernel");
45  ret->rclass = strdup("zimg");
46  ret->os = strdup("linux");
47  ret->subsystem = strdup("linux");
48  ret->machine = strdup("ARM"); // TODO: can be other cpus
49  ret->arch = strdup("arm");
50  ret->lang = "C";
51  ret->bits = 32;
52  ret->big_endian = 0;
53  ret->dbg_info = 0; // 1 | 4 | 8; /* Stripped | LineNums | Syms */
54  return ret;
55 }
return strdup("=SP r13\n" "=LR r14\n" "=PC r15\n" "=A0 r0\n" "=A1 r1\n" "=A2 r2\n" "=A3 r3\n" "=ZF zf\n" "=SF nf\n" "=OF vf\n" "=CF cf\n" "=SN or0\n" "gpr lr .32 56 0\n" "gpr pc .32 60 0\n" "gpr cpsr .32 64 0 ____tfiae_________________qvczn\n" "gpr or0 .32 68 0\n" "gpr tf .1 64.5 0 thumb\n" "gpr ef .1 64.9 0 endian\n" "gpr jf .1 64.24 0 java\n" "gpr qf .1 64.27 0 sticky_overflow\n" "gpr vf .1 64.28 0 overflow\n" "gpr cf .1 64.29 0 carry\n" "gpr zf .1 64.30 0 zero\n" "gpr nf .1 64.31 0 negative\n" "gpr itc .4 64.10 0 if_then_count\n" "gpr gef .4 64.16 0 great_or_equal\n" "gpr r0 .32 0 0\n" "gpr r1 .32 4 0\n" "gpr r2 .32 8 0\n" "gpr r3 .32 12 0\n" "gpr r4 .32 16 0\n" "gpr r5 .32 20 0\n" "gpr r6 .32 24 0\n" "gpr r7 .32 28 0\n" "gpr r8 .32 32 0\n" "gpr r9 .32 36 0\n" "gpr r10 .32 40 0\n" "gpr r11 .32 44 0\n" "gpr r12 .32 48 0\n" "gpr r13 .32 52 0\n" "gpr r14 .32 56 0\n" "gpr r15 .32 60 0\n" "gpr r16 .32 64 0\n" "gpr r17 .32 68 0\n")
#define RZ_NEW0(x)
Definition: rz_types.h:284
char * file
Definition: rz_bin.h:299
int has_va
Definition: rz_bin.h:228
char * type
Definition: rz_bin.h:211
char * os
Definition: rz_bin.h:219
char * subsystem
Definition: rz_bin.h:220
char * machine
Definition: rz_bin.h:216
const char * lang
Definition: rz_bin.h:224
char * bclass
Definition: rz_bin.h:212
char * file
Definition: rz_bin.h:210
ut64 dbg_info
Definition: rz_bin.h:240
char * rclass
Definition: rz_bin.h:213
char * arch
Definition: rz_bin.h:214
int big_endian
Definition: rz_bin.h:235

References rz_bin_info_t::arch, rz_bin_info_t::bclass, rz_bin_info_t::big_endian, rz_bin_info_t::bits, rz_bin_info_t::dbg_info, rz_bin_info_t::file, rz_bin_file_t::file, rz_bin_info_t::has_va, rz_bin_info_t::lang, rz_bin_info_t::machine, NULL, rz_bin_info_t::os, rz_bin_info_t::rclass, RZ_NEW0, strdup(), rz_bin_info_t::subsystem, and rz_bin_info_t::type.

◆ load_buffer()

static bool load_buffer ( RzBinFile bf,
RzBinObject obj,
RzBuffer b,
Sdb sdb 
)
static

Definition at line 16 of file bin_zimg.c.

16  {
18  return obj->bin_obj != NULL;
19 }
struct rz_bin_zimg_obj_t * rz_bin_zimg_new_buf(RzBuffer *buf)
Definition: zimg.c:8

References b, rz_bin_object_t::bin_obj, NULL, and rz_bin_zimg_new_buf().

Variable Documentation

◆ rizin_plugin

RZ_API RzLibStruct rizin_plugin
Initial value:
= {
.type = RZ_LIB_TYPE_BIN,
}
RzBinPlugin rz_bin_plugin_zimg
Definition: bin_zimg.c:57
@ RZ_LIB_TYPE_BIN
Definition: rz_lib.h:75
#define RZ_VERSION
Definition: rz_version.h:8
char * version
Definition: rz_bin.h:512

Definition at line 69 of file bin_zimg.c.

◆ rz_bin_plugin_zimg

RzBinPlugin rz_bin_plugin_zimg
Initial value:
= {
.name = "zimg",
.desc = "zimg format bin plugin",
.license = "LGPL3",
.get_sdb = &get_sdb,
.load_buffer = &load_buffer,
.check_buffer = &check_buffer,
.baddr = &baddr,
.info = &info,
}
static bool load_buffer(RzBinFile *bf, RzBinObject *obj, RzBuffer *b, Sdb *sdb)
Definition: bin_zimg.c:16
static Sdb * get_sdb(RzBinFile *bf)
Definition: bin_zimg.c:10
static bool check_buffer(RzBuffer *b)
Definition: bin_zimg.c:25
static RzBinInfo * info(RzBinFile *bf)
Definition: bin_zimg.c:36
static ut64 baddr(RzBinFile *bf)
Definition: bin_zimg.c:21

Definition at line 57 of file bin_zimg.c.