From 9e5cf9b3383adcb08ce4a334e19bf02dafe5771a Mon Sep 17 00:00:00 2001
From: Cyrille Bagard <nocbos@gmail.com>
Date: Wed, 15 May 2024 21:27:41 +0200
Subject: Rebuild an empty Python module.

---
 plugins/Makefile.am                   | 53 ++++++++++++++++++-----------------
 plugins/pychrysalide/Makefile.am      | 47 +++++++++++++++++--------------
 plugins/pychrysalide/core.c           | 44 +++++++++++++++++++----------
 plugins/pychrysalide/core/Makefile.am | 17 +++++++----
 plugins/pychrysalide/core/module.c    | 20 ++++++-------
 plugins/pychrysalide/helpers.c        |  4 +++
 plugins/pychrysalide/helpers.h        |  4 +++
 plugins/pychrysalide/plugins/plugin.c | 18 ++++++++++--
 src/common/Makefile.am                |  2 ++
 9 files changed, 129 insertions(+), 80 deletions(-)

diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 1cda6e0..9e177fa 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -13,29 +13,30 @@ endif
 
 # androhelpers
 SUBDIRS = \
-	$(PYTHON3_SUBDIRS) \
-	arm \
-	bootimg \
-	devdbg \
-	dex \
-	dexbnf \
-	dwarf \
-	elf \
-	fmtp \
-	itanium \
-	javadesc \
-	kaitai \
-	mobicore \
-	pe \
-	yaml \
-	apihashing \
-	bhash \
-	dalvik \
-	encodings \
-	libcsem \
-	lnxsyscalls \
-	readdex \
-	readelf \
-	readmc \
-	$(ROPGADGETS_SUBDIRS) \
-	winordinals
+	$(PYTHON3_SUBDIRS)
+
+# arm \
+# bootimg \
+# devdbg \
+# dex \
+# dexbnf \
+# dwarf \
+# elf \
+# fmtp \
+# itanium \
+# javadesc \
+# kaitai \
+# mobicore \
+# pe \
+# yaml \
+# apihashing \
+# bhash \
+# dalvik \
+# encodings \
+# libcsem \
+# lnxsyscalls \
+# readdex \
+# readelf \
+# readmc \
+# $(ROPGADGETS_SUBDIRS) \
+# winordinals
diff --git a/plugins/pychrysalide/Makefile.am b/plugins/pychrysalide/Makefile.am
index 4b6e551..1818613 100644
--- a/plugins/pychrysalide/Makefile.am
+++ b/plugins/pychrysalide/Makefile.am
@@ -13,21 +13,21 @@ RUN_PATH = -Wl,-rpath,'$$ORIGIN/chrysalide-libs'
 endif
 
 
-if BUILD_GTK_SUPPORT
+# if BUILD_GTK_SUPPORT
 
-GTKEXT_LIBADD =								\
-	gtkext/libpychrysagtkext.la
+# GTKEXT_LIBADD =								\
+# 	gtkext/libpychrysagtkext.la
 
-GTKEXT_SUBDIR = 							\
-	gtkext
+# GTKEXT_SUBDIR = 							\
+# 	gtkext
 
-GUI_LIBADD =								\
-	gui/libpychrysagui.la
+# GUI_LIBADD =								\
+# 	gui/libpychrysagui.la
 
-GUI_SUBDIR =								\
-	gui
+# GUI_SUBDIR =								\
+# 	gui
 
-endif
+# endif
 
 
 pychrysalide_la_SOURCES =					\
@@ -41,17 +41,21 @@ pychrysalide_la_SOURCES =					\
 AM_CFLAGS = $(LIBPYTHON_INTERPRETER_CFLAGS) $(LIBPYGOBJECT_CFLAGS) $(TOOLKIT_CFLAGS) $(LIBXML_CFLAGS) \
 	-I$(top_srcdir)/src -DNO_IMPORT_PYGOBJECT
 
+# pychrysalide_la_LIBADD =					\
+# 	analysis/libpychrysaanalysis.la			\
+# 	arch/libpychrysaarch.la					\
+# 	common/libpychrysacommon.la				\
+# 	core/libpychrysacore.la					\
+# 	debug/libpychrysadebug.la				\
+# 	format/libpychrysaformat.la				\
+# 	glibext/libpychrysaglibext.la			\
+# 	$(GTKEXT_LIBADD)						\
+# 	$(GUI_LIBADD)							\
+# 	mangling/libpychrysamangling.la			\
+# 	plugins/libpychrysaplugins.la
+
 pychrysalide_la_LIBADD =					\
-	analysis/libpychrysaanalysis.la			\
-	arch/libpychrysaarch.la					\
-	common/libpychrysacommon.la				\
 	core/libpychrysacore.la					\
-	debug/libpychrysadebug.la				\
-	format/libpychrysaformat.la				\
-	glibext/libpychrysaglibext.la			\
-	$(GTKEXT_LIBADD)						\
-	$(GUI_LIBADD)							\
-	mangling/libpychrysamangling.la			\
 	plugins/libpychrysaplugins.la
 
 # -ldl: dladdr(), dlerror()
@@ -59,7 +63,7 @@ pychrysalide_la_LDFLAGS =					\
 	-module -avoid-version -ldl				\
 	$(LIBPYTHON_INTERPRETER_LIBS)			\
 	$(LIBPYGOBJECT_LIBS)					\
-	-L$(top_srcdir)/src/.libs -lchrysacore	\
+	-L$(top_srcdir)/src/.libs -lchrysacore4	\
 	$(RUN_PATH)
 
 
@@ -68,4 +72,5 @@ devdir = $(includedir)/chrysalide/$(subdir)
 dev_HEADERS = $(pychrysalide_la_SOURCES:%c=)
 
 
-SUBDIRS = analysis arch common core debug format glibext $(GTKEXT_SUBDIR) $(GUI_SUBDIR) mangling plugins
+#SUBDIRS = analysis arch common core debug format glibext $(GTKEXT_SUBDIR) $(GUI_SUBDIR) mangling plugins
+SUBDIRS = core plugins
diff --git a/plugins/pychrysalide/core.c b/plugins/pychrysalide/core.c
index 08f570f..1157e73 100644
--- a/plugins/pychrysalide/core.c
+++ b/plugins/pychrysalide/core.c
@@ -57,18 +57,18 @@
 #include "star.h"
 #include "strenum.h"
 #include "struct.h"
-#include "analysis/module.h"
-#include "arch/module.h"
-#include "common/module.h"
-#include "core/module.h"
-#include "debug/module.h"
-#include "format/module.h"
-#include "glibext/module.h"
-#ifdef INCLUDE_GTK_SUPPORT
-#   include "gtkext/module.h"
-#   include "gui/module.h"
-#endif
-#include "mangling/module.h"
+/* #include "analysis/module.h" */
+/* #include "arch/module.h" */
+/* #include "common/module.h" */
+/* #include "core/module.h" */
+/* #include "debug/module.h" */
+/* #include "format/module.h" */
+/* #include "glibext/module.h" */
+/* #ifdef INCLUDE_GTK_SUPPORT */
+/* #   include "gtkext/module.h" */
+/* #   include "gui/module.h" */
+/* #endif */
+/* #include "mangling/module.h" */
 #include "plugins/module.h"
 #include "plugins/plugin.h"
 
@@ -482,9 +482,11 @@ static void PyExit_pychrysalide(void)
 {
     assert(_standalone);
 
+    /*
     extern void set_current_project(void *project);
 
     set_current_project(NULL);
+    */
 
 #ifdef TRACK_GOBJECT_LEAKS
     remember_gtypes_for_leaks();
@@ -492,7 +494,7 @@ static void PyExit_pychrysalide(void)
 
     exit_all_plugins();
 
-    unload_all_core_components(true);
+    //unload_all_core_components(true);
 
 #ifdef TRACK_GOBJECT_LEAKS
     dump_remaining_gtypes();
@@ -589,16 +591,20 @@ PyMODINIT_FUNC PyInit_pychrysalide(void)
     if (!install_metaclass_for_python_gobjects())
         goto exit;
 
+#if 0
 #ifdef INCLUDE_GTK_SUPPORT
     if (!set_version_for_gtk_namespace("3.0"))
         goto exit;
 #endif
+#endif
 
+    /*
     if (!load_all_core_components(true))
     {
         PyErr_SetString(PyExc_SystemError, "unable to load all basic components.");
         goto exit;
     }
+    */
 
     /* Mise en place des fonctionnalités offertes */
 
@@ -610,6 +616,7 @@ PyMODINIT_FUNC PyInit_pychrysalide(void)
 
     if (status) status = add_features_module(result);
 
+    /*
     if (status) status = add_analysis_module(result);
     if (status) status = add_arch_module(result);
     if (status) status = add_common_module(result);
@@ -622,8 +629,10 @@ PyMODINIT_FUNC PyInit_pychrysalide(void)
     if (status) status = add_gui_module(result);
 #endif
     if (status) status = add_mangling_module(result);
+    */
     if (status) status = add_plugins_module(result);
 
+    /*
     if (status) status = ensure_python_string_enum_is_registered();
     if (status) status = ensure_python_py_struct_is_registered();
 
@@ -639,6 +648,7 @@ PyMODINIT_FUNC PyInit_pychrysalide(void)
     if (status) status = populate_gui_module();
 #endif
     if (status) status = populate_mangling_module();
+    */
     if (status) status = populate_plugins_module();
 
     if (!status)
@@ -668,9 +678,11 @@ PyMODINIT_FUNC PyInit_pychrysalide(void)
          *
          * On la déclare donc à la main.
          */
+        /*
         extern void set_batch_mode(void);
 
         set_batch_mode();
+        */
 
         /**
          * Si cette extension pour Python est chargée depuis un dépôt Python,
@@ -791,7 +803,7 @@ static void load_python_plugins(GPluginModule *plugin)
     char *filename;                         /* Chemin d'accès reconstruit  */
     GPluginModule *pyplugin;                /* Lien vers un grffon Python  */
     bool status;                            /* Bilan d'une opération       */
-    GGenConfig *config;                     /* Configuration à charger     */
+    //GGenConfig *config;                     /* Configuration à charger     */
 
     /* Définition des zones d'influence */
 
@@ -878,7 +890,7 @@ static void load_python_plugins(GPluginModule *plugin)
                 goto done_with_plugin;
             }
 
-            g_plugin_module_create_config(pyplugin);
+            //g_plugin_module_create_config(pyplugin);
 
             status = g_plugin_module_manage(pyplugin, PGA_PLUGIN_LOADED);
 
@@ -890,9 +902,11 @@ static void load_python_plugins(GPluginModule *plugin)
                 goto done_with_plugin;
             }
 
+            /*
             config = g_plugin_module_get_config(pyplugin);
             g_generic_config_read(config);
             g_object_unref(G_OBJECT(config));
+            */
 
             g_plugin_module_log_variadic_message(plugin, LMT_PROCESS,
                                                  _("Loaded the Python plugin found in the '<b>%s</b>' directory"),
diff --git a/plugins/pychrysalide/core/Makefile.am b/plugins/pychrysalide/core/Makefile.am
index 880823d..a50324a 100644
--- a/plugins/pychrysalide/core/Makefile.am
+++ b/plugins/pychrysalide/core/Makefile.am
@@ -1,15 +1,20 @@
 
 noinst_LTLIBRARIES = libpychrysacore.la
 
+# libpychrysacore_la_SOURCES =				\
+# 	constants.h constants.c					\
+# 	demanglers.h demanglers.c				\
+# 	global.h global.c						\
+# 	logs.h logs.c							\
+# 	module.h module.c						\
+# 	params.h params.c						\
+# 	processors.h processors.c				\
+# 	queue.h queue.c
+
 libpychrysacore_la_SOURCES =				\
 	constants.h constants.c					\
-	demanglers.h demanglers.c				\
-	global.h global.c						\
 	logs.h logs.c							\
-	module.h module.c						\
-	params.h params.c						\
-	processors.h processors.c				\
-	queue.h queue.c
+	module.h module.c
 
 libpychrysacore_la_CFLAGS = $(TOOLKIT_CFLAGS) $(LIBXML_CFLAGS) $(LIBPYTHON_INTERPRETER_CFLAGS) $(LIBPYGOBJECT_CFLAGS) \
 	-I$(top_srcdir)/src -DNO_IMPORT_PYGOBJECT
diff --git a/plugins/pychrysalide/core/module.c b/plugins/pychrysalide/core/module.c
index 846e961..b588057 100644
--- a/plugins/pychrysalide/core/module.c
+++ b/plugins/pychrysalide/core/module.c
@@ -28,12 +28,12 @@
 #include <assert.h>
 
 
-#include "demanglers.h"
-#include "global.h"
+//#include "demanglers.h"
+//#include "global.h"
 #include "logs.h"
-#include "params.h"
-#include "processors.h"
-#include "queue.h"
+//#include "params.h"
+//#include "processors.h"
+//#include "queue.h"
 #include "../helpers.h"
 
 
@@ -102,12 +102,12 @@ bool populate_core_module(void)
 
     result = true;
 
-    if (result) result = populate_core_module_with_demanglers();
-    if (result) result = populate_core_module_with_global();
+    //if (result) result = populate_core_module_with_demanglers();
+    //if (result) result = populate_core_module_with_global();
     if (result) result = populate_core_module_with_logs();
-    if (result) result = populate_core_module_with_params();
-    if (result) result = populate_core_module_with_processors();
-    if (result) result = populate_core_module_with_queue();
+    //if (result) result = populate_core_module_with_params();
+    //if (result) result = populate_core_module_with_processors();
+    //if (result) result = populate_core_module_with_queue();
 
     assert(result);
 
diff --git a/plugins/pychrysalide/helpers.c b/plugins/pychrysalide/helpers.c
index c2b1868..179f03b 100644
--- a/plugins/pychrysalide/helpers.c
+++ b/plugins/pychrysalide/helpers.c
@@ -1247,6 +1247,8 @@ int convert_to_gobject(PyObject *arg, void *dst)
 }
 
 
+#if 0
+
 #ifdef INCLUDE_GTK_SUPPORT
 
 
@@ -1486,6 +1488,8 @@ int convert_to_gdk_rgba(PyObject *arg, void *dst)
 
 }
 
+#endif
+
 
 
 /* ---------------------------------------------------------------------------------- */
diff --git a/plugins/pychrysalide/helpers.h b/plugins/pychrysalide/helpers.h
index 57cf96d..cc82bba 100644
--- a/plugins/pychrysalide/helpers.h
+++ b/plugins/pychrysalide/helpers.h
@@ -242,6 +242,8 @@ int convert_to_gtype(PyObject *, void *);
 /* Tente de convertir en instance GObject. */
 int convert_to_gobject(PyObject *, void *);
 
+#if 0
+
 #ifdef INCLUDE_GTK_SUPPORT
 
 /* Tente de convertir en instance de composant GTK. */
@@ -279,6 +281,8 @@ PyObject *create_gdk_rgba(const GdkRGBA *);
 int convert_to_gdk_rgba(PyObject *, void *);
 
 
+#endif
+
 
 /* ----------------------- TRANSFERT DES VALEURS CONSTANTES ------------------------- */
 
diff --git a/plugins/pychrysalide/plugins/plugin.c b/plugins/pychrysalide/plugins/plugin.c
index b013345..de070cb 100644
--- a/plugins/pychrysalide/plugins/plugin.c
+++ b/plugins/pychrysalide/plugins/plugin.c
@@ -74,6 +74,8 @@ static PyObject *py_plugin_module_get_modname_by_default(PyObject *, PyObject *)
 /* Fournit le nom brut associé au greffon. */
 static char *py_plugin_module_get_modname_wrapper(const GPluginModule *);
 
+#if 0
+
 #ifdef INCLUDE_GTK_SUPPORT
 
 /* Complète une liste de resources pour thème. */
@@ -108,6 +110,8 @@ static void py_plugin_module_process_disassembly_event_wrapper(const GPluginModu
 /* Effectue la détection d'effets d'outils externes. */
 static void py_plugin_module_detect_external_tools_wrapper(const GPluginModule *, PluginAction, const GLoadedContent *, bool, char ***, size_t *);
 
+#endif
+
 
 
 /* ------------------------- MODULE PYTHON POUR LES SCRIPTS ------------------------- */
@@ -158,6 +162,8 @@ static void py_plugin_module_init_gclass(GPluginModuleClass *class, gpointer unu
 
     class->get_modname = py_plugin_module_get_modname_wrapper;
 
+#if 0
+
 #ifdef INCLUDE_GTK_SUPPORT
     class->include_theme = py_plugin_module_include_theme_wrapper;
     class->notify_panel = py_plugin_module_notify_panel_creation_wrapper;
@@ -175,6 +181,8 @@ static void py_plugin_module_init_gclass(GPluginModuleClass *class, gpointer unu
 
     class->detect = py_plugin_module_detect_external_tools_wrapper;
 
+#endif
+
 }
 
 
@@ -609,6 +617,8 @@ static char *py_plugin_module_get_modname_wrapper(const GPluginModule *plugin)
 }
 
 
+#if 0
+
 #ifdef INCLUDE_GTK_SUPPORT
 
 
@@ -1359,6 +1369,7 @@ static void py_plugin_module_detect_external_tools_wrapper(const GPluginModule *
 
 }
 
+#endif
 
 
 /* ---------------------------------------------------------------------------------- */
@@ -1598,7 +1609,7 @@ static PyObject *py_plugin_module_get_interface(PyObject *self, void *closure)
 
 }
 
-
+#if 0
 /******************************************************************************
 *                                                                             *
 *  Paramètres  : self    = objet Python concerné par l'appel.                 *
@@ -1652,6 +1663,7 @@ static PyObject *py_plugin_module_get_config(PyObject *self, void *closure)
     return result;
 
 }
+#endif
 
 
 /******************************************************************************
@@ -1672,6 +1684,7 @@ PyTypeObject *get_python_plugin_module_type(void)
         PLUGIN_MODULE_MANAGE_WRAPPER,
         PLUGIN_MODULE_NOTIFY_PLUGINS_LOADED_WRAPPER,
         PLUGIN_MODULE_GET_MODNAME_WRAPPER,
+#if 0
 #ifdef INCLUDE_GTK_SUPPORT
         PLUGIN_MODULE_INCLUDE_THEME_WRAPPER,
         PLUGIN_MODULE_ON_PANEL_CREATION_WRAPPER,
@@ -1685,6 +1698,7 @@ PyTypeObject *get_python_plugin_module_type(void)
         PLUGIN_MODULE_PROCESS_DISASSEMBLY_EVENT_WRAPPER,
         PLUGIN_MODULE_DETECT_EXTERNAL_TOOLS_WRAPPER,
         PLUGIN_MODULE_BUILD_CONFIG_FILENAME_METHOD,
+#endif
         PLUGIN_MODULE_LOG_MESSAGE_METHOD,
         { NULL }
     };
@@ -1693,7 +1707,7 @@ PyTypeObject *get_python_plugin_module_type(void)
         PLUGIN_MODULE_MODNAME_ATTRIB,
         PLUGIN_MODULE_FILENAME_ATTRIB,
         PLUGIN_MODULE_INTERFACE_ATTRIB,
-        PLUGIN_MODULE_CONFIG_ATTRIB,
+        //PLUGIN_MODULE_CONFIG_ATTRIB,
         { NULL }
     };
 
diff --git a/src/common/Makefile.am b/src/common/Makefile.am
index af18ab8..8366376 100644
--- a/src/common/Makefile.am
+++ b/src/common/Makefile.am
@@ -56,8 +56,10 @@ libcommon4_la_SOURCES =						\
 	asm.h asm.c								\
 	bits.h bits.c							\
 	compiler.h								\
+	environment.h environment.c				\
 	extstr.h extstr.c						\
 	pathname.h pathname.c					\
+	sort.h sort.c							\
 	xdg.h xdg.c
 
 libcommon4_la_CFLAGS = $(TOOLKIT_CFLAGS) $(LIBXML_CFLAGS)
-- 
cgit v0.11.2-87-g4458