diff options
Diffstat (limited to 'plugins/dex')
-rw-r--r-- | plugins/dex/Makefile.am | 28 | ||||
-rw-r--r-- | plugins/dex/core.c | 7 | ||||
-rw-r--r-- | plugins/dex/loading.h | 4 | ||||
-rw-r--r-- | plugins/dex/pool.c | 35 | ||||
-rw-r--r-- | plugins/dex/python/Makefile.am | 27 | ||||
-rw-r--r-- | plugins/dex/python/class.c | 6 | ||||
-rw-r--r-- | plugins/dex/python/field.c | 6 | ||||
-rw-r--r-- | plugins/dex/python/format.c | 5 | ||||
-rw-r--r-- | plugins/dex/python/method.c | 6 | ||||
-rw-r--r-- | plugins/dex/python/pool.c | 2 | ||||
-rw-r--r-- | plugins/dex/python/routine.c | 5 |
11 files changed, 83 insertions, 48 deletions
diff --git a/plugins/dex/Makefile.am b/plugins/dex/Makefile.am index 8eb7bde..a587fe2 100644 --- a/plugins/dex/Makefile.am +++ b/plugins/dex/Makefile.am @@ -35,21 +35,23 @@ PYTHON3_SUBDIRS = python endif -libdex_la_SOURCES = \ - core.h core.c \ - class.h class.c \ - dex-int.h dex-int.c \ - dex_def.h \ - field.h field.c \ - format.h format.c \ - loading.h loading.c \ - method.h method.c \ - pool.h pool.c \ +libdex_la_SOURCES = \ + core.h core.c \ + class.h class.c \ + dex-int.h dex-int.c \ + dex_def.h \ + field.h field.c \ + format.h format.c \ + loading.h loading.c \ + method.h method.c \ + pool.h pool.c \ routine.h routine.c -libdex_la_LIBADD = \ +libdex_la_LIBADD = \ $(PYTHON3_LIBADD) +libdex_la_CFLAGS = $(TOOLKIT_CFLAGS) $(LIBXML_CFLAGS) -I$(top_srcdir)/src + libdex_la_LDFLAGS = \ -avoid-version \ -L$(top_srcdir)/src/.libs -lchrysacore \ @@ -61,8 +63,4 @@ devdir = $(includedir)/chrysalide/$(subdir) dev_HEADERS = $(libdex_la_SOURCES:%c=) -AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) -I$(top_srcdir)/src - -AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS) - SUBDIRS = $(PYTHON3_SUBDIRS) diff --git a/plugins/dex/core.c b/plugins/dex/core.c index 22ebfff..1101a89 100644 --- a/plugins/dex/core.c +++ b/plugins/dex/core.c @@ -24,18 +24,17 @@ #include "core.h" -#include <config.h> #include <core/global.h> #include <plugins/self.h> #include "format.h" -#ifdef HAVE_PYTHON3_BINDINGS +#ifdef INCLUDE_PYTHON3_BINDINGS # include "python/module.h" #endif -#ifdef HAVE_PYTHON3_BINDINGS +#ifdef INCLUDE_PYTHON3_BINDINGS # define PG_REQ RL("PyChrysalide") #else # define PG_REQ NO_REQ @@ -65,7 +64,7 @@ G_MODULE_EXPORT bool chrysalide_plugin_init(GPluginModule *plugin) { bool result; /* Bilan à retourner */ -#ifdef HAVE_PYTHON3_BINDINGS +#ifdef INCLUDE_PYTHON3_BINDINGS result = add_format_dex_module_to_python_module(); #else result = true; diff --git a/plugins/dex/loading.h b/plugins/dex/loading.h index 5560e4e..4de6df1 100644 --- a/plugins/dex/loading.h +++ b/plugins/dex/loading.h @@ -26,9 +26,11 @@ #include <glib-object.h> +#include <stdbool.h> +#include <stdint.h> -#include <gtkext/gtkstatusstack.h> +#include <glibext/notifier.h> diff --git a/plugins/dex/pool.c b/plugins/dex/pool.c index 6007019..af591d3 100644 --- a/plugins/dex/pool.c +++ b/plugins/dex/pool.c @@ -26,6 +26,7 @@ #include <assert.h> #include <malloc.h> +#include <stdlib.h> #include <string.h> @@ -1181,6 +1182,10 @@ bool g_dex_pool_load_all_classes(GDexPool *pool, wgroup_id_t gid, GtkStatusStack size_t scount; /* Quantité de ces symboles */ uint32_t j; /* Boucle de parcours #2 */ size_t k; /* Boucle de parcours #3 */ + bool need_sort; /* Tri des symboles nécessaire */ + phys_t last; /* Dernière position rencontrée*/ + const mrange_t *range; /* Couverture du symbole */ + const vmpa2t *addr; /* Emplacement du symbole */ result = true; @@ -1229,8 +1234,38 @@ bool g_dex_pool_load_all_classes(GDexPool *pool, wgroup_id_t gid, GtkStatusStack result = g_dex_class_get_collect_symbols(pool->classes[j], &symbols, &scount); if (result) + { + /** + * Si le format DEX impose un ordre croissant dans les identifiants + * des méthodes d'une classe (champ method_idx de la structure + * encoded_method), cela ne conduit pas forcément à : + * - à disposer de champs code_off eux-même ordonnés ; + * - à retrouver des ordonnancements d'une classe à une autre. + * + * Un tri est donc forcé ici s'il s'avère nécessaire. + */ + + need_sort = false; + last = VMPA_NO_PHYSICAL; + + for (k = 0; k < scount && !need_sort; k++) + { + range = g_binary_symbol_get_range(symbols[k]); + addr = get_mrange_addr(range); + + need_sort = (last != VMPA_NO_PHYSICAL && last > get_phy_addr(addr)); + + last = get_phy_addr(addr); + + } + + if (need_sort) + qsort(symbols, count, sizeof(GBinSymbol *), (__compar_fn_t)g_binary_symbol_cmp); + result = g_binary_format_add_symbols(G_BIN_FORMAT(pool->format), symbols, count); + } + for (k = 0; k < scount; k++) g_object_unref(symbols[k]); diff --git a/plugins/dex/python/Makefile.am b/plugins/dex/python/Makefile.am index e91630e..b627157 100644 --- a/plugins/dex/python/Makefile.am +++ b/plugins/dex/python/Makefile.am @@ -1,26 +1,21 @@ noinst_LTLIBRARIES = libdexpython.la -libdexpython_la_SOURCES = \ - class.h class.c \ - constants.h constants.c \ - field.h field.c \ - format.h format.c \ - method.h method.c \ - module.h module.c \ - pool.h pool.c \ - routine.h routine.c \ +libdexpython_la_SOURCES = \ + class.h class.c \ + constants.h constants.c \ + field.h field.c \ + format.h format.c \ + method.h method.c \ + module.h module.c \ + pool.h pool.c \ + routine.h routine.c \ translate.h translate.c -libdexpython_la_LDFLAGS = +libdexpython_la_CFLAGS = $(TOOLKIT_CFLAGS) $(LIBXML_CFLAGS) $(LIBPYTHON_CFLAGS) $(LIBPYGOBJECT_CFLAGS) \ + -I$(top_srcdir)/src -DNO_IMPORT_PYGOBJECT devdir = $(includedir)/chrysalide/$(subdir) dev_HEADERS = $(libdexpython_la_SOURCES:%c=) - - -AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) $(LIBPYTHON_CFLAGS) $(LIBPYGOBJECT_CFLAGS) \ - -I$(top_srcdir)/src -DNO_IMPORT_PYGOBJECT - -AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS) diff --git a/plugins/dex/python/class.c b/plugins/dex/python/class.c index e344124..247197c 100644 --- a/plugins/dex/python/class.c +++ b/plugins/dex/python/class.c @@ -584,14 +584,14 @@ PyTypeObject *get_python_dex_class_type(void) bool register_python_dex_class(PyObject *module) { - PyTypeObject *py_dex_class_type; /* Type Python 'DexClass' */ + PyTypeObject *type; /* Type Python 'DexClass' */ PyObject *dict; /* Dictionnaire du module */ - py_dex_class_type = get_python_dex_class_type(); + type = get_python_dex_class_type(); dict = PyModule_GetDict(module); - if (!register_class_for_pygobject(dict, G_TYPE_DEX_CLASS, py_dex_class_type, &PyGObject_Type)) + if (!register_class_for_pygobject(dict, G_TYPE_DEX_CLASS, type)) return false; return true; diff --git a/plugins/dex/python/field.c b/plugins/dex/python/field.c index 1381af6..081d0af 100644 --- a/plugins/dex/python/field.c +++ b/plugins/dex/python/field.c @@ -181,14 +181,14 @@ PyTypeObject *get_python_dex_field_type(void) bool register_python_dex_field(PyObject *module) { - PyTypeObject *py_dex_field_type; /* Type Python 'DexField' */ + PyTypeObject *type; /* Type Python 'DexField' */ PyObject *dict; /* Dictionnaire du module */ - py_dex_field_type = get_python_dex_field_type(); + type = get_python_dex_field_type(); dict = PyModule_GetDict(module); - if (!register_class_for_pygobject(dict, G_TYPE_DEX_FIELD, py_dex_field_type, &PyGObject_Type)) + if (!register_class_for_pygobject(dict, G_TYPE_DEX_FIELD, type)) return false; return true; diff --git a/plugins/dex/python/format.c b/plugins/dex/python/format.c index fa65b25..4a8939b 100644 --- a/plugins/dex/python/format.c +++ b/plugins/dex/python/format.c @@ -281,7 +281,10 @@ bool register_python_dex_format(PyObject *module) dict = PyModule_GetDict(module); - if (!register_class_for_pygobject(dict, G_TYPE_DEX_FORMAT, type, get_python_executable_format_type())) + if (!ensure_python_executable_format_is_registered()) + return false; + + if (!register_class_for_pygobject(dict, G_TYPE_DEX_FORMAT, type)) return false; if (!define_python_dex_format_common_constants(type)) diff --git a/plugins/dex/python/method.c b/plugins/dex/python/method.c index fc56f29..ed67176 100644 --- a/plugins/dex/python/method.c +++ b/plugins/dex/python/method.c @@ -291,14 +291,14 @@ PyTypeObject *get_python_dex_method_type(void) bool register_python_dex_method(PyObject *module) { - PyTypeObject *py_dex_method_type; /* Type Python 'DexMethod' */ + PyTypeObject *type; /* Type Python 'DexMethod' */ PyObject *dict; /* Dictionnaire du module */ - py_dex_method_type = get_python_dex_method_type(); + type = get_python_dex_method_type(); dict = PyModule_GetDict(module); - if (!register_class_for_pygobject(dict, G_TYPE_DEX_METHOD, py_dex_method_type, &PyGObject_Type)) + if (!register_class_for_pygobject(dict, G_TYPE_DEX_METHOD, type)) return false; return true; diff --git a/plugins/dex/python/pool.c b/plugins/dex/python/pool.c index ddfc900..0c08865 100644 --- a/plugins/dex/python/pool.c +++ b/plugins/dex/python/pool.c @@ -822,7 +822,7 @@ bool register_python_dex_pool(PyObject *module) dict = PyModule_GetDict(module); - if (!register_class_for_pygobject(dict, G_TYPE_DEX_POOL, type, &PyGObject_Type)) + if (!register_class_for_pygobject(dict, G_TYPE_DEX_POOL, type)) return false; return true; diff --git a/plugins/dex/python/routine.c b/plugins/dex/python/routine.c index 31410c7..af38263 100644 --- a/plugins/dex/python/routine.c +++ b/plugins/dex/python/routine.c @@ -165,7 +165,10 @@ bool register_python_dex_routine(PyObject *module) dict = PyModule_GetDict(module); - if (!register_class_for_pygobject(dict, G_TYPE_DEX_ROUTINE, type, get_python_binary_routine_type())) + if (!ensure_python_binary_routine_is_registered()) + return false; + + if (!register_class_for_pygobject(dict, G_TYPE_DEX_ROUTINE, type)) return false; return true; |