mirror of
https://github.com/wiiu-env/WiiUPluginSystem.git
synced 2024-12-24 00:51:59 +01:00
[Example Plugin] Updated the example plugin to override the OSFatal function.
The new OSFatal function logs the old message, and the calls the "real" OSFatal with a new String. [General] - Added the .sdata section to the wups.ld - Added all library_types to the enum - Updated the wups_loader_entry_t struct to store the needed data - Simplified the WUPS_MUST_REPLACE macro - Removed unneeded stuff
This commit is contained in:
parent
10c5eccd93
commit
b6119fde91
@ -11,21 +11,18 @@ WUPS_MODULE_VERSION("v1.0");
|
||||
WUPS_MODULE_AUTHOR("Maschell");
|
||||
WUPS_MODULE_LICENSE("BSD");
|
||||
|
||||
int func(void);
|
||||
|
||||
|
||||
static int my_func2(void)
|
||||
{
|
||||
DECL_FUNCTION(void,OSFatal,char * msg){
|
||||
InitOSFunctionPointers();
|
||||
InitSocketFunctionPointers();
|
||||
|
||||
log_init();
|
||||
|
||||
//log_printf is not working.
|
||||
log_print("Logging from custom function.\n");
|
||||
|
||||
return 43;
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
WUPS_MUST_REPLACE(func,WUPS_LOADER_LIBRARY_GX2, my_func2);
|
||||
WUPS_MUST_REPLACE(OSFatal,WUPS_LOADER_LIBRARY_COREINIT, OSFatal);
|
||||
|
4
wups.ld
4
wups.ld
@ -8,7 +8,9 @@ SECTIONS {
|
||||
.text : {
|
||||
*(.text*)
|
||||
}
|
||||
.data : {
|
||||
.sdata : {
|
||||
*(.sdata*)
|
||||
}.data : {
|
||||
*(.data*)
|
||||
}
|
||||
.rodata : {
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* wups.h
|
||||
/* based on blsug.h
|
||||
* by Alex Chadwick
|
||||
*
|
||||
* Copyright (C) 2014, Alex Chadwick
|
||||
@ -29,73 +29,123 @@
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define WUPS_SECTION(x) __attribute__((__section__ (".wups." x)))
|
||||
|
||||
#define DECL_FUNCTION(res, name, ...) \
|
||||
res (* real_ ## name)(__VA_ARGS__) __attribute__((section(".data"))); \
|
||||
res my_ ## name(__VA_ARGS__)
|
||||
|
||||
typedef enum wups_loader_entry_type_t {
|
||||
WUPS_LOADER_ENTRY_FUNCTION,
|
||||
WUPS_LOADER_ENTRY_FUNCTION_MANDATORY,
|
||||
WUPS_LOADER_ENTRY_EXPORT
|
||||
} wups_loader_entry_type_t;
|
||||
|
||||
|
||||
typedef enum wups_loader_library_type_t {
|
||||
WUPS_LOADER_LIBRARY_AVM,
|
||||
WUPS_LOADER_LIBRARY_CAMERA,
|
||||
WUPS_LOADER_LIBRARY_COREINIT,
|
||||
WUPS_LOADER_LIBRARY_GX2
|
||||
WUPS_LOADER_LIBRARY_DC,
|
||||
WUPS_LOADER_LIBRARY_DMAE,
|
||||
WUPS_LOADER_LIBRARY_DRMAPP,
|
||||
WUPS_LOADER_LIBRARY_ERREULA,
|
||||
WUPS_LOADER_LIBRARY_GX2,
|
||||
WUPS_LOADER_LIBRARY_H264,
|
||||
WUPS_LOADER_LIBRARY_LZMA920,
|
||||
WUPS_LOADER_LIBRARY_MIC,
|
||||
WUPS_LOADER_LIBRARY_NFC,
|
||||
WUPS_LOADER_LIBRARY_NIO_PROF,
|
||||
WUPS_LOADER_LIBRARY_NLIBCURL,
|
||||
WUPS_LOADER_LIBRARY_NLIBNSS,
|
||||
WUPS_LOADER_LIBRARY_NLIBNSS2,
|
||||
WUPS_LOADER_LIBRARY_NN_AC,
|
||||
WUPS_LOADER_LIBRARY_NN_ACP,
|
||||
WUPS_LOADER_LIBRARY_NN_ACT,
|
||||
WUPS_LOADER_LIBRARY_NN_AOC,
|
||||
WUPS_LOADER_LIBRARY_NN_BOSS,
|
||||
WUPS_LOADER_LIBRARY_NN_CCR,
|
||||
WUPS_LOADER_LIBRARY_NN_CMPT,
|
||||
WUPS_LOADER_LIBRARY_NN_DLP,
|
||||
WUPS_LOADER_LIBRARY_NN_EC,
|
||||
WUPS_LOADER_LIBRARY_NN_FP,
|
||||
WUPS_LOADER_LIBRARY_NN_HAI,
|
||||
WUPS_LOADER_LIBRARY_NN_HPAD,
|
||||
WUPS_LOADER_LIBRARY_NN_IDBE,
|
||||
WUPS_LOADER_LIBRARY_NN_NDM,
|
||||
WUPS_LOADER_LIBRARY_NN_NETS2,
|
||||
WUPS_LOADER_LIBRARY_NN_NFP,
|
||||
WUPS_LOADER_LIBRARY_NN_NIM,
|
||||
WUPS_LOADER_LIBRARY_NN_OLV,
|
||||
WUPS_LOADER_LIBRARY_NN_PDM,
|
||||
WUPS_LOADER_LIBRARY_NN_SAVE,
|
||||
WUPS_LOADER_LIBRARY_NN_SL,
|
||||
WUPS_LOADER_LIBRARY_NN_SPM,
|
||||
WUPS_LOADER_LIBRARY_NN_TEMP,
|
||||
WUPS_LOADER_LIBRARY_NN_UDS,
|
||||
WUPS_LOADER_LIBRARY_NN_VCTL,
|
||||
WUPS_LOADER_LIBRARY_NSYSCCR,
|
||||
WUPS_LOADER_LIBRARY_NSYSHID,
|
||||
WUPS_LOADER_LIBRARY_NSYSKBD,
|
||||
WUPS_LOADER_LIBRARY_NSYSNET,
|
||||
WUPS_LOADER_LIBRARY_NSYSUHS,
|
||||
WUPS_LOADER_LIBRARY_NSYSUVD,
|
||||
WUPS_LOADER_LIBRARY_NTAG,
|
||||
WUPS_LOADER_LIBRARY_PADSCORE,
|
||||
WUPS_LOADER_LIBRARY_PROC_UI,
|
||||
WUPS_LOADER_LIBRARY_SND_CORE,
|
||||
WUPS_LOADER_LIBRARY_SND_USER,
|
||||
WUPS_LOADER_LIBRARY_SNDCORE2,
|
||||
WUPS_LOADER_LIBRARY_SNDUSER2,
|
||||
WUPS_LOADER_LIBRARY_SWKBD,
|
||||
WUPS_LOADER_LIBRARY_SYSAPP,
|
||||
WUPS_LOADER_LIBRARY_TCL,
|
||||
WUPS_LOADER_LIBRARY_TVE,
|
||||
WUPS_LOADER_LIBRARY_UAC,
|
||||
WUPS_LOADER_LIBRARY_UAC_RPL,
|
||||
WUPS_LOADER_LIBRARY_USB_MIC,
|
||||
WUPS_LOADER_LIBRARY_UVC,
|
||||
WUPS_LOADER_LIBRARY_UVD,
|
||||
WUPS_LOADER_LIBRARY_VPAD,
|
||||
WUPS_LOADER_LIBRARY_VPADBASE,
|
||||
WUPS_LOADER_LIBRARY_ZLIB125,
|
||||
} wups_loader_library_type_t;
|
||||
|
||||
typedef struct wups_loader_entry_t {
|
||||
wups_loader_entry_type_t type;
|
||||
union {
|
||||
struct {
|
||||
const char *name;
|
||||
const wups_loader_library_type_t library;
|
||||
const void *target;
|
||||
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) */
|
||||
const void *call_addr; /* Function name of function, to call the real function.(real_XXX) */
|
||||
const void *target; /*Address of our own, new function (my_XXX)*/
|
||||
} _function;
|
||||
struct {
|
||||
const char *name;
|
||||
const void *target;
|
||||
} _export;
|
||||
} data;
|
||||
} wups_loader_entry_t;
|
||||
|
||||
#define WUPS_REPLACE(original_func, rpl_type, replace_func) \
|
||||
extern const wups_loader_entry_t wups_load_ ## original_func \
|
||||
|
||||
|
||||
#define WUPS_MUST_REPLACE(x, lib, function_name) WUPS_MUST_REPLACE_EX(real_ ## x, lib, my_ ## x, function_name);
|
||||
|
||||
#define WUPS_MUST_REPLACE_EX(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_ ## original_func = { \
|
||||
.type = WUPS_LOADER_ENTRY_FUNCTION, \
|
||||
.data = { \
|
||||
._function = { \
|
||||
.name = #original_func, \
|
||||
.library = rpl_type, \
|
||||
.target = (const void*)&(replace_func) \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
#define WUPS_MUST_REPLACE(original_func, rpl_type, replace_func) \
|
||||
extern const wups_loader_entry_t wups_load_ ## original_func \
|
||||
WUPS_SECTION("load"); \
|
||||
const wups_loader_entry_t wups_load_ ## original_func = { \
|
||||
const wups_loader_entry_t wups_load_ ## replace_func = { \
|
||||
.type = WUPS_LOADER_ENTRY_FUNCTION_MANDATORY, \
|
||||
.data = { \
|
||||
._function = { \
|
||||
.name = #original_func, \
|
||||
.name = #replace_function_name, \
|
||||
.library = rpl_type, \
|
||||
.my_function_name = #replace_func, \
|
||||
.call_addr = (const void*)&(original_func), \
|
||||
.target = (const void*)&(replace_func) \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
#define WUPS_EXPORT(symbol) \
|
||||
extern const wups_loader_entry_t wups_export_ ## symbol \
|
||||
WUPS_SECTION("load"); \
|
||||
const wups_loader_entry_t wups_export_ ## symbol = { \
|
||||
.type = WUPS_LOADER_ENTRY_EXPORT, \
|
||||
.data = { \
|
||||
._export = { \
|
||||
.name = #symbol, \
|
||||
.target = (const void*)&(symbol) \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
#define WUPS_META(id, value) \
|
||||
extern const char wups_meta_ ## id [] WUPS_SECTION("meta"); \
|
||||
@ -106,17 +156,6 @@ typedef struct wups_loader_entry_t {
|
||||
#define WUPS_MODULE_VERSION(x) WUPS_META(version, x)
|
||||
#define WUPS_MODULE_LICENSE(x) WUPS_META(license, x)
|
||||
|
||||
/* wups_game_start - first address that is part of the game's executable.
|
||||
* wups_game_end - address after the end of the game's executable.
|
||||
* Added in WUPS_LIB_VERSION 0.1.1 */
|
||||
extern uint8_t wups_game_start[];
|
||||
extern uint8_t wups_game_end[];
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user