summaryrefslogtreecommitdiff
path: root/src/analysis/scan/context.h
blob: c3b979df924e6d74802b96d713247eb258374494 (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

/* Chrysalide - Outil d'analyse de fichiers binaires
 * context.h - prototypes pour le suivi d'analyses via contextes
 *
 * Copyright (C) 2022 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/>.
 */


#ifndef _ANALYSIS_SCAN_CONTEXT_H
#define _ANALYSIS_SCAN_CONTEXT_H


#include <glib-object.h>


#include "matches.h"
#include "options.h"
#include "matches/area.h"
#include "patterns/patid.h"
#include "../content.h"



/* Depuis expr.h : expression d'évaluation généraliste (instance) */
typedef struct _GScanExpression GScanExpression;


#define G_TYPE_SCAN_CONTEXT            g_scan_context_get_type()
#define G_SCAN_CONTEXT(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_SCAN_CONTEXT, GScanContext))
#define G_IS_SCAN_CONTEXT(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_SCAN_CONTEXT))
#define G_SCAN_CONTEXT_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_SCAN_CONTEXT, GScanContextClass))
#define G_IS_SCAN_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_SCAN_CONTEXT))
#define G_SCAN_CONTEXT_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_SCAN_CONTEXT, GScanContextClass))


/* Contexte de suivi d'une analyse en cours (instance) */
typedef struct _GScanContext GScanContext;

/* Contexte de suivi d'une analyse en cours (classe) */
typedef struct _GScanContextClass GScanContextClass;


/* Indique le type défini pour un contexte de suivi d'analyse. */
GType g_scan_context_get_type(void);

/* Définit un contexte pour suivi d'analyse. */
GScanContext *g_scan_context_new(GScanOptions *);

/* Fournit l'ensemble des options à respecter pour les analyses. */
GScanOptions *g_scan_context_get_options(const GScanContext *);

/* Définit le contenu principal à analyser. */
void g_scan_context_set_content(GScanContext *, GBinContent *, size_t);

/* Fournit une référence au contenu principal analysé. */
GBinContent *g_scan_context_get_content(const GScanContext *);

/* Indique si la phase d'analyse de contenu est terminée. */
bool g_scan_context_is_scan_done(const GScanContext *);

/* Note que la phase d'analyse de contenu est terminée. */
void g_scan_context_mark_scan_as_done(GScanContext *);

/* Retourne tous les correspondances partielles notées. */
void g_scan_context_store_atom_match_end(GScanContext *, patid_t, phys_t);

/* Retourne tous les correspondances partielles notées. */
match_area_t *g_scan_context_get_atom_matches(const GScanContext *, patid_t);

/* Enregistre toutes les correspondances établies pour un motif. */
void g_scan_context_register_full_matches(GScanContext *, GSearchPattern *, GScanMatches *);

/* Fournit la liste de toutes les correspondances pour un motif. */
GScanMatches *g_scan_context_get_full_matches(const GScanContext *, const GSearchPattern *);

/* Dénombre les correspondances associées à un motif. */
size_t g_scan_context_count_full_matches(const GScanContext *, const GSearchPattern *);

/* Intègre une condition de correspondance pour règle. */
bool g_scan_context_set_rule_condition(GScanContext *, const char *, GScanExpression *);

/* Indique si un nom donné correspond à une règle. */
bool g_scan_context_has_rule_for_name(const GScanContext *, const char *);

/* Indique le bilan des règles globales. */
bool g_scan_context_has_global_match(const GScanContext *);

/* Définit le bilan des règles globales. */
void g_scan_context_set_global_match(GScanContext *, bool);

/* Indique si une correspondance globale a pu être établie. */
bool g_scan_context_has_match_for_rule(GScanContext *, const char *);



#endif  /* _ANALYSIS_SCAN_CONTEXT_H */