Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"files.associations": {
"*.ejs": "html",
"array": "cpp",
"atomic": "cpp",
"bit": "cpp",
"*.tcc": "cpp",
"cctype": "cpp",
"charconv": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"compare": "cpp",
"concepts": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"deque": "cpp",
"string": "cpp",
"unordered_map": "cpp",
"vector": "cpp",
"exception": "cpp",
"algorithm": "cpp",
"functional": "cpp",
"iterator": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"optional": "cpp",
"random": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"format": "cpp",
"initializer_list": "cpp",
"iosfwd": "cpp",
"limits": "cpp",
"new": "cpp",
"numbers": "cpp",
"ostream": "cpp",
"span": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"text_encoding": "cpp",
"typeinfo": "cpp",
"variant": "cpp"
}
}
30 changes: 14 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ WUMS_ROOT := $(DEVKITPRO)/wums
TARGET := RosePatcher
BUILD := build
SOURCES := src src/utils src/patches
DATA := data
DATA := data data/1stNUP/Us data/1stNUP/Eu
INCLUDES := src

#-------------------------------------------------------------------------------
Expand Down Expand Up @@ -106,51 +106,49 @@ clean:
@rm -fr $(BUILD) $(TARGET).wps $(TARGET).elf

#-------------------------------------------------------------------------------
run: # need wiiload + wiiload plugin on the Wii U (get plugin at https://aroma.foryour.cafe/)
# ^^^^ (I don't know if it comes pre-installed with devkitpro without having the wii portion installed, so you can also get it from the hackmii installer https://bootmii.org/download)
run: # need wiiload + wiiload plugin on the Wii U
@wiiload $(TARGET).wps

#-------------------------------------------------------------------------------
else
.PHONY: all
.PHONY: all

DEPENDS := $(OFILES:.o=.d)

#-------------------------------------------------------------------------------
# main targets
#-------------------------------------------------------------------------------
all : $(OUTPUT).wps
all : $(OUTPUT).wps

$(OUTPUT).wps : $(OUTPUT).elf
$(OUTPUT).elf : $(OFILES)
$(OUTPUT).wps : $(OUTPUT).elf
$(OUTPUT).elf : $(OFILES)

$(OFILES_SRC) : $(HFILES_BIN)

#-------------------------------------------------------------------------------
# you need a rule like this for each extension you use as binary data
#-------------------------------------------------------------------------------
%.bin.o %_bin.h : %.bin
#-------------------------------------------------------------------------------
%.bin.o %_bin.h : %.bin
@echo $(notdir $<)
@$(bin2o)

%.txt.o %_txt.h : %.txt
#-------------------------------------------------------------------------------
%.txt.o %_txt.h : %.txt
@echo $(notdir $<)
@$(bin2o)

%.der.o %_der.h : %.der
#-------------------------------------------------------------------------------
%.der.o %_der.h : %.der
@echo $(notdir $<)
@$(bin2o)

%.pem.o %_pem.h : %.pem
#-------------------------------------------------------------------------------
%.pem.o %_pem.h : %.pem
@echo $(notdir $<)
@$(bin2o)

-include $(DEPENDS)
%.xml.o %_xml.h : %.xml
@echo $(notdir $<)
@$(bin2o)

-include $(DEPENDS)

#-------------------------------------------------------------------------------
endif
Expand Down
4,736 changes: 4,736 additions & 0 deletions data/1stNUP/Eu/EuDutch.xml

Large diffs are not rendered by default.

4,736 changes: 4,736 additions & 0 deletions data/1stNUP/Eu/EuEnglish.xml

Large diffs are not rendered by default.

4,738 changes: 4,738 additions & 0 deletions data/1stNUP/Eu/EuFrench.xml

Large diffs are not rendered by default.

4,740 changes: 4,740 additions & 0 deletions data/1stNUP/Eu/EuGerman.xml

Large diffs are not rendered by default.

4,739 changes: 4,739 additions & 0 deletions data/1stNUP/Eu/EuItalian.xml

Large diffs are not rendered by default.

4,737 changes: 4,737 additions & 0 deletions data/1stNUP/Eu/EuPortuguese.xml

Large diffs are not rendered by default.

4,740 changes: 4,740 additions & 0 deletions data/1stNUP/Eu/EuRussian.xml

Large diffs are not rendered by default.

4,738 changes: 4,738 additions & 0 deletions data/1stNUP/Eu/EuSpanish.xml

Large diffs are not rendered by default.

4,738 changes: 4,738 additions & 0 deletions data/1stNUP/Us/UsEnglish.xml

Large diffs are not rendered by default.

4,739 changes: 4,739 additions & 0 deletions data/1stNUP/Us/UsFrench.xml

Large diffs are not rendered by default.

4,737 changes: 4,737 additions & 0 deletions data/1stNUP/Us/UsPortuguese.xml

Large diffs are not rendered by default.

4,739 changes: 4,739 additions & 0 deletions data/1stNUP/Us/UsSpanish.xml

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions data/rose_config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ EnableAc:1
EnableEventLock:1

# User Agent Setting
# UserAgent_String: Mozilla/5.0 (Nintendo WiiU) AppleWebKit/534.52 (KHTML, like Gecko) NX/
# UserAgent_String: Mozilla/5.0 (Nintendo WiiU) AppleWebKit/534.52 (KHTML, like Gecko) NX/2.2.0.8.21 vn/1.1.JP
# 0/1/2/3 WhiteList Setting.
# 0:None (vino does not use white-list)
# 1:File (vino uses white-list on file, path is written at 'WhiteList_Path')
# 2:Network (vino uses white-list on network, path is written at 'WhiteList_Path'. in this mode, white-list is downloaded with a paticular ssl certification for client and server.)
# 3:Release (vino uses the final environment by each region.)
WhiteList_Use:2
WhiteList_Path:https://web-jp.l1.jp.vino.wup.app.projectrose.cafe/whitelist.txt?country=jp
WhiteList_Path:https://web-jp.l1.jp.vino.wup.app.projectrose.cafe/whitelist.txt?country=us

# Allow 'file:' and 'http:' scheme. Finally, it is set to 'Not Allow'
# 0:Not Allow
Expand Down
16 changes: 16 additions & 0 deletions src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ namespace config {
bool connectToRose = CONNECT_TO_ROSE_DEFUALT_VALUE;
bool tviiIconHBM = TVII_ICON_HBM_PATCH_DEFAULT_VALUE;
bool tviiIconWUM = TVII_ICON_WUM_PATCH_DEFAULT_VALUE;
bool patchWWP = PATCH_WWP_DEFUALT_VALUE;
bool forceJPNconsole = FORCE_JPN_CONSOLE_DEFAULT_VALUE;
bool needRelaunch = false;

Expand Down Expand Up @@ -51,6 +52,18 @@ namespace config {
}
}

void patchWWPChanged(ConfigItemBoolean *item, bool newValue) {
if (patchWWP != newValue) {
WUPSStorageAPI::Store(PATCH_WWP_COFNIG_ID, newValue);
}

patchWWP = newValue;
auto title = OSGetTitleID();
if (utils::isWiiUMenuTitleID(title, false)) {
needRelaunch = true;
}
}

// Open event for the Aroma config menu
WUPSConfigAPICallbackStatus ConfigMenuOpenedCallback(WUPSConfigCategoryHandle rootHandle) {
WUPSConfigCategory root = WUPSConfigCategory(rootHandle);
Expand All @@ -66,6 +79,9 @@ namespace config {
root.add(WUPSConfigItemBoolean::Create(TVII_ICON_WUM_PATCH_COFNIG_ID, "Add TVii Icon to the Wii U Menu", TVII_ICON_WUM_PATCH_DEFAULT_VALUE, tviiIconWUM, tviiIconWUMChanged));
root.add(WUPSConfigItemStub::Create("Note: Wii U Menu will restart if \"Add TVii Icon to the Wii U Menu\""));
root.add(WUPSConfigItemStub::Create("is toggled."));
root.add(WUPSConfigItemBoolean::Create(PATCH_WWP_COFNIG_ID, "Add TVii Icon to Wara Wara Plaza", PATCH_WWP_DEFUALT_VALUE, patchWWP, patchWWPChanged));
root.add(WUPSConfigItemStub::Create("Note: Wii U Menu will restart if \"Add TVii Icon to Wara Wara Plaza\""));
root.add(WUPSConfigItemStub::Create("is toggled."));
}
} catch (std::exception &e) {
DEBUG_FUNCTION_LINE("Creating config menu failed: %s", e.what());
Expand Down
7 changes: 6 additions & 1 deletion src/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
#define TVII_ICON_WUM_PATCH_COFNIG_ID "tvii_icon_wum_patch"
#define TVII_ICON_WUM_PATCH_DEFAULT_VALUE true

#define PATCH_WWP_COFNIG_ID "tvii_icon_wwp_patch"
#define PATCH_WWP_DEFUALT_VALUE true

#define FORCE_JPN_CONSOLE_CONFIG_ID "force_jpn_console"
#define FORCE_JPN_CONSOLE_DEFAULT_VALUE false

Expand All @@ -27,12 +30,14 @@ namespace config {
extern bool connectToRose;
extern bool tviiIconHBM;
extern bool tviiIconWUM;
extern bool needRelaunch;
extern bool patchWWP;
extern bool forceJPNconsole;
extern bool needRelaunch;

void connectToRoseChanged(ConfigItemBoolean *item, bool newValue);
void tviiIconHBMChanged(ConfigItemBoolean *item, bool newValue);
void tviiIconWUMChanged(ConfigItemBoolean *item, bool newValue);
void patchWWPChanged(ConfigItemBoolean *item, bool newValue);

WUPSConfigAPICallbackStatus ConfigMenuOpenedCallback(WUPSConfigCategoryHandle rootHandle);

Expand Down
128 changes: 127 additions & 1 deletion src/patches/fileReplacements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,57 @@
#include "../utils/logger.h"
#include "../utils/patch.hpp"

#include "rose_config_txt.h" // included at runtime
// included at runtime
#include "rose_config_txt.h"
#include "UsEnglish_xml.h"
#include "UsFrench_xml.h"
#include "UsPortuguese_xml.h"
#include "UsSpanish_xml.h"
#include "EuDutch_xml.h"
#include "EuEnglish_xml.h"
#include "EuFrench_xml.h"
#include "EuGerman_xml.h"
#include "EuItalian_xml.h"
#include "EuPortuguese_xml.h"
#include "EuRussian_xml.h"
#include "EuSpanish_xml.h"

#define VINO_CONFIG_PATH "/vol/content/vino_config.txt"

const char* WWP_PATH = nullptr;

int getWWPPath() {
if (utils::getConsoleRegion() == 'U' && utils::getConsoleLanguage() == nn::swkbd::LanguageType::English) {
WWP_PATH = "/vol/content/UsEnglish/olive/1stNUP.xml";
} else if (utils::getConsoleRegion() == 'U' && utils::getConsoleLanguage() == nn::swkbd::LanguageType::French) {
WWP_PATH = "/vol/content/UsFrench/olive/1stNUP.xml";
} else if (utils::getConsoleRegion() == 'U' && utils::getConsoleLanguage() == nn::swkbd::LanguageType::Portuguese) {
WWP_PATH = "/vol/content/UsPortuguese/olive/1stNUP.xml";
} else if (utils::getConsoleRegion() == 'U' && utils::getConsoleLanguage() == nn::swkbd::LanguageType::Spanish) {
WWP_PATH = "/vol/content/UsSpanish/olive/1stNUP.xml";
} else if (utils::getConsoleRegion() == 'E' && utils::getConsoleLanguage() == nn::swkbd::LanguageType::Dutch) {
WWP_PATH = "/vol/content/EuDutch/olive/1stNUP.xml";
} else if (utils::getConsoleRegion() == 'E' && utils::getConsoleLanguage() == nn::swkbd::LanguageType::English) {
WWP_PATH = "/vol/content/EuEnglish/olive/1stNUP.xml";
} else if (utils::getConsoleRegion() == 'E' && utils::getConsoleLanguage() == nn::swkbd::LanguageType::French) {
WWP_PATH = "/vol/content/EuFrench/olive/1stNUP.xml";
} else if (utils::getConsoleRegion() == 'E' && utils::getConsoleLanguage() == nn::swkbd::LanguageType::German) {
WWP_PATH = "/vol/content/EuGerman/olive/1stNUP.xml";
} else if (utils::getConsoleRegion() == 'E' && utils::getConsoleLanguage() == nn::swkbd::LanguageType::Italian) {
WWP_PATH = "/vol/content/EuItalian/olive/1stNUP.xml";
} else if (utils::getConsoleRegion() == 'E' && utils::getConsoleLanguage() == nn::swkbd::LanguageType::Portuguese) {
WWP_PATH = "/vol/content/EuPortuguese/olive/1stNUP.xml";
} else if (utils::getConsoleRegion() == 'E' && utils::getConsoleLanguage() == nn::swkbd::LanguageType::Russian) {
WWP_PATH = "/vol/content/EuRussian/olive/1stNUP.xml";
} else if (utils::getConsoleRegion() == 'E' && utils::getConsoleLanguage() == nn::swkbd::LanguageType::Spanish) {
WWP_PATH = "/vol/content/EuSpanish/olive/1stNUP.xml";
}

return 0;
}

int result = getWWPPath();

static std::optional<FSFileHandle> config_handle{};

DECL_FUNCTION(FSStatus, FSOpenFile_VINO, FSClient *client, FSCmdBlock *block,
Expand Down Expand Up @@ -54,3 +101,82 @@ DECL_FUNCTION(FSStatus, FSCloseFile_VINO, FSClient *client, FSCmdBlock *block, F
WUPS_MUST_REPLACE_FOR_PROCESS(FSOpenFile_VINO, WUPS_LOADER_LIBRARY_COREINIT, FSOpenFile, WUPS_FP_TARGET_PROCESS_TVII);
WUPS_MUST_REPLACE_FOR_PROCESS(FSReadFile_VINO, WUPS_LOADER_LIBRARY_COREINIT, FSReadFile, WUPS_FP_TARGET_PROCESS_TVII);
WUPS_MUST_REPLACE_FOR_PROCESS(FSCloseFile_VINO, WUPS_LOADER_LIBRARY_COREINIT, FSCloseFile, WUPS_FP_TARGET_PROCESS_TVII);

DECL_FUNCTION(FSStatus, FSOpenFile_WWP, FSClient *client, FSCmdBlock *block,
const char *path, const char *mode, FSFileHandle *handle,
FSErrorFlag errorMask) {

// DEBUG("Wii U wants to open file: %s", path);

if (config::patchWWP && strcmp(WWP_PATH, path) == 0) {
FSStatus res = real_FSOpenFile_WWP(client, block, path, mode, handle, errorMask);
config_handle = *handle;
return res;
}

return real_FSOpenFile_WWP(client, block, path, mode, handle, errorMask);
}

DECL_FUNCTION(FSStatus, FSReadFile_WWP, FSClient *client, FSCmdBlock *block, uint8_t *buffer, uint32_t size, uint32_t count,
FSFileHandle handle, uint32_t unk1, uint32_t flags) {
if (size != 1) {
DEBUG_FUNCTION_LINE("Falied to patch 1stNUP. Size is not 1");
}


if (config_handle && *config_handle == handle) {
DEBUG_FUNCTION_LINE("Trying to read 1stNUP detected, returning patched data.");
if (utils::getConsoleRegion() == 'U' && utils::getConsoleLanguage() == nn::swkbd::LanguageType::English) {
strlcpy((char *) buffer, (const char *) UsEnglish_xml, size * count);
return (FSStatus) count;
} else if (utils::getConsoleRegion() == 'U' && utils::getConsoleLanguage() == nn::swkbd::LanguageType::French) {
strlcpy((char *) buffer, (const char *) UsFrench_xml, size * count);
return (FSStatus) count;
} else if (utils::getConsoleRegion() == 'U' && utils::getConsoleLanguage() == nn::swkbd::LanguageType::Portuguese) {
strlcpy((char *) buffer, (const char *) UsPortuguese_xml, size * count);
return (FSStatus) count;
} else if (utils::getConsoleRegion() == 'U' && utils::getConsoleLanguage() == nn::swkbd::LanguageType::Spanish) {
strlcpy((char *) buffer, (const char *) UsSpanish_xml, size * count);
return (FSStatus) count;
} else if (utils::getConsoleRegion() == 'E' && utils::getConsoleLanguage() == nn::swkbd::LanguageType::Dutch) {
strlcpy((char *) buffer, (const char *) EuDutch_xml, size * count);
return (FSStatus) count;
} else if (utils::getConsoleRegion() == 'E' && utils::getConsoleLanguage() == nn::swkbd::LanguageType::English) {
strlcpy((char *) buffer, (const char *) EuEnglish_xml, size * count);
return (FSStatus) count;
} else if (utils::getConsoleRegion() == 'E' && utils::getConsoleLanguage() == nn::swkbd::LanguageType::French) {
strlcpy((char *) buffer, (const char *) EuFrench_xml, size * count);
return (FSStatus) count;
} else if (utils::getConsoleRegion() == 'E' && utils::getConsoleLanguage() == nn::swkbd::LanguageType::German) {
strlcpy((char *) buffer, (const char *) EuGerman_xml, size * count);
return (FSStatus) count;
} else if (utils::getConsoleRegion() == 'E' && utils::getConsoleLanguage() == nn::swkbd::LanguageType::Italian) {
strlcpy((char *) buffer, (const char *) EuItalian_xml, size * count);
return (FSStatus) count;
} else if (utils::getConsoleRegion() == 'E' && utils::getConsoleLanguage() == nn::swkbd::LanguageType::Portuguese) {
strlcpy((char *) buffer, (const char *) EuPortuguese_xml, size * count);
return (FSStatus) count;
} else if (utils::getConsoleRegion() == 'E' && utils::getConsoleLanguage() == nn::swkbd::LanguageType::Russian) {
strlcpy((char *) buffer, (const char *) EuRussian_xml, size * count);
return (FSStatus) count;
} else if (utils::getConsoleRegion() == 'E' && utils::getConsoleLanguage() == nn::swkbd::LanguageType::Spanish) {
strlcpy((char *) buffer, (const char *) EuSpanish_xml, size * count);
return (FSStatus) count;
}
}

return real_FSReadFile_WWP(client, block, buffer, size, count, handle, unk1, flags);
}

DECL_FUNCTION(FSStatus, FSCloseFile_WWP, FSClient *client, FSCmdBlock *block, FSFileHandle handle, FSErrorFlag errorMask) {
if (handle == config_handle) {
DEBUG("Closing 1stNUP file and resetting handle");
config_handle.reset();
}

return real_FSCloseFile_WWP(client, block, handle, errorMask);
}

WUPS_MUST_REPLACE_FOR_PROCESS(FSOpenFile_WWP, WUPS_LOADER_LIBRARY_COREINIT, FSOpenFile, WUPS_FP_TARGET_PROCESS_WII_U_MENU);
WUPS_MUST_REPLACE_FOR_PROCESS(FSReadFile_WWP, WUPS_LOADER_LIBRARY_COREINIT, FSReadFile, WUPS_FP_TARGET_PROCESS_WII_U_MENU);
WUPS_MUST_REPLACE_FOR_PROCESS(FSCloseFile_WWP, WUPS_LOADER_LIBRARY_COREINIT, FSCloseFile, WUPS_FP_TARGET_PROCESS_WII_U_MENU);
6 changes: 3 additions & 3 deletions src/patches/olvFix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ namespace patches::olv {
}
}

DECL_FUNCTION(int, FSOpenFile, FSClient *pClient, FSCmdBlock *pCmd,
DECL_FUNCTION(int, FSOpenFile_OLV, FSClient *pClient, FSCmdBlock *pCmd,
const char *path, const char *mode, int *handle, int error) {
if (strcmp("/vol/content/vino_config.txt", path) == 0) {
OSDynLoad_AddNotifyCallback(&osdynload_notify_callback, nullptr);
}

return real_FSOpenFile(pClient, pCmd, path, mode, handle, error);;
return real_FSOpenFile_OLV(pClient, pCmd, path, mode, handle, error);;
}

WUPS_MUST_REPLACE_FOR_PROCESS(FSOpenFile, WUPS_LOADER_LIBRARY_COREINIT, FSOpenFile, WUPS_FP_TARGET_PROCESS_TVII);
WUPS_MUST_REPLACE_FOR_PROCESS(FSOpenFile_OLV, WUPS_LOADER_LIBRARY_COREINIT, FSOpenFile, WUPS_FP_TARGET_PROCESS_TVII);
} // namespace olv
6 changes: 3 additions & 3 deletions src/patches/tviiIcon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@ namespace patches::icon {
}
}; // namespace icon

DECL_FUNCTION(int, FSOpenFile, FSClient *pClient, FSCmdBlock *pCmd, const char *path, const char *mode, int *handle, int error) {
DECL_FUNCTION(int, FSOpenFile_TVii, FSClient *pClient, FSCmdBlock *pCmd, const char *path, const char *mode, int *handle, int error) {
if (strcmp("/vol/content/Common/Package/Hbm2-2.pack", path) == 0) {
patches::icon::perform_hbm_patches(config::tviiIconHBM);
}

return real_FSOpenFile(pClient, pCmd, path, mode, handle, error);;
return real_FSOpenFile_TVii(pClient, pCmd, path, mode, handle, error);;
}

WUPS_MUST_REPLACE_FOR_PROCESS(FSOpenFile, WUPS_LOADER_LIBRARY_COREINIT, FSOpenFile, WUPS_FP_TARGET_PROCESS_ALL);
WUPS_MUST_REPLACE_FOR_PROCESS(FSOpenFile_TVii, WUPS_LOADER_LIBRARY_COREINIT, FSOpenFile, WUPS_FP_TARGET_PROCESS_ALL);
Loading
Loading