From 9ebad4be5d45aad946372695cb9aa76c216403ff Mon Sep 17 00:00:00 2001 From: Maschell Date: Sat, 10 Feb 2018 17:05:32 +0100 Subject: [PATCH] [example_plugin] Changed to example_plugin to hook into FS_INIT - Using the init hook --- example_plugin/Makefile | 2 +- example_plugin/src/main.c | 15 +++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/example_plugin/Makefile b/example_plugin/Makefile index 8ff7784..a314baa 100644 --- a/example_plugin/Makefile +++ b/example_plugin/Makefile @@ -67,7 +67,7 @@ OBJDUMP := $(PREFIX)objdump # --gc-sections: remove unneeded symbols # -T: use the linker script specified (to force certain wups sections together) # -Map: generate a map file -LDFLAGS += --relocatable -s --gc-sections -u wups_load -u wups_meta \ +LDFLAGS += --relocatable -s --gc-sections -u wups_load -u wups_meta -u wups_hooks \ -T $(WUPSDIR)/wups.ld \ $(patsubst %,-Map %,$(strip $(MAP))) -wrap malloc -wrap free -wrap memalign -wrap calloc -wrap realloc -wrap malloc_usable_size -wrap _malloc_r -wrap _free_r -wrap _realloc_r -wrap _calloc_r -wrap _memalign_r -wrap _malloc_usable_size_r LD1FLAGS += --relocatable -s \ diff --git a/example_plugin/src/main.c b/example_plugin/src/main.c index 5cba545..6b1f591 100644 --- a/example_plugin/src/main.c +++ b/example_plugin/src/main.c @@ -5,24 +5,23 @@ #include "dynamic_libs/socket_functions.h" #include "utils/logger.h" - WUPS_MODULE_NAME("test module"); WUPS_MODULE_VERSION("v1.0"); WUPS_MODULE_AUTHOR("Maschell"); WUPS_MODULE_LICENSE("BSD"); -DECL_FUNCTION(void,OSFatal,char * msg){ +INITIALIZE(){ InitOSFunctionPointers(); InitSocketFunctionPointers(); log_init(); - //log_printf is not working. - log_print(msg); - log_print("\n^--- Someone called OSFatal with this string. Lets modify it. Bye bye =(\n"); - real_OSFatal("Does the replacement work?"); - return; + log_print("Init of example_plugin!\n"); +} +DECL_FUNCTION(int,FSInit,void){ + log_print("FSInit called\n"); + return real_FSInit(); } -WUPS_MUST_REPLACE(OSFatal,WUPS_LOADER_LIBRARY_COREINIT, OSFatal); +WUPS_MUST_REPLACE(FSInit,WUPS_LOADER_LIBRARY_COREINIT, FSInit);