summaryrefslogtreecommitdiff
path: root/src/arch/dalvik/operand.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2016-04-24 18:43:54 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2016-04-24 18:43:54 (GMT)
commit9d04b66153bd0b354c0fb5c097b9face61a649db (patch)
tree54a507c720287597e7a70808e64ad36b37ed41b8 /src/arch/dalvik/operand.c
parenta5758a42acdfaf0ac20c4cfb9cf162a9b4440e39 (diff)
Handled hooks and rules in Dalvik opcodes definitions.
Diffstat (limited to 'src/arch/dalvik/operand.c')
-rw-r--r--src/arch/dalvik/operand.c66
1 files changed, 63 insertions, 3 deletions
diff --git a/src/arch/dalvik/operand.c b/src/arch/dalvik/operand.c
index 83d95e5..ab098f3 100644
--- a/src/arch/dalvik/operand.c
+++ b/src/arch/dalvik/operand.c
@@ -56,6 +56,9 @@ typedef enum _DalvikOperandID
} DalvikOperandID;
+/* Crée un opérande visant une instruction Dalvik. */
+static GArchOperand *dalvik_build_target_operand(const GBinContent *, vmpa2t *, MemoryDataSize , SourceEndian, const vmpa2t *);
+
/* Procède à la lecture d'opérandes pour une instruction. */
static bool dalvik_read_basic_operands(GArchInstruction *, GDexFormat *, const GBinContent *, vmpa2t *, bool *, SourceEndian, DalvikOperandType, ...);
@@ -69,6 +72,63 @@ static bool dalvik_read_variatic_operands(GArchInstruction *, GDexFormat *, cons
/******************************************************************************
* *
+* Paramètres : content = flux de données à analyser. *
+* pos = position courante dans ce flux. [OUT] *
+* size = taille de l'opérande. *
+* endian = ordre des bits dans la source. *
+* base = adresse de référence pour le calcul. *
+* *
+* Description : Crée un opérande visant une instruction Dalvik. *
+* *
+* Retour : Opérande mis en place. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static GArchOperand *dalvik_build_target_operand(const GBinContent *content, vmpa2t *pos, MemoryDataSize size, SourceEndian endian, const vmpa2t *base)
+{
+ GArchOperand *result; /* Structure à retourner */
+ phys_t offset; /* Emplacement de base */
+ int8_t val8; /* Valeur sur 8 bits */
+ int16_t val16; /* Valeur sur 16 bits */
+ int32_t val32; /* Valeur sur 32 bits */
+ bool test; /* Bilan de lecture */
+ phys_t address; /* Adresse finale visée */
+
+ offset = get_phy_addr(base);
+
+ switch (size)
+ {
+ case MDS_8_BITS_SIGNED:
+ test = g_binary_content_read_s8(content, pos, &val8);
+ address = offset + val8 * sizeof(uint16_t);
+ break;
+ case MDS_16_BITS_SIGNED:
+ test = g_binary_content_read_s16(content, pos, endian, &val16);
+ address = offset + val16 * sizeof(uint16_t);
+ break;
+ case MDS_32_BITS_SIGNED:
+ test = g_binary_content_read_s32(content, pos, endian, &val32);
+ address = offset + val32 * sizeof(uint16_t);
+ break;
+ default:
+ test = false;
+ break;
+ }
+
+ if (!test)
+ return NULL;
+
+ result = g_imm_operand_new_from_value(MDS_32_BITS, address);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : instr = instruction dont la définition est incomplète.[OUT]*
* format = format du fichier contenant le code. *
* content = flux de données à analyser. *
@@ -339,21 +399,21 @@ static bool dalvik_read_basic_operands(GArchInstruction *instr, GDexFormat *form
case DOI_TARGET_8:
va_start(ap, model);
base = va_arg(ap, const vmpa2t *);
- op = g_dalvik_target_operand_new(content, pos, MDS_8_BITS_SIGNED, endian, base);
+ op = dalvik_build_target_operand(content, pos, MDS_8_BITS_SIGNED, endian, base);
va_end(ap);
break;
case DOI_TARGET_16:
va_start(ap, model);
base = va_arg(ap, const vmpa2t *);
- op = g_dalvik_target_operand_new(content, pos, MDS_16_BITS_SIGNED, endian, base);
+ op = dalvik_build_target_operand(content, pos, MDS_16_BITS_SIGNED, endian, base);
va_end(ap);
break;
case DOI_TARGET_32:
va_start(ap, model);
base = va_arg(ap, const vmpa2t *);
- op = g_dalvik_target_operand_new(content, pos, MDS_32_BITS_SIGNED, endian, base);
+ op = dalvik_build_target_operand(content, pos, MDS_32_BITS_SIGNED, endian, base);
va_end(ap);
break;