diff options
Diffstat (limited to 'plugins/dalvik')
| -rw-r--r-- | plugins/dalvik/context.c | 379 | ||||
| -rw-r--r-- | plugins/dalvik/context.h | 28 | ||||
| -rw-r--r-- | plugins/dalvik/processor.c | 24 | 
3 files changed, 0 insertions, 431 deletions
| diff --git a/plugins/dalvik/context.c b/plugins/dalvik/context.c index 70cbee5..e27fbf0 100644 --- a/plugins/dalvik/context.c +++ b/plugins/dalvik/context.c @@ -89,55 +89,6 @@ static void g_dalvik_context_finalize(GDalvikContext *); -/* ------------------------- CONTEXTE POUR LA DECOMPILATION ------------------------- */ - - -#if 0 -/* Définition d'un contexte pour décompilation Dalkvik (instance) */ -struct _GDalvikDContext -{ -    GDecContext parent;                     /* A laisser en premier        */ - -    GDecInstruction *this;                  /* Représentation de la classe */ -    GHashTable *args;                       /* Correspondance arg./pseudo  */ -    GHashTable *locals;                     /* Correspondance var./pseudo  */ -    size_t locals_count;                    /* Quantité de var. locales    */ - -}; - - -/* Définition d'un contexte pour décompilation Dalkvik (classe) */ -struct _GDalvikDContextClass -{ -    GDecContextClass parent;                /* A laisser en premier        */ - -}; - - -/* Initialise la classe des contextes de décompilation Dalkvik. */ -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 *); - -/* Duplique un contexte de compilation. */ -static GDalvikDContext *g_dalvik_dcontext_dup(GDalvikDContext *); - -/* Propage un registre alloué et attendu par la suite. */ -static void g_dalvik_context_spread_allocated_shared_reg(GDalvikDContext *, GDalvikRegister *, GDecInstruction *); - -/* Convertit un registre machine en un pseudo-registre. */ -static GDecInstruction *g_dalvik_dcontext_convert_register(GDalvikDContext *, GDalvikRegisterOperand *, bool, vmpa_t); -#endif - - -  /* ---------------------------------------------------------------------------------- */  /*                          MANIPULATION GLOBALE DU CONTEXTE                          */  /* ---------------------------------------------------------------------------------- */ @@ -481,333 +432,3 @@ GArchInstruction *g_dalvik_context_get_raw_data(GDalvikContext *ctx, const GBinC      return result;  } - - - -/* ---------------------------------------------------------------------------------- */ -/*                           CONTEXTE POUR LA DECOMPILATION                           */ -/* ---------------------------------------------------------------------------------- */ - - -#if 0 -/* Indique le type définit par la GLib pour le contexte de décompilation Dalkvik. */ -G_DEFINE_TYPE(GDalvikDContext, g_dalvik_dcontext, G_TYPE_DEC_CONTEXT); - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : class = classe à initialiser.                                * -*                                                                             * -*  Description : Initialise la classe des contextes de décompilation Dalkvik. * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -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; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : ctx = instance à initialiser.                                * -*                                                                             * -*  Description : Initialise une instance de contexte de décompilation Dalkvik.* -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static void g_dalvik_dcontext_init(GDalvikDContext *ctx) -{ -    GDecContext *parent;                    /* Instance parente            */ - -    ctx->args = g_hash_table_new(g_constant_hash, g_direct_equal); -    ctx->locals = g_hash_table_new(g_constant_hash, g_direct_equal); - -    parent = G_DEC_CONTEXT(ctx); - -    parent->dup = (dup_dec_context_fc)g_dalvik_dcontext_dup; -    parent->spread = (spread_reg_fc)g_dalvik_context_spread_allocated_shared_reg; -    parent->convert_reg = (convert_register_fc)g_dalvik_dcontext_convert_register; - -} - - -/****************************************************************************** -*                                                                             * -*  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.               * -*                                                                             * -*  Retour      : Contexte mis en place.                                       * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -GDalvikDContext *g_dalvik_dcontext_new(void) -{ -    GDalvikDContext *result;                /* Structure à retourner       */ - -    result = g_object_new(G_TYPE_DALVIK_DCONTEXT, NULL); - -    return result; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : orig = contexte de compilation à copier.                     * -*                                                                             * -*  Description : Duplique un contexte de compilation.                         * -*                                                                             * -*  Retour      : Contexte de décompilation prêt à emploi.                     * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static GDalvikDContext *g_dalvik_dcontext_dup(GDalvikDContext *orig) -{ -    GDalvikDContext *result;                /* Structure à retourner       */ - -    result = g_object_new(G_TYPE_DALVIK_DCONTEXT, NULL); - -    //g_object_unref(G_OBJECT(result->args)); -    //g_object_unref(G_OBJECT(result->locals)); - -    _g_dec_context_dup(G_DEC_CONTEXT(result), G_DEC_CONTEXT(orig)); - -    if (orig->this != NULL) g_object_ref(G_OBJECT(orig->this)); -    //g_object_ref(G_OBJECT(orig->args)); -    //g_object_ref(G_OBJECT(orig->locals)); - -    result->this = orig->this; -    result->args = orig->args; -    result->locals = orig->locals; -    result->locals_count = orig->locals_count; - -    return result; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : parent = instance à éventuellement compléter.                * -*                child  = instance à venir consulter.                         * -*                                                                             * -*  Description : Propage un registre alloué et attendu par la suite.          * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static void g_dalvik_context_spread_allocated_shared_reg(GDalvikDContext *ctx, GDalvikRegister *reg, GDecInstruction *dinstr) -{ -    GDexFormat *format;                     /* Recherche de méthode        */ -    GBinRoutine *routine;                   /* Objet des recherches        */ -    const mrange_t *range;                  /* Emplacement du symbole      */ -    GDexMethod *method;                     /* Méthode décompilée          */ -    uint16_t index;                         /* Identifiant du registre     */ -    DexVariableIndex info;                  /* Nature du registre          */ - -    format = G_DEX_FORMAT(G_DEC_CONTEXT(ctx)->format); -    routine = G_DEC_CONTEXT(ctx)->routine; -    range = g_binary_symbol_get_range(G_BIN_SYMBOL(routine)); - -    method = g_dex_format_find_method_by_address(format, get_mrange_addr(range)); - -    index = g_dalvik_register_get_index(reg); -    info = g_dex_method_get_variable(method, index); - -    g_object_ref(G_OBJECT(dinstr)); -    g_hash_table_insert(ctx->locals, GUINT_TO_POINTER(DVI_INDEX(info)), dinstr); -    ctx->locals_count++; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : ctx     = instance à consulter, voire mettre à jour.         * -*                operand = opérande représentant un registre quelconque.      * -*                assign  = précise le sort prochain du registre.              * -*                addr    = adresse de l'instruction décompilée.               * -*                                                                             * -*  Description : Convertit un registre machine en un pseudo-registre.         * -*                                                                             * -*  Retour      : Pseudo-registre, existant ou non, prêt à emploi.             * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static GDecInstruction *g_dalvik_dcontext_convert_register(GDalvikDContext *ctx, GDalvikRegisterOperand *operand, bool assign, vmpa_t addr) -{ -    GDecInstruction *result;                /* Instance à retourner        */ -    GDexFormat *format;                     /* Recherche de méthode        */ -    GBinRoutine *routine;                   /* Objet des recherches        */ -    const mrange_t *range;                  /* Emplacement du symbole      */ -    GDexMethod *method;                     /* Méthode décompilée          */ -    const GDalvikRegister *reg;             /* Registre Dalvik représenté  */ -    uint16_t index;                         /* Identifiant du registre     */ -    DexVariableIndex info;                  /* Nature du registre          */ -    GBinVariable *this;                     /* Définition de "this"        */ -    gpointer *found;                        /* Pseudo-registre trouvé      */ - -    format = G_DEX_FORMAT(G_DEC_CONTEXT(ctx)->format); -    routine = G_DEC_CONTEXT(ctx)->routine; -    range = g_binary_symbol_get_range(G_BIN_SYMBOL(routine)); - -    method = g_dex_format_find_method_by_address(format, get_mrange_addr(range)); - -    reg = g_dalvik_register_operand_get(operand); - -    index = g_dalvik_register_get_index(reg); -    info = g_dex_method_get_variable(method, index); - -    /* Objet "this" */ -    if (info & DVI_THIS) -    { -        if (ctx->this == NULL) -        { -            this = g_binary_variable_new(/* FIXME */g_basic_type_new(BTP_OTHER) /* FIXME */); -            g_binary_variable_set_name(this, "this"); - -            ctx->this = g_pseudo_register_new(PRU_THIS); -            g_pseudo_register_set_variable(G_PSEUDO_REGISTER(ctx->this), this); - -        } - -        g_object_ref(G_OBJECT(ctx->this)); -        result = ctx->this; - -    } - -    /* Argument d'appel */ -    else if (info & DVI_ARGUMENT) -    { -        found = g_hash_table_lookup(ctx->args, GUINT_TO_POINTER(DVI_INDEX(info))); - -        if (found != NULL) -        { -            g_object_ref(G_OBJECT(found)); -            result = G_DEC_INSTRUCTION(found); -        } -        else -        { -            result = g_pseudo_register_new(PRU_ARG); -            g_pseudo_register_set_basename(G_PSEUDO_REGISTER(result), "arg"); -            g_pseudo_register_set_index(G_PSEUDO_REGISTER(result), DVI_INDEX(info)); - -            g_hash_table_insert(ctx->args, GUINT_TO_POINTER(DVI_INDEX(info)), result); - -        } - -    } - -    /* Variable locale */ -    else -    { -        found = g_hash_table_lookup(ctx->locals, GUINT_TO_POINTER(DVI_INDEX(info))); - -        if (!assign && found != NULL) -        { -            g_object_ref(G_OBJECT(found)); -            result = G_DEC_INSTRUCTION(found); -        } -        else -        { -            /* -            if (!assign) -            { -                printf("bug"); -                exit(0); -            } -            */ - -            result = g_dec_context_get_awaited_alloc(G_DEC_CONTEXT(ctx), G_ARCH_REGISTER(reg), addr); - -            if (result == NULL) -            { -                result = g_pseudo_register_new(PRU_LOCAL); -                g_pseudo_register_set_basename(G_PSEUDO_REGISTER(result), "var"); -                g_pseudo_register_set_index(G_PSEUDO_REGISTER(result), ctx->locals_count); - -                g_dec_context_notify_reg_alloc(G_DEC_CONTEXT(ctx), G_ARCH_REGISTER(reg), -                                               result, addr); - -            } -            else -                g_object_ref(G_OBJECT(result)); - -            g_object_ref(G_OBJECT(result)); -            g_hash_table_insert(ctx->locals, GUINT_TO_POINTER(DVI_INDEX(info)), result); -            ctx->locals_count++; - -        } - -    } - -    return result; - -} -#endif diff --git a/plugins/dalvik/context.h b/plugins/dalvik/context.h index dbcc979..1dd45f7 100644 --- a/plugins/dalvik/context.h +++ b/plugins/dalvik/context.h @@ -71,32 +71,4 @@ GArchInstruction *g_dalvik_context_get_raw_data(GDalvikContext *, const GBinCont -/* ------------------------- CONTEXTE POUR LA DECOMPILATION ------------------------- */ - - -#if 0 -#define G_TYPE_DALVIK_DCONTEXT              g_dalvik_dcontext_get_type() -#define G_DALVIK_DCONTEXT(obj)              (G_TYPE_CHECK_INSTANCE_CAST((obj), g_dalvik_dcontext_get_type(), GDalvikDContext)) -#define G_IS_DALVIK_DCONTEXT(obj)           (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_dalvik_dcontext_get_type())) -#define G_DALVIK_DCONTEXT_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_DALVIK_DCONTEXT, GGDalvikDContextClass)) -#define G_IS_DALVIK_DCONTEXT_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_DALVIK_DCONTEXT)) -#define G_DALVIK_DCONTEXT_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_DALVIK_DCONTEXT, GGDalvikDContextClass)) - - -/* Définition d'un contexte pour décompilation Dalkvik (instance) */ -typedef struct _GDalvikDContext GDalvikDContext; - -/* Définition d'un contexte pour décompilation Dalkvik (classe) */ -typedef struct _GDalvikDContextClass GDalvikDContextClass; - - -/* Indique le type définit par la GLib pour le contexte de décompilation Dalkvik. */ -GType g_dalvik_dcontext_get_type(void); - -/* Crée un contexte pour la décompilation Dalvik. */ -GDalvikDContext *g_dalvik_dcontext_new(void); -#endif - - -  #endif  /* _PLUGINS_DALVIK_CONTEXT_H */ diff --git a/plugins/dalvik/processor.c b/plugins/dalvik/processor.c index 3ed0507..5c5ecb6 100644 --- a/plugins/dalvik/processor.c +++ b/plugins/dalvik/processor.c @@ -53,9 +53,6 @@ static void g_dalvik_processor_finalize(GDalvikProcessor *);  /* Fournit un contexte pour l'exécution du processeur Dalvik. */  static GDalvikContext *g_dalvik_processor_get_context(const GDalvikProcessor *); -/* Fournit un contexte pour la décompilation Dalvik. */ -//static GDalvikDContext *g_dalvik_processor_get_decomp_context(const GDalvikProcessor *); -  /* Indique le type défini par la GLib pour le processeur DALVIK. */ @@ -87,7 +84,6 @@ static void g_dalvik_processor_class_init(GDalvikProcessorClass *klass)      proc = G_ARCH_PROCESSOR_CLASS(klass);      proc->get_ctx = (get_processor_context_fc)g_dalvik_processor_get_context; -    //proc->get_dec_ctx = (get_decomp_context_fc)g_dalvik_processor_get_decomp_context;  } @@ -177,26 +173,6 @@ static GDalvikContext *g_dalvik_processor_get_context(const GDalvikProcessor *pr  /******************************************************************************  *                                                                             * -*  Paramètres  : proc = architecture, spectatrice ici.                        * -*                                                                             * -*  Description : Fournit un contexte pour la décompilation Dalvik.            * -*                                                                             * -*  Retour      : Contexte mis en place.                                       * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ -#if 0 -static GDalvikDContext *g_dalvik_processor_get_decomp_context(const GDalvikProcessor *proc) -{ -    return g_dalvik_dcontext_new(); - -} -#endif - - -/****************************************************************************** -*                                                                             *  *  Paramètres  : proc    = architecture visée par la procédure.               *  *                data    = flux de données à analyser.                        *  *                pos     = position courante dans ce flux. [OUT]              * | 
