diff options
Diffstat (limited to 'plugins/dalvik')
-rw-r--r-- | plugins/dalvik/core.c | 39 | ||||
-rw-r--r-- | plugins/dalvik/operand.c | 2 | ||||
-rw-r--r-- | plugins/dalvik/operands/args.c | 108 | ||||
-rw-r--r-- | plugins/dalvik/operands/args.h | 12 | ||||
-rw-r--r-- | plugins/dalvik/operands/pool.c | 99 | ||||
-rw-r--r-- | plugins/dalvik/operands/register.c | 156 | ||||
-rw-r--r-- | plugins/dalvik/operands/register.h | 6 | ||||
-rw-r--r-- | plugins/dalvik/register.h | 12 | ||||
-rw-r--r-- | plugins/dalvik/v35/Makefile.am | 1 | ||||
-rw-r--r-- | plugins/dalvik/v35/core.c | 99 | ||||
-rw-r--r-- | plugins/dalvik/v35/core.h | 40 |
11 files changed, 474 insertions, 100 deletions
diff --git a/plugins/dalvik/core.c b/plugins/dalvik/core.c index f945c18..cc96843 100644 --- a/plugins/dalvik/core.c +++ b/plugins/dalvik/core.c @@ -24,12 +24,14 @@ #include "core.h" -#include <core/processors.h> #include <plugins/plugin-def.h> #include "register.h" -#include "v35/processor.h" +#include "operands/args.h" +#include "operands/pool.h" +#include "operands/register.h" +#include "v35/core.h" @@ -38,6 +40,32 @@ DEFINE_CHRYSALIDE_PLUGIN("dalvik", "Add support for the Dalvik architecture", "0 +/* Assure l'enregistrement de types pour les caches à charger. */ +static void register_dalvik_gtypes(void); + + + +/****************************************************************************** +* * +* Paramètres : - * +* * +* Description : Assure l'enregistrement de types pour les caches à charger. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void register_dalvik_gtypes(void) +{ + g_type_ensure(G_TYPE_DALVIK_ARGS_OPERAND); + g_type_ensure(G_TYPE_DALVIK_POOL_OPERAND); + g_type_ensure(G_TYPE_DALVIK_REGISTER_OPERAND); + +} + + /****************************************************************************** * * * Paramètres : plugin = greffon à manipuler. * @@ -54,12 +82,15 @@ G_MODULE_EXPORT bool chrysalide_plugin_init(GPluginModule *plugin) { bool result; /* Bilan à retourner */ - result = register_processor_type("dalvik35", "Dalvik Virtual Machine v35", G_TYPE_DALVIK35_PROCESSOR); + register_dalvik_gtypes(); + + result = init_dalvik35_core(); return result; } + /****************************************************************************** * * * Paramètres : plugin = greffon à manipuler. * @@ -74,6 +105,8 @@ G_MODULE_EXPORT bool chrysalide_plugin_init(GPluginModule *plugin) G_MODULE_EXPORT void chrysalide_plugin_exit(GPluginModule *plugin) { + exit_dalvik35_core(); + clean_dalvik_register_cache(); } diff --git a/plugins/dalvik/operand.c b/plugins/dalvik/operand.c index ae57498..4d8fc73 100644 --- a/plugins/dalvik/operand.c +++ b/plugins/dalvik/operand.c @@ -747,7 +747,7 @@ void dalvik_mark_first_operand_as_written(GArchInstruction *instr) operand = g_arch_instruction_get_operand(instr, 0); - g_dalvik_register_operand_mark_as_written(G_DALVIK_REGISTER_OPERAND(operand)); + g_register_operand_mark_as_written(G_REGISTER_OPERAND(operand)); g_object_unref(G_OBJECT(operand)); diff --git a/plugins/dalvik/operands/args.c b/plugins/dalvik/operands/args.c index f35a11f..5224567 100644 --- a/plugins/dalvik/operands/args.c +++ b/plugins/dalvik/operands/args.c @@ -72,6 +72,17 @@ static void g_dalvik_args_operand_print(const GDalvikArgsOperand *, GBufferLine +/* --------------------- TRANSPOSITIONS VIA CACHE DES OPERANDES --------------------- */ + + +/* Charge un opérande depuis une mémoire tampon. */ +static bool g_dalvik_args_operand_unserialize(GDalvikArgsOperand *, GAsmStorage *, GBinFormat *, packed_buffer *); + +/* Sauvegarde un opérande dans une mémoire tampon. */ +static bool g_dalvik_args_operand_serialize(const GDalvikArgsOperand *, GAsmStorage *, packed_buffer *); + + + /* Indique le type défini par la GLib pour une liste d'arguments Dalvik. */ G_DEFINE_TYPE(GDalvikArgsOperand, g_dalvik_args_operand, G_TYPE_ARCH_OPERAND); @@ -102,6 +113,9 @@ static void g_dalvik_args_operand_class_init(GDalvikArgsOperandClass *klass) operand->compare = (operand_compare_fc)g_dalvik_args_operand_compare; operand->print = (operand_print_fc)g_dalvik_args_operand_print; + operand->unserialize = (unserialize_operand_fc)g_dalvik_args_operand_unserialize; + operand->serialize = (serialize_operand_fc)g_dalvik_args_operand_serialize; + } @@ -119,6 +133,8 @@ static void g_dalvik_args_operand_class_init(GDalvikArgsOperandClass *klass) static void g_dalvik_args_operand_init(GDalvikArgsOperand *operand) { + operand->args = NULL; + operand->count = 0; } @@ -161,6 +177,9 @@ static void g_dalvik_args_operand_dispose(GDalvikArgsOperand *operand) static void g_dalvik_args_operand_finalize(GDalvikArgsOperand *operand) { + if (operand->args != NULL) + free(operand->args); + G_OBJECT_CLASS(g_dalvik_args_operand_parent_class)->finalize(G_OBJECT(operand)); } @@ -280,7 +299,6 @@ GArchOperand *g_dalvik_args_operand_new(void) void g_dalvik_args_operand_add(GDalvikArgsOperand *operand, GArchOperand *arg) { - operand->count++; operand->args = (GArchOperand **)realloc(operand->args, operand->count * sizeof(GArchOperand *)); @@ -328,3 +346,91 @@ GArchOperand *g_dalvik_args_operand_get(const GDalvikArgsOperand *operand, size_ return operand->args[index]; } + + + +/* ---------------------------------------------------------------------------------- */ +/* TRANSPOSITIONS VIA CACHE DES OPERANDES */ +/* ---------------------------------------------------------------------------------- */ + + +/****************************************************************************** +* * +* Paramètres : operand = opérande d'assemblage à constituer. * +* storage = mécanisme de sauvegarde à manipuler. * +* format = format binaire chargé associé à l'architecture. * +* pbuf = zone tampon à remplir. * +* * +* Description : Charge un opérande depuis une mémoire tampon. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static bool g_dalvik_args_operand_unserialize(GDalvikArgsOperand *operand, GAsmStorage *storage, GBinFormat *format, packed_buffer *pbuf) +{ + bool result; /* Bilan à retourner */ + GArchOperandClass *parent; /* Classe parente à consulter */ + size_t count; /* Nombre d'opérandes à charger*/ + size_t i; /* Boucle de parcours */ + GArchOperand *arg; /* Nouvel argument à intégrer */ + + parent = G_ARCH_OPERAND_CLASS(g_dalvik_args_operand_parent_class); + + result = parent->unserialize(G_ARCH_OPERAND(operand), storage, format, pbuf); + + if (result) + result = extract_packed_buffer(pbuf, &count, sizeof(size_t), true); + + for (i = 0; i < count && result; i++) + { + arg = g_arch_operand_load(storage, format, pbuf); + + if (arg == NULL) + result = false; + + else + g_dalvik_args_operand_add(operand, arg); + + } + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : operand = opérande d'assemblage à consulter. * +* storage = mécanisme de sauvegarde à manipuler. * +* pbuf = zone tampon à remplir. * +* * +* Description : Sauvegarde un opérande dans une mémoire tampon. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static bool g_dalvik_args_operand_serialize(const GDalvikArgsOperand *operand, GAsmStorage *storage, packed_buffer *pbuf) +{ + bool result; /* Bilan à retourner */ + GArchOperandClass *parent; /* Classe parente à consulter */ + size_t i; /* Boucle de parcours */ + + parent = G_ARCH_OPERAND_CLASS(g_dalvik_args_operand_parent_class); + + result = parent->serialize(G_ARCH_OPERAND(operand), storage, pbuf); + + if (result) + result = extend_packed_buffer(pbuf, &operand->count, sizeof(size_t), true); + + for (i = 0; i < operand->count && result; i++) + result = g_arch_operand_store(operand->args[i], storage, pbuf); + + return result; + +} diff --git a/plugins/dalvik/operands/args.h b/plugins/dalvik/operands/args.h index bf2fac4..3852e6d 100644 --- a/plugins/dalvik/operands/args.h +++ b/plugins/dalvik/operands/args.h @@ -32,12 +32,12 @@ -#define G_TYPE_DALVIK_ARGS_OPERAND g_dalvik_args_operand_get_type() -#define G_DALVIK_ARGS_OPERAND(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_dalvik_args_operand_get_type(), GDalvikArgsOperand)) -#define G_IS_DALVIK_ARGS_OPERAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_dalvik_args_operand_get_type())) -#define G_DALVIK_ARGS_OPERAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_DALVIK_ARGS_OPERAND, GDalvikArgsOperandClass)) -#define G_IS_DALVIK_ARGS_OPERAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_DALVIK_ARGS_OPERAND)) -#define G_DALVIK_ARGS_OPERAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_DALVIK_ARGS_OPERAND, GDalvikArgsOperandClass)) +#define G_TYPE_DALVIK_ARGS_OPERAND g_dalvik_args_operand_get_type() +#define G_DALVIK_ARGS_OPERAND(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_DALVIK_ARGS_OPERAND, GDalvikArgsOperand)) +#define G_IS_DALVIK_ARGS_OPERAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_DALVIK_ARGS_OPERAND)) +#define G_DALVIK_ARGS_OPERAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_DALVIK_ARGS_OPERAND, GDalvikArgsOperandClass)) +#define G_IS_DALVIK_ARGS_OPERAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_DALVIK_ARGS_OPERAND)) +#define G_DALVIK_ARGS_OPERAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_DALVIK_ARGS_OPERAND, GDalvikArgsOperandClass)) /* Définition d'un opérande visant une liste d'opérandes Dalvik (instance) */ diff --git a/plugins/dalvik/operands/pool.c b/plugins/dalvik/operands/pool.c index 9acfdb6..6bb1323 100644 --- a/plugins/dalvik/operands/pool.c +++ b/plugins/dalvik/operands/pool.c @@ -77,6 +77,17 @@ static void g_dalvik_pool_operand_print(const GDalvikPoolOperand *, GBufferLine +/* --------------------- TRANSPOSITIONS VIA CACHE DES OPERANDES --------------------- */ + + +/* Charge un opérande depuis une mémoire tampon. */ +static bool g_dalvik_pool_operand_unserialize(GDalvikPoolOperand *, GAsmStorage *, GBinFormat *, packed_buffer *); + +/* Sauvegarde un opérande dans une mémoire tampon. */ +static bool g_dalvik_pool_operand_serialize(const GDalvikPoolOperand *, GAsmStorage *, packed_buffer *); + + + /* Indique le type défini par la GLib pour un un élément de table de constantes Dalvik. */ G_DEFINE_TYPE(GDalvikPoolOperand, g_dalvik_pool_operand, G_TYPE_ARCH_OPERAND); @@ -108,6 +119,9 @@ static void g_dalvik_pool_operand_class_init(GDalvikPoolOperandClass *klass) operand->compare = (operand_compare_fc)g_dalvik_pool_operand_compare; operand->print = (operand_print_fc)g_dalvik_pool_operand_print; + operand->unserialize = (unserialize_operand_fc)g_dalvik_pool_operand_unserialize; + operand->serialize = (serialize_operand_fc)g_dalvik_pool_operand_serialize; + } @@ -125,6 +139,7 @@ static void g_dalvik_pool_operand_class_init(GDalvikPoolOperandClass *klass) static void g_dalvik_pool_operand_init(GDalvikPoolOperand *operand) { + operand->format = NULL; } @@ -143,7 +158,8 @@ static void g_dalvik_pool_operand_init(GDalvikPoolOperand *operand) static void g_dalvik_pool_operand_dispose(GDalvikPoolOperand *operand) { - g_object_unref(G_OBJECT(operand->format)); + if (operand->format != NULL) + g_object_unref(G_OBJECT(operand->format)); G_OBJECT_CLASS(g_dalvik_pool_operand_parent_class)->dispose(G_OBJECT(operand)); @@ -453,3 +469,84 @@ uint32_t g_dalvik_pool_operand_get_index(const GDalvikPoolOperand *operand) return operand->index; } + + + +/* ---------------------------------------------------------------------------------- */ +/* TRANSPOSITIONS VIA CACHE DES OPERANDES */ +/* ---------------------------------------------------------------------------------- */ + + +/****************************************************************************** +* * +* Paramètres : operand = opérande d'assemblage à constituer. * +* storage = mécanisme de sauvegarde à manipuler. * +* format = format binaire chargé associé à l'architecture. * +* pbuf = zone tampon à remplir. * +* * +* Description : Charge un opérande depuis une mémoire tampon. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static bool g_dalvik_pool_operand_unserialize(GDalvikPoolOperand *operand, GAsmStorage *storage, GBinFormat *format, packed_buffer *pbuf) +{ + bool result; /* Bilan à retourner */ + GArchOperandClass *parent; /* Classe parente à consulter */ + + parent = G_ARCH_OPERAND_CLASS(g_dalvik_pool_operand_parent_class); + + result = parent->unserialize(G_ARCH_OPERAND(operand), storage, format, pbuf); + + if (result) + { + operand->format = G_DEX_FORMAT(format); + g_object_ref(G_OBJECT(format)); + } + + if (result) + result = extract_packed_buffer(pbuf, &operand->type, sizeof(DalvikPoolType), true); + + if (result) + result = extract_packed_buffer(pbuf, &operand->index, sizeof(uint32_t), true); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : operand = opérande d'assemblage à consulter. * +* storage = mécanisme de sauvegarde à manipuler. * +* pbuf = zone tampon à remplir. * +* * +* Description : Sauvegarde un opérande dans une mémoire tampon. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static bool g_dalvik_pool_operand_serialize(const GDalvikPoolOperand *operand, GAsmStorage *storage, packed_buffer *pbuf) +{ + bool result; /* Bilan à retourner */ + GArchOperandClass *parent; /* Classe parente à consulter */ + + parent = G_ARCH_OPERAND_CLASS(g_dalvik_pool_operand_parent_class); + + result = parent->serialize(G_ARCH_OPERAND(operand), storage, pbuf); + + if (result) + result = extend_packed_buffer(pbuf, &operand->type, sizeof(DalvikPoolType), true); + + if (result) + result = extend_packed_buffer(pbuf, &operand->index, sizeof(uint32_t), true); + + return result; + +} diff --git a/plugins/dalvik/operands/register.c b/plugins/dalvik/operands/register.c index d2dd174..7d011a0 100644 --- a/plugins/dalvik/operands/register.c +++ b/plugins/dalvik/operands/register.c @@ -24,18 +24,14 @@ #include "register.h" -#include <arch/operand-int.h> -#include <arch/register.h> +#include <arch/register-int.h> /* Définition d'un opérande visant un registre Dalvik (instance) */ struct _GDalvikRegisterOperand { - GArchOperand parent; /* Instance parente */ - - GDalvikRegister *reg; /* Registre représenté */ - bool is_written; /* Changement de contenu */ + GRegisterOperand parent; /* Instance parente */ }; @@ -43,7 +39,7 @@ struct _GDalvikRegisterOperand /* Définition d'un opérande visant un registre Dalvik (classe) */ struct _GDalvikRegisterOperandClass { - GArchOperandClass parent; /* Classe parente */ + GRegisterOperandClass parent; /* Classe parente */ }; @@ -60,16 +56,21 @@ static void g_dalvik_register_operand_dispose(GDalvikRegisterOperand *); /* Procède à la libération totale de la mémoire. */ static void g_dalvik_register_operand_finalize(GDalvikRegisterOperand *); -/* Compare un opérande avec un autre. */ -static int g_dalvik_register_operand_compare(const GDalvikRegisterOperand *, const GDalvikRegisterOperand *); -/* Traduit un opérande en version humainement lisible. */ -static void g_dalvik_register_operand_print(const GDalvikRegisterOperand *, GBufferLine *, AsmSyntax); + +/* --------------------- TRANSPOSITIONS VIA CACHE DES OPERANDES --------------------- */ + + +/* Charge un opérande depuis une mémoire tampon. */ +static bool g_dalvik_register_operand_unserialize(GDalvikRegisterOperand *, GAsmStorage *, GBinFormat *, packed_buffer *); + +/* Sauvegarde un opérande dans une mémoire tampon. */ +static bool g_dalvik_register_operand_serialize(const GDalvikRegisterOperand *, GAsmStorage *, packed_buffer *); /* Indique le type défini par la GLib pour un opérande de registre Dalvik. */ -G_DEFINE_TYPE(GDalvikRegisterOperand, g_dalvik_register_operand, G_TYPE_ARCH_OPERAND); +G_DEFINE_TYPE(GDalvikRegisterOperand, g_dalvik_register_operand, G_TYPE_REGISTER_OPERAND); /****************************************************************************** @@ -96,8 +97,8 @@ static void g_dalvik_register_operand_class_init(GDalvikRegisterOperandClass *kl operand = G_ARCH_OPERAND_CLASS(klass); - operand->compare = (operand_compare_fc)g_dalvik_register_operand_compare; - operand->print = (operand_print_fc)g_dalvik_register_operand_print; + operand->unserialize = (unserialize_operand_fc)g_dalvik_register_operand_unserialize; + operand->serialize = (serialize_operand_fc)g_dalvik_register_operand_serialize; } @@ -116,8 +117,6 @@ static void g_dalvik_register_operand_class_init(GDalvikRegisterOperandClass *kl static void g_dalvik_register_operand_init(GDalvikRegisterOperand *operand) { - operand->reg = NULL; - operand->is_written = false; } @@ -136,9 +135,6 @@ static void g_dalvik_register_operand_init(GDalvikRegisterOperand *operand) static void g_dalvik_register_operand_dispose(GDalvikRegisterOperand *operand) { - if (operand->reg != NULL) - g_object_unref(G_OBJECT(operand->reg)); - G_OBJECT_CLASS(g_dalvik_register_operand_parent_class)->dispose(G_OBJECT(operand)); } @@ -165,51 +161,6 @@ static void g_dalvik_register_operand_finalize(GDalvikRegisterOperand *operand) /****************************************************************************** * * -* Paramètres : a = premier opérande à consulter. * -* b = second opérande à consulter. * -* * -* Description : Compare un opérande avec un autre. * -* * -* Retour : Bilan de la comparaison. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static int g_dalvik_register_operand_compare(const GDalvikRegisterOperand *a, const GDalvikRegisterOperand *b) -{ - int result; /* Bilan à retourner */ - - result = g_dalvik_register_compare(a->reg, b->reg); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : operand = opérande à traiter. * -* line = ligne tampon où imprimer l'opérande donné. * -* syntax = type de représentation demandée. * -* * -* Description : Traduit un opérande en version humainement lisible. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_dalvik_register_operand_print(const GDalvikRegisterOperand *operand, GBufferLine *line, AsmSyntax syntax) -{ - g_arch_register_print(G_ARCH_REGISTER(operand->reg), line, syntax); - -} - - -/****************************************************************************** -* * * Paramètres : content = flux de données à analyser. * * pos = position courante dans ce flux. [OUT] * * low = position éventuelle des 4 bits visés. [OUT] * @@ -303,7 +254,7 @@ GArchOperand *g_dalvik_register_operand_new_from_existing(GDalvikRegister *reg) result = g_object_new(G_TYPE_DALVIK_REGISTER_OPERAND, NULL); - result->reg = reg; + G_REGISTER_OPERAND(result)->reg = G_ARCH_REGISTER(reg); return G_ARCH_OPERAND(result); @@ -324,44 +275,97 @@ GArchOperand *g_dalvik_register_operand_new_from_existing(GDalvikRegister *reg) const GDalvikRegister *g_dalvik_register_operand_get(const GDalvikRegisterOperand *operand) { - return operand->reg; + GDalvikRegister *result; /* Instance à retourner */ + + result = G_DALVIK_REGISTER(G_REGISTER_OPERAND(operand)->reg); + + return result; } + +/* ---------------------------------------------------------------------------------- */ +/* TRANSPOSITIONS VIA CACHE DES OPERANDES */ +/* ---------------------------------------------------------------------------------- */ + + /****************************************************************************** * * -* Paramètres : operand = opérande représentant un registre à mettre à jour. * +* Paramètres : operand = opérande d'assemblage à constituer. * +* storage = mécanisme de sauvegarde à manipuler. * +* format = format binaire chargé associé à l'architecture. * +* pbuf = zone tampon à remplir. * * * -* Description : Marque l'opérande comme étant écrit plutôt que consulté. * +* Description : Charge un opérande depuis une mémoire tampon. * * * -* Retour : - * +* Retour : Bilan de l'opération. * * * * Remarques : - * * * ******************************************************************************/ -void g_dalvik_register_operand_mark_as_written(GDalvikRegisterOperand *operand) +static bool g_dalvik_register_operand_unserialize(GDalvikRegisterOperand *operand, GAsmStorage *storage, GBinFormat *format, packed_buffer *pbuf) { - operand->is_written = true; + bool result; /* Bilan à retourner */ + GArchOperandClass *parent; /* Classe parente à consulter */ + uint16_t index; /* Identifiant de registre */ + GDalvikRegister *reg; /* Registre à intégrer */ + + parent = G_ARCH_OPERAND_CLASS(g_dalvik_register_operand_parent_class); + + result = parent->unserialize(G_ARCH_OPERAND(operand), storage, format, pbuf); + + if (result) + { + result = extract_packed_buffer(pbuf, &index, sizeof(uint16_t), true); + + if (result) + { + reg = g_dalvik_register_new(index); + result = (reg != NULL); + } + + if (result) + G_REGISTER_OPERAND(operand)->reg = G_ARCH_REGISTER(reg); + + } + + return result; } /****************************************************************************** * * -* Paramètres : operand = opérande représentant un registre à consulter. * +* Paramètres : operand = opérande d'assemblage à consulter. * +* storage = mécanisme de sauvegarde à manipuler. * +* pbuf = zone tampon à remplir. * * * -* Description : Indique le type d'accès réalisé sur l'opérande. * +* Description : Sauvegarde un opérande dans une mémoire tampon. * * * -* Retour : Type d'accès : true en cas d'écriture, false sinon. * +* Retour : Bilan de l'opération. * * * * Remarques : - * * * ******************************************************************************/ -bool g_dalvik_register_operand_is_written(const GDalvikRegisterOperand *operand) +static bool g_dalvik_register_operand_serialize(const GDalvikRegisterOperand *operand, GAsmStorage *storage, packed_buffer *pbuf) { - return operand->is_written; + bool result; /* Bilan à retourner */ + GArchOperandClass *parent; /* Classe parente à consulter */ + uint16_t index; /* Identifiant de registre */ + + parent = G_ARCH_OPERAND_CLASS(g_dalvik_register_operand_parent_class); + + result = parent->serialize(G_ARCH_OPERAND(operand), storage, pbuf); + + if (result) + { + index = g_dalvik_register_get_index(G_DALVIK_REGISTER(G_REGISTER_OPERAND(operand)->reg)); + result = extend_packed_buffer(pbuf, &index, sizeof(uint16_t), true); + } + + return result; } diff --git a/plugins/dalvik/operands/register.h b/plugins/dalvik/operands/register.h index efc3651..29b14c8 100644 --- a/plugins/dalvik/operands/register.h +++ b/plugins/dalvik/operands/register.h @@ -64,12 +64,6 @@ GArchOperand *g_dalvik_register_operand_new_from_existing(GDalvikRegister *); /* Fournit le registre Dalvik associé à l'opérande. */ const GDalvikRegister *g_dalvik_register_operand_get(const GDalvikRegisterOperand *); -/* Marque l'opérande comme étant écrit plutôt que consulté. */ -void g_dalvik_register_operand_mark_as_written(GDalvikRegisterOperand *); - -/* Indique le type d'accès réalisé sur l'opérande. */ -bool g_dalvik_register_operand_is_written(const GDalvikRegisterOperand *); - #endif /* _PLUGINS_DALVIK_OPERANDS_REGISTER_H */ diff --git a/plugins/dalvik/register.h b/plugins/dalvik/register.h index ffa44e4..42206c8 100644 --- a/plugins/dalvik/register.h +++ b/plugins/dalvik/register.h @@ -33,12 +33,12 @@ /* ------------------------- GESTION UNITAIRE DES REGISTRES ------------------------- */ -#define G_TYPE_DALVIK_REGISTER g_dalvik_register_get_type() -#define G_DALVIK_REGISTER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_dalvik_register_get_type(), GDalvikRegister)) -#define G_IS_DALVIK_REGISTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_dalvik_register_get_type())) -#define G_DALVIK_REGISTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_DALVIK_REGISTER, GDalvikRegisterClass)) -#define G_IS_DALVIK_REGISTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_DALVIK_REGISTER)) -#define G_DALVIK_REGISTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_DALVIK_REGISTER, GDalvikRegisterClass)) +#define G_TYPE_DALVIK_REGISTER g_dalvik_register_get_type() +#define G_DALVIK_REGISTER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_DALVIK_REGISTER, GDalvikRegister)) +#define G_IS_DALVIK_REGISTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_DALVIK_REGISTER)) +#define G_DALVIK_REGISTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_DALVIK_REGISTER, GDalvikRegisterClass)) +#define G_IS_DALVIK_REGISTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_DALVIK_REGISTER)) +#define G_DALVIK_REGISTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_DALVIK_REGISTER, GDalvikRegisterClass)) /* Représentation d'un registre Dalvik (instance) */ diff --git a/plugins/dalvik/v35/Makefile.am b/plugins/dalvik/v35/Makefile.am index ad179c0..eecdeba 100644 --- a/plugins/dalvik/v35/Makefile.am +++ b/plugins/dalvik/v35/Makefile.am @@ -2,6 +2,7 @@ noinst_LTLIBRARIES = libdalvik35.la libdalvik35_la_SOURCES = \ + core.h core.c \ instruction.h instruction.c \ operand.h \ processor.h processor.c diff --git a/plugins/dalvik/v35/core.c b/plugins/dalvik/v35/core.c new file mode 100644 index 0000000..7e36691 --- /dev/null +++ b/plugins/dalvik/v35/core.c @@ -0,0 +1,99 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * core.c - chargement et déchargement des mécanismes internes de l'architecture Dalvik v35 + * + * Copyright (C) 2018 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Chrysalide. If not, see <http://www.gnu.org/licenses/>. + */ + + +#include "core.h" + + +#include <core/processors.h> + + +#include "instruction.h" +#include "processor.h" + + + +/* Assure l'enregistrement de types pour les caches à charger. */ +static void register_dalvik35_gtypes(void); + + + +/****************************************************************************** +* * +* Paramètres : - * +* * +* Description : Assure l'enregistrement de types pour les caches à charger. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void register_dalvik35_gtypes(void) +{ + g_type_ensure(G_TYPE_DALVIK35_INSTRUCTION); + +} + + +/****************************************************************************** +* * +* Paramètres : - * +* * +* Description : Met en place les mécanismes internes de l'archi. Dalvik v35. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool init_dalvik35_core(void) +{ + bool result; /* Bilan à renvoyer */ + + register_dalvik35_gtypes(); + + result = register_processor_type("dalvik35", "Dalvik Virtual Machine v35", G_TYPE_DALVIK35_PROCESSOR); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : - * +* * +* Description : Supprime les mécanismes internes de l'archi. Dalvik v35. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void exit_dalvik35_core(void) +{ + +} diff --git a/plugins/dalvik/v35/core.h b/plugins/dalvik/v35/core.h new file mode 100644 index 0000000..1ee4bf6 --- /dev/null +++ b/plugins/dalvik/v35/core.h @@ -0,0 +1,40 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * core.h - prototypes pour le chargement et le déchargement des mécanismes internes de l'architecture Dalvik v35 + * + * Copyright (C) 2018 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Chrysalide. If not, see <http://www.gnu.org/licenses/>. + */ + + +#ifndef _PLUGINS_DALVIK_V35_CORE_H +#define _PLUGINS_DALVIK_V35_CORE_H + + +#include <stdbool.h> + + + +/* Met en place les mécanismes internes de l'architecture Dalvik v35. */ +bool init_dalvik35_core(void); + +/* Supprime les mécanismes internes de l'architecture Dalvik v35. */ +void exit_dalvik35_core(void); + + + +#endif /* _PLUGINS_DALVIK_V35_CORE_H */ |