summaryrefslogtreecommitdiff
path: root/src/format/dex/pool.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/format/dex/pool.c')
-rw-r--r--src/format/dex/pool.c36
1 files changed, 29 insertions, 7 deletions
diff --git a/src/format/dex/pool.c b/src/format/dex/pool.c
index 9a99cc8..0180b19 100644
--- a/src/format/dex/pool.c
+++ b/src/format/dex/pool.c
@@ -52,19 +52,29 @@
bool find_all_dex_strings(GDexFormat *format)
{
+ GBinFormat *base; /* Autre version du format */
uint32_t i; /* Boucle de parcours */
+ mrange_t range; /* Couverture associée */
const char *text; /* Texte issu du binaire */
GBinSymbol *symbol; /* Nouveau symbole construit */
+ char *label; /* Désignation de la chaîne */
+
+ base = G_BIN_FORMAT(format);
for (i = 0; i < format->header.string_ids_size; i++)
{
- text = get_string_from_dex_pool(format, i);
+ text = get_string_from_dex_pool(format, i, &range);
if (text == NULL) continue;
- symbol = g_binary_symbol_new(STP_STRING);
- g_binary_symbol_set_alt_label(symbol, text);
+ symbol = g_binary_symbol_new(&range, STP_STRING);
+
+ label = create_string_label(base, get_mrange_addr(&range), get_mrange_length(&range));
+
+ g_binary_symbol_set_alt_label(symbol, label);
- g_binary_format_add_symbol(G_BIN_FORMAT(format), symbol);
+ free(label);
+
+ g_binary_format_add_symbol(base, symbol);
}
@@ -77,6 +87,7 @@ bool find_all_dex_strings(GDexFormat *format)
* *
* Paramètres : format = représentation interne du format DEX à consulter. *
* index = index du type recherchée. *
+* range = éventuelle couverture à renseigner ou NULL. [OUT] *
* *
* Description : Extrait une chaîne de caractères d'une table DEX. *
* *
@@ -86,12 +97,14 @@ bool find_all_dex_strings(GDexFormat *format)
* *
******************************************************************************/
-const char *get_string_from_dex_pool(const GDexFormat *format, uint32_t index)
+const char *get_string_from_dex_pool(const GDexFormat *format, uint32_t index, mrange_t *range)
{
off_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 */
+ vmpa2t start; /* Début de la chaîne */
+ phys_t diff; /* Avancée de tête de lecture */
if (index >= format->header.string_ids_size)
return NULL;
@@ -108,6 +121,15 @@ const char *get_string_from_dex_pool(const GDexFormat *format, uint32_t index)
if (!read_dex_string_data_item(format, &addr, &str_data))
return NULL;
+ if (range != NULL)
+ {
+ init_vmpa(&start, pos, VMPA_NO_VIRTUAL);
+ diff = compute_vmpa_diff(&start, &addr);
+
+ init_mrange(range, &start, diff);
+
+ }
+
return (const char *)str_data.data;
}
@@ -362,7 +384,7 @@ GBinVariable *get_field_from_dex_pool(GDexFormat *format, uint32_t index)
type = get_type_from_dex_pool(format, field_id.type_idx);
if (type == NULL) goto gffdp_error;
- name = get_string_from_dex_pool(format, field_id.name_idx);
+ name = get_string_from_dex_pool(format, field_id.name_idx, NULL);
if (name == NULL) goto gffdp_bad_name;
field = g_binary_variable_new(type);
@@ -452,7 +474,7 @@ GBinRoutine *get_prototype_from_dex_pool(GDexFormat *format, uint32_t index)
/* Nom de la méthode */
- name = get_string_from_dex_pool(format, proto_id.shorty_idx);
+ name = get_string_from_dex_pool(format, proto_id.shorty_idx, NULL);
/* Liste des arguments */