Use latest librpxloader and libwupsbackend

This commit is contained in:
Maschell 2022-05-14 16:19:26 +02:00
parent 57ecb8befc
commit 7d7b04f3ea
4 changed files with 38 additions and 29 deletions

View File

@ -1,7 +1,7 @@
FROM wiiuenv/devkitppc:20211229
FROM wiiuenv/devkitppc:20220507
COPY --from=wiiuenv/libwupsbackend:20211001 /artifacts $DEVKITPRO
COPY --from=wiiuenv/librpxloader:20211002 /artifacts $DEVKITPRO
COPY --from=wiiuenv/wiiupluginsystem:20220123 /artifacts $DEVKITPRO
COPY --from=wiiuenv/libwupsbackend:20220514 /artifacts $DEVKITPRO
COPY --from=wiiuenv/librpxloader:20220422 /artifacts $DEVKITPRO
COPY --from=wiiuenv/wiiupluginsystem:20220513 /artifacts $DEVKITPRO
WORKDIR project

View File

@ -39,7 +39,7 @@ CFLAGS += $(INCLUDE) -D__WIIU__ -D__WUT__ -D__WUPS__
CXXFLAGS := $(CFLAGS) -std=gnu++17
ASFLAGS := -g $(ARCH)
LDFLAGS = -g $(ARCH) $(RPXSPECS) -Wl,-Map,$(notdir $*.map) -T$(WUPS_ROOT)/share/libwupsbackend.ld -T$(WUMS_ROOT)/share/librpxloader.ld $(WUPSSPECS)
LDFLAGS = -g $(ARCH) $(RPXSPECS) -Wl,-Map,$(notdir $*.map) -T$(WUPS_ROOT)/share/libwupsbackend.ld $(WUPSSPECS)
ifeq ($(DEBUG),1)
CXXFLAGS += -DDEBUG -g

View File

@ -1,5 +1,7 @@
#include "utils/TcpReceiver.h"
#include "utils/logger.h"
#include <coreinit/debug.h>
#include <rpxloader/rpxloader.h>
#include <wups.h>
WUPS_PLUGIN_NAME("Wiiload");
@ -12,6 +14,14 @@ WUPS_USE_WUT_DEVOPTAB();
TcpReceiver *thread = nullptr;
INITIALIZE_PLUGIN() {
RPXLoaderStatus error;
if ((error = RPXLoader_Init()) != RPX_LOADER_RESULT_SUCCESS) {
DEBUG_FUNCTION_LINE_ERR("WiiLoad Plugin: Failed to init RPXLoader. Error %d", error);
OSFatal("WiiLoad Plugin: Failed to init RPXLoader.");
}
}
/* Entry point */
ON_APPLICATION_START() {
initLogging();

View File

@ -7,8 +7,7 @@
#include <coreinit/dynload.h>
#include <coreinit/title.h>
#include <cstring>
#include <rpxloader.h>
#include <string>
#include <rpxloader/rpxloader.h>
#include <sysapp/launch.h>
#include <sysapp/title.h>
#include <vector>
@ -148,7 +147,7 @@ int32_t TcpReceiver::loadToMemory(int32_t clientSocket, uint32_t ipAddress) {
// Do we need to unzip this thing?
if (haxx[4] > 0 || haxx[5] > 4) {
unsigned char *inflatedData = nullptr;
unsigned char *inflatedData;
// We need to unzip...
if (loadAddress[0] == 'P' && loadAddress[1] == 'K' && loadAddress[2] == 0x03 && loadAddress[3] == 0x04) {
@ -240,34 +239,34 @@ int32_t TcpReceiver::loadToMemory(int32_t clientSocket, uint32_t ipAddress) {
} else if (inflatedData[0x7] == 0xCA && inflatedData[0x8] == 0xFE && inflatedData[0x9] == 0x50 && inflatedData[0xA] == 0x4C) {
auto newContainer = PluginUtils::getPluginForBuffer((char *) inflatedData, fileSize);
if (newContainer) {
auto oldPlugins = PluginUtils::getLoadedPlugins(8);
std::vector<PluginContainer> finalList;
auto plugins = PluginUtils::getLoadedPlugins(32);
finalList.push_back(newContainer.value());
for (auto &plugin : oldPlugins) {
if (plugin.metaInformation.getName() == newContainer->metaInformation.getName() &&
plugin.metaInformation.getAuthor() == newContainer->metaInformation.getAuthor()) {
DEBUG_FUNCTION_LINE("Skipping duplicate");
PluginUtils::destroyPluginContainer(plugin);
continue;
} else {
finalList.push_back(plugin);
}
}
auto &metaInformation = newContainer.value()->metaInformation;
// remove plugins with the same name and author as our new plugin
plugins.erase(std::remove_if(plugins.begin(), plugins.end(),
[metaInformation](auto &plugin) {
return plugin->metaInformation->getName() == metaInformation->getName() &&
plugin->metaInformation->getAuthor() == metaInformation->getAuthor();
}),
plugins.end());
// at the new plugin
plugins.push_back(std::move(newContainer.value()));
#ifdef VERBOSE_DEBUG
for (auto &plugin : finalList) {
DEBUG_FUNCTION_LINE_VERBOSE("name: %s", plugin.getMetaInformation().getName().c_str());
DEBUG_FUNCTION_LINE_VERBOSE("author: %s", plugin.getMetaInformation().getAuthor().c_str());
DEBUG_FUNCTION_LINE_VERBOSE("handle: %08X", plugin.getPluginData().getHandle());
for (auto &plugin : plugins) {
DEBUG_FUNCTION_LINE_VERBOSE("name: %s", plugin->getMetaInformation()->getName().c_str());
DEBUG_FUNCTION_LINE_VERBOSE("author: %s", plugin->getMetaInformation()->getAuthor().c_str());
DEBUG_FUNCTION_LINE_VERBOSE("handle: %08X", plugin->getPluginData()->getHandle());
DEBUG_FUNCTION_LINE_VERBOSE("====");
}
#endif
if (PluginUtils::LoadAndLinkOnRestart(finalList) != 0) {
DEBUG_FUNCTION_LINE("Failed to load & link");
if (PluginUtils::LoadAndLinkOnRestart(plugins) != 0) {
DEBUG_FUNCTION_LINE_ERR("Failed to load & link");
}
PluginUtils::destroyPluginContainer(finalList);
free(loadAddress);
free(inflatedData);
@ -305,7 +304,7 @@ int32_t TcpReceiver::loadToMemory(int32_t clientSocket, uint32_t ipAddress) {
if (loadedRPX) {
DEBUG_FUNCTION_LINE("Starting a homebrew title!");
RL_LoadFromSDOnNextLaunch(file_path);
RPXLoader_LoadFromSDOnNextLaunch(file_path);
uint64_t titleID = _SYSGetSystemApplicationTitleId(SYSTEM_APP_ID_HEALTH_AND_SAFETY);
_SYSLaunchTitleWithStdArgsInNoSplash(titleID, nullptr);