summaryrefslogtreecommitdiff
path: root/src/arch
diff options
context:
space:
mode:
Diffstat (limited to 'src/arch')
-rw-r--r--src/arch/arm/v7/processor.c31
-rw-r--r--src/arch/dalvik/operand.c4
-rw-r--r--src/arch/dalvik/operands/pool.c2
-rw-r--r--src/arch/dalvik/operands/register.c4
-rw-r--r--src/arch/dalvik/operands/target.c2
-rw-r--r--src/arch/immediate.c12
-rw-r--r--src/arch/immediate.h3
-rw-r--r--src/arch/instruction.h2
-rw-r--r--src/arch/processor-int.h2
-rw-r--r--src/arch/processor.c7
10 files changed, 28 insertions, 41 deletions
diff --git a/src/arch/arm/v7/processor.c b/src/arch/arm/v7/processor.c
index 9117861..7a1dd5a 100644
--- a/src/arch/arm/v7/processor.c
+++ b/src/arch/arm/v7/processor.c
@@ -68,7 +68,7 @@ static void g_armv7_processor_finalize(GArmV7Processor *);
static GArmV7Context *g_armv7_processor_get_context(const GArmV7Processor *);
/* Décode une instruction dans un flux de données. */
-static GArchInstruction *g_armv7_processor_disassemble(const GArmV7Processor *, GArmV7Context *, const bin_t *, vmpa2t *, phys_t);
+static GArchInstruction *g_armv7_processor_disassemble(const GArmV7Processor *, GArmV7Context *, const GBinContent *, vmpa2t *);
@@ -218,11 +218,10 @@ static GArmV7Context *g_armv7_processor_get_context(const GArmV7Processor *proc)
/******************************************************************************
* *
-* Paramètres : proc = architecture visée par la procédure. *
-* ctx = contexte lié à l'exécution du processeur. *
-* data = flux de données à analyser. *
-* pos = position courante dans ce flux. [OUT] *
-* end = limite des données à analyser. *
+* Paramètres : proc = architecture visée par la procédure. *
+* ctx = contexte lié à l'exécution du processeur. *
+* content = flux de données à analyser. *
+* pos = position courante dans ce flux. [OUT] *
* *
* Description : Désassemble une instruction dans un flux de données. *
* *
@@ -232,26 +231,23 @@ static GArmV7Context *g_armv7_processor_get_context(const GArmV7Processor *proc)
* *
******************************************************************************/
-static GArchInstruction *g_armv7_processor_disassemble(const GArmV7Processor *proc, GArmV7Context *ctx, const bin_t *data, vmpa2t *pos, phys_t end)
+static GArchInstruction *g_armv7_processor_disassemble(const GArmV7Processor *proc, GArmV7Context *ctx, const GBinContent *content, vmpa2t *pos)
{
GArchInstruction *result; /* Instruction à renvoyer */
- phys_t start; /* Point de départ de lecture */
- phys_t diff; /* Avancée dans la lecture */
+ SourceEndian endian; /* Boutisme des données lues */
uint16_t raw16; /* Donnée 16 bits à analyser */
uint32_t raw32; /* Donnée 32 bits à analyser */
ArmV7InstrSet iset; /* Type de jeu d'instructions */
- iset = g_armv7_context_find_encoding(ctx, get_virt_addr(pos));
-
- start = get_phy_addr(pos);
+ endian = G_ARCH_PROCESSOR(proc)->endianness;
- diff = 4;
+ iset = g_armv7_context_find_encoding(ctx, get_virt_addr(pos));
switch (iset)
{
case AV7IS_ARM:
- if (!read_u32(&raw32, data, &start, end, G_ARCH_PROCESSOR(proc)->endianness))
+ if (!g_binary_content_read_u32(content, pos, endian, &raw32))
return NULL;
result = process_armv7_arm_instruction_set_encoding(raw32);
@@ -260,7 +256,7 @@ static GArchInstruction *g_armv7_processor_disassemble(const GArmV7Processor *pr
case AV7IS_THUMB:
- if (!read_u16(&raw16, data, &start, end, G_ARCH_PROCESSOR(proc)->endianness))
+ if (!g_binary_content_read_u16(content, pos, endian, &raw16))
return NULL;
switch (raw16 >> 11)
@@ -271,7 +267,7 @@ static GArchInstruction *g_armv7_processor_disassemble(const GArmV7Processor *pr
raw32 = raw16 << 16;
- if (!read_u16(&raw16, data, &start, end, G_ARCH_PROCESSOR(proc)->endianness))
+ if (!g_binary_content_read_u16(content, pos, endian, &raw16))
return NULL;
raw32 |= raw16;
@@ -280,7 +276,6 @@ static GArchInstruction *g_armv7_processor_disassemble(const GArmV7Processor *pr
break;
default:
- diff = 2;
result = process_armv7_thumb_16_instruction_set_encoding(raw16);
break;
@@ -294,8 +289,6 @@ static GArchInstruction *g_armv7_processor_disassemble(const GArmV7Processor *pr
}
- if (result != NULL)
- advance_vmpa(pos, diff);
/*
else
result = g_raw_instruction_new_array_old(data, MDS_32_BITS, 1, pos, end,
diff --git a/src/arch/dalvik/operand.c b/src/arch/dalvik/operand.c
index fca7956..838d953 100644
--- a/src/arch/dalvik/operand.c
+++ b/src/arch/dalvik/operand.c
@@ -398,7 +398,7 @@ static bool dalvik_read_fixed_operands(GArchInstruction *instr, const GDexFormat
opa = g_dalvik_register_operand_new(data, pos, end, low, MDS_4_BITS, endian);
- if (!read_u4(&b, data, pos, end, low, endian))
+ if (!read_u4(&b, data, pos, end, low))
goto err_va;
@@ -492,7 +492,7 @@ static bool dalvik_read_variatic_operands(GArchInstruction *instr, const GDexFor
uint16_t c; /* Indice de registre */
GArchOperand *op; /* Opérande unique décodé */
- if (!read_u8(&a, data, pos, end, endian))
+ if (!read_u8(&a, data, pos, end))
return false;
if (!read_u16(&b, data, pos, end, endian))
diff --git a/src/arch/dalvik/operands/pool.c b/src/arch/dalvik/operands/pool.c
index a1fde2e..3537cd6 100644
--- a/src/arch/dalvik/operands/pool.c
+++ b/src/arch/dalvik/operands/pool.c
@@ -191,7 +191,7 @@ GArchOperand *g_dalvik_pool_operand_new(const GDexFormat *format, DalvikPoolType
switch (size)
{
case MDS_8_BITS:
- test = read_u8(&index8, data, pos, end, endian);
+ test = read_u8(&index8, data, pos, end);
break;
case MDS_16_BITS:
test = read_u16(&index16, data, pos, end, endian);
diff --git a/src/arch/dalvik/operands/register.c b/src/arch/dalvik/operands/register.c
index 2ae9224..1b789f2 100644
--- a/src/arch/dalvik/operands/register.c
+++ b/src/arch/dalvik/operands/register.c
@@ -184,10 +184,10 @@ 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, endian);
+ test = read_u4(&index8, data, pos, end, low);
break;
case MDS_8_BITS:
- test = read_u8(&index8, data, pos, end, endian);
+ test = read_u8(&index8, data, pos, end);
break;
case MDS_16_BITS:
test = read_u16(&index16, data, pos, end, endian);
diff --git a/src/arch/dalvik/operands/target.c b/src/arch/dalvik/operands/target.c
index 147aaae..690858b 100644
--- a/src/arch/dalvik/operands/target.c
+++ b/src/arch/dalvik/operands/target.c
@@ -181,7 +181,7 @@ GArchOperand *g_dalvik_target_operand_new(const bin_t *data, off_t *pos, off_t e
switch (size)
{
case MDS_8_BITS_SIGNED:
- read_s8(&val8, data, pos, end, endian);
+ read_s8(&val8, data, pos, end);
address = base + val8 * sizeof(uint16_t);
break;
case MDS_16_BITS_SIGNED:
diff --git a/src/arch/immediate.c b/src/arch/immediate.c
index c21239e..3720bff 100644
--- a/src/arch/immediate.c
+++ b/src/arch/immediate.c
@@ -235,13 +235,13 @@ GArchOperand *_g_imm_operand_new_from_data_old(MemoryDataSize size, const bin_t
switch (size)
{
case MDS_4_BITS_UNSIGNED:
- if (!read_u4(&uval8, data, &pos, end, low, endian))
+ if (!read_u4(&uval8, data, &pos, end, low))
goto gionfd_error;
result->raw = uval8;
break;
case MDS_8_BITS_UNSIGNED:
- if (!read_u8(&uval8, data, &pos, end, endian))
+ if (!read_u8(&uval8, data, &pos, end))
goto gionfd_error;
result->raw = uval8;
break;
@@ -265,13 +265,13 @@ GArchOperand *_g_imm_operand_new_from_data_old(MemoryDataSize size, const bin_t
break;
case MDS_4_BITS_SIGNED:
- if (!read_s4(&sval8, data, &pos, end, low, endian))
+ if (!read_s4(&sval8, data, &pos, end, low))
goto gionfd_error;
result->raw = sval8;
break;
case MDS_8_BITS_SIGNED:
- if (!read_s8(&sval8, data, &pos, end, endian))
+ if (!read_s8(&sval8, data, &pos, end))
goto gionfd_error;
result->raw = sval8;
break;
@@ -348,7 +348,7 @@ GArchOperand *_g_imm_operand_new_from_data(MemoryDataSize size, const GBinConten
switch (size)
{
case MDS_4_BITS_UNSIGNED:
- if (!g_binary_content_read_u4(content, addr, low, endian, &uval8))
+ if (!g_binary_content_read_u4(content, addr, low, &uval8))
goto gionfd_error;
result->raw = uval8;
break;
@@ -378,7 +378,7 @@ GArchOperand *_g_imm_operand_new_from_data(MemoryDataSize size, const GBinConten
break;
case MDS_4_BITS_SIGNED:
- if (!g_binary_content_read_s4(content, addr, low, endian, &sval8))
+ if (!g_binary_content_read_s4(content, addr, low, &sval8))
goto gionfd_error;
result->raw = sval8;
break;
diff --git a/src/arch/immediate.h b/src/arch/immediate.h
index 2393b49..1a587ad 100644
--- a/src/arch/immediate.h
+++ b/src/arch/immediate.h
@@ -32,8 +32,7 @@
#include "archbase.h"
#include "operand.h"
-#include "../common/endianness.h"
-#include "../glibext/gbincontent.h"
+#include "../analysis/content.h"
diff --git a/src/arch/instruction.h b/src/arch/instruction.h
index b3a272f..baeee2e 100644
--- a/src/arch/instruction.h
+++ b/src/arch/instruction.h
@@ -32,10 +32,10 @@
#include "immediate.h"
#include "register.h"
#include "vmpa.h"
+#include "../analysis/content.h"
#include "../analysis/type.h"
#include "../decomp/context.h"
#include "../decomp/instruction.h"
-#include "../glibext/gbincontent.h"
//#include "../format/executable.h"
//#include "../format/format.h"
diff --git a/src/arch/processor-int.h b/src/arch/processor-int.h
index d387bde..f4562f6 100644
--- a/src/arch/processor-int.h
+++ b/src/arch/processor-int.h
@@ -58,7 +58,7 @@ typedef GDecContext * (* get_decomp_context_fc) (const GArchProcessor *);
typedef GArchInstruction * (* decode_instruction_fc) (const GArchProcessor *, GProcContext *, const bin_t *, off_t *, off_t, vmpa_t, GBinFormat *);
/* Désassemble une instruction dans un flux de données. */
-typedef GArchInstruction * (* disass_instr_fc) (const GArchProcessor *, GProcContext *, const bin_t *, vmpa2t *, phys_t);
+typedef GArchInstruction * (* disass_instr_fc) (const GArchProcessor *, GProcContext *, const GBinContent *, vmpa2t *);
/* Définition générique d'un processeur d'architecture (instance) */
diff --git a/src/arch/processor.c b/src/arch/processor.c
index 95176e9..7e2ecec 100644
--- a/src/arch/processor.c
+++ b/src/arch/processor.c
@@ -286,15 +286,10 @@ GArchInstruction *g_arch_processor_disassemble(const GArchProcessor *proc, GProc
{
GArchInstruction *result; /* Instruction à renvoyer */
vmpa2t back; /* Position sauvegardée */
- /* FIXME */
- const bin_t *_bin_data;
- off_t _bin_length;
copy_vmpa(&back, pos);
- _bin_data = g_binary_content_get(content, &_bin_length);
-
- result = G_ARCH_PROCESSOR_GET_CLASS(proc)->disassemble(proc, ctx, _bin_data, pos, _bin_length);
+ result = G_ARCH_PROCESSOR_GET_CLASS(proc)->disassemble(proc, ctx, content, pos);
if (result == NULL)
copy_vmpa(pos, &back);