diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2018-04-02 11:58:42 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2018-04-02 12:39:30 (GMT) |
commit | 1db4ef323b7a76093356ae76268132f3760e1631 (patch) | |
tree | fec36ee0ec1b6b2010b62ca4177edca0e31e2114 /plugins/dalvik/pseudo | |
parent | 1bc80837dde03a32b5ab185067f7bd4c499a9850 (diff) |
Rewritten the whole instruction definition format.
Diffstat (limited to 'plugins/dalvik/pseudo')
-rw-r--r-- | plugins/dalvik/pseudo/fill.c | 36 | ||||
-rw-r--r-- | plugins/dalvik/pseudo/fill.h | 6 | ||||
-rw-r--r-- | plugins/dalvik/pseudo/identifiers.h | 39 | ||||
-rw-r--r-- | plugins/dalvik/pseudo/switch.c | 38 | ||||
-rw-r--r-- | plugins/dalvik/pseudo/switch.h | 6 |
5 files changed, 114 insertions, 11 deletions
diff --git a/plugins/dalvik/pseudo/fill.c b/plugins/dalvik/pseudo/fill.c index dc5683c..5c86a80 100644 --- a/plugins/dalvik/pseudo/fill.c +++ b/plugins/dalvik/pseudo/fill.c @@ -28,6 +28,7 @@ #include <string.h> +#include "identifiers.h" #include "../instruction-int.h" @@ -63,6 +64,9 @@ static void g_dalvik_fill_instr_dispose(GDalvikFillInstr *); /* Procède à la libération totale de la mémoire. */ static void g_dalvik_fill_instr_finalize(GDalvikFillInstr *); +/* Fournit le nom humain de l'instruction manipulée. */ +static const char *g_dalvik_fill_instruction_get_keyword(const GDalvikFillInstr *, AsmSyntax); + /* Indique le type défini pour une pseudo-instruction Dalvik de remplissage. */ @@ -84,12 +88,17 @@ G_DEFINE_TYPE(GDalvikFillInstr, g_dalvik_fill_instr, G_TYPE_DALVIK_INSTRUCTION); static void g_dalvik_fill_instr_class_init(GDalvikFillInstrClass *klass) { GObjectClass *object; /* Autre version de la classe */ + GArchInstructionClass *instr; /* Encore une autre vision... */ object = G_OBJECT_CLASS(klass); object->dispose = (GObjectFinalizeFunc/* ! */)g_dalvik_fill_instr_dispose; object->finalize = (GObjectFinalizeFunc)g_dalvik_fill_instr_finalize; + instr = G_ARCH_INSTRUCTION_CLASS(klass); + + instr->get_keyword = (get_instruction_keyword_fc)g_dalvik_fill_instruction_get_keyword; + } @@ -107,7 +116,6 @@ static void g_dalvik_fill_instr_class_init(GDalvikFillInstrClass *klass) static void g_dalvik_fill_instr_init(GDalvikFillInstr *instr) { - G_DALVIK_INSTRUCTION(instr)->keyword = "array-data"; } @@ -174,7 +182,7 @@ GArchInstruction *g_dalvik_fill_instr_new(uint16_t ident, GDalvikContext *ctx, c result = g_object_new(G_TYPE_DALVIK_FILL_INSTR, NULL); - G_DALVIK_INSTRUCTION(result)->ptype = ident; + G_ARCH_INSTRUCTION(result)->uid = DPO_FILL_ARRAY_DATA; if (!g_binary_content_read_u16(content, pos, SRE_LITTLE, &result->item_width)) goto gdfin_bad; @@ -196,3 +204,27 @@ GArchInstruction *g_dalvik_fill_instr_new(uint16_t ident, GDalvikContext *ctx, c return NULL; } + + +/****************************************************************************** +* * +* Paramètres : instr = instruction d'assemblage à consulter. * +* syntax = type de représentation demandée. * +* * +* Description : Fournit le nom humain de l'instruction manipulée. * +* * +* Retour : Mot clef de bas niveau. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static const char *g_dalvik_fill_instruction_get_keyword(const GDalvikFillInstr *instr, AsmSyntax syntax) +{ + const char *result; /* Désignation à retourner */ + + result = "array-data"; + + return result; + +} diff --git a/plugins/dalvik/pseudo/fill.h b/plugins/dalvik/pseudo/fill.h index 2a63df9..a022ed2 100644 --- a/plugins/dalvik/pseudo/fill.h +++ b/plugins/dalvik/pseudo/fill.h @@ -21,8 +21,8 @@ */ -#ifndef _ARCH_DALVIK_PSEUDO_FILL_H -#define _ARCH_DALVIK_PSEUDO_FILL_H +#ifndef _PLUGINS_DALVIK_PSEUDO_FILL_H +#define _PLUGINS_DALVIK_PSEUDO_FILL_H #include "../context.h" @@ -57,4 +57,4 @@ GArchInstruction *g_dalvik_fill_instr_new(uint16_t, GDalvikContext *, const GBin -#endif /* _ARCH_DALVIK_PSEUDO_FILL_H */ +#endif /* _PLUGINS_DALVIK_PSEUDO_FILL_H */ diff --git a/plugins/dalvik/pseudo/identifiers.h b/plugins/dalvik/pseudo/identifiers.h new file mode 100644 index 0000000..e1ab8fc --- /dev/null +++ b/plugins/dalvik/pseudo/identifiers.h @@ -0,0 +1,39 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * identifiers.h - définition d'identifiants uniques pour Dalvik + * + * 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_PSEUDO_IDENTIFIERS_H +#define _PLUGINS_DALVIK_PSEUDO_IDENTIFIERS_H + + +/* Enumération de tous les pseudo-opcodes */ +typedef enum _DalvikPseudoOpcodes +{ + DPO_PACKED_SWITCH = 0x0100, /* Switch aux clefs compactes */ + DPO_SPARSE_SWITCH = 0x0200, /* Switch aux clefs éclatées */ + DPO_FILL_ARRAY_DATA = 0x0300 /* Contenu de tableau */ + +} DalvikPseudoOpcodes; + + + +#endif /* _PLUGINS_DALVIK_PSEUDO_IDENTIFIERS_H */ diff --git a/plugins/dalvik/pseudo/switch.c b/plugins/dalvik/pseudo/switch.c index 90cff87..d6d255c 100644 --- a/plugins/dalvik/pseudo/switch.c +++ b/plugins/dalvik/pseudo/switch.c @@ -28,6 +28,7 @@ #include <malloc.h> +#include "identifiers.h" #include "../instruction-int.h" @@ -68,6 +69,9 @@ static void g_dalvik_switch_instr_finalize(GDalvikSwitchInstr *); /* Lit toutes les valeurs associés aux branchements. */ static bool g_dalvik_switch_decode_data(GDalvikSwitchInstr *, const GBinContent *, const vmpa2t *); +/* Fournit le nom humain de l'instruction manipulée. */ +static const char *g_dalvik_switch_instruction_get_keyword(const GDalvikSwitchInstr *, AsmSyntax); + /* Indique le type défini pour une pseudo-instruction Dalvik de remplissage. */ @@ -89,12 +93,17 @@ G_DEFINE_TYPE(GDalvikSwitchInstr, g_dalvik_switch_instr, G_TYPE_DALVIK_INSTRUCTI static void g_dalvik_switch_instr_class_init(GDalvikSwitchInstrClass *klass) { GObjectClass *object; /* Autre version de la classe */ + GArchInstructionClass *instr; /* Encore une autre vision... */ object = G_OBJECT_CLASS(klass); object->dispose = (GObjectFinalizeFunc/* ! */)g_dalvik_switch_instr_dispose; object->finalize = (GObjectFinalizeFunc)g_dalvik_switch_instr_finalize; + instr = G_ARCH_INSTRUCTION_CLASS(klass); + + instr->get_keyword = (get_instruction_keyword_fc)g_dalvik_switch_instruction_get_keyword; + } @@ -112,7 +121,6 @@ static void g_dalvik_switch_instr_class_init(GDalvikSwitchInstrClass *klass) static void g_dalvik_switch_instr_init(GDalvikSwitchInstr *instr) { - G_DALVIK_INSTRUCTION(instr)->keyword = "switch-data"; } @@ -185,7 +193,7 @@ GArchInstruction *g_dalvik_switch_instr_new(uint16_t ident, GDalvikContext *ctx, result = g_object_new(G_TYPE_DALVIK_SWITCH_INSTR, NULL); - G_DALVIK_INSTRUCTION(result)->ptype = ident; + G_ARCH_INSTRUCTION(result)->uid = ident; if (!g_binary_content_read_u16(content, pos, SRE_LITTLE, &result->switch_size)) goto gdsin_bad; @@ -237,7 +245,7 @@ static bool g_dalvik_switch_decode_data(GDalvikSwitchInstr *instr, const GBinCon copy_vmpa(&iter, pos); - if (G_DALVIK_INSTRUCTION(instr)->ptype == DPO_PACKED_SWITCH) + if (G_ARCH_INSTRUCTION(instr)->uid == DPO_PACKED_SWITCH) { if (!g_binary_content_read_s32(content, &iter, SRE_LITTLE, &first_key)) goto gdsdd_bad; @@ -276,6 +284,30 @@ static bool g_dalvik_switch_decode_data(GDalvikSwitchInstr *instr, const GBinCon /****************************************************************************** * * +* Paramètres : instr = instruction d'assemblage à consulter. * +* syntax = type de représentation demandée. * +* * +* Description : Fournit le nom humain de l'instruction manipulée. * +* * +* Retour : Mot clef de bas niveau. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static const char *g_dalvik_switch_instruction_get_keyword(const GDalvikSwitchInstr *instr, AsmSyntax syntax) +{ + const char *result; /* Désignation à retourner */ + + result = "switch-data"; + + return result; + +} + + +/****************************************************************************** +* * * Paramètres : instr = instruction d'assemblage à compléter. * * keys = tableau renseignant les conditions de saut. [OUT] * * targets = tableau renseignant les sauts relatifs. [OUT] * diff --git a/plugins/dalvik/pseudo/switch.h b/plugins/dalvik/pseudo/switch.h index d672f86..b17a9c9 100644 --- a/plugins/dalvik/pseudo/switch.h +++ b/plugins/dalvik/pseudo/switch.h @@ -21,8 +21,8 @@ */ -#ifndef _ARCH_DALVIK_PSEUDO_SWITCH_H -#define _ARCH_DALVIK_PSEUDO_SWITCH_H +#ifndef _PLUGINS_DALVIK_PSEUDO_SWITCH_H +#define _PLUGINS_DALVIK_PSEUDO_SWITCH_H #include "../context.h" @@ -60,4 +60,4 @@ uint16_t g_dalvik_switch_get_data(GDalvikSwitchInstr *, const int32_t **, const -#endif /* _ARCH_DALVIK_PSEUDO_SWITCH_H */ +#endif /* _PLUGINS_DALVIK_PSEUDO_SWITCH_H */ |