diff options
Diffstat (limited to 'src/meta')
-rw-r--r-- | src/meta/pe_get_image_stack_heap_info.c | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/src/meta/pe_get_image_stack_heap_info.c b/src/meta/pe_get_image_stack_heap_info.c index 5a5e22a..67a6de9 100644 --- a/src/meta/pe_get_image_stack_heap_info.c +++ b/src/meta/pe_get_image_stack_heap_info.c @@ -9,6 +9,21 @@ #include <pemagine/pe_structs.h> #include <pemagine/pemagine.h> +static uint32_t pe_read_raw_data_32(unsigned char * addr) +{ + uint32_t * p32; + + p32 = (uint32_t *)addr; + return *p32; +} + +static uint64_t pe_read_raw_data_64(unsigned char * addr) +{ + uint64_t * p64; + + p64 = (uint64_t *)addr; + return *p64; +} int pe_get_image_stack_heap_info(const void * base, struct pe_stack_heap_info * stack_heap_info) { @@ -22,17 +37,17 @@ int pe_get_image_stack_heap_info(const void * base, struct pe_stack_heap_info * switch (*magic) { case PE_MAGIC_PE32: - stack_heap_info->size_of_stack_reserve = *(uint32_t *)hdr->opt_hdr_32.coh_size_of_stack_reserve; - stack_heap_info->size_of_stack_commit = *(uint32_t *)hdr->opt_hdr_32.coh_size_of_stack_commit; - stack_heap_info->size_of_heap_reserve = *(uint32_t *)hdr->opt_hdr_32.coh_size_of_heap_reserve; - stack_heap_info->size_of_heap_commit = *(uint32_t *)hdr->opt_hdr_32.coh_size_of_heap_commit; + stack_heap_info->size_of_stack_reserve = pe_read_raw_data_32(hdr->opt_hdr_32.coh_size_of_stack_reserve); + stack_heap_info->size_of_stack_commit = pe_read_raw_data_32(hdr->opt_hdr_32.coh_size_of_stack_commit); + stack_heap_info->size_of_heap_reserve = pe_read_raw_data_32(hdr->opt_hdr_32.coh_size_of_heap_reserve); + stack_heap_info->size_of_heap_commit = pe_read_raw_data_32(hdr->opt_hdr_32.coh_size_of_heap_commit); break; case PE_MAGIC_PE32_PLUS: - stack_heap_info->size_of_stack_reserve = *(size_t *)hdr->opt_hdr_64.coh_size_of_stack_reserve; - stack_heap_info->size_of_stack_commit = *(size_t *)hdr->opt_hdr_64.coh_size_of_stack_commit; - stack_heap_info->size_of_heap_reserve = *(size_t *)hdr->opt_hdr_64.coh_size_of_heap_reserve; - stack_heap_info->size_of_heap_commit = *(size_t *)hdr->opt_hdr_64.coh_size_of_heap_commit; + stack_heap_info->size_of_stack_reserve = pe_read_raw_data_64(hdr->opt_hdr_64.coh_size_of_stack_reserve); + stack_heap_info->size_of_stack_commit = pe_read_raw_data_64(hdr->opt_hdr_64.coh_size_of_stack_commit); + stack_heap_info->size_of_heap_reserve = pe_read_raw_data_64(hdr->opt_hdr_64.coh_size_of_heap_reserve); + stack_heap_info->size_of_heap_commit = pe_read_raw_data_64(hdr->opt_hdr_64.coh_size_of_heap_commit); break; default: |