summaryrefslogtreecommitdiff
path: root/plugins/dex
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2019-07-20 15:59:12 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2019-07-20 15:59:12 (GMT)
commitf0682e7b195acbd4d83148f3829479d682f9ee9f (patch)
tree39ec963de4b08dfde01cb621a48d14e01a365541 /plugins/dex
parent71db5a3a8a7a337ba63a47b6472baf99581d8400 (diff)
Marked some Dex strings as structural.
Diffstat (limited to 'plugins/dex')
-rw-r--r--plugins/dex/class.c2
-rw-r--r--plugins/dex/method.c2
-rw-r--r--plugins/dex/pool.c49
-rw-r--r--plugins/dex/pool.h2
-rw-r--r--plugins/dex/python/pool.c2
5 files changed, 30 insertions, 27 deletions
diff --git a/plugins/dex/class.c b/plugins/dex/class.c
index b5ec462..9defac7 100644
--- a/plugins/dex/class.c
+++ b/plugins/dex/class.c
@@ -741,7 +741,7 @@ const char *g_dex_class_get_source_file(const GDexClass *class)
pool = g_dex_format_get_pool(class->format);
- result = g_dex_pool_get_string(pool, class->definition.source_file_idx, NULL);
+ result = g_dex_pool_get_string(pool, class->definition.source_file_idx, (bool []) { true }, NULL);
g_object_unref(G_OBJECT(pool));
diff --git a/plugins/dex/method.c b/plugins/dex/method.c
index 75293b7..e93e185 100644
--- a/plugins/dex/method.c
+++ b/plugins/dex/method.c
@@ -283,7 +283,7 @@ GDexMethod *g_dex_method_new_callable(GDexFormat *format, const method_id_item *
ns = g_dex_pool_get_type_(pool, id_item->class_idx);
- name = g_dex_pool_get_string(pool, id_item->name_idx, NULL);
+ name = g_dex_pool_get_string(pool, id_item->name_idx, (bool []) { true }, NULL);
if (name == NULL) goto gdmne_exit;
routine = g_dex_pool_get_prototype(pool, id_item->proto_idx);
diff --git a/plugins/dex/pool.c b/plugins/dex/pool.c
index e7dd205..c24617a 100644
--- a/plugins/dex/pool.c
+++ b/plugins/dex/pool.c
@@ -24,6 +24,7 @@
#include "pool.h"
+#include <assert.h>
#include <malloc.h>
#include <string.h>
@@ -282,6 +283,7 @@ uint32_t g_dex_pool_count_strings(const GDexPool *pool)
* *
* Paramètres : pool = table de resources pour format Dex à consulter. *
* index = index de la chaîne recherchée. *
+* mark = marque la chaîne comme structurelle si définie. *
* range = éventuelle couverture à renseigner ou NULL. [OUT] *
* *
* Description : Extrait une chaîne de caractères d'une table DEX. *
@@ -292,7 +294,7 @@ uint32_t g_dex_pool_count_strings(const GDexPool *pool)
* *
******************************************************************************/
-const char *g_dex_pool_get_string(const GDexPool *pool, uint32_t index, mrange_t *range)
+const char *g_dex_pool_get_string(const GDexPool *pool, uint32_t index, bool *mark, mrange_t *range)
{
uint32_t count; /* Nombre d'éléments présents */
GDexFormat *format; /* Format associé à la table */
@@ -322,6 +324,15 @@ const char *g_dex_pool_get_string(const GDexPool *pool, uint32_t index, mrange_t
if (!read_dex_string_data_item(format, &addr, &inter, &str_data))
return NULL;
+ if (mark != NULL)
+ {
+ assert(*mark);
+
+ assert(pool->strings[index] != NULL);
+ g_string_symbol_set_structural(G_STR_SYMBOL(pool->strings[index]), true);
+
+ }
+
if (range != NULL)
{
diff = compute_vmpa_diff(&inter, &addr);
@@ -367,7 +378,7 @@ GBinSymbol *g_dex_pool_get_string_symbol(GDexPool *pool, uint32_t index)
if (pool->strings[index] == NULL)
{
- string = g_dex_pool_get_string(pool, index, &range);
+ string = g_dex_pool_get_string(pool, index, NULL, &range);
if (string == NULL) goto gssfdp_error;
base = G_BIN_FORMAT(pool->format);
@@ -549,11 +560,7 @@ GDataType *g_dex_pool_get_type_(GDexPool *pool, uint32_t index)
{
GDataType *result; /* Instance à retourner */
type_id_item type_id; /* Définition de la classe */
- GDexFormat *format; /* Format associé à la table */
- phys_t pos; /* Tête de lecture */
- vmpa2t addr; /* Tête de lecture générique */
- string_id_item str_id; /* Identifiant de chaîne */
- string_data_item str_data; /* Description de chaîne */
+ const char *desc; /* Description de type */
result = NULL;
@@ -562,21 +569,10 @@ GDataType *g_dex_pool_get_type_(GDexPool *pool, uint32_t index)
if (!g_dex_pool_get_raw_type(pool, index, &type_id))
goto no_type_id;
- format = pool->format;
-
- pos = format->header.string_ids_off + type_id.descriptor_idx * sizeof(string_id_item);
- init_vmpa(&addr, pos, VMPA_NO_VIRTUAL);
-
- if (!read_dex_string_id_item(format, &addr, &str_id))
- goto type_error;
-
- pos = str_id.string_data_off;
- init_vmpa(&addr, pos, VMPA_NO_VIRTUAL);
-
- if (!read_dex_string_data_item(format, &addr, NULL, &str_data))
- goto type_error;
+ desc = g_dex_pool_get_string(pool, type_id.descriptor_idx, (bool []) { true }, NULL);
+ if (desc == NULL) goto type_error;
- pool->types[index] = g_binary_format_decode_type(G_BIN_FORMAT(format), (char *)str_data.data);
+ pool->types[index] = g_binary_format_decode_type(G_BIN_FORMAT(pool->format), desc);
}
@@ -760,9 +756,9 @@ GBinVariable *g_dex_pool_get_field(GDexPool *pool, uint32_t index)
type = g_dex_pool_get_type_(pool, field_id.type_idx);
if (type == NULL) goto type_error;
- name = g_dex_pool_get_string(pool, field_id.name_idx, NULL);
+ name = g_dex_pool_get_string(pool, field_id.name_idx, (bool []) { true }, NULL);
if (name == NULL) goto bad_name;
-
+
field = g_binary_variable_new(type);
g_binary_variable_set_name(field, name);
@@ -909,6 +905,13 @@ GBinRoutine *g_dex_pool_get_prototype(GDexPool *pool, uint32_t index)
* autres champs de la structure, donc l'information paraît redondante.
*/
+ /**
+ * On marque cependant la chaîne de description comme étant structurelle.
+ */
+
+ assert(pool->strings[proto_id.shorty_idx] != NULL);
+ g_string_symbol_set_structural(G_STR_SYMBOL(pool->strings[proto_id.shorty_idx]), true);
+
/* Type de retour */
type = g_dex_pool_get_type_(pool, proto_id.return_type_idx);
diff --git a/plugins/dex/pool.h b/plugins/dex/pool.h
index c8f9b01..1ab227d 100644
--- a/plugins/dex/pool.h
+++ b/plugins/dex/pool.h
@@ -63,7 +63,7 @@ bool g_dex_pool_load_all_string_symbols(GDexPool *, wgroup_id_t, GtkStatusStack
uint32_t g_dex_pool_count_strings(const GDexPool *);
/* Extrait une chaîne de caractères d'une table DEX. */
-const char *g_dex_pool_get_string(const GDexPool *, uint32_t, mrange_t *);
+const char *g_dex_pool_get_string(const GDexPool *, uint32_t, bool *, mrange_t *);
/* Extrait un symbole de chaîne d'une table DEX. */
GBinSymbol *g_dex_pool_get_string_symbol(GDexPool *, uint32_t);
diff --git a/plugins/dex/python/pool.c b/plugins/dex/python/pool.c
index 971f163..450c76c 100644
--- a/plugins/dex/python/pool.c
+++ b/plugins/dex/python/pool.c
@@ -427,7 +427,7 @@ static PyObject *py_dex_pool_get_strings(PyObject *self, void *closure)
for (i = 0; i < count; i++)
{
- string = g_dex_pool_get_string(pool, i, NULL);
+ string = g_dex_pool_get_string(pool, i, NULL, NULL);
if (string == NULL)
{