1 #ifndef RZ_HEAP_GLIBC_H
2 #define RZ_HEAP_GLIBC_H
12 #define PRINTF_A(color, fmt, ...) rz_cons_printf(color fmt Color_RESET, __VA_ARGS__)
13 #define PRINTF_YA(fmt, ...) PRINTF_A("%s", fmt, pal->offset, __VA_ARGS__)
14 #define PRINTF_GA(fmt, ...) PRINTF_A("%s", fmt, pal->args, __VA_ARGS__)
15 #define PRINTF_BA(fmt, ...) PRINTF_A("%s", fmt, pal->num, __VA_ARGS__)
16 #define PRINTF_RA(fmt, ...) PRINTF_A("%s", fmt, pal->invalid, __VA_ARGS__)
18 #define PRINT_A(color, msg) rz_cons_print(color msg Color_RESET)
19 #define PRINT_YA(msg) rz_cons_printf("%s" msg Color_RESET, pal->offset)
20 #define PRINT_GA(msg) rz_cons_printf("%s" msg Color_RESET, pal->args)
21 #define PRINT_BA(msg) rz_cons_printf("%s" msg Color_RESET, pal->num)
22 #define PRINT_RA(msg) rz_cons_printf("%s" msg Color_RESET, pal->invalid)
24 #define PREV_INUSE 0x1
25 #define IS_MMAPPED 0x2
26 #define NON_MAIN_ARENA 0x4
32 #define SZ core->dbg->bits
33 #define FASTBIN_IDX_TO_SIZE(i) ((SZ * 4) + (SZ * 2) * (i - 1))
34 #define BITSPERMAP (1U << BINMAPSHIFT)
35 #define BINMAPSIZE (NBINS / BITSPERMAP)
37 #define TCACHE_MAX_BINS 64
38 #define TCACHE_FILL_COUNT 7
39 #define TCACHE_NEW_VERSION 230
41 #define MMAP_ALIGN_32 0x14
42 #define MMAP_ALIGN_64 0x18
43 #define MMAP_OFFSET 0x8
46 #define HDR_SZ_64 0x10
47 #define TC_HDR_SZ 0x10
53 #define largebin_index_32(size) \
54 (((((ut32)(size)) >> 6) <= 38) ? 56 + (((ut32)(size)) >> 6) : ((((ut32)(size)) >> 9) <= 20) ? 91 + (((ut32)(size)) >> 9) \
55 : ((((ut32)(size)) >> 12) <= 10) ? 110 + (((ut32)(size)) >> 12) \
56 : ((((ut32)(size)) >> 15) <= 4) ? 119 + (((ut32)(size)) >> 15) \
57 : ((((ut32)(size)) >> 18) <= 2) ? 124 + (((ut32)(size)) >> 18) \
59 #define largebin_index_32_big(size) \
60 (((((ut32)(size)) >> 6) <= 45) ? 49 + (((ut32)(size)) >> 6) : ((((ut32)(size)) >> 9) <= 20) ? 91 + (((ut32)(size)) >> 9) \
61 : ((((ut32)(size)) >> 12) <= 10) ? 110 + (((ut32)(size)) >> 12) \
62 : ((((ut32)(size)) >> 15) <= 4) ? 119 + (((ut32)(size)) >> 15) \
63 : ((((ut32)(size)) >> 18) <= 2) ? 124 + (((ut32)(size)) >> 18) \
65 #define largebin_index_64(size) \
66 (((((ut32)(size)) >> 6) <= 48) ? 48 + (((ut32)(size)) >> 6) : ((((ut32)(size)) >> 9) <= 20) ? 91 + (((ut32)(size)) >> 9) \
67 : ((((ut32)(size)) >> 12) <= 10) ? 110 + (((ut32)(size)) >> 12) \
68 : ((((ut32)(size)) >> 15) <= 4) ? 119 + (((ut32)(size)) >> 15) \
69 : ((((ut32)(size)) >> 18) <= 2) ? 124 + (((ut32)(size)) >> 18) \
72 #define largebin_index(size) \
73 (SZ == 8 ? largebin_index_64(size) : largebin_index_32(size))
75 #define fastbin_index(size) \
76 (SZ == 8 ? (size >> 4) - 2 : (size >> 3) - 2)
struct rz_tcache_perthread_struct_32 RzHeapTcache_32
struct rz_malloc_state_tcache_64 RzHeap_MallocState_tcache_64
RZ_API bool rz_heap_write_heap_chunk_64(RzCore *core, RzHeapChunkSimple *chunk_simple)
RZ_API RzHeapChunkSimple * rz_heap_chunk_wrapper_32(RzCore *core, ut32 addr)
RZ_API bool rz_heap_write_heap_chunk_32(RzCore *core, RzHeapChunkSimple *chunk_simple)
RZ_API RzHeapBin * rz_heap_fastbin_content_32(RzCore *core, MallocState *main_arena, int bin_num)
RZ_API RzList * rz_heap_arenas_list_32(RzCore *core, ut32 m_arena, MallocState *main_arena)
RZ_IPI int rz_cmd_heap_fastbins_print_32(void *data, const char *input)
struct rz_malloc_state_tcache_32 RzHeap_MallocState_tcache_32
struct rz_tcache_perthread_struct_pre_230_64 RzHeapTcachePre230_64
RZ_API RzList * rz_heap_arena_list_wrapper_32(RzCore *core)
struct rz_heap_info_32 RzHeapInfo_32
RZ_API RzList * rz_heap_chunks_list_wrapper_32(RzCore *core, ut64 m_state)
struct rz_heap_chunk_list_item RzHeapChunkListItem
RZ_API void rz_heap_bin_free_32(RzHeapBin *bin)
struct rz_heap_chunk_simple RzHeapChunkSimple
struct rz_heap_bin RzHeapBin
RZ_API RzList * rz_heap_tcache_content_32(RzCore *core, ut32 arena_base)
RZ_API bool rz_heap_update_main_arena_32(RzCore *core, ut32 m_arena, MallocState *main_arena)
RZ_API RzHeapChunk_64 * rz_heap_get_chunk_at_addr_64(RzCore *core, ut64 addr)
RZ_API RzList * rz_heap_chunks_list_64(RzCore *core, MallocState *main_arena, ut64 m_arena, ut64 m_state, bool top_chunk)
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 RzList * rz_heap_tcache_content_64(RzCore *core, ut64 arena_base)
struct rz_malloc_state MallocState
RZ_API RzList * rz_heap_arena_list_wrapper_64(RzCore *core)
struct rz_malloc_chunk_64 RzHeapChunk_64
RZ_API MallocState * rz_heap_get_arena_64(RzCore *core, ut64 m_state)
struct rz_arena_list_item RzArenaListItem
RZ_IPI int rz_cmd_heap_fastbins_print_64(void *data, const char *input)
RZ_API RzList * rz_heap_chunks_list_32(RzCore *core, MallocState *main_arena, ut32 m_arena, ut32 m_state, bool top_chunk)
RZ_API RzList * rz_heap_arenas_list_64(RzCore *core, ut64 m_arena, MallocState *main_arena)
RZ_API RzHeapChunkSimple * rz_heap_chunk_wrapper_64(RzCore *core, ut64 addr)
RZ_API RzList * rz_heap_chunks_list_wrapper_64(RzCore *core, ut64 m_state)
struct rz_malloc_state_32 RzHeap_MallocState_32
RZ_IPI int rz_cmd_heap_bins_list_print_32(RzCore *core, const char *input)
RZ_IPI int rz_cmd_heap_bins_list_print_64(RzCore *core, const char *input)
struct rz_malloc_chunk_32 RzHeapChunk_32
RZ_API MallocState * rz_heap_get_arena_32(RzCore *core, ut32 m_state)
struct rz_malloc_state_64 RzHeap_MallocState_64
struct rz_tcache_perthread_struct_pre_230_32 RzHeapTcachePre230_32
RZ_API RzHeapBin * rz_heap_fastbin_content_64(RzCore *core, MallocState *main_arena, int bin_num)
struct rz_heap_info_64 RzHeapInfo_64
RZ_API bool rz_heap_resolve_main_arena_64(RzCore *core, ut64 *m_arena)
RZ_API RzHeapBin * rz_heap_bin_content_32(RzCore *core, MallocState *main_arena, int bin_num, ut32 m_arena)
enum rz_heap_bin_type RzHeapBinType
RZ_LIB_VERSION_HEADER(rz_heap_glibc)
RZ_API void rz_heap_bin_free_64(RzHeapBin *bin)
struct rz_tcache_perthread_struct_64 RzHeapTcache_64
RZ_API RzHeapBin * rz_heap_bin_content_64(RzCore *core, MallocState *main_arena, int bin_num, ut64 m_arena)
RZ_API RzHeapChunk_32 * rz_heap_get_chunk_at_addr_32(RzCore *core, ut32 addr)
RzHeapTcache_32 * heap_tcache
RzHeapTcachePre230_32 * heap_tcache_pre_230
RzHeapTcachePre230_64 * heap_tcache_pre_230
RzHeapTcache_64 * heap_tcache
unsigned int binmap[BINMAPSIZE]
ut32 fastbinsY[NFASTBINS]
unsigned int attached_threads
ut64 fastbinsY[NFASTBINS]
unsigned int binmap[BINMAPSIZE]
unsigned int attached_threads
ut32 fastbinsY[NFASTBINS+1]
unsigned int binmap[BINMAPSIZE]
unsigned int attached_threads
ut64 fastbinsY[NFASTBINS]
unsigned int attached_threads
unsigned int binmap[BINMAPSIZE]
ut64 fastbinsY[NFASTBINS]
unsigned int attached_threads
unsigned int binmap[BINMAPSIZE]
ut16 counts[TCACHE_MAX_BINS]
ut32 entries[TCACHE_MAX_BINS]
ut64 entries[TCACHE_MAX_BINS]
ut16 counts[TCACHE_MAX_BINS]
ut8 counts[TCACHE_MAX_BINS]
ut32 entries[TCACHE_MAX_BINS]
ut8 counts[TCACHE_MAX_BINS]
ut64 entries[TCACHE_MAX_BINS]
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
static bool input(void *ud, zip_uint8_t *data, zip_uint64_t length)