summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/perk/perk.h12
-rw-r--r--src/logic/pe_get_image_meta.c42
2 files changed, 54 insertions, 0 deletions
diff --git a/include/perk/perk.h b/include/perk/perk.h
index d667413..e012a96 100644
--- a/include/perk/perk.h
+++ b/include/perk/perk.h
@@ -79,6 +79,8 @@ struct pe_expsym {
struct pe_meta_stats {
int32_t t_nexpsyms;
int32_t t_nimplibs;
+ int32_t t_ndsolibs;
+ int32_t t_ndsosyms;
int32_t t_nrelocs;
};
@@ -93,6 +95,11 @@ struct pe_image_meta {
struct pe_raw_export_hdr * r_edata;
struct pe_raw_import_hdr * r_idata;
+ void * r_dsometa;
+ void * r_dsosyms;
+ char * r_dsostrs;
+ void * r_dsodata;
+
struct pe_meta_stats m_stats;
struct pe_meta_image_dos_hdr m_dos;
struct pe_meta_coff_file_hdr m_coff;
@@ -104,6 +111,11 @@ struct pe_image_meta {
struct pe_meta_sec_hdr * h_edata;
struct pe_meta_sec_hdr * h_idata;
+
+ struct pe_meta_sec_hdr * h_dsometa;
+ struct pe_meta_sec_hdr * h_dsosyms;
+ struct pe_meta_sec_hdr * h_dsostrs;
+ struct pe_meta_sec_hdr * h_dsodata;
};
struct pe_source_version {
diff --git a/src/logic/pe_get_image_meta.c b/src/logic/pe_get_image_meta.c
index f995b11..b8bf8a8 100644
--- a/src/logic/pe_get_image_meta.c
+++ b/src/logic/pe_get_image_meta.c
@@ -9,6 +9,9 @@
#include <stdio.h>
#include <string.h>
+#include <mdso/mdso_specs.h>
+#include <mdso/mdso_structs.h>
+
#include <perk/perk.h>
#include "perk_reader_impl.h"
#include "perk_errinfo_impl.h"
@@ -349,6 +352,45 @@ int pe_get_image_meta(
}
}
+ /* .dsometa */
+ if ((i = pe_get_named_section_index(m,MDSO_META_SECTION)) >= 0) {
+ m->h_dsometa = &m->m_sectbl[i];
+ m->r_dsometa = base + m->m_sectbl[i].sh_ptr_to_raw_data;
+
+ m->m_stats.t_ndsolibs = (m->m_opt.oh_std.coh_magic == PE_MAGIC_PE32_PLUS)
+ ? m->h_dsometa->sh_virtual_size / sizeof(struct mdso_raw_meta_record_m64)
+ : m->h_dsometa->sh_virtual_size / sizeof(struct mdso_raw_meta_record_m32);
+ }
+
+ /* .dsosyms */
+ if ((i = pe_get_named_section_index(m,MDSO_SYMS_SECTION)) >= 0) {
+ m->h_dsosyms = &m->m_sectbl[i];
+ m->r_dsosyms = base + m->m_sectbl[i].sh_ptr_to_raw_data;
+
+ m->m_stats.t_ndsosyms = (m->m_opt.oh_std.coh_magic == PE_MAGIC_PE32_PLUS)
+ ? m->h_dsosyms->sh_virtual_size / sizeof(struct mdso_raw_sym_entry_m64)
+ : m->h_dsosyms->sh_virtual_size / sizeof(struct mdso_raw_sym_entry_m32);
+ }
+
+ /* .dsostrs */
+ if ((i = pe_get_named_section_index(m,MDSO_STRS_SECTION)) >= 0) {
+ m->h_dsostrs = &m->m_sectbl[i];
+ m->r_dsostrs = base + m->m_sectbl[i].sh_ptr_to_raw_data;
+ }
+
+ /* .dsodata */
+ if ((i = pe_get_named_section_index(m,MDSO_DATA_SECTION)) >= 0) {
+ m->h_dsodata = &m->m_sectbl[i];
+ m->r_dsodata = base + m->m_sectbl[i].sh_ptr_to_raw_data;
+ }
+
+ /* mdso abi */
+ if (m->h_dsometa || m->h_dsosyms)
+ if (pe_get_image_abi(m,0) == PE_ABI_UNSUPPORTED)
+ return pe_free_image_meta_impl(
+ m,PERK_CUSTOM_ERROR(
+ dctx,PERK_ERR_UNSUPPORTED_ABI));
+
/* image */
m->r_image.map_addr = image->map_addr;
m->r_image.map_size = image->map_size;