Use the latest wut version

This commit is contained in:
Maschell 2021-04-17 11:53:51 +02:00
parent b560e1d2ba
commit a45d0d092d
4 changed files with 73 additions and 18 deletions

View File

@ -1,4 +1,4 @@
FROM wiiuenv/devkitppc:20210101
FROM wiiuenv/devkitppc:20210414
COPY --from=wiiuenv/wiiumodulesystem:20210219 /artifacts $DEVKITPRO

View File

@ -4,7 +4,6 @@
#include <cstdint>
#include <coreinit/dynload.h>
#include <coreinit/cache.h>
#include <nsysnet/socket.h>
#include <map>
#include <algorithm>
#include <coreinit/memexpheap.h>
@ -21,6 +20,8 @@ MEMHeapHandle gHeapHandle __attribute__((section(".data"))) = nullptr;
uint8_t gFunctionsPatched __attribute__((section(".data"))) = 0;
uint8_t gInitCalled __attribute__((section(".data"))) = 0;
extern "C" void socket_lib_init();
std::vector<ModuleData> OrderModulesByDependencies(const std::vector<ModuleData> &loadedModules);
extern "C" void doStart(int argc, char **argv);
@ -41,6 +42,8 @@ extern "C" int _start(int argc, char **argv) {
doStart(argc, argv);
DEBUG_FUNCTION_LINE_VERBOSE("Call real one\n");
log_deinit();
return ((int (*)(int, char **)) (*(unsigned int *) 0x1005E040))(argc, argv);
}

View File

@ -4,9 +4,7 @@
#include <string.h>
#include <errno.h>
#include "logger.h"
#include <nsysnet/socket.h>
#include <coreinit/debug.h>
#include <coreinit/systeminfo.h>
#include <coreinit/thread.h>
@ -14,7 +12,57 @@ static int log_socket __attribute__((section(".data"))) = -1;
static struct sockaddr_in connect_addr __attribute__((section(".data")));
static volatile int log_lock __attribute__((section(".data"))) = 0;
void log_init_() {
#define SOL_SOCKET -1
#define SOCK_DGRAM 2
#define INADDR_ANY 0
#define INADDR_BROADCAST 0xFFFFFFFF
#define PF_UNSPEC 0
#define PF_INET 2
#define PF_INET6 23
#define AF_UNSPEC PF_UNSPEC
#define AF_INET PF_INET
#define AF_INET6 PF_INET6
#define IPPROTO_UDP 17
#define SO_BROADCAST 0x0020 // broadcast
typedef uint16_t sa_family_t;
struct in_addr
{
unsigned int s_addr;
};
struct sockaddr
{
sa_family_t sa_family;
char sa_data[];
};
struct sockaddr_in
{
unsigned short sin_family;
unsigned short sin_port;
struct in_addr sin_addr;
char sin_zero[8];
};
typedef uint32_t socklen_t;
extern int setsockopt(int sockfd, int level, int optname, const void *optval, socklen_t optlen);
extern int socket(int domain, int type, int protocol);
extern int socketclose(int sockfd);
extern int sendto(int sockfd, const void *buf, size_t len, int flags, const struct sockaddr *dest_addr, socklen_t addrlen);
extern uint32_t htonl(uint32_t val);
void log_init() {
int broadcastEnable = 1;
log_socket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (log_socket < 0)
@ -28,7 +76,16 @@ void log_init_() {
connect_addr.sin_addr.s_addr = htonl(INADDR_BROADCAST);
}
void log_print_(const char *str) {
void log_deinit() {
if (log_socket < 0){
return;
}
if(socketclose(log_socket) != 0) {
return;
}
}
void log_print(const char *str) {
// socket is always 0 initially as it is in the BSS
if (log_socket < 0) {
return;
@ -65,7 +122,7 @@ void OSFatal_printf(const char *format, ...) {
va_end(va);
}
void log_printf_(const char *format, ...) {
void log_printf(const char *format, ...) {
if (log_socket < 0) {
return;
}
@ -76,7 +133,7 @@ void log_printf_(const char *format, ...) {
va_list va;
va_start(va, format);
if ((vsprintf(tmp, format, va) >= 0)) {
log_print_(tmp);
log_print(tmp);
}
va_end(va);
}

View File

@ -7,12 +7,13 @@ extern "C" {
#include <string.h>
void log_init_();
void log_init();
//void log_deinit_(void);
void log_print_(const char *str);
void log_deinit(void);
void log_printf_(const char *format, ...);
void log_print(const char *str);
void log_printf(const char *format, ...);
void OSFatal_printf(const char *format, ...);
@ -23,12 +24,6 @@ void OSFatal_printf(const char *format, ...);
OSFatal_printf("[%s]%s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \
} while (0)
#define log_init() log_init_()
//#define log_deinit() log_deinit_()
#define log_print(str) log_print_(str)
#define log_printf(FMT, ARGS...) log_printf_(FMT, ## ARGS);
#define DEBUG_FUNCTION_LINE(FMT, ARGS...)do { \
log_printf("[%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \
} while (0)