diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2018-07-19 19:00:34 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2018-07-19 19:00:34 (GMT) |
commit | a4f40b1971fe208bd9c25adebaeff5614aee87ee (patch) | |
tree | 376d1832e345b0bf451cd8d06b97e0c2cd37fa86 /src/arch/target.c | |
parent | 5d94aa1a1e3af384307bb9d760410b61a33e7323 (diff) |
Created an interface for jumping to addresses from operands.
Diffstat (limited to 'src/arch/target.c')
-rw-r--r-- | src/arch/target.c | 89 |
1 files changed, 68 insertions, 21 deletions
diff --git a/src/arch/target.c b/src/arch/target.c index 97b2192..6872efe 100644 --- a/src/arch/target.c +++ b/src/arch/target.c @@ -33,6 +33,7 @@ #include "operand-int.h" +#include "targetableop-int.h" #include "../analysis/routine.h" #include "../common/extstr.h" #include "../format/format.h" @@ -69,6 +70,9 @@ static void g_target_operand_class_init(GTargetOperandClass *); /* Initialise la classe des opérandes ciblant des symboles. */ static void g_target_operand_init(GTargetOperand *); +/* Procède à l'initialisation de l'interface de ciblage. */ +static void g_target_operand_targetable_interface_init(GTargetableOperandInterface *); + /* Supprime toutes les références externes. */ static void g_target_operand_dispose(GTargetOperand *); @@ -97,8 +101,17 @@ static bool g_target_operand_serialize(const GTargetOperand *, GAsmStorage *, pa +/* ----------------------- INTERFACE DE CIBLAGE POUR OPERANDE ----------------------- */ + + +/* Obtient l'adresse de la cible visée par un opérande. */ +static bool g_target_operand_get_addr(const GTargetOperand *, const vmpa2t *, GBinFormat *, GArchProcessor *, vmpa2t *); + + + /* Indique le type défini pour un opérande de valeur numérique. */ -G_DEFINE_TYPE(GTargetOperand, g_target_operand, G_TYPE_ARCH_OPERAND); +G_DEFINE_TYPE_WITH_CODE(GTargetOperand, g_target_operand, G_TYPE_ARCH_OPERAND, + G_IMPLEMENT_INTERFACE(G_TYPE_TARGETABLE_OPERAND, g_target_operand_targetable_interface_init)); @@ -161,6 +174,25 @@ static void g_target_operand_init(GTargetOperand *operand) /****************************************************************************** * * +* Paramètres : iface = interface GLib à initialiser. * +* * +* Description : Procède à l'initialisation de l'interface de ciblage. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_target_operand_targetable_interface_init(GTargetableOperandInterface *iface) +{ + iface->get_addr = (get_targetable_addr_fc)g_target_operand_get_addr; + +} + + +/****************************************************************************** +* * * Paramètres : operand = instance d'objet GLib à traiter. * * * * Description : Supprime toutes les références externes. * @@ -452,26 +484,6 @@ MemoryDataSize g_target_operand_get_size(const GTargetOperand *operand) /****************************************************************************** * * -* Paramètres : operand = structure dont le contenu est à consulter. * -* addr = localisation à renseigner. [OUT] * -* * -* Description : Fournit l'adresse en mémoire de l'élément visé. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void g_target_operand_get_addr(const GTargetOperand *operand, vmpa2t *addr) -{ - copy_vmpa(addr, &operand->addr); - -} - - -/****************************************************************************** -* * * Paramètres : operand = opérande dont le contenu est à raffiner. [OUT] * * format = format du binaire d'origine à consulter. * * strict = indique la perfection attendue de la résolution. * @@ -659,3 +671,38 @@ static bool g_target_operand_serialize(const GTargetOperand *operand, GAsmStorag return result; } + + + +/* ---------------------------------------------------------------------------------- */ +/* INTERFACE DE CIBLAGE POUR OPERANDE */ +/* ---------------------------------------------------------------------------------- */ + + +/****************************************************************************** +* * +* Paramètres : operand = operande à consulter. * +* src = localisation de l'instruction mère. * +* format = format reconnu pour le binaire chargé. * +* proc = architecture associée à ce même binaire. * +* addr = localisation de la cible. [OUT] * +* * +* Description : Obtient l'adresse de la cible visée par un opérande. * +* * +* Retour : true si la cible est valide, false sinon. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static bool g_target_operand_get_addr(const GTargetOperand *operand, const vmpa2t *src, GBinFormat *format, GArchProcessor *proc, vmpa2t *addr) +{ + bool result; /* Bilan à retourner */ + + result = true; + + copy_vmpa(addr, &operand->addr); + + return result; + +} |