Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring for WUPS 0.8.0 #28

Merged
merged 5 commits into from
Apr 26, 2024
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
- name: zip artifact
run: zip -r ${{ env.REPOSITORY_NAME }}_${{ env.DATETIME }}.zip *.wps
- name: Create Release
uses: "softprops/action-gh-release@v1"
uses: "softprops/action-gh-release@v2"
with:
tag_name: ${{ env.REPOSITORY_NAME }}-${{ env.DATETIME }}
draft: false
Expand Down
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM ghcr.io/wiiu-env/devkitppc:20230621
FROM ghcr.io/wiiu-env/devkitppc:20240423

COPY --from=ghcr.io/wiiu-env/wiiupluginsystem:20230719 /artifacts $DEVKITPRO
COPY --from=ghcr.io/wiiu-env/wiiupluginsystem:20240425 /artifacts $DEVKITPRO
COPY --from=ghcr.io/wiiu-env/libmappedmemory:20230621 /artifacts $DEVKITPRO
COPY --from=ghcr.io/wiiu-env/libnotifications:20230621 /artifacts $DEVKITPRO

WORKDIR project
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ CXXFLAGS += -DDEBUG -DVERBOSE_DEBUG -g
CFLAGS += -DDEBUG -DVERBOSE_DEBUG -g
endif

LIBS := -lwups -lwut -lmappedmemory
LIBS := -lwups -lwut -lnotifications -lmappedmemory

#-------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level
Expand Down
68 changes: 68 additions & 0 deletions src/function_patches.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#include "utils/SettingsUtils.h"
#include "utils/logger.h"
#include <coreinit/debug.h>
#include <coreinit/userconfig.h>
#include <nn/acp/title.h>
#include <string_view>
#include <sysapp/switch.h>
#include <sysapp/title.h>
#include <wups/function_patching.h>

DECL_FUNCTION(int32_t, ACPGetTitleMetaXmlByDevice, uint64_t titleid, ACPMetaXml *metaxml, uint32_t device) {
int result = real_ACPGetTitleMetaXmlByDevice(titleid, metaxml, device);
if (metaxml != nullptr) {
metaxml->region = 0xFFFFFFFF;
}
return result;
}

DECL_FUNCTION(int32_t, ACPGetLaunchMetaXml, ACPMetaXml *metaxml) {
int result = real_ACPGetLaunchMetaXml(metaxml);
if (metaxml != nullptr) {
metaxml->region = 0xFFFFFFFF;
}

return result;
}

DECL_FUNCTION(int, UCReadSysConfig, int IOHandle, int count, UCSysConfig *settings) {
int result = real_UCReadSysConfig(IOHandle, count, settings);
auto upid = OSGetUPID();

if (!gRegionFreeValuesSetupDone || result != 0 || (upid != SYSAPP_PFID_WII_U_MENU && upid != SYSAPP_PFID_DOWNLOAD_GAME && upid != SYSAPP_PFID_EMANUAL)) {
return result;
}

if (std::string_view("cafe.language") == settings->name) {
DEBUG_FUNCTION_LINE_VERBOSE("UCReadSysConfig: cafe.language found!");
DEBUG_FUNCTION_LINE_VERBOSE("UCReadSysConfig: forcing language...");
DEBUG_FUNCTION_LINE("UCReadSysConfig: original lang %d, new %d", *((int *) settings->data), gCurrentLanguage);
*((int *) settings->data) = gCurrentLanguage;
} else if (std::string_view("cafe.cntry_reg") == settings->name) {
DEBUG_FUNCTION_LINE_VERBOSE("UCReadSysConfig: cafe.cntry_reg found!");
DEBUG_FUNCTION_LINE_VERBOSE("UCReadSysConfig: forcing cntry_reg...");
DEBUG_FUNCTION_LINE("UCReadSysConfig: original cntry_reg %d, new %d", *((int *) settings->data), gCurrentCountry);
*((int *) settings->data) = gCurrentCountry;
}

return result;
}

DECL_FUNCTION(int, MCP_GetSysProdSettings, int IOHandle, MCPSysProdSettings *settings) {
int result = real_MCP_GetSysProdSettings(IOHandle, settings);
auto upid = OSGetUPID();
if (!gRegionFreeValuesSetupDone || result != 0 || (upid != SYSAPP_PFID_WII_U_MENU && upid != SYSAPP_PFID_DOWNLOAD_GAME && upid != SYSAPP_PFID_EMANUAL)) {
return result;
}

DEBUG_FUNCTION_LINE_VERBOSE("MCP_GetSysProdSettings: forcing platform region...");
DEBUG_FUNCTION_LINE("MCP_GetSysProdSettings: original region %d, new %d...", settings->product_area, gCurrentProductArea);
settings->product_area = gCurrentProductArea;

return result;
}

WUPS_MUST_REPLACE(ACPGetTitleMetaXmlByDevice, WUPS_LOADER_LIBRARY_NN_ACP, ACPGetTitleMetaXmlByDevice);
WUPS_MUST_REPLACE(ACPGetLaunchMetaXml, WUPS_LOADER_LIBRARY_NN_ACP, ACPGetLaunchMetaXml);
WUPS_MUST_REPLACE_FOR_PROCESS(MCP_GetSysProdSettings, WUPS_LOADER_LIBRARY_COREINIT, MCP_GetSysProdSettings, WUPS_FP_TARGET_PROCESS_ALL);
WUPS_MUST_REPLACE_FOR_PROCESS(UCReadSysConfig, WUPS_LOADER_LIBRARY_COREINIT, UCReadSysConfig, WUPS_FP_TARGET_PROCESS_ALL);
7 changes: 7 additions & 0 deletions src/function_patches.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#pragma once

#include <coreinit/mcp.h>
#include <coreinit/userconfig.h>

extern "C" int (*real_UCReadSysConfig)(int IOHandle, int count, UCSysConfig *settings) __attribute__((section(".data")));
extern "C" int (*real_MCP_GetSysProdSettings)(int IOHandle, MCPSysProdSettings *settings) __attribute__((section(".data")));
34 changes: 18 additions & 16 deletions src/globals.cpp
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
#include "globals.h"

int gPreferSystemSettings = 1;
int gSkipOwnRegion = 1;
int gAutoDetection = 1;
int gForceSettingsEnabled = 0;
Lanuages gDefaultLanguage = LANG_ENGLISH;
int32_t gDefaultCountry = 78;
MCPRegion gDefaultProductArea = MCP_REGION_EUROPE;
std::optional<MCPRegion> gRealRegionOpt = {};
std::optional<int32_t> gRealCountryOpt = {};
std::optional<Languages> gRealLanguageOpt = {};

Lanuages gCurrentLanguage = gDefaultLanguage;
int32_t gCurrentCountry = gDefaultCountry;
MCPRegion gCurrentProductArea = gDefaultProductArea;
bool gRegionFreeValuesSetupDone = false;

Lanuages gDefaultLangForEUR = LANG_ENGLISH;
int32_t gDefaultCountryForEUR = 110;
Lanuages gDefaultLangForUSA = LANG_ENGLISH;
int32_t gDefaultCountryForUSA = 49;
Lanuages gDefaultLangForJPN = LANG_JAPANESE;
int32_t gDefaultCountryForJPN = 1;
bool gPreferSystemSettings = DEFAULT_PREFER_SYSTEM_SETTINGS;
bool gSkipOwnRegion = DEFAULT_SKIP_OWN_REGION;
bool gAutoDetection = DEFAULT_AUTO_DETECTION_VALUE;

Languages gCurrentLanguage = LANG_ENGLISH;
int32_t gCurrentCountry = 0;
MCPRegion gCurrentProductArea = MCP_REGION_USA;

Languages gDefaultLangForEUR = DEFAULT_LANG_FOR_EUR;
int32_t gDefaultCountryForEUR = DEFAULT_COUNTRY_FOR_EUR;
Languages gDefaultLangForUSA = DEFAULT_LANG_FOR_USA;
int32_t gDefaultCountryForUSA = DEFAULT_COUNTRY_FOR_USA;
Languages gDefaultLangForJPN = DEFAULT_LANG_FOR_JPN;
int32_t gDefaultCountryForJPN = DEFAULT_COUNTRY_FOR_JPN;
45 changes: 31 additions & 14 deletions src/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

#include "version.h"
#include <coreinit/mcp.h>
#include <optional>

#define VERSION "v0.2.3"
#define VERSION "v0.2.4"
#define VERSION_FULL VERSION VERSION_EXTRA

extern int gForceSettingsEnabled;

enum Lanuages {
enum Languages {
LANG_JAPANESE = 0,
LANG_ENGLISH = 1,
LANG_FRANCAIS = 2,
Expand All @@ -20,21 +19,39 @@ enum Lanuages {
LANG_RUSSKI = 10,
};

extern std::optional<MCPRegion> gRealRegionOpt;
extern std::optional<int32_t> gRealCountryOpt;
extern std::optional<Languages> gRealLanguageOpt;

extern bool gRegionFreeValuesSetupDone;

#define DEFAULT_AUTO_DETECTION_VALUE true
extern bool gAutoDetection;

extern int gPreferSystemSettings;
extern int gSkipOwnRegion;
extern int gAutoDetection;
extern Lanuages gDefaultLanguage;
extern int32_t gDefaultCountry;
extern MCPRegion gDefaultProductArea;
#define DEFAULT_PREFER_SYSTEM_SETTINGS true
extern bool gPreferSystemSettings;

extern Lanuages gCurrentLanguage;
#define DEFAULT_SKIP_OWN_REGION true
extern bool gSkipOwnRegion;

extern Languages gCurrentLanguage;
extern int32_t gCurrentCountry;
extern MCPRegion gCurrentProductArea;

extern Lanuages gDefaultLangForEUR;
#define DEFAULT_LANG_FOR_EUR LANG_ENGLISH
#define DEFAULT_COUNTRY_FOR_EUR 110

#define DEFAULT_LANG_FOR_USA LANG_ENGLISH
#define DEFAULT_COUNTRY_FOR_USA 49

#define DEFAULT_LANG_FOR_JPN LANG_JAPANESE
#define DEFAULT_COUNTRY_FOR_JPN 1

extern Languages gDefaultLangForEUR;
extern int32_t gDefaultCountryForEUR;
extern Lanuages gDefaultLangForUSA;

extern Languages gDefaultLangForUSA;
extern int32_t gDefaultCountryForUSA;
extern Lanuages gDefaultLangForJPN;

extern Languages gDefaultLangForJPN;
extern int32_t gDefaultCountryForJPN;
Loading