mirror of
https://github.com/wiiu-env/WiiUPluginSystem.git
synced 2024-12-26 01:51:56 +01:00
Added SD/USB support for plugins!
Now the plugins inherit the SD/USB access from the loader. Check (args != NULL && (args->device_mounted & WUPS_SD_MOUNTED) > 0) in your INITIALZE method if you have SD access, and (args != NULL && (args->device_mounted & WUPS_USB_MOUNTED) > 0) for usb access. You can simply use open, read etc. then with "sd:/" and "usb:". No (un)mounting required. NTFS support is NOT implemented yet. So: HID to VPAD plugin can now read configurations SDCafiine now has support for libfat (other games than SSBU + FAT32 USB)
This commit is contained in:
parent
f8e8f7f52e
commit
46358ce67a
@ -65,7 +65,7 @@ before_deploy:
|
|||||||
- versiontag="$(./gitrev.sh)"
|
- versiontag="$(./gitrev.sh)"
|
||||||
- (cd loader && make)
|
- (cd loader && make)
|
||||||
- cp example_plugin/example_plugin.mod wiiu/plugins
|
- cp example_plugin/example_plugin.mod wiiu/plugins
|
||||||
- cp plugins/*.mod wiiu/plugins
|
- find plugins -type f -name "*.mod" | xargs -i cp {} wiiu/plugins
|
||||||
- cp loader/meta/* wiiu/apps/wiiupluginloader
|
- cp loader/meta/* wiiu/apps/wiiupluginloader
|
||||||
- cp loader/wiiupluginloader.elf wiiu/apps/wiiupluginloader
|
- cp loader/wiiupluginloader.elf wiiu/apps/wiiupluginloader
|
||||||
- zip -r WiiUPluginLoader_$versiontag.zip wiiu
|
- zip -r WiiUPluginLoader_$versiontag.zip wiiu
|
||||||
|
@ -11,7 +11,7 @@ WUPS_MODULE_VERSION("v1.0");
|
|||||||
WUPS_MODULE_AUTHOR("Maschell");
|
WUPS_MODULE_AUTHOR("Maschell");
|
||||||
WUPS_MODULE_LICENSE("BSD");
|
WUPS_MODULE_LICENSE("BSD");
|
||||||
|
|
||||||
INITIALIZE(){
|
INITIALIZE(args){
|
||||||
InitOSFunctionPointers();
|
InitOSFunctionPointers();
|
||||||
InitSocketFunctionPointers();
|
InitSocketFunctionPointers();
|
||||||
|
|
||||||
|
@ -19,14 +19,6 @@ extern "C" {
|
|||||||
#define ELF_DATA_SIZE (*(volatile unsigned int*)(MEM_BASE + 0x1300 + 0x04))
|
#define ELF_DATA_SIZE (*(volatile unsigned int*)(MEM_BASE + 0x1300 + 0x04))
|
||||||
#define MAIN_ENTRY_ADDR (*(volatile unsigned int*)(MEM_BASE + 0x1400 + 0x00))
|
#define MAIN_ENTRY_ADDR (*(volatile unsigned int*)(MEM_BASE + 0x1400 + 0x00))
|
||||||
|
|
||||||
#define SDUSB_MOUNTED_NONE 0
|
|
||||||
#define SDUSB_MOUNTED_FAKE (1<<0)
|
|
||||||
#define SDUSB_MOUNTED_OS_SD (1<<1)
|
|
||||||
#define SDUSB_LIBIOSU_LOADED (1<<2)
|
|
||||||
#define SD_MOUNTED_LIBFAT (1<<3)
|
|
||||||
#define USB_MOUNTED_LIBFAT (1<<4)
|
|
||||||
#define USB_MOUNTED_LIBNTFS (1<<5)
|
|
||||||
|
|
||||||
#ifndef EXIT_SUCCESS
|
#ifndef EXIT_SUCCESS
|
||||||
#define EXIT_SUCCESS 0
|
#define EXIT_SUCCESS 0
|
||||||
#endif
|
#endif
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
|
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <dynamic_libs/os_functions.h>
|
#include <dynamic_libs/os_functions.h>
|
||||||
#include <dynamic_libs/socket_functions.h>
|
#include <dynamic_libs/socket_functions.h>
|
||||||
@ -65,7 +67,7 @@ extern "C" int Menu_Main(int argc, char **argv){
|
|||||||
|
|
||||||
DEBUG_FUNCTION_LINE("Wii U Plugin System Loader %s\n",APP_VERSION);
|
DEBUG_FUNCTION_LINE("Wii U Plugin System Loader %s\n",APP_VERSION);
|
||||||
|
|
||||||
setup_os_exceptions();
|
//setup_os_exceptions();
|
||||||
|
|
||||||
DEBUG_FUNCTION_LINE("Mount SD partition\n");
|
DEBUG_FUNCTION_LINE("Mount SD partition\n");
|
||||||
Init_SD_USB();
|
Init_SD_USB();
|
||||||
@ -129,9 +131,25 @@ void CallHook(wups_loader_hook_type_t hook_type){
|
|||||||
void * func_ptr = hook_data->func_pointer;
|
void * func_ptr = hook_data->func_pointer;
|
||||||
//TODO: Switch cases depending on arguments etc.
|
//TODO: Switch cases depending on arguments etc.
|
||||||
// Adding arguments!
|
// Adding arguments!
|
||||||
|
|
||||||
if(func_ptr != NULL){
|
if(func_ptr != NULL){
|
||||||
|
if(hook_type == WUPS_LOADER_HOOK_INIT_FUNCTION){
|
||||||
DEBUG_FUNCTION_LINE("Calling it! %08X\n",func_ptr);
|
DEBUG_FUNCTION_LINE("Calling it! %08X\n",func_ptr);
|
||||||
( (void (*)(void))((unsigned int*)func_ptr) )();
|
wups_loader_init_args_t args;
|
||||||
|
args.device_mounted = gSDInitDone;
|
||||||
|
args.fs_wrapper.open_repl = (const void*)&open;
|
||||||
|
args.fs_wrapper.close_repl = (const void*)&close;
|
||||||
|
args.fs_wrapper.write_repl = (const void*)&write;
|
||||||
|
args.fs_wrapper.read_repl = (const void*)&read;
|
||||||
|
args.fs_wrapper.lseek_repl = (const void*)&lseek;
|
||||||
|
args.fs_wrapper.stat_repl = (const void*)&stat;
|
||||||
|
args.fs_wrapper.fstat_repl = (const void*)&fstat;
|
||||||
|
args.fs_wrapper.opendir_repl = (const void*)&opendir;
|
||||||
|
args.fs_wrapper.closedir_repl = (const void*)&closedir;
|
||||||
|
args.fs_wrapper.readdir_repl = (const void*)&readdir;
|
||||||
|
|
||||||
|
( (void (*)(wups_loader_init_args_t *))((unsigned int*)func_ptr) )(&args);
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
DEBUG_FUNCTION_LINE("Was not defined\n");
|
DEBUG_FUNCTION_LINE("Was not defined\n");
|
||||||
}
|
}
|
||||||
@ -167,7 +185,7 @@ s32 isInMiiMakerHBL(){
|
|||||||
#define PLUGIN_LOCATION_END_ADDRESS 0x01000000
|
#define PLUGIN_LOCATION_END_ADDRESS 0x01000000
|
||||||
|
|
||||||
bool loadSamplePlugins(){
|
bool loadSamplePlugins(){
|
||||||
if((gSDInitDone & (SDUSB_MOUNTED_OS_SD | SD_MOUNTED_LIBFAT)) > 0){
|
if((gSDInitDone & WUPS_SD_MOUNTED) > 0){
|
||||||
DEBUG_FUNCTION_LINE("Mounting successful. Loading modules\n");
|
DEBUG_FUNCTION_LINE("Mounting successful. Loading modules\n");
|
||||||
|
|
||||||
std::vector<ModuleData *> modules;
|
std::vector<ModuleData *> modules;
|
||||||
@ -287,27 +305,27 @@ void Init_SD_USB() {
|
|||||||
}
|
}
|
||||||
deleteDevTabsNames();
|
deleteDevTabsNames();
|
||||||
mount_fake();
|
mount_fake();
|
||||||
gSDInitDone |= SDUSB_MOUNTED_FAKE;
|
gSDInitDone |= WUPS_SDUSB_MOUNTED_FAKE;
|
||||||
|
|
||||||
if(res < 0){
|
if(res < 0){
|
||||||
DEBUG_FUNCTION_LINE("IOSUHAX_open failed\n");
|
DEBUG_FUNCTION_LINE("IOSUHAX_open failed\n");
|
||||||
if((res = mount_sd_fat("sd")) >= 0){
|
if((res = mount_sd_fat("sd")) >= 0){
|
||||||
DEBUG_FUNCTION_LINE("mount_sd_fat success\n");
|
DEBUG_FUNCTION_LINE("mount_sd_fat success\n");
|
||||||
gSDInitDone |= SDUSB_MOUNTED_OS_SD;
|
gSDInitDone |= WUPS_SDUSB_MOUNTED_OS_SD;
|
||||||
}else{
|
}else{
|
||||||
DEBUG_FUNCTION_LINE("mount_sd_fat failed %d\n",res);
|
DEBUG_FUNCTION_LINE("mount_sd_fat failed %d\n",res);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
DEBUG_FUNCTION_LINE("Using IOSUHAX for SD/USB access\n");
|
DEBUG_FUNCTION_LINE("Using IOSUHAX for SD/USB access\n");
|
||||||
gSDInitDone |= SDUSB_LIBIOSU_LOADED;
|
gSDInitDone |= WUPS_SDUSB_LIBIOSU_LOADED;
|
||||||
int ntfs_mounts = mountAllNTFS();
|
int ntfs_mounts = mountAllNTFS();
|
||||||
if(ntfs_mounts > 0){
|
if(ntfs_mounts > 0){
|
||||||
gSDInitDone |= USB_MOUNTED_LIBNTFS;
|
gSDInitDone |= WUPS_USB_MOUNTED_LIBNTFS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mount_libfatAll() == 0){
|
if(mount_libfatAll() == 0){
|
||||||
gSDInitDone |= SD_MOUNTED_LIBFAT;
|
gSDInitDone |= WUPS_SD_MOUNTED_LIBFAT;
|
||||||
gSDInitDone |= USB_MOUNTED_LIBFAT;
|
gSDInitDone |= WUPS_USB_MOUNTED_LIBFAT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DEBUG_FUNCTION_LINE("%08X\n",gSDInitDone);
|
DEBUG_FUNCTION_LINE("%08X\n",gSDInitDone);
|
||||||
@ -316,43 +334,43 @@ void Init_SD_USB() {
|
|||||||
void DeInit_SD_USB(){
|
void DeInit_SD_USB(){
|
||||||
DEBUG_FUNCTION_LINE("Called this function.\n");
|
DEBUG_FUNCTION_LINE("Called this function.\n");
|
||||||
|
|
||||||
if(gSDInitDone & SDUSB_MOUNTED_FAKE){
|
if(gSDInitDone & WUPS_SDUSB_MOUNTED_FAKE){
|
||||||
DEBUG_FUNCTION_LINE("Unmounting fake\n");
|
DEBUG_FUNCTION_LINE("Unmounting fake\n");
|
||||||
unmount_fake();
|
unmount_fake();
|
||||||
gSDInitDone &= ~SDUSB_MOUNTED_FAKE;
|
gSDInitDone &= ~WUPS_SDUSB_MOUNTED_FAKE;
|
||||||
}
|
}
|
||||||
if(gSDInitDone & SDUSB_MOUNTED_OS_SD){
|
if(gSDInitDone & WUPS_SDUSB_MOUNTED_OS_SD){
|
||||||
DEBUG_FUNCTION_LINE("Unmounting OS SD\n");
|
DEBUG_FUNCTION_LINE("Unmounting OS SD\n");
|
||||||
unmount_sd_fat("sd");
|
unmount_sd_fat("sd");
|
||||||
gSDInitDone &= ~SDUSB_MOUNTED_OS_SD;
|
gSDInitDone &= ~WUPS_SDUSB_MOUNTED_OS_SD;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(gSDInitDone & SD_MOUNTED_LIBFAT){
|
if(gSDInitDone & WUPS_SD_MOUNTED_LIBFAT){
|
||||||
DEBUG_FUNCTION_LINE("Unmounting LIBFAT SD\n");
|
DEBUG_FUNCTION_LINE("Unmounting LIBFAT SD\n");
|
||||||
unmount_libfat("sd");
|
unmount_libfat("sd");
|
||||||
gSDInitDone &= ~SD_MOUNTED_LIBFAT;
|
gSDInitDone &= ~WUPS_SD_MOUNTED_LIBFAT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(gSDInitDone & USB_MOUNTED_LIBFAT){
|
if(gSDInitDone & WUPS_USB_MOUNTED_LIBFAT){
|
||||||
DEBUG_FUNCTION_LINE("Unmounting LIBFAT USB\n");
|
DEBUG_FUNCTION_LINE("Unmounting LIBFAT USB\n");
|
||||||
unmount_libfat("usb");
|
unmount_libfat("usb");
|
||||||
gSDInitDone &= ~USB_MOUNTED_LIBFAT;
|
gSDInitDone &= ~WUPS_USB_MOUNTED_LIBFAT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(gSDInitDone & USB_MOUNTED_LIBNTFS){
|
if(gSDInitDone & WUPS_USB_MOUNTED_LIBNTFS){
|
||||||
DEBUG_FUNCTION_LINE("Unmounting LIBNTFS USB\n");
|
DEBUG_FUNCTION_LINE("Unmounting LIBNTFS USB\n");
|
||||||
unmountAllNTFS();
|
unmountAllNTFS();
|
||||||
gSDInitDone &= ~USB_MOUNTED_LIBNTFS;
|
gSDInitDone &= ~WUPS_USB_MOUNTED_LIBNTFS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(gSDInitDone & SDUSB_LIBIOSU_LOADED){
|
if(gSDInitDone & WUPS_SDUSB_LIBIOSU_LOADED){
|
||||||
DEBUG_FUNCTION_LINE("Calling IOSUHAX_Close\n");
|
DEBUG_FUNCTION_LINE("Calling IOSUHAX_Close\n");
|
||||||
IOSUHAX_Close();
|
IOSUHAX_Close();
|
||||||
gSDInitDone &= ~SDUSB_LIBIOSU_LOADED;
|
gSDInitDone &= ~WUPS_SDUSB_LIBIOSU_LOADED;
|
||||||
|
|
||||||
}
|
}
|
||||||
deleteDevTabsNames();
|
deleteDevTabsNames();
|
||||||
if(gSDInitDone != SDUSB_MOUNTED_NONE){
|
if(gSDInitDone != WUPS_SDUSB_MOUNTED_NONE){
|
||||||
DEBUG_FUNCTION_LINE("WARNING. Some devices are still mounted.\n");
|
DEBUG_FUNCTION_LINE("WARNING. Some devices are still mounted.\n");
|
||||||
}
|
}
|
||||||
DEBUG_FUNCTION_LINE("Function end.\n");
|
DEBUG_FUNCTION_LINE("Function end.\n");
|
||||||
|
@ -87,6 +87,7 @@ ASFLAGS := -mregnames
|
|||||||
# -Map: generate a map file
|
# -Map: generate a map file
|
||||||
|
|
||||||
LDFLAG_COMMON += -u wups_load -u wups_meta -u wups_hooks -T $(WUPSDIR)/wups.ld \
|
LDFLAG_COMMON += -u wups_load -u wups_meta -u wups_hooks -T $(WUPSDIR)/wups.ld \
|
||||||
|
-Wl,-wrap,open,-wrap,close,-wrap,write,-wrap,read,-wrap,lseek,-wrap,stat,-wrap,fstat,-wrap,opendir,-wrap,closedir,-wrap,readdir \
|
||||||
-Wl,-Map,$(notdir $@).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,--gc-sections
|
-Wl,-Map,$(notdir $@).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,--gc-sections
|
||||||
|
|
||||||
LDFLAGS_MOD += $(LDFLAG_COMMON),--relocatable
|
LDFLAGS_MOD += $(LDFLAG_COMMON),--relocatable
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <dynamic_libs/os_functions.h>
|
#include <dynamic_libs/os_functions.h>
|
||||||
#include <dynamic_libs/vpad_functions.h>
|
#include <dynamic_libs/vpad_functions.h>
|
||||||
|
#include <dynamic_libs/padscore_functions.h>
|
||||||
#include <dynamic_libs/socket_functions.h>
|
#include <dynamic_libs/socket_functions.h>
|
||||||
#include <dynamic_libs/proc_ui_functions.h>
|
#include <dynamic_libs/proc_ui_functions.h>
|
||||||
#include <controller_patcher/ControllerPatcher.hpp>
|
#include <controller_patcher/ControllerPatcher.hpp>
|
||||||
@ -13,29 +14,40 @@ WUPS_MODULE_VERSION("v1.0");
|
|||||||
WUPS_MODULE_AUTHOR("Maschell");
|
WUPS_MODULE_AUTHOR("Maschell");
|
||||||
WUPS_MODULE_LICENSE("GPL");
|
WUPS_MODULE_LICENSE("GPL");
|
||||||
|
|
||||||
|
#define SD_PATH "sd:"
|
||||||
|
#define WIIU_PATH "/wiiu"
|
||||||
|
#define DEFAULT_HID_TO_VPAD_PATH SD_PATH WIIU_PATH "/apps/hidtovpad"
|
||||||
|
|
||||||
INITIALIZE(){
|
INITIALIZE(args){
|
||||||
InitOSFunctionPointers();
|
InitOSFunctionPointers();
|
||||||
InitSocketFunctionPointers();
|
InitSocketFunctionPointers();
|
||||||
InitVPadFunctionPointers();
|
InitVPadFunctionPointers();
|
||||||
InitProcUIFunctionPointers();
|
InitProcUIFunctionPointers();
|
||||||
|
InitPadScoreFunctionPointers();
|
||||||
|
|
||||||
log_init();
|
log_init();
|
||||||
log_print("Init of hid_to_vpad!\n");
|
log_print("Init of hid_to_vpad!\n");
|
||||||
|
if(args != NULL && (args->device_mounted & WUPS_SD_MOUNTED) > 0){
|
||||||
|
DEBUG_FUNCTION_LINE("Loading with SD Access\n");
|
||||||
|
ControllerPatcher::Init(CONTROLLER_PATCHER_PATH);
|
||||||
|
} else {
|
||||||
|
DEBUG_FUNCTION_LINE("Loading without SD Access\n");
|
||||||
ControllerPatcher::Init(NULL);
|
ControllerPatcher::Init(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ControllerPatcher::disableControllerMapping();
|
ControllerPatcher::disableControllerMapping();
|
||||||
|
|
||||||
log_print("Start network server\n");
|
log_print("Start network server\n");
|
||||||
ControllerPatcher::startNetworkServer();
|
ControllerPatcher::startNetworkServer();
|
||||||
|
//TODO: ControllerPatcher::DeInit() on restore.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DECL_FUNCTION(void, __PPCExit, void){
|
DECL_FUNCTION(void, __PPCExit, void){
|
||||||
ControllerPatcher::resetCallbackData();
|
ControllerPatcher::resetCallbackData();
|
||||||
|
|
||||||
ControllerPatcher::DeInit();
|
ControllerPatcher::destroyConfigHelper();
|
||||||
ControllerPatcher::stopNetworkServer();
|
ControllerPatcher::stopNetworkServer();
|
||||||
real___PPCExit();
|
real___PPCExit();
|
||||||
}
|
}
|
||||||
|
@ -85,6 +85,7 @@ ASFLAGS := -mregnames
|
|||||||
# -Map: generate a map file
|
# -Map: generate a map file
|
||||||
|
|
||||||
LDFLAG_COMMON += -u wups_load -u wups_meta -u wups_hooks -T $(WUPSDIR)/wups.ld \
|
LDFLAG_COMMON += -u wups_load -u wups_meta -u wups_hooks -T $(WUPSDIR)/wups.ld \
|
||||||
|
-Wl,-wrap,open,-wrap,close,-wrap,write,-wrap,read,-wrap,lseek,-wrap,stat,-wrap,fstat,-wrap,opendir,-wrap,closedir,-wrap,readdir \
|
||||||
-Wl,-Map,$(notdir $@).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,--gc-sections
|
-Wl,-Map,$(notdir $@).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,--gc-sections
|
||||||
|
|
||||||
LDFLAGS_MOD += $(LDFLAG_COMMON),--relocatable
|
LDFLAGS_MOD += $(LDFLAG_COMMON),--relocatable
|
||||||
|
@ -11,7 +11,7 @@ WUPS_MODULE_AUTHOR("Maschell");
|
|||||||
WUPS_MODULE_LICENSE("GPL");
|
WUPS_MODULE_LICENSE("GPL");
|
||||||
|
|
||||||
|
|
||||||
INITIALIZE(){
|
INITIALIZE(args){
|
||||||
InitOSFunctionPointers();
|
InitOSFunctionPointers();
|
||||||
InitSocketFunctionPointers();
|
InitSocketFunctionPointers();
|
||||||
InitVPadFunctionPointers();
|
InitVPadFunctionPointers();
|
||||||
|
@ -88,7 +88,8 @@ ASFLAGS := -mregnames
|
|||||||
# -Map: generate a map file
|
# -Map: generate a map file
|
||||||
|
|
||||||
LDFLAG_COMMON += -u wups_load -u wups_meta -u wups_hooks -T $(WUPSDIR)/wups.ld \
|
LDFLAG_COMMON += -u wups_load -u wups_meta -u wups_hooks -T $(WUPSDIR)/wups.ld \
|
||||||
-Wl,-Map,$(notdir $@).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,--gc-sections
|
-Wl,-wrap,open,-wrap,close,-wrap,write,-wrap,read,-wrap,lseek,-wrap,stat,-wrap,fstat,-wrap,opendir,-wrap,closedir,-wrap,readdir \
|
||||||
|
-Wl,-Map,$(notdir $@).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,-wrap,opendir,--gc-sections
|
||||||
|
|
||||||
LDFLAGS_MOD += $(LDFLAG_COMMON),--relocatable
|
LDFLAGS_MOD += $(LDFLAG_COMMON),--relocatable
|
||||||
LDFLAGS_ELF += --relocatable -s -T $(WUPSDIR)/wups_elf.ld
|
LDFLAGS_ELF += --relocatable -s -T $(WUPSDIR)/wups_elf.ld
|
||||||
@ -160,7 +161,7 @@ export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \
|
|||||||
-L$(PORTLIBS)/lib
|
-L$(PORTLIBS)/lib
|
||||||
|
|
||||||
export OUTPUT := $(CURDIR)/$(TARGET)
|
export OUTPUT := $(CURDIR)/$(TARGET)
|
||||||
.PHONY: $(BUILD) clean install
|
.PHONY: all $(BUILD) clean install
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
$(BUILD):
|
$(BUILD):
|
||||||
|
@ -11,5 +11,4 @@ extern volatile u8 gSDInitDone;
|
|||||||
|
|
||||||
extern char gModFolder[FS_MAX_ENTNAME_SIZE];
|
extern char gModFolder[FS_MAX_ENTNAME_SIZE];
|
||||||
|
|
||||||
|
|
||||||
#endif // RETAINS_VARS_H_
|
#endif // RETAINS_VARS_H_
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
#include <wups.h>
|
#include <wups.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/types.h>
|
|
||||||
#include <dirent.h>
|
|
||||||
#include <dynamic_libs/os_functions.h>
|
#include <dynamic_libs/os_functions.h>
|
||||||
#include <dynamic_libs/vpad_functions.h>
|
#include <dynamic_libs/vpad_functions.h>
|
||||||
#include <dynamic_libs/sys_functions.h>
|
#include <dynamic_libs/sys_functions.h>
|
||||||
@ -21,9 +19,10 @@ WUPS_MODULE_VERSION("v1.0");
|
|||||||
WUPS_MODULE_AUTHOR("Maschell");
|
WUPS_MODULE_AUTHOR("Maschell");
|
||||||
WUPS_MODULE_LICENSE("GPL");
|
WUPS_MODULE_LICENSE("GPL");
|
||||||
|
|
||||||
INITIALIZE(){
|
INITIALIZE(args){
|
||||||
InitOSFunctionPointers();
|
InitOSFunctionPointers();
|
||||||
InitSocketFunctionPointers(); //For logging
|
InitSocketFunctionPointers(); //For logging
|
||||||
|
InitVPadFunctionPointers(); //For logging
|
||||||
|
|
||||||
log_init();
|
log_init();
|
||||||
|
|
||||||
@ -31,6 +30,21 @@ INITIALIZE(){
|
|||||||
DEBUG_FUNCTION_LINE("SUCCESS\n");
|
DEBUG_FUNCTION_LINE("SUCCESS\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(args != NULL){
|
||||||
|
gSDInitDone = args->device_mounted;
|
||||||
|
/*if((args->device_mounted & WUPS_SD_MOUNTED) > 0){
|
||||||
|
DEBUG_FUNCTION_LINE("Yay, SD was mounted!\n");
|
||||||
|
gSDInitDone = WUPS_SD_MOUNTED;
|
||||||
|
|
||||||
|
DEBUG_FUNCTION_LINE("opendir result %08X!\n",opendir("sd:/"));
|
||||||
|
|
||||||
|
} else {
|
||||||
|
DEBUG_FUNCTION_LINE("SD wasn't mounted...!\n");
|
||||||
|
}*/
|
||||||
|
}else {
|
||||||
|
DEBUG_FUNCTION_LINE("args were NULL!\n");
|
||||||
|
}
|
||||||
|
|
||||||
HandleMultiModPacks(OSGetTitleID());
|
HandleMultiModPacks(OSGetTitleID());
|
||||||
|
|
||||||
log_print("Init of SDCafiine!\n");
|
log_print("Init of SDCafiine!\n");
|
||||||
@ -40,4 +54,3 @@ void deInitApplication(){
|
|||||||
//FileReplacerUtils::getInstance()->StopAsyncThread();
|
//FileReplacerUtils::getInstance()->StopAsyncThread();
|
||||||
FileReplacerUtils::destroyInstance();
|
FileReplacerUtils::destroyInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,6 +87,7 @@ ASFLAGS := -mregnames
|
|||||||
# -Map: generate a map file
|
# -Map: generate a map file
|
||||||
|
|
||||||
LDFLAG_COMMON += -u wups_load -u wups_meta -u wups_hooks -T $(WUPSDIR)/wups.ld \
|
LDFLAG_COMMON += -u wups_load -u wups_meta -u wups_hooks -T $(WUPSDIR)/wups.ld \
|
||||||
|
-Wl,-wrap,open,-wrap,close,-wrap,write,-wrap,read,-wrap,lseek,-wrap,stat,-wrap,fstat,-wrap,opendir,-wrap,closedir,-wrap,readdir \
|
||||||
-Wl,-Map,$(notdir $@).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,--gc-sections
|
-Wl,-Map,$(notdir $@).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,--gc-sections
|
||||||
|
|
||||||
LDFLAGS_MOD += $(LDFLAG_COMMON),--relocatable
|
LDFLAGS_MOD += $(LDFLAG_COMMON),--relocatable
|
||||||
|
@ -44,7 +44,7 @@ u8 isFirstBoot __attribute__((section(".data"))) = 1;
|
|||||||
u32 SplashScreen(s32 time,s32 combotime);
|
u32 SplashScreen(s32 time,s32 combotime);
|
||||||
|
|
||||||
/* Entry point */
|
/* Entry point */
|
||||||
INITIALIZE(){
|
INITIALIZE(args){
|
||||||
if(gAppStatus == 2){
|
if(gAppStatus == 2){
|
||||||
log_printf("No, we don't want to patch stuff again.");
|
log_printf("No, we don't want to patch stuff again.");
|
||||||
return;
|
return;
|
||||||
|
@ -28,6 +28,11 @@
|
|||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <dirent.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@ -119,6 +124,8 @@ typedef struct wups_loader_hook_t {
|
|||||||
const void *target; /*Address of our own, new function (my_XXX)*/
|
const void *target; /*Address of our own, new function (my_XXX)*/
|
||||||
} wups_loader_hook_t;
|
} wups_loader_hook_t;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define WUPS_HOOK_INIT(original_func) \
|
#define WUPS_HOOK_INIT(original_func) \
|
||||||
extern const wups_loader_hook_t wups_hooks_init_ ## original_func \
|
extern const wups_loader_hook_t wups_hooks_init_ ## original_func \
|
||||||
WUPS_SECTION("hooks"); \
|
WUPS_SECTION("hooks"); \
|
||||||
@ -127,10 +134,126 @@ typedef struct wups_loader_hook_t {
|
|||||||
.target = (const void*)&(original_func) \
|
.target = (const void*)&(original_func) \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define INITIALIZE() \
|
#define WUPS_SDUSB_MOUNTED_NONE 0
|
||||||
void init();\
|
#define WUPS_SDUSB_MOUNTED_FAKE (1<<0)
|
||||||
|
#define WUPS_SDUSB_MOUNTED_OS_SD (1<<1)
|
||||||
|
#define WUPS_SDUSB_LIBIOSU_LOADED (1<<2)
|
||||||
|
#define WUPS_SD_MOUNTED_LIBFAT (1<<3)
|
||||||
|
#define WUPS_USB_MOUNTED_LIBFAT (1<<4)
|
||||||
|
#define WUPS_USB_MOUNTED_LIBNTFS (1<<5)
|
||||||
|
|
||||||
|
#define WUPS_SD_MOUNTED (WUPS_SDUSB_MOUNTED_OS_SD | WUPS_SD_MOUNTED_LIBFAT)
|
||||||
|
#define WUPS_USB_MOUNTED (WUPS_USB_MOUNTED_LIBFAT)
|
||||||
|
|
||||||
|
typedef struct wups_loader_init_args_t {
|
||||||
|
int device_mounted;
|
||||||
|
struct {
|
||||||
|
const void * open_repl;
|
||||||
|
const void * close_repl;
|
||||||
|
const void * write_repl;
|
||||||
|
const void * read_repl;
|
||||||
|
const void * lseek_repl;
|
||||||
|
const void * stat_repl;
|
||||||
|
const void * fstat_repl;
|
||||||
|
const void * opendir_repl;
|
||||||
|
const void * closedir_repl;
|
||||||
|
const void * readdir_repl;
|
||||||
|
} fs_wrapper;
|
||||||
|
} wups_loader_init_args_t;
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#define EXTERN_C_START extern "C" {
|
||||||
|
#define EXTERN_C_END }
|
||||||
|
#else
|
||||||
|
#define EXTERN_C_START
|
||||||
|
#define EXTERN_C_END
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define INITIALIZE(my_args) \
|
||||||
|
void init(wups_loader_init_args_t*);\
|
||||||
|
void myInit(wups_loader_init_args_t*);\
|
||||||
WUPS_HOOK_INIT(init); \
|
WUPS_HOOK_INIT(init); \
|
||||||
void init()
|
static void * new_open_ptr __attribute__((section(".data"))) = NULL; \
|
||||||
|
static void * new_close_ptr __attribute__((section(".data"))) = NULL; \
|
||||||
|
static void * new_write_ptr __attribute__((section(".data"))) = NULL; \
|
||||||
|
static void * new_read_ptr __attribute__((section(".data"))) = NULL; \
|
||||||
|
static void * new_lseek_ptr __attribute__((section(".data"))) = NULL; \
|
||||||
|
static void * new_stat_ptr __attribute__((section(".data"))) = NULL; \
|
||||||
|
static void * new_fstat_ptr __attribute__((section(".data"))) = NULL; \
|
||||||
|
static void * new_opendir_ptr __attribute__((section(".data"))) = NULL; \
|
||||||
|
static void * new_closedir_ptr __attribute__((section(".data"))) = NULL; \
|
||||||
|
static void * new_readdir_ptr __attribute__((section(".data"))) = NULL; \
|
||||||
|
void init(wups_loader_init_args_t* args){ \
|
||||||
|
if(args != NULL){\
|
||||||
|
new_open_ptr = (void*) args->fs_wrapper.open_repl; \
|
||||||
|
new_close_ptr = (void*) args->fs_wrapper.close_repl; \
|
||||||
|
new_write_ptr = (void*) args->fs_wrapper.write_repl; \
|
||||||
|
new_read_ptr = (void*) args->fs_wrapper.read_repl; \
|
||||||
|
new_lseek_ptr = (void*) args->fs_wrapper.lseek_repl; \
|
||||||
|
new_stat_ptr = (void*) args->fs_wrapper.stat_repl; \
|
||||||
|
new_fstat_ptr = (void*) args->fs_wrapper.fstat_repl; \
|
||||||
|
new_opendir_ptr = (void*) args->fs_wrapper.opendir_repl; \
|
||||||
|
new_closedir_ptr = (void*) args->fs_wrapper.closedir_repl; \
|
||||||
|
new_readdir_ptr = (void*) args->fs_wrapper.readdir_repl; \
|
||||||
|
}\
|
||||||
|
myInit(args);\
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
EXTERN_C_START \
|
||||||
|
\
|
||||||
|
int __real_open(const char *pathname, int flags);\
|
||||||
|
int __wrap_open(const char *pathname, int flags){\
|
||||||
|
if(new_open_ptr == NULL) return __real_open(pathname,flags); \
|
||||||
|
return ( (int (*)(const char *,int))((unsigned int*)new_open_ptr) )(pathname,flags);\
|
||||||
|
}\
|
||||||
|
int __real_close(int fd);\
|
||||||
|
int __wrap_close(int fd){\
|
||||||
|
if(new_close_ptr == NULL) return __real_close(fd); \
|
||||||
|
return ( (int (*)(int))((unsigned int*)new_close_ptr) )(fd);\
|
||||||
|
}\
|
||||||
|
ssize_t __real_write(int fd, const void *buf, size_t count);\
|
||||||
|
ssize_t __wrap_write(int fd, const void *buf, size_t count){\
|
||||||
|
if(new_write_ptr == NULL) return __real_write(fd,buf,count); \
|
||||||
|
return ( (ssize_t (*)(int, const void *, size_t))((unsigned int*)new_write_ptr) )(fd,buf,count);\
|
||||||
|
}\
|
||||||
|
ssize_t __real_read(int fd, const void *buf, size_t count);\
|
||||||
|
ssize_t __wrap_read(int fd, const void *buf, size_t count){\
|
||||||
|
if(new_read_ptr == NULL) return __real_read(fd,buf,count); \
|
||||||
|
return ( (ssize_t (*)(int, const void *, size_t))((unsigned int*)new_read_ptr) )(fd,buf,count);\
|
||||||
|
}\
|
||||||
|
off_t __real_lseek(int fd, off_t offset, int whence);\
|
||||||
|
off_t __wrap_lseek(int fd, off_t offset, int whence){\
|
||||||
|
if(new_lseek_ptr == NULL) return __real_lseek(fd, offset, whence); \
|
||||||
|
return ( (off_t (*)(int, off_t, int))((unsigned int*)new_lseek_ptr) )(fd, offset, whence);\
|
||||||
|
}\
|
||||||
|
int __real_stat(const char *pathname, struct stat *statbuf);\
|
||||||
|
int __wrap_stat(const char *pathname, struct stat *statbuf){\
|
||||||
|
if(new_stat_ptr == NULL) return __real_stat(pathname,statbuf); \
|
||||||
|
return ( (int (*)(const char *, struct stat *))((unsigned int*)new_stat_ptr) )(pathname,statbuf);\
|
||||||
|
}\
|
||||||
|
int __real_fstat(int fd, struct stat *statbuf);\
|
||||||
|
int __wrap_fstat(int fd, struct stat *statbuf){\
|
||||||
|
if(new_fstat_ptr == NULL) return __real_fstat(fd,statbuf); \
|
||||||
|
return ( (int (*)(int, struct stat *))((unsigned int*)new_fstat_ptr) )(fd,statbuf);\
|
||||||
|
}\
|
||||||
|
DIR* __real_opendir(const char * arg);\
|
||||||
|
DIR* __wrap_opendir(const char * arg){\
|
||||||
|
if(new_opendir_ptr == NULL) return __real_opendir(arg); \
|
||||||
|
return ( (DIR* (*)(const char *))((unsigned int*)new_opendir_ptr) )(arg);\
|
||||||
|
}\
|
||||||
|
int __real_closedir(DIR *dirp);\
|
||||||
|
int __wrap_closedir(DIR *dirp){\
|
||||||
|
if(new_closedir_ptr == NULL) return __real_closedir(dirp); \
|
||||||
|
return ( (int (*)(DIR *))((unsigned int*)new_closedir_ptr) )(dirp);\
|
||||||
|
}\
|
||||||
|
struct dirent * __real_readdir(DIR *dirp);\
|
||||||
|
struct dirent * __wrap_readdir(DIR *dirp){\
|
||||||
|
if(new_readdir_ptr == NULL) return __real_readdir(dirp); \
|
||||||
|
return ( (struct dirent * (*)(DIR *))((unsigned int*)new_readdir_ptr) )(dirp);\
|
||||||
|
}\
|
||||||
|
\
|
||||||
|
EXTERN_C_END\
|
||||||
|
void myInit(wups_loader_init_args_t* my_args)
|
||||||
|
|
||||||
typedef enum wups_loader_entry_type_t {
|
typedef enum wups_loader_entry_type_t {
|
||||||
WUPS_LOADER_ENTRY_FUNCTION,
|
WUPS_LOADER_ENTRY_FUNCTION,
|
||||||
|
Loading…
Reference in New Issue
Block a user