summaryrefslogtreecommitdiff
path: root/plugins/readdex/code.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/readdex/code.c')
-rw-r--r--plugins/readdex/code.c560
1 files changed, 320 insertions, 240 deletions
diff --git a/plugins/readdex/code.c b/plugins/readdex/code.c
index 2f43e86..23e82ac 100644
--- a/plugins/readdex/code.c
+++ b/plugins/readdex/code.c
@@ -24,254 +24,271 @@
#include "code.h"
-#include <assert.h>
-#include <malloc.h>
-#include <stdio.h>
+#include <format/dex/dex_def.h>
+#include <plugins/fmtp/parser.h>
-#include <i18n.h>
-#include <arch/raw.h>
-#include <format/symbol.h>
-#include <format/dex/dex_def.h>
+/* Définition des champs */
+typedef struct _code_item_data
+{
+ uint16_t tries_size; /* Nombre de gestionnaires */
+ uint32_t insns_size; /* Nombre d'instructions */
-/* Commente les définitions d'une protection contre exceptions. */
-static bool annotate_dex_try_item(const GDexFormat *, vmpa2t *);
+} code_item_data;
-/*Commente les définitions des listes de gestion d'exceptions. */
-static bool annotate_dex_encoded_catch_handler_list(const GDexFormat *, vmpa2t *);
+/* Récupère le nombre de couvertures pour exceptions. */
+static bool get_code_tries_size_value(const fmt_field_def *, GBinContent *, vmpa2t *, SourceEndian, code_item_data *);
-/* Commente les définitions d'une prise en compte d'exceptions. */
-static bool annotate_dex_encoded_catch_handler(const GDexFormat *, vmpa2t *);
+/* Récupère le nombre de blocs d'instructions. */
+static bool get_code_insns_size_value(const fmt_field_def *, GBinContent *, vmpa2t *, SourceEndian, code_item_data *);
-/* Commente les définitions des gestions d'exceptions par type. */
-static bool annotate_dex_encoded_type_addr_pair(const GDexFormat *, vmpa2t *);
+/* Récupère le nombre d'éléments d'une liste de couvertures. */
+static bool get_encoded_catch_handler_list_size_value(const fmt_field_def *, GBinContent *, vmpa2t *, SourceEndian, uleb128_t *);
+/* Récupère le nombre d'exécptions gérées dans une couverture. */
+static bool get_encoded_catch_handler_size_value(const fmt_field_def *, GBinContent *, vmpa2t *, SourceEndian, leb128_t *);
-/******************************************************************************
-* *
-* Paramètres : format = description de l'exécutable à compléter. *
-* *
-* Description : Commente les définitions d'un corps de méthode. *
-* *
-* Retour : Bilan de l'opération. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
+static fmt_field_def _dex_code_item[] = {
-bool annotate_dex_code_item(const GDexFormat *format, uleb128_t offset)
-{
- bool result; /* Bilan à retourner */
- GBinContent *content; /* Contenu binaire à lire */
- SourceEndian endian; /* Boutisme utilisé */
- vmpa2t pos; /* Tête de lecture des symboles*/
- GArchInstruction *instr; /* Instruction décodée */
- GArchOperand *operand; /* Opérande à venir modifier */
- GDbComment *comment; /* Définition de commentaire */
- GBinSymbol *symbol; /* Symbole à intégrer */
- char *text; /* Texte constant à insérer */
- uint16_t tries_size; /* Nombre de gestionnaires */
- uint32_t insns_size; /* Nombre d'instructions */
- uint16_t i; /* Boucle de parcours */
+ {
+ .name = "registers_size",
- content = g_binary_format_get_content(G_BIN_FORMAT(format));
+ .size = MDS_16_BITS,
+ .repeat = 1,
- endian = SRE_LITTLE;//g_dex_format_get_endianness(format);
+ DISPLAY_RULES(IOD_DEC),
- if (!g_exe_format_translate_offset_into_vmpa(G_EXE_FORMAT(format), offset, &pos))
- return false;
+ PLAIN_COMMENT(__("Number of registers used by this code"))
- /* registers_size */
+ },
- instr = g_raw_instruction_new_array(content, MDS_16_BITS, 1, &pos, endian);
+ {
+ .name = "ins_size",
- SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC);
+ .size = MDS_16_BITS,
+ .repeat = 1,
- asprintf(&text, _("Number of registers used by this code"));
+ DISPLAY_RULES(IOD_DEC),
- ADD_RAW_AS_SYM(format, symbol, instr, comment, text);
+ PLAIN_COMMENT(__("Number of words of incoming arguments to the method that this code is for"))
- free(text);
+ },
- g_binary_symbol_define_as_block_start(symbol, true);
+ {
+ .name = "outs_size",
- /* ins_size */
+ .size = MDS_16_BITS,
+ .repeat = 1,
- instr = g_raw_instruction_new_array(content, MDS_16_BITS, 1, &pos, endian);
+ DISPLAY_RULES(IOD_DEC),
- SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC);
+ PLAIN_COMMENT(__("Number of words of outgoing argument space required by this code for method invocation"))
- asprintf(&text, _("Number of words of incoming arguments to the method that this code is for"));
+ },
- ADD_RAW_AS_SYM(format, symbol, instr, comment, text);
+ {
+ .name = "tries_size",
- free(text);
+ .get_value = (get_fdef_value_cb)get_code_tries_size_value,
- /* outs_size */
+ .size = MDS_16_BITS,
+ .repeat = 1,
- instr = g_raw_instruction_new_array(content, MDS_16_BITS, 1, &pos, endian);
+ DISPLAY_RULES(IOD_DEC),
- SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC);
+ PLAIN_COMMENT(__("Number of try_items for this instance"))
- asprintf(&text, _("Number of words of outgoing argument space required by this code for method invocation"));
+ },
- ADD_RAW_AS_SYM(format, symbol, instr, comment, text);
+ {
+ .name = "debug_info_off",
- free(text);
+ .size = MDS_32_BITS,
+ .repeat = 1,
- /* tries_size */
+ PLAIN_COMMENT(__("Offset to the debug info sequence for this code"))
- instr = g_raw_instruction_new_array(content, MDS_16_BITS, 1, &pos, endian);
+ },
- SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC);
+ {
+ .name = "insns_size",
- asprintf(&text, _("Number of try_items for this instance"));
+ .get_value = (get_fdef_value_cb)get_code_insns_size_value,
- ADD_RAW_AS_SYM(format, symbol, instr, comment, text);
+ .size = MDS_32_BITS,
+ .repeat = 1,
- free(text);
+ DISPLAY_RULES(IOD_DEC),
- g_imm_operand_get_value(G_IMM_OPERAND(operand), MDS_16_BITS, &tries_size);
+ PLAIN_COMMENT(__("Size of the instructions list, in 16-bit code units"))
- /* debug_info_off */
+ }
- instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, &pos, endian);
+};
- SET_IMM_DISPLAY(instr, operand, 0, IOD_HEX);
+static fmt_field_def _dex_code_item_padding[] = {
- asprintf(&text, _("Offset to the debug info sequence for this code"));
+ {
+ .name = "padding",
- ADD_RAW_AS_SYM(format, symbol, instr, comment, text);
+ .size = MDS_16_BITS,
+ .repeat = 1,
- free(text);
+ PLAIN_COMMENT(__("Padding"))
- /* insns_size */
+ }
- instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, &pos, endian);
+};
- SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC);
+static fmt_field_def _dex_try_item[] = {
- asprintf(&text, _("Size of the instructions list, in 16-bit code units"));
+ {
+ .name = "start_addr",
- ADD_RAW_AS_SYM(format, symbol, instr, comment, text);
+ .size = MDS_32_BITS,
+ .repeat = 1,
- free(text);
+ PLAIN_COMMENT(__("Start address of the block of code covered by this entry"))
- /* insns */
+ },
- g_imm_operand_get_value(G_IMM_OPERAND(operand), MDS_32_BITS, &insns_size);
+ {
+ .name = "insn_count",
- advance_vmpa(&pos, insns_size * 2);
+ .size = MDS_16_BITS,
+ .repeat = 1,
- /* padding */
+ DISPLAY_RULES(IOD_DEC),
+
+ PLAIN_COMMENT(__("Number of 16-bit code units covered by this entry"))
+
+ },
- if (insns_size % 2 != 0)
{
- instr = g_raw_instruction_new_array(content, MDS_16_BITS, 1, &pos, endian);
+ .name = "handler_off",
+
+ .size = MDS_16_BITS,
+ .repeat = 1,
+
+ PLAIN_COMMENT(__("Offset to the encoded_catch_handler for this entry"))
+
+ }
+
+};
- SET_IMM_DISPLAY(instr, operand, 0, IOD_HEX);
+static fmt_field_def _dex_encoded_catch_handler_list[] = {
+
+ {
+ .name = "size",
- asprintf(&text, _("Pading"));
+ .get_value = (get_fdef_value_cb)get_encoded_catch_handler_list_size_value,
- ADD_RAW_AS_SYM(format, symbol, instr, comment, text);
+ .is_uleb128 = true,
- free(text);
+ DISPLAY_RULES(IOD_DEC),
+
+ PLAIN_COMMENT(__("Size of the list, in entries"))
}
- /* tries */
+};
- result = true;
+static fmt_field_def _dex_encoded_catch_handler[] = {
- for (i = 0; i < tries_size && result; i++)
- result = annotate_dex_try_item(format, &pos);
+ {
+ .name = "size",
- if (tries_size > 0 && result)
- result = annotate_dex_encoded_catch_handler_list(format, &pos);
+ .get_value = (get_fdef_value_cb)get_encoded_catch_handler_size_value,
- /* Nettoyage final */
+ .is_leb128 = true,
- g_object_unref(G_OBJECT(content));
+ DISPLAY_RULES(IOD_DEC),
- return result;
+ PLAIN_COMMENT(__("Number of static fields defined in this item"))
-}
+ }
+};
-/******************************************************************************
-* *
-* Paramètres : format = description de l'exécutable à compléter. *
-* pos = tête de lecture pour les symboles. *
-* *
-* Description : Commente les définitions d'une protection contre exceptions. *
-* *
-* Retour : Bilan de l'opération. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
+static fmt_field_def _dex_encoded_catch_handler_all[] = {
-static bool annotate_dex_try_item(const GDexFormat *format, vmpa2t *pos)
-{
- bool result; /* Bilan à retourner */
- GBinContent *content; /* Contenu binaire à lire */
- SourceEndian endian; /* Boutisme utilisé */
- GArchInstruction *instr; /* Instruction décodée */
- GArchOperand *operand; /* Opérande à venir modifier */
- GDbComment *comment; /* Définition de commentaire */
- GBinSymbol *symbol; /* Symbole à intégrer */
- char *text; /* Texte constant à insérer */
+ {
+ .name = "catch_all_addr",
- result = true;
+ .is_uleb128 = true,
- content = g_binary_format_get_content(G_BIN_FORMAT(format));
+ PLAIN_COMMENT(__("Bytecode address of the catch-all handler"))
- endian = SRE_LITTLE;//g_dex_format_get_endianness(format);
+ }
- /* start_addr */
+};
- instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, endian);
+static fmt_field_def _dex_encoded_type_addr_pair[] = {
- SET_IMM_DISPLAY(instr, operand, 0, IOD_HEX);
+ {
+ .name = "type_idx",
- asprintf(&text, _("Start address of the block of code covered by this entry"));
+ .is_uleb128 = true,
- ADD_RAW_AS_SYM(format, symbol, instr, comment, text);
+ DISPLAY_RULES(IOD_DEC),
- free(text);
+ PLAIN_COMMENT(__("Index for the type of the exception to catch"))
- g_binary_symbol_define_as_block_start(symbol, true);
+ },
- /* insn_count */
+ {
+ .name = "addr",
- instr = g_raw_instruction_new_array(content, MDS_16_BITS, 1, pos, endian);
+ .is_uleb128 = true,
- SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC);
+ DISPLAY_RULES(IOD_DEC),
- asprintf(&text, _("Number of 16-bit code units covered by this entry"));
+ PLAIN_COMMENT(__("Bytecode address of the associated exception handler"))
- ADD_RAW_AS_SYM(format, symbol, instr, comment, text);
+ }
- free(text);
+};
- /* handler_off */
- instr = g_raw_instruction_new_array(content, MDS_16_BITS, 1, pos, endian);
- SET_IMM_DISPLAY(instr, operand, 0, IOD_HEX);
+/* Commente les définitions d'une protection contre exceptions. */
+static bool annotate_dex_try_item(const GDexFormat *, vmpa2t *);
- asprintf(&text, _("Offset to the encoded_catch_handler for this entry"));
+/*Commente les définitions des listes de gestion d'exceptions. */
+static bool annotate_dex_encoded_catch_handler_list(const GDexFormat *, vmpa2t *);
- ADD_RAW_AS_SYM(format, symbol, instr, comment, text);
+/* Commente les définitions d'une prise en compte d'exceptions. */
+static bool annotate_dex_encoded_catch_handler(const GDexFormat *, vmpa2t *);
- free(text);
+/* Commente les définitions des gestions d'exceptions par type. */
+static bool annotate_dex_encoded_type_addr_pair(const GDexFormat *, vmpa2t *);
- /* Nettoyage final */
- g_object_unref(G_OBJECT(content));
+
+/******************************************************************************
+* *
+* Paramètres : def = définition à l'origine de l'appel. *
+* content = contenu binaire à venir lire. *
+* pos = position de la tête de lecture. *
+* endian = ordre des bits dans la source. *
+* data = lieu d'enregistrement de la lecture. [OUT] *
+* *
+* Description : Récupère le nombre de couvertures pour exceptions. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static bool get_code_tries_size_value(const fmt_field_def *def, GBinContent *content, vmpa2t *pos, SourceEndian endian, code_item_data *data)
+{
+ bool result; /* Bilan à retourner */
+
+ result = g_binary_content_read_u16(content, pos, endian, &data->tries_size);
return result;
@@ -280,10 +297,13 @@ static bool annotate_dex_try_item(const GDexFormat *format, vmpa2t *pos)
/******************************************************************************
* *
-* Paramètres : format = description de l'exécutable à compléter. *
-* pos = tête de lecture physique des symboles. *
+* Paramètres : def = définition à l'origine de l'appel. *
+* content = contenu binaire à venir lire. *
+* pos = position de la tête de lecture. *
+* endian = ordre des bits dans la source. *
+* data = lieu d'enregistrement de la lecture. [OUT] *
* *
-* Description : Commente les définitions des listes de gestion d'exceptions. *
+* Description : Récupère le nombre de blocs d'instructions. *
* *
* Retour : Bilan de l'opération. *
* *
@@ -291,46 +311,65 @@ static bool annotate_dex_try_item(const GDexFormat *format, vmpa2t *pos)
* *
******************************************************************************/
-static bool annotate_dex_encoded_catch_handler_list(const GDexFormat *format, vmpa2t *pos)
+static bool get_code_insns_size_value(const fmt_field_def *def, GBinContent *content, vmpa2t *pos, SourceEndian endian, code_item_data *data)
{
bool result; /* Bilan à retourner */
- GBinContent *content; /* Contenu binaire à lire */
- GArchInstruction *instr; /* Instruction décodée */
- GArchOperand *operand; /* Opérande à venir modifier */
- GDbComment *comment; /* Définition de commentaire */
- GBinSymbol *symbol; /* Symbole à intégrer */
- char *text; /* Texte constant à insérer */
- uleb128_t size; /* Nombre d'entrées */
- uleb128_t i; /* Boucle de parcours */
- content = g_binary_format_get_content(G_BIN_FORMAT(format));
+ result = g_binary_content_read_u32(content, pos, endian, &data->insns_size);
- /* static_fields_size */
-
- instr = g_raw_instruction_new_uleb128(content, pos);
+ return result;
- SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC);
+}
- asprintf(&text, _("Size of the list, in entries"));
- ADD_RAW_AS_SYM(format, symbol, instr, comment, text);
+/******************************************************************************
+* *
+* Paramètres : def = définition à l'origine de l'appel. *
+* content = contenu binaire à venir lire. *
+* pos = position de la tête de lecture. *
+* endian = ordre des bits dans la source. *
+* size = lieu d'enregistrement de la lecture. [OUT] *
+* *
+* Description : Récupère le nombre d'éléments d'une liste de couvertures. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
- free(text);
+static bool get_encoded_catch_handler_list_size_value(const fmt_field_def *def, GBinContent *content, vmpa2t *pos, SourceEndian endian, uleb128_t *size)
+{
+ bool result; /* Bilan à retourner */
- g_binary_symbol_define_as_block_start(symbol, true);
+ result = g_binary_content_read_uleb128(content, pos, size);
- /* instance_fields_size */
+ return result;
- g_imm_operand_as_uleb128(G_IMM_OPERAND(operand), &size);
+}
- result = true;
- for (i = 0; i < size && result; i++)
- result = annotate_dex_encoded_catch_handler(format, pos);
+/******************************************************************************
+* *
+* Paramètres : def = définition à l'origine de l'appel. *
+* content = contenu binaire à venir lire. *
+* pos = position de la tête de lecture. *
+* endian = ordre des bits dans la source. *
+* size = lieu d'enregistrement de la lecture. [OUT] *
+* *
+* Description : Récupère le nombre d'exécptions gérées dans une couverture. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
- /* Nettoyage final */
+static bool get_encoded_catch_handler_size_value(const fmt_field_def *def, GBinContent *content, vmpa2t *pos, SourceEndian endian, leb128_t *size)
+{
+ bool result; /* Bilan à retourner */
- g_object_unref(G_OBJECT(content));
+ result = g_binary_content_read_leb128(content, pos, size);
return result;
@@ -340,9 +379,8 @@ static bool annotate_dex_encoded_catch_handler_list(const GDexFormat *format, vm
/******************************************************************************
* *
* Paramètres : format = description de l'exécutable à compléter. *
-* pos = tête de lecture physique des symboles. *
* *
-* Description : Commente les définitions d'une prise en compte d'exceptions. *
+* Description : Commente les définitions d'un corps de méthode. *
* *
* Retour : Bilan de l'opération. *
* *
@@ -350,68 +388,95 @@ static bool annotate_dex_encoded_catch_handler_list(const GDexFormat *format, vm
* *
******************************************************************************/
-static bool annotate_dex_encoded_catch_handler(const GDexFormat *format, vmpa2t *pos)
+bool annotate_dex_code_item(const GDexFormat *format, uleb128_t offset)
{
bool result; /* Bilan à retourner */
- GBinContent *content; /* Contenu binaire à lire */
- GArchInstruction *instr; /* Instruction décodée */
- GArchOperand *operand; /* Opérande à venir modifier */
- GDbComment *comment; /* Définition de commentaire */
- GBinSymbol *symbol; /* Symbole à intégrer */
- char *text; /* Texte constant à insérer */
- leb128_t size; /* Nombre de gestionnaires */
- bool has_catch_all; /* Gestion par défaut ? */
- uleb128_t i; /* Boucle de parcours */
+ vmpa2t pos; /* Tête de lecture des symboles*/
+ code_item_data data; /* Valeurs brutes lues */
+ uint16_t i; /* Boucle de parcours */
- content = g_binary_format_get_content(G_BIN_FORMAT(format));
+ result = g_exe_format_translate_offset_into_vmpa(G_EXE_FORMAT(format), offset, &pos);
- /* size */
+ if (!result)
+ goto adci_exit;
- instr = g_raw_instruction_new_sleb128(content, pos);
+ result = parse_field_definitions(PARSING_DEFS(_dex_code_item), G_BIN_FORMAT(format), &pos, &data);
- SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC);
+ if (!result)
+ goto adci_exit;
- asprintf(&text, _("Number of static fields defined in this item"));
+ /* insns */
- ADD_RAW_AS_SYM(format, symbol, instr, comment, text);
+ advance_vmpa(&pos, data.insns_size * 2);
- free(text);
+ /* padding */
- g_binary_symbol_define_as_block_start(symbol, true);
+ if (data.insns_size % 2 != 0)
+ result = parse_field_definitions(PARSING_DEFS(_dex_code_item_padding), G_BIN_FORMAT(format), &pos, NULL);
- g_imm_operand_as_leb128(G_IMM_OPERAND(operand), &size);
+ /* tries */
- has_catch_all = (size <= 0);
+ for (i = 0; i < data.tries_size && result; i++)
+ result = annotate_dex_try_item(format, &pos);
- if (size < 0)
- size *= -1;
+ if (data.tries_size > 0 && result)
+ result = annotate_dex_encoded_catch_handler_list(format, &pos);
- /* handlers */
+ adci_exit:
- result = true;
+ return result;
- for (i = 0; i < size && result; i++)
- result = annotate_dex_encoded_type_addr_pair(format, pos);
+}
- /* catch_all_addr */
- if (has_catch_all)
- {
- instr = g_raw_instruction_new_uleb128(content, pos);
+/******************************************************************************
+* *
+* Paramètres : format = description de l'exécutable à compléter. *
+* pos = tête de lecture pour les symboles. *
+* *
+* Description : Commente les définitions d'une protection contre exceptions. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static bool annotate_dex_try_item(const GDexFormat *format, vmpa2t *pos)
+{
+ bool result; /* Bilan à retourner */
- SET_IMM_DISPLAY(instr, operand, 0, IOD_HEX);
+ result = parse_field_definitions(PARSING_DEFS(_dex_try_item), G_BIN_FORMAT(format), pos, NULL);
- asprintf(&text, _("Bytecode address of the catch-all handler"));
+ return result;
- ADD_RAW_AS_SYM(format, symbol, instr, comment, text);
+}
- free(text);
- }
+/******************************************************************************
+* *
+* Paramètres : format = description de l'exécutable à compléter. *
+* pos = tête de lecture physique des symboles. *
+* *
+* Description : Commente les définitions des listes de gestion d'exceptions. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
- /* Nettoyage final */
+static bool annotate_dex_encoded_catch_handler_list(const GDexFormat *format, vmpa2t *pos)
+{
+ bool result; /* Bilan à retourner */
+ uleb128_t size; /* Nombre d'entrées */
+ uleb128_t i; /* Boucle de parcours */
- g_object_unref(G_OBJECT(content));
+ result = parse_field_definitions(PARSING_DEFS(_dex_encoded_catch_handler_list),
+ G_BIN_FORMAT(format), pos, &size);
+
+ for (i = 0; i < size && result; i++)
+ result = annotate_dex_encoded_catch_handler(format, pos);
return result;
@@ -421,9 +486,9 @@ static bool annotate_dex_encoded_catch_handler(const GDexFormat *format, vmpa2t
/******************************************************************************
* *
* Paramètres : format = description de l'exécutable à compléter. *
-* pos = tête de lecture des symboles. *
+* pos = tête de lecture physique des symboles. *
* *
-* Description : Commente les définitions des gestions d'exceptions par type. *
+* Description : Commente les définitions d'une prise en compte d'exceptions. *
* *
* Retour : Bilan de l'opération. *
* *
@@ -431,45 +496,60 @@ static bool annotate_dex_encoded_catch_handler(const GDexFormat *format, vmpa2t
* *
******************************************************************************/
-static bool annotate_dex_encoded_type_addr_pair(const GDexFormat *format, vmpa2t *pos)
+static bool annotate_dex_encoded_catch_handler(const GDexFormat *format, vmpa2t *pos)
{
- GBinContent *content; /* Contenu binaire à lire */
- GArchInstruction *instr; /* Instruction décodée */
- GArchOperand *operand; /* Opérande à venir modifier */
- GDbComment *comment; /* Définition de commentaire */
- GBinSymbol *symbol; /* Symbole à intégrer */
- char *text; /* Texte constant à insérer */
+ bool result; /* Bilan à retourner */
+ leb128_t size; /* Nombre de gestionnaires */
+ bool has_catch_all; /* Gestion par défaut ? */
+ uleb128_t i; /* Boucle de parcours */
- content = g_binary_format_get_content(G_BIN_FORMAT(format));
+ result = parse_field_definitions(PARSING_DEFS(_dex_encoded_catch_handler), G_BIN_FORMAT(format), pos, &size);
- /* type_idx */
+ if (!result)
+ goto adech_exit;
- instr = g_raw_instruction_new_uleb128(content, pos);
+ has_catch_all = (size <= 0);
- SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC);
+ if (size < 0)
+ size *= -1;
- asprintf(&text, _("Index for the type of the exception to catch"));
+ /* handlers */
- ADD_RAW_AS_SYM(format, symbol, instr, comment, text);
+ for (i = 0; i < size && result; i++)
+ result = annotate_dex_encoded_type_addr_pair(format, pos);
- free(text);
+ /* catch_all_addr */
- /* addr */
+ if (result && has_catch_all)
+ result = parse_field_definitions(PARSING_DEFS(_dex_encoded_catch_handler_all),
+ G_BIN_FORMAT(format), pos, &size);
- instr = g_raw_instruction_new_uleb128(content, pos);
+ adech_exit:
- SET_IMM_DISPLAY(instr, operand, 0, IOD_HEX);
+ return result;
- asprintf(&text, _("Bytecode address of the associated exception handler"));
+}
- ADD_RAW_AS_SYM(format, symbol, instr, comment, text);
- free(text);
+/******************************************************************************
+* *
+* Paramètres : format = description de l'exécutable à compléter. *
+* pos = tête de lecture des symboles. *
+* *
+* Description : Commente les définitions des gestions d'exceptions par type. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
- /* Nettoyage final */
+static bool annotate_dex_encoded_type_addr_pair(const GDexFormat *format, vmpa2t *pos)
+{
+ bool result; /* Bilan à retourner */
- g_object_unref(G_OBJECT(content));
+ result = parse_field_definitions(PARSING_DEFS(_dex_encoded_type_addr_pair), G_BIN_FORMAT(format), pos, NULL);
- return true;
+ return result;
}