mirror of
https://github.com/wiiu-env/RPXLoadingModule.git
synced 2024-06-02 02:18:53 +02:00
Compare commits
35 Commits
RPXLoading
...
main
Author | SHA1 | Date | |
---|---|---|---|
|
5239704327 | ||
|
176b1c06c4 | ||
|
2fb721d6d5 | ||
|
a0913ed652 | ||
|
b6d28a891f | ||
|
9eed09d8bf | ||
|
bafc8b69bf | ||
|
a31646fbfe | ||
|
77c7db4ed9 | ||
|
626704d06f | ||
|
a3eb1a27a6 | ||
|
49c938e7c9 | ||
|
92df19d02e | ||
|
6850128812 | ||
|
4e8c32aaf4 | ||
|
a387ba9f1e | ||
|
63caa85ec8 | ||
|
bc3b6315c3 | ||
|
32e9a29a54 | ||
|
3acecfcae2 | ||
|
746934442c | ||
|
b396aa892a | ||
|
275eb604c6 | ||
|
8f2cbfb72e | ||
|
d50e438024 | ||
|
40688d9275 | ||
|
fe9c74708d | ||
|
3eb40b1eef | ||
|
afeb29f81b | ||
|
7ffde9961b | ||
|
ba1ea768e4 | ||
|
7ee7d4f404 | ||
|
1422cec156 | ||
|
bade403102 | ||
|
a26aa080b2 |
10
.github/dependabot.yml
vendored
Normal file
10
.github/dependabot.yml
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "docker"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
- package-ecosystem: "github-actions"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "daily"
|
42
.github/workflows/ci.yml
vendored
42
.github/workflows/ci.yml
vendored
|
@ -7,17 +7,24 @@ on:
|
|||
|
||||
jobs:
|
||||
clang-format:
|
||||
runs-on: ubuntu-18.04
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
- name: clang-format
|
||||
run: |
|
||||
docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./src
|
||||
docker run --rm -v ${PWD}:/src ghcr.io/wiiu-env/clang-format:13.0.0-2 -r ./src
|
||||
build-binary:
|
||||
runs-on: ubuntu-18.04
|
||||
runs-on: ubuntu-22.04
|
||||
needs: clang-format
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
- name: create version.h
|
||||
run: |
|
||||
git_hash=$(git rev-parse --short "$GITHUB_SHA")
|
||||
cat <<EOF > ./src/version.h
|
||||
#pragma once
|
||||
#define VERSION_EXTRA " (nightly-$git_hash)"
|
||||
EOF
|
||||
- name: build binary
|
||||
run: |
|
||||
docker build . -t builder
|
||||
|
@ -28,7 +35,7 @@ jobs:
|
|||
path: "*.wms"
|
||||
deploy-binary:
|
||||
needs: build-binary
|
||||
runs-on: ubuntu-18.04
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- name: Get environment variables
|
||||
id: get_repository_name
|
||||
|
@ -41,25 +48,12 @@ jobs:
|
|||
- name: zip artifact
|
||||
run: zip -r ${{ env.REPOSITORY_NAME }}_${{ env.DATETIME }}.zip *.wms
|
||||
- name: Create Release
|
||||
id: create_release
|
||||
uses: actions/create-release@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
uses: "softprops/action-gh-release@v2"
|
||||
with:
|
||||
tag_name: ${{ env.REPOSITORY_NAME }}-${{ env.DATETIME }}
|
||||
release_name: Nightly-${{ env.REPOSITORY_NAME }}-${{ env.DATETIME }}
|
||||
draft: false
|
||||
prerelease: true
|
||||
body: |
|
||||
Not a stable release:
|
||||
${{ github.event.head_commit.message }}
|
||||
- name: Upload Release Asset
|
||||
id: upload-release-asset
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
|
||||
asset_path: ./${{ env.REPOSITORY_NAME }}_${{ env.DATETIME }}.zip
|
||||
asset_name: ${{ env.REPOSITORY_NAME }}_${{ env.DATETIME }}.zip
|
||||
asset_content_type: application/zip
|
||||
generate_release_notes: true
|
||||
name: Nightly-${{ env.REPOSITORY_NAME }}-${{ env.DATETIME }}
|
||||
files: |
|
||||
./${{ env.REPOSITORY_NAME }}_${{ env.DATETIME }}.zip
|
21
.github/workflows/pr.yml
vendored
21
.github/workflows/pr.yml
vendored
|
@ -4,17 +4,17 @@ on: [pull_request]
|
|||
|
||||
jobs:
|
||||
clang-format:
|
||||
runs-on: ubuntu-18.04
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
- name: clang-format
|
||||
run: |
|
||||
docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./src
|
||||
docker run --rm -v ${PWD}:/src ghcr.io/wiiu-env/clang-format:13.0.0-2 -r ./src
|
||||
check-build-with-logging:
|
||||
runs-on: ubuntu-18.04
|
||||
runs-on: ubuntu-22.04
|
||||
needs: clang-format
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
- name: build binary with logging
|
||||
run: |
|
||||
docker build . -t builder
|
||||
|
@ -22,10 +22,17 @@ jobs:
|
|||
docker run --rm -v ${PWD}:/project builder make clean
|
||||
docker run --rm -v ${PWD}:/project builder make DEBUG=1
|
||||
build-binary:
|
||||
runs-on: ubuntu-18.04
|
||||
runs-on: ubuntu-22.04
|
||||
needs: clang-format
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
- name: create version.h
|
||||
run: |
|
||||
git_hash=$(git rev-parse --short "${{ github.event.pull_request.head.sha }}")
|
||||
cat <<EOF > ./src/version.h
|
||||
#pragma once
|
||||
#define VERSION_EXTRA " (nightly-$git_hash)"
|
||||
EOF
|
||||
- name: build binary
|
||||
run: |
|
||||
docker build . -t builder
|
||||
|
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -8,3 +8,4 @@ build/
|
|||
cmake-build-debug/
|
||||
CMakeLists.txt
|
||||
*.wms
|
||||
*.zip
|
||||
|
|
16
Dockerfile
16
Dockerfile
|
@ -1,11 +1,11 @@
|
|||
FROM wiiuenv/devkitppc:20220806
|
||||
FROM ghcr.io/wiiu-env/devkitppc:20240505
|
||||
|
||||
COPY --from=wiiuenv/librpxloader:20220903 /artifacts $DEVKITPRO
|
||||
COPY --from=wiiuenv/libfunctionpatcher:20220724 /artifacts $DEVKITPRO
|
||||
COPY --from=wiiuenv/wiiumodulesystem:20220724 /artifacts $DEVKITPRO
|
||||
COPY --from=wiiuenv/libwuhbutils:20220903 /artifacts $DEVKITPRO
|
||||
COPY --from=wiiuenv/libcontentredirection:20220903 /artifacts $DEVKITPRO
|
||||
COPY --from=wiiuenv/libromfs_wiiu:20220903 /artifacts $DEVKITPRO
|
||||
COPY --from=wiiuenv/libmocha:20220903 /artifacts $DEVKITPRO
|
||||
COPY --from=ghcr.io/wiiu-env/librpxloader:20240425 /artifacts $DEVKITPRO
|
||||
COPY --from=ghcr.io/wiiu-env/libfunctionpatcher:20230621 /artifacts $DEVKITPRO
|
||||
COPY --from=ghcr.io/wiiu-env/wiiumodulesystem:20240424 /artifacts $DEVKITPRO
|
||||
COPY --from=ghcr.io/wiiu-env/libwuhbutils:20230621 /artifacts $DEVKITPRO
|
||||
COPY --from=ghcr.io/wiiu-env/libcontentredirection:20240424 /artifacts $DEVKITPRO
|
||||
COPY --from=ghcr.io/wiiu-env/libromfs_wiiu:20240505 /artifacts $DEVKITPRO
|
||||
COPY --from=ghcr.io/wiiu-env/libmocha:20231127 /artifacts $DEVKITPRO
|
||||
|
||||
WORKDIR project
|
||||
|
|
13
Makefile
13
Makefile
|
@ -38,7 +38,7 @@ CFLAGS += $(INCLUDE) -D__WIIU__ -D__WUT__
|
|||
CXXFLAGS := $(CFLAGS) -std=c++20
|
||||
|
||||
ASFLAGS := -g $(ARCH)
|
||||
LDFLAGS = -g $(ARCH) $(RPXSPECS) -Wl,-Map,$(notdir $*.map) -T$(WUMS_ROOT)/share/libfunctionpatcher.ld -Tcontentredirection.ld -Twuhbutils.ld $(WUMSSPECS)
|
||||
LDFLAGS = -g $(ARCH) $(RPXSPECS) -Wl,-Map,$(notdir $*.map) $(WUMSSPECS)
|
||||
|
||||
ifeq ($(DEBUG),1)
|
||||
CXXFLAGS += -DDEBUG -g
|
||||
|
@ -77,7 +77,6 @@ export DEPSDIR := $(CURDIR)/$(BUILD)
|
|||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
||||
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
||||
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
||||
DEFFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.def)))
|
||||
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
@ -95,7 +94,7 @@ endif
|
|||
#-------------------------------------------------------------------------------
|
||||
|
||||
export OFILES_BIN := $(addsuffix .o,$(BINFILES))
|
||||
export OFILES_SRC := $(DEFFILES:.def=.o) $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
|
||||
export OFILES_SRC := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
|
||||
export OFILES := $(OFILES_BIN) $(OFILES_SRC)
|
||||
export HFILES_BIN := $(addsuffix .h,$(subst .,_,$(BINFILES)))
|
||||
|
||||
|
@ -111,7 +110,7 @@ export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
|
|||
all: $(BUILD)
|
||||
|
||||
$(BUILD):
|
||||
@[ -d $@ ] || mkdir -p $@
|
||||
@$(shell [ ! -d $(BUILD) ] && mkdir -p $(BUILD))
|
||||
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
@ -139,11 +138,7 @@ $(OFILES_SRC) : $(HFILES_BIN)
|
|||
#-------------------------------------------------------------------------------
|
||||
# you need a rule like this for each extension you use as binary data
|
||||
#-------------------------------------------------------------------------------
|
||||
%.o: %.def
|
||||
$(SILENTMSG) $(notdir $<)
|
||||
$(SILENTCMD)rplimportgen $< $*.s $*.ld $(ERROR_FILTER)
|
||||
$(SILENTCMD)$(CC) -x assembler-with-cpp $(ASFLAGS) -c $*.s -o $@ $(ERROR_FILTER)
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%_bin.h %.bin.o : %.bin
|
||||
#---------------------------------------------------------------------------------
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
|
||||
1. Copy the file `RPXLoadingModule.wms` into `sd:/wiiu/environments/[ENVIRONMENT]/modules`.
|
||||
2. Requires the [WUMSLoader](https://github.com/wiiu-env/WUMSLoader) in `sd:/wiiu/environments/[ENVIRONMENT]/modules/setup`.
|
||||
3. Requires the [ContentRedirectionModule](https://github.com/wiiu-env/ContentRedirectionModule) in `sd:/wiiu/environments/[ENVIRONMENT]/modules/setup`.
|
||||
4. Requires the [WUHBUtilsModule](https://github.com/wiiu-env/WUHBUtilsModule) in `sd:/wiiu/environments/[ENVIRONMENT]/modules/setup`.
|
||||
3. Requires the [ContentRedirectionModule](https://github.com/wiiu-env/ContentRedirectionModule) in `sd:/wiiu/environments/[ENVIRONMENT]/modules`.
|
||||
4. Requires the [WUHBUtilsModule](https://github.com/wiiu-env/WUHBUtilsModule) in `sd:/wiiu/environments/[ENVIRONMENT]/modules`.
|
||||
5. Use [librpxloading](https://github.com/wiiu-env/librpxloader)
|
||||
|
||||
## Buildflags
|
||||
|
@ -37,4 +37,4 @@ docker run -it --rm -v ${PWD}:/project rpxloadingmodule-builder make clean
|
|||
|
||||
## Format the code via docker
|
||||
|
||||
`docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./src -i`
|
||||
`docker run --rm -v ${PWD}:/src ghcr.io/wiiu-env/clang-format:13.0.0-2 -r ./src -i`
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <coreinit/cache.h>
|
||||
#include <coreinit/debug.h>
|
||||
#include <coreinit/ios.h>
|
||||
#include <coreinit/title.h>
|
||||
#include <cstring>
|
||||
#include <mocha/mocha.h>
|
||||
#include <mutex>
|
||||
|
@ -15,6 +16,7 @@
|
|||
#include <romfs_dev.h>
|
||||
#include <rpxloader/rpxloader.h>
|
||||
#include <string>
|
||||
#include <sysapp/title.h>
|
||||
#include <wuhb_utils/utils.h>
|
||||
|
||||
std::mutex fileReaderListMutex;
|
||||
|
@ -33,11 +35,12 @@ DECL_FUNCTION(int32_t, HBM_NN_ACP_ACPGetTitleMetaXmlByDevice, uint32_t titleid_u
|
|||
memset(&metaxml->longname_ja, 0, 0x338C - 0x38C); // clear all names
|
||||
|
||||
snprintf(metaxml->longname_en, sizeof(metaxml->longname_en), "%s", gReplacementInfo.rpxReplacementInfo.metaInformation.longname);
|
||||
snprintf(metaxml->shortname_en, sizeof(metaxml->shortname_en), "%s", gReplacementInfo.rpxReplacementInfo.metaInformation.longname);
|
||||
snprintf(metaxml->publisher_en, sizeof(metaxml->publisher_en), "%s", gReplacementInfo.rpxReplacementInfo.metaInformation.longname);
|
||||
snprintf(metaxml->shortname_en, sizeof(metaxml->shortname_en), "%s", gReplacementInfo.rpxReplacementInfo.metaInformation.shortname);
|
||||
snprintf(metaxml->publisher_en, sizeof(metaxml->publisher_en), "%s", gReplacementInfo.rpxReplacementInfo.metaInformation.author);
|
||||
|
||||
// Disbale the emanual
|
||||
metaxml->e_manual = 0;
|
||||
// Disable the emanual
|
||||
metaxml->e_manual = 0;
|
||||
metaxml->closing_msg = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -85,15 +88,32 @@ DECL_FUNCTION(FSStatus, RPX_FSCloseFile, FSClient *client, FSCmdBlock *block, FS
|
|||
return real_RPX_FSCloseFile(client, block, handle, flags);
|
||||
}
|
||||
|
||||
DECL_FUNCTION(void, Loader_ReportWarn) {
|
||||
RPXLoaderStatus RL_PrepareLaunchFromSD(const char *bundle_path);
|
||||
|
||||
DECL_FUNCTION(void, OSRestartGame, int argc, char *argv[]) {
|
||||
if (OSGetTitleID() == _SYSGetSystemApplicationTitleId(SYSTEM_APP_ID_HEALTH_AND_SAFETY) &&
|
||||
strlen(gReplacementInfo.contentReplacementInfo.bundleMountInformation.toMountPath) == 0) {
|
||||
RL_PrepareLaunchFromSD(gReplacementInfo.lastFileLoaded);
|
||||
}
|
||||
real_OSRestartGame(argc, argv);
|
||||
}
|
||||
|
||||
DECL_FUNCTION(void, _SYSLaunchTitleWithStdArgsInNoSplash, uint64_t titleId, void *u1) {
|
||||
if (titleId == _SYSGetSystemApplicationTitleId(SYSTEM_APP_ID_HEALTH_AND_SAFETY) &&
|
||||
titleId == OSGetTitleID() &&
|
||||
strlen(gReplacementInfo.contentReplacementInfo.bundleMountInformation.toMountPath) == 0) {
|
||||
RL_PrepareLaunchFromSD(gReplacementInfo.lastFileLoaded);
|
||||
}
|
||||
real__SYSLaunchTitleWithStdArgsInNoSplash(titleId, u1);
|
||||
}
|
||||
|
||||
function_replacement_data_t rpx_utils_function_replacements[] = {
|
||||
REPLACE_FUNCTION_VIA_ADDRESS(Loader_ReportWarn, 0x32002f74, 0x01002f74),
|
||||
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),
|
||||
};
|
||||
|
||||
uint32_t rpx_utils_function_replacements_size = sizeof(rpx_utils_function_replacements) / sizeof(function_replacement_data_t);
|
||||
|
@ -241,6 +261,8 @@ RPXLoaderStatus RL_PrepareLaunchFromSD(const char *bundle_path) {
|
|||
}
|
||||
}
|
||||
|
||||
strncpy(gReplacementInfo.lastFileLoaded, bundle_path, sizeof(gReplacementInfo.lastFileLoaded) - 2);
|
||||
|
||||
OSMemoryBarrier();
|
||||
|
||||
return RPX_LOADER_RESULT_SUCCESS;
|
||||
|
@ -322,7 +344,7 @@ RPXLoaderStatus RL_UnmountCurrentRunningBundle() {
|
|||
}
|
||||
|
||||
int outRes = -1;
|
||||
if (ContentRedirection_RemoveDevice(WUHB_ROMFS_NAME, &outRes) == CONTENT_REDIRECTION_RESULT_SUCCESS) {
|
||||
if (ContentRedirection_RemoveDevice(WUHB_ROMFS_PATH, &outRes) == CONTENT_REDIRECTION_RESULT_SUCCESS) {
|
||||
if (outRes < 0) {
|
||||
DEBUG_FUNCTION_LINE_ERR("RemoveDevice \"%s\" failed for ContentRedirection Module", WUHB_ROMFS_NAME);
|
||||
OSFatal("RL_UnmountCurrentRunningBundle: RemoveDevice \"" WUHB_ROMFS_NAME "\" failed for ContentRedirection Module");
|
||||
|
@ -360,10 +382,33 @@ RPXLoaderStatus RL_GetVersion(RPXLoaderVersion *outVersion) {
|
|||
if (!outVersion) {
|
||||
return RPX_LOADER_RESULT_INVALID_ARGUMENT;
|
||||
}
|
||||
*outVersion = 1;
|
||||
*outVersion = 3;
|
||||
return RPX_LOADER_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
RPXLoaderStatus RL_GetPathOfRunningExecutable(char *outBuffer, uint32_t outSize) {
|
||||
if (outBuffer == nullptr || outSize == 0) {
|
||||
return RPX_LOADER_RESULT_INVALID_ARGUMENT;
|
||||
}
|
||||
if (strlen(gReplacementInfo.lastFileLoaded) > 0) {
|
||||
strncpy(outBuffer, gReplacementInfo.lastFileLoaded, outSize - 1);
|
||||
return RPX_LOADER_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
return RPX_LOADER_RESULT_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
RPXLoaderStatus RL_GetPathOfSaveRedirection(char *outBuffer, uint32_t outSize) {
|
||||
if (outBuffer == nullptr || outSize == 0) {
|
||||
return RPX_LOADER_RESULT_INVALID_ARGUMENT;
|
||||
}
|
||||
if (saveLayerHandle != 0 && !gActiveSaveRedirectionPath.empty()) {
|
||||
strncpy(outBuffer, gActiveSaveRedirectionPath.c_str(), outSize - 1);
|
||||
return RPX_LOADER_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
return RPX_LOADER_RESULT_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
WUMS_EXPORT_FUNCTION(RL_PrepareLaunchFromSD);
|
||||
WUMS_EXPORT_FUNCTION(RL_LaunchPreparedHomebrew);
|
||||
|
@ -372,4 +417,6 @@ WUMS_EXPORT_FUNCTION(RL_LaunchHomebrew);
|
|||
WUMS_EXPORT_FUNCTION(RL_GetVersion);
|
||||
WUMS_EXPORT_FUNCTION(RL_EnableContentRedirection);
|
||||
WUMS_EXPORT_FUNCTION(RL_DisableContentRedirection);
|
||||
WUMS_EXPORT_FUNCTION(RL_UnmountCurrentRunningBundle);
|
||||
WUMS_EXPORT_FUNCTION(RL_UnmountCurrentRunningBundle);
|
||||
WUMS_EXPORT_FUNCTION(RL_GetPathOfRunningExecutable);
|
||||
WUMS_EXPORT_FUNCTION(RL_GetPathOfSaveRedirection);
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
:NAME homebrew_content_redirection
|
||||
|
||||
:TEXT
|
||||
CRGetVersion
|
|
@ -1,5 +1,6 @@
|
|||
#include "globals.h"
|
||||
|
||||
RPXLoader_ReplacementInformation gReplacementInfo __attribute__((section(".data")));
|
||||
CRLayerHandle contentLayerHandle __attribute__((section(".data"))) = 0;
|
||||
CRLayerHandle saveLayerHandle __attribute__((section(".data"))) = 0;
|
||||
#include "globals.h"
|
||||
|
||||
RPXLoader_ReplacementInformation gReplacementInfo = {};
|
||||
CRLayerHandle contentLayerHandle = 0;
|
||||
CRLayerHandle saveLayerHandle = 0;
|
||||
std::string gActiveSaveRedirectionPath;
|
|
@ -47,9 +47,11 @@ typedef struct RPXLoader_ReplacementInformation_t {
|
|||
RPXReplacementInfo rpxReplacementInfo;
|
||||
ContentReplacementInfo contentReplacementInfo;
|
||||
ContentReplacementWithFallback contentReplacementWithFallbackInfo;
|
||||
char lastFileLoaded[0x280];
|
||||
} RPXLoader_ReplacementInformation;
|
||||
|
||||
extern RPXLoader_ReplacementInformation gReplacementInfo;
|
||||
|
||||
extern CRLayerHandle contentLayerHandle;
|
||||
extern CRLayerHandle saveLayerHandle;
|
||||
extern CRLayerHandle saveLayerHandle;
|
||||
extern std::string gActiveSaveRedirectionPath;
|
47
src/main.cpp
47
src/main.cpp
|
@ -3,6 +3,7 @@
|
|||
#include "globals.h"
|
||||
#include "utils/StringTools.h"
|
||||
#include "utils/logger.h"
|
||||
#include "version.h"
|
||||
#include <content_redirection/redirection.h>
|
||||
#include <coreinit/cache.h>
|
||||
#include <coreinit/debug.h>
|
||||
|
@ -15,37 +16,38 @@
|
|||
#include <wuhb_utils/utils.h>
|
||||
#include <wums.h>
|
||||
|
||||
#define VERSION "v0.3.4"
|
||||
|
||||
WUMS_MODULE_EXPORT_NAME("homebrew_rpx_loader");
|
||||
WUMS_USE_WUT_DEVOPTAB();
|
||||
|
||||
extern "C" ContentRedirectionApiErrorType CRGetVersion(ContentRedirectionVersion *);
|
||||
extern "C" WUHBUtilsApiErrorType WUU_GetVersion(WUHBUtilsVersion *);
|
||||
WUMS_DEPENDS_ON(homebrew_content_redirection);
|
||||
WUMS_DEPENDS_ON(homebrew_wuhb_utils);
|
||||
WUMS_DEPENDS_ON(homebrew_functionpatcher);
|
||||
|
||||
WUMS_INITIALIZE() {
|
||||
initLogging();
|
||||
|
||||
if (FunctionPatcher_InitLibrary() != FUNCTION_PATCHER_RESULT_SUCCESS) {
|
||||
OSFatal("homebrew_rpx_loader: FunctionPatcher_InitLibrary failed");
|
||||
}
|
||||
|
||||
DEBUG_FUNCTION_LINE("Patch functions");
|
||||
for (uint32_t i = 0; i < rpx_utils_function_replacements_size; i++) {
|
||||
if (!FunctionPatcherPatchFunction(&rpx_utils_function_replacements[i], nullptr)) {
|
||||
bool wasPatched = false;
|
||||
if (FunctionPatcher_AddFunctionPatch(&rpx_utils_function_replacements[i], nullptr, &wasPatched) != FUNCTION_PATCHER_RESULT_SUCCESS || !wasPatched) {
|
||||
OSFatal("homebrew_rpx_loader: Failed to patch function");
|
||||
}
|
||||
}
|
||||
DEBUG_FUNCTION_LINE("Patch functions finished");
|
||||
gReplacementInfo = {};
|
||||
|
||||
// Call this function to make sure the Content Redirection will be loaded before this module is module.
|
||||
CRGetVersion(nullptr);
|
||||
|
||||
// Call this function to make sure the WUHBUtils will be loaded before this module is module.
|
||||
WUU_GetVersion(nullptr);
|
||||
|
||||
// But then use libcontentredirection instead.
|
||||
ContentRedirectionStatus error;
|
||||
if ((error = ContentRedirection_InitLibrary()) != CONTENT_REDIRECTION_RESULT_SUCCESS) {
|
||||
DEBUG_FUNCTION_LINE_ERR("Failed to init ContentRedirection. Error %d", error);
|
||||
OSFatal("Failed to init ContentRedirection.");
|
||||
}
|
||||
|
||||
// But then use libwuhbutils instead.
|
||||
WUHBUtilsStatus error2;
|
||||
if ((error2 = WUHBUtils_InitLibrary()) != WUHB_UTILS_RESULT_SUCCESS) {
|
||||
DEBUG_FUNCTION_LINE_ERR("Failed to init WUHBUtils. Error %d", error2);
|
||||
|
@ -78,23 +80,36 @@ WUMS_APPLICATION_STARTS() {
|
|||
if (upid != 2 && upid != 15) {
|
||||
return;
|
||||
}
|
||||
OSReport("Running RPXLoadingModule " VERSION VERSION_EXTRA "\n");
|
||||
initLogging();
|
||||
if (gReplacementInfo.rpxReplacementInfo.willRPXBeReplaced) {
|
||||
gReplacementInfo.rpxReplacementInfo.willRPXBeReplaced = false;
|
||||
gReplacementInfo.rpxReplacementInfo.isRPXReplaced = true;
|
||||
}
|
||||
|
||||
if (_SYSGetSystemApplicationTitleId(SYSTEM_APP_ID_HEALTH_AND_SAFETY) != OSGetTitleID()) {
|
||||
gReplacementInfo.lastFileLoaded[0] = '\0';
|
||||
}
|
||||
|
||||
gActiveSaveRedirectionPath.clear();
|
||||
|
||||
if (_SYSGetSystemApplicationTitleId(SYSTEM_APP_ID_HEALTH_AND_SAFETY) == OSGetTitleID() &&
|
||||
strlen(gReplacementInfo.contentReplacementInfo.bundleMountInformation.toMountPath) > 0) {
|
||||
uint32_t currentHash = StringTools::hash(gReplacementInfo.contentReplacementInfo.bundleMountInformation.toMountPath);
|
||||
uint32_t currentHash = StringTools::hash(gReplacementInfo.contentReplacementInfo.bundleMountInformation.toMountPath);
|
||||
std::string shortNameSanitized = sanitizeName(gReplacementInfo.rpxReplacementInfo.metaInformation.shortname);
|
||||
|
||||
nn::act::Initialize();
|
||||
nn::act::PersistentId persistentId = nn::act::GetPersistentId();
|
||||
nn::act::Finalize();
|
||||
|
||||
std::string basePath = string_format("fs:/vol/external01/wiiu/apps/save/%08X", currentHash);
|
||||
std::string common = string_format("fs:/vol/external01/wiiu/apps/save/%08X/common", currentHash);
|
||||
std::string user = string_format("fs:/vol/external01/wiiu/apps/save/%08X/%08X", currentHash, 0x80000000 | persistentId);
|
||||
std::string relativePath = string_format("wiiu/apps/save/%08X", currentHash);
|
||||
if (!shortNameSanitized.empty()) {
|
||||
relativePath += string_format(" (%s)", shortNameSanitized.c_str());
|
||||
}
|
||||
std::string basePath = "fs:/vol/external01/" + relativePath;
|
||||
|
||||
std::string common = basePath + "/common";
|
||||
std::string user = basePath + string_format("/%08X", 0x80000000 | persistentId);
|
||||
|
||||
CreateSubfolder(common.c_str());
|
||||
CreateSubfolder(user.c_str());
|
||||
|
@ -133,6 +148,8 @@ WUMS_APPLICATION_STARTS() {
|
|||
gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted = true;
|
||||
gReplacementInfo.contentReplacementInfo.bundleMountInformation.toMountPath[0] = '\0';
|
||||
|
||||
gActiveSaveRedirectionPath = relativePath;
|
||||
|
||||
OSMemoryBarrier();
|
||||
return;
|
||||
} else {
|
||||
|
|
|
@ -1,9 +1,41 @@
|
|||
#include "utils/logger.h"
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
#include <whb/log.h>
|
||||
|
||||
#define PRINTF_BUFFER_LENGTH 2048
|
||||
std::string sanitizeName(const std::string &input) {
|
||||
if (input.empty() || input.starts_with(' ')) {
|
||||
return "";
|
||||
}
|
||||
std::string result = input;
|
||||
std::string illegalChars = "\\/:?\"<>|@=;`_^][";
|
||||
for (auto it = result.begin(); it < result.end(); ++it) {
|
||||
if (*it < '0' || *it > 'z') {
|
||||
*it = ' ';
|
||||
}
|
||||
}
|
||||
for (auto it = result.begin(); it < result.end(); ++it) {
|
||||
bool found = illegalChars.find(*it) != std::string::npos;
|
||||
if (found) {
|
||||
*it = ' ';
|
||||
}
|
||||
}
|
||||
uint32_t length = result.length();
|
||||
for (uint32_t i = 1; i < length; ++i) {
|
||||
if (result[i - 1] == ' ' && result[i] == ' ') {
|
||||
result.erase(i, 1);
|
||||
i--;
|
||||
length--;
|
||||
}
|
||||
}
|
||||
if (result.size() == 1 && result[0] == ' ') {
|
||||
result.clear();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
#define PRINTF_BUFFER_LENGTH 2048
|
||||
// https://gist.github.com/ccbrown/9722406
|
||||
void dumpHex(const void *data, size_t size) {
|
||||
char ascii[17];
|
||||
|
|
|
@ -35,6 +35,8 @@ bool remove_locked_first_if(std::mutex &mutex, std::forward_list<T, Allocator> &
|
|||
return false;
|
||||
}
|
||||
|
||||
std::string sanitizeName(const std::string &input);
|
||||
|
||||
// those work only in powers of 2
|
||||
#define ROUNDDOWN(val, align) ((val) & ~(align - 1))
|
||||
#define ROUNDUP(val, align) ROUNDDOWN(((val) + (align - 1)), align)
|
2
src/version.h
Normal file
2
src/version.h
Normal file
|
@ -0,0 +1,2 @@
|
|||
#pragma once
|
||||
#define VERSION_EXTRA ""
|
|
@ -1,4 +0,0 @@
|
|||
:NAME homebrew_wuhb_utils
|
||||
|
||||
:TEXT
|
||||
WUU_GetVersion
|
Loading…
Reference in New Issue
Block a user