diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/mobicore/mclf.c | 40 |
1 files changed, 32 insertions, 8 deletions
diff --git a/plugins/mobicore/mclf.c b/plugins/mobicore/mclf.c index 740e7b1..7697d15 100644 --- a/plugins/mobicore/mclf.c +++ b/plugins/mobicore/mclf.c @@ -270,6 +270,8 @@ static const char *g_mclf_format_get_target_machine(const GMCLFFormat *format) static void g_mclf_format_refine_portions(GMCLFFormat *format) { GExeFormat *exe_format; /* Autre version du format */ + phys_t offset; /* Position physique */ + vmpa2t origin; /* Origine d'une définition */ vmpa2t addr; /* Emplacement dans le binaire */ GBinPortion *new; /* Nouvelle portion définie */ char desc[MAX_PORTION_DESC]; /* Description d'une portion */ @@ -279,6 +281,18 @@ static void g_mclf_format_refine_portions(GMCLFFormat *format) /* Segment de code */ + offset = sizeof(uint32_t) /* magic */ \ + + sizeof(uint32_t) /* version */ \ + + sizeof(uint32_t) /* flags */ \ + + sizeof(uint32_t) /* mem_type */ \ + + sizeof(uint32_t) /* service_type */ \ + + sizeof(uint32_t) /* num_instances */ \ + + 16 /* uuid */ \ + + sizeof(uint32_t) /* driver_id */ \ + + sizeof(uint32_t); /* num_threads */ + + init_vmpa(&origin, offset, VMPA_NO_VIRTUAL); + init_vmpa(&addr, 0, format->header.v1.text.start); new = g_binary_portion_new(BPC_CODE, &addr, format->header.v1.text.len); @@ -288,10 +302,15 @@ static void g_mclf_format_refine_portions(GMCLFFormat *format) g_binary_portion_set_rights(new, PAC_WRITE | PAC_EXEC); - g_exe_format_include_portion(exe_format, new); + g_exe_format_include_portion(exe_format, new, &origin); /* Segment de données */ + offset += sizeof(uint32_t) /* start */ \ + + sizeof(uint32_t); /* len */ + + init_vmpa(&origin, offset, VMPA_NO_VIRTUAL); + init_vmpa(&addr, format->header.v1.text.len, format->header.v1.data.start); new = g_binary_portion_new(BPC_DATA, &addr, format->header.v1.data.len); @@ -301,20 +320,25 @@ static void g_mclf_format_refine_portions(GMCLFFormat *format) g_binary_portion_set_rights(new, PAC_READ | PAC_WRITE); - g_exe_format_include_portion(exe_format, new); + g_exe_format_include_portion(exe_format, new, &origin); /* Signature finale */ length = g_binary_content_compute_size(G_BIN_FORMAT(format)->content); - init_vmpa(&addr, length - 521, VMPA_NO_VIRTUAL); /* FIXME */ - new = g_binary_portion_new(BPC_DATA, &addr, 521); + if (length > 521) + { + init_vmpa(&addr, length - 521, VMPA_NO_VIRTUAL); + + new = g_binary_portion_new(BPC_DATA, &addr, 521); - sprintf(desc, "%s \"%s\"", _("Segment"), "sig"); - g_binary_portion_set_desc(new, desc); + sprintf(desc, "%s \"%s\"", _("Segment"), "sig"); + g_binary_portion_set_desc(new, desc); - g_binary_portion_set_rights(new, PAC_READ | PAC_WRITE); + g_binary_portion_set_rights(new, PAC_READ | PAC_WRITE); - g_exe_format_include_portion(exe_format, new); + g_exe_format_include_portion(exe_format, new, NULL); + + } } |