summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2018-11-13 21:42:10 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2018-11-13 21:42:10 (GMT)
commit23bc425f9c35c31a80d65d824452c8728614a206 (patch)
tree71b1c9762fee17f85648bf210a88adad5ab60052
parent65e12afde4bd9cd32e206f874cfa378708248918 (diff)
Exported extra processor features.
-rw-r--r--plugins/pychrysalide/arch/processor.c113
-rw-r--r--src/analysis/disass/area.c26
-rw-r--r--src/arch/processor.c4
-rw-r--r--src/arch/processor.h2
4 files changed, 141 insertions, 4 deletions
diff --git a/plugins/pychrysalide/arch/processor.c b/plugins/pychrysalide/arch/processor.c
index 6466fc9..7ff374b 100644
--- a/plugins/pychrysalide/arch/processor.c
+++ b/plugins/pychrysalide/arch/processor.c
@@ -49,6 +49,15 @@
/* ---------------------------- DEFINITION DE PROCESSEUR ---------------------------- */
+/* Fournit le boustime du processeur d'une architecture. */
+static PyObject *py_arch_processor_get_endianness(PyObject *, void *);
+
+/* Fournit la taille de l'espace mémoire d'une architecture. */
+static PyObject *py_arch_processor_get_memory_size(PyObject *, void *);
+
+/* Fournit la taille min. des instructions d'une architecture. */
+static PyObject *py_arch_processor_get_instruction_min_size(PyObject *, void *);
+
/* Indique si l'architecture possède un espace virtuel ou non. */
static PyObject *py_arch_processor_has_virtual_space(PyObject *, void *);
@@ -91,10 +100,102 @@ static bool define_python_arch_processor_constants(PyTypeObject *);
+/* ---------------------------------------------------------------------------------- */
+/* DEFINITION DE PROCESSEUR */
+/* ---------------------------------------------------------------------------------- */
+
+/******************************************************************************
+* *
+* Paramètres : self = objet Python concerné par l'appel. *
+* closure = non utilisé ici. *
+* *
+* Description : Fournit le boustime du processeur d'une architecture. *
+* *
+* Retour : Boutisme associé au processeur. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+static PyObject *py_arch_processor_get_endianness(PyObject *self, void *closure)
+{
+ PyObject *result; /* Instance Python à retourner */
+ GArchProcessor *proc; /* Version GLib de l'opérande */
+ SourceEndian endianness; /* Boutisme du processeur */
+ proc = G_ARCH_PROCESSOR(pygobject_get(self));
+ assert(proc != NULL);
+ endianness = g_arch_processor_get_endianness(proc);
+
+ result = Py_BuildValue("I", endianness);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : self = objet Python concerné par l'appel. *
+* closure = non utilisé ici. *
+* *
+* Description : Fournit la taille de l'espace mémoire d'une architecture. *
+* *
+* Retour : Taille de l'espace mémoire. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *py_arch_processor_get_memory_size(PyObject *self, void *closure)
+{
+ PyObject *result; /* Instance Python à retourner */
+ GArchProcessor *proc; /* Version GLib de l'opérande */
+ MemoryDataSize size; /* Type de donnée représentée */
+
+ proc = G_ARCH_PROCESSOR(pygobject_get(self));
+ assert(proc != NULL);
+
+ size = g_arch_processor_get_memory_size(proc);
+
+ result = Py_BuildValue("I", size);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : self = objet Python concerné par l'appel. *
+* closure = non utilisé ici. *
+* *
+* Description : Fournit la taille min. des instructions d'une architecture. *
+* *
+* Retour : Taille d'encodage des instructions. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *py_arch_processor_get_instruction_min_size(PyObject *self, void *closure)
+{
+ PyObject *result; /* Instance Python à retourner */
+ GArchProcessor *proc; /* Version GLib de l'opérande */
+ MemoryDataSize size; /* Type de donnée représentée */
+
+ proc = G_ARCH_PROCESSOR(pygobject_get(self));
+ assert(proc != NULL);
+
+ size = g_arch_processor_get_instruction_min_size(proc);
+
+ result = Py_BuildValue("I", size);
+
+ return result;
+
+}
/******************************************************************************
@@ -440,6 +541,18 @@ PyTypeObject *get_python_arch_processor_type(void)
static PyGetSetDef py_arch_processor_getseters[] = {
{
+ "endianness", py_arch_processor_get_endianness, NULL,
+ "Provide the processor endianness.", NULL
+ },
+ {
+ "mem_size", py_arch_processor_get_memory_size, NULL,
+ "Provide the size of memory addresses for the given architecture.", NULL
+ },
+ {
+ "ins_min_size", py_arch_processor_get_instruction_min_size, NULL,
+ "Provide the minimal size of one processor instruction.", NULL
+ },
+ {
"virtual_space", py_arch_processor_has_virtual_space, NULL,
"Tell if the processor provides a virtual address space.", NULL
},
diff --git a/src/analysis/disass/area.c b/src/analysis/disass/area.c
index 2dca001..0a82b99 100644
--- a/src/analysis/disass/area.c
+++ b/src/analysis/disass/area.c
@@ -286,7 +286,31 @@ static void init_mem_area_from_addr(mem_area *area, const vmpa2t *addr, phys_t l
area->content = g_restricted_content_new(content, &area->range);
- area->packing_size = 2; /* FIXME */
+ switch (g_arch_processor_get_instruction_min_size(area->proc))
+ {
+ case MDS_4_BITS:
+ case MDS_8_BITS:
+ area->packing_size = 1;
+ break;
+
+ case MDS_16_BITS:
+ area->packing_size = 2;
+ break;
+
+ case MDS_32_BITS:
+ area->packing_size = 4;
+ break;
+
+ case MDS_64_BITS:
+ area->packing_size = 8;
+ break;
+
+ default:
+ assert(false);
+ area->packing_size = 1;
+ break;
+
+ }
area->processed = create_bit_field(len, false);
area->instructions = (GArchInstruction **)calloc(len, sizeof(GArchInstruction *));
diff --git a/src/arch/processor.c b/src/arch/processor.c
index 06f9c2f..4450208 100644
--- a/src/arch/processor.c
+++ b/src/arch/processor.c
@@ -297,13 +297,13 @@ MemoryDataSize g_arch_processor_get_memory_size(const GArchProcessor *proc)
* *
* Description : Fournit la taille min. des instructions d'une architecture. *
* *
-* Retour : Taille d'encodage des instructions *
+* Retour : Taille d'encodage des instructions. *
* *
* Remarques : - *
* *
******************************************************************************/
-MemoryDataSize g_arch_processor_get_instruction_size(const GArchProcessor *proc)
+MemoryDataSize g_arch_processor_get_instruction_min_size(const GArchProcessor *proc)
{
return proc->inssize;
diff --git a/src/arch/processor.h b/src/arch/processor.h
index 762d547..24d9287 100644
--- a/src/arch/processor.h
+++ b/src/arch/processor.h
@@ -65,7 +65,7 @@ SourceEndian g_arch_processor_get_endianness(const GArchProcessor *);
MemoryDataSize g_arch_processor_get_memory_size(const GArchProcessor *);
/* Fournit la taille min. des instructions d'une architecture. */
-MemoryDataSize g_arch_processor_get_instruction_size(const GArchProcessor *);
+MemoryDataSize g_arch_processor_get_instruction_min_size(const GArchProcessor *);
/* Indique si l'architecture possède un espace virtuel ou non. */
bool g_arch_processor_has_virtual_space(const GArchProcessor *);