summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2019-05-12 22:09:53 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2019-05-12 22:09:53 (GMT)
commit00e93226e72bdb18853580f553e32df111422936 (patch)
tree9c346903d4506cae2df19b9314cf307c783c0cb3 /plugins
parente44ffc323c8a9d4b446baba6e0b131107312fa84 (diff)
Simplified the way processors are registered.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/arm/v7/core.c2
-rw-r--r--plugins/arm/v7/processor.c21
-rw-r--r--plugins/dalvik/processor.c13
-rw-r--r--plugins/dalvik/v35/core.c2
-rw-r--r--plugins/dalvik/v35/processor.c3
-rw-r--r--plugins/pychrysalide/arch/processor.c33
-rw-r--r--plugins/pychrysalide/core/processors.c63
-rw-r--r--plugins/pychrysalide/format/executable.c2
-rw-r--r--plugins/ropgadgets/finder.c2
9 files changed, 49 insertions, 92 deletions
diff --git a/plugins/arm/v7/core.c b/plugins/arm/v7/core.c
index 5fd355c..6849171 100644
--- a/plugins/arm/v7/core.c
+++ b/plugins/arm/v7/core.c
@@ -106,7 +106,7 @@ bool init_armv7_core(void)
register_armv7_gtypes();
- result = register_processor_type("armv7", "ARM v7", G_TYPE_ARMV7_PROCESSOR);
+ result = register_processor_type(G_TYPE_ARMV7_PROCESSOR);
return result;
diff --git a/plugins/arm/v7/processor.c b/plugins/arm/v7/processor.c
index b7a73f4..fca1415 100644
--- a/plugins/arm/v7/processor.c
+++ b/plugins/arm/v7/processor.c
@@ -96,11 +96,20 @@ static void g_armv7_processor_class_init(GArmV7ProcessorClass *klass)
GArchProcessorClass *proc; /* Encore une autre vision... */
object_class = G_OBJECT_CLASS(klass);
- proc = G_ARCH_PROCESSOR_CLASS(klass);
object_class->dispose = (GObjectFinalizeFunc/* ! */)g_armv7_processor_dispose;
object_class->finalize = (GObjectFinalizeFunc)g_armv7_processor_finalize;
+ proc = G_ARCH_PROCESSOR_CLASS(klass);
+
+ proc->key = "armv7";
+ proc->desc = "ARM v7";
+
+ proc->endianness = SRE_LITTLE;
+ proc->memsize = MDS_32_BITS;
+ proc->inssize = MDS_32_BITS;
+ proc->virt_space = true;
+
proc->get_ctx = (get_processor_context_fc)g_armv7_processor_get_context;
proc->disassemble = (disass_instr_fc)g_armv7_processor_disassemble;
@@ -122,14 +131,6 @@ static void g_armv7_processor_class_init(GArmV7ProcessorClass *klass)
static void g_armv7_processor_init(GArmV7Processor *proc)
{
- GArchProcessor *parent; /* Instance parente */
-
- parent = G_ARCH_PROCESSOR(proc);
-
- parent->endianness = SRE_LITTLE;
- parent->memsize = MDS_32_BITS;
- parent->inssize = MDS_32_BITS;
- parent->virt_space = true;
}
@@ -238,7 +239,7 @@ static GArchInstruction *g_armv7_processor_disassemble(const GArmV7Processor *pr
uint32_t raw32; /* Donnée 32 bits à analyser */
ArmV7InstrSet iset; /* Type de jeu d'instructions */
- endian = G_ARCH_PROCESSOR(proc)->endianness;
+ endian = G_ARCH_PROCESSOR_GET_CLASS(proc)->endianness;
iset = g_armv7_context_find_encoding(ctx, get_virt_addr(pos));
diff --git a/plugins/dalvik/processor.c b/plugins/dalvik/processor.c
index 5c5ecb6..429c431 100644
--- a/plugins/dalvik/processor.c
+++ b/plugins/dalvik/processor.c
@@ -83,6 +83,11 @@ static void g_dalvik_processor_class_init(GDalvikProcessorClass *klass)
proc = G_ARCH_PROCESSOR_CLASS(klass);
+ proc->endianness = SRE_LITTLE;
+ proc->memsize = MDS_32_BITS;
+ proc->inssize = MDS_16_BITS;
+ proc->virt_space = false;
+
proc->get_ctx = (get_processor_context_fc)g_dalvik_processor_get_context;
}
@@ -102,14 +107,6 @@ static void g_dalvik_processor_class_init(GDalvikProcessorClass *klass)
static void g_dalvik_processor_init(GDalvikProcessor *proc)
{
- GArchProcessor *parent; /* Instance parente */
-
- parent = G_ARCH_PROCESSOR(proc);
-
- parent->endianness = SRE_LITTLE;
- parent->memsize = MDS_32_BITS;
- parent->inssize = MDS_16_BITS;
- parent->virt_space = false;
}
diff --git a/plugins/dalvik/v35/core.c b/plugins/dalvik/v35/core.c
index 7e36691..1ecaf82 100644
--- a/plugins/dalvik/v35/core.c
+++ b/plugins/dalvik/v35/core.c
@@ -74,7 +74,7 @@ bool init_dalvik35_core(void)
register_dalvik35_gtypes();
- result = register_processor_type("dalvik35", "Dalvik Virtual Machine v35", G_TYPE_DALVIK35_PROCESSOR);
+ result = register_processor_type(G_TYPE_DALVIK35_PROCESSOR);
return result;
diff --git a/plugins/dalvik/v35/processor.c b/plugins/dalvik/v35/processor.c
index b1c13d2..507373b 100644
--- a/plugins/dalvik/v35/processor.c
+++ b/plugins/dalvik/v35/processor.c
@@ -97,6 +97,9 @@ static void g_dalvik35_processor_class_init(GDalvik35ProcessorClass *klass)
proc = G_ARCH_PROCESSOR_CLASS(klass);
+ proc->key = "dalvik35";
+ proc->desc = "Dalvik Virtual Machine v35";
+
proc->disassemble = (disass_instr_fc)g_dalvik35_processor_disassemble;
}
diff --git a/plugins/pychrysalide/arch/processor.c b/plugins/pychrysalide/arch/processor.c
index 94ba7df..f356a91 100644
--- a/plugins/pychrysalide/arch/processor.c
+++ b/plugins/pychrysalide/arch/processor.c
@@ -208,6 +208,23 @@ static PyObject *py_arch_processor_new(PyTypeObject *type, PyObject *args, PyObj
static void py_arch_processor_init_gclass(GArchProcessorClass *class, gpointer unused)
{
+ GType type; /* Type d'instances concerné */
+ GArchProcessor *pattern; /* Patron de données à copier */
+
+ type = G_TYPE_FROM_CLASS(class);
+
+ pattern = get_dynamic_type_pattern(type);
+
+ if (pattern != NULL)
+ {
+ /*
+ class->endianness = pattern->endianness;
+ class->memsize = pattern->memsize;
+ class->inssize = pattern->inssize;
+ class->virt_space = pattern->virt_space;
+ */
+ }
+
class->get_ctx = py_arch_processor_get_context_wrapper;
class->disassemble = py_arch_processor_disassemble_wrapper;
@@ -230,20 +247,6 @@ static void py_arch_processor_init_gclass(GArchProcessorClass *class, gpointer u
static void py_arch_processor_init_ginstance(GArchProcessor *proc, GArchProcessor *class)
{
- GType type; /* Type d'instances concerné */
- GArchProcessor *pattern; /* Patron de données à copier */
-
- type = G_TYPE_FROM_INSTANCE(proc);
-
- pattern = get_dynamic_type_pattern(type);
-
- if (pattern != NULL)
- {
- proc->endianness = pattern->endianness;
- proc->memsize = pattern->memsize;
- proc->inssize = pattern->inssize;
- proc->virt_space = pattern->virt_space;
- }
}
@@ -294,10 +297,12 @@ static int py_arch_processor_init(PyObject *self, PyObject *args, PyObject *kwds
proc = G_ARCH_PROCESSOR(pygobject_get(self));
+ /*
proc->endianness = endianness;
proc->memsize = mem_size;
proc->inssize = ins_min_size;
proc->virt_space = vspace;
+ */
register_dynamic_type_pattern(G_OBJECT(proc));
diff --git a/plugins/pychrysalide/core/processors.c b/plugins/pychrysalide/core/processors.c
index 56498f3..47e4643 100644
--- a/plugins/pychrysalide/core/processors.c
+++ b/plugins/pychrysalide/core/processors.c
@@ -43,11 +43,8 @@
/* Enregistre un processeur pour une architecture donnée. */
static PyObject *py_processors_register_type(PyObject *, PyObject *);
-/* Fournit le nom humain de l'architecture visée. */
-static PyObject *py_processors_get_description(PyObject *, PyObject *);
-
/* Fournit le processeur d'architecture correspondant à un nom. */
-static PyObject *py_processors_get_for_name(PyObject *, PyObject *);
+static PyObject *py_processors_get_for_key(PyObject *, PyObject *);
@@ -67,8 +64,6 @@ static PyObject *py_processors_get_for_name(PyObject *, PyObject *);
static PyObject *py_processors_register_type(PyObject *self, PyObject *args)
{
PyObject *result; /* Bilan à retourner */
- const char *name; /* Nom technique de processeur */
- const char *desc; /* description humaine liée */
PyObject *type; /* Type d'une instance future */
int ret; /* Bilan de lecture des args. */
PyObject *new_args; /* Nouveaux arguments épurés */
@@ -77,7 +72,7 @@ static PyObject *py_processors_register_type(PyObject *self, PyObject *args)
GType instance; /* Type pour futures instances */
bool status; /* Bilan d'un enregistrement */
- ret = PyArg_ParseTuple(args, "ssO!", &name, &desc, &PyType_Type, &type);
+ ret = PyArg_ParseTuple(args, "O!", &PyType_Type, &type);
if (!ret) return NULL;
ret = PyObject_IsSubclass(type, (PyObject *)get_python_arch_processor_type());;
@@ -112,7 +107,7 @@ static PyObject *py_processors_register_type(PyObject *self, PyObject *args)
Py_DECREF(dummy);
- status = register_processor_type(name, desc, instance);
+ status = register_processor_type(instance);
result = status ? Py_True : Py_False;
Py_INCREF(result);
@@ -127,45 +122,6 @@ static PyObject *py_processors_register_type(PyObject *self, PyObject *args)
* Paramètres : self = objet Python concerné par l'appel. *
* args = arguments fournis à l'appel. *
* *
-* Description : Fournit le nom humain de l'architecture visée. *
-* *
-* Retour : Désignation humaine trouvée ou NULL. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static PyObject *py_processors_get_description(PyObject *self, PyObject *args)
-{
- PyObject *result; /* Bilan à retourner */
- const char *name; /* Nom technique de processeur */
- int ret; /* Bilan de lecture des args. */
- const char *desc; /* Description humaine obtenue */
-
- ret = PyArg_ParseTuple(args, "s", &name);
- if (!ret) return NULL;
-
- desc = get_arch_processor_description(name);
-
- if (desc != NULL)
- result = PyUnicode_FromString(desc);
-
- else
- {
- result = Py_None;
- Py_INCREF(result);
- }
-
- return result;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : self = objet Python concerné par l'appel. *
-* args = arguments fournis à l'appel. *
-* *
* Description : Fournit le processeur d'architecture correspondant à un nom. *
* *
* Retour : Processeur d'architecture trouvé. *
@@ -174,7 +130,7 @@ static PyObject *py_processors_get_description(PyObject *self, PyObject *args)
* *
******************************************************************************/
-static PyObject *py_processors_get_for_name(PyObject *self, PyObject *args)
+static PyObject *py_processors_get_for_key(PyObject *self, PyObject *args)
{
PyObject *result; /* Bilan à retourner */
const char *name; /* Nom technique de processeur */
@@ -184,7 +140,7 @@ static PyObject *py_processors_get_for_name(PyObject *self, PyObject *args)
ret = PyArg_ParseTuple(args, "s", &name);
if (!ret) return NULL;
- proc = get_arch_processor_for_name(name);
+ proc = get_arch_processor_for_key(name);
if (proc != NULL)
{
@@ -226,14 +182,9 @@ bool populate_core_module_with_processors(void)
"register_processor(name, desc, cls, /)\n--\n\nRegister an an architecture processor by its name, description and class type."
},
{
- "get_processor_description", py_processors_get_description,
- METH_VARARGS,
- "get_processor_description(name, /)\n--\n\nProvide the description of a given architecture processor."
- },
- {
- "get_processor_for_name", py_processors_get_for_name,
+ "get_processor_for_key", py_processors_get_for_key,
METH_VARARGS,
- "get_processor_for_name(name, /)\n--\n\nProvide an instance of an architecture processor for a given name."
+ "get_processor_for_key(name, /)\n--\n\nProvide an instance of an architecture processor for a given name."
},
{ NULL }
diff --git a/plugins/pychrysalide/format/executable.c b/plugins/pychrysalide/format/executable.c
index 5621d26..f49a459 100644
--- a/plugins/pychrysalide/format/executable.c
+++ b/plugins/pychrysalide/format/executable.c
@@ -361,7 +361,7 @@ int convert_to_vmpa_using_executable(PyObject *obj, exe_cv_info_t *info)
{
arch = g_exe_format_get_target_machine(info->format);
- conv.proc = get_arch_processor_for_name(arch);
+ conv.proc = get_arch_processor_for_key(arch);
if (conv.proc != NULL)
{
diff --git a/plugins/ropgadgets/finder.c b/plugins/ropgadgets/finder.c
index b9a4500..5d0e9c2 100644
--- a/plugins/ropgadgets/finder.c
+++ b/plugins/ropgadgets/finder.c
@@ -387,7 +387,7 @@ found_rop_list *list_all_gadgets(GExeFormat *format, unsigned int max_depth, upd
domain.content = g_binary_format_get_content(G_BIN_FORMAT(format));
target = g_exe_format_get_target_machine(format);
- domain.proc = get_arch_processor_for_name(target);
+ domain.proc = get_arch_processor_for_key(target);
bool collect_x_ranges(GBinPortion *portion, GBinPortion *parent, BinaryPortionVisit visit, void *unused)
{