diff options
Diffstat (limited to 'src/arch')
| -rw-r--r-- | src/arch/dalvik/context.c | 67 | ||||
| -rw-r--r-- | src/arch/dalvik/decomp/const.c | 4 | ||||
| -rw-r--r-- | src/arch/dalvik/decomp/iget.c | 4 | ||||
| -rw-r--r-- | src/arch/dalvik/decomp/invoke.c | 12 | ||||
| -rw-r--r-- | src/arch/dalvik/decomp/iput.c | 4 | ||||
| -rw-r--r-- | src/arch/dalvik/decomp/new.c | 4 | 
6 files changed, 66 insertions, 29 deletions
| diff --git a/src/arch/dalvik/context.c b/src/arch/dalvik/context.c index e5041cb..f1af7e9 100644 --- a/src/arch/dalvik/context.c +++ b/src/arch/dalvik/context.c @@ -114,6 +114,12 @@ static void g_dalvik_dcontext_class_init(GDalvikDContextClass *);  /* Initialise une instance de contexte de décompilation Dalkvik. */  static void g_dalvik_dcontext_init(GDalvikDContext *); +/* Supprime toutes les références externes. */ +static void g_dalvik_dcontext_dispose(GDalvikDContext *); + +/* Procède à la libération totale de la mémoire. */ +static void g_dalvik_dcontext_finalize(GDalvikDContext *); +  /* Convertit un registre machine en un pseudo-registre. */  static GDecInstruction *g_dalvik_dcontext_convert_register(GDalvikDContext *, GDalvikRegisterOperand *, bool); @@ -282,7 +288,7 @@ G_DEFINE_TYPE(GDalvikDContext, g_dalvik_dcontext, G_TYPE_DEC_CONTEXT);  /******************************************************************************  *                                                                             * -*  Paramètres  : klass = classe à initialiser.                                * +*  Paramètres  : class = classe à initialiser.                                *  *                                                                             *  *  Description : Initialise la classe des contextes de décompilation Dalkvik. *  *                                                                             * @@ -292,8 +298,14 @@ G_DEFINE_TYPE(GDalvikDContext, g_dalvik_dcontext, G_TYPE_DEC_CONTEXT);  *                                                                             *  ******************************************************************************/ -static void g_dalvik_dcontext_class_init(GDalvikDContextClass *klass) +static void g_dalvik_dcontext_class_init(GDalvikDContextClass *class)  { +    GObjectClass *object;                   /* Autre version de la classe  */ + +    object = G_OBJECT_CLASS(class); + +    object->dispose = (GObjectFinalizeFunc/* ! */)g_dalvik_dcontext_dispose; +    object->finalize = (GObjectFinalizeFunc)g_dalvik_dcontext_finalize;  } @@ -326,6 +338,47 @@ static void g_dalvik_dcontext_init(GDalvikDContext *ctx)  /******************************************************************************  *                                                                             * +*  Paramètres  : ctx = instance d'objet GLib à traiter.                       * +*                                                                             * +*  Description : Supprime toutes les références externes.                     * +*                                                                             * +*  Retour      : -                                                            * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +static void g_dalvik_dcontext_dispose(GDalvikDContext *ctx) +{ +    if (ctx->this != NULL) +        g_object_unref(G_OBJECT(ctx->this)); + +    G_OBJECT_CLASS(g_dalvik_dcontext_parent_class)->dispose(G_OBJECT(ctx)); + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : ctx = instance d'objet GLib à traiter.                       * +*                                                                             * +*  Description : Procède à la libération totale de la mémoire.                * +*                                                                             * +*  Retour      : -                                                            * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +static void g_dalvik_dcontext_finalize(GDalvikDContext *ctx) +{ +    G_OBJECT_CLASS(g_dalvik_dcontext_parent_class)->finalize(G_OBJECT(ctx)); + +} + + +/****************************************************************************** +*                                                                             *  *  Paramètres  : -                                                            *  *                                                                             *  *  Description : Crée un contexte pour la décompilation Dalvik.               * @@ -373,8 +426,8 @@ static GDecInstruction *g_dalvik_dcontext_convert_register(GDalvikDContext *ctx,      GBinVariable *this;                     /* Définition de "this"        */      gpointer *found;                        /* Pseudo-registre trouvé      */ -    format = G_DEX_FORMAT(g_object_get_data(G_OBJECT(ctx), "format")); -    routine = G_BIN_ROUTINE(g_object_get_data(G_OBJECT(ctx), "routine")); +    format = G_DEX_FORMAT(G_DEC_CONTEXT(ctx)->format); +    routine = G_DEC_CONTEXT(ctx)->routine;      method = g_dex_format_find_method_by_address(format, g_binary_routine_get_address(routine)); @@ -386,10 +439,7 @@ static GDecInstruction *g_dalvik_dcontext_convert_register(GDalvikDContext *ctx,      /* Objet "this" */      if (info & DVI_THIS)      { -        if (ctx->this != NULL) -            g_object_ref(G_OBJECT(ctx->this)); - -        else +        if (ctx->this == NULL)          {              this = g_binary_variable_new(/* FIXME */g_basic_type_new(BTP_OTHER) /* FIXME */);              g_binary_variable_set_name(this, "this"); @@ -399,6 +449,7 @@ static GDecInstruction *g_dalvik_dcontext_convert_register(GDalvikDContext *ctx,          } +        g_object_ref(G_OBJECT(ctx->this));          result = ctx->this;      } diff --git a/src/arch/dalvik/decomp/const.c b/src/arch/dalvik/decomp/const.c index 47a859e..98133ac 100644 --- a/src/arch/dalvik/decomp/const.c +++ b/src/arch/dalvik/decomp/const.c @@ -83,7 +83,6 @@ GDecInstruction *dalvik_decomp_instr_const_str(const GArchInstruction *instr, GD      GArchOperand *operand;                  /* Opérande de l'instruction   */      GDecInstruction *reg;                   /* Pseudo-registre redéfini    */      uint32_t index;                         /* Indice de la chaîne         */ -    GDexFormat *format;                     /* Accès aux constantes        */      const char *value;                      /* Chaîne de caractères        */      GDecInstruction *str;                   /* Chaîne décompilée           */ @@ -93,8 +92,7 @@ GDecInstruction *dalvik_decomp_instr_const_str(const GArchInstruction *instr, GD      operand = g_arch_instruction_get_operand(instr, 1);      index = g_dalvik_pool_operand_get_index(G_DALVIK_POOL_OPERAND(operand)); -    format = G_DEX_FORMAT(g_object_get_data(G_OBJECT(ctx), "format")); -    value = get_string_from_dex_pool(format, index); +    value = get_string_from_dex_pool(G_DEX_FORMAT(g_dec_context_get_format(ctx)), index);      if (value == NULL) return NULL;      str = g_str_expression_new(value); diff --git a/src/arch/dalvik/decomp/iget.c b/src/arch/dalvik/decomp/iget.c index 931438c..5d1cf65 100644 --- a/src/arch/dalvik/decomp/iget.c +++ b/src/arch/dalvik/decomp/iget.c @@ -50,7 +50,6 @@ GDecInstruction *dalvik_decomp_instr_iget(const GArchInstruction *instr, GDecCon      GArchOperand *operand;                  /* Opérande de l'instruction   */      GDecInstruction *src;                   /* Registre de l'object        */      uint32_t index;                         /* Indice dans la table        */ -    GDexFormat *format;                     /* Accès aux constantes        */      GDecInstruction *field;                 /* Champ concerné par l'opérat°*/      GBinVariable *var;                      /* Variable / champ accédé     */      GDecInstruction *dest;                  /* Registre de destination     */ @@ -61,8 +60,7 @@ GDecInstruction *dalvik_decomp_instr_iget(const GArchInstruction *instr, GDecCon      operand = g_arch_instruction_get_operand(instr, 2);      index = g_dalvik_pool_operand_get_index(G_DALVIK_POOL_OPERAND(operand)); -    format = G_DEX_FORMAT(g_object_get_data(G_OBJECT(ctx), "format")); -    var = get_field_from_dex_pool(format, index); +    var = get_field_from_dex_pool(G_DEX_FORMAT(g_dec_context_get_format(ctx)), index);      field = g_pseudo_register_new();      g_pseudo_register_set_variable(G_PSEUDO_REGISTER(field), var); diff --git a/src/arch/dalvik/decomp/invoke.c b/src/arch/dalvik/decomp/invoke.c index 6f863be..7337ccc 100644 --- a/src/arch/dalvik/decomp/invoke.c +++ b/src/arch/dalvik/decomp/invoke.c @@ -58,7 +58,6 @@ GDecInstruction *dalvik_decomp_instr_invoke_direct(const GArchInstruction *instr      size_t count;                           /* Quantité d'opérandes        */      GArchOperand *operand;                  /* Opérande de l'instruction   */      uint32_t index;                         /* Indice de l'élément visé    */ -    GDexFormat *format;                     /* Accès aux constantes        */      GBinRoutine *routine;                   /* Routine visée par l'appel   */      const char *name;                       /* Chaîne à afficher           */      GDecInstruction *src;                   /* Source de l'assignation     */ @@ -80,8 +79,7 @@ GDecInstruction *dalvik_decomp_instr_invoke_direct(const GArchInstruction *instr      index = g_dalvik_pool_operand_get_index(G_DALVIK_POOL_OPERAND(operand)); -    format = G_DEX_FORMAT(g_object_get_data(G_OBJECT(ctx), "format")); -    routine = get_routine_from_dex_pool(format, index); +    routine = get_routine_from_dex_pool(G_DEX_FORMAT(g_dec_context_get_format(ctx)), index);      if (routine == NULL) return NULL;      /* Détermination de la routine-cible exacte */ @@ -158,7 +156,6 @@ GDecInstruction *dalvik_decomp_instr_invoke_static(const GArchInstruction *instr      size_t count;                           /* Quantité d'opérandes        */      GArchOperand *operand;                  /* Opérande de l'instruction   */      uint32_t index;                         /* Indice de l'élément visé    */ -    GDexFormat *format;                     /* Accès aux constantes        */      GBinRoutine *routine;                   /* Routine visée par l'appel   */      GDecInstruction *call;                  /* Représentation de l'appel   */      size_t i;                               /* Boucle de parcours #2       */ @@ -174,8 +171,7 @@ GDecInstruction *dalvik_decomp_instr_invoke_static(const GArchInstruction *instr      index = g_dalvik_pool_operand_get_index(G_DALVIK_POOL_OPERAND(operand)); -    format = G_DEX_FORMAT(g_object_get_data(G_OBJECT(ctx), "format")); -    routine = get_routine_from_dex_pool(format, index); +    routine = get_routine_from_dex_pool(G_DEX_FORMAT(g_dec_context_get_format(ctx)), index);      if (routine == NULL) return NULL;      call = g_routine_call_new(routine); @@ -218,7 +214,6 @@ GDecInstruction *dalvik_decomp_instr_invoke_virtual(const GArchInstruction *inst      size_t count;                           /* Quantité d'opérandes        */      GArchOperand *operand;                  /* Opérande de l'instruction   */      uint32_t index;                         /* Indice de l'élément visé    */ -    GDexFormat *format;                     /* Accès aux constantes        */      GBinRoutine *routine;                   /* Routine visée par l'appel   */      GDecInstruction *call;                  /* Représentation de l'appel   */      size_t i;                               /* Boucle de parcours #2       */ @@ -234,8 +229,7 @@ GDecInstruction *dalvik_decomp_instr_invoke_virtual(const GArchInstruction *inst      index = g_dalvik_pool_operand_get_index(G_DALVIK_POOL_OPERAND(operand)); -    format = G_DEX_FORMAT(g_object_get_data(G_OBJECT(ctx), "format")); -    routine = get_routine_from_dex_pool(format, index); +    routine = get_routine_from_dex_pool(G_DEX_FORMAT(g_dec_context_get_format(ctx)), index);      if (routine == NULL) return NULL;      call = g_routine_call_new(routine); diff --git a/src/arch/dalvik/decomp/iput.c b/src/arch/dalvik/decomp/iput.c index 002bdd4..fedb00e 100644 --- a/src/arch/dalvik/decomp/iput.c +++ b/src/arch/dalvik/decomp/iput.c @@ -51,7 +51,6 @@ GDecInstruction *dalvik_decomp_instr_iput(const GArchInstruction *instr, GDecCon      GDecInstruction *dest;                  /* Registre de destination     */      GDecInstruction *src;                   /* Registre de l'object        */      uint32_t index;                         /* Indice dans la table        */ -    GDexFormat *format;                     /* Accès aux constantes        */      GDecInstruction *field;                 /* Champ concerné par l'opérat°*/      GBinVariable *var;                      /* Variable / champ accédé     */      GDecInstruction *access;                /* Représentation de l'accès   */ @@ -64,8 +63,7 @@ GDecInstruction *dalvik_decomp_instr_iput(const GArchInstruction *instr, GDecCon      operand = g_arch_instruction_get_operand(instr, 2);      index = g_dalvik_pool_operand_get_index(G_DALVIK_POOL_OPERAND(operand)); -    format = G_DEX_FORMAT(g_object_get_data(G_OBJECT(ctx), "format")); -    var = get_field_from_dex_pool(format, index); +    var = get_field_from_dex_pool(G_DEX_FORMAT(g_dec_context_get_format(ctx)), index);      field = g_pseudo_register_new();      g_pseudo_register_set_variable(G_PSEUDO_REGISTER(field), var); diff --git a/src/arch/dalvik/decomp/new.c b/src/arch/dalvik/decomp/new.c index ff80411..75dc259 100644 --- a/src/arch/dalvik/decomp/new.c +++ b/src/arch/dalvik/decomp/new.c @@ -48,7 +48,6 @@ GDecInstruction *dalvik_decomp_instr_new_instance(const GArchInstruction *instr,      GDecInstruction *result;                /* Instruction à retourner     */      GArchOperand *operand;                  /* Opérande de l'instruction   */      uint32_t index;                         /* Indice dans la table        */ -    GDexFormat *format;                     /* Accès aux constantes        */      GDataType *type;                        /* Type concerné par l'opérat° */      GBinRoutine *constructor;               /* Constructeur reconstruit    */      GDecInstruction *call;                  /* Appel au constructeur       */ @@ -56,8 +55,7 @@ GDecInstruction *dalvik_decomp_instr_new_instance(const GArchInstruction *instr,      operand = g_arch_instruction_get_operand(instr, 1);      index = g_dalvik_pool_operand_get_index(G_DALVIK_POOL_OPERAND(operand)); -    format = G_DEX_FORMAT(g_object_get_data(G_OBJECT(ctx), "format")); -    type = get_type_from_dex_pool(format, index); +    type = get_type_from_dex_pool(G_DEX_FORMAT(g_dec_context_get_format(ctx)), index);      constructor = g_binary_routine_new_constructor(type);      call = g_routine_call_new(constructor); | 
