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/libwupsbackend:20220514 /artifacts $DEVKITPRO
COPY --from=wiiuenv/librpxloader:20211002 /artifacts $DEVKITPRO COPY --from=wiiuenv/librpxloader:20220422 /artifacts $DEVKITPRO
COPY --from=wiiuenv/wiiupluginsystem:20220123 /artifacts $DEVKITPRO COPY --from=wiiuenv/wiiupluginsystem:20220513 /artifacts $DEVKITPRO
WORKDIR project WORKDIR project

View File

@ -39,7 +39,7 @@ CFLAGS += $(INCLUDE) -D__WIIU__ -D__WUT__ -D__WUPS__
CXXFLAGS := $(CFLAGS) -std=gnu++17 CXXFLAGS := $(CFLAGS) -std=gnu++17
ASFLAGS := -g $(ARCH) 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) ifeq ($(DEBUG),1)
CXXFLAGS += -DDEBUG -g CXXFLAGS += -DDEBUG -g

View File

@ -1,5 +1,7 @@
#include "utils/TcpReceiver.h" #include "utils/TcpReceiver.h"
#include "utils/logger.h" #include "utils/logger.h"
#include <coreinit/debug.h>
#include <rpxloader/rpxloader.h>
#include <wups.h> #include <wups.h>
WUPS_PLUGIN_NAME("Wiiload"); WUPS_PLUGIN_NAME("Wiiload");
@ -12,6 +14,14 @@ WUPS_USE_WUT_DEVOPTAB();
TcpReceiver *thread = nullptr; 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 */ /* Entry point */
ON_APPLICATION_START() { ON_APPLICATION_START() {
initLogging(); initLogging();

View File

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