Various fixes and clean up, reload application via _SYSLaunchTitleWithStdArgsInNoSplash when loading a plugin

This commit is contained in:
Maschell 2021-01-10 18:22:17 +01:00
parent d350fa801c
commit 6c1607b097
3 changed files with 16 additions and 49 deletions

View File

@ -12,34 +12,23 @@ WUPS_PLUGIN_LICENSE("GPL");
WUPS_USE_WUT_CRT() WUPS_USE_WUT_CRT()
TcpReceiver *thread = NULL; TcpReceiver *thread = nullptr;
/* Entry point */ /* Entry point */
ON_APPLICATION_START(args) { ON_APPLICATION_START(args) {
WHBLogUdpInit(); WHBLogUdpInit();
DEBUG_FUNCTION_LINE("Started wiiload thread"); DEBUG_FUNCTION_LINE("Start wiiload thread");
thread = new TcpReceiver(4299); thread = new TcpReceiver(4299);
} }
void stopThread() { void stopThread() {
if (thread != NULL) { if (thread != nullptr) {
delete thread; delete thread;
thread = NULL; thread = nullptr;
} }
} }
ON_APPLICATION_END() { ON_APPLICATION_END() {
DEBUG_FUNCTION_LINE("Kill thread"); DEBUG_FUNCTION_LINE("Kill wiiload thread");
stopThread(); 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));
}
}

View File

@ -1,5 +1,4 @@
#ifndef _MAIN_H_ #pragma once
#define _MAIN_H_
/* Main */ /* Main */
#ifdef __cplusplus #ifdef __cplusplus
@ -8,22 +7,6 @@ extern "C" {
#include <stdint.h> #include <stdint.h>
#include <nsysnet/socket.h> #include <nsysnet/socket.h>
#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 #ifdef __cplusplus
} }

View File

@ -6,6 +6,7 @@
#include <sysapp/launch.h> #include <sysapp/launch.h>
#include <coreinit/dynload.h> #include <coreinit/dynload.h>
#include <coreinit/title.h>
#include <coreinit/messagequeue.h> #include <coreinit/messagequeue.h>
#include <coreinit/ios.h> #include <coreinit/ios.h>
@ -99,13 +100,6 @@ void TcpReceiver::executeThread() {
socketclose(serverSocket); 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; extern bool gDoRelaunch;
int32_t TcpReceiver::loadToMemory(int32_t clientSocket, uint32_t ipAddress) { 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()); finalList.push_back(newContainer.value());
for (auto &plugin : oldPlugins) { for (auto &plugin : oldPlugins) {
if (plugin.metaInformation.getName().compare(newContainer->metaInformation.getName()) == 0 && if (plugin.metaInformation.getName() == newContainer->metaInformation.getName() &&
plugin.metaInformation.getAuthor().compare(newContainer->metaInformation.getAuthor()) == 0 plugin.metaInformation.getAuthor() == newContainer->metaInformation.getAuthor()
) { ) {
DEBUG_FUNCTION_LINE("Skipping duplicate"); DEBUG_FUNCTION_LINE("Skipping duplicate");
PluginUtils::destroyPluginContainer(plugin); PluginUtils::destroyPluginContainer(plugin);
@ -271,15 +265,16 @@ int32_t TcpReceiver::loadToMemory(int32_t clientSocket, uint32_t ipAddress) {
if (PluginUtils::LoadAndLinkOnRestart(finalList) != 0) { if (PluginUtils::LoadAndLinkOnRestart(finalList) != 0) {
DEBUG_FUNCTION_LINE("Failed to load & link"); DEBUG_FUNCTION_LINE("Failed to load & link");
PluginUtils::destroyPluginContainer(finalList);
} else { } else {
PluginUtils::destroyPluginContainer(finalList); //gDoRelaunch = true;
gDoRelaunch = 1; //DCFlushRange(&gDoRelaunch, sizeof(gDoRelaunch));
DCFlushRange(&gDoRelaunch, sizeof(gDoRelaunch));
} }
PluginUtils::destroyPluginContainer(finalList);
free(loadAddress); free(loadAddress);
free(inflatedData); free(inflatedData);
_SYSLaunchTitleWithStdArgsInNoSplash(OSGetTitleID(), 0);
return fileSize; return fileSize;
} else { } else {
DEBUG_FUNCTION_LINE("Failed to parse plugin"); DEBUG_FUNCTION_LINE("Failed to parse plugin");