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()
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));
}
}

View File

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

View File

@ -6,6 +6,7 @@
#include <sysapp/launch.h>
#include <coreinit/dynload.h>
#include <coreinit/title.h>
#include <coreinit/messagequeue.h>
#include <coreinit/ios.h>
@ -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");