Update hooks and add a new way for patching functions

This commit is contained in:
Maschell 2019-11-17 17:43:09 +01:00
parent e9ea643f19
commit d2e557412f
6 changed files with 368 additions and 169 deletions

View File

@ -51,6 +51,8 @@ include $(WUPSDIR)/plugin_makefile.mk
# options for code generation
#---------------------------------------------------------------------------------
MACHDEP = -DESPRESSO -mcpu=750 -meabi -mhard-float
# -Os: optimise size
# -Wall: generate lots of warnings
# -D__wiiu__: define the symbol __wiiu__ (used in some headers)
@ -60,27 +62,24 @@ include $(WUPSDIR)/plugin_makefile.mk
# -nostartfiles: Do not use the standard system startup files when linking
# -ffunction-sections: split up functions so linker can garbage collect
# -fdata-sections: split up data so linker can garbage collect
COMMON_CFLAGS := -Os -Wall -mcpu=750 -meabi -mhard-float -D__WIIU__ -nostartfiles -ffunction-sections -fdata-sections -Wl,-q $(COMMON_CFLAGS)
COMMON_CFLAGS := -O0 -Wall $(MACHDEP) -meabi -ffunction-sections -fdata-sections -Wl,-q $(COMMON_CFLAGS)
CFLAGS += -D__WIIU__ -D__WUT__
# -x c: compile as c code
# -std=c11: use the c11 standard
CFLAGS := $(COMMON_CFLAGS) -x c -std=gnu11 $(CFLAGS)
# -x c: compile as c++ code
# -x c++: compile as c++ code
# -std=gnu++11: use the c++11 standard
CXXFLAGS := $(COMMON_CFLAGS) -x c++ -std=gnu++11 $(CXXFLAGS)
ifeq ($(DO_LOGGING), 1)
CFLAGS += -D__LOGGING__
CXXFLAGS += -D__LOGGING__
endif
#---------------------------------------------------------------------------------
# any extra ld flags
#--------------------------------------------------------------------------------
# --gc-sections: remove unneeded symbols
# -Map: generate a map file
LDFLAGS += -Wl,-Map,$(notdir $@).map,--gc-sections
LDFLAGS += $(ARCH) -Wl,-Map,$(notdir $@).map,--gc-sections,-wrap,__gxx_personality_v0
#---------------------------------------------------------------------------------
@ -97,33 +96,6 @@ LIBS +=
#---------------------------------------------------------------------------------
LIBDIRS +=
NEEDS_WUT := 0
ifeq ($(WUT_ENABLE_CPP), 1)
WUT_ENABLE_NEWLIB := 1
LDFLAGS += -Wl,-whole-archive,-lwutstdc++,-no-whole-archive
NEEDS_WUT := 1
endif
ifeq ($(WUT_ENABLE_NEWLIB), 1)
LDFLAGS += -Wl,-whole-archive,-lwutnewlib,-no-whole-archive
NEEDS_WUT := 1
endif
ifeq ($(WUT_DEFAULT_MALLOC), 1)
LDFLAGS += -Wl,-whole-archive,-lwutmalloc,-no-whole-archive
NEEDS_WUT := 1
endif
ifeq ($(NEEDS_WUT), 1)
ifeq ($(strip $(WUT_ROOT)),)
$(error "Please set WUT_ROOT in your environment. export WUT_ROOT=<path to>wut)
endif
CFLAGS += -D__WUT__
CXXFLAGS += -D__WUT__
endif
#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions

View File

@ -1,20 +1,3 @@
# Compiling the projects with libutils logging code?
DO_LOGGING := 1
# Links against the wut implementation of newlib, this is useful for using any function
# from the C standard library
WUT_ENABLE_NEWLIB := 0
# Links against the wut implementation of stdcpp, this is useful for using any function
# from the C++ standard library. This will enable WUT_ENABLE_NEWLIB if you have not already done so.
WUT_ENABLE_CPP := 0
# By default newlib will allocate 90% of the default heap for use with sbrk & malloc,
# if this is unacceptable to you then you should use this as it replaces the newlib
# malloc functions which ones which redirect to the CafeOS default heap functions
# such as MEMAllocFromDefaultHeap.
WUT_DEFAULT_MALLOC := 1
# Target filename
TARGET := $(notdir $(CURDIR)).mod
@ -43,12 +26,12 @@ LDFLAGS :=
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS := $(WUPSDIR) $(WUT_ROOT)
LIBDIRS := $(WUPSDIR) $(WUT_ROOT) $(PORTLIBS)
#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project
#---------------------------------------------------------------------------------
LIBS := -lwups -lutilswut -lcoreinit -lnsysnet
LIBS := -lwups -lwut
#---------------------------------------------------------------------------------
# Will be added to the final lib paths
@ -61,4 +44,4 @@ EXTERNAL_LIBPATHS :=
# Will be added to the final include paths
# -IC:/library1/include
#---------------------------------------------------------------------------------
EXTERNAL_INCLUDE := -I$(WUT_ROOT)/include/libutilswut
EXTERNAL_INCLUDE :=

378
wups.ld
View File

@ -27,80 +27,299 @@ SECTIONS {
*(.gcc_except_table*)
}
.fimport_avm ALIGN(16) : { *(.fimport_avm) }
.fimport_camera ALIGN(16) : { *(.fimport_camera) }
.fimport_coreinit ALIGN(16) : { *(.fimport_coreinit) }
.fimport_dc ALIGN(16) : { *(.fimport_dc) }
.fimport_dmae ALIGN(16) : { *(.fimport_dmae) }
.fimport_drmapp ALIGN(16) : { *(.fimport_drmapp) }
.fimport_erreula ALIGN(16) : { *(.fimport_erreula) }
.fimport_gx2 ALIGN(16) : { *(.fimport_gx2) }
.fimport_h264 ALIGN(16) : { *(.fimport_h264) }
.fimport_lzma920 ALIGN(16) : { *(.fimport_lzma920) }
.fimport_mic ALIGN(16) : { *(.fimport_mic) }
.fimport_nfc ALIGN(16) : { *(.fimport_nfc) }
.fimport_nio_prof ALIGN(16) : { *(.fimport_nio_prof) }
.fimport_nlibcurl ALIGN(16) : { *(.fimport_nlibcurl) }
.fimport_nlibnss2 ALIGN(16) : { *(.fimport_nlibnss2) }
.fimport_nlibnss ALIGN(16) : { *(.fimport_nlibnss) }
.fimport_nn_ac ALIGN(16) : { *(.fimport_nn_ac) }
.fimport_nn_acp ALIGN(16) : { *(.fimport_nn_acp) }
.fimport_nn_act ALIGN(16) : { *(.fimport_nn_act) }
.fimport_nn_aoc ALIGN(16) : { *(.fimport_nn_aoc) }
.fimport_nn_boss ALIGN(16) : { *(.fimport_nn_boss) }
.fimport_nn_ccr ALIGN(16) : { *(.fimport_nn_ccr) }
.fimport_nn_cmpt ALIGN(16) : { *(.fimport_nn_cmpt) }
.fimport_nn_dlp ALIGN(16) : { *(.fimport_nn_dlp) }
.fimport_nn_ec ALIGN(16) : { *(.fimport_nn_ec) }
.fimport_nn_fp ALIGN(16) : { *(.fimport_nn_fp) }
.fimport_nn_hai ALIGN(16) : { *(.fimport_nn_hai) }
.fimport_nn_hpad ALIGN(16) : { *(.fimport_nn_hpad) }
.fimport_nn_idbe ALIGN(16) : { *(.fimport_nn_idbe) }
.fimport_nn_ndm ALIGN(16) : { *(.fimport_nn_ndm) }
.fimport_nn_nets2 ALIGN(16) : { *(.fimport_nn_nets2) }
.fimport_nn_nfp ALIGN(16) : { *(.fimport_nn_nfp) }
.fimport_nn_nim ALIGN(16) : { *(.fimport_nn_nim) }
.fimport_nn_olv ALIGN(16) : { *(.fimport_nn_olv) }
.fimport_nn_pdm ALIGN(16) : { *(.fimport_nn_pdm) }
.fimport_nn_save ALIGN(16) : { *(.fimport_nn_save) }
.fimport_nn_sl ALIGN(16) : { *(.fimport_nn_sl) }
.fimport_nn_spm ALIGN(16) : { *(.fimport_nn_spm) }
.fimport_nn_temp ALIGN(16) : { *(.fimport_nn_temp) }
.fimport_nn_uds ALIGN(16) : { *(.fimport_nn_uds) }
.fimport_nn_vctl ALIGN(16) : { *(.fimport_nn_vctl) }
.fimport_nsysccr ALIGN(16) : { *(.fimport_nsysccr) }
.fimport_nsyshid ALIGN(16) : { *(.fimport_nsyshid) }
.fimport_nsyskbd ALIGN(16) : { *(.fimport_nsyskbd) }
.fimport_nsysnet ALIGN(16) : { *(.fimport_nsysnet) }
.fimport_nsysuhs ALIGN(16) : { *(.fimport_nsysuhs) }
.fimport_nsysuvd ALIGN(16) : { *(.fimport_nsysuvd) }
.fimport_ntag ALIGN(16) : { *(.fimport_ntag) }
.fimport_padscore ALIGN(16) : { *(.fimport_padscore) }
.fimport_proc_ui ALIGN(16) : { *(.fimport_proc_ui) }
.fimport_sndcore2 ALIGN(16) : { *(.fimport_sndcore2) }
.fimport_snd_core ALIGN(16) : { *(.fimport_snd_core) }
.fimport_snduser2 ALIGN(16) : { *(.fimport_snduser2) }
.fimport_snd_user ALIGN(16) : { *(.fimport_snd_user) }
.fimport_swkbd ALIGN(16) : { *(.fimport_swkbd) }
.fimport_sysapp ALIGN(16) : { *(.fimport_sysapp) }
.fimport_tcl ALIGN(16) : { *(.fimport_tcl) }
.fimport_tve ALIGN(16) : { *(.fimport_tve) }
.fimport_uac ALIGN(16) : { *(.fimport_uac) }
.fimport_uac_rpl ALIGN(16) : { *(.fimport_uac_rpl) }
.fimport_usb_mic ALIGN(16) : { *(.fimport_usb_mic) }
.fimport_uvc ALIGN(16) : { *(.fimport_uvc) }
.fimport_uvd ALIGN(16) : { *(.fimport_uvd) }
.fimport_vpadbase ALIGN(16) : { *(.fimport_vpadbase) }
.fimport_vpad ALIGN(16) : { *(.fimport_vpad) }
.fimport_zlib125 ALIGN(16) : { *(.fimport_zlib125) }
.fimport_avm ALIGN(16) : {
KEEP ( *(.fimport_avm) )
*(.fimport_avm.*)
}
.fimport_camera ALIGN(16) : {
KEEP ( *(.fimport_camera) )
*(.fimport_camera.*)
}
.fimport_coreinit ALIGN(16) : {
KEEP ( *(.fimport_coreinit) )
*(.fimport_coreinit.*)
}
.fimport_dc ALIGN(16) : {
KEEP ( *(.fimport_dc) )
*(.fimport_dc.*)
}
.fimport_dmae ALIGN(16) : {
KEEP ( *(.fimport_dmae) )
*(.fimport_dmae.*)
}
.fimport_drmapp ALIGN(16) : {
KEEP ( *(.fimport_drmapp) )
*(.fimport_drmapp.*)
}
.fimport_erreula ALIGN(16) : {
KEEP ( *(.fimport_erreula) )
*(.fimport_erreula.*)
}
.fimport_gx2 ALIGN(16) : {
KEEP ( *(.fimport_gx2) )
*(.fimport_gx2.*)
}
.fimport_h264 ALIGN(16) : {
KEEP ( *(.fimport_h264) )
*(.fimport_h264.*)
}
.fimport_lzma920 ALIGN(16) : {
KEEP ( *(.fimport_lzma920) )
*(.fimport_lzma920.*)
}
.fimport_mic ALIGN(16) : {
KEEP ( *(.fimport_mic) )
*(.fimport_mic.*)
}
.fimport_nfc ALIGN(16) : {
KEEP ( *(.fimport_nfc) )
*(.fimport_nfc.*)
}
.fimport_nio_prof ALIGN(16) : {
KEEP ( *(.fimport_nio_prof) )
*(.fimport_nio_prof.*)
}
.fimport_nlibcurl ALIGN(16) : {
KEEP ( *(.fimport_nlibcurl) )
*(.fimport_nlibcurl.*)
}
.fimport_nlibnss2 ALIGN(16) : {
KEEP ( *(.fimport_nlibnss2) )
*(.fimport_nlibnss2.*)
}
.fimport_nlibnss ALIGN(16) : {
KEEP ( *(.fimport_nlibnss) )
*(.fimport_nlibnss.*)
}
.fimport_nn_ac ALIGN(16) : {
KEEP ( *(.fimport_nn_ac) )
*(.fimport_nn_ac.*)
}
.fimport_nn_acp ALIGN(16) : {
KEEP ( *(.fimport_nn_acp) )
*(.fimport_nn_acp.*)
}
.fimport_nn_act ALIGN(16) : {
KEEP ( *(.fimport_nn_act) )
*(.fimport_nn_act.*)
}
.fimport_nn_aoc ALIGN(16) : {
KEEP ( *(.fimport_nn_aoc) )
*(.fimport_nn_aoc.*)
}
.fimport_nn_boss ALIGN(16) : {
KEEP ( *(.fimport_nn_boss) )
*(.fimport_nn_boss.*)
}
.fimport_nn_ccr ALIGN(16) : {
KEEP ( *(.fimport_nn_ccr) )
*(.fimport_nn_ccr.*)
}
.fimport_nn_cmpt ALIGN(16) : {
KEEP ( *(.fimport_nn_cmpt) )
*(.fimport_nn_cmpt.*)
}
.fimport_nn_dlp ALIGN(16) : {
KEEP ( *(.fimport_nn_dlp) )
*(.fimport_nn_dlp.*)
}
.fimport_nn_ec ALIGN(16) : {
KEEP ( *(.fimport_nn_ec) )
*(.fimport_nn_ec.*)
}
.fimport_nn_fp ALIGN(16) : {
KEEP ( *(.fimport_nn_fp) )
*(.fimport_nn_fp.*)
}
.fimport_nn_hai ALIGN(16) : {
KEEP ( *(.fimport_nn_hai) )
*(.fimport_nn_hai.*)
}
.fimport_nn_hpad ALIGN(16) : {
KEEP ( *(.fimport_nn_hpad) )
*(.fimport_nn_hpad.*)
}
.fimport_nn_idbe ALIGN(16) : {
KEEP ( *(.fimport_nn_idbe) )
*(.fimport_nn_idbe.*)
}
.fimport_nn_ndm ALIGN(16) : {
KEEP ( *(.fimport_nn_ndm) )
*(.fimport_nn_ndm.*)
}
.fimport_nn_nets2 ALIGN(16) : {
KEEP ( *(.fimport_nn_nets2) )
*(.fimport_nn_nets2.*)
}
.fimport_nn_nfp ALIGN(16) : {
KEEP ( *(.fimport_nn_nfp) )
*(.fimport_nn_nfp.*)
}
.fimport_nn_nim ALIGN(16) : {
KEEP ( *(.fimport_nn_nim) )
*(.fimport_nn_nim.*)
}
.fimport_nn_olv ALIGN(16) : {
KEEP ( *(.fimport_nn_olv) )
*(.fimport_nn_olv.*)
}
.fimport_nn_pdm ALIGN(16) : {
KEEP ( *(.fimport_nn_pdm) )
*(.fimport_nn_pdm.*)
}
.fimport_nn_save ALIGN(16) : {
KEEP ( *(.fimport_nn_save) )
*(.fimport_nn_save.*)
}
.fimport_nn_sl ALIGN(16) : {
KEEP ( *(.fimport_nn_sl) )
*(.fimport_nn_sl.*)
}
.fimport_nn_spm ALIGN(16) : {
KEEP ( *(.fimport_nn_spm) )
*(.fimport_nn_spm.*)
}
.fimport_nn_temp ALIGN(16) : {
KEEP ( *(.fimport_nn_temp) )
*(.fimport_nn_temp.*)
}
.fimport_nn_uds ALIGN(16) : {
KEEP ( *(.fimport_nn_uds) )
*(.fimport_nn_uds.*)
}
.fimport_nn_vctl ALIGN(16) : {
KEEP ( *(.fimport_nn_vctl) )
*(.fimport_nn_vctl.*)
}
.fimport_nsysccr ALIGN(16) : {
KEEP ( *(.fimport_nsysccr) )
*(.fimport_nsysccr.*)
}
.fimport_nsyshid ALIGN(16) : {
KEEP ( *(.fimport_nsyshid) )
*(.fimport_nsyshid.*)
}
.fimport_nsyskbd ALIGN(16) : {
KEEP ( *(.fimport_nsyskbd) )
*(.fimport_nsyskbd.*)
}
.fimport_nsysnet ALIGN(16) : {
KEEP ( *(.fimport_nsysnet) )
*(.fimport_nsysnet.*)
}
.fimport_nsysuhs ALIGN(16) : {
KEEP ( *(.fimport_nsysuhs) )
*(.fimport_nsysuhs.*)
}
.fimport_nsysuvd ALIGN(16) : {
KEEP ( *(.fimport_nsysuvd) )
*(.fimport_nsysuvd.*)
}
.fimport_ntag ALIGN(16) : {
KEEP ( *(.fimport_ntag) )
*(.fimport_ntag.*)
}
.fimport_padscore ALIGN(16) : {
KEEP ( *(.fimport_padscore) )
*(.fimport_padscore.*)
}
.fimport_proc_ui ALIGN(16) : {
KEEP ( *(.fimport_proc_ui) )
*(.fimport_proc_ui.*)
}
.fimport_sndcore2 ALIGN(16) : {
KEEP ( *(.fimport_sndcore2) )
*(.fimport_sndcore2.*)
}
.fimport_snd_core ALIGN(16) : {
KEEP ( *(.fimport_snd_core) )
*(.fimport_snd_core.*)
}
.fimport_snduser2 ALIGN(16) : {
KEEP ( *(.fimport_snduser2) )
*(.fimport_snduser2.*)
}
.fimport_snd_user ALIGN(16) : {
KEEP ( *(.fimport_snd_user) )
*(.fimport_snd_user.*)
}
.fimport_swkbd ALIGN(16) : {
KEEP ( *(.fimport_swkbd) )
*(.fimport_swkbd.*)
}
.fimport_sysapp ALIGN(16) : {
KEEP ( *(.fimport_sysapp) )
*(.fimport_sysapp.*)
}
.fimport_tcl ALIGN(16) : {
KEEP ( *(.fimport_tcl) )
*(.fimport_tcl.*)
}
.fimport_tve ALIGN(16) : {
KEEP ( *(.fimport_tve) )
*(.fimport_tve.*)
}
.fimport_uac ALIGN(16) : {
KEEP ( *(.fimport_uac) )
*(.fimport_uac.*)
}
.fimport_uac_rpl ALIGN(16) : {
KEEP ( *(.fimport_uac_rpl) )
*(.fimport_uac_rpl.*)
}
.fimport_usb_mic ALIGN(16) : {
KEEP ( *(.fimport_usb_mic) )
*(.fimport_usb_mic.*)
}
.fimport_uvc ALIGN(16) : {
KEEP ( *(.fimport_uvc) )
*(.fimport_uvc.*)
}
.fimport_uvd ALIGN(16) : {
KEEP ( *(.fimport_uvd) )
*(.fimport_uvd.*)
}
.fimport_vpadbase ALIGN(16) : {
KEEP ( *(.fimport_vpadbase) )
*(.fimport_vpadbase.*)
}
.fimport_vpad ALIGN(16) : {
KEEP ( *(.fimport_vpad) )
*(.fimport_vpad.*)
}
.fimport_zlib125 ALIGN(16) : {
KEEP ( *(.fimport_zlib125) )
*(.fimport_zlib125.*)
}
.dimport_coreinit ALIGN(16) : { *(.dimport_coreinit) }
.dimport_nn_act ALIGN(16) : { *(.dimport_nn_act) }
.dimport_nn_boss ALIGN(16) : { *(.dimport_nn_boss) }
.dimport_nn_ec ALIGN(16) : { *(.dimport_nn_ec) }
.dimport_nn_nim ALIGN(16) : { *(.dimport_nn_nim) }
.dimport_nn_sl ALIGN(16) : { *(.dimport_nn_sl) }
.dimport_nn_uds ALIGN(16) : { *(.dimport_nn_uds) }
.dimport_coreinit ALIGN(16) : {
KEEP ( *(.dimport_coreinit) )
*(.dimport_coreinit.*)
}
.dimport_nn_act ALIGN(16) : {
KEEP ( *(.dimport_nn_act) )
*(.dimport_nn_act.*)
}
.dimport_nn_boss ALIGN(16) : {
KEEP ( *(.dimport_nn_boss) )
*(.dimport_nn_boss.*)
}
.dimport_nn_ec ALIGN(16) : {
KEEP ( *(.dimport_nn_ec) )
*(.dimport_nn_ec.*)
}
.dimport_nn_nim ALIGN(16) : {
KEEP ( *(.dimport_nn_nim) )
*(.dimport_nn_nim.*)
}
.dimport_nn_sl ALIGN(16) : {
KEEP ( *(.dimport_nn_sl) )
*(.dimport_nn_sl.*)
}
.dimport_nn_uds ALIGN(16) : {
KEEP ( *(.dimport_nn_uds) )
*(.dimport_nn_uds.*)
}
.wups.meta : {
*(.wups.meta*)
@ -114,12 +333,13 @@ SECTIONS {
*(.wups.hooks*)
KEEP(*(.wups.hooks*))
}
/DISCARD/ : {
*(.abs)
*(.comment)
*(.gnu.attributes)
*(.gnu.version)
*(.gnu.version_d)
*(.gnu.version_r)
*(.abs)
*(.comment)
*(.gnu.attributes)
*(.gnu.version)
*(.gnu.version_d)
*(.gnu.version_r)
}
}

View File

@ -1,6 +1,6 @@
/* based on blsug.h
* by Alex Chadwick
*
*
* Copyright (C) 2014, Alex Chadwick
* Modified by Maschell, 2018
*
@ -45,7 +45,7 @@ extern "C" {
extern const char wups_meta_ ## id [] WUPS_SECTION("meta"); \
const char wups_meta_ ## id [] = #id "=" value
#define WUPS_PLUGIN_NAME(x) WUPS_META(name, x); WUPS_META(wups, "0.1"); WUPS_META(buildtimestamp, __DATE__ " " __TIME__)
#define WUPS_PLUGIN_NAME(x) WUPS_META(name, x); WUPS_META(wups, "0.2"); WUPS_META(buildtimestamp, __DATE__ " " __TIME__)
#define WUPS_PLUGIN_AUTHOR(x) WUPS_META(author, x)
#define WUPS_PLUGIN_VERSION(x) WUPS_META(version, x)
#define WUPS_PLUGIN_LICENSE(x) WUPS_META(license, x)
@ -55,4 +55,4 @@ extern "C" {
}
#endif
#endif /* WUPS_COMMON_DEF_H_ */
#endif /* WUPS_COMMON_DEF_H_ */

View File

@ -99,6 +99,7 @@ typedef enum wups_loader_library_type_t {
WUPS_LOADER_LIBRARY_VPAD,
WUPS_LOADER_LIBRARY_VPADBASE,
WUPS_LOADER_LIBRARY_ZLIB125,
WUPS_LOADER_LIBRARY_OTHER,
}
wups_loader_library_type_t;
@ -111,6 +112,8 @@ typedef enum wups_loader_entry_type_t {
typedef struct wups_loader_entry_t {
wups_loader_entry_type_t type;
struct {
const void *physical_address; /* (optional) Physical Address. If set, the name and lib will be ignored */
const void *virtual_address; /* (optional) Physical Address. If set, the name and lib will be ignored */
const char *name; /* Name of the function that will be replaced */
const wups_loader_library_type_t library; /**/
const char *my_function_name; /* Function name of your own, new function (my_XXX) */
@ -119,14 +122,19 @@ typedef struct wups_loader_entry_t {
} _function;
} wups_loader_entry_t;
#define WUPS_MUST_REPLACE(x, lib, function_name) WUPS_MUST_REPLACE_EX(real_ ## x, lib, my_ ## x, function_name);
#define WUPS_MUST_REPLACE_PHYSICAL(x, physical_address, virtual_address) WUPS_MUST_REPLACE_EX(physical_address, virtual_address, real_ ## x, WUPS_LOADER_LIBRARY_OTHER, my_ ## x, x);
#define WUPS_MUST_REPLACE_EX(original_func, rpl_type, replace_func, replace_function_name) \
#define WUPS_MUST_REPLACE(x, lib, function_name) WUPS_MUST_REPLACE_EX(NULL, NULL, real_ ## x, lib, my_ ## x, function_name);
#define WUPS_MUST_REPLACE_EX(pAddress, vAddress, original_func, rpl_type, replace_func, replace_function_name) \
extern const wups_loader_entry_t wups_load_ ## replace_func \
WUPS_SECTION("load"); \
const wups_loader_entry_t wups_load_ ## replace_func = { \
.type = WUPS_LOADER_ENTRY_FUNCTION_MANDATORY, \
._function = { \
.physical_address = (const void*) pAddress, \
.virtual_address = (const void*) vAddress, \
.name = #replace_function_name, \
.library = rpl_type, \
.my_function_name = #replace_func, \

View File

@ -33,22 +33,25 @@ extern "C" {
}
typedef enum wups_loader_hook_type_t {
WUPS_LOADER_HOOK_INIT_FS, /* Only for internal usage */
WUPS_LOADER_HOOK_INIT_OVERLAY, /* Only for internal usage */
WUPS_LOADER_HOOK_INIT_FS, /* Only for internal usage */
WUPS_LOADER_HOOK_INIT_OVERLAY, /* Only for internal usage */
WUPS_LOADER_HOOK_INIT_KERNEL, /* Only for internal usage */
WUPS_LOADER_HOOK_INIT_VID_MEM, /* Only for internal usage */
WUPS_LOADER_HOOK_INIT_PLUGIN, /* Called when exiting the plugin loader */
WUPS_LOADER_HOOK_DEINIT_PLUGIN, /* Called when re-entering the plugin loader */
WUPS_LOADER_HOOK_STARTING_APPLICATION, /* Called when an application gets started */
WUPS_LOADER_HOOK_FUNCTIONS_PATCHED, /* Called when the functions where patched */
WUPS_LOADER_HOOK_ENDING_APPLICATION, /* Called when an application ends */
WUPS_LOADER_HOOK_VSYNC, /* Called when an application calls GX2WaitForVsync (most times each frame) */
WUPS_LOADER_HOOK_APP_STATUS_CHANGED, /* Called when the app status changes (foreground, background, closing) */
WUPS_LOADER_HOOK_INIT_KERNEL, /* Only for internal usage */
WUPS_LOADER_HOOK_GET_CONFIG, /* Called when the config-menu will be loaded */
WUPS_LOADER_HOOK_INIT_VID_MEM, /* Only for internal usage */
WUPS_LOADER_HOOK_VID_DRC_DRAW, /* Called when the DRC was rendered */
WUPS_LOADER_HOOK_VID_TV_DRAW, /* Called when the TV was rendered */
WUPS_LOADER_HOOK_INIT_PLUGIN, /* Called when exiting the plugin loader */
WUPS_LOADER_HOOK_DEINIT_PLUGIN, /* Called when re-entering the plugin loader */
WUPS_LOADER_HOOK_APPLICATION_START, /* Called when an application gets started */
WUPS_LOADER_HOOK_FUNCTIONS_PATCHED, /* Called when the functions where patched */
WUPS_LOADER_HOOK_RELEASE_FOREGROUND, /* Called when an foreground is going to be released */
WUPS_LOADER_HOOK_ACQUIRED_FOREGROUND, /* Called when an foreground is acquired */
WUPS_LOADER_HOOK_APPLICATION_END, /* Called when an application ends */
WUPS_LOADER_HOOK_CONFIRM_RELEASE_FOREGROUND, /* */
WUPS_LOADER_HOOK_SAVES_DONE_READY_TO_RELEASE, /* */
WUPS_LOADER_HOOK_VSYNC, /* Called when an application calls GX2WaitForVsync (most times each frame) */
WUPS_LOADER_HOOK_GET_CONFIG, /* Called when the config-menu will be loaded */
WUPS_LOADER_HOOK_VID_DRC_DRAW, /* Called when the DRC was rendered */
WUPS_LOADER_HOOK_VID_TV_DRAW, /* Called when the TV was rendered */
WUPS_LOADER_HOOK_APPLET_START, /* Called when the an applet was started */
} wups_loader_hook_type_t;
typedef struct wups_loader_hook_t {
@ -56,13 +59,6 @@ typedef struct wups_loader_hook_t {
const void *target; /* Address of our own, new function */
} wups_loader_hook_t;
typedef enum wups_loader_app_status_t {
WUPS_APP_STATUS_FOREGROUND, /* App is now running in foreground */
WUPS_APP_STATUS_BACKGROUND, /* App is now running in background */
WUPS_APP_STATUS_CLOSED, /* App is going to be closed */
WUPS_APP_STATUS_UNKNOWN, /* Unknown status _should_ never happen.*/
} wups_loader_app_status_t;
typedef struct wups_loader_vid_buffer_t {
const void * color_buffer_ptr;
const void * tv_texture_ptr;
@ -116,7 +112,7 @@ typedef struct wups_loader_app_started_args_t {
#define ON_APPLICATION_START(myargs) \
void on_app_starting(wups_loader_app_started_args_t);\
WUPS_HOOK_EX(WUPS_LOADER_HOOK_STARTING_APPLICATION,on_app_starting); \
WUPS_HOOK_EX(WUPS_LOADER_HOOK_APPLICATION_START,on_app_starting); \
void on_app_starting(wups_loader_app_started_args_t myargs)
#define ON_FUNCTIONS_PATCHED() \
@ -124,21 +120,41 @@ typedef struct wups_loader_app_started_args_t {
WUPS_HOOK_EX(WUPS_LOADER_HOOK_FUNCTIONS_PATCHED,on_functions_patched); \
void on_functions_patched()
#define ON_APPLICATION_ENDING() \
#define ON_RELEASE_FOREGROUND() \
void on_release_foreground(void);\
WUPS_HOOK_EX(WUPS_LOADER_HOOK_RELEASE_FOREGROUND,on_release_foreground); \
void on_release_foreground(void)
#define ON_ACQUIRED_FOREGROUND() \
void on_acquired_foreground(void);\
WUPS_HOOK_EX(WUPS_LOADER_HOOK_ACQUIRED_FOREGROUND,on_acquired_foreground); \
void on_acquired_foreground(void)
#define ON_APPLICATION_END() \
void on_app_ending(void);\
WUPS_HOOK_EX(WUPS_LOADER_HOOK_ENDING_APPLICATION,on_app_ending); \
WUPS_HOOK_EX(WUPS_LOADER_HOOK_APPLICATION_END,on_app_ending); \
void on_app_ending(void)
#define ON_CONFIRM_RELEASE_FOREGROUND() \
void on_confirm_release_foreground(void);\
WUPS_HOOK_EX(WUPS_LOADER_HOOK_CONFIRM_RELEASE_FOREGROUND,on_confirm_release_foreground); \
void on_confirm_release_foreground(void)
#define ON_SAVES_DONE_READY_TO_RELEASE() \
void on_saves_done_ready_to_release(void);\
WUPS_HOOK_EX(WUPS_LOADER_HOOK_SAVES_DONE_READY_TO_RELEASE,on_saves_done_ready_to_release); \
void on_saves_done_ready_to_release(void)
#define ON_APPLET_START() \
void on_applet_start(void);\
WUPS_HOOK_EX(WUPS_LOADER_HOOK_APPLET_START,on_applet_start); \
void on_applet_start(void)
#define ON_VYSNC() \
void on_vsync(void);\
WUPS_HOOK_EX(WUPS_LOADER_HOOK_VSYNC,on_vsync); \
void on_vsync(void)
#define ON_APP_STATUS_CHANGED(status) \
void on_app_status_changed(wups_loader_app_status_t);\
WUPS_HOOK_EX(WUPS_LOADER_HOOK_APP_STATUS_CHANGED,on_app_status_changed); \
void on_app_status_changed(wups_loader_app_status_t status)
#define ON_DRC_TO_SCAN_BUFFER(myargs) \
void on_drc_to_scan_buf(wups_loader_vid_buffer_t);\
WUPS_HOOK_EX(WUPS_LOADER_HOOK_VID_DRC_DRAW,on_drc_to_scan_buf); \