diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2019-05-12 22:09:53 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2019-05-12 22:09:53 (GMT) |
commit | 00e93226e72bdb18853580f553e32df111422936 (patch) | |
tree | 9c346903d4506cae2df19b9314cf307c783c0cb3 /plugins/pychrysalide | |
parent | e44ffc323c8a9d4b446baba6e0b131107312fa84 (diff) |
Simplified the way processors are registered.
Diffstat (limited to 'plugins/pychrysalide')
-rw-r--r-- | plugins/pychrysalide/arch/processor.c | 33 | ||||
-rw-r--r-- | plugins/pychrysalide/core/processors.c | 63 | ||||
-rw-r--r-- | plugins/pychrysalide/format/executable.c | 2 |
3 files changed, 27 insertions, 71 deletions
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) { |