summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/Makefile.am5
-rw-r--r--src/core/core.c25
-rw-r--r--src/core/core.h9
-rw-r--r--src/core/global.c46
-rw-r--r--src/core/global.h7
-rw-r--r--src/core/logs.h9
-rw-r--r--src/core/processors.c23
-rw-r--r--src/core/processors.h6
8 files changed, 105 insertions, 25 deletions
diff --git a/src/core/Makefile.am b/src/core/Makefile.am
index e1e3c4e..15ed866 100644
--- a/src/core/Makefile.am
+++ b/src/core/Makefile.am
@@ -20,9 +20,10 @@ libcore4_la_SOURCES = \
logs.h logs.c \
nox.h nox.c \
nproc.h nproc.c \
- paths.h paths.c
+ paths.h paths.c \
+ processors.h processors.c
-libcore4_la_CFLAGS = $(TOOLKIT_CFLAGS)
+libcore4_la_CFLAGS = $(TOOLKIT_CFLAGS) $(LIBSSL_CFLAGS)
devdir = $(includedir)/chrysalide/$(subdir:src/%=core/%)
diff --git a/src/core/core.c b/src/core/core.c
index 9514ee1..c730fad 100644
--- a/src/core/core.c
+++ b/src/core/core.c
@@ -25,6 +25,7 @@
#include "global.h"
+#include "processors.h"
@@ -53,12 +54,22 @@ bool load_core_components(AvailableCoreComponent flags)
if ((flags & ACC_GLOBAL_VARS) != 0 && (__loaded & ACC_GLOBAL_VARS) == 0)
{
+ set_secret_storage(g_secret_storage_new(NULL));
+
set_work_queue(g_work_queue_new());
__loaded |= ACC_GLOBAL_VARS;
}
+ if ((flags & ACC_CODE_ANALYSIS) != 0 && (__loaded & ACC_CODE_ANALYSIS) == 0)
+ {
+ register_arch_gtypes();
+
+ init_operands_factory();
+
+ }
+
return result;
}
@@ -78,10 +89,18 @@ bool load_core_components(AvailableCoreComponent flags)
void unload_core_components(AvailableCoreComponent flags)
{
+ if ((flags & ACC_CODE_ANALYSIS) != 0 && (__loaded & ACC_CODE_ANALYSIS) == 0)
+ {
+ exit_operands_factory();
+
+ }
+
if ((flags & ACC_GLOBAL_VARS) != 0 && (__loaded & ACC_GLOBAL_VARS) == 0)
{
set_work_queue(NULL);
+ set_secret_storage(NULL);
+
__loaded &= ~ACC_GLOBAL_VARS;
}
@@ -107,7 +126,6 @@ void unload_core_components(AvailableCoreComponent flags)
#include "demanglers.h"
#include "global.h"
#include "params.h"
-#include "processors.h"
#include "queue.h"
#include "../analysis/scan/core.h"
#ifdef INCLUDE_MAGIC_SUPPORT
@@ -191,9 +209,6 @@ bool load_all_core_components(bool cs)
if (result) result = init_segment_content_hash_table();
- register_arch_gtypes();
- init_operands_factory();
-
}
}
@@ -219,8 +234,6 @@ void unload_all_core_components(bool cs)
{
if (cs)
{
- exit_operands_factory();
-
exit_segment_content_hash_table();
unload_demanglers_definitions();
diff --git a/src/core/core.h b/src/core/core.h
index 7c50f6c..640476a 100644
--- a/src/core/core.h
+++ b/src/core/core.h
@@ -32,9 +32,12 @@
/* Eléments à (dé)charger disponibles */
typedef enum _AvailableCoreComponent
{
- ACC_NONE = (0 << 0), /* Statut initial */
- ACC_GLOBAL_VARS = (1 << 0), /* Singletons globaux */
- ACC_SCAN_FEATURES = (1 << 0), /* Espace de noms pour scan */
+ ACC_NONE = (0 << 0), /* Statut initial */
+ ACC_GLOBAL_VARS = (1 << 0), /* Singletons globaux */
+ ACC_CODE_ANALYSIS = (1 << 1), /* Désassemblage de code */
+ ACC_SCAN_FEATURES = (1 << 2), /* Espace de noms pour scan */
+
+ ACC_ALL_COMPONENTS = (1 << 3) - 1
} AvailableCoreComponent;
diff --git a/src/core/global.c b/src/core/global.c
index d38656b..0275e09 100644
--- a/src/core/global.c
+++ b/src/core/global.c
@@ -36,6 +36,9 @@ static size_t _bytes_sent = 0;
/* Gestionnaire de tâches parallèles */
static GWorkQueue *_queue = NULL;
+/* Gardien des secrets avec support des stockages */
+static GSecretStorage *_storage = NULL;
+
/******************************************************************************
@@ -131,6 +134,49 @@ GWorkQueue *get_work_queue(void)
}
+/******************************************************************************
+* *
+* Paramètres : queue = nouveau stockage sécurisé à mémoriser ou NULL. *
+* *
+* Description : Définit le stockage sécurisé principal. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void set_secret_storage(/* __steal */GSecretStorage *storage)
+{
+ if (_storage != NULL)
+ unref_object(_storage);
+
+ _storage = storage;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Fournit le stockage sécurisé principal. *
+* *
+* Retour : Gestionnaire de traitements parallèles courant. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GSecretStorage *get_secret_storage(void)
+{
+ ref_object(_storage);
+
+ return _storage;
+
+}
+
+
diff --git a/src/core/global.h b/src/core/global.h
index b861ad8..f5d8a62 100644
--- a/src/core/global.h
+++ b/src/core/global.h
@@ -25,6 +25,7 @@
#define _CORE_GLOBAL_H
+#include "../glibext/secstorage.h"
#include "../glibext/workqueue.h"
@@ -41,6 +42,12 @@ void set_work_queue(/* __steal */GWorkQueue *);
/* Fournit le gestionnaire de traitements parallèles courant. */
GWorkQueue *get_work_queue(void);
+/* Définit le stockage sécurisé principal. */
+void set_secret_storage(/* __steal */GSecretStorage *);
+
+/* Fournit le stockage sécurisé principal. */
+GSecretStorage *get_secret_storage(void);
+
diff --git a/src/core/logs.h b/src/core/logs.h
index e8df8bd..3719c6b 100644
--- a/src/core/logs.h
+++ b/src/core/logs.h
@@ -162,6 +162,15 @@ void log_variadic_message(LogMessageType, const char *, ...);
} \
while (0)
+#define LOG_ERROR_ZIP(func, err) \
+ do \
+ { \
+ const char *__msg; \
+ __msg = zip_error_strerror(err); \
+ log_variadic_message(LMT_EXT_ERROR, "[%s:%u] %s: %s", __FUNCTION__, __LINE__, func, __msg); \
+ } \
+ while (0)
+
#endif /* _CORE_LOGS_H */
diff --git a/src/core/processors.c b/src/core/processors.c
index e4a558f..056fc23 100644
--- a/src/core/processors.c
+++ b/src/core/processors.c
@@ -2,7 +2,7 @@
/* Chrysalide - Outil d'analyse de fichiers binaires
* processors.c - enregistrement et fourniture des architectures supportées
*
- * Copyright (C) 2015-2020 Cyrille Bagard
+ * Copyright (C) 2015-2025 Cyrille Bagard
*
* This file is part of Chrysalide.
*
@@ -29,13 +29,13 @@
#include <pthread.h>
#include <string.h>
-
+#if 0
#include "../arch/instructions/raw.h"
#include "../arch/instructions/undefined.h"
#include "../arch/operands/immediate.h"
#include "../arch/operands/register.h"
#include "../arch/operands/target.h"
-
+#endif
/* Cache des singletons d'opérandes */
@@ -77,12 +77,12 @@ static proc_t *find_processor_by_key(const char *);
void register_arch_gtypes(void)
{
- g_type_ensure(G_TYPE_RAW_INSTRUCTION);
- g_type_ensure(G_TYPE_UNDEF_INSTRUCTION);
+ //g_type_ensure(G_TYPE_RAW_INSTRUCTION);
+ //g_type_ensure(G_TYPE_UNDEF_INSTRUCTION);
- g_type_ensure(G_TYPE_IMM_OPERAND);
- g_type_ensure(G_TYPE_REGISTER_OPERAND);
- g_type_ensure(G_TYPE_TARGET_OPERAND);
+ //g_type_ensure(G_TYPE_IMM_OPERAND);
+ //g_type_ensure(G_TYPE_REGISTER_OPERAND);
+ //g_type_ensure(G_TYPE_TARGET_OPERAND);
}
@@ -126,7 +126,7 @@ GSingletonFactory *get_operands_factory(void)
result = __operands_factory;
- g_object_ref(G_OBJECT(result));
+ ref_object(result);
return result;
@@ -154,7 +154,7 @@ void exit_operands_factory(void)
}
-
+#if 0
/******************************************************************************
* *
* Paramètres : type = type GLib représentant le type à instancier. *
@@ -206,7 +206,7 @@ bool register_processor_type(GType type)
done:
- g_object_unref(G_OBJECT(proc));
+ unref_object(proc);
return result;
@@ -341,3 +341,4 @@ GArchProcessor *get_arch_processor_for_key(const char *key)
return result;
}
+#endif
diff --git a/src/core/processors.h b/src/core/processors.h
index 6aa2d1e..b622305 100644
--- a/src/core/processors.h
+++ b/src/core/processors.h
@@ -29,7 +29,7 @@
#include <stdbool.h>
-#include "../arch/processor.h"
+//#include "../arch/processor.h"
#include "../glibext/singleton.h"
@@ -45,7 +45,7 @@ GSingletonFactory *get_operands_factory(void);
/* Supprime le fournisseur d'instances uniques d'opérandes. */
void exit_operands_factory(void);
-
+#if 0
/* Enregistre un processeur pour une architecture donnée. */
bool register_processor_type(GType);
@@ -57,7 +57,7 @@ char **get_all_processor_keys(size_t *);
/* Fournit le processeur d'architecture correspondant à un nom. */
GArchProcessor *get_arch_processor_for_key(const char *);
-
+#endif
#endif /* _CORE_PROCESSORS_H */