Rizin
unix-like reverse engineering framework and cli tools
dmap.c
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2009-2017 pancake <pancake@nopcode.org>
2 // SPDX-License-Identifier: LGPL-3.0-only
3 
4 #include <rz_debug.h>
5 #include <rz_list.h>
6 
7 RZ_API RzDebugMap *rz_debug_map_new(char *name, ut64 addr, ut64 addr_end, int perm, int user) {
9  /* range could be 0k on OpenBSD, it's a honeypot */
10  if (!name || addr > addr_end) {
11  eprintf("rz_debug_map_new: error (\
12  %" PFMT64x ">%" PFMT64x ")\n",
13  addr, addr_end);
14  return NULL;
15  }
17  if (!map) {
18  return NULL;
19  }
20  map->name = strdup(name);
21  map->addr = addr;
22  map->addr_end = addr_end;
23  map->size = addr_end - addr;
24  map->perm = perm;
25  map->user = user;
26  return map;
27 }
28 
30  return (dbg && dbg->cur && dbg->cur->modules_get) ? dbg->cur->modules_get(dbg) : NULL;
31 }
32 
34  bool ret = false;
35  if (dbg && dbg->cur && dbg->cur->map_get) {
36  RzList *newmaps = dbg->cur->map_get(dbg);
37  if (newmaps) {
39  dbg->maps = newmaps;
40  ret = true;
41  }
42  }
43  return ret;
44 }
45 
47  RzDebugMap *map = NULL;
48  if (dbg && dbg->cur && dbg->cur->map_alloc) {
49  map = dbg->cur->map_alloc(dbg, addr, size, thp);
50  }
51  return map;
52 }
53 
55  bool ret = false;
56  ut64 addr = map->addr;
57  if (dbg && dbg->cur && dbg->cur->map_dealloc) {
58  if (dbg->cur->map_dealloc(dbg, addr, map->size)) {
59  ret = true;
60  }
61  }
62  return (int)ret;
63 }
64 
66  RzDebugMap *map, *ret = NULL;
68  rz_list_foreach (dbg->maps, iter, map) {
69  if (addr >= map->addr && addr <= map->addr_end) {
70  ret = map;
71  break;
72  }
73  }
74  return ret;
75 }
76 
78  free(map->name);
79  free(map->file);
80  free(map);
81 }
82 
84  RzList *list = rz_list_new();
85  if (!list) {
86  return NULL;
87  }
89  return list;
90 }
91 
99  return user_map ? dbg->maps_user : dbg->maps;
100 }
#define RZ_API
#define NULL
Definition: cris-opc.c:27
RzDebug * dbg
Definition: desil.c:30
RZ_API RzList * rz_debug_map_list_new(void)
Definition: dmap.c:83
RZ_API RZ_BORROW RzList * rz_debug_map_list(RzDebug *dbg, bool user_map)
Get RzList* of memory maps for the process currently being debugged.
Definition: dmap.c:98
RZ_API RzDebugMap * rz_debug_map_get(RzDebug *dbg, ut64 addr)
Definition: dmap.c:65
RZ_API void rz_debug_map_free(RzDebugMap *map)
Definition: dmap.c:77
RZ_API int rz_debug_map_dealloc(RzDebug *dbg, RzDebugMap *map)
Definition: dmap.c:54
RZ_API bool rz_debug_map_sync(RzDebug *dbg)
Definition: dmap.c:33
RZ_API RzDebugMap * rz_debug_map_new(char *name, ut64 addr, ut64 addr_end, int perm, int user)
Definition: dmap.c:7
RZ_API RzDebugMap * rz_debug_map_alloc(RzDebug *dbg, ut64 addr, int size, bool thp)
Definition: dmap.c:46
RZ_API RzList * rz_debug_modules_list(RzDebug *dbg)
Definition: dmap.c:29
size_t map(int syms, int left, int len)
Definition: enough.c:237
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
voidpf void uLong size
Definition: ioapi.h:138
static void list(RzEgg *egg)
Definition: rz-gg.c:52
RZ_API RZ_OWN RzList * rz_list_new(void)
Returns a new initialized RzList pointer (free method is not initialized)
Definition: list.c:235
RZ_API void rz_list_free(RZ_NONNULL RzList *list)
Empties the list and frees the list pointer.
Definition: list.c:137
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 eprintf(x, y...)
Definition: rlcc.c:7
void(* RzListFree)(void *ptr)
Definition: rz_list.h:11
#define RZ_NEW0(x)
Definition: rz_types.h:284
#define PFMT64x
Definition: rz_types.h:393
#define RZ_BORROW
Definition: rz_types.h:63
Definition: z80asm.h:102
RzDebugMap *(* map_alloc)(RzDebug *dbg, ut64 addr, int size, bool thp)
Definition: rz_debug.h:399
int(* map_dealloc)(RzDebug *dbg, ut64 addr, int size)
Definition: rz_debug.h:400
RzList *(* modules_get)(RzDebug *dbg)
Definition: rz_debug.h:398
RzList *(* map_get)(RzDebug *dbg)
Definition: rz_debug.h:397
RzList * maps_user
Definition: rz_debug.h:307
RzList * maps
Definition: rz_debug.h:306
struct rz_debug_plugin_t * cur
Definition: rz_debug.h:295
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
static int addr
Definition: z80asm.c:58