summaryrefslogtreecommitdiff
path: root/src/arch/dalvik/operands
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2016-01-30 00:21:08 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2016-01-30 00:21:08 (GMT)
commitc922b6b9c841a97dd948755658cff07b2c6762ff (patch)
tree7236b03fde56edde625e406085862381cde6e955 /src/arch/dalvik/operands
parent16e0fd9d89ef433848678dfc8dd20426844a2868 (diff)
Updated some parts of the code dealing with Dalvik.
Diffstat (limited to 'src/arch/dalvik/operands')
-rw-r--r--src/arch/dalvik/operands/pool.c21
-rw-r--r--src/arch/dalvik/operands/pool.h2
-rw-r--r--src/arch/dalvik/operands/register.c19
-rw-r--r--src/arch/dalvik/operands/register.h4
-rw-r--r--src/arch/dalvik/operands/target.c23
-rw-r--r--src/arch/dalvik/operands/target.h2
6 files changed, 36 insertions, 35 deletions
diff --git a/src/arch/dalvik/operands/pool.c b/src/arch/dalvik/operands/pool.c
index 2f5c4a0..0d88242 100644
--- a/src/arch/dalvik/operands/pool.c
+++ b/src/arch/dalvik/operands/pool.c
@@ -41,7 +41,7 @@ struct _GDalvikPoolOperand
{
GArchOperand parent; /* Instance parente */
- const GDexFormat *format; /* Lien vers le contenu réel */
+ GDexFormat *format; /* Lien vers le contenu réel */
DalvikPoolType type; /* Type de table visée */
uint32_t index; /* Indice de l'élément visé */
@@ -165,13 +165,12 @@ static void g_dalvik_pool_operand_finalize(GDalvikPoolOperand *operand)
/******************************************************************************
* *
-* Paramètres : format = format du fichier contenant le code. *
-* type = type de table visée avec la référence. *
-* data = flux de données à analyser. *
-* pos = position courante dans ce flux. [OUT] *
-* end = limite des données à analyser. *
-* size = taille de l'opérande, et donc du registre. *
-* endian = ordre des bits dans la source. *
+* Paramètres : format = format du fichier contenant le code. *
+* type = type de table visée avec la référence. *
+* content = flux de données à analyser. *
+* pos = position courante dans ce flux. [OUT] *
+* size = taille de l'opérande, et donc du registre. *
+* endian = ordre des bits dans la source. *
* *
* Description : Crée un opérande visant un élément constant Dalvik. *
* *
@@ -181,7 +180,7 @@ static void g_dalvik_pool_operand_finalize(GDalvikPoolOperand *operand)
* *
******************************************************************************/
-GArchOperand *g_dalvik_pool_operand_new(const GDexFormat *format, DalvikPoolType type, const bin_t *data, off_t *pos, off_t end, MemoryDataSize size, SourceEndian endian)
+GArchOperand *g_dalvik_pool_operand_new(GDexFormat *format, DalvikPoolType type, const GBinContent *content, vmpa2t *pos, MemoryDataSize size, SourceEndian endian)
{
GDalvikPoolOperand *result; /* Structure à retourner */
uint8_t index8; /* Indice sur 8 bits */
@@ -191,10 +190,10 @@ GArchOperand *g_dalvik_pool_operand_new(const GDexFormat *format, DalvikPoolType
switch (size)
{
case MDS_8_BITS:
- test = read_u8(&index8, data, pos, end);
+ test = g_binary_content_read_u8(content, pos, &index8);
break;
case MDS_16_BITS:
- test = read_u16(&index16, data, pos, end, endian);
+ test = g_binary_content_read_u16(content, pos, endian, &index16);
break;
default:
test = false;
diff --git a/src/arch/dalvik/operands/pool.h b/src/arch/dalvik/operands/pool.h
index 604302d..3d75142 100644
--- a/src/arch/dalvik/operands/pool.h
+++ b/src/arch/dalvik/operands/pool.h
@@ -67,7 +67,7 @@ typedef enum _DalvikPoolType
GType g_dalvik_pool_operand_get_type(void);
/* Crée un opérande visant un élément constant Dalvik. */
-GArchOperand *g_dalvik_pool_operand_new(const GDexFormat *, DalvikPoolType, const bin_t *, off_t *, off_t, MemoryDataSize, SourceEndian);
+GArchOperand *g_dalvik_pool_operand_new(GDexFormat *, DalvikPoolType, const GBinContent *, vmpa2t *, MemoryDataSize, SourceEndian);
/* Indique la nature de la table de constantes visée ici. */
DalvikPoolType g_dalvik_pool_operand_get_pool_type(const GDalvikPoolOperand *);
diff --git a/src/arch/dalvik/operands/register.c b/src/arch/dalvik/operands/register.c
index 1b789f2..7f243ad 100644
--- a/src/arch/dalvik/operands/register.c
+++ b/src/arch/dalvik/operands/register.c
@@ -159,12 +159,11 @@ static void g_dalvik_register_operand_finalize(GDalvikRegisterOperand *operand)
/******************************************************************************
* *
-* Paramètres : data = flux de données à analyser. *
-* pos = position courante dans ce flux. [OUT] *
-* end = limite des données à analyser. *
-* low = position éventuelle des 4 bits visés. [OUT] *
-* size = taille de l'opérande, et donc du registre. *
-* endian = ordre des bits dans la source. *
+* Paramètres : content = flux de données à analyser. *
+* pos = position courante dans ce flux. [OUT] *
+* low = position éventuelle des 4 bits visés. [OUT] *
+* size = taille de l'opérande, et donc du registre. *
+* endian = ordre des bits dans la source. *
* *
* Description : Crée un opérande visant un registre Dalvik. *
* *
@@ -174,7 +173,7 @@ static void g_dalvik_register_operand_finalize(GDalvikRegisterOperand *operand)
* *
******************************************************************************/
-GArchOperand *g_dalvik_register_operand_new(const bin_t *data, off_t *pos, off_t end, bool *low, MemoryDataSize size, SourceEndian endian)
+GArchOperand *g_dalvik_register_operand_new(const GBinContent *content, vmpa2t *pos, bool *low, MemoryDataSize size, SourceEndian endian)
{
GDalvikRegisterOperand *result; /* Structure à retourner */
uint8_t index8; /* Indice sur 8 bits */
@@ -184,13 +183,13 @@ GArchOperand *g_dalvik_register_operand_new(const bin_t *data, off_t *pos, off_t
switch (size)
{
case MDS_4_BITS:
- test = read_u4(&index8, data, pos, end, low);
+ test = g_binary_content_read_u4(content, pos, low, &index8);
break;
case MDS_8_BITS:
- test = read_u8(&index8, data, pos, end);
+ test = g_binary_content_read_u8(content, pos, &index8);
break;
case MDS_16_BITS:
- test = read_u16(&index16, data, pos, end, endian);
+ test = g_binary_content_read_u16(content, pos, endian, &index16);
break;
default:
test = false;
diff --git a/src/arch/dalvik/operands/register.h b/src/arch/dalvik/operands/register.h
index cd341b4..d70f410 100644
--- a/src/arch/dalvik/operands/register.h
+++ b/src/arch/dalvik/operands/register.h
@@ -30,7 +30,7 @@
#include "../register.h"
#include "../../operand.h"
-#include "../../../common/endianness.h"
+#include "../../../analysis/content.h"
@@ -53,7 +53,7 @@ typedef struct _GDalvikRegisterOperandClass GDalvikRegisterOperandClass;
GType g_dalvik_register_operand_get_type(void);
/* Crée un opérande visant un registre Dalvik. */
-GArchOperand *g_dalvik_register_operand_new(const bin_t *, off_t *, off_t, bool *, MemoryDataSize, SourceEndian);
+GArchOperand *g_dalvik_register_operand_new(const GBinContent *, vmpa2t *, bool *, MemoryDataSize, SourceEndian);
/* Crée un opérande visant un registre Dalvik. */
GArchOperand *g_dalvik_register_operand_new_from_existing(GDalvikRegister *);
diff --git a/src/arch/dalvik/operands/target.c b/src/arch/dalvik/operands/target.c
index 690858b..42d09cf 100644
--- a/src/arch/dalvik/operands/target.c
+++ b/src/arch/dalvik/operands/target.c
@@ -155,12 +155,11 @@ static void g_dalvik_target_operand_finalize(GDalvikTargetOperand *operand)
/******************************************************************************
* *
-* Paramètres : data = flux de données à analyser. *
-* pos = position courante dans ce flux. [OUT] *
-* end = limite des données à analyser. *
-* size = taille de l'opérande. *
-* endian = ordre des bits dans la source. *
-* base = adresse de référence pour le calcul. *
+* 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 un instruction Dalvik. *
* *
@@ -170,26 +169,27 @@ static void g_dalvik_target_operand_finalize(GDalvikTargetOperand *operand)
* *
******************************************************************************/
-GArchOperand *g_dalvik_target_operand_new(const bin_t *data, off_t *pos, off_t end, MemoryDataSize size, SourceEndian endian, vmpa_t base)
+GArchOperand *g_dalvik_target_operand_new(const GBinContent *content, vmpa2t *pos, MemoryDataSize size, SourceEndian endian, vmpa_t base)
{
GDalvikTargetOperand *result; /* Structure à retourner */
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 */
vmpa_t address; /* Adresse finale visée */
switch (size)
{
case MDS_8_BITS_SIGNED:
- read_s8(&val8, data, pos, end);
+ test = g_binary_content_read_s8(content, pos, &val8);
address = base + val8 * sizeof(uint16_t);
break;
case MDS_16_BITS_SIGNED:
- read_s16(&val16, data, pos, end, endian);
+ test = g_binary_content_read_s16(content, pos, endian, &val16);
address = base + val16 * sizeof(uint16_t);
break;
case MDS_32_BITS_SIGNED:
- read_s32(&val32, data, pos, end, endian);
+ test = g_binary_content_read_s32(content, pos, endian, &val32);
address = base + val32 * sizeof(uint16_t);
break;
default:
@@ -197,6 +197,9 @@ GArchOperand *g_dalvik_target_operand_new(const bin_t *data, off_t *pos, off_t e
break;
}
+ if (!test)
+ return NULL;
+
result = g_object_new(G_TYPE_DALVIK_TARGET_OPERAND, NULL);
result->immediate = G_IMM_OPERAND(g_imm_operand_new_from_value(MDS_32_BITS/*FIXME*/, (uint32_t)address/* FIXME */));
diff --git a/src/arch/dalvik/operands/target.h b/src/arch/dalvik/operands/target.h
index e15b167..cb0e9f1 100644
--- a/src/arch/dalvik/operands/target.h
+++ b/src/arch/dalvik/operands/target.h
@@ -51,7 +51,7 @@ typedef struct _GDalvikTargetOperandClass GDalvikTargetOperandClass;
GType g_dalvik_target_operand_get_type(void);
/* Crée un opérande visant un instruction Dalvik. */
-GArchOperand *g_dalvik_target_operand_new(const bin_t *, off_t *, off_t, MemoryDataSize, SourceEndian, vmpa_t);
+GArchOperand *g_dalvik_target_operand_new(const GBinContent *, vmpa2t *, MemoryDataSize, SourceEndian, vmpa_t);
/* Fournit l'adresse représentée par une opérande Dalvik. */
const GImmOperand *g_dalvik_target_operand_get_value(const GDalvikTargetOperand *);