summaryrefslogtreecommitdiff
path: root/plugins/mobicore/mclf-int.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2015-02-16 07:07:15 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2015-02-16 07:07:15 (GMT)
commit635640a32fecbb9b8a5ddf239b819c022c4b9977 (patch)
treef8fc69a2c2db411000996146536ca5cc4f54d417 /plugins/mobicore/mclf-int.c
parentbf879f2562545ab7de23f9d38364b7bd4b43fb2c (diff)
Added a basic support for Mobicore truslets.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@472 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'plugins/mobicore/mclf-int.c')
-rw-r--r--plugins/mobicore/mclf-int.c122
1 files changed, 122 insertions, 0 deletions
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;
+
+}