summaryrefslogtreecommitdiff
path: root/src/decomp/context-int.h
blob: 24cf636cbfebb0684e2ec541b3a702ccc9a0a57f (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

/* Chrysalide - Outil d'analyse de fichiers binaires
 * context.c - mise en place d'un contexte de décompilation
 *
 * Copyright (C) 2012-2013 Cyrille Bagard
 *
 *  This file is part of Chrysalide.
 *
 *  OpenIDA 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.
 *
 *  OpenIDA 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/>.
 */


#ifndef _DECOMP_CONTEXT_INT_H
#define _DECOMP_CONTEXT_INT_H


#include "context.h"


#include "../analysis/routine.h"
#include "../glibext/gnhash.h"



/* Duplique un contexte de compilation. */
typedef GDecContext * (* dup_dec_context_fc) (GDecContext *);

/* Propage un registre alloué et attendu par la suite. */
typedef void (* spread_reg_fc) (GDecContext *, GArchRegister *, GDecInstruction *);

/* Convertit un registre machine en un pseudo-registre. */
typedef GDecInstruction * (* convert_register_fc) (GDecContext *, gpointer, bool, vmpa_t);



/* Définition d'une context décompilée (instance) */
struct _GDecContext
{
    GObject parent;                         /* A laisser en premier        */

    dup_dec_context_fc dup;                 /* Duplication de contexte     */
    spread_reg_fc spread;                   /* Propagation des allocations */
    convert_register_fc convert_reg;        /* Traduction des registres    */

    GExeFormat *format;                     /* Format binaire concerné     */
    GBinRoutine *routine;                   /* Routine visée par l'opérat° */

    GRAccessList *awaited;                  /* Allocations attendues       */
    GHashTable *shared;                     /* Allocations à propager      */

    GDecInstruction *list;                  /* Chaîne décompilée           */

};


/* Définition d'une context décompilée (classe) */
struct _GDecContextClass
{
    GObjectClass parent;                    /* A laisser en premier        */

};


/* Duplique partiellement un contexte de compilation. */
void _g_dec_context_dup(GDecContext *, GDecContext *);

/* Sauvegarde une conversion de registre si elle est attendue. */
void g_dec_context_notify_reg_alloc(GDecContext *, GArchRegister *, GDecInstruction *, vmpa_t);

/* Fournit une conversiond de registre déjà faite et attendue. */
GDecInstruction *g_dec_context_get_awaited_alloc(GDecContext *, GArchRegister *, vmpa_t);



#endif  /* _DECOMP_CONTEXT_INT_H */