summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Makefile.am2
-rw-r--r--plugins/devdbg/speed.c1
-rw-r--r--plugins/devdbg/speed.h27
-rw-r--r--plugins/mobicore/Makefile.am17
-rw-r--r--plugins/mobicore/annotations.c470
-rw-r--r--plugins/mobicore/annotations.h40
-rw-r--r--plugins/mobicore/mclf-def.h222
-rw-r--r--plugins/mobicore/mclf-int.c122
-rw-r--r--plugins/mobicore/mclf-int.h64
-rw-r--r--plugins/mobicore/mclf.c258
-rw-r--r--plugins/mobicore/mclf.h63
-rw-r--r--plugins/mobicore/mobicore.c83
-rw-r--r--plugins/mobicore/mobicore.h41
-rw-r--r--plugins/mobicore/symbols.c145
-rw-r--r--plugins/mobicore/symbols.h40
-rw-r--r--plugins/pychrysa/plugin.c8
-rw-r--r--plugins/pychrysa/pychrysa.c2
17 files changed, 1572 insertions, 33 deletions
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 84336ca..5eadf0c 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -1,2 +1,2 @@
-SUBDIRS = androhelpers devdbg pychrysa python stackvars
+SUBDIRS = androhelpers devdbg mobicore pychrysa python stackvars
diff --git a/plugins/devdbg/speed.c b/plugins/devdbg/speed.c
index 7f9705d..e5042ea 100644
--- a/plugins/devdbg/speed.c
+++ b/plugins/devdbg/speed.c
@@ -31,7 +31,6 @@
#include <plugins/plugin-def.h>
-#include <plugins/plugin-int.h>
diff --git a/plugins/devdbg/speed.h b/plugins/devdbg/speed.h
index bad7ba5..ba013f7 100644
--- a/plugins/devdbg/speed.h
+++ b/plugins/devdbg/speed.h
@@ -25,12 +25,8 @@
#define _PLUGINS_DEVDBG_SPEED_H
-#include <gmodule.h>
-
-#include <analysis/binary.h>
#include <plugins/plugin.h>
-#include <plugins/plugin-def.h>
-
+#include <plugins/plugin-int.h>
@@ -39,25 +35,4 @@ G_MODULE_EXPORT void process_binary_disassembly(const GPluginModule *, PluginAct
-
-
-#if 0
-#include <glib-object.h>
-#include <gmodule.h>
-#include <stdbool.h>
-
-
-
-
-/* Initialise le greffon pour les bornes de routine. */
-G_MODULE_EXPORT bool init_plugin(GObject *);
-
-/* Fournit une indication sur le type d'opération(s) menée(s). */
-G_MODULE_EXPORT PluginAction get_plugin_action(void);
-
-/* Exécute une action définie sur un binaire chargé. */
-G_MODULE_EXPORT bool execute_action_on_binary(GLoadedBinary *, PluginAction);
-#endif
-
-
#endif /* _PLUGINS_DEVDBG_SPEED_H */
diff --git a/plugins/mobicore/Makefile.am b/plugins/mobicore/Makefile.am
new file mode 100644
index 0000000..ee5cc66
--- /dev/null
+++ b/plugins/mobicore/Makefile.am
@@ -0,0 +1,17 @@
+
+lib_LTLIBRARIES = libmobicore.la
+
+libmobicore_la_SOURCES = \
+ annotations.h annotations.c \
+ mclf-def.h \
+ mclf-int.h mclf-int.c \
+ mclf.h mclf.c \
+ mobicore.h mobicore.c \
+ symbols.h symbols.c
+
+libmobicore_la_CFLAGS = $(AM_CFLAGS)
+
+
+AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) -I../../src
+
+AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS)
diff --git a/plugins/mobicore/annotations.c b/plugins/mobicore/annotations.c
new file mode 100644
index 0000000..94fecaf
--- /dev/null
+++ b/plugins/mobicore/annotations.c
@@ -0,0 +1,470 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * annotations.c - enregistrement des annotations liées au format MCLF
+ *
+ * Copyright (C) 2015 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * OpenIDA is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenIDA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include "annotations.h"
+
+
+#include <malloc.h>
+
+
+#include <i18n.h>
+#include <arch/raw.h>
+#include <common/extstr.h>
+
+
+#include "mclf-int.h"
+
+
+
+/* Place des annotations sur un descripteur de segment MCLF. */
+static bool annotate_mclf_segment_descriptor(GMCLFFormat *, const char *, vmpa2t *);
+
+/* Place des annotations sur le début commun du binaire MCLF. */
+static bool annotate_mclf_intro(GMCLFFormat *, vmpa2t *pos);
+
+/* Place des annotations sur l'en-tête v1 du binaire MCLF. */
+static bool annotate_mclf_header_v1(GMCLFFormat *, vmpa2t *pos);
+
+/* Place des annotations sur l'en-tête du segment de code. */
+static bool annotate_mclf_text_segment_header(GMCLFFormat *format, vmpa2t *);
+
+
+
+/******************************************************************************
+* *
+* Paramètres : format = description de l'exécutable à compléter. *
+* prefix = désignation du segment dans son ensemble. *
+* pos = tête de lecture à initialiser / faire évoluer. [OUT]*
+* *
+* Description : Place des annotations sur un descripteur de segment MCLF. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static bool annotate_mclf_segment_descriptor(GMCLFFormat *format, const char *prefix, vmpa2t *pos)
+{
+ GBinContent *content; /* Contenu binaire à lire */
+ GArchInstruction *instr; /* Instruction décodée */
+ char *text; /* Texte construit par étapes */
+ GDbComment *comment; /* Définition de commentaire */
+ GBinSymbol *symbol; /* Symbole à intégrer */
+
+ content = G_BIN_FORMAT(format)->conten_;
+
+ /* start */
+
+ instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, format->endian);
+
+ text = strdup(prefix);
+ text = stradd(text, _(": start address"));
+
+ ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, text);
+
+ free(text);
+
+ /* len */
+
+ instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, format->endian);
+
+ text = strdup(prefix);
+ text = stradd(text, _(": length"));
+
+ ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, text);
+
+ free(text);
+
+ return true;
+
+}
+
+
+
+/******************************************************************************
+* *
+* Paramètres : format = description de l'exécutable à compléter. *
+* pos = tête de lecture à initialiser / faire évoluer. [OUT]*
+* *
+* Description : Place des annotations sur le début commun du binaire MCLF. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static bool annotate_mclf_intro(GMCLFFormat *format, vmpa2t *pos)
+{
+ GBinContent *content; /* Contenu binaire à lire */
+ GArchInstruction *instr; /* Instruction décodée */
+ GArchOperand *operand; /* Opérande à venir modifier */
+ GDbComment *comment; /* Définition de commentaire */
+ GBinSymbol *symbol; /* Symbole à intégrer */
+
+ content = G_BIN_FORMAT(format)->conten_;
+
+ init_vmpa(pos, 0, format->header.v1.text.start);
+
+ /* magic */
+
+ instr = g_raw_instruction_new_array(content, MDS_8_BITS, 4, pos, format->endian);
+
+ SET_IMM_DISPLAY(instr, operand, 0, IOD_CHAR);
+ SET_IMM_DISPLAY(instr, operand, 1, IOD_CHAR);
+ SET_IMM_DISPLAY(instr, operand, 2, IOD_CHAR);
+ SET_IMM_DISPLAY(instr, operand, 3, IOD_CHAR);
+
+ ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, _("MCLF magic number"));
+
+ /* version */
+
+ instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, format->endian);
+
+ ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, _("Version"));
+
+ return true;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : format = description de l'exécutable à compléter. *
+* pos = tête de lecture à faire évoluer. [OUT] *
+* *
+* Description : Place des annotations sur l'en-tête v1 du binaire MCLF. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static bool annotate_mclf_header_v1(GMCLFFormat *format, vmpa2t *pos)
+{
+ GBinContent *content; /* Contenu binaire à lire */
+ GArchInstruction *instr; /* Instruction décodée */
+ GDbComment *comment; /* Définition de commentaire */
+ GBinSymbol *symbol; /* Symbole à intégrer */
+ const char *text; /* Commentaire variable */
+
+ content = G_BIN_FORMAT(format)->conten_;
+
+ /* flags */
+
+ instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, format->endian);
+
+ ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, _("Service flags"));
+
+ /* mem_type */
+
+ instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, format->endian);
+
+ switch (format->header.v1.mem_type)
+ {
+ case MCLF_MEM_TYPE_INTERNAL_PREFERRED:
+ text = _("Memory to use: internal if available, otherwise external memory");
+ break;
+ case MCLF_MEM_TYPE_INTERNAL:
+ text = _("Internal memory must be used for executing the service");
+ break;
+ case MCLF_MEM_TYPE_EXTERNAL:
+ text = _("External memory must be used for executing the service");
+ break;
+ default:
+ text = _("Unknown memory usage");
+ break;
+ }
+
+ ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, text);
+
+ /* service_type */
+
+ instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, format->endian);
+
+ switch (format->header.v1.service_type)
+ {
+ case SERVICE_TYPE_ILLEGAL:
+ text = _("Service type is invalid");
+ break;
+
+ case SERVICE_TYPE_DRIVER:
+ text = _("Service is a driver");
+ break;
+
+ case SERVICE_TYPE_SP_TRUSTLET:
+ text = _("Service is a Trustlet");
+ break;
+
+ case SERVICE_TYPE_SYSTEM_TRUSTLET:
+ text = _("Service is a system Trustlet");
+ break;
+ }
+
+ ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, text);
+
+ /* num_instances */
+
+ instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, format->endian);
+
+ ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, _("Number of instances which can be run simultaneously"));
+
+ /* uuid */
+
+ instr = g_raw_instruction_new_array(content, MDS_8_BITS, 16, pos, format->endian);
+
+ g_raw_instruction_mark_as_padding(G_RAW_INSTRUCTION(instr), true);
+
+ ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, _("Loadable service unique identifier (UUID)"));
+
+ /* driver_id */
+
+ instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, format->endian);
+
+ if (format->header.v1.service_type == SERVICE_TYPE_DRIVER)
+ text = _("Driver ID");
+ else
+ text = _("Unused Driver ID");
+
+ ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, _("Number of threads"));
+
+ /* num_threads */
+
+ instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, format->endian);
+
+ ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, _("Number of threads"));
+
+ /* text.start */
+
+ instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, format->endian);
+
+ ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, _("Virtual text segment: start address"));
+
+ /* text.len */
+
+ instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, format->endian);
+
+ ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, _("Virtual text segment: length"));
+
+ /* data.start */
+
+ instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, format->endian);
+
+ ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, _("Virtual data segment: start address"));
+
+ /* data.len */
+
+ instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, format->endian);
+
+ ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, _("Virtual data segment: length"));
+
+ /* bss_len */
+
+ instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, format->endian);
+
+ ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, _("Length of the BSS segment in bytes"));
+
+ /* entry */
+
+ instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, format->endian);
+
+ ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, _("Virtual start address of service code"));
+
+
+
+
+
+ /* service_version */
+
+ instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, format->endian);
+
+ ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, _("Version of the interface the driver exports"));
+
+
+
+
+ /* sip_id */
+
+ instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, format->endian);
+
+ ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, _("Silicon Provider ID"));
+
+ /* sip_data */
+
+ instr = g_raw_instruction_new_array(content, MDS_32_BITS, 3, pos, format->endian);
+
+ ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, _("Platform specific device identifier"));
+
+ /* permitted_hw_cfg */
+
+ instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, format->endian);
+
+ ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, _("Configuration which is allowed to execute binary"));
+
+
+ return true;
+
+}
+
+
+
+
+
+
+
+
+
+/******************************************************************************
+* *
+* Paramètres : format = description de l'exécutable à compléter. *
+* pos = tête de lecture à initialiser / faire évoluer. [OUT]*
+* *
+* Description : Place des annotations sur l'en-tête du segment de code. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static bool annotate_mclf_text_segment_header(GMCLFFormat *format, vmpa2t *pos)
+{
+ GBinContent *content; /* Contenu binaire à lire */
+ vmpa2t old; /* Position précédente */
+ phys_t diff; /* Décallage entre positions */
+ GArchInstruction *instr; /* Instruction décodée */
+ GDbComment *comment; /* Définition de commentaire */
+ GBinSymbol *symbol; /* Symbole à intégrer */
+
+ content = G_BIN_FORMAT(format)->conten_;
+
+ copy_vmpa(&old, pos);
+ init_vmpa(pos, 0x80, format->header.v1.text.start + 0x80);
+
+ diff = compute_vmpa_diff(&old, pos);
+
+ printf("DIFF : %u\n", (unsigned int)diff);
+
+ instr = g_raw_instruction_new_array(content, MDS_8_BITS, diff, &old, format->endian);
+
+ g_raw_instruction_mark_as_padding(G_RAW_INSTRUCTION(instr), true);
+
+ ADD_RAW_AS_SYM(format, symbol, &old, instr, comment, _("Padding"));
+
+ /* version */
+
+ instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, format->endian);
+
+ ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, _("Version of the TextHeader structure"));
+
+ /* text_header_len */
+
+ instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, format->endian);
+
+ ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, _("Size of this structure"));
+
+ /* required_feat */
+
+ instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, format->endian);
+
+ ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, _("Features that Mobicore must understand when loading"));
+
+ /* mc_lib_entry */
+
+ instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, format->endian);
+
+ ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, _("Address for McLib entry"));
+
+ /* mc_lib_data */
+
+ if (!annotate_mclf_segment_descriptor(format, _("Segment for McLib data"), pos))
+ return false;
+
+ //Segment for McLib data
+
+ /* mc_lib_base */
+
+ instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, format->endian);
+
+ ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, _("McLib base address"));
+
+ /* tl_api_vers */
+
+ instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, format->endian);
+
+ ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, _("TlApi version used when building trustlet"));
+
+ /* dr_api_vers */
+
+ instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, format->endian);
+
+ ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, _("DrApi version used when building trustlet"));
+
+ /* ta_properties */
+
+ instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, format->endian);
+
+ ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, _("Address of _TA_Properties in the TA"));
+
+ return true;
+
+}
+
+
+
+
+
+
+
+
+
+
+/******************************************************************************
+* *
+* Paramètres : format = description de l'exécutable à compléter. *
+* *
+* Description : Place des annotations sur le binaire MCLF. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool annotate_mclf_binary(GMCLFFormat *format)
+{
+ bool result; /* Bilan à retourner */
+ vmpa2t pos; /* Localisation des symboles */
+
+
+ result = annotate_mclf_intro(format, &pos);
+
+ result &= annotate_mclf_header_v1(format, &pos);
+
+ result &= annotate_mclf_text_segment_header(format, &pos);
+
+ return result;
+
+}
diff --git a/plugins/mobicore/annotations.h b/plugins/mobicore/annotations.h
new file mode 100644
index 0000000..2e06915
--- /dev/null
+++ b/plugins/mobicore/annotations.h
@@ -0,0 +1,40 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * annotations.h - prototypes pour l'enregistrement des annotations liées au format MCLF
+ *
+ * Copyright (C) 2015 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * OpenIDA is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenIDA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef _PLUGINS_MOBICORE_ANNOTATIONS_H
+#define _PLUGINS_MOBICORE_ANNOTATIONS_H
+
+
+#include <stdbool.h>
+
+
+#include "mclf.h"
+
+
+
+/*Place des annotations sur le binaire MCLF. */
+bool annotate_mclf_binary(GMCLFFormat *);
+
+
+
+#endif /* _PLUGINS_MOBICORE_ANNOTATIONS_H */
diff --git a/plugins/mobicore/mclf-def.h b/plugins/mobicore/mclf-def.h
new file mode 100644
index 0000000..c02d6c2
--- /dev/null
+++ b/plugins/mobicore/mclf-def.h
@@ -0,0 +1,222 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * mclf-def.h - liste des structures et constantes utilisées par le format MCLF
+ *
+ * Copyright (C) 2015 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * OpenIDA is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenIDA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef _PLUGINS_MOBICORE_MCLF_DEF_H
+#define _PLUGINS_MOBICORE_MCLF_DEF_H
+
+
+#include <stdint.h>
+
+
+
+/* ------------------------------ DECLARATIONS DE BASE ------------------------------ */
+
+
+#define MC_SERVICE_HEADER_MAGIC_STR "MCLF"
+
+
+/* En-tête de base */
+typedef struct _mclf_intro_t
+{
+ uint32_t magic; /* Valeur magique "MCLF" */
+ uint32_t version; /* Version de l'en-tête */
+
+} mclf_intro_t;
+
+
+
+/** Get major version number from complete version. */
+#define MC_GET_MAJOR_VERSION(version) ((version) >> 16)
+
+/** Get minor version number from complete version. */
+#define MC_GET_MINOR_VERSION(version) ((version) & 0xffff)
+
+
+
+/**
+ * Drapeaux MCLF
+ */
+
+/* Le service ne peut pas être déchargé depuis MobiCore */
+#define MC_SERVICE_HEADER_FLAGS_PERMANENT (1u << 0)
+
+/* Le service n'a pas d'interface de contrôle WSM */
+#define MC_SERVICE_HEADER_FLAGS_NO_CONTROL_INTERFACE (1u << 1)
+
+
+/* Adresse, physique ou virtuelle */
+typedef uint32_t mclf_addr_t;
+
+/* Types de service définissant l'exécutable */
+typedef enum service_type_t
+{
+ SERVICE_TYPE_ILLEGAL = 0, /* Type invalide */
+ SERVICE_TYPE_DRIVER = 1, /* Le service est un pilote */
+ SERVICE_TYPE_SP_TRUSTLET = 2, /* Le service est un Trustlet */
+ SERVICE_TYPE_SYSTEM_TRUSTLET = 3 /* Idem, mais Trustlet système */
+
+} service_type_t;
+
+/* Types de mémoire */
+typedef enum _mem_type_t
+{
+ MCLF_MEM_TYPE_INTERNAL_PREFERRED = 0, /* Mémoire interne si possible */
+ MCLF_MEM_TYPE_INTERNAL = 1, /* Mémoire d'exécution interne */
+ MCLF_MEM_TYPE_EXTERNAL = 2 /* Mémoire d'exécution externe */
+
+} mem_type_t;
+
+/* Description d'un segment mémoire */
+typedef struct segment_descriptor_t
+{
+ mclf_addr_t start; /* Adresse virtuelle de départ */
+ uint32_t len; /* Taille du segment */
+
+} segment_descriptor_t;
+
+
+
+/* ------------------------------ IDENTIFIANTS UNIQUES ------------------------------ */
+
+
+/* Identifiant sur 16 octets */
+typedef struct _mc_uuid_t
+{
+ uint8_t value[16]; /* Valeur de l'UUID */
+
+} mc_uuid_t;
+
+
+
+
+
+typedef enum {
+
+ TODO_
+
+} mc_driver_id_t;
+
+
+
+/* ----------------------------- DEFINITION VERSION N°1 ----------------------------- */
+
+
+/* En-tête associée */
+typedef struct _mclf_header_v1_t
+{
+ mclf_intro_t intro; /* Introduction obligatoire */
+ uint32_t flags; /* Indicateurs de service */
+ mem_type_t mem_type; /* Type de mémoire d'exécution */
+ service_type_t service_type; /* Type de service */
+
+ uint32_t num_instances; /* Nbre d'instances simultanées*/
+ mc_uuid_t uuid; /* Identifiant unique (UUID) */
+ mc_driver_id_t driver_id; /* Identifiant éventuel */
+ uint32_t num_threads; /* Nbre de threads du service */
+
+ segment_descriptor_t text; /* Segment virtuel de code */
+ segment_descriptor_t data; /* Segment virtuel de données */
+
+ uint32_t bss_len; /* Taille du segment BSS */
+ mclf_addr_t entry; /* Point d'entrée du service */
+
+} mclf_header_v1_t;
+
+
+
+/* ----------------------------- DEFINITION VERSION N°2 ----------------------------- */
+
+
+/* En-tête associée */
+typedef struct _mclf_header_v2_t
+{
+ mclf_intro_t intro; /* Introduction obligatoire */
+ uint32_t flags; /* Indicateurs de service */
+ mem_type_t mem_type; /* Type de mémoire d'exécution */
+ service_type_t service_type; /* Type de service */
+
+ uint32_t num_instances; /* Nbre d'instances simultanées*/
+ mc_uuid_t uuid; /* Identifiant unique (UUID) */
+ mc_driver_id_t driver_id; /* Identifiant éventuel */
+ uint32_t num_threads; /* Nbre de threads du service */
+
+ segment_descriptor_t text; /* Segment virtuel de code */
+ segment_descriptor_t data; /* Segment virtuel de données */
+
+ uint32_t bss_len; /* Taille du segment BSS */
+ mclf_addr_t entry; /* Point d'entrée du service */
+ uint32_t service_version; /* Version de l'interface */
+
+} mclf_header_v2_t;
+
+
+
+
+
+/* ------------------------------- DEFINITION GLOBALE ------------------------------- */
+/* ------------------------------- DEFINITION GLOBALE ------------------------------- */
+
+
+
+
+/**
+ * Version 2 MCLF text segment header.
+ * Required to be present in MobiCore 1.2 components at address (0x1080).
+ * This extension is initialized already at trustlet compile time,
+ * but may be modified later by configuration tools and by MobiCore at load time.
+ */
+typedef struct _mclf_text_header_t
+{
+ uint32_t version; /* Version de la structure */
+ uint32_t text_header_len; /* Taille de la structure */
+ uint32_t required_feat; /* Fonctionnalités requises */
+
+ uint32_t mc_lib_entry; /* Adresse d'entrée McLib */
+ segment_descriptor_t mc_lib_data; /* Segment pour McLib */
+ uint32_t mc_lib_base; /* Adresse de base pour McLib */
+
+ uint32_t tl_api_vers; /* Version TlApi utilisée */
+ uint32_t dr_api_vers; /* Version DrApi utilisée */
+ uint32_t ta_properties; /* Position de _TA_Properties */
+
+} mclf_text_header_t;
+
+
+
+
+
+/* ------------------------------- DEFINITION GLOBALE ------------------------------- */
+
+
+/* En-tête générique */
+typedef union _mclf_header_t
+{
+ mclf_intro_t intro; /* Base pour identification */
+ mclf_header_v1_t v1; /* En-tête version 1 */
+ mclf_header_v2_t v2; /* En-tête version 2 */
+
+} mclf_header_t;
+
+
+
+#endif /* _PLUGINS_MOBICORE_MCLF_DEF_H */
diff --git a/plugins/mobicore/mclf-int.c b/plugins/mobicore/mclf-int.c
new file mode 100644
index 0000000..2f2300d
--- /dev/null
+++ b/plugins/mobicore/mclf-int.c
@@ -0,0 +1,122 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * mclf-int.c - structures internes du format MCLF
+ *
+ * Copyright (C) 2015 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * OpenIDA is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenIDA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include "mclf-int.h"
+
+
+
+/******************************************************************************
+* *
+* Paramètres : format = informations chargées à consulter. *
+* header = en-tête à déterminer. [OUT] *
+* endian = boutisme reconnu dans le format. [OUT] *
+* *
+* Description : Procède à la lecture de l'en-tête d'un contenu binaire MCLF. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool read_mclf_header(GMCLFFormat *format, mclf_header_t *header, SourceEndian endian)
+{
+ bool result; /* Bilan à retourner */
+ GBinContent *content; /* Contenu binaire à lire */
+ vmpa2t pos; /* Position de lecture */
+
+ content = G_BIN_FORMAT(format)->conten_;
+
+ init_vmpa(&pos, 0, VMPA_NO_VIRTUAL);
+
+ result = g_binary_content_read_u32(content, &pos, endian, &header->intro.magic);
+ result &= g_binary_content_read_u32(content, &pos, endian, &header->intro.version);
+
+ printf("Version :: %u (%x)\n", header->intro.version, header->intro.version);
+
+
+ result &= g_binary_content_read_u32(content, &pos, endian, &header->v1.flags);
+ result &= g_binary_content_read_u32(content, &pos, endian, &header->v1.mem_type);
+ result &= g_binary_content_read_u32(content, &pos, endian, &header->v1.service_type);
+
+ printf("Mem type : 0x%08x\n", header->v1.mem_type);
+
+ result &= g_binary_content_read_u32(content, &pos, endian, &header->v1.num_instances);
+ result &= g_binary_content_get_raw(content, &pos, 16, (bin_t *)&header->v1.uuid);
+ result &= g_binary_content_read_u32(content, &pos, endian, &header->v1.driver_id);
+ result &= g_binary_content_read_u32(content, &pos, endian, &header->v1.num_threads);
+
+ printf("Num threads : 0x%08x\n", header->v1.num_threads);
+
+ result &= read_mclf_segment_desc(format, &header->v1.text, &pos, endian);
+
+ printf("TEXT :: 0x%08x + %u\n", header->v1.text.start, header->v1.text.len);
+
+ result &= read_mclf_segment_desc(format, &header->v1.data, &pos, endian);
+
+ printf("DATA :: 0x%08x + %u\n", header->v1.data.start, header->v1.data.len);
+
+
+ result &= g_binary_content_read_u32(content, &pos, endian, &header->v1.bss_len);
+ result &= g_binary_content_read_u32(content, &pos, endian, &header->v1.entry);
+
+ printf("ENTRY :: 0x%08x\n", header->v1.entry);
+
+
+
+ result &= g_binary_content_read_u32(content, &pos, endian, &header->v2.service_version);
+
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : format = informations chargées à consulter. *
+* segment = descripteur à déterminer. [OUT] *
+* pos = position de début de lecture. [OUT] *
+* endian = boutisme reconnu dans le format. [OUT] *
+* *
+* Description : Procède à la lecture d'un descripteur de segment MCLF. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool read_mclf_segment_desc(GMCLFFormat *format, segment_descriptor_t *segment, vmpa2t *pos, SourceEndian endian)
+{
+ bool result; /* Bilan à retourner */
+ GBinContent *content; /* Contenu binaire à lire */
+
+ content = G_BIN_FORMAT(format)->conten_;
+
+ result = g_binary_content_read_u32(content, pos, endian, &segment->start);
+ result &= g_binary_content_read_u32(content, pos, endian, &segment->len);
+
+ return result;
+
+}
diff --git a/plugins/mobicore/mclf-int.h b/plugins/mobicore/mclf-int.h
new file mode 100644
index 0000000..e34419b
--- /dev/null
+++ b/plugins/mobicore/mclf-int.h
@@ -0,0 +1,64 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * mclf-int.h - prototypes pour les structures internes du format MCLF
+ *
+ * Copyright (C) 2015 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * OpenIDA is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenIDA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef _PLUGINS_MOBICORE_MCLF_INT_H
+#define _PLUGINS_MOBICORE_MCLF_INT_H
+
+
+#include <common/endianness.h>
+#include <format/executable-int.h>
+
+
+#include "mclf.h"
+#include "mclf-def.h"
+
+
+
+/* Format d'exécutable MCLF (instance) */
+struct _GMCLFFormat
+{
+ GExeFormat parent; /* A laisser en premier */
+
+ mclf_header_t header; /* En-tête du format */
+ SourceEndian endian; /* Boutisme du format */
+
+};
+
+/* Format d'exécutable MCLF (classe) */
+struct _GMCLFFormatClass
+{
+ GExeFormatClass parent; /* A laisser en premier */
+
+};
+
+
+
+/* Procède à la lecture de l'en-tête d'un contenu binaire MCLF. */
+bool read_mclf_header(GMCLFFormat *, mclf_header_t *, SourceEndian);
+
+/* Procède à la lecture d'un descripteur de segment MCLF. */
+bool read_mclf_segment_desc(GMCLFFormat *, segment_descriptor_t *, vmpa2t *, SourceEndian);
+
+
+
+#endif /* _PLUGINS_MOBICORE_MCLF_INT_H */
diff --git a/plugins/mobicore/mclf.c b/plugins/mobicore/mclf.c
new file mode 100644
index 0000000..3fc9e21
--- /dev/null
+++ b/plugins/mobicore/mclf.c
@@ -0,0 +1,258 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * mclf.c - prise en compte du format binaire 'MCLF'
+ *
+ * Copyright (C) 2015 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * OpenIDA is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenIDA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include "mclf.h"
+
+
+#include <i18n.h>
+
+
+#include "annotations.h"
+#include "mclf-int.h"
+
+
+
+/* Taille maximale d'une description */
+#define MAX_PORTION_DESC 256
+
+
+
+/* Initialise la classe des formats d'exécutables MCLF. */
+static void g_mclf_format_class_init(GMCLFFormatClass *);
+
+/* Initialise une instance de format d'exécutable MCLF. */
+static void g_mclf_format_init(GMCLFFormat *);
+
+/* Indique le type d'architecture visée par le format. */
+static const char *g_mclf_format_get_target_machine(const GMCLFFormat *);
+
+/* Etend la définition des portions au sein d'un binaire. */
+static void g_mclf_format_refine_portions(const GMCLFFormat *, GBinPortion *);
+
+
+
+/******************************************************************************
+* *
+* Paramètres : content = contenu binaire à parcourir. *
+* *
+* Description : Indique si le format peut être pris en charge ici. *
+* *
+* Retour : true si la réponse est positive, false sinon. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool mclf_is_matching(GBinContent *content)
+{
+ bool result; /* Bilan à faire connaître */
+ vmpa2t addr; /* Tête de lecture initiale */
+ char magic[4]; /* Idenfiant standard */
+
+ init_vmpa(&addr, 0, VMPA_NO_VIRTUAL);
+
+ result = g_binary_content_get_raw(content, &addr, 4, (bin_t *)magic);
+
+ result &= (memcmp(magic, MC_SERVICE_HEADER_MAGIC_STR, 4) == 0);
+
+ return result;
+
+}
+
+
+/* Indique le type défini pour un format d'exécutable MCLF. */
+G_DEFINE_TYPE(GMCLFFormat, g_mclf_format, G_TYPE_EXE_FORMAT);
+
+
+/******************************************************************************
+* *
+* Paramètres : klass = classe à initialiser. *
+* *
+* Description : Initialise la classe des formats d'exécutables MCLF. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_mclf_format_class_init(GMCLFFormatClass *klass)
+{
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : format = instance à initialiser. *
+* *
+* Description : Initialise une instance de format d'exécutable MCLF. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_mclf_format_init(GMCLFFormat *format)
+{
+ GExeFormat *exe_format; /* Format parent à constituer */
+
+ exe_format = G_EXE_FORMAT(format);
+
+ exe_format->get_machine = (get_target_machine_fc)g_mclf_format_get_target_machine;
+ exe_format->refine_portions = (refine_portions_fc)g_mclf_format_refine_portions;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : content = contenu binaire à parcourir. *
+* *
+* Description : Prend en charge un nouveau format MCLF. *
+* *
+* Retour : Adresse de la structure mise en place ou NULL en cas d'échec.*
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GBinFormat *g_mclf_format_new(GBinContent *content)
+{
+ GMCLFFormat *result; /* Structure à retourner */
+
+ result = g_object_new(G_TYPE_MCLF_FORMAT, NULL);
+
+ g_binary_format_set_content(G_BIN_FORMAT(result), content);
+
+
+
+ if (!read_mclf_header(result, &result->header, result->endian))
+ {
+ /* TODO */
+ return NULL;
+ }
+
+
+
+ if (!load_mclf_symbols(result))
+ {
+ /* TODO */
+ return NULL;
+ }
+
+
+ if (!annotate_mclf_binary(result))
+ printf("ERRR\n");
+
+ return G_BIN_FORMAT(result);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : format = informations chargées à consulter. *
+* *
+* Description : Indique le type d'architecture visée par le format. *
+* *
+* Retour : Identifiant de l'architecture ciblée par le format. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static const char *g_mclf_format_get_target_machine(const GMCLFFormat *format)
+{
+ const char *result; /* Identifiant à retourner */
+
+ result = "armv7";
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : format = informations chargées à consulter. *
+* raw = portion de binaire brut à raffiner. *
+* *
+* Description : Etend la définition des portions au sein d'un binaire. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_mclf_format_refine_portions(const GMCLFFormat *format, GBinPortion *raw)
+{
+ GBinPortion *new; /* Nouvelle portion définie */
+ char desc[MAX_PORTION_DESC]; /* Description d'une portion */
+ vmpa2t addr; /* Emplacement dans le binaire */
+
+ /* Segment de code */
+
+ new = g_binary_portion_new(BPC_CODE);
+
+ sprintf(desc, "%s \"%s\"", _("Segment"), "text");
+ g_binary_portion_set_desc(new, desc);
+
+ init_vmpa(&addr, 0, format->header.v1.text.start);
+ g_binary_portion_set_values(new, &addr, format->header.v1.text.len);
+
+ g_binary_portion_set_rights(new, PAC_WRITE | PAC_EXEC);
+
+ g_binary_portion_include(raw, new);
+
+ /* Segment de données */
+
+ new = g_binary_portion_new(BPC_DATA);
+
+ sprintf(desc, "%s \"%s\"", _("Segment"), "data");
+ g_binary_portion_set_desc(new, desc);
+
+ init_vmpa(&addr, format->header.v1.text.len, format->header.v1.data.start);
+ g_binary_portion_set_values(new, &addr, format->header.v1.data.len);
+
+ g_binary_portion_set_rights(new, PAC_READ | PAC_WRITE);
+
+ g_binary_portion_include(raw, new);
+
+ /* Signature finale */
+
+ new = g_binary_portion_new(BPC_DATA);
+
+ sprintf(desc, "%s \"%s\"", _("Segment"), "sig");
+ g_binary_portion_set_desc(new, desc);
+
+ init_vmpa(&addr, G_BIN_FORMAT(format)->length - 521, VMPA_NO_VIRTUAL); /* FIXME */
+ g_binary_portion_set_values(new, &addr, 521);
+
+ g_binary_portion_set_rights(new, PAC_READ | PAC_WRITE);
+
+ g_binary_portion_include(raw, new);
+
+}
diff --git a/plugins/mobicore/mclf.h b/plugins/mobicore/mclf.h
new file mode 100644
index 0000000..c2752b8
--- /dev/null
+++ b/plugins/mobicore/mclf.h
@@ -0,0 +1,63 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * mclf.h - prototypes pour la prise en compte du format binaire 'MCLF'
+ *
+ * Copyright (C) 2015 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * OpenIDA is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenIDA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef _PLUGINS_MOBICORE_MCLF_H
+#define _PLUGINS_MOBICORE_MCLF_H
+
+
+#include <glib-object.h>
+#include <stdbool.h>
+#include <sys/types.h>
+
+
+#include <format/format.h>
+
+
+
+#define G_TYPE_MCLF_FORMAT (g_mclf_format_get_type())
+#define G_MCLF_FORMAT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_MCLF_FORMAT, GMCLFFormat))
+#define G_IS_MCLF_FORMAT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_MCLF_FORMAT))
+#define G_MCLF_FORMAT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_MCLF_FORMAT, GMCLFFormatClass))
+#define G_IS_MCLF_FORMAT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_MCLF_FORMAT))
+#define G_MCLF_FORMAT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_MCLF_FORMAT, GMCLFFormatClass))
+
+
+/* Format d'exécutable MCLF (instance) */
+typedef struct _GMCLFFormat GMCLFFormat;
+
+/* Format d'exécutable MCLF (classe) */
+typedef struct _GMCLFFormatClass GMCLFFormatClass;
+
+
+/* Indique si le format peut être pris en charge ici. */
+bool mclf_is_matching(GBinContent *);
+
+/* Indique le type défini pour un format d'exécutable MCLF. */
+GType g_mclf_format_get_type(void);
+
+/* Prend en charge un nouveau format MCLF. */
+GBinFormat *g_mclf_format_new(GBinContent *);
+
+
+
+#endif /* _PLUGINS_MOBICORE_MCLF_H */
diff --git a/plugins/mobicore/mobicore.c b/plugins/mobicore/mobicore.c
new file mode 100644
index 0000000..9f7b8a4
--- /dev/null
+++ b/plugins/mobicore/mobicore.c
@@ -0,0 +1,83 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * mobicore.c - support du format de chargement MobiCore
+ *
+ * Copyright (C) 2015 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * OpenIDA is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenIDA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include "mobicore.h"
+
+
+#include <core/formats.h>
+#include <plugins/plugin-def.h>
+
+
+#include "mclf.h"
+
+
+
+DEFINE_CHRYSALIDE_ACTIVE_PLUGIN("Mobicore", "Support MobiCore file format for Trusted Applications", "0.1.0",
+ PGA_PLUGIN_INIT, PGA_PLUGIN_EXIT);
+
+
+
+/******************************************************************************
+* *
+* Paramètres : plugin = greffon à manipuler. *
+* *
+* Description : Prend acte du chargement du greffon. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+G_MODULE_EXPORT bool chrysalide_plugin_init(GPluginModule *plugin)
+{
+ bool result; /* Bilan à retourner */
+
+ printf("Loaded !\n");
+
+ result = register_format_type("mclf", "MobiCore Load Format", mclf_is_matching, g_mclf_format_new);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : plugin = greffon à manipuler. *
+* *
+* Description : Prend acte du déchargement du greffon. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+G_MODULE_EXPORT void chrysalide_plugin_exit(GPluginModule *plugin)
+{
+
+ printf("Unloaded !\n");
+
+
+}
diff --git a/plugins/mobicore/mobicore.h b/plugins/mobicore/mobicore.h
new file mode 100644
index 0000000..d8687a1
--- /dev/null
+++ b/plugins/mobicore/mobicore.h
@@ -0,0 +1,41 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * mobicore.h - prototypes pour le support du format de chargement MobiCore
+ *
+ * Copyright (C) 2015 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * OpenIDA is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenIDA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef _PLUGINS_MOBICORE_MOBICORE_H
+#define _PLUGINS_MOBICORE_MOBICORE_H
+
+
+#include <plugins/plugin.h>
+#include <plugins/plugin-int.h>
+
+
+
+/* Prend acte du chargement du greffon. */
+G_MODULE_EXPORT bool chrysalide_plugin_init(GPluginModule *);
+
+/* Prend acte du déchargement du greffon. */
+G_MODULE_EXPORT void chrysalide_plugin_exit(GPluginModule *);
+
+
+
+#endif /* _PLUGINS_MOBICORE_MOBICORE_H */
diff --git a/plugins/mobicore/symbols.c b/plugins/mobicore/symbols.c
new file mode 100644
index 0000000..c718cfa
--- /dev/null
+++ b/plugins/mobicore/symbols.c
@@ -0,0 +1,145 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * symbols.c - gestion des symboles d'un MCLF
+ *
+ * Copyright (C) 2015 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * OpenIDA is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenIDA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include "symbols.h"
+
+
+#include <malloc.h>
+
+
+#include <format/mangling/demangler.h>
+
+
+#include "mclf-int.h"
+
+
+
+/* Enregistre un point d'entrée au sein d'un binaire MCLF. */
+static void register_mclf_entry_point(GMCLFFormat *, virt_t, phys_t, GBinRoutine *);
+
+/* Enumère les points d'entrée principaux d'un binaire MCLF. */
+static bool load_all_mclf_basic_entry_points(GMCLFFormat *format);
+
+
+
+/******************************************************************************
+* *
+* Paramètres : format = description de l'exécutable à compléter. *
+* vaddr = adresse virtuelle du symbole à insérer. *
+* len = taille de la routine à ajouter. *
+* routine = représentation de la fonction repérée. *
+* *
+* Description : Enregistre un point d'entrée au sein d'un binaire MCLF. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void register_mclf_entry_point(GMCLFFormat *format, virt_t vaddr, phys_t len, GBinRoutine *routine)
+{
+ GBinFormat *base; /* Version basique de l'instance */
+ vmpa2t addr; /* Localisation d'une routine */
+ mrange_t range; /* Couverture mémoire associée */
+ GBinSymbol *symbol; /* Nouveau symbole construit */
+
+ base = G_BIN_FORMAT(format);
+
+ /* Comptabilisation pour le désassemblage brut */
+
+ base->entry_points = (virt_t *)realloc(base->entry_points, ++base->ep_count * sizeof(virt_t));
+
+ base->entry_points[base->ep_count - 1] = vaddr;
+
+ /* Comptabilisation en tant que symbole */
+
+ vaddr &= ~0x1;
+
+ init_vmpa(&addr, vaddr - format->header.v1.text.start, vaddr);
+ init_vmpa(&addr, VMPA_NO_PHYSICAL, vaddr);
+
+ init_mrange(&range, &addr, len);
+
+ g_binary_routine_set_range(routine, &range);
+
+ symbol = g_binary_symbol_new(STP_ENTRY_POINT, "XXX", ~0);
+ g_binary_symbol_attach_routine(symbol, routine);
+ g_binary_format_add_symbol(base, symbol);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : format = description de l'exécutable à consulter. *
+* *
+* Description : Enumère les points d'entrée principaux d'un binaire MCLF. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static bool load_all_mclf_basic_entry_points(GMCLFFormat *format)
+{
+ virt_t ep; /* Point d'entrée détecté */
+ GBinRoutine *routine; /* Routine à associer à un pt. */
+
+ /* Point d'entrée principal éventuel */
+
+ ep = format->header.v1.entry;
+
+ if (ep != 0x0)
+ {
+ routine = try_to_demangle_routine("entry_point");
+ register_mclf_entry_point(format, ep, 0, routine);
+ }
+
+ return true;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : format = description de l'exécutable à compléter. *
+* *
+* Description : Charge en mémoire la liste humaine des symboles. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool load_mclf_symbols(GMCLFFormat *format)
+{
+ bool result; /* Bilan à retourner */
+
+ result = load_all_mclf_basic_entry_points(format);
+
+ return result;
+
+}
diff --git a/plugins/mobicore/symbols.h b/plugins/mobicore/symbols.h
new file mode 100644
index 0000000..c528994
--- /dev/null
+++ b/plugins/mobicore/symbols.h
@@ -0,0 +1,40 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * symbols.h - prototypes pour la gestion des symboles d'un MCLF
+ *
+ * Copyright (C) 2015 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * OpenIDA is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenIDA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef _PLUGINS_MOBICORE_SYMBOLS_H
+#define _PLUGINS_MOBICORE_SYMBOLS_H
+
+
+#include <stdbool.h>
+
+
+#include "mclf.h"
+
+
+
+/* Charge en mémoire la liste humaine des symboles. */
+bool load_mclf_symbols(GMCLFFormat *);
+
+
+
+#endif /* _PLUGINS_MOBICORE_SYMBOLS_H */
diff --git a/plugins/pychrysa/plugin.c b/plugins/pychrysa/plugin.c
index 0a27fa1..e1db3de 100644
--- a/plugins/pychrysa/plugin.c
+++ b/plugins/pychrysa/plugin.c
@@ -331,7 +331,7 @@ static PluginAction g_python_plugin_get_action(const GPythonPlugin *plugin)
Py_DECREF(value);
}
else
- result = PGA_NONE;
+ result = 0;//PGA_NONE;
return result;
@@ -581,8 +581,8 @@ static bool pychrysa_plugin_define_constants(PyObject *dict)
{
int ret; /* Bilan d'un ajout */
- ret = PyDict_SetItemString(dict, "PGA_NONE", PyInt_FromLong(PGA_NONE));
- if (ret == -1) return false;
+ //ret = PyDict_SetItemString(dict, "PGA_NONE", PyInt_FromLong(PGA_NONE));
+ //if (ret == -1) return false;
ret = PyDict_SetItemString(dict, "PGA_FORMAT_MATCHER", PyInt_FromLong(PGA_FORMAT_MATCHER));
if (ret == -1) return false;
@@ -669,7 +669,7 @@ static PyObject *pychrysa_plugin_init(PyObject *self, PyObject *args)
static PyObject *pychrysa_plugin_get_action(PyObject *self, PyObject *args)
{
- return PyInt_FromLong(PGA_NONE);
+ return PyInt_FromLong(0/*PGA_NONE*/);
}
diff --git a/plugins/pychrysa/pychrysa.c b/plugins/pychrysa/pychrysa.c
index 2b8202e..00856f3 100644
--- a/plugins/pychrysa/pychrysa.c
+++ b/plugins/pychrysa/pychrysa.c
@@ -229,7 +229,7 @@ PluginAction get_plugin_action(const GPluginModule *plugin)
{
PluginAction result; /* Combinaison à retourner */
- result = PGA_NONE;
+ //result = PGA_NONE;
return result;