Skip to content

Commit

Permalink
Stub some SAVE function if save redirection is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
Maschell committed Dec 23, 2023
1 parent 626704d commit ab940ab
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions src/RPXLoading.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <mocha/mocha.h>
#include <mutex>
#include <nn/acp/title.h>
#include <nn/save.h>
#include <romfs_dev.h>
#include <rpxloader/rpxloader.h>
#include <string>
Expand Down Expand Up @@ -107,13 +108,55 @@ DECL_FUNCTION(void, _SYSLaunchTitleWithStdArgsInNoSplash, uint64_t titleId, void
real__SYSLaunchTitleWithStdArgsInNoSplash(titleId, u1);
}

DECL_FUNCTION(SAVEStatus, SAVEInitSaveDir, uint8_t slotNo) {
if (saveLayerHandle != 0) {
return SAVE_STATUS_OK;
}
return real_SAVEInitSaveDir(slotNo);
}

DECL_FUNCTION(SAVEStatus, SAVEInitCommonSaveDir) {
if (saveLayerHandle != 0) {
return SAVE_STATUS_OK;
}
return real_SAVEInitCommonSaveDir();
}

DECL_FUNCTION(SAVEStatus, SAVEInitAccountSaveDir, uint8_t slotNo) {
if (saveLayerHandle != 0) {
return SAVE_STATUS_OK;
}
return real_SAVEInitAccountSaveDir(slotNo);
}


DECL_FUNCTION(SAVEStatus, SAVEInitNoDeleteGroupSaveDir) {
if (saveLayerHandle != 0) {
return SAVE_STATUS_OK;
}
return real_SAVEInitNoDeleteGroupSaveDir();
}

DECL_FUNCTION(SAVEStatus, SAVEUpdateSaveDir) {
if (saveLayerHandle != 0) {
return SAVE_STATUS_OK;
}
return real_SAVEUpdateSaveDir();
}

function_replacement_data_t rpx_utils_function_replacements[] = {
REPLACE_FUNCTION_VIA_ADDRESS_FOR_PROCESS(HBM_NN_ACP_ACPGetTitleMetaXmlByDevice, 0x2E36CE44, 0x0E36CE44, FP_TARGET_PROCESS_HOME_MENU),
REPLACE_FUNCTION_FOR_PROCESS(RPX_FSOpenFile, LIBRARY_COREINIT, FSOpenFile, FP_TARGET_PROCESS_HOME_MENU),
REPLACE_FUNCTION_FOR_PROCESS(RPX_FSReadFile, LIBRARY_COREINIT, FSReadFile, FP_TARGET_PROCESS_HOME_MENU),
REPLACE_FUNCTION_FOR_PROCESS(RPX_FSCloseFile, LIBRARY_COREINIT, FSCloseFile, FP_TARGET_PROCESS_HOME_MENU),
REPLACE_FUNCTION(OSRestartGame, LIBRARY_COREINIT, OSRestartGame),
REPLACE_FUNCTION(_SYSLaunchTitleWithStdArgsInNoSplash, LIBRARY_SYSAPP, _SYSLaunchTitleWithStdArgsInNoSplash),

REPLACE_FUNCTION(SAVEInitSaveDir, LIBRARY_NN_SAVE, SAVEInitSaveDir),
REPLACE_FUNCTION(SAVEInitCommonSaveDir, LIBRARY_NN_SAVE, SAVEInitCommonSaveDir),
REPLACE_FUNCTION(SAVEInitAccountSaveDir, LIBRARY_NN_SAVE, SAVEInitAccountSaveDir),
REPLACE_FUNCTION(SAVEInitNoDeleteGroupSaveDir, LIBRARY_NN_SAVE, SAVEInitNoDeleteGroupSaveDir),
REPLACE_FUNCTION(SAVEUpdateSaveDir, LIBRARY_NN_SAVE, SAVEUpdateSaveDir),
};

uint32_t rpx_utils_function_replacements_size = sizeof(rpx_utils_function_replacements) / sizeof(function_replacement_data_t);
Expand Down

0 comments on commit ab940ab

Please sign in to comment.