diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2009-09-30 00:00:43 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2009-09-30 00:00:43 (GMT) |
commit | 3c6968d4d5a8918c456cdea28a7c6195368d996e (patch) | |
tree | e6909254a8033cdabd116f287db2893e938a636d /src/analysis/variable.c | |
parent | 1beaa1af679d49d99696ec907662b764f7ba1867 (diff) |
Parsed and replaced ModRM operands.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@121 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/analysis/variable.c')
-rw-r--r-- | src/analysis/variable.c | 201 |
1 files changed, 200 insertions, 1 deletions
diff --git a/src/analysis/variable.c b/src/analysis/variable.c index 058c152..01c780e 100644 --- a/src/analysis/variable.c +++ b/src/analysis/variable.c @@ -25,7 +25,7 @@ #include <malloc.h> -#include <stdbool.h> +#include <stdint.h> #include <string.h> @@ -33,6 +33,205 @@ + +/* -------------------- BASE DE VARIABLES OU VARIABLES INCONNUES -------------------- */ + + +/* Base de variable (instance) */ +struct _GUnknownVariable +{ + GObject parent; /* A laisser en premier */ + + size_t offset; /* Position abstraite associée */ + size_t size; /* Taille en mémoire */ + +}; + +/* Base de variable (classe) */ +struct _GUnknownVariableClass +{ + GObjectClass parent; /* A laisser en premier */ + +}; + + +/* Initialise la classe des bases de variables. */ +static void g_unknown_variable_class_init(GUnknownVariableClass *); + +/* Initialise l'instande d'une base de variable. */ +static void g_unknown_variable_init(GUnknownVariable *); + + + +/* ---------------------------------------------------------------------------------- */ +/* BASE DE VARIABLES OU VARIABLES INCONNUES */ +/* ---------------------------------------------------------------------------------- */ + + +/* Indique le type défini pour une base de variable. */ +G_DEFINE_TYPE(GUnknownVariable, g_unknown_variable, G_TYPE_OBJECT); + + +/****************************************************************************** +* * +* Paramètres : klass = classe à initialiser. * +* * +* Description : Initialise la classe des bases de variables. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_unknown_variable_class_init(GUnknownVariableClass *klass) +{ + +} + + +/****************************************************************************** +* * +* Paramètres : var = instance à initialiser. * +* * +* Description : Initialise l'instande d'une base de variable. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_unknown_variable_init(GUnknownVariable *var) +{ + var->offset = SIZE_MAX; + var->size = SIZE_MAX; + +} + + +/****************************************************************************** +* * +* Paramètres : - * +* * +* Description : Crée une représentation de variable de type inconnu. * +* * +* Retour : Variable mise en place. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GUnknownVariable *g_unknown_variable_new(void) +{ + GUnknownVariable *result; /* Variable à retourner */ + + result = g_object_new(G_TYPE_UNKNOWN_VARIABLE, NULL); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : a = premières informations à consulter. * +* b = secondes informations à consulter. * +* * +* Description : Etablit la comparaison ascendante entre deux variables. * +* * +* Retour : Bilan : -1 (a < b), 0 (a == b) ou 1 (a > b). * +* * +* Remarques : - * +* * +******************************************************************************/ + +int g_unknown_variable_compare(const GUnknownVariable **a, const GUnknownVariable **b) +{ + int result; /* Bilan à renvoyer */ + + if ((*a)->offset < (*b)->offset) result = -1; + else if((*a)->offset > (*b)->offset) result = 1; + else result = 0; + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : var = variable à manipuler. * +* offset = position (abstraite ou non) à enregistrer. * +* * +* Description : Définit la position associée à une variable. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void g_unknown_variable_set_offset(GUnknownVariable *var, size_t offset) +{ + var->offset = offset; + +} + + +/****************************************************************************** +* * +* Paramètres : var = variable à manipuler. * +* * +* Description : Fournit la position associée à une variable. * +* * +* Retour : Position de la variable. * +* * +* Remarques : - * +* * +******************************************************************************/ + +size_t g_unknown_variable_get_offset(const GUnknownVariable *var) +{ + return var->offset; + +} + + +/****************************************************************************** +* * +* Paramètres : var = variable à manipuler. * +* offset = position (abstraite ou non) à traiter. * +* * +* Description : Indique si une position est contenue dans une variable. * +* * +* Retour : Bilan de la consultation. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool g_unknown_variable_contains_offset(const GUnknownVariable *var, size_t offset) +{ + bool result; /* Bilan à retourner */ + + if (var->offset == SIZE_MAX) + return false; + + if (var->size == SIZE_MAX) + result = (var->offset == offset); + + else result = (var->offset <= offset && offset < (var->offset + var->size)); + + return result; + +} + + + + + + /* ---------------------------- TYPES DE DONNEES SIMPLES ---------------------------- */ |