Rizin
unix-like reverse engineering framework and cli tools
cmd_linux_heap_glibc.c
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2021 Pulak Malhotra <pulakmalhotra2000@gmail.com>
2 // SPDX-License-Identifier: LGPL-3.0-only
3 
4 #include <rz_types.h>
5 #include <rz_core.h>
6 #include <rz_heap_glibc.h>
7 #include "cmd_descs.h"
8 #include "../linux_heap_glibc.h"
9 #include "../linux_heap_glibc64.h"
10 
11 #define call_handler(fun, ...) \
12  { \
13  if (core->rasm->bits == 64) { \
14  return fun##_64(core, ##__VA_ARGS__); \
15  } else { \
16  return fun##_32(core, ##__VA_ARGS__); \
17  } \
18  }
19 
22 }
23 
24 RZ_IPI RzCmdStatus rz_cmd_arena_print_handler(RzCore *core, int argc, const char **argv) {
26 }
27 
30 }
31 
34 }
35 
37  // RZ_OUTPUT_MODE_LONG_JSON mode workaround for graph
38  RzCmdStateOutput state = { 0 };
40  return RZ_CMD_STATUS_ERROR;
41  }
42  RzCmdStatus res;
43  if (core->rasm->bits == 64) {
44  res = rz_cmd_heap_chunks_print_handler_64(core, argc, argv, &state);
45  } else {
46  res = rz_cmd_heap_chunks_print_handler_32(core, argc, argv, &state);
47  }
50  return res;
51 }
52 
55 }
56 
59 }
60 
61 RZ_IPI int rz_cmd_heap_bins_list_print(void *data, const char *input) {
62  RzCore *core = (RzCore *)data;
64 }
65 
66 RZ_IPI int rz_cmd_heap_fastbins_print(void *data, const char *input) {
67  RzCore *core = (RzCore *)data;
69 }
70 
73 }
74 
75 /* API functions for Heap Viewer in Cutter */
76 
82 RZ_API RzList /*<MallocState *>*/ *rz_heap_arenas_list(RzCore *core) {
84 }
85 
92 RZ_API RzList /*<RzHeapChunkListItem *>*/ *rz_heap_chunks_list(RzCore *core, ut64 m_arena) {
94 }
95 
104 }
105 
114 RZ_API RzHeapBin *rz_heap_bin_content(RzCore *core, MallocState *arena, int bin_num, ut64 m_arena) {
115  call_handler(rz_heap_bin_content, arena, bin_num, m_arena);
116 }
117 
126  call_handler(rz_heap_fastbin_content, arena, bin_num);
127 }
128 
139 }
140 
149 RZ_API RzList /*<RzHeapBin *>*/ *rz_heap_tcache_content(RzCore *core, ut64 arena_base) {
151 }
152 
160  call_handler(rz_heap_write_heap_chunk, chunk_simple);
161 }
#define RZ_IPI
Definition: analysis_wasm.c:11
RZ_API bool rz_cmd_state_output_init(RZ_NONNULL RzCmdStateOutput *state, RzOutputMode mode)
Initialize a RzCmdStateOutput structure and its inner fields based on the provided mode.
Definition: cmd_api.c:2634
RZ_API void rz_cmd_state_output_fini(RZ_NONNULL RzCmdStateOutput *state)
Clear the inner fields of RzCmdStateOutput structure, but do not free it.
Definition: cmd_api.c:2603
RZ_API void rz_cmd_state_output_print(RZ_NONNULL RzCmdStateOutput *state)
Print the output accumulated in state to RzCons, if necessary.
Definition: cmd_api.c:2668
RZ_API bool rz_heap_write_chunk(RzCore *core, RzHeapChunkSimple *chunk_simple)
Write a heap chunk header to memory.
RZ_IPI int rz_cmd_heap_bins_list_print(void *data, const char *input)
RZ_API RzHeapChunkSimple * rz_heap_chunk(RzCore *core, ut64 addr)
Returns detailed information about a heap chunk. The chunk is represented by RzHeapChunkSimple struct...
RZ_IPI RzCmdStatus rz_cmd_heap_info_print_handler(RzCore *core, int argc, const char **argv)
RZ_API RzList * rz_heap_chunks_list(RzCore *core, ut64 m_arena)
Returns RzList* for a list of chunks from the arena. Each chunk is represented by RzHeapChunkListItem...
RZ_API RzList * rz_heap_tcache_content(RzCore *core, ut64 arena_base)
Get a list of bins for the tcache associated with an arena The list is in form of RzList and the bins...
RZ_API RzList * rz_heap_arenas_list(RzCore *core)
Returns RzList* for a list of arenas. Each arena is represented by RzArenaListItem struct.
RZ_IPI RzCmdStatus rz_cmd_heap_chunks_graph_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_cmd_heap_arena_bins_print_handler(RzCore *core, int argc, const char **argv, RzOutputMode mode)
RZ_IPI RzCmdStatus rz_cmd_heap_tcache_print_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_cmd_arena_print_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_cmd_heap_chunk_print_handler(RzCore *core, int argc, const char **argv)
#define call_handler(fun,...)
RZ_API MallocState * rz_heap_get_arena(RzCore *core, ut64 m_state)
Returns MallocState struct for given base address of the arena. This function checks if the arena is ...
RZ_API RzHeapBin * rz_heap_fastbin_content(RzCore *core, MallocState *arena, int bin_num)
Returns information about a fastbin. The information is represented as RzHeapBin struct.
RZ_IPI int rz_cmd_heap_fastbins_print(void *data, const char *input)
RZ_API RzHeapBin * rz_heap_bin_content(RzCore *core, MallocState *arena, int bin_num, ut64 m_arena)
Returns information about a heap bin. The information is represented as RzHeapBin struct The bins cov...
RZ_IPI RzCmdStatus rz_cmd_heap_chunks_print_handler(RzCore *core, int argc, const char **argv, RzCmdStateOutput *state)
RZ_IPI RzCmdStatus rz_cmd_main_arena_print_handler(RzCore *core, int argc, const char **argv, RzOutputMode mode)
#define RZ_API
const char int mode
Definition: ioapi.h:137
static static fork const void static count static fd const char const char static newpath char char argv
Definition: sflib.h:40
RZ_API RzList *GH() rz_heap_arena_list_wrapper(RzCore *core)
A wrapper around GH(rz_heap_arenas_list) which handles finding main_arena.
RZ_API RzHeapChunkSimple *GH() rz_heap_chunk_wrapper(RzCore *core, GHT addr)
Get info about a heap chunk as RzHeapChunkSimple.
RZ_API bool GH() rz_heap_write_heap_chunk(RzCore *core, RzHeapChunkSimple *chunk_simple)
Write a heap chunk header to memory.
RZ_API RzList *GH() rz_heap_chunks_list_wrapper(RzCore *core, ut64 m_state)
A wrapper around GH(rz_heap_chunks_list) which handles finding the main arena.
enum rz_cmd_status_t RzCmdStatus
@ RZ_CMD_STATUS_ERROR
command handler had issues while running (e.g. allocation error, etc.)
Definition: rz_cmd.h:26
RzOutputMode
Enum to describe the way data are printed.
Definition: rz_types.h:38
@ RZ_OUTPUT_MODE_LONG
Definition: rz_types.h:44
int bits
Definition: rz_asm.h:100
Represent the output state of a command handler.
Definition: rz_cmd.h:91
RzAsm * rasm
Definition: rz_core.h:323
Definition: dis.h:43
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
static int addr
Definition: z80asm.c:58
static bool input(void *ud, zip_uint8_t *data, zip_uint64_t length)