Skip to content

Commit 38a9914

Browse files
committed
Implement support for adding devices via ContentRedirectionDeviceABI instead of devoptab_t
1 parent 85c4802 commit 38a9914

5 files changed

Lines changed: 736 additions & 7 deletions

File tree

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
FROM ghcr.io/wiiu-env/devkitppc:20260225
22

3-
COPY --from=ghcr.io/wiiu-env/libfunctionpatcher:20260208 /artifacts $DEVKITPRO
4-
COPY --from=ghcr.io/wiiu-env/wiiumodulesystem:20260225 /artifacts $DEVKITPRO
5-
COPY --from=ghcr.io/wiiu-env/libcontentredirection:20260329 /artifacts $DEVKITPRO
3+
COPY --from=ghcr.io/wiiu-env/libfunctionpatcher:20260331 /artifacts $DEVKITPRO
4+
COPY --from=ghcr.io/wiiu-env/wiiumodulesystem:reentfix-dev-20260403-5ca1144 /artifacts $DEVKITPRO
5+
COPY --from=ghcr.io/wiiu-env/libcontentredirection:abisafe-dev-20260403-502a496 /artifacts $DEVKITPRO
66

77
WORKDIR project

src/export.cpp

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33
#include "FileUtils.h"
44
#include "IFSWrapper.h"
55
#include "malloc.h"
6+
#include "utils/DevoptabTrampoline.h"
67
#include "utils/StringTools.h"
78
#include "utils/logger.h"
89
#include "utils/utils.h"
910

1011
#include <FSWrapperReplaceSingleFile.h>
1112
#include <content_redirection/redirection.h>
1213
#include <coreinit/dynload.h>
14+
#include <cstring>
1315
#include <mutex>
1416
#include <nn/act.h>
1517
#include <wums/exports.h>
@@ -209,22 +211,63 @@ ContentRedirectionApiErrorType CRGetVersion(ContentRedirectionVersion *outVersio
209211
if (outVersion == nullptr) {
210212
return CONTENT_REDIRECTION_API_ERROR_INVALID_ARG;
211213
}
212-
*outVersion = 2;
214+
*outVersion = 3;
213215
return CONTENT_REDIRECTION_API_ERROR_NONE;
214216
}
215217

216218
int CRAddDevice(const devoptab_t *device) {
219+
DEBUG_FUNCTION_LINE_WARN("Usage of deprecated \"CRAddDevice\" API detected. Please use latest libcontentredirection.");
217220
return AddDevice(device);
218221
}
219222

220223
int CRRemoveDevice(const char *name) {
224+
DEBUG_FUNCTION_LINE_WARN("Usage deprecated \"CRRemoveDevice\" API. Please use latest libcontentredirection.");
221225
return RemoveDevice(name);
222226
}
223227

228+
ContentRedirectionApiErrorType CRAddDeviceABI(const ContentRedirectionDeviceABI *device, int *resultOut) {
229+
if (!device || device->magic != CONTENT_REDIRECTION_DEVICE_MAGIC || device->version < CONTENT_REDIRECTION_DEVICE_VERSION || !resultOut) {
230+
return CONTENT_REDIRECTION_API_ERROR_INVALID_ARG;
231+
}
232+
233+
const auto *host_dev = DevoptabTrampoline::CreateDevoptab(device);
234+
if (!host_dev) {
235+
return CONTENT_REDIRECTION_API_ERROR_NO_MEMORY;
236+
}
237+
238+
*resultOut = AddDevice(host_dev);
239+
240+
if (*resultOut < 0) {
241+
DevoptabTrampoline::ClearDevoptab(host_dev);
242+
}
243+
244+
return CONTENT_REDIRECTION_API_ERROR_NONE;
245+
}
246+
247+
ContentRedirectionApiErrorType CRRemoveDeviceABI(const char *device_name, int *resultOut) {
248+
if (!device_name || !resultOut) {
249+
return CONTENT_REDIRECTION_API_ERROR_INVALID_ARG;
250+
}
251+
252+
if (!DevoptabTrampoline::RemoveDevoptab(device_name, resultOut)) {
253+
*resultOut = -1;
254+
return CONTENT_REDIRECTION_API_ERROR_INVALID_ARG;
255+
}
256+
257+
return CONTENT_REDIRECTION_API_ERROR_NONE;
258+
}
259+
260+
// API Version 1
224261
WUMS_EXPORT_FUNCTION(CRGetVersion);
225-
WUMS_EXPORT_FUNCTION(CRAddFSLayerEx);
226262
WUMS_EXPORT_FUNCTION(CRAddFSLayer);
227263
WUMS_EXPORT_FUNCTION(CRRemoveFSLayer);
228264
WUMS_EXPORT_FUNCTION(CRSetActive);
229265
WUMS_EXPORT_FUNCTION(CRAddDevice);
230-
WUMS_EXPORT_FUNCTION(CRRemoveDevice);
266+
WUMS_EXPORT_FUNCTION(CRRemoveDevice);
267+
268+
// API Version 2
269+
WUMS_EXPORT_FUNCTION(CRAddFSLayerEx);
270+
271+
// API Version 3
272+
WUMS_EXPORT_FUNCTION(CRAddDeviceABI);
273+
WUMS_EXPORT_FUNCTION(CRRemoveDeviceABI);

src/main.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#include "FSAReplacements.h"
22
#include "FSReplacements.h"
33
#include "FileUtils.h"
4-
#include "utils/StringTools.h"
54
#include "utils/logger.h"
65
#include "version.h"
76
#include <wums.h>

0 commit comments

Comments
 (0)