summaryrefslogtreecommitdiff
path: root/src/arch/dalvik/processor.c
blob: a7a95c36ef74a1a4f45f179a2b586e71e50fdedd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581

/* Chrysalide - Outil d'analyse de fichiers binaires
 * processor.c - manipulation du processeur de la VM Dalvik
 *
 * Copyright (C) 2010-2012 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 Foobar.  If not, see <http://www.gnu.org/licenses/>.
 */


#include "processor.h"


#include <assert.h>


#include "context.h"
#include "instruction.h"
#include "opcodes/opcodes.h"
#include "pseudo/fill.h"
#include "pseudo/switch.h"
#include "../processor-int.h"
#include "../../format/dex/dex.h"



/* Définition du processeur de la VM Dalvik (instance) */
struct _GDalvikProcessor
{
    GArchProcessor parent;                  /* Instance parente            */

};


/* Définition du processeur de la VM Dalvik (classe) */
struct _GDalvikProcessorClass
{
    GArchProcessorClass parent;             /* Classe parente              */

};


/* Initialise la classe des processeurs de VM Dalvik. */
static void g_dalvik_processor_class_init(GDalvikProcessorClass *);

/* Initialise une instance de processeur de VM Dalvik. */
static void g_dalvik_processor_init(GDalvikProcessor *);

/* Supprime toutes les références externes. */
static void g_dalvik_processor_dispose(GDalvikProcessor *);

/* Procède à la libération totale de la mémoire. */
static void g_dalvik_processor_finalize(GDalvikProcessor *);

/* Fournit un contexte pour l'exécution du processeur Dalvik. */
static GDalvikContext *g_dalvik_processor_get_context(const GDalvikProcessor *);

/* Fournit un contexte pour la décompilation Dalvik. */
//static GDalvikDContext *g_dalvik_processor_get_decomp_context(const GDalvikProcessor *);

/* Décode une instruction dans un flux de données. */
static GArchInstruction *g_dalvik_processor_disassemble(const GArchProcessor *, GDalvikContext *, const GBinContent *, vmpa2t *, GExeFormat *);

/* Décode une pseudo-instruction dans un flux de données. */
static GArchInstruction *g_dalvik_processor_disassemble_pseudo(const GArchProcessor *, GDalvikContext *, const GBinContent *, vmpa2t *, uint8_t);



/* Indique le type défini par la GLib pour le processeur DALVIK. */
G_DEFINE_TYPE(GDalvikProcessor, g_dalvik_processor, G_TYPE_ARCH_PROCESSOR);



/******************************************************************************
*                                                                             *
*  Paramètres  : klass = classe à initialiser.                                *
*                                                                             *
*  Description : Initialise la classe des processeurs de VM Dalvik.           *
*                                                                             *
*  Retour      : -                                                            *
*                                                                             *
*  Remarques   : -                                                            *
*                                                                             *
******************************************************************************/

static void g_dalvik_processor_class_init(GDalvikProcessorClass *klass)
{
    GObjectClass *object;                   /* Autre version de la classe  */
    GArchProcessorClass *proc;              /* Encore une autre vision...  */

    object = G_OBJECT_CLASS(klass);

    object->dispose = (GObjectFinalizeFunc/* ! */)g_dalvik_processor_dispose;
    object->finalize = (GObjectFinalizeFunc)g_dalvik_processor_finalize;

    proc = G_ARCH_PROCESSOR_CLASS(klass);

    proc->disassemble = (disass_instr_fc)g_dalvik_processor_disassemble;

}


/******************************************************************************
*                                                                             *
*  Paramètres  : proc = instance à initialiser.                               *
*                                                                             *
*  Description : Initialise une instance de processeur de VM Dalvik.          *
*                                                                             *
*  Retour      : -                                                            *
*                                                                             *
*  Remarques   : -                                                            *
*                                                                             *
******************************************************************************/

static void g_dalvik_processor_init(GDalvikProcessor *proc)
{
    GArchProcessor *parent;                 /* Instance parente            */

    parent = G_ARCH_PROCESSOR(proc);

    parent->endianness = SRE_LITTLE;
    parent->memsize = MDS_32_BITS;
    parent->inssize = MDS_16_BITS;

    parent->get_ctx = (get_processor_context_fc)g_dalvik_processor_get_context;
    //parent->get_dec_ctx = (get_decomp_context_fc)g_dalvik_processor_get_decomp_context;

}


/******************************************************************************
*                                                                             *
*  Paramètres  : proc = instance d'objet GLib à traiter.                      *
*                                                                             *
*  Description : Supprime toutes les références externes.                     *
*                                                                             *
*  Retour      : -                                                            *
*                                                                             *
*  Remarques   : -                                                            *
*                                                                             *
******************************************************************************/

static void g_dalvik_processor_dispose(GDalvikProcessor *proc)
{
    G_OBJECT_CLASS(g_dalvik_processor_parent_class)->dispose(G_OBJECT(proc));

}


/******************************************************************************
*                                                                             *
*  Paramètres  : bookmark = instance d'objet GLib à traiter.                  *
*                                                                             *
*  Description : Procède à la libération totale de la mémoire.                *
*                                                                             *
*  Retour      : -                                                            *
*                                                                             *
*  Remarques   : -                                                            *
*                                                                             *
******************************************************************************/

static void g_dalvik_processor_finalize(GDalvikProcessor *proc)
{
    G_OBJECT_CLASS(g_dalvik_processor_parent_class)->finalize(G_OBJECT(proc));

}


/******************************************************************************
*                                                                             *
*  Paramètres  : -                                                            *
*                                                                             *
*  Description : Crée le support de l'architecture Dalvik.                    *
*                                                                             *
*  Retour      : Architecture mise en place.                                  *
*                                                                             *
*  Remarques   : -                                                            *
*                                                                             *
******************************************************************************/

GArchProcessor *g_dalvik_processor_new(void)
{
    GArchProcessor *result;                 /* Structure à retourner       */

    result = g_object_new(G_TYPE_DALVIK_PROCESSOR, NULL);

    return result;

}


/******************************************************************************
*                                                                             *
*  Paramètres  : proc = architecture, spectatrice ici.                        *
*                                                                             *
*  Description : Fournit un contexte pour l'exécution du processeur Dalvik.   *
*                                                                             *
*  Retour      : Contexte mis en place.                                       *
*                                                                             *
*  Remarques   : -                                                            *
*                                                                             *
******************************************************************************/

static GDalvikContext *g_dalvik_processor_get_context(const GDalvikProcessor *proc)
{
    return g_dalvik_context_new();

}


/******************************************************************************
*                                                                             *
*  Paramètres  : proc = architecture, spectatrice ici.                        *
*                                                                             *
*  Description : Fournit un contexte pour la décompilation Dalvik.            *
*                                                                             *
*  Retour      : Contexte mis en place.                                       *
*                                                                             *
*  Remarques   : -                                                            *
*                                                                             *
******************************************************************************/
#if 0
static GDalvikDContext *g_dalvik_processor_get_decomp_context(const GDalvikProcessor *proc)
{
    return g_dalvik_dcontext_new();

}
#endif


/******************************************************************************
*                                                                             *
*  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]              *
*                format  = format du fichier contenant le code.               *
*                                                                             *
*  Description : Désassemble une instruction dans un flux de données.         *
*                                                                             *
*  Retour      : Instruction mise en place ou NULL en cas d'échec.            *
*                                                                             *
*  Remarques   : -                                                            *
*                                                                             *
******************************************************************************/

static GArchInstruction *g_dalvik_processor_disassemble(const GArchProcessor *proc, GDalvikContext *ctx, const GBinContent *content, vmpa2t *pos, GExeFormat *format)
{
    GArchInstruction *result;               /* Instruction à renvoyer      */
    uint8_t raw8;                           /* Donnée de 8 bits à analyser */
    DalvikOpcodes id;                       /* Identifiant d'instruction   */

    static const disass_instr_fc decodings[DOP_COUNT] = {

        [DOP_NOP]                   = dalvik_read_instr_nop,
        [DOP_MOVE]                  = dalvik_read_instr_move,
        [DOP_MOVE_FROM_16]          = dalvik_read_instr_move_from16,
        [DOP_MOVE_16]               = dalvik_read_instr_move_16,
        [DOP_MOVE_WIDE]             = dalvik_read_instr_move_wide,
        [DOP_MOVE_WIDE_FROM_16]     = dalvik_read_instr_move_wide_from16,
        [DOP_MOVE_WIDE_16]          = dalvik_read_instr_move_wide_16,
        [DOP_MOVE_OBJECT]           = dalvik_read_instr_move_object,
        [DOP_MOVE_OBJECT_FROM_16]   = dalvik_read_instr_move_object_from16,
        [DOP_MOVE_OBJECT_16]        = dalvik_read_instr_move_object_16,
        [DOP_MOVE_RESULT]           = dalvik_read_instr_move_result,
        [DOP_MOVE_RESULT_WIDE]      = dalvik_read_instr_move_result_wide,
        [DOP_MOVE_RESULT_OBJECT]    = dalvik_read_instr_move_result_object,
        [DOP_MOVE_EXCEPTION]        = dalvik_read_instr_move_exception,
        [DOP_RETURN_VOID]           = dalvik_read_instr_return_void,
        [DOP_RETURN]                = dalvik_read_instr_return,
        [DOP_RETURN_WIDE]           = dalvik_read_instr_return_wide,
        [DOP_RETURN_OBJECT]         = dalvik_read_instr_return_object,
        [DOP_CONST_4]               = dalvik_read_instr_const_4,
        [DOP_CONST_16]              = dalvik_read_instr_const_16,
        [DOP_CONST]                 = dalvik_read_instr_const,
        [DOP_CONST_HIGH16]          = dalvik_read_instr_const_high16,
        [DOP_CONST_WIDE_16]         = dalvik_read_instr_const_wide_16,
        [DOP_CONST_WIDE_32]         = dalvik_read_instr_const_wide_32,
        [DOP_CONST_WIDE]            = dalvik_read_instr_const_wide,
        [DOP_CONST_WIDE_HIGH16]     = dalvik_read_instr_const_wide_high16,
        [DOP_CONST_STRING]          = dalvik_read_instr_const_string,
        [DOP_CONST_STRING_JUMBO]    = dalvik_read_instr_const_string_jumbo,
        [DOP_CONST_CLASS]           = dalvik_read_instr_const_class,
        [DOP_MONITOR_ENTER]         = dalvik_read_instr_monitor_enter,
        [DOP_MONITOR_EXIT]          = dalvik_read_instr_monitor_exit,
        [DOP_CHECK_CAST]            = dalvik_read_instr_check_cast,
        [DOP_INSTANCE_OF]           = dalvik_read_instr_instance_of,
        [DOP_ARRAY_LENGTH]          = dalvik_read_instr_array_length,
        [DOP_NEW_INSTANCE]          = dalvik_read_instr_new_instance,
        [DOP_NEW_ARRAY]             = dalvik_read_instr_new_array,
        [DOP_FILLED_NEW_ARRAY]      = dalvik_read_instr_filled_new_array,
        [DOP_FILLED_NEW_ARRAY_RANGE]= dalvik_read_instr_filled_new_array_range,
        [DOP_FILL_ARRAY_DATA]       = dalvik_read_instr_fill_array_data,
        [DOP_THROW]                 = dalvik_read_instr_throw,
        [DOP_GOTO]                  = dalvik_read_instr_goto,
        [DOP_GOTO_16]               = dalvik_read_instr_goto_16,
        [DOP_GOTO_32]               = dalvik_read_instr_goto_32,
        [DOP_PACKED_SWITCH]         = dalvik_read_instr_packed_switch,
        [DOP_SPARSE_SWITCH]         = dalvik_read_instr_sparse_switch,
        [DOP_CMPL_FLOAT]            = dalvik_read_instr_cmpl_float,
        [DOP_CMPG_FLOAT]            = dalvik_read_instr_cmpg_float,
        [DOP_CMPL_DOUBLE]           = dalvik_read_instr_cmpl_double,
        [DOP_CMPG_DOUBLE]           = dalvik_read_instr_cmpg_double,
        [DOP_CMP_LONG]              = dalvik_read_instr_cmp_long,
        [DOP_IF_EQ]                 = dalvik_read_instr_if_eq,
        [DOP_IF_NE]                 = dalvik_read_instr_if_ne,
        [DOP_IF_LT]                 = dalvik_read_instr_if_lt,
        [DOP_IF_GE]                 = dalvik_read_instr_if_ge,
        [DOP_IF_GT]                 = dalvik_read_instr_if_gt,
        [DOP_IF_LE]                 = dalvik_read_instr_if_le,
        [DOP_IF_EQZ]                = dalvik_read_instr_if_eqz,
        [DOP_IF_NEZ]                = dalvik_read_instr_if_nez,
        [DOP_IF_LTZ]                = dalvik_read_instr_if_ltz,
        [DOP_IF_GEZ]                = dalvik_read_instr_if_gez,
        [DOP_IF_GTZ]                = dalvik_read_instr_if_gtz,
        [DOP_IF_LEZ]                = dalvik_read_instr_if_lez,
        [DOP_AGET]                  = dalvik_read_instr_aget,
        [DOP_AGET_WIDE]             = dalvik_read_instr_aget_wide,
        [DOP_AGET_OBJECT]           = dalvik_read_instr_aget_object,
        [DOP_AGET_BOOLEAN]          = dalvik_read_instr_aget_boolean,
        [DOP_AGET_BYTE]             = dalvik_read_instr_aget_byte,
        [DOP_AGET_CHAR]             = dalvik_read_instr_aget_char,
        [DOP_AGET_SHORT]            = dalvik_read_instr_aget_short,
        [DOP_APUT]                  = dalvik_read_instr_aput,
        [DOP_APUT_WIDE]             = dalvik_read_instr_aput_wide,
        [DOP_APUT_OBJECT]           = dalvik_read_instr_aput_object,
        [DOP_APUT_BOOLEAN]          = dalvik_read_instr_aput_boolean,
        [DOP_APUT_BYTE]             = dalvik_read_instr_aput_byte,
        [DOP_APUT_CHAR]             = dalvik_read_instr_aput_char,
        [DOP_APUT_SHORT]            = dalvik_read_instr_aput_short,
        [DOP_IGET]                  = dalvik_read_instr_iget,
        [DOP_IGET_WIDE]             = dalvik_read_instr_iget_wide,
        [DOP_IGET_OBJECT]           = dalvik_read_instr_iget_object,
        [DOP_IGET_BOOLEAN]          = dalvik_read_instr_iget_boolean,
        [DOP_IGET_BYTE]             = dalvik_read_instr_iget_byte,
        [DOP_IGET_CHAR]             = dalvik_read_instr_iget_char,
        [DOP_IGET_SHORT]            = dalvik_read_instr_iget_short,
        [DOP_IPUT]                  = dalvik_read_instr_iput,
        [DOP_IPUT_WIDE]             = dalvik_read_instr_iput_wide,
        [DOP_IPUT_OBJECT]           = dalvik_read_instr_iput_object,
        [DOP_IPUT_BOOLEAN]          = dalvik_read_instr_iput_boolean,
        [DOP_IPUT_BYTE]             = dalvik_read_instr_iput_byte,
        [DOP_IPUT_CHAR]             = dalvik_read_instr_iput_char,
        [DOP_IPUT_SHORT]            = dalvik_read_instr_iput_short,
        [DOP_SGET]                  = dalvik_read_instr_sget,
        [DOP_SGET_WIDE]             = dalvik_read_instr_sget_wide,
        [DOP_SGET_OBJECT]           = dalvik_read_instr_sget_object,
        [DOP_SGET_BOOLEAN]          = dalvik_read_instr_sget_boolean,
        [DOP_SGET_BYTE]             = dalvik_read_instr_sget_byte,
        [DOP_SGET_CHAR]             = dalvik_read_instr_sget_char,
        [DOP_SGET_SHORT]            = dalvik_read_instr_sget_short,
        [DOP_SPUT]                  = dalvik_read_instr_sput,
        [DOP_SPUT_WIDE]             = dalvik_read_instr_sput_wide,
        [DOP_SPUT_OBJECT]           = dalvik_read_instr_sput_object,
        [DOP_SPUT_BOOLEAN]          = dalvik_read_instr_sput_boolean,
        [DOP_SPUT_BYTE]             = dalvik_read_instr_sput_byte,
        [DOP_SPUT_CHAR]             = dalvik_read_instr_sput_char,
        [DOP_SPUT_SHORT]            = dalvik_read_instr_sput_short,
        [DOP_INVOKE_VIRTUAL]        = dalvik_read_instr_invoke_virtual,
        [DOP_INVOKE_SUPER]          = dalvik_read_instr_invoke_super,
        [DOP_INVOKE_DIRECT]         = dalvik_read_instr_invoke_direct,
        [DOP_INVOKE_STATIC]         = dalvik_read_instr_invoke_static,
        [DOP_INVOKE_INTERFACE]      = dalvik_read_instr_invoke_interface,
        [DOP_INVOKE_VIRTUAL_RANGE]  = dalvik_read_instr_invoke_virtual_range,
        [DOP_INVOKE_SUPER_RANGE]    = dalvik_read_instr_invoke_super_range,
        [DOP_INVOKE_DIRECT_RANGE]   = dalvik_read_instr_invoke_direct_range,
        [DOP_INVOKE_STATIC_RANGE]   = dalvik_read_instr_invoke_static_range,
        [DOP_INVOKE_INTERFACE_RANGE]= dalvik_read_instr_invoke_interface_range,
        [DOP_NEG_INT]               = dalvik_read_instr_neg_int,
        [DOP_NOT_INT]               = dalvik_read_instr_not_int,
        [DOP_NEG_LONG]              = dalvik_read_instr_neg_long,
        [DOP_NOT_LONG]              = dalvik_read_instr_not_long,
        [DOP_NEG_FLOAT]             = dalvik_read_instr_neg_float,
        [DOP_NEG_DOUBLE]            = dalvik_read_instr_neg_double,
        [DOP_TO_INT_LONG]           = dalvik_read_instr_int_to_long,
        [DOP_TO_INT_FLOAT]          = dalvik_read_instr_int_to_float,
        [DOP_TO_INT_DOUBLE]         = dalvik_read_instr_int_to_double,
        [DOP_TO_LONG_INT]           = dalvik_read_instr_long_to_int,
        [DOP_TO_LONG_FLOAT]         = dalvik_read_instr_long_to_float,
        [DOP_TO_LONG_DOUBLE]        = dalvik_read_instr_long_to_double,
        [DOP_TO_FLOAT_INT]          = dalvik_read_instr_float_to_int,
        [DOP_TO_FLOAT_LONG]         = dalvik_read_instr_float_to_long,
        [DOP_TO_FLOAT_DOUBLE]       = dalvik_read_instr_float_to_double,
        [DOP_TO_DOUBLE_INT]         = dalvik_read_instr_double_to_int,
        [DOP_TO_DOUBLE_LONG]        = dalvik_read_instr_double_to_long,
        [DOP_TO_DOUBLE_FLOAT]       = dalvik_read_instr_double_to_float,
        [DOP_TO_INT_BYTE]           = dalvik_read_instr_int_to_byte,
        [DOP_TO_INT_CHAR]           = dalvik_read_instr_int_to_char,
        [DOP_TO_INT_SHORT]          = dalvik_read_instr_int_to_short,
        [DOP_ADD_INT]               = dalvik_read_instr_add_int,
        [DOP_SUB_INT]               = dalvik_read_instr_sub_int,
        [DOP_MUL_INT]               = dalvik_read_instr_mul_int,
        [DOP_DIV_INT]               = dalvik_read_instr_div_int,
        [DOP_REM_INT]               = dalvik_read_instr_rem_int,
        [DOP_AND_INT]               = dalvik_read_instr_and_int,
        [DOP_OR_INT]                = dalvik_read_instr_or_int,
        [DOP_XOR_INT]               = dalvik_read_instr_xor_int,
        [DOP_SHL_INT]               = dalvik_read_instr_shl_int,
        [DOP_SHR_INT]               = dalvik_read_instr_shr_int,
        [DOP_USHR_INT]              = dalvik_read_instr_ushr_int,
        [DOP_ADD_LONG]              = dalvik_read_instr_add_long,
        [DOP_SUB_LONG]              = dalvik_read_instr_sub_long,
        [DOP_MUL_LONG]              = dalvik_read_instr_mul_long,
        [DOP_DIV_LONG]              = dalvik_read_instr_div_long,
        [DOP_REM_LONG]              = dalvik_read_instr_rem_long,
        [DOP_AND_LONG]              = dalvik_read_instr_and_long,
        [DOP_OR_LONG]               = dalvik_read_instr_or_long,
        [DOP_XOR_LONG]              = dalvik_read_instr_xor_long,
        [DOP_SHL_LONG]              = dalvik_read_instr_shl_long,
        [DOP_SHR_LONG]              = dalvik_read_instr_shr_long,
        [DOP_USHR_LONG]             = dalvik_read_instr_ushr_long,
        [DOP_ADD_FLOAT]             = dalvik_read_instr_add_float,
        [DOP_SUB_FLOAT]             = dalvik_read_instr_sub_float,
        [DOP_MUL_FLOAT]             = dalvik_read_instr_mul_float,
        [DOP_DIV_FLOAT]             = dalvik_read_instr_div_float,
        [DOP_REM_FLOAT]             = dalvik_read_instr_rem_float,
        [DOP_ADD_DOUBLE]            = dalvik_read_instr_add_double,
        [DOP_SUB_DOUBLE]            = dalvik_read_instr_sub_double,
        [DOP_MUL_DOUBLE]            = dalvik_read_instr_mul_double,
        [DOP_DIV_DOUBLE]            = dalvik_read_instr_div_double,
        [DOP_REM_DOUBLE]            = dalvik_read_instr_rem_double,
        [DOP_ADD_INT_2ADDR]         = dalvik_read_instr_add_int_2addr,
        [DOP_SUB_INT_2ADDR]         = dalvik_read_instr_sub_int_2addr,
        [DOP_MUL_INT_2ADDR]         = dalvik_read_instr_mul_int_2addr,
        [DOP_DIV_INT_2ADDR]         = dalvik_read_instr_div_int_2addr,
        [DOP_REM_INT_2ADDR]         = dalvik_read_instr_rem_int_2addr,
        [DOP_AND_INT_2ADDR]         = dalvik_read_instr_and_int_2addr,
        [DOP_OR_INT_2ADDR]          = dalvik_read_instr_or_int_2addr,
        [DOP_XOR_INT_2ADDR]         = dalvik_read_instr_xor_int_2addr,
        [DOP_SHL_INT_2ADDR]         = dalvik_read_instr_shl_int_2addr,
        [DOP_SHR_INT_2ADDR]         = dalvik_read_instr_shr_int_2addr,
        [DOP_USHR_INT_2ADDR]        = dalvik_read_instr_ushr_int_2addr,
        [DOP_ADD_LONG_2ADDR]        = dalvik_read_instr_add_long_2addr,
        [DOP_SUB_LONG_2ADDR]        = dalvik_read_instr_sub_long_2addr,
        [DOP_MUL_LONG_2ADDR]        = dalvik_read_instr_mul_long_2addr,
        [DOP_DIV_LONG_2ADDR]        = dalvik_read_instr_div_long_2addr,
        [DOP_REM_LONG_2ADDR]        = dalvik_read_instr_rem_long_2addr,
        [DOP_AND_LONG_2ADDR]        = dalvik_read_instr_and_long_2addr,
        [DOP_OR_LONG_2ADDR]         = dalvik_read_instr_or_long_2addr,
        [DOP_XOR_LONG_2ADDR]        = dalvik_read_instr_xor_long_2addr,
        [DOP_SHL_LONG_2ADDR]        = dalvik_read_instr_shl_long_2addr,
        [DOP_SHR_LONG_2ADDR]        = dalvik_read_instr_shr_long_2addr,
        [DOP_USHR_LONG_2ADDR]       = dalvik_read_instr_ushr_long_2addr,
        [DOP_ADD_FLOAT_2ADDR]       = dalvik_read_instr_add_float_2addr,
        [DOP_SUB_FLOAT_2ADDR]       = dalvik_read_instr_sub_float_2addr,
        [DOP_MUL_FLOAT_2ADDR]       = dalvik_read_instr_mul_float_2addr,
        [DOP_DIV_FLOAT_2ADDR]       = dalvik_read_instr_div_float_2addr,
        [DOP_REM_FLOAT_2ADDR]       = dalvik_read_instr_rem_float_2addr,
        [DOP_ADD_DOUBLE_2ADDR]      = dalvik_read_instr_add_double_2addr,
        [DOP_SUB_DOUBLE_2ADDR]      = dalvik_read_instr_sub_double_2addr,
        [DOP_MUL_DOUBLE_2ADDR]      = dalvik_read_instr_mul_double_2addr,
        [DOP_DIV_DOUBLE_2ADDR]      = dalvik_read_instr_div_double_2addr,
        [DOP_REM_DOUBLE_2ADDR]      = dalvik_read_instr_rem_double_2addr,
        [DOP_ADD_INT_LIT16]         = dalvik_read_instr_add_int_lit16,
        [DOP_RSUB_INT]              = dalvik_read_instr_rsub_int,
        [DOP_MUL_INT_LIT16]         = dalvik_read_instr_mul_int_lit16,
        [DOP_DIV_INT_LIT16]         = dalvik_read_instr_div_int_lit16,
        [DOP_REM_INT_LIT16]         = dalvik_read_instr_rem_int_lit16,
        [DOP_AND_INT_LIT16]         = dalvik_read_instr_and_int_lit16,
        [DOP_OR_INT_LIT16]          = dalvik_read_instr_or_int_lit16,
        [DOP_XOR_INT_LIT16]         = dalvik_read_instr_xor_int_lit16,
        [DOP_ADD_INT_LIT8]          = dalvik_read_instr_add_int_lit8,
        [DOP_RSUB_INT_LIT8]         = dalvik_read_instr_rsub_int_lit8,
        [DOP_MUL_INT_LIT8]          = dalvik_read_instr_mul_int_lit8,
        [DOP_DIV_INT_LIT8]          = dalvik_read_instr_div_int_lit8,
        [DOP_REM_INT_LIT8]          = dalvik_read_instr_rem_int_lit8,
        [DOP_AND_INT_LIT8]          = dalvik_read_instr_and_int_lit8,
        [DOP_OR_INT_LIT8]           = dalvik_read_instr_or_int_lit8,
        [DOP_XOR_INT_LIT8]          = dalvik_read_instr_xor_int_lit8,
        [DOP_SHL_INT_LIT8]          = dalvik_read_instr_shl_int_lit8,
        [DOP_SHR_INT_LIT8]          = dalvik_read_instr_shr_int_lit8,
        [DOP_USHR_INT_LIT8]         = dalvik_read_instr_ushr_int_lit8

    };

    /* Données brutes associées à une instruction ? */

    result = g_dalvik_context_get_raw_data(ctx, content, pos);

    if (result != NULL) goto gdpd_done;

    /* Pseudo-instruction... */

    if (!g_binary_content_read_u8(content, pos, &raw8))
        return NULL;

    result = g_dalvik_processor_disassemble_pseudo(proc, ctx, content, pos, raw8);

    if (result != NULL) goto gdpd_done;

    /* ... ou instruction classique */

    assert(raw8 < DOP_COUNT);

    id = (DalvikOpcodes)raw8;

    if (decodings[id] != NULL)
        result = decodings[id](proc, G_PROC_CONTEXT(ctx), content, pos, format);

 gdpd_done:

    return result;

}


/******************************************************************************
*                                                                             *
*  Paramètres  : proc = architecture visée par la procédure.                  *
*                data = flux de données à analyser.                           *
*                pos  = position courante dans ce flux. [OUT]                 *
*                end  = limite des données à analyser.                        *
*                addr = adresse virtuelle de l'instruction.                   *
*                low8 = 8 bits de poids faible déjà lus.                      *
*                                                                             *
*  Description : Décode une pseudo-instruction dans un flux de données.       *
*                                                                             *
*  Retour      : Instruction mise en place ou NULL si aucune trouvée.         *
*                                                                             *
*  Remarques   : -                                                            *
*                                                                             *
******************************************************************************/

static GArchInstruction *g_dalvik_processor_disassemble_pseudo(const GArchProcessor *proc, GDalvikContext *ctx, const GBinContent *content, vmpa2t *pos, uint8_t low8)
{
    GArchInstruction *result;               /* Instruction à renvoyer      */
    vmpa2t tmp;                             /* Position modifiable         */
    uint8_t high8;                          /* Nouvelle octet à venir lire */
    uint16_t ident;                         /* Valeur lue dans le code     */

    /* Vérification astucieuse et rapide...*/
    if (low8 != 0x00 /* DOP_NOP */)
        return NULL;

    result = NULL;

    copy_vmpa(&tmp, pos);

    if (!g_binary_content_read_u8(content, pos, &high8))
        goto gdpdp_exit;

    ident = high8 << 8 | low8;

    switch (ident)
    {
        case DPO_PACKED_SWITCH:
        case DPO_SPARSE_SWITCH:
            result = g_dalvik_switch_instr_new(ident, ctx, content, pos);
            break;

        case DPO_FILL_ARRAY_DATA:
            result = g_dalvik_fill_instr_new(ident, ctx, content, pos);
            break;

        default:
            result = NULL;
            break;

    }

 gdpdp_exit:

    if (result == NULL)
        copy_vmpa(pos, &tmp);

    return result;

}