Rizin
unix-like reverse engineering framework and cli tools
cmd_linux_heap_glibc.c File Reference
#include <rz_types.h>
#include <rz_core.h>
#include <rz_heap_glibc.h>
#include "cmd_descs.h"
#include "../linux_heap_glibc.h"
#include "../linux_heap_glibc64.h"

Go to the source code of this file.

Macros

#define call_handler(fun, ...)
 

Functions

RZ_IPI RzCmdStatus rz_cmd_heap_chunks_print_handler (RzCore *core, int argc, const char **argv, RzCmdStateOutput *state)
 
RZ_IPI RzCmdStatus rz_cmd_arena_print_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_cmd_main_arena_print_handler (RzCore *core, int argc, const char **argv, RzOutputMode mode)
 
RZ_IPI RzCmdStatus rz_cmd_heap_chunk_print_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_cmd_heap_chunks_graph_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_cmd_heap_info_print_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_cmd_heap_tcache_print_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI int rz_cmd_heap_bins_list_print (void *data, const char *input)
 
RZ_IPI int rz_cmd_heap_fastbins_print (void *data, const char *input)
 
RZ_IPI RzCmdStatus rz_cmd_heap_arena_bins_print_handler (RzCore *core, int argc, const char **argv, RzOutputMode mode)
 
RZ_API RzListrz_heap_arenas_list (RzCore *core)
 Returns RzList* for a list of arenas. Each arena is represented by RzArenaListItem struct. More...
 
RZ_API RzListrz_heap_chunks_list (RzCore *core, ut64 m_arena)
 Returns RzList* for a list of chunks from the arena. Each chunk is represented by RzHeapChunkListItem struct. More...
 
RZ_API RzHeapChunkSimplerz_heap_chunk (RzCore *core, ut64 addr)
 Returns detailed information about a heap chunk. The chunk is represented by RzHeapChunkSimple struct. More...
 
RZ_API RzHeapBinrz_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 covered by this are unsorted, small and large bins Bin num is zero indexed i.e unsorted bin starts from number 0. More...
 
RZ_API RzHeapBinrz_heap_fastbin_content (RzCore *core, MallocState *arena, int bin_num)
 Returns information about a fastbin. The information is represented as RzHeapBin struct. More...
 
RZ_API MallocStaterz_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 valid and then returns the MallocState. If the base address provided is zero it returns the malloc state for the main arena. More...
 
RZ_API RzListrz_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 are of the form of RzHeapBin Arena has the base address arena_base. More...
 
RZ_API bool rz_heap_write_chunk (RzCore *core, RzHeapChunkSimple *chunk_simple)
 Write a heap chunk header to memory. More...
 

Macro Definition Documentation

◆ call_handler

#define call_handler (   fun,
  ... 
)
Value:
{ \
if (core->rasm->bits == 64) { \
return fun##_64(core, ##__VA_ARGS__); \
} else { \
return fun##_32(core, ##__VA_ARGS__); \
} \
}

Definition at line 11 of file cmd_linux_heap_glibc.c.

Function Documentation

◆ rz_cmd_arena_print_handler()

RZ_IPI RzCmdStatus rz_cmd_arena_print_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 24 of file cmd_linux_heap_glibc.c.

24  {
26 }
RZ_IPI RzCmdStatus rz_cmd_arena_print_handler(RzCore *core, int argc, const char **argv)
#define call_handler(fun,...)
static static fork const void static count static fd const char const char static newpath char char argv
Definition: sflib.h:40

Referenced by rz_cmd_arena_print_handler().

◆ rz_cmd_heap_arena_bins_print_handler()

RZ_IPI RzCmdStatus rz_cmd_heap_arena_bins_print_handler ( RzCore core,
int  argc,
const char **  argv,
RzOutputMode  mode 
)

Definition at line 71 of file cmd_linux_heap_glibc.c.

71  {
73 }
RZ_IPI RzCmdStatus rz_cmd_heap_arena_bins_print_handler(RzCore *core, int argc, const char **argv, RzOutputMode mode)
const char int mode
Definition: ioapi.h:137

Referenced by rz_cmd_heap_arena_bins_print_handler().

◆ rz_cmd_heap_bins_list_print()

RZ_IPI int rz_cmd_heap_bins_list_print ( void *  data,
const char *  input 
)

Definition at line 61 of file cmd_linux_heap_glibc.c.

61  {
62  RzCore *core = (RzCore *)data;
64 }
RZ_IPI int rz_cmd_heap_bins_list_print(void *data, const char *input)
static bool input(void *ud, zip_uint8_t *data, zip_uint64_t length)

References call_handler, input(), and rz_cmd_heap_bins_list_print().

Referenced by rz_cmd_heap_bins_list_print(), and rzshell_cmddescs_init().

◆ rz_cmd_heap_chunk_print_handler()

RZ_IPI RzCmdStatus rz_cmd_heap_chunk_print_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 32 of file cmd_linux_heap_glibc.c.

32  {
34 }
RZ_IPI RzCmdStatus rz_cmd_heap_chunk_print_handler(RzCore *core, int argc, const char **argv)

Referenced by rz_cmd_heap_chunk_print_handler().

◆ rz_cmd_heap_chunks_graph_handler()

RZ_IPI RzCmdStatus rz_cmd_heap_chunks_graph_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 36 of file cmd_linux_heap_glibc.c.

36  {
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 }
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
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
@ 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

References argv, rz_asm_t::bits, rz_core_t::rasm, rz_cmd_state_output_fini(), rz_cmd_state_output_init(), rz_cmd_state_output_print(), RZ_CMD_STATUS_ERROR, and RZ_OUTPUT_MODE_LONG.

Referenced by rzshell_cmddescs_init().

◆ rz_cmd_heap_chunks_print_handler()

RZ_IPI RzCmdStatus rz_cmd_heap_chunks_print_handler ( RzCore core,
int  argc,
const char **  argv,
RzCmdStateOutput state 
)

Definition at line 20 of file cmd_linux_heap_glibc.c.

20  {
22 }
RZ_IPI RzCmdStatus rz_cmd_heap_chunks_print_handler(RzCore *core, int argc, const char **argv, RzCmdStateOutput *state)

Referenced by rz_cmd_heap_chunks_print_handler().

◆ rz_cmd_heap_fastbins_print()

RZ_IPI int rz_cmd_heap_fastbins_print ( void *  data,
const char *  input 
)

Definition at line 66 of file cmd_linux_heap_glibc.c.

66  {
67  RzCore *core = (RzCore *)data;
69 }
RZ_IPI int rz_cmd_heap_fastbins_print(void *data, const char *input)

Referenced by rz_cmd_heap_fastbins_print().

◆ rz_cmd_heap_info_print_handler()

RZ_IPI RzCmdStatus rz_cmd_heap_info_print_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 53 of file cmd_linux_heap_glibc.c.

53  {
55 }
RZ_IPI RzCmdStatus rz_cmd_heap_info_print_handler(RzCore *core, int argc, const char **argv)

Referenced by rz_cmd_heap_info_print_handler().

◆ rz_cmd_heap_tcache_print_handler()

RZ_IPI RzCmdStatus rz_cmd_heap_tcache_print_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 57 of file cmd_linux_heap_glibc.c.

57  {
59 }
RZ_IPI RzCmdStatus rz_cmd_heap_tcache_print_handler(RzCore *core, int argc, const char **argv)

Referenced by rz_cmd_heap_tcache_print_handler().

◆ rz_cmd_main_arena_print_handler()

RZ_IPI RzCmdStatus rz_cmd_main_arena_print_handler ( RzCore core,
int  argc,
const char **  argv,
RzOutputMode  mode 
)

Definition at line 28 of file cmd_linux_heap_glibc.c.

28  {
30 }
RZ_IPI RzCmdStatus rz_cmd_main_arena_print_handler(RzCore *core, int argc, const char **argv, RzOutputMode mode)

Referenced by rz_cmd_main_arena_print_handler().

◆ rz_heap_arenas_list()

RZ_API RzList* rz_heap_arenas_list ( RzCore core)

Returns RzList* for a list of arenas. Each arena is represented by RzArenaListItem struct.

Parameters
coreRzCore pointer
Returns
RzList of arenas

Definition at line 82 of file cmd_linux_heap_glibc.c.

82  {
84 }
RZ_API RzList *GH() rz_heap_arena_list_wrapper(RzCore *core)
A wrapper around GH(rz_heap_arenas_list) which handles finding main_arena.

References call_handler, and rz_heap_arena_list_wrapper().

◆ rz_heap_bin_content()

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 covered by this are unsorted, small and large bins Bin num is zero indexed i.e unsorted bin starts from number 0.

Parameters
coreRzCore pointer
arenaMalloc state struct for the arena
bin_numBin number from NBINS array
Returns
RzHeapBin struct for the bin

Definition at line 114 of file cmd_linux_heap_glibc.c.

114  {
115  call_handler(rz_heap_bin_content, arena, bin_num, m_arena);
116 }
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...

References call_handler.

◆ rz_heap_chunk()

RZ_API RzHeapChunkSimple* rz_heap_chunk ( RzCore core,
ut64  addr 
)

Returns detailed information about a heap chunk. The chunk is represented by RzHeapChunkSimple struct.

Parameters
coreRzCore pointer
addrBase address of the heap chunk
Returns
RzHeapChunkSimple struct pointer for the chunk

Definition at line 102 of file cmd_linux_heap_glibc.c.

102  {
104 }
RZ_API RzHeapChunkSimple *GH() rz_heap_chunk_wrapper(RzCore *core, GHT addr)
Get info about a heap chunk as RzHeapChunkSimple.
static int addr
Definition: z80asm.c:58

References addr, call_handler, and rz_heap_chunk_wrapper().

◆ rz_heap_chunks_list()

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 struct.

Parameters
coreRzCore pointer
m_arenaBase Address of the arena
Returns
RzList of heap chunks

Definition at line 92 of file cmd_linux_heap_glibc.c.

92  {
94 }
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.

References call_handler, and rz_heap_chunks_list_wrapper().

◆ rz_heap_fastbin_content()

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.

Parameters
coreRzCore pointer
arenaMalloc state struct for the arena
bin_numBin number from Fastbins array
Returns
RzHeapBin struct for the bin

Definition at line 125 of file cmd_linux_heap_glibc.c.

125  {
126  call_handler(rz_heap_fastbin_content, arena, bin_num);
127 }
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.

References call_handler.

◆ rz_heap_get_arena()

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 valid and then returns the MallocState. If the base address provided is zero it returns the malloc state for the main arena.

Parameters
coreRzCore pointer
m_stateBase address of the arena
Returns
MallocState struct for the arena

Definition at line 137 of file cmd_linux_heap_glibc.c.

137  {
139 }
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 ...

References call_handler.

◆ rz_heap_tcache_content()

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 are of the form of RzHeapBin Arena has the base address arena_base.

Parameters
coreRzCore pointer
arena_baseBase address of the arena
Returns
RzList of RzHeapBin pointers

Definition at line 149 of file cmd_linux_heap_glibc.c.

149  {
151 }
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...

References call_handler.

◆ rz_heap_write_chunk()

RZ_API bool rz_heap_write_chunk ( RzCore core,
RzHeapChunkSimple chunk_simple 
)

Write a heap chunk header to memory.

Parameters
coreRzCore pointer
chunk_simpleRzHeapChunkSimple pointer to the heap chunk data
Returns
bool if the write succeeded or not

Definition at line 159 of file cmd_linux_heap_glibc.c.

159  {
160  call_handler(rz_heap_write_heap_chunk, chunk_simple);
161 }
RZ_API bool GH() rz_heap_write_heap_chunk(RzCore *core, RzHeapChunkSimple *chunk_simple)
Write a heap chunk header to memory.

References call_handler, and rz_heap_write_heap_chunk().