mirror of
https://github.com/azahar-emu/azahar
synced 2025-11-06 23:19:57 +01:00
Fix fatal error caused by auto-detect region
This commit is contained in:
parent
9203b23868
commit
d8077fdea6
@ -108,5 +108,53 @@ HackManager hack_manager = {
|
|||||||
},
|
},
|
||||||
}},
|
}},
|
||||||
|
|
||||||
|
{HackType::REGION_FROM_SECURE,
|
||||||
|
HackEntry{
|
||||||
|
.mode = HackAllowMode::FORCE,
|
||||||
|
.affected_title_ids =
|
||||||
|
{
|
||||||
|
// eShop
|
||||||
|
0x0004001000020900, // JPN
|
||||||
|
0x0004001000021900, // USA
|
||||||
|
0x0004001000022900, // EUR
|
||||||
|
0x0004001000027900, // KOR
|
||||||
|
0x0004001000028900, // TWN
|
||||||
|
|
||||||
|
// System Settings
|
||||||
|
0x0004001000020000, // JPN
|
||||||
|
0x0004001000021000, // USA
|
||||||
|
0x0004001000022000, // EUR
|
||||||
|
0x0004001000026000, // CHN
|
||||||
|
0x0004001000027000, // KOR
|
||||||
|
0x0004001000028000, // TWN
|
||||||
|
|
||||||
|
// Nintendo Network ID Settings
|
||||||
|
0x000400100002BF00, // JPN
|
||||||
|
0x000400100002C000, // USA
|
||||||
|
0x000400100002C100, // EUR
|
||||||
|
|
||||||
|
// System Settings
|
||||||
|
0x0004003000008202, // JPN
|
||||||
|
0x0004003000008F02, // USA
|
||||||
|
0x0004003000009802, // EUR
|
||||||
|
0x000400300000A102, // CHN
|
||||||
|
0x000400300000A902, // KOR
|
||||||
|
0x000400300000B102, // TWN
|
||||||
|
|
||||||
|
// NIM
|
||||||
|
0x0004013000002C02, // Normal
|
||||||
|
0x0004013000002C03, // Safe mode
|
||||||
|
0x0004013020002C03, // New 3DS safe mode
|
||||||
|
|
||||||
|
// ACT
|
||||||
|
0x0004013000003802, // Normal
|
||||||
|
|
||||||
|
// FRD
|
||||||
|
0x0004013000003202, // Normal
|
||||||
|
0x0004013000003203, // Safe mode
|
||||||
|
0x0004013020003203, // New 3DS safe mode
|
||||||
|
},
|
||||||
|
}},
|
||||||
|
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
@ -13,6 +13,7 @@ enum class HackType : int {
|
|||||||
ACCURATE_MULTIPLICATION,
|
ACCURATE_MULTIPLICATION,
|
||||||
DECRYPTION_AUTHORIZED,
|
DECRYPTION_AUTHORIZED,
|
||||||
ONLINE_LLE_REQUIRED,
|
ONLINE_LLE_REQUIRED,
|
||||||
|
REGION_FROM_SECURE,
|
||||||
};
|
};
|
||||||
|
|
||||||
class UserHackData {};
|
class UserHackData {};
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2018 Citra Emulator Project
|
// Copyright Citra Emulator Project / Azahar Emulator Project
|
||||||
// Licensed under GPLv2 or any later version
|
// Licensed under GPLv2 or any later version
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
@ -573,9 +573,11 @@ Result AppletManager::PrepareToStartLibraryApplet(AppletId applet_id) {
|
|||||||
capture_buffer_info.reset();
|
capture_buffer_info.reset();
|
||||||
|
|
||||||
if (Settings::values.lle_applets) {
|
if (Settings::values.lle_applets) {
|
||||||
|
bool is_setup = system.GetAppLoader().DoingInitialSetup();
|
||||||
auto cfg = Service::CFG::GetModule(system);
|
auto cfg = Service::CFG::GetModule(system);
|
||||||
auto process = NS::LaunchTitle(system, FS::MediaType::NAND,
|
auto process =
|
||||||
GetTitleIdForApplet(applet_id, cfg->GetRegionValue()));
|
NS::LaunchTitle(system, FS::MediaType::NAND,
|
||||||
|
GetTitleIdForApplet(applet_id, cfg->GetRegionValue(is_setup)));
|
||||||
if (process) {
|
if (process) {
|
||||||
return ResultSuccess;
|
return ResultSuccess;
|
||||||
}
|
}
|
||||||
@ -602,9 +604,11 @@ Result AppletManager::PreloadLibraryApplet(AppletId applet_id) {
|
|||||||
last_prepared_library_applet = applet_id;
|
last_prepared_library_applet = applet_id;
|
||||||
|
|
||||||
if (Settings::values.lle_applets) {
|
if (Settings::values.lle_applets) {
|
||||||
|
bool is_setup = system.GetAppLoader().DoingInitialSetup();
|
||||||
auto cfg = Service::CFG::GetModule(system);
|
auto cfg = Service::CFG::GetModule(system);
|
||||||
auto process = NS::LaunchTitle(system, FS::MediaType::NAND,
|
auto process =
|
||||||
GetTitleIdForApplet(applet_id, cfg->GetRegionValue()));
|
NS::LaunchTitle(system, FS::MediaType::NAND,
|
||||||
|
GetTitleIdForApplet(applet_id, cfg->GetRegionValue(is_setup)));
|
||||||
if (process) {
|
if (process) {
|
||||||
return ResultSuccess;
|
return ResultSuccess;
|
||||||
}
|
}
|
||||||
@ -814,9 +818,11 @@ Result AppletManager::StartSystemApplet(AppletId applet_id, std::shared_ptr<Kern
|
|||||||
const auto slot_id =
|
const auto slot_id =
|
||||||
applet_id == AppletId::HomeMenu ? AppletSlot::HomeMenu : AppletSlot::SystemApplet;
|
applet_id == AppletId::HomeMenu ? AppletSlot::HomeMenu : AppletSlot::SystemApplet;
|
||||||
if (!GetAppletSlot(slot_id)->registered) {
|
if (!GetAppletSlot(slot_id)->registered) {
|
||||||
|
bool is_setup = system.GetAppLoader().DoingInitialSetup();
|
||||||
auto cfg = Service::CFG::GetModule(system);
|
auto cfg = Service::CFG::GetModule(system);
|
||||||
auto process = NS::LaunchTitle(system, FS::MediaType::NAND,
|
auto process =
|
||||||
GetTitleIdForApplet(applet_id, cfg->GetRegionValue()));
|
NS::LaunchTitle(system, FS::MediaType::NAND,
|
||||||
|
GetTitleIdForApplet(applet_id, cfg->GetRegionValue(is_setup)));
|
||||||
if (!process) {
|
if (!process) {
|
||||||
// TODO: Find the right error code.
|
// TODO: Find the right error code.
|
||||||
return {ErrorDescription::NotFound, ErrorModule::Applet, ErrorSummary::NotSupported,
|
return {ErrorDescription::NotFound, ErrorModule::Applet, ErrorSummary::NotSupported,
|
||||||
@ -1422,7 +1428,7 @@ void AppletManager::EnsureHomeMenuLoaded() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto cfg = Service::CFG::GetModule(system);
|
auto cfg = Service::CFG::GetModule(system);
|
||||||
auto menu_title_id = GetTitleIdForApplet(AppletId::HomeMenu, cfg->GetRegionValue());
|
auto menu_title_id = GetTitleIdForApplet(AppletId::HomeMenu, cfg->GetRegionValue(false));
|
||||||
auto process = NS::LaunchTitle(system, FS::MediaType::NAND, menu_title_id);
|
auto process = NS::LaunchTitle(system, FS::MediaType::NAND, menu_title_id);
|
||||||
if (!process) {
|
if (!process) {
|
||||||
LOG_WARNING(Service_APT,
|
LOG_WARNING(Service_APT,
|
||||||
|
|||||||
@ -196,7 +196,7 @@ static u32 DecompressLZ11(const u8* in, u8* out) {
|
|||||||
bool Module::LoadSharedFont() {
|
bool Module::LoadSharedFont() {
|
||||||
auto cfg = Service::CFG::GetModule(system);
|
auto cfg = Service::CFG::GetModule(system);
|
||||||
u8 font_region_code;
|
u8 font_region_code;
|
||||||
switch (cfg->GetRegionValue()) {
|
switch (cfg->GetRegionValue(false)) {
|
||||||
case 4: // CHN
|
case 4: // CHN
|
||||||
font_region_code = 2;
|
font_region_code = 2;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -12,6 +12,7 @@
|
|||||||
#include <fmt/ranges.h>
|
#include <fmt/ranges.h>
|
||||||
#include "common/archives.h"
|
#include "common/archives.h"
|
||||||
#include "common/file_util.h"
|
#include "common/file_util.h"
|
||||||
|
#include "common/hacks/hack_manager.h"
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "common/settings.h"
|
#include "common/settings.h"
|
||||||
#include "common/string_util.h"
|
#include "common/string_util.h"
|
||||||
@ -21,6 +22,7 @@
|
|||||||
#include "core/file_sys/errors.h"
|
#include "core/file_sys/errors.h"
|
||||||
#include "core/file_sys/file_backend.h"
|
#include "core/file_sys/file_backend.h"
|
||||||
#include "core/hle/ipc_helpers.h"
|
#include "core/hle/ipc_helpers.h"
|
||||||
|
#include "core/hle/kernel/process.h"
|
||||||
#include "core/hle/result.h"
|
#include "core/hle/result.h"
|
||||||
#include "core/hle/service/cfg/cfg.h"
|
#include "core/hle/service/cfg/cfg.h"
|
||||||
#include "core/hle/service/cfg/cfg_defaults.h"
|
#include "core/hle/service/cfg/cfg_defaults.h"
|
||||||
@ -200,7 +202,14 @@ void Module::Interface::GetCountryCodeID(Kernel::HLERequestContext& ctx) {
|
|||||||
rb.Push<u16>(country_code_id);
|
rb.Push<u16>(country_code_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 Module::GetRegionValue() {
|
u32 Module::GetRegionValue(bool from_secure_info) {
|
||||||
|
if (from_secure_info) {
|
||||||
|
auto& sec_info = HW::UniqueData::GetSecureInfoA();
|
||||||
|
if (sec_info.IsValid()) {
|
||||||
|
return sec_info.body.region;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (Settings::values.region_value.GetValue() == Settings::REGION_VALUE_AUTO_SELECT) {
|
if (Settings::values.region_value.GetValue() == Settings::REGION_VALUE_AUTO_SELECT) {
|
||||||
UpdatePreferredRegionCode();
|
UpdatePreferredRegionCode();
|
||||||
return preferred_region_code;
|
return preferred_region_code;
|
||||||
@ -212,9 +221,13 @@ u32 Module::GetRegionValue() {
|
|||||||
void Module::Interface::GetRegion(Kernel::HLERequestContext& ctx) {
|
void Module::Interface::GetRegion(Kernel::HLERequestContext& ctx) {
|
||||||
IPC::RequestParser rp(ctx);
|
IPC::RequestParser rp(ctx);
|
||||||
|
|
||||||
|
u64 caller_tid = ctx.ClientThread()->owner_process.lock()->codeset->program_id;
|
||||||
|
bool from_secure_info = Common::Hacks::hack_manager.OverrideBooleanSetting(
|
||||||
|
Common::Hacks::HackType::REGION_FROM_SECURE, caller_tid, false);
|
||||||
|
|
||||||
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
|
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
|
||||||
rb.Push(ResultSuccess);
|
rb.Push(ResultSuccess);
|
||||||
rb.Push<u8>(static_cast<u8>(cfg->GetRegionValue()));
|
rb.Push<u8>(static_cast<u8>(cfg->GetRegionValue(from_secure_info)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Module::Interface::SecureInfoGetByte101(Kernel::HLERequestContext& ctx) {
|
void Module::Interface::SecureInfoGetByte101(Kernel::HLERequestContext& ctx) {
|
||||||
@ -319,8 +332,12 @@ void Module::Interface::IsCoppacsSupported(Kernel::HLERequestContext& ctx) {
|
|||||||
|
|
||||||
rb.Push(ResultSuccess);
|
rb.Push(ResultSuccess);
|
||||||
|
|
||||||
|
u64 caller_tid = ctx.ClientThread()->owner_process.lock()->codeset->program_id;
|
||||||
|
bool from_secure_info = Common::Hacks::hack_manager.OverrideBooleanSetting(
|
||||||
|
Common::Hacks::HackType::REGION_FROM_SECURE, caller_tid, false);
|
||||||
|
|
||||||
u8 canada_or_usa = 1;
|
u8 canada_or_usa = 1;
|
||||||
if (canada_or_usa == cfg->GetRegionValue()) {
|
if (canada_or_usa == cfg->GetRegionValue(from_secure_info)) {
|
||||||
rb.Push(true);
|
rb.Push(true);
|
||||||
} else {
|
} else {
|
||||||
rb.Push(false);
|
rb.Push(false);
|
||||||
|
|||||||
@ -484,7 +484,7 @@ private:
|
|||||||
void LoadMCUConfig();
|
void LoadMCUConfig();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
u32 GetRegionValue();
|
u32 GetRegionValue(bool from_secure_info);
|
||||||
|
|
||||||
// Utilities for frontend to set config data.
|
// Utilities for frontend to set config data.
|
||||||
// Note: UpdateConfigNANDSavegame should be called after making changes to config data.
|
// Note: UpdateConfigNANDSavegame should be called after making changes to config data.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user