Rizin
unix-like reverse engineering framework and cli tools
|
#include <rz_windows.h>
#include <rz_core.h>
#include <TlHelp32.h>
#include <windows_heap.h>
#include "..\..\debug\p\native\maps\windows_maps.h"
#include "..\..\bin\pdb\pdb_downloader.h"
#include "..\..\bin\pdb\pdb.h"
Go to the source code of this file.
Classes | |
struct | _th_query_params |
Macros | |
#define | PDI_MODULES 0x01 |
#define | PDI_HEAPS 0x04 |
#define | PDI_HEAP_TAGS 0x08 |
#define | PDI_HEAP_BLOCKS 0x10 |
#define | PDI_HEAP_ENTRIES_EX 0x200 |
#define | CHECK_INFO(heapInfo) |
#define | CHECK_INFO_RETURN_NULL(heapInfo) |
#define | UPDATE_FLAGS(hb, flags) |
#define | GROW_BLOCKS() |
#define | GROW_PBLOCKS() |
Typedefs | |
typedef struct _th_query_params | th_query_params |
Variables | |
static size_t | RtlpHpHeapGlobalsOffset = 0 |
static size_t | RtlpLFHKeyOffset = 0 |
#define CHECK_INFO | ( | heapInfo | ) |
Definition at line 61 of file windows_heap.c.
#define CHECK_INFO_RETURN_NULL | ( | heapInfo | ) |
Definition at line 71 of file windows_heap.c.
#define GROW_BLOCKS | ( | ) |
Definition at line 579 of file windows_heap.c.
#define GROW_PBLOCKS | ( | ) |
Definition at line 592 of file windows_heap.c.
#define PDI_HEAP_BLOCKS 0x10 |
Definition at line 55 of file windows_heap.c.
#define PDI_HEAP_ENTRIES_EX 0x200 |
Definition at line 56 of file windows_heap.c.
#define PDI_HEAP_TAGS 0x08 |
Definition at line 54 of file windows_heap.c.
#define PDI_HEAPS 0x04 |
Definition at line 53 of file windows_heap.c.
#define PDI_MODULES 0x01 |
Definition at line 52 of file windows_heap.c.
#define UPDATE_FLAGS | ( | hb, | |
flags | |||
) |
Definition at line 81 of file windows_heap.c.
typedef struct _th_query_params th_query_params |
|
static |
Definition at line 91 of file windows_heap.c.
References info(), major, rz_sys_info(), and rz_sys_info_free().
Referenced by InitHeapInfo(), rz_heap_blocks_list(), rz_heap_list(), rz_heap_list_w32(), and w32_list_heaps_blocks().
|
static |
Definition at line 605 of file windows_heap.c.
References _HEAP_LFH_SUBSEGMENT::BlockBitmap, _HEAP_LFH_SUBSEGMENT::BlockCount, _HEAP_LFH_SUBSEGMENT::BlockOffsets, _HEAP_LFH_SUBSEGMENT_ENCODED_OFFSETS::BlockSize, count, DWORD, _HEAP_LFH_SUBSEGMENT_ENCODED_OFFSETS::EncodedData, EXTRA_FLAG, _HEAP_LFH_SUBSEGMENT_ENCODED_OFFSETS::FirstBlockOffset, _HeapBlockExtraInfo::granularity, GROW_PBLOCKS, LFH_BLOCK, _HEAP_LFH_SUBSEGMENT::ListEntry, mask, NULL, off, offsetof, RZ_NEW0, _HeapBlockExtraInfo::segment, and SEGMENT_HEAP_BLOCK.
Referenced by GetSegmentHeapBlocks().
|
static |
Definition at line 1226 of file windows_heap.c.
References rz_table_add_column(), rz_table_new(), and rz_table_type().
Referenced by rz_heap_debug_block_win(), and w32_list_heaps_blocks().
|
static |
Definition at line 451 of file windows_heap.c.
References _th_query_params::db, _th_query_params::dbg, _th_query_params::fin, free(), _th_query_params::hanged, _th_query_params::mask, rz_debug_t::pid, and _th_query_params::ret.
Referenced by InitHeapInfo().
|
static |
Definition at line 416 of file windows_heap.c.
References rz_debug_t::bits, dbg, rz_return_val_if_fail, and RZ_SYS_BITS_64.
Referenced by GetHeapBlocks(), and GetSingleBlock().
|
static |
Definition at line 430 of file windows_heap.c.
References addr, rz_debug_t::bits, dbg, DWORD, key, rz_return_val_if_fail, and RZ_SYS_BITS_64.
Referenced by GetHeapBlocks(), and GetSingleBlock().
|
static |
Definition at line 257 of file windows_heap.c.
References _HeapBlock::extraInfo, GetFirstHeapBlock(), GetNextHeapBlock(), RZ_FREE, and rz_return_if_fail.
Referenced by GetHeapBlocks(), rz_heap_blocks_list(), rz_heap_list(), rz_heap_list_w32(), and w32_list_heaps_blocks().
|
static |
Definition at line 105 of file windows_heap.c.
References BACKEND_BLOCK, flags, LARGE_BLOCK, LFH_BLOCK, NT_BLOCK, rz_str_newf(), SEGMENT_HEAP_BLOCK, type, and VS_BLOCK.
Referenced by rz_heap_blocks_list(), rz_heap_debug_block_win(), and w32_list_heaps_blocks().
|
static |
Definition at line 168 of file windows_heap.c.
References _HeapBlockBasicInfo::address, _DEBUG_HEAP_INFORMATION::BlockCount, _DEBUG_HEAP_INFORMATION::Blocks, _HeapBlock::dwAddress, _HeapBlock::dwFlags, _HeapBlock::dwSize, EXTRA_FLAG, _HeapBlock::extraInfo, flags, _HeapBlockBasicInfo::flags, _HeapBlockExtraInfo::granularity, _DEBUG_HEAP_INFORMATION::Granularity, if(), _HeapBlock::index, NULL, rz_return_val_if_fail, _HeapBlockBasicInfo::size, _HeapBlockExtraInfo::unusedBytes, and UPDATE_FLAGS.
Referenced by free_extra_info(), rz_heap_blocks_list(), and w32_list_heaps_blocks().
|
static |
Definition at line 780 of file windows_heap.c.
References BACKEND_BLOCK, _HEAP_SEGMENT::BaseAddress, _HEAP::BaseAddress, rz_debug_t::bits, blocks, _HEAP_SUBSEGMENT::BlockSize, _RTL_BITMAP_EX::Buffer, _HEAP_USERDATA_HEADER::BusyBitmap, _HEAP_VIRTUAL_ALLOC_ENTRY::BusyBlock, calloc(), _HEAP_VIRTUAL_ALLOC_ENTRY::CommitSize, count, _HeapInformation::count, _HEAP::Counters, _HEAP_LOCAL_DATA::CrtZone, dbg, DecodeHeapEntry(), DecodeLFHEntry(), _HEAP_USERDATA_HEADER::EncodedOffsets, _HEAP_VIRTUAL_ALLOC_ENTRY::Entry, eprintf, err, EXTRA_FLAG, FALSE, _HEAP_USERDATA_OFFSETS::FirstAllocationOffset, _HEAP_SEGMENT::FirstEntry, _HEAP_ENTRY::Flags, free(), free_extra_info(), from, _HEAP::FrontEndHeap, _HEAP::FrontEndHeapType, GetLFHKey(), GetSegmentHeapBlocks(), _HeapBlockExtraInfo::granularity, GROW_BLOCKS, HANDLE, _DEBUG_BUFFER::HeapInformation, _HeapInformation::heaps, i, if(), info(), InitHeapInfo(), LARGE_BLOCK, _HEAP_COUNTERS::LastPolledSize, _HEAP_SEGMENT::LastValidEntry, LFH_BLOCK, mask, _LFH_BLOCK_ZONE::NextIndex, NT_BLOCK, NULL, off, offsetof, PDI_HEAPS, pid, PVOID, _HEAP_VIRTUAL_ALLOC_ENTRY::ReserveSize, RZ_FREE, RZ_LOG_ERROR, RZ_NEW0, RZ_SYS_BITS_32, rz_sys_perror, _HeapBlockExtraInfo::segment, _HEAP::SegmentList, _HEAP_SEGMENT::SegmentListEntry, _HEAP::SegmentSignature, _RTL_BITMAP_EX::SizeOfBitMap, _HEAP_USERDATA_OFFSETS::StrideAndOffset, _LFH_HEAP::SubSegmentZones, _HEAP_COUNTERS::TotalMemoryCommitted, _HeapBlockExtraInfo::unusedBytes, ut64(), and _HEAP::VirtualAllocdBlocks.
Referenced by rz_heap_blocks_list(), rz_heap_list(), rz_heap_list_w32(), and w32_list_heaps_blocks().
Definition at line 271 of file windows_heap.c.
References baddr(), baseaddr, rz_bin_file_load_options_t::baseaddr, rz_core_t::bin, rz_json_t::children, rz_core_t::config, rz_core_bind_t::core, rz_debug_t::corebind, rz_bin_t::cur, dbg, eprintf, SPDBOptions::extract, fail, fd, found, free(), rz_bin_info_t::guid, has_heap_globals(), info(), rz_core_t::io, map(), regress::modules, rz_json_t::next, NULL, rz_json_t::num, rz_bin_file_t::o, rz_bin_object_t::opts, pj_free(), pj_new(), RtlpHpHeapGlobalsOffset, RtlpLFHKeyOffset, rz_bin_cur(), rz_bin_file_delete(), rz_bin_file_set_cur_binfile(), rz_bin_get_info(), rz_bin_open_io(), rz_bin_pdb_download(), rz_bin_pdb_free(), rz_bin_pdb_parse_from_file(), rz_config_get(), rz_config_get_i(), rz_core_bin_pdb_gvars_as_string(), rz_file_exists(), rz_io_fd_close(), rz_io_fd_open(), rz_io_fd_size(), rz_json_get(), rz_json_parse(), rz_list_free(), RZ_LOG_ERROR, RZ_OUTPUT_MODE_JSON, RZ_PERM_R, rz_str_newf(), rz_w32_dbg_modules(), rz_json_t::str_value, SPDBOptions::symbol_server, SPDBOptions::symbol_store_path, and ut64().
Referenced by GetLFHKey().
Definition at line 393 of file windows_heap.c.
References dbg, eprintf, GetHeapGlobalsOffset(), NULL, PVOID, RtlpHpHeapGlobalsOffset, RtlpLFHKeyOffset, rz_return_val_if_fail, and rz_sys_perror.
Referenced by GetHeapBlocks(), GetSingleBlock(), and GetSingleSegmentBlock().
Definition at line 462 of file windows_heap.c.
References rz_debug_t::bits, dbg, NULL, ph, PVOID, rz_list_new(), rz_list_push(), RZ_SYS_BITS_64, rz_sys_perror, and ULONG.
Referenced by InitHeapInfo().
|
static |
Definition at line 208 of file windows_heap.c.
References _HeapBlockBasicInfo::address, _DEBUG_HEAP_INFORMATION::BlockCount, _DEBUG_HEAP_INFORMATION::Blocks, _HeapBlock::dwAddress, _HeapBlock::dwSize, EXTRA_FLAG, _HeapBlock::extraInfo, flags, _HeapBlockBasicInfo::flags, _HeapBlockExtraInfo::granularity, _DEBUG_HEAP_INFORMATION::Granularity, if(), _HeapBlock::index, NULL, rz_return_val_if_fail, _HeapBlockBasicInfo::size, _HeapBlockExtraInfo::unusedBytes, and UPDATE_FLAGS.
Referenced by free_extra_info(), rz_heap_blocks_list(), and w32_list_heaps_blocks().
|
static |
Definition at line 641 of file windows_heap.c.
References __lfh_segment_loop(), _HEAP_LFH_BUCKET::AffinitySlots, _HEAP_VS_CHUNK_HEADER_SIZE::Allocated, _HEAP_LFH_SUBSEGMENT_OWNER::AvailableSubsegmentList, BACKEND_BLOCK, blocks, _HEAP_LFH_CONTEXT::Buckets, count, _HEAP_PAGE_SEGMENT::DescArray, eprintf, EXTRA_FLAG, free(), from, _HEAP_LFH_SUBSEGMENT_OWNER::FullSubsegmentList, _HeapBlockExtraInfo::granularity, GROW_PBLOCKS, _HEAP_VS_CHUNK_HEADER_SIZE::HeaderBits, i, if(), LARGE_BLOCK, _SEGMENT_HEAP::LargeAllocMetadata, _SEGMENT_HEAP::LargeReservedPages, _RTL_BALANCED_NODE::Left, _SEGMENT_HEAP::LfhContext, _HEAP_PAGE_SEGMENT::ListEntry, malloc(), offsetof, PAGE_RANGE_FLAGS_ALLOCATED, PAGE_RANGE_FLAGS_FIRST, PVOID, _HEAP_PAGE_RANGE_DESCRIPTOR::RangeFlags, _RTL_RB_TREE::Root, RtlpHpHeapGlobalsOffset, RZ_NEW0, rz_return_val_if_fail, rz_stack_free(), rz_stack_is_empty(), rz_stack_new(), rz_stack_pop(), rz_stack_push(), rz_sys_perror, s, _SEGMENT_HEAP::SegContexts, _HeapBlockExtraInfo::segment, SEGMENT_HEAP_BLOCK, _SEGMENT_HEAP::Signature, _HEAP_VS_SUBSEGMENT::Size, _HEAP_VS_CHUNK_HEADER::Sizes, start, _HEAP_LFH_AFFINITY_SLOT::State, _HEAP_PAGE_RANGE_DESCRIPTOR::UnitSize, _HEAP_VS_CHUNK_HEADER_SIZE::UnsafeSize, _HEAP_PAGE_RANGE_DESCRIPTOR::UnusedBytes, _HeapBlockExtraInfo::unusedBytes, and VS_BLOCK.
Referenced by GetHeapBlocks().
|
static |
Definition at line 1112 of file windows_heap.c.
References BACKEND_BLOCK, rz_debug_t::bits, _HEAP_SUBSEGMENT::BlockSize, _HEAP_VIRTUAL_ALLOC_ENTRY::CommitSize, _HeapInformation::count, dbg, DecodeHeapEntry(), DecodeLFHEntry(), _HeapBlock::dwAddress, _HeapBlock::dwFlags, DWORD, _HeapBlock::dwSize, err, _HeapBlock::extraInfo, FALSE, free(), GetLFHKey(), GetSingleSegmentBlock(), _HeapBlockExtraInfo::granularity, h, HANDLE, _DEBUG_BUFFER::HeapInformation, _HeapInformation::heaps, i, InitHeapInfo(), is_segment_heap(), LARGE_BLOCK, LFH_BLOCK, NT_BLOCK, NULL, PDI_HEAPS, rz_debug_t::pid, PVOID, _HEAP_VIRTUAL_ALLOC_ENTRY::ReserveSize, RZ_FREE, RZ_LOG_ERROR, RZ_NEW0, RZ_SYS_BITS_64, rz_sys_perror, _HEAP_USERDATA_HEADER::SubSegment, _HeapBlockExtraInfo::unusedBytes, and UPDATE_FLAGS.
Referenced by rz_heap_debug_block_win().
|
static |
Definition at line 1009 of file windows_heap.c.
References rz_debug_t::bits, _HEAP_LFH_SUBSEGMENT::BlockOffsets, _HEAP_LFH_SUBSEGMENT_ENCODED_OFFSETS::BlockSize, dbg, _HEAP_PAGE_SEGMENT::DescArray, _HeapBlock::dwAddress, _HeapBlock::dwFlags, DWORD, _HeapBlock::dwSize, _HEAP_LFH_SUBSEGMENT_ENCODED_OFFSETS::EncodedData, err, _HeapBlock::extraInfo, free(), GetLFHKey(), _HeapBlockExtraInfo::granularity, header, _HeapBlockExtraInfo::heap, LARGE_BLOCK, _RTL_BALANCED_NODE::Left, LFH_BLOCK, NULL, offsetof, PAGE_RANGE_FLAGS_FIRST, PAGE_RANGE_FLAGS_LFH_SUBSEGMENT, PVOID, _HEAP_PAGE_RANGE_DESCRIPTOR::RangeFlags, _RTL_BALANCED_NODE::Right, RtlpHpHeapGlobalsOffset, RZ_LOG_ERROR, RZ_NEW0, _HeapBlockExtraInfo::segment, SEGMENT_HEAP_BLOCK, _HEAP_VS_SUBSEGMENT::Signature, _HEAP_VS_SUBSEGMENT::Size, _HEAP_PAGE_RANGE_DESCRIPTOR::UnitOffset, _HEAP_PAGE_RANGE_DESCRIPTOR::UnusedBytes, _HeapBlockExtraInfo::unusedBytes, and VS_BLOCK.
Referenced by GetSingleBlock().
|
inlinestatic |
Definition at line 267 of file windows_heap.c.
References RtlpHpHeapGlobalsOffset, and RtlpLFHKeyOffset.
Referenced by GetHeapGlobalsOffset().
|
static |
Definition at line 496 of file windows_heap.c.
References __is_windows_ten(), __th_QueryDebugBuffer(), _DEBUG_HEAP_INFORMATION::Allocated, _DEBUG_HEAP_INFORMATION::Base, _DEBUG_HEAP_INFORMATION::Committed, _HeapInformation::count, dbg, eprintf, FALSE, _th_query_params::fin, free(), GetListOfHeaps(), _DEBUG_HEAP_INFORMATION::Granularity, HANDLE, _th_query_params::hanged, _DEBUG_BUFFER::HeapInformation, _HeapInformation::heaps, i, rz_list_t::length, mask, NULL, PDI_HEAPS, rz_debug_t::pid, realloc(), _th_query_params::ret, rz_list_free(), RZ_LOG_ERROR, RZ_NEW0, rz_sys_perror, and autogen_x86imm::tmp.
Referenced by GetHeapBlocks(), GetSingleBlock(), rz_heap_blocks_list(), rz_heap_list(), rz_heap_list_w32(), and w32_list_heaps_blocks().
|
static |
Definition at line 137 of file windows_heap.c.
References DWORD, HANDLE, PULONG, PVOID, and ULONG.
Referenced by rz_heap_blocks_list(), rz_heap_debug_block_win(), rz_heap_list(), and rz_heap_list_w32().
Definition at line 1412 of file windows_heap.c.
References __is_windows_ten(), _DEBUG_HEAP_INFORMATION::Blocks, CHECK_INFO_RETURN_NULL, _HeapInformation::count, rz_core_t::dbg, _HeapBlock::dwAddress, _HeapBlock::dwFlags, DWORD, _HeapBlock::dwSize, eprintf, _HeapBlock::extraInfo, free(), free_extra_info(), get_type(), GetFirstHeapBlock(), GetHeapBlocks(), GetNextHeapBlock(), _HeapBlockExtraInfo::granularity, _DEBUG_HEAP_INFORMATION::Granularity, _DEBUG_BUFFER::HeapInformation, _HeapInformation::heaps, i, _DEBUG_BUFFER::InfoClassMask, InitHeapInfo(), initialize_windows_ntdll_query_api_functions(), malloc(), NULL, PDI_HEAP_BLOCKS, PDI_HEAPS, rz_debug_t::pid, pid, RZ_FREE, rz_list_append(), rz_list_free(), rz_list_newf(), RZ_NEW0, type, _HeapBlockExtraInfo::unusedBytes, and ut64().
RZ_IPI void rz_heap_debug_block_win | ( | RzCore * | core, |
const char * | addr, | ||
RzOutputMode | mode, | ||
bool | flag | ||
) |
Definition at line 1370 of file windows_heap.c.
References __new_heapblock_tbl(), addr, rz_core_t::dbg, _HeapBlock::dwFlags, _HeapBlock::dwSize, _HeapBlock::extraInfo, free(), get_type(), GetSingleBlock(), _HeapBlockExtraInfo::granularity, initialize_windows_ntdll_query_api_functions(), rz_core_t::num, off, pj_end(), pj_free(), pj_kN(), pj_ks(), pj_new(), pj_o(), pj_string(), rz_cons_println(), rz_num_math(), RZ_OUTPUT_MODE_JSON, RZ_OUTPUT_MODE_STANDARD, rz_table_add_rowf(), rz_table_free(), rz_table_tostring(), type, _HeapBlockExtraInfo::unusedBytes, ut64(), and w32_list_heaps_blocks().
Definition at line 1470 of file windows_heap.c.
References __is_windows_ten(), rz_heap_info::allocated, rz_heap_info::base, rz_heap_info::blockCount, CHECK_INFO_RETURN_NULL, rz_heap_info::committed, _HeapInformation::count, rz_core_t::dbg, eprintf, free(), free_extra_info(), GetHeapBlocks(), _DEBUG_BUFFER::HeapInformation, _HeapInformation::heaps, i, _DEBUG_BUFFER::InfoClassMask, InitHeapInfo(), initialize_windows_ntdll_query_api_functions(), NULL, PDI_HEAP_BLOCKS, PDI_HEAPS, rz_debug_t::pid, pid, RZ_FREE, rz_list_append(), rz_list_free(), rz_list_newf(), RZ_NEW0, ULONG, and ut64().
RZ_IPI void rz_heap_list_w32 | ( | RzCore * | core, |
RzOutputMode | mode | ||
) |
Definition at line 1237 of file windows_heap.c.
References __is_windows_ten(), CHECK_INFO, _HeapInformation::count, rz_core_t::dbg, eprintf, free_extra_info(), GetHeapBlocks(), _DEBUG_BUFFER::HeapInformation, _HeapInformation::heaps, i, _DEBUG_BUFFER::InfoClassMask, InitHeapInfo(), initialize_windows_ntdll_query_api_functions(), PDI_HEAP_BLOCKS, PDI_HEAPS, rz_debug_t::pid, pid, pj_a(), pj_end(), pj_free(), pj_kN(), pj_new(), pj_o(), pj_string(), rz_cons_println(), RZ_FREE, RZ_OUTPUT_MODE_JSON, rz_table_add_column(), rz_table_add_rowf(), rz_table_free(), rz_table_new(), rz_table_tostring(), rz_table_type(), ULONG, and ut64().
|
static |
Definition at line 1288 of file windows_heap.c.
References __is_windows_ten(), __new_heapblock_tbl(), _DEBUG_HEAP_INFORMATION::Base, _DEBUG_HEAP_INFORMATION::BlockCount, _DEBUG_HEAP_INFORMATION::Blocks, CHECK_INFO, _HeapInformation::count, rz_core_t::dbg, _HeapBlock::dwAddress, _HeapBlock::dwFlags, DWORD, _HeapBlock::dwSize, eprintf, _HeapBlock::extraInfo, rz_core_t::flags, free(), free_extra_info(), get_type(), GetFirstHeapBlock(), GetHeapBlocks(), GetNextHeapBlock(), _HeapBlockExtraInfo::granularity, _DEBUG_HEAP_INFORMATION::Granularity, _DEBUG_BUFFER::HeapInformation, _HeapInformation::heaps, i, if(), _DEBUG_BUFFER::InfoClassMask, InitHeapInfo(), malloc(), PDI_HEAP_BLOCKS, PDI_HEAPS, PFMT64x, rz_debug_t::pid, pid, pj_a(), pj_end(), pj_free(), pj_k(), pj_kN(), pj_ks(), pj_new(), pj_o(), pj_string(), rz_cons_println(), rz_cons_yesno(), rz_flag_set(), RZ_FREE, RZ_OUTPUT_MODE_JSON, rz_str_newf(), rz_table_add_rowf(), rz_table_free(), rz_table_tostring(), type, _HeapBlockExtraInfo::unusedBytes, and ut64().
Referenced by rz_heap_debug_block_win().
|
static |
Definition at line 58 of file windows_heap.c.
Referenced by GetHeapGlobalsOffset(), GetLFHKey(), GetSegmentHeapBlocks(), GetSingleSegmentBlock(), and has_heap_globals().
|
static |
Definition at line 59 of file windows_heap.c.
Referenced by GetHeapGlobalsOffset(), GetLFHKey(), and has_heap_globals().