diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2018-10-27 22:54:30 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2018-10-27 22:54:30 (GMT) |
commit | ce27af7f442d1fa580311eac83bc44d7db4e0d05 (patch) | |
tree | 64a897f76e84ef401a0d5987eb56422e95606b09 /plugins/pychrysalide/format/executable.c | |
parent | 7932fbf156fc357139638a342a46189450f7f484 (diff) |
Accepted integer values as usable addresses for some Python bindings.
Diffstat (limited to 'plugins/pychrysalide/format/executable.c')
-rw-r--r-- | plugins/pychrysalide/format/executable.c | 82 |
1 files changed, 81 insertions, 1 deletions
diff --git a/plugins/pychrysalide/format/executable.c b/plugins/pychrysalide/format/executable.c index 8e24699..0346ecb 100644 --- a/plugins/pychrysalide/format/executable.c +++ b/plugins/pychrysalide/format/executable.c @@ -28,16 +28,21 @@ #include <pygobject.h> -#include <format/executable.h> +#include <i18n.h> +#include <core/processors.h> #include "format.h" #include "../access.h" #include "../helpers.h" +#include "../arch/processor.h" #include "../arch/vmpa.h" +/* ------------------------ DECLARATION DE FORMAT EXECUTABLE ------------------------ */ + + /* Fournit l'emplacement correspondant à une position physique. */ static PyObject *py_exe_format_translate_offset_into_vmpa(PyObject *, PyObject *); @@ -46,6 +51,11 @@ static PyObject *py_exe_format_translate_address_into_vmpa(PyObject *, PyObject +/* ---------------------------------------------------------------------------------- */ +/* DECLARATION DE FORMAT EXECUTABLE */ +/* ---------------------------------------------------------------------------------- */ + + /****************************************************************************** * * * Paramètres : self = description de l'exécutable à consulter. * @@ -224,3 +234,73 @@ bool ensure_python_executable_format_is_registered(void) return true; } + + + +/* ---------------------------------------------------------------------------------- */ +/* TRADUCTION D'EMPLACEMENT */ +/* ---------------------------------------------------------------------------------- */ + + +/****************************************************************************** +* * +* Paramètres : obj = objet Python à convertir en emplacement. * +* info = informations utiles à l'opération. * +* * +* Description : Réalise une conversion d'un objet Python en localisation. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +int convert_to_vmpa_using_executable(PyObject *obj, exe_cv_info_t *info) +{ + int result; /* Bilan à retourner */ + int ret; /* Bilan d'une consultation */ + const char *arch; /* Architecture d'exécution */ + proc_cv_info_t conv; /* Informations de conversion */ + + ret = PyObject_IsInstance(obj, (PyObject *)get_python_vmpa_type()); + + if (ret) + { + info->vmpa = get_internal_vmpa(obj); + result = 1; + } + + else if (info->format != NULL) + { + arch = g_exe_format_get_target_machine(info->format); + + conv.proc = get_arch_processor_for_type(arch); + + if (conv.proc != NULL) + { + result = convert_to_vmpa_using_processor(obj, &conv); + + if (result == 1) + { + info->vmpa = conv.vmpa; + copy_vmpa(&info->tmp, &conv.tmp); + } + + g_object_unref(G_OBJECT(conv.proc)); + + } + + else + result = 0; + + } + + else + result = 0; + + if (result == 0) + PyErr_Format(PyExc_TypeError, _("unable to convert object to VMPA location")); + + return result; + +} |