diff --git a/Makefile b/Makefile index 8320bc7..986ba6b 100644 --- a/Makefile +++ b/Makefile @@ -56,7 +56,7 @@ MAKEFLAGS += --no-print-directory #--------------------------------------------------------------------------------- # any extra libraries we wish to link with the project #--------------------------------------------------------------------------------- -LIBS := -lgcc -lgd -lpng -lz -lfreetype -lvorbisidec -liosuhax +LIBS := -lgcc -lgd -lpng -lz -lfreetype -lvorbisidec -liosuhax -lfat #--------------------------------------------------------------------------------- # list of directories containing libraries, this must be the top level containing @@ -114,8 +114,8 @@ export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ #--------------------------------------------------------------------------------- # build a list of library paths #--------------------------------------------------------------------------------- -export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \ - -L$(LIBOGC_LIB) -L$(PORTLIBS)/lib +export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \ + -L$(PORTLIBS)/lib -L$(LIBOGC_LIB) export OUTPUT := $(CURDIR)/$(TARGET) .PHONY: $(BUILD) clean install diff --git a/dumpling.png b/dumpling.png new file mode 100644 index 0000000..29f11b5 Binary files /dev/null and b/dumpling.png differ diff --git a/meta/meta.xml b/meta/meta.xml index ef4f228..08312b0 100644 --- a/meta/meta.xml +++ b/meta/meta.xml @@ -2,7 +2,7 @@ dumpling emiyl - 0.2.1 + 0.3.0 20200411200000 Simple Cemu File Dumper Simple Cemu File Dumper diff --git a/src/dynamic_libs/ax_functions.c b/src/dynamic_libs/ax_functions.c index d84d6f8..815ec7b 100644 --- a/src/dynamic_libs/ax_functions.c +++ b/src/dynamic_libs/ax_functions.c @@ -71,4 +71,3 @@ void InitAXFunctionPointers(void) OS_FIND_EXPORT(sound_handle, AXSetVoiceEndOffset); OS_FIND_EXPORT(sound_handle, AXSetVoiceLoopOffset); } - diff --git a/src/dynamic_libs/os_functions.c b/src/dynamic_libs/os_functions.c index 143db91..2f2b457 100644 --- a/src/dynamic_libs/os_functions.c +++ b/src/dynamic_libs/os_functions.c @@ -24,7 +24,7 @@ #include "common/common.h" #include "os_functions.h" -unsigned int coreinit_handle __attribute__((section(".data"))) = 0; +unsigned int coreinit_handle = 0; //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- //! Lib handle functions @@ -32,12 +32,6 @@ unsigned int coreinit_handle __attribute__((section(".data"))) = 0; EXPORT_DECL(int, OSDynLoad_Acquire, const char* rpl, u32 *handle); EXPORT_DECL(int, OSDynLoad_FindExport, u32 handle, int isdata, const char *symbol, void *address); -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -//! Security functions -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -EXPORT_DECL(int, OSGetSecurityLevel, void); -EXPORT_DECL(int, OSForceFullRelaunch, void); - //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- //! Thread functions //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -53,7 +47,6 @@ EXPORT_DECL(void, OSSleepTicks, u64 ticks); EXPORT_DECL(u64, OSGetTick, void); EXPORT_DECL(u64, OSGetTime, void); - //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- //! Mutex functions //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -66,7 +59,6 @@ EXPORT_DECL(int, OSTryLockMutex, void* mutex); //! System functions //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- EXPORT_DECL(u64, OSGetTitleID, void); -EXPORT_DECL(void, OSGetArgcArgv, int* argc, char*** argv); EXPORT_DECL(void, __Exit, void); EXPORT_DECL(void, OSFatal, const char* msg); EXPORT_DECL(void, OSSetExceptionCallback, u8 exceptionType, exception_callback newCallback); @@ -74,7 +66,6 @@ EXPORT_DECL(void, DCFlushRange, const void *addr, u32 length); EXPORT_DECL(void, ICInvalidateRange, const void *addr, u32 length); EXPORT_DECL(void*, OSEffectiveToPhysical, const void*); EXPORT_DECL(int, __os_snprintf, char* s, int n, const char * format, ...); -EXPORT_DECL(int *, __gh_errno_ptr, void); EXPORT_DECL(void, OSScreenInit, void); EXPORT_DECL(unsigned int, OSScreenGetBufferSizeEx, unsigned int bufferNum); @@ -84,6 +75,11 @@ EXPORT_DECL(int, OSScreenFlipBuffersEx, unsigned int bufferNum); EXPORT_DECL(int, OSScreenPutFontEx, unsigned int bufferNum, unsigned int posX, unsigned int posY, const char * buffer); EXPORT_DECL(int, OSScreenEnableEx, unsigned int bufferNum, int enable); +EXPORT_DECL(int, IOS_Ioctl,int fd, unsigned int request, void *input_buffer,unsigned int input_buffer_len, void *output_buffer, unsigned int output_buffer_len); +EXPORT_DECL(int, IOS_IoctlAsync,int fd, unsigned int request, void *input_buffer,unsigned int input_buffer_len, void *output_buffer, unsigned int output_buffer_len, void *cb, void *cbarg); +EXPORT_DECL(int, IOS_Open,char *path, unsigned int mode); +EXPORT_DECL(int, IOS_Close,int fd); + //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- //! Memory functions //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -105,70 +101,34 @@ EXPORT_DECL(void, MEMFreeToExpHeap, int heap, void* ptr); //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- EXPORT_DECL(int, MCP_Open, void); EXPORT_DECL(int, MCP_Close, int handle); -EXPORT_DECL(int, MCP_GetOwnTitleInfo, int handle, void * data); - -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -//! Kernel function addresses -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -EXPORT_DECL(void, addr_PrepareTitle_hook, void); - -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -//! Other function addresses -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -EXPORT_DECL(void, DCInvalidateRange, void *buffer, uint32_t length); //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -//! Energy Saver functions +//! Loader functions (not real rpl) //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -//Burn-in Reduction -EXPORT_DECL(int, IMEnableDim,void); -EXPORT_DECL(int, IMDisableDim,void); -EXPORT_DECL(int, IMIsDimEnabled,int * result); -//Auto power down -EXPORT_DECL(int, IMEnableAPD,void); -EXPORT_DECL(int, IMDisableAPD,void); -EXPORT_DECL(int, IMIsAPDEnabled,int * result); -EXPORT_DECL(int, IMIsAPDEnabledBySysSettings,int * result); +EXPORT_DECL(int, LiWaitIopComplete, int unknown_syscall_arg_r3, int * remaining_bytes); +EXPORT_DECL(int, LiWaitIopCompleteWithInterrupts, int unknown_syscall_arg_r3, int * remaining_bytes); - -EXPORT_DECL(int, IOS_Ioctl,int fd, unsigned int request, void *input_buffer,unsigned int input_buffer_len, void *output_buffer, unsigned int output_buffer_len); -EXPORT_DECL(int, IOS_Open,char *path, unsigned int mode); -EXPORT_DECL(int, IOS_Close,int fd); -void InitAcquireOS(void) +void InitOSFunctionPointers(void) { - //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + unsigned int *funcPointer = 0; + //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- //! Lib handle functions //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- EXPORT_FUNC_WRITE(OSDynLoad_Acquire, (int (*)(const char*, unsigned *))OS_SPECIFICS->addr_OSDynLoad_Acquire); EXPORT_FUNC_WRITE(OSDynLoad_FindExport, (int (*)(u32, int, const char *, void *))OS_SPECIFICS->addr_OSDynLoad_FindExport); OSDynLoad_Acquire("coreinit.rpl", &coreinit_handle); -} - -void InitOSFunctionPointers(void) -{ - unsigned int *funcPointer = 0; - - InitAcquireOS(); - //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - //! Security functions - //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - OS_FIND_EXPORT(coreinit_handle, OSGetSecurityLevel); - OS_FIND_EXPORT(coreinit_handle, OSForceFullRelaunch); //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- //! System functions //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- OS_FIND_EXPORT(coreinit_handle, OSFatal); OS_FIND_EXPORT(coreinit_handle, OSGetTitleID); - OS_FIND_EXPORT(coreinit_handle, OSGetArgcArgv); OS_FIND_EXPORT(coreinit_handle, OSSetExceptionCallback); OS_FIND_EXPORT(coreinit_handle, DCFlushRange); OS_FIND_EXPORT(coreinit_handle, ICInvalidateRange); OS_FIND_EXPORT(coreinit_handle, OSEffectiveToPhysical); OS_FIND_EXPORT(coreinit_handle, __os_snprintf); - OS_FIND_EXPORT(coreinit_handle, __gh_errno_ptr); - OSDynLoad_FindExport(coreinit_handle, 0, "_Exit", &__Exit); OS_FIND_EXPORT(coreinit_handle, OSScreenInit); @@ -192,7 +152,6 @@ void InitOSFunctionPointers(void) OS_FIND_EXPORT(coreinit_handle, OSSleepTicks); OS_FIND_EXPORT(coreinit_handle, OSGetTick); OS_FIND_EXPORT(coreinit_handle, OSGetTime); - //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- //! Mutex functions //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -205,7 +164,6 @@ void InitOSFunctionPointers(void) //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- OS_FIND_EXPORT(coreinit_handle, MCP_Open); OS_FIND_EXPORT(coreinit_handle, MCP_Close); - OS_FIND_EXPORT(coreinit_handle, MCP_GetOwnTitleInfo); //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- //! Memory functions @@ -226,22 +184,8 @@ void InitOSFunctionPointers(void) //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- //! Other function addresses //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - OS_FIND_EXPORT(coreinit_handle, DCInvalidateRange); - - //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - //! Energy Saver functions - //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - //Burn-in Reduction - OS_FIND_EXPORT(coreinit_handle, IMEnableDim); - OS_FIND_EXPORT(coreinit_handle, IMDisableDim); - OS_FIND_EXPORT(coreinit_handle, IMIsDimEnabled); - //Auto power down - OS_FIND_EXPORT(coreinit_handle, IMEnableAPD); - OS_FIND_EXPORT(coreinit_handle, IMDisableAPD); - OS_FIND_EXPORT(coreinit_handle, IMIsAPDEnabled); - OS_FIND_EXPORT(coreinit_handle, IMIsAPDEnabledBySysSettings); - OS_FIND_EXPORT(coreinit_handle, IOS_Ioctl); + OS_FIND_EXPORT(coreinit_handle, IOS_IoctlAsync); OS_FIND_EXPORT(coreinit_handle, IOS_Open); OS_FIND_EXPORT(coreinit_handle, IOS_Close); } diff --git a/src/dynamic_libs/os_functions.h b/src/dynamic_libs/os_functions.h index 02b27cd..9c36643 100644 --- a/src/dynamic_libs/os_functions.h +++ b/src/dynamic_libs/os_functions.h @@ -66,7 +66,6 @@ extern "C" { /* Handle for coreinit */ extern unsigned int coreinit_handle; void InitOSFunctionPointers(void); -void InitAcquireOS(void); //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- //! Lib handle functions @@ -74,12 +73,6 @@ void InitAcquireOS(void); extern int (* OSDynLoad_Acquire)(const char* rpl, u32 *handle); extern int (* OSDynLoad_FindExport)(u32 handle, int isdata, const char *symbol, void *address); -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -//! Security functions -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -extern int (* OSGetSecurityLevel)(void); -extern int (* OSForceFullRelaunch)(void); - //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- //! Thread functions //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -103,18 +96,26 @@ extern void (* OSLockMutex)(void* mutex); extern void (* OSUnlockMutex)(void* mutex); extern int (* OSTryLockMutex)(void* mutex); +//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +//! MCP functions +//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +extern int (* MCP_Open)(void); +extern int (* MCP_Close)(int handle); + //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- //! System functions //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- extern u64 (* OSGetTitleID)(void); -extern void (* OSGetArgcArgv)(int* argc, char*** argv); extern void (* __Exit)(void); extern void (* OSFatal)(const char* msg); extern void (* DCFlushRange)(const void *addr, u32 length); extern void (* ICInvalidateRange)(const void *addr, u32 length); extern void* (* OSEffectiveToPhysical)(const void*); extern int (* __os_snprintf)(char* s, int n, const char * format, ...); -extern int * (* __gh_errno_ptr)(void); +extern int (*IOS_Ioctl)(int fd, unsigned int request, void *input_buffer,unsigned int input_buffer_len, void *output_buffer, unsigned int output_buffer_len); +extern int (*IOS_IoctlAsync)(int fd, unsigned int request, void *input_buffer,unsigned int input_buffer_len, void *output_buffer, unsigned int output_buffer_len, void *cb, void *cbarg); +extern int (*IOS_Open)(char *path, unsigned int mode); +extern int (*IOS_Close)(int fd); extern void (*OSScreenInit)(void); extern unsigned int (*OSScreenGetBufferSizeEx)(unsigned int bufferNum); @@ -127,34 +128,9 @@ extern int (*OSScreenEnableEx)(unsigned int bufferNum, int enable); typedef unsigned char (*exception_callback)(void * interruptedContext); extern void (* OSSetExceptionCallback)(u8 exceptionType, exception_callback newCallback); -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -//! MCP functions -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -extern int (* MCP_Open)(void); -extern int (* MCP_Close)(int handle); -extern int (* MCP_GetOwnTitleInfo)(int handle, void * data); - -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -//! Other function addresses -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -extern void (*DCInvalidateRange)(void *buffer, uint32_t length); +extern int (* LiWaitIopComplete)(int unknown_syscall_arg_r3, int * remaining_bytes); +extern int (* LiWaitIopCompleteWithInterrupts)(int unknown_syscall_arg_r3, int * remaining_bytes); -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -//! Energy Saver functions -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -////Burn-in Reduction -extern int (*IMEnableDim)(void); -extern int (*IMDisableDim)(void); -extern int (*IMIsDimEnabled)(int * result); -//Auto power down -extern int (*IMEnableAPD)(void); -extern int (*IMDisableAPD)(void); -extern int (*IMIsAPDEnabled)(int * result); -extern int (*IMIsAPDEnabledBySysSettings)(int * result); - -extern int (*IOS_Ioctl)(int fd, unsigned int request, void *input_buffer,unsigned int input_buffer_len, void *output_buffer, unsigned int output_buffer_len); -extern int (*IOS_Open)(char *path, unsigned int mode); -extern int (*IOS_Close)(int fd); #ifdef __cplusplus } diff --git a/src/fs/fs_utils.c b/src/fs/fs_utils.c index efa2e55..613cec6 100644 --- a/src/fs/fs_utils.c +++ b/src/fs/fs_utils.c @@ -95,9 +95,9 @@ int LoadFileToMem(const char *filepath, u8 **inbuffer, u32 *size) *inbuffer = buffer; //! sign is optional input - if(size) + if(size) { *size = filesize; - + } return filesize; } diff --git a/src/main.c b/src/main.c index 8ef445f..02f8d1b 100644 --- a/src/main.c +++ b/src/main.c @@ -3,23 +3,26 @@ #include #include #include +#include #include "dynamic_libs/os_functions.h" #include "dynamic_libs/fs_functions.h" -#include "dynamic_libs/gx2_functions.h" -#include "dynamic_libs/sys_functions.h" -#include "dynamic_libs/vpad_functions.h" -#include "dynamic_libs/padscore_functions.h" -#include "dynamic_libs/socket_functions.h" -#include "dynamic_libs/ax_functions.h" +#include +#include +#include +#include +#include +#include #include "fs/fs_utils.h" #include "fs/sd_fat_devoptab.h" -#include #include +#include +#include #include "system/memory.h" #include "utils/logger.h" #include "utils/utils.h" #include "common/common.h" #include "sd_dumper.h" +#include "virtualpath.h" #define MAX_CONSOLE_LINES_TV 27 #define MAX_CONSOLE_LINES_DRC 18 @@ -127,7 +130,7 @@ void console_printf(int newline, const char *format, ...) return 0; }*/ -int dump_func(const char *mount_path, int selectedItem, int fsaFd, int initScreen, int dump_source) +int dump_func(const char *mount_path, int selectedItem, int fsaFd, int initScreen, int dump_source, int dump_target) { int res = mount_fs("dev", fsaFd, NULL, mount_path); if(res < 0) @@ -141,20 +144,15 @@ int dump_func(const char *mount_path, int selectedItem, int fsaFd, int initScree { strcpy(targetPath, "dev:/"); char sdPath[255] = "sd:/dumpling"; - if (dump_source) { - if (selectedItem == 0) strcpy(sdPath, "sd:/dumpling/games"); - if (selectedItem == 1) strcpy(sdPath, "sd:/dumpling/updates"); - if (selectedItem == 2) strcpy(sdPath, "sd:/dumpling/dlc"); - if (selectedItem == 3) strcpy(sdPath, "sd:/dumpling/saves"); - } else { - if (selectedItem == 0) snprintf(sdPath, sizeof(sdPath), "sd:/dumpling/online_files/%s", mount_path + 13); - if (selectedItem == 1) strcpy(sdPath, "sd:/dumpling/friends_list"); - if (selectedItem == 2) strcpy(sdPath, "sd:/dumpling/games"); - if (selectedItem == 3) strcpy(sdPath, "sd:/dumpling/updates"); - if (selectedItem == 4) strcpy(sdPath, "sd:/dumpling/dlc"); - if (selectedItem == 5) strcpy(sdPath, "sd:/dumpling/saves"); - if (selectedItem == 6) strcpy(sdPath, "sd:/dumpling/nand"); - } + char dumpTo[127] = "dumps"; + if (!dump_source && (selectedItem == 0)) snprintf(dumpTo, sizeof(dumpTo), "online_files/%s", mount_path + 13); + if (!dump_source && (selectedItem == 1)) strcpy(dumpTo, "friends_list"); + if ((!dump_source && (selectedItem == 2)) | (dump_source && (selectedItem == 0))) strcpy(dumpTo, "games"); + if ((!dump_source && (selectedItem == 3)) | (dump_source && (selectedItem == 1))) strcpy(dumpTo, "updates"); + if ((!dump_source && (selectedItem == 4)) | (dump_source && (selectedItem == 2))) strcpy(dumpTo, "dlc"); + if ((!dump_source && (selectedItem == 5)) | (dump_source && (selectedItem == 3))) strcpy(dumpTo, "saves"); + if (!dump_source && (selectedItem == 6)) strcpy(dumpTo, "nand"); + snprintf(sdPath, sizeof(sdPath), "%s:/dumpling/%s", (dump_target) ? "usb" : "sd", dumpTo); DumpDir(targetPath, sdPath); free(targetPath); @@ -167,6 +165,43 @@ int dump_func(const char *mount_path, int selectedItem, int fsaFd, int initScree return initScreen; } +//just to be able to call async +void someFunc(void *arg) +{ + (void)arg; +} + +static int mcp_hook_fd = -1; +int MCPHookOpen() +{ + //take over mcp thread + mcp_hook_fd = MCP_Open(); + if(mcp_hook_fd < 0) + return -1; + IOS_IoctlAsync(mcp_hook_fd, 0x62, (void*)0, 0, (void*)0, 0, someFunc, (void*)0); + //let wupserver start up + sleep(1); + if(IOSUHAX_Open("/dev/mcp") < 0) + { + MCP_Close(mcp_hook_fd); + mcp_hook_fd = -1; + return -1; + } + return 0; +} + +void MCPHookClose() +{ + if(mcp_hook_fd < 0) + return; + //close down wupserver, return control to mcp + IOSUHAX_Close(); + //wait for mcp to return + sleep(1); + MCP_Close(mcp_hook_fd); + mcp_hook_fd = -1; +} + /* Entry point */ int Menu_Main(void) { @@ -226,21 +261,49 @@ int Menu_Main(void) OSScreenFlipBuffersEx(0); OSScreenFlipBuffersEx(1); - int res = IOSUHAX_Open(NULL); - if(res < 0) - { - console_printf(1, "IOSUHAX_open failed - Ensure you are using MochaCFW\n"); - sleep(2); - return 0; - } + int fsaFd = -1; + int iosuhaxMount = 0; - int fsaFd = IOSUHAX_FSA_Open(); - if(fsaFd < 0) - { - console_printf(1, "IOSUHAX_FSA_Open failed\n"); + int res = IOSUHAX_Open(NULL); + if(res < 0) + res = MCPHookOpen(); + if(res < 0) + { + log_printf("IOSUHAX_open failed\nEnsure you are using MochaCFW\n"); sleep(2); - return 0; - } + return 0; + } + else + { + iosuhaxMount = 1; + fatInitDefault(); + + fsaFd = IOSUHAX_FSA_Open(); + if(fsaFd < 0) + { + log_printf("IOSUHAX_FSA_Open failed\n"); + } + + //mount_fs("slccmpt01", fsaFd, "/dev/slccmpt01", "/vol/storage_slccmpt01"); + //mount_fs("storage_odd_tickets", fsaFd, "/dev/odd01", "/vol/storage_odd_tickets"); + //mount_fs("storage_odd_updates", fsaFd, "/dev/odd02", "/vol/storage_odd_updates"); + //mount_fs("storage_odd_content", fsaFd, "/dev/odd03", "/vol/storage_odd_content"); + //mount_fs("storage_odd_content2", fsaFd, "/dev/odd04", "/vol/storage_odd_content2"); + //mount_fs("storage_slc", fsaFd, NULL, "/vol/system"); + //mount_fs("storage_mlc", fsaFd, NULL, "/vol/storage_mlc01"); + //mount_fs("storage_usb", fsaFd, NULL, "/vol/storage_usb01"); + + VirtualMountDevice("sd:/"); + //VirtualMountDevice("slccmpt01:/"); + //VirtualMountDevice("storage_odd_tickets:/"); + //VirtualMountDevice("storage_odd_updates:/"); + //VirtualMountDevice("storage_odd_content:/"); + //VirtualMountDevice("storage_odd_content2:/"); + //VirtualMountDevice("storage_slc:/"); + //VirtualMountDevice("storage_mlc:/"); + //VirtualMountDevice("storage_usb:/"); + VirtualMountDevice("usb:/"); + } int vpadError = -1; VPADData vpad; @@ -288,7 +351,7 @@ int Menu_Main(void) int selectedItem = 0; int dump_source = 0; - //int dump_target = 0; + int dump_target = 0; while(1) { @@ -319,12 +382,11 @@ int Menu_Main(void) OSScreenClearBufferEx(1, 0); - console_print_pos(0, 1, "-- Dumpling v0.2.2 by emiyl --"); - console_print_pos(0, 2, "Source: %s", (dump_source) ? "USB" : "MLC"); - //console_print_pos(0, 2, "Target: %s", (dump_target) ? "USB" : "SD"); + console_print_pos(0, 1, "-- Dumpling v0.3.0 by emiyl --"); + console_print_pos(0, 2, "Source: %s // Target: %s", (dump_source) ? "USB" : "MLC", (dump_target) ? "USB" : "SD"); - console_print_pos(0, 4, "Select what to dump to SD card and press A to start dump."); - console_print_pos(0, 5, "Use L/R to change source.");// and ZL/ZR to change target."); + console_print_pos(0, 4, "Select what to dump to USB storage and press A to start dump."); + console_print_pos(0, 5, "Use L/R to change source and ZL/ZR to change target."); u32 i; for(i = 0; i < (((dump_source) ? sizeof(usb_selection_paths) : sizeof(mlc_selection_paths)) / 4); i++) @@ -378,19 +440,34 @@ int Menu_Main(void) usleep(200000); } + if(vpadError == 0 && ((vpad.btns_d | vpad.btns_h) & (VPAD_BUTTON_ZL))) + { + dump_target = !dump_target; + initScreen = 1; + usleep(200000); + } + + if(vpadError == 0 && ((vpad.btns_d | vpad.btns_h) & (VPAD_BUTTON_ZR))) + { + dump_target = !dump_target; + initScreen = 1; + usleep(200000); + } + if(vpadError == 0 && ((vpad.btns_d | vpad.btns_h) & VPAD_BUTTON_A)) { - if (dump_source | (selectedItem > 1)) initScreen = dump_func(((dump_source) ? usb_selection_paths : mlc_selection_paths)[selectedItem], selectedItem, fsaFd, initScreen, dump_source); + if (dump_source | (selectedItem > 1)) + initScreen = dump_func(((dump_source) ? usb_selection_paths : mlc_selection_paths)[selectedItem], selectedItem, fsaFd, initScreen, dump_source, dump_target); else if (selectedItem == 0) { - initScreen = dump_func("/vol/storage_mlc01/usr/save/system/act/" , selectedItem, fsaFd, initScreen, dump_source); // account.dat - initScreen = dump_func("/vol/storage_mlc01/sys/title/0005001b/10054000/content/ccerts", selectedItem, fsaFd, initScreen, dump_source); // ccerts - initScreen = dump_func("/vol/storage_mlc01/sys/title/0005001b/10054000/content/scerts", selectedItem, fsaFd, initScreen, dump_source); // scerts - initScreen = dump_func("/vol/storage_mlc01/sys/title/0005001b/10056000/" , selectedItem, fsaFd, initScreen, dump_source); // mii data + initScreen = dump_func("/vol/storage_mlc01/usr/save/system/act/" , selectedItem, fsaFd, initScreen, dump_source, dump_target); // account.dat + initScreen = dump_func("/vol/storage_mlc01/sys/title/0005001b/10054000/content/ccerts", selectedItem, fsaFd, initScreen, dump_source, dump_target); // ccerts + initScreen = dump_func("/vol/storage_mlc01/sys/title/0005001b/10054000/content/scerts", selectedItem, fsaFd, initScreen, dump_source, dump_target); // scerts + initScreen = dump_func("/vol/storage_mlc01/sys/title/0005001b/10056000/" , selectedItem, fsaFd, initScreen, dump_source, dump_target); // mii data } else if (selectedItem == 1) { - initScreen = dump_func("/vol/storage_mlc01/sys/title/00050030/1001500A/", selectedItem, fsaFd, initScreen, dump_source); // JP friends list - initScreen = dump_func("/vol/storage_mlc01/sys/title/00050030/1001510A/", selectedItem, fsaFd, initScreen, dump_source); // US friends list - initScreen = dump_func("/vol/storage_mlc01/sys/title/00050030/1001520A/", selectedItem, fsaFd, initScreen, dump_source); // EU friends list + initScreen = dump_func("/vol/storage_mlc01/sys/title/00050030/1001500A/", selectedItem, fsaFd, initScreen, dump_source, dump_target); // JP friends list + initScreen = dump_func("/vol/storage_mlc01/sys/title/00050030/1001510A/", selectedItem, fsaFd, initScreen, dump_source, dump_target); // US friends list + initScreen = dump_func("/vol/storage_mlc01/sys/title/00050030/1001520A/", selectedItem, fsaFd, initScreen, dump_source, dump_target); // EU friends list console_printf(1, "Dump complete"); sleep(1); } @@ -422,7 +499,33 @@ int Menu_Main(void) //!******************************************************************* log_printf("Unmount SD\n"); - unmount_sd_fat("sd"); + if(iosuhaxMount) + { + fatUnmount("sd"); + fatUnmount("usb"); + IOSUHAX_sdio_disc_interface.shutdown(); + IOSUHAX_usb_disc_interface.shutdown(); + + /*unmount_fs("slccmpt01"); + unmount_fs("storage_odd_tickets"); + unmount_fs("storage_odd_updates"); + unmount_fs("storage_odd_content"); + unmount_fs("storage_odd_content2"); + unmount_fs("storage_slc"); + unmount_fs("storage_mlc"); + unmount_fs("storage_usb");*/ + IOSUHAX_FSA_Close(fsaFd); + if(mcp_hook_fd >= 0) + MCPHookClose(); + else + IOSUHAX_Close(); + } + else + { + unmount_sd_fat("sd:/"); + } + + UnmountVirtualPaths(); IOSUHAX_FSA_Close(fsaFd); IOSUHAX_Close(); diff --git a/src/sd_dumper.c b/src/sd_dumper.c index 84ca822..d9d123c 100644 --- a/src/sd_dumper.c +++ b/src/sd_dumper.c @@ -60,7 +60,7 @@ static int DumpFile(char *pPath, const char * output_path) FILE *pWriteFile = fopen(output_path, "wb"); if(!pWriteFile) { - if (detailed_logs) console_printf(1, "Can't open write file %s\n", output_path); + console_printf(1, "Can't open write file %s\n", output_path); fclose(pReadFile); return -3; } diff --git a/src/virtualpath.c b/src/virtualpath.c new file mode 100644 index 0000000..e1b6aec --- /dev/null +++ b/src/virtualpath.c @@ -0,0 +1,125 @@ +/**************************************************************************** +* Copyright (C) 2008 +* Joseph Jordan +* +* Copyright (C) 2010 +* by Dimok +* +* This software is provided 'as-is', without any express or implied +* warranty. In no event will the authors be held liable for any +* damages arising from the use of this software. +* +* Permission is granted to anyone to use this software for any +* purpose, including commercial applications, and to alter it and +* redistribute it freely, subject to the following restrictions: +* +* 1. The origin of this software must not be misrepresented; you +* must not claim that you wrote the original software. If you use +* this software in a product, an acknowledgment in the product +* documentation would be appreciated but is not required. +* +* 2. Altered source versions must be plainly marked as such, and +* must not be misrepresented as being the original software. +* +* 3. This notice may not be removed or altered from any source +* distribution. +* +* for WiiXplorer 2010 +***************************************************************************/ +#include +#include +#include "virtualpath.h" + +u8 MAX_VIRTUAL_PARTITIONS = 0; +VIRTUAL_PARTITION * VIRTUAL_PARTITIONS = NULL; + +void VirtualMountDevice(const char * path) +{ + if(!path) + return; + + int i = 0; + char name[255]; + char alias[255]; + char prefix[255]; + bool namestop = false; + + alias[0] = '/'; + + do + { + if(path[i] == ':') + namestop = true; + + if(!namestop) + { + name[i] = path[i]; + name[i+1] = '\0'; + alias[i+1] = path[i]; + alias[i+2] = '\0'; + } + + prefix[i] = path[i]; + prefix[i+1] = '\0'; + i++; + } + while(path[i-1] != '/'); + + AddVirtualPath(name, alias, prefix); +} + +void AddVirtualPath(const char *name, const char *alias, const char *prefix) +{ + if(!VIRTUAL_PARTITIONS) + VIRTUAL_PARTITIONS = (VIRTUAL_PARTITION *) malloc(sizeof(VIRTUAL_PARTITION)); + + VIRTUAL_PARTITION * tmp = realloc(VIRTUAL_PARTITIONS, sizeof(VIRTUAL_PARTITION)*(MAX_VIRTUAL_PARTITIONS+1)); + if(!tmp) + { + free(VIRTUAL_PARTITIONS); + MAX_VIRTUAL_PARTITIONS = 0; + return; + } + + VIRTUAL_PARTITIONS = tmp; + + VIRTUAL_PARTITIONS[MAX_VIRTUAL_PARTITIONS].name = strdup(name); + VIRTUAL_PARTITIONS[MAX_VIRTUAL_PARTITIONS].alias = strdup(alias); + VIRTUAL_PARTITIONS[MAX_VIRTUAL_PARTITIONS].prefix = strdup(prefix); + VIRTUAL_PARTITIONS[MAX_VIRTUAL_PARTITIONS].inserted = true; + + MAX_VIRTUAL_PARTITIONS++; +} + +void MountVirtualDevices() +{ + VirtualMountDevice("sd:/"); + VirtualMountDevice("slccmpt01:/"); + VirtualMountDevice("storage_odd_tickets:/"); + VirtualMountDevice("storage_odd_updates:/"); + VirtualMountDevice("storage_odd_content:/"); + VirtualMountDevice("storage_odd_content2:/"); + VirtualMountDevice("storage_slc:/"); + VirtualMountDevice("storage_mlc:/"); + VirtualMountDevice("storage_usb:/"); + VirtualMountDevice("usb:/"); +} + +void UnmountVirtualPaths() +{ + u32 i = 0; + for(i = 0; i < MAX_VIRTUAL_PARTITIONS; i++) + { + if(VIRTUAL_PARTITIONS[i].name) + free(VIRTUAL_PARTITIONS[i].name); + if(VIRTUAL_PARTITIONS[i].alias) + free(VIRTUAL_PARTITIONS[i].alias); + if(VIRTUAL_PARTITIONS[i].prefix) + free(VIRTUAL_PARTITIONS[i].prefix); + } + + if(VIRTUAL_PARTITIONS) + free(VIRTUAL_PARTITIONS); + VIRTUAL_PARTITIONS = NULL; + MAX_VIRTUAL_PARTITIONS = 0; +} diff --git a/src/virtualpath.h b/src/virtualpath.h new file mode 100644 index 0000000..12464a2 --- /dev/null +++ b/src/virtualpath.h @@ -0,0 +1,58 @@ +/**************************************************************************** +* Copyright (C) 2010 +* by Dimok +* +* Original VIRTUAL_PART Struct +* Copyright (C) 2008 +* Joseph Jordan +* +* This software is provided 'as-is', without any express or implied +* warranty. In no event will the authors be held liable for any +* damages arising from the use of this software. +* +* Permission is granted to anyone to use this software for any +* purpose, including commercial applications, and to alter it and +* redistribute it freely, subject to the following restrictions: +* +* 1. The origin of this software must not be misrepresented; you +* must not claim that you wrote the original software. If you use +* this software in a product, an acknowledgment in the product +* documentation would be appreciated but is not required. +* +* 2. Altered source versions must be plainly marked as such, and +* must not be misrepresented as being the original software. +* +* 3. This notice may not be removed or altered from any source +* distribution. +* +* for WiiXplorer 2010 +***************************************************************************/ +#ifndef _VIRTUALPATH_H_ +#define _VIRTUALPATH_H_ + +#ifdef __cplusplus +extern "C"{ +#endif + +#include + +typedef struct { + char *name; + char *alias; + char *prefix; + bool inserted; +} VIRTUAL_PARTITION; + +extern VIRTUAL_PARTITION * VIRTUAL_PARTITIONS; +extern u8 MAX_VIRTUAL_PARTITIONS; + +void VirtualMountDevice(const char * devicepath); +void AddVirtualPath(const char *name, const char *alias, const char *prefix); +void MountVirtualDevices(); +void UnmountVirtualPaths(); + +#ifdef __cplusplus +} +#endif + +#endif /* _VIRTUALPART_H_ */