Rizin
unix-like reverse engineering framework and cli tools
ddesc.c
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2010-2013 pancake <pancake@nopcode.org>
2 // SPDX-License-Identifier: LGPL-3.0-only
3 
4 // XXX: All this stuff must be linked to the code injection api
5 
6 #include <rz_debug.h>
7 
8 RZ_API RzDebugDesc *rz_debug_desc_new(int fd, char *path, int perm, int type, int off) {
10  if (desc) {
11  desc->fd = fd;
12  desc->path = strdup(path);
13  desc->perm = perm;
14  desc->type = type;
15  desc->off = off;
16  }
17  return desc;
18 }
19 
21  if (p) {
22  if (p->path) {
23  free(p->path);
24  }
25  free(p);
26  }
27 }
28 
30  if (dbg && dbg->cur && dbg->cur->desc.open) {
31  return dbg->cur->desc.open(path);
32  }
33  return false;
34 }
35 
37  if (dbg && dbg->cur && dbg->cur->desc.close) {
38  return dbg->cur->desc.close(fd);
39  }
40  return false;
41 }
42 
43 RZ_API int rz_debug_desc_dup(RzDebug *dbg, int fd, int newfd) {
44  if (dbg && dbg->cur && dbg->cur->desc.dup) {
45  return dbg->cur->desc.dup(fd, newfd);
46  }
47  return false;
48 }
49 
51  if (dbg && dbg->cur && dbg->cur->desc.read) {
52  return dbg->cur->desc.read(fd, addr, len);
53  }
54  return false;
55 }
56 
58  if (dbg && dbg->cur && dbg->cur->desc.seek) {
59  return dbg->cur->desc.seek(fd, addr);
60  }
61  return false;
62 }
63 
65  if (dbg && dbg->cur && dbg->cur->desc.write) {
66  return dbg->cur->desc.write(fd, addr, len);
67  }
68  return false;
69 }
70 
72  int count = 0;
73  RzList *list;
75  RzDebugDesc *p;
76 
77  if (rad) {
78  if (dbg && dbg->cb_printf) {
79  dbg->cb_printf("TODO \n");
80  }
81  } else {
82  if (dbg && dbg->cur && dbg->cur->desc.list) {
83  list = dbg->cur->desc.list(dbg->pid);
84  rz_list_foreach (list, iter, p) {
85  dbg->cb_printf("%i 0x%" PFMT64x " %c%c%c %s\n", p->fd, p->off,
86  (p->perm & RZ_PERM_R) ? 'r' : '-',
87  (p->perm & RZ_PERM_W) ? 'w' : '-',
88  p->type, p->path);
89  }
91  free(list);
92  }
93  }
94  return count;
95 }
size_t len
Definition: 6502dis.c:15
const char * desc
Definition: bin_vsf.c:19
#define RZ_API
static static fork const void static count static fd const char const char static newpath const char static path const char path
Definition: sflib.h:35
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void count
Definition: sflib.h:98
RZ_API int rz_debug_desc_open(RzDebug *dbg, const char *path)
Definition: ddesc.c:29
RZ_API int rz_debug_desc_seek(RzDebug *dbg, int fd, ut64 addr)
Definition: ddesc.c:57
RZ_API int rz_debug_desc_list(RzDebug *dbg, int rad)
Definition: ddesc.c:71
RZ_API int rz_debug_desc_dup(RzDebug *dbg, int fd, int newfd)
Definition: ddesc.c:43
RZ_API int rz_debug_desc_write(RzDebug *dbg, int fd, ut64 addr, int len)
Definition: ddesc.c:64
RZ_API int rz_debug_desc_close(RzDebug *dbg, int fd)
Definition: ddesc.c:36
RZ_API RzDebugDesc * rz_debug_desc_new(int fd, char *path, int perm, int type, int off)
Definition: ddesc.c:8
RZ_API int rz_debug_desc_read(RzDebug *dbg, int fd, ut64 addr, int len)
Definition: ddesc.c:50
RZ_API void rz_debug_desc_free(RzDebugDesc *p)
Definition: ddesc.c:20
RzDebug * dbg
Definition: desil.c:30
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
void * p
Definition: libc.cpp:67
static void list(RzEgg *egg)
Definition: rz-gg.c:52
RZ_API void rz_list_purge(RZ_NONNULL RzList *list)
Empties the list without freeing the list pointer.
Definition: list.c:120
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")
int type
Definition: mipsasm.c:17
int off
Definition: pal.c:13
#define RZ_PERM_R
Definition: rz_types.h:93
#define RZ_NEW(x)
Definition: rz_types.h:285
#define RZ_PERM_W
Definition: rz_types.h:94
#define PFMT64x
Definition: rz_types.h:393
int(* write)(int fd, ut64 addr, int len)
Definition: rz_debug.h:330
RzList *(* list)(int pid)
Definition: rz_debug.h:333
int(* dup)(int fd, int newfd)
Definition: rz_debug.h:332
int(* close)(int fd)
Definition: rz_debug.h:328
int(* seek)(int fd, ut64 addr)
Definition: rz_debug.h:331
int(* open)(const char *path)
Definition: rz_debug.h:327
int(* read)(int fd, ut64 addr, int len)
Definition: rz_debug.h:329
RzDebugDescPlugin desc
Definition: rz_debug.h:403
PrintfCallback cb_printf
Definition: rz_debug.h:292
struct rz_debug_plugin_t * cur
Definition: rz_debug.h:295
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
static const z80_opcode fd[]
Definition: z80_tab.h:997
static int addr
Definition: z80asm.c:58