summaryrefslogtreecommitdiff
path: root/src/format/dex
diff options
context:
space:
mode:
Diffstat (limited to 'src/format/dex')
-rw-r--r--src/format/dex/class.c9
-rw-r--r--src/format/dex/class.h2
-rwxr-xr-xsrc/format/dex/dex.c16
-rw-r--r--src/format/dex/method.c18
-rw-r--r--src/format/dex/method.h2
5 files changed, 19 insertions, 28 deletions
diff --git a/src/format/dex/class.c b/src/format/dex/class.c
index 26907ed..c1ff62a 100644
--- a/src/format/dex/class.c
+++ b/src/format/dex/class.c
@@ -401,9 +401,8 @@ GDexMethod *g_dex_class_get_method(const GDexClass *class, bool virtual, size_t
/******************************************************************************
* *
-* Paramètres : class = informations chargées à consulter. *
+* Paramètres : class = informations chargées à consulter. *
* format = format permettant d'obtenir une adresse complète. *
-* layer = couche de portions à raffiner. *
* *
* Description : Intègre la méthode en tant que portion de code. *
* *
@@ -413,15 +412,15 @@ GDexMethod *g_dex_class_get_method(const GDexClass *class, bool virtual, size_t
* *
******************************************************************************/
-void g_dex_class_include_as_portion(const GDexClass *class, const GDexFormat *format, GPortionLayer *layer)
+void g_dex_class_include_as_portion(const GDexClass *class, GExeFormat *format)
{
size_t i; /* Boucle de parcours */
for (i = 0; i < class->dmethods_count; i++)
- g_dex_method_include_as_portion(class->direct_methods[i], format, layer);
+ g_dex_method_include_as_portion(class->direct_methods[i], format);
for (i = 0; i < class->vmethods_count; i++)
- g_dex_method_include_as_portion(class->virtual_methods[i], format, layer);
+ g_dex_method_include_as_portion(class->virtual_methods[i], format);
}
diff --git a/src/format/dex/class.h b/src/format/dex/class.h
index 46529c3..ec2fa24 100644
--- a/src/format/dex/class.h
+++ b/src/format/dex/class.h
@@ -69,7 +69,7 @@ size_t g_dex_class_count_methods(const GDexClass *, bool);
GDexMethod *g_dex_class_get_method(const GDexClass *, bool, size_t);
/* Intègre la méthode en tant que portion de code. */
-void g_dex_class_include_as_portion(const GDexClass *, const GDexFormat *, GPortionLayer *);
+void g_dex_class_include_as_portion(const GDexClass *, GExeFormat *);
/* Retrouve si possible la méthode associée à une adresse. */
GDexMethod *g_dex_class_find_method_by_address(const GDexClass *, vmpa_t);
diff --git a/src/format/dex/dex.c b/src/format/dex/dex.c
index c550375..df920b2 100755
--- a/src/format/dex/dex.c
+++ b/src/format/dex/dex.c
@@ -58,7 +58,7 @@ static void g_dex_format_finalize(GDexFormat *);
static const char *g_dex_format_get_target_machine(const GDexFormat *);
/* Etend la définition des portions au sein d'un binaire. */
-static void g_dex_format_refine_portions(const GDexFormat *, GPortionLayer *);
+static void g_dex_format_refine_portions(GDexFormat *);
/* Fournit l'emplacement d'une section donnée. */
static bool g_dex_format_get_section_range_by_name(const GDexFormat *, const char *, mrange_t *);
@@ -247,12 +247,14 @@ GBinFormat *g_dex_format_new(GBinContent *content, GExeFormat *parent, GtkStatus
{
GDexFormat *result; /* Structure à retourner */
GBinFormat *base; /* Version basique du format */
+ GExeFormat *exe_format; /* Autre version du format */
vmpa2t pos; /* Position de tête de lecture */
wgroup_id_t gid; /* Identifiant pour les tâches */
result = g_object_new(G_TYPE_DEX_FORMAT, NULL);
base = G_BIN_FORMAT(result);
+ exe_format = G_EXE_FORMAT(result);
g_binary_format_set_content(base, content);
@@ -277,7 +279,7 @@ GBinFormat *g_dex_format_new(GBinContent *content, GExeFormat *parent, GtkStatus
if (!load_all_dex_classes(result, gid, status))
goto gdfn_error;
- if (!g_binary_format_complete_loading(base, status))
+ if (!g_executable_format_complete_loading(exe_format, status))
goto gdfn_error;
return base;
@@ -322,20 +324,18 @@ static const char *g_dex_format_get_target_machine(const GDexFormat *format)
* *
******************************************************************************/
-static void g_dex_format_refine_portions(const GDexFormat *format, GPortionLayer *main)
+static void g_dex_format_refine_portions(GDexFormat *format)
{
- GPortionLayer *layer; /* Couche à mettre en place */
+ GExeFormat *exe_format; /* Autre version du format */
size_t max; /* Nombre d'itérations prévues */
size_t i; /* Boucle de parcours */
- layer = g_portion_layer_new(NO_LENGTH_YET, _("Code"));
-
- g_portion_layer_attach_sub(main, layer);
+ exe_format = G_EXE_FORMAT(format);
max = g_dex_format_count_classes(format);
for (i = 0; i < max; i++)
- g_dex_class_include_as_portion(format->classes[i], format, layer);
+ g_dex_class_include_as_portion(format->classes[i], exe_format);
}
diff --git a/src/format/dex/method.c b/src/format/dex/method.c
index 1223eb9..8659a73 100644
--- a/src/format/dex/method.c
+++ b/src/format/dex/method.c
@@ -338,7 +338,6 @@ GBinRoutine *g_dex_method_get_routine(const GDexMethod *method)
* *
* Paramètres : method = représentation interne du format DEX à consulter. *
* format = format permettant d'obtenir une adresse complète. *
-* layer = couche de portions à raffiner. *
* *
* Description : Intègre la méthode en tant que portion de code. *
* *
@@ -348,11 +347,10 @@ GBinRoutine *g_dex_method_get_routine(const GDexMethod *method)
* *
******************************************************************************/
-void g_dex_method_include_as_portion(const GDexMethod *method, const GDexFormat *format, GPortionLayer *layer)
+void g_dex_method_include_as_portion(const GDexMethod *method, GExeFormat *format)
{
vmpa2t addr; /* Emplacement dans le binaire */
GBinPortion *new; /* Nouvelle portion définie */
- char *desc; /* Description d'une portion */
/* Si la taille est nulle, on ne fait rien */
if (method->info.access_flags & ACC_NATIVE)
@@ -361,22 +359,16 @@ void g_dex_method_include_as_portion(const GDexMethod *method, const GDexFormat
if (!method->has_body)
return;
- if (!g_exe_format_translate_offset_into_vmpa(G_EXE_FORMAT(format), method->offset, &addr))
+ if (!g_exe_format_translate_offset_into_vmpa(format, method->offset, &addr))
return;
- new = g_binary_portion_new(BPC_CODE);
+ new = g_binary_portion_new(BPC_CODE, &addr, method->body.insns_size * sizeof(uint16_t));
- asprintf(&desc, _("Dalvik code"));
-
- g_binary_portion_set_desc(new, desc);
-
- free(desc);
-
- g_binary_portion_set_values(new, &addr, method->body.insns_size * sizeof(uint16_t));
+ g_binary_portion_set_desc(new, _("Dalvik code"));
g_binary_portion_set_rights(new, PAC_READ | PAC_EXEC);
- g_portion_layer_include(layer, new);
+ g_exe_format_include_portion(format, new);
}
diff --git a/src/format/dex/method.h b/src/format/dex/method.h
index 41ddb4c..8836abb 100644
--- a/src/format/dex/method.h
+++ b/src/format/dex/method.h
@@ -82,7 +82,7 @@ const code_item *g_dex_method_get_dex_body(const GDexMethod *);
GBinRoutine *g_dex_method_get_routine(const GDexMethod *);
/* Intègre la méthode en tant que portion de code. */
-void g_dex_method_include_as_portion(const GDexMethod *, const GDexFormat *, GPortionLayer *);
+void g_dex_method_include_as_portion(const GDexMethod *, GExeFormat *);
/* Indique la position de la méthode au sein du binaire. */
bool g_dex_method_get_offset(const GDexMethod *method, phys_t *);