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

Implement support for API Version 3 (RPXLoader_GetPathOfSaveRedirection) #14

Merged
merged 5 commits into from
Apr 25, 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
4 changes: 2 additions & 2 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ jobs:
clang-format:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: clang-format
run: |
docker run --rm -v ${PWD}:/src ghcr.io/wiiu-env/clang-format:13.0.0-2 -r ./source ./include
build-lib:
runs-on: ubuntu-22.04
needs: clang-format
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: build lib
run: |
docker build . -f Dockerfile.buildlocal -t builder
Expand Down
28 changes: 24 additions & 4 deletions .github/workflows/push_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,49 @@ 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@v4
- 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@v4
- 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

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v4
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 Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ghcr.io/wiiu-env/devkitppc:20230621
FROM ghcr.io/wiiu-env/devkitppc:20240423

WORKDIR tmp_build
COPY . .
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.buildlocal
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
FROM ghcr.io/wiiu-env/devkitppc:20230621
FROM ghcr.io/wiiu-env/devkitppc:20240423

WORKDIR project
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
19 changes: 18 additions & 1 deletion 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_GetPathOfSaveRedirection 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