Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for RPXLoader_GetPathOfSaveRedirection #11

Merged
merged 2 commits into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions .github/workflows/push_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,32 @@ on:
push:
branches:
- main
- '*-dev'

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
clang-format-lib:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: clang-format
run: |
docker run --rm -v ${PWD}:/src ghcr.io/wiiu-env/clang-format:13.0.0-2 -r ./include ./source
build-lib:
runs-on: ubuntu-22.04
needs: clang-format-lib
steps:
- uses: actions/checkout@v3
- name: build binary
run: |
docker build . -f Dockerfile.buildlocal -t builder
docker run --rm -v ${PWD}:/project builder make
build-and-push-image:
runs-on: ubuntu-latest
needs: [build-lib]
permissions:
contents: read
packages: write
Expand All @@ -23,9 +42,10 @@ jobs:
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value={{date 'YYYYMMDD'}}-{{sha}}
type=raw,value={{date 'YYYYMMDD'}}
type=raw,value=latest
type=raw,value={{branch}}-{{date 'YYYYMMDD'}}-{{sha}},enable=${{ github.ref != format('refs/heads/{0}', 'main') }}
type=raw,value={{date 'YYYYMMDD'}}-{{sha}},enable={{is_default_branch}}
type=raw,value={{date 'YYYYMMDD'}},enable={{is_default_branch}}
type=raw,value=latest,enable={{is_default_branch}}

- name: Log into registry ${{ env.REGISTRY }}
uses: docker/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ TOPDIR ?= $(CURDIR)
include $(DEVKITPRO)/wut/share/wut_rules

export VER_MAJOR := 1
export VER_MINOR := 2
export VER_MINOR := 3
export VER_PATCH := 0

VERSION := $(VER_MAJOR).$(VER_MINOR).$(VER_PATCH)
Expand Down
19 changes: 18 additions & 1 deletion include/rpxloader/rpxloader.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,31 @@ RPXLoaderStatus RPXLoader_UnmountCurrentRunningBundle();
*
* @param outBuffer buffer where the result will be stored
* @param outSize size of outBuffer
* @return RPX_LOADER_RESULT_SUCCESS: The path of the currently running executable has been written to outBuffer
* @return RPX_LOADER_RESULT_SUCCESS: The path of the currently running executable has been written to outBuffer. <br>
* RPX_LOADER_RESULT_UNSUPPORTED_COMMAND: Command not supported by the currently loaded RPXLoaderModule version.<br>
* RPX_LOADER_RESULT_INVALID_ARGUMENT: The given outBuffer was NULL or outSize was 0 <br>
* RPX_LOADER_RESULT_LIB_UNINITIALIZED: "RPXLoader_Init()" was not called.<br>
* RPX_LOADER_RESULT_NOT_AVAILABLE: The path is not available.<br>
*/
RPXLoaderStatus RPXLoader_GetPathOfRunningExecutable(char *outBuffer, uint32_t outSize);

/**
* Returns the path currently used for /vol/save redirection <br>
* This function is not guaranteed to succeed, it only works if the executable is loaded via the RPXLoadingModule <br>
* The returned path is relative to the root of the sd card. <br>
* <br>
* Requires API version 3 or higher. <br>
*
* @param outBuffer buffer where the result will be stored
* @param outSize size of outBuffer
* @return RPX_LOADER_RESULT_SUCCESS: The path of the /vol/save redirection has been written to outBuffer.<br>
* RPX_LOADER_RESULT_UNSUPPORTED_COMMAND: Command not supported by the currently loaded RPXLoaderModule version.<br>
* RPX_LOADER_RESULT_INVALID_ARGUMENT: The given outBuffer was NULL or outSize was 0 <br>
* RPX_LOADER_RESULT_LIB_UNINITIALIZED: "RPXLoader_Init()" was not called.<br>
* RPX_LOADER_RESULT_NOT_AVAILABLE: The path is not available.<br>
*/
RPXLoaderStatus RPXLoader_GetPathOfSaveRedirection(char *outBuffer, uint32_t outSize);

#ifdef __cplusplus
} // extern "C"
#endif
17 changes: 17 additions & 0 deletions source/rpxloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ static RPXLoaderStatus (*sRLDisableContentRedirection)()
static RPXLoaderStatus (*sRLEnableContentRedirection)() = nullptr;
static RPXLoaderStatus (*sRLUnmountCurrentRunningBundle)() = nullptr;
static RPXLoaderStatus (*sRL_GetPathOfRunningExecutable)(char *outBuffer, uint32_t outSize) = nullptr;
static RPXLoaderStatus (*sRL_GetPathOfSaveRedirection)(char *outBuffer, uint32_t outSize) = nullptr;

const char *RPXLoader_GetStatusStr(RPXLoaderStatus status) {
switch (status) {
Expand Down Expand Up @@ -93,6 +94,11 @@ RPXLoaderStatus RPXLoader_InitLibrary() {
sRL_GetPathOfRunningExecutable = nullptr;
}

if (OSDynLoad_FindExport(sModuleHandle, OS_DYNLOAD_EXPORT_FUNC, "RL_GetPathOfSaveRedirection", (void **) &sRL_GetPathOfSaveRedirection) != OS_DYNLOAD_OK) {
DEBUG_FUNCTION_LINE_WARN("FindExport RL_GetPathOfRunningExecutable failed.");
sRL_GetPathOfSaveRedirection = nullptr;
}

return RPX_LOADER_RESULT_SUCCESS;
}

Expand Down Expand Up @@ -193,4 +199,15 @@ RPXLoaderStatus RPXLoader_GetPathOfRunningExecutable(char *outBuffer, uint32_t o
}

return reinterpret_cast<decltype(&RPXLoader_GetPathOfRunningExecutable)>(sRL_GetPathOfRunningExecutable)(outBuffer, outSize);
}

RPXLoaderStatus RPXLoader_GetPathOfSaveRedirection(char *outBuffer, uint32_t outSize) {
if (rpxLoaderVersion == RPX_LOADER_MODULE_VERSION_ERROR) {
return RPX_LOADER_RESULT_LIB_UNINITIALIZED;
}
if (sRL_GetPathOfSaveRedirection == nullptr || rpxLoaderVersion < 3) {
return RPX_LOADER_RESULT_UNSUPPORTED_COMMAND;
}

return reinterpret_cast<decltype(&RPXLoader_GetPathOfSaveRedirection)>(sRL_GetPathOfSaveRedirection)(outBuffer, outSize);
}
Loading