From 6c1607b0975c959a03ce031f3ea87050799305c8 Mon Sep 17 00:00:00 2001 From: Maschell Date: Sun, 10 Jan 2021 18:22:17 +0100 Subject: [PATCH] Various fixes and clean up, reload application via _SYSLaunchTitleWithStdArgsInNoSplash when loading a plugin --- src/main.cpp | 23 ++++++----------------- src/main.h | 19 +------------------ src/utils/TcpReceiver.cpp | 23 +++++++++-------------- 3 files changed, 16 insertions(+), 49 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index a455068..3235066 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -12,34 +12,23 @@ WUPS_PLUGIN_LICENSE("GPL"); WUPS_USE_WUT_CRT() -TcpReceiver *thread = NULL; +TcpReceiver *thread = nullptr; /* Entry point */ ON_APPLICATION_START(args) { WHBLogUdpInit(); - DEBUG_FUNCTION_LINE("Started wiiload thread"); + DEBUG_FUNCTION_LINE("Start wiiload thread"); thread = new TcpReceiver(4299); } void stopThread() { - if (thread != NULL) { + if (thread != nullptr) { delete thread; - thread = NULL; + thread = nullptr; } } ON_APPLICATION_END() { - DEBUG_FUNCTION_LINE("Kill thread"); + DEBUG_FUNCTION_LINE("Kill wiiload thread"); stopThread(); -} - -bool gDoRelaunch __attribute__((section(".data"))) = 0; - -ON_VYSNC() { - // On each frame check if we want to exit. - if(gDoRelaunch){ - SYSRelaunchTitle(0, NULL); - gDoRelaunch = 0; - DCFlushRange(&gDoRelaunch, sizeof(gDoRelaunch)); - } -} +} \ No newline at end of file diff --git a/src/main.h b/src/main.h index dfc7038..67b89ad 100644 --- a/src/main.h +++ b/src/main.h @@ -1,5 +1,4 @@ -#ifndef _MAIN_H_ -#define _MAIN_H_ +#pragma once /* Main */ #ifdef __cplusplus @@ -8,22 +7,6 @@ extern "C" { #include #include -#define MAXPATHLEN 256 - -#define WIIU_EAGAIN EWOULDBLOCK -#define ENODATA 1 -#define EISCONN 3 -#define EWOULDBLOCK 6 -#define EALREADY 10 -#define EAGAIN EWOULDBLOCK -#define EINVAL 11 -#define ENOMEM 18 -#define EINPROGRESS 22 - -#define wiiu_geterrno() (socketlasterr()) - -//! C wrapper for our C++ functions -int Menu_Main(void); #ifdef __cplusplus } diff --git a/src/utils/TcpReceiver.cpp b/src/utils/TcpReceiver.cpp index becaa7a..6f250e5 100644 --- a/src/utils/TcpReceiver.cpp +++ b/src/utils/TcpReceiver.cpp @@ -6,6 +6,7 @@ #include #include +#include #include #include @@ -99,13 +100,6 @@ void TcpReceiver::executeThread() { socketclose(serverSocket); } -typedef struct __attribute((packed)) { - uint32_t command; - uint32_t target; - uint32_t filesize; - uint32_t fileoffset; - char path[256]; -} LOAD_REQUEST; extern bool gDoRelaunch; int32_t TcpReceiver::loadToMemory(int32_t clientSocket, uint32_t ipAddress) { @@ -251,8 +245,8 @@ int32_t TcpReceiver::loadToMemory(int32_t clientSocket, uint32_t ipAddress) { finalList.push_back(newContainer.value()); for (auto &plugin : oldPlugins) { - if (plugin.metaInformation.getName().compare(newContainer->metaInformation.getName()) == 0 && - plugin.metaInformation.getAuthor().compare(newContainer->metaInformation.getAuthor()) == 0 + if (plugin.metaInformation.getName() == newContainer->metaInformation.getName() && + plugin.metaInformation.getAuthor() == newContainer->metaInformation.getAuthor() ) { DEBUG_FUNCTION_LINE("Skipping duplicate"); PluginUtils::destroyPluginContainer(plugin); @@ -270,16 +264,17 @@ int32_t TcpReceiver::loadToMemory(int32_t clientSocket, uint32_t ipAddress) { } if (PluginUtils::LoadAndLinkOnRestart(finalList) != 0) { - DEBUG_FUNCTION_LINE("Failed to load& link"); - PluginUtils::destroyPluginContainer(finalList); + DEBUG_FUNCTION_LINE("Failed to load & link"); } else { - PluginUtils::destroyPluginContainer(finalList); - gDoRelaunch = 1; - DCFlushRange(&gDoRelaunch, sizeof(gDoRelaunch)); + //gDoRelaunch = true; + //DCFlushRange(&gDoRelaunch, sizeof(gDoRelaunch)); } + PluginUtils::destroyPluginContainer(finalList); free(loadAddress); free(inflatedData); + + _SYSLaunchTitleWithStdArgsInNoSplash(OSGetTitleID(), 0); return fileSize; } else { DEBUG_FUNCTION_LINE("Failed to parse plugin");