diff options
author | midipix <writeonce@midipix.org> | 2016-12-01 06:15:50 -0500 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2016-12-01 06:15:50 -0500 |
commit | 9b6975e989a2aff8c18f7496a2f730874ad3b08e (patch) | |
tree | 445c66fe73653a9c1cbe078308cbf9f15edc942c | |
parent | 012431abcb9b2fdba8e1c55d774d551a161ae5fe (diff) | |
download | perk-9b6975e989a2aff8c18f7496a2f730874ad3b08e.tar.bz2 perk-9b6975e989a2aff8c18f7496a2f730874ad3b08e.tar.xz |
struct pe_raw_opt_hdr_{32|64}: member name normalization.
-rw-r--r-- | include/perk/perk_structs.h | 182 | ||||
-rw-r--r-- | src/logic/pe_get_image_meta.c | 2 | ||||
-rw-r--r-- | src/reader/pe_read_optional_header.c | 42 |
3 files changed, 113 insertions, 113 deletions
diff --git a/include/perk/perk_structs.h b/include/perk/perk_structs.h index acc3617..9bcd366 100644 --- a/include/perk/perk_structs.h +++ b/include/perk/perk_structs.h @@ -119,101 +119,101 @@ struct pe_raw_data_dirs { }; struct pe_raw_opt_hdr_32 { - unsigned char magic [0x02]; /* 0x00 */ - unsigned char major_linker_ver [0x01]; /* 0x02 */ - unsigned char minor_linker_ver [0x01]; /* 0x03 */ - unsigned char size_of_code [0x04]; /* 0x04 */ - unsigned char size_of_initialized_data [0x04]; /* 0x08 */ - unsigned char size_of_uninitialized_data [0x04]; /* 0x0c */ - unsigned char entry_point [0x04]; /* 0x10 */ - unsigned char base_of_code [0x04]; /* 0x14 */ - unsigned char base_of_data [0x04]; /* 0x18 */ - unsigned char image_base [0x04]; /* 0x1c */ - unsigned char section_align [0x04]; /* 0x20 */ - unsigned char file_align [0x04]; /* 0x24 */ - unsigned char major_os_ver [0x02]; /* 0x28 */ - unsigned char minor_os_ver [0x02]; /* 0x2a */ - unsigned char major_image_ver [0x02]; /* 0x2c */ - unsigned char minor_image_ver [0x02]; /* 0x2e */ - unsigned char major_subsys_ver [0x02]; /* 0x30 */ - unsigned char minor_subsys_ver [0x02]; /* 0x32 */ - unsigned char win32_ver [0x04]; /* 0x34 */ - unsigned char size_of_image [0x04]; /* 0x38 */ - unsigned char size_of_headers [0x04]; /* 0x3c */ - unsigned char checksum [0x04]; /* 0x40 */ - unsigned char subsystem [0x02]; /* 0x44 */ - unsigned char dll_characteristics [0x02]; /* 0x46 */ - unsigned char size_of_stack_reserve [0x04]; /* 0x48 */ - unsigned char size_of_stack_commit [0x04]; /* 0x4c */ - unsigned char size_of_heap_reserve [0x04]; /* 0x50 */ - unsigned char size_of_heap_commit [0x04]; /* 0x54 */ - unsigned char loader_flags [0x04]; /* 0x58 */ - unsigned char rva_and_sizes [0x04]; /* 0x5c */ - unsigned char export_tbl [0x08]; /* 0x60 */ - unsigned char import_tbl [0x08]; /* 0x68 */ - unsigned char resource_tbl [0x08]; /* 0x70 */ - unsigned char exception_tbl [0x08]; /* 0x78 */ - unsigned char certificate_tbl [0x08]; /* 0x80 */ - unsigned char base_reloc_tbl [0x08]; /* 0x88 */ - unsigned char debug [0x08]; /* 0x90 */ - unsigned char arch [0x08]; /* 0x98 */ - unsigned char global_ptr [0x08]; /* 0xa0 */ - unsigned char tls_tbl [0x08]; /* 0xa8 */ - unsigned char load_config_tbl [0x08]; /* 0xb0 */ - unsigned char bound_import [0x08]; /* 0xb8 */ - unsigned char iat [0x08]; /* 0xc0 */ - unsigned char delay_import_descriptor [0x08]; /* 0xc8 */ - unsigned char clr_runtime_hdr [0x08]; /* 0xd0 */ - unsigned char reserved [0x08]; /* 0xd8 */ + unsigned char coh_magic [0x02]; /* 0x00 */ + unsigned char coh_major_linker_ver [0x01]; /* 0x02 */ + unsigned char coh_minor_linker_ver [0x01]; /* 0x03 */ + unsigned char coh_size_of_code [0x04]; /* 0x04 */ + unsigned char coh_size_of_inited_data [0x04]; /* 0x08 */ + unsigned char coh_size_of_uninited_data [0x04]; /* 0x0c */ + unsigned char coh_entry_point [0x04]; /* 0x10 */ + unsigned char coh_base_of_code [0x04]; /* 0x14 */ + unsigned char coh_base_of_data [0x04]; /* 0x18 */ + unsigned char coh_image_base [0x04]; /* 0x1c */ + unsigned char coh_section_align [0x04]; /* 0x20 */ + unsigned char coh_file_align [0x04]; /* 0x24 */ + unsigned char coh_major_os_ver [0x02]; /* 0x28 */ + unsigned char coh_minor_os_ver [0x02]; /* 0x2a */ + unsigned char coh_major_image_ver [0x02]; /* 0x2c */ + unsigned char coh_minor_image_ver [0x02]; /* 0x2e */ + unsigned char coh_major_subsys_ver [0x02]; /* 0x30 */ + unsigned char coh_minor_subsys_ver [0x02]; /* 0x32 */ + unsigned char coh_win32_ver [0x04]; /* 0x34 */ + unsigned char coh_size_of_image [0x04]; /* 0x38 */ + unsigned char coh_size_of_headers [0x04]; /* 0x3c */ + unsigned char coh_checksum [0x04]; /* 0x40 */ + unsigned char coh_subsystem [0x02]; /* 0x44 */ + unsigned char coh_dll_characteristics [0x02]; /* 0x46 */ + unsigned char coh_size_of_stack_reserve [0x04]; /* 0x48 */ + unsigned char coh_size_of_stack_commit [0x04]; /* 0x4c */ + unsigned char coh_size_of_heap_reserve [0x04]; /* 0x50 */ + unsigned char coh_size_of_heap_commit [0x04]; /* 0x54 */ + unsigned char coh_loader_flags [0x04]; /* 0x58 */ + unsigned char coh_rva_and_sizes [0x04]; /* 0x5c */ + unsigned char coh_export_tbl [0x08]; /* 0x60 */ + unsigned char coh_import_tbl [0x08]; /* 0x68 */ + unsigned char coh_resource_tbl [0x08]; /* 0x70 */ + unsigned char coh_exception_tbl [0x08]; /* 0x78 */ + unsigned char coh_certificate_tbl [0x08]; /* 0x80 */ + unsigned char coh_base_reloc_tbl [0x08]; /* 0x88 */ + unsigned char coh_debug [0x08]; /* 0x90 */ + unsigned char coh_arch [0x08]; /* 0x98 */ + unsigned char coh_global_ptr [0x08]; /* 0xa0 */ + unsigned char coh_tls_tbl [0x08]; /* 0xa8 */ + unsigned char coh_load_config_tbl [0x08]; /* 0xb0 */ + unsigned char coh_bound_import [0x08]; /* 0xb8 */ + unsigned char coh_iat [0x08]; /* 0xc0 */ + unsigned char coh_delay_import_descriptor [0x08]; /* 0xc8 */ + unsigned char coh_clr_runtime_hdr [0x08]; /* 0xd0 */ + unsigned char coh_reserved [0x08]; /* 0xd8 */ }; struct pe_raw_opt_hdr_64 { - unsigned char magic [0x02]; /* 0x00 */ - unsigned char major_linker_ver [0x01]; /* 0x02 */ - unsigned char minor_linker_ver [0x01]; /* 0x03 */ - unsigned char size_of_code [0x04]; /* 0x04 */ - unsigned char size_of_initialized_data [0x04]; /* 0x08 */ - unsigned char size_of_uninitialized_data [0x04]; /* 0x0c */ - unsigned char entry_point [0x04]; /* 0x10 */ - unsigned char base_of_code [0x04]; /* 0x14 */ - unsigned char image_base [0x08]; /* 0x18 */ - unsigned char section_align [0x04]; /* 0x20 */ - unsigned char file_align [0x04]; /* 0x24 */ - unsigned char major_os_ver [0x02]; /* 0x28 */ - unsigned char minor_os_ver [0x02]; /* 0x2a */ - unsigned char major_image_ver [0x02]; /* 0x2c */ - unsigned char minor_image_ver [0x02]; /* 0x2e */ - unsigned char major_subsys_ver [0x02]; /* 0x30 */ - unsigned char minor_subsys_ver [0x02]; /* 0x32 */ - unsigned char win32_ver [0x04]; /* 0x34 */ - unsigned char size_of_image [0x04]; /* 0x38 */ - unsigned char size_of_headers [0x04]; /* 0x3c */ - unsigned char checksum [0x04]; /* 0x40 */ - unsigned char subsystem [0x02]; /* 0x44 */ - unsigned char dll_characteristics [0x02]; /* 0x46 */ - unsigned char size_of_stack_reserve [0x08]; /* 0x48 */ - unsigned char size_of_stack_commit [0x08]; /* 0x50 */ - unsigned char size_of_heap_reserve [0x08]; /* 0x58 */ - unsigned char size_of_heap_commit [0x08]; /* 0x60 */ - unsigned char loader_flags [0x04]; /* 0x68 */ - unsigned char rva_and_sizes [0x04]; /* 0x6c */ - unsigned char export_tbl [0x08]; /* 0x70 */ - unsigned char import_tbl [0x08]; /* 0x78 */ - unsigned char resource_tbl [0x08]; /* 0x80 */ - unsigned char exception_tbl [0x08]; /* 0x88 */ - unsigned char certificate_tbl [0x08]; /* 0x90 */ - unsigned char base_reloc_tbl [0x08]; /* 0x98 */ - unsigned char debug [0x08]; /* 0xa0 */ - unsigned char arch [0x08]; /* 0xa8 */ - unsigned char global_ptr [0x08]; /* 0xb0 */ - unsigned char tls_tbl [0x08]; /* 0xb8 */ - unsigned char load_config_tbl [0x08]; /* 0xc0 */ - unsigned char bound_import [0x08]; /* 0xc8 */ - unsigned char iat [0x08]; /* 0xd0 */ - unsigned char delay_import_descriptor [0x08]; /* 0xd8 */ - unsigned char clr_runtime_hdr [0x08]; /* 0xe0 */ - unsigned char reserved [0x08]; /* 0xe8 */ + unsigned char coh_magic [0x02]; /* 0x00 */ + unsigned char coh_major_linker_ver [0x01]; /* 0x02 */ + unsigned char coh_minor_linker_ver [0x01]; /* 0x03 */ + unsigned char coh_size_of_code [0x04]; /* 0x04 */ + unsigned char coh_size_of_inited_data [0x04]; /* 0x08 */ + unsigned char coh_size_of_uninited_data [0x04]; /* 0x0c */ + unsigned char coh_entry_point [0x04]; /* 0x10 */ + unsigned char coh_base_of_code [0x04]; /* 0x14 */ + unsigned char coh_image_base [0x08]; /* 0x18 */ + unsigned char coh_section_align [0x04]; /* 0x20 */ + unsigned char coh_file_align [0x04]; /* 0x24 */ + unsigned char coh_major_os_ver [0x02]; /* 0x28 */ + unsigned char coh_minor_os_ver [0x02]; /* 0x2a */ + unsigned char coh_major_image_ver [0x02]; /* 0x2c */ + unsigned char coh_minor_image_ver [0x02]; /* 0x2e */ + unsigned char coh_major_subsys_ver [0x02]; /* 0x30 */ + unsigned char coh_minor_subsys_ver [0x02]; /* 0x32 */ + unsigned char coh_win32_ver [0x04]; /* 0x34 */ + unsigned char coh_size_of_image [0x04]; /* 0x38 */ + unsigned char coh_size_of_headers [0x04]; /* 0x3c */ + unsigned char coh_checksum [0x04]; /* 0x40 */ + unsigned char coh_subsystem [0x02]; /* 0x44 */ + unsigned char coh_dll_characteristics [0x02]; /* 0x46 */ + unsigned char coh_size_of_stack_reserve [0x08]; /* 0x48 */ + unsigned char coh_size_of_stack_commit [0x08]; /* 0x50 */ + unsigned char coh_size_of_heap_reserve [0x08]; /* 0x58 */ + unsigned char coh_size_of_heap_commit [0x08]; /* 0x60 */ + unsigned char coh_loader_flags [0x04]; /* 0x68 */ + unsigned char coh_rva_and_sizes [0x04]; /* 0x6c */ + unsigned char coh_export_tbl [0x08]; /* 0x70 */ + unsigned char coh_import_tbl [0x08]; /* 0x78 */ + unsigned char coh_resource_tbl [0x08]; /* 0x80 */ + unsigned char coh_exception_tbl [0x08]; /* 0x88 */ + unsigned char coh_certificate_tbl [0x08]; /* 0x90 */ + unsigned char coh_base_reloc_tbl [0x08]; /* 0x98 */ + unsigned char coh_debug [0x08]; /* 0xa0 */ + unsigned char coh_arch [0x08]; /* 0xa8 */ + unsigned char coh_global_ptr [0x08]; /* 0xb0 */ + unsigned char coh_tls_tbl [0x08]; /* 0xb8 */ + unsigned char coh_load_config_tbl [0x08]; /* 0xc0 */ + unsigned char coh_bound_import [0x08]; /* 0xc8 */ + unsigned char coh_iat [0x08]; /* 0xd0 */ + unsigned char coh_delay_import_descriptor [0x08]; /* 0xd8 */ + unsigned char coh_clr_runtime_hdr [0x08]; /* 0xe0 */ + unsigned char coh_reserved [0x08]; /* 0xe8 */ }; diff --git a/src/logic/pe_get_image_meta.c b/src/logic/pe_get_image_meta.c index d329727..007bda6 100644 --- a/src/logic/pe_get_image_meta.c +++ b/src/logic/pe_get_image_meta.c @@ -203,7 +203,7 @@ int pe_get_image_meta( return pe_free_image_meta_impl( m,PERK_CUSTOM_ERROR(dctx,ret)); - mark = &m->aopt->opt_hdr_32.magic[0]; + mark = &m->aopt->opt_hdr_32.coh_magic[0]; m->asectbl = (struct pe_raw_sec_hdr *)(mark + m->coff.cfh_size_of_opt_hdr); if (!(m->sectbl = calloc(m->coff.cfh_num_of_sections,sizeof(*(m->sectbl))))) diff --git a/src/reader/pe_read_optional_header.c b/src/reader/pe_read_optional_header.c index 274a22d..14ac4c0 100644 --- a/src/reader/pe_read_optional_header.c +++ b/src/reader/pe_read_optional_header.c @@ -22,23 +22,23 @@ static int pe_read_optional_header_structs(const union pe_raw_opt_hdr * p, struc struct pe_raw_opt_hdr_img * aimg; struct pe_raw_opt_hdr_ldr * aldr; - m->std.coh_magic = pe_read_short(p->opt_hdr_32.magic); + m->std.coh_magic = pe_read_short(p->opt_hdr_32.coh_magic); switch (m->std.coh_magic) { case PE_MAGIC_PE32: astd = (struct pe_raw_opt_hdr_std *)p; - avers = (struct pe_raw_opt_hdr_vers *)&p->opt_hdr_32.major_os_ver; - aalign = (struct pe_raw_opt_hdr_align *)&p->opt_hdr_32.section_align; - aimg = (struct pe_raw_opt_hdr_img *)&p->opt_hdr_32.size_of_image; - aldr = (struct pe_raw_opt_hdr_ldr *)&p->opt_hdr_32.loader_flags; + avers = (struct pe_raw_opt_hdr_vers *)&p->opt_hdr_32.coh_major_os_ver; + aalign = (struct pe_raw_opt_hdr_align *)&p->opt_hdr_32.coh_section_align; + aimg = (struct pe_raw_opt_hdr_img *)&p->opt_hdr_32.coh_size_of_image; + aldr = (struct pe_raw_opt_hdr_ldr *)&p->opt_hdr_32.coh_loader_flags; break; case PE_MAGIC_PE32_PLUS: astd = (struct pe_raw_opt_hdr_std *)p; - avers = (struct pe_raw_opt_hdr_vers *)&p->opt_hdr_64.major_os_ver; - aalign = (struct pe_raw_opt_hdr_align *)&p->opt_hdr_64.section_align; - aimg = (struct pe_raw_opt_hdr_img *)&p->opt_hdr_64.size_of_image; - aldr = (struct pe_raw_opt_hdr_ldr *)&p->opt_hdr_64.loader_flags; + avers = (struct pe_raw_opt_hdr_vers *)&p->opt_hdr_64.coh_major_os_ver; + aalign = (struct pe_raw_opt_hdr_align *)&p->opt_hdr_64.coh_section_align; + aimg = (struct pe_raw_opt_hdr_img *)&p->opt_hdr_64.coh_size_of_image; + aldr = (struct pe_raw_opt_hdr_ldr *)&p->opt_hdr_64.coh_loader_flags; break; default: @@ -88,7 +88,7 @@ static int pe_read_optional_header_structs(const union pe_raw_opt_hdr * p, struc if (m->ldr.coh_rva_and_sizes < 0x10) memset(&m->dirs,0,sizeof(m->dirs)); - mark = p->opt_hdr_64.export_tbl; + mark = p->opt_hdr_64.coh_export_tbl; pdir = &m->dirs.coh_export_tbl; for (i=0; i<m->ldr.coh_rva_and_sizes; i++) { @@ -108,21 +108,21 @@ int pe_read_optional_header(const union pe_raw_opt_hdr * p, struct pe_meta_opt_h switch (m->std.coh_magic) { case PE_MAGIC_PE32: - m->mem.coh_base_of_data = pe_read_long(p->opt_hdr_32.base_of_data); - m->mem.coh_image_base = pe_read_long(p->opt_hdr_32.image_base); - m->mem.coh_size_of_stack_reserve = pe_read_long(p->opt_hdr_32.size_of_stack_reserve); - m->mem.coh_size_of_stack_commit = pe_read_long(p->opt_hdr_32.size_of_stack_commit); - m->mem.coh_size_of_heap_reserve = pe_read_long(p->opt_hdr_32.size_of_heap_reserve); - m->mem.coh_size_of_heap_commit = pe_read_long(p->opt_hdr_32.size_of_heap_commit); + m->mem.coh_base_of_data = pe_read_long(p->opt_hdr_32.coh_base_of_data); + m->mem.coh_image_base = pe_read_long(p->opt_hdr_32.coh_image_base); + m->mem.coh_size_of_stack_reserve = pe_read_long(p->opt_hdr_32.coh_size_of_stack_reserve); + m->mem.coh_size_of_stack_commit = pe_read_long(p->opt_hdr_32.coh_size_of_stack_commit); + m->mem.coh_size_of_heap_reserve = pe_read_long(p->opt_hdr_32.coh_size_of_heap_reserve); + m->mem.coh_size_of_heap_commit = pe_read_long(p->opt_hdr_32.coh_size_of_heap_commit); break; case PE_MAGIC_PE32_PLUS: m->mem.coh_base_of_data = (uint64_t)-1; - m->mem.coh_image_base = pe_read_quad(p->opt_hdr_64.image_base); - m->mem.coh_size_of_stack_reserve = pe_read_quad(p->opt_hdr_64.size_of_stack_reserve); - m->mem.coh_size_of_stack_commit = pe_read_quad(p->opt_hdr_64.size_of_stack_commit); - m->mem.coh_size_of_heap_reserve = pe_read_quad(p->opt_hdr_64.size_of_heap_reserve); - m->mem.coh_size_of_heap_commit = pe_read_quad(p->opt_hdr_64.size_of_heap_commit); + m->mem.coh_image_base = pe_read_quad(p->opt_hdr_64.coh_image_base); + m->mem.coh_size_of_stack_reserve = pe_read_quad(p->opt_hdr_64.coh_size_of_stack_reserve); + m->mem.coh_size_of_stack_commit = pe_read_quad(p->opt_hdr_64.coh_size_of_stack_commit); + m->mem.coh_size_of_heap_reserve = pe_read_quad(p->opt_hdr_64.coh_size_of_heap_reserve); + m->mem.coh_size_of_heap_commit = pe_read_quad(p->opt_hdr_64.coh_size_of_heap_commit); break; } |