Rizin
unix-like reverse engineering framework and cli tools
rz_heap_glibc.h File Reference
#include <rz_core.h>

Go to the source code of this file.

Classes

struct  rz_malloc_chunk_64
 
struct  rz_malloc_chunk_32
 
struct  rz_malloc_state_32
 
struct  rz_malloc_state_64
 
struct  rz_tcache_perthread_struct_32
 
struct  rz_tcache_perthread_struct_64
 
struct  rz_tcache_perthread_struct_pre_230_32
 
struct  rz_tcache_perthread_struct_pre_230_64
 
struct  RTcache_64
 
struct  RTcache_32
 
struct  rz_malloc_state_tcache_32
 
struct  rz_malloc_state_tcache_64
 
struct  rz_malloc_state
 
struct  rz_heap_info_32
 
struct  rz_heap_info_64
 
struct  rz_heap_chunk_list_item
 
struct  rz_arena_list_item
 
struct  rz_heap_chunk_simple
 
struct  rz_heap_bin
 

Macros

#define PRINTF_A(color, fmt, ...)   rz_cons_printf(color fmt Color_RESET, __VA_ARGS__)
 
#define PRINTF_YA(fmt, ...)   PRINTF_A("%s", fmt, pal->offset, __VA_ARGS__)
 
#define PRINTF_GA(fmt, ...)   PRINTF_A("%s", fmt, pal->args, __VA_ARGS__)
 
#define PRINTF_BA(fmt, ...)   PRINTF_A("%s", fmt, pal->num, __VA_ARGS__)
 
#define PRINTF_RA(fmt, ...)   PRINTF_A("%s", fmt, pal->invalid, __VA_ARGS__)
 
#define PRINT_A(color, msg)   rz_cons_print(color msg Color_RESET)
 
#define PRINT_YA(msg)   rz_cons_printf("%s" msg Color_RESET, pal->offset)
 
#define PRINT_GA(msg)   rz_cons_printf("%s" msg Color_RESET, pal->args)
 
#define PRINT_BA(msg)   rz_cons_printf("%s" msg Color_RESET, pal->num)
 
#define PRINT_RA(msg)   rz_cons_printf("%s" msg Color_RESET, pal->invalid)
 
#define PREV_INUSE   0x1
 
#define IS_MMAPPED   0x2
 
#define NON_MAIN_ARENA   0x4
 
#define NBINS   128
 
#define NSMALLBINS   64
 
#define NFASTBINS   10
 
#define BINMAPSHIFT   5
 
#define SZ   core->dbg->bits
 
#define FASTBIN_IDX_TO_SIZE(i)   ((SZ * 4) + (SZ * 2) * (i - 1))
 
#define BITSPERMAP   (1U << BINMAPSHIFT)
 
#define BINMAPSIZE   (NBINS / BITSPERMAP)
 
#define NPAD   -6
 
#define TCACHE_MAX_BINS   64
 
#define TCACHE_FILL_COUNT   7
 
#define TCACHE_NEW_VERSION   230
 
#define MMAP_ALIGN_32   0x14
 
#define MMAP_ALIGN_64   0x18
 
#define MMAP_OFFSET   0x8
 
#define HDR_SZ_32   0x8
 
#define HDR_SZ_64   0x10
 
#define TC_HDR_SZ   0x10
 
#define TC_SZ_32   0x0
 
#define TC_SZ_64   0x10
 
#define largebin_index_32(size)
 
#define largebin_index_32_big(size)
 
#define largebin_index_64(size)
 
#define largebin_index(size)    (SZ == 8 ? largebin_index_64(size) : largebin_index_32(size))
 
#define fastbin_index(size)    (SZ == 8 ? (size >> 4) - 2 : (size >> 3) - 2)
 

Typedefs

typedef struct rz_malloc_chunk_64 RzHeapChunk_64
 
typedef struct rz_malloc_chunk_32 RzHeapChunk_32
 
typedef struct rz_malloc_state_32 RzHeap_MallocState_32
 
typedef struct rz_malloc_state_64 RzHeap_MallocState_64
 
typedef struct rz_tcache_perthread_struct_32 RzHeapTcache_32
 
typedef struct rz_tcache_perthread_struct_64 RzHeapTcache_64
 
typedef struct rz_tcache_perthread_struct_pre_230_32 RzHeapTcachePre230_32
 
typedef struct rz_tcache_perthread_struct_pre_230_64 RzHeapTcachePre230_64
 
typedef struct rz_malloc_state_tcache_32 RzHeap_MallocState_tcache_32
 
typedef struct rz_malloc_state_tcache_64 RzHeap_MallocState_tcache_64
 
typedef struct rz_malloc_state MallocState
 
typedef struct rz_heap_info_32 RzHeapInfo_32
 
typedef struct rz_heap_info_64 RzHeapInfo_64
 
typedef enum rz_heap_bin_type RzHeapBinType
 
typedef struct rz_heap_chunk_list_item RzHeapChunkListItem
 
typedef struct rz_arena_list_item RzArenaListItem
 
typedef struct rz_heap_chunk_simple RzHeapChunkSimple
 
typedef struct rz_heap_bin RzHeapBin
 

Enumerations

enum  tcache_type { NEW , OLD }
 
enum  rz_heap_bin_type {
  RZ_HEAP_BIN_ANY , RZ_HEAP_BIN_TCACHE , RZ_HEAP_BIN_FAST , RZ_HEAP_BIN_UNSORTED ,
  RZ_HEAP_BIN_SMALL , RZ_HEAP_BIN_LARGE
}
 

Functions

 RZ_LIB_VERSION_HEADER (rz_heap_glibc)
 
RZ_API RzHeapChunkSimplerz_heap_chunk_wrapper_32 (RzCore *core, ut32 addr)
 
RZ_API RzHeapChunkSimplerz_heap_chunk_wrapper_64 (RzCore *core, ut64 addr)
 
RZ_API RzHeapChunk_64rz_heap_get_chunk_at_addr_64 (RzCore *core, ut64 addr)
 
RZ_API RzHeapChunk_32rz_heap_get_chunk_at_addr_32 (RzCore *core, ut32 addr)
 
RZ_API RzListrz_heap_arenas_list_64 (RzCore *core, ut64 m_arena, MallocState *main_arena)
 
RZ_API RzListrz_heap_arenas_list_32 (RzCore *core, ut32 m_arena, MallocState *main_arena)
 
RZ_API RzListrz_heap_chunks_list_64 (RzCore *core, MallocState *main_arena, ut64 m_arena, ut64 m_state, bool top_chunk)
 
RZ_API RzListrz_heap_chunks_list_32 (RzCore *core, MallocState *main_arena, ut32 m_arena, ut32 m_state, bool top_chunk)
 
RZ_API bool rz_heap_resolve_main_arena_64 (RzCore *core, ut64 *m_arena)
 
RZ_API bool rz_heap_resolve_main_arena_32 (RzCore *core, ut32 *m_arena)
 
RZ_API bool rz_heap_update_main_arena_64 (RzCore *core, ut64 m_arena, MallocState *main_arena)
 
RZ_API bool rz_heap_update_main_arena_32 (RzCore *core, ut32 m_arena, MallocState *main_arena)
 
RZ_API bool rz_heap_write_heap_chunk_64 (RzCore *core, RzHeapChunkSimple *chunk_simple)
 
RZ_API bool rz_heap_write_heap_chunk_32 (RzCore *core, RzHeapChunkSimple *chunk_simple)
 
RZ_API RzListrz_heap_tcache_content_64 (RzCore *core, ut64 arena_base)
 
RZ_API RzListrz_heap_tcache_content_32 (RzCore *core, ut32 arena_base)
 
RZ_API MallocStaterz_heap_get_arena_64 (RzCore *core, ut64 m_state)
 
RZ_API MallocStaterz_heap_get_arena_32 (RzCore *core, ut32 m_state)
 
RZ_API RzHeapBinrz_heap_fastbin_content_64 (RzCore *core, MallocState *main_arena, int bin_num)
 
RZ_API RzHeapBinrz_heap_fastbin_content_32 (RzCore *core, MallocState *main_arena, int bin_num)
 
RZ_API RzHeapBinrz_heap_bin_content_64 (RzCore *core, MallocState *main_arena, int bin_num, ut64 m_arena)
 
RZ_API RzHeapBinrz_heap_bin_content_32 (RzCore *core, MallocState *main_arena, int bin_num, ut32 m_arena)
 
RZ_API RzListrz_heap_chunks_list_wrapper_64 (RzCore *core, ut64 m_state)
 
RZ_API RzListrz_heap_chunks_list_wrapper_32 (RzCore *core, ut64 m_state)
 
RZ_API RzListrz_heap_arena_list_wrapper_64 (RzCore *core)
 
RZ_API RzListrz_heap_arena_list_wrapper_32 (RzCore *core)
 
RZ_IPI int rz_cmd_heap_fastbins_print_64 (void *data, const char *input)
 
RZ_IPI int rz_cmd_heap_fastbins_print_32 (void *data, const char *input)
 
RZ_IPI int rz_cmd_heap_bins_list_print_64 (RzCore *core, const char *input)
 
RZ_IPI int rz_cmd_heap_bins_list_print_32 (RzCore *core, const char *input)
 
RZ_API void rz_heap_bin_free_64 (RzHeapBin *bin)
 
RZ_API void rz_heap_bin_free_32 (RzHeapBin *bin)
 

Macro Definition Documentation

◆ BINMAPSHIFT

#define BINMAPSHIFT   5

Definition at line 31 of file rz_heap_glibc.h.

◆ BINMAPSIZE

#define BINMAPSIZE   (NBINS / BITSPERMAP)

Definition at line 35 of file rz_heap_glibc.h.

◆ BITSPERMAP

#define BITSPERMAP   (1U << BINMAPSHIFT)

Definition at line 34 of file rz_heap_glibc.h.

◆ FASTBIN_IDX_TO_SIZE

#define FASTBIN_IDX_TO_SIZE (   i)    ((SZ * 4) + (SZ * 2) * (i - 1))

Definition at line 33 of file rz_heap_glibc.h.

◆ fastbin_index

#define fastbin_index (   size)     (SZ == 8 ? (size >> 4) - 2 : (size >> 3) - 2)

Definition at line 75 of file rz_heap_glibc.h.

◆ HDR_SZ_32

#define HDR_SZ_32   0x8

Definition at line 45 of file rz_heap_glibc.h.

◆ HDR_SZ_64

#define HDR_SZ_64   0x10

Definition at line 46 of file rz_heap_glibc.h.

◆ IS_MMAPPED

#define IS_MMAPPED   0x2

Definition at line 25 of file rz_heap_glibc.h.

◆ largebin_index

#define largebin_index (   size)     (SZ == 8 ? largebin_index_64(size) : largebin_index_32(size))

Definition at line 72 of file rz_heap_glibc.h.

◆ largebin_index_32

#define largebin_index_32 (   size)
Value:
(((((ut32)(size)) >> 6) <= 38) ? 56 + (((ut32)(size)) >> 6) : ((((ut32)(size)) >> 9) <= 20) ? 91 + (((ut32)(size)) >> 9) \
: ((((ut32)(size)) >> 12) <= 10) ? 110 + (((ut32)(size)) >> 12) \
: ((((ut32)(size)) >> 15) <= 4) ? 119 + (((ut32)(size)) >> 15) \
: ((((ut32)(size)) >> 18) <= 2) ? 124 + (((ut32)(size)) >> 18) \
: 126)
uint32_t ut32
voidpf void uLong size
Definition: ioapi.h:138

Definition at line 53 of file rz_heap_glibc.h.

◆ largebin_index_32_big

#define largebin_index_32_big (   size)
Value:
(((((ut32)(size)) >> 6) <= 45) ? 49 + (((ut32)(size)) >> 6) : ((((ut32)(size)) >> 9) <= 20) ? 91 + (((ut32)(size)) >> 9) \
: ((((ut32)(size)) >> 12) <= 10) ? 110 + (((ut32)(size)) >> 12) \
: ((((ut32)(size)) >> 15) <= 4) ? 119 + (((ut32)(size)) >> 15) \
: ((((ut32)(size)) >> 18) <= 2) ? 124 + (((ut32)(size)) >> 18) \
: 126)

Definition at line 59 of file rz_heap_glibc.h.

◆ largebin_index_64

#define largebin_index_64 (   size)
Value:
(((((ut32)(size)) >> 6) <= 48) ? 48 + (((ut32)(size)) >> 6) : ((((ut32)(size)) >> 9) <= 20) ? 91 + (((ut32)(size)) >> 9) \
: ((((ut32)(size)) >> 12) <= 10) ? 110 + (((ut32)(size)) >> 12) \
: ((((ut32)(size)) >> 15) <= 4) ? 119 + (((ut32)(size)) >> 15) \
: ((((ut32)(size)) >> 18) <= 2) ? 124 + (((ut32)(size)) >> 18) \
: 126)

Definition at line 65 of file rz_heap_glibc.h.

◆ MMAP_ALIGN_32

#define MMAP_ALIGN_32   0x14

Definition at line 41 of file rz_heap_glibc.h.

◆ MMAP_ALIGN_64

#define MMAP_ALIGN_64   0x18

Definition at line 42 of file rz_heap_glibc.h.

◆ MMAP_OFFSET

#define MMAP_OFFSET   0x8

Definition at line 43 of file rz_heap_glibc.h.

◆ NBINS

#define NBINS   128

Definition at line 28 of file rz_heap_glibc.h.

◆ NFASTBINS

#define NFASTBINS   10

Definition at line 30 of file rz_heap_glibc.h.

◆ NON_MAIN_ARENA

#define NON_MAIN_ARENA   0x4

Definition at line 26 of file rz_heap_glibc.h.

◆ NPAD

#define NPAD   -6

Definition at line 36 of file rz_heap_glibc.h.

◆ NSMALLBINS

#define NSMALLBINS   64

Definition at line 29 of file rz_heap_glibc.h.

◆ PREV_INUSE

#define PREV_INUSE   0x1

Definition at line 24 of file rz_heap_glibc.h.

◆ PRINT_A

#define PRINT_A (   color,
  msg 
)    rz_cons_print(color msg Color_RESET)

Definition at line 18 of file rz_heap_glibc.h.

◆ PRINT_BA

#define PRINT_BA (   msg)    rz_cons_printf("%s" msg Color_RESET, pal->num)

Definition at line 21 of file rz_heap_glibc.h.

◆ PRINT_GA

#define PRINT_GA (   msg)    rz_cons_printf("%s" msg Color_RESET, pal->args)

Definition at line 20 of file rz_heap_glibc.h.

◆ PRINT_RA

#define PRINT_RA (   msg)    rz_cons_printf("%s" msg Color_RESET, pal->invalid)

Definition at line 22 of file rz_heap_glibc.h.

◆ PRINT_YA

#define PRINT_YA (   msg)    rz_cons_printf("%s" msg Color_RESET, pal->offset)

Definition at line 19 of file rz_heap_glibc.h.

◆ PRINTF_A

#define PRINTF_A (   color,
  fmt,
  ... 
)    rz_cons_printf(color fmt Color_RESET, __VA_ARGS__)

Definition at line 12 of file rz_heap_glibc.h.

◆ PRINTF_BA

#define PRINTF_BA (   fmt,
  ... 
)    PRINTF_A("%s", fmt, pal->num, __VA_ARGS__)

Definition at line 15 of file rz_heap_glibc.h.

◆ PRINTF_GA

#define PRINTF_GA (   fmt,
  ... 
)    PRINTF_A("%s", fmt, pal->args, __VA_ARGS__)

Definition at line 14 of file rz_heap_glibc.h.

◆ PRINTF_RA

#define PRINTF_RA (   fmt,
  ... 
)    PRINTF_A("%s", fmt, pal->invalid, __VA_ARGS__)

Definition at line 16 of file rz_heap_glibc.h.

◆ PRINTF_YA

#define PRINTF_YA (   fmt,
  ... 
)    PRINTF_A("%s", fmt, pal->offset, __VA_ARGS__)

Definition at line 13 of file rz_heap_glibc.h.

◆ SZ

#define SZ   core->dbg->bits

Definition at line 32 of file rz_heap_glibc.h.

◆ TC_HDR_SZ

#define TC_HDR_SZ   0x10

Definition at line 47 of file rz_heap_glibc.h.

◆ TC_SZ_32

#define TC_SZ_32   0x0

Definition at line 48 of file rz_heap_glibc.h.

◆ TC_SZ_64

#define TC_SZ_64   0x10

Definition at line 49 of file rz_heap_glibc.h.

◆ TCACHE_FILL_COUNT

#define TCACHE_FILL_COUNT   7

Definition at line 38 of file rz_heap_glibc.h.

◆ TCACHE_MAX_BINS

#define TCACHE_MAX_BINS   64

Definition at line 37 of file rz_heap_glibc.h.

◆ TCACHE_NEW_VERSION

#define TCACHE_NEW_VERSION   230

Definition at line 39 of file rz_heap_glibc.h.

Typedef Documentation

◆ MallocState

typedef struct rz_malloc_state MallocState

◆ RzArenaListItem

◆ RzHeap_MallocState_32

◆ RzHeap_MallocState_64

◆ RzHeap_MallocState_tcache_32

◆ RzHeap_MallocState_tcache_64

◆ RzHeapBin

typedef struct rz_heap_bin RzHeapBin

◆ RzHeapBinType

◆ RzHeapChunk_32

◆ RzHeapChunk_64

◆ RzHeapChunkListItem

◆ RzHeapChunkSimple

◆ RzHeapInfo_32

◆ RzHeapInfo_64

◆ RzHeapTcache_32

◆ RzHeapTcache_64

◆ RzHeapTcachePre230_32

◆ RzHeapTcachePre230_64

Enumeration Type Documentation

◆ rz_heap_bin_type

Enumerator
RZ_HEAP_BIN_ANY 
RZ_HEAP_BIN_TCACHE 
RZ_HEAP_BIN_FAST 
RZ_HEAP_BIN_UNSORTED 
RZ_HEAP_BIN_SMALL 
RZ_HEAP_BIN_LARGE 

Definition at line 261 of file rz_heap_glibc.h.

261  {
268 } RzHeapBinType;
@ RZ_HEAP_BIN_TCACHE
@ RZ_HEAP_BIN_LARGE
@ RZ_HEAP_BIN_FAST
@ RZ_HEAP_BIN_SMALL
@ RZ_HEAP_BIN_ANY
@ RZ_HEAP_BIN_UNSORTED
enum rz_heap_bin_type RzHeapBinType

◆ tcache_type

Enumerator
NEW 
OLD 

Definition at line 166 of file rz_heap_glibc.h.

166  { NEW,
167  OLD } tcache_type;
tcache_type
@ OLD
@ NEW

Function Documentation

◆ rz_cmd_heap_bins_list_print_32()

RZ_IPI int rz_cmd_heap_bins_list_print_32 ( RzCore core,
const char *  input 
)

◆ rz_cmd_heap_bins_list_print_64()

RZ_IPI int rz_cmd_heap_bins_list_print_64 ( RzCore core,
const char *  input 
)

◆ rz_cmd_heap_fastbins_print_32()

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

◆ rz_cmd_heap_fastbins_print_64()

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

◆ rz_heap_arena_list_wrapper_32()

RZ_API RzList* rz_heap_arena_list_wrapper_32 ( RzCore core)

◆ rz_heap_arena_list_wrapper_64()

RZ_API RzList* rz_heap_arena_list_wrapper_64 ( RzCore core)

◆ rz_heap_arenas_list_32()

RZ_API RzList* rz_heap_arenas_list_32 ( RzCore core,
ut32  m_arena,
MallocState main_arena 
)

◆ rz_heap_arenas_list_64()

RZ_API RzList* rz_heap_arenas_list_64 ( RzCore core,
ut64  m_arena,
MallocState main_arena 
)

◆ rz_heap_bin_content_32()

RZ_API RzHeapBin* rz_heap_bin_content_32 ( RzCore core,
MallocState main_arena,
int  bin_num,
ut32  m_arena 
)

◆ rz_heap_bin_content_64()

RZ_API RzHeapBin* rz_heap_bin_content_64 ( RzCore core,
MallocState main_arena,
int  bin_num,
ut64  m_arena 
)

◆ rz_heap_bin_free_32()

RZ_API void rz_heap_bin_free_32 ( RzHeapBin bin)

◆ rz_heap_bin_free_64()

RZ_API void rz_heap_bin_free_64 ( RzHeapBin bin)

◆ rz_heap_chunk_wrapper_32()

RZ_API RzHeapChunkSimple* rz_heap_chunk_wrapper_32 ( RzCore core,
ut32  addr 
)

◆ rz_heap_chunk_wrapper_64()

RZ_API RzHeapChunkSimple* rz_heap_chunk_wrapper_64 ( RzCore core,
ut64  addr 
)

◆ rz_heap_chunks_list_32()

RZ_API RzList* rz_heap_chunks_list_32 ( RzCore core,
MallocState main_arena,
ut32  m_arena,
ut32  m_state,
bool  top_chunk 
)

◆ rz_heap_chunks_list_64()

RZ_API RzList* rz_heap_chunks_list_64 ( RzCore core,
MallocState main_arena,
ut64  m_arena,
ut64  m_state,
bool  top_chunk 
)

◆ rz_heap_chunks_list_wrapper_32()

RZ_API RzList* rz_heap_chunks_list_wrapper_32 ( RzCore core,
ut64  m_state 
)

◆ rz_heap_chunks_list_wrapper_64()

RZ_API RzList* rz_heap_chunks_list_wrapper_64 ( RzCore core,
ut64  m_state 
)

◆ rz_heap_fastbin_content_32()

RZ_API RzHeapBin* rz_heap_fastbin_content_32 ( RzCore core,
MallocState main_arena,
int  bin_num 
)

◆ rz_heap_fastbin_content_64()

RZ_API RzHeapBin* rz_heap_fastbin_content_64 ( RzCore core,
MallocState main_arena,
int  bin_num 
)

◆ rz_heap_get_arena_32()

RZ_API MallocState* rz_heap_get_arena_32 ( RzCore core,
ut32  m_state 
)

◆ rz_heap_get_arena_64()

RZ_API MallocState* rz_heap_get_arena_64 ( RzCore core,
ut64  m_state 
)

◆ rz_heap_get_chunk_at_addr_32()

RZ_API RzHeapChunk_32* rz_heap_get_chunk_at_addr_32 ( RzCore core,
ut32  addr 
)

◆ rz_heap_get_chunk_at_addr_64()

RZ_API RzHeapChunk_64* rz_heap_get_chunk_at_addr_64 ( RzCore core,
ut64  addr 
)

◆ rz_heap_resolve_main_arena_32()

RZ_API bool rz_heap_resolve_main_arena_32 ( RzCore core,
ut32 m_arena 
)

◆ rz_heap_resolve_main_arena_64()

RZ_API bool rz_heap_resolve_main_arena_64 ( RzCore core,
ut64 m_arena 
)

◆ rz_heap_tcache_content_32()

RZ_API RzList* rz_heap_tcache_content_32 ( RzCore core,
ut32  arena_base 
)

◆ rz_heap_tcache_content_64()

RZ_API RzList* rz_heap_tcache_content_64 ( RzCore core,
ut64  arena_base 
)

◆ rz_heap_update_main_arena_32()

RZ_API bool rz_heap_update_main_arena_32 ( RzCore core,
ut32  m_arena,
MallocState main_arena 
)

◆ rz_heap_update_main_arena_64()

RZ_API bool rz_heap_update_main_arena_64 ( RzCore core,
ut64  m_arena,
MallocState main_arena 
)

◆ rz_heap_write_heap_chunk_32()

RZ_API bool rz_heap_write_heap_chunk_32 ( RzCore core,
RzHeapChunkSimple chunk_simple 
)

◆ rz_heap_write_heap_chunk_64()

RZ_API bool rz_heap_write_heap_chunk_64 ( RzCore core,
RzHeapChunkSimple chunk_simple 
)

◆ RZ_LIB_VERSION_HEADER()

RZ_LIB_VERSION_HEADER ( rz_heap_glibc  )